Skip to content

Commit

Permalink
Merge pull request #52 from smoogipoo/fix-d3d-buffer-update-regression
Browse files Browse the repository at this point in the history
Fix D3D regression causing broken buffer updates
  • Loading branch information
smoogipoo authored May 1, 2024
2 parents 164a28c + 630a56b commit f258ed0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Veldrid/D3D11/D3D11CommandList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f258ed0

Please sign in to comment.