From e17c93ab04f9f88d9ff8e66ce241ffbfec053220 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 22 Jul 2021 13:57:58 +1000 Subject: [PATCH] D3D12HostDisplay: Fix incorrect resource state in DownloadTexture() --- src/frontend-common/d3d12_host_display.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/frontend-common/d3d12_host_display.cpp b/src/frontend-common/d3d12_host_display.cpp index b63f83899..9239e092f 100644 --- a/src/frontend-common/d3d12_host_display.cpp +++ b/src/frontend-common/d3d12_host_display.cpp @@ -123,7 +123,11 @@ bool D3D12HostDisplay::DownloadTexture(const void* texture_handle, HostDisplayPi if (!m_readback_staging_texture.EnsureSize(width, height, texture->GetFormat(), false)) return false; + const D3D12_RESOURCE_STATES old_state = texture->GetState(); + texture->TransitionToState(D3D12_RESOURCE_STATE_COPY_SOURCE); m_readback_staging_texture.CopyFromTexture(texture->GetResource(), 0, x, y, 0, 0, width, height); + texture->TransitionToState(old_state); + return m_readback_staging_texture.ReadPixels(0, 0, width, height, out_data, out_data_stride); }