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

Side by Side Diff: gpu/command_buffer/service/gpu_scheduler.h

Issue 7458010: Revert 93066 - Execute all GL commands up to the put offset reported by a each flush.This means g... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GPU_SCHEDULER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <vector> 10 #include <vector>
(...skipping 25 matching lines...) Expand all
36 36
37 namespace gpu { 37 namespace gpu {
38 namespace gles2 { 38 namespace gles2 {
39 class ContextGroup; 39 class ContextGroup;
40 } 40 }
41 41
42 // This class processes commands in a command buffer. It is event driven and 42 // This class processes commands in a command buffer. It is event driven and
43 // posts tasks to the current message loop to do additional work. 43 // posts tasks to the current message loop to do additional work.
44 class GpuScheduler : public CommandBufferEngine { 44 class GpuScheduler : public CommandBufferEngine {
45 public: 45 public:
46 // Scheduler quantum: makes ProcessCommands continue until the specified time
47 // has passed, or the command buffer yields or runs out of commands.
48 static const int kMinimumSchedulerQuantumMicros = 2000;
49
46 // If a group is not passed in one will be created. 50 // If a group is not passed in one will be created.
47 static GpuScheduler* Create(CommandBuffer* command_buffer, 51 GpuScheduler(CommandBuffer* command_buffer,
48 SurfaceManager* surface_manager, 52 SurfaceManager* surface_manager,
49 gles2::ContextGroup* group); 53 gles2::ContextGroup* group);
50 54
51 // This constructor is for unit tests. 55 // This constructor is for unit tests.
52 static GpuScheduler* CreateForTests(CommandBuffer* command_buffer, 56 GpuScheduler(CommandBuffer* command_buffer,
53 gles2::GLES2Decoder* decoder, 57 gles2::GLES2Decoder* decoder,
54 CommandParser* parser); 58 CommandParser* parser,
59 int commands_per_update);
55 60
56 virtual ~GpuScheduler(); 61 virtual ~GpuScheduler();
57 62
58 // Perform platform specific and common initialization. 63 // Perform platform specific and common initialization.
59 bool Initialize(gfx::PluginWindowHandle hwnd, 64 bool Initialize(gfx::PluginWindowHandle hwnd,
60 const gfx::Size& size, 65 const gfx::Size& size,
61 const gles2::DisallowedExtensions& disallowed_extensions, 66 const gles2::DisallowedExtensions& disallowed_extensions,
62 const char* allowed_extensions, 67 const char* allowed_extensions,
63 const std::vector<int32>& attribs, 68 const std::vector<int32>& attribs,
64 gfx::GLShareGroup* share_group); 69 gfx::GLShareGroup* share_group);
65 70
66 void Destroy(); 71 void Destroy();
67 void DestroyCommon(); 72 void DestroyCommon();
68 73
69 bool SetParent(GpuScheduler* parent_scheduler, uint32 parent_texture_id); 74 bool SetParent(GpuScheduler* parent_scheduler, uint32 parent_texture_id);
70 75
71 void PutChanged(); 76 void PutChanged(bool sync);
72 77
73 // Sets whether commands should be processed by this scheduler. Setting to 78 // Sets whether commands should be processed by this scheduler. Setting to
74 // false unschedules. Setting to true reschedules. Whether or not the 79 // false unschedules. Setting to true reschedules. Whether or not the
75 // scheduler is currently scheduled is "reference counted". Every call with 80 // scheduler is currently scheduled is "reference counted". Every call with
76 // false must eventually be paired by a call with true. 81 // false must eventually be paired by a call with true.
77 void SetScheduled(bool is_scheduled); 82 void SetScheduled(bool is_scheduled);
78 83
79 // Returns whether the scheduler is currently scheduled to process commands. 84 // Returns whether the scheduler is currently scheduled to process commands.
80 bool IsScheduled(); 85 bool IsScheduled();
81 86
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // is processed. 144 // is processed.
140 void SetResizeCallback(Callback1<gfx::Size>::Type* callback); 145 void SetResizeCallback(Callback1<gfx::Size>::Type* callback);
141 146
142 // Sets a callback which is called when a SwapBuffers command is processed. 147 // Sets a callback which is called when a SwapBuffers command is processed.
143 // Must be called after Initialize(). 148 // Must be called after Initialize().
144 // It is not defined on which thread this callback is called. 149 // It is not defined on which thread this callback is called.
145 void SetSwapBuffersCallback(Callback0::Type* callback); 150 void SetSwapBuffersCallback(Callback0::Type* callback);
146 151
147 void SetCommandProcessedCallback(Callback0::Type* callback); 152 void SetCommandProcessedCallback(Callback0::Type* callback);
148 153
154 // Sets a callback which is called after a Set/WaitLatch command is processed.
155 // The bool parameter will be true for SetLatch, and false for a WaitLatch
156 // that is blocked. An unblocked WaitLatch will not trigger a callback.
157 void SetLatchCallback(const base::Callback<void(bool)>& callback) {
158 decoder_->SetLatchCallback(callback);
159 }
160
149 // Sets a callback which is called when set_token() is called, and passes the 161 // Sets a callback which is called when set_token() is called, and passes the
150 // just-set token to the callback. DCHECKs that no callback has previously 162 // just-set token to the callback. DCHECKs that no callback has previously
151 // been registered for this notification. 163 // been registered for this notification.
152 void SetTokenCallback(const base::Callback<void(int32)>& callback); 164 void SetTokenCallback(const base::Callback<void(int32)>& callback);
153 165
154 // Get the GLES2Decoder associated with this scheduler. 166 // Get the GLES2Decoder associated with this scheduler.
155 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } 167 gles2::GLES2Decoder* decoder() const { return decoder_.get(); }
156 168
157 protected: 169 protected:
158 // Perform common initialization. Takes ownership of GLSurface and GLContext. 170 // Perform common initialization. Takes ownership of GLSurface and GLContext.
159 bool InitializeCommon( 171 bool InitializeCommon(
160 const scoped_refptr<gfx::GLSurface>& surface, 172 const scoped_refptr<gfx::GLSurface>& surface,
161 const scoped_refptr<gfx::GLContext>& context, 173 const scoped_refptr<gfx::GLContext>& context,
162 const gfx::Size& size, 174 const gfx::Size& size,
163 const gles2::DisallowedExtensions& disallowed_extensions, 175 const gles2::DisallowedExtensions& disallowed_extensions,
164 const char* allowed_extensions, 176 const char* allowed_extensions,
165 const std::vector<int32>& attribs); 177 const std::vector<int32>& attribs);
166 178
167 179
168 private: 180 private:
169 // If a group is not passed in one will be created. 181 // Helper which causes a call to ProcessCommands to be scheduled later.
170 GpuScheduler(CommandBuffer* command_buffer, 182 void ScheduleProcessCommands();
171 gles2::GLES2Decoder* decoder,
172 CommandParser* parser);
173 183
174 // Called via a callback just before we are supposed to call the 184 // Called via a callback just before we are supposed to call the
175 // user's resize callback. 185 // user's resize callback.
176 void WillResize(gfx::Size size); 186 void WillResize(gfx::Size size);
177 187
178 // Called via a callback just before we are supposed to call the 188 // Called via a callback just before we are supposed to call the
179 // user's swap buffers callback. 189 // user's swap buffers callback.
180 void WillSwapBuffers(); 190 void WillSwapBuffers();
191 void ProcessCommands();
181 192
182 // The GpuScheduler holds a weak reference to the CommandBuffer. The 193 // The GpuScheduler holds a weak reference to the CommandBuffer. The
183 // CommandBuffer owns the GpuScheduler and holds a strong reference to it 194 // CommandBuffer owns the GpuScheduler and holds a strong reference to it
184 // through the ProcessCommands callback. 195 // through the ProcessCommands callback.
185 CommandBuffer* command_buffer_; 196 CommandBuffer* command_buffer_;
186 197
198 int commands_per_update_;
199
187 scoped_ptr<gles2::GLES2Decoder> decoder_; 200 scoped_ptr<gles2::GLES2Decoder> decoder_;
188 scoped_ptr<CommandParser> parser_; 201 scoped_ptr<CommandParser> parser_;
189 202
190 // Greater than zero if this is waiting to be rescheduled before continuing. 203 // Greater than zero if this is waiting to be rescheduled before continuing.
191 int unscheduled_count_; 204 int unscheduled_count_;
192 205
193 scoped_ptr<Callback0::Type> scheduled_callback_; 206 scoped_ptr<Callback0::Type> scheduled_callback_;
194 207
195 #if defined(OS_MACOSX) || defined(TOUCH_UI) 208 #if defined(OS_MACOSX) || defined(TOUCH_UI)
196 uint64 swap_buffers_count_; 209 uint64 swap_buffers_count_;
(...skipping 12 matching lines...) Expand all
209 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; 222 ScopedRunnableMethodFactory<GpuScheduler> method_factory_;
210 scoped_ptr<Callback1<gfx::Size>::Type> wrapped_resize_callback_; 223 scoped_ptr<Callback1<gfx::Size>::Type> wrapped_resize_callback_;
211 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; 224 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_;
212 scoped_ptr<Callback0::Type> command_processed_callback_; 225 scoped_ptr<Callback0::Type> command_processed_callback_;
213 base::Callback<void(int32)> set_token_callback_; 226 base::Callback<void(int32)> set_token_callback_;
214 }; 227 };
215 228
216 } // namespace gpu 229 } // namespace gpu
217 230
218 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ 231 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h ('k') | gpu/command_buffer/service/gpu_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698