metal: error when generated SPIR-V shader IR can't be parsed

This commit is contained in:
Sasha Szpakowski
2024-01-09 21:29:54 -04:00
parent 7ff6f74a92
commit bf6a6f1237
+13 -8
View File
@@ -30,6 +30,7 @@
#include "libraries/spirv_cross/spirv_reflect.hpp" #include "libraries/spirv_cross/spirv_reflect.hpp"
#include <algorithm> #include <algorithm>
#include <memory>
namespace love namespace love
{ {
@@ -456,11 +457,20 @@ void Shader::compileFromGLSLang(id<MTLDevice> device, const glslang::TProgram &p
std::string msgs = logger.getAllMessages(); std::string msgs = logger.getAllMessages();
// printf("spirv length: %ld, messages:\n%s\n", spirv.size(), msgs.c_str()); // printf("spirv length: %ld, messages:\n%s\n", spirv.size(), msgs.c_str());
try
{
// printf("GLSL INPUT SOURCE:\n\n%s\n\n", pixel->getSource().c_str()); // printf("GLSL INPUT SOURCE:\n\n%s\n\n", pixel->getSource().c_str());
CompilerMSL msl(std::move(spirv)); std::unique_ptr<CompilerMSL> mslpointer;
try
{
mslpointer.reset(new CompilerMSL(std::move(spirv)));
}
catch (std::exception &e)
{
throw love::Exception("Error parsing SPIR-V shader source: %s", e.what());
}
auto &msl = *mslpointer;
auto interfacevars = msl.get_active_interface_variables(); auto interfacevars = msl.get_active_interface_variables();
@@ -724,11 +734,6 @@ void Shader::compileFromGLSLang(id<MTLDevice> device, const glslang::TProgram &p
} }
} }
} }
catch (std::exception &e)
{
printf("Error parsing SPIR-V shader source: %s\n", e.what());
}
}
// Initialize default resource bindings. // Initialize default resource bindings.
for (auto &kvp : uniforms) for (auto &kvp : uniforms)