From 386e33010b94493d87cb5e4ccac46973eac67ed4 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 28 Aug 2018 18:27:04 -0700 Subject: Fixed https://github.com/DiligentGraphics/DiligentCore/issues/27 (alignment issue with d3d12 texture update) --- Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 70dddbcd..39481a36 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -845,7 +845,9 @@ namespace Diligent auto UpdateRegionWidth = DstBox.MaxX - DstBox.MinX; auto UpdateRegionHeight = DstBox.MaxY - DstBox.MinY; auto UpdateRegionDepth = DstBox.MaxZ - DstBox.MinZ; - auto BufferDataStride = UpdateRegionWidth * FmtAttribs.ComponentSize * FmtAttribs.NumComponents; + auto BufferDataStride = UpdateRegionWidth * Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; + // RowPitch must be a multiple of 256 (aka. D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) + BufferDataStride = (BufferDataStride + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT-1) & ~(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT-1); auto BufferDataDepthStride = UpdateRegionHeight * BufferDataStride; auto MemorySize = UpdateRegionDepth * BufferDataDepthStride; auto UploadSpace = AllocateDynamicSpace(MemorySize, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); -- cgit v1.2.3