From 817038e8d876c7e84464181399346020739d8bf2 Mon Sep 17 00:00:00 2001 From: Malcolm Bechard's MacMini M1 Date: Tue, 18 Jul 2023 20:19:23 -0400 Subject: [PATCH] Fix regression caused by #1922 Needed to complete fix for #1874 We can't wait until getMTLComputeEncoder() is called to dirty the state, because this call will be avoided by dirty checks themselves. Those checks are comparing against leftover and now incorrect state since the previous encoder has already ended. It needs to be dirtied on encoder end. --- MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm index a58d6457..5edc13aa 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm @@ -839,6 +839,10 @@ void MVKCommandEncoder::endMetalRenderEncoding() { void MVKCommandEncoder::endCurrentMetalEncoding() { endMetalRenderEncoding(); + _computePipelineState.markDirty(); + _computePushConstants.markDirty(); + _computeResourcesState.markDirty(); + if (_mtlComputeEncoder && _cmdBuffer->_hasStageCounterTimestampCommand) { [_mtlComputeEncoder updateFence: getStageCountersMTLFence()]; } endMetalEncoding(_mtlComputeEncoder); _mtlComputeEncoderUse = kMVKCommandUseNone; @@ -856,7 +860,7 @@ id MVKCommandEncoder::getMTLComputeEncoder(MVKCommandU _mtlComputeEncoder = [_mtlCmdBuffer computeCommandEncoder]; retainIfImmediatelyEncoding(_mtlComputeEncoder); beginMetalComputeEncoding(cmdUse); - markCurrentComputeStateDirty = true; // Always mark current compute state dirty for new encoder + markCurrentComputeStateDirty = false; // Already marked dirty above in endCurrentMetalEncoding() } if(markCurrentComputeStateDirty) { _computePipelineState.markDirty();