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

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

Issue 1308913004: GPU Channel's now maintain a global order number for each processed IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated command buffer stub to use 32 bit order numbers Created 5 years, 4 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
« no previous file with comments | « no previous file | content/common/gpu/gpu_channel.cc » ('j') | content/common/gpu/gpu_channel.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_channel.h
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h
index c51baa800265f9682f39e30c18b98c3672629ba6..5b280fa3814319e84471b50c47f5fa19f96520f9 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -8,11 +8,14 @@
#include <deque>
#include <string>
+#include "base/atomicops.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/process/process.h"
+#include "base/synchronization/lock.h"
+#include "base/timer/timer.h"
#include "base/trace_event/memory_dump_provider.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
@@ -95,6 +98,19 @@ class CONTENT_EXPORT GpuChannel
return io_task_runner_;
}
+ // Thread-safe channel message functions.
+ bool HasQueuedMessages();
+ base::TimeTicks GetNextMessageTimeTick();
+ void PushBackMessage(uint32_t order_number, const IPC::Message& message);
+ void PushFrontMessage(const IPC::Message& message);
+
+ // TODO(dyen): Temporary sync point insertion hook.
+ void PushSyncPointMessage(uint32_t order_number, const IPC::Message& message,
+ bool retire_sync_point, uint32_t sync_point_num);
+
+ // Process channel message from main thread.
+ void ProcessMessage(uint32_t order_number, const IPC::Message& message);
+
// IPC::Listener implementation:
bool OnMessageReceived(const IPC::Message& msg) override;
void OnChannelError() override;
@@ -145,7 +161,6 @@ class CONTENT_EXPORT GpuChannel
gpu::PreemptionFlag* GetPreemptionFlag();
bool handle_messages_scheduled() const { return handle_messages_scheduled_; }
- uint64 messages_processed() const { return messages_processed_; }
// If |preemption_flag->IsSet()|, any stub on this channel
// should stop issuing GL commands. Setting this to NULL stops deferral.
@@ -175,6 +190,12 @@ class CONTENT_EXPORT GpuChannel
return pending_valuebuffer_state_.get();
}
+ uint32_t GetCurrentOrderNum() const { return current_order_num_; }
+ uint32_t GetProcessedOrderNum() const { return processed_order_num_; }
+ uint32_t GetUnprocessedOrderNum() const {
+ return base::subtle::Acquire_Load(&unprocessed_order_num_);
+ }
+
protected:
// The message filter on the io thread.
scoped_refptr<GpuChannelMessageFilter> filter_;
@@ -200,8 +221,13 @@ class CONTENT_EXPORT GpuChannel
void OnDestroyCommandBuffer(int32 route_id);
void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg);
- // Decrement the count of unhandled IPC messages and defer preemption.
- void MessageProcessed();
+ void PushUnfinishedMessage(uint32_t order_number,
+ const IPC::Message& message);
+ void ScheduleHandleMessage();
+ void ScheduleHandleMessageLocked();
+
+ // Update processed order number and defer preemption.
+ void MessageProcessed(uint32_t order_number);
// The lifetime of objects of this class is managed by a GpuChannelManager.
// The GpuChannelManager destroy all the GpuChannels that they own when they
@@ -216,8 +242,6 @@ class CONTENT_EXPORT GpuChannel
// Used to implement message routing functionality to CommandBuffer objects
MessageRouter router_;
- uint64 messages_processed_;
-
// Whether the processing of IPCs on this channel is stalled and we should
// preempt other GpuChannels.
scoped_refptr<gpu::PreemptionFlag> preempting_flag_;
@@ -226,7 +250,28 @@ class CONTENT_EXPORT GpuChannel
// commands (via their GpuScheduler) when preempted_flag_->IsSet()
scoped_refptr<gpu::PreemptionFlag> preempted_flag_;
- std::deque<IPC::Message*> deferred_messages_;
+ struct ChannelMessage {
+ uint32_t order_number;
+ base::TimeTicks time_received;
+ IPC::Message message;
+
+ // TODO(dyen): Temporary sync point data, remove once new sync point lands.
+ bool retire_sync_point;
+ uint32 sync_point_number;
+
+ ChannelMessage(uint32_t order_num, const IPC::Message& msg)
+ : order_number(order_num),
+ time_received(base::TimeTicks::Now()),
+ message(msg),
+ retire_sync_point(false),
+ sync_point_number(0) {}
+ };
piman 2015/08/31 23:15:04 nit: move to before OnDestroy (within each visibli
David Yen 2015/09/01 02:01:52 Done.
+ bool handle_messages_scheduled_;
+ std::deque<ChannelMessage*> channel_messages_;
+
+ // This lock protects both handle_messages_scheduled_ and channel_messages_.
+ base::Lock channel_messages_lock_;
+
// The id of the client who is on the other side of the channel.
int client_id_;
@@ -253,11 +298,18 @@ class CONTENT_EXPORT GpuChannel
gpu::gles2::DisallowedFeatures disallowed_features_;
GpuWatchdog* watchdog_;
bool software_;
- bool handle_messages_scheduled_;
- IPC::Message* currently_processing_message_;
+ ChannelMessage* currently_processing_message_;
- size_t num_stubs_descheduled_;
+ // Current IPC order number being processed.
+ uint32_t current_order_num_;
+ // Last finished IPC order number.
+ uint32_t processed_order_num_;
+
+ // Highest IPC order number seen, set when queued on the IO thread.
+ base::subtle::Atomic32 unprocessed_order_num_;
piman 2015/08/31 23:15:04 As far as I can tell, this is only used in a DCHEC
David Yen 2015/09/01 02:01:52 This is going to be used later in the actual sync
+
+ size_t num_stubs_descheduled_;
bool allow_future_sync_points_;
// Member variables should appear before the WeakPtrFactory, to ensure
« no previous file with comments | « no previous file | content/common/gpu/gpu_channel.cc » ('j') | content/common/gpu/gpu_channel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698