aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2015-08-26 13:58:23 -0600
committerBrian Paul <[email protected]>2015-08-27 13:11:26 -0600
commitbcae4640c89bc2775d1a85b2b27d2787cac8f843 (patch)
tree6ffb3f25012ea77cb330766c79a1f7e17e466add /src/mesa/state_tracker/st_glsl_to_tgsi.cpp
parent42c7be5877665dfcbeb317c7eb163a03d56fe661 (diff)
st/mesa: use PROGRAM_ARRAY for storing structs containing arrays
Previously, we used PROGRAM_ARRAY only for variables which were arrays or matrices. But if the variable is a structure containing an array or matrix, we need to use PROGRAM_ARRAY for that too. Before, we failed an assertion: state_tracker/st_glsl_to_tgsi.cpp:4900: Assertion `src_reg->file != PROGRAM_TEMPORARY' failed. when running the piglit test glsl-1.20/execution/fs-const-array-of-struct-of-array.shader_test Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_glsl_to_tgsi.cpp')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index cba98819718..695644117ac 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1123,6 +1123,34 @@ type_size(const struct glsl_type *type)
return 0;
}
+
+/**
+ * If the given GLSL type is an array or matrix or a structure containing
+ * an array/matrix member, return true. Else return false.
+ *
+ * This is used to determine which kind of temp storage (PROGRAM_TEMPORARY
+ * or PROGRAM_ARRAY) should be used for variables of this type. Anytime
+ * we have an array that might be indexed with a variable, we need to use
+ * the later storage type.
+ */
+static bool
+type_has_array_or_matrix(const glsl_type *type)
+{
+ if (type->is_array() || type->is_matrix())
+ return true;
+
+ if (type->is_record()) {
+ for (unsigned i = 0; i < type->length; i++) {
+ if (type_has_array_or_matrix(type->fields.structure[i].type)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
/**
* In the initial pass of codegen, we assign temporary numbers to
* intermediate results. (not SSA -- variable assignments will reuse
@@ -1137,9 +1165,7 @@ glsl_to_tgsi_visitor::get_temp(const glsl_type *type)
src.reladdr = NULL;
src.negate = 0;
- if (!options->EmitNoIndirectTemp &&
- (type->is_array() || type->is_matrix())) {
-
+ if (!options->EmitNoIndirectTemp && type_has_array_or_matrix(type)) {
if (next_array >= max_num_arrays) {
max_num_arrays += 32;
array_sizes = (unsigned*)