diff options
author | Samuel Iglesias Gonsálvez <siglesias@igalia.com> | 2017-11-20 13:12:12 +0100 |
---|---|---|
committer | Samuel Iglesias Gonsálvez <siglesias@igalia.com> | 2017-12-07 10:19:34 +0100 |
commit | 392638d6b549dbed85ed2a82fa41d38336ac9938 (patch) | |
tree | 2e6375f086745837fbd16aa6e53389a625e001a0 /src/compiler/spirv | |
parent | 67ec314347ed03738cb4eece64c7b25b4ab7d3c8 (diff) |
spirv: fix bug when OpSpecConstantOp calls a conversion
In that case, nir_eval_const_opcode() will evaluate the conversion
but as it was using destination's bit_size, the resulting
value was just a cast of the source constant value. By passing the
source's bit size, it does the conversion properly.
Fixes:
dEQP-VK.spirv_assembly.instruction.*.opspecconstantop.*convert*
v2:
- Remove invalid conversion op cases.
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index c6efefb26f7..e5d447f23a9 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1570,16 +1570,31 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode, bool swap; nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_type(val->const_type); nir_alu_type src_alu_type = dst_alu_type; + unsigned num_components = glsl_get_vector_elements(val->const_type); + unsigned bit_size; + + vtn_assert(count <= 7); + + switch (opcode) { + case SpvOpSConvert: + case SpvOpFConvert: + /* We have a source in a conversion */ + src_alu_type = + nir_get_nir_type_for_glsl_type( + vtn_value(b, w[4], vtn_value_type_constant)->const_type); + /* We use the bitsize of the conversion source to evaluate the opcode later */ + bit_size = glsl_get_bit_size( + vtn_value(b, w[4], vtn_value_type_constant)->const_type); + break; + default: + bit_size = glsl_get_bit_size(val->const_type); + }; + nir_op op = vtn_nir_alu_op_for_spirv_opcode(b, opcode, &swap, src_alu_type, dst_alu_type); - - unsigned num_components = glsl_get_vector_elements(val->const_type); - unsigned bit_size = - glsl_get_bit_size(val->const_type); - nir_const_value src[4]; - vtn_assert(count <= 7); + for (unsigned i = 0; i < count - 4; i++) { nir_constant *c = vtn_value(b, w[4 + i], vtn_value_type_constant)->constant; |