summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-09-01 12:26:39 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-09-03 17:14:59 +0200
commit6cdf95a970f499f7d724e79638856a71942dd30d (patch)
tree96a946b51d5494a1db02324a4082812981122fbe /src/gui/rhi/qrhi.cpp
parentaac1858920864ac0939fd7b17b49fb76a83f0f70 (diff)
rhi: Include resource count in srb layout compatibility checks
Relevant for Vulkan, given that descriptorCount is part of VkDescriptorSetLayoutBinding, meaning two srbs with arrays of SampledTextures should only be reported as compatible if the array size matches. Also reduces the prealloc size for the VLAs. For Qt Quick even a lower number would be sufficient, but we still keep the number something fairly high in order to play nice with Quick3D. Pick-to: 6.2 Change-Id: Id92b7c09b051ebe54b1fa2bf4ba78950fe60ba27 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhi.cpp')
-rw-r--r--src/gui/rhi/qrhi.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index b9cf0a1a36..228fc91ce3 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -3044,9 +3044,11 @@ void QRhiImplementation::updateLayoutDesc(QRhiShaderResourceBindings *srb)
srb->m_layoutDesc.clear();
for (const QRhiShaderResourceBinding &b : qAsConst(srb->m_bindings)) {
const QRhiShaderResourceBinding::Data *d = b.data();
- // must match QRhiShaderResourceBinding::isLayoutCompatible()
- srb->m_layoutDescHash ^= uint(d->binding) ^ uint(d->stage) ^ uint(d->type);
- srb->m_layoutDesc << uint(d->binding) << uint(d->stage) << uint(d->type);
+ // the logic must match QRhiShaderResourceBinding::isLayoutCompatible()
+ const int count = d->type == QRhiShaderResourceBinding::SampledTexture ? d->u.stex.count : 1;
+ // the number of entries here should match LAYOUT_DESC_FIELD_COUNT
+ srb->m_layoutDescHash ^= uint(d->binding) ^ uint(d->stage) ^ uint(d->type) ^ uint(count);
+ srb->m_layoutDesc << uint(d->binding) << uint(d->stage) << uint(d->type) << uint(count);
}
}
@@ -3110,7 +3112,10 @@ void QRhiImplementation::updateLayoutDesc(QRhiShaderResourceBindings *srb)
*/
bool QRhiShaderResourceBinding::isLayoutCompatible(const QRhiShaderResourceBinding &other) const
{
- return d.binding == other.d.binding && d.stage == other.d.stage && d.type == other.d.type;
+ // i.e. everything that goes into a VkDescriptorSetLayoutBinding must match
+ const int thisCount = d.type == QRhiShaderResourceBinding::SampledTexture ? d.u.stex.count : 1;
+ const int otherCount = other.d.type == QRhiShaderResourceBinding::SampledTexture ? other.d.u.stex.count : 1;
+ return d.binding == other.d.binding && d.stage == other.d.stage && d.type == other.d.type && thisCount == otherCount;
}
/*!