glsl/linker: remove a bunch more gl_context references.

This leaves only one reference used for the ctx->Driver.NewProgram
hook, this should likely be revisited.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14433>
This commit is contained in:
Dave Airlie 2022-01-07 12:37:56 +10:00 committed by Marge Bot
parent 636b07943e
commit ef3303385d
5 changed files with 42 additions and 41 deletions

View file

@ -200,7 +200,7 @@ process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
* matching input to another stage.
*/
static void
cross_validate_types_and_qualifiers(struct gl_context *ctx,
cross_validate_types_and_qualifiers(const struct gl_constants *consts,
struct gl_shader_program *prog,
const ir_variable *input,
const ir_variable *output,
@ -375,7 +375,7 @@ cross_validate_types_and_qualifiers(struct gl_context *ctx,
}
if (input_interpolation != output_interpolation &&
prog->data->Version < 440) {
if (!ctx->Const.AllowGLSLCrossStageInterpolationMismatch) {
if (!consts->AllowGLSLCrossStageInterpolationMismatch) {
linker_error(prog,
"%s shader output `%s' specifies %s "
"interpolation qualifier, "
@ -406,7 +406,7 @@ cross_validate_types_and_qualifiers(struct gl_context *ctx,
* Validate front and back color outputs against single color input
*/
static void
cross_validate_front_and_back_color(struct gl_context *ctx,
cross_validate_front_and_back_color(const struct gl_constants *consts,
struct gl_shader_program *prog,
const ir_variable *input,
const ir_variable *front_color,
@ -415,11 +415,11 @@ cross_validate_front_and_back_color(struct gl_context *ctx,
gl_shader_stage producer_stage)
{
if (front_color != NULL && front_color->data.assigned)
cross_validate_types_and_qualifiers(ctx, prog, input, front_color,
cross_validate_types_and_qualifiers(consts, prog, input, front_color,
consumer_stage, producer_stage);
if (back_color != NULL && back_color->data.assigned)
cross_validate_types_and_qualifiers(ctx, prog, input, back_color,
cross_validate_types_and_qualifiers(consts, prog, input, back_color,
consumer_stage, producer_stage);
}
@ -620,7 +620,7 @@ check_location_aliasing(struct explicit_location_info explicit_locations[][4],
}
static bool
validate_explicit_variable_location(struct gl_context *ctx,
validate_explicit_variable_location(const struct gl_constants *consts,
struct explicit_location_info explicit_locations[][4],
ir_variable *var,
gl_shader_program *prog,
@ -639,12 +639,12 @@ validate_explicit_variable_location(struct gl_context *ctx,
if (var->data.mode == ir_var_shader_out) {
assert(sh->Stage != MESA_SHADER_FRAGMENT);
slot_max =
ctx->Const.Program[sh->Stage].MaxOutputComponents / 4;
consts->Program[sh->Stage].MaxOutputComponents / 4;
} else {
assert(var->data.mode == ir_var_shader_in);
assert(sh->Stage != MESA_SHADER_VERTEX);
slot_max =
ctx->Const.Program[sh->Stage].MaxInputComponents / 4;
consts->Program[sh->Stage].MaxInputComponents / 4;
}
if (slot_limit > slot_max) {
@ -694,7 +694,7 @@ validate_explicit_variable_location(struct gl_context *ctx,
* shaders.
*/
void
validate_first_and_last_interface_explicit_locations(struct gl_context *ctx,
validate_first_and_last_interface_explicit_locations(const struct gl_constants *consts,
struct gl_shader_program *prog,
gl_shader_stage first_stage,
gl_shader_stage last_stage)
@ -734,7 +734,7 @@ validate_first_and_last_interface_explicit_locations(struct gl_context *ctx,
continue;
if (!validate_explicit_variable_location(
ctx, explicit_locations, var, prog, sh)) {
consts, explicit_locations, var, prog, sh)) {
return;
}
}
@ -783,7 +783,7 @@ static_input_output_matching(struct gl_shader_program *prog)
* Validate that outputs from one stage match inputs of another
*/
void
cross_validate_outputs_to_inputs(struct gl_context *ctx,
cross_validate_outputs_to_inputs(const struct gl_constants *consts,
struct gl_shader_program *prog,
gl_linked_shader *producer,
gl_linked_shader *consumer)
@ -807,7 +807,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
/* User-defined varyings with explicit locations are handled
* differently because they do not need to have matching names.
*/
if (!validate_explicit_variable_location(ctx,
if (!validate_explicit_variable_location(consts,
output_explicit_locations,
var, prog, producer)) {
return;
@ -837,7 +837,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
const ir_variable *const back_color =
parameters.get_variable("gl_BackColor");
cross_validate_front_and_back_color(ctx, prog, input,
cross_validate_front_and_back_color(consts, prog, input,
front_color, back_color,
consumer->Stage, producer->Stage);
} else if (strcmp(input->name, "gl_SecondaryColor") == 0 && input->data.used) {
@ -847,7 +847,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
const ir_variable *const back_color =
parameters.get_variable("gl_BackSecondaryColor");
cross_validate_front_and_back_color(ctx, prog, input,
cross_validate_front_and_back_color(consts, prog, input,
front_color, back_color,
consumer->Stage, producer->Stage);
} else {
@ -866,7 +866,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
compute_variable_location_slot(input, consumer->Stage);
unsigned slot_limit = idx + num_elements;
if (!validate_explicit_variable_location(ctx,
if (!validate_explicit_variable_location(consts,
input_explicit_locations,
input, prog, consumer)) {
return;
@ -915,7 +915,7 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
*/
if (!(input->get_interface_type() &&
output->get_interface_type()))
cross_validate_types_and_qualifiers(ctx, prog, input, output,
cross_validate_types_and_qualifiers(consts, prog, input, output,
consumer->Stage,
producer->Stage);
} else {
@ -2411,7 +2411,7 @@ varying_matches::not_xfb_comparator(const void *x_generic, const void *y_generic
/**
* Is the given variable a varying variable to be counted against the
* limit in ctx->Const.MaxVarying?
* limit in consts->MaxVarying?
* This includes variables such as texcoords, colors and generic
* varyings, but excludes variables such as gl_FrontFacing and gl_FragCoord.
*/

View file

@ -296,13 +296,13 @@ link_varyings(struct gl_shader_program *prog, unsigned first, unsigned last,
gl_api api, void *mem_ctx);
void
validate_first_and_last_interface_explicit_locations(struct gl_context *ctx,
validate_first_and_last_interface_explicit_locations(const struct gl_constants *consts,
struct gl_shader_program *prog,
gl_shader_stage first,
gl_shader_stage last);
void
cross_validate_outputs_to_inputs(struct gl_context *ctx,
cross_validate_outputs_to_inputs(const struct gl_constants *consts,
struct gl_shader_program *prog,
gl_linked_shader *producer,
gl_linked_shader *consumer);

View file

@ -941,7 +941,8 @@ validate_intrastage_arrays(struct gl_shader_program *prog,
* Perform validation of global variables used across multiple shaders
*/
static void
cross_validate_globals(struct gl_context *ctx, struct gl_shader_program *prog,
cross_validate_globals(const struct gl_constants *consts,
struct gl_shader_program *prog,
struct exec_list *ir, glsl_symbol_table *variables,
bool uniforms_only)
{
@ -1167,7 +1168,7 @@ cross_validate_globals(struct gl_context *ctx, struct gl_shader_program *prog,
/* Check the precision qualifier matches for uniform variables on
* GLSL ES.
*/
if (!ctx->Const.AllowGLSLRelaxedES &&
if (!consts->AllowGLSLRelaxedES &&
prog->IsES && !var->get_interface_type() &&
existing->data.precision != var->data.precision) {
if ((existing->data.used && var->data.used) || prog->data->Version >= 300) {
@ -1221,7 +1222,7 @@ cross_validate_globals(struct gl_context *ctx, struct gl_shader_program *prog,
* Perform validation of uniforms used across multiple shader stages
*/
static void
cross_validate_uniforms(struct gl_context *ctx,
cross_validate_uniforms(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
glsl_symbol_table variables;
@ -1229,7 +1230,7 @@ cross_validate_uniforms(struct gl_context *ctx,
if (prog->_LinkedShaders[i] == NULL)
continue;
cross_validate_globals(ctx, prog, prog->_LinkedShaders[i]->ir,
cross_validate_globals(consts, prog, prog->_LinkedShaders[i]->ir,
&variables, true);
}
}
@ -2433,7 +2434,7 @@ link_intrastage_shaders(void *mem_ctx,
for (unsigned i = 0; i < num_shaders; i++) {
if (shader_list[i] == NULL)
continue;
cross_validate_globals(ctx, prog, shader_list[i]->ir, &variables,
cross_validate_globals(&ctx->Const, prog, shader_list[i]->ir, &variables,
false);
}
@ -3592,12 +3593,12 @@ reserve_subroutine_explicit_locations(struct gl_shader_program *prog,
* inactive array elements that may get trimmed away.
*/
static void
check_explicit_uniform_locations(struct gl_context *ctx,
check_explicit_uniform_locations(const struct gl_extensions *exts,
struct gl_shader_program *prog)
{
prog->NumExplicitUniformLocations = 0;
if (!ctx->Extensions.ARB_explicit_uniform_location)
if (!exts->ARB_explicit_uniform_location)
return;
/* This map is used to detect if overlapping explicit locations
@ -4093,7 +4094,7 @@ add_fragdata_arrays(struct gl_shader_program *shProg,
* resource data.
*/
void
build_program_resource_list(struct gl_context *ctx,
build_program_resource_list(const struct gl_constants *consts,
struct gl_shader_program *shProg,
bool add_packed_varyings_only)
{
@ -4167,7 +4168,7 @@ build_program_resource_list(struct gl_context *ctx,
}
/* Add transform feedback buffers. */
for (unsigned i = 0; i < ctx->Const.MaxTransformFeedbackBuffers; i++) {
for (unsigned i = 0; i < consts->MaxTransformFeedbackBuffers; i++) {
if ((linked_xfb->ActiveBuffers >> i) & 1) {
linked_xfb->Buffers[i].Binding = i;
if (!link_util_add_program_resource(shProg, resource_set,
@ -4300,7 +4301,7 @@ build_program_resource_list(struct gl_context *ctx,
* that includes loop induction variable).
*/
static bool
validate_sampler_array_indexing(struct gl_context *ctx,
validate_sampler_array_indexing(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
dynamic_sampler_array_indexing_visitor v;
@ -4309,7 +4310,7 @@ validate_sampler_array_indexing(struct gl_context *ctx,
continue;
bool no_dynamic_indexing =
ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectSampler;
consts->ShaderCompilerOptions[i].EmitNoIndirectSampler;
/* Search for array derefs in shader. */
v.run(prog->_LinkedShaders[i]->ir);
@ -4662,7 +4663,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
min_version = MIN2(min_version, prog->Shaders[i]->Version);
max_version = MAX2(max_version, prog->Shaders[i]->Version);
if (!ctx->Const.AllowGLSLRelaxedES &&
if (!consts->AllowGLSLRelaxedES &&
prog->Shaders[i]->IsES != prog->Shaders[0]->IsES) {
linker_error(prog, "all shaders must use same shading "
"language version\n");
@ -4681,7 +4682,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* In desktop GLSL, different shader versions may be linked together. In
* GLSL ES, all shader versions must be the same.
*/
if (!ctx->Const.AllowGLSLRelaxedES && prog->Shaders[0]->IsES &&
if (!consts->AllowGLSLRelaxedES && prog->Shaders[0]->IsES &&
min_version != max_version) {
linker_error(prog, "all shaders must use same shading "
"language version\n");
@ -4808,7 +4809,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
* performed, then locations are assigned for uniforms, attributes, and
* varyings.
*/
cross_validate_uniforms(ctx, prog);
cross_validate_uniforms(consts, prog);
if (!prog->data->LinkStatus)
goto done;
@ -4826,7 +4827,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
last = i;
}
check_explicit_uniform_locations(ctx, prog);
check_explicit_uniform_locations(&ctx->Extensions, prog);
link_assign_subroutine_types(prog);
verify_subroutine_associated_funcs(prog);
@ -4848,7 +4849,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (!prog->data->LinkStatus)
goto done;
cross_validate_outputs_to_inputs(ctx, prog,
cross_validate_outputs_to_inputs(consts, prog,
prog->_LinkedShaders[prev],
prog->_LinkedShaders[i]);
if (!prog->data->LinkStatus)
@ -4862,7 +4863,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
* stage and outputs of the last stage included in the program, since there
* is no cross validation for these.
*/
validate_first_and_last_interface_explicit_locations(ctx, prog,
validate_first_and_last_interface_explicit_locations(consts, prog,
(gl_shader_stage) first,
(gl_shader_stage) last);
@ -4941,7 +4942,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
* vertex shader inputs here.
*/
if (prog->IsES && i == MESA_SHADER_VERTEX) {
if (!assign_attribute_or_color_locations(mem_ctx, prog, &ctx->Const,
if (!assign_attribute_or_color_locations(mem_ctx, prog, consts,
MESA_SHADER_VERTEX, false)) {
goto done;
}
@ -4966,7 +4967,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
*/
if ((!prog->IsES && prog->data->Version < 130) ||
(prog->IsES && prog->data->Version < 300)) {
if (!validate_sampler_array_indexing(ctx, prog))
if (!validate_sampler_array_indexing(consts, prog))
goto done;
}
@ -4975,7 +4976,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
store_fragdepth_layout(prog);
if(!link_varyings_and_uniforms(first, last, &ctx->Const,
if(!link_varyings_and_uniforms(first, last, consts,
&ctx->Extensions, ctx->API, prog, mem_ctx))
goto done;

View file

@ -45,7 +45,7 @@ extern void
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);
extern void
build_program_resource_list(struct gl_context *ctx,
build_program_resource_list(const struct gl_constants *consts,
struct gl_shader_program *shProg,
bool add_packed_varyings_only);

View file

@ -170,7 +170,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
validate_ir_tree(ir);
}
build_program_resource_list(ctx, prog, use_nir);
build_program_resource_list(&ctx->Const, prog, use_nir);
if (use_nir)
ret = st_link_nir(ctx, prog);