OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "gpu/gpu_export.h" | 30 #include "gpu/gpu_export.h" |
31 #include "ui/gfx/gpu_memory_buffer.h" | 31 #include "ui/gfx/gpu_memory_buffer.h" |
32 #include "ui/gfx/native_widget_types.h" | 32 #include "ui/gfx/native_widget_types.h" |
33 #include "ui/gl/gl_surface.h" | 33 #include "ui/gl/gl_surface.h" |
34 #include "ui/gl/gpu_preference.h" | 34 #include "ui/gl/gpu_preference.h" |
35 | 35 |
36 namespace base { | 36 namespace base { |
37 class SequenceChecker; | 37 class SequenceChecker; |
38 } | 38 } |
39 | 39 |
40 namespace gfx { | 40 namespace gl { |
41 class GLContext; | 41 class GLContext; |
42 class GLShareGroup; | 42 class GLShareGroup; |
43 class GLSurface; | 43 class GLSurface; |
| 44 } |
| 45 |
| 46 namespace gfx { |
44 class Size; | 47 class Size; |
45 } | 48 } |
46 | 49 |
47 namespace gpu { | 50 namespace gpu { |
48 class SyncPointClient; | 51 class SyncPointClient; |
49 class SyncPointOrderData; | 52 class SyncPointOrderData; |
50 class SyncPointManager; | 53 class SyncPointManager; |
51 | 54 |
52 namespace gles2 { | 55 namespace gles2 { |
53 struct ContextCreationAttribHelper; | 56 struct ContextCreationAttribHelper; |
(...skipping 17 matching lines...) Expand all Loading... |
71 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, | 74 class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
72 public GpuControl { | 75 public GpuControl { |
73 public: | 76 public: |
74 class Service; | 77 class Service; |
75 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); | 78 explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); |
76 ~InProcessCommandBuffer() override; | 79 ~InProcessCommandBuffer() override; |
77 | 80 |
78 // If |surface| is not null, use it directly; in this case, the command | 81 // If |surface| is not null, use it directly; in this case, the command |
79 // buffer gpu thread must be the same as the client thread. Otherwise create | 82 // buffer gpu thread must be the same as the client thread. Otherwise create |
80 // a new GLSurface. | 83 // a new GLSurface. |
81 bool Initialize(scoped_refptr<gfx::GLSurface> surface, | 84 bool Initialize(scoped_refptr<gl::GLSurface> surface, |
82 bool is_offscreen, | 85 bool is_offscreen, |
83 gfx::AcceleratedWidget window, | 86 gfx::AcceleratedWidget window, |
84 const gfx::Size& size, | 87 const gfx::Size& size, |
85 const gles2::ContextCreationAttribHelper& attribs, | 88 const gles2::ContextCreationAttribHelper& attribs, |
86 gfx::GpuPreference gpu_preference, | 89 gl::GpuPreference gpu_preference, |
87 InProcessCommandBuffer* share_group, | 90 InProcessCommandBuffer* share_group, |
88 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 91 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
89 ImageFactory* image_factory); | 92 ImageFactory* image_factory); |
90 | 93 |
91 // CommandBuffer implementation: | 94 // CommandBuffer implementation: |
92 State GetLastState() override; | 95 State GetLastState() override; |
93 int32_t GetLastToken() override; | 96 int32_t GetLastToken() override; |
94 void Flush(int32_t put_offset) override; | 97 void Flush(int32_t put_offset) override; |
95 void OrderingBarrier(int32_t put_offset) override; | 98 void OrderingBarrier(int32_t put_offset) override; |
96 void WaitForTokenInRange(int32_t start, int32_t end) override; | 99 void WaitForTokenInRange(int32_t start, int32_t end) override; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 virtual void ScheduleDelayedWork(const base::Closure& task) = 0; | 149 virtual void ScheduleDelayedWork(const base::Closure& task) = 0; |
147 | 150 |
148 virtual bool UseVirtualizedGLContexts() = 0; | 151 virtual bool UseVirtualizedGLContexts() = 0; |
149 virtual scoped_refptr<gles2::ShaderTranslatorCache> | 152 virtual scoped_refptr<gles2::ShaderTranslatorCache> |
150 shader_translator_cache() = 0; | 153 shader_translator_cache() = 0; |
151 virtual scoped_refptr<gles2::FramebufferCompletenessCache> | 154 virtual scoped_refptr<gles2::FramebufferCompletenessCache> |
152 framebuffer_completeness_cache() = 0; | 155 framebuffer_completeness_cache() = 0; |
153 virtual SyncPointManager* sync_point_manager() = 0; | 156 virtual SyncPointManager* sync_point_manager() = 0; |
154 const GpuPreferences& gpu_preferences(); | 157 const GpuPreferences& gpu_preferences(); |
155 const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds(); | 158 const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds(); |
156 scoped_refptr<gfx::GLShareGroup> share_group(); | 159 scoped_refptr<gl::GLShareGroup> share_group(); |
157 scoped_refptr<gles2::MailboxManager> mailbox_manager(); | 160 scoped_refptr<gles2::MailboxManager> mailbox_manager(); |
158 gpu::gles2::ProgramCache* program_cache(); | 161 gpu::gles2::ProgramCache* program_cache(); |
159 | 162 |
160 private: | 163 private: |
161 const GpuPreferences gpu_preferences_; | 164 const GpuPreferences gpu_preferences_; |
162 const GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; | 165 const GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
163 scoped_refptr<gfx::GLShareGroup> share_group_; | 166 scoped_refptr<gl::GLShareGroup> share_group_; |
164 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 167 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
165 std::unique_ptr<gpu::gles2::ProgramCache> program_cache_; | 168 std::unique_ptr<gpu::gles2::ProgramCache> program_cache_; |
166 }; | 169 }; |
167 | 170 |
168 private: | 171 private: |
169 struct InitializeOnGpuThreadParams { | 172 struct InitializeOnGpuThreadParams { |
170 bool is_offscreen; | 173 bool is_offscreen; |
171 gfx::AcceleratedWidget window; | 174 gfx::AcceleratedWidget window; |
172 const gfx::Size& size; | 175 const gfx::Size& size; |
173 const gles2::ContextCreationAttribHelper& attribs; | 176 const gles2::ContextCreationAttribHelper& attribs; |
174 gfx::GpuPreference gpu_preference; | 177 gl::GpuPreference gpu_preference; |
175 gpu::Capabilities* capabilities; // Ouptut. | 178 gpu::Capabilities* capabilities; // Ouptut. |
176 InProcessCommandBuffer* context_group; | 179 InProcessCommandBuffer* context_group; |
177 ImageFactory* image_factory; | 180 ImageFactory* image_factory; |
178 | 181 |
179 InitializeOnGpuThreadParams( | 182 InitializeOnGpuThreadParams( |
180 bool is_offscreen, | 183 bool is_offscreen, |
181 gfx::AcceleratedWidget window, | 184 gfx::AcceleratedWidget window, |
182 const gfx::Size& size, | 185 const gfx::Size& size, |
183 const gles2::ContextCreationAttribHelper& attribs, | 186 const gles2::ContextCreationAttribHelper& attribs, |
184 gfx::GpuPreference gpu_preference, | 187 gl::GpuPreference gpu_preference, |
185 gpu::Capabilities* capabilities, | 188 gpu::Capabilities* capabilities, |
186 InProcessCommandBuffer* share_group, | 189 InProcessCommandBuffer* share_group, |
187 ImageFactory* image_factory) | 190 ImageFactory* image_factory) |
188 : is_offscreen(is_offscreen), | 191 : is_offscreen(is_offscreen), |
189 window(window), | 192 window(window), |
190 size(size), | 193 size(size), |
191 attribs(attribs), | 194 attribs(attribs), |
192 gpu_preference(gpu_preference), | 195 gpu_preference(gpu_preference), |
193 capabilities(capabilities), | 196 capabilities(capabilities), |
194 context_group(share_group), | 197 context_group(share_group), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 void OnContextLost(); | 234 void OnContextLost(); |
232 | 235 |
233 const CommandBufferId command_buffer_id_; | 236 const CommandBufferId command_buffer_id_; |
234 | 237 |
235 // Members accessed on the gpu thread (possibly with the exception of | 238 // Members accessed on the gpu thread (possibly with the exception of |
236 // creation): | 239 // creation): |
237 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 240 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
238 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 241 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
239 std::unique_ptr<CommandExecutor> executor_; | 242 std::unique_ptr<CommandExecutor> executor_; |
240 std::unique_ptr<gles2::GLES2Decoder> decoder_; | 243 std::unique_ptr<gles2::GLES2Decoder> decoder_; |
241 scoped_refptr<gfx::GLContext> context_; | 244 scoped_refptr<gl::GLContext> context_; |
242 scoped_refptr<gfx::GLSurface> surface_; | 245 scoped_refptr<gl::GLSurface> surface_; |
243 scoped_refptr<SyncPointOrderData> sync_point_order_data_; | 246 scoped_refptr<SyncPointOrderData> sync_point_order_data_; |
244 std::unique_ptr<SyncPointClient> sync_point_client_; | 247 std::unique_ptr<SyncPointClient> sync_point_client_; |
245 base::Closure context_lost_callback_; | 248 base::Closure context_lost_callback_; |
246 // Used to throttle PerformDelayedWorkOnGpuThread. | 249 // Used to throttle PerformDelayedWorkOnGpuThread. |
247 bool delayed_work_pending_; | 250 bool delayed_work_pending_; |
248 ImageFactory* image_factory_; | 251 ImageFactory* image_factory_; |
249 | 252 |
250 // Members accessed on the client thread: | 253 // Members accessed on the client thread: |
251 GpuControlClient* gpu_control_client_; | 254 GpuControlClient* gpu_control_client_; |
252 #if DCHECK_IS_ON() | 255 #if DCHECK_IS_ON() |
253 bool context_lost_; | 256 bool context_lost_; |
254 #endif | 257 #endif |
255 State last_state_; | 258 State last_state_; |
256 int32_t last_put_offset_; | 259 int32_t last_put_offset_; |
257 gpu::Capabilities capabilities_; | 260 gpu::Capabilities capabilities_; |
258 GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 261 GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
259 base::AtomicSequenceNumber next_image_id_; | 262 base::AtomicSequenceNumber next_image_id_; |
260 uint64_t next_fence_sync_release_; | 263 uint64_t next_fence_sync_release_; |
261 uint64_t flushed_fence_sync_release_; | 264 uint64_t flushed_fence_sync_release_; |
262 | 265 |
263 // Accessed on both threads: | 266 // Accessed on both threads: |
264 std::unique_ptr<CommandBufferServiceBase> command_buffer_; | 267 std::unique_ptr<CommandBufferServiceBase> command_buffer_; |
265 base::Lock command_buffer_lock_; | 268 base::Lock command_buffer_lock_; |
266 base::WaitableEvent flush_event_; | 269 base::WaitableEvent flush_event_; |
267 scoped_refptr<Service> service_; | 270 scoped_refptr<Service> service_; |
268 State state_after_last_flush_; | 271 State state_after_last_flush_; |
269 base::Lock state_after_last_flush_lock_; | 272 base::Lock state_after_last_flush_lock_; |
270 scoped_refptr<gfx::GLShareGroup> gl_share_group_; | 273 scoped_refptr<gl::GLShareGroup> gl_share_group_; |
271 base::WaitableEvent fence_sync_wait_event_; | 274 base::WaitableEvent fence_sync_wait_event_; |
272 | 275 |
273 // Only used with explicit scheduling and the gpu thread is the same as | 276 // Only used with explicit scheduling and the gpu thread is the same as |
274 // the client thread. | 277 // the client thread. |
275 std::unique_ptr<base::SequenceChecker> sequence_checker_; | 278 std::unique_ptr<base::SequenceChecker> sequence_checker_; |
276 | 279 |
277 base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; | 280 base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; |
278 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; | 281 base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; |
279 base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; | 282 base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; |
280 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; | 283 base::WeakPtrFactory<InProcessCommandBuffer> gpu_thread_weak_ptr_factory_; |
(...skipping 27 matching lines...) Expand all Loading... |
308 SyncPointManager* sync_point_manager_; // Non-owning. | 311 SyncPointManager* sync_point_manager_; // Non-owning. |
309 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; | 312 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
310 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> | 313 scoped_refptr<gpu::gles2::FramebufferCompletenessCache> |
311 framebuffer_completeness_cache_; | 314 framebuffer_completeness_cache_; |
312 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); | 315 DISALLOW_COPY_AND_ASSIGN(GpuInProcessThread); |
313 }; | 316 }; |
314 | 317 |
315 } // namespace gpu | 318 } // namespace gpu |
316 | 319 |
317 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ | 320 #endif // GPU_COMMAND_BUFFER_SERVICE_IN_PROCESS_COMMAND_BUFFER_H_ |
OLD | NEW |