v3d: Stop advertising support for HW clip planes.

The GL frontend is perfectly good at lowering it like we do.  Cuts out a
bunch of duplicate code.

We still have ucp_enables for the FS due to lowering of CLIPDIST to
discards in the FS.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8953>
This commit is contained in:
Emma Anholt
2025-06-18 14:59:07 -07:00
committed by Marge Bot
parent 211e03d026
commit eae86f455c
9 changed files with 31 additions and 76 deletions
-9
View File
@@ -3536,15 +3536,6 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr)
nir_src_comp_as_uint(instr->src[0], 0)));
break;
case nir_intrinsic_load_user_clip_plane:
for (int i = 0; i < nir_intrinsic_dest_components(instr); i++) {
ntq_store_def(c, &instr->def, i,
vir_uniform(c, QUNIFORM_USER_CLIP_PLANE,
nir_intrinsic_ucp_id(instr) *
4 + i));
}
break;
case nir_intrinsic_load_viewport_x_scale:
ntq_store_def(c, &instr->def, 0,
vir_uniform(c, QUNIFORM_VIEWPORT_X_SCALE, 0));
+1 -3
View File
@@ -205,8 +205,6 @@ enum quniform_contents {
QUNIFORM_VIEWPORT_Z_OFFSET,
QUNIFORM_VIEWPORT_Z_SCALE,
QUNIFORM_USER_CLIP_PLANE,
/**
* A reference to a V3D 3.x texture config parameter 0 uniform.
*
@@ -414,7 +412,6 @@ struct v3d_key {
*/
uint32_t sampler_is_32b;
uint8_t ucp_enables;
bool is_last_geometry_stage;
bool robust_uniform_access;
bool robust_storage_access;
@@ -437,6 +434,7 @@ struct v3d_fs_key {
uint8_t swap_color_rb;
/* Mask of which render targets need to be written as 32-bit floats */
uint8_t f32_color_rb;
uint8_t ucp_enables;
/* Color format information per render target. Only set when logic
* operations are enabled, when fbfetch is in use or when falling back
+10 -22
View File
@@ -1119,41 +1119,29 @@ v3d_nir_lower_fs_early(struct v3d_compile *c)
static void
v3d_nir_lower_gs_late(struct v3d_compile *c)
{
if (c->key->ucp_enables) {
NIR_PASS(_, c->s, nir_lower_clip_gs, c->key->ucp_enables,
true, NULL);
}
/* Note: GS output scalarizing must happen after nir_lower_clip_gs. */
NIR_PASS(_, c->s, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL);
}
static void
v3d_nir_lower_vs_late(struct v3d_compile *c)
{
if (c->key->ucp_enables) {
NIR_PASS(_, c->s, nir_lower_clip_vs, c->key->ucp_enables,
false, true, NULL);
NIR_PASS(_, c->s, nir_lower_io_to_scalar,
nir_var_shader_out, NULL, NULL);
}
/* Note: VS output scalarizing must happen after nir_lower_clip_vs. */
NIR_PASS(_, c->s, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL);
}
static void
v3d_nir_lower_fs_late(struct v3d_compile *c)
{
/* In OpenGL the fragment shader can't read gl_ClipDistance[], but
* Vulkan allows it, in which case the SPIR-V compiler will declare
* VARING_SLOT_CLIP_DIST0 as compact array variable. Pass true as
* the last parameter to always operate with a compact array in both
* OpenGL and Vulkan so we do't have to care about the API we
* are using.
/* If there are clip distance writes (either GL/Vulkan
* gl_ClipDistance[], or lowered user clip planes for desktop GL),
* then we need to emit the discards for them at the top of the fragment
* shader.
*
* The SPIR-V compiler will declare VARING_SLOT_CLIP_DIST0 as compact
* array variable, so we have GL's clip lowering follow suit
* (PIPE_CAP_NIR_COMPACT_ARRAYS).
*/
if (c->key->ucp_enables)
NIR_PASS(_, c->s, nir_lower_clip_fs, c->key->ucp_enables, true, false);
if (c->fs_key->ucp_enables)
NIR_PASS(_, c->s, nir_lower_clip_fs, c->fs_key->ucp_enables, true, false);
NIR_PASS(_, c->s, nir_lower_io_to_scalar, nir_var_shader_in, NULL, NULL);
}