summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhimetal.mm
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-07-10 14:50:55 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-07-13 14:54:30 +0200
commit351d42175dc6367a711e2cc4ac6aace23cc462b7 (patch)
tree6896bce75795881d224541183524b6b2adcc8a45 /src/gui/rhi/qrhimetal.mm
parente8d5000026dbad4f48dfed882f4b19d6c4b34c67 (diff)
rhi: Allow null resources in srb
In this case the srb represents the layout only, and can still be used to create a pipeline. For setShaderResources() one will then need to use another, layout compatible, srb that references valid resources. Change-Id: I3ea5b63df3be8847540ca4c0c40fbd29dbed8fb7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r--src/gui/rhi/qrhimetal.mm50
1 files changed, 2 insertions, 48 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index ee7735c1bb..d9575e949b 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -3006,54 +3006,8 @@ bool QMetalShaderResourceBindings::create()
boundResourceData.resize(sortedBindings.count());
- for (int i = 0, ie = sortedBindings.count(); i != ie; ++i) {
- const QRhiShaderResourceBinding::Data *b = sortedBindings.at(i).data();
- QMetalShaderResourceBindings::BoundResourceData &bd(boundResourceData[i]);
- switch (b->type) {
- case QRhiShaderResourceBinding::UniformBuffer:
- {
- QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.ubuf.buf);
- bd.ubuf.id = bufD->m_id;
- bd.ubuf.generation = bufD->generation;
- }
- break;
- case QRhiShaderResourceBinding::SampledTexture:
- {
- const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex;
- bd.stex.count = data->count;
- for (int elem = 0; elem < data->count; ++elem) {
- QMetalTexture *texD = QRHI_RES(QMetalTexture, data->texSamplers[elem].tex);
- QMetalSampler *samplerD = QRHI_RES(QMetalSampler, data->texSamplers[elem].sampler);
- bd.stex.d[elem].texId = texD->m_id;
- bd.stex.d[elem].texGeneration = texD->generation;
- bd.stex.d[elem].samplerId = samplerD->m_id;
- bd.stex.d[elem].samplerGeneration = samplerD->generation;
- }
- }
- break;
- case QRhiShaderResourceBinding::ImageLoad:
- case QRhiShaderResourceBinding::ImageStore:
- case QRhiShaderResourceBinding::ImageLoadStore:
- {
- QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex);
- bd.simage.id = texD->m_id;
- bd.simage.generation = texD->generation;
- }
- break;
- case QRhiShaderResourceBinding::BufferLoad:
- case QRhiShaderResourceBinding::BufferStore:
- case QRhiShaderResourceBinding::BufferLoadStore:
- {
- QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf);
- bd.sbuf.id = bufD->m_id;
- bd.sbuf.generation = bufD->generation;
- }
- break;
- default:
- Q_UNREACHABLE();
- break;
- }
- }
+ for (BoundResourceData &bd : boundResourceData)
+ memset(&bd, 0, sizeof(BoundResourceData));
generation += 1;
return true;