From 16e987271833c8e9e753ab7bdf74672b6f98ecd6 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Wed, 14 Aug 2024 02:09:16 +0200 Subject: [PATCH] vkd3d: Use D3D12_SHADER_VISIBILITY_ALL for 32-bit root constants when using vk_heaps. The existing code sets "stageFlags" to VK_SHADER_STAGE_ALL when "use_vk_heaps" is true, but doesn't adjust the visibility. This potentially violates the "Any two elements of pPushConstantRanges must not include the same stage in stageFlags" constraint, and causes the validation layers to complain accordingly. --- libs/vkd3d/state.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 0bdb7ea5..519d1a2d 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -635,14 +635,18 @@ static HRESULT d3d12_root_signature_init_push_constants(struct d3d12_root_signat for (i = 0; i < desc->NumParameters; ++i) { const D3D12_ROOT_PARAMETER *p = &desc->pParameters[i]; + D3D12_SHADER_VISIBILITY visibility; + if (p->ParameterType != D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS) continue; - VKD3D_ASSERT(p->ShaderVisibility <= D3D12_SHADER_VISIBILITY_PIXEL); - push_constants[p->ShaderVisibility].stageFlags = use_vk_heaps ? VK_SHADER_STAGE_ALL - : stage_flags_from_visibility(p->ShaderVisibility); - push_constants[p->ShaderVisibility].size += align(p->u.Constants.Num32BitValues, 4) * sizeof(uint32_t); + visibility = use_vk_heaps ? D3D12_SHADER_VISIBILITY_ALL : p->ShaderVisibility; + VKD3D_ASSERT(visibility <= D3D12_SHADER_VISIBILITY_PIXEL); + + push_constants[visibility].stageFlags = stage_flags_from_visibility(visibility); + push_constants[visibility].size += align(p->u.Constants.Num32BitValues, 4) * sizeof(uint32_t); } + if (push_constants[D3D12_SHADER_VISIBILITY_ALL].size) { /* When D3D12_SHADER_VISIBILITY_ALL is used we use a single push