memset(& fields, 0, sizeof(fields));
- matrix_columns = vector_elements = 1;
+ if (is_sampler()) {
+ /* Samplers take no storage whatsoever. */
+ matrix_columns = vector_elements = 0;
+ } else {
+ matrix_columns = vector_elements = 1;
+ }
}
glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
}
{
- unsigned elements = uni->type->components();
+ unsigned elements = (uni->type->is_sampler())
+ ? 1 : uni->type->components();
const int dmul = uni->type->is_64bit() ? 2 : 1;
const int rmul = glsl_base_type_is_64bit(returnType) ? 2 : 1;
{
unsigned i;
- const unsigned components = uni->type->vector_elements;
- const unsigned vectors = uni->type->matrix_columns;
+ /* vector_elements and matrix_columns can be 0 for samplers.
+ */
+ const unsigned components = MAX2(1, uni->type->vector_elements);
+ const unsigned vectors = MAX2(1, uni->type->matrix_columns);
const int dmul = uni->type->is_64bit() ? 2 : 1;
/* Store the data in the driver's requested type in the driver's storage
}
/* Verify that the types are compatible. */
- const unsigned components = uni->type->vector_elements;
+ const unsigned components = uni->type->is_sampler()
+ ? 1 : uni->type->vector_elements;
if (components != src_components) {
/* glUniformN() must match float/vecN type */
return;
}
- const unsigned components = uni->type->vector_elements;
+ const unsigned components = uni->type->is_sampler()
+ ? 1 : uni->type->vector_elements;
/* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
*