From 4d11afa422c081bb31445b9d0c4362e9e3e789bc Mon Sep 17 00:00:00 2001 From: Caleb Cornett Date: Wed, 7 Feb 2024 10:08:23 -0600 Subject: [PATCH] Fix 3D texture SRV creation, use UpdateSubresource1 to avoid bug with non-zero offsets on deferred contexts --- src/Refresh_Driver_D3D11.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Refresh_Driver_D3D11.c b/src/Refresh_Driver_D3D11.c index 59f270f..bc4f9ab 100644 --- a/src/Refresh_Driver_D3D11.c +++ b/src/Refresh_Driver_D3D11.c @@ -1405,6 +1405,12 @@ static Refresh_Texture* D3D11_CreateTexture( srvDesc.Texture3D.MipLevels = desc3D.MipLevels; srvDesc.Texture3D.MostDetailedMip = 0; + res = ID3D11Device_CreateShaderResourceView( + renderer->device, + textureHandle, + &srvDesc, + &srv + ); if (FAILED(res)) { ID3D11Resource_Release(textureHandle); @@ -1516,7 +1522,7 @@ static void D3D11_SetTextureData( dstBox.bottom = textureSlice->rectangle.y + h; dstBox.back = textureSlice->depth + 1; - ID3D11DeviceContext_UpdateSubresource( + ID3D11DeviceContext1_UpdateSubresource1( d3d11CommandBuffer->context, d3d11Texture->handle, D3D11_INTERNAL_CalcSubresource( @@ -1527,7 +1533,8 @@ static void D3D11_SetTextureData( &dstBox, data, BytesPerRow(w, d3d11Texture->format), - BytesPerImage(w, h, d3d11Texture->format) + BytesPerImage(w, h, d3d11Texture->format), + D3D11_COPY_DISCARD /* FIXME: Is this right? */ ); }