[Mesa-dev] [PATCH v3] glsl/linker: dvec3/dvec4 consume twice input vertex attributes
Dave Airlie
airlied at gmail.com
Mon May 23 01:01:04 UTC 2016
On 19 May 2016 at 02:41, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On Wednesday, May 18, 2016 1:19:39 PM PDT Juan A. Suarez Romero wrote:
>> From the GL 4.5 core spec, section 11.1.1 (Vertex Attributes):
>>
>> "A program with more than the value of MAX_VERTEX_ATTRIBS
>> active attribute variables may fail to link, unless
>> device-dependent optimizations are able to make the program
>> fit within available hardware resources. For the purposes
>> of this test, attribute variables of the type dvec3, dvec4,
>> dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3, and dmat4 may
>> count as consuming twice as many attributes as equivalent
>> single-precision types. While these types use the same number
>> of generic attributes as their single-precision equivalents,
>> implementations are permitted to consume two single-precision
>> vectors of internal storage for each three- or four-component
>> double-precision vector."
>>
>> This commits makes dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4,
>> dmat4x3 and dmat4 consume twice as many attributes as equivalent
>> single-precision types.
>>
>> v3: count doubles as consuming two attributes (Dave Airlie)
>>
>> Signed-off-by: Antia Puentes <apuentes at igalia.com>
>> Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
>> ---
>> src/compiler/glsl/linker.cpp | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
>> index f208d19..ad96a63 100644
>> --- a/src/compiler/glsl/linker.cpp
>> +++ b/src/compiler/glsl/linker.cpp
>> @@ -2873,6 +2873,25 @@ assign_attribute_or_color_locations(gl_shader_program
> *prog,
>> to_assign[i].var->data.location = generic_base + location;
>> to_assign[i].var->data.is_unmatched_generic_inout = 0;
>> used_locations |= (use_mask << location);
>> +
>> + if (to_assign[i].var->type->without_array()->is_dual_slot_double())
>> + double_storage_locations |= (use_mask << location);
>> + }
>> +
>> + /* Now that we have all the locations, take in account that dvec3/4 can
>> + * require twice the space of single-precision vectors. Check if we run
> out
>> + * of attribute slots.
>> + */
>> + if (target_index == MESA_SHADER_VERTEX) {
>> + unsigned total_attribs_size =
>> + _mesa_bitcount(used_locations & ((1 << max_index) - 1)) +
>> + _mesa_bitcount(double_storage_locations);
>> + if (total_attribs_size > max_index) {
>> + linker_error(prog,
>> + "attempt to use %d vertex attribute slots only %d available ",
>> + total_attribs_size, max_index);
>> + return false;
>> + }
>> }
>>
>> return true;
>>
>
>
> This looks good to me, but it would be good to get a reviewed-by or
> tested-by from Dave Airlie as well.
>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Dave.
More information about the mesa-dev
mailing list