summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-07-18 18:46:09 -0700
committerKenneth Graunke <[email protected]>2019-01-11 13:07:54 -0800
commit2b876bc92260991ad3ad1fd6b38240f6983078e1 (patch)
tree88e8e5179cdc9b55c11f61f79f96fc9fca5f072f
parent3d182601bb3314513500e39092c48a7126b3278a (diff)
st/nir: Lower TES gl_PatchVerticesIn to a constant if linked with a TCS.
If the TCS and TES are linked together, we can simply replace the TES's gl_PatchVerticesIn system value with a constant, possibly allowing extra optimization or letting the driver avoid uploading a special value. Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp23
1 files changed, 23 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 87e4a37a9d9..3ab7af7c20c 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -626,6 +626,27 @@ st_nir_link_shaders(nir_shader **producer, nir_shader **consumer, bool scalar)
}
}
+static void
+st_lower_patch_vertices_in(struct gl_shader_program *shader_prog)
+{
+ struct gl_linked_shader *linked_tcs =
+ shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
+ struct gl_linked_shader *linked_tes =
+ shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+
+ /* If we have a TCS and TES linked together, lower TES patch vertices. */
+ if (linked_tcs && linked_tes) {
+ nir_shader *tcs_nir = linked_tcs->Program->nir;
+ nir_shader *tes_nir = linked_tes->Program->nir;
+
+ /* The TES input vertex count is the TCS output vertex count,
+ * lower TES gl_PatchVerticesIn to a constant.
+ */
+ uint32_t tes_patch_verts = tcs_nir->info.tess.tcs_vertices_out;
+ NIR_PASS_V(tes_nir, nir_lower_patch_vertices, tes_patch_verts, NULL);
+ }
+}
+
extern "C" {
void
@@ -747,6 +768,8 @@ st_link_nir(struct gl_context *ctx,
prev = i;
}
+ st_lower_patch_vertices_in(shader_program);
+
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *shader = shader_program->_LinkedShaders[i];
if (shader == NULL)