mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 22:28:32 +09:00
[Fix] (MG/GLSLTool): Finally fixing blur shader!
- use glslang mapIO() function to correctly link shader in/out varyings - no need to flip y (already using VK_KHR_maintenance1 to specify negative viewport height) - use pointers to avoid unnecessary copying
This commit is contained in:
@@ -119,14 +119,14 @@ namespace MG_Util::Program {
|
||||
if (MG_Global::Common::LogLevel > MG_Constants::Common::LOG_LEVEL_DEBUG)
|
||||
return;
|
||||
|
||||
auto prog = (ProgramObject)state.GetProgramObject(program);
|
||||
if (!prog.linked.toBool()) {
|
||||
auto* prog = state.GetProgramObject(program);
|
||||
if (!prog->linked.toBool()) {
|
||||
MG_Util::Debug::LogE("Program %u not linked", program);
|
||||
return;
|
||||
}
|
||||
MG_Util::Debug::LogD("=== Dumping uniforms for program %u ===", program);
|
||||
for(const auto& [name, loc] : prog.uniformLocations) {
|
||||
const auto& value = prog.uniformValues.at(name);
|
||||
for(const auto& [name, loc] : prog->uniformLocations) {
|
||||
const auto& value = prog->uniformValues.at(name);
|
||||
MG_Util::Debug::LogD("Uniform: %-24s Location: %-4d Type: %-16s Count: %-3d Value: %s",
|
||||
name.c_str(),
|
||||
loc,
|
||||
|
||||
@@ -111,12 +111,8 @@ namespace MG_Util::Program {
|
||||
|
||||
// TODO: Use other methods to implement clip space fixing.
|
||||
size_t pos = output_glsl.find("\n gl_Position.y = -gl_Position.y;\n}");
|
||||
size_t blur_pos = output_glsl.find("BlurDir"); // TODO: Fix this really hacky way of fixing blur shader...
|
||||
if (pos != std::string::npos) {
|
||||
if (blur_pos != std::string::npos) {
|
||||
output_glsl.replace(pos, strlen("\n gl_Position.y = -gl_Position.y;\n}"), "\n}");
|
||||
} else
|
||||
output_glsl.replace(pos, strlen("\n gl_Position.y = -gl_Position.y;\n}"), "\n gl_Position.y = -gl_Position.y;\n gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n}");
|
||||
output_glsl.replace(pos, strlen("\n gl_Position.y = -gl_Position.y;\n}"), "\n gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n}");
|
||||
}
|
||||
return output_glsl;
|
||||
}
|
||||
@@ -645,12 +641,12 @@ namespace MG_Util::Program {
|
||||
std::vector<EShLanguage> usedShaderTypes;
|
||||
TProgram program;
|
||||
for (GLuint shaderId : prog.attachedShaders) {
|
||||
auto shaderObject = state.GetShaderObject(shaderId);
|
||||
EShLanguage shLanguage = GetEShLanguageByShaderType(shaderObject.type);
|
||||
auto* shaderObject = state.GetShaderObject(shaderId);
|
||||
EShLanguage shLanguage = GetEShLanguageByShaderType(shaderObject->type);
|
||||
TShader* shader = nullptr;
|
||||
std::string infoLogOfShader = CompileGLSLToTShader(shaderObject.type, shaderObject.source, shader);
|
||||
std::string infoLogOfShader = CompileGLSLToTShader(shaderObject->type, shaderObject->source, shader);
|
||||
if (!infoLogOfShader.empty()) {
|
||||
infoLog = "Error: [glslang] Cannot compile " + GetShaderTypeName(shaderObject.type) +
|
||||
infoLog = "Error: [glslang] Cannot compile " + GetShaderTypeName(shaderObject->type) +
|
||||
" :\n" + infoLogOfShader;
|
||||
return {};
|
||||
}
|
||||
@@ -691,6 +687,7 @@ namespace MG_Util::Program {
|
||||
infoLog = "Error: [glslang] Cannot link the program of the single shader:\n" + std::to_string(program.getInfoLog());
|
||||
return {};
|
||||
}
|
||||
program.mapIO();
|
||||
std::vector<unsigned> spirv;
|
||||
|
||||
SpvOptions spvOptions;
|
||||
|
||||
Reference in New Issue
Block a user