fStencilVerifiedColorConfigs.reset();
fMSFBOType = kNone_MSFBOType;
fFBFetchType = kNone_FBFetchType;
+ fInvalidateFBType = kNone_InvalidateFBType;
fMaxFragmentUniformVectors = 0;
fMaxVertexAttributes = 0;
fMaxFragmentTextureUnits = 0;
fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords;
fMSFBOType = caps.fMSFBOType;
fFBFetchType = caps.fFBFetchType;
+ fInvalidateFBType = caps.fInvalidateFBType;
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
fBGRAFormatSupport = caps.fBGRAFormatSupport;
fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
fUseNonVBOVertexAndIndexDynamicData = true;
}
- fDiscardRenderTargetSupport = ctxInfo.hasExtension("GL_EXT_discard_framebuffer");
+ if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) ||
+ (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) ||
+ ctxInfo.hasExtension("GL_ARB_invalidate_subdata")) {
+ fDiscardRenderTargetSupport = true;
+ fInvalidateFBType = kInvalidate_InvalidateFBType;
+ } else if (ctxInfo.hasExtension("GL_EXT_discard_framebuffer")) {
+ fDiscardRenderTargetSupport = true;
+ fInvalidateFBType = kDiscard_InvalidateFBType;
+ }
if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) {
fFullClearIsFree = true;
GR_STATIC_ASSERT(2 == kNV_FBFetchType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFBFetchTypeStr) == kLast_FBFetchType + 1);
+ static const char* kInvalidateFBTypeStr[] = {
+ "None",
+ "Discard",
+ "Invalidate",
+ };
+ GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
+ GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
+ GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
+ GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
r.appendf("Fixed Function Support: %s\n", (fFixedFunctionSupport ? "YES" : "NO"));
r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]);
+ r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
if (fFixedFunctionSupport) {
/** GL_NV_shader_framebuffer_fetch */
kNV_FBFetchType,
- kLast_FBFetchType = kNV_FBFetchType,
+ kLast_FBFetchType = kNV_FBFetchType
+ };
+
+ enum InvalidateFBType {
+ kNone_InvalidateFBType,
+ kDiscard_InvalidateFBType, //<! glDiscardFramebuffer()
+ kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer()
+
+ kLast_InvalidateFBType = kInvalidate_InvalidateFBType
};
/**
FBFetchType fbFetchType() const { return fFBFetchType; }
+ InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
+
/**
* Returs a string containeng the caps info.
*/
int fMaxFragmentTextureUnits;
int fMaxFixedFunctionTextureCoords;
- MSFBOType fMSFBOType;
-
- FBFetchType fFBFetchType;
+ MSFBOType fMSFBOType;
+ FBFetchType fFBFetchType;
+ InvalidateFBType fInvalidateFBType;
bool fRGBA8RenderbufferSupport : 1;
bool fBGRAFormatSupport : 1;
}
void GrGpuGL::discard(GrRenderTarget* renderTarget) {
+ if (!this->caps()->discardRenderTargetSupport()) {
+ return;
+ }
if (NULL == renderTarget) {
renderTarget = this->drawState()->getRenderTarget();
if (NULL == renderTarget) {
fHWBoundRenderTarget = NULL;
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
}
- GrGLenum attachments[] = { GR_GL_COLOR };
- GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments), attachments));
+ switch (this->glCaps().invalidateFBType()) {
+ case GrGLCaps::kNone_FBFetchType:
+ GrCrash("Should never get here.");
+ break;
+ case GrGLCaps::kInvalidate_InvalidateFBType:
+ if (0 == glRT->renderFBOID()) {
+ // When rendering to the default framebuffer the legal values for attachments
+ // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the various FBO attachment
+ // types.
+ static const GrGLenum attachments[] = { GR_GL_COLOR };
+ GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments),
+ attachments));
+ } else {
+ static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 };
+ GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments),
+ attachments));
+ }
+ break;
+ case GrGLCaps::kDiscard_InvalidateFBType: {
+ static const GrGLenum attachments[] = { GR_GL_COLOR };
+ GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(attachments),
+ attachments));
+ break;
+ }
+ }
renderTarget->flagAsResolved();
}