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 <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31041>
This commit is contained in:
Lars-Ivar Hesselberg Simonsen 2024-09-05 12:19:23 +02:00 committed by Marge Bot
parent f5dab1b77e
commit 0c18aa996b

View file

@ -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;
}