Revert "nir: Add a type parameter to nir_lower_point_size()"

This reverts commit 6ee4ea5ea3.

Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Acked-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38681>
This commit is contained in:
Faith Ekstrand 2025-12-04 11:50:51 -05:00 committed by Marge Bot
parent 88cce35415
commit f2f792996d
11 changed files with 22 additions and 48 deletions

View file

@ -1048,7 +1048,7 @@ hk_lower_hw_vs(nir_shader *nir, struct hk_shader *shader, bool kill_psiz)
*
* Must be synced with pointSizeRange.
*/
NIR_PASS(_, nir, nir_lower_point_size, 1.0f, 511.95f, nir_type_invalid);
NIR_PASS(_, nir, nir_lower_point_size, 1.0f, 511.95f);
if (kill_psiz) {
NIR_PASS(_, nir, nir_shader_intrinsics_pass, kill_psiz_write,

View file

@ -1036,7 +1036,7 @@ v3d_nir_lower_vs_early(struct v3d_compile *c)
/* This must go before nir_lower_io */
if (c->vs_key->per_vertex_point_size)
NIR_PASS(_, c->s, nir_lower_point_size, 1.0f, 0.0f, nir_type_invalid);
NIR_PASS(_, c->s, nir_lower_point_size, 1.0f, 0.0f);
NIR_PASS(_, c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
type_size_vec4,
@ -1079,7 +1079,7 @@ v3d_nir_lower_gs_early(struct v3d_compile *c)
/* This must go before nir_lower_io */
if (c->gs_key->per_vertex_point_size)
NIR_PASS(_, c->s, nir_lower_point_size, 1.0f, 0.0f, nir_type_invalid);
NIR_PASS(_, c->s, nir_lower_point_size, 1.0f, 0.0f);
NIR_PASS(_, c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
type_size_vec4,

View file

@ -6356,8 +6356,7 @@ typedef struct nir_tex_src_type_constraint {
bool nir_legalize_16bit_sampler_srcs(nir_shader *nir,
nir_tex_src_type_constraints constraints);
bool nir_lower_point_size(nir_shader *shader, float min, float max,
nir_alu_type type);
bool nir_lower_point_size(nir_shader *shader, float min, float max);
bool nir_lower_default_point_size(nir_shader *nir);

View file

@ -23,12 +23,6 @@
#include "nir_builder.h"
struct lower_point_size_options {
float min;
float max;
nir_alu_type type;
};
/** @file nir_lower_point_size.c
*
* The OpenGL spec requires that implementations clamp gl_PointSize to an
@ -41,7 +35,7 @@ struct lower_point_size_options {
static bool
lower_point_size_intrin(nir_builder *b, nir_intrinsic_instr *intr, void *data)
{
const struct lower_point_size_options *opts = data;
float *minmax = (float *)data;
gl_varying_slot location = VARYING_SLOT_MAX;
nir_src *psiz_src;
@ -68,22 +62,11 @@ lower_point_size_intrin(nir_builder *b, nir_intrinsic_instr *intr, void *data)
nir_def *psiz = psiz_src->ssa;
assert(psiz->num_components == 1);
if (opts->min > 0.0f)
psiz = nir_fmax(b, psiz, nir_imm_float(b, opts->min));
if (minmax[0] > 0.0f)
psiz = nir_fmax(b, psiz, nir_imm_float(b, minmax[0]));
if (opts->max > 0.0f)
psiz = nir_fmin(b, psiz, nir_imm_float(b, opts->max));
if (opts->type != nir_type_invalid) {
/* Currently only supported for lowered I/O */
assert(intr->intrinsic != nir_intrinsic_store_deref);
nir_alu_type old_type = nir_intrinsic_src_type(intr);
if (old_type != opts->type) {
psiz = nir_type_convert(b, psiz, old_type, opts->type,
nir_rounding_mode_undef);
nir_intrinsic_set_src_type(intr, opts->type);
}
}
if (minmax[1] > 0.0f)
psiz = nir_fmin(b, psiz, nir_imm_float(b, minmax[1]));
nir_src_rewrite(psiz_src, psiz);
@ -92,13 +75,10 @@ lower_point_size_intrin(nir_builder *b, nir_intrinsic_instr *intr, void *data)
/**
* Clamps gl_PointSize to the range [min, max]. If either min or max are not
* greater than 0 then no clamping is done for that side of the range. If
* type is not nir_type_invalid, the value is converted and the type on the
* store is updated accordingly.
* greater than 0 then no clamping is done for that side of the range.
*/
bool
nir_lower_point_size(nir_shader *s, float min, float max,
nir_alu_type type)
nir_lower_point_size(nir_shader *s, float min, float max)
{
assert(s->info.stage != MESA_SHADER_FRAGMENT &&
s->info.stage != MESA_SHADER_COMPUTE);
@ -106,14 +86,10 @@ nir_lower_point_size(nir_shader *s, float min, float max,
assert(min > 0.0f || max > 0.0f);
assert(min <= 0.0f || max <= 0.0f || min <= max);
struct lower_point_size_options options = {
.min = min,
.max = max,
.type = type,
};
float minmax[] = { min, max };
return nir_shader_intrinsics_pass(s, lower_point_size_intrin,
nir_metadata_control_flow,
&options);
minmax);
}
/*

View file

@ -1189,7 +1189,7 @@ crocus_compile_vs(struct crocus_context *ice,
}
if (key->clamp_pointsize)
nir_lower_point_size(nir, 1.0, 255.0, nir_type_invalid);
nir_lower_point_size(nir, 1.0, 255.0);
prog_data->use_alt_mode = nir->info.use_legacy_math_rules;
@ -1548,7 +1548,7 @@ crocus_compile_tes(struct crocus_context *ice,
}
if (key->clamp_pointsize)
nir_lower_point_size(nir, 1.0, 255.0, nir_type_invalid);
nir_lower_point_size(nir, 1.0, 255.0);
crocus_setup_uniforms(devinfo, mem_ctx, nir, prog_data, &system_values,
&num_system_values, &num_cbufs);
@ -1691,7 +1691,7 @@ crocus_compile_gs(struct crocus_context *ice,
}
if (key->clamp_pointsize)
nir_lower_point_size(nir, 1.0, 255.0, nir_type_invalid);
nir_lower_point_size(nir, 1.0, 255.0);
crocus_setup_uniforms(devinfo, mem_ctx, nir, prog_data, &system_values,
&num_system_values, &num_cbufs);

View file

@ -673,7 +673,7 @@ i915_create_vs_state(struct pipe_context *pipe,
if (templ->type == PIPE_SHADER_IR_NIR) {
nir_shader *s = templ->ir.nir;
NIR_PASS(_, s, nir_lower_point_size, 1.0, 255.0, nir_type_invalid);
NIR_PASS(_, s, nir_lower_point_size, 1.0, 255.0);
/* The gallivm draw path doesn't support non-native-integers NIR shaders,
* st/mesa does native-integers for the screen as a whole rather than

View file

@ -114,7 +114,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
bool progress;
NIR_PASS(_, s, nir_lower_viewport_transform);
NIR_PASS(_, s, nir_lower_point_size, 1.0f, 100.0f, nir_type_invalid);
NIR_PASS(_, s, nir_lower_point_size, 1.0f, 100.0f);
NIR_PASS(_, s, nir_lower_io,
nir_var_shader_in | nir_var_shader_out, type_size, 0);
NIR_PASS(_, s, nir_lower_load_const_to_scalar);

View file

@ -2507,7 +2507,7 @@ vc4_shader_state_create(struct pipe_context *pctx,
}
if (s->info.stage == MESA_SHADER_VERTEX)
NIR_PASS(_, s, nir_lower_point_size, 1.0f, 0.0f, nir_type_invalid);
NIR_PASS(_, s, nir_lower_point_size, 1.0f, 0.0f);
NIR_PASS(_, s, nir_lower_io,
nir_var_shader_in | nir_var_shader_out | nir_var_uniform,

View file

@ -922,8 +922,7 @@ void pco_lower_nir(pco_ctx *ctx, nir_shader *nir, pco_data *data)
nir,
nir_lower_point_size,
PVR_POINT_SIZE_RANGE_MIN,
PVR_POINT_SIZE_RANGE_MAX,
nir_type_invalid);
PVR_POINT_SIZE_RANGE_MAX);
if (!nir->info.internal)
NIR_PASS(_, nir, pco_nir_point_size);

View file

@ -6280,7 +6280,7 @@ bifrost_postprocess_nir(nir_shader *nir, unsigned gpu_id)
NIR_PASS(_, nir, bifrost_nir_lower_load_output);
} else if (nir->info.stage == MESA_SHADER_VERTEX) {
NIR_PASS(_, nir, nir_lower_viewport_transform);
NIR_PASS(_, nir, nir_lower_point_size, 1.0, 0.0, nir_type_float32);
NIR_PASS(_, nir, nir_lower_point_size, 1.0, 0.0);
NIR_PASS(_, nir, pan_nir_lower_noperspective_vs);
/* nir_lower[_explicit]_io is lazy and emits mul+add chains even

View file

@ -387,7 +387,7 @@ midgard_postprocess_nir(nir_shader *nir, UNUSED unsigned gpu_id)
if (nir->info.stage == MESA_SHADER_VERTEX) {
NIR_PASS(_, nir, nir_lower_viewport_transform);
NIR_PASS(_, nir, nir_lower_point_size, 1.0, 0.0, nir_type_invalid);
NIR_PASS(_, nir, nir_lower_point_size, 1.0, 0.0);
/* nir_lower[_explicit]_io is lazy and emits mul+add chains even
* for offsets it could figure out are constant. Do some