Quellcode durchsuchen

added execute_indirect

Nicolas Cannasse vor 3 Jahren
Ursprung
Commit
467ffb9132
2 geänderte Dateien mit 56 neuen und 0 gelöschten Zeilen
  1. 44 0
      libs/directx/dx/Dx12.hx
  2. 12 0
      libs/directx/dx12.cpp

+ 44 - 0
libs/directx/dx/Dx12.hx

@@ -50,6 +50,10 @@ abstract GpuResource(Resource) {
 abstract PipelineState(Resource) {
 }
 
+@:forward(release)
+abstract CommandSignature(Resource) {
+}
+
 @:hlNative("dx12","command_allocator_")
 abstract CommandAllocator(Resource) {
 	public function new(type) {
@@ -193,6 +197,7 @@ abstract CommandList(Resource) {
 
 	public function drawInstanced( vertexCountPerInstance : Int, instanceCount : Int, startVertexLocation : Int, startInstanceLocation : Int ) {}
 	public function drawIndexedInstanced( indexCountPerInstance : Int, instanceCount : Int, startIndexLocation : Int, baseVertexLocation : Int, startInstanceLocation : Int ) {}
+	public function executeIndirect( sign : CommandSignature, maxCommandCount : Int, args : Resource, argsOffset : Int64, count : Resource, countOffset : Int64 ) {}
 
 	public function omSetRenderTargets( count : Int, handles : hl.BytesAccess<Address>, flag : Bool32, depthStencils : hl.BytesAccess<Address> ) {}
 	public function omSetStencilRef( value : Int ) {}
@@ -1390,6 +1395,41 @@ enum abstract BufferSRVFlags(Int) {
 	}
 }
 
+enum abstract IndirectArgumentType(Int) {
+	var DRAW = 0;
+	var DRAW_INDEXED = 1;
+	var DISPATCH = 2;
+	var VERTEX_BUFFER_VIEW = 3;
+	var INDEX_BUFFER_VIEW = 4;
+	var CONSTANT = 5;
+	var CONSTANT_BUFFER_VIEW = 6;
+	var SHADER_RESOURCE_VIEW = 7;
+	var UNORDERED_ACCESS_VIEW = 8;
+	var DISPATCH_RAYS = 9;
+	var DISPATCH_MESH = 10;
+}
+
+@:struct class IndirectArgumentDesc {
+	public var type : IndirectArgumentType;
+	public var rootParameterIndex : Int;
+	public var destOffsetIn32BitValues : Int;
+	public var num32BitValuesToSet : Int;
+	public var slot(get,set) : Int;
+	inline function get_slot() return rootParameterIndex;
+	inline function set_slot(v) return rootParameterIndex = v;
+	public function new() {
+	}
+}
+
+@:struct class CommandSignatureDesc {
+	public var byteStride :Int;
+	public var numArgumentDescs : Int;
+	public var argumentDescs : IndirectArgumentDesc;
+	public var nodeMask : Int;
+	public function new() {
+	}
+}
+
 @:hlNative("dx12")
 class Dx12 {
 
@@ -1442,6 +1482,10 @@ class Dx12 {
 		return null;
 	}
 
+	public static function createCommandSignature( desc : CommandSignatureDesc, root : RootSignature ) : CommandSignature {
+		return null;
+	}
+
 	public static function resize( width : Int, height : Int, bufferCount : Int, format : DxgiFormat ) {
 	}
 

+ 12 - 0
libs/directx/dx12.cpp

@@ -498,12 +498,19 @@ ID3D12PipelineState *HL_NAME(create_graphics_pipeline_state)( D3D12_GRAPHICS_PIP
 	return state;
 }
 
+ID3D12CommandSignature *HL_NAME(create_command_signature)( D3D12_COMMAND_SIGNATURE_DESC *desc, ID3D12RootSignature *rootSign ) {
+	ID3D12CommandSignature *sign = NULL;
+	DXERR(static_driver->device->CreateCommandSignature(desc,rootSign,IID_PPV_ARGS(&sign)));
+	return sign;
+}
+
 #define _COMPILER _ABSTRACT(dx_compiler)
 DEFINE_PRIM(_COMPILER, compiler_create, _NO_ARG);
 DEFINE_PRIM(_BYTES, compiler_compile, _COMPILER _BYTES _BYTES _ARR _REF(_I32));
 DEFINE_PRIM(_BYTES, serialize_root_signature, _STRUCT _I32 _REF(_I32));
 DEFINE_PRIM(_RES, rootsignature_create, _BYTES _I32);
 DEFINE_PRIM(_RES, create_graphics_pipeline_state, _STRUCT);
+DEFINE_PRIM(_RES, create_command_signature, _STRUCT _RES);
 
 // ---- HEAPS
 
@@ -673,6 +680,10 @@ void HL_NAME(command_list_set_graphics_root_shader_resource_view)( ID3D12Graphic
 	l->SetGraphicsRootShaderResourceView(index,handle);
 }
 
+void HL_NAME(command_list_execute_indirect)( ID3D12GraphicsCommandList *l, ID3D12CommandSignature *sign, int maxCommandCount, ID3D12Resource *args, int64 argsOffset, ID3D12Resource *count, int64 countOffset  ) {
+	l->ExecuteIndirect(sign, maxCommandCount, args, argsOffset, count, countOffset);
+}
+
 DEFINE_PRIM(_RES, command_allocator_create, _I32);
 DEFINE_PRIM(_VOID, command_allocator_reset, _RES);
 DEFINE_PRIM(_RES, command_list_create, _I32 _RES _RES);
@@ -700,3 +711,4 @@ DEFINE_PRIM(_VOID, command_list_om_set_render_targets, _RES _I32 _BYTES _I32 _BY
 DEFINE_PRIM(_VOID, command_list_om_set_stencil_ref, _RES _I32);
 DEFINE_PRIM(_VOID, command_list_rs_set_viewports, _RES _I32 _STRUCT);
 DEFINE_PRIM(_VOID, command_list_rs_set_scissor_rects, _RES _I32 _STRUCT);
+DEFINE_PRIM(_VOID, command_list_execute_indirect, _RES _RES _I32 _RES _I64 _RES _I64);