From 0c18aa996b31f4cc385c1798d8775ec168ed2967 Mon Sep 17 00:00:00 2001 From: Lars-Ivar Hesselberg Simonsen Date: Thu, 5 Sep 2024 12:19:23 +0200 Subject: [PATCH] panfrost: Enable support for depth clamping Depth clamping was not enabled in panfrost, leading to the fixed range [0.0, 1.0] always being used. This commit sets the bits to enable depth clamp to near/far plane depending on the passed rasterizer state. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11506 Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index f2c212c6d5e..0715841da31 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -805,6 +805,9 @@ panfrost_emit_depth_stencil(struct panfrost_batch *batch) assert(rast->base.depth_clip_near == rast->base.depth_clip_far); cfg.depth_cull_enable = rast->base.depth_clip_near; + cfg.depth_clamp_mode = rast->base.depth_clamp + ? MALI_DEPTH_CLAMP_MODE_BOUNDS + : MALI_DEPTH_CLAMP_MODE_0_1; } pan_merge(dynamic, zsa->desc, DEPTH_STENCIL); @@ -3323,6 +3326,7 @@ panfrost_create_rasterizer_state(struct pipe_context *pctx, cfg.multisample_enable = cso->multisample; cfg.fixed_function_near_discard = cso->depth_clip_near; cfg.fixed_function_far_discard = cso->depth_clip_far; + cfg.fixed_function_depth_range_fixed = !cso->depth_clamp; cfg.shader_depth_range_fixed = true; }