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

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: rebase 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 void initFSAASupport(); 240 void initFSAASupport();
241 241
242 // determines valid stencil formats 242 // determines valid stencil formats
243 void initStencilFormats(); 243 void initStencilFormats();
244 244
245 // sets a texture unit to use for texture operations other than binding a te xture to a program. 245 // 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. 246 // ensures that such operations don't negatively interact with tracking boun d textures.
247 void setScratchTextureUnit(); 247 void setScratchTextureUnit();
248 248
249 // bounds is region that may be modified and therefore has to be resolved. 249 // Enumerates the reasons for binding an FBO.
250 // NULL means whole target. Can be an empty rect. 250 enum FBOBinding {
251 void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); 251 kDraw_FBOBinding,
252 kClear_FBOBinding,
253 kDiscard_FBOBinding,
254 kChangeAttachments_FBOBinding,
255 kReadPixels_FBOBinding,
256 kBlitSrc_FBOBinding,
257 kBlitDst_FBOBinding,
258 };
259
260 // binds the FBO and returns the GL enum of the framebuffer target it was bo und to.
261 GrGLenum bindFBO(FBOBinding, const GrGLFBO*);
262
263 // Tracks dirty area for resolve, and tracks whether mip maps need rebuildin g. bounds is the
264 // region that may be modified. NULL means whole surface. Can be an empty re ct.
265 void markSurfaceContentsDirty(GrSurface*, const SkIRect* bounds);
266
267 void setViewport(const GrGLIRect& viewport);
268
egdaniel 2015/03/17 17:44:58 extra \n
252 269
253 void flushStencil(const GrStencilSettings&); 270 void flushStencil(const GrStencilSettings&);
254 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw); 271 void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool isLineDraw);
255 272
256 bool configToGLFormats(GrPixelConfig config, 273 bool configToGLFormats(GrPixelConfig config,
257 bool getSizedInternal, 274 bool getSizedInternal,
258 GrGLenum* internalFormat, 275 GrGLenum* internalFormat,
259 GrGLenum* externalFormat, 276 GrGLenum* externalFormat,
260 GrGLenum* externalType); 277 GrGLenum* externalType);
261 // helper for onCreateTexture and writeTexturePixels 278 // helper for onCreateTexture and writeTexturePixels
(...skipping 12 matching lines...) Expand all
274 // with new data. 291 // with new data.
275 bool uploadCompressedTexData(const GrSurfaceDesc& desc, 292 bool uploadCompressedTexData(const GrSurfaceDesc& desc,
276 const void* data, 293 const void* data,
277 bool isNewTexture = true, 294 bool isNewTexture = true,
278 int left = 0, int top = 0, 295 int left = 0, int top = 0,
279 int width = -1, int height = -1); 296 int width = -1, int height = -1);
280 297
281 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID, 298 bool createRenderTargetObjects(const GrSurfaceDesc&, bool budgeted, GrGLuint texID,
282 GrGLRenderTarget::IDDesc*); 299 GrGLRenderTarget::IDDesc*);
283 300
284 enum TempFBOTarget { 301 static const FBOBinding kInvalidFBOBinding = static_cast<FBOBinding>(-1);
285 kSrc_TempFBOTarget,
286 kDst_TempFBOTarget
287 };
288 302
289 GrGLuint bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport, 303 // Binds a surface as an FBO. A temporary FBO ID may be used if the surface is not already
290 TempFBOTarget tempFBOTarget); 304 // a render target. Afterwards unbindSurfaceAsFBOForCopy must be called with the value returned.
305 FBOBinding bindSurfaceAsFBOForCopy(GrSurface*, FBOBinding, GrGLIRect* viewpo rt);
291 306
292 void unbindTextureFromFBO(GrGLenum fboTarget); 307 // Must be matched with bindSurfaceAsFBOForCopy.
308 void unbindSurfaceAsFBOForCopy(FBOBinding);
293 309
294 GrGLContext fGLContext; 310 GrGLContext fGLContext;
295 311
296 // GL program-related state 312 // GL program-related state
297 ProgramCache* fProgramCache; 313 ProgramCache* fProgramCache;
298 SkAutoTUnref<GrGLProgram> fCurrentProgram; 314 SkAutoTUnref<GrGLProgram> fCurrentProgram;
299 315
300 /////////////////////////////////////////////////////////////////////////// 316 ///////////////////////////////////////////////////////////////////////////
301 ///@name Caching of GL State 317 ///@name Caching of GL State
302 ///@{ 318 ///@{
303 int fHWActiveTextureUnitIdx; 319 int fHWActiveTextureUnitIdx;
304 GrGLuint fHWProgramID; 320 GrGLuint fHWProgramID;
305 321
306 enum TriState { 322 enum TriState {
307 kNo_TriState, 323 kNo_TriState,
308 kYes_TriState, 324 kYes_TriState,
309 kUnknown_TriState 325 kUnknown_TriState
310 }; 326 };
311 327
312 GrGLuint fTempSrcFBOID; 328 SkAutoTUnref<GrGLFBO> fTempSrcFBO;
313 GrGLuint fTempDstFBOID; 329 SkAutoTUnref<GrGLFBO> fTempDstFBO;
314 330 SkAutoTUnref<GrGLFBO> fStencilClearFBO;
315 GrGLuint fStencilClearFBOID;
316 331
317 // last scissor / viewport scissor state seen by the GL. 332 // last scissor / viewport scissor state seen by the GL.
318 struct { 333 struct {
319 TriState fEnabled; 334 TriState fEnabled;
320 GrGLIRect fRect; 335 GrGLIRect fRect;
321 void invalidate() { 336 void invalidate() {
322 fEnabled = kUnknown_TriState; 337 fEnabled = kUnknown_TriState;
323 fRect.invalidate(); 338 fRect.invalidate();
324 } 339 }
325 } fHWScissorSettings; 340 } fHWScissorSettings;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 466
452 TriState fMSAAEnabled; 467 TriState fMSAAEnabled;
453 468
454 GrStencilSettings fHWStencilSettings; 469 GrStencilSettings fHWStencilSettings;
455 TriState fHWStencilTestEnabled; 470 TriState fHWStencilTestEnabled;
456 471
457 472
458 GrPipelineBuilder::DrawFace fHWDrawFace; 473 GrPipelineBuilder::DrawFace fHWDrawFace;
459 TriState fHWWriteToColor; 474 TriState fHWWriteToColor;
460 TriState fHWDitherEnabled; 475 TriState fHWDitherEnabled;
461 uint32_t fHWBoundRenderTargetUniqueID;
462 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs; 476 SkTArray<uint32_t, true> fHWBoundTextureUniqueIDs;
463 477
478 // Track fbo binding state for GL_DRAW_FRAMEBUFFER and GL_READ_FRAMEBUFFER
479 struct HWFBOBinding {
480 SkAutoTUnref<const GrGLFBO> fFBO;
481 void invalidate() { fFBO.reset(NULL); }
482 } fHWFBOBinding[2];
483
464 ///@} 484 ///@}
465 485
466 // we record what stencil format worked last time to hopefully exit early 486 // 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. 487 // from our loop that tries stencil formats and calls check fb status.
468 int fLastSuccessfulStencilFmtIdx; 488 int fLastSuccessfulStencilFmtIdx;
469 489
470 typedef GrGpu INHERITED; 490 typedef GrGpu INHERITED;
471 friend class GrGLPathRendering; // For accessing setTextureUnit. 491 friend class GrGLPathRendering; // For accessing setTextureUnit.
472 }; 492 };
473 493
474 #endif 494 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | src/gpu/gl/GrGLGpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698