diff --git a/doc/changelog.dox b/doc/changelog.dox index 5f3415dd0..a20686b51 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -293,6 +293,11 @@ See also: @ref GL::Context::DetectedDriver::ArmMali "ARM Mali" drivers complain about R8 not being renderable (even though the format shouldn't matter when unbinding a texture) +- The engine was silently doing an explicit initial call to @fn_gl{Viewport} + when it detected it's running under ApiTrace, because otherwise ApiTrace + would assume a zero-sized framebuffer. This behavior is no longer silent + but advertised as a @cpp "apitrace-zero-initial-viewport" @ce workaround. + See @ref opengl-workarounds for more information. @subsubsection changelog-latest-changes-math Math library diff --git a/src/Magnum/GL/DefaultFramebuffer.cpp b/src/Magnum/GL/DefaultFramebuffer.cpp index c3e079aa8..53b5a7897 100644 --- a/src/Magnum/GL/DefaultFramebuffer.cpp +++ b/src/Magnum/GL/DefaultFramebuffer.cpp @@ -121,12 +121,6 @@ void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) { glGetIntegerv(GL_VIEWPORT, viewport); defaultFramebuffer._viewport = state.viewport = Range2Di::fromSize({viewport[0], viewport[1]}, {viewport[2], viewport[3]}); CORRADE_INTERNAL_ASSERT(defaultFramebuffer._viewport != Implementation::FramebufferState::DisengagedViewport); - - /* Fake initial glViewport() call for ApiTrace */ - #ifndef MAGNUM_TARGET_GLES - if(context.isExtensionSupported()) - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); - #endif } #ifndef DOXYGEN_GENERATING_OUTPUT diff --git a/src/Magnum/GL/Implementation/driverSpecific.cpp b/src/Magnum/GL/Implementation/driverSpecific.cpp index c72225b5c..8bd9d7025 100644 --- a/src/Magnum/GL/Implementation/driverSpecific.cpp +++ b/src/Magnum/GL/Implementation/driverSpecific.cpp @@ -256,6 +256,12 @@ namespace { glGetFramebufferParameter() works correctly. */ "nv-implementation-color-read-format-dsa-broken", #endif + +#ifndef MAGNUM_TARGET_GLES +/* ApiTrace needs an explicit initial glViewport() call to initialize its + framebuffer size, otherwise it assumes it's zero-sized. */ +"apitrace-zero-initial-viewport", +#endif /* [workarounds] */ }; } @@ -431,6 +437,15 @@ void Context::setupDriverWorkarounds() { #endif #undef _setRequiredVersion + + #ifndef MAGNUM_TARGET_GLES + if(isExtensionSupported() && + !isDriverWorkaroundDisabled("apitrace-zero-initial-viewport")) { + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + } + #endif } }}