mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
glsl: Generate code for constant ir_triop_vector_insert 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>
This commit is contained in:
parent
9f1d7c5235
commit
4d8ac28b20
1 changed files with 25 additions and 2 deletions
|
|
@ -288,6 +288,26 @@ constant_template_vector_extract = mako.template.Template("""\
|
|||
break;
|
||||
}""")
|
||||
|
||||
# This template is for ir_triop_vector_insert.
|
||||
constant_template_vector_insert = mako.template.Template("""\
|
||||
case ${op.get_enum_name()}: {
|
||||
const unsigned idx = op[2]->value.u[0];
|
||||
|
||||
memcpy(&data, &op[0]->value, sizeof(data));
|
||||
|
||||
switch (this->type->base_type) {
|
||||
% for dst_type, src_types in op.signatures():
|
||||
case ${src_types[0].glsl_type}:
|
||||
data.${dst_type.union_field}[idx] = op[1]->value.${src_types[0].union_field}[0];
|
||||
break;
|
||||
% endfor
|
||||
default:
|
||||
assert(!"Should not get here.");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}""")
|
||||
|
||||
|
||||
vector_scalar_operation = "vector-scalar"
|
||||
horizontal_operation = "horizontal"
|
||||
|
|
@ -370,7 +390,10 @@ class operation(object):
|
|||
else:
|
||||
return constant_template3.render(op=self)
|
||||
elif self.num_operands == 3:
|
||||
return constant_template3.render(op=self)
|
||||
if self.name == "vector_insert":
|
||||
return constant_template_vector_insert.render(op=self)
|
||||
else:
|
||||
return constant_template3.render(op=self)
|
||||
|
||||
return None
|
||||
|
||||
|
|
@ -632,7 +655,7 @@ ir_expression_operation = [
|
|||
# operand0 is the vector
|
||||
# operand1 is the value to write into the vector result
|
||||
# operand2 is the index in operand0 to be modified
|
||||
operation("vector_insert", 3),
|
||||
operation("vector_insert", 3, source_types=all_types, c_expression="anything-except-None"),
|
||||
|
||||
operation("bitfield_insert", 4),
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue