From 971df0f22220cfa2bf0d3e3ad0a70417f85e1cc3 Mon Sep 17 00:00:00 2001 From: Khushal Date: Wed, 25 Jul 2018 01:42:04 +0000 Subject: [PATCH] Revert "Reland gpu: Add disk caching for skia generated shaders in OOP-R." This reverts commit c2667e316f9bec1194d8d468862e772add87aeaa. Reason for revert: Only the first part made it to M69, without the subsequent patches this is just unnecessary overhead. Original change's description: > Reland gpu: Add disk caching for skia generated shaders in OOP-R. > > This reverts commit f9395d77ab8feb15a222dc8e2b3608ac6db22302. > > Use the GrContextOptions::PersistentCache API provided by skia to > persist shaders generated internally by skia for OOP raster to disk. > This requires using a special client id to namespace these shaders, > similar to the one used by the InProcessCommandBuffer for viz. > > While the shaders for different sources are stored seperately on disk, > they are finally merged into a single memory cache in the GPU process. In > order to maintain a seperate cache for skia generated shaders, this also > plumbs the client id for a loaded shader to the GPU process. > > TBR=tsepez@chromium.org > > Bug: 854416,840559, 865138 > 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: I65544ccaff96c3154a822dbc2500468fbcac8a0b > Reviewed-on: https://chromium-review.googlesource.com/1142829 > Commit-Queue: Khushal > Reviewed-by: Antoine Labour > Cr-Commit-Position: refs/heads/master@{#576742} TBR=tsepez@chromium.org,khushalsagar@chromium.org,piman@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 865138 Change-Id: Ia38b186475f802efb81d0764bf0a24350103f868 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 Reviewed-on: https://chromium-review.googlesource.com/1147041 Reviewed-by: Khushal Cr-Commit-Position: refs/branch-heads/3497@{#61} Cr-Branched-From: 271eaf50594eb818c9295dc78d364aea18c82ea8-refs/heads/master@{#576753} --- ...host_gpu_memory_buffer_manager_unittest.cc | 5 +- .../in_process_gpu_memory_buffer_manager.cc | 3 +- components/viz/service/gl/gpu_service_impl.cc | 23 +-- components/viz/service/gl/gpu_service_impl.h | 5 +- .../gpu/browser_gpu_channel_host_factory.cc | 3 +- content/browser/gpu/gpu_process_host.cc | 16 +- content/browser/gpu/gpu_process_host.h | 4 +- gpu/BUILD.gn | 1 - gpu/command_buffer/service/BUILD.gn | 2 - .../service/gr_cache_controller_unittest.cc | 2 +- gpu/command_buffer/service/gr_shader_cache.cc | 164 ------------------ gpu/command_buffer/service/gr_shader_cache.h | 105 ----------- .../service/gr_shader_cache_unittest.cc | 133 -------------- .../service/raster_decoder_context_state.cc | 4 +- .../service/raster_decoder_context_state.h | 3 +- .../service/raster_decoder_unittest.cc | 2 +- gpu/command_buffer/tests/fuzzer_main.cc | 2 +- gpu/command_buffer/tests/gl_manager.cc | 3 +- gpu/ipc/BUILD.gn | 1 - gpu/ipc/common/BUILD.gn | 1 - gpu/ipc/common/gpu_client_ids.h | 31 ---- gpu/ipc/in_process_command_buffer.cc | 13 +- gpu/ipc/in_process_command_buffer.h | 2 + gpu/ipc/service/command_buffer_stub.cc | 10 +- gpu/ipc/service/gpu_channel_manager.cc | 34 +--- gpu/ipc/service/gpu_channel_manager.h | 20 +-- .../service/gpu_channel_manager_unittest.cc | 4 +- gpu/ipc/service/gpu_channel_test_common.cc | 2 +- services/ui/gpu_host/gpu_client.cc | 3 +- .../interfaces/gl/gpu_service.mojom | 5 +- 30 files changed, 49 insertions(+), 557 deletions(-) delete mode 100644 gpu/command_buffer/service/gr_shader_cache.cc delete mode 100644 gpu/command_buffer/service/gr_shader_cache.h delete mode 100644 gpu/command_buffer/service/gr_shader_cache_unittest.cc delete mode 100644 gpu/ipc/common/gpu_client_ids.h diff --git a/components/viz/host/host_gpu_memory_buffer_manager_unittest.cc b/components/viz/host/host_gpu_memory_buffer_manager_unittest.cc index 1a3974dc2079..d6cc034d588a 100644 --- a/components/viz/host/host_gpu_memory_buffer_manager_unittest.cc +++ b/components/viz/host/host_gpu_memory_buffer_manager_unittest.cc @@ -58,7 +58,6 @@ class TestGpuService : public mojom::GpuService { void EstablishGpuChannel(int32_t client_id, uint64_t client_tracing_id, bool is_gpu_host, - bool cache_shaders_on_disk, EstablishGpuChannelCallback callback) override {} void CloseChannel(int32_t client_id) override {} @@ -112,9 +111,7 @@ class TestGpuService : public mojom::GpuService { void RequestHDRStatus(RequestHDRStatusCallback callback) override {} - void LoadedShader(int32_t client_id, - const std::string& key, - const std::string& data) override {} + void LoadedShader(const std::string& key, const std::string& data) override {} void WakeUpGpu() override {} diff --git a/components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.cc b/components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.cc index 84d25eb8dbba..37fa4f2c3345 100644 --- a/components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.cc +++ b/components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.cc @@ -5,7 +5,6 @@ #include "components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.h" #include "base/bind.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/common/gpu_memory_buffer_impl.h" #include "gpu/ipc/common/gpu_memory_buffer_support.h" #include "gpu/ipc/in_process_command_buffer.h" @@ -17,7 +16,7 @@ namespace viz { InProcessGpuMemoryBufferManager::InProcessGpuMemoryBufferManager( gpu::GpuChannelManager* channel_manager) : gpu_memory_buffer_support_(new gpu::GpuMemoryBufferSupport()), - client_id_(gpu::kInProcessCommandBufferClientId), + client_id_(gpu::InProcessCommandBuffer::kGpuClientId), channel_manager_(channel_manager), weak_factory_(this) { weak_ptr_ = weak_factory_.GetWeakPtr(); diff --git a/components/viz/service/gl/gpu_service_impl.cc b/components/viz/service/gl/gpu_service_impl.cc index e4a80f8a7322..a9e578db6e98 100644 --- a/components/viz/service/gl/gpu_service_impl.cc +++ b/components/viz/service/gl/gpu_service_impl.cc @@ -28,7 +28,6 @@ #include "gpu/config/gpu_info_collector.h" #include "gpu/config/gpu_switches.h" #include "gpu/config/gpu_util.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/common/gpu_memory_buffer_support.h" #include "gpu/ipc/common/memory_stats.h" #include "gpu/ipc/in_process_command_buffer.h" @@ -703,9 +702,8 @@ void GpuServiceImpl::SetActiveURL(const GURL& url) { void GpuServiceImpl::EstablishGpuChannel(int32_t client_id, uint64_t client_tracing_id, bool is_gpu_host, - bool cache_shaders_on_disk, EstablishGpuChannelCallback callback) { - if (gpu::IsReservedClientId(client_id)) { + if (oopd_enabled_ && client_id == gpu::InProcessCommandBuffer::kGpuClientId) { std::move(callback).Run(mojo::ScopedMessagePipeHandle()); return; } @@ -719,15 +717,14 @@ void GpuServiceImpl::EstablishGpuChannel(int32_t client_id, }, io_runner_, std::move(callback)); main_runner_->PostTask( - FROM_HERE, - base::BindOnce(&GpuServiceImpl::EstablishGpuChannel, weak_ptr_, - client_id, client_tracing_id, is_gpu_host, - cache_shaders_on_disk, std::move(wrap_callback))); + FROM_HERE, base::BindOnce(&GpuServiceImpl::EstablishGpuChannel, + weak_ptr_, client_id, client_tracing_id, + is_gpu_host, std::move(wrap_callback))); return; } gpu::GpuChannel* gpu_channel = gpu_channel_manager_->EstablishChannel( - client_id, client_tracing_id, is_gpu_host, cache_shaders_on_disk); + client_id, client_tracing_id, is_gpu_host); mojo::MessagePipe pipe; gpu_channel->Init(std::make_unique( @@ -747,16 +744,14 @@ void GpuServiceImpl::CloseChannel(int32_t client_id) { gpu_channel_manager_->RemoveChannel(client_id); } -void GpuServiceImpl::LoadedShader(int32_t client_id, - const std::string& key, +void GpuServiceImpl::LoadedShader(const std::string& key, const std::string& data) { if (io_runner_->BelongsToCurrentThread()) { - main_runner_->PostTask(FROM_HERE, - base::Bind(&GpuServiceImpl::LoadedShader, weak_ptr_, - client_id, key, data)); + main_runner_->PostTask(FROM_HERE, base::Bind(&GpuServiceImpl::LoadedShader, + weak_ptr_, key, data)); return; } - gpu_channel_manager_->PopulateShaderCache(client_id, key, data); + gpu_channel_manager_->PopulateShaderCache(key, data); } void GpuServiceImpl::WakeUpGpu() { diff --git a/components/viz/service/gl/gpu_service_impl.h b/components/viz/service/gl/gpu_service_impl.h index 136573359769..31e1b5134c2e 100644 --- a/components/viz/service/gl/gpu_service_impl.h +++ b/components/viz/service/gl/gpu_service_impl.h @@ -182,7 +182,6 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate, void EstablishGpuChannel(int32_t client_id, uint64_t client_tracing_id, bool is_gpu_host, - bool cache_shaders_on_disk, EstablishGpuChannelCallback callback) override; void CloseChannel(int32_t client_id) override; #if defined(OS_CHROMEOS) @@ -218,9 +217,7 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate, void GetGpuSupportedRuntimeVersion( GetGpuSupportedRuntimeVersionCallback callback) override; void RequestHDRStatus(RequestHDRStatusCallback callback) override; - void LoadedShader(int32_t client_id, - const std::string& key, - const std::string& data) override; + void LoadedShader(const std::string& key, const std::string& data) override; void WakeUpGpu() override; void GpuSwitched() override; void DestroyAllChannels() override; diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc index 108046255a3e..ca32413b3f3c 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -28,7 +28,6 @@ #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "gpu/command_buffer/service/gpu_switches.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/in_process_command_buffer.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/constants.mojom.h" #include "services/service_manager/runner/common/client_util.h" @@ -387,7 +386,7 @@ void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( GetShaderCacheFactorySingleton()->SetCacheInfo(gpu_client_id, cache_dir); if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor)) { GetShaderCacheFactorySingleton()->SetCacheInfo( - gpu::kInProcessCommandBufferClientId, cache_dir); + gpu::InProcessCommandBuffer::kGpuClientId, cache_dir); } } diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 808fdb860222..8f0c3ee7befb 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -64,7 +64,6 @@ #include "gpu/config/gpu_driver_bug_list.h" #include "gpu/config/gpu_driver_bug_workaround_type.h" #include "gpu/config/gpu_preferences.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/host/shader_disk_cache.h" #include "gpu/ipc/in_process_command_buffer.h" #include "media/base/media_switches.h" @@ -997,7 +996,7 @@ void GpuProcessHost::EstablishGpuChannel( bool oopd_enabled = base::FeatureList::IsEnabled(features::kVizDisplayCompositor); - if (oopd_enabled && client_id == gpu::kInProcessCommandBufferClientId) { + if (oopd_enabled && client_id == gpu::InProcessCommandBuffer::kGpuClientId) { // The display-compositor in the gpu process uses this special client id. callback.Run(mojo::ScopedMessagePipeHandle(), gpu::GPUInfo(), gpu::GpuFeatureInfo(), @@ -1010,9 +1009,8 @@ void GpuProcessHost::EstablishGpuChannel( bool is_gpu_host = preempts; channel_requests_.push(callback); - const bool cache_shaders_on_disk = true; gpu_service_ptr_->EstablishGpuChannel( - client_id, client_tracing_id, is_gpu_host, cache_shaders_on_disk, + client_id, client_tracing_id, is_gpu_host, base::BindOnce(&GpuProcessHost::OnChannelEstablished, weak_ptr_factory_.GetWeakPtr(), client_id, callback)); @@ -1020,7 +1018,7 @@ void GpuProcessHost::EstablishGpuChannel( switches::kDisableGpuShaderDiskCache)) { CreateChannelCache(client_id); if (oopd_enabled) - CreateChannelCache(gpu::kInProcessCommandBufferClientId); + CreateChannelCache(gpu::InProcessCommandBuffer::kGpuClientId); } } @@ -1590,8 +1588,7 @@ std::string GpuProcessHost::GetShaderPrefixKey() { return shader_prefix_key_; } -void GpuProcessHost::LoadedShader(int32_t client_id, - const std::string& key, +void GpuProcessHost::LoadedShader(const std::string& key, const std::string& data) { std::string prefix = GetShaderPrefixKey(); bool prefix_ok = !key.compare(0, prefix.length(), prefix); @@ -1599,7 +1596,7 @@ void GpuProcessHost::LoadedShader(int32_t client_id, if (prefix_ok) { // Remove the prefix from the key before load. std::string key_no_prefix = key.substr(prefix.length() + 1); - gpu_service_ptr_->LoadedShader(client_id, key_no_prefix, data); + gpu_service_ptr_->LoadedShader(key_no_prefix, data); } } @@ -1617,8 +1614,7 @@ void GpuProcessHost::CreateChannelCache(int32_t client_id) { return; cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, - weak_ptr_factory_.GetWeakPtr(), - client_id)); + weak_ptr_factory_.GetWeakPtr())); client_id_to_shader_cache_[client_id] = cache; } diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index 5b318818094e..3ca9cf5c561b 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -172,9 +172,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, // Forcefully terminates the GPU process. void ForceShutdown(); - void LoadedShader(int32_t client_id, - const std::string& key, - const std::string& data); + void LoadedShader(const std::string& key, const std::string& data); CONTENT_EXPORT viz::mojom::GpuService* gpu_service(); diff --git a/gpu/BUILD.gn b/gpu/BUILD.gn index c5ecd79f4cb3..0e9fa8241a12 100644 --- a/gpu/BUILD.gn +++ b/gpu/BUILD.gn @@ -350,7 +350,6 @@ test("gpu_unittests") { "command_buffer/service/gpu_service_test.h", "command_buffer/service/gpu_tracer_unittest.cc", "command_buffer/service/gr_cache_controller_unittest.cc", - "command_buffer/service/gr_shader_cache_unittest.cc", "command_buffer/service/id_manager_unittest.cc", "command_buffer/service/indexed_buffer_binding_host_unittest.cc", "command_buffer/service/mailbox_manager_unittest.cc", diff --git a/gpu/command_buffer/service/BUILD.gn b/gpu/command_buffer/service/BUILD.gn index e445d7067199..a8a16dcc822c 100644 --- a/gpu/command_buffer/service/BUILD.gn +++ b/gpu/command_buffer/service/BUILD.gn @@ -161,8 +161,6 @@ target(link_target_type, "gles2_sources") { "gpu_tracer.h", "gr_cache_controller.cc", "gr_cache_controller.h", - "gr_shader_cache.cc", - "gr_shader_cache.h", "id_manager.cc", "id_manager.h", "indexed_buffer_binding_host.cc", diff --git a/gpu/command_buffer/service/gr_cache_controller_unittest.cc b/gpu/command_buffer/service/gr_cache_controller_unittest.cc index 467ffe918772..eb69950e3e0b 100644 --- a/gpu/command_buffer/service/gr_cache_controller_unittest.cc +++ b/gpu/command_buffer/service/gr_cache_controller_unittest.cc @@ -36,7 +36,7 @@ class GrCacheControllerTest : public testing::Test { context_state_ = new raster::RasterDecoderContextState( std::move(share_group), std::move(surface), std::move(context), false /* use_virtualized_gl_contexts */); - context_state_->InitializeGrContext(workarounds, nullptr); + context_state_->InitializeGrContext(workarounds); controller_ = std::make_unique(context_state_.get(), task_runner_); diff --git a/gpu/command_buffer/service/gr_shader_cache.cc b/gpu/command_buffer/service/gr_shader_cache.cc deleted file mode 100644 index 9fcff56915f3..000000000000 --- a/gpu/command_buffer/service/gr_shader_cache.cc +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 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/service/gr_shader_cache.h" - -#include "base/trace_event/trace_event.h" - -namespace gpu { -namespace raster { -namespace { - -std::string MakeString(const SkData* data) { - return std::string(static_cast(data->data()), data->size()); -} - -sk_sp MakeData(const std::string& str) { - return SkData::MakeWithCopy(str.c_str(), str.length()); -} - -} // namespace - -GrShaderCache::GrShaderCache(size_t max_cache_size_bytes, Client* client) - : cache_size_limit_(max_cache_size_bytes), - store_(Store::NO_AUTO_EVICT), - client_(client) {} - -GrShaderCache::~GrShaderCache() = default; - -sk_sp GrShaderCache::load(const SkData& key) { - TRACE_EVENT0("gpu", "GrShaderCache::load"); - DCHECK_NE(current_client_id_, kInvalidClientId); - - CacheKey cache_key(SkData::MakeWithoutCopy(key.data(), key.size())); - auto it = store_.Get(cache_key); - if (it == store_.end()) - return nullptr; - - WriteToDisk(it->first, &it->second); - return it->second.data; -} - -void GrShaderCache::store(const SkData& key, const SkData& data) { - TRACE_EVENT0("gpu", "GrShaderCache::store"); - DCHECK_NE(current_client_id_, kInvalidClientId); - - if (data.size() > cache_size_limit_) - return; - EnforceLimits(data.size()); - - CacheKey cache_key(SkData::MakeWithCopy(key.data(), key.size())); - CacheData cache_data(SkData::MakeWithCopy(data.data(), data.size())); - auto it = store_.Put(std::move(cache_key), std::move(cache_data)); - curr_size_bytes_ += it->second.data->size(); - - WriteToDisk(it->first, &it->second); -} - -void GrShaderCache::PopulateCache(const std::string& key, - const std::string& data) { - if (data.length() > cache_size_limit_) - return; - - EnforceLimits(data.size()); - - CacheKey cache_key(MakeData(key)); - CacheData cache_data(MakeData(data)); - auto it = store_.Put(std::move(cache_key), std::move(cache_data)); - curr_size_bytes_ += it->second.data->size(); - - // This was loaded off the disk cache, no need to push this back for disk - // write. - it->second.pending_disk_write = false; -} - -void GrShaderCache::CacheClientIdOnDisk(int32_t client_id) { - client_ids_to_cache_on_disk_.insert(client_id); -} - -void GrShaderCache::PurgeMemory( - base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { - size_t original_limit = cache_size_limit_; - - switch (memory_pressure_level) { - case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: - // This function is only called with moderate or critical pressure. - NOTREACHED(); - return; - case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: - cache_size_limit_ = cache_size_limit_ / 4; - break; - case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: - cache_size_limit_ = 0; - break; - } - - EnforceLimits(0u); - cache_size_limit_ = original_limit; -} - -void GrShaderCache::WriteToDisk(const CacheKey& key, CacheData* data) { - DCHECK_NE(current_client_id_, kInvalidClientId); - - if (!data->pending_disk_write) - return; - - // Only cache the shader on disk if this client id is permitted. - if (client_ids_to_cache_on_disk_.count(current_client_id_) == 0) - return; - - data->pending_disk_write = false; - client_->StoreShader(MakeString(key.data.get()), - MakeString(data->data.get())); -} - -void GrShaderCache::EnforceLimits(size_t size_needed) { - DCHECK_LE(size_needed, cache_size_limit_); - - while (size_needed + curr_size_bytes_ > cache_size_limit_) { - auto it = store_.rbegin(); - DCHECK_GE(curr_size_bytes_, it->second.data->size()); - curr_size_bytes_ -= it->second.data->size(); - store_.Erase(it); - } -} - -GrShaderCache::ScopedCacheUse::ScopedCacheUse(GrShaderCache* cache, - int32_t client_id) - : cache_(cache) { - cache_->current_client_id_ = client_id; -} - -GrShaderCache::ScopedCacheUse::~ScopedCacheUse() { - cache_->current_client_id_ = kInvalidClientId; -} - -GrShaderCache::CacheKey::CacheKey(sk_sp data) : data(std::move(data)) { - hash = base::Hash(this->data->data(), this->data->size()); -} -GrShaderCache::CacheKey::CacheKey(const CacheKey& other) = default; -GrShaderCache::CacheKey::CacheKey(CacheKey&& other) = default; -GrShaderCache::CacheKey& GrShaderCache::CacheKey::operator=( - const CacheKey& other) = default; -GrShaderCache::CacheKey& GrShaderCache::CacheKey::operator=(CacheKey&& other) = - default; -GrShaderCache::CacheKey::~CacheKey() = default; - -bool GrShaderCache::CacheKey::operator==(const CacheKey& other) const { - return data->equals(other.data.get()); -} - -GrShaderCache::CacheData::CacheData(sk_sp data) - : data(std::move(data)) {} -GrShaderCache::CacheData::CacheData(CacheData&& other) = default; -GrShaderCache::CacheData& GrShaderCache::CacheData::operator=( - CacheData&& other) = default; -GrShaderCache::CacheData::~CacheData() = default; - -bool GrShaderCache::CacheData::operator==(const CacheData& other) const { - return data->equals(other.data.get()); -} - -} // namespace raster -} // namespace gpu diff --git a/gpu/command_buffer/service/gr_shader_cache.h b/gpu/command_buffer/service/gr_shader_cache.h deleted file mode 100644 index bb1ae2e83893..000000000000 --- a/gpu/command_buffer/service/gr_shader_cache.h +++ /dev/null @@ -1,105 +0,0 @@ -// 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_SERVICE_GR_SHADER_CACHE_H_ -#define GPU_COMMAND_BUFFER_SERVICE_GR_SHADER_CACHE_H_ - -#include "base/containers/flat_set.h" -#include "base/containers/mru_cache.h" -#include "base/hash.h" -#include "base/memory/memory_pressure_listener.h" -#include "gpu/gpu_gles2_export.h" -#include "third_party/skia/include/gpu/GrContextOptions.h" - -namespace gpu { -namespace raster { - -class GPU_GLES2_EXPORT GrShaderCache - : public GrContextOptions::PersistentCache { - public: - class GPU_GLES2_EXPORT Client { - public: - virtual ~Client() {} - - virtual void StoreShader(const std::string& key, - const std::string& shader) = 0; - }; - - class GPU_GLES2_EXPORT ScopedCacheUse { - public: - ScopedCacheUse(GrShaderCache* cache, int32_t client_id); - ~ScopedCacheUse(); - - private: - GrShaderCache* cache_; - }; - - GrShaderCache(size_t max_cache_size_bytes, Client* client); - ~GrShaderCache() override; - - // GrContextOptions::PersistentCache implementation. - sk_sp load(const SkData& key) override; - void store(const SkData& key, const SkData& data) override; - - void PopulateCache(const std::string& key, const std::string& data); - void CacheClientIdOnDisk(int32_t client_id); - void PurgeMemory( - base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); - - size_t num_cache_entries() const { return store_.size(); } - - private: - static constexpr int32_t kInvalidClientId = 0; - - struct CacheKey { - explicit CacheKey(sk_sp data); - CacheKey(CacheKey&& other); - CacheKey(const CacheKey& other); - CacheKey& operator=(const CacheKey& other); - CacheKey& operator=(CacheKey&& other); - ~CacheKey(); - - bool operator==(const CacheKey& other) const; - - sk_sp data; - size_t hash; - }; - - struct CacheData { - public: - explicit CacheData(sk_sp data); - CacheData(CacheData&& other); - CacheData& operator=(CacheData&& other); - ~CacheData(); - - bool operator==(const CacheData& other) const; - - sk_sp data; - bool pending_disk_write = true; - }; - - struct CacheKeyHash { - size_t operator()(const CacheKey& key) const { return key.hash; } - }; - - void EnforceLimits(size_t size_needed); - void WriteToDisk(const CacheKey& key, CacheData* data); - - size_t cache_size_limit_; - size_t curr_size_bytes_ = 0u; - using Store = base::HashingMRUCache; - Store store_; - - Client* const client_; - base::flat_set client_ids_to_cache_on_disk_; - - int32_t current_client_id_ = kInvalidClientId; - - DISALLOW_COPY_AND_ASSIGN(GrShaderCache); -}; - -} // namespace raster -} // namespace gpu - -#endif // GPU_COMMAND_BUFFER_SERVICE_GR_SHADER_CACHE_H_ diff --git a/gpu/command_buffer/service/gr_shader_cache_unittest.cc b/gpu/command_buffer/service/gr_shader_cache_unittest.cc deleted file mode 100644 index ce334c8a25ba..000000000000 --- a/gpu/command_buffer/service/gr_shader_cache_unittest.cc +++ /dev/null @@ -1,133 +0,0 @@ -// 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/service/gr_shader_cache.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace gpu { -namespace raster { -namespace { -constexpr char kShaderKey[] = "key"; -constexpr char kShader[] = "shader"; -constexpr size_t kCacheLimit = 1024u; - -} // namespace - -class GrShaderCacheTest : public GrShaderCache::Client, public testing::Test { - public: - GrShaderCacheTest() : cache_(kCacheLimit, this) {} - - void StoreShader(const std::string& key, const std::string& shader) override { - CHECK_EQ(disk_cache_.count(key), 0u); - disk_cache_[key] = shader; - } - - GrShaderCache cache_; - std::unordered_map disk_cache_; -}; - -TEST_F(GrShaderCacheTest, DoesNotCacheForIncognito) { - int32_t incognito_client_id = 2; - auto key = SkData::MakeWithCString(kShaderKey); - auto shader = SkData::MakeWithCString(kShader); - { - GrShaderCache::ScopedCacheUse cache_use(&cache_, incognito_client_id); - EXPECT_EQ(cache_.load(*key), nullptr); - cache_.store(*key, *shader); - } - EXPECT_EQ(disk_cache_.size(), 0u); - - int32_t regular_client_id = 3; - cache_.CacheClientIdOnDisk(regular_client_id); - { - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - auto cached_shader = cache_.load(*key); - ASSERT_TRUE(cached_shader); - EXPECT_TRUE(cached_shader->equals(shader.get())); - } - EXPECT_EQ(disk_cache_.size(), 1u); - - { - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - auto second_key = SkData::MakeWithCString("key2"); - EXPECT_EQ(cache_.load(*second_key), nullptr); - cache_.store(*second_key, *shader); - } - EXPECT_EQ(disk_cache_.size(), 2u); -} - -TEST_F(GrShaderCacheTest, LoadedFromDisk) { - int32_t regular_client_id = 3; - cache_.CacheClientIdOnDisk(regular_client_id); - auto key = SkData::MakeWithCopy(kShaderKey, strlen(kShaderKey)); - auto shader = SkData::MakeWithCString(kShader); - - std::string key_str(static_cast(key->data()), key->size()); - std::string shader_str(static_cast(shader->data()), - shader->size()); - cache_.PopulateCache(key_str, shader_str); - { - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - auto cached_shader = cache_.load(*key); - ASSERT_TRUE(cached_shader); - EXPECT_TRUE(cached_shader->equals(shader.get())); - } - EXPECT_EQ(disk_cache_.size(), 0u); -} - -TEST_F(GrShaderCacheTest, EnforcesLimits) { - int32_t regular_client_id = 3; - cache_.CacheClientIdOnDisk(regular_client_id); - - auto key = SkData::MakeWithCopy(kShaderKey, strlen(kShaderKey)); - auto shader = SkData::MakeUninitialized(kCacheLimit); - { - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - EXPECT_EQ(cache_.load(*key), nullptr); - cache_.store(*key, *shader); - } - EXPECT_EQ(cache_.num_cache_entries(), 1u); - - { - auto second_key = SkData::MakeWithCString("key2"); - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - EXPECT_EQ(cache_.load(*second_key), nullptr); - cache_.store(*second_key, *shader); - } - EXPECT_EQ(cache_.num_cache_entries(), 1u); - - { - auto third_key = SkData::MakeWithCString("key3"); - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - EXPECT_EQ(cache_.load(*third_key), nullptr); - std::string key_str(static_cast(third_key->data()), - third_key->size()); - std::string shader_str(static_cast(shader->data()), - shader->size()); - cache_.PopulateCache(key_str, shader_str); - } - EXPECT_EQ(cache_.num_cache_entries(), 1u); -} - -TEST_F(GrShaderCacheTest, MemoryPressure) { - int32_t regular_client_id = 3; - cache_.CacheClientIdOnDisk(regular_client_id); - - auto key = SkData::MakeWithCopy(kShaderKey, strlen(kShaderKey)); - auto shader = SkData::MakeUninitialized(kCacheLimit); - { - GrShaderCache::ScopedCacheUse cache_use(&cache_, regular_client_id); - EXPECT_EQ(cache_.load(*key), nullptr); - cache_.store(*key, *shader); - } - EXPECT_EQ(cache_.num_cache_entries(), 1u); - - cache_.PurgeMemory( - base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); - EXPECT_EQ(cache_.num_cache_entries(), 0u); -} - -} // namespace raster -} // namespace gpu diff --git a/gpu/command_buffer/service/raster_decoder_context_state.cc b/gpu/command_buffer/service/raster_decoder_context_state.cc index ff5f5a05d683..9eab0cc984f7 100644 --- a/gpu/command_buffer/service/raster_decoder_context_state.cc +++ b/gpu/command_buffer/service/raster_decoder_context_state.cc @@ -39,8 +39,7 @@ RasterDecoderContextState::~RasterDecoderContextState() { } void RasterDecoderContextState::InitializeGrContext( - const GpuDriverBugWorkarounds& workarounds, - GrContextOptions::PersistentCache* cache) { + const GpuDriverBugWorkarounds& workarounds) { DCHECK(context->IsCurrent(surface.get())); sk_sp interface( @@ -62,7 +61,6 @@ void RasterDecoderContextState::InitializeGrContext( raster::DetermineGrCacheLimitsFromAvailableMemory( &max_resource_cache_bytes, &glyph_cache_max_texture_bytes); options.fGlyphCacheTextureMaximumBytes = glyph_cache_max_texture_bytes; - options.fPersistentCache = cache; gr_context = GrContext::MakeGL(std::move(interface), options); if (!gr_context) { LOG(ERROR) << "OOP raster support disabled: GrContext creation " diff --git a/gpu/command_buffer/service/raster_decoder_context_state.h b/gpu/command_buffer/service/raster_decoder_context_state.h index daaf1640c490..45bb2f6da883 100644 --- a/gpu/command_buffer/service/raster_decoder_context_state.h +++ b/gpu/command_buffer/service/raster_decoder_context_state.h @@ -32,8 +32,7 @@ struct GPU_GLES2_EXPORT RasterDecoderContextState scoped_refptr surface, scoped_refptr context, bool use_virtualized_gl_contexts); - void InitializeGrContext(const GpuDriverBugWorkarounds& workarounds, - GrContextOptions::PersistentCache* cache); + void InitializeGrContext(const GpuDriverBugWorkarounds& workarounds); void PurgeMemory( base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); diff --git a/gpu/command_buffer/service/raster_decoder_unittest.cc b/gpu/command_buffer/service/raster_decoder_unittest.cc index 968736e80891..859d19d4a7a9 100644 --- a/gpu/command_buffer/service/raster_decoder_unittest.cc +++ b/gpu/command_buffer/service/raster_decoder_unittest.cc @@ -571,7 +571,7 @@ class RasterDecoderOOPTest : public testing::Test, DecoderClient { context_state_ = new raster::RasterDecoderContextState( std::move(share_group), std::move(surface), std::move(context), false /* use_virtualized_gl_contexts */); - context_state_->InitializeGrContext(workarounds, nullptr); + context_state_->InitializeGrContext(workarounds); GpuFeatureInfo gpu_feature_info; gpu_feature_info.status_values[GPU_FEATURE_TYPE_OOP_RASTERIZATION] = diff --git a/gpu/command_buffer/tests/fuzzer_main.cc b/gpu/command_buffer/tests/fuzzer_main.cc index 28ae5bc28ff1..ab4cc15b28a6 100644 --- a/gpu/command_buffer/tests/fuzzer_main.cc +++ b/gpu/command_buffer/tests/fuzzer_main.cc @@ -359,7 +359,7 @@ class CommandBufferSetup { new raster::RasterDecoderContextState( share_group_, surface_, context_, config_.workarounds.use_virtualized_gl_contexts); - context_state->InitializeGrContext(config_.workarounds, nullptr); + context_state->InitializeGrContext(config_.workarounds); decoder_.reset(raster::RasterDecoder::Create( command_buffer_.get(), command_buffer_->service(), &outputter_, context_group.get(), std::move(context_state))); diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index e4d4117eae09..c861fb229462 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -36,7 +36,6 @@ #include "gpu/command_buffer/service/memory_tracking.h" #include "gpu/command_buffer/service/service_utils.h" #include "gpu/command_buffer/service/transfer_buffer_manager.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/in_process_command_buffer.h" #include "gpu/ipc/service/gpu_memory_buffer_factory.h" #include "testing/gtest/include/gtest/gtest.h" @@ -516,7 +515,7 @@ int32_t GLManager::CreateImage(ClientBuffer buffer, gl_image = gpu_memory_buffer_factory_->AsImageFactory() ->CreateImageForGpuMemoryBuffer( handle, size, format, internalformat, - gpu::kInProcessCommandBufferClientId, + gpu::InProcessCommandBuffer::kGpuClientId, gpu::kNullSurfaceHandle); if (!gl_image) return -1; diff --git a/gpu/ipc/BUILD.gn b/gpu/ipc/BUILD.gn index 4605852d4e7f..5d99902af722 100644 --- a/gpu/ipc/BUILD.gn +++ b/gpu/ipc/BUILD.gn @@ -37,7 +37,6 @@ component("gl_in_process_context") { "//gpu/command_buffer/service:gles2", "//gpu/config", "//gpu/ipc/client", - "//gpu/ipc/common", "//gpu/ipc/common:surface_handle_type", "//gpu/ipc/host", "//gpu/ipc/service", diff --git a/gpu/ipc/common/BUILD.gn b/gpu/ipc/common/BUILD.gn index 1f508059b309..f11ae7d0fa77 100644 --- a/gpu/ipc/common/BUILD.gn +++ b/gpu/ipc/common/BUILD.gn @@ -67,7 +67,6 @@ source_set("ipc_common_sources") { sources = [ "flush_params.cc", "flush_params.h", - "gpu_client_ids.h", "gpu_memory_buffer_impl.cc", "gpu_memory_buffer_impl.h", "gpu_memory_buffer_impl_shared_memory.cc", diff --git a/gpu/ipc/common/gpu_client_ids.h b/gpu/ipc/common/gpu_client_ids.h deleted file mode 100644 index 4189674c43b3..000000000000 --- a/gpu/ipc/common/gpu_client_ids.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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_IPC_COMMON_GPU_CLIENT_IDS_H_ -#define GPU_IPC_COMMON_GPU_CLIENT_IDS_H_ - -namespace gpu { - -// The list of client id constants used to identify unique GPU clients. In the -// general case, GPU clients are assigned unique IDs in the browser. But these -// special constants are used for particular clients that should always be -// assigned the same ID. - -// The ID used by the InProcessCommandBuffer created in the GPU process for viz -// display compositor. -constexpr int32_t kInProcessCommandBufferClientId = -1; - -// The ID used for storing shaders created by skia in the GPU process. Note that -// this ID doesn't correspond to a real Gpu client/channel, but is required so -// we can use the same disk caching system for shaders and use a unique -// namespace for these shaders. -constexpr int32_t kGrShaderCacheClientId = -2; - -inline bool IsReservedClientId(int32_t client_id) { - return client_id < 0; -} - -} // namespace gpu - -#endif // GPU_IPC_COMMON_GPU_CLIENT_IDS_H_ diff --git a/gpu/ipc/in_process_command_buffer.cc b/gpu/ipc/in_process_command_buffer.cc index 20aeea5a0632..fff92806ab7a 100644 --- a/gpu/ipc/in_process_command_buffer.cc +++ b/gpu/ipc/in_process_command_buffer.cc @@ -54,7 +54,6 @@ #include "gpu/config/gpu_preferences.h" #include "gpu/config/gpu_switches.h" #include "gpu/ipc/command_buffer_task_executor.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/gpu_in_process_thread_service.h" #include "gpu/ipc/host/gpu_memory_buffer_support.h" #include "gpu/ipc/service/gpu_channel_manager_delegate.h" @@ -161,6 +160,9 @@ scoped_refptr MaybeGetDefaultTaskExecutor( } // anonyous namespace +const int InProcessCommandBuffer::kGpuClientId = + std::numeric_limits::max(); + InProcessCommandBuffer::InProcessCommandBuffer( scoped_refptr task_executer) : command_buffer_id_(CommandBufferId::FromUnsafeValue( @@ -432,7 +434,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread( new raster::RasterDecoderContextState(gl_share_group_, surface_, real_context, use_virtualized_gl_context_); - context_state->InitializeGrContext(workarounds, nullptr); + context_state->InitializeGrContext(workarounds); if (base::ThreadTaskRunnerHandle::IsSet()) { gr_cache_controller_.emplace(context_state.get(), @@ -922,8 +924,8 @@ void InProcessCommandBuffer::CreateImageOnGpuThread( scoped_refptr image = image_factory_->CreateImageForGpuMemoryBuffer( - std::move(handle), size, format, internalformat, - kInProcessCommandBufferClientId, kNullSurfaceHandle); + std::move(handle), size, format, internalformat, kGpuClientId, + kNullSurfaceHandle); if (!image.get()) { LOG(ERROR) << "Failed to create image for buffer."; return; @@ -965,8 +967,7 @@ void InProcessCommandBuffer::OnConsoleMessage(int32_t id, void InProcessCommandBuffer::CacheShader(const std::string& key, const std::string& shader) { if (gpu_channel_manager_delegate_) - gpu_channel_manager_delegate_->StoreShaderToDisk( - kInProcessCommandBufferClientId, key, shader); + gpu_channel_manager_delegate_->StoreShaderToDisk(kGpuClientId, key, shader); } void InProcessCommandBuffer::OnFenceSyncRelease(uint64_t release) { diff --git a/gpu/ipc/in_process_command_buffer.h b/gpu/ipc/in_process_command_buffer.h index 7e2864a279c5..fcc35e4c9efa 100644 --- a/gpu/ipc/in_process_command_buffer.h +++ b/gpu/ipc/in_process_command_buffer.h @@ -187,6 +187,8 @@ class GL_IN_PROCESS_CONTEXT_EXPORT InProcessCommandBuffer gpu::ServiceTransferCache* GetTransferCacheForTest() const; int GetRasterDecoderIdForTest() const; + static const int kGpuClientId; + CommandBufferTaskExecutor* service_for_testing() const { return task_executor_.get(); } diff --git a/gpu/ipc/service/command_buffer_stub.cc b/gpu/ipc/service/command_buffer_stub.cc index a5109da413e8..195ea0fcf25c 100644 --- a/gpu/ipc/service/command_buffer_stub.cc +++ b/gpu/ipc/service/command_buffer_stub.cc @@ -610,15 +610,7 @@ void CommandBufferStub::OnAsyncFlush(int32_t put_offset, uint32_t flush_id) { last_flush_id_ = flush_id; CommandBuffer::State pre_state = command_buffer_->GetState(); FastSetActiveURL(active_url_, active_url_hash_, channel_); - - { - auto* gr_shader_cache = channel_->gpu_channel_manager()->gr_shader_cache(); - base::Optional cache_use; - if (gr_shader_cache) - cache_use.emplace(gr_shader_cache, channel_->client_id()); - command_buffer_->Flush(put_offset, decoder_context_.get()); - } - + command_buffer_->Flush(put_offset, decoder_context_.get()); CommandBuffer::State post_state = command_buffer_->GetState(); if (pre_state.get_offset != post_state.get_offset) diff --git a/gpu/ipc/service/gpu_channel_manager.cc b/gpu/ipc/service/gpu_channel_manager.cc index be6239fb26f8..eb2da5963454 100644 --- a/gpu/ipc/service/gpu_channel_manager.cc +++ b/gpu/ipc/service/gpu_channel_manager.cc @@ -25,7 +25,6 @@ #include "gpu/command_buffer/service/scheduler.h" #include "gpu/command_buffer/service/service_utils.h" #include "gpu/command_buffer/service/sync_point_manager.h" -#include "gpu/ipc/common/gpu_client_ids.h" #include "gpu/ipc/common/gpu_messages.h" #include "gpu/ipc/common/memory_stats.h" #include "gpu/ipc/service/gpu_channel.h" @@ -83,15 +82,6 @@ GpuChannelManager::GpuChannelManager( DCHECK(task_runner->BelongsToCurrentThread()); DCHECK(io_task_runner); DCHECK(scheduler); - - const bool enable_raster_transport = - gpu_feature_info_.status_values[GPU_FEATURE_TYPE_OOP_RASTERIZATION] == - gpu::kGpuFeatureStatusEnabled; - bool disable_disk_cache = - gpu_preferences_.disable_gpu_shader_disk_cache || - gpu_driver_bug_workarounds_.disable_program_disk_cache; - if (enable_raster_transport && !disable_disk_cache) - gr_shader_cache_.emplace(gpu_preferences.gpu_program_cache_size, this); } GpuChannelManager::~GpuChannelManager() { @@ -143,11 +133,7 @@ GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { GpuChannel* GpuChannelManager::EstablishChannel(int client_id, uint64_t client_tracing_id, - bool is_gpu_host, - bool cache_shaders_on_disk) { - if (gr_shader_cache_ && cache_shaders_on_disk) - gr_shader_cache_->CacheClientIdOnDisk(client_id); - + bool is_gpu_host) { std::unique_ptr gpu_channel = std::make_unique( this, scheduler_, sync_point_manager_, share_group_, task_runner_, io_task_runner_, client_id, client_tracing_id, is_gpu_host); @@ -184,15 +170,8 @@ void GpuChannelManager::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, } } -void GpuChannelManager::PopulateShaderCache(int32_t client_id, - const std::string& key, +void GpuChannelManager::PopulateShaderCache(const std::string& key, const std::string& program) { - if (client_id == kGrShaderCacheClientId) { - if (gr_shader_cache_) - gr_shader_cache_->PopulateCache(key, program); - return; - } - if (program_cache()) program_cache()->LoadProgram(key, program); } @@ -343,8 +322,6 @@ void GpuChannelManager::HandleMemoryPressure( discardable_manager_.HandleMemoryPressure(memory_pressure_level); if (raster_decoder_context_state_) raster_decoder_context_state_->PurgeMemory(memory_pressure_level); - if (gr_shader_cache_) - gr_shader_cache_->PurgeMemory(memory_pressure_level); } scoped_refptr @@ -434,7 +411,7 @@ GpuChannelManager::GetRasterDecoderContextState(ContextResult* result) { gpu::kGpuFeatureStatusEnabled; if (enable_raster_transport) { raster_decoder_context_state_->InitializeGrContext( - gpu_driver_bug_workarounds_, gr_shader_cache()); + gpu_driver_bug_workarounds_); } gr_cache_controller_.emplace(raster_decoder_context_state_.get(), @@ -449,9 +426,4 @@ void GpuChannelManager::ScheduleGrContextCleanup() { gr_cache_controller_->ScheduleGrContextCleanup(); } -void GpuChannelManager::StoreShader(const std::string& key, - const std::string& shader) { - delegate_->StoreShaderToDisk(kGrShaderCacheClientId, key, shader); -} - } // namespace gpu diff --git a/gpu/ipc/service/gpu_channel_manager.h b/gpu/ipc/service/gpu_channel_manager.h index 255986d1f3c5..d44640794676 100644 --- a/gpu/ipc/service/gpu_channel_manager.h +++ b/gpu/ipc/service/gpu_channel_manager.h @@ -22,7 +22,6 @@ #include "gpu/command_buffer/common/activity_flags.h" #include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/service/gr_cache_controller.h" -#include "gpu/command_buffer/service/gr_shader_cache.h" #include "gpu/command_buffer/service/raster_decoder_context_state.h" #include "gpu/command_buffer/service/service_discardable_manager.h" #include "gpu/command_buffer/service/shader_translator_cache.h" @@ -60,8 +59,7 @@ class ProgramCache; // A GpuChannelManager is a thread responsible for issuing rendering commands // managing the lifetimes of GPU channels and forwarding IPC requests from the // browser process to them based on the corresponding renderer ID. -class GPU_IPC_SERVICE_EXPORT GpuChannelManager - : public raster::GrShaderCache::Client { +class GPU_IPC_SERVICE_EXPORT GpuChannelManager { public: GpuChannelManager(const GpuPreferences& gpu_preferences, GpuChannelManagerDelegate* delegate, @@ -73,19 +71,16 @@ class GPU_IPC_SERVICE_EXPORT GpuChannelManager GpuMemoryBufferFactory* gpu_memory_buffer_factory, const GpuFeatureInfo& gpu_feature_info, GpuProcessActivityFlags activity_flags); - ~GpuChannelManager() override; + ~GpuChannelManager(); GpuChannelManagerDelegate* delegate() const { return delegate_; } GpuWatchdogThread* watchdog() const { return watchdog_; } GpuChannel* EstablishChannel(int client_id, uint64_t client_tracing_id, - bool is_gpu_host, - bool cache_shaders_on_disk); + bool is_gpu_host); - void PopulateShaderCache(int32_t client_id, - const std::string& key, - const std::string& program); + void PopulateShaderCache(const std::string& key, const std::string& program); void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, const SyncToken& sync_token); @@ -147,12 +142,6 @@ class GPU_IPC_SERVICE_EXPORT GpuChannelManager scoped_refptr GetRasterDecoderContextState( ContextResult* result); void ScheduleGrContextCleanup(); - raster::GrShaderCache* gr_shader_cache() { - return gr_shader_cache_ ? &*gr_shader_cache_ : nullptr; - } - - // raster::GrShaderCache::Client implementation. - void StoreShader(const std::string& key, const std::string& shader) override; private: void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); @@ -221,7 +210,6 @@ class GPU_IPC_SERVICE_EXPORT GpuChannelManager // order to avoid having the GpuChannelManager keep the lost context state // alive until all clients have recovered, we use a ref-counted object and // allow the decoders to manage its lifetime. - base::Optional gr_shader_cache_; base::Optional gr_cache_controller_; scoped_refptr raster_decoder_context_state_; diff --git a/gpu/ipc/service/gpu_channel_manager_unittest.cc b/gpu/ipc/service/gpu_channel_manager_unittest.cc index d9f5b3519fa7..c62e49af061b 100644 --- a/gpu/ipc/service/gpu_channel_manager_unittest.cc +++ b/gpu/ipc/service/gpu_channel_manager_unittest.cc @@ -73,8 +73,8 @@ TEST_F(GpuChannelManagerTest, EstablishChannel) { uint64_t kClientTracingId = 1; ASSERT_TRUE(channel_manager()); - GpuChannel* channel = channel_manager()->EstablishChannel( - kClientId, kClientTracingId, false, true); + GpuChannel* channel = + channel_manager()->EstablishChannel(kClientId, kClientTracingId, false); EXPECT_TRUE(channel); EXPECT_EQ(channel_manager()->LookupChannel(kClientId), channel); } diff --git a/gpu/ipc/service/gpu_channel_test_common.cc b/gpu/ipc/service/gpu_channel_test_common.cc index 0705f075b509..eddef8f86292 100644 --- a/gpu/ipc/service/gpu_channel_test_common.cc +++ b/gpu/ipc/service/gpu_channel_test_common.cc @@ -107,7 +107,7 @@ GpuChannel* GpuChannelTestCommon::CreateChannel(int32_t client_id, bool is_gpu_host) { uint64_t kClientTracingId = 1; GpuChannel* channel = channel_manager()->EstablishChannel( - client_id, kClientTracingId, is_gpu_host, true); + client_id, kClientTracingId, is_gpu_host); channel->Init(std::make_unique()); base::ProcessId kProcessId = 1; channel->OnChannelConnected(kProcessId); diff --git a/services/ui/gpu_host/gpu_client.cc b/services/ui/gpu_host/gpu_client.cc index 8784f96f67b1..afd2cbe9a538 100644 --- a/services/ui/gpu_host/gpu_client.cc +++ b/services/ui/gpu_host/gpu_client.cc @@ -53,9 +53,8 @@ void GpuClient::EstablishGpuChannel(EstablishGpuChannelCallback callback) { gpu::GpuFeatureInfo()); } establish_callback_ = std::move(callback); - const bool cache_shaders_on_disk = true; gpu_service_->EstablishGpuChannel( - client_id_, client_tracing_id, is_gpu_host, cache_shaders_on_disk, + client_id_, client_tracing_id, is_gpu_host, base::Bind(&GpuClient::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); } diff --git a/services/viz/privileged/interfaces/gl/gpu_service.mojom b/services/viz/privileged/interfaces/gl/gpu_service.mojom index 2541925da94c..2e1faf249ac5 100644 --- a/services/viz/privileged/interfaces/gl/gpu_service.mojom +++ b/services/viz/privileged/interfaces/gl/gpu_service.mojom @@ -23,8 +23,7 @@ interface GpuService { // client. The GPU service responds with an IPC handle. EstablishGpuChannel(int32 client_id, uint64 client_tracing_id, - bool is_gpu_host, - bool cache_shaders_on_disk) + bool is_gpu_host) => (handle? channel_handle); // Tells the GPU process to close the channel identified by |client_id|. @@ -82,7 +81,7 @@ interface GpuService { // Notify GPU that a shader program was loaded from disk. Key is an // SHA-1 hash, and data a binary blob with serialized program info. // Note that this method is used only from a trusted process. - LoadedShader(int32 client_id, string key, string data); + LoadedShader(string key, string data); // Tells GPU to wake up the GPU because we're about to draw. WakeUpGpu();