summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir_expression_operation.py
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2016-07-12 16:42:36 -0700
committerIan Romanick <ian.d.romanick@intel.com>2016-08-30 16:28:02 -0700
commit2761190baa7c0b99dfe29366dd6a88449bd6d5bb (patch)
treee440266883fe1236147ac57aed88b2ef445a1f26 /src/compiler/glsl/ir_expression_operation.py
parent6e09c8715de5320dca433c4379fac59efc99c5a8 (diff)
downloadexternal_mesa3d-2761190baa7c0b99dfe29366dd6a88449bd6d5bb.zip
external_mesa3d-2761190baa7c0b99dfe29366dd6a88449bd6d5bb.tar.gz
external_mesa3d-2761190baa7c0b99dfe29366dd6a88449bd6d5bb.tar.bz2
glsl: Generate code for constant ir_triop_lrp expressions
v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
Diffstat (limited to 'src/compiler/glsl/ir_expression_operation.py')
-rw-r--r--src/compiler/glsl/ir_expression_operation.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py
index 5c899a7..0bca59c 100644
--- a/src/compiler/glsl/ir_expression_operation.py
+++ b/src/compiler/glsl/ir_expression_operation.py
@@ -332,6 +332,31 @@ constant_template_vector = mako.template.Template("""\
}
break;""")
+# This template is for ir_triop_lrp.
+constant_template_lrp = mako.template.Template("""\
+ case ${op.get_enum_name()}: {
+ assert(op[0]->type->base_type == GLSL_TYPE_FLOAT ||
+ op[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(op[1]->type->base_type == GLSL_TYPE_FLOAT ||
+ op[1]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(op[2]->type->base_type == GLSL_TYPE_FLOAT ||
+ op[2]->type->base_type == GLSL_TYPE_DOUBLE);
+
+ unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
+ for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
+ switch (this->type->base_type) {
+ % for dst_type, src_types in op.signatures():
+ case ${src_types[0].glsl_type}:
+ data.${dst_type.union_field}[c] = ${op.get_c_expression(src_types, ("c", "c", "c2"))};
+ break;
+ % endfor
+ default:
+ assert(0);
+ }
+ }
+ break;
+ }""")
+
vector_scalar_operation = "vector-scalar"
horizontal_operation = "horizontal"
@@ -416,6 +441,8 @@ class operation(object):
elif self.num_operands == 3:
if self.name == "vector_insert":
return constant_template_vector_insert.render(op=self)
+ elif self.name == "lrp":
+ return constant_template_lrp.render(op=self)
else:
return constant_template3.render(op=self)
elif self.num_operands == 4:
@@ -665,7 +692,7 @@ ir_expression_operation = [
# Fused floating-point multiply-add, part of ARB_gpu_shader5.
operation("fma", 3, source_types=real_types, c_expression="{src0} * {src1} + {src2}"),
- operation("lrp", 3),
+ operation("lrp", 3, source_types=real_types, c_expression={'f': "{src0} * (1.0f - {src2}) + ({src1} * {src2})", 'd': "{src0} * (1.0 - {src2}) + ({src1} * {src2})"}),
# Conditional Select
#