summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhimetal.mm
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-08-11 14:08:34 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-08-12 12:51:59 +0200
commit011d10fe264a9e7fbeaaa537f987d9ed0c830763 (patch)
treec429f527a884e16f7ae81ac70148de936187f13e /src/gui/rhi/qrhimetal.mm
parentea1f17226705567ba8c20c3d400ab76724fc4bd7 (diff)
rhi: metal: Simplify batch comparisons
Change-Id: I9d61ce3f2e8501a854e070a83cd748928129e76d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r--src/gui/rhi/qrhimetal.mm61
1 files changed, 11 insertions, 50 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index f0b8fcac78..dc21feb74c 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -819,46 +819,6 @@ static inline int mapBinding(int binding,
return -1;
}
-static inline bool areBufferBatchesEqual(const QRhiBatchedBindings<id<MTLBuffer> >::Batch &batch1,
- const QRhiBatchedBindings<NSUInteger>::Batch &offsetBatch1,
- const QRhiBatchedBindings<id<MTLBuffer> >::Batch &batch2,
- const QRhiBatchedBindings<NSUInteger>::Batch &offsetBatch2)
-{
- if (batch1.startBinding != batch2.startBinding)
- return false;
- if (batch1.resources.count() != batch2.resources.count())
- return false;
- if (batch1 != batch2)
- return false;
- if (offsetBatch1 != offsetBatch2)
- return false;
- return true;
-}
-
-static inline bool areTextureBatchesEqual(const QRhiBatchedBindings<id<MTLTexture> >::Batch &batch1,
- const QRhiBatchedBindings<id<MTLTexture> >::Batch &batch2)
-{
- if (batch1.startBinding != batch2.startBinding)
- return false;
- if (batch1.resources.count() != batch2.resources.count())
- return false;
- if (batch1 != batch2)
- return false;
- return true;
-};
-
-static inline bool areSamplerBatchesEqual(const QRhiBatchedBindings<id<MTLSamplerState> >::Batch &batch1,
- const QRhiBatchedBindings<id<MTLSamplerState> >::Batch &batch2)
-{
- if (batch1.startBinding != batch2.startBinding)
- return false;
- if (batch1.resources.count() != batch2.resources.count())
- return false;
- if (batch1 != batch2)
- return false;
- return true;
-};
-
void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD,
QMetalCommandBuffer *cbD,
int dynamicOffsetCount,
@@ -1022,12 +982,11 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
const auto &bufferBatch(bindingData.res[stage].bufferBatches.batches[i]);
const auto &offsetBatch(bindingData.res[stage].bufferOffsetBatches.batches[i]);
// skip setting Buffer binding if the current state is already correct
- if (cbD->d->currentShaderResourceBindingState.res[stage].bufferBatches.batches.count() > i &&
- cbD->d->currentShaderResourceBindingState.res[stage].bufferOffsetBatches.batches.count() > i &&
- areBufferBatchesEqual(bufferBatch,
- offsetBatch,
- cbD->d->currentShaderResourceBindingState.res[stage].bufferBatches.batches[i],
- cbD->d->currentShaderResourceBindingState.res[stage].bufferOffsetBatches.batches[i])) {
+ if (cbD->d->currentShaderResourceBindingState.res[stage].bufferBatches.batches.count() > i
+ && cbD->d->currentShaderResourceBindingState.res[stage].bufferOffsetBatches.batches.count() > i
+ && bufferBatch == cbD->d->currentShaderResourceBindingState.res[stage].bufferBatches.batches[i]
+ && offsetBatch == cbD->d->currentShaderResourceBindingState.res[stage].bufferOffsetBatches.batches[i])
+ {
continue;
}
switch (stage) {
@@ -1075,8 +1034,9 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
for (int i = 0, ie = bindingData.res[stage].textureBatches.batches.count(); i != ie; ++i) {
const auto &batch(bindingData.res[stage].textureBatches.batches[i]);
// skip setting Texture binding if the current state is already correct
- if (cbD->d->currentShaderResourceBindingState.res[stage].textureBatches.batches.count() > i &&
- areTextureBatchesEqual(batch, cbD->d->currentShaderResourceBindingState.res[stage].textureBatches.batches[i])) {
+ if (cbD->d->currentShaderResourceBindingState.res[stage].textureBatches.batches.count() > i
+ && batch == cbD->d->currentShaderResourceBindingState.res[stage].textureBatches.batches[i])
+ {
continue;
}
switch (stage) {
@@ -1101,8 +1061,9 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD
for (int i = 0, ie = bindingData.res[stage].samplerBatches.batches.count(); i != ie; ++i) {
const auto &batch(bindingData.res[stage].samplerBatches.batches[i]);
// skip setting Sampler State if the current state is already correct
- if (cbD->d->currentShaderResourceBindingState.res[stage].samplerBatches.batches.count() > i &&
- areSamplerBatchesEqual(batch, cbD->d->currentShaderResourceBindingState.res[stage].samplerBatches.batches[i])) {
+ if (cbD->d->currentShaderResourceBindingState.res[stage].samplerBatches.batches.count() > i
+ && batch == cbD->d->currentShaderResourceBindingState.res[stage].samplerBatches.batches[i])
+ {
continue;
}
switch (stage) {