summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_glsl_to_nir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_glsl_to_nir.cpp')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index a87284ef2a7..11fc03baf86 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -655,6 +655,28 @@ st_nir_get_mesa_program(struct gl_context *ctx,
}
static void
+st_nir_vectorize_io(nir_shader *producer, nir_shader *consumer)
+{
+ NIR_PASS_V(producer, nir_lower_io_to_vector, nir_var_shader_out);
+ NIR_PASS_V(producer, nir_opt_combine_stores, nir_var_shader_out);
+ NIR_PASS_V(consumer, nir_lower_io_to_vector, nir_var_shader_in);
+
+ if ((producer)->info.stage != MESA_SHADER_TESS_CTRL) {
+ /* Calling lower_io_to_vector creates output variable writes with
+ * write-masks. We only support these for TCS outputs, so for other
+ * stages, we need to call nir_lower_io_to_temporaries to get rid of
+ * them. This, in turn, creates temporary variables and extra
+ * copy_deref intrinsics that we need to clean up.
+ */
+ NIR_PASS_V(producer, nir_lower_io_to_temporaries,
+ nir_shader_get_entrypoint(producer), true, false);
+ NIR_PASS_V(producer, nir_lower_global_vars_to_local);
+ NIR_PASS_V(producer, nir_split_var_copies);
+ NIR_PASS_V(producer, nir_lower_var_copies);
+ }
+}
+
+static void
st_nir_link_shaders(nir_shader **producer, nir_shader **consumer, bool scalar)
{
if (scalar) {
@@ -844,6 +866,9 @@ st_link_nir(struct gl_context *ctx,
prev_shader->sh.LinkedTransformFeedback->NumVarying > 0))
nir_compact_varyings(shader_program->_LinkedShaders[prev]->Program->nir,
nir, ctx->API != API_OPENGL_COMPAT);
+
+ if (ctx->Const.ShaderCompilerOptions[i].NirOptions->vectorize_io)
+ st_nir_vectorize_io(prev_shader->nir, nir);
}
prev = i;
}