glsl: Add ir_binop_vector_extract
The new opcode is used to get a single field from a vector. The field index may not be constant. This will eventually replace ir_dereference_array of vectors. This is similar to the extractelement instruction in LLVM IR. http://llvm.org/docs/LangRef.html#extractelement-instruction v2: Convert tabs to spaces. Suggested by Eric. v3: Add array index range checking to ir_binop_vector_extract constant expression handling. Suggested by Ken. v4: Use CLAMP instead of MIN2(MAX2()). Suggested by Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -399,6 +399,10 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
|
||||
this->type = op0->type;
|
||||
break;
|
||||
|
||||
case ir_binop_vector_extract:
|
||||
this->type = op0->type->get_scalar_type();
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(!"not reached: missing automatic type setup for ir_expression");
|
||||
this->type = glsl_type::float_type;
|
||||
@@ -510,6 +514,7 @@ static const char *const operator_strs[] = {
|
||||
"packHalf2x16_split",
|
||||
"bfm",
|
||||
"ubo_load",
|
||||
"vector_extract",
|
||||
"lrp",
|
||||
"bfi",
|
||||
"bitfield_extract",
|
||||
|
Reference in New Issue
Block a user