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

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

Issue 1336623004: content/gpu: Simplify gpu channel message handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: piman 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
« 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 d51a98ba2761383b87df9247cfe2f7ffc2adb608..14fce544a947f41a6f9a8effd88529409a72884d 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -106,11 +106,6 @@ class CONTENT_EXPORT GpuChannel
// IPC::Sender implementation:
bool Send(IPC::Message* msg) override;
- // Requeue the message that is currently being processed to the beginning of
- // the queue. Used when the processing of a message gets aborted because of
- // unscheduling conditions.
- void RequeueMessage();
-
// SubscriptionRefSet::Observer implementation
void OnAddSubscription(unsigned int target) override;
void OnRemoveSubscription(unsigned int target) override;
@@ -179,10 +174,18 @@ class CONTENT_EXPORT GpuChannel
// Visible for testing.
GpuChannelMessageFilter* filter() const { return filter_.get(); }
- uint32_t GetCurrentOrderNum() const { return current_order_num_; }
- uint32_t GetProcessedOrderNum() const { return processed_order_num_; }
+ // Returns the global order number of the IPC message that started processing
+ // last.
+ uint32_t current_order_num() const { return current_order_num_; }
+
+ // Returns the global order number for the last processed IPC message.
+ uint32_t GetProcessedOrderNum() const;
+
+ // Returns the global order number for the last unprocessed IPC message.
uint32_t GetUnprocessedOrderNum() const;
+ void HandleMessage();
+
protected:
// The message filter on the io thread.
scoped_refptr<GpuChannelMessageFilter> filter_;
@@ -210,14 +213,11 @@ class CONTENT_EXPORT GpuChannel
base::hash_set<int32> routes_;
};
- friend class GpuChannelMessageFilter;
- friend class GpuChannelMessageQueue;
-
void OnDestroy();
bool OnControlMessageReceived(const IPC::Message& msg);
- void HandleMessage();
+ void ScheduleHandleMessage();
// Message handlers.
void OnCreateOffscreenCommandBuffer(
@@ -228,9 +228,6 @@ class CONTENT_EXPORT GpuChannel
void OnDestroyCommandBuffer(int32 route_id);
void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg);
- // 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
// are destroyed. So a raw pointer is safe.
@@ -280,17 +277,13 @@ class CONTENT_EXPORT GpuChannel
GpuWatchdog* watchdog_;
bool software_;
- // Current IPC order number being processed.
- uint32_t current_order_num_;
-
- // Last finished IPC order number.
- uint32_t processed_order_num_;
-
size_t num_stubs_descheduled_;
// Map of stream id to stream state.
base::hash_map<int32, StreamState> streams_;
+ uint32_t current_order_num_;
+
bool allow_future_sync_points_;
bool allow_real_time_streams_;
@@ -315,11 +308,10 @@ class CONTENT_EXPORT GpuChannel
// - it generates mailbox names for clients of the GPU process on the IO thread.
class GpuChannelMessageFilter : public IPC::MessageFilter {
public:
- GpuChannelMessageFilter(
- scoped_refptr<GpuChannelMessageQueue> message_queue,
- gpu::SyncPointManager* sync_point_manager,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
- bool future_sync_points);
+ GpuChannelMessageFilter(GpuChannelMessageQueue* message_queue,
+ gpu::SyncPointManager* sync_point_manager,
+ base::SingleThreadTaskRunner* task_runner,
+ bool future_sync_points);
// IPC::MessageFilter implementation.
void OnFilterAdded(IPC::Sender* sender) override;
@@ -397,6 +389,90 @@ class GpuChannelMessageFilter : public IPC::MessageFilter {
static uint32_t global_order_counter_;
};
+struct GpuChannelMessage {
+ 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;
+
+ GpuChannelMessage(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(0) {}
+};
dcheng 2015/09/17 00:15:18 DISALLOW_COPY_AND_ASSIGN? Since it looks like the
sunnyps 2015/09/17 00:32:39 Done.
+
+class GpuChannelMessageQueue
+ : public base::RefCountedThreadSafe<GpuChannelMessageQueue> {
+ public:
+ static scoped_refptr<GpuChannelMessageQueue> Create(
+ const base::WeakPtr<GpuChannel>& gpu_channel,
+ base::SingleThreadTaskRunner* task_runner);
+
+ // Returns the global order number for the last processed IPC message.
+ uint32_t GetUnprocessedOrderNum() const;
+
+ // Returns the global order number for the last unprocessed IPC message.
+ uint32_t processed_order_num() const { return processed_order_num_; }
+
+ bool HasQueuedMessages() const;
+
+ base::TimeTicks GetNextMessageTimeTick() const;
+
+ GpuChannelMessage* GetNextMessage() const;
+
+ // Should be called after a message returned by GetNextMessage is processed.
+ // Returns true if there are more messages on the queue.
+ bool MessageProcessed(uint32_t order_number);
+
+ void PushBackMessage(uint32_t order_number, const IPC::Message& message);
+
+ bool GenerateSyncPointMessage(gpu::SyncPointManager* sync_point_manager,
+ uint32_t order_number,
+ const IPC::Message& message,
+ bool retire_sync_point,
+ uint32_t* sync_point_number);
+
+ void DeleteAndDisableMessages(GpuChannelManager* gpu_channel_manager);
+
+ private:
+ friend class base::RefCountedThreadSafe<GpuChannelMessageQueue>;
+
+ GpuChannelMessageQueue(const base::WeakPtr<GpuChannel>& gpu_channel,
+ base::SingleThreadTaskRunner* task_runner);
+ ~GpuChannelMessageQueue();
+
+ void ScheduleHandleMessage();
+
+ void PushMessageHelper(scoped_ptr<GpuChannelMessage> msg);
+
+ bool HasQueuedMessagesHelper() const;
+
+ bool enabled_;
+
+ // Highest IPC order number seen, set when queued on the IO thread.
+ uint32_t unprocessed_order_num_;
+ // Both deques own the messages.
+ std::deque<GpuChannelMessage*> channel_messages_;
+ std::deque<GpuChannelMessage*> out_of_order_messages_;
+
+ // This lock protects enabled_, unprocessed_order_num_, and both deques.
+ mutable base::Lock channel_messages_lock_;
+
+ // Last finished IPC order number. Not protected by a lock as it's only
+ // accessed on the main thread.
+ uint32_t processed_order_num_;
+
+ base::WeakPtr<GpuChannel> gpu_channel_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue);
+};
+
} // namespace content
#endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_
« 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