[Mesa-dev] [PATCH V2] glsl: check if implicitly sized arrays match explicitly sized arrays across the same stage
Timothy Arceri
t_arceri at yahoo.com.au
Sun Nov 30 13:37:56 PST 2014
V2: Improve error message.
Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
src/glsl/linker.cpp | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
I came across this when I was writting arrays of arrays piglit tests.
This change fixes the new link error tests for single dimension arrays
which I've sent to the piglit list [1].
Example error message:
"shader output `color' declared as type `vec4[3]' but outermost
dimension has an index of `3'"
I've also run all the glsl piglit tests without any regressions.
[1] http://lists.freedesktop.org/archives/piglit/2014-November/013478.html
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index de6b1fb..03cbe85 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -732,8 +732,27 @@ cross_validate_globals(struct gl_shader_program *prog,
&& ((var->type->length == 0)
|| (existing->type->length == 0))) {
if (var->type->length != 0) {
+ if (var->type->length <= existing->data.max_array_access) {
+ linker_error(prog, "%s `%s' declared as type "
+ "`%s' but outermost dimension has an index"
+ " of `%i'\n",
+ mode_string(var),
+ var->name, var->type->name,
+ existing->data.max_array_access);
+ return;
+ }
existing->type = var->type;
- }
+ } else if (existing->type->length != 0
+ && existing->type->length <=
+ var->data.max_array_access) {
+ linker_error(prog, "%s `%s' declared as type "
+ "`%s' but outermost dimension has an index"
+ " of `%i'\n",
+ mode_string(var),
+ var->name, existing->type->name,
+ var->data.max_array_access);
+ return;
+ }
} else if (var->type->is_record()
&& existing->type->is_record()
&& existing->type->record_compare(var->type)) {
--
1.9.3
More information about the mesa-dev
mailing list