Commit 689c31f3 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

Add --force-max-texture-size flag to limit texture size.

Previously Skia was always using max texture size that it gets from the
GPU. In some scenarious it's useful to set a lower texture size limit.
Particularly it's useful in some configurations on Fuchsia to reduce
probablity that we fail to allocate a texture due to protected memory
fragmentation. The new --force-max-texture-size flag will allow to set
this value from command line.

Bug: fuchsia:43693
Change-Id: Ia55ee08e611f762a95ef285252a2ef9b9fa3bd90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2018386
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735141}
parent 23e3babc
...@@ -178,6 +178,10 @@ GpuServiceImpl::GpuServiceImpl( ...@@ -178,6 +178,10 @@ GpuServiceImpl::GpuServiceImpl(
GrContextOptions context_options; GrContextOptions context_options;
context_options.fGlyphCacheTextureMaximumBytes = context_options.fGlyphCacheTextureMaximumBytes =
max_glyph_cache_texture_bytes; max_glyph_cache_texture_bytes;
if (gpu_preferences_.force_max_texture_size) {
context_options.fMaxTextureSizeOverride =
gpu_preferences_.force_max_texture_size;
}
#if BUILDFLAG(ENABLE_VULKAN) #if BUILDFLAG(ENABLE_VULKAN)
if (vulkan_implementation_) { if (vulkan_implementation_) {
......
...@@ -159,6 +159,7 @@ bool MaybeAddCommandLineArgsFromConfig(const base::Value& config, ...@@ -159,6 +159,7 @@ bool MaybeAddCommandLineArgsFromConfig(const base::Value& config,
switches::kEnableLowEndDeviceMode, switches::kEnableLowEndDeviceMode,
switches::kForceGpuMemAvailableMb, switches::kForceGpuMemAvailableMb,
switches::kForceGpuMemDiscardableLimitMb, switches::kForceGpuMemDiscardableLimitMb,
switches::kForceMaxTextureSize,
switches::kMinHeightForGpuRasterTile, switches::kMinHeightForGpuRasterTile,
switches::kRendererProcessLimit, switches::kRendererProcessLimit,
}; };
......
...@@ -47,6 +47,9 @@ const char kForceGpuMemAvailableMb[] = "force-gpu-mem-available-mb"; ...@@ -47,6 +47,9 @@ const char kForceGpuMemAvailableMb[] = "force-gpu-mem-available-mb";
const char kForceGpuMemDiscardableLimitMb[] = const char kForceGpuMemDiscardableLimitMb[] =
"force-gpu-mem-discardable-limit-mb"; "force-gpu-mem-discardable-limit-mb";
// Sets the maximum texture size in pixels.
const char kForceMaxTextureSize[] = "force-max-texture-size";
// Sets the maximum size of the in-memory gpu program cache, in kb // Sets the maximum size of the in-memory gpu program cache, in kb
const char kGpuProgramCacheSizeKb[] = "gpu-program-cache-size-kb"; const char kGpuProgramCacheSizeKb[] = "gpu-program-cache-size-kb";
......
...@@ -24,6 +24,7 @@ GPU_EXPORT extern const char kDisableGpuProgramCache[]; ...@@ -24,6 +24,7 @@ GPU_EXPORT extern const char kDisableGpuProgramCache[];
GPU_EXPORT extern const char kEnforceGLMinimums[]; GPU_EXPORT extern const char kEnforceGLMinimums[];
GPU_EXPORT extern const char kForceGpuMemAvailableMb[]; GPU_EXPORT extern const char kForceGpuMemAvailableMb[];
GPU_EXPORT extern const char kForceGpuMemDiscardableLimitMb[]; GPU_EXPORT extern const char kForceGpuMemDiscardableLimitMb[];
GPU_EXPORT extern const char kForceMaxTextureSize[];
GPU_EXPORT extern const char kGpuProgramCacheSizeKb[]; GPU_EXPORT extern const char kGpuProgramCacheSizeKb[];
GPU_EXPORT extern const char kDisableGpuShaderDiskCache[]; GPU_EXPORT extern const char kDisableGpuShaderDiskCache[];
GPU_EXPORT extern const char kEnableThreadedTextureMailboxes[]; GPU_EXPORT extern const char kEnableThreadedTextureMailboxes[];
......
...@@ -138,6 +138,8 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) { ...@@ -138,6 +138,8 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {
&gpu_preferences.force_gpu_mem_discardable_limit_bytes)) { &gpu_preferences.force_gpu_mem_discardable_limit_bytes)) {
gpu_preferences.force_gpu_mem_discardable_limit_bytes *= 1024 * 1024; gpu_preferences.force_gpu_mem_discardable_limit_bytes *= 1024 * 1024;
} }
GetUintFromSwitch(command_line, switches::kForceMaxTextureSize,
&gpu_preferences.force_max_texture_size);
if (GetUintFromSwitch(command_line, switches::kGpuProgramCacheSizeKb, if (GetUintFromSwitch(command_line, switches::kGpuProgramCacheSizeKb,
&gpu_preferences.gpu_program_cache_size)) { &gpu_preferences.gpu_program_cache_size)) {
gpu_preferences.gpu_program_cache_size *= 1024; gpu_preferences.gpu_program_cache_size *= 1024;
......
...@@ -218,6 +218,8 @@ void SharedContextState::InitializeGrContext( ...@@ -218,6 +218,8 @@ void SharedContextState::InitializeGrContext(
GrContextOptions::ShaderCacheStrategy::kBackendSource; GrContextOptions::ShaderCacheStrategy::kBackendSource;
} }
options.fShaderErrorHandler = this; options.fShaderErrorHandler = this;
if (gpu_preferences.force_max_texture_size)
options.fMaxTextureSizeOverride = gpu_preferences.force_max_texture_size;
// TODO(csmartdalton): enable internal multisampling after the related Skia // TODO(csmartdalton): enable internal multisampling after the related Skia
// rolls are in. // rolls are in.
options.fInternalMultisampleCount = 0; options.fInternalMultisampleCount = 0;
......
...@@ -141,6 +141,9 @@ struct GPU_EXPORT GpuPreferences { ...@@ -141,6 +141,9 @@ struct GPU_EXPORT GpuPreferences {
// Sets the maximum discardable cache size limit for GPU resources. // Sets the maximum discardable cache size limit for GPU resources.
uint32_t force_gpu_mem_discardable_limit_bytes = 0u; uint32_t force_gpu_mem_discardable_limit_bytes = 0u;
// Sets maximum texture size.
uint32_t force_max_texture_size = 0u;
// Sets the maximum size of the in-memory gpu program cache, in kb // Sets the maximum size of the in-memory gpu program cache, in kb
uint32_t gpu_program_cache_size = kDefaultMaxProgramCacheMemoryBytes; uint32_t gpu_program_cache_size = kDefaultMaxProgramCacheMemoryBytes;
......
...@@ -57,6 +57,7 @@ struct GpuPreferences { ...@@ -57,6 +57,7 @@ struct GpuPreferences {
bool enforce_gl_minimums; bool enforce_gl_minimums;
uint32 force_gpu_mem_available_bytes; uint32 force_gpu_mem_available_bytes;
uint32 force_gpu_mem_discardable_limit_bytes; uint32 force_gpu_mem_discardable_limit_bytes;
uint32 force_max_texture_size;
uint32 gpu_program_cache_size; uint32 gpu_program_cache_size;
bool disable_gpu_shader_disk_cache; bool disable_gpu_shader_disk_cache;
bool enable_threaded_texture_mailboxes; bool enable_threaded_texture_mailboxes;
......
...@@ -127,6 +127,7 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> { ...@@ -127,6 +127,7 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
out->force_gpu_mem_available_bytes = prefs.force_gpu_mem_available_bytes(); out->force_gpu_mem_available_bytes = prefs.force_gpu_mem_available_bytes();
out->force_gpu_mem_discardable_limit_bytes = out->force_gpu_mem_discardable_limit_bytes =
prefs.force_gpu_mem_discardable_limit_bytes(); prefs.force_gpu_mem_discardable_limit_bytes();
out->force_max_texture_size = prefs.force_max_texture_size();
out->gpu_program_cache_size = prefs.gpu_program_cache_size(); out->gpu_program_cache_size = prefs.gpu_program_cache_size();
out->disable_gpu_shader_disk_cache = prefs.disable_gpu_shader_disk_cache(); out->disable_gpu_shader_disk_cache = prefs.disable_gpu_shader_disk_cache();
out->enable_threaded_texture_mailboxes = out->enable_threaded_texture_mailboxes =
...@@ -255,6 +256,9 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> { ...@@ -255,6 +256,9 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
const gpu::GpuPreferences& prefs) { const gpu::GpuPreferences& prefs) {
return prefs.force_gpu_mem_discardable_limit_bytes; return prefs.force_gpu_mem_discardable_limit_bytes;
} }
static uint32_t force_max_texture_size(const gpu::GpuPreferences& prefs) {
return prefs.force_max_texture_size;
}
static uint32_t gpu_program_cache_size(const gpu::GpuPreferences& prefs) { static uint32_t gpu_program_cache_size(const gpu::GpuPreferences& prefs) {
return prefs.gpu_program_cache_size; return prefs.gpu_program_cache_size;
} }
......
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