don't transition simultaneous-access rt/dt on discard

This commit is contained in:
jacob 2026-02-27 12:28:49 -08:00
parent 7b7b0afd64
commit 983d9f0040

View File

@ -1312,7 +1312,6 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_CommandListHandle
//- Initialize d3d resource desc
D3D12_BARRIER_LAYOUT d3d_begin_layout = D3D12_BARRIER_LAYOUT_UNDEFINED;
D3D12_BARRIER_LAYOUT d3d_end_layout = D3D12_BARRIER_LAYOUT_UNDEFINED;
D3D12_CLEAR_VALUE clear_value = Zi;
D3D12_RESOURCE_DESC1 d3d_desc = Zi;
if (is_buffer)
@ -1357,8 +1356,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_CommandListHandle
clear_value.Format = d3d_desc.Format;
d3d_begin_layout = G_D12_BarrierLayoutFromLayout(desc.texture.initial_layout);
d3d_end_layout = d3d_begin_layout;
if (!AnyBit(flags, G_ResourceFlag_ZeroMemory))
if (!AnyBit(flags, G_ResourceFlag_ZeroMemory) && !AnyBit(d3d_desc.Flags, D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS))
{
if (AnyBit(d3d_desc.Flags, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET))
{
@ -1501,13 +1499,14 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_CommandListHandle
// Queue initial Rtv/Dsv discard
if (!AnyBit(flags, G_ResourceFlag_ZeroMemory))
{
if (d3d_begin_layout == D3D12_BARRIER_LAYOUT_RENDER_TARGET)
{
if (AnyBit(d3d_desc.Flags, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL))
{
G_D12_Cmd *cmd = G_D12_PushCmd(cl);
cmd->kind = G_D12_CmdKind_Discard;
cmd->discard.resource = resource;
}
if (d3d_begin_layout == D3D12_BARRIER_LAYOUT_RENDER_TARGET)
{
G_MemoryLayoutSync(
cl_handle, G_D12_MakeHandle(G_ResourceHandle, resource),
@ -1516,14 +1515,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_CommandListHandle
desc.texture.initial_layout
);
}
}
else if (d3d_begin_layout == D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE)
{
{
G_D12_Cmd *cmd = G_D12_PushCmd(cl);
cmd->kind = G_D12_CmdKind_Discard;
cmd->discard.resource = resource;
}
{
G_MemoryLayoutSync(
cl_handle, G_D12_MakeHandle(G_ResourceHandle, resource),
@ -1533,7 +1525,6 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_CommandListHandle
);
}
}
}
if (!SUCCEEDED(hr))
{