Commit 437a6e06 authored by Khushal's avatar Khushal Committed by Commit Bot

gpu: Tune Gr cache memory limits for OOP raster.

Use same limits for GrContext cache limits in OOP and GPU raster, which
is tuned based on system memory.

R=piman@chromium.org
TBR=sadrul@chromium.org

Bug: 844207
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;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I7a0ae83a4b1ff14d2a9b5f14f6568a9c9cf25dc1
Reviewed-on: https://chromium-review.googlesource.com/1100008
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567148}
parent 182e86d6
......@@ -6,6 +6,7 @@ include_rules = [
"+gpu/command_buffer/client/raster_implementation_gles.h",
"+gpu/command_buffer/client/shared_memory_limits.h",
"+gpu/command_buffer/common/context_creation_attribs.h",
"+gpu/command_buffer/common/skia_utils.h",
"+gpu/command_buffer/service/image_factory.h",
"+gpu/ipc",
"+gpu/skia_bindings/grcontext_for_gles2_interface.h",
......
......@@ -18,6 +18,7 @@
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include "gpu/command_buffer/client/shared_memory_limits.h"
#include "gpu/command_buffer/common/context_creation_attribs.h"
#include "gpu/command_buffer/common/skia_utils.h"
#include "gpu/ipc/gl_in_process_context.h"
#include "gpu/ipc/raster_in_process_context.h"
#include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
......@@ -147,8 +148,8 @@ class GrContext* TestInProcessContextProvider::GrContext() {
size_t max_resource_cache_bytes;
size_t max_glyph_cache_texture_bytes;
skia_bindings::GrContextForGLES2Interface::DefaultCacheLimitsForTests(
&max_resource_cache_bytes, &max_glyph_cache_texture_bytes);
gpu::DefaultGrCacheLimitsForTests(&max_resource_cache_bytes,
&max_glyph_cache_texture_bytes);
gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(
ContextGL(), ContextSupport(), ContextCapabilities(),
max_resource_cache_bytes, max_glyph_cache_texture_bytes));
......
......@@ -17,6 +17,7 @@
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include "gpu/command_buffer/common/context_creation_attribs.h"
#include "gpu/command_buffer/common/skia_utils.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/config/gpu_feature_info.h"
......@@ -101,9 +102,8 @@ class GrContext* VizProcessContextProvider::GrContext() {
size_t max_resource_cache_bytes;
size_t max_glyph_cache_texture_bytes;
skia_bindings::GrContextForGLES2Interface::
DetermineCacheLimitsFromAvailableMemory(&max_resource_cache_bytes,
&max_glyph_cache_texture_bytes);
gpu::DetermineGrCacheLimitsFromAvailableMemory(
&max_resource_cache_bytes, &max_glyph_cache_texture_bytes);
gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(
ContextGL(), ContextSupport(), ContextCapabilities(),
......
......@@ -7,6 +7,7 @@ include_rules = [
"+gpu/command_buffer/client/gles2_interface_stub.h",
"+gpu/command_buffer/client/raster_implementation_gles.h",
"+gpu/command_buffer/common/capabilities.h",
"+gpu/command_buffer/common/skia_utils.h",
"+gpu/command_buffer/common/sync_token.h",
"+gpu/config/gpu_feature_info.h",
"+gpu/GLES2",
......
......@@ -18,6 +18,7 @@
#include "components/viz/common/gpu/context_cache_controller.h"
#include "components/viz/test/test_gles2_interface.h"
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include "gpu/command_buffer/common/skia_utils.h"
#include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
......@@ -256,8 +257,8 @@ class GrContext* TestContextProvider::GrContext() {
size_t max_resource_cache_bytes;
size_t max_glyph_cache_texture_bytes;
skia_bindings::GrContextForGLES2Interface::DefaultCacheLimitsForTests(
&max_resource_cache_bytes, &max_glyph_cache_texture_bytes);
gpu::DefaultGrCacheLimitsForTests(&max_resource_cache_bytes,
&max_glyph_cache_texture_bytes);
gr_context_ = std::make_unique<skia_bindings::GrContextForGLES2Interface>(
context_gl_.get(), support_.get(), context_gl_->test_capabilities(),
max_resource_cache_bytes, max_glyph_cache_texture_bytes);
......
......@@ -79,6 +79,8 @@ source_set("common_sources") {
"mailbox_holder.h",
"scheduling_priority.cc",
"scheduling_priority.h",
"skia_utils.cc",
"skia_utils.h",
"swap_buffers_complete_params.cc",
"swap_buffers_complete_params.h",
"swap_buffers_flags.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/command_buffer/common/skia_utils.h"
#include "base/sys_info.h"
#include "build/build_config.h"
namespace gpu {
void DetermineGrCacheLimitsFromAvailableMemory(
size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes) {
// Default limits.
constexpr size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024;
constexpr size_t kMaxDefaultGlyphCacheTextureBytes = 2048 * 1024 * 4;
*max_resource_cache_bytes = kMaxGaneshResourceCacheBytes;
*max_glyph_cache_texture_bytes = kMaxDefaultGlyphCacheTextureBytes;
// We can't call AmountOfPhysicalMemory under NACL, so leave the default.
#if !defined(OS_NACL)
// The limit of the bytes allocated toward GPU resources in the GrContext's
// GPU cache.
constexpr size_t kMaxLowEndGaneshResourceCacheBytes = 48 * 1024 * 1024;
constexpr size_t kMaxHighEndGaneshResourceCacheBytes = 256 * 1024 * 1024;
// Limits for glyph cache textures.
constexpr size_t kMaxLowEndGlyphCacheTextureBytes = 1024 * 512 * 4;
// High-end / low-end memory cutoffs.
constexpr int64_t kHighEndMemoryThreshold = (int64_t)4096 * 1024 * 1024;
constexpr int64_t kLowEndMemoryThreshold = (int64_t)512 * 1024 * 1024;
int64_t amount_of_physical_memory = base::SysInfo::AmountOfPhysicalMemory();
if (amount_of_physical_memory <= kLowEndMemoryThreshold) {
*max_resource_cache_bytes = kMaxLowEndGaneshResourceCacheBytes;
*max_glyph_cache_texture_bytes = kMaxLowEndGlyphCacheTextureBytes;
} else if (amount_of_physical_memory >= kHighEndMemoryThreshold) {
*max_resource_cache_bytes = kMaxHighEndGaneshResourceCacheBytes;
}
#endif
}
void DefaultGrCacheLimitsForTests(size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes) {
constexpr size_t kDefaultGlyphCacheTextureBytes = 2048 * 1024 * 4;
constexpr size_t kDefaultGaneshResourceCacheBytes = 96 * 1024 * 1024;
*max_resource_cache_bytes = kDefaultGaneshResourceCacheBytes;
*max_glyph_cache_texture_bytes = kDefaultGlyphCacheTextureBytes;
}
} // namespace gpu
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_COMMON_SKIA_UTILS_H_
#define GPU_COMMAND_BUFFER_COMMON_SKIA_UTILS_H_
#include <memory>
#include "gpu/gpu_export.h"
namespace gpu {
GPU_EXPORT void DetermineGrCacheLimitsFromAvailableMemory(
size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes);
GPU_EXPORT void DefaultGrCacheLimitsForTests(
size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes);
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_COMMON_SKIA_UTILS_H_
......@@ -32,6 +32,7 @@
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/raster_cmd_format.h"
#include "gpu/command_buffer/common/raster_cmd_ids.h"
#include "gpu/command_buffer/common/skia_utils.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
......@@ -984,7 +985,10 @@ ContextResult RasterDecoderImpl::Initialize(
GrContextOptions options;
options.fDriverBugWorkarounds =
GrDriverBugWorkarounds(workarounds().ToIntSet());
glyph_cache_max_texture_bytes_ = options.fGlyphCacheTextureMaximumBytes;
size_t max_resource_cache_bytes = 0u;
DetermineGrCacheLimitsFromAvailableMemory(
&max_resource_cache_bytes, &glyph_cache_max_texture_bytes_);
options.fGlyphCacheTextureMaximumBytes = glyph_cache_max_texture_bytes_;
gr_context_ = GrContext::MakeGL(std::move(interface), options);
if (gr_context_) {
......@@ -993,10 +997,9 @@ ContextResult RasterDecoderImpl::Initialize(
// rethought before shipping. Most likely a different command buffer
// context for raster-in-gpu, with a shared gl context / gr context
// that different decoders can use.
static constexpr int kMaxGaneshResourceCacheCount = 8196;
static constexpr size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024;
constexpr int kMaxGaneshResourceCacheCount = 16384;
gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount,
kMaxGaneshResourceCacheBytes);
max_resource_cache_bytes);
transfer_cache_ = std::make_unique<ServiceTransferCache>();
} else {
bool was_lost = CheckResetStatus();
......
......@@ -22,42 +22,6 @@
namespace skia_bindings {
void GrContextForGLES2Interface::DetermineCacheLimitsFromAvailableMemory(
size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes) {
// The limit of the bytes allocated toward GPU resources in the GrContext's
// GPU cache.
static const size_t kMaxLowEndGaneshResourceCacheBytes = 48 * 1024 * 1024;
static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024;
static const size_t kMaxHighEndGaneshResourceCacheBytes = 256 * 1024 * 1024;
// Limits for glyph cache textures.
static const size_t kMaxDefaultGlyphCacheTextureBytes = 2048 * 1024 * 4;
static const size_t kMaxLowEndGlyphCacheTextureBytes = 1024 * 512 * 4;
// High-end / low-end memory cutoffs.
static const int64_t kHighEndMemoryThreshold = (int64_t)4096 * 1024 * 1024;
static const int64_t kLowEndMemoryThreshold = (int64_t)512 * 1024 * 1024;
int64_t amount_of_physical_memory = base::SysInfo::AmountOfPhysicalMemory();
*max_resource_cache_bytes = kMaxGaneshResourceCacheBytes;
*max_glyph_cache_texture_bytes = kMaxDefaultGlyphCacheTextureBytes;
if (amount_of_physical_memory <= kLowEndMemoryThreshold) {
*max_resource_cache_bytes = kMaxLowEndGaneshResourceCacheBytes;
*max_glyph_cache_texture_bytes = kMaxLowEndGlyphCacheTextureBytes;
} else if (amount_of_physical_memory >= kHighEndMemoryThreshold) {
*max_resource_cache_bytes = kMaxHighEndGaneshResourceCacheBytes;
}
}
void GrContextForGLES2Interface::DefaultCacheLimitsForTests(
size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes) {
static const size_t kDefaultGlyphCacheTextureBytes = 2048 * 1024 * 4;
static const size_t kDefaultGaneshResourceCacheBytes = 96 * 1024 * 1024;
*max_resource_cache_bytes = kDefaultGaneshResourceCacheBytes;
*max_glyph_cache_texture_bytes = kDefaultGlyphCacheTextureBytes;
}
GrContextForGLES2Interface::GrContextForGLES2Interface(
gpu::gles2::GLES2Interface* gl,
gpu::ContextSupport* context_support,
......
......@@ -25,13 +25,6 @@ namespace skia_bindings {
// is alive.
class GrContextForGLES2Interface {
public:
static void DetermineCacheLimitsFromAvailableMemory(
size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes);
static void DefaultCacheLimitsForTests(size_t* max_resource_cache_bytes,
size_t* max_glyph_cache_texture_bytes);
explicit GrContextForGLES2Interface(gpu::gles2::GLES2Interface* gl,
gpu::ContextSupport* context_support,
const gpu::Capabilities& capabilities,
......
......@@ -28,6 +28,7 @@
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/skia_utils.h"
#include "gpu/ipc/client/command_buffer_proxy_impl.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "gpu/skia_bindings/gles2_implementation_with_grcontext_support.h"
......@@ -438,9 +439,8 @@ class GrContext* ContextProviderCommandBuffer::GrContext() {
size_t max_resource_cache_bytes;
size_t max_glyph_cache_texture_bytes;
skia_bindings::GrContextForGLES2Interface::
DetermineCacheLimitsFromAvailableMemory(&max_resource_cache_bytes,
&max_glyph_cache_texture_bytes);
gpu::DetermineGrCacheLimitsFromAvailableMemory(
&max_resource_cache_bytes, &max_glyph_cache_texture_bytes);
gpu::gles2::GLES2Interface* gl_interface;
if (trace_impl_)
......
......@@ -15,6 +15,7 @@
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include "gpu/command_buffer/client/shared_memory_limits.h"
#include "gpu/command_buffer/common/skia_utils.h"
#include "gpu/ipc/gl_in_process_context.h"
#include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
#include "third_party/skia/include/gpu/GrContext.h"
......@@ -158,8 +159,8 @@ class GrContext* InProcessContextProvider::GrContext() {
size_t max_resource_cache_bytes;
size_t max_glyph_cache_texture_bytes;
skia_bindings::GrContextForGLES2Interface::DefaultCacheLimitsForTests(
&max_resource_cache_bytes, &max_glyph_cache_texture_bytes);
gpu::DefaultGrCacheLimitsForTests(&max_resource_cache_bytes,
&max_glyph_cache_texture_bytes);
gr_context_.reset(new skia_bindings::GrContextForGLES2Interface(
ContextGL(), ContextSupport(), ContextCapabilities(),
max_resource_cache_bytes, max_glyph_cache_texture_bytes));
......
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