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,
Error FramebufferGL::discard(size_t count, const GLenum *attachments)
{
UNIMPLEMENTED();
return Error(GL_INVALID_OPERATION);
// glInvalidateFramebuffer accepts the same enums as glDiscardFramebufferEXT
return invalidate(count, 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)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
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,
......
......@@ -788,7 +788,8 @@ FunctionsGL::FunctionsGL()
blendBarrier(nullptr),
primitiveBoundingBox(nullptr),
eglImageTargetRenderbufferStorageOES(nullptr),
eglImageTargetTexture2DOES(nullptr)
eglImageTargetTexture2DOES(nullptr),
discardFramebuffer(nullptr)
{
}
......@@ -1029,6 +1030,14 @@ void FunctionsGL::initializeProcsDesktopGL()
// GL_KHR_robustness
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
if (isAtLeastGL(gl::Version(1, 0)))
{
......@@ -1897,6 +1906,9 @@ void FunctionsGL::initializeProcsGLES()
// GL_KHR_robustness
AssignGLExtensionEntryPoint(extensions, "GL_KHR_robustness", loadProcAddress("glGetGraphicsResetStatusKHR"), &getGraphicsResetStatus);
// GL_EXT_discard_framebuffer
AssignGLExtensionEntryPoint(extensions, "GL_EXT_discard_framebuffer", loadProcAddress("glDiscardFramebufferEXT"), &discardFramebuffer);
// 2.0
if (isAtLeastGLES(gl::Version(2, 0)))
{
......
......@@ -775,10 +775,13 @@ class FunctionsGL
PFNGLBLENDBARRIERPROC blendBarrier;
PFNGLPRIMITIVEBOUNDINGBOXPROC primitiveBoundingBox;
// ES extensions
// GL_OES_EGL_image
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC eglImageTargetRenderbufferStorageOES;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES;
// GL_EXT_discard_framebuffer
PFNGLDISCARDFRAMEBUFFEREXTPROC discardFramebuffer;
private:
void initializeProcsDesktopGL();
void initializeProcsGLES();
......
......@@ -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.
extensions->sRGBWriteControl = false;
#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)
......
......@@ -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)
{
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