aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gmmain.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-11 20:22:31 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-11 20:22:31 +0000
commit8a8fcba5b6dc47f11187452604b5cd0c8e3fe848 (patch)
treea1cec2594c1e5acd68ae34de00460d1dbf44f743 /gm/gmmain.cpp
parentc732f259fa9cb0045623f3e0e3f033c20f06be8c (diff)
Make GPU cache size cmd line configurable in GM.
Review URL: https://codereview.chromium.org/12717002 git-svn-id: http://skia.googlecode.com/svn/trunk@8076 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/gmmain.cpp')
-rw-r--r--gm/gmmain.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 588ddb9b1d..160a983c34 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -1033,6 +1033,10 @@ static void usage(const char * argv0) {
" unable to read a reference image for any tests (default behavior)\n"
" [--exclude-config]: disable this config (may be used multiple times)\n"
" [--forceBWtext]: disable text anti-aliasing\n"
+#if SK_SUPPORT_GPU
+" [--gpuCacheSize <bytes> <count>]: limits gpu cache to byte size or object count\n"
+" -1 for either value means use the default. 0 for either disables the cache.\n"
+#endif
" [--help|-h]: show this help message\n"
" [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\n"
" when reading/writing files; default is no\n"
@@ -1049,7 +1053,6 @@ static void usage(const char * argv0) {
" [--resourcePath|-i <path>]: directory that stores image resources\n"
" [--nortree]: Do not exercise the R-Tree variant of SkPicture\n"
" [--noserialize]: do not exercise SkPicture serialization & deserialization\n"
-" [--notexturecache]: disable the gpu texture cache\n"
" [--tiledPipe]: Exercise tiled SkGPipe replay\n"
" [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n"
" [--tileGridReplayScales <scales>]: Comma separated list of floating-point scale\n"
@@ -1166,9 +1169,7 @@ int tool_main(int argc, char** argv) {
bool doRTree = true;
bool doTileGrid = true;
bool doVerbose = false;
-#if SK_SUPPORT_GPU
- bool disableTextureCache = false;
-#endif
+
SkTDArray<size_t> configs;
SkTDArray<size_t> excludeConfigs;
SkTDArray<SkScalar> tileGridReplayScales;
@@ -1178,6 +1179,13 @@ int tool_main(int argc, char** argv) {
int moduloRemainder = -1;
int moduloDivisor = -1;
+#if SK_SUPPORT_GPU
+ struct {
+ size_t fBytes;
+ int fCount;
+ } gpuCacheSize = { -1, -1 }; // -1s mean use the default
+#endif
+
const char* const commandName = argv[0];
char* const* stop = argv + argc;
for (++argv; argv < stop; ++argv) {
@@ -1253,6 +1261,17 @@ int tool_main(int argc, char** argv) {
notifyMissingReadReference = true;
} else if (strcmp(*argv, "--forceBWtext") == 0) {
gForceBWtext = true;
+#if SK_SUPPORT_GPU
+ } else if (strcmp(*argv, "--gpuCacheSize") == 0) {
+ if (stop - argv > 2) {
+ gpuCacheSize.fBytes = atoi(*++argv);
+ gpuCacheSize.fCount = atoi(*++argv);
+ } else {
+ SkDebugf("missing arg for --gpuCacheSize\n");
+ usage(commandName);
+ return -1;
+ }
+#endif
} else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) {
usage(commandName);
return -1;
@@ -1304,10 +1323,6 @@ int tool_main(int argc, char** argv) {
doSerialize = true;
} else if (strcmp(*argv, "--noserialize") == 0) {
doSerialize = false;
- } else if (strcmp(*argv, "--notexturecache") == 0) {
-#if SK_SUPPORT_GPU
- disableTextureCache = true;
-#endif
} else if (strcmp(*argv, "--tiledPipe") == 0) {
doTiledPipe = true;
} else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) {
@@ -1408,9 +1423,6 @@ int tool_main(int argc, char** argv) {
#if SK_SUPPORT_GPU
GrContextFactory* grFactory = new GrContextFactory;
- if (disableTextureCache) {
- skiagm::GetGr()->setTextureCacheLimits(0, 0);
- }
#endif
int gmIndex = -1;
@@ -1506,6 +1518,17 @@ int tool_main(int argc, char** argv) {
renderTarget = rt.get();
grSuccess = NULL != renderTarget;
}
+ // Set the user specified cache limits if non-default.
+ size_t bytes;
+ int count;
+ gr->getTextureCacheLimits(&count, &bytes);
+ if (-1 != gpuCacheSize.fBytes) {
+ bytes = gpuCacheSize.fBytes;
+ }
+ if (-1 != gpuCacheSize.fCount) {
+ count = gpuCacheSize.fCount;
+ }
+ gr->setTextureCacheLimits(count, bytes);
}
if (!grSuccess) {
renderErrors |= kNoGpuContext_ErrorBitmask;