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

Side by Side 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: Enforce that queue is to not be modified after being disabled 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/common/gpu/gpu_channel.cc » ('j') | content/common/gpu/gpu_channel.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_
7 7
8 #include <deque>
9 #include <string> 8 #include <string>
10 9
11 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
15 #include "base/process/process.h" 14 #include "base/process/process.h"
16 #include "base/trace_event/memory_dump_provider.h" 15 #include "base/trace_event/memory_dump_provider.h"
17 #include "build/build_config.h" 16 #include "build/build_config.h"
18 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
(...skipping 24 matching lines...) Expand all
43 } 42 }
44 43
45 namespace IPC { 44 namespace IPC {
46 class AttachmentBroker; 45 class AttachmentBroker;
47 class MessageFilter; 46 class MessageFilter;
48 } 47 }
49 48
50 namespace content { 49 namespace content {
51 class GpuChannelManager; 50 class GpuChannelManager;
52 class GpuChannelMessageFilter; 51 class GpuChannelMessageFilter;
52 class GpuChannelMessageQueue;
53 class GpuJpegDecodeAccelerator; 53 class GpuJpegDecodeAccelerator;
54 class GpuWatchdog; 54 class GpuWatchdog;
55 55
56 struct GpuChannelMessage;
57
56 // Encapsulates an IPC channel between the GPU process and one renderer 58 // Encapsulates an IPC channel between the GPU process and one renderer
57 // process. On the renderer side there's a corresponding GpuChannelHost. 59 // process. On the renderer side there's a corresponding GpuChannelHost.
58 class CONTENT_EXPORT GpuChannel 60 class CONTENT_EXPORT GpuChannel
59 : public IPC::Listener, 61 : public IPC::Listener,
60 public IPC::Sender, 62 public IPC::Sender,
61 public gpu::gles2::SubscriptionRefSet::Observer { 63 public gpu::gles2::SubscriptionRefSet::Observer {
62 public: 64 public:
63 // Takes ownership of the renderer process handle. 65 // Takes ownership of the renderer process handle.
64 GpuChannel(GpuChannelManager* gpu_channel_manager, 66 GpuChannel(GpuChannelManager* gpu_channel_manager,
65 GpuWatchdog* watchdog, 67 GpuWatchdog* watchdog,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 // Called to add a listener for a particular message routing ID. 140 // Called to add a listener for a particular message routing ID.
139 // Returns true if succeeded. 141 // Returns true if succeeded.
140 bool AddRoute(int32 route_id, IPC::Listener* listener); 142 bool AddRoute(int32 route_id, IPC::Listener* listener);
141 143
142 // Called to remove a listener for a particular message routing ID. 144 // Called to remove a listener for a particular message routing ID.
143 void RemoveRoute(int32 route_id); 145 void RemoveRoute(int32 route_id);
144 146
145 gpu::PreemptionFlag* GetPreemptionFlag(); 147 gpu::PreemptionFlag* GetPreemptionFlag();
146 148
147 bool handle_messages_scheduled() const { return handle_messages_scheduled_; }
148 uint64 messages_processed() const { return messages_processed_; }
149
150 // If |preemption_flag->IsSet()|, any stub on this channel 149 // If |preemption_flag->IsSet()|, any stub on this channel
151 // should stop issuing GL commands. Setting this to NULL stops deferral. 150 // should stop issuing GL commands. Setting this to NULL stops deferral.
152 void SetPreemptByFlag( 151 void SetPreemptByFlag(
153 scoped_refptr<gpu::PreemptionFlag> preemption_flag); 152 scoped_refptr<gpu::PreemptionFlag> preemption_flag);
154 153
155 void CacheShader(const std::string& key, const std::string& shader); 154 void CacheShader(const std::string& key, const std::string& shader);
156 155
157 virtual void AddFilter(IPC::MessageFilter* filter); 156 virtual void AddFilter(IPC::MessageFilter* filter);
158 virtual void RemoveFilter(IPC::MessageFilter* filter); 157 virtual void RemoveFilter(IPC::MessageFilter* filter);
159 158
160 uint64 GetMemoryUsage(); 159 uint64 GetMemoryUsage();
161 160
162 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( 161 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
163 const gfx::GpuMemoryBufferHandle& handle, 162 const gfx::GpuMemoryBufferHandle& handle,
164 const gfx::Size& size, 163 const gfx::Size& size,
165 gfx::BufferFormat format, 164 gfx::BufferFormat format,
166 uint32 internalformat); 165 uint32 internalformat);
167 166
168 bool allow_future_sync_points() const { return allow_future_sync_points_; } 167 bool allow_future_sync_points() const { return allow_future_sync_points_; }
169 168
170 void HandleUpdateValueState(unsigned int target, 169 void HandleUpdateValueState(unsigned int target,
171 const gpu::ValueState& state); 170 const gpu::ValueState& state);
172 171
173 // Visible for testing. 172 // Visible for testing.
174 const gpu::ValueStateMap* pending_valuebuffer_state() const { 173 const gpu::ValueStateMap* pending_valuebuffer_state() const {
175 return pending_valuebuffer_state_.get(); 174 return pending_valuebuffer_state_.get();
176 } 175 }
177 176
177 uint32_t GetCurrentOrderNum() const { return current_order_num_; }
178 uint32_t GetProcessedOrderNum() const { return processed_order_num_; }
179 uint32_t GetUnprocessedOrderNum() const;
180
178 protected: 181 protected:
179 // The message filter on the io thread. 182 // The message filter on the io thread.
180 scoped_refptr<GpuChannelMessageFilter> filter_; 183 scoped_refptr<GpuChannelMessageFilter> filter_;
181 184
182 // Map of routing id to command buffer stub. 185 // Map of routing id to command buffer stub.
183 base::ScopedPtrHashMap<int32, scoped_ptr<GpuCommandBufferStub>> stubs_; 186 base::ScopedPtrHashMap<int32, scoped_ptr<GpuCommandBufferStub>> stubs_;
184 187
185 private: 188 private:
186 friend class GpuChannelMessageFilter; 189 friend class GpuChannelMessageFilter;
190 friend class GpuChannelMessageQueue;
187 191
188 void OnDestroy(); 192 void OnDestroy();
189 193
190 bool OnControlMessageReceived(const IPC::Message& msg); 194 bool OnControlMessageReceived(const IPC::Message& msg);
191 195
192 void HandleMessage(); 196 void HandleMessage();
193 197
194 // Message handlers. 198 // Message handlers.
195 void OnCreateOffscreenCommandBuffer( 199 void OnCreateOffscreenCommandBuffer(
196 const gfx::Size& size, 200 const gfx::Size& size,
197 const GPUCreateCommandBufferConfig& init_params, 201 const GPUCreateCommandBufferConfig& init_params,
198 int32 route_id, 202 int32 route_id,
199 bool* succeeded); 203 bool* succeeded);
200 void OnDestroyCommandBuffer(int32 route_id); 204 void OnDestroyCommandBuffer(int32 route_id);
201 void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg); 205 void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg);
202 206
203 // Decrement the count of unhandled IPC messages and defer preemption. 207 // Update processed order number and defer preemption.
204 void MessageProcessed(); 208 void MessageProcessed(uint32_t order_number);
205 209
206 // The lifetime of objects of this class is managed by a GpuChannelManager. 210 // The lifetime of objects of this class is managed by a GpuChannelManager.
207 // The GpuChannelManager destroy all the GpuChannels that they own when they 211 // The GpuChannelManager destroy all the GpuChannels that they own when they
208 // are destroyed. So a raw pointer is safe. 212 // are destroyed. So a raw pointer is safe.
209 GpuChannelManager* gpu_channel_manager_; 213 GpuChannelManager* gpu_channel_manager_;
210 214
211 scoped_ptr<IPC::SyncChannel> channel_; 215 scoped_ptr<IPC::SyncChannel> channel_;
212 216
213 // Uniquely identifies the channel within this GPU process. 217 // Uniquely identifies the channel within this GPU process.
214 std::string channel_id_; 218 std::string channel_id_;
215 219
216 // Used to implement message routing functionality to CommandBuffer objects 220 // Used to implement message routing functionality to CommandBuffer objects
217 MessageRouter router_; 221 MessageRouter router_;
218 222
219 uint64 messages_processed_;
220
221 // Whether the processing of IPCs on this channel is stalled and we should 223 // Whether the processing of IPCs on this channel is stalled and we should
222 // preempt other GpuChannels. 224 // preempt other GpuChannels.
223 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; 225 scoped_refptr<gpu::PreemptionFlag> preempting_flag_;
224 226
225 // If non-NULL, all stubs on this channel should stop processing GL 227 // If non-NULL, all stubs on this channel should stop processing GL
226 // commands (via their GpuScheduler) when preempted_flag_->IsSet() 228 // commands (via their GpuScheduler) when preempted_flag_->IsSet()
227 scoped_refptr<gpu::PreemptionFlag> preempted_flag_; 229 scoped_refptr<gpu::PreemptionFlag> preempted_flag_;
228 230
229 std::deque<IPC::Message*> deferred_messages_; 231 scoped_refptr<GpuChannelMessageQueue> message_queue_;
230 232
231 // The id of the client who is on the other side of the channel. 233 // The id of the client who is on the other side of the channel.
232 int client_id_; 234 int client_id_;
233 235
234 // The tracing ID used for memory allocations associated with this client. 236 // The tracing ID used for memory allocations associated with this client.
235 uint64_t client_tracing_id_; 237 uint64_t client_tracing_id_;
236 238
237 // The task runners for the main thread and the io thread. 239 // The task runners for the main thread and the io thread.
238 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 240 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
239 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 241 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
240 242
241 // The share group that all contexts associated with a particular renderer 243 // The share group that all contexts associated with a particular renderer
242 // process use. 244 // process use.
243 scoped_refptr<gfx::GLShareGroup> share_group_; 245 scoped_refptr<gfx::GLShareGroup> share_group_;
244 246
245 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; 247 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
246 248
247 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_; 249 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_;
248 250
249 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; 251 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_;
250 252
251 scoped_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_; 253 scoped_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_;
252 254
253 gpu::gles2::DisallowedFeatures disallowed_features_; 255 gpu::gles2::DisallowedFeatures disallowed_features_;
254 GpuWatchdog* watchdog_; 256 GpuWatchdog* watchdog_;
255 bool software_; 257 bool software_;
256 bool handle_messages_scheduled_; 258
257 IPC::Message* currently_processing_message_; 259 // Current IPC order number being processed.
260 uint32_t current_order_num_;
261
262 // Last finished IPC order number.
263 uint32_t processed_order_num_;
258 264
259 size_t num_stubs_descheduled_; 265 size_t num_stubs_descheduled_;
260 266
261 bool allow_future_sync_points_; 267 bool allow_future_sync_points_;
262 268
263 // Member variables should appear before the WeakPtrFactory, to ensure 269 // Member variables should appear before the WeakPtrFactory, to ensure
264 // that any WeakPtrs to Controller are invalidated before its members 270 // that any WeakPtrs to Controller are invalidated before its members
265 // variable's destructors are executed, rendering them invalid. 271 // variable's destructors are executed, rendering them invalid.
266 base::WeakPtrFactory<GpuChannel> weak_factory_; 272 base::WeakPtrFactory<GpuChannel> weak_factory_;
267 273
268 DISALLOW_COPY_AND_ASSIGN(GpuChannel); 274 DISALLOW_COPY_AND_ASSIGN(GpuChannel);
269 }; 275 };
270 276
271 } // namespace content 277 } // namespace content
272 278
273 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ 279 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_
OLDNEW
« 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