summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhid3d11.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-09-02 15:27:22 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-09-03 17:14:59 +0200
commit69065160048335b8f5e2e3d0ba254a2065c51c5d (patch)
tree865e572355c1f860562b2b4badadfe01639e6fe2 /src/gui/rhi/qrhid3d11.cpp
parentc104af4c44dcbe9be23f2cc0259d39fe4f2d1c70 (diff)
rhi: Add a way to tell an srb that only the resources have changed
Until now, after updating the bindings one had to always rebuild the srb, which can be heavy esp. on Vulkan (release old objects, create new layout object, descriptor sets). When updating the binding list in a way that it is fully isLayoutCompatible() == true with the previous list, this is an overkill. Internally, most notably in setShaderResources(), we already should have everything in place in all backends to recognize if the entries in the binding list refer to QRhiBuffer/Texture/Sampler objects that are different than before, and so apart from adding an alternative to create() in the API there is not much else needed here. Pick-to: 6.2 Change-Id: I2efdd4fd0b24c7ebba694a975ed83509744b044b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhid3d11.cpp')
-rw-r--r--src/gui/rhi/qrhid3d11.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index bdbb6f538b..b2bc631569 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -3622,6 +3622,21 @@ bool QD3D11ShaderResourceBindings::create()
return true;
}
+void QD3D11ShaderResourceBindings::updateResources(UpdateFlags flags)
+{
+ sortedBindings.clear();
+ std::copy(m_bindings.cbegin(), m_bindings.cend(), std::back_inserter(sortedBindings));
+ if (!flags.testFlag(BindingsAreSorted)) {
+ std::sort(sortedBindings.begin(), sortedBindings.end(),
+ [](const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
+ {
+ return a.data()->binding < b.data()->binding;
+ });
+ }
+
+ generation += 1;
+}
+
QD3D11GraphicsPipeline::QD3D11GraphicsPipeline(QRhiImplementation *rhi)
: QRhiGraphicsPipeline(rhi)
{