From: robertphillips@google.com Date: Mon, 29 Apr 2013 16:50:17 +0000 (+0000) Subject: Plumbed in discard_framebuffer extension X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~12566 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6ffb58b109f71512bde4e14d06a655914578c8d;p=platform%2Fupstream%2FlibSkiaSharp.git Plumbed in discard_framebuffer extension https://codereview.chromium.org/14461006/ git-svn-id: http://skia.googlecode.com/svn/trunk@8906 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h index 1d96849..c29c14f 100644 --- a/include/gpu/gl/GrGLFunctions.h +++ b/include/gpu/gl/GrGLFunctions.h @@ -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); diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h index 5954c82..6cc8e17 100644 --- a/include/gpu/gl/GrGLInterface.h +++ b/include/gpu/gl/GrGLInterface.h @@ -235,6 +235,7 @@ public: GLPtr fTexParameteriv; GLPtr fTexSubImage2D; GLPtr fTexStorage2D; + GLPtr fDiscardFramebuffer; GLPtr fUniform1f; GLPtr fUniform1i; GLPtr fUniform1fv; diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 461b3d6..b868d6a 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -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")); } diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 4599e57..4aff025 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -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; }; diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index 5a5ec6b..1c2e1cd 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -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; diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp index 89912a0..b70841c 100644 --- a/src/gpu/gl/GrGLInterface.cpp +++ b/src/gpu/gl/GrGLInterface.cpp @@ -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 diff --git a/src/gpu/gl/GrGLNoOpInterface.cpp b/src/gpu/gl/GrGLNoOpInterface.cpp index 82e7a1b..f61fa55 100644 --- a/src/gpu/gl/GrGLNoOpInterface.cpp +++ b/src/gpu/gl/GrGLNoOpInterface.cpp @@ -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, diff --git a/src/gpu/gl/GrGLNoOpInterface.h b/src/gpu/gl/GrGLNoOpInterface.h index b04cdca..3002c07 100644 --- a/src/gpu/gl/GrGLNoOpInterface.h +++ b/src/gpu/gl/GrGLNoOpInterface.h @@ -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, diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 0f3d534..de7746f 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -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) { diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp index 081fa05..842741c 100644 --- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp +++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp @@ -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; diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp index 2d7b044..4162331 100644 --- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp +++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp @@ -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; diff --git a/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp b/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp index 0ab0dbb..e83ccdd 100644 --- a/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp +++ b/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp @@ -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;