On Wed, Jan 24, 2018 at 1:41 AM, Timothy Arceri <[email protected]> wrote: > We move the nir check before the shader cache call so that we can > call a nir based caching function in a following patch. > --- > src/mesa/state_tracker/st_glsl_to_nir.cpp | 10 ++------- > src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 36 > +++++++++++++++++++++++------- > 2 files changed, 30 insertions(+), 16 deletions(-) > > diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp > b/src/mesa/state_tracker/st_glsl_to_nir.cpp > index 21b3640b2c..9e627be6da 100644 > --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp > +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp > @@ -304,14 +304,8 @@ st_glsl_to_nir(struct st_context *st, struct gl_program > *prog, > struct gl_shader_program *shader_program, > gl_shader_stage stage) > { > - struct pipe_screen *pscreen = st->pipe->screen; > - enum pipe_shader_type ptarget = pipe_shader_type_from_mesa(stage); > - const nir_shader_compiler_options *options; > - > - assert(pscreen->get_compiler_options); /* drivers using NIR must > implement this */ > - > - options = (const nir_shader_compiler_options *) > - pscreen->get_compiler_options(pscreen, PIPE_SHADER_IR_NIR, ptarget); > + const nir_shader_compiler_options *options = > + st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions; > assert(options); > > if (prog->nir) > diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > index f44f02ad9d..f496bcfe59 100644 > --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > @@ -6917,15 +6917,41 @@ extern "C" { > GLboolean > st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) > { > + struct pipe_screen *pscreen = ctx->st->pipe->screen; > + > + bool use_nir = false; > + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { > + if (prog->_LinkedShaders[i] == NULL) > + continue; > + > + gl_shader_stage stage = prog->_LinkedShaders[i]->Stage; > + enum pipe_shader_type ptarget = pipe_shader_type_from_mesa(stage); > + enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir) > + pscreen->get_shader_param(pscreen, ptarget, > + PIPE_SHADER_CAP_PREFERRED_IR); > + use_nir = preferred_ir == PIPE_SHADER_IR_NIR; > + > + if (use_nir) { > + const nir_shader_compiler_options *options; > + > + /* drivers using NIR must implement this */ > + assert(pscreen->get_compiler_options); > + > + options = (const nir_shader_compiler_options *) > + pscreen->get_compiler_options(pscreen, PIPE_SHADER_IR_NIR, > ptarget); > + assert(options); > + > + ctx->Const.ShaderCompilerOptions[stage].NirOptions = options;
ctx->Const should be constant during the lifetime of the context. The correct place for initializing ctx->Const is st_init_limits. Marek _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
