Browse Source

New explicit-uniform-location-is-less-explicit-than-you-hoped workaround.

Intel drivers on Windows. Surprisingly unsurprising.
findsdl-include-root
Vladimír Vondruš 7 years ago
parent
commit
65b589f765
  1. 4
      doc/changelog.dox
  2. 28
      src/Magnum/GL/Implementation/driverSpecific.cpp
  3. 8
      src/Magnum/Shaders/MeshVisualizer.frag
  4. 2
      src/Magnum/Shaders/MeshVisualizer.geom
  5. 10
      src/Magnum/Shaders/MeshVisualizer.h

4
doc/changelog.dox

@ -449,6 +449,10 @@ See also:
- @ref Shaders::Phong can now handle zero lights, in which case its output is - @ref Shaders::Phong can now handle zero lights, in which case its output is
equivalent to @ref Shaders::Flat3D. See @ref Shaders-Phong-zero-lights for equivalent to @ref Shaders::Flat3D. See @ref Shaders-Phong-zero-lights for
more information. more information.
- @ref Shaders::MeshVisualizer is fixed to work properly on Intel Windows
drivers, adding a new
@cpp "intel-windows-explicit-uniform-location-is-less-explicit-than-you-hoped" @ce
workaround
@subsubsection changelog-latest-changes-texturetools TextureTools library @subsubsection changelog-latest-changes-texturetools TextureTools library

28
src/Magnum/GL/Implementation/driverSpecific.cpp

@ -253,6 +253,18 @@ namespace {
glVertexAttribIFormat() works or not. A test that triggers this issue is in glVertexAttribIFormat() works or not. A test that triggers this issue is in
MeshGLTest::addVertexBufferIntWithShort(). */ MeshGLTest::addVertexBufferIntWithShort(). */
"intel-windows-broken-dsa-integer-vertex-attributes", "intel-windows-broken-dsa-integer-vertex-attributes",
/* When using more than just a vertex and fragment shader (geometry shader,
e.g.), ARB_explicit_uniform_location on Intel silently uses wrong
locations, blowing up with either a non-descript
Error has been generated. GL error GL_INVALID_OPERATION in ProgramUniformMatrix4fv: (ID: 2052228270) Generic error
or, if you are lucky, a highly-cryptic-but-still-better-than-nothing
Error has been generated. GL error GL_INVALID_OPERATION in ProgramUniform4fv: (ID: 1725519030) GL error GL_INVALID_OPERATION: mismatched type setting uniform of location "3" in program 1, "" using shaders, 2, "", 3, "", 8, ""
*unless* you have vertex uniform locations first, fragment locations second
and geometry locations last. Not sure about the other stages. Note that this
workaround doesn't actually do anything, it's just printed as a heads-up
for the sleepless nights debugging issues that happen only on Intel. */
"intel-windows-explicit-uniform-location-is-less-explicit-than-you-hoped",
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -396,16 +408,22 @@ void Context::setupDriverWorkarounds() {
_extensionRequiredVersion[Extensions::extension::Index] = Version::version _extensionRequiredVersion[Extensions::extension::Index] = Version::version
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
#ifdef CORRADE_TARGET_WINDOWS
if((detectedDriver() & DetectedDriver::IntelWindows) && !isExtensionSupported<Extensions::ARB::shading_language_420pack>() && !isDriverWorkaroundDisabled("intel-windows-glsl-exposes-unsupported-shading-language-420pack"))
_setRequiredVersion(ARB::shading_language_420pack, None);
#endif
if(!isDriverWorkaroundDisabled("no-layout-qualifiers-on-old-glsl")) { if(!isDriverWorkaroundDisabled("no-layout-qualifiers-on-old-glsl")) {
_setRequiredVersion(ARB::explicit_attrib_location, GL320); _setRequiredVersion(ARB::explicit_attrib_location, GL320);
_setRequiredVersion(ARB::explicit_uniform_location, GL320); _setRequiredVersion(ARB::explicit_uniform_location, GL320);
_setRequiredVersion(ARB::shading_language_420pack, GL320); _setRequiredVersion(ARB::shading_language_420pack, GL320);
} }
#ifdef CORRADE_TARGET_WINDOWS
if((detectedDriver() & DetectedDriver::IntelWindows) && !isExtensionSupported<Extensions::ARB::shading_language_420pack>() && !isDriverWorkaroundDisabled("intel-windows-glsl-exposes-unsupported-shading-language-420pack"))
_setRequiredVersion(ARB::shading_language_420pack, None);
if((detectedDriver() & DetectedDriver::IntelWindows) && isExtensionSupported<Extensions::ARB::explicit_uniform_location>() && !isDriverWorkaroundDisabled("intel-windows-explicit-uniform-location-is-less-explicit-than-you-hoped")) {
/* Just to have it printed in the log. Ideal would be to have this
covered with a minimal repro case but I have better things to do
in my life. */
}
#endif
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES

8
src/Magnum/Shaders/MeshVisualizer.frag

@ -45,7 +45,7 @@
#endif #endif
#ifdef EXPLICIT_UNIFORM_LOCATION #ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 2) layout(location = 1)
#endif #endif
uniform lowp vec4 color uniform lowp vec4 color
#ifndef GL_ES #ifndef GL_ES
@ -55,7 +55,7 @@ uniform lowp vec4 color
#ifdef WIREFRAME_RENDERING #ifdef WIREFRAME_RENDERING
#ifdef EXPLICIT_UNIFORM_LOCATION #ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 3) layout(location = 2)
#endif #endif
uniform lowp vec4 wireframeColor uniform lowp vec4 wireframeColor
#ifndef GL_ES #ifndef GL_ES
@ -64,7 +64,7 @@ uniform lowp vec4 wireframeColor
; ;
#ifdef EXPLICIT_UNIFORM_LOCATION #ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 4) layout(location = 3)
#endif #endif
uniform lowp float wireframeWidth uniform lowp float wireframeWidth
#ifndef GL_ES #ifndef GL_ES
@ -73,7 +73,7 @@ uniform lowp float wireframeWidth
; ;
#ifdef EXPLICIT_UNIFORM_LOCATION #ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 5) layout(location = 4)
#endif #endif
uniform lowp float smoothness uniform lowp float smoothness
#ifndef GL_ES #ifndef GL_ES

2
src/Magnum/Shaders/MeshVisualizer.geom

@ -35,7 +35,7 @@
#endif #endif
#ifdef EXPLICIT_UNIFORM_LOCATION #ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 1) layout(location = 5)
#endif #endif
uniform lowp vec2 viewportSize; /* defaults to zero */ uniform lowp vec2 viewportSize; /* defaults to zero */

10
src/Magnum/Shaders/MeshVisualizer.h

@ -252,11 +252,11 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public GL::AbstractShaderProgram {
private: private:
Flags _flags; Flags _flags;
Int _transformationProjectionMatrixUniform{0}, Int _transformationProjectionMatrixUniform{0},
_viewportSizeUniform{1}, _colorUniform{1},
_colorUniform{2}, _wireframeColorUniform{2},
_wireframeColorUniform{3}, _wireframeWidthUniform{3},
_wireframeWidthUniform{4}, _smoothnessUniform{4},
_smoothnessUniform{5}; _viewportSizeUniform{5};
}; };
/** @debugoperatorclassenum{MeshVisualizer,MeshVisualizer::Flag} */ /** @debugoperatorclassenum{MeshVisualizer,MeshVisualizer::Flag} */

Loading…
Cancel
Save