v3dv: disable depth/stencil testing if we don't have a depth/stencil attachment
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 19 Mar 2020 09:45:12 +0000 (10:45 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:28 +0000 (21:21 +0000)
Also, remove obsolete FIXME.

Fixes:
dEQP-VK.fragment_operations.early_fragment.early_fragment_tests_stencil_no_attachment

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_pipeline.c

index e2860d4..eab5559 100644 (file)
@@ -1437,11 +1437,13 @@ pack_cfg_bits(struct v3dv_pipeline *pipeline,
 
       config.blend_enable = pipeline->blend.enables != 0;
 
-      /* Note: ez state may update based on the compiled FS, along with zsa
-       * (FIXME: not done)
-       */
+      /* Disable depth/stencil if we don't have a D/S attachment */
+      bool has_ds_attachment =
+         pipeline->subpass->ds_attachment.attachment != VK_ATTACHMENT_UNUSED;
+
+      /* Note: ez state may update based on the compiled FS, along with zsa */
       config.early_z_updates_enable = false;
-      if (ds_info && ds_info->depthTestEnable) {
+      if (ds_info && ds_info->depthTestEnable && has_ds_attachment) {
          config.z_updates_enable = true;
          config.early_z_enable = false;
          config.depth_test_function = ds_info->depthCompareOp;
@@ -1449,7 +1451,8 @@ pack_cfg_bits(struct v3dv_pipeline *pipeline,
          config.depth_test_function = VK_COMPARE_OP_ALWAYS;
       }
 
-      config.stencil_enable = ds_info ? ds_info->stencilTestEnable : false;
+      config.stencil_enable =
+         ds_info ? ds_info->stencilTestEnable && has_ds_attachment: false;
    };
 }
 
@@ -1534,6 +1537,9 @@ pack_stencil_cfg(struct v3dv_pipeline *pipeline,
    if (!ds_info || !ds_info->stencilTestEnable)
       return;
 
+   if (pipeline->subpass->ds_attachment.attachment == VK_ATTACHMENT_UNUSED)
+      return;
+
    const uint32_t dynamic_stencil_states = V3DV_DYNAMIC_STENCIL_COMPARE_MASK |
                                            V3DV_DYNAMIC_STENCIL_WRITE_MASK |
                                            V3DV_DYNAMIC_STENCIL_REFERENCE;