From 804ddcfb17e532deb164459c25e20fbe0b286598 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 31 Jul 2019 15:08:11 +0200 Subject: [PATCH] rhi: gl: Add support for bool members in uniform blocks Note that SPIRV-Cross does not translate 'bool' to GLSL versions that do not have uint. So in practice we will still need to use 'int' instead in shaders that also target old GL versions. Change-Id: I070f5414fe761796ab92937034b7182cdfb73a14 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhigles2.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 929f3fe21d..a4ab1cf2ec 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2337,6 +2337,18 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC case QShaderDescription::Uint4: f->glUniform4uiv(uniform.glslLocation, 1, reinterpret_cast(src)); break; + case QShaderDescription::Bool: // a glsl bool is 4 bytes, like (u)int + f->glUniform1i(uniform.glslLocation, *reinterpret_cast(src)); + break; + case QShaderDescription::Bool2: + f->glUniform2iv(uniform.glslLocation, 1, reinterpret_cast(src)); + break; + case QShaderDescription::Bool3: + f->glUniform3iv(uniform.glslLocation, 1, reinterpret_cast(src)); + break; + case QShaderDescription::Bool4: + f->glUniform4iv(uniform.glslLocation, 1, reinterpret_cast(src)); + break; // ### more types default: break;