summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-12-11 11:01:06 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-12-11 11:35:45 +0000
commitff102f01ed25b80abb770c6c6ef82d877dd508a3 (patch)
tree864b25f9e6db732812a56d6d0033e556ad7ce414
parentfbd5b7bb63000a5ea11f5647d05f9d14315a7193 (diff)
Drop binding qualifiers from samplers in GLSL
Enabling GL_ARB_shading_language_420pack (for core-compatible shaders) is not quite ok when the OpenGL implementation (e.g. the one on macOS) does not support this extension. The QRhi OpenGL backend does not rely on bindings for samplers in the first place (and uniform blocks are converted to plain uniforms). So there is no purpose for the binding points in the GLSL code. This fixes operating on macOS with the 4.1 core profile context. (2.1 worked in any case, as this flag and the concept of layout qualifiers are not relevant for <= 120 shaders) Change-Id: Iaec2130aac5fef7c3d8656718bd9ccf418299580 Fixes: QTBUG-80690 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/shadertools/qspirvshader.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/shadertools/qspirvshader.cpp b/src/shadertools/qspirvshader.cpp
index a8ae0bf..0110bad 100644
--- a/src/shadertools/qspirvshader.cpp
+++ b/src/shadertools/qspirvshader.cpp
@@ -546,6 +546,10 @@ QByteArray QSpirvShader::translateToGLSL(int version, GlslFlags flags) const
// behavior regardless of the GLSL version.
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_EMIT_UNIFORM_BUFFER_AS_PLAIN_UNIFORMS,
true);
+ // Do not emit binding qualifiers for samplers (and for uniform blocks, but
+ // those we just disabled above).
+ spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_ENABLE_420PACK_EXTENSION,
+ false);
spvc_compiler_install_compiler_options(d->glslGen, options);
const char *result = nullptr;
@@ -554,19 +558,10 @@ QByteArray QSpirvShader::translateToGLSL(int version, GlslFlags flags) const
return QByteArray();
}
- QByteArray src(result);
-
- // Fix it up by adding #extension GL_ARB_separate_shader_objects : require
- // as well in order to make Mesa and perhaps others happy.
- const QByteArray searchStr = QByteArrayLiteral("#extension GL_ARB_shading_language_420pack : require\n#endif\n");
- int pos = src.indexOf(searchStr);
- if (pos >= 0) {
- src.insert(pos + searchStr.count(), QByteArrayLiteral("#ifdef GL_ARB_separate_shader_objects\n"
- "#extension GL_ARB_separate_shader_objects : require\n"
- "#endif\n"));
- }
-
- return src;
+ // We used to fix up the result to complement GL_ARB_shading_language_420pack
+ // with GL_ARB_separate_shader_objects to make Mesa happy, but the 420pack
+ // is never relied on now so no need to do anything here.
+ return result;
}
QByteArray QSpirvShader::translateToHLSL(int version) const