From: Caio Marcelo de Oliveira Filho Date: Mon, 16 Sep 2019 21:07:00 +0000 (-0700) Subject: spirv: Implement SPV_KHR_non_semantic_info X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4fbc99c1244555eee306053f4757d8bf6d37e2df;p=mesa.git spirv: Implement SPV_KHR_non_semantic_info Do nothing for OpExtInst from extended instruction sets that name start with "NonSemantic.". Since they can be used within the "preamble" to annotate global decorations, also don't stop iterating when one of them is found. Reviewed-by: Jason Ekstrand Tested-by: Marge Bot Part-of: --- diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 4c85321bff6..29fef9fad66 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -371,6 +371,14 @@ vtn_foreach_instruction(struct vtn_builder *b, const uint32_t *start, return w; } +static bool +vtn_handle_non_semantic_instruction(struct vtn_builder *b, SpvOp ext_opcode, + const uint32_t *w, unsigned count) +{ + /* Do nothing. */ + return true; +} + static void vtn_handle_extension(struct vtn_builder *b, SpvOp opcode, const uint32_t *w, unsigned count) @@ -392,6 +400,8 @@ vtn_handle_extension(struct vtn_builder *b, SpvOp opcode, val->ext_handler = vtn_handle_amd_shader_trinary_minmax_instruction; } else if (strcmp(ext, "OpenCL.std") == 0) { val->ext_handler = vtn_handle_opencl_instruction; + } else if (strstr(ext, "NonSemantic.") == ext) { + val->ext_handler = vtn_handle_non_semantic_instruction; } else { vtn_fail("Unsupported extension: %s", ext); } @@ -4131,6 +4141,17 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, vtn_handle_decoration(b, opcode, w, count); break; + case SpvOpExtInst: { + struct vtn_value *val = vtn_value(b, w[3], vtn_value_type_extension); + if (val->ext_handler == vtn_handle_non_semantic_instruction) { + /* NonSemantic extended instructions are acceptable in preamble. */ + vtn_handle_non_semantic_instruction(b, w[4], w, count); + return true; + } else { + return false; /* End of preamble. */ + } + } + default: return false; /* End of preamble */ } @@ -4469,6 +4490,14 @@ vtn_handle_variable_or_type_instruction(struct vtn_builder *b, SpvOp opcode, vtn_handle_variables(b, opcode, w, count); break; + case SpvOpExtInst: { + struct vtn_value *val = vtn_value(b, w[3], vtn_value_type_extension); + /* NonSemantic extended instructions are acceptable in preamble, others + * will indicate the end of preamble. + */ + return val->ext_handler == vtn_handle_non_semantic_instruction; + } + default: return false; /* End of preamble */ }