From 011d10fe264a9e7fbeaaa537f987d9ed0c830763 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 11 Aug 2022 14:08:34 +0200 Subject: rhi: metal: Simplify batch comparisons Change-Id: I9d61ce3f2e8501a854e070a83cd748928129e76d Reviewed-by: Andy Nichols --- src/gui/rhi/qrhimetal.mm | 61 +++++++++--------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) (limited to 'src/gui/rhi/qrhimetal.mm') 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 >::Batch &batch1, - const QRhiBatchedBindings::Batch &offsetBatch1, - const QRhiBatchedBindings >::Batch &batch2, - const QRhiBatchedBindings::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 >::Batch &batch1, - const QRhiBatchedBindings >::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 >::Batch &batch1, - const QRhiBatchedBindings >::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) { -- cgit v1.2.3