glsl: move PositionAlwaysInvariant/Precise options to gl_constants

They are only set for 1 shader stage.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36582>
This commit is contained in:
Marek Olšák 2025-08-05 15:16:17 -04:00
parent a489fd32f0
commit 10b7f0e95d
4 changed files with 14 additions and 17 deletions

View file

@ -1543,9 +1543,6 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type,
void
builtin_variable_generator::generate_varyings()
{
const struct gl_shader_compiler_options *options =
&state->consts->ShaderCompilerOptions[state->stage];
/* gl_Position and gl_PointSize are not visible from fragment shaders. */
if (state->stage != MESA_SHADER_FRAGMENT) {
add_varying(VARYING_SLOT_POS, vec4_t, GLSL_PRECISION_HIGH, "gl_Position");
@ -1666,11 +1663,13 @@ builtin_variable_generator::generate_varyings()
var->data.patch = fields[i].patch;
var->init_interface_type(per_vertex_out_type);
var->data.invariant = fields[i].location == VARYING_SLOT_POS &&
options->PositionAlwaysInvariant;
var->data.invariant = state->stage == MESA_SHADER_VERTEX &&
fields[i].location == VARYING_SLOT_POS &&
state->consts->VSPositionAlwaysInvariant;
var->data.precise = fields[i].location == VARYING_SLOT_POS &&
options->PositionAlwaysPrecise;
var->data.precise = state->stage == MESA_SHADER_TESS_EVAL &&
fields[i].location == VARYING_SLOT_POS &&
state->consts->TESPositionAlwaysPrecise;
}
}
}

View file

@ -1284,8 +1284,6 @@ preprocess_shader(const struct pipe_screen *screen,
struct gl_shader_program *shader_program,
mesa_shader_stage stage)
{
const struct gl_shader_compiler_options *gl_options =
&consts->ShaderCompilerOptions[prog->info.stage];
const nir_shader_compiler_options *options = screen->nir_options[prog->info.stage];
assert(options);

View file

@ -356,12 +356,6 @@ struct gl_shader_compiler_options
/** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
GLboolean ClampBlockIndicesToArrayBounds;
/** (driconf) Force gl_Position to be considered invariant */
GLboolean PositionAlwaysInvariant;
/** (driconf) Force gl_Position to be considered precise */
GLboolean PositionAlwaysPrecise;
};
/**
@ -896,6 +890,12 @@ struct gl_constants
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
/** (driconf) Force gl_Position to be considered invariant */
GLboolean VSPositionAlwaysInvariant;
/** (driconf) Force gl_Position to be considered precise */
GLboolean TESPositionAlwaysPrecise;
/** GL_ARB_tessellation_shader */
GLuint MaxPatchVertices;
GLuint MaxTessGenLevel;

View file

@ -681,9 +681,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
ctx->Const.ForceFloat32TexNearest =
!screen->caps.texture_float_linear;
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].PositionAlwaysInvariant = options->vs_position_always_invariant;
ctx->Const.VSPositionAlwaysInvariant = options->vs_position_always_invariant;
ctx->Const.ShaderCompilerOptions[MESA_SHADER_TESS_EVAL].PositionAlwaysPrecise = options->vs_position_always_precise;
ctx->Const.TESPositionAlwaysPrecise = options->vs_position_always_precise;
/* Set which shader types can be compiled at link time. */
st->shader_has_one_variant[MESA_SHADER_VERTEX] =