Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(918)

Unified Diff: content/common/gpu/gpu_channel.cc

Issue 782583003: List sync points to wait on in AsyncFlush message Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/gpu_channel.cc
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index 7bf61344c8fb2029e179fd21b2a92e5a9219f7c6..44746f465df334bdf205899f35555af0d8c6115f 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -98,53 +98,79 @@ class GpuChannelMessageFilter : public IPC::MessageFilter {
sender_ = NULL;
}
- bool OnMessageReceived(const IPC::Message& message) override {
- DCHECK(sender_);
+ struct MessageStatus {
+ int routing_id;
+ bool forwarded;
+ bool handled;
+ };
- bool handled = false;
- if ((message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) &&
- !future_sync_points_) {
+ void OnRetireSyncPoint(uint32 sync_point) {
+ if (future_sync_points_) {
+ current_status_.handled = false;
+ } else {
DLOG(ERROR) << "Untrusted client should not send "
"GpuCommandBufferMsg_RetireSyncPoint message";
- return true;
+ current_status_.forwarded = false;
}
+ }
- if (message.type() == GpuCommandBufferMsg_InsertSyncPoint::ID) {
- Tuple1<bool> retire;
- IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message);
- if (!GpuCommandBufferMsg_InsertSyncPoint::ReadSendParam(&message,
- &retire)) {
- reply->set_reply_error();
- Send(reply);
- return true;
- }
- if (!future_sync_points_ && !retire.a) {
- LOG(ERROR) << "Untrusted contexts can't create future sync points";
- reply->set_reply_error();
- Send(reply);
- return true;
- }
- uint32 sync_point = sync_point_manager_->GenerateSyncPoint();
- GpuCommandBufferMsg_InsertSyncPoint::WriteReplyParams(reply, sync_point);
- Send(reply);
- message_loop_->PostTask(
- FROM_HERE,
- base::Bind(&GpuChannelMessageFilter::InsertSyncPointOnMainThread,
- gpu_channel_,
- sync_point_manager_,
- message.routing_id(),
- retire.a,
- sync_point));
- handled = true;
+ void OnAsyncFlush(int32 put_offset,
+ uint32 flush_count,
+ const std::vector<uint32>& sync_points,
+ const std::vector<ui::LatencyInfo>& latency_info) {
+ std::vector<uint32> sanitized_sync_points;
+ for (uint32 sync_point : sync_points) {
+ if (sync_point_manager_->WasSyncPointGenerated(sync_point))
+ sanitized_sync_points.push_back(sync_point);
}
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(&GpuChannel::OnMessageReceived),
+ gpu_channel_,
+ GpuCommandBufferMsg_AsyncFlush(
+ current_status_.routing_id, put_offset, flush_count,
+ sanitized_sync_points, latency_info)));
+ }
+
+ void OnInsertSyncPoint(bool retire, uint32* sync_point) {
+ if (!future_sync_points_ && !retire) {
+ *sync_point = 0;
+ LOG(ERROR) << "Untrusted contexts can't create future sync points";
+ current_status_.forwarded = false;
+ return;
+ }
+ *sync_point = sync_point_manager_->GenerateSyncPoint();
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&GpuChannelMessageFilter::InsertSyncPointOnMainThread,
+ gpu_channel_, sync_point_manager_,
+ current_status_.routing_id, retire, *sync_point));
+ }
- // All other messages get processed by the GpuChannel.
- messages_forwarded_to_channel_++;
- if (preempting_flag_.get())
- pending_messages_.push(PendingMessage(messages_forwarded_to_channel_));
- UpdatePreemptionState();
+ bool OnMessageReceived(const IPC::Message& message) override {
+ DCHECK(sender_);
+
+ current_status_.routing_id = message.routing_id();
+ current_status_.forwarded = true;
+ current_status_.handled = true;
+ IPC_BEGIN_MESSAGE_MAP(GpuChannelMessageFilter, message)
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint,
+ OnRetireSyncPoint)
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush)
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_InsertSyncPoint,
+ OnInsertSyncPoint)
+ IPC_MESSAGE_UNHANDLED(current_status_.handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ if (current_status_.forwarded) {
+ // All other messages get processed by the GpuChannel.
+ messages_forwarded_to_channel_++;
+ if (preempting_flag_.get())
+ pending_messages_.push(PendingMessage(messages_forwarded_to_channel_));
+ UpdatePreemptionState();
+ }
- return handled;
+ return current_status_.handled;
}
void MessageProcessed(uint64 messages_processed) {
@@ -382,6 +408,7 @@ class GpuChannelMessageFilter : public IPC::MessageFilter {
// passed through - therefore the WeakPtr assumptions are respected.
base::WeakPtr<GpuChannel> gpu_channel_;
IPC::Sender* sender_;
+ MessageStatus current_status_;
scoped_refptr<gpu::SyncPointManager> sync_point_manager_;
scoped_refptr<base::MessageLoopProxy> message_loop_;
scoped_refptr<gpu::PreemptionFlag> preempting_flag_;
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.cc ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698