[Mesa-dev] [PATCH] anv: Fix sanitization of stencil state when the depth test is disabled

Alex Smith asmith at feralinteractive.com
Thu Oct 25 10:24:34 UTC 2018


When depth testing is disabled, we shouldn't pay attention to the
specified depthCompareOp, and just treat it as always passing. Before,
if the depth test is disabled, but depthCompareOp is VK_COMPARE_OP_NEVER
(e.g. from the app having zero-initialized the structure), then
sanitize_stencil_face() would have incorrectly changed passOp to
VK_STENCIL_OP_KEEP.

Signed-off-by: Alex Smith <asmith at feralinteractive.com>
---
 src/intel/vulkan/genX_pipeline.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 33f1f7832a..877a9fb850 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -755,9 +755,13 @@ sanitize_ds_state(VkPipelineDepthStencilStateCreateInfo *state,
 {
    *stencilWriteEnable = state->stencilTestEnable;
 
-   /* If the depth test is disabled, we won't be writing anything. */
-   if (!state->depthTestEnable)
+   /* If the depth test is disabled, we won't be writing anything. Make sure
+    * we treat it as always passing later on as well.
+    */
+   if (!state->depthTestEnable) {
       state->depthWriteEnable = false;
+      state->depthCompareOp = VK_COMPARE_OP_ALWAYS;
+   }
 
    /* The Vulkan spec requires that if either depth or stencil is not present,
     * the pipeline is to act as if the test silently passes.
-- 
2.14.4



More information about the mesa-dev mailing list