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 d6cc034d588ae6..1a3974dc207950 100644 --- a/components/viz/host/host_gpu_memory_buffer_manager_unittest.cc +++ b/components/viz/host/host_gpu_memory_buffer_manager_unittest.cc @@ -58,6 +58,7 @@ 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 {} @@ -111,7 +112,9 @@ class TestGpuService : public mojom::GpuService { void RequestHDRStatus(RequestHDRStatusCallback callback) override {} - void LoadedShader(const std::string& key, const std::string& data) override {} + void LoadedShader(int32_t client_id, + 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 37fa4f2c33458e..84d25eb8dbbaa5 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,6 +5,7 @@ #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" @@ -16,7 +17,7 @@ namespace viz { InProcessGpuMemoryBufferManager::InProcessGpuMemoryBufferManager( gpu::GpuChannelManager* channel_manager) : gpu_memory_buffer_support_(new gpu::GpuMemoryBufferSupport()), - client_id_(gpu::InProcessCommandBuffer::kGpuClientId), + client_id_(gpu::kInProcessCommandBufferClientId), 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 a9e578db6e98b6..e4a80f8a732282 100644 --- a/components/viz/service/gl/gpu_service_impl.cc +++ b/components/viz/service/gl/gpu_service_impl.cc @@ -28,6 +28,7 @@ #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" @@ -702,8 +703,9 @@ 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 (oopd_enabled_ && client_id == gpu::InProcessCommandBuffer::kGpuClientId) { + if (gpu::IsReservedClientId(client_id)) { std::move(callback).Run(mojo::ScopedMessagePipeHandle()); return; } @@ -717,14 +719,15 @@ 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, std::move(wrap_callback))); + FROM_HERE, + base::BindOnce(&GpuServiceImpl::EstablishGpuChannel, weak_ptr_, + client_id, client_tracing_id, is_gpu_host, + cache_shaders_on_disk, std::move(wrap_callback))); return; } gpu::GpuChannel* gpu_channel = gpu_channel_manager_->EstablishChannel( - client_id, client_tracing_id, is_gpu_host); + client_id, client_tracing_id, is_gpu_host, cache_shaders_on_disk); mojo::MessagePipe pipe; gpu_channel->Init(std::make_unique( @@ -744,14 +747,16 @@ void GpuServiceImpl::CloseChannel(int32_t client_id) { gpu_channel_manager_->RemoveChannel(client_id); } -void GpuServiceImpl::LoadedShader(const std::string& key, +void GpuServiceImpl::LoadedShader(int32_t client_id, + const std::string& key, const std::string& data) { if (io_runner_->BelongsToCurrentThread()) { - main_runner_->PostTask(FROM_HERE, base::Bind(&GpuServiceImpl::LoadedShader, - weak_ptr_, key, data)); + main_runner_->PostTask(FROM_HERE, + base::Bind(&GpuServiceImpl::LoadedShader, weak_ptr_, + client_id, key, data)); return; } - gpu_channel_manager_->PopulateShaderCache(key, data); + gpu_channel_manager_->PopulateShaderCache(client_id, 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 31e1b5134c2efb..1365733597699a 100644 --- a/components/viz/service/gl/gpu_service_impl.h +++ b/components/viz/service/gl/gpu_service_impl.h @@ -182,6 +182,7 @@ 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) @@ -217,7 +218,9 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate, void GetGpuSupportedRuntimeVersion( GetGpuSupportedRuntimeVersionCallback callback) override; void RequestHDRStatus(RequestHDRStatusCallback callback) override; - void LoadedShader(const std::string& key, const std::string& data) override; + void LoadedShader(int32_t client_id, + 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 ca32413b3f3c23..108046255a3e75 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -28,6 +28,7 @@ #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" @@ -386,7 +387,7 @@ void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( GetShaderCacheFactorySingleton()->SetCacheInfo(gpu_client_id, cache_dir); if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor)) { GetShaderCacheFactorySingleton()->SetCacheInfo( - gpu::InProcessCommandBuffer::kGpuClientId, cache_dir); + gpu::kInProcessCommandBufferClientId, cache_dir); } } diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 8f0c3ee7befb62..808fdb860222ec 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -64,6 +64,7 @@ #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" @@ -996,7 +997,7 @@ void GpuProcessHost::EstablishGpuChannel( bool oopd_enabled = base::FeatureList::IsEnabled(features::kVizDisplayCompositor); - if (oopd_enabled && client_id == gpu::InProcessCommandBuffer::kGpuClientId) { + if (oopd_enabled && client_id == gpu::kInProcessCommandBufferClientId) { // The display-compositor in the gpu process uses this special client id. callback.Run(mojo::ScopedMessagePipeHandle(), gpu::GPUInfo(), gpu::GpuFeatureInfo(), @@ -1009,8 +1010,9 @@ 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, + client_id, client_tracing_id, is_gpu_host, cache_shaders_on_disk, base::BindOnce(&GpuProcessHost::OnChannelEstablished, weak_ptr_factory_.GetWeakPtr(), client_id, callback)); @@ -1018,7 +1020,7 @@ void GpuProcessHost::EstablishGpuChannel( switches::kDisableGpuShaderDiskCache)) { CreateChannelCache(client_id); if (oopd_enabled) - CreateChannelCache(gpu::InProcessCommandBuffer::kGpuClientId); + CreateChannelCache(gpu::kInProcessCommandBufferClientId); } } @@ -1588,7 +1590,8 @@ std::string GpuProcessHost::GetShaderPrefixKey() { return shader_prefix_key_; } -void GpuProcessHost::LoadedShader(const std::string& key, +void GpuProcessHost::LoadedShader(int32_t client_id, + const std::string& key, const std::string& data) { std::string prefix = GetShaderPrefixKey(); bool prefix_ok = !key.compare(0, prefix.length(), prefix); @@ -1596,7 +1599,7 @@ void GpuProcessHost::LoadedShader(const std::string& key, 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(key_no_prefix, data); + gpu_service_ptr_->LoadedShader(client_id, key_no_prefix, data); } } @@ -1614,7 +1617,8 @@ void GpuProcessHost::CreateChannelCache(int32_t client_id) { return; cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, - weak_ptr_factory_.GetWeakPtr())); + weak_ptr_factory_.GetWeakPtr(), + client_id)); 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 3ca9cf5c561bc1..5b318818094e7d 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -172,7 +172,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, // Forcefully terminates the GPU process. void ForceShutdown(); - void LoadedShader(const std::string& key, const std::string& data); + void LoadedShader(int32_t client_id, + 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 0e9fa8241a122f..c5ecd79f4cb313 100644 --- a/gpu/BUILD.gn +++ b/gpu/BUILD.gn @@ -350,6 +350,7 @@ 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 a8a16dcc822cf8..e445d706719957 100644 --- a/gpu/command_buffer/service/BUILD.gn +++ b/gpu/command_buffer/service/BUILD.gn @@ -161,6 +161,8 @@ 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 eb69950e3e0b88..467ffe9187720e 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); + context_state_->InitializeGrContext(workarounds, nullptr); 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 new file mode 100644 index 00000000000000..9fcff56915f37e --- /dev/null +++ b/gpu/command_buffer/service/gr_shader_cache.cc @@ -0,0 +1,164 @@ +// 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 new file mode 100644 index 00000000000000..bb1ae2e83893c2 --- /dev/null +++ b/gpu/command_buffer/service/gr_shader_cache.h @@ -0,0 +1,105 @@ +// 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 new file mode 100644 index 00000000000000..ce334c8a25ba76 --- /dev/null +++ b/gpu/command_buffer/service/gr_shader_cache_unittest.cc @@ -0,0 +1,133 @@ +// 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 9eab0cc984f71c..ff5f5a05d68305 100644 --- a/gpu/command_buffer/service/raster_decoder_context_state.cc +++ b/gpu/command_buffer/service/raster_decoder_context_state.cc @@ -39,7 +39,8 @@ RasterDecoderContextState::~RasterDecoderContextState() { } void RasterDecoderContextState::InitializeGrContext( - const GpuDriverBugWorkarounds& workarounds) { + const GpuDriverBugWorkarounds& workarounds, + GrContextOptions::PersistentCache* cache) { DCHECK(context->IsCurrent(surface.get())); sk_sp interface( @@ -61,6 +62,7 @@ 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 45bb2f6da883e5..daaf1640c490de 100644 --- a/gpu/command_buffer/service/raster_decoder_context_state.h +++ b/gpu/command_buffer/service/raster_decoder_context_state.h @@ -32,7 +32,8 @@ struct GPU_GLES2_EXPORT RasterDecoderContextState scoped_refptr surface, scoped_refptr context, bool use_virtualized_gl_contexts); - void InitializeGrContext(const GpuDriverBugWorkarounds& workarounds); + void InitializeGrContext(const GpuDriverBugWorkarounds& workarounds, + GrContextOptions::PersistentCache* cache); 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 859d19d4a7a983..968736e8089162 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); + context_state_->InitializeGrContext(workarounds, nullptr); 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 ab4cc15b28a686..28ae5bc28ff11a 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); + context_state->InitializeGrContext(config_.workarounds, nullptr); 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 c861fb229462b1..e4d4117eae09b3 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -36,6 +36,7 @@ #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" @@ -515,7 +516,7 @@ int32_t GLManager::CreateImage(ClientBuffer buffer, gl_image = gpu_memory_buffer_factory_->AsImageFactory() ->CreateImageForGpuMemoryBuffer( handle, size, format, internalformat, - gpu::InProcessCommandBuffer::kGpuClientId, + gpu::kInProcessCommandBufferClientId, gpu::kNullSurfaceHandle); if (!gl_image) return -1; diff --git a/gpu/ipc/BUILD.gn b/gpu/ipc/BUILD.gn index 5d99902af722a6..4605852d4e7f4e 100644 --- a/gpu/ipc/BUILD.gn +++ b/gpu/ipc/BUILD.gn @@ -37,6 +37,7 @@ 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 f11ae7d0fa7782..1f508059b309de 100644 --- a/gpu/ipc/common/BUILD.gn +++ b/gpu/ipc/common/BUILD.gn @@ -67,6 +67,7 @@ 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 new file mode 100644 index 00000000000000..4189674c43b3ba --- /dev/null +++ b/gpu/ipc/common/gpu_client_ids.h @@ -0,0 +1,31 @@ +// 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 fff92806ab7a48..20aeea5a0632be 100644 --- a/gpu/ipc/in_process_command_buffer.cc +++ b/gpu/ipc/in_process_command_buffer.cc @@ -54,6 +54,7 @@ #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" @@ -160,9 +161,6 @@ scoped_refptr MaybeGetDefaultTaskExecutor( } // anonyous namespace -const int InProcessCommandBuffer::kGpuClientId = - std::numeric_limits::max(); - InProcessCommandBuffer::InProcessCommandBuffer( scoped_refptr task_executer) : command_buffer_id_(CommandBufferId::FromUnsafeValue( @@ -434,7 +432,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread( new raster::RasterDecoderContextState(gl_share_group_, surface_, real_context, use_virtualized_gl_context_); - context_state->InitializeGrContext(workarounds); + context_state->InitializeGrContext(workarounds, nullptr); if (base::ThreadTaskRunnerHandle::IsSet()) { gr_cache_controller_.emplace(context_state.get(), @@ -924,8 +922,8 @@ void InProcessCommandBuffer::CreateImageOnGpuThread( scoped_refptr image = image_factory_->CreateImageForGpuMemoryBuffer( - std::move(handle), size, format, internalformat, kGpuClientId, - kNullSurfaceHandle); + std::move(handle), size, format, internalformat, + kInProcessCommandBufferClientId, kNullSurfaceHandle); if (!image.get()) { LOG(ERROR) << "Failed to create image for buffer."; return; @@ -967,7 +965,8 @@ 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(kGpuClientId, key, shader); + gpu_channel_manager_delegate_->StoreShaderToDisk( + kInProcessCommandBufferClientId, 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 fcc35e4c9efa0f..7e2864a279c588 100644 --- a/gpu/ipc/in_process_command_buffer.h +++ b/gpu/ipc/in_process_command_buffer.h @@ -187,8 +187,6 @@ 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 195ea0fcf25cb6..a5109da413e807 100644 --- a/gpu/ipc/service/command_buffer_stub.cc +++ b/gpu/ipc/service/command_buffer_stub.cc @@ -610,7 +610,15 @@ 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_); - command_buffer_->Flush(put_offset, decoder_context_.get()); + + { + 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()); + } + 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 eb2da596345433..be6239fb26f89e 100644 --- a/gpu/ipc/service/gpu_channel_manager.cc +++ b/gpu/ipc/service/gpu_channel_manager.cc @@ -25,6 +25,7 @@ #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" @@ -82,6 +83,15 @@ 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() { @@ -133,7 +143,11 @@ GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { GpuChannel* GpuChannelManager::EstablishChannel(int client_id, uint64_t client_tracing_id, - bool is_gpu_host) { + bool is_gpu_host, + bool cache_shaders_on_disk) { + if (gr_shader_cache_ && cache_shaders_on_disk) + gr_shader_cache_->CacheClientIdOnDisk(client_id); + 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); @@ -170,8 +184,15 @@ void GpuChannelManager::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, } } -void GpuChannelManager::PopulateShaderCache(const std::string& key, +void GpuChannelManager::PopulateShaderCache(int32_t client_id, + 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); } @@ -322,6 +343,8 @@ 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 @@ -411,7 +434,7 @@ GpuChannelManager::GetRasterDecoderContextState(ContextResult* result) { gpu::kGpuFeatureStatusEnabled; if (enable_raster_transport) { raster_decoder_context_state_->InitializeGrContext( - gpu_driver_bug_workarounds_); + gpu_driver_bug_workarounds_, gr_shader_cache()); } gr_cache_controller_.emplace(raster_decoder_context_state_.get(), @@ -426,4 +449,9 @@ 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 d446407946767a..255986d1f3c5ea 100644 --- a/gpu/ipc/service/gpu_channel_manager.h +++ b/gpu/ipc/service/gpu_channel_manager.h @@ -22,6 +22,7 @@ #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" @@ -59,7 +60,8 @@ 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 { +class GPU_IPC_SERVICE_EXPORT GpuChannelManager + : public raster::GrShaderCache::Client { public: GpuChannelManager(const GpuPreferences& gpu_preferences, GpuChannelManagerDelegate* delegate, @@ -71,16 +73,19 @@ class GPU_IPC_SERVICE_EXPORT GpuChannelManager { GpuMemoryBufferFactory* gpu_memory_buffer_factory, const GpuFeatureInfo& gpu_feature_info, GpuProcessActivityFlags activity_flags); - ~GpuChannelManager(); + ~GpuChannelManager() override; 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 is_gpu_host, + bool cache_shaders_on_disk); - void PopulateShaderCache(const std::string& key, const std::string& program); + void PopulateShaderCache(int32_t client_id, + const std::string& key, + const std::string& program); void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, const SyncToken& sync_token); @@ -142,6 +147,12 @@ 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); @@ -210,6 +221,7 @@ 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 c62e49af061b45..d9f5b3519fa70a 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); + GpuChannel* channel = channel_manager()->EstablishChannel( + kClientId, kClientTracingId, false, true); 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 eddef8f8629250..0705f075b5096a 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); + client_id, kClientTracingId, is_gpu_host, true); 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 afd2cbe9a538e8..8784f96f67b126 100644 --- a/services/ui/gpu_host/gpu_client.cc +++ b/services/ui/gpu_host/gpu_client.cc @@ -53,8 +53,9 @@ 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, + client_id_, client_tracing_id, is_gpu_host, cache_shaders_on_disk, 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 2e1faf249ac510..2541925da94c71 100644 --- a/services/viz/privileged/interfaces/gl/gpu_service.mojom +++ b/services/viz/privileged/interfaces/gl/gpu_service.mojom @@ -23,7 +23,8 @@ interface GpuService { // client. The GPU service responds with an IPC handle. EstablishGpuChannel(int32 client_id, uint64 client_tracing_id, - bool is_gpu_host) + bool is_gpu_host, + bool cache_shaders_on_disk) => (handle? channel_handle); // Tells the GPU process to close the channel identified by |client_id|. @@ -81,7 +82,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(string key, string data); + LoadedShader(int32 client_id, string key, string data); // Tells GPU to wake up the GPU because we're about to draw. WakeUpGpu();