[Mesa-dev] [PATCH] radeonsi/nir: set TGSI_PROPERTY_NEXT_SHADER

Timothy Arceri tarceri at itsqueeze.com
Mon Feb 26 09:25:26 UTC 2018


---
 src/compiler/shader_info.h                   |  5 +++++
 src/gallium/drivers/radeonsi/si_shader_nir.c |  9 +++++++++
 src/mesa/state_tracker/st_glsl_to_nir.cpp    | 12 ++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index e7fd7dbe62..11a59ff6ac 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -54,6 +54,11 @@ typedef struct shader_info {
    /** The shader stage, such as MESA_SHADER_VERTEX. */
    gl_shader_stage stage;
 
+   /** The shader stage in a non SSO linked program that follows this stage,
+     * such as MESA_SHADER_FRAGMENT.
+     */
+   gl_shader_stage next_stage;
+
    /* Number of textures used by this shader */
    unsigned num_textures;
    /* Number of uniform buffers used by this shader */
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index d410a6c2d6..57f8dc6f03 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -247,6 +247,15 @@ void si_nir_scan_shader(const struct nir_shader *nir,
 	info->num_tokens = 2; /* indicate that the shader is non-empty */
 	info->num_instructions = 2;
 
+	/* Set the next shader stage hint for VS and TES. */
+	if (!nir->info.separate_shader &&
+	    (nir->info.stage == MESA_SHADER_VERTEX ||
+	     nir->info.stage == MESA_SHADER_TESS_EVAL)) {
+
+		info->properties[TGSI_PROPERTY_NEXT_SHADER] =
+			pipe_shader_type_from_mesa(nir->info.next_stage);
+	}
+
 	if (nir->info.stage == MESA_SHADER_TESS_CTRL) {
 		info->properties[TGSI_PROPERTY_TCS_VERTICES_OUT] =
 			nir->info.tess.tcs_vertices_out;
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 765c827d93..760aee1af6 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -317,6 +317,18 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
 
    nir_shader *nir = glsl_to_nir(shader_program, stage, options);
 
+   /* Set the next shader stage hint for VS and TES. */
+   if (!nir->info.separate_shader &&
+       (nir->info.stage == MESA_SHADER_VERTEX ||
+        nir->info.stage == MESA_SHADER_TESS_EVAL)) {
+
+      unsigned stages_mask =
+          (prog->info.stage + 1) >> shader_program->data->linked_stages;
+
+      nir->info.next_stage = stages_mask ?
+         (gl_shader_stage) u_bit_scan(&stages_mask) : MESA_SHADER_FRAGMENT;
+   }
+
    nir_variable_mode mask =
       (nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
    nir_remove_dead_variables(nir, mask);
-- 
2.14.3



More information about the mesa-dev mailing list