summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_lower_alu_to_scalar.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2016-01-21 15:46:47 -0800
committerMatt Turner <mattst88@gmail.com>2016-02-01 10:43:57 -0800
commit9ce901058f3d08031d486da7f0f8b86ea351ef69 (patch)
tree147e1533815114813e2da1129b3e0e7221740123 /src/compiler/nir/nir_lower_alu_to_scalar.c
parente4278a847e28e763255b8be0daefcf744210a373 (diff)
downloadexternal_mesa3d-9ce901058f3d08031d486da7f0f8b86ea351ef69.zip
external_mesa3d-9ce901058f3d08031d486da7f0f8b86ea351ef69.tar.gz
external_mesa3d-9ce901058f3d08031d486da7f0f8b86ea351ef69.tar.bz2
nir: Add lowering of nir_op_unpack_half_2x16.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Diffstat (limited to 'src/compiler/nir/nir_lower_alu_to_scalar.c')
-rw-r--r--src/compiler/nir/nir_lower_alu_to_scalar.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_lower_alu_to_scalar.c b/src/compiler/nir/nir_lower_alu_to_scalar.c
index 0a27e66..5372fbe 100644
--- a/src/compiler/nir/nir_lower_alu_to_scalar.c
+++ b/src/compiler/nir/nir_lower_alu_to_scalar.c
@@ -97,6 +97,20 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)
*/
return;
+ case nir_op_pack_half_2x16:
+ if (!b->shader->options->lower_pack_half_2x16)
+ return;
+
+ nir_ssa_def *val =
+ nir_pack_half_2x16_split(b, nir_channel(b, instr->src[0].src.ssa,
+ instr->src[0].swizzle[0]),
+ nir_channel(b, instr->src[0].src.ssa,
+ instr->src[0].swizzle[1]));
+
+ nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(val));
+ nir_instr_remove(&instr->instr);
+ return;
+
case nir_op_unpack_unorm_4x8:
case nir_op_unpack_snorm_4x8:
case nir_op_unpack_unorm_2x16:
@@ -106,11 +120,19 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)
*/
return;
- case nir_op_unpack_half_2x16:
- /* We could split this into unpack_half_2x16_split_[xy], but should
- * we?
- */
+ case nir_op_unpack_half_2x16: {
+ if (!b->shader->options->lower_unpack_half_2x16)
+ return;
+
+ nir_ssa_def *comps[2];
+ comps[0] = nir_unpack_half_2x16_split_x(b, instr->src[0].src.ssa);
+ comps[1] = nir_unpack_half_2x16_split_y(b, instr->src[0].src.ssa);
+ nir_ssa_def *vec = nir_vec(b, comps, 2);
+
+ nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(vec));
+ nir_instr_remove(&instr->instr);
return;
+ }
case nir_op_fdph: {
nir_ssa_def *sum[4];