summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-08-22 07:10:32 -0700
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-09-10 14:36:46 -0700
commit18e79e97e5d83c9cb2f98f0e0b9a0f964014ba69 (patch)
tree456f48d973827ee331206b604f65bb74178d1e77 /src/mesa
parentb6384e57f5f6e454c06ec1ada1c1138dd0dc84f2 (diff)
mesa/st: Extract preprocessing NIR steps
Refactor to split the glsl_to_nir conversion from the preprocessing NIR passes into separate functions, so we can use them in SPIR-V. Unlike in GLSL, there we'll need to perform a few passes with the NIR linker before doing the individual preprocess calls. No behavior should change with this patch. Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 52f56642078..5922650de2c 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -269,10 +269,10 @@ st_nir_opts(nir_shader *nir, bool scalar)
* nir_lower_io state, so that shader variants can more easily insert/
* replace variables, etc.
*/
-static nir_shader *
-st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
- struct gl_shader_program *shader_program,
- gl_shader_stage stage)
+static void
+st_nir_preprocess(struct st_context *st, struct gl_program *prog,
+ struct gl_shader_program *shader_program,
+ gl_shader_stage stage)
{
const nir_shader_compiler_options *options =
st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
@@ -282,11 +282,7 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
assert(options);
bool lower_64bit =
options->lower_int64_options || options->lower_doubles_options;
-
- if (prog->nir)
- return prog->nir;
-
- nir_shader *nir = glsl_to_nir(st->ctx, shader_program, stage, options);
+ nir_shader *nir = prog->nir;
/* Set the next shader stage hint for VS and TES. */
if (!nir->info.separate_shader &&
@@ -355,8 +351,6 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
if (lowered_64bit_ops)
st_nir_opts(nir, is_scalar);
}
-
- return nir;
}
/* Second third of converting glsl_to_nir. This creates uniforms, gathers
@@ -510,10 +504,17 @@ st_nir_get_mesa_program(struct gl_context *ctx,
prog->ExternalSamplersUsed = gl_external_samplers(prog);
_mesa_update_shader_textures_used(shader_program, prog);
- nir_shader *nir = st_glsl_to_nir(st, prog, shader_program, shader->Stage);
+ if (!prog->nir) {
+ const nir_shader_compiler_options *options =
+ st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
+ assert(options);
+
+ prog->nir = glsl_to_nir(st->ctx, shader_program,
+ prog->info.stage, options);
+ st_nir_preprocess(st, prog, shader_program, prog->info.stage);
+ }
- set_st_program(prog, shader_program, nir);
- prog->nir = nir;
+ set_st_program(prog, shader_program, prog->nir);
}
static void