Commit 7102df0b authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

gpu: Cache shaders from InProcessCommandBuffer.

Notable change(s):
. Assign the InProcessCommandBuffer a gpu-client id different from the
  browser. The implications are that the OOP-D gets a different shader
  cache, and gpu-memory namespace. This also applies to the display
  compositor with in-process-gpu.
. Channel-creation request with the client-id of the OOP-D is rejected.

BUG=845593

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: Ib74daf5c81ca9fa3fd28b390f5e721a9651f6d4a
Reviewed-on: https://chromium-review.googlesource.com/1069490
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562712}
parent d3766242
......@@ -15,7 +15,7 @@ namespace viz {
InProcessGpuMemoryBufferManager::InProcessGpuMemoryBufferManager(
gpu::GpuChannelManager* channel_manager)
: gpu_memory_buffer_support_(new gpu::GpuMemoryBufferSupport()),
client_id_(gpu::InProcessCommandBuffer::kGpuMemoryBufferClientId),
client_id_(gpu::InProcessCommandBuffer::kGpuClientId),
channel_manager_(channel_manager),
weak_factory_(this) {
weak_ptr_ = weak_factory_.GetWeakPtr();
......
......@@ -27,6 +27,7 @@
#include "gpu/config/gpu_util.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"
#include "gpu/ipc/service/gpu_channel.h"
#include "gpu/ipc/service/gpu_channel_manager.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
......@@ -634,6 +635,10 @@ void GpuServiceImpl::EstablishGpuChannel(int32_t client_id,
uint64_t client_tracing_id,
bool is_gpu_host,
EstablishGpuChannelCallback callback) {
if (oopd_enabled_ && client_id == gpu::InProcessCommandBuffer::kGpuClientId) {
std::move(callback).Run(mojo::ScopedMessagePipeHandle());
return;
}
if (io_runner_->BelongsToCurrentThread()) {
EstablishGpuChannelCallback wrap_callback = base::BindOnce(
[](scoped_refptr<base::SingleThreadTaskRunner> runner,
......
......@@ -127,6 +127,8 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate,
gl::GLContext* context_for_skia() { return context_for_skia_.get(); }
GrContext* gr_context() { return gr_context_.get(); }
void set_oopd_enabled() { oopd_enabled_ = true; }
private:
void RecordLogMessage(int severity,
size_t message_start,
......@@ -278,6 +280,8 @@ class VIZ_SERVICE_EXPORT GpuServiceImpl : public gpu::GpuChannelManagerDelegate,
scoped_refptr<arc::ProtectedBufferManager> protected_buffer_manager_;
#endif // defined(OS_CHROMEOS)
bool oopd_enabled_ = false;
base::WeakPtr<GpuServiceImpl> weak_ptr_;
base::WeakPtrFactory<GpuServiceImpl> weak_ptr_factory_;
......
......@@ -155,6 +155,8 @@ VizMainImpl::VizMainImpl(Delegate* delegate,
gpu_init_->gpu_feature_info(), gpu_init_->gpu_preferences(),
gpu_init_->gpu_info_for_hardware_gpu(),
gpu_init_->gpu_feature_info_for_hardware_gpu(), std::move(exit_callback));
if (dependencies_.create_display_compositor)
gpu_service_->set_oopd_enabled();
}
VizMainImpl::~VizMainImpl() {
......
......@@ -94,6 +94,7 @@ jumbo_source_set("browser") {
"//gpu/command_buffer/client:gles2_implementation",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/client:raster_interface",
"//gpu/ipc:gl_in_process_context",
"//gpu/ipc/common:gpu_preferences_util",
"//gpu/ipc/host",
"//gpu/vulkan:buildflags",
......
......@@ -15,6 +15,7 @@
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/features.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
......@@ -26,6 +27,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/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"
#include "ui/base/ui_base_features.h"
......@@ -371,6 +373,10 @@ void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO(
int gpu_client_id,
const base::FilePath& cache_dir) {
GetShaderCacheFactorySingleton()->SetCacheInfo(gpu_client_id, cache_dir);
if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor)) {
GetShaderCacheFactorySingleton()->SetCacheInfo(
gpu::InProcessCommandBuffer::kGpuClientId, cache_dir);
}
}
} // namespace content
......@@ -61,6 +61,7 @@
#include "gpu/config/gpu_driver_bug_list.h"
#include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "gpu/ipc/in_process_command_buffer.h"
#include "media/base/media_switches.h"
#include "media/media_buildflags.h"
#include "mojo/edk/embedder/embedder.h"
......@@ -940,6 +941,16 @@ void GpuProcessHost::EstablishGpuChannel(
return;
}
bool oopd_enabled =
base::FeatureList::IsEnabled(features::kVizDisplayCompositor);
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(),
EstablishChannelStatus::GPU_ACCESS_DENIED);
return;
}
DCHECK_EQ(preempts, allow_view_command_buffers);
DCHECK_EQ(preempts, allow_real_time_streams);
bool is_gpu_host = preempts;
......@@ -953,6 +964,8 @@ void GpuProcessHost::EstablishGpuChannel(
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGpuShaderDiskCache)) {
CreateChannelCache(client_id);
if (oopd_enabled)
CreateChannelCache(gpu::InProcessCommandBuffer::kGpuClientId);
}
}
......
......@@ -514,7 +514,7 @@ int32_t GLManager::CreateImage(ClientBuffer buffer,
gl_image = gpu_memory_buffer_factory_->AsImageFactory()
->CreateImageForGpuMemoryBuffer(
handle, size, format, internalformat,
gpu::InProcessCommandBuffer::kGpuMemoryBufferClientId,
gpu::InProcessCommandBuffer::kGpuClientId,
gpu::kNullSurfaceHandle);
if (!gl_image)
return -1;
......
......@@ -152,7 +152,8 @@ scoped_refptr<InProcessCommandBuffer::Service> GetInitialService(
} // anonyous namespace
const int InProcessCommandBuffer::kGpuMemoryBufferClientId = 1;
const int InProcessCommandBuffer::kGpuClientId =
std::numeric_limits<int>::max();
InProcessCommandBuffer::Service::Service(
const GpuPreferences& gpu_preferences,
......@@ -951,7 +952,7 @@ void InProcessCommandBuffer::CreateImageOnGpuThread(
scoped_refptr<gl::GLImage> image =
image_factory_->CreateImageForGpuMemoryBuffer(
handle, size, format, internalformat, kGpuMemoryBufferClientId,
handle, size, format, internalformat, kGpuClientId,
kNullSurfaceHandle);
if (!image.get()) {
LOG(ERROR) << "Failed to create image for buffer.";
......@@ -993,7 +994,8 @@ void InProcessCommandBuffer::OnConsoleMessage(int32_t id,
void InProcessCommandBuffer::CacheShader(const std::string& key,
const std::string& shader) {
// TODO(piman): implement this.
if (gpu_channel_manager_delegate_)
gpu_channel_manager_delegate_->StoreShaderToDisk(kGpuClientId, key, shader);
}
void InProcessCommandBuffer::OnFenceSyncRelease(uint64_t release) {
......
......@@ -202,7 +202,7 @@ class GL_IN_PROCESS_CONTEXT_EXPORT InProcessCommandBuffer
gpu::ServiceTransferCache* GetTransferCacheForTest() const;
static const int kGpuMemoryBufferClientId;
static const int kGpuClientId;
// The serializer interface to the GPU service (i.e. thread).
class Service {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment