Browse Source

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>
master
Caio Marcelo de Oliveira Filho 7 years ago
parent
commit
4fbc99c124
1 changed files with 29 additions and 0 deletions
  1. 29
    0
      src/compiler/spirv/spirv_to_nir.c

+ 29
- 0
src/compiler/spirv/spirv_to_nir.c View File

return w; 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 static void
vtn_handle_extension(struct vtn_builder *b, SpvOp opcode, vtn_handle_extension(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count) const uint32_t *w, unsigned count)
val->ext_handler = vtn_handle_amd_shader_trinary_minmax_instruction; val->ext_handler = vtn_handle_amd_shader_trinary_minmax_instruction;
} else if (strcmp(ext, "OpenCL.std") == 0) { } else if (strcmp(ext, "OpenCL.std") == 0) {
val->ext_handler = vtn_handle_opencl_instruction; val->ext_handler = vtn_handle_opencl_instruction;
} else if (strstr(ext, "NonSemantic.") == ext) {
val->ext_handler = vtn_handle_non_semantic_instruction;
} else { } else {
vtn_fail("Unsupported extension: %s", ext); vtn_fail("Unsupported extension: %s", ext);
} }
vtn_handle_decoration(b, opcode, w, count); vtn_handle_decoration(b, opcode, w, count);
break; 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: default:
return false; /* End of preamble */ return false; /* End of preamble */
} }
vtn_handle_variables(b, opcode, w, count); vtn_handle_variables(b, opcode, w, count);
break; 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: default:
return false; /* End of preamble */ return false; /* End of preamble */
} }

Loading…
Cancel
Save