summaryrefslogtreecommitdiffstats
path: root/src/glsl/lower_variable_index_to_cond_assign.cpp
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2015-05-28 23:24:08 +0200
committerMarek Olšák <marek.olsak@amd.com>2015-07-23 00:59:27 +0200
commitfb800b3dcd32ddb6f57143b46105d677eb01da80 (patch)
treed4ff07137695c7484afabdc8ebb6474b3fd9b184 /src/glsl/lower_variable_index_to_cond_assign.cpp
parent0cfac917554aeb46bd78ba5b5f5ee1c8ed1d68bc (diff)
downloadexternal_mesa3d-fb800b3dcd32ddb6f57143b46105d677eb01da80.zip
external_mesa3d-fb800b3dcd32ddb6f57143b46105d677eb01da80.tar.gz
external_mesa3d-fb800b3dcd32ddb6f57143b46105d677eb01da80.tar.bz2
glsl: don't lower variable indexing on non-patch tessellation inputs/outputs
There is no way to lower them, because the array sizes are unknown at compile time. Based on a patch from: Fabian Bieler <fabianbieler@fastmail.fm> v2: add comments Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/glsl/lower_variable_index_to_cond_assign.cpp')
-rw-r--r--src/glsl/lower_variable_index_to_cond_assign.cpp58
1 files changed, 45 insertions, 13 deletions
diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp
index 4a6a76c..1ab3afe 100644
--- a/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -335,12 +335,14 @@ struct switch_generator
class variable_index_to_cond_assign_visitor : public ir_rvalue_visitor {
public:
- variable_index_to_cond_assign_visitor(bool lower_input,
- bool lower_output,
- bool lower_temp,
- bool lower_uniform)
+ variable_index_to_cond_assign_visitor(gl_shader_stage stage,
+ bool lower_input,
+ bool lower_output,
+ bool lower_temp,
+ bool lower_uniform)
{
this->progress = false;
+ this->stage = stage;
this->lower_inputs = lower_input;
this->lower_outputs = lower_output;
this->lower_temps = lower_temp;
@@ -348,6 +350,8 @@ public:
}
bool progress;
+
+ gl_shader_stage stage;
bool lower_inputs;
bool lower_outputs;
bool lower_temps;
@@ -369,18 +373,44 @@ public:
case ir_var_auto:
case ir_var_temporary:
return this->lower_temps;
+
case ir_var_uniform:
case ir_var_shader_storage:
return this->lower_uniforms;
+
case ir_var_function_in:
case ir_var_const_in:
return this->lower_temps;
+
case ir_var_shader_in:
+ /* The input array size is unknown at compiler time for non-patch
+ * inputs in TCS and TES. The arrays are sized to
+ * the implementation-dependent limit "gl_MaxPatchVertices", but
+ * the real size is stored in the "gl_PatchVerticesIn" built-in
+ * uniform.
+ *
+ * The TCS input array size is specified by
+ * glPatchParameteri(GL_PATCH_VERTICES).
+ *
+ * The TES input array size is specified by the "vertices" output
+ * layout qualifier in TCS.
+ */
+ if ((stage == MESA_SHADER_TESS_CTRL ||
+ stage == MESA_SHADER_TESS_EVAL) && !var->data.patch)
+ return false;
return this->lower_inputs;
+
case ir_var_function_out:
+ /* TCS non-patch outputs can only be indexed with "gl_InvocationID".
+ * Other expressions are not allowed.
+ */
+ if (stage == MESA_SHADER_TESS_CTRL && !var->data.patch)
+ return false;
return this->lower_temps;
+
case ir_var_shader_out:
return this->lower_outputs;
+
case ir_var_function_inout:
return this->lower_temps;
}
@@ -523,16 +553,18 @@ public:
} /* anonymous namespace */
bool
-lower_variable_index_to_cond_assign(exec_list *instructions,
- bool lower_input,
- bool lower_output,
- bool lower_temp,
- bool lower_uniform)
+lower_variable_index_to_cond_assign(gl_shader_stage stage,
+ exec_list *instructions,
+ bool lower_input,
+ bool lower_output,
+ bool lower_temp,
+ bool lower_uniform)
{
- variable_index_to_cond_assign_visitor v(lower_input,
- lower_output,
- lower_temp,
- lower_uniform);
+ variable_index_to_cond_assign_visitor v(stage,
+ lower_input,
+ lower_output,
+ lower_temp,
+ lower_uniform);
/* Continue lowering until no progress is made. If there are multiple
* levels of indirection (e.g., non-constant indexing of array elements and