Mesa (main): zink: Always enable depth clamping, make depth clipping independent.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 21 16:23:05 UTC 2022


Module: Mesa
Branch: main
Commit: 21ea19d504bb96aea9f218fe6bfa5a9a40a72eb9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=21ea19d504bb96aea9f218fe6bfa5a9a40a72eb9

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Wed Jun  8 18:26:16 2022 +0200

zink: Always enable depth clamping, make depth clipping independent.

Enabling depth clamping ensures that the Vulkan driver respects
the depth range that zink sets on viewport objects in zink_draw.

When depth clipping is required, use VK_EXT_depth_clip_enable to
enable that independently of depth clamping.

Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16929>

---

 src/gallium/drivers/zink/ci/zink-radv-fails.txt |  8 --------
 src/gallium/drivers/zink/zink_pipeline.c        | 13 ++++++++++++-
 src/gallium/drivers/zink/zink_state.c           |  2 +-
 src/gallium/drivers/zink/zink_state.h           |  2 +-
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/zink/ci/zink-radv-fails.txt b/src/gallium/drivers/zink/ci/zink-radv-fails.txt
index a2af3511ba9..696657832f2 100644
--- a/src/gallium/drivers/zink/ci/zink-radv-fails.txt
+++ b/src/gallium/drivers/zink/ci/zink-radv-fails.txt
@@ -109,14 +109,6 @@ dEQP-GLES3.functional.draw_buffers_indexed.overwrite_common.common_separate_blen
 dEQP-GLES3.functional.draw_buffers_indexed.overwrite_indexed.common_advanced_blend_eq_buffer_advanced_blend_eq,Fail
 dEQP-GLES3.functional.draw_buffers_indexed.overwrite_indexed.common_advanced_blend_eq_buffer_blend_eq,Fail
 dEQP-GLES3.functional.draw_buffers_indexed.overwrite_indexed.common_advanced_blend_eq_buffer_separate_blend_eq,Fail
-dEQP-GLES3.functional.fbo.depth.depth_test_clamp.depth24_stencil8,Fail
-dEQP-GLES3.functional.fbo.depth.depth_test_clamp.depth32f_stencil8,Fail
-dEQP-GLES3.functional.fbo.depth.depth_test_clamp.depth_component24,Fail
-dEQP-GLES3.functional.fbo.depth.depth_test_clamp.depth_component32f,Fail
-dEQP-GLES3.functional.fbo.depth.depth_write_clamp.depth24_stencil8,Fail
-dEQP-GLES3.functional.fbo.depth.depth_write_clamp.depth32f_stencil8,Fail
-dEQP-GLES3.functional.fbo.depth.depth_write_clamp.depth_component24,Fail
-dEQP-GLES3.functional.fbo.depth.depth_write_clamp.depth_component32f,Fail
 dEQP-GLES3.functional.rasterization.primitives.line_loop_wide,Fail
 dEQP-GLES3.functional.rasterization.primitives.line_strip_wide,Fail
 dEQP-GLES3.functional.shaders.metamorphic.bubblesort_flag.variant_1,Fail
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 0c5257631a0..a4f78b4eaec 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -170,7 +170,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    VkPipelineRasterizationStateCreateInfo rast_state = {0};
    rast_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
 
-   rast_state.depthClampEnable = hw_rast_state->depth_clamp;
+   rast_state.depthClampEnable = true;
    rast_state.rasterizerDiscardEnable = state->dyn_state2.rasterizer_discard;
    rast_state.polygonMode = hw_rast_state->polygon_mode;
    rast_state.cullMode = state->dyn_state1.cull_mode;
@@ -182,6 +182,17 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    rast_state.depthBiasSlopeFactor = 0.0;
    rast_state.lineWidth = 1.0f;
 
+   VkPipelineRasterizationDepthClipStateCreateInfoEXT depth_clip_state = {0};
+   depth_clip_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT;
+   depth_clip_state.depthClipEnable = hw_rast_state->depth_clip;
+   if (screen->info.have_EXT_depth_clip_enable) {
+      depth_clip_state.pNext = rast_state.pNext;
+      rast_state.pNext = &depth_clip_state;
+   } else {
+      static bool warned = false;
+      warn_missing_feature(warned, "VK_EXT_depth_clip_enable");
+   }
+
    VkPipelineRasterizationProvokingVertexStateCreateInfoEXT pv_state;
    pv_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT;
    pv_state.provokingVertexMode = hw_rast_state->pv_last ?
diff --git a/src/gallium/drivers/zink/zink_state.c b/src/gallium/drivers/zink/zink_state.c
index 4cf441c094c..c6c19602c78 100644
--- a/src/gallium/drivers/zink/zink_state.c
+++ b/src/gallium/drivers/zink/zink_state.c
@@ -578,7 +578,7 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
    state->hw_state.line_stipple_enable = rs_state->line_stipple_enable;
 
    assert(rs_state->depth_clip_far == rs_state->depth_clip_near);
-   state->hw_state.depth_clamp = rs_state->depth_clip_near == 0;
+   state->hw_state.depth_clip = rs_state->depth_clip_near;
    state->hw_state.force_persample_interp = rs_state->force_persample_interp;
    state->hw_state.pv_last = !rs_state->flatshade_first;
    state->hw_state.clip_halfz = rs_state->clip_halfz;
diff --git a/src/gallium/drivers/zink/zink_state.h b/src/gallium/drivers/zink/zink_state.h
index c4c425467d5..2efc4fb2cb6 100644
--- a/src/gallium/drivers/zink/zink_state.h
+++ b/src/gallium/drivers/zink/zink_state.h
@@ -70,7 +70,7 @@ struct zink_vertex_state {
 struct zink_rasterizer_hw_state {
    unsigned polygon_mode : 2; //VkPolygonMode
    unsigned line_mode : 2; //VkLineRasterizationModeEXT
-   unsigned depth_clamp:1;
+   unsigned depth_clip:1;
    unsigned pv_last:1;
    unsigned line_stipple_enable:1;
    unsigned force_persample_interp:1;



More information about the mesa-commit mailing list