From a4ad90bc1d466f0bb902db6ae321f28362c16429 Mon Sep 17 00:00:00 2001 From: David Donaldson Date: Tue, 13 Dec 2022 11:01:04 -0800 Subject: [PATCH] Use STATE_COMMON to read/write resource data When reading or writing resource data in Dx12ResourceDataUtil, transition the resource to D3D12_RESOURCE_STATE_COMMON instead of D3D12_RESOURCE_STATE_GENERIC_READ or D3D12_RESOURCE_STATE_COPY_DEST. The resource should automatically be promoted to COPY_SOURCE or COPY_DEST by the command list. This fixes corruption occasionally seen in the first frame of trimmed captures. --- framework/graphics/dx12_resource_data_util.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/framework/graphics/dx12_resource_data_util.cpp b/framework/graphics/dx12_resource_data_util.cpp index 262aa4b6ba..2cd49896ba 100644 --- a/framework/graphics/dx12_resource_data_util.cpp +++ b/framework/graphics/dx12_resource_data_util.cpp @@ -625,11 +625,8 @@ Dx12ResourceDataUtil::ExecuteCopyCommandList(ID3D12Resource* ID3D12Resource* staging_buffer, bool batching) { - const dx12::ResourceStateInfo kReadState = { D3D12_RESOURCE_STATE_GENERIC_READ, D3D12_RESOURCE_BARRIER_FLAG_NONE }; - const dx12::ResourceStateInfo kWriteState = { D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_BARRIER_FLAG_NONE }; - // The resource state required to copy data to the target resource. - const dx12::ResourceStateInfo copy_state = (copy_type == kCopyTypeRead) ? kReadState : kWriteState; + const dx12::ResourceStateInfo copy_state = { D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_BARRIER_FLAG_NONE }; uint64_t subresource_count = subresource_layouts.size();