From: Alejandro Piñeiro Date: Fri, 13 Oct 2017 14:17:51 +0000 (+0200) Subject: spirv_extensions: add list of extensions and to_string method X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=06e5daf5758ffdc06a5a96ab0fe58552732e35d1;p=mesa.git spirv_extensions: add list of extensions and to_string method Ideally this should be generated somehow. One option would be gather all the extension dependencies listed on the core grammar, but there would be the possibility of not including some of the extensions. Note that spirv-tools is doing it just slightly better, as it has a hardcoded list of extensions manually took from the registry, that they parse to get the enum and the to_string method (see generate_grammar_tables.py). v2: * Use a macro to improve readability. (Tapani Pälli) * Add unreachable on the switch, no default (Eric Engestrom) * No typedef enum (Ian Romanick) * Sort extensions names (Ian Romanick) * Don't add extensions unlikely to be supported by Mesa at any point (Ian Romanick) v3: rebase update v4: Include AMD_gcn_shader v5: move spirv_extensions_to_string to src/mesa/main/spirv_extensions.c Signed-off-by: Alejandro Piñeiro Signed-off-by: Arcady Goldmints-Orlov Reviewed-by: Caio Marcelo de Oliveira Filho --- diff --git a/src/mesa/main/spirv_extensions.c b/src/mesa/main/spirv_extensions.c index 40a89c133aa..7598510e21c 100644 --- a/src/mesa/main/spirv_extensions.c +++ b/src/mesa/main/spirv_extensions.c @@ -40,3 +40,25 @@ _mesa_get_enabled_spirv_extension(struct gl_context *ctx, { return (const GLubyte *) 0; } + +const char * +_mesa_spirv_extensions_to_string(enum SpvExtension ext) +{ +#define STR(x) case x: return #x; + switch (ext) { + STR(SPV_KHR_16bit_storage); + STR(SPV_KHR_device_group); + STR(SPV_KHR_multiview); + STR(SPV_KHR_shader_ballot); + STR(SPV_KHR_shader_draw_parameters); + STR(SPV_KHR_storage_buffer_storage_class); + STR(SPV_KHR_subgroup_vote); + STR(SPV_KHR_variable_pointers); + STR(SPV_AMD_gcn_shader); + case SPV_EXTENSIONS_COUNT: + unreachable("Unknown SPIR-V extension"); + } +#undef STR + + return "unknown"; +} diff --git a/src/mesa/main/spirv_extensions.h b/src/mesa/main/spirv_extensions.h index 35754f7e53b..6c8b8275945 100644 --- a/src/mesa/main/spirv_extensions.h +++ b/src/mesa/main/spirv_extensions.h @@ -35,6 +35,19 @@ extern "C" { #endif +enum SpvExtension { + SPV_KHR_16bit_storage = 0, + SPV_KHR_device_group, + SPV_KHR_multiview, + SPV_KHR_shader_ballot, + SPV_KHR_shader_draw_parameters, + SPV_KHR_storage_buffer_storage_class, + SPV_KHR_subgroup_vote, + SPV_KHR_variable_pointers, + SPV_AMD_gcn_shader, + SPV_EXTENSIONS_COUNT +}; + extern GLuint _mesa_get_spirv_extension_count(struct gl_context *ctx); @@ -42,6 +55,8 @@ extern const GLubyte * _mesa_get_enabled_spirv_extension(struct gl_context *ctx, GLuint index); +const char *_mesa_spirv_extensions_to_string(enum SpvExtension ext); + #ifdef __cplusplus } #endif