diff options
author | Matt Turner <mattst88@gmail.com> | 2014-01-23 15:39:43 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2014-01-27 21:15:35 -0800 |
commit | 3ea64f9093fa1a37abf31db1360e0a66a5e50d98 (patch) | |
tree | 80d59c10e4d5684bec0066d8f51e16654e7d534f /src/glsl/ir_constant_expression.cpp | |
parent | c59a605c70752b584a05bc6f129a1aa894c861ce (diff) | |
download | external_mesa3d-3ea64f9093fa1a37abf31db1360e0a66a5e50d98.zip external_mesa3d-3ea64f9093fa1a37abf31db1360e0a66a5e50d98.tar.gz external_mesa3d-3ea64f9093fa1a37abf31db1360e0a66a5e50d98.tar.bz2 |
glsl: Add constant evaluation of ir_binop_bfm.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r-- | src/glsl/ir_constant_expression.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index f811fd1..7fa5a09 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1397,6 +1397,23 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) break; } + case ir_binop_bfm: { + int bits = op[0]->value.i[0]; + int offset = op[1]->value.i[0]; + + for (unsigned c = 0; c < components; c++) { + if (bits == 0) + data.u[c] = op[0]->value.u[c]; + else if (offset < 0 || bits < 0) + data.u[c] = 0; /* Undefined for bitfieldInsert, per spec. */ + else if (offset + bits > 32) + data.u[c] = 0; /* Undefined for bitfieldInsert, per spec. */ + else + data.u[c] = ((1 << bits) - 1) << offset; + } + break; + } + case ir_binop_ldexp: for (unsigned c = 0; c < components; c++) { data.f[c] = ldexp(op[0]->value.f[c], op[1]->value.i[c]); |