Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit f80a7d1

Browse files
committed
More Direct3D12 improvements.
1 parent 0e33d1c commit f80a7d1

3 files changed

Lines changed: 70 additions & 15 deletions

File tree

Source/SharpDX.Direct3D12/Device.cs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ public bool CheckFeatureSupport<T>(SharpDX.Direct3D12.Feature feature, ref T fea
7878
/// <summary>
7979
/// <p>Creates a command queue.</p>
8080
/// </summary>
81-
/// <param name="descRef"><dd> <p> Specifies a <see cref="SharpDX.Direct3D12.CommandQueueDescription"/> that describes the command queue. </p> </dd></param>
82-
/// <param name="riid"><dd> <p> The globally unique identifier (<see cref="System.Guid"/>) for the command queue interface. See remarks. An input parameter. </p> </dd></param>
81+
/// <param name="description"><dd> <p> Specifies a <see cref="SharpDX.Direct3D12.CommandQueueDescription"/> that describes the command queue. </p> </dd></param>
8382
/// <returns><dd> <p> A reference to a memory block that receives a reference to the <strong><see cref="SharpDX.Direct3D12.CommandQueue"/></strong> interface for the command queue. </p> </dd></returns>
84-
/// <remarks>
85-
/// <p> The <strong>REFIID</strong>, or <strong><see cref="System.Guid"/></strong>, of the interface to the command queue can be obtained by using the __uuidof() macro. For example, __uuidof(<see cref="SharpDX.Direct3D12.CommandQueue"/>) will get the <strong><see cref="System.Guid"/></strong> of the interface to a command queue. </p>
86-
/// </remarks>
8783
/// <include file='Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12Device::CreateCommandQueue']/*"/>
8884
/// <msdn-id>dn788657</msdn-id>
8985
/// <unmanaged>HRESULT ID3D12Device::CreateCommandQueue([In] const D3D12_COMMAND_QUEUE_DESC* pDesc,[In] const GUID&amp; riid,[Out] ID3D12CommandQueue** ppCommandQueue)</unmanaged>
@@ -93,11 +89,31 @@ public SharpDX.Direct3D12.CommandQueue CreateCommandQueue(SharpDX.Direct3D12.Com
9389
return CreateCommandQueue(description, Utilities.GetGuidFromType(typeof(CommandQueue)));
9490
}
9591

92+
/// <summary>
93+
/// <p>Creates a command queue.</p>
94+
/// </summary>
95+
/// <param name="type">The <see cref="SharpDX.Direct3D12.CommandListType"/> that describes the command queue.</param>
96+
/// <returns><dd> <p> A reference to a memory block that receives a reference to the <strong><see cref="SharpDX.Direct3D12.CommandQueue"/></strong> interface for the command queue. </p> </dd></returns>
97+
public SharpDX.Direct3D12.CommandQueue CreateCommandQueue(SharpDX.Direct3D12.CommandListType type)
98+
{
99+
return CreateCommandQueue(new SharpDX.Direct3D12.CommandQueueDescription(type), Utilities.GetGuidFromType(typeof(CommandQueue)));
100+
}
101+
102+
/// <summary>
103+
/// <p>Creates a command queue.</p>
104+
/// </summary>
105+
/// <param name="type">The <see cref="SharpDX.Direct3D12.CommandListType"/> that describes the command queue.</param>
106+
/// <param name="nodeMask">Multi GPU node mask.</param>
107+
/// <returns><dd> <p> A reference to a memory block that receives a reference to the <strong><see cref="SharpDX.Direct3D12.CommandQueue"/></strong> interface for the command queue. </p> </dd></returns>
108+
public SharpDX.Direct3D12.CommandQueue CreateCommandQueue(SharpDX.Direct3D12.CommandListType type, int nodeMask)
109+
{
110+
return CreateCommandQueue(new SharpDX.Direct3D12.CommandQueueDescription(type, nodeMask), Utilities.GetGuidFromType(typeof(CommandQueue)));
111+
}
112+
96113
/// <summary>
97114
/// <p>Creates a command allocator object.</p>
98115
/// </summary>
99116
/// <param name="type"><dd> <p> A <strong><see cref="SharpDX.Direct3D12.CommandListType"/></strong>-typed value that specifies the type of command allocator to create. The type of command allocator can be the type that records either direct command lists or bundles. </p> </dd></param>
100-
/// <param name="riid"><dd> <p> The globally unique identifier (<strong><see cref="System.Guid"/></strong>) for the command allocator interface (<strong><see cref="SharpDX.Direct3D12.CommandAllocator"/></strong>). The <strong>REFIID</strong>, or <strong><see cref="System.Guid"/></strong>, of the interface to the command allocator can be obtained by using the __uuidof() macro. For example, __uuidof(<see cref="SharpDX.Direct3D12.CommandAllocator"/>) will get the <strong><see cref="System.Guid"/></strong> of the interface to a command allocator. </p> </dd></param>
101117
/// <returns><dd> <p> A reference to a memory block that receives a reference to the <strong><see cref="SharpDX.Direct3D12.CommandAllocator"/></strong> interface for the command allocator. </p> </dd></returns>
102118
/// <remarks>
103119
/// <p> The device creates command lists from the command allocator. </p>
@@ -148,10 +164,10 @@ public GraphicsCommandList CreateCommandList(int nodeMask,
148164
SharpDX.Direct3D12.PipelineState initialState)
149165
{
150166
var nativePointer = CreateCommandList(
151-
nodeMask,
152-
type,
167+
nodeMask,
168+
type,
153169
commandAllocator,
154-
initialState,
170+
initialState,
155171
Utilities.GetGuidFromType(typeof(GraphicsCommandList)));
156172
return new GraphicsCommandList(nativePointer);
157173
}
@@ -171,9 +187,9 @@ public unsafe CommandSignature CreateCommandSignature(SharpDX.Direct3D12.Command
171187
{
172188
var nativeDesc = new CommandSignatureDescription.__Native();
173189
descRef.__MarshalTo(ref nativeDesc);
174-
fixed(void* pIndirectArguments = descRef.IndirectArguments)
190+
fixed (void* pIndirectArguments = descRef.IndirectArguments)
175191
{
176-
if(descRef.IndirectArguments != null)
192+
if (descRef.IndirectArguments != null)
177193
{
178194
nativeDesc.ArgumentDescCount = descRef.IndirectArguments.Length;
179195
nativeDesc.ArgumentDescsPointer = new IntPtr(pIndirectArguments);
@@ -224,7 +240,7 @@ public unsafe SharpDX.Direct3D12.PipelineState CreateComputePipelineState(SharpD
224240
{
225241
descRef.ComputeShader.UpdateNative(ref nativeDesc.ComputeShader, (IntPtr)pComputeShader);
226242
return CreateComputePipelineState(new IntPtr(&nativeDesc), Utilities.GetGuidFromType(typeof(PipelineState)));
227-
}
243+
}
228244
}
229245

230246
/// <summary>
@@ -366,7 +382,7 @@ public unsafe SharpDX.Direct3D12.PipelineState CreateGraphicsPipelineState(Sharp
366382
{
367383
var ptr = stackalloc StreamOutputElement.__Native[streamOutElements.Length];
368384
nativeStreamOutElements = ptr;
369-
for(int i = 0; i < streamOutElements.Length; i++)
385+
for (int i = 0; i < streamOutElements.Length; i++)
370386
{
371387
streamOutElements[i].__MarshalTo(ref nativeStreamOutElements[i]);
372388
}

Source/SharpDX.Direct3D12/GraphicsCommandList.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ public unsafe void SetScissorRectangles(SharpDX.Mathematics.Interop.RawRectangle
340340
/// <unmanaged-short>ID3D12GraphicsCommandList::BeginEvent</unmanaged-short>
341341
public void BeginEvent(string name)
342342
{
343-
if (name == null) throw new ArgumentNullException("name");
343+
if (name == null)
344+
throw new ArgumentNullException(nameof(name));
345+
344346
IntPtr hMessage = IntPtr.Zero;
345347
try
346348
{
@@ -383,5 +385,39 @@ public void SetMarker(string name)
383385
}
384386
}
385387
}
388+
389+
/// <summary>
390+
/// <p> Apps perform indirect draws/dispatches using the <strong>ExecuteIndirect</strong> method. </p>
391+
/// </summary>
392+
/// <param name="commandSignature"><dd> <p> Specifies a <strong><see cref="SharpDX.Direct3D12.CommandSignature"/></strong>. The data referenced by <em>pArgumentBuffer</em> will be interpreted depending on the contents of the command signature. Refer to Indirect Drawing for the APIs that are used to create a command signature. </p> </dd></param>
393+
/// <param name="maxCommandCount"><dd> <p>There are two ways that command counts can be specified:</p> <ul> <li> If <em>pCountBuffer</em> is not <c>null</c>, then <em>MaxCommandCount</em> specifies the maximum number of operations which will be performed. The actual number of operations to be performed are defined by the minimum of this value, and a 32-bit unsigned integer contained in <em>pCountBuffer</em> (at the byte offset specified by <em>CountBufferOffset</em>). </li> <li> If <em>pCountBuffer</em> is <c>null</c>, the <em>MaxCommandCount</em> specifies the exact number of operations which will be performed. </li> </ul> </dd></param>
394+
/// <param name="argumentBuffer"><dd> <p> Specifies one or more <strong><see cref="SharpDX.Direct3D12.Resource"/></strong> objects, containing the command arguments. </p> </dd></param>
395+
/// <param name="argumentBufferOffset"><dd> <p> Specifies an offset into <em>pArgumentBuffer</em> to identify the first command argument. </p> </dd></param>
396+
/// <remarks>
397+
/// <p>The semantics of this API are defined with the following pseudo-code:</p><p>Non-<c>null</c> pCountBuffer:</p><code>// Read draw count out of count buffer
398+
/// UINT CommandCount = pCountBuffer-&gt;ReadUINT32(CountBufferOffset); CommandCount = min(CommandCount, MaxCommandCount) // Get reference to first Commanding argument
399+
/// BYTE* Arguments = pArgumentBuffer-&gt;GetBase() + ArgumentBufferOffset; for(UINT CommandIndex = 0; CommandIndex &lt; CommandCount; CommandIndex++)
400+
/// { // Interpret the data contained in *Arguments // according to the command signature pCommandSignature-&gt;Interpret(Arguments); Arguments += pCommandSignature -&gt;GetByteStride();
401+
/// }
402+
/// </code><p><c>null</c> pCountBuffer:</p><code>// Get reference to first Commanding argument
403+
/// BYTE* Arguments = pArgumentBuffer-&gt;GetBase() + ArgumentBufferOffset; for(UINT CommandIndex = 0; CommandIndex &lt; MaxCommandCount; CommandIndex++)
404+
/// { // Interpret the data contained in *Arguments // according to the command signature pCommandSignature-&gt;Interpret(Arguments); Arguments += pCommandSignature -&gt;GetByteStride();
405+
/// }
406+
/// </code><p>The debug layer will issue an error if either the count buffer or the argument buffer are not in the <see cref="SharpDX.Direct3D12.ResourceStates.IndirectArgument"/> state. The core runtime will validate:</p><ul> <li><em>CountBufferOffset</em> and <em>ArgumentBufferOffset</em> are 4-byte aligned </li> <li><em>pCountBuffer</em> and <em>pArgumentBuffer</em> are buffer resources (any heap type) </li> <li> The offset implied by <em>MaxCommandCount</em>, <em>ArgumentBufferOffset</em>, and the drawing program stride do not exceed the bounds of <em>pArgumentBuffer</em> (similarly for count buffer) </li> <li>The command list is a direct command list or a compute command list (not a copy or JPEG decode command list)</li> <li>The root signature of the command list matches the root signature of the command signature</li> </ul><p> The functionality of two APIs from earlier versions of Direct3D, <code>DrawInstancedIndirect</code> and <code>DrawIndexedInstancedIndirect</code>, are encompassed by <strong>ExecuteIndirect</strong>. </p>
407+
/// </remarks>
408+
public void ExecuteIndirect(
409+
SharpDX.Direct3D12.CommandSignature commandSignature,
410+
int maxCommandCount,
411+
SharpDX.Direct3D12.Resource argumentBuffer,
412+
long argumentBufferOffset)
413+
{
414+
ExecuteIndirect(
415+
commandSignature,
416+
maxCommandCount,
417+
argumentBuffer,
418+
argumentBufferOffset,
419+
null,
420+
0);
421+
}
386422
}
387423
}

Source/SharpDX.Direct3D12/Mapping.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@
238238
<map method="ID3D12GraphicsCommandList::IASetIndexBuffer" property="false"/>
239239

240240
<map method="ID3D12Device::RegisterBudgetChangeCallback" visibility="internal"/>
241-
241+
<map method="ID3D12GraphicsCommandList::BeginEvent" visibility="internal" />
242+
243+
<map method="ID3D12GraphicsCommandList1::OMSetDepthBounds" visibility="private" />
244+
242245
<!--Revert changes inherited from D3D11. Leave all Device.CreateXXX method as-is-->
243246
<map method="ID3D12Device::CreateCommandAllocator" visibility="public"/>
244247
<map param="ID3D12Device::CreateCommandAllocator::ppCommandAllocator" attribute="out" return="true"/>

0 commit comments

Comments
 (0)