From fd05cd3adb8db612c3881a559e83ce81f74a48d5 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 13 Jun 2020 22:54:33 +0300 Subject: [PATCH] don't use small resource alignment for large textures thanks to Emil for this one see https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_resource_desc#alignment for an explanation --- src/pc/gfx/gfx_direct3d12.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pc/gfx/gfx_direct3d12.cpp b/src/pc/gfx/gfx_direct3d12.cpp index e01ce720..3fe9aed1 100644 --- a/src/pc/gfx/gfx_direct3d12.cpp +++ b/src/pc/gfx/gfx_direct3d12.cpp @@ -423,7 +423,8 @@ static void gfx_d3d12_upload_texture(uint8_t *rgba32_buf, int width, int height) texture_desc.SampleDesc.Count = 1; texture_desc.SampleDesc.Quality = 0; texture_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - texture_desc.Alignment = D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; + texture_desc.Alignment = ((width + 31) / 32) * ((height + 31) / 32) > 16 ? + 0 : D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; D3D12_RESOURCE_ALLOCATION_INFO alloc_info = get_resource_allocation_info(&texture_desc);