glsl: remove gl_shader_compiler_options
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

unused

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:20:43 -04:00
parent 10b7f0e95d
commit ba6f731ead
7 changed files with 15 additions and 126 deletions

View file

@ -2391,14 +2391,11 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
state->has_implicit_int_to_uint_conversion();
shader->KHR_shader_subgroup_basic_enable = state->KHR_shader_subgroup_basic_enable;
struct gl_shader_compiler_options *options =
&ctx->Const.ShaderCompilerOptions[shader->Stage];
if (!state->error && !shader->ir->is_empty()) {
if (state->es_shader &&
(ctx->screen->shader_caps[shader->Stage].fp16 ||
ctx->screen->shader_caps[shader->Stage].int16))
lower_precision(ctx->screen, shader->Stage, options, shader->ir);
lower_precision(ctx->screen, shader->Stage, shader->ir);
lower_builtins(shader->ir);
assign_subroutine_indexes(state);

View file

@ -67,7 +67,6 @@ namespace ir_builder { class ir_factory; };
void lower_precision(const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options,
ir_exec_list *instructions);
#endif /* GLSL_IR_OPTIMIZATION_H */

View file

@ -43,8 +43,7 @@ namespace {
class find_precision_visitor : public ir_rvalue_enter_visitor {
public:
find_precision_visitor(const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options);
mesa_shader_stage stage);
find_precision_visitor(const find_precision_visitor &) = delete;
~find_precision_visitor();
find_precision_visitor & operator=(const find_precision_visitor &) = delete;
@ -72,7 +71,6 @@ public:
const struct pipe_screen *screen;
mesa_shader_stage stage;
const struct gl_shader_compiler_options *options;
};
class find_lowerable_rvalues_visitor : public ir_hierarchical_visitor {
@ -110,8 +108,7 @@ public:
find_lowerable_rvalues_visitor(struct set *result,
const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options);
mesa_shader_stage stage);
static void stack_enter(class ir_instruction *ir, void *data);
static void stack_leave(class ir_instruction *ir, void *data);
@ -137,7 +134,6 @@ public:
mesa_shader_stage stage;
std::vector<stack_entry> stack;
struct set *lowerable_rvalues;
const struct gl_shader_compiler_options *options;
void pop_stack_entry();
void add_lowerable_children(const stack_entry &entry);
@ -187,13 +183,11 @@ can_lower_type(const struct pipe_screen *screen, mesa_shader_stage stage,
find_lowerable_rvalues_visitor::find_lowerable_rvalues_visitor(struct set *res,
const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *opts)
mesa_shader_stage stage)
{
this->screen = screen;
this->stage = stage;
lowerable_rvalues = res;
options = opts;
callback_enter = stack_enter;
callback_leave = stack_leave;
data_enter = this;
@ -423,8 +417,7 @@ find_lowerable_rvalues_visitor::visit_enter(ir_expression *ir)
static unsigned
handle_call(ir_call *ir, const struct set *lowerable_rvalues,
const struct pipe_screen *screen, mesa_shader_stage stage,
const struct gl_shader_compiler_options *options)
const struct pipe_screen *screen, mesa_shader_stage stage)
{
/* The intrinsic call is inside the wrapper imageLoad function that will
* be inlined. We have to handle both of them.
@ -568,7 +561,7 @@ find_lowerable_rvalues_visitor::visit_leave(ir_call *ir)
assert(var->data.mode == ir_var_temporary);
unsigned return_precision = handle_call(ir, lowerable_rvalues, screen,
stage, options);
stage);
can_lower_state lower_state =
handle_precision(var->type, return_precision);
@ -619,11 +612,10 @@ find_lowerable_rvalues_visitor::visit_leave(ir_assignment *ir)
static void
find_lowerable_rvalues(const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options,
ir_exec_list *instructions,
struct set *result)
{
find_lowerable_rvalues_visitor v(result, screen, stage, options);
find_lowerable_rvalues_visitor v(result, screen, stage);
visit_list_elements(&v, instructions);
@ -929,7 +921,7 @@ find_precision_visitor::map_builtin(linear_ctx *linalloc, ir_function_signature
}
}
lower_precision(screen, stage, options, &lowered_sig->body);
lower_precision(screen, stage, &lowered_sig->body);
_mesa_hash_table_clear(clone_ht, NULL);
@ -939,14 +931,12 @@ find_precision_visitor::map_builtin(linear_ctx *linalloc, ir_function_signature
}
find_precision_visitor::find_precision_visitor(const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options)
mesa_shader_stage stage)
: lowerable_rvalues(_mesa_pointer_set_create(NULL)),
lowered_builtins(NULL),
clone_ht(NULL),
screen(screen),
stage(stage),
options(options)
stage(stage)
{
}
@ -971,9 +961,8 @@ find_precision_visitor::~find_precision_visitor()
class lower_variables_visitor : public ir_rvalue_enter_visitor {
public:
lower_variables_visitor(const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options)
: screen(screen), stage(stage), options(options) {
mesa_shader_stage stage)
: screen(screen), stage(stage) {
lower_vars = _mesa_pointer_set_create(NULL);
}
@ -997,7 +986,6 @@ public:
const struct pipe_screen *screen;
mesa_shader_stage stage;
const struct gl_shader_compiler_options *options;
set *lower_vars;
};
@ -1366,14 +1354,13 @@ lower_variables_visitor::visit_enter(ir_call *ir)
void
lower_precision(const struct pipe_screen *screen,
mesa_shader_stage stage,
const struct gl_shader_compiler_options *options,
ir_exec_list *instructions)
{
find_precision_visitor v(screen, stage, options);
find_lowerable_rvalues(screen, stage, options, instructions,
find_precision_visitor v(screen, stage);
find_lowerable_rvalues(screen, stage, instructions,
v.lowerable_rvalues);
visit_list_elements(&v, instructions);
lower_variables_visitor vars(screen, stage, options);
lower_variables_visitor vars(screen, stage);
visit_list_elements(&vars, instructions);
}

View file

@ -284,14 +284,6 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0; /* not used */
/* Set up default shader compiler options. */
struct gl_shader_compiler_options options;
memset(&options, 0, sizeof(options));
options.MaxIfDepth = UINT_MAX;
for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh)
memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
ctx->Driver.NewProgram = standalone_new_program;
}

View file

@ -315,49 +315,6 @@ struct gl_extensions
GLubyte Version;
};
/**
* Compiler options for a single GLSL shaders type
*/
struct gl_shader_compiler_options
{
/** Driver-selectable options: */
GLboolean EmitNoCont; /**< Emit CONT opcode? */
GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
GLbitfield LowerBuiltinVariablesXfb; /**< Which builtin variables should
* be lowered for transform feedback
**/
/**
* If we can lower the precision of variables based on precision
* qualifiers
*/
GLboolean LowerPrecisionFloat16;
GLboolean LowerPrecisionInt16;
GLboolean LowerPrecisionDerivatives;
GLboolean LowerPrecisionFloat16Uniforms;
GLboolean LowerPrecision16BitLoadDst;
/**
* This enables lowering of 16b constants. Some drivers may not
* to lower constants to 16b (ie. if the hw can do automatic
* narrowing on constant load)
*/
GLboolean LowerPrecisionConstants;
/**
* \name Forms of indirect addressing the driver cannot do.
*/
/*@{*/
GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
/*@}*/
GLuint MaxIfDepth; /**< Maximum nested IF blocks */
/** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
GLboolean ClampBlockIndicesToArrayBounds;
};
/**
* Precision info for shader datatypes. See glGetShaderPrecisionFormat().
*/
@ -888,8 +845,6 @@ struct gl_constants
/** GL_KHR_context_flush_control */
GLenum16 ContextReleaseBehavior;
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
/** (driconf) Force gl_Position to be considered invariant */
GLboolean VSPositionAlwaysInvariant;

View file

@ -198,19 +198,8 @@ _mesa_get_shader_capture_path(void)
void
_mesa_init_shader_state(struct gl_context *ctx)
{
/* Device drivers may override these to control what kind of instructions
* are generated by the GLSL compiler.
*/
struct gl_shader_compiler_options options;
mesa_shader_stage sh;
int i;
memset(&options, 0, sizeof(options));
options.MaxIfDepth = UINT_MAX;
for (sh = 0; sh < MESA_SHADER_STAGES; ++sh)
memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
ctx->Shader.Flags = _mesa_get_shader_flags();
if (ctx->Shader.Flags != 0)

View file

@ -201,8 +201,6 @@ void st_init_limits(struct pipe_screen *screen,
for (sh = 0; sh < MESA_SHADER_STAGES; ++sh) {
const mesa_shader_stage stage = tgsi_processor_to_shader_stage(sh);
struct gl_shader_compiler_options *options =
&c->ShaderCompilerOptions[stage];
struct gl_program_constants *pc = &c->Program[stage];
if (!screen->nir_options[stage] ||
@ -320,39 +318,11 @@ void st_init_limits(struct pipe_screen *screen,
pc->MediumFloat = pc->LowFloat;
}
/* TODO: make these more fine-grained if anyone needs it */
options->MaxIfDepth =
screen->shader_caps[sh].max_control_flow_depth;
options->EmitNoMainReturn =
!screen->shader_caps[sh].subroutines;
options->EmitNoCont =
!screen->shader_caps[sh].cont_supported;
options->EmitNoIndirectTemp =
!screen->shader_caps[sh].indirect_temp_addr;
options->EmitNoIndirectUniform =
!screen->shader_caps[sh].indirect_const_addr;
if (pc->MaxInstructions &&
(!screen->shader_caps[sh].indirect_const_addr ||
pc->MaxUniformBlocks < 12)) {
can_ubo = false;
}
options->LowerPrecisionFloat16 =
screen->shader_caps[sh].fp16;
options->LowerPrecisionDerivatives =
screen->shader_caps[sh].fp16_derivatives;
options->LowerPrecisionInt16 =
screen->shader_caps[sh].int16;
options->LowerPrecisionConstants =
screen->shader_caps[sh].glsl_16bit_consts;
options->LowerPrecisionFloat16Uniforms =
screen->shader_caps[sh].fp16_const_buffers;
options->LowerPrecision16BitLoadDst =
screen->shader_caps[sh].glsl_16bit_load_dst;
}
c->MaxUserAssignableUniformLocations =