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

Side by Side Diff: src/gpu/GrContext.cpp

Issue 871373007: discard scratch render targets when they are recycled. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 10 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 | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrContext.h" 9 #include "GrContext.h"
10 10
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 uint32_t scratchFlags = 0; 466 uint32_t scratchFlags = 0;
467 if (calledDuringFlush) { 467 if (calledDuringFlush) {
468 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ; 468 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ;
469 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { 469 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
470 // If it is not a render target then it will most likely be popu lated by 470 // If it is not a render target then it will most likely be popu lated by
471 // writePixels() which will trigger a flush if the texture has p ending IO. 471 // writePixels() which will trigger a flush if the texture has p ending IO.
472 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag; 472 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
473 } 473 }
474 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags); 474 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags);
475 if (resource) { 475 if (resource) {
476 return static_cast<GrSurface*>(resource)->asTexture(); 476 GrSurface* surface = static_cast<GrSurface*>(resource);
477 GrRenderTarget* rt = surface->asRenderTarget();
478 if (rt && fGpu->caps()->discardRenderTargetSupport()) {
479 rt->discard();
480 }
481 return surface->asTexture();
477 } 482 }
478 483
479 if (kExact_ScratchTexMatch == match) { 484 if (kExact_ScratchTexMatch == match) {
480 break; 485 break;
481 } 486 }
482 // We had a cache miss and we are in approx mode, relax the fit of t he flags. 487 // We had a cache miss and we are in approx mode, relax the fit of t he flags.
483 488
484 // We no longer try to reuse textures that were previously used as r ender targets in 489 // We no longer try to reuse textures that were previously used as r ender targets in
485 // situations where no RT is needed; doing otherwise can confuse the video driver and 490 // situations where no RT is needed; doing otherwise can confuse the video driver and
486 // cause significant performance problems in some cases. 491 // cause significant performance problems in some cases.
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 fResourceCache2->printStats(); 1793 fResourceCache2->printStats();
1789 } 1794 }
1790 #endif 1795 #endif
1791 1796
1792 #if GR_GPU_STATS 1797 #if GR_GPU_STATS
1793 const GrContext::GPUStats* GrContext::gpuStats() const { 1798 const GrContext::GPUStats* GrContext::gpuStats() const {
1794 return fGpu->gpuStats(); 1799 return fGpu->gpuStats();
1795 } 1800 }
1796 #endif 1801 #endif
1797 1802
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698