Skip to content
Snippets Groups Projects
Commit 7e5dd39f authored by Józef Kucia's avatar Józef Kucia
Browse files

libs/vkd3d: Prefer VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL.

Use VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL if depth/stencil
writes are disabled.
parent b109a1fc
No related branches found
No related tags found
No related merge requests found
......@@ -1953,6 +1953,9 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
graphics->rt_idx = 0;
if (desc->DepthStencilState.DepthEnable || desc->DepthStencilState.StencilEnable)
{
const D3D12_DEPTH_STENCIL_DESC *ds_desc = &desc->DepthStencilState;
VkImageLayout depth_layout;
if (!(format = vkd3d_get_format(desc->DSVFormat, true)))
{
WARN("Invalid DXGI format %#x.\n", desc->DSVFormat);
......@@ -1960,6 +1963,12 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
goto fail;
}
if ((ds_desc->DepthEnable && ds_desc->DepthWriteMask)
|| (ds_desc->StencilEnable && ds_desc->StencilWriteMask))
depth_layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
else
depth_layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
graphics->attachments[0].flags = 0;
graphics->attachments[0].format = format->vk_format;
graphics->attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
......@@ -1983,11 +1992,11 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
graphics->attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
graphics->attachments[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
}
graphics->attachments[0].initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
graphics->attachments[0].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
graphics->attachments[0].initialLayout = depth_layout;
graphics->attachments[0].finalLayout = depth_layout;
graphics->attachment_references[0].attachment = 0;
graphics->attachment_references[0].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
graphics->attachment_references[0].layout = depth_layout;
++graphics->rt_idx;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment