Plumbed in discard_framebuffer extension
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 29 Apr 2013 16:50:17 +0000 (16:50 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 29 Apr 2013 16:50:17 +0000 (16:50 +0000)
https://codereview.chromium.org/14461006/

git-svn-id: http://skia.googlecode.com/svn/trunk@8906 2bbb7eff-a529-9590-31e7-b0007b416f81

12 files changed:
include/gpu/gl/GrGLFunctions.h
include/gpu/gl/GrGLInterface.h
src/gpu/gl/GrGLCaps.cpp
src/gpu/gl/GrGLCaps.h
src/gpu/gl/GrGLCreateNullInterface.cpp
src/gpu/gl/GrGLInterface.cpp
src/gpu/gl/GrGLNoOpInterface.cpp
src/gpu/gl/GrGLNoOpInterface.h
src/gpu/gl/GrGpuGL.cpp
src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp
src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp

index 1d96849..c29c14f 100644 (file)
@@ -143,6 +143,7 @@ extern "C" {
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexParameterivProc)(GrGLenum target, GrGLenum pname, const GrGLint* params);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexStorage2DProc)(GrGLenum target, GrGLsizei levels, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
+    typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDiscardFramebufferProc)(GrGLenum target, GrGLsizei numAttachments, const GrGLenum* attachments);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
     typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLUniform1iProc)(GrGLint location, GrGLint v0);
index 5954c82..6cc8e17 100644 (file)
@@ -235,6 +235,7 @@ public:
     GLPtr<GrGLTexParameterivProc> fTexParameteriv;
     GLPtr<GrGLTexSubImage2DProc> fTexSubImage2D;
     GLPtr<GrGLTexStorage2DProc> fTexStorage2D;
+    GLPtr<GrGLDiscardFramebufferProc> fDiscardFramebuffer;
     GLPtr<GrGLUniform1fProc> fUniform1f;
     GLPtr<GrGLUniform1iProc> fUniform1i;
     GLPtr<GrGLUniform1fvProc> fUniform1fv;
index 461b3d6..b868d6a 100644 (file)
@@ -43,6 +43,7 @@ void GrGLCaps::reset() {
     fVertexArrayObjectSupport = false;
     fUseNonVBOVertexAndIndexDynamicData = false;
     fIsCoreProfile = false;
+    fDiscardFBSupport = false;
 }
 
 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
@@ -76,6 +77,7 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
     fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport;
     fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData;
     fIsCoreProfile = caps.fIsCoreProfile;
+    fDiscardFBSupport = caps.fDiscardFBSupport;
 
     return *this;
 }
@@ -194,6 +196,8 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
         fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
     }
 
+    fDiscardFBSupport = ctxInfo.hasExtension("GL_EXT_discard_framebuffer");
+
     if (kDesktop_GrGLBinding == binding) {
         fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
                                     ctxInfo.hasExtension("GL_ARB_vertex_array_object");
@@ -548,4 +552,5 @@ void GrGLCaps::print() const {
     GrPrintf("Use non-VBO for dynamic data: %s\n",
              (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
     GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
+    GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "NO"));
 }
index 4599e57..4aff025 100644 (file)
@@ -236,6 +236,9 @@ public:
 
     bool isCoreProfile() const { return fIsCoreProfile; }
 
+    /// Is there support for discarding the frame buffer
+    bool discardFBSupport() const { return fDiscardFBSupport; }
+
 private:
     /**
      * Maintains a bit per GrPixelConfig. It is used to avoid redundantly
@@ -311,6 +314,7 @@ private:
     bool fVertexArrayObjectSupport : 1;
     bool fUseNonVBOVertexAndIndexDynamicData : 1;
     bool fIsCoreProfile : 1;
+    bool fDiscardFBSupport : 1;
 
     typedef GrDrawTargetCaps INHERITED;
 };
index 5a5ec6b..1c2e1cd 100644 (file)
@@ -241,6 +241,7 @@ const GrGLInterface* GrGLCreateNullInterface() {
         interface->fTexParameteriv = noOpGLTexParameteriv;
         interface->fTexSubImage2D = noOpGLTexSubImage2D;
         interface->fTexStorage2D = noOpGLTexStorage2D;
+        interface->fDiscardFramebuffer = noOpGLDiscardFramebuffer;
         interface->fUniform1f = noOpGLUniform1f;
         interface->fUniform1i = noOpGLUniform1i;
         interface->fUniform1fv = noOpGLUniform1fv;
index 89912a0..b70841c 100644 (file)
@@ -295,6 +295,15 @@ bool GrGLInterface::validate(GrGLBinding binding) const {
         }
     }
 
+    if (extensions.has("GL_EXT_discard_framebuffer")) {
+// FIXME: Remove this once Chromium is updated to provide this function
+#if 0
+        if (NULL == fDiscardFramebuffer) {
+            return false;
+        }
+#endif
+    }
+
     // FBO MSAA
     if (kDesktop_GrGLBinding == binding) {
         // GL 3.0 and the ARB extension have multisample + blit
index 82e7a1b..f61fa55 100644 (file)
@@ -238,6 +238,11 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexStorage2D(GrGLenum target,
                                                 GrGLsizei height) {
 }
 
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDiscardFramebuffer(GrGLenum target, 
+                                                      GrGLsizei numAttachments, 
+                                                      const GrGLenum* attachments) {
+}
+
 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexSubImage2D(GrGLenum target,
                                                  GrGLint level,
                                                  GrGLint xoffset,
index b04cdca..3002c07 100644 (file)
@@ -159,6 +159,10 @@ GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexStorage2D(GrGLenum target,
                                                 GrGLsizei width,
                                                 GrGLsizei height);
 
+GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDiscardFramebuffer(GrGLenum target, 
+                                                      GrGLsizei numAttachments, 
+                                                      const GrGLenum* attachments);
+
 GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexSubImage2D(GrGLenum target,
                                                  GrGLint level,
                                                  GrGLint xoffset,
index 0f3d534..de7746f 100644 (file)
@@ -1519,13 +1519,13 @@ void GrGpuGL::flushRenderTarget(const GrIRect* bound) {
 
     if (fHWBoundRenderTarget != rt) {
         GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID()));
-    #if GR_DEBUG
+#if GR_DEBUG
         GrGLenum status;
         GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
         if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
             GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x\n", status);
         }
-    #endif
+#endif
         fHWBoundRenderTarget = rt;
         const GrGLIRect& vp = rt->getViewport();
         if (fHWViewport != vp) {
index 081fa05..842741c 100644 (file)
@@ -95,6 +95,9 @@ const GrGLInterface* GrGLCreateNativeInterface() {
 #else
         interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
 #endif
+#if GL_EXT_discard_framebuffer
+        interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
+#endif
         interface->fUniform1f = glUniform1f;
         interface->fUniform1i = glUniform1i;
         interface->fUniform1fv = glUniform1fv;
index 2d7b044..4162331 100644 (file)
@@ -861,6 +861,7 @@ const GrGLInterface* GrGLCreateDebugInterface() {
     interface->fTexParameteriv = noOpGLTexParameteriv;
     interface->fTexSubImage2D = noOpGLTexSubImage2D;
     interface->fTexStorage2D = noOpGLTexStorage2D;
+    interface->fDiscardFramebuffer = noOpGLDiscardFramebuffer;
     interface->fUniform1f = noOpGLUniform1f;
     interface->fUniform1i = noOpGLUniform1i;
     interface->fUniform1fv = noOpGLUniform1fv;
index 0ab0dbb..e83ccdd 100644 (file)
@@ -85,6 +85,9 @@ const GrGLInterface* GrGLCreateNativeInterface() {
 #elif GL_EXT_texture_storage
         interface->fTexStorage2D = glTexStorage2DEXT;
 #endif
+#if GL_EXT_discard_framebuffer
+        interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
+#endif
         interface->fTexParameteri = glTexParameteri;
         interface->fTexParameteriv = glTexParameteriv;
         interface->fTexSubImage2D = glTexSubImage2D;