diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-09-16 14:07:00 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-12-19 22:49:39 -0800 |
commit | 4fbc99c1244555eee306053f4757d8bf6d37e2df (patch) | |
tree | 2d67ddd268ccca33dd0facf498440937d621b954 | |
parent | 13adce28455daab3906215aa8d5d473f57cc2e27 (diff) |
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 <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3154>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3154>
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 */ } |