From 50e99dd1ff2cef3a93f4b036c9e4e925bea8f4a3 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 23 Apr 2025 22:12:23 +1000 Subject: [PATCH] D3D12Device: Fix incorrect state when texture uploaded 2x w/o use --- src/util/d3d12_texture.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/d3d12_texture.cpp b/src/util/d3d12_texture.cpp index e6bc39d6c..354e08dc7 100644 --- a/src/util/d3d12_texture.cpp +++ b/src/util/d3d12_texture.cpp @@ -178,7 +178,14 @@ std::unique_ptr D3D12Device::CreateTexture(u32 width, u32 height, u3 if (data) { tex->Update(0, 0, width, height, data, data_stride); - tex->TransitionToState(D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + + if (type == GPUTexture::Type::Texture) + { + // resource barrier must be in the same command buffer as the upload + tex->TransitionSubresourceToState(GetInitCommandList(), 0u, 0u, D3D12_RESOURCE_STATE_COPY_DEST, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + tex->m_resource_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + } } return tex;