[Mesa-dev] [PATCH 03/17] glsl: Uniform linking support for doubles (was: add double support)

Ilia Mirkin imirkin at alum.mit.edu
Thu Feb 5 17:27:57 PST 2015


On Thu, Feb 5, 2015 at 1:27 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Thu, Feb 5, 2015 at 3:05 AM, Topi Pohjolainen
> <topi.pohjolainen at intel.com> wrote:
>> From: Dave Airlie <airlied at gmail.com>
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>>  src/glsl/link_uniforms.cpp | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
>> index de2f6c9..0db70d5 100644
>> --- a/src/glsl/link_uniforms.cpp
>> +++ b/src/glsl/link_uniforms.cpp
>> @@ -51,6 +51,9 @@ values_for_type(const glsl_type *type)
>>        return 1;
>>     } else if (type->is_array() && type->fields.array->is_sampler()) {
>>        return type->array_size();
>> +   } else if ((type->is_array() && type->fields.array->is_double()) ||
>> +              type->is_double()) {
>> +      return 2 * type->component_slots();
>>     } else {
>>        return type->component_slots();
>>     }
>> @@ -608,8 +611,11 @@ private:
>>          }
>>
>>          if (type->without_array()->is_matrix()) {
>> -           this->uniforms[id].matrix_stride = 16;
>> +            unsigned N = type->base_type == GLSL_TYPE_DOUBLE ? 8 : 4;
>> +            unsigned items = row_major ? type->matrix_columns : type->vector_elements;
>
> I'm not sure I understand how this line relates to adding double
> support. If we needed to consider row_major, shouldn't we have already
> been doing that?

Not sure, but my understanding is that the max size in any direction
was 4, hence it was statically set to 16. With doubles, a dmat2 will
have 16, while a dmat3/dmat4 will have 32. The row/column major thing
comes in for, e.g., dmat2x4.

>
>> +            this->uniforms[id].matrix_stride = glsl_align(items * N, 16);
>>             this->uniforms[id].row_major = row_major;
>> +
>
> Stray newline.
> _______________________________________________
> 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