[Mesa-dev] [PATCH 6/9] glsl: mark named uniform block arrays as active if defined with shared or std140 layout qualifier
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Tue May 5 01:23:39 PDT 2015
On 05/05/15 01:03, Matt Turner wrote:
> On Tue, Feb 24, 2015 at 10:02 AM, Eduardo Lima Mitev <elima at igalia.com> wrote:
>> From: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
>>
>> If the named uniform block is an array declared with a shared or
>> std140 layout qualifier and no shader instruction has referenced it,
>> then it is never marked as active, then num_array_elements is zero.
>>
>> Section 2.12.6 (Uniform Variables) of the OpenGL ES 3.0.4 spec says
>> that is should be considered active:
>>
>> "All members of a named uniform block declared with a shared or
>> std140 layout qualifier are considered active, even if they are not
>> referenced in any shader in the program. The uniform block itself is
>> also considered active, even if no member of the block is
>> referenced."
>>
>> Fixes:
>>
>> dEQP-GLES3.functional.ubo.random.basic_instance_arrays.18
>>
>> Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
>> ---
>> src/glsl/link_uniform_blocks.cpp | 26 ++++++++++++++++++++++++++
>> 1 file changed, 26 insertions(+)
>>
>> diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp
>> index f5fc502..67a3f00 100644
>> --- a/src/glsl/link_uniform_blocks.cpp
>> +++ b/src/glsl/link_uniform_blocks.cpp
>> @@ -213,6 +213,32 @@ link_uniform_blocks(void *mem_ctx,
>> const glsl_type *const block_type =
>> b->type->is_array() ? b->type->fields.array : b->type;
>>
>> + /* Section 2.12.6 (Uniform Variables) of the OpenGL ES 3.0.4 spec says:
>> + *
>> + * "All members of a named uniform block declared with a shared or
>> + * std140 layout qualifier are considered active, even if they are not
>> + * referenced in any shader in the program. The uniform block itself is
>> + * also considered active, even if no member of the block is
>> + * referenced."
>> + *
>> + * If the named uniform block is an array declared with a shared or
>> + * std140 layout qualifier and no shader instruction has referenced it,
>> + * then it is never marked as active, then num_array_elements is zero.
>> + */
>
> As far as I can tell, this is a difference between Desktop GL and ES.
> If that is indeed the case, shouldn't the block below contain a
> _mesa_is_gles3() check?
>
Yeah, you are right, the block below should have _mesa_is_gles3() check.
There is an unreviewed patch from Antía [0] which tackles the same bug
but in src/glsl/link_uniform_block_active_visitor.cpp.
It also needs the _mesa_is_gles3() check. However, I think her patch is
better than this one.
Can you take a look at it? If you agree, we can skip this patch.
Sam
[0] http://lists.freedesktop.org/archives/mesa-dev/2015-March/079102.html
>> + if (b->num_array_elements == 0 && b->type->is_array() &&
>> + (b->type->interface_packing == GLSL_INTERFACE_PACKING_STD140 ||
>> + b->type->interface_packing == GLSL_INTERFACE_PACKING_SHARED)) {
>> + struct link_uniform_block_active *const block =
>> + (struct link_uniform_block_active *) entry->data;
>> + block->num_array_elements = block->type->length;
>> + block->array_elements = reralloc(mem_ctx,
>> + block->array_elements,
>> + unsigned,
>> + block->num_array_elements);
>> + /* Mark the entire array as used. */
>> + for (unsigned i = 0; i < block->num_array_elements; i++)
>> + block->array_elements[i] = i;
>> + }
>> assert((b->num_array_elements > 0) == b->type->is_array());
>>
>> block_size.num_active_uniforms = 0;
>> --
>> 2.1.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