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

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

Issue 2440093003: WIP GPU scheduler + delayed activation / tile draw
Patch Set: SignalSyncToken -> IsFenceSyncReleased Created 4 years 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
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 GPU_COMMAND_BUFFER_SERVICE_COMMAND_EXECUTOR_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMAND_EXECUTOR_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_COMMAND_EXECUTOR_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMAND_EXECUTOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/atomic_ref_count.h"
14 #include "base/atomicops.h"
15 #include "base/callback.h" 13 #include "base/callback.h"
16 #include "base/macros.h" 14 #include "base/macros.h"
17 #include "base/memory/ref_counted.h"
18 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
19 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
20 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 17 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
21 #include "gpu/command_buffer/service/cmd_parser.h" 18 #include "gpu/command_buffer/service/cmd_parser.h"
22 #include "gpu/command_buffer/service/command_buffer_service.h" 19 #include "gpu/command_buffer/service/command_buffer_service.h"
23 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
24 #include "gpu/gpu_export.h" 21 #include "gpu/gpu_export.h"
25 22
26 namespace gpu { 23 namespace gpu {
27 24
28 class PreemptionFlag : public base::RefCountedThreadSafe<PreemptionFlag> {
29 public:
30 PreemptionFlag() : flag_(0) {}
31
32 bool IsSet() { return !base::AtomicRefCountIsZero(&flag_); }
33 void Set() { base::AtomicRefCountInc(&flag_); }
34 void Reset() { base::subtle::NoBarrier_Store(&flag_, 0); }
35
36 private:
37 base::AtomicRefCount flag_;
38
39 ~PreemptionFlag() {}
40
41 friend class base::RefCountedThreadSafe<PreemptionFlag>;
42 };
43
44 // This class schedules commands that have been flushed. They are received via 25 // This class schedules commands that have been flushed. They are received via
45 // a command buffer and forwarded to a command parser. TODO(apatrick): This 26 // a command buffer and forwarded to a command parser. TODO(apatrick): This
46 // class should not know about the decoder. Do not add additional dependencies 27 // class should not know about the decoder. Do not add additional dependencies
47 // on it. 28 // on it.
48 class GPU_EXPORT CommandExecutor 29 class GPU_EXPORT CommandExecutor
49 : NON_EXPORTED_BASE(public CommandBufferEngine), 30 : NON_EXPORTED_BASE(public CommandBufferEngine),
50 public base::SupportsWeakPtr<CommandExecutor> { 31 public base::SupportsWeakPtr<CommandExecutor> {
51 public: 32 public:
52 CommandExecutor(CommandBufferServiceBase* command_buffer, 33 CommandExecutor(CommandBufferServiceBase* command_buffer,
53 AsyncAPIInterface* handler, 34 AsyncAPIInterface* handler,
54 gles2::GLES2Decoder* decoder); 35 gles2::GLES2Decoder* decoder);
55 36
56 ~CommandExecutor() override; 37 ~CommandExecutor() override;
57 38
58 void PutChanged(); 39 void PutChanged();
59 40
60 void SetPreemptByFlag(scoped_refptr<PreemptionFlag> flag) { 41 // This callback is checked regularly and execution is stopped if it returns
61 preemption_flag_ = flag; 42 // true.
62 } 43 typedef base::Callback<bool(void)> PreemptionCallback;
44 void SetPreemptionCallback(const PreemptionCallback& callback);
63 45
64 // Sets whether commands should be processed by this scheduler. Setting to 46 // Sets whether commands should be processed by this scheduler. Setting to
65 // false unschedules. Setting to true reschedules. 47 // false unschedules. Setting to true reschedules.
66 void SetScheduled(bool scheduled); 48 void SetScheduled(bool scheduled);
67 49
68 bool scheduled() const { return scheduled_; } 50 bool scheduled() const { return scheduled_; }
69 51
70 // Returns whether the scheduler needs to be polled again in the future to 52 // Returns whether the scheduler needs to be polled again in the future to
71 // process pending queries. 53 // process pending queries.
72 bool HasPendingQueries() const; 54 bool HasPendingQueries() const;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // reason for context lost. 97 // reason for context lost.
116 gles2::GLES2Decoder* decoder_; 98 gles2::GLES2Decoder* decoder_;
117 99
118 // TODO(apatrick): The CommandExecutor currently creates and owns the parser. 100 // TODO(apatrick): The CommandExecutor currently creates and owns the parser.
119 // This should be an argument to the constructor. 101 // This should be an argument to the constructor.
120 std::unique_ptr<CommandParser> parser_; 102 std::unique_ptr<CommandParser> parser_;
121 103
122 // Whether the scheduler is currently able to process more commands. 104 // Whether the scheduler is currently able to process more commands.
123 bool scheduled_; 105 bool scheduled_;
124 106
107 PreemptionCallback preemption_callback_;
108
125 base::Closure command_processed_callback_; 109 base::Closure command_processed_callback_;
126 110
127 // If non-NULL and |preemption_flag_->IsSet()|, exit PutChanged early.
128 scoped_refptr<PreemptionFlag> preemption_flag_;
129 bool was_preempted_; 111 bool was_preempted_;
130 112
131 DISALLOW_COPY_AND_ASSIGN(CommandExecutor); 113 DISALLOW_COPY_AND_ASSIGN(CommandExecutor);
132 }; 114 };
133 115
134 } // namespace gpu 116 } // namespace gpu
135 117
136 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_EXECUTOR_H_ 118 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_EXECUTOR_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_buffer_service.cc ('k') | gpu/command_buffer/service/command_executor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698