[Mesa-dev] [PATCH V2] glsl: check if implicitly sized arrays match explicitly sized arrays across the same stage

Chris Forbes chrisf at ijw.co.nz
Mon Dec 22 02:55:47 PST 2014


OK, cool.

This patch is

Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>

On Mon, Dec 22, 2014 at 11:44 PM, Timothy Arceri <t_arceri at yahoo.com.au> wrote:
>
>
>
>
>
> ----- Original Message -----
> From: Chris Forbes <chrisf at ijw.co.nz>
>
>>Does this work correctly for arrays of interface blocks too?
>
>>
>
> Hi Chris, sorry this got lost in my indox.
>
>
> Just to be sure I made some tests:
> http://lists.freedesktop.org/archives/piglit/2014-December/013847.html
>
> The answer is yes it woks correctly however because of the input check it was already catching the problem in geometry shaders.
>
>
> Before my patch:
>
>
> error: geometry shader accesses element 4 of i, but only 4 input vertices
>
> After my patch:
>
>
> error: shader input `i' declared as type `ArrayInterfaceBlock[4]' but outermost dimension has an index of `4'
>
> On Mon, Dec 1, 2014 at 10:37 AM, Timothy Arceri <t_arceri at yahoo.com.au> wrote:
>> 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
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list