Browse Source

There is glDiscardSubFramebuffer() in EXT_discard_framebuffer.

The relevant functions are now a no-op on ES2.
pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
8c18bd0995
  1. 2
      doc/opengl-mapping.dox
  2. 11
      src/Magnum/AbstractFramebuffer.cpp
  3. 2
      src/Magnum/AbstractFramebuffer.h
  4. 2
      src/Magnum/DefaultFramebuffer.cpp
  5. 12
      src/Magnum/DefaultFramebuffer.h
  6. 2
      src/Magnum/Framebuffer.cpp
  7. 12
      src/Magnum/Framebuffer.h
  8. 2
      src/Magnum/Implementation/FramebufferState.cpp
  9. 2
      src/Magnum/Implementation/FramebufferState.h

2
doc/opengl-mapping.dox

@ -184,7 +184,7 @@ OpenGL function | Matching API
@fn_gl{InvalidateBufferData} | @ref Buffer::invalidateData()
@fn_gl{InvalidateBufferSubData} | @ref Buffer::invalidateSubData()
@fn_gl{InvalidateFramebuffer}, \n @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate()
@fn_gl{InvalidateSubFramebuffer}, \n @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate()
@fn_gl{InvalidateSubFramebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate()
@fn_gl{InvalidateTexImage} | @ref Texture::invalidateImage(), \n @ref TextureArray::invalidateImage(), \n @ref CubeMapTexture::invalidateImage(), \n @ref CubeMapTextureArray::invalidateImage(), \n @ref RectangleTexture::invalidateImage(), \n @ref MultisampleTexture::invalidateImage()
@fn_gl{InvalidateTexSubImage} | @ref Texture::invalidateSubImage(), \n @ref TextureArray::invalidateSubImage(), \n @ref CubeMapTexture::invalidateSubImage(), \n @ref CubeMapTextureArray::invalidateSubImage(), \n @ref RectangleTexture::invalidateSubImage(), \n @ref MultisampleTexture::invalidateSubImage()
@fn_gl{IsBuffer}, \n @fn_gl{IsFramebuffer}, \n @fn_gl{IsProgram}, \n @fn_gl{IsProgramPipeline}, \n @fn_gl{IsQuery}, \n @fn_gl{IsRenderbuffer}, \n @fn_gl{IsSampler}, \n @fn_gl{IsShader}, \n @fn_gl{IsSync}, \n @fn_gl{IsTexture}, \n @fn_gl{IsTransformFeedback}, \n @fn_gl{IsVertexArray} | not needed, objects are strongly typed

11
src/Magnum/AbstractFramebuffer.cpp

@ -221,20 +221,13 @@ void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, c
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&) {}
void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) {
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY());
#else
static_cast<void>(count);
static_cast<void>(attachments);
static_cast<void>(rectangle);
CORRADE_INTERNAL_ASSERT(false);
//glDiscardSubFramebufferEXT(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.width(), rectangle.height());
#endif
}
#endif
GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTarget target) {
bindInternal(target);

2
src/Magnum/AbstractFramebuffer.h

@ -363,8 +363,10 @@ class MAGNUM_EXPORT AbstractFramebuffer {
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments);
#ifndef MAGNUM_TARGET_GLES2
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments, const Range2Di& rectangle);
#endif
};
CORRADE_ENUMSET_OPERATORS(FramebufferClearMask)

2
src/Magnum/DefaultFramebuffer.cpp

@ -80,6 +80,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
(this->*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments);
}
#ifndef MAGNUM_TARGET_GLES2
void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle) {
/** @todo C++14: use VLA to avoid heap allocation */
Containers::Array<GLenum> _attachments(attachments.size());
@ -88,6 +89,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
(this->*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle);
}
#endif
void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) {
Implementation::FramebufferState* state = context.state().framebuffer;

12
src/Magnum/DefaultFramebuffer.h

@ -404,12 +404,11 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
* @param rectangle %Rectangle to invalidate
*
* 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.
* 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.
* @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer}
* on OpenGL ES 2.0
* @see @ref invalidate(std::initializer_list<InvalidationAttachment>),
* @fn_gl{InvalidateSubFramebuffer}
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle);
@ -431,6 +430,11 @@ 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<InvalidationAttachment>, const Range2Di&) {}
#endif
}
#endif

2
src/Magnum/Framebuffer.cpp

@ -157,6 +157,7 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
(this->*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments);
}
#ifndef MAGNUM_TARGET_GLES2
void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle) {
/** @todo C++14: use VLA to avoid heap allocation */
Containers::Array<GLenum> _attachments(attachments.size());
@ -165,6 +166,7 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
(this->*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle);
}
#endif
Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) {
(this->*Context::current()->state().framebuffer->renderbufferImplementation)(attachment, renderbuffer);

12
src/Magnum/Framebuffer.h

@ -458,12 +458,11 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
* @param rectangle %Rectangle to invalidate
*
* 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.
* 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.
* @see @fn_gl{InvalidateFramebuffer} or @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer}
* on OpenGL ES 2.0
* @see @ref invalidate(std::initializer_list<InvalidationAttachment>),
* @fn_gl{InvalidateFramebuffer}
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle);
@ -672,6 +671,11 @@ 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<InvalidationAttachment>, const Range2Di&) {}
#endif
}
#endif

2
src/Magnum/Implementation/FramebufferState.cpp

@ -157,10 +157,8 @@ FramebufferState::FramebufferState(Context& context, std::vector<std::string>& e
extensions.push_back(Extensions::GL::EXT::discard_framebuffer::string());
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
} else {
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationNoOp;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationNoOp;
}
/* Always available on ES3 */

2
src/Magnum/Implementation/FramebufferState.h

@ -42,7 +42,9 @@ struct FramebufferState {
void(AbstractFramebuffer::*drawBufferImplementation)(GLenum);
void(AbstractFramebuffer::*readBufferImplementation)(GLenum);
void(AbstractFramebuffer::*invalidateImplementation)(GLsizei, const GLenum*);
#ifndef MAGNUM_TARGET_GLES2
void(AbstractFramebuffer::*invalidateSubImplementation)(GLsizei, const GLenum*, const Range2Di&);
#endif
void(Framebuffer::*renderbufferImplementation)(Framebuffer::BufferAttachment, Renderbuffer&);
#ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save