- if (!all_parameters_are_constant)
- return NULL;
-
- return new(ctx) ir_constant(constructor_type, parameters);
-}
-
-
-/**
- * Generate data for a constant matrix constructor w/a single scalar parameter
- *
- * Matrix constructors in GLSL can be passed a single scalar of the
- * approriate type. In these cases, the resulting matrix is the identity
- * matrix multipled by the specified scalar. This function generates data for
- * that matrix.
- *
- * \param type Type of the desired matrix.
- * \param initializer Scalar value used to initialize the matrix diagonal.
- * \param data Location to store the resulting matrix.
- */
-void
-generate_constructor_matrix(const glsl_type *type, ir_constant *initializer,
- ir_constant_data *data)
-{
- switch (type->base_type) {
- case GLSL_TYPE_UINT:
- case GLSL_TYPE_INT:
- for (unsigned i = 0; i < type->components(); i++)
- data->u[i] = 0;
-
- for (unsigned i = 0; i < type->matrix_columns; i++) {
- /* The array offset of the ith row and column of the matrix.
- */
- const unsigned idx = (i * type->vector_elements) + i;
-
- data->u[idx] = initializer->value.u[0];
- }
- break;
-
- case GLSL_TYPE_FLOAT:
- for (unsigned i = 0; i < type->components(); i++)
- data->f[i] = 0;
-
- for (unsigned i = 0; i < type->matrix_columns; i++) {
- /* The array offset of the ith row and column of the matrix.
- */
- const unsigned idx = (i * type->vector_elements) + i;
-
- data->f[idx] = initializer->value.f[0];
- }
-
- break;
-
- default:
- assert(!"Should not get here.");
- break;
- }
-}
-
-
-/**
- * Generate data for a constant vector constructor w/a single scalar parameter
- *
- * Vector constructors in GLSL can be passed a single scalar of the
- * approriate type. In these cases, the resulting vector contains the specified
- * value in all components. This function generates data for that vector.
- *
- * \param type Type of the desired vector.
- * \param initializer Scalar value used to initialize the vector.
- * \param data Location to store the resulting vector data.
- */
-void
-generate_constructor_vector(const glsl_type *type, ir_constant *initializer,
- ir_constant_data *data)
-{
- switch (type->base_type) {
- case GLSL_TYPE_UINT:
- case GLSL_TYPE_INT:
- for (unsigned i = 0; i < type->components(); i++)
- data->u[i] = initializer->value.u[0];
-
- break;
-
- case GLSL_TYPE_FLOAT:
- for (unsigned i = 0; i < type->components(); i++)
- data->f[i] = initializer->value.f[0];
-
- break;
-
- case GLSL_TYPE_BOOL:
- for (unsigned i = 0; i < type->components(); i++)
- data->b[i] = initializer->value.b[0];
-
- break;
-
- default:
- assert(!"Should not get here.");
- break;
- }