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>
This commit is contained in:
parent
f49d35084c
commit
09a8283fb6
@ -241,6 +241,7 @@ struct QMetalCommandBufferData
|
|||||||
int currentFirstVertexBinding;
|
int currentFirstVertexBinding;
|
||||||
QRhiBatchedBindings<id<MTLBuffer> > currentVertexInputsBuffers;
|
QRhiBatchedBindings<id<MTLBuffer> > currentVertexInputsBuffers;
|
||||||
QRhiBatchedBindings<NSUInteger> currentVertexInputOffsets;
|
QRhiBatchedBindings<NSUInteger> currentVertexInputOffsets;
|
||||||
|
id<MTLDepthStencilState> currentDepthStencilState;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QMetalRenderTargetData
|
struct QMetalRenderTargetData
|
||||||
@ -1051,7 +1052,11 @@ void QRhiMetal::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
|
|||||||
cbD->currentPipelineGeneration = psD->generation;
|
cbD->currentPipelineGeneration = psD->generation;
|
||||||
|
|
||||||
[cbD->d->currentRenderPassEncoder setRenderPipelineState: psD->d->ps];
|
[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)) {
|
if (cbD->currentCullMode == -1 || psD->d->cullMode != uint(cbD->currentCullMode)) {
|
||||||
[cbD->d->currentRenderPassEncoder setCullMode: psD->d->cullMode];
|
[cbD->d->currentRenderPassEncoder setCullMode: psD->d->cullMode];
|
||||||
@ -3952,6 +3957,7 @@ void QMetalCommandBuffer::resetPerPassCachedState()
|
|||||||
currentFrontFaceWinding = -1;
|
currentFrontFaceWinding = -1;
|
||||||
currentDepthBiasValues = { 0.0f, 0.0f };
|
currentDepthBiasValues = { 0.0f, 0.0f };
|
||||||
|
|
||||||
|
d->currentDepthStencilState = nil;
|
||||||
d->currentFirstVertexBinding = -1;
|
d->currentFirstVertexBinding = -1;
|
||||||
d->currentVertexInputsBuffers.clear();
|
d->currentVertexInputsBuffers.clear();
|
||||||
d->currentVertexInputOffsets.clear();
|
d->currentVertexInputOffsets.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user