84constexpr ProxyParams::Kind kDeferred = ProxyParams::Kind::kDeferred;
85constexpr ProxyParams::Kind kBackend = ProxyParams::Kind::kBackend;
86constexpr ProxyParams::Kind kInstantiated = ProxyParams::Kind::kInstantiated;
87constexpr ProxyParams::Kind kLazy = ProxyParams::Kind::kLazy;
88constexpr ProxyParams::Kind kFullyLazy = ProxyParams::Kind::kFullyLazy;
92 const ProxyParams&
p) {
102 "ResourceAllocatorTest_Deffered");
111 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
122 mbet->refCountedCallback());
126 const ProxyParams&
p) {
137 "ResourceAllocatorTest_FullLazy");
146 const ProxyParams&
p) {
157 "ResourceAllocatorTest_Lazy");
178 case ProxyParams::kDeferred:
181 case ProxyParams::kBackend:
184 case ProxyParams::kFullyLazy:
187 case ProxyParams::kLazy:
190 case ProxyParams::kInstantiated:
198 if (proxy &&
p.fUniqueKey.isValid()) {
209 bool expectedResult) {
233 bool expectedResult) {
262 auto dContext = ctxInfo.directContext();
263 const GrCaps* caps = dContext->priv().caps();
271 constexpr bool kShare =
true;
272 constexpr bool kDontShare =
false;
277 static const TestCase overlappingTests[] = {
280 {{64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
281 {64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
284 {{64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
285 {64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
289 for (
size_t i = 0;
i <
std::size(overlappingTests);
i++) {
290 const TestCase&
test = overlappingTests[
i];
304 const TestCase nonOverlappingTests[] = {
307 {{64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
308 {64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
310 {{64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
311 {64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
312 kConditionallyShare},
314 {{64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
315 {50, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
317 {{64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
318 {50, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
319 kConditionallyShare},
321 {{64, kRT,
kRGBA,
kE, 1, kNotB, kDeferred},
322 {64, kRT,
kRGBA,
kE, 1, kNotB, kDeferred},
324 {{64, kNotRT,
kRGBA,
kE, 1, kNotB, kDeferred},
325 {64, kNotRT,
kRGBA,
kE, 1, kNotB, kDeferred},
326 kConditionallyShare},
328 {{56, kRT,
kRGBA,
kE, 1, kNotB, kDeferred},
329 {54, kRT,
kRGBA,
kE, 1, kNotB, kDeferred},
332 {{255, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
333 {127, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
336 {{64, kRT,
kRGBA,
kA, k2, kNotB, kDeferred},
337 {64, kRT,
kRGBA,
kA, k4, kNotB, kDeferred},
340 {{64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
341 {64, kRT,
kAlpha,
kA, 1, kNotB, kDeferred},
344 {{64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
345 {64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
347 {{64, kNotRT,
kRGBA,
kA, 1, kNotB, kDeferred},
348 {64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
351 {{64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
352 {64, kRT,
kRGBA,
kA, 1, kNotB, kDeferred},
355 {{64, kNotRT,
kRGBA,
kE, 1, kNotB, kBackend},
356 {64, kNotRT,
kRGBA,
kE, 1, kNotB, kDeferred},
360 for (
size_t i = 0;
i <
std::size(nonOverlappingTests);
i++) {
361 const TestCase&
test = nonOverlappingTests[
i];
391 auto context = ctxInfo.directContext();
393 size_t maxBytes = context->getResourceCacheLimit();
395 context->setResourceCacheLimit(0);
401 context->flushAndSubmit();
403 context->setResourceCacheLimit(maxBytes);
424 const TestCase&
test) {
431 size_t expectedPurgeableBytes = 0;
433 for (
auto&
params :
test.fPurgeableResourcesInCache) {
440 purgeableSurfaces.
clear();
442 "%zu",
cache->getPurgeableBytes());
445 size_t expectedUnpurgeableBytes = 0;
447 for (
auto&
params :
test.fUnpurgeableResourcesInCache) {
455 auto unpurgeableBytes =
cache->getBudgetedResourceBytes() -
cache->getPurgeableBytes();
457 "%zu", unpurgeableBytes);
461 for (
auto& interval :
test.fIntervals) {
462 for (
int i = interval.fStart;
i <= interval.fEnd;
i++) {
465 alloc.
addInterval(interval.fProxy.get(), interval.fStart, interval.fEnd,
477 auto dContext = ctxInfo.directContext();
479 constexpr bool kUnder =
true;
480 constexpr bool kOver =
false;
481 constexpr size_t kRGBA64Bytes = 4 * 64 * 64;
482 const ProxyParams kProxy64 = {64, kRT,
kRGBA,
kE, 1,
kB, kDeferred};
483 const ProxyParams kProxy64NotBudgeted = {64, kRT,
kRGBA,
kE, 1, kNotB, kDeferred};
484 const ProxyParams kProxy64Lazy = {64, kRT,
kRGBA,
kE, 1,
kB, kLazy};
485 const ProxyParams kProxy64FullyLazy = {64, kRT,
kRGBA,
kE, 1,
kB, kFullyLazy};
486 const ProxyParams kProxy32Instantiated = {32, kRT,
kRGBA,
kE, 1,
kB, kInstantiated};
487 const ProxyParams kProxy64Instantiated = {64, kRT,
kRGBA,
kE, 1,
kB, kInstantiated};
490 {
"empty DAG", kUnder, 0, {}, {}, {}},
491 {
"unbudgeted", kUnder, 0, {}, {}, {{kProxy64NotBudgeted, 0, 2}}},
492 {
"basic", kUnder, kRGBA64Bytes, {}, {}, {{kProxy64, 0, 2}}},
493 {
"basic, over",
kOver, kRGBA64Bytes - 1, {}, {}, {{kProxy64, 0, 2}}},
494 {
"shared", kUnder, kRGBA64Bytes, {}, {},
499 {
"retrieved from cache", kUnder, kRGBA64Bytes,
500 {kProxy64Instantiated},
505 {
"purge 4", kUnder, kRGBA64Bytes,
507 kProxy32Instantiated,
508 kProxy32Instantiated,
509 kProxy32Instantiated,
516 {
"dont purge what we've reserved",
kOver, kRGBA64Bytes,
517 {kProxy64Instantiated},
523 {
"unpurgeable",
kOver, kRGBA64Bytes,
525 {kProxy64Instantiated},
529 {
"lazy", kUnder, kRGBA64Bytes,
535 {
"lazy, over",
kOver, kRGBA64Bytes - 1,
541 {
"fully-lazy", kUnder, kRGBA64Bytes,
545 {kProxy64FullyLazy, 0, 2}
547 {
"fully-lazy, over",
kOver, kRGBA64Bytes - 1,
551 {kProxy64FullyLazy, 0, 2}
@ kBorrow_GrWrapOwnership
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
@ kTopLeft_GrSurfaceOrigin
static const uint64_t kAlpha
static sk_sp< GrSurfaceProxy > make_proxy(GrDirectContext *dContext, const ProxyParams &p)
static void overlap_test(skiatest::Reporter *reporter, GrDirectContext *dContext, const sk_sp< GrSurfaceProxy > &p1, const sk_sp< GrSurfaceProxy > &p2, bool expectedResult)
static sk_sp< GrSurfaceProxy > make_backend(GrDirectContext *dContext, const ProxyParams &p)
static void memory_budget_test(skiatest::Reporter *reporter, GrDirectContext *dContext, const TestCase &test)
static void non_overlap_test(skiatest::Reporter *reporter, GrDirectContext *dContext, const sk_sp< GrSurfaceProxy > &p1, const sk_sp< GrSurfaceProxy > &p2, bool expectedResult)
static sk_sp< GrSurfaceProxy > make_deferred(GrProxyProvider *proxyProvider, const GrCaps *caps, const ProxyParams &p)
static sk_sp< GrSurfaceProxy > make_lazy(GrProxyProvider *proxyProvider, const GrCaps *caps, const ProxyParams &p)
static void draw(GrRecordingContext *rContext)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo, CtsEnforcement::kNever)
static sk_sp< GrSurfaceProxy > make_fully_lazy(GrProxyProvider *proxyProvider, const GrCaps *caps, const ProxyParams &p)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
constexpr SkColor SK_ColorBLACK
sk_sp< T > sk_ref_sp(T *obj)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
constexpr int SkToInt(S x)
#define REPORTER_ASSERT(r, cond,...)
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const =0
bool reuseScratchTextures() const
GrResourceProvider * resourceProvider()
GrResourceCache * getResourceCache()
GrDirectContextPriv priv()
sk_sp< GrTextureProxy > createLazyProxy(LazyInstantiateCallback &&, const GrBackendFormat &, SkISize dimensions, skgpu::Mipmapped, GrMipmapStatus, GrInternalSurfaceFlags, SkBackingFit, skgpu::Budgeted, GrProtected, UseAllocator, std::string_view label)
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
bool assignUniqueKeyToProxy(const skgpu::UniqueKey &, GrTextureProxy *)
static sk_sp< GrTextureProxy > MakeFullyLazyProxy(LazyInstantiateCallback &&, const GrBackendFormat &, GrRenderable, int renderTargetSampleCnt, GrProtected, const GrCaps &, UseAllocator)
GrProxyProvider * proxyProvider()
void addInterval(GrSurfaceProxy *, unsigned int start, unsigned int end, ActualUse actualUse, AllowRecycling SkDEBUGCODE(, bool isDirectDstRead=false))
bool makeBudgetHeadroom()
sk_sp< GrTexture > createTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped mipmapped, skgpu::Budgeted budgeted, skgpu::Protected isProtected, std::string_view label)
sk_sp< GrSurface > createSurface(GrResourceProvider *resourceProvider) const
void assign(sk_sp< GrSurface > surface)
UniqueID underlyingUniqueID() const
size_t gpuMemorySize() const
GrSurfaceProxyPriv priv()
virtual GrTextureProxy * asTextureProxy()
GrSurface * peekSurface() const
void clear(SkColor color)
const EmbeddedViewParams * params
uint32_t uint32_t * format
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
sk_sp< GrSurfaceProxy > fProxy
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
TArray< ProxyParams > fUnpurgeableResourcesInCache
TArray< Interval > fIntervals
TArray< ProxyParams > fPurgeableResourcesInCache