rhi: Remove QRhiSrb data getters
This is for internal use, QRhiShaderResourceBinding does not need to have the data() getters. The backends can use any internal means to access this, no need to have the getters in the frontend just for that. Now, Qt Quick 3D has a special case of accessing this, hence keeping the two getters for now, to be removed in a follow up once that repo updates. While we are at it, share and reuse the sorting function. Change-Id: Ia2308af79863c72ca65024ce6c00531d0256a2cb Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
6cf3447f1d
commit
7dbf9ae9e4
@ -3367,7 +3367,7 @@ void QRhiImplementation::updateLayoutDesc(QRhiShaderResourceBindings *srb)
|
||||
srb->m_layoutDesc.clear();
|
||||
auto layoutDescAppender = std::back_inserter(srb->m_layoutDesc);
|
||||
for (const QRhiShaderResourceBinding &b : std::as_const(srb->m_bindings)) {
|
||||
const QRhiShaderResourceBinding::Data *d = b.data();
|
||||
const QRhiShaderResourceBinding::Data *d = &b.d;
|
||||
srb->m_layoutDescHash ^= uint(d->binding) ^ uint(d->stage) ^ uint(d->type)
|
||||
^ uint(d->arraySize());
|
||||
layoutDescAppender = d->serialize(layoutDescAppender);
|
||||
@ -4083,8 +4083,8 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoadStore(
|
||||
*/
|
||||
bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b) noexcept
|
||||
{
|
||||
const QRhiShaderResourceBinding::Data *da = a.data();
|
||||
const QRhiShaderResourceBinding::Data *db = b.data();
|
||||
const QRhiShaderResourceBinding::Data *da = QRhiImplementation::shaderResourceBindingData(a);
|
||||
const QRhiShaderResourceBinding::Data *db = QRhiImplementation::shaderResourceBindingData(b);
|
||||
|
||||
if (da == db)
|
||||
return true;
|
||||
@ -4173,7 +4173,7 @@ bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind
|
||||
*/
|
||||
size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) noexcept
|
||||
{
|
||||
const QRhiShaderResourceBinding::Data *d = b.data();
|
||||
const QRhiShaderResourceBinding::Data *d = QRhiImplementation::shaderResourceBindingData(b);
|
||||
size_t h = uint(d->binding) ^ uint(d->stage) ^ uint(d->type) ^ seed;
|
||||
switch (d->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
@ -4207,7 +4207,7 @@ size_t qHash(const QRhiShaderResourceBinding &b, size_t seed) noexcept
|
||||
QDebug operator<<(QDebug dbg, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
const QRhiShaderResourceBinding::Data *d = b.data();
|
||||
const QRhiShaderResourceBinding::Data *d = QRhiImplementation::shaderResourceBindingData(b);
|
||||
dbg.nospace() << "QRhiShaderResourceBinding("
|
||||
<< "binding=" << d->binding
|
||||
<< " stage=" << d->stage
|
||||
@ -5431,7 +5431,7 @@ bool QRhiImplementation::sanityCheckShaderResourceBindings(QRhiShaderResourceBin
|
||||
const int CHECKED_BINDINGS_COUNT = 64;
|
||||
bool bindingSeen[CHECKED_BINDINGS_COUNT] = {};
|
||||
for (auto it = srb->cbeginBindings(), end = srb->cendBindings(); it != end; ++it) {
|
||||
const int binding = it->data()->binding;
|
||||
const int binding = shaderResourceBindingData(*it)->binding;
|
||||
if (binding >= CHECKED_BINDINGS_COUNT)
|
||||
continue;
|
||||
if (binding < 0) {
|
||||
@ -5439,7 +5439,7 @@ bool QRhiImplementation::sanityCheckShaderResourceBindings(QRhiShaderResourceBin
|
||||
bindingsOk = false;
|
||||
continue;
|
||||
}
|
||||
switch (it->data()->type) {
|
||||
switch (shaderResourceBindingData(*it)->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
if (!bindingSeen[binding]) {
|
||||
bindingSeen[binding] = true;
|
||||
@ -5493,7 +5493,7 @@ bool QRhiImplementation::sanityCheckShaderResourceBindings(QRhiShaderResourceBin
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning("Unknown binding type %d", int(it->data()->type));
|
||||
qWarning("Unknown binding type %d", int(shaderResourceBindingData(*it)->type));
|
||||
bindingsOk = false;
|
||||
break;
|
||||
}
|
||||
|
@ -409,6 +409,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// ### remove these two once Qt Quick 3D is updated
|
||||
Data *data() { return &d; }
|
||||
const Data *data() const { return &d; }
|
||||
|
||||
@ -420,13 +421,14 @@ public:
|
||||
Output dst)
|
||||
{
|
||||
while (first != last) {
|
||||
dst = first->data()->serialize(dst);
|
||||
dst = first->d.serialize(dst);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Data d;
|
||||
friend class QRhiImplementation;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QRhiShaderResourceBinding::StageFlags)
|
||||
|
@ -220,6 +220,21 @@ public:
|
||||
QRhiVertexInputAttribute::Format shaderDescVariableFormatToVertexInputFormat(QShaderDescription::VariableType type) const;
|
||||
quint32 byteSizePerVertexForVertexInputFormat(QRhiVertexInputAttribute::Format format) const;
|
||||
|
||||
static const QRhiShaderResourceBinding::Data *shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
|
||||
{
|
||||
return &binding.d;
|
||||
}
|
||||
|
||||
static QRhiShaderResourceBinding::Data *shaderResourceBindingData(QRhiShaderResourceBinding &binding)
|
||||
{
|
||||
return &binding.d;
|
||||
}
|
||||
|
||||
static bool sortedBindingLessThan(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
return a.d.binding < b.d.binding;
|
||||
}
|
||||
|
||||
QRhi *q;
|
||||
|
||||
static const int MAX_SHADER_CACHE_ENTRIES = 128;
|
||||
|
@ -854,7 +854,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
|
||||
|
||||
bool srbUpdate = false;
|
||||
for (int i = 0, ie = srbD->sortedBindings.count(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings.at(i));
|
||||
QD3D11ShaderResourceBindings::BoundResourceData &bd(srbD->boundResourceData[i]);
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
@ -2143,7 +2143,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD,
|
||||
} res[RBM_SUPPORTED_STAGES];
|
||||
|
||||
for (int i = 0, ie = srbD->sortedBindings.count(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings.at(i));
|
||||
QD3D11ShaderResourceBindings::BoundResourceData &bd(srbD->boundResourceData[i]);
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
@ -3841,11 +3841,7 @@ bool QD3D11ShaderResourceBindings::create()
|
||||
rhiD->updateLayoutDesc(this);
|
||||
|
||||
std::copy(m_bindings.cbegin(), m_bindings.cend(), std::back_inserter(sortedBindings));
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(),
|
||||
[](const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
return a.data()->binding < b.data()->binding;
|
||||
});
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
boundResourceData.resize(sortedBindings.count());
|
||||
|
||||
@ -3854,7 +3850,7 @@ bool QD3D11ShaderResourceBindings::create()
|
||||
|
||||
hasDynamicOffset = false;
|
||||
for (const QRhiShaderResourceBinding &b : sortedBindings) {
|
||||
const QRhiShaderResourceBinding::Data *bd = b.data();
|
||||
const QRhiShaderResourceBinding::Data *bd = QRhiImplementation::shaderResourceBindingData(b);
|
||||
if (bd->type == QRhiShaderResourceBinding::UniformBuffer && bd->u.ubuf.hasDynamicOffset) {
|
||||
hasDynamicOffset = true;
|
||||
break;
|
||||
@ -3869,13 +3865,8 @@ 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;
|
||||
});
|
||||
}
|
||||
if (!flags.testFlag(BindingsAreSorted))
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
Q_ASSERT(boundResourceData.count() == sortedBindings.count());
|
||||
for (BoundResourceData &bd : boundResourceData)
|
||||
|
@ -786,7 +786,7 @@ 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 = srbD->sortedBindings[i].data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings[i]);
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
{
|
||||
@ -2239,7 +2239,7 @@ void QD3D12ShaderResourceVisitor::visit()
|
||||
{
|
||||
for (int bindingIdx = 0, bindingCount = srb->sortedBindings.count(); bindingIdx != bindingCount; ++bindingIdx) {
|
||||
const QRhiShaderResourceBinding &b(srb->sortedBindings[bindingIdx]);
|
||||
const QRhiShaderResourceBinding::Data *bd = b.data();
|
||||
const QRhiShaderResourceBinding::Data *bd = QRhiImplementation::shaderResourceBindingData(b);
|
||||
|
||||
for (int stageIdx = 0; stageIdx < stageCount; ++stageIdx) {
|
||||
const QD3D12ShaderStageData *sd = &stageData[stageIdx];
|
||||
@ -4408,15 +4408,11 @@ bool QD3D12ShaderResourceBindings::create()
|
||||
rhiD->updateLayoutDesc(this);
|
||||
|
||||
std::copy(m_bindings.cbegin(), m_bindings.cend(), std::back_inserter(sortedBindings));
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(),
|
||||
[](const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
return a.data()->binding < b.data()->binding;
|
||||
});
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
hasDynamicOffset = false;
|
||||
for (const QRhiShaderResourceBinding &b : sortedBindings) {
|
||||
const QRhiShaderResourceBinding::Data *bd = b.data();
|
||||
const QRhiShaderResourceBinding::Data *bd = QRhiImplementation::shaderResourceBindingData(b);
|
||||
if (bd->type == QRhiShaderResourceBinding::UniformBuffer && bd->u.ubuf.hasDynamicOffset) {
|
||||
hasDynamicOffset = true;
|
||||
break;
|
||||
@ -4439,13 +4435,8 @@ 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(),
|
||||
[](const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
return a.data()->binding < b.data()->binding;
|
||||
});
|
||||
}
|
||||
if (!flags.testFlag(BindingsAreSorted))
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
generation += 1;
|
||||
}
|
||||
|
@ -1613,7 +1613,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
|
||||
if (cbD->passNeedsResourceTracking) {
|
||||
QRhiPassResourceTracker &passResTracker(cbD->passResTrackers[cbD->currentPassResTrackerIndex]);
|
||||
for (int i = 0, ie = srbD->m_bindings.size(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->m_bindings.at(i));
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
// no BufUniformRead / AccessUniform because no real uniform buffers are used
|
||||
@ -3699,7 +3699,7 @@ void QRhiGles2::bindShaderResources(QGles2CommandBuffer *cbD,
|
||||
QVarLengthArray<SeparateSampler, 4> separateSamplerBindings;
|
||||
|
||||
for (int i = 0, ie = srbD->m_bindings.size(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->m_bindings.at(i));
|
||||
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
@ -4318,7 +4318,7 @@ void QRhiGles2::dispatch(QRhiCommandBuffer *cb, int x, int y, int z)
|
||||
QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, cbD->currentComputeSrb);
|
||||
const int bindingCount = srbD->m_bindings.size();
|
||||
for (int i = 0; i < bindingCount; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->m_bindings.at(i));
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::ImageLoad:
|
||||
case QRhiShaderResourceBinding::ImageStore:
|
||||
@ -5576,7 +5576,7 @@ bool QGles2ShaderResourceBindings::create()
|
||||
|
||||
hasDynamicOffset = false;
|
||||
for (int i = 0, ie = m_bindings.size(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = m_bindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = QRhiImplementation::shaderResourceBindingData(m_bindings.at(i));
|
||||
if (b->type == QRhiShaderResourceBinding::UniformBuffer) {
|
||||
if (b->u.ubuf.hasDynamicOffset) {
|
||||
hasDynamicOffset = true;
|
||||
|
@ -1208,7 +1208,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
|
||||
QMetalShaderResourceBindingsData bindingData;
|
||||
|
||||
for (const QRhiShaderResourceBinding &binding : std::as_const(srbD->sortedBindings)) {
|
||||
const QRhiShaderResourceBinding::Data *b = binding.data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(binding);
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
{
|
||||
@ -1471,7 +1471,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
|
||||
|
||||
// do buffer writes, figure out if we need to rebind, and mark as in-use
|
||||
for (int i = 0, ie = srbD->sortedBindings.count(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings.at(i));
|
||||
QMetalShaderResourceBindings::BoundResourceData &bd(srbD->boundResourceData[i]);
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
@ -4176,13 +4176,9 @@ bool QMetalShaderResourceBindings::create()
|
||||
rhiD->updateLayoutDesc(this);
|
||||
|
||||
std::copy(m_bindings.cbegin(), m_bindings.cend(), std::back_inserter(sortedBindings));
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(),
|
||||
[](const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
return a.data()->binding < b.data()->binding;
|
||||
});
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
if (!sortedBindings.isEmpty())
|
||||
maxBinding = sortedBindings.last().data()->binding;
|
||||
maxBinding = QRhiImplementation::shaderResourceBindingData(sortedBindings.last())->binding;
|
||||
else
|
||||
maxBinding = -1;
|
||||
|
||||
@ -4199,13 +4195,8 @@ void QMetalShaderResourceBindings::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;
|
||||
});
|
||||
}
|
||||
if (!flags.testFlag(BindingsAreSorted))
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
for (BoundResourceData &bd : boundResourceData)
|
||||
memset(&bd, 0, sizeof(BoundResourceData));
|
||||
|
@ -2464,7 +2464,7 @@ void QRhiVulkan::dispatch(QRhiCommandBuffer *cb, int x, int y, int z)
|
||||
QVkShaderResourceBindings *srbD = QRHI_RES(QVkShaderResourceBindings, cbD->currentComputeSrb);
|
||||
const int bindingCount = srbD->m_bindings.size();
|
||||
for (int i = 0; i < bindingCount; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->m_bindings.at(i));
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::ImageLoad:
|
||||
case QRhiShaderResourceBinding::ImageStore:
|
||||
@ -2622,7 +2622,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i
|
||||
int frameSlot = updateAll ? 0 : descSetIdx;
|
||||
while (frameSlot < (updateAll ? QVK_FRAMES_IN_FLIGHT : descSetIdx + 1)) {
|
||||
for (int i = 0, ie = srbD->sortedBindings.size(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings.at(i).data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings.at(i));
|
||||
QVkShaderResourceBindings::BoundResourceData &bd(srbD->boundResourceData[frameSlot][i]);
|
||||
|
||||
VkWriteDescriptorSet writeInfo = {};
|
||||
@ -4569,7 +4569,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin
|
||||
// Do host writes and mark referenced shader resources as in-use.
|
||||
// Also prepare to ensure the descriptor set we are going to bind refers to up-to-date Vk objects.
|
||||
for (int i = 0, ie = srbD->sortedBindings.size(); i != ie; ++i) {
|
||||
const QRhiShaderResourceBinding::Data *b = srbD->sortedBindings[i].data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(srbD->sortedBindings[i]);
|
||||
QVkShaderResourceBindings::BoundResourceData &bd(descSetBd[i]);
|
||||
switch (b->type) {
|
||||
case QRhiShaderResourceBinding::UniformBuffer:
|
||||
@ -4716,7 +4716,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin
|
||||
// and neither srb nor dynamicOffsets has any such ordering
|
||||
// requirement.
|
||||
for (const QRhiShaderResourceBinding &binding : std::as_const(srbD->sortedBindings)) {
|
||||
const QRhiShaderResourceBinding::Data *b = binding.data();
|
||||
const QRhiShaderResourceBinding::Data *b = shaderResourceBindingData(binding);
|
||||
if (b->type == QRhiShaderResourceBinding::UniformBuffer && b->u.ubuf.hasDynamicOffset) {
|
||||
uint32_t offset = 0;
|
||||
for (int i = 0; i < dynamicOffsetCount; ++i) {
|
||||
@ -6696,16 +6696,12 @@ bool QVkShaderResourceBindings::create()
|
||||
|
||||
sortedBindings.clear();
|
||||
std::copy(m_bindings.cbegin(), m_bindings.cend(), std::back_inserter(sortedBindings));
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(),
|
||||
[](const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
|
||||
{
|
||||
return a.data()->binding < b.data()->binding;
|
||||
});
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
hasSlottedResource = false;
|
||||
hasDynamicOffset = false;
|
||||
for (const QRhiShaderResourceBinding &binding : std::as_const(sortedBindings)) {
|
||||
const QRhiShaderResourceBinding::Data *b = binding.data();
|
||||
const QRhiShaderResourceBinding::Data *b = QRhiImplementation::shaderResourceBindingData(binding);
|
||||
if (b->type == QRhiShaderResourceBinding::UniformBuffer && b->u.ubuf.buf) {
|
||||
if (QRHI_RES(QVkBuffer, b->u.ubuf.buf)->type() == QRhiBuffer::Dynamic)
|
||||
hasSlottedResource = true;
|
||||
@ -6716,7 +6712,7 @@ bool QVkShaderResourceBindings::create()
|
||||
|
||||
QVarLengthArray<VkDescriptorSetLayoutBinding, 4> vkbindings;
|
||||
for (const QRhiShaderResourceBinding &binding : std::as_const(sortedBindings)) {
|
||||
const QRhiShaderResourceBinding::Data *b = binding.data();
|
||||
const QRhiShaderResourceBinding::Data *b = QRhiImplementation::shaderResourceBindingData(binding);
|
||||
VkDescriptorSetLayoutBinding vkbinding = {};
|
||||
vkbinding.binding = uint32_t(b->binding);
|
||||
vkbinding.descriptorType = toVkDescriptorType(b);
|
||||
@ -6765,13 +6761,8 @@ void QVkShaderResourceBindings::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;
|
||||
});
|
||||
}
|
||||
if (!flags.testFlag(BindingsAreSorted))
|
||||
std::sort(sortedBindings.begin(), sortedBindings.end(), QRhiImplementation::sortedBindingLessThan);
|
||||
|
||||
// Reset the state tracking table too - it can deal with assigning a
|
||||
// different QRhiBuffer/Texture/Sampler for a binding point, but it cannot
|
||||
|
Loading…
Reference in New Issue
Block a user