Use empty depth state for tessellation vertex pre-pass.
diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm b/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm
index 88d88a8..5ba285d 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm
@@ -115,6 +115,8 @@
}
for (uint32_t s : stages) {
auto stage = MVKGraphicsStage(s);
+ if (stage == kMVKGraphicsStageVertex)
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->finalizeDrawState(stage); // Ensure all updated state has been submitted to Metal
id<MTLComputeCommandEncoder> mtlTessCtlEncoder = nil;
@@ -150,6 +152,7 @@
// so I apply them during the next stage.
cmdEncoder->_graphicsPipelineState.beginMetalRenderPass();
cmdEncoder->_graphicsResourcesState.beginMetalRenderPass();
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->getPushConstants(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)->beginMetalRenderPass();
break;
case kMVKGraphicsStageTessControl:
@@ -343,6 +346,8 @@
atIndex: 4];
[mtlTessCtlEncoder dispatchThreadgroups: MTLSizeMake(1, 1, 1) threadsPerThreadgroup: MTLSizeMake(1, 1, 1)];
}
+ if (stage == kMVKGraphicsStageVertex)
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->finalizeDrawState(stage); // Ensure all updated state has been submitted to Metal
switch (stage) {
@@ -380,6 +385,7 @@
// so I apply them during the next stage.
cmdEncoder->_graphicsPipelineState.beginMetalRenderPass();
cmdEncoder->_graphicsResourcesState.beginMetalRenderPass();
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->getPushConstants(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)->beginMetalRenderPass();
break;
case kMVKGraphicsStageTessControl:
@@ -610,6 +616,8 @@
threadsPerThreadgroup: MTLSizeMake(mtlConvertState.threadExecutionWidth, 1, 1)];
}
+ if (stage == kMVKGraphicsStageVertex)
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->finalizeDrawState(stage); // Ensure all updated state has been submitted to Metal
switch (stage) {
@@ -630,6 +638,7 @@
// so I apply them during the next stage.
cmdEncoder->_graphicsPipelineState.beginMetalRenderPass();
cmdEncoder->_graphicsResourcesState.beginMetalRenderPass();
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->getPushConstants(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)->beginMetalRenderPass();
break;
case kMVKGraphicsStageTessControl:
@@ -857,6 +866,8 @@
[mtlTessCtlEncoder dispatchThreadgroups: MTLSizeMake(1, 1, 1) threadsPerThreadgroup: MTLSizeMake(1, 1, 1)];
}
+ if (stage == kMVKGraphicsStageVertex)
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->finalizeDrawState(stage); // Ensure all updated state has been submitted to Metal
switch (stage) {
@@ -880,6 +891,7 @@
// so I apply them during the next stage.
cmdEncoder->_graphicsPipelineState.beginMetalRenderPass();
cmdEncoder->_graphicsResourcesState.beginMetalRenderPass();
+ cmdEncoder->_depthStencilState.markDirty();
cmdEncoder->getPushConstants(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)->beginMetalRenderPass();
break;
case kMVKGraphicsStageTessControl:
diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
index cd5ef52..b671f79 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandEncoderState.mm
@@ -277,10 +277,10 @@
}
void MVKDepthStencilCommandEncoderState::encodeImpl(uint32_t stage) {
- if (stage != kMVKGraphicsStageRasterization) { return; }
+ if (stage != kMVKGraphicsStageRasterization && stage != kMVKGraphicsStageVertex) { return; }
MVKRenderSubpass *subpass = _cmdEncoder->getSubpass();
id<MTLDepthStencilState> mtlDSS = nil;
- if (subpass->getDepthStencilFormat() != VK_FORMAT_UNDEFINED) {
+ if (stage != kMVKGraphicsStageVertex && subpass->getDepthStencilFormat() != VK_FORMAT_UNDEFINED) {
mtlDSS = _cmdEncoder->getCommandEncodingPool()->getMTLDepthStencilState(_depthStencilData);
} else {
// If there is no depth attachment but the depth/stencil state contains a non-always depth