Commit 2abe2821 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

exo: Use SharedImages instead of GL images

This patch gets rid of GL dependencies in exo.
It replaces GL images creations, updates and deletions with SharedImages.
Copies between shared images and queries are now issued using
RasterInterface.

Test: ARC++ works with Playstore and Youtube
Change-Id: I1dda38fb2b4b93393f9f4a7d308a5c80a53c47e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1527328Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Auto-Submit: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644525}
parent 46889bc4
......@@ -59,7 +59,7 @@ source_set("exo") {
"//device/gamepad",
"//device/gamepad/public/cpp:shared_with_blink",
"//gpu",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/client:raster_interface",
"//services/ws/public/mojom",
"//skia",
"//ui/aura",
......@@ -184,7 +184,7 @@ source_set("unit_tests") {
"//components/viz/service",
"//components/viz/test:test_support",
"//device/gamepad:test_helpers",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/client:raster_interface",
"//skia",
"//testing/gmock",
"//testing/gtest",
......
This diff is collapsed.
......@@ -14,9 +14,8 @@
#include "components/exo/test/exo_test_helper.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/resources/single_release_callback.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "ui/aura/env.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/test/in_process_context_factory.h"
......@@ -39,11 +38,12 @@ void VerifySyncTokensInCompositorFrame(viz::CompositorFrame* frame) {
std::vector<GLbyte*> sync_tokens;
for (auto& resource : frame->resource_list)
sync_tokens.push_back(resource.mailbox_holder.sync_token.GetData());
gpu::gles2::GLES2Interface* gles2 = GetAuraEnv()
->context_factory()
->SharedMainThreadContextProvider()
->ContextGL();
gles2->VerifySyncTokensCHROMIUM(sync_tokens.data(), sync_tokens.size());
gpu::raster::RasterInterface* ri =
GetAuraEnv()
->context_factory()
->SharedMainThreadRasterContextProvider()
->RasterInterface();
ri->VerifySyncTokensCHROMIUM(sync_tokens.data(), sync_tokens.size());
}
TEST_F(BufferTest, ReleaseCallback) {
......@@ -102,12 +102,12 @@ TEST_F(BufferTest, IsLost) {
frame_sink_holder->resource_manager(), false, &resource);
ASSERT_TRUE(rv);
scoped_refptr<viz::ContextProvider> context_provider =
GetAuraEnv()->context_factory()->SharedMainThreadContextProvider();
scoped_refptr<viz::RasterContextProvider> context_provider =
GetAuraEnv()->context_factory()->SharedMainThreadRasterContextProvider();
if (context_provider) {
gpu::gles2::GLES2Interface* gles2 = context_provider->ContextGL();
gles2->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
GL_INNOCENT_CONTEXT_RESET_ARB);
gpu::raster::RasterInterface* ri = context_provider->RasterInterface();
ri->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
GL_INNOCENT_CONTEXT_RESET_ARB);
}
// Release buffer.
......
......@@ -877,7 +877,7 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() {
bool need_alpha_channel = false;
bool support_locking = false;
bool support_gles2_interface = true;
bool support_raster_interface = false;
bool support_raster_interface = true;
bool support_grcontext = true;
shared_main_thread_contexts_ = CreateContextCommon(
std::move(gpu_channel_host), gpu::kNullSurfaceHandle, need_alpha_channel,
......@@ -893,6 +893,14 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() {
return shared_main_thread_contexts_;
}
scoped_refptr<viz::RasterContextProvider>
GpuProcessTransportFactory::SharedMainThreadRasterContextProvider() {
SharedMainThreadContextProvider();
DCHECK(!shared_main_thread_contexts_ ||
shared_main_thread_contexts_->RasterInterface());
return shared_main_thread_contexts_;
}
scoped_refptr<viz::RasterContextProvider>
GpuProcessTransportFactory::shared_worker_context_provider() {
return shared_worker_context_provider_factory_.provider();
......
......@@ -70,6 +70,9 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
base::WeakPtr<ui::Compositor> compositor) override;
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
void AddObserver(ui::ContextFactoryObserver* observer) override;
......
......@@ -95,6 +95,12 @@ TestImageTransportFactory::SharedMainThreadContextProvider() {
return shared_main_context_provider_;
}
scoped_refptr<viz::RasterContextProvider>
TestImageTransportFactory::SharedMainThreadRasterContextProvider() {
NOTIMPLEMENTED();
return nullptr;
}
gpu::GpuMemoryBufferManager*
TestImageTransportFactory::GetGpuMemoryBufferManager() {
return &gpu_memory_buffer_manager_;
......
......@@ -47,6 +47,9 @@ class TestImageTransportFactory : public ui::ContextFactory,
base::WeakPtr<ui::Compositor> compositor) override;
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
void RemoveCompositor(ui::Compositor* compositor) override {}
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
......
......@@ -248,6 +248,13 @@ VizProcessTransportFactory::SharedMainThreadContextProvider() {
return main_context_provider_;
}
scoped_refptr<viz::RasterContextProvider>
VizProcessTransportFactory::SharedMainThreadRasterContextProvider() {
SharedMainThreadContextProvider();
DCHECK(!main_context_provider_ || main_context_provider_->RasterInterface());
return main_context_provider_;
}
void VizProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) {
context_factory_private_.UnconfigureCompositor(compositor);
}
......@@ -451,7 +458,7 @@ VizProcessTransportFactory::TryCreateContextsForGpuCompositing(
if (!main_context_provider_) {
constexpr bool kCompositorContextSupportsLocking = false;
constexpr bool kCompositorContextSupportsGLES2 = true;
constexpr bool kCompositorContextSupportsRaster = false;
constexpr bool kCompositorContextSupportsRaster = true;
constexpr bool kCompositorContextSupportsGrContext = true;
constexpr bool kCompositorContextSupportsOOPR = false;
......
......@@ -64,6 +64,9 @@ class VizProcessTransportFactory : public ui::ContextFactory,
base::WeakPtr<ui::Compositor> compositor) override;
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
void RemoveCompositor(ui::Compositor* compositor) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
......
......@@ -9,6 +9,7 @@
#include "components/viz/common/gpu/raster_context_provider.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "services/ws/ids.h"
#include "services/ws/public/cpp/gpu/context_provider_command_buffer.h"
#include "services/ws/public/cpp/gpu/gpu.h"
#include "ui/compositor/host/host_context_factory_private.h"
......@@ -37,7 +38,7 @@ void HostContextFactory::OnEstablishedGpuChannel(
if (!compositor)
return;
scoped_refptr<viz::ContextProvider> context_provider =
scoped_refptr<ws::ContextProviderCommandBuffer> context_provider =
gpu_->CreateContextProvider(std::move(gpu_channel));
// If the binding fails, then we need to return early since the compositor
// expects a successfully initialized/bound provider.
......@@ -70,6 +71,16 @@ HostContextFactory::SharedMainThreadContextProvider() {
return shared_main_thread_context_provider_;
}
scoped_refptr<viz::RasterContextProvider>
HostContextFactory::SharedMainThreadRasterContextProvider() {
// Exo is currently the only client requesting this context provider.
// Exo does not request this context in the Window Service.
SharedMainThreadContextProvider();
DCHECK(!shared_main_thread_context_provider_ ||
shared_main_thread_context_provider_->RasterInterface());
return shared_main_thread_context_provider_;
}
void HostContextFactory::RemoveCompositor(ui::Compositor* compositor) {
context_factory_private_->UnconfigureCompositor(compositor);
}
......
......@@ -14,6 +14,7 @@
#include "base/memory/weak_ptr.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/gpu/raster_context_provider.h"
#include "services/ws/public/cpp/raster_thread_helper.h"
#include "ui/compositor/compositor.h"
......@@ -27,6 +28,7 @@ class HostContextFactoryPrivate;
namespace ws {
class ContextProviderCommandBuffer;
class Gpu;
// ui::ContextFactory used when the WindowService is acting as the viz host.
......@@ -50,6 +52,8 @@ class HostContextFactory : public ui::ContextFactory {
base::WeakPtr<ui::Compositor> compositor) override;
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
void RemoveCompositor(ui::Compositor* compositor) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
......@@ -59,7 +63,8 @@ class HostContextFactory : public ui::ContextFactory {
RasterThreadHelper raster_thread_helper_;
Gpu* gpu_;
scoped_refptr<viz::ContextProvider> shared_main_thread_context_provider_;
scoped_refptr<ws::ContextProviderCommandBuffer>
shared_main_thread_context_provider_;
std::unique_ptr<ui::HostContextFactoryPrivate> context_factory_private_;
......
......@@ -276,7 +276,7 @@ std::unique_ptr<Gpu> Gpu::Create(
return base::WrapUnique(new Gpu(std::move(gpu_ptr), std::move(task_runner)));
}
scoped_refptr<viz::ContextProvider> Gpu::CreateContextProvider(
scoped_refptr<ws::ContextProviderCommandBuffer> Gpu::CreateContextProvider(
scoped_refptr<gpu::GpuChannelHost> gpu_channel) {
int32_t stream_id = 0;
gpu::SchedulingPriority stream_priority = gpu::SchedulingPriority::kNormal;
......@@ -293,6 +293,7 @@ scoped_refptr<viz::ContextProvider> Gpu::CreateContextProvider(
attributes.sample_buffers = 0;
attributes.bind_generates_resource = false;
attributes.lose_context_when_out_of_memory = true;
attributes.enable_raster_interface = true;
return base::MakeRefCounted<ContextProviderCommandBuffer>(
std::move(gpu_channel), GetGpuMemoryBufferManager(), stream_id,
stream_priority, gpu::kNullSurfaceHandle,
......
......@@ -22,6 +22,8 @@ class Connector;
namespace ws {
class ContextProviderCommandBuffer;
class Gpu : public gpu::GpuChannelEstablishFactory {
public:
// The Gpu has to be initialized in the main thread before establishing
......@@ -37,7 +39,7 @@ class Gpu : public gpu::GpuChannelEstablishFactory {
return gpu_memory_buffer_manager_.get();
}
scoped_refptr<viz::ContextProvider> CreateContextProvider(
scoped_refptr<ws::ContextProviderCommandBuffer> CreateContextProvider(
scoped_refptr<gpu::GpuChannelHost> gpu_channel);
void CreateJpegDecodeAccelerator(
......
......@@ -12,6 +12,7 @@
#include "components/viz/host/renderer_settings_creation.h"
#include "gpu/command_buffer/common/scheduling_priority.h"
#include "services/ws/public/cpp/gpu/command_buffer_metrics.h"
#include "services/ws/public/cpp/gpu/context_provider_command_buffer.h"
#include "services/ws/public/cpp/gpu/gpu.h"
#include "services/ws/public/cpp/gpu/shared_worker_context_provider_factory.h"
#include "ui/aura/mus/window_port_mus.h"
......@@ -49,7 +50,7 @@ void MusContextFactory::OnEstablishedGpuChannel(
DCHECK_EQ(host->compositor(), compositor.get());
scoped_refptr<viz::ContextProvider> context_provider =
scoped_refptr<ws::ContextProviderCommandBuffer> context_provider =
gpu_->CreateContextProvider(gpu_channel);
// If the binding fails, then we need to return early since the compositor
// expects a successfully initialized/bound provider.
......@@ -107,6 +108,14 @@ MusContextFactory::SharedMainThreadContextProvider() {
return shared_main_thread_context_provider_;
}
scoped_refptr<viz::RasterContextProvider>
MusContextFactory::SharedMainThreadRasterContextProvider() {
// Exo is currently the only client requesting this context provider.
// Exo does not request this context in MUS.
NOTREACHED();
return nullptr;
}
void MusContextFactory::RemoveCompositor(ui::Compositor* compositor) {
// NOTIMPLEMENTED();
}
......
......@@ -48,6 +48,10 @@ class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
base::WeakPtr<ui::Compositor> compositor) override;
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
void RemoveCompositor(ui::Compositor* compositor) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
......
......@@ -67,6 +67,7 @@ namespace viz {
class FrameSinkManagerImpl;
class ContextProvider;
class HostFrameSinkManager;
class RasterContextProvider;
}
namespace ui {
......@@ -86,10 +87,11 @@ class COMPOSITOR_EXPORT ContextFactoryObserver {
public:
virtual ~ContextFactoryObserver() {}
// Notifies that the viz::ContextProvider returned from
// ui::ContextFactory::SharedMainThreadContextProvider was lost. When this
// is called, the old resources (e.g. shared context, GL helper) still
// exist, but are about to be destroyed. Getting a reference to those
// Notifies that the viz::ContextProviders returned from
// ui::ContextFactory::SharedMainThreadContextProvider and/or
// ui::ContextFactory::SharedMainThreadRasterContextProvider were lost.
// When this is called, the old resources (e.g. shared context, GL helper)
// still exist, but are about to be destroyed. Getting a reference to those
// resources from the ContextFactory (e.g. through
// SharedMainThreadContextProvider()) will return newly recreated, valid
// resources.
......@@ -177,6 +179,11 @@ class COMPOSITOR_EXPORT ContextFactory {
virtual scoped_refptr<viz::ContextProvider>
SharedMainThreadContextProvider() = 0;
// Return a reference to a shared offscreen context provider usable from the
// main thread.
virtual scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() = 0;
// Destroys per-compositor data.
virtual void RemoveCompositor(Compositor* compositor) = 0;
......
......@@ -51,6 +51,11 @@ FakeContextFactory::SharedMainThreadContextProvider() {
return nullptr;
}
scoped_refptr<viz::RasterContextProvider>
FakeContextFactory::SharedMainThreadRasterContextProvider() {
return nullptr;
}
void FakeContextFactory::RemoveCompositor(ui::Compositor* compositor) {
frame_sink_ = nullptr;
}
......
......@@ -35,6 +35,8 @@ class FakeContextFactory : public ui::ContextFactory {
base::WeakPtr<ui::Compositor> compositor) override;
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
void RemoveCompositor(ui::Compositor* compositor) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
......
......@@ -311,6 +311,14 @@ InProcessContextFactory::SharedMainThreadContextProvider() {
return shared_main_thread_contexts_;
}
scoped_refptr<viz::RasterContextProvider>
InProcessContextFactory::SharedMainThreadRasterContextProvider() {
SharedMainThreadContextProvider();
DCHECK(!shared_main_thread_contexts_ ||
shared_main_thread_contexts_->RasterInterface());
return shared_main_thread_contexts_;
}
void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {
auto it = per_compositor_data_.find(compositor);
if (it == per_compositor_data_.end())
......
......@@ -65,6 +65,9 @@ class InProcessContextFactory : public ContextFactory,
scoped_refptr<viz::ContextProvider> SharedMainThreadContextProvider()
override;
scoped_refptr<viz::RasterContextProvider>
SharedMainThreadRasterContextProvider() override;
void RemoveCompositor(Compositor* compositor) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
......
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