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

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

Issue 1339203002: Added global order numbers to in process command buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reverted unnecessary changes Created 5 years, 3 months 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 3f7361dc1860ceaf5fe897bf05b093ee20717365..d7b7496833d72218af1cc8481a693eaed6588ae6 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -70,21 +70,22 @@ const int64 kStopPreemptThresholdMs = kVsyncIntervalMs;
} // anonymous namespace
-// Begin order numbers at 1 so 0 can mean no orders.
-uint32_t GpuChannelMessageQueue::global_order_counter_ = 1;
-
scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create(
const base::WeakPtr<GpuChannel>& gpu_channel,
base::SingleThreadTaskRunner* task_runner) {
return new GpuChannelMessageQueue(gpu_channel, task_runner);
}
+scoped_refptr<gpu::SyncPointClientState>
+ GpuChannelMessageQueue::sync_point_client_state() {
+ return sync_point_client_state_;
+}
+
GpuChannelMessageQueue::GpuChannelMessageQueue(
const base::WeakPtr<GpuChannel>& gpu_channel,
base::SingleThreadTaskRunner* task_runner)
: enabled_(true),
- unprocessed_order_num_(0),
- processed_order_num_(0),
+ sync_point_client_state_(gpu::SyncPointClientState::Create()),
gpu_channel_(gpu_channel),
task_runner_(task_runner) {}
@@ -93,14 +94,19 @@ GpuChannelMessageQueue::~GpuChannelMessageQueue() {
}
uint32_t GpuChannelMessageQueue::GetUnprocessedOrderNum() const {
- base::AutoLock auto_lock(channel_messages_lock_);
- return unprocessed_order_num_;
+ return sync_point_client_state_->unprocessed_order_num();
+}
+
+uint32_t GpuChannelMessageQueue::GetProcessedOrderNum() const {
+ return sync_point_client_state_->processed_order_num();
}
-void GpuChannelMessageQueue::PushBackMessage(const IPC::Message& message) {
+void GpuChannelMessageQueue::PushBackMessage(
+ gpu::SyncPointManager* sync_point_manager, const IPC::Message& message) {
base::AutoLock auto_lock(channel_messages_lock_);
if (enabled_)
piman 2015/09/22 19:43:08 nit: needs {} per style.
David Yen 2015/09/22 20:01:54 Done.
- PushMessageHelper(make_scoped_ptr(new GpuChannelMessage(message)));
+ PushMessageHelper(sync_point_manager,
+ make_scoped_ptr(new GpuChannelMessage(message)));
}
bool GpuChannelMessageQueue::GenerateSyncPointMessage(
@@ -118,7 +124,7 @@ bool GpuChannelMessageQueue::GenerateSyncPointMessage(
msg->retire_sync_point = retire_sync_point;
msg->sync_point = *sync_point;
- PushMessageHelper(msg.Pass());
+ PushMessageHelper(sync_point_manager, msg.Pass());
return true;
}
return false;
@@ -139,9 +145,14 @@ base::TimeTicks GpuChannelMessageQueue::GetNextMessageTimeTick() const {
GpuChannelMessage* GpuChannelMessageQueue::GetNextMessage() const {
base::AutoLock auto_lock(channel_messages_lock_);
if (!channel_messages_.empty()) {
- DCHECK_GT(channel_messages_.front()->order_number, processed_order_num_);
- DCHECK_LE(channel_messages_.front()->order_number, unprocessed_order_num_);
- return channel_messages_.front();
+ DCHECK_GT(channel_messages_.front()->order_number,
+ sync_point_client_state_->processed_order_num());
+ DCHECK_LE(channel_messages_.front()->order_number,
+ sync_point_client_state_->unprocessed_order_num());
+
+ GpuChannelMessage* m = channel_messages_.front();
+ sync_point_client_state_->BeginProcessingOrderNumber(m->order_number);
sunnyps 2015/09/22 17:25:59 How does this work? GetNextMessage is const but Be
piman 2015/09/22 19:43:08 scoped_refptr::operator-> is const but returns a T
David Yen 2015/09/22 20:01:54 Done.
+ return m;
}
return nullptr;
}
@@ -151,7 +162,7 @@ bool GpuChannelMessageQueue::MessageProcessed() {
DCHECK(!channel_messages_.empty());
scoped_ptr<GpuChannelMessage> msg(channel_messages_.front());
channel_messages_.pop_front();
- processed_order_num_ = msg->order_number;
+ sync_point_client_state_->FinishProcessingOrderNumber(msg->order_number);
return !channel_messages_.empty();
}
@@ -186,15 +197,16 @@ void GpuChannelMessageQueue::ScheduleHandleMessage() {
}
void GpuChannelMessageQueue::PushMessageHelper(
+ gpu::SyncPointManager* sync_point_manager,
scoped_ptr<GpuChannelMessage> msg) {
channel_messages_lock_.AssertAcquired();
DCHECK(enabled_);
- msg->order_number = global_order_counter_++;
+ msg->order_number =
+ sync_point_client_state_->GenerateUnprocessedOrderNumber(
+ sync_point_manager);
msg->time_received = base::TimeTicks::Now();
- unprocessed_order_num_ = msg->order_number;
-
bool had_messages = !channel_messages_.empty();
channel_messages_.push_back(msg.release());
if (!had_messages)
@@ -339,7 +351,7 @@ bool GpuChannelMessageFilter::OnMessageReceived(const IPC::Message& message) {
base::Bind(&GpuChannel::HandleOutOfOrderMessage,
gpu_channel_, message));
} else {
- message_queue_->PushBackMessage(message);
+ message_queue_->PushBackMessage(sync_point_manager_, message);
}
handled = true;
}
@@ -611,7 +623,7 @@ base::ProcessId GpuChannel::GetClientPID() const {
}
uint32_t GpuChannel::GetProcessedOrderNum() const {
- return message_queue_->processed_order_num();
+ return message_queue_->GetProcessedOrderNum();
}
uint32_t GpuChannel::GetUnprocessedOrderNum() const {
@@ -806,6 +818,10 @@ bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
return handled;
}
+scoped_refptr<gpu::SyncPointClientState> GpuChannel::GetSyncPointClientState() {
+ return message_queue_->sync_point_client_state();
+}
+
void GpuChannel::HandleMessage() {
// If we have been preempted by another channel, just post a task to wake up.
if (preempted_flag_ && preempted_flag_->IsSet()) {
@@ -819,7 +835,6 @@ void GpuChannel::HandleMessage() {
if (!m)
return;
- current_order_num_ = m->order_number;
const IPC::Message& message = m->message;
int32_t routing_id = message.routing_id();
GpuCommandBufferStub* stub = stubs_.get(routing_id);

Powered by Google App Engine
This is Rietveld 408576698