summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2016-04-04 00:31:45 -0700
committerKenneth Graunke <kenneth@whitecape.org>2016-04-04 14:29:21 -0700
commit5509d43a11d42f15c91572aaf69a0f8e1ec31c71 (patch)
treebaa106a4bd02068f458346b824afe388b2fe367f /src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
parent88ef2476dcdd61000cbae7ded9c8fa52927429d8 (diff)
downloadexternal_mesa3d-5509d43a11d42f15c91572aaf69a0f8e1ec31c71.zip
external_mesa3d-5509d43a11d42f15c91572aaf69a0f8e1ec31c71.tar.gz
external_mesa3d-5509d43a11d42f15c91572aaf69a0f8e1ec31c71.tar.bz2
glsl: Lower variable indexing of system value arrays unconditionally.
lower_variable_index_to_cond_assign() did not handle system values. gl_SampleMaskIn[] is a system value, and also an array. Accessing it with a variable index would trigger an unreachable() assert. Rather than adding a new EmitNoIndirectSystemValues flag, we simply lower unconditionally. There is exactly one case where this occurs, and for all current drivers, lowering produces optimal code. Even for future drivers with 32x MSAA, it produces reasonable code. Fixes Piglit's new samplemaskin-indirect test. Also fixes many ES31-CTS tests when OES_sample_variables is enabled. Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/compiler/glsl/lower_variable_index_to_cond_assign.cpp')
-rw-r--r--src/compiler/glsl/lower_variable_index_to_cond_assign.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
index 278d545..fcb12d1 100644
--- a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
@@ -385,6 +385,26 @@ public:
case ir_var_const_in:
return this->lower_temps;
+ case ir_var_system_value:
+ /* There are only a few system values that have array types:
+ *
+ * gl_TessLevelInner[]
+ * gl_TessLevelOuter[]
+ * gl_SampleMaskIn[]
+ *
+ * The tessellation factor arrays are lowered to vec4/vec2s
+ * by lower_tess_level() before this pass occurs, so we'll
+ * never see them here.
+ *
+ * The only remaining case is gl_SampleMaskIn[], which has
+ * a length of ceil(ctx->Const.MaxSamples / 32). Most hardware
+ * supports no more than 32 samples, in which case our lowering
+ * produces a single read of gl_SampleMaskIn[0]. Even with 64x
+ * MSAA, the array length is only 2, so the lowering is fairly
+ * efficient. Therefore, lower unconditionally.
+ */
+ return true;
+
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