[Mesa-dev] Returning 0 from std430_base_alignment
Ilia Mirkin
imirkin at alum.mit.edu
Mon Sep 28 08:49:50 PDT 2015
On Mon, Sep 28, 2015 at 5:44 AM, Samuel Iglesias Gonsálvez
<siglesias at igalia.com> wrote:
>
>
> On 26/09/15 19:42, Ilia Mirkin wrote:
>> Hi Samuel,
>>
>> Coverity is up in a tizzy because std430_base_alignment can return 0
>> (which in turn would cause tons of errors since it's used with
>> glsl_align). Is there a better starting value that can be used for its
>> is_record() case? For std140 it's 16... I assume for std430 it's 4 or
>> something? That would allow Coverity to conclude that 0 will never be
>> returned from the function... as-is an empty struct would get an
>> alignment of 0 and create lots of div-by-zero. Not sure if that's a
>> legit scenario though.
>>
>
> After looking at the specs and what other drivers do, empty struct
> declarations are not allowed. From GLSL 1.50 spec, section 4.1.8
> "Structures"
>
> "Structures must have at least one member declaration."
>
> Similar wording appears in GLSL 4.30, GLSL ES 3.0 and others.
>
>> Alternatively, an assert(base_alignment > 0) will most likely appease it.
>>
>
> I prefer to add this assertion in std430_base_alignment() because the
> base alignment rules (*) are always talking about basic machine units
> and I prefer not assume than a basic machine unit is 4.
>
> What do you think?
Works for me! Hopefully something further up the stack validates that
structs can't be empty.
-ilia
More information about the mesa-dev
mailing list