diff --git a/libs/matdbg/src/DebugServer.cpp b/libs/matdbg/src/DebugServer.cpp index f3449bffe4..95c5a637d9 100644 --- a/libs/matdbg/src/DebugServer.cpp +++ b/libs/matdbg/src/DebugServer.cpp @@ -70,20 +70,13 @@ static const std::string_view kErrorHeader = "Connection: close\r\n\r\n"; static void spirvToAsm(struct mg_connection *conn, const uint32_t* spirv, size_t size) { - auto context = spvContextCreate(SPV_ENV_UNIVERSAL_1_3); - spv_text text = nullptr; - const uint32_t options = SPV_BINARY_TO_TEXT_OPTION_INDENT | - SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES; - spvBinaryToText(context, spirv, size / 4, options, &text, nullptr); - + auto spirvDisassembly = ShaderExtractor::spirvToText(spirv, size / 4); mg_printf(conn, kSuccessHeader.data(), "application/txt"); - mg_write(conn, text->str, text->length); - spvTextDestroy(text); - spvContextDestroy(context); + mg_write(conn, spirvDisassembly.c_str(), spirvDisassembly.size()); } -static void spirvToGlsl(ShaderModel shaderModel, struct mg_connection *conn, const uint32_t* spirv, - size_t size) { +static void spirvToGlsl(ShaderModel shaderModel, struct mg_connection *conn, + const uint32_t* spirv, size_t size) { auto glsl = ShaderExtractor::spirvToGLSL(shaderModel, spirv, size / 4); mg_printf(conn, kSuccessHeader.data(), "application/txt"); mg_printf(conn, glsl.c_str(), glsl.size()); diff --git a/libs/matdbg/src/ShaderExtractor.cpp b/libs/matdbg/src/ShaderExtractor.cpp index b463a8e344..5de2f5ab97 100644 --- a/libs/matdbg/src/ShaderExtractor.cpp +++ b/libs/matdbg/src/ShaderExtractor.cpp @@ -101,7 +101,6 @@ CString ShaderExtractor::spirvToGLSL(ShaderModel shaderModel, const uint32_t* da emitOptions.version = 450; } emitOptions.vulkan_semantics = true; - //emitOptions.emit_line_directives = true; std::vector spirv(data, data + wordCount); CompilerGLSL glslCompiler(std::move(spirv)); @@ -115,7 +114,8 @@ CString ShaderExtractor::spirvToGLSL(ShaderModel shaderModel, const uint32_t* da // uses, which lets us easily generate test cases for the spirv-cross project. CString ShaderExtractor::spirvToText(const uint32_t* begin, size_t wordCount) { spv_context context = spvContextCreate(SPV_ENV_UNIVERSAL_1_3); - if (SPV_SUCCESS != spvValidateBinary(context, begin, wordCount, nullptr)) { + + if (spvValidateBinary(context, begin, wordCount, nullptr) != SPV_SUCCESS) { spvContextDestroy(context); return CString("Validation failure."); }