Conversation
…if depth stencil view was not bound (and cause a nullreferenceexception in that case)
| public unsafe void SetUnorderedAccessViews(int startSlot, ComArray<SharpDX.Direct3D11.UnorderedAccessView> unorderedAccessViews, int[] uavInitialCounts) | ||
| { | ||
| fixed (void* puav = uavInitialCounts) | ||
| SetUnorderedAccessViews(startSlot, unorderedAccessViews == null ? 0 : unorderedAccessViews.Length, unorderedAccessViews.NativePointer, (IntPtr)puav); |
There was a problem hiding this comment.
Won't you get a null pointer exception on unorderedAccessViews.NativePointer for SetUnorderedAccessViews as you are not testing the 3rd parameter that the object is also Null? You would need to repeat the same test on the 3rd parameter also, so that you do not get a null reference exception if the object is null when calling NativePointer.
There was a problem hiding this comment.
Indeed, thinking of that in pretty much all existing DeviceContext "Set[]" which use ComArray, there is no null check at all, so could actually remove the first check.
There was a problem hiding this comment.
There are a couple of such cases, agreed, but I think if you did check Null Pointer on unorderedAccessViews then that woudl be fine. OR for removing ambiguity, set the code as:
fixed (void* puav = uavInitialCounts) { if (unorderedAccessViews != null) { SetUnorderedAccessViews(startSlot, unorderedAccessViews.Length, uorderedAccessViews.NativePointer, (IntPtr)puav); } else { SetUnorderedAccessViews(startSlot, 0, null, (IntPtr)puav); } }
I think the null pointer checks are correct that you are doing. I think some expansion to protect against a legitimate use case where the UAV is set to null. But yes, there are some checks missed in the code.
Hello, just a small change in Direct3D11.
Thanks