From bac8058aa84d07162b0bc53c20ae5976bea4d4ff Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Tue, 8 Feb 2022 18:05:20 +0100 Subject: [PATCH] Fix depth pitch in `UpdateTexture` on D3D11 for volume textures --- Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp index dd422bf1c..53234330e 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp @@ -725,7 +725,8 @@ void GPUContextDX11::UpdateTexture(GPUTexture* texture, int32 arrayIndex, int32 auto textureDX11 = static_cast(texture); const int32 subresourceIndex = RenderToolsDX::CalcSubresourceIndex(mipIndex, arrayIndex, texture->MipLevels()); - _context->UpdateSubresource(textureDX11->GetResource(), subresourceIndex, nullptr, data, static_cast(rowPitch), slicePitch); + const uint32 depthPitch = texture->IsVolume() ? slicePitch / texture->Depth() : slicePitch; + _context->UpdateSubresource(textureDX11->GetResource(), subresourceIndex, nullptr, data, (UINT)rowPitch, (UINT)depthPitch); //D3D11_MAPPED_SUBRESOURCE mapped; //_device->GetIM()->Map(_resource, textureMipIndex, D3D11_MAP_WRITE_DISCARD, 0, &mapped);