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 <jason@jlekstrand.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3154>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3154>
This commit is contained in:
Caio Marcelo de Oliveira Filho
2019-09-16 14:07:00 -07:00
parent 13adce2845
commit 4fbc99c124

View File

@@ -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 */
}