[Mesa-dev] [PATCH v2 1/3] glsl: add glsl_external_mode() helper
Timothy Arceri
tarceri at itsqueeze.com
Sat May 12 04:49:09 UTC 2018
This allows us to get the variable mode as specified by the GLSL
spec. We will use this in the following patch.
---
src/compiler/glsl/ast_to_hir.cpp | 73 ++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 3bf581571e2..a7a9ac80769 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4175,6 +4175,79 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
apply_image_qualifier_to_variable(qual, var, state, loc);
}
+/**
+ * Get the GLSL mode specified in for system values (if any).
+ */
+static enum ir_variable_mode
+glsl_external_mode(enum ir_variable_mode internal_mode, gl_shader_stage stage,
+ unsigned slot) {
+ if (internal_mode == ir_var_system_value) {
+ switch (slot) {
+ case SYSTEM_VALUE_SUBGROUP_SIZE:
+ return ir_var_uniform;
+ case SYSTEM_VALUE_PRIMITIVE_ID:
+ if (stage == MESA_SHADER_GEOMETRY) {
+ return ir_var_shader_out;
+ } else {
+ return ir_var_shader_in;
+ }
+ case SYSTEM_VALUE_TESS_LEVEL_OUTER:
+ case SYSTEM_VALUE_TESS_LEVEL_INNER:
+ if (stage == MESA_SHADER_TESS_CTRL) {
+ return ir_var_shader_out;
+ } else {
+ assert(stage == MESA_SHADER_TESS_EVAL);
+ return ir_var_shader_in;
+ }
+ case SYSTEM_VALUE_SUBGROUP_INVOCATION:
+ case SYSTEM_VALUE_SUBGROUP_EQ_MASK:
+ case SYSTEM_VALUE_SUBGROUP_GE_MASK:
+ case SYSTEM_VALUE_SUBGROUP_GT_MASK:
+ case SYSTEM_VALUE_SUBGROUP_LE_MASK:
+ case SYSTEM_VALUE_SUBGROUP_LT_MASK:
+ case SYSTEM_VALUE_INSTANCE_ID:
+ case SYSTEM_VALUE_VERTEX_ID:
+ case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
+ case SYSTEM_VALUE_BASE_VERTEX:
+ case SYSTEM_VALUE_BASE_INSTANCE:
+ case SYSTEM_VALUE_DRAW_ID:
+ case SYSTEM_VALUE_INVOCATION_ID:
+ case SYSTEM_VALUE_FRAG_COORD:
+ case SYSTEM_VALUE_FRONT_FACE:
+ case SYSTEM_VALUE_SAMPLE_ID:
+ case SYSTEM_VALUE_SAMPLE_POS:
+ case SYSTEM_VALUE_SAMPLE_MASK_IN:
+ case SYSTEM_VALUE_HELPER_INVOCATION:
+ case SYSTEM_VALUE_TESS_COORD:
+ case SYSTEM_VALUE_VERTICES_IN:
+ case SYSTEM_VALUE_LOCAL_INVOCATION_ID:
+ case SYSTEM_VALUE_LOCAL_INVOCATION_INDEX:
+ case SYSTEM_VALUE_GLOBAL_INVOCATION_ID:
+ case SYSTEM_VALUE_WORK_GROUP_ID:
+ case SYSTEM_VALUE_NUM_WORK_GROUPS:
+ case SYSTEM_VALUE_LOCAL_GROUP_SIZE:
+ return ir_var_shader_in;
+ case SYSTEM_VALUE_NUM_SUBGROUPS:
+ case SYSTEM_VALUE_SUBGROUP_ID:
+ case SYSTEM_VALUE_INSTANCE_INDEX:
+ case SYSTEM_VALUE_FIRST_VERTEX:
+ case SYSTEM_VALUE_IS_INDEXED_DRAW:
+ case SYSTEM_VALUE_DEVICE_INDEX:
+ case SYSTEM_VALUE_VIEW_INDEX:
+ case SYSTEM_VALUE_VERTEX_CNT:
+ /* These system values have no GLSL facing equal */
+ return internal_mode;
+ case SYSTEM_VALUE_MAX:
+ unreachable("Invalid system value slot SYSTEM_VALUE_MAX");
+ break;
+ default:
+ unreachable("Unhandled system value in glsl_external_mode()");
+ }
+ }
+
+ return internal_mode;
+}
+
/**
* Get the variable that is being redeclared by this declaration or if it
* does not exist, the current declared variable.
--
2.17.0
More information about the mesa-dev
mailing list