From 630a56bd9c61d9d5fcc2ac7ee6768e42b1dcdf8e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 1 May 2024 20:24:11 +0900 Subject: [PATCH] Fix D3D regression causing broken buffer updates --- src/Veldrid/D3D11/D3D11CommandList.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Veldrid/D3D11/D3D11CommandList.cs b/src/Veldrid/D3D11/D3D11CommandList.cs index da80d4f37..e97c431c2 100644 --- a/src/Veldrid/D3D11/D3D11CommandList.cs +++ b/src/Veldrid/D3D11/D3D11CommandList.cs @@ -1009,16 +1009,16 @@ private void bindSampler(D3D11Sampler sampler, int slot, ShaderStages stages) private unsafe void UpdateSubresource_Workaround( ID3D11Resource resource, int subresource, - Box region, + Box? region, IntPtr data) { bool needWorkaround = !gd.SupportsCommandLists; var pAdjustedSrcData = data.ToPointer(); - if (needWorkaround) + if (needWorkaround && region is Box dstRegion) { - Debug.Assert(region.Top == 0 && region.Front == 0); - pAdjustedSrcData = (byte*)data - region.Left; + Debug.Assert(dstRegion.Top == 0 && dstRegion.Front == 0); + pAdjustedSrcData = (byte*)data - dstRegion.Left; } DeviceContext.UpdateSubresource(resource, subresource, region, (IntPtr)pAdjustedSrcData, 0, 0); @@ -1215,10 +1215,10 @@ private protected override unsafe void UpdateBufferCore(DeviceBuffer buffer, uin if (useUpdateSubresource) { - Box subregion = new Box((int)bufferOffsetInBytes, 0, 0, (int)(sizeInBytes + bufferOffsetInBytes), 1, 1); + Box? subregion = new Box((int)bufferOffsetInBytes, 0, 0, (int)(sizeInBytes + bufferOffsetInBytes), 1, 1); if (isUniformBuffer) - subregion = default; + subregion = null; if (bufferOffsetInBytes == 0) DeviceContext.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);