On Fri, Feb 6, 2015 at 2:38 AM, Ian Romanick <i...@freedesktop.org> wrote: > On 02/06/2015 06:56 AM, Ilia Mirkin wrote: >> From: Dave Airlie <airl...@gmail.com> >> >> Signed-off-by: Dave Airlie <airl...@redhat.com> >> --- >> src/glsl/link_uniforms.cpp | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp >> index de2f6c9..0a4dac2 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,7 +611,9 @@ 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; >> + this->uniforms[id].matrix_stride = glsl_align(items * N, 16); > > Could we add an assert that matrix_stride is either 16 or 32? The > value is always 16 if GLSL_TYPE_FLOAT or items <= 2, and it's 32 > otherwise. I'm on the fence whether it's better to just do that > explicitly: > > const unsigned items = row_major ? type->matrix_columns : > type->vector_elements; > this->uniforms[id].matrix_stride = (type->base_type == GLSL_TYPE_FLOAT || > items <= 2) ? 16 : 32; > > Thoughts?
I actually kinda prefer assert(items <= 4) Since N is fixed at either 4 or 8, and glsl_align is a pretty obvious function. I've added this for the next version. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev