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

Unified Diff: bench/GrResourceCacheBench.cpp

Issue 752213002: Revert of Use scratch keys for stencil buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/gpu/GrContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/GrResourceCacheBench.cpp
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index 272e7bf01eec4a8cdff1738a3dcf20f8a759f7a5..e1ec90d51106ea31bddc4e50e61effc0976f8b05 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -14,6 +14,9 @@
#include "GrContext.h"
#include "GrGpu.h"
#include "GrResourceCache2.h"
+#include "GrStencilBuffer.h"
+#include "GrTexture.h"
+#include "GrTexturePriv.h"
#include "SkCanvas.h"
enum {
@@ -21,24 +24,17 @@
CACHE_SIZE_BYTES = 2 * 1024 * 1024,
};
-class FooResource : public GrGpuResource {
-public:
- SK_DECLARE_INST_COUNT(FooResource);
- FooResource(GrGpu* gpu, int id)
+class StencilResource : public GrGpuResource {
+public:
+ SK_DECLARE_INST_COUNT(StencilResource);
+ StencilResource(GrGpu* gpu, int id)
: INHERITED(gpu, false)
, fID(id) {
this->registerWithCache();
}
static GrResourceKey ComputeKey(int width, int height, int sampleCnt) {
- GrCacheID::Key key;
- memset(&key, 0, sizeof(key));
- key.fData32[0] = width;
- key.fData32[1] = height;
- key.fData32[2] = sampleCnt;
- static int gType = GrResourceKey::GenerateResourceType();
- static int gDomain = GrCacheID::GenerateDomain();
- return GrResourceKey(GrCacheID(gDomain, key), gType, 0);
+ return GrStencilBuffer::ComputeKey(width, height, sampleCnt);
}
int fID;
@@ -51,10 +47,10 @@
typedef GrGpuResource INHERITED;
};
-class BarResource : public GrGpuResource {
-public:
- SK_DECLARE_INST_COUNT(BarResource);
- BarResource(GrGpu* gpu, int id)
+class TextureResource : public GrGpuResource {
+public:
+ SK_DECLARE_INST_COUNT(TextureResource);
+ TextureResource(GrGpu* gpu, int id)
: INHERITED(gpu, false)
, fID(id) {
this->registerWithCache();
@@ -81,13 +77,13 @@
typedef GrGpuResource INHERITED;
};
-static void get_foo_params(int i, int* w, int* h, int* s) {
+static void get_stencil(int i, int* w, int* h, int* s) {
*w = i % 1024;
*h = i * 2 % 1024;
- *s = i % 2 == 0 ? 0 : 4;
-}
-
-static void get_bar_surf_desc(int i, GrSurfaceDesc* desc) {
+ *s = i % 1 == 0 ? 0 : 4;
+}
+
+static void get_texture_desc(int i, GrSurfaceDesc* desc) {
desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
desc->fWidth = i % 1024;
desc->fHeight = i * 2 % 1024;
@@ -98,18 +94,18 @@
static void populate_cache(GrGpu* gpu, int resourceCount) {
for (int i = 0; i < resourceCount; ++i) {
int w, h, s;
- get_foo_params(i, &w, &h, &s);
- GrResourceKey key = FooResource::ComputeKey(w, h, s);
- GrGpuResource* resource = SkNEW_ARGS(FooResource, (gpu, i));
+ get_stencil(i, &w, &h, &s);
+ GrResourceKey key = GrStencilBuffer::ComputeKey(w, h, s);
+ GrGpuResource* resource = SkNEW_ARGS(StencilResource, (gpu, i));
resource->cacheAccess().setContentKey(key);
resource->unref();
}
for (int i = 0; i < resourceCount; ++i) {
GrSurfaceDesc desc;
- get_bar_surf_desc(i, &desc);
- GrResourceKey key = BarResource::ComputeKey(desc);
- GrGpuResource* resource = SkNEW_ARGS(BarResource, (gpu, i));
+ get_texture_desc(i, &desc);
+ GrResourceKey key = TextureResource::ComputeKey(desc);
+ GrGpuResource* resource = SkNEW_ARGS(TextureResource, (gpu, i));
resource->cacheAccess().setContentKey(key);
resource->unref();
}
@@ -119,28 +115,28 @@
// Benchmark find calls that succeed.
{
GrSurfaceDesc desc;
- get_bar_surf_desc(k, &desc);
- GrResourceKey key = BarResource::ComputeKey(desc);
+ get_texture_desc(k, &desc);
+ GrResourceKey key = TextureResource::ComputeKey(desc);
SkAutoTUnref<GrGpuResource> item(cache->findAndRefContentResource(key));
if (!item) {
SkFAIL("cache add does not work as expected");
return;
}
- if (static_cast<BarResource*>(item.get())->fID != k) {
+ if (static_cast<TextureResource*>(item.get())->fID != k) {
SkFAIL("cache add does not work as expected");
return;
}
}
{
int w, h, s;
- get_foo_params(k, &w, &h, &s);
- GrResourceKey key = FooResource::ComputeKey(w, h, s);
+ get_stencil(k, &w, &h, &s);
+ GrResourceKey key = StencilResource::ComputeKey(w, h, s);
SkAutoTUnref<GrGpuResource> item(cache->findAndRefContentResource(key));
if (!item) {
SkFAIL("cache add does not work as expected");
return;
}
- if (static_cast<FooResource*>(item.get())->fID != k) {
+ if (static_cast<TextureResource*>(item.get())->fID != k) {
SkFAIL("cache add does not work as expected");
return;
}
@@ -149,9 +145,9 @@
// Benchmark also find calls that always fail.
{
GrSurfaceDesc desc;
- get_bar_surf_desc(k, &desc);
+ get_texture_desc(k, &desc);
desc.fHeight |= 1;
- GrResourceKey key = BarResource::ComputeKey(desc);
+ GrResourceKey key = TextureResource::ComputeKey(desc);
SkAutoTUnref<GrGpuResource> item(cache->findAndRefContentResource(key));
if (item) {
SkFAIL("cache add does not work as expected");
@@ -160,9 +156,9 @@
}
{
int w, h, s;
- get_foo_params(k, &w, &h, &s);
+ get_stencil(k, &w, &h, &s);
h |= 1;
- GrResourceKey key = FooResource::ComputeKey(w, h, s);
+ GrResourceKey key = StencilResource::ComputeKey(w, h, s);
SkAutoTUnref<GrGpuResource> item(cache->findAndRefContentResource(key));
if (item) {
SkFAIL("cache add does not work as expected");
« no previous file with comments | « no previous file | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698