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

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

Powered by Google App Engine
This is Rietveld 408576698