summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2014-09-03 13:12:54 +0300
committerTopi Pohjolainen <topi.pohjolainen@intel.com>2014-11-11 11:15:00 +0200
commitf1e51b0ea4a7b2b6f02ed95814e0d73d27795d15 (patch)
tree2b2e4df790cfcd557c7998d87f9fa65a63b3d995
parent6aa3c626b943a8b242f98a7f152f07ce8cff8d7b (diff)
SQUASH: support double when constructing matrix from scalar
Patch adds support for both const and non-const cases. Patch makes following Piglit test pass: glsl-double-conversion-constructor-01.shader_test Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
-rw-r--r--src/glsl/ast_function.cpp17
-rw-r--r--src/glsl/ir.cpp13
2 files changed, 21 insertions, 9 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index a66d7309447..36ad66691d2 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -1203,16 +1203,21 @@ emit_inline_matrix_constructor(const glsl_type *type,
/* Assign the scalar to the X component of a vec4, and fill the remaining
* components with zero.
*/
+ glsl_base_type param_base_type = first_param->type->base_type;
+ assert(param_base_type == GLSL_TYPE_FLOAT ||
+ param_base_type == GLSL_TYPE_DOUBLE);
ir_variable *rhs_var =
- new(ctx) ir_variable(glsl_type::vec4_type, "mat_ctor_vec",
- ir_var_temporary);
+ new(ctx) ir_variable(glsl_type::get_instance(param_base_type, 4, 1),
+ "mat_ctor_vec",
+ ir_var_temporary);
instructions->push_tail(rhs_var);
ir_constant_data zero;
- zero.f[0] = 0.0;
- zero.f[1] = 0.0;
- zero.f[2] = 0.0;
- zero.f[3] = 0.0;
+ for (unsigned i = 0; i < 4; i++)
+ if (param_base_type == GLSL_TYPE_FLOAT)
+ zero.f[i] = 0.0;
+ else
+ zero.d[i] = 0.0;
ir_instruction *inst =
new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var),
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 37dbc96cd67..4db7fa9a9f9 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -800,9 +800,16 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
if (value->type->is_scalar() && value->next->is_tail_sentinel()) {
if (type->is_matrix()) {
/* Matrix - fill diagonal (rest is already set to 0) */
- assert(type->base_type == GLSL_TYPE_FLOAT);
- for (unsigned i = 0; i < type->matrix_columns; i++)
- this->value.f[i * type->vector_elements + i] = value->value.f[0];
+ assert(type->base_type == GLSL_TYPE_FLOAT ||
+ type->base_type == GLSL_TYPE_DOUBLE);
+ for (unsigned i = 0; i < type->matrix_columns; i++) {
+ if (type->base_type == GLSL_TYPE_FLOAT)
+ this->value.f[i * type->vector_elements + i] =
+ value->value.f[0];
+ else
+ this->value.d[i * type->vector_elements + i] =
+ value->value.d[0];
+ }
} else {
/* Vector or scalar - fill all components */
switch (type->base_type) {