diff options
author | 2015-03-17 15:55:42 -0700 | |
---|---|---|
committer | 2015-03-17 15:55:42 -0700 | |
commit | 160f24ce0e8d6dd7ca80b78871e063d4f4609cfb (patch) | |
tree | 536d98947826b92b1bb8f489d0d331bd8d7462ad /src/gpu/gl/GrGLGpu.h | |
parent | 9251d4e9c6191aa26680911ed938dafdaebf5f61 (diff) |
Improve tracking of bound FBOs in GrGLGpu.
Committed: https://skia.googlesource.com/skia/+/d2ad8eb5801e2c8c0fa544a6a776bb46eedde2a0
Committed: https://skia.googlesource.com/skia/+/b2af2d8b83ca4774c3b3bb1e49bc72605faa9589
Committed: https://skia.googlesource.com/skia/+/0b70b86a7e9fda52ee7ebc1b9897eeaa09b9abef
Committed: https://skia.googlesource.com/skia/+/6ba6fa15261be591f33cf0e5df7134e4fc6432ac
Committed: https://skia.googlesource.com/skia/+/dc963b9264908f53650c40a97cff414101dd3e88
Review URL: https://codereview.chromium.org/949263002
Diffstat (limited to 'src/gpu/gl/GrGLGpu.h')
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index c9e280c3cb..6bd8e4db66 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -244,11 +244,29 @@ private: // ensures that such operations don't negatively interact with tracking bound textures. void setScratchTextureUnit(); - // bounds is region that may be modified and therefore has to be resolved. - // NULL means whole target. Can be an empty rect. - void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); + // Enumerates the reasons for binding an FBO. + enum FBOBinding { + kDraw_FBOBinding, + kClear_FBOBinding, + kDiscard_FBOBinding, + kChangeAttachments_FBOBinding, + kReadPixels_FBOBinding, + kCopyTexSrc_FBOBinding, + kBlitSrc_FBOBinding, + kBlitDst_FBOBinding, + }; + + // binds the FBO and returns the GL enum of the framebuffer target it was bound to. + GrGLenum bindFBO(FBOBinding, const GrGLFBO*); + + // Tracks dirty area for resolve, and tracks whether mip maps need rebuilding. bounds is the + // region that may be modified. NULL means whole surface. Can be an empty rect. + void markSurfaceContentsDirty(GrSurface*, const SkIRect* bounds); + + void setViewport(const GrGLIRect& viewport); void flushStencil(const GrStencilSettings&); + void flushHWAAState(GrRenderTarget* rt, bool useHWAA); bool configToGLFormats(GrPixelConfig config, @@ -279,15 +297,14 @@ private: bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID, GrGLRenderTarget::IDDesc*); - enum TempFBOTarget { - kSrc_TempFBOTarget, - kDst_TempFBOTarget - }; + static const FBOBinding kInvalidFBOBinding = static_cast<FBOBinding>(-1); - GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, - TempFBOTarget tempFBOTarget); + // Binds a surface as an FBO. A temporary FBO ID may be used if the surface is not already + // a render target. Afterwards unbindSurfaceAsFBOForCopy must be called with the value returned. + FBOBinding bindSurfaceAsFBOForCopy(GrSurface*, FBOBinding, GrGLIRect* viewport); - void unbindTextureFromFBO(GrGLenum fboTarget); + // Must be matched with bindSurfaceAsFBOForCopy. + void unbindSurfaceAsFBOForCopy(FBOBinding); GrGLContext fGLContext; @@ -307,10 +324,9 @@ private: kUnknown_TriState }; - GrGLuint fTempSrcFBOID; - GrGLuint fTempDstFBOID; - - GrGLuint fStencilClearFBOID; + SkAutoTUnref<GrGLFBO> fTempSrcFBO; + SkAutoTUnref<GrGLFBO> fTempDstFBO; + SkAutoTUnref<GrGLFBO> fStencilClearFBO; // last scissor / viewport scissor state seen by the GL. struct { @@ -456,9 +472,14 @@ private: GrPipelineBuilder::DrawFace fHWDrawFace; TriState fHWWriteToColor; TriState fHWDitherEnabled; - uint32_t fHWBoundRenderTargetUniqueID; SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; + // Track fbo binding state for GL_DRAW_FRAMEBUFFER and GL_READ_FRAMEBUFFER + struct HWFBOBinding { + SkAutoTUnref<const GrGLFBO> fFBO; + void invalidate() { fFBO.reset(NULL); } + } fHWFBOBinding[2]; + ///@} // we record what stencil format worked last time to hopefully exit early |