From b7439712b93793f5f5480c16f5d3fa73973ff1c4 Mon Sep 17 00:00:00 2001 From: Julien Vulliet Date: Tue, 26 Feb 2019 16:36:36 +0300 Subject: [PATCH 1/2] [Direct3D11] Device context GetUnorderedAccessViews was not checking if depth stencil view was not bound (and cause a nullreferenceexception in that case) --- Source/SharpDX.Direct3D11/DeviceContext.OutputMergerStage.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/SharpDX.Direct3D11/DeviceContext.OutputMergerStage.cs b/Source/SharpDX.Direct3D11/DeviceContext.OutputMergerStage.cs index 847b53c55..15691199e 100644 --- a/Source/SharpDX.Direct3D11/DeviceContext.OutputMergerStage.cs +++ b/Source/SharpDX.Direct3D11/DeviceContext.OutputMergerStage.cs @@ -122,7 +122,8 @@ public UnorderedAccessView[] GetUnorderedAccessViews(int startSlot, int count) var temp = new UnorderedAccessView[count]; DepthStencilView depthStencilView; GetRenderTargetsAndUnorderedAccessViews(0, new RenderTargetView[0], out depthStencilView, startSlot, count, temp); - depthStencilView.Dispose(); + if (depthStencilView != null) + depthStencilView.Dispose(); return temp; } From b86006d231a1bece621e853dac15f2c883a6f088 Mon Sep 17 00:00:00 2001 From: Julien Vulliet Date: Tue, 26 Feb 2019 17:05:53 +0300 Subject: [PATCH 2/2] [Direct3D11] Add overload in compute shader stage to allow comarray binding for UAV --- .../DeviceContext.ComputeShaderStage.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/SharpDX.Direct3D11/DeviceContext.ComputeShaderStage.cs b/Source/SharpDX.Direct3D11/DeviceContext.ComputeShaderStage.cs index 660c6d955..c29cf363e 100644 --- a/Source/SharpDX.Direct3D11/DeviceContext.ComputeShaderStage.cs +++ b/Source/SharpDX.Direct3D11/DeviceContext.ComputeShaderStage.cs @@ -105,5 +105,16 @@ public unsafe void SetUnorderedAccessViews(int startSlot, SharpDX.Direct3D11.Uno fixed (void* puav = uavInitialCounts) SetUnorderedAccessViews(startSlot, unorderedAccessViews != null ? unorderedAccessViews.Length : 0, (IntPtr)unorderedAccessViewsOut_, (IntPtr)puav); } + + /// + /// Sets an array of views for an unordered resource. + /// + /// Index of the first element in the zero-based array to begin setting. + /// A reference to an array of references to be set by the method. + public unsafe void SetUnorderedAccessViews(int startSlot, ComArray unorderedAccessViews, int[] uavInitialCounts) + { + fixed (void* puav = uavInitialCounts) + SetUnorderedAccessViews(startSlot, unorderedAccessViews == null ? 0 : unorderedAccessViews.Length, unorderedAccessViews.NativePointer, (IntPtr)puav); + } } } \ No newline at end of file