Skip to content

Commit 063f6d2

Browse files
sunnypsCommit Bot
authored and
Commit Bot
committed
Revert "Remove WaitSyncTokenCHROMIUM command"
This reverts commit c19106d. Reason for revert: Causing multiple mac gpu fyi failures crbug.com/895984 Original change's description: > Remove WaitSyncTokenCHROMIUM command > > After migrating InProcessCommandBuffer to use GPU scheduler, most tasks > are scheduled after their sync token dependencies are satisifed (see > crrev.com/c/1157874). > > The one exception was the WaitSyncToken IPC used by ReturnFrontBuffer > for pepper, which specifies a sync token, and waits while handling the > message. > > Change ReturnFrontBuffer to contain the sync token, and use it to > specify the dependency to the scheduler. > > Remove WaitSyncTokenCHROMIUM command, since sync token dependencies are > specified as task metadata in all cases. > > Make other cleanups such as removing unnecessary sync token tests, and > make sure the sync token code paths are not used where unsupported by > using NOTREACHED. > > 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: Ieee4f6e2427a59a4e0c4b3c983cb489741241272 > Bug: 778753 > Reviewed-on: https://chromium-review.googlesource.com/c/1168155 > Reviewed-by: Bo <boliu@chromium.org> > Reviewed-by: Daniel Cheng <dcheng@chromium.org> > Reviewed-by: Antoine Labour <piman@chromium.org> > Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org> > Cr-Commit-Position: refs/heads/master@{#599849} TBR=dcheng@chromium.org,boliu@chromium.org,sunnyps@chromium.org,piman@chromium.org Change-Id: I87347c05dded27955410b08e40f37388a484d5f9 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 778753, 895984 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/c/1284394 Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org> Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org> Cr-Commit-Position: refs/heads/master@{#600102}
1 parent 248a5a8 commit 063f6d2

File tree

61 files changed

+928
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+928
-333
lines changed

android_webview/browser/deferred_gpu_command_service.cc

+8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class TaskForwardingSequence : public gpu::CommandBufferTaskExecutor::Sequence {
7272

7373
bool ShouldYield() override { return false; }
7474

75+
// Should not be called because BlockThreadOnWaitSyncToken() returns true,
76+
// and the client should not disable sequences to wait for sync tokens.
77+
void SetEnabled(bool enabled) override { NOTREACHED(); }
78+
7579
void ScheduleTask(base::OnceClosure task,
7680
std::vector<gpu::SyncToken> sync_token_fences) override {
7781
uint32_t order_num =
@@ -283,6 +287,10 @@ void DeferredGpuCommandService::RunTasks() {
283287
}
284288
}
285289

290+
bool DeferredGpuCommandService::BlockThreadOnWaitSyncToken() const {
291+
return true;
292+
}
293+
286294
bool DeferredGpuCommandService::CanSupportThreadedTextureMailbox() const {
287295
return gpu_info_.can_support_threaded_texture_mailbox;
288296
}

android_webview/browser/deferred_gpu_command_service.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class DeferredGpuCommandService : public gpu::CommandBufferTaskExecutor {
4949
// gpu::CommandBufferTaskExecutor implementation.
5050
bool ForceVirtualizedGLContexts() const override;
5151
bool ShouldCreateMemoryTracker() const override;
52+
bool BlockThreadOnWaitSyncToken() const override;
5253
std::unique_ptr<gpu::CommandBufferTaskExecutor::Sequence> CreateSequence()
5354
override;
5455
void ScheduleOutOfOrderTask(base::OnceClosure task) override;

gpu/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ test("gl_tests") {
213213
"command_buffer/tests/gl_ext_multisample_compatibility_unittest.cc",
214214
"command_buffer/tests/gl_ext_srgb_unittest.cc",
215215
"command_buffer/tests/gl_ext_window_rectangles_unittest.cc",
216+
"command_buffer/tests/gl_fence_sync_unittest.cc",
216217
"command_buffer/tests/gl_gpu_memory_buffer_unittest.cc",
217218
"command_buffer/tests/gl_iosurface_readback_workaround_unittest.cc",
218219
"command_buffer/tests/gl_lose_context_chromium_unittest.cc",

gpu/command_buffer/build_gles2_cmd_buffer.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3707,7 +3707,12 @@
37073707
'extension': "CHROMIUM_sync_point",
37083708
},
37093709
'WaitSyncTokenCHROMIUM': {
3710-
'type': 'NoCommand',
3710+
'type': 'Custom',
3711+
'impl_func': False,
3712+
'cmd_args': 'GLint namespace_id, '
3713+
'GLuint64 command_buffer_id, '
3714+
'GLuint64 release_count',
3715+
'client_test': False,
37113716
'extension': "CHROMIUM_sync_point",
37123717
},
37133718
'DiscardBackbufferCHROMIUM': {

gpu/command_buffer/build_raster_cmd_buffer.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,12 @@
365365
'type': 'NoCommand',
366366
},
367367
'WaitSyncTokenCHROMIUM': {
368-
'type': 'NoCommand',
368+
'type': 'Custom',
369+
'impl_func': False,
370+
'cmd_args': 'GLint namespace_id, '
371+
'GLuint64 command_buffer_id, '
372+
'GLuint64 release_count',
373+
'client_test': False,
369374
},
370375
'InitializeDiscardableTextureCHROMIUM': {
371376
'type': 'Custom',

gpu/command_buffer/client/client_test_helper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class MockClientGpuControl : public GpuControl {
137137
DoSignalSyncToken(sync_token, &callback);
138138
}
139139

140-
MOCK_METHOD1(WaitSyncToken, void(const SyncToken&));
140+
MOCK_METHOD1(WaitSyncTokenHint, void(const SyncToken&));
141141
MOCK_METHOD1(CanWaitUnverifiedSyncToken, bool(const SyncToken&));
142142
MOCK_METHOD2(CreateGpuFence,
143143
void(uint32_t gpu_fence_id, ClientGpuFence source));

gpu/command_buffer/client/gles2_cmd_helper_autogen.h

+10
Original file line numberDiff line numberDiff line change
@@ -2734,6 +2734,16 @@ void InsertFenceSyncCHROMIUM(GLuint64 release_count) {
27342734
}
27352735
}
27362736

2737+
void WaitSyncTokenCHROMIUM(GLint namespace_id,
2738+
GLuint64 command_buffer_id,
2739+
GLuint64 release_count) {
2740+
gles2::cmds::WaitSyncTokenCHROMIUM* c =
2741+
GetCmdSpace<gles2::cmds::WaitSyncTokenCHROMIUM>();
2742+
if (c) {
2743+
c->Init(namespace_id, command_buffer_id, release_count);
2744+
}
2745+
}
2746+
27372747
void UnpremultiplyAndDitherCopyCHROMIUM(GLuint source_id,
27382748
GLuint dest_id,
27392749
GLint x,

gpu/command_buffer/client/gles2_implementation.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -6300,9 +6300,14 @@ void GLES2Implementation::WaitSyncTokenCHROMIUM(const GLbyte* sync_token_data) {
63006300
return;
63016301
}
63026302

6303+
helper_->WaitSyncTokenCHROMIUM(
6304+
static_cast<GLint>(sync_token.namespace_id()),
6305+
sync_token.command_buffer_id().GetUnsafeValue(),
6306+
sync_token.release_count());
6307+
63036308
// Enqueue sync token in flush after inserting command so that it's not
63046309
// included in an automatic flush.
6305-
gpu_control_->WaitSyncToken(verified_sync_token);
6310+
gpu_control_->WaitSyncTokenHint(verified_sync_token);
63066311
}
63076312

63086313
namespace {

gpu/command_buffer/client/gles2_implementation_unittest.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -3931,9 +3931,12 @@ TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
39313931

39323932
struct Cmds {
39333933
cmds::InsertFenceSyncCHROMIUM insert_fence_sync;
3934+
cmds::WaitSyncTokenCHROMIUM wait_sync_token;
39343935
};
39353936
Cmds expected;
39363937
expected.insert_fence_sync.Init(kFenceSync);
3938+
expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId.GetUnsafeValue(),
3939+
kFenceSync);
39373940

39383941
EXPECT_CALL(*gpu_control_, GetNamespaceID()).WillOnce(Return(kNamespaceId));
39393942
EXPECT_CALL(*gpu_control_, GetCommandBufferID())
@@ -3943,7 +3946,7 @@ TEST_F(GLES2ImplementationTest, WaitSyncTokenCHROMIUM) {
39433946
EXPECT_CALL(*gpu_control_, EnsureWorkVisible());
39443947
gl_->GenSyncTokenCHROMIUM(sync_token_data);
39453948

3946-
EXPECT_CALL(*gpu_control_, WaitSyncToken(sync_token));
3949+
EXPECT_CALL(*gpu_control_, WaitSyncTokenHint(sync_token));
39473950
gl_->WaitSyncTokenCHROMIUM(sync_token_data);
39483951
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
39493952
}

gpu/command_buffer/client/gpu_control.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ class GPU_EXPORT GpuControl {
105105
base::OnceClosure callback) = 0;
106106

107107
// This allows the command buffer proxy to mark the next flush with sync token
108-
// dependencies for the gpu scheduler, or to block prior to the flush in case
109-
// of android webview.
110-
virtual void WaitSyncToken(const SyncToken& sync_token) = 0;
108+
// dependencies for the gpu scheduler. This is used in addition to the
109+
// WaitSyncToken command in the command buffer which is still needed. For
110+
// example, the WaitSyncToken command is used to pull texture updates when
111+
// used in conjunction with MailboxManagerSync.
112+
virtual void WaitSyncTokenHint(const SyncToken& sync_token) = 0;
111113

112114
// Under some circumstances a sync token may be used which has not been
113115
// verified to have been flushed. For example, fence syncs queued on the same

gpu/command_buffer/client/raster_cmd_helper_autogen.h

+10
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ void InsertFenceSyncCHROMIUM(GLuint64 release_count) {
103103
}
104104
}
105105

106+
void WaitSyncTokenCHROMIUM(GLint namespace_id,
107+
GLuint64 command_buffer_id,
108+
GLuint64 release_count) {
109+
raster::cmds::WaitSyncTokenCHROMIUM* c =
110+
GetCmdSpace<raster::cmds::WaitSyncTokenCHROMIUM>();
111+
if (c) {
112+
c->Init(namespace_id, command_buffer_id, release_count);
113+
}
114+
}
115+
106116
void UnpremultiplyAndDitherCopyCHROMIUM(GLuint source_id,
107117
GLuint dest_id,
108118
GLint x,

gpu/command_buffer/client/raster_implementation.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,14 @@ void RasterImplementation::WaitSyncTokenCHROMIUM(
955955
return;
956956
}
957957

958-
gpu_control_->WaitSyncToken(verified_sync_token);
958+
helper_->WaitSyncTokenCHROMIUM(
959+
static_cast<GLint>(sync_token.namespace_id()),
960+
sync_token.command_buffer_id().GetUnsafeValue(),
961+
sync_token.release_count());
962+
963+
// Enqueue sync token in flush after inserting command so that it's not
964+
// included in an automatic flush.
965+
gpu_control_->WaitSyncTokenHint(verified_sync_token);
959966
}
960967

961968
namespace {

gpu/command_buffer/client/raster_implementation_unittest.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,12 @@ TEST_F(RasterImplementationTest, WaitSyncTokenCHROMIUM) {
736736

737737
struct Cmds {
738738
cmds::InsertFenceSyncCHROMIUM insert_fence_sync;
739+
cmds::WaitSyncTokenCHROMIUM wait_sync_token;
739740
};
740741
Cmds expected;
741742
expected.insert_fence_sync.Init(kFenceSync);
743+
expected.wait_sync_token.Init(kNamespaceId, kCommandBufferId.GetUnsafeValue(),
744+
kFenceSync);
742745

743746
EXPECT_CALL(*gpu_control_, GetNamespaceID()).WillOnce(Return(kNamespaceId));
744747
EXPECT_CALL(*gpu_control_, GetCommandBufferID())
@@ -748,7 +751,7 @@ TEST_F(RasterImplementationTest, WaitSyncTokenCHROMIUM) {
748751
EXPECT_CALL(*gpu_control_, EnsureWorkVisible());
749752
gl_->GenSyncTokenCHROMIUM(sync_token_data);
750753

751-
EXPECT_CALL(*gpu_control_, WaitSyncToken(sync_token));
754+
EXPECT_CALL(*gpu_control_, WaitSyncTokenHint(sync_token));
752755
gl_->WaitSyncTokenCHROMIUM(sync_token_data);
753756
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
754757
}

gpu/command_buffer/common/gles2_cmd_format_autogen.h

+67
Original file line numberDiff line numberDiff line change
@@ -13519,6 +13519,73 @@ static_assert(offsetof(InsertFenceSyncCHROMIUM, release_count_0) == 4,
1351913519
static_assert(offsetof(InsertFenceSyncCHROMIUM, release_count_1) == 8,
1352013520
"offset of InsertFenceSyncCHROMIUM release_count_1 should be 8");
1352113521

13522+
struct WaitSyncTokenCHROMIUM {
13523+
typedef WaitSyncTokenCHROMIUM ValueType;
13524+
static const CommandId kCmdId = kWaitSyncTokenCHROMIUM;
13525+
static const cmd::ArgFlags kArgFlags = cmd::kFixed;
13526+
static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
13527+
13528+
static uint32_t ComputeSize() {
13529+
return static_cast<uint32_t>(sizeof(ValueType)); // NOLINT
13530+
}
13531+
13532+
void SetHeader() { header.SetCmd<ValueType>(); }
13533+
13534+
void Init(GLint _namespace_id,
13535+
GLuint64 _command_buffer_id,
13536+
GLuint64 _release_count) {
13537+
SetHeader();
13538+
namespace_id = _namespace_id;
13539+
GLES2Util::MapUint64ToTwoUint32(static_cast<uint64_t>(_command_buffer_id),
13540+
&command_buffer_id_0, &command_buffer_id_1);
13541+
GLES2Util::MapUint64ToTwoUint32(static_cast<uint64_t>(_release_count),
13542+
&release_count_0, &release_count_1);
13543+
}
13544+
13545+
void* Set(void* cmd,
13546+
GLint _namespace_id,
13547+
GLuint64 _command_buffer_id,
13548+
GLuint64 _release_count) {
13549+
static_cast<ValueType*>(cmd)->Init(_namespace_id, _command_buffer_id,
13550+
_release_count);
13551+
return NextCmdAddress<ValueType>(cmd);
13552+
}
13553+
13554+
GLuint64 command_buffer_id() const volatile {
13555+
return static_cast<GLuint64>(GLES2Util::MapTwoUint32ToUint64(
13556+
command_buffer_id_0, command_buffer_id_1));
13557+
}
13558+
13559+
GLuint64 release_count() const volatile {
13560+
return static_cast<GLuint64>(
13561+
GLES2Util::MapTwoUint32ToUint64(release_count_0, release_count_1));
13562+
}
13563+
13564+
gpu::CommandHeader header;
13565+
int32_t namespace_id;
13566+
uint32_t command_buffer_id_0;
13567+
uint32_t command_buffer_id_1;
13568+
uint32_t release_count_0;
13569+
uint32_t release_count_1;
13570+
};
13571+
13572+
static_assert(sizeof(WaitSyncTokenCHROMIUM) == 24,
13573+
"size of WaitSyncTokenCHROMIUM should be 24");
13574+
static_assert(offsetof(WaitSyncTokenCHROMIUM, header) == 0,
13575+
"offset of WaitSyncTokenCHROMIUM header should be 0");
13576+
static_assert(offsetof(WaitSyncTokenCHROMIUM, namespace_id) == 4,
13577+
"offset of WaitSyncTokenCHROMIUM namespace_id should be 4");
13578+
static_assert(
13579+
offsetof(WaitSyncTokenCHROMIUM, command_buffer_id_0) == 8,
13580+
"offset of WaitSyncTokenCHROMIUM command_buffer_id_0 should be 8");
13581+
static_assert(
13582+
offsetof(WaitSyncTokenCHROMIUM, command_buffer_id_1) == 12,
13583+
"offset of WaitSyncTokenCHROMIUM command_buffer_id_1 should be 12");
13584+
static_assert(offsetof(WaitSyncTokenCHROMIUM, release_count_0) == 16,
13585+
"offset of WaitSyncTokenCHROMIUM release_count_0 should be 16");
13586+
static_assert(offsetof(WaitSyncTokenCHROMIUM, release_count_1) == 20,
13587+
"offset of WaitSyncTokenCHROMIUM release_count_1 should be 20");
13588+
1352213589
struct UnpremultiplyAndDitherCopyCHROMIUM {
1352313590
typedef UnpremultiplyAndDitherCopyCHROMIUM ValueType;
1352413591
static const CommandId kCmdId = kUnpremultiplyAndDitherCopyCHROMIUM;

gpu/command_buffer/common/gles2_cmd_format_test_autogen.h

+15
Original file line numberDiff line numberDiff line change
@@ -4520,6 +4520,21 @@ TEST_F(GLES2FormatTest, InsertFenceSyncCHROMIUM) {
45204520
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
45214521
}
45224522

4523+
TEST_F(GLES2FormatTest, WaitSyncTokenCHROMIUM) {
4524+
cmds::WaitSyncTokenCHROMIUM& cmd =
4525+
*GetBufferAs<cmds::WaitSyncTokenCHROMIUM>();
4526+
void* next_cmd =
4527+
cmd.Set(&cmd, static_cast<GLint>(11), static_cast<GLuint64>(12),
4528+
static_cast<GLuint64>(13));
4529+
EXPECT_EQ(static_cast<uint32_t>(cmds::WaitSyncTokenCHROMIUM::kCmdId),
4530+
cmd.header.command);
4531+
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
4532+
EXPECT_EQ(static_cast<GLint>(11), cmd.namespace_id);
4533+
EXPECT_EQ(static_cast<GLuint64>(12), cmd.command_buffer_id());
4534+
EXPECT_EQ(static_cast<GLuint64>(13), cmd.release_count());
4535+
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
4536+
}
4537+
45234538
TEST_F(GLES2FormatTest, UnpremultiplyAndDitherCopyCHROMIUM) {
45244539
cmds::UnpremultiplyAndDitherCopyCHROMIUM& cmd =
45254540
*GetBufferAs<cmds::UnpremultiplyAndDitherCopyCHROMIUM>();

0 commit comments

Comments
 (0)