From 58ddf6aaf0b48109d797ffad7f00acbda818af8f Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 4 Apr 2025 14:56:15 +0200 Subject: [PATCH] r600: fix points clipping This is the backport of eca57f85ee1 ("radeonsi: fix gl_ClipDistance and gl_ClipVertex for points"). This change was tested on rv770, palm, barts and cayman. It fixes 450 khr-gl tests and 64 khr-gles tests on evergreen and cayman gpus. Here is the list: spec/glsl-1.20/execution/clipping/vs-clip-vertex-primitives: fail pass spec/glsl-1.30/execution/clipping/vs-clip-distance-primitives: fail pass spec/glsl-1.50/execution/compatibility/clipping/gs-clip-vertex-primitives-points: fail pass khr-gl(3[0-3]|4[0-5])/clip_distance/functional: fail pass khr-gl(33|4[0-5])/cull_distance/functional_test_item_[0-8]_primitive_mode_points_max_culldist_[0-7]: fail pass khr-gles3/clip_distance/functional: fail pass khr-gles3/cull_distance/functional_test_item_[0-8]_primitive_mode_points_max_culldist_[0-7]: fail pass Cc: mesa-stable Signed-off-by: Patrick Lerda Part-of: --- src/gallium/drivers/r600/r600_state_common.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 113ce14fbdb..7e0682883d5 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -2062,6 +2062,17 @@ void r600_emit_clip_misc_state(struct r600_context *rctx, struct r600_atom *atom { struct radeon_cmdbuf *cs = &rctx->b.gfx.cs; struct r600_clip_misc_state *state = &rctx->clip_misc_state; + unsigned clipdist_mask = state->clip_dist_write; + unsigned culldist_mask = state->cull_dist_write; + + /* Clip distances on points have no effect, so need to be implemented + * as cull distances. This applies for the clipvertex case as well. + * + * Setting this for primitives other than points should have no adverse + * effects. + */ + clipdist_mask &= state->clip_plane_enable; + culldist_mask |= clipdist_mask; radeon_set_context_reg(cs, R_028810_PA_CL_CLIP_CNTL, state->pa_cl_clip_cntl | @@ -2069,8 +2080,8 @@ void r600_emit_clip_misc_state(struct r600_context *rctx, struct r600_atom *atom S_028810_CLIP_DISABLE(state->clip_disable)); radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL, state->pa_cl_vs_out_cntl | - (state->clip_plane_enable & state->clip_dist_write) | - (state->cull_dist_write << 8)); + clipdist_mask | + (culldist_mask << 8)); /* reuse needs to be set off if we write oViewport */ if (rctx->b.gfx_level >= EVERGREEN) radeon_set_context_reg(cs, R_028AB4_VGT_REUSE_OFF,