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;
+ }
+ }
+
/* Return early if we are loading the shader from on-disk cache */
if (st_load_tgsi_from_disk_cache(ctx, prog)) {
return GL_TRUE;
}
- struct pipe_screen *pscreen = ctx->st->pipe->screen;
assert(prog->data->LinkStatus);
- bool use_nir = false;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (prog->_LinkedShaders[i] == NULL)
continue;
@@ -6945,12 +6971,6 @@ st_link_shader(struct gl_context *ctx, struct
gl_shader_program *prog)
unsigned if_threshold = pscreen->get_shader_param(pscreen, ptarget,
PIPE_SHADER_CAP_LOWER_IF_THRESHOLD);
- enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir)
- pscreen->get_shader_param(pscreen, ptarget,
- PIPE_SHADER_CAP_PREFERRED_IR);
- if (preferred_ir == PIPE_SHADER_IR_NIR)
- use_nir = true;
-
/* If there are forms of indirect addressing that the driver
* cannot handle, perform the lowering pass.
*/
--
2.14.3
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev