From 8be9dde47dac6ba4cdd44f3020237dfae5a20ae6 Mon Sep 17 00:00:00 2001 From: Maksim Date: Mon, 14 Mar 2022 11:11:25 +0200 Subject: [PATCH] Don't fail if the driver is uncertain whether there are any active uniforms Co-Authored-By: Vitaliy --- source/Irrlicht/COGLES2MaterialRenderer.cpp | 11 ++++++++-- source/Irrlicht/COpenGLSLMaterialRenderer.cpp | 22 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/source/Irrlicht/COGLES2MaterialRenderer.cpp b/source/Irrlicht/COGLES2MaterialRenderer.cpp index 628df02c..f9e139b8 100644 --- a/source/Irrlicht/COGLES2MaterialRenderer.cpp +++ b/source/Irrlicht/COGLES2MaterialRenderer.cpp @@ -292,16 +292,23 @@ bool COGLES2MaterialRenderer::linkProgram() if (num == 0) return true; - GLint maxlen = 0; + GLint maxlen = -1; glGetProgramiv(Program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen); - if (maxlen == 0) + if (maxlen == -1) { os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR); return false; } + if (maxlen == 0) + { + os::Printer::log("GLSL: there are active uniforms but max. name length is zero", ELL_WARNING); + UniformInfo.clear(); + return true; + } + // seems that some implementations use an extra null terminator. ++maxlen; c8 *buf = new c8[maxlen]; diff --git a/source/Irrlicht/COpenGLSLMaterialRenderer.cpp b/source/Irrlicht/COpenGLSLMaterialRenderer.cpp index b2ba9f67..74401f60 100644 --- a/source/Irrlicht/COpenGLSLMaterialRenderer.cpp +++ b/source/Irrlicht/COpenGLSLMaterialRenderer.cpp @@ -449,17 +449,24 @@ bool COpenGLSLMaterialRenderer::linkProgram() return true; } - GLint maxlen = 0; + GLint maxlen = -1; #ifdef GL_VERSION_2_0 Driver->extGlGetProgramiv(Program2, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen); #endif - if (maxlen == 0) + if (maxlen == -1) { os::Printer::log("GLSL (> 2.x): failed to retrieve uniform information", ELL_ERROR); return false; } + if (maxlen == 0) + { + os::Printer::log("GLSL (> 2.x): there are active uniforms but max. name length is zero", ELL_WARNING); + UniformInfo.clear(); + return true; + } + // seems that some implementations use an extra null terminator ++maxlen; c8 *buf = new c8[maxlen]; @@ -526,17 +533,24 @@ bool COpenGLSLMaterialRenderer::linkProgram() return true; } - GLint maxlen = 0; + GLint maxlen = -1; #ifdef GL_ARB_shader_objects Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen); #endif - if (maxlen == 0) + if (maxlen == -1) { os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR); return false; } + if (maxlen == 0) + { + os::Printer::log("GLSL: there are active uniforms but max. name length is zero", ELL_WARNING); + UniformInfo.clear(); + return true; + } + // seems that some implementations use an extra null terminator ++maxlen; c8 *buf = new c8[maxlen];