2013-08-21 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GrTest.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include <algorithm>
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
#include "GrBackendSurface.h"
|
2015-05-22 21:01:46 +00:00
|
|
|
#include "GrContextOptions.h"
|
2017-05-05 15:26:15 +00:00
|
|
|
#include "GrContextPriv.h"
|
2016-12-16 23:59:19 +00:00
|
|
|
#include "GrDrawOpAtlas.h"
|
2015-10-17 14:43:27 +00:00
|
|
|
#include "GrDrawingManager.h"
|
2017-06-15 16:07:18 +00:00
|
|
|
#include "GrGpu.h"
|
2015-02-13 22:20:05 +00:00
|
|
|
#include "GrGpuResourceCacheAccess.h"
|
2016-07-21 16:21:04 +00:00
|
|
|
#include "GrPipelineBuilder.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "GrRenderTargetContext.h"
|
2016-12-16 23:59:19 +00:00
|
|
|
#include "GrRenderTargetContextPriv.h"
|
2016-08-10 18:09:07 +00:00
|
|
|
#include "GrRenderTargetProxy.h"
|
2015-02-11 18:49:59 +00:00
|
|
|
#include "GrResourceCache.h"
|
2017-03-01 22:01:09 +00:00
|
|
|
#include "GrSemaphore.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "GrSurfaceContextPriv.h"
|
2017-06-13 16:44:56 +00:00
|
|
|
#include "GrTexture.h"
|
2017-03-07 21:58:08 +00:00
|
|
|
#include "SkGr.h"
|
2016-12-20 13:57:26 +00:00
|
|
|
#include "SkImage_Gpu.h"
|
2016-06-08 00:21:10 +00:00
|
|
|
#include "SkMathPriv.h"
|
2015-02-03 02:26:03 +00:00
|
|
|
#include "SkString.h"
|
2017-05-12 18:09:46 +00:00
|
|
|
#include "ops/GrMeshDrawOp.h"
|
2016-12-16 19:24:34 +00:00
|
|
|
#include "text/GrAtlasGlyphCache.h"
|
2015-12-11 14:11:21 +00:00
|
|
|
#include "text/GrTextBlobCache.h"
|
|
|
|
|
2015-08-21 18:08:00 +00:00
|
|
|
namespace GrTest {
|
|
|
|
void SetupAlwaysEvictAtlas(GrContext* context) {
|
|
|
|
// These sizes were selected because they allow each atlas to hold a single plot and will thus
|
|
|
|
// stress the atlas
|
2016-12-16 23:59:19 +00:00
|
|
|
int dim = GrDrawOpAtlas::kGlyphMaxDim;
|
|
|
|
GrDrawOpAtlasConfig configs[3];
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kA8_GrMaskFormat].fWidth = dim;
|
|
|
|
configs[kA8_GrMaskFormat].fHeight = dim;
|
2016-02-22 19:25:32 +00:00
|
|
|
configs[kA8_GrMaskFormat].fLog2Width = SkNextLog2(dim);
|
|
|
|
configs[kA8_GrMaskFormat].fLog2Height = SkNextLog2(dim);
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kA8_GrMaskFormat].fPlotWidth = dim;
|
|
|
|
configs[kA8_GrMaskFormat].fPlotHeight = dim;
|
|
|
|
|
|
|
|
configs[kA565_GrMaskFormat].fWidth = dim;
|
|
|
|
configs[kA565_GrMaskFormat].fHeight = dim;
|
2016-02-22 19:25:32 +00:00
|
|
|
configs[kA565_GrMaskFormat].fLog2Width = SkNextLog2(dim);
|
|
|
|
configs[kA565_GrMaskFormat].fLog2Height = SkNextLog2(dim);
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kA565_GrMaskFormat].fPlotWidth = dim;
|
|
|
|
configs[kA565_GrMaskFormat].fPlotHeight = dim;
|
|
|
|
|
|
|
|
configs[kARGB_GrMaskFormat].fWidth = dim;
|
|
|
|
configs[kARGB_GrMaskFormat].fHeight = dim;
|
2016-02-22 19:25:32 +00:00
|
|
|
configs[kARGB_GrMaskFormat].fLog2Width = SkNextLog2(dim);
|
|
|
|
configs[kARGB_GrMaskFormat].fLog2Height = SkNextLog2(dim);
|
2015-08-21 18:08:00 +00:00
|
|
|
configs[kARGB_GrMaskFormat].fPlotWidth = dim;
|
|
|
|
configs[kARGB_GrMaskFormat].fPlotHeight = dim;
|
|
|
|
|
|
|
|
context->setTextContextAtlasSizes_ForTesting(configs);
|
|
|
|
}
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
|
|
|
|
GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
|
|
|
|
GrPixelConfig config, GrBackendObject handle) {
|
2017-06-14 10:03:10 +00:00
|
|
|
#ifdef SK_VULKAN
|
2017-06-14 01:43:29 +00:00
|
|
|
if (kVulkan_GrBackend == backend) {
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
|
2017-04-26 17:29:21 +00:00
|
|
|
return GrBackendTexture(width, height, *vkInfo);
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
}
|
2017-06-14 01:43:29 +00:00
|
|
|
#endif
|
|
|
|
SkASSERT(kOpenGL_GrBackend == backend);
|
|
|
|
GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
|
|
|
|
return GrBackendTexture(width, height, config, *glInfo);
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
}
|
2015-08-21 18:08:00 +00:00
|
|
|
};
|
|
|
|
|
2016-11-08 13:49:39 +00:00
|
|
|
bool GrSurfaceProxy::isWrapped_ForTesting() const {
|
|
|
|
return SkToBool(fTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GrRenderTargetContext::isWrapped_ForTesting() const {
|
|
|
|
return fRenderTargetProxy->isWrapped_ForTesting();
|
|
|
|
}
|
|
|
|
|
2015-08-03 17:17:44 +00:00
|
|
|
void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) {
|
|
|
|
fTextBlobCache->setBudget(bytes);
|
|
|
|
}
|
|
|
|
|
2016-12-16 23:59:19 +00:00
|
|
|
void GrContext::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
|
2016-12-16 19:24:34 +00:00
|
|
|
fAtlasGlyphCache->setAtlasSizes_ForTesting(configs);
|
2015-08-19 15:16:43 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 19:27:48 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-12-18 17:25:33 +00:00
|
|
|
void GrContext::purgeAllUnlockedResources() {
|
2015-02-11 18:49:59 +00:00
|
|
|
fResourceCache->purgeAllUnlocked();
|
2013-12-18 17:25:33 +00:00
|
|
|
}
|
2014-11-05 22:47:41 +00:00
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
void GrContext::resetGpuStats() const {
|
|
|
|
#if GR_GPU_STATS
|
|
|
|
fGpu->stats()->reset();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
void GrContext::dumpCacheStats(SkString* out) const {
|
|
|
|
#if GR_CACHE_STATS
|
2015-02-11 18:49:59 +00:00
|
|
|
fResourceCache->dumpStats(out);
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-12-02 22:08:25 +00:00
|
|
|
void GrContext::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
|
|
|
#if GR_CACHE_STATS
|
|
|
|
fResourceCache->dumpStatsKeyValuePairs(keys, values);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
void GrContext::printCacheStats() const {
|
|
|
|
SkString out;
|
|
|
|
this->dumpCacheStats(&out);
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", out.c_str());
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GrContext::dumpGpuStats(SkString* out) const {
|
|
|
|
#if GR_GPU_STATS
|
|
|
|
return fGpu->stats()->dump(out);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
void GrContext::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
|
|
|
#if GR_GPU_STATS
|
|
|
|
return fGpu->stats()->dumpKeyValuePairs(keys, values);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
void GrContext::printGpuStats() const {
|
|
|
|
SkString out;
|
|
|
|
this->dumpGpuStats(&out);
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", out.c_str());
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
|
|
|
|
2017-01-20 15:03:25 +00:00
|
|
|
sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format) {
|
2016-12-16 19:24:34 +00:00
|
|
|
GrAtlasGlyphCache* cache = this->getAtlasGlyphCache();
|
2015-11-08 16:07:24 +00:00
|
|
|
|
2017-02-28 21:20:03 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = cache->getProxy(format);
|
|
|
|
if (!proxy) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-09 21:36:32 +00:00
|
|
|
SkASSERT(proxy->priv().isExact());
|
|
|
|
sk_sp<SkImage> image(new SkImage_Gpu(this, kNeedNewImageUniqueID, kPremul_SkAlphaType,
|
|
|
|
std::move(proxy), nullptr, SkBudgeted::kNo));
|
2016-12-20 13:57:26 +00:00
|
|
|
return image;
|
2015-12-09 02:53:44 +00:00
|
|
|
}
|
2015-11-08 16:07:24 +00:00
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
#if GR_GPU_STATS
|
|
|
|
void GrGpu::Stats::dump(SkString* out) {
|
|
|
|
out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
|
|
|
|
out->appendf("Shader Compilations: %d\n", fShaderCompilations);
|
2015-02-03 05:19:50 +00:00
|
|
|
out->appendf("Textures Created: %d\n", fTextureCreates);
|
|
|
|
out->appendf("Texture Uploads: %d\n", fTextureUploads);
|
2016-01-05 18:41:27 +00:00
|
|
|
out->appendf("Transfers to Texture: %d\n", fTransfersToTexture);
|
2015-04-16 18:22:42 +00:00
|
|
|
out->appendf("Stencil Buffer Creates: %d\n", fStencilAttachmentCreates);
|
2015-09-08 20:42:05 +00:00
|
|
|
out->appendf("Number of draws: %d\n", fNumDraws);
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
2015-12-02 17:05:37 +00:00
|
|
|
|
|
|
|
void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) {
|
|
|
|
keys->push_back(SkString("render_target_binds")); values->push_back(fRenderTargetBinds);
|
|
|
|
keys->push_back(SkString("shader_compilations")); values->push_back(fShaderCompilations);
|
|
|
|
keys->push_back(SkString("texture_uploads")); values->push_back(fTextureUploads);
|
|
|
|
keys->push_back(SkString("number_of_draws")); values->push_back(fNumDraws);
|
2016-03-23 18:50:26 +00:00
|
|
|
keys->push_back(SkString("number_of_failed_draws")); values->push_back(fNumFailedDraws);
|
2015-12-02 17:05:37 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GR_CACHE_STATS
|
2015-11-09 21:51:06 +00:00
|
|
|
void GrResourceCache::getStats(Stats* stats) const {
|
|
|
|
stats->reset();
|
2015-02-03 02:26:03 +00:00
|
|
|
|
2015-11-09 21:51:06 +00:00
|
|
|
stats->fTotal = this->getResourceCount();
|
|
|
|
stats->fNumNonPurgeable = fNonpurgeableResources.count();
|
|
|
|
stats->fNumPurgeable = fPurgeableQueue.count();
|
2015-02-03 02:26:03 +00:00
|
|
|
|
2015-02-17 23:09:34 +00:00
|
|
|
for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
|
2015-11-09 21:51:06 +00:00
|
|
|
stats->update(fNonpurgeableResources[i]);
|
2015-02-17 23:09:34 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < fPurgeableQueue.count(); ++i) {
|
2015-11-09 21:51:06 +00:00
|
|
|
stats->update(fPurgeableQueue.at(i));
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
2015-11-09 21:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GrResourceCache::dumpStats(SkString* out) const {
|
|
|
|
this->validate();
|
|
|
|
|
|
|
|
Stats stats;
|
|
|
|
|
|
|
|
this->getStats(&stats);
|
2015-02-03 02:26:03 +00:00
|
|
|
|
|
|
|
float countUtilization = (100.f * fBudgetedCount) / fMaxCount;
|
|
|
|
float byteUtilization = (100.f * fBudgetedBytes) / fMaxBytes;
|
|
|
|
|
|
|
|
out->appendf("Budget: %d items %d bytes\n", fMaxCount, (int)fMaxBytes);
|
|
|
|
out->appendf("\t\tEntry Count: current %d"
|
Refactor to separate backend object lifecycle and GpuResource budget decision
Refactor GrGpuResource to contain two different pieces of state:
a) instance is budgeted or not budgeted
b) instance references wrapped backend objects or not
The "object lifecycle" was also attached to backend object
handles (ids), which made the code a bit unclear. Backend objects
would be associated with GrGpuResource::LifeCycle, even though
GrGpuResource::LifeCycle refers to the GpuResource, and individual
backend objects in one GpuResource might be governed with different
"lifecycle".
Mark the budgeted/not budgeted with SkBudgeted::kYes, SkBudgeted::kNo.
This was previously GrGpuResource::kCached_LifeCycle,
GrGpuResource::kUncached_LifeCycle.
Mark the "references wrapped object" with boolean. This was previously
GrGpuResource::kBorrowed_LifeCycle,
GrGpuResource::kAdopted_LifeCycle for GrGpuResource.
Associate the backend object ownership status with
GrBackendObjectOwnership for the backend object handles.
The resource type leaf constuctors, such has GrGLTexture or
GrGLTextureRenderTarget take "budgeted" parameter. This parameter
is passed to GrGpuResource::registerWithCache().
The resource type intermediary constructors, such as GrGLTexture
constructors for class GrGLTextureRenderTarget do not take "budgeted"
parameters, intermediary construtors do not call registerWithCache.
Removes the need for tagging GrGpuResource -derived subclass
constructors with "Derived" parameter.
Makes instances that wrap backend objects be registered with
a new function GrGpuResource::registerWithCacheWrapped().
Removes "budgeted" parameter from classes such as StencilAttahment, as
they are always cached and never wrap any external backend objects.
Removes the use of concept "external" from the member function names.
The API refers to the objects as "wrapped", so make all related
functions use the term consistently.
No change in functionality. Resources referencing wrapped objects are
always inserted to the cache with budget decision kNo.
BUG=594928
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1862043002
Review URL: https://codereview.chromium.org/1862043002
2016-04-22 08:48:29 +00:00
|
|
|
" (%d budgeted, %d wrapped, %d locked, %d scratch %.2g%% full), high %d\n",
|
|
|
|
stats.fTotal, fBudgetedCount, stats.fWrapped, stats.fNumNonPurgeable,
|
|
|
|
stats.fScratch, countUtilization, fHighWaterCount);
|
2015-02-03 02:26:03 +00:00
|
|
|
out->appendf("\t\tEntry Bytes: current %d (budgeted %d, %.2g%% full, %d unbudgeted) high %d\n",
|
2015-02-17 23:09:34 +00:00
|
|
|
SkToInt(fBytes), SkToInt(fBudgetedBytes), byteUtilization,
|
|
|
|
SkToInt(stats.fUnbudgetedSize), SkToInt(fHighWaterBytes));
|
2015-02-03 02:26:03 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 22:08:25 +00:00
|
|
|
void GrResourceCache::dumpStatsKeyValuePairs(SkTArray<SkString>* keys,
|
|
|
|
SkTArray<double>* values) const {
|
|
|
|
this->validate();
|
|
|
|
|
|
|
|
Stats stats;
|
|
|
|
this->getStats(&stats);
|
|
|
|
|
|
|
|
keys->push_back(SkString("gpu_cache_purgable_entries")); values->push_back(stats.fNumPurgeable);
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-19 19:38:44 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newTimestamp; }
|
2015-02-03 02:26:03 +00:00
|
|
|
|
2017-01-06 17:04:19 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
int GrResourceCache::countUniqueKeysWithTag(const char* tag) const {
|
|
|
|
int count = 0;
|
|
|
|
UniqueHash::ConstIter iter(&fUniqueHash);
|
|
|
|
while (!iter.done()) {
|
|
|
|
if (0 == strcmp(tag, (*iter).getUniqueKey().tag())) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-13 15:47:38 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define ASSERT_SINGLE_OWNER \
|
2017-04-10 12:19:26 +00:00
|
|
|
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());)
|
2016-01-13 15:47:38 +00:00
|
|
|
|
2017-04-03 14:38:00 +00:00
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_addLegacyMeshDrawOp(
|
|
|
|
GrPaint&& paint,
|
|
|
|
GrAAType aaType,
|
|
|
|
std::unique_ptr<GrLegacyMeshDrawOp> op,
|
|
|
|
const GrUserStencilSettings* uss,
|
|
|
|
bool snapToCenters) {
|
2016-01-13 15:47:38 +00:00
|
|
|
ASSERT_SINGLE_OWNER
|
2017-03-08 16:50:55 +00:00
|
|
|
if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
|
|
|
|
return SK_InvalidUniqueID;
|
|
|
|
}
|
2017-05-08 14:43:33 +00:00
|
|
|
SkDEBUGCODE(fRenderTargetContext->validate());
|
|
|
|
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
|
|
|
"GrRenderTargetContext::testingOnly_addLegacyMeshDrawOp");
|
2016-01-13 15:47:38 +00:00
|
|
|
|
2017-01-11 18:42:54 +00:00
|
|
|
GrPipelineBuilder pipelineBuilder(std::move(paint), aaType);
|
2016-06-23 21:07:00 +00:00
|
|
|
if (uss) {
|
|
|
|
pipelineBuilder.setUserStencil(uss);
|
2016-05-13 17:25:00 +00:00
|
|
|
}
|
2017-01-19 14:55:19 +00:00
|
|
|
pipelineBuilder.setSnapVerticesToPixelCenters(snapToCenters);
|
2016-06-23 21:07:00 +00:00
|
|
|
|
2017-04-04 19:13:25 +00:00
|
|
|
return fRenderTargetContext->addLegacyMeshDrawOp(std::move(pipelineBuilder), GrNoClip(),
|
|
|
|
std::move(op));
|
2016-01-13 15:47:38 +00:00
|
|
|
}
|
|
|
|
|
2017-05-08 14:43:33 +00:00
|
|
|
uint32_t GrRenderTargetContextPriv::testingOnly_addDrawOp(std::unique_ptr<GrDrawOp> op) {
|
|
|
|
ASSERT_SINGLE_OWNER
|
|
|
|
if (fRenderTargetContext->drawingManager()->wasAbandoned()) {
|
|
|
|
return SK_InvalidUniqueID;
|
|
|
|
}
|
|
|
|
SkDEBUGCODE(fRenderTargetContext->validate());
|
|
|
|
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
|
|
|
"GrRenderTargetContext::testingOnly_addDrawOp");
|
|
|
|
return fRenderTargetContext->addDrawOp(GrNoClip(), std::move(op));
|
|
|
|
}
|
|
|
|
|
2016-01-13 15:47:38 +00:00
|
|
|
#undef ASSERT_SINGLE_OWNER
|
|
|
|
|
2016-08-10 18:09:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-13 12:11:36 +00:00
|
|
|
GrRenderTargetFlags GrRenderTargetProxy::testingOnly_getFlags() const {
|
2017-02-28 21:11:04 +00:00
|
|
|
return fRenderTargetFlags;
|
2016-08-10 18:09:07 +00:00
|
|
|
}
|
|
|
|
|
2017-05-12 18:09:46 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-05-05 15:26:15 +00:00
|
|
|
void GrContextPriv::testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
|
|
|
|
fContext->flush();
|
|
|
|
fContext->fDrawingManager->testingOnly_removeOnFlushCallbackObject(cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
|
|
|
|
int n = std::find(fOnFlushCBObjects.begin(), fOnFlushCBObjects.end(), cb) -
|
|
|
|
fOnFlushCBObjects.begin();
|
|
|
|
SkASSERT(n < fOnFlushCBObjects.count());
|
|
|
|
fOnFlushCBObjects.removeShuffle(n);
|
|
|
|
}
|
2017-05-12 18:09:46 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define DRAW_OP_TEST_EXTERN(Op) \
|
2017-07-11 12:52:13 +00:00
|
|
|
extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, GrContext*, GrFSAAType)
|
2017-05-12 18:09:46 +00:00
|
|
|
|
|
|
|
#define LEGACY_MESH_DRAW_OP_TEST_EXTERN(Op) \
|
2017-07-11 12:52:13 +00:00
|
|
|
extern std::unique_ptr<GrLegacyMeshDrawOp> Op##__Test(SkRandom*, GrContext*)
|
2017-05-12 18:09:46 +00:00
|
|
|
|
|
|
|
#define DRAW_OP_TEST_ENTRY(Op) Op##__Test
|
|
|
|
|
2017-07-11 12:52:13 +00:00
|
|
|
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp);
|
2017-05-12 18:09:46 +00:00
|
|
|
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AnalyticRectOp);
|
|
|
|
LEGACY_MESH_DRAW_OP_TEST_EXTERN(DefaultPathOp);
|
|
|
|
LEGACY_MESH_DRAW_OP_TEST_EXTERN(TextBlobOp);
|
|
|
|
|
2017-06-15 20:21:49 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAConvexPathOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAFillRectOp);
|
2017-07-07 17:29:28 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAHairlineOp);
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(CircleOp);
|
2017-07-12 19:27:54 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DashOp);
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(DIEllipseOp);
|
|
|
|
DRAW_OP_TEST_EXTERN(EllipseOp);
|
2017-07-12 15:51:27 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
|
2017-07-12 18:11:22 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(GrDrawVerticesOp);
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(NonAAFillRectOp);
|
|
|
|
DRAW_OP_TEST_EXTERN(NonAALatticeOp);
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
|
2017-07-13 15:20:51 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(ShadowRRectOp);
|
2017-07-11 19:52:02 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(SmallPathOp);
|
2017-07-11 19:53:05 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(RegionOp);
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(RRectOp);
|
2017-07-11 13:03:10 +00:00
|
|
|
DRAW_OP_TEST_EXTERN(TesselatingPathOp);
|
2017-05-12 18:09:46 +00:00
|
|
|
|
|
|
|
void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext, GrPaint&& paint) {
|
|
|
|
GrContext* context = renderTargetContext->surfPriv().getContext();
|
|
|
|
using MakeTestLegacyMeshDrawOpFn = std::unique_ptr<GrLegacyMeshDrawOp>(SkRandom*, GrContext*);
|
|
|
|
static constexpr MakeTestLegacyMeshDrawOpFn* gLegacyFactories[] = {
|
|
|
|
DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(AnalyticRectOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(DefaultPathOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(TextBlobOp),
|
|
|
|
};
|
|
|
|
|
|
|
|
using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*, GrContext*, GrFSAAType);
|
|
|
|
static constexpr MakeDrawOpFn* gFactories[] = {
|
2017-06-15 20:21:49 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(AAConvexPathOp),
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(AAFillRectOp),
|
2017-07-07 17:29:28 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(AAHairlineOp),
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(CircleOp),
|
2017-07-12 19:27:54 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(DashOp),
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(DIEllipseOp),
|
|
|
|
DRAW_OP_TEST_ENTRY(EllipseOp),
|
2017-07-12 15:51:27 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
|
2017-07-12 18:11:22 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(GrDrawVerticesOp),
|
2017-05-12 18:09:46 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(NonAAFillRectOp),
|
2017-07-11 12:52:13 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(NonAALatticeOp),
|
2017-06-15 13:59:23 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
|
2017-07-13 15:20:51 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(ShadowRRectOp),
|
2017-07-11 19:52:02 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(SmallPathOp),
|
2017-07-11 19:53:05 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(RegionOp),
|
2017-05-15 20:45:49 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(RRectOp),
|
2017-07-11 13:03:10 +00:00
|
|
|
DRAW_OP_TEST_ENTRY(TesselatingPathOp),
|
2017-05-12 18:09:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr size_t kTotal = SK_ARRAY_COUNT(gLegacyFactories) + SK_ARRAY_COUNT(gFactories);
|
|
|
|
|
|
|
|
uint32_t index = random->nextULessThan(static_cast<uint32_t>(kTotal));
|
|
|
|
if (index < SK_ARRAY_COUNT(gLegacyFactories)) {
|
|
|
|
const GrUserStencilSettings* uss = GrGetRandomStencil(random, context);
|
|
|
|
// We don't use kHW because we will hit an assertion if the render target is not
|
|
|
|
// multisampled
|
|
|
|
static constexpr GrAAType kAATypes[] = {GrAAType::kNone, GrAAType::kCoverage};
|
|
|
|
GrAAType aaType = kAATypes[random->nextULessThan(SK_ARRAY_COUNT(kAATypes))];
|
|
|
|
bool snapToCenters = random->nextBool();
|
|
|
|
auto op = gLegacyFactories[index](random, context);
|
|
|
|
SkASSERT(op);
|
|
|
|
renderTargetContext->priv().testingOnly_addLegacyMeshDrawOp(
|
|
|
|
std::move(paint), aaType, std::move(op), uss, snapToCenters);
|
|
|
|
} else {
|
|
|
|
auto op = gFactories[index - SK_ARRAY_COUNT(gLegacyFactories)](
|
|
|
|
std::move(paint), random, context, renderTargetContext->fsaaType());
|
|
|
|
SkASSERT(op);
|
|
|
|
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
|
|
|
|
}
|
|
|
|
}
|