Revert "[Chore] (MG_Util/Program): use SPIRV-Cross C++ API instead of C ones"

This reverts commit 8e0284faec.
This commit is contained in:
2025-08-02 18:01:36 +08:00
parent 8e0284faec
commit 972a4efed1
6 changed files with 57 additions and 83 deletions
+3 -1
View File
@@ -27,8 +27,10 @@ namespace MobileGL {
WideCharToMultiByte(CP_UTF8, 0, desc, -1, buffer, sizeof(buffer), nullptr, nullptr);
LocalFree(desc);
}
#elif defined(__ANDROID__) || defined(__linux__) || defined(__APPLE__)
#elif defined(__ANDROID__) || defined(__linux__)
pthread_getname_np(pthread_self(), buffer, sizeof(buffer));
#elif defined(__APPLE__)
pthread_getname_np(buffer, sizeof(buffer));
#endif
return buffer[0] ? buffer : "UnknownThread";
}
@@ -207,37 +207,18 @@ namespace MobileGL {
const char *result = nullptr;
session.Compile(&result);
// if (!result) {
// ResultInfo r;
// r.log += "Failed to compile the shader to GLSL: \n";
// r.log += session.GetLastErrorString();
// r.errc = -5;
// return std::unexpected(r);
// }
if (!result) {
ResultInfo r;
r.log += "Failed to compile the shader to GLSL: \n";
r.log += session.GetLastErrorString();
r.errc = -5;
return std::unexpected(r);
}
std::string glsl = result;
return glsl;
}
Result<String> ShaderCompiler::DecompileShader(spirv_cross::CompilerGLSL& compiler) {
try {
spirv_cross::CompilerGLSL::Options options;
options.version = 450;
options.es = false;
options.vulkan_semantics = true;
compiler.set_common_options(options);
auto result = compiler.compile();
return result;
} catch (const spirv_cross::CompilerError& e) {
ResultInfo r;
r.log += "Failed to compile the shader to GLSL: \n";
r.log += e.what();
r.errc = -5;
return std::unexpected(r);
}
}
}
}
}
@@ -8,7 +8,6 @@ namespace ShaderTranspiler {
static Result<SharedPtr<glslang::TShader>> CompileShader(const ShaderAttrib& attrib);
static Result<Vector<Vector<unsigned>>> LinkProgram(const ProgramAttrib& attrib);
static Result<String> DecompileShader(SpvcSession& session);
static Result<String> DecompileShader(spirv_cross::CompilerGLSL& compiler);
};
}
}