Commit 57ce9ea2 by Geoff Lang Committed by Commit Bot

Implement EXT_discard_framebuffer for the GL backend.

BUG=angleproject:1634 Change-Id: I3822b99b59d4653e4d9a2c1d3dd16734f2050fae Reviewed-on: https://chromium-review.googlesource.com/414437 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent fb02830d
...@@ -127,20 +127,25 @@ static void BindFramebufferAttachment(const FunctionsGL *functions, ...@@ -127,20 +127,25 @@ static void BindFramebufferAttachment(const FunctionsGL *functions,
Error FramebufferGL::discard(size_t count, const GLenum *attachments) Error FramebufferGL::discard(size_t count, const GLenum *attachments)
{ {
UNIMPLEMENTED(); // glInvalidateFramebuffer accepts the same enums as glDiscardFramebufferEXT
return Error(GL_INVALID_OPERATION); return invalidate(count, attachments);
} }
Error FramebufferGL::invalidate(size_t count, const GLenum *attachments) Error FramebufferGL::invalidate(size_t count, const GLenum *attachments)
{ {
// Since this function is just a hint and not available until OpenGL 4.3, only call it if it is available. // Since this function is just a hint, only call a native function if it exists.
if (mFunctions->invalidateFramebuffer) if (mFunctions->invalidateFramebuffer)
{ {
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->invalidateFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count), attachments); mFunctions->invalidateFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count), attachments);
} }
else if (mFunctions->discardFramebuffer)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->discardFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count), attachments);
}
return Error(GL_NO_ERROR); return gl::NoError();
} }
Error FramebufferGL::invalidateSub(size_t count, Error FramebufferGL::invalidateSub(size_t count,
......
...@@ -788,7 +788,8 @@ FunctionsGL::FunctionsGL() ...@@ -788,7 +788,8 @@ FunctionsGL::FunctionsGL()
blendBarrier(nullptr), blendBarrier(nullptr),
primitiveBoundingBox(nullptr), primitiveBoundingBox(nullptr),
eglImageTargetRenderbufferStorageOES(nullptr), eglImageTargetRenderbufferStorageOES(nullptr),
eglImageTargetTexture2DOES(nullptr) eglImageTargetTexture2DOES(nullptr),
discardFramebuffer(nullptr)
{ {
} }
...@@ -1029,6 +1030,14 @@ void FunctionsGL::initializeProcsDesktopGL() ...@@ -1029,6 +1030,14 @@ void FunctionsGL::initializeProcsDesktopGL()
// GL_KHR_robustness // GL_KHR_robustness
AssignGLExtensionEntryPoint(extensions, "GL_KHR_robustness", loadProcAddress("glGetGraphicsResetStatus"), &getGraphicsResetStatus); AssignGLExtensionEntryPoint(extensions, "GL_KHR_robustness", loadProcAddress("glGetGraphicsResetStatus"), &getGraphicsResetStatus);
// GL_ARB_invalidate_subdata
AssignGLExtensionEntryPoint(extensions, "GL_ARB_invalidate_subdata", loadProcAddress("glInvalidateTexSubImage"), &invalidateTexSubImage);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_invalidate_subdata", loadProcAddress("glInvalidateTexImage"), &invalidateTexImage);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_invalidate_subdata", loadProcAddress("glInvalidateBufferSubData"), &invalidateBufferSubData);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_invalidate_subdata", loadProcAddress("glInvalidateBufferData"), &invalidateBufferData);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_invalidate_subdata", loadProcAddress("glInvalidateFramebuffer"), &invalidateFramebuffer);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_invalidate_subdata", loadProcAddress("glInvalidateSubFramebuffer"), &invalidateSubFramebuffer);
// 1.0 // 1.0
if (isAtLeastGL(gl::Version(1, 0))) if (isAtLeastGL(gl::Version(1, 0)))
{ {
...@@ -1897,6 +1906,9 @@ void FunctionsGL::initializeProcsGLES() ...@@ -1897,6 +1906,9 @@ void FunctionsGL::initializeProcsGLES()
// GL_KHR_robustness // GL_KHR_robustness
AssignGLExtensionEntryPoint(extensions, "GL_KHR_robustness", loadProcAddress("glGetGraphicsResetStatusKHR"), &getGraphicsResetStatus); AssignGLExtensionEntryPoint(extensions, "GL_KHR_robustness", loadProcAddress("glGetGraphicsResetStatusKHR"), &getGraphicsResetStatus);
// GL_EXT_discard_framebuffer
AssignGLExtensionEntryPoint(extensions, "GL_EXT_discard_framebuffer", loadProcAddress("glDiscardFramebufferEXT"), &discardFramebuffer);
// 2.0 // 2.0
if (isAtLeastGLES(gl::Version(2, 0))) if (isAtLeastGLES(gl::Version(2, 0)))
{ {
......
...@@ -775,10 +775,13 @@ class FunctionsGL ...@@ -775,10 +775,13 @@ class FunctionsGL
PFNGLBLENDBARRIERPROC blendBarrier; PFNGLBLENDBARRIERPROC blendBarrier;
PFNGLPRIMITIVEBOUNDINGBOXPROC primitiveBoundingBox; PFNGLPRIMITIVEBOUNDINGBOXPROC primitiveBoundingBox;
// ES extensions // GL_OES_EGL_image
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC eglImageTargetRenderbufferStorageOES; PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC eglImageTargetRenderbufferStorageOES;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES; PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES;
// GL_EXT_discard_framebuffer
PFNGLDISCARDFRAMEBUFFEREXTPROC discardFramebuffer;
private: private:
void initializeProcsDesktopGL(); void initializeProcsDesktopGL();
void initializeProcsGLES(); void initializeProcsGLES();
......
...@@ -899,6 +899,14 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM ...@@ -899,6 +899,14 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
// Disabling GL_FRAMEBUFFER_SRGB will then convert in the wrong direction. // Disabling GL_FRAMEBUFFER_SRGB will then convert in the wrong direction.
extensions->sRGBWriteControl = false; extensions->sRGBWriteControl = false;
#endif #endif
// EXT_discard_framebuffer can be implemented as long as glDiscardFramebufferEXT or
// glInvalidateFramebuffer is available
extensions->discardFramebuffer = functions->isAtLeastGL(gl::Version(4, 3)) ||
functions->hasGLExtension("GL_ARB_invalidate_subdata") ||
functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLESExtension("GL_EXT_discard_framebuffer") ||
functions->hasGLESExtension("GL_ARB_invalidate_subdata");
} }
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds) void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds)
......
...@@ -24,21 +24,6 @@ protected: ...@@ -24,21 +24,6 @@ protected:
} }
}; };
TEST_P(DiscardFramebufferEXTTest, ExtensionEnabled)
{
EGLPlatformParameters platform = GetParam().eglParameters;
if (platform.renderer == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
EXPECT_TRUE(extensionEnabled("EXT_discard_framebuffer"));
}
else
{
// Other platforms don't currently implement this extension
EXPECT_FALSE(extensionEnabled("EXT_discard_framebuffer"));
}
}
TEST_P(DiscardFramebufferEXTTest, DefaultFramebuffer) TEST_P(DiscardFramebufferEXTTest, DefaultFramebuffer)
{ {
if (!extensionEnabled("EXT_discard_framebuffer")) if (!extensionEnabled("EXT_discard_framebuffer"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment