mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (MG_Util/GLSLTool): specify vulkan semantics to convert gl_VertexID/gl_InstanceID
This commit is contained in:
@@ -233,7 +233,7 @@ namespace MG_GL::GL {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
MG_State::SetError(result);
|
MG_State::SetError(result);
|
||||||
MG_Util::Debug::LogE("Error deleting shader: %s", MG_Util::Debug::GLEnumToString(result));
|
MG_Util::Debug::LogW("Error deleting shader: %s", MG_Util::Debug::GLEnumToString(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteProgram(GLuint program) {
|
void DeleteProgram(GLuint program) {
|
||||||
@@ -297,7 +297,7 @@ namespace MG_GL::GL {
|
|||||||
auto it = MG_State_T::programState->shaders_.find(shaderId);
|
auto it = MG_State_T::programState->shaders_.find(shaderId);
|
||||||
if (it != MG_State_T::programState->shaders_.end() && !it->second.markedForDeletion) {
|
if (it != MG_State_T::programState->shaders_.end() && !it->second.markedForDeletion) {
|
||||||
shaderSources[it->first] = it->second.source;
|
shaderSources[it->first] = it->second.source;
|
||||||
MG_Util::Program::RenameGLSLBuiltinsForVulkan(shaderSources[it->first]);
|
// MG_Util::Program::RenameGLSLBuiltinsForVulkan(shaderSources[it->first]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,7 +394,8 @@ namespace MG_GL::GL {
|
|||||||
ShaderCI.SourceLanguage = Diligent::SHADER_SOURCE_LANGUAGE_GLSL_VERBATIM;
|
ShaderCI.SourceLanguage = Diligent::SHADER_SOURCE_LANGUAGE_GLSL_VERBATIM;
|
||||||
|
|
||||||
Diligent::IShader* pShader = nullptr;
|
Diligent::IShader* pShader = nullptr;
|
||||||
MG_Diligent::g_pDevice->CreateShader(ShaderCI, &pShader);
|
Diligent::RefCntAutoPtr<Diligent::IDataBlob> pMsg;
|
||||||
|
MG_Diligent::g_pDevice->CreateShader(ShaderCI, &pShader, &pMsg);
|
||||||
|
|
||||||
if (pShader) {
|
if (pShader) {
|
||||||
MG_Diligent::g_ShaderMap[shaderId] = pShader;
|
MG_Diligent::g_ShaderMap[shaderId] = pShader;
|
||||||
@@ -405,7 +406,7 @@ namespace MG_GL::GL {
|
|||||||
} else {
|
} else {
|
||||||
shaderObj.compiled = UncertainBool::False;
|
shaderObj.compiled = UncertainBool::False;
|
||||||
shaderObj.compileStatus = GL_FALSE;
|
shaderObj.compileStatus = GL_FALSE;
|
||||||
MG_Util::Debug::LogE("Failed to compile shader ID: %u for program %u", shaderId, program);
|
MG_Util::Debug::LogE("Failed to compile shader ID: %u for program %u. \ncompiler info:\n%s", shaderId, program, pMsg->GetConstDataPtr<char>());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Shader already compiled, just add to programInfo
|
// Shader already compiled, just add to programInfo
|
||||||
@@ -494,7 +495,7 @@ namespace MG_GL::GL {
|
|||||||
GLenum result = MG_State::QueryProgramStateIntVector(program, pname, params);
|
GLenum result = MG_State::QueryProgramStateIntVector(program, pname, params);
|
||||||
if (result == GL_NO_ERROR) return;
|
if (result == GL_NO_ERROR) return;
|
||||||
MG_State::SetError(result);
|
MG_State::SetError(result);
|
||||||
MG_Util::Debug::LogE("Error getting program param: %s", MG_Util::Debug::GLEnumToString(result));
|
MG_Util::Debug::LogW("Error getting program param: %s", MG_Util::Debug::GLEnumToString(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
|
void GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
namespace MG_Util::Program {
|
namespace MG_Util::Program {
|
||||||
void RenameGLSLBuiltinsForVulkan(std::string &src) {
|
void RenameGLSLBuiltinsForVulkan(std::string &src) {
|
||||||
static const std::vector<std::pair<std::regex, std::string>> rules = {
|
static const std::vector<std::pair<std::regex, std::string>> rules = {
|
||||||
{ std::regex(R"(\bgl_VertexID\b)"), "gl_VertexIndex" },
|
{ std::regex(R"(gl_VertexID)"), "gl_VertexIndex" },
|
||||||
{ std::regex(R"(\bgl_InstanceID\b)"), "gl_InstanceIndex" }
|
{ std::regex(R"(gl_InstanceID)"), "gl_InstanceIndex" }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto &rule : rules) {
|
for (auto &rule : rules) {
|
||||||
@@ -94,6 +94,7 @@ namespace MG_Util::Program {
|
|||||||
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_GLSL_VERSION, 450);
|
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_GLSL_VERSION, 450);
|
||||||
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_ES, SPVC_FALSE);
|
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_ES, SPVC_FALSE);
|
||||||
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_FLIP_VERTEX_Y, SPVC_TRUE);
|
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_FLIP_VERTEX_Y, SPVC_TRUE);
|
||||||
|
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_VULKAN_SEMANTICS, SPVC_TRUE);
|
||||||
|
|
||||||
spvc_compiler_install_compiler_options(compiler, options);
|
spvc_compiler_install_compiler_options(compiler, options);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user