From 9ea3947df91fb113568cf08a7d5b7a87eda24de0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Oct 2023 21:25:47 +0200 Subject: [PATCH] rhi: d3d12: Mark CBV root parameters as DATA_STATIC CBV and SRV descriptor ranges default to DATA_STATIC_WHILE_SET_AT_EXECUTE with RS 1.1. Due to how constant buffers (that back Dynamic+UniformBuffer QRhiBuffers) are implemented, DATA_STATIC is more appropriate, leaving more optimization opportunities. The buffer contents will not change once setShaderResources() is called (which is what issues the SetGraphicsRootConstantBufferView()). In fact the buffer contents should not be changing anymore during the whole render pass recording (begin..endPass). Change-Id: I5901a6d9608fb7c61f04f9d6a3a9acebce37a673 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhid3d12.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 502a9bc911a..febe5364e62 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -2698,6 +2698,7 @@ bool QD3D12MipmapGenerator::create(QRhiD3D12 *rhiD) // b0 rootParams[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; rootParams[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + rootParams[0].Descriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC; // t0 descriptorRanges[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; @@ -4821,6 +4822,7 @@ void QD3D12ShaderResourceBindings::visitUniformBuffer(QD3D12Stage s, rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; rootParam.ShaderVisibility = qd3d12_stageToVisibility(s); rootParam.Descriptor.ShaderRegister = shaderRegister; + rootParam.Descriptor.Flags = D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC; visitorData.cbParams[s].append(rootParam); }