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
This commit is contained in:
robertphillips@google.com 2013-04-29 16:50:17 +00:00
parent 5c341d1ff1
commit a6ffb58b10
12 changed files with 39 additions and 2 deletions

View 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);

View 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;

View 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"));
}

View 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;
};

View 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;

View 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

View 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,

View 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,

View 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) {

View File

@ -94,6 +94,9 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fTexStorage2D = glTexStorage2DEXT;
#else
interface->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT");
#endif
#if GL_EXT_discard_framebuffer
interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
#endif
interface->fUniform1f = glUniform1f;
interface->fUniform1i = glUniform1i;

View 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;

View File

@ -84,6 +84,9 @@ const GrGLInterface* GrGLCreateNativeInterface() {
interface->fTexStorage2D = glTexStorage2D;
#elif GL_EXT_texture_storage
interface->fTexStorage2D = glTexStorage2DEXT;
#endif
#if GL_EXT_discard_framebuffer
interface->fDiscardFramebuffer = glDiscardFramebufferEXT;
#endif
interface->fTexParameteri = glTexParameteri;
interface->fTexParameteriv = glTexParameteriv;