Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 30, 2019. It is now read-only.
/SharpDXPublic archive

Commit1b22d9e

Browse files
committed
GraphicsCommandList improvements and add better BeginEvent and SetMarker methods.
1 parent55abe14 commit1b22d9e

File tree

1 file changed

+69
-25
lines changed

1 file changed

+69
-25
lines changed

‎Source/SharpDX.Direct3D12/GraphicsCommandList.cs‎

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// THE SOFTWARE.
2020

2121
usingSystem;
22+
usingSystem.Runtime.InteropServices;
2223

2324
namespaceSharpDX.Direct3D12
2425
{
@@ -142,7 +143,7 @@ public unsafe void ResourceBarrier(SharpDX.Direct3D12.ResourceBarrier barrier)
142143
/// <unmanaged-short>ID3D12GraphicsCommandList::ResourceBarrier</unmanaged-short>
143144
publicunsafevoidResourceBarrier(paramsSharpDX.Direct3D12.ResourceBarrier[]barriers)
144145
{
145-
if(barriers==null)thrownewArgumentNullException("barriers");
146+
if(barriers==null)thrownewArgumentNullException("barriers");
146147

147148
fixed(void*pBarriers=barriers)
148149
ResourceBarrier(barriers.Length,newIntPtr(pBarriers));
@@ -197,7 +198,7 @@ public unsafe void SetRenderTargets(CpuDescriptorHandle[] renderTargetDescriptor
197198
publicunsafevoidSetRenderTargets(CpuDescriptorHandle?renderTargetDescriptor,SharpDX.Direct3D12.CpuDescriptorHandle?depthStencilDescriptorRef)
198199
{
199200
varrenderTargetDesc=newCpuDescriptorHandle();
200-
if(renderTargetDescriptor.HasValue)
201+
if(renderTargetDescriptor.HasValue)
201202
{
202203
renderTargetDesc=renderTargetDescriptor.Value;
203204
}
@@ -208,17 +209,16 @@ public unsafe void SetRenderTargets(CpuDescriptorHandle? renderTargetDescriptor,
208209
/// <p>Sets a CPU descriptor handle for the vertex buffers.</p>
209210
/// </summary>
210211
/// <param name="startSlot"><dd> <p> Index into the device's zero-based array to begin setting vertex buffers. </p> </dd></param>
211-
/// <param name="numViews"><dd> <p> The number of views in the <em>pViews</em> array. </p> </dd></param>
212-
/// <param name="viewsRef"><dd> <p> Specifies the vertex buffer views in an array of <strong><see cref="SharpDX.Direct3D12.VertexBufferView"/></strong> structures. </p> </dd></param>
213-
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::IASetVertexBuffers']/*"/>
212+
/// <param name="vertexBufferViews"><dd> <p> Specifies the vertex buffer views in an array of <strong><see cref="SharpDX.Direct3D12.VertexBufferView"/></strong> structures. </p> </dd></param>
213+
/// <param name="numBuffers"><dd> <p> The number of views in the <em>pViews</em> array. </p> </dd></param>
214214
/// <msdn-id>dn986883</msdn-id>
215215
/// <unmanaged>void ID3D12GraphicsCommandList::IASetVertexBuffers([In] unsigned int StartSlot,[In] unsigned int NumViews,[In] const void* pViews)</unmanaged>
216216
/// <unmanaged-short>ID3D12GraphicsCommandList::IASetVertexBuffers</unmanaged-short>
217-
publicvoidSetVertexBuffers(intstartSlot,SharpDX.Direct3D12.VertexBufferView[]descRef,intnumBuffers)
217+
publicvoidSetVertexBuffers(intstartSlot,SharpDX.Direct3D12.VertexBufferView[]vertexBufferViews,intnumBuffers)
218218
{
219219
unsafe
220220
{
221-
fixed(void*descPtr=descRef)
221+
fixed(void*descPtr=vertexBufferViews)
222222
SetVertexBuffers(startSlot,numBuffers,newIntPtr(descPtr));
223223
}
224224
}
@@ -227,35 +227,31 @@ public void SetVertexBuffers(int startSlot, SharpDX.Direct3D12.VertexBufferView[
227227
/// <p>Sets a CPU descriptor handle for the vertex buffers.</p>
228228
/// </summary>
229229
/// <param name="startSlot"><dd> <p> Index into the device's zero-based array to begin setting vertex buffers. </p> </dd></param>
230-
/// <param name="numViews"><dd> <p> The number of views in the <em>pViews</em> array. </p> </dd></param>
231-
/// <param name="viewsRef"><dd> <p> Specifies the vertex buffer views in an array of <strong><see cref="SharpDX.Direct3D12.VertexBufferView"/></strong> structures. </p> </dd></param>
232-
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::IASetVertexBuffers']/*"/>
230+
/// <param name="vertexBufferView"><dd> <p> Specifies the vertex buffer view of <strong><see cref="SharpDX.Direct3D12.VertexBufferView"/></strong> structures. </p> </dd></param>
233231
/// <msdn-id>dn986883</msdn-id>
234232
/// <unmanaged>void ID3D12GraphicsCommandList::IASetVertexBuffers([In] unsigned int StartSlot,[In] unsigned int NumViews,[In] const void* pViews)</unmanaged>
235233
/// <unmanaged-short>ID3D12GraphicsCommandList::IASetVertexBuffers</unmanaged-short>
236-
publicvoidSetVertexBuffer(intstartSlot,SharpDX.Direct3D12.VertexBufferViewdescRef)
234+
publicvoidSetVertexBuffer(intstartSlot,SharpDX.Direct3D12.VertexBufferViewvertexBufferView)
237235
{
238236
unsafe
239237
{
240-
SetVertexBuffers(startSlot,1,(IntPtr)(&descRef));
238+
SetVertexBuffers(startSlot,1,(IntPtr)(&vertexBufferView));
241239
}
242240
}
243241

244242
/// <summary>
245243
/// <p> Bind an array of viewports to the rasterizer stage of the pipeline. </p>
246244
/// </summary>
247-
/// <param name="numViewports"><dd> <p> Number of viewports to bind. The range of valid values is (0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE). </p> </dd></param>
248-
/// <param name="viewportsRef"><dd> <p> An array of <strong><see cref="SharpDX.Direct3D12.Viewport"/></strong> structures to bind to the device. </p> </dd></param>
245+
/// <param name="viewports"><dd> <p> Number of viewports to bind. The range of valid values is (0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE). </p> </dd></param>
249246
/// <remarks>
250247
/// <p> All viewports must be set atomically as one operation. Any viewports not defined by the call are disabled. </p><p> Which viewport to use is determined by the SV_ViewportArrayIndex semantic output by a geometry shader; if a geometry shader does not specify the semantic, Direct3D will use the first viewport in the array. </p><strong>Note</strong> Even though you specify float values to the members of the <strong><see cref="SharpDX.Direct3D12.Viewport"/></strong> structure for the <em>pViewports</em> array in a call to <strong>RSSetViewports</strong> for feature levels 9_x, <strong>RSSetViewports</strong> uses DWORDs internally. Because of this behavior, when you use a negative top left corner for the viewport, the call to <strong>RSSetViewports</strong> for feature levels 9_x fails. This failure occurs because <strong>RSSetViewports</strong> for 9_x casts the floating point values into unsigned integers without validation, which results in integer overflow.
251248
/// </remarks>
252-
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::RSSetViewports']/*"/>
253249
/// <msdn-id>dn903900</msdn-id>
254250
/// <unmanaged>void ID3D12GraphicsCommandList::RSSetViewports([In] unsigned int NumViewports,[In, Buffer] const D3D12_VIEWPORT* pViewports)</unmanaged>
255251
/// <unmanaged-short>ID3D12GraphicsCommandList::RSSetViewports</unmanaged-short>
256252
publicvoidSetViewports(paramsSharpDX.Mathematics.Interop.RawViewportF[]viewports)
257253
{
258-
if(viewports==null)thrownewArgumentNullException("viewports");
254+
if(viewports==null)thrownewArgumentNullException("viewports");
259255
unsafe
260256
{
261257
fixed(void*pViewPorts=viewports)
@@ -266,12 +262,10 @@ public void SetViewports(params SharpDX.Mathematics.Interop.RawViewportF[] viewp
266262
/// <summary>
267263
/// <p> Bind an array of viewports to the rasterizer stage of the pipeline. </p>
268264
/// </summary>
269-
/// <param name="numViewports"><dd> <p> Number of viewports to bind. The range of valid values is (0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE). </p> </dd></param>
270-
/// <param name="viewportsRef"><dd> <p> An array of <strong><see cref="SharpDX.Direct3D12.Viewport"/></strong> structures to bind to the device. </p> </dd></param>
265+
/// <param name="viewport"><dd> <p> Number of viewports to bind. The range of valid values is (0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE). </p> </dd></param>
271266
/// <remarks>
272267
/// <p> All viewports must be set atomically as one operation. Any viewports not defined by the call are disabled. </p><p> Which viewport to use is determined by the SV_ViewportArrayIndex semantic output by a geometry shader; if a geometry shader does not specify the semantic, Direct3D will use the first viewport in the array. </p><strong>Note</strong> Even though you specify float values to the members of the <strong><see cref="SharpDX.Direct3D12.Viewport"/></strong> structure for the <em>pViewports</em> array in a call to <strong>RSSetViewports</strong> for feature levels 9_x, <strong>RSSetViewports</strong> uses DWORDs internally. Because of this behavior, when you use a negative top left corner for the viewport, the call to <strong>RSSetViewports</strong> for feature levels 9_x fails. This failure occurs because <strong>RSSetViewports</strong> for 9_x casts the floating point values into unsigned integers without validation, which results in integer overflow.
273268
/// </remarks>
274-
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::RSSetViewports']/*"/>
275269
/// <msdn-id>dn903900</msdn-id>
276270
/// <unmanaged>void ID3D12GraphicsCommandList::RSSetViewports([In] unsigned int NumViewports,[In, Buffer] const D3D12_VIEWPORT* pViewports)</unmanaged>
277271
/// <unmanaged-short>ID3D12GraphicsCommandList::RSSetViewports</unmanaged-short>
@@ -283,9 +277,7 @@ public unsafe void SetViewport(SharpDX.Mathematics.Interop.RawViewportF viewport
283277
/// <summary>
284278
/// Binds an array of scissor rectangles to the rasterizer stage.
285279
/// </summary>
286-
/// <param name="numRects">No documentation.</param>
287-
/// <param name="rectsRef">No documentation.</param>
288-
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::RSSetScissorRects']/*"/>
280+
/// <param name="rectangles">No documentation.</param>
289281
/// <msdn-id>dn903899</msdn-id>
290282
/// <unmanaged>void ID3D12GraphicsCommandList::RSSetScissorRects([In] unsigned int NumRects,[In, Buffer] const RECT* pRects)</unmanaged>
291283
/// <unmanaged-short>ID3D12GraphicsCommandList::RSSetScissorRects</unmanaged-short>
@@ -298,15 +290,67 @@ public void SetScissorRectangles(params SharpDX.Mathematics.Interop.RawRectangle
298290
/// <summary>
299291
/// Binds an array of scissor rectangles to the rasterizer stage.
300292
/// </summary>
301-
/// <param name="numRects">No documentation.</param>
302-
/// <param name="rectsRef">No documentation.</param>
303-
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::RSSetScissorRects']/*"/>
293+
/// <param name="rectangle">No documentation.</param>
304294
/// <msdn-id>dn903899</msdn-id>
305295
/// <unmanaged>void ID3D12GraphicsCommandList::RSSetScissorRects([In] unsigned int NumRects,[In, Buffer] const RECT* pRects)</unmanaged>
306296
/// <unmanaged-short>ID3D12GraphicsCommandList::RSSetScissorRects</unmanaged-short>
307297
publicunsafevoidSetScissorRectangles(SharpDX.Mathematics.Interop.RawRectanglerectangle)
308298
{
309299
SetScissorRectangles(1,newIntPtr(&rectangle));
310300
}
301+
302+
/// <summary>
303+
/// <p> For internal use only. </p>
304+
/// </summary>
305+
/// <param name="name"><dd> <p> Internal. </p> </dd></param>
306+
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::BeginEvent']/*"/>
307+
/// <msdn-id>dn986879</msdn-id>
308+
/// <unmanaged>void ID3D12GraphicsCommandList::BeginEvent([In] unsigned int Metadata,[In, Buffer, Optional] const void* pData,[In] unsigned int Size)</unmanaged>
309+
/// <unmanaged-short>ID3D12GraphicsCommandList::BeginEvent</unmanaged-short>
310+
publicvoidBeginEvent(stringname)
311+
{
312+
if(name==null)thrownewArgumentNullException("name");
313+
IntPtrhMessage=IntPtr.Zero;
314+
try
315+
{
316+
hMessage=Marshal.StringToHGlobalUni(name);
317+
BeginEvent(1,hMessage,name.Length);
318+
}
319+
finally
320+
{
321+
if(hMessage!=IntPtr.Zero)
322+
{
323+
Marshal.FreeHGlobal(hMessage);
324+
hMessage=IntPtr.Zero;
325+
}
326+
}
327+
}
328+
329+
/// <summary>
330+
/// <p> For internal use only.</p>
331+
/// </summary>
332+
/// <param name="name"><dd> <p> Internal. </p> </dd></param>
333+
/// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID3D12GraphicsCommandList::SetMarker']/*"/>
334+
/// <msdn-id>dn986885</msdn-id>
335+
/// <unmanaged>void ID3D12GraphicsCommandList::SetMarker([In] unsigned int Metadata,[In, Buffer, Optional] const void* pData,[In] unsigned int Size)</unmanaged>
336+
/// <unmanaged-short>ID3D12GraphicsCommandList::SetMarker</unmanaged-short>
337+
publicvoidSetMarker(stringname)
338+
{
339+
if(name==null)thrownewArgumentNullException("name");
340+
IntPtrhMessage=IntPtr.Zero;
341+
try
342+
{
343+
hMessage=Marshal.StringToHGlobalUni(name);
344+
SetMarker(1,hMessage,name.Length);
345+
}
346+
finally
347+
{
348+
if(hMessage!=IntPtr.Zero)
349+
{
350+
Marshal.FreeHGlobal(hMessage);
351+
hMessage=IntPtr.Zero;
352+
}
353+
}
354+
}
311355
}
312356
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp