Fix 3D texture SRV creation, use UpdateSubresource1 to avoid bug with non-zero offsets on deferred contexts

d3d11
Caleb Cornett 2024-02-07 10:08:23 -06:00 committed by cosmonaut
parent 5d069f006d
commit 4d11afa422
1 changed files with 9 additions and 2 deletions

View File

@ -1405,6 +1405,12 @@ static Refresh_Texture* D3D11_CreateTexture(
srvDesc.Texture3D.MipLevels = desc3D.MipLevels; srvDesc.Texture3D.MipLevels = desc3D.MipLevels;
srvDesc.Texture3D.MostDetailedMip = 0; srvDesc.Texture3D.MostDetailedMip = 0;
res = ID3D11Device_CreateShaderResourceView(
renderer->device,
textureHandle,
&srvDesc,
&srv
);
if (FAILED(res)) if (FAILED(res))
{ {
ID3D11Resource_Release(textureHandle); ID3D11Resource_Release(textureHandle);
@ -1516,7 +1522,7 @@ static void D3D11_SetTextureData(
dstBox.bottom = textureSlice->rectangle.y + h; dstBox.bottom = textureSlice->rectangle.y + h;
dstBox.back = textureSlice->depth + 1; dstBox.back = textureSlice->depth + 1;
ID3D11DeviceContext_UpdateSubresource( ID3D11DeviceContext1_UpdateSubresource1(
d3d11CommandBuffer->context, d3d11CommandBuffer->context,
d3d11Texture->handle, d3d11Texture->handle,
D3D11_INTERNAL_CalcSubresource( D3D11_INTERNAL_CalcSubresource(
@ -1527,7 +1533,8 @@ static void D3D11_SetTextureData(
&dstBox, &dstBox,
data, data,
BytesPerRow(w, d3d11Texture->format), BytesPerRow(w, d3d11Texture->format),
BytesPerImage(w, h, d3d11Texture->format) BytesPerImage(w, h, d3d11Texture->format),
D3D11_COPY_DISCARD /* FIXME: Is this right? */
); );
} }