Commit b62f9ecf authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Pass the cache size in the command line to the ShaderDiskCache::CacheSizeBytes

Although there have been the thresholds of cache usage limitations for the Android
in /gpu/config/gpu_preferences.h, it would be good if we can give embedders the power
to set the cache size for the ShaderDiskCache. Because there are many various embedded
devices which have different sizes of disk.

Bug: 854494
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ie1ecb903a79e52ee79503df30fe1ae15b95739ea
Reviewed-on: https://chromium-review.googlesource.com/1107517
Commit-Queue: Gyuyoung Kim <gyuyoung.kim@lge.com>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569221}
parent 092d7b24
...@@ -33,6 +33,11 @@ const char kGpuBlacklistTestGroup[] = "gpu-blacklist-test-group"; ...@@ -33,6 +33,11 @@ const char kGpuBlacklistTestGroup[] = "gpu-blacklist-test-group";
// test_group ID. // test_group ID.
const char kGpuDriverBugListTestGroup[] = "gpu-driver-bug-list-test-group"; const char kGpuDriverBugListTestGroup[] = "gpu-driver-bug-list-test-group";
// Allows explicitly specifying the shader disk cache size for embedded devices.
// Default value is 6MB. On Android, 2MB is default and 128KB for low-end
// devices.
const char kShaderDiskCacheSizeKB[] = "shader-disk-cache-size-kb";
// Use GpuFence objects to synchronize display of overlay planes. // Use GpuFence objects to synchronize display of overlay planes.
const char kUseGpuFencesForOverlayPlanes[] = const char kUseGpuFencesForOverlayPlanes[] =
"use-gpu-fences-for-overlay-planes"; "use-gpu-fences-for-overlay-planes";
......
...@@ -16,6 +16,7 @@ GPU_EXPORT extern const char kGpuPreferences[]; ...@@ -16,6 +16,7 @@ GPU_EXPORT extern const char kGpuPreferences[];
GPU_EXPORT extern const char kIgnoreGpuBlacklist[]; GPU_EXPORT extern const char kIgnoreGpuBlacklist[];
GPU_EXPORT extern const char kGpuBlacklistTestGroup[]; GPU_EXPORT extern const char kGpuBlacklistTestGroup[];
GPU_EXPORT extern const char kGpuDriverBugListTestGroup[]; GPU_EXPORT extern const char kGpuDriverBugListTestGroup[];
GPU_EXPORT extern const char kShaderDiskCacheSizeKB[];
GPU_EXPORT extern const char kUseGpuFencesForOverlayPlanes[]; GPU_EXPORT extern const char kUseGpuFencesForOverlayPlanes[];
GPU_EXPORT extern const char kWebglAntialiasingMode[]; GPU_EXPORT extern const char kWebglAntialiasingMode[];
GPU_EXPORT extern const char kWebglMSAASampleCount[]; GPU_EXPORT extern const char kWebglMSAASampleCount[];
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
#include "gpu/ipc/host/shader_disk_cache.h" #include "gpu/ipc/host/shader_disk_cache.h"
#include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/common/constants.h"
#include "gpu/config/gpu_preferences.h" #include "gpu/config/gpu_preferences.h"
#include "gpu/config/gpu_switches.h"
#include "net/base/cache_type.h" #include "net/base/cache_type.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -21,6 +24,22 @@ namespace { ...@@ -21,6 +24,22 @@ namespace {
static const base::FilePath::CharType kGpuCachePath[] = static const base::FilePath::CharType kGpuCachePath[] =
FILE_PATH_LITERAL("GPUCache"); FILE_PATH_LITERAL("GPUCache");
#if !defined(OS_ANDROID)
size_t GetCustomCacheSizeBytesIfExists(base::StringPiece switch_string) {
const base::CommandLine& process_command_line =
*base::CommandLine::ForCurrentProcess();
size_t cache_size;
if (process_command_line.HasSwitch(switch_string)) {
if (base::StringToSizeT(
process_command_line.GetSwitchValueASCII(switch_string),
&cache_size)) {
return cache_size * 1024; // Bytes
}
}
return 0;
}
#endif
} // namespace } // namespace
// ShaderDiskCacheEntry handles the work of caching/updating the cached // ShaderDiskCacheEntry handles the work of caching/updating the cached
...@@ -637,6 +656,10 @@ int ShaderDiskCache::SetCacheCompleteCallback( ...@@ -637,6 +656,10 @@ int ShaderDiskCache::SetCacheCompleteCallback(
// static // static
size_t ShaderDiskCache::CacheSizeBytes() { size_t ShaderDiskCache::CacheSizeBytes() {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
size_t custom_cache_size =
GetCustomCacheSizeBytesIfExists(switches::kShaderDiskCacheSizeKB);
if (custom_cache_size)
return custom_cache_size;
return kDefaultMaxProgramCacheMemoryBytes; return kDefaultMaxProgramCacheMemoryBytes;
#else // !defined(OS_ANDROID) #else // !defined(OS_ANDROID)
if (!base::SysInfo::IsLowEndDevice()) if (!base::SysInfo::IsLowEndDevice())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment