From f9c6deae6376d4fc2885740015dcb2077e6a3969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Mar 2019 13:01:41 +0100 Subject: [PATCH] GL: new "intel-windows-half-baked-dsa-texture-bind" workaround. This is broken as well, in a novel and interesting way. Haha. --- doc/changelog.dox | 3 +++ src/Magnum/GL/AbstractTexture.cpp | 8 ++++++++ src/Magnum/GL/AbstractTexture.h | 3 +++ src/Magnum/GL/Implementation/TextureState.cpp | 15 +++++++++++++-- src/Magnum/GL/Implementation/driverSpecific.cpp | 6 ++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index aa2b3d044..15c8dcff0 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -81,6 +81,9 @@ See also: @ref GL::Mesh::setIndexBuffer() - @cpp "intel-windows-broken-dsa-for-cubemaps" @ce fixing everything about @ref GL::CubeMapTexture (see [mosra/magnum-examples#55](https://github.com/mosra/magnum-examples/issues/55)) + - @cpp "intel-windows-half-baked-dsa-texture-bind" @ce fixing texture + binding inconsistencies (affected [mosra/magnum-examples#55](https://github.com/mosra/magnum-examples/issues/55) + as well) - New `--magnum-gpu-validation` @ref GL-Context-command-line "command-line option" and a corresponding environment variable to conveniently enable @gl_extension{KHR,debug} debug output diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index a521faed6..4cbe0d46a 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -361,6 +361,14 @@ void AbstractTexture::bindImplementationMulti(GLint textureUnit) { void AbstractTexture::bindImplementationDSA(const GLint textureUnit) { glBindTextureUnit(textureUnit, _id); } + +#ifdef CORRADE_TARGET_WINDOWS +void AbstractTexture::bindImplementationDSAIntelWindows(const GLint textureUnit) { + /* See the "intel-windows-half-baked-dsa-texture-bind" workaround */ + if(_target == GL_TEXTURE_CUBE_MAP) bindImplementationDefault(textureUnit); + else bindImplementationDSA(textureUnit); +} +#endif #endif #ifndef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/GL/AbstractTexture.h b/src/Magnum/GL/AbstractTexture.h index 199d0fa04..f72b09b39 100644 --- a/src/Magnum/GL/AbstractTexture.h +++ b/src/Magnum/GL/AbstractTexture.h @@ -531,6 +531,9 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject { #ifndef MAGNUM_TARGET_GLES void MAGNUM_GL_LOCAL bindImplementationMulti(GLint textureUnit); void MAGNUM_GL_LOCAL bindImplementationDSA(GLint textureUnit); + #ifdef CORRADE_TARGET_WINDOWS + void MAGNUM_GL_LOCAL bindImplementationDSAIntelWindows(GLint textureUnit); + #endif #endif void MAGNUM_GL_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); diff --git a/src/Magnum/GL/Implementation/TextureState.cpp b/src/Magnum/GL/Implementation/TextureState.cpp index a5df7e4ae..b7e6ec84a 100644 --- a/src/Magnum/GL/Implementation/TextureState.cpp +++ b/src/Magnum/GL/Implementation/TextureState.cpp @@ -79,8 +79,19 @@ TextureState::TextureState(Context& context, std::vector& extension if(context.isExtensionSupported()) { /* Extension name added below */ - unbindImplementation = &AbstractTexture::unbindImplementationDSA; - bindImplementation = &AbstractTexture::bindImplementationDSA; + #ifdef CORRADE_TARGET_WINDOWS + if((context.detectedDriver() & Context::DetectedDriver::IntelWindows) && + !context.isDriverWorkaroundDisabled("intel-windows-half-baked-dsa-texture-bind")) + { + unbindImplementation = &AbstractTexture::unbindImplementationDefault; + bindImplementation = &AbstractTexture::bindImplementationDSAIntelWindows; + } else + #endif + { + unbindImplementation = &AbstractTexture::unbindImplementationDSA; + bindImplementation = &AbstractTexture::bindImplementationDSA; + } + } else if(context.isExtensionSupported()) { /* Extension name added below */ diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index 8e24b0c5e..80aa2a015 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -218,6 +218,12 @@ namespace { for 34067" (GL_TEXTURE_CUBE_MAP is 34067). Using the non-DSA code path as a workaround. */ "intel-windows-broken-dsa-for-cubemaps", + + /* DSA glBindTextureUnit() on Intel Windows drivers simply doesn't work + when passing 0 to it. Non-zero IDs work correctly except for cube + maps. Using the non-DSA code path for unbinding and cube maps as a + workaround. */ + "intel-windows-half-baked-dsa-texture-bind", #endif #ifndef MAGNUM_TARGET_GLES