don't issue barriers in BeginTextureReadback when not needed

This commit is contained in:
myT 2023-11-18 04:02:14 +01:00
parent f37a3ee7c0
commit 4795cf3666
1 changed files with 14 additions and 4 deletions

View File

@ -1162,17 +1162,27 @@ namespace RHI
srcBox.bottom = textureDesc.Height;
srcBox.back = 1;
const D3D12_RESOURCE_STATES prevState = texture.currentState;
// @TODO: use CmdBarrier
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Transition.pResource = texture.texture;
barrier.Transition.StateBefore = texture.currentState;
barrier.Transition.StateBefore = prevState;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
if(texture.currentState != D3D12_RESOURCE_STATE_COPY_SOURCE)
{
readbackCommandList->ResourceBarrier(1, &barrier);
texture.currentState = D3D12_RESOURCE_STATE_COPY_SOURCE;
}
readbackCommandList->CopyTextureRegion(&dstLoc, 0, 0, 0, &srcLoc, &srcBox);
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
barrier.Transition.StateAfter = texture.currentState;
barrier.Transition.StateAfter = prevState;
if(texture.currentState != prevState)
{
readbackCommandList->ResourceBarrier(1, &barrier);
texture.currentState = prevState;
}
D3D(readbackCommandList->Close());
ID3D12CommandList* commandListArray[] = { readbackCommandList };