Skip to content

Commit

Permalink
Revert "Reland gpu: Add disk caching for skia generated shaders in OO…
Browse files Browse the repository at this point in the history
…P-R."

This reverts commit c2667e3.

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 f9395d7.
>
> 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.
>
> [email protected]
>
> 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 <[email protected]>
> Reviewed-by: Antoine Labour <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#576742}

[email protected],[email protected],[email protected]

# 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 <[email protected]>
Cr-Commit-Position: refs/branch-heads/3497@{#61}
Cr-Branched-From: 271eaf5-refs/heads/master@{#576753}
  • Loading branch information
khushalsagar committed Jul 25, 2018
1 parent dba741d commit 971df0f
Show file tree
Hide file tree
Showing 30 changed files with 49 additions and 557 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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 {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
Expand Down
23 changes: 9 additions & 14 deletions components/viz/service/gl/gpu_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand All @@ -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<gpu::SyncChannelFilteredSender>(
Expand All @@ -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() {
Expand Down
5 changes: 1 addition & 4 deletions components/viz/service/gl/gpu_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions content/browser/gpu/browser_gpu_channel_host_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
}

Expand Down
16 changes: 6 additions & 10 deletions content/browser/gpu/gpu_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
Expand All @@ -1010,17 +1009,16 @@ 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));

if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGpuShaderDiskCache)) {
CreateChannelCache(client_id);
if (oopd_enabled)
CreateChannelCache(gpu::kInProcessCommandBufferClientId);
CreateChannelCache(gpu::InProcessCommandBuffer::kGpuClientId);
}
}

Expand Down Expand Up @@ -1590,16 +1588,15 @@ 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);
UMA_HISTOGRAM_BOOLEAN("GPU.ShaderLoadPrefixOK", prefix_ok);
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);
}
}

Expand All @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions content/browser/gpu/gpu_process_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 0 additions & 1 deletion gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions gpu/command_buffer/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion gpu/command_buffer/service/gr_cache_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<GrCacheController>(context_state_.get(), task_runner_);
Expand Down
164 changes: 0 additions & 164 deletions gpu/command_buffer/service/gr_shader_cache.cc

This file was deleted.

Loading

0 comments on commit 971df0f

Please sign in to comment.