aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Ho <[email protected]>2020-05-14 11:51:43 -0700
committerMarge Bot <[email protected]>2020-06-22 14:35:45 +0000
commitd2d4677b56efa0003065b61e39c1ef977c83f7da (patch)
tree5560d8133d17aabdbdd8a2c48ffbf19cb5bdb45c
parentffc4d82438d9806c222a6eaadad5e00985e4d367 (diff)
nir: Support sysval tess levels in SPIR-V to NIR
This commit adds a tess_levels_are_sysvals flag to spirv_to_nir_options similar to GLSLTessLevelsAsInputs in the GLSL to NIR compiler options. This will be used by turnip as the tess IR3 lowering pass (ir3_nir_lower_tess) operates on TessLevelInner and TessLevelOuter in the DS as sysvals. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5059>
-rw-r--r--src/compiler/spirv/nir_spirv.h5
-rw-r--r--src/compiler/spirv/vtn_variables.c16
2 files changed, 19 insertions, 2 deletions
diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index 3d6f74e43ca..acfcc084f41 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -64,6 +64,11 @@ struct spirv_to_nir_options {
*/
bool frag_coord_is_sysval;
+ /* Whether to lower TessLevelInner and TessLevelOuter to system values.
+ * This is the inverse of GLSLTessLevelsAsInputs in GLSL.
+ */
+ bool tess_levels_are_sysvals;
+
struct spirv_supported_capabilities caps;
/* Address format for various kinds of pointers. */
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index afe2aa89bbf..b36edbafa12 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1354,10 +1354,22 @@ vtn_get_builtin_location(struct vtn_builder *b,
vtn_fail("invalid stage for SpvBuiltInViewportIndex");
break;
case SpvBuiltInTessLevelOuter:
- *location = VARYING_SLOT_TESS_LEVEL_OUTER;
+ if (b->options && b->options->tess_levels_are_sysvals &&
+ *mode == nir_var_shader_in) {
+ *location = SYSTEM_VALUE_TESS_LEVEL_OUTER;
+ set_mode_system_value(b, mode);
+ } else {
+ *location = VARYING_SLOT_TESS_LEVEL_OUTER;
+ }
break;
case SpvBuiltInTessLevelInner:
- *location = VARYING_SLOT_TESS_LEVEL_INNER;
+ if (b->options && b->options->tess_levels_are_sysvals &&
+ *mode == nir_var_shader_in) {
+ *location = SYSTEM_VALUE_TESS_LEVEL_INNER;
+ set_mode_system_value(b, mode);
+ } else {
+ *location = VARYING_SLOT_TESS_LEVEL_INNER;
+ }
break;
case SpvBuiltInTessCoord:
*location = SYSTEM_VALUE_TESS_COORD;