summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Nichols <nezticle@gmail.com>2022-08-03 20:33:09 +0200
committerAndy Nichols <nezticle@gmail.com>2022-08-09 14:20:08 +0200
commit09a8283fb6b831ed05f580313dd6857ee3a94e8d (patch)
treed7a12be4f28aec5f6e7cdb86f64b70c7305b8807 /src
parentf49d35084c90aeec910cb6f37aeceba8c4194ca5 (diff)
RHI: Reduce redundant MTLDepthStencilState changes
The metal profiler reports many redundant state changes of MTLDepthStencilState which can be reduced by checking if the current depthStencilState is the same as already set before setting it again. Pick-to: 6.4 Change-Id: Ie14f0491ad2cb1c3ce13c1cf3992d06561fbb826 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/rhi/qrhimetal.mm8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index 186fca63d7..3aec160c74 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -241,6 +241,7 @@ struct QMetalCommandBufferData
int currentFirstVertexBinding;
QRhiBatchedBindings<id<MTLBuffer> > currentVertexInputsBuffers;
QRhiBatchedBindings<NSUInteger> currentVertexInputOffsets;
+ id<MTLDepthStencilState> currentDepthStencilState;
};
struct QMetalRenderTargetData
@@ -1051,7 +1052,11 @@ void QRhiMetal::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
cbD->currentPipelineGeneration = psD->generation;
[cbD->d->currentRenderPassEncoder setRenderPipelineState: psD->d->ps];
- [cbD->d->currentRenderPassEncoder setDepthStencilState: psD->d->ds];
+
+ if (cbD->d->currentDepthStencilState != psD->d->ds) {
+ [cbD->d->currentRenderPassEncoder setDepthStencilState: psD->d->ds];
+ cbD->d->currentDepthStencilState = psD->d->ds;
+ }
if (cbD->currentCullMode == -1 || psD->d->cullMode != uint(cbD->currentCullMode)) {
[cbD->d->currentRenderPassEncoder setCullMode: psD->d->cullMode];
@@ -3952,6 +3957,7 @@ void QMetalCommandBuffer::resetPerPassCachedState()
currentFrontFaceWinding = -1;
currentDepthBiasValues = { 0.0f, 0.0f };
+ d->currentDepthStencilState = nil;
d->currentFirstVertexBinding = -1;
d->currentVertexInputsBuffers.clear();
d->currentVertexInputOffsets.clear();