diff options
author | Caio Oliveira <caio.oliveira@intel.com> | 2023-05-11 14:32:45 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-05-17 18:27:41 +0000 |
commit | a32f97530a3874d4b3933c591683c3b4a60306f5 (patch) | |
tree | 6e5d3992d18958b5bbd529c35a91d17fbf943ce7 | |
parent | 5039b595477589a6e39bd6e5a390ed565b89a793 (diff) | |
download | mesa-a32f97530a3874d4b3933c591683c3b4a60306f5.tar.gz |
spirv: Extract vtn_handle_debug_text() helper
This will be later used by gl_spirv handling.
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22973>
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 81 | ||||
-rw-r--r-- | src/compiler/spirv/vtn_private.h | 3 |
2 files changed, 53 insertions, 31 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index d94c736147a..11c12ceb3d5 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -4497,28 +4497,13 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, const uint32_t *w, unsigned count) { switch (opcode) { - case SpvOpSource: { - const char *lang; - switch (w[1]) { - default: - case SpvSourceLanguageUnknown: lang = "unknown"; break; - case SpvSourceLanguageESSL: lang = "ESSL"; break; - case SpvSourceLanguageGLSL: lang = "GLSL"; break; - case SpvSourceLanguageOpenCL_C: lang = "OpenCL C"; break; - case SpvSourceLanguageOpenCL_CPP: lang = "OpenCL C++"; break; - case SpvSourceLanguageHLSL: lang = "HLSL"; break; - } - - uint32_t version = w[2]; - - const char *file = - (count > 3) ? vtn_value(b, w[3], vtn_value_type_string)->str : ""; - - vtn_info("Parsing SPIR-V from %s %u source file %s", lang, version, file); - - b->source_lang = w[1]; + case SpvOpString: + case SpvOpSource: + case SpvOpSourceExtension: + case SpvOpSourceContinued: + case SpvOpModuleProcessed: + vtn_handle_debug_text(b, opcode, w, count); break; - } case SpvOpExtension: { /* Implementing both NV_mesh_shader and EXT_mesh_shader @@ -4530,11 +4515,6 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, b->shader->info.mesh.nv = true; break; } - case SpvOpSourceExtension: - case SpvOpSourceContinued: - case SpvOpModuleProcessed: - /* Unhandled, but these are for debug so that's ok. */ - break; case SpvOpCapability: { SpvCapability cap = w[1]; @@ -5022,11 +5002,6 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, vtn_handle_entry_point(b, w, count); break; - case SpvOpString: - vtn_push_value(b, w[1], vtn_value_type_string)->str = - vtn_string_literal(b, &w[2], count - 2, NULL); - break; - case SpvOpName: b->values[w[1]].name = vtn_string_literal(b, &w[2], count - 2, NULL); break; @@ -5063,6 +5038,50 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, return true; } +void +vtn_handle_debug_text(struct vtn_builder *b, SpvOp opcode, + const uint32_t *w, unsigned count) +{ + switch (opcode) { + case SpvOpString: + vtn_push_value(b, w[1], vtn_value_type_string)->str = + vtn_string_literal(b, &w[2], count - 2, NULL); + break; + + case SpvOpSource: { + const char *lang; + switch (w[1]) { + default: + case SpvSourceLanguageUnknown: lang = "unknown"; break; + case SpvSourceLanguageESSL: lang = "ESSL"; break; + case SpvSourceLanguageGLSL: lang = "GLSL"; break; + case SpvSourceLanguageOpenCL_C: lang = "OpenCL C"; break; + case SpvSourceLanguageOpenCL_CPP: lang = "OpenCL C++"; break; + case SpvSourceLanguageHLSL: lang = "HLSL"; break; + } + + uint32_t version = w[2]; + + const char *file = + (count > 3) ? vtn_value(b, w[3], vtn_value_type_string)->str : ""; + + vtn_info("Parsing SPIR-V from %s %u source file %s", lang, version, file); + + b->source_lang = w[1]; + break; + } + + case SpvOpSourceExtension: + case SpvOpSourceContinued: + case SpvOpModuleProcessed: + /* Unhandled, but these are for debug so that's ok. */ + break; + + default: + unreachable("Unhandled opcode"); + } +} + static void vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, const struct vtn_decoration *mode, UNUSED void *data) diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 465367823fe..0f5593605ac 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -955,6 +955,9 @@ struct vtn_builder* vtn_create_builder(const uint32_t *words, size_t word_count, void vtn_handle_entry_point(struct vtn_builder *b, const uint32_t *w, unsigned count); +void vtn_handle_debug_text(struct vtn_builder *b, SpvOp opcode, + const uint32_t *w, unsigned count); + void vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode, const uint32_t *w, unsigned count); |