Mesa (wip/tgl-depth-bounds-test): anv: Add support for depth bounds testing.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 23 21:12:37 UTC 2019


Module: Mesa
Branch: wip/tgl-depth-bounds-test
Commit: f2b6f254629a65206121970ada68b338b46d280a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2b6f254629a65206121970ada68b338b46d280a

Author: Plamena Manolova <plamena.manolova at intel.com>
Date:   Wed Oct 23 20:59:02 2019 +0100

anv: Add support for depth bounds testing.

In gen12 we use the 3DSTATE_DEPTH_BOUNDS instruction
to enable depth bounds testing.

Signed-off-by: Plamena Manolova <plamena.manolova at intel.com>

---

 src/intel/vulkan/anv_private.h     |  4 ++++
 src/intel/vulkan/gen8_cmd_buffer.c | 19 +++++++++++++++++++
 src/intel/vulkan/genX_pipeline.c   | 20 ++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index aa1f2cbea87..f6d47463a67 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2898,6 +2898,10 @@ struct anv_pipeline {
       uint32_t                                  wm_depth_stencil[4];
    } gen9;
 
+   struct {
+      uint32_t                                  depth_bounds[4];
+   } gen12;
+
    uint32_t                                     interface_descriptor_data[8];
 };
 
diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c
index e4f0c1410fb..e4497ac7b9f 100644
--- a/src/intel/vulkan/gen8_cmd_buffer.c
+++ b/src/intel/vulkan/gen8_cmd_buffer.c
@@ -542,6 +542,25 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer)
    }
 #endif
 
+#if GEN_GEN >= 12
+   if(cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_DEPTH_BOUNDS) {
+      uint32_t dwords[GENX(3DSTATE_DEPTH_BOUNDS_length)];
+      struct GENX(3DSTATE_DEPTH_BOUNDS) depth_bounds = {
+         GENX(3DSTATE_DEPTH_BOUNDS_header),
+         .DepthBoundsTestValueModifyDisable = false,
+         .DepthBoundsTestEnableModifyDisable = false,
+         .DepthBoundsTestEnable = pipeline->depth_test_enable,
+         .DepthBoundsTestMinValue = d->depth_bounds.min,
+         .DepthBoundsTestMaxValue = d->depth_bounds.max,
+      };
+
+      GENX(3DSTATE_DEPTH_BOUNDS_pack)(NULL, dwords, &depth_bounds);
+
+      anv_batch_emit_merge(&cmd_buffer->batch, dwords,
+                           pipeline->gen12.depth_bounds);
+   }
+#endif
+
    if (cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_DYNAMIC_LINE_STIPPLE) {
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_LINE_STIPPLE), ls) {
          ls.LineStipplePattern = d->line_stipple.pattern;
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 88f5b358faf..e6eda2371e3 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -997,6 +997,10 @@ emit_ds_state(struct anv_pipeline *pipeline,
 #  define depth_stencil_dw pipeline->gen9.wm_depth_stencil
 #endif
 
+#if GEN_GEN >= 12
+#  define depth_bounds_dw pipeline->gen12.depth_bounds
+#endif
+
    if (pCreateInfo == NULL) {
       /* We're going to OR this together with the dynamic state.  We need
        * to make sure it's initialized to something useful.
@@ -1006,6 +1010,9 @@ emit_ds_state(struct anv_pipeline *pipeline,
       pipeline->writes_depth = false;
       pipeline->depth_test_enable = false;
       memset(depth_stencil_dw, 0, sizeof(depth_stencil_dw));
+#if GEN_GEN >= 12
+      memset(depth_bounds_dw, 0, sizeof(depth_bounds_dw));
+#endif
       return;
    }
 
@@ -1050,6 +1057,19 @@ emit_ds_state(struct anv_pipeline *pipeline,
 #else
    GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, depth_stencil_dw, &depth_stencil);
 #endif
+
+#if GEN_GEN >= 12
+   struct GENX(3DSTATE_DEPTH_BOUNDS) depth_bounds = {
+      GENX(3DSTATE_DEPTH_BOUNDS_header),
+      .DepthBoundsTestValueModifyDisable = false,
+      .DepthBoundsTestEnableModifyDisable = false,
+      .DepthBoundsTestEnable = info.depthBoundsTestEnable,
+      .DepthBoundsTestMinValue = info.minDepthBounds,
+      .DepthBoundsTestMaxValue = info.maxDepthBounds,
+   };
+
+   GENX(3DSTATE_DEPTH_BOUNDS_pack)(NULL, depth_bounds_dw, &depth_bounds);
+#endif
 }
 
 static bool




More information about the mesa-commit mailing list