Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/gpu/gl/GrGLGpu.h

Issue 949263002: Improve tracking of bound FBOs in GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGLGpu_DEFINED 8 #ifndef GrGLGpu_DEFINED
9 #define GrGLGpu_DEFINED 9 #define GrGLGpu_DEFINED
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 GrGLStandard glStandard() const { return fGLContext.standard(); } 43 GrGLStandard glStandard() const { return fGLContext.standard(); }
44 GrGLVersion glVersion() const { return fGLContext.version(); } 44 GrGLVersion glVersion() const { return fGLContext.version(); }
45 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration() ; } 45 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration() ; }
46 const GrGLCaps& glCaps() const { return *fGLContext.caps(); } 46 const GrGLCaps& glCaps() const { return *fGLContext.caps(); }
47 47
48 GrGLPathRendering* glPathRendering() { 48 GrGLPathRendering* glPathRendering() {
49 SkASSERT(glCaps().pathRenderingSupport()); 49 SkASSERT(glCaps().pathRenderingSupport());
50 return static_cast<GrGLPathRendering*>(pathRendering()); 50 return static_cast<GrGLPathRendering*>(pathRendering());
51 } 51 }
52 52
53 // On older GLs there may not be separate FBO bindings for draw and read. In that case these
54 // alias each other.
55 enum FBOBinding {
56 kDraw_FBOBinding, // drawing or dst of blit
57 kRead_FBOBinding, // src of blit, read pixels.
58 };
59
60 void willDeleteOrAbandonFramebuffer(GrGLFBO* fbo);
61
53 void discard(GrRenderTarget*) SK_OVERRIDE; 62 void discard(GrRenderTarget*) SK_OVERRIDE;
54 63
55 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL 64 // Used by GrGLProgram and GrGLPathTexGenProgramEffects to configure OpenGL
56 // state. 65 // state.
57 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te xture); 66 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te xture);
58 67
59 // GrGpu overrides 68 // GrGpu overrides
60 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig, 69 GrPixelConfig preferredReadPixelsConfig(GrPixelConfig readConfig,
61 GrPixelConfig surfaceConfig) const S K_OVERRIDE; 70 GrPixelConfig surfaceConfig) const S K_OVERRIDE;
62 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig, 71 GrPixelConfig preferredWritePixelsConfig(GrPixelConfig writeConfig,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 248
240 void initFSAASupport(); 249 void initFSAASupport();
241 250
242 // determines valid stencil formats 251 // determines valid stencil formats
243 void initStencilFormats(); 252 void initStencilFormats();
244 253
245 // sets a texture unit to use for texture operations other than binding a te xture to a program. 254 // sets a texture unit to use for texture operations other than binding a te xture to a program.
246 // ensures that such operations don't negatively interact with tracking boun d textures. 255 // ensures that such operations don't negatively interact with tracking boun d textures.
247 void setScratchTextureUnit(); 256 void setScratchTextureUnit();
248 257
249 // bounds is region that may be modified and therefore has to be resolved. 258 // Binds the render target, sets the viewport, tracks dirty are for resolve, and tracks whether
250 // NULL means whole target. Can be an empty rect. 259 // mip maps need rebuilding.
251 void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); 260 // bounds is region that may be modified by the draw. NULL means whole targe t. Can be an empty
261 // rect.
262 void prepareToDrawToRenderTarget(GrGLRenderTarget*, const SkIRect* bounds);
263
264 static const FBOBinding kInvalidFBOBinding = static_cast<FBOBinding>(-1);
265
266 // binds the FBO and returns the GL enum of the framebuffer target it was bo und to.
267 GrGLenum bindFBO(FBOBinding, const GrGLFBO*);
268
269 void setViewport(const GrGLIRect& viewport);
252 270
253 void flushStencil(const GrStencilSettings&); 271 void flushStencil(const GrStencilSettings&);
254 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw); 272 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw);
255 273
256 bool configToGLFormats(GrPixelConfig config, 274 bool configToGLFormats(GrPixelConfig config,
257 bool getSizedInternal, 275 bool getSizedInternal,
258 GrGLenum* internalFormat, 276 GrGLenum* internalFormat,
259 GrGLenum* externalFormat, 277 GrGLenum* externalFormat,
260 GrGLenum* externalType); 278 GrGLenum* externalType);
261 // helper for onCreateTexture and writeTexturePixels 279 // helper for onCreateTexture and writeTexturePixels
(...skipping 12 matching lines...) Expand all
274 // with new data. 292 // with new data.
275 bool uploadCompressedTexData(const GrSurfaceDesc& desc, 293 bool uploadCompressedTexData(const GrSurfaceDesc& desc,
276 const void* data, 294 const void* data,
277 bool isNewTexture = true, 295 bool isNewTexture = true,
278 int left = 0, int top = 0, 296 int left = 0, int top = 0,
279 int width = -1, int height = -1); 297 int width = -1, int height = -1);
280 298
281 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID, 299 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID,
282 GrGLRenderTarget::IDDesc*); 300 GrGLRenderTarget::IDDesc*);
283 301
284 enum TempFBOTarget { 302 // Binds a surface as an FBO. A temporary FBO ID may be used if the surface is not already
285 kSrc_TempFBOTarget, 303 // a render target. Afterwards unbindSurfaceforCopy must be called with the value returned.
286 kDst_TempFBOTarget 304 FBOBinding bindSurfaceAsFBOForCopy(GrSurface*, FBOBinding, GrGLIRect* viewpo rt);
287 };
288 305
289 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, 306 // Must be matched with bindSurfaceAsFBOForCopy.
290 TempFBOTarget tempFBOTarget); 307 void unbindSurfaceAsFBOForCopy(FBOBinding);
291
292 void unbindTextureFromFBO(GrGLenum fboTarget);
293 308
294 GrGLContext fGLContext; 309 GrGLContext fGLContext;
295 310
296 // GL program-related state 311 // GL program-related state
297 ProgramCache* fProgramCache; 312 ProgramCache* fProgramCache;
298 SkAutoTUnref<GrGLProgram> fCurrentProgram; 313 SkAutoTUnref<GrGLProgram> fCurrentProgram;
299 314
300 /////////////////////////////////////////////////////////////////////////// 315 ///////////////////////////////////////////////////////////////////////////
301 ///@name Caching of GL State 316 ///@name Caching of GL State
302 ///@{ 317 ///@{
303 int fHWActiveTextureUnitIdx; 318 int fHWActiveTextureUnitIdx;
304 GrGLuint fHWProgramID; 319 GrGLuint fHWProgramID;
305 320
306 enum TriState { 321 enum TriState {
307 kNo_TriState, 322 kNo_TriState,
308 kYes_TriState, 323 kYes_TriState,
309 kUnknown_TriState 324 kUnknown_TriState
310 }; 325 };
311 326
312 GrGLuint fTempSrcFBOID; 327 SkAutoTUnref<GrGLFBO> fTempSrcFBO;
313 GrGLuint fTempDstFBOID; 328 SkAutoTUnref<GrGLFBO> fTempDstFBO;
314 329 SkAutoTUnref<GrGLFBO> fStencilClearFBO;
315 GrGLuint fStencilClearFBOID;
316 330
317 // last scissor / viewport scissor state seen by the GL. 331 // last scissor / viewport scissor state seen by the GL.
318 struct { 332 struct {
319 TriState fEnabled; 333 TriState fEnabled;
320 GrGLIRect fRect; 334 GrGLIRect fRect;
321 void invalidate() { 335 void invalidate() {
322 fEnabled = kUnknown_TriState; 336 fEnabled = kUnknown_TriState;
323 fRect.invalidate(); 337 fRect.invalidate();
324 } 338 }
325 } fHWScissorSettings; 339 } fHWScissorSettings;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 465
452 TriState fMSAAEnabled; 466 TriState fMSAAEnabled;
453 467
454 GrStencilSettings fHWStencilSettings; 468 GrStencilSettings fHWStencilSettings;
455 TriState fHWStencilTestEnabled; 469 TriState fHWStencilTestEnabled;
456 470
457 471
458 GrPipelineBuilder::DrawFace fHWDrawFace; 472 GrPipelineBuilder::DrawFace fHWDrawFace;
459 TriState fHWWriteToColor; 473 TriState fHWWriteToColor;
460 TriState fHWDitherEnabled; 474 TriState fHWDitherEnabled;
461 uint32_t fHWBoundRenderTargetUniqueID;
462 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; 475 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs;
463 476
477 // Track read/draw fbo binding state.
478 struct HWFBOBinding {
479 uint32_t fGenID;
480 bool fIsDefaultFBO;
481 void invalidate() {
482 fGenID = SK_InvalidGenID;
483 fIsDefaultFBO = false;
484 }
485 } fHWFBOBinding[2];
egdaniel 2015/02/24 18:47:01 Do we want to distinguish these as 0 is draw and 1
bsalomon 2015/02/24 21:00:52 I added a cnt value and used it here. In the impl
486
464 ///@} 487 ///@}
465 488
466 // we record what stencil format worked last time to hopefully exit early 489 // we record what stencil format worked last time to hopefully exit early
467 // from our loop that tries stencil formats and calls check fb status. 490 // from our loop that tries stencil formats and calls check fb status.
468 int fLastSuccessfulStencilFmtIdx; 491 int fLastSuccessfulStencilFmtIdx;
469 492
470 typedef GrGpu INHERITED; 493 typedef GrGpu INHERITED;
471 friend class GrGLPathRendering; // For accessing setTextureUnit. 494 friend class GrGLPathRendering; // For accessing setTextureUnit.
472 }; 495 };
473 496
474 #endif 497 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698