glsl/nir: don't pass gl_context to the convertor routine.

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:47:08 +10:00 committed by Marge Bot
parent ef3303385d
commit f7bb68e499
7 changed files with 15 additions and 14 deletions

View file

@ -107,7 +107,7 @@ compile_shader(char **argv)
util_dynarray_init(&binary, NULL);
for (unsigned i = 0; i < 2; ++i) {
nir[i] = glsl_to_nir(&local_ctx, prog, shader_types[i], &agx_nir_options);
nir[i] = glsl_to_nir(&local_ctx.Const, prog, shader_types[i], &agx_nir_options);
if (i == 0) {
nir_assign_var_locations(nir[i], nir_var_shader_in, &nir[i]->num_inputs,

View file

@ -55,7 +55,7 @@ namespace {
class nir_visitor : public ir_visitor
{
public:
nir_visitor(gl_context *ctx, nir_shader *shader);
nir_visitor(const struct gl_constants *consts, nir_shader *shader);
~nir_visitor();
virtual void visit(ir_variable *);
@ -190,7 +190,7 @@ has_unsupported_function_param(exec_list *ir)
}
nir_shader *
glsl_to_nir(struct gl_context *ctx,
glsl_to_nir(const struct gl_constants *consts,
const struct gl_shader_program *shader_prog,
gl_shader_stage stage,
const nir_shader_compiler_options *options)
@ -198,7 +198,7 @@ glsl_to_nir(struct gl_context *ctx,
struct gl_linked_shader *sh = shader_prog->_LinkedShaders[stage];
const struct gl_shader_compiler_options *gl_options =
&ctx->Const.ShaderCompilerOptions[stage];
&consts->ShaderCompilerOptions[stage];
/* glsl_to_nir can only handle converting certain function paramaters
* to NIR. If we find something we can't handle then we get the GLSL IR
@ -208,13 +208,13 @@ glsl_to_nir(struct gl_context *ctx,
*/
while (has_unsupported_function_param(sh->ir)) {
do_common_optimization(sh->ir, true, true, gl_options,
ctx->Const.NativeIntegers);
consts->NativeIntegers);
}
nir_shader *shader = nir_shader_create(NULL, stage, options,
&sh->Program->info);
nir_visitor v1(ctx, shader);
nir_visitor v1(consts, shader);
nir_function_visitor v2(&v1);
v2.run(sh->ir);
visit_exec_list(sh->ir, &v1);
@ -263,9 +263,9 @@ glsl_to_nir(struct gl_context *ctx,
return shader;
}
nir_visitor::nir_visitor(gl_context *ctx, nir_shader *shader)
nir_visitor::nir_visitor(const struct gl_constants *consts, nir_shader *shader)
{
this->supports_std430 = ctx->Const.UseSTD430AsDefaultPacking;
this->supports_std430 = consts->UseSTD430AsDefaultPacking;
this->shader = shader;
this->is_global = true;
this->var_table = _mesa_pointer_hash_table_create(NULL);
@ -2634,7 +2634,7 @@ glsl_float64_funcs_to_nir(struct gl_context *ctx,
nir_shader *nir = nir_shader_create(NULL, MESA_SHADER_VERTEX, options, NULL);
nir_visitor v1(ctx, nir);
nir_visitor v1(&ctx->Const, nir);
nir_function_visitor v2(&v1);
v2.run(sh->ir);
visit_exec_list(sh->ir, &v1);

View file

@ -35,9 +35,10 @@ extern "C" {
#endif
struct gl_context;
struct gl_constants;
struct gl_shader_program;
nir_shader *glsl_to_nir(struct gl_context *ctx,
nir_shader *glsl_to_nir(const struct gl_constants *consts,
const struct gl_shader_program *shader_prog,
gl_shader_stage stage,
const nir_shader_compiler_options *options);

View file

@ -121,7 +121,7 @@ load_glsl(unsigned num_files, char *const *files, gl_shader_stage stage)
if (!prog)
errx(1, "couldn't parse `%s'", files[0]);
nir_shader *nir = glsl_to_nir(&local_ctx, prog, stage, nir_options);
nir_shader *nir = glsl_to_nir(&local_ctx.Const, prog, stage, nir_options);
/* required NIR passes: */
if (nir_options->lower_all_io_to_temps ||

View file

@ -112,7 +112,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
lima_do_glsl_optimizations(prog->_LinkedShaders[stage]->ir);
nir_shader *nir = glsl_to_nir(&local_ctx, prog, stage, nir_options);
nir_shader *nir = glsl_to_nir(&local_ctx.Const, prog, stage, nir_options);
/* required NIR passes: */
if (nir_options->lower_all_io_to_temps ||

View file

@ -762,7 +762,7 @@ st_link_nir(struct gl_context *ctx,
_mesa_log("\n\n");
}
prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
prog->nir = glsl_to_nir(&st->ctx->Const, shader_program, shader->Stage, options);
}
memcpy(prog->nir->info.source_sha1, shader->linked_source_sha1,

View file

@ -148,7 +148,7 @@ compile_shader(int stages, char **files)
util_dynarray_init(&binary, NULL);
for (unsigned i = 0; i < stages; ++i) {
nir[i] = glsl_to_nir(&local_ctx, prog, shader_types[i], &bifrost_nir_options);
nir[i] = glsl_to_nir(&local_ctx.Const, prog, shader_types[i], &bifrost_nir_options);
if (shader_types[i] == MESA_SHADER_VERTEX) {
nir_assign_var_locations(nir[i], nir_var_shader_in, &nir[i]->num_inputs,