Skip to content

Commit

Permalink
Revert "GPU: Migrate remaining control IPCs to Mojo"
Browse files Browse the repository at this point in the history
This reverts commit 42c21d0.

Reason for revert: Need to revert a CL this depended on, due to crbug.com/1206286

Original change's description:
> GPU: Migrate remaining control IPCs to Mojo
>
> This migrates the GPU Channel's remaining three legacy IPC control
> messages to Mojo. Remaining legacy IPC messages are specific to shared
> images, or individual command buffers or stream texures.
>
> Bug: 1196476
> Change-Id: I79a788fefa986d5d9572cc6768970195342d3d9f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2847202
> Commit-Queue: Ken Rockot <rockot@google.com>
> Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#879814}

Bug: 1196476
Change-Id: Ic3bfc62b6d1b876290c2621fba5d3a1c54043956
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2879898
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Joseph Arhar (please use jarhar@chromium.org) <jarhar@google.com>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880611}
  • Loading branch information
krockot authored and Chromium LUCI CQ committed May 7, 2021
1 parent 7595558 commit 157765a
Show file tree
Hide file tree
Showing 27 changed files with 317 additions and 853 deletions.
5 changes: 2 additions & 3 deletions content/renderer/media/android/stream_texture_factory.cc
Expand Up @@ -137,10 +137,9 @@ bool StreamTextureFactory::IsLost() const {
unsigned StreamTextureFactory::CreateStreamTexture() {
int32_t stream_id = channel_->GenerateRouteID();
bool succeeded = false;
mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync;
channel_->GetGpuChannel().CreateStreamTexture(stream_id, &succeeded);
channel_->Send(new GpuChannelMsg_CreateStreamTexture(stream_id, &succeeded));
if (!succeeded) {
DLOG(ERROR) << "CreateStreamTexture returned failure";
DLOG(ERROR) << "GpuChannelMsg_CreateStreamTexture returned failure";
return 0;
}
return stream_id;
Expand Down
29 changes: 12 additions & 17 deletions gpu/ipc/client/command_buffer_proxy_impl.cc
Expand Up @@ -32,7 +32,6 @@
#include "gpu/ipc/common/gpu_channel.mojom.h"
#include "gpu/ipc/common/gpu_messages.h"
#include "gpu/ipc/common/gpu_param_traits.h"
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
#include "mojo/public/cpp/system/buffer.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "ui/gfx/buffer_format_util.h"
Expand Down Expand Up @@ -78,14 +77,14 @@ ContextResult CommandBufferProxyImpl::Initialize(
// prevent cleanup on destruction.
auto channel = std::move(channel_);

auto params = mojom::CreateCommandBufferParams::New();
params->surface_handle = surface_handle;
params->share_group_id =
GPUCreateCommandBufferConfig init_params;
init_params.surface_handle = surface_handle;
init_params.share_group_id =
share_group ? share_group->route_id_ : MSG_ROUTING_NONE;
params->stream_id = stream_id_;
params->stream_priority = stream_priority;
params->attribs = attribs;
params->active_url = active_url;
init_params.stream_id = stream_id_;
init_params.stream_priority = stream_priority;
init_params.attribs = attribs;
init_params.active_url = active_url;

TRACE_EVENT0("gpu", "CommandBufferProxyImpl::Initialize");
std::tie(shared_state_shm_, shared_state_mapping_) =
Expand Down Expand Up @@ -118,17 +117,16 @@ ContextResult CommandBufferProxyImpl::Initialize(
// so it won't cause additional jank.
// TODO(piman): Make this asynchronous (http://crbug.com/125248).
ContextResult result = ContextResult::kSuccess;
mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync;
bool sent = channel->GetGpuChannel().CreateCommandBuffer(
std::move(params), route_id_, std::move(region), &result, &capabilities_);
bool sent = channel->Send(new GpuChannelMsg_CreateCommandBuffer(
init_params, route_id_, std::move(region), &result, &capabilities_));
if (!sent) {
channel->RemoveRoute(route_id_);
LOG(ERROR) << "ContextResult::kTransientFailure: "
"Failed to send GpuControl.CreateCommandBuffer.";
"Failed to send GpuChannelMsg_CreateCommandBuffer.";
return ContextResult::kTransientFailure;
}
if (result != ContextResult::kSuccess) {
DLOG(ERROR) << "Failure processing GpuControl.CreateCommandBuffer.";
DLOG(ERROR) << "Failure processing GpuChannelMsg_CreateCommandBuffer.";
channel->RemoveRoute(route_id_);
return result;
}
Expand Down Expand Up @@ -921,10 +919,7 @@ void CommandBufferProxyImpl::DisconnectChannel() {
return;
disconnected_ = true;
channel_->VerifyFlush(UINT32_MAX);

mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync;
channel_->GetGpuChannel().DestroyCommandBuffer(route_id_);

channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_));
channel_->RemoveRoute(route_id_);
if (gpu_control_client_)
gpu_control_client_->OnGpuControlLostContext();
Expand Down
79 changes: 20 additions & 59 deletions gpu/ipc/client/command_buffer_proxy_impl_unittest.cc
Expand Up @@ -87,20 +87,6 @@ class CommandBufferProxyImplTest : public testing::Test {
auto proxy = std::make_unique<CommandBufferProxyImpl>(
channel_, nullptr /* gpu_memory_buffer_manager */, 0 /* stream_id */,
base::ThreadTaskRunnerHandle::Get());

// The Initialize() call below synchronously requests a new CommandBuffer
// using the channel's GpuControl interface. Simulate success, since we're
// not actually talking to the service in these tests.
EXPECT_CALL(mock_gpu_channel_, CreateCommandBuffer(_, _, _, _, _))
.Times(1)
.WillOnce(Invoke(
[&](mojom::CreateCommandBufferParamsPtr params, int32_t routing_id,
base::UnsafeSharedMemoryRegion shared_state,
ContextResult* result, Capabilities* capabilities) -> bool {
*result = ContextResult::kSuccess;
return true;
}));

proxy->Initialize(kNullSurfaceHandle, nullptr, SchedulingPriority::kNormal,
ContextCreationAttribs(), GURL());
// Use an arbitrary valid shm_id. The command buffer doesn't use this
Expand Down Expand Up @@ -151,12 +137,7 @@ TEST_F(CommandBufferProxyImplTest, OrderingBarriersAreCoalescedWithFlush) {
proxy1->OrderingBarrier(40);
proxy1->Flush(50);

// Once for each proxy.
EXPECT_CALL(mock_gpu_channel_, DestroyCommandBuffer(_))
.Times(2)
.WillRepeatedly(Return(true));

// Each proxy sends a sync GpuControl flush on disconnect.
// Each proxy sends a sync GpuChannel flush on disconnect.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(2).WillRepeatedly(Return(true));
EXPECT_EQ(0u, sink_.message_count());
}
Expand All @@ -179,12 +160,7 @@ TEST_F(CommandBufferProxyImplTest, FlushPendingWorkFlushesOrderingBarriers) {
proxy1->OrderingBarrier(30);
proxy2->FlushPendingWork();

// Once for each proxy.
EXPECT_CALL(mock_gpu_channel_, DestroyCommandBuffer(_))
.Times(2)
.WillRepeatedly(Return(true));

// Each proxy sends a sync GpuControl flush on disconnect.
// Each proxy sends a sync GpuChannel flush on disconnect.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(2).WillRepeatedly(Return(true));
EXPECT_EQ(0u, sink_.message_count());
}
Expand All @@ -193,36 +169,29 @@ TEST_F(CommandBufferProxyImplTest, EnsureWorkVisibleFlushesOrderingBarriers) {
auto proxy1 = CreateAndInitializeProxy();
auto proxy2 = CreateAndInitializeProxy();

// Ordering of these flush operations must be preserved.
{
::testing::InSequence in_sequence;

// First we expect to see a FlushDeferredRequests call.
EXPECT_CALL(mock_gpu_channel_, FlushDeferredRequests(_))
.Times(1)
.WillOnce(Invoke([&](std::vector<mojom::DeferredRequestPtr> requests) {
EXPECT_EQ(3u, requests.size());
ExpectOrderingBarrier(*requests[0], proxy1->route_id(), 10);
ExpectOrderingBarrier(*requests[1], proxy2->route_id(), 20);
ExpectOrderingBarrier(*requests[2], proxy1->route_id(), 30);
}));

// Next we expect a full `Flush()`.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(1).RetiresOnSaturation();
}
// Ordering of the flush operations must be preserved.
::testing::InSequence in_sequence;

// First we expect to see a FlushDeferredRequests call.
EXPECT_CALL(mock_gpu_channel_, FlushDeferredRequests(_))
.Times(1)
.WillOnce(Invoke([&](std::vector<mojom::DeferredRequestPtr> requests) {
EXPECT_EQ(3u, requests.size());
ExpectOrderingBarrier(*requests[0], proxy1->route_id(), 10);
ExpectOrderingBarrier(*requests[1], proxy2->route_id(), 20);
ExpectOrderingBarrier(*requests[2], proxy1->route_id(), 30);
}));

// Next we expect a full `Flush()`.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(1);

proxy1->OrderingBarrier(10);
proxy2->OrderingBarrier(20);
proxy1->OrderingBarrier(30);

proxy2->EnsureWorkVisible();

// Once for each proxy.
EXPECT_CALL(mock_gpu_channel_, DestroyCommandBuffer(_))
.Times(2)
.WillRepeatedly(Return(true));

// Each proxy sends a sync GpuControl flush on disconnect.
// Each proxy sends a sync GpuChannel flush on disconnect.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(2).WillRepeatedly(Return(true));
EXPECT_EQ(0u, sink_.message_count());
}
Expand Down Expand Up @@ -258,11 +227,7 @@ TEST_F(CommandBufferProxyImplTest,

proxy1->FlushPendingWork();

EXPECT_CALL(mock_gpu_channel_, DestroyCommandBuffer(_))
.Times(1)
.WillOnce(Return(true));

// The proxy sends a sync GpuControl flush on disconnect.
// The proxy sends a sync GpuChannel flush on disconnect.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(1).WillRepeatedly(Return(true));
EXPECT_EQ(0u, sink_.message_count());
}
Expand Down Expand Up @@ -313,11 +278,7 @@ TEST_F(CommandBufferProxyImplTest, CreateTransferBufferOOM) {
std::numeric_limits<uint32_t>::max(), &id,
TransferBufferAllocationOption::kLoseContextOnOOM);

EXPECT_CALL(mock_gpu_channel_, DestroyCommandBuffer(_))
.Times(1)
.WillOnce(Return(true));

// The proxy sends a sync GpuControl flush on disconnect.
// The proxy sends a sync GpuChannel flush on disconnect.
EXPECT_CALL(mock_gpu_channel_, Flush()).Times(1).WillRepeatedly(Return(true));
}

Expand Down
36 changes: 1 addition & 35 deletions gpu/ipc/common/BUILD.gn
Expand Up @@ -235,44 +235,10 @@ mojom("gpu_channel_mojom") {
"//skia/public/mojom",
"//ui/gfx/geometry/mojom",
"//ui/gfx/mojom",
"//ui/gl/mojom",
"//url/mojom:url_mojom_gurl",
]

mojom_source_deps = [ ":interfaces" ]

cpp_typemaps = [
{
types = [
{
mojom = "gpu.mojom.ContextColorspace"
cpp = "::gpu::ColorSpace"
},
{
mojom = "gpu.mojom.ContextCreationAttribs"
cpp = "::gpu::ContextCreationAttribs"
},
{
mojom = "gpu.mojom.ContextType"
cpp = "::gpu::ContextType"
},
]
traits_headers = [ "context_creation_attribs_mojom_traits.h" ]
traits_sources = [ "context_creation_attribs_mojom_traits.cc" ]
traits_public_deps = [ "//gpu/command_buffer/common:common_base_sources" ]
},
{
types = [
{
mojom = "gpu.mojom.SchedulingPriority"
cpp = "::gpu::SchedulingPriority"
},
]
traits_headers = [ "scheduling_priority_mojom_traits.h" ]
traits_public_deps = [ "//gpu/command_buffer/common:common_base_sources" ]
},
]

# Unlike some definitions in ":interfaces_mojom", these bindings are never
# used in Blink. We disable variants to simplify the dependency graph.
disable_variants = true
Expand Down Expand Up @@ -725,7 +691,7 @@ source_set("test_support") {
"mock_gpu_channel.h",
]
public_deps = [
":common",
":interfaces",
"//testing/gmock",
]
}
47 changes: 0 additions & 47 deletions gpu/ipc/common/context_creation_attribs_mojom_traits.cc

This file was deleted.

0 comments on commit 157765a

Please sign in to comment.