From d6d83fe520608c5a22db881fd7f2cf9449384bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 17 Nov 2014 17:39:42 +0100 Subject: [PATCH] Disable framebuffer subdata invalidation for ES2. I think it's better to leave the choice on the user -- whether to do nothing (which might be slower), invalidate whole framebuffer (which might lose data) or do scissor + clear and thus emulate the sub-framebuffer invalidation somehow. Also, for some weird reason I made off-by-one error in eb32fb1c400edbb6b564ff09e64f406ae2d9c37a, so the documentation for Framebuffer::invalidate() appeared in documentation block for Framebuffer::attachRenderbuffer(). Should be fixed now. --- src/Magnum/DefaultFramebuffer.h | 14 +++++------ src/Magnum/Framebuffer.h | 41 ++++++++++++++------------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/Magnum/DefaultFramebuffer.h b/src/Magnum/DefaultFramebuffer.h index d6ef8459c..3de70506e 100644 --- a/src/Magnum/DefaultFramebuffer.h +++ b/src/Magnum/DefaultFramebuffer.h @@ -398,19 +398,22 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { */ void invalidate(std::initializer_list attachments); + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Invalidate framebuffer rectangle * @param attachments Attachments to invalidate * @param rectangle Rectangle to invalidate * * If extension @extension{ARB,invalidate_subdata} (part of OpenGL - * 4.3) or OpenGL ES 3.0 is not available, this function does nothing. - * The framebuffer is bound to some target before the operation, if not - * already. + * 4.3) is not available, this function does nothing. The framebuffer + * is bound to some target before the operation, if not already. * @see @ref invalidate(std::initializer_list), * @fn_gl{InvalidateSubFramebuffer} + * @requires_gles30 Use @ref Magnum::DefaultFramebuffer::invalidate(std::initializer_list) "invalidate(std::initializer_list)" + * in OpenGL ES 2.0 instead. */ void invalidate(std::initializer_list attachments, const Range2Di& rectangle); + #endif /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT @@ -430,11 +433,6 @@ extern DefaultFramebuffer MAGNUM_EXPORT defaultFramebuffer; /** @debugoperatorclassenum{Magnum::DefaultFramebuffer,Magnum::DefaultFramebuffer::Status} */ Debug MAGNUM_EXPORT operator<<(Debug debug, DefaultFramebuffer::Status value); -#ifdef MAGNUM_TARGET_GLES2 -/* No-op implementation on ES2 */ -inline void DefaultFramebuffer::invalidate(std::initializer_list, const Range2Di&) {} -#endif - } #endif diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index c78db5aa8..340e89d44 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -442,32 +442,32 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @brief Invalidate framebuffer * @param attachments Attachments to invalidate * - * The framebuffer is bound to some target before the operation, if - * not already. + * If extension @extension{ARB,invalidate_subdata} (part of OpenGL + * 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES + * 2.0 or OpenGL ES 3.0 is not available, this function does nothing. + * The framebuffer is bound to some target before the operation, if not + * already. * @see @fn_gl{InvalidateFramebuffer} or @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} * on OpenGL ES 2.0 - * @requires_gl43 Extension @extension{ARB,invalidate_subdata}. Use - * @ref Magnum::Framebuffer::clear() "clear()" instead where the - * extension is not supported. - * @requires_gles30 Extension @es_extension{EXT,discard_framebuffer} - * in OpenGL ES 2.0. Use @ref Magnum::Framebuffer::clear() "clear()" - * instead where the extension is not supported. */ void invalidate(std::initializer_list attachments); + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Invalidate framebuffer rectangle * @param attachments Attachments to invalidate * @param rectangle Rectangle to invalidate * * If extension @extension{ARB,invalidate_subdata} (part of OpenGL - * 4.3) or OpenGL ES 3.0 is not available, this function does nothing. - * The framebuffer is bound to some target before the operation, if not - * already. + * 4.3) is not available, this function does nothing. The framebuffer + * is bound to some target before the operation, if not already. * @see @ref invalidate(std::initializer_list), - * @fn_gl{InvalidateFramebuffer} + * @fn_gl{InvalidateSubFramebuffer} + * @requires_gles30 Use @ref Magnum::Framebuffer::invalidate(std::initializer_list) "invalidate(std::initializer_list)" + * in OpenGL ES 2.0 instead. */ void invalidate(std::initializer_list attachments, const Range2Di& rectangle); + #endif /** * @brief Attach renderbuffer to given buffer @@ -475,13 +475,11 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @param renderbuffer Renderbuffer * @return Reference to self (for method chaining) * - * If extension @extension{ARB,invalidate_subdata} (part of OpenGL - * 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES - * 2.0 or OpenGL ES 3.0 is not available, this function does nothing. - * The framebuffer is bound to some target before the operation, if not - * already. - * @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer} - * on OpenGL ES 2.0 + * If @extension{EXT,direct_state_access} is not available and the + * framebufferbuffer is not currently bound, it is bound before the + * operation. + * @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or + * @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} */ Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer& renderbuffer); @@ -684,11 +682,6 @@ inline Framebuffer& Framebuffer::operator=(Framebuffer&& other) noexcept { return *this; } -#ifdef MAGNUM_TARGET_GLES2 -/* No-op implementation on ES2 */ -inline void Framebuffer::invalidate(std::initializer_list, const Range2Di&) {} -#endif - } #endif