[Mesa-dev] [PATCH 13/20] glsl: fixes to implicit conversions required by GL_ARB_gpu_shader_fp64
Dave Airlie
airlied at gmail.com
Wed Sep 3 21:15:35 PDT 2014
From: Tapani Pälli <tapani.palli at intel.com>
Patch makes following Piglit test pass:
arb_gpu_shader_fp64/compiler/implicit-conversions.vert
v2: fix issues in 'can_implicitly_convert_to' and take
has_double() in use (Dave Airlie)
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
src/glsl/ast_to_hir.cpp | 10 ++++++++++
src/glsl/glsl_types.cpp | 12 ++++++++++++
src/glsl/ir_builder.cpp | 12 ++++++++++++
src/glsl/ir_builder.h | 2 ++
src/mesa/drivers/dri/i965/brw_fs.cpp | 1 +
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 1 +
6 files changed, 38 insertions(+)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index efebf50..06864da 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -184,6 +184,16 @@ get_conversion_operation(const glsl_type *to, const glsl_type *from,
default: return (ir_expression_operation)0;
}
+ case GLSL_TYPE_DOUBLE:
+ if (!state->has_double())
+ return (ir_expression_operation)0;
+ switch (from->base_type) {
+ case GLSL_TYPE_INT: return ir_unop_i2d;
+ case GLSL_TYPE_UINT: return ir_unop_u2d;
+ case GLSL_TYPE_FLOAT: return ir_unop_f2d;
+ default: return (ir_expression_operation)0;
+ }
+
default: return (ir_expression_operation)0;
}
}
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 649dbc4..6ab1db3 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -777,6 +777,18 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired,
desired->base_type == GLSL_TYPE_UINT && this->base_type == GLSL_TYPE_INT)
return true;
+ /* No implicit conversions from double. */
+ if ((!state || state->has_double()) && this->is_double())
+ return false;
+
+ /* Conversions from different types to double. */
+ if ((!state || state->has_double()) && desired->is_double()) {
+ if (this->is_float())
+ return true;
+ if (this->is_integer())
+ return true;
+ }
+
return false;
}
diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 25789e9..37bbffa 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -526,6 +526,18 @@ f2d(operand a)
}
ir_expression *
+i2d(operand a)
+{
+ return expr(ir_unop_i2d, a);
+}
+
+ir_expression *
+u2d(operand a)
+{
+ return expr(ir_unop_u2d, a);
+}
+
+ir_expression *
fma(operand a, operand b, operand c)
{
return expr(ir_triop_fma, a, b, c);
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index 7881288..81571ef 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -185,6 +185,8 @@ ir_expression *f2b(operand a);
ir_expression *b2f(operand a);
ir_expression *f2d(operand a);
+ir_expression *i2d(operand a);
+ir_expression *u2d(operand a);
ir_expression *min2(operand a, operand b);
ir_expression *max2(operand a, operand b);
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 5f98287..e5dbfe0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -501,6 +501,7 @@ fs_visitor::type_size(const struct glsl_type *type)
case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT:
case GLSL_TYPE_BOOL:
+ case GLSL_TYPE_DOUBLE:
return type->components();
case GLSL_TYPE_ARRAY:
return type_size(type->fields.array) * type->length;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index ba163ec..6eeefbf 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1013,6 +1013,7 @@ fs_visitor::emit_assignment_writes(fs_reg &l, fs_reg &r,
{
switch (type->base_type) {
case GLSL_TYPE_FLOAT:
+ case GLSL_TYPE_DOUBLE:
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
case GLSL_TYPE_BOOL:
--
2.1.0
More information about the mesa-dev
mailing list