diff options
author | Samuel Iglesias Gonsálvez <[email protected]> | 2016-12-07 08:10:16 +0100 |
---|---|---|
committer | Samuel Iglesias Gonsálvez <[email protected]> | 2017-01-09 09:10:13 +0100 |
commit | c332432bae6d78c8fa8a74ecae7ef3d22a500762 (patch) | |
tree | 84fdd549116e074cf9b6afc967b48324cff29c4d /src/compiler/spirv/vtn_alu.c | |
parent | 27cf6a369fcec15a9f65837507f57dbd8bdfaaaa (diff) |
spirv/nir: implement DF conversions
SPIR-V does not have special opcodes for DF conversions. We need to identify
them by checking the bit size of the operand and the result.
Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_alu.c')
-rw-r--r-- | src/compiler/spirv/vtn_alu.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c index 95ff2b1aafe..55f7f2ea42f 100644 --- a/src/compiler/spirv/vtn_alu.c +++ b/src/compiler/spirv/vtn_alu.c @@ -211,7 +211,8 @@ vtn_handle_matrix_alu(struct vtn_builder *b, SpvOp opcode, } nir_op -vtn_nir_alu_op_for_spirv_opcode(SpvOp opcode, bool *swap) +vtn_nir_alu_op_for_spirv_opcode(SpvOp opcode, bool *swap, + nir_alu_type src, nir_alu_type dst) { /* Indicates that the first two arguments should be swapped. This is * used for implementing greater-than and less-than-or-equal. @@ -284,16 +285,16 @@ vtn_nir_alu_op_for_spirv_opcode(SpvOp opcode, bool *swap) case SpvOpFUnordGreaterThanEqual: return nir_op_fge; /* Conversions: */ - case SpvOpConvertFToU: return nir_op_f2u; - case SpvOpConvertFToS: return nir_op_f2i; - case SpvOpConvertSToF: return nir_op_i2f; - case SpvOpConvertUToF: return nir_op_u2f; case SpvOpBitcast: return nir_op_imov; case SpvOpUConvert: case SpvOpQuantizeToF16: return nir_op_fquantize2f16; - /* TODO: NIR is 32-bit only; these are no-ops. */ - case SpvOpSConvert: return nir_op_imov; - case SpvOpFConvert: return nir_op_fmov; + case SpvOpConvertFToU: + case SpvOpConvertFToS: + case SpvOpConvertSToF: + case SpvOpConvertUToF: + case SpvOpSConvert: + case SpvOpFConvert: + return nir_type_conversion_op(src, dst); /* Derivatives: */ case SpvOpDPdx: return nir_op_fddx; @@ -457,7 +458,9 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode, case SpvOpFUnordLessThanEqual: case SpvOpFUnordGreaterThanEqual: { bool swap; - nir_op op = vtn_nir_alu_op_for_spirv_opcode(opcode, &swap); + nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_type(vtn_src[0]->type); + nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type); + nir_op op = vtn_nir_alu_op_for_spirv_opcode(opcode, &swap, src_alu_type, dst_alu_type); if (swap) { nir_ssa_def *tmp = src[0]; @@ -481,7 +484,9 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode, case SpvOpFOrdLessThanEqual: case SpvOpFOrdGreaterThanEqual: { bool swap; - nir_op op = vtn_nir_alu_op_for_spirv_opcode(opcode, &swap); + nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_type(vtn_src[0]->type); + nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type); + nir_op op = vtn_nir_alu_op_for_spirv_opcode(opcode, &swap, src_alu_type, dst_alu_type); if (swap) { nir_ssa_def *tmp = src[0]; @@ -500,7 +505,9 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode, default: { bool swap; - nir_op op = vtn_nir_alu_op_for_spirv_opcode(opcode, &swap); + nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_type(vtn_src[0]->type); + nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(type); + nir_op op = vtn_nir_alu_op_for_spirv_opcode(opcode, &swap, src_alu_type, dst_alu_type); if (swap) { nir_ssa_def *tmp = src[0]; |