summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-10-24 21:24:40 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-11-17 20:06:33 +0200
commit445fb40081c870c0a9b1c1c3cf27b20fdd36a531 (patch)
tree8736003c51b1635d2d826de2f5b76d198a94feba /src/gui/rhi
parentccc46d8f89226b6a89f7c1a63e44d4605483b1cb (diff)
rhi: d3d12: Do not waste time on sorting the binding list
Nothing is relying on the binding list being sorted based on the binding number. In many ways the D3D12 backend is very similar to the OpenGL one: the srb merely holds some flags derived from the binding list and that's it really, no native resources or other content are owned directly by the binding set objects. Change-Id: I35d652c9738308bff691095e43aea9706031dd90 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhid3d12.cpp23
-rw-r--r--src/gui/rhi/qrhid3d12_p.h4
2 files changed, 8 insertions, 19 deletions
diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp
index 47c0a228b1..502a9bc911 100644
--- a/src/gui/rhi/qrhid3d12.cpp
+++ b/src/gui/rhi/qrhid3d12.cpp
@@ -951,8 +951,8 @@ void QRhiD3D12::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
QD3D12ShaderResourceBindings *srbD = QRHI_RES(QD3D12ShaderResourceBindings, srb);
- for (int i = 0, ie = srbD->sortedBindings.size(); i != ie; ++i) {
- const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings[i]);
+ for (int i = 0, ie = srbD->m_bindings.size(); i != ie; ++i) {
+ const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->m_bindings[i]);
switch (b->type) {
case QRhiShaderResourceBinding::UniformBuffer:
{
@@ -2546,8 +2546,8 @@ static inline QPair<int, int> mapBinding(int binding, const QShader::NativeResou
void QD3D12ShaderResourceVisitor::visit()
{
- for (int bindingIdx = 0, bindingCount = srb->sortedBindings.count(); bindingIdx != bindingCount; ++bindingIdx) {
- const QRhiShaderResourceBinding &b(srb->sortedBindings[bindingIdx]);
+ for (int bindingIdx = 0, bindingCount = srb->m_bindings.count(); bindingIdx != bindingCount; ++bindingIdx) {
+ const QRhiShaderResourceBinding &b(srb->m_bindings[bindingIdx]);
const QRhiShaderResourceBinding::Data *bd = QRhiImplementation::shaderResourceBindingData(b);
for (int stageIdx = 0; stageIdx < stageCount; ++stageIdx) {
@@ -4767,8 +4767,6 @@ QD3D12ShaderResourceBindings::~QD3D12ShaderResourceBindings()
void QD3D12ShaderResourceBindings::destroy()
{
- sortedBindings.clear();
-
QRHI_RES_RHI(QRhiD3D12);
if (rhiD)
rhiD->unregisterResource(this);
@@ -4776,20 +4774,14 @@ void QD3D12ShaderResourceBindings::destroy()
bool QD3D12ShaderResourceBindings::create()
{
- if (!sortedBindings.isEmpty())
- destroy();
-
QRHI_RES_RHI(QRhiD3D12);
if (!rhiD->sanityCheckShaderResourceBindings(this))
return false;
rhiD->updateLayoutDesc(this);
- std::copy(m_bindings.cbegin(), m_bindings.cend(), std::back_inserter(sortedBindings));
- std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
-
hasDynamicOffset = false;
- for (const QRhiShaderResourceBinding &b : sortedBindings) {
+ for (const QRhiShaderResourceBinding &b : std::as_const(m_bindings)) {
const QRhiShaderResourceBinding::Data *bd = QRhiImplementation::shaderResourceBindingData(b);
if (bd->type == QRhiShaderResourceBinding::UniformBuffer && bd->u.ubuf.hasDynamicOffset) {
hasDynamicOffset = true;
@@ -4812,11 +4804,6 @@ bool QD3D12ShaderResourceBindings::create()
void QD3D12ShaderResourceBindings::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(), QRhiImplementation::sortedBindingLessThan);
-
generation += 1;
}
diff --git a/src/gui/rhi/qrhid3d12_p.h b/src/gui/rhi/qrhid3d12_p.h
index 2f8e00f130..e4bf9a1fde 100644
--- a/src/gui/rhi/qrhid3d12_p.h
+++ b/src/gui/rhi/qrhid3d12_p.h
@@ -867,9 +867,11 @@ struct QD3D12ShaderResourceBindings : public QRhiShaderResourceBindings
QD3D12ShaderResourceVisitor::StorageOp op,
int shaderRegister);
- QVarLengthArray<QRhiShaderResourceBinding, 8> sortedBindings;
bool hasDynamicOffset = false;
uint generation = 0;
+
+ friend class QRhiD3D12;
+ friend struct QD3D12ShaderResourceVisitor;
};
struct QD3D12GraphicsPipeline : public QRhiGraphicsPipeline