summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-10-29 22:41:18 -0700
committerKenneth Graunke <[email protected]>2019-02-05 13:43:02 -0800
commit4f799264d1ac40769f84d27e945e981a89f4346e (patch)
tree413ab2bd9b1748c15ffd87016f5a3379487e8293 /src/mesa
parent36734987a59f087ae499c5d0736995007f4af780 (diff)
st/nir: Move varying setup code to a helper function.
I want to reuse this for built-in shaders. Reviewed-by: Marek Olšák <[email protected]> Tested-by: Rob Clark <[email protected]> Tested-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp46
-rw-r--r--src/mesa/state_tracker/st_nir.h3
2 files changed, 29 insertions, 20 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 271a30eab70..d87444aa70c 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -794,27 +794,9 @@ st_link_nir(struct gl_context *ctx,
return true;
}
-/* Last third of preparing nir from glsl, which happens after shader
- * variant lowering.
- */
void
-st_finalize_nir(struct st_context *st, struct gl_program *prog,
- struct gl_shader_program *shader_program, nir_shader *nir)
+st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir)
{
- struct pipe_screen *screen = st->pipe->screen;
- const nir_shader_compiler_options *options =
- st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
-
- NIR_PASS_V(nir, nir_split_var_copies);
- NIR_PASS_V(nir, nir_lower_var_copies);
- if (options->lower_all_io_to_temps ||
- nir->info.stage == MESA_SHADER_VERTEX ||
- nir->info.stage == MESA_SHADER_GEOMETRY) {
- NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
- } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
- NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true);
- }
-
if (nir->info.stage == MESA_SHADER_VERTEX) {
/* Needs special handling so drvloc matches the vbo state: */
st_nir_assign_vs_in_locations(nir);
@@ -852,9 +834,33 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
} else if (nir->info.stage == MESA_SHADER_COMPUTE) {
/* TODO? */
} else {
- unreachable("invalid shader type for tgsi bypass\n");
+ unreachable("invalid shader type");
+ }
+}
+
+/* Last third of preparing nir from glsl, which happens after shader
+ * variant lowering.
+ */
+void
+st_finalize_nir(struct st_context *st, struct gl_program *prog,
+ struct gl_shader_program *shader_program, nir_shader *nir)
+{
+ struct pipe_screen *screen = st->pipe->screen;
+ const nir_shader_compiler_options *options =
+ st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
+
+ NIR_PASS_V(nir, nir_split_var_copies);
+ NIR_PASS_V(nir, nir_lower_var_copies);
+ if (options->lower_all_io_to_temps ||
+ nir->info.stage == MESA_SHADER_VERTEX ||
+ nir->info.stage == MESA_SHADER_GEOMETRY) {
+ NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false);
+ } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+ NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true);
}
+ st_nir_assign_varying_locations(st, nir);
+
NIR_PASS_V(nir, nir_lower_atomics_to_ssbo,
st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers);
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index 10f23c03ef6..1bb65c9d3f1 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -52,6 +52,9 @@ bool
st_link_nir(struct gl_context *ctx,
struct gl_shader_program *shader_program);
+void st_nir_assign_varying_locations(struct st_context *st,
+ struct nir_shader *nir);
+
#ifdef __cplusplus
}
#endif