OLD | NEW |
---|---|
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_CLIENT_SHARE_GROUP_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ |
7 | 7 |
8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 typedef void (GLES2Implementation::*DeleteFn)(GLsizei n, const GLuint* ids); | 26 typedef void (GLES2Implementation::*DeleteFn)(GLsizei n, const GLuint* ids); |
27 typedef void (GLES2Implementation::*DeleteRangeFn)(const GLuint first_id, | 27 typedef void (GLES2Implementation::*DeleteRangeFn)(const GLuint first_id, |
28 GLsizei range); | 28 GLsizei range); |
29 typedef void (GLES2Implementation::*BindFn)(GLenum target, GLuint id); | 29 typedef void (GLES2Implementation::*BindFn)(GLenum target, GLuint id); |
30 typedef void (GLES2Implementation::*BindIndexedFn)( \ | 30 typedef void (GLES2Implementation::*BindIndexedFn)( \ |
31 GLenum target, GLuint index, GLuint id); | 31 GLenum target, GLuint index, GLuint id); |
32 typedef void (GLES2Implementation::*BindIndexedRangeFn)( \ | 32 typedef void (GLES2Implementation::*BindIndexedRangeFn)( \ |
33 GLenum target, GLuint index, GLuint id, GLintptr offset, GLsizeiptr size); | 33 GLenum target, GLuint index, GLuint id, GLintptr offset, GLsizeiptr size); |
34 | 34 |
35 template <typename Type> | |
36 inline int ToInt(Type t) { | |
Zhenyao Mo
2017/05/11 22:10:57
You don't need this. See my comments in other pla
Chandan
2017/05/12 12:30:31
Done.
| |
37 return static_cast<int>(t); | |
38 } | |
39 | |
40 using SharedIdNamespaces = id_namespaces::SharedIdNamespaces; | |
41 | |
35 class ShareGroupContextData { | 42 class ShareGroupContextData { |
36 public: | 43 public: |
37 struct IdHandlerData { | 44 struct IdHandlerData { |
38 IdHandlerData(); | 45 IdHandlerData(); |
39 ~IdHandlerData(); | 46 ~IdHandlerData(); |
40 | 47 |
41 std::vector<GLuint> freed_ids_; | 48 std::vector<GLuint> freed_ids_; |
42 uint32_t flush_generation_; | 49 uint32_t flush_generation_; |
43 }; | 50 }; |
44 | 51 |
45 IdHandlerData* id_handler_data(int namespace_id) { | 52 IdHandlerData* id_handler_data(int namespace_id) { |
46 return &id_handler_data_[namespace_id]; | 53 return &id_handler_data_[namespace_id]; |
47 } | 54 } |
48 | 55 |
49 private: | 56 private: |
50 IdHandlerData id_handler_data_[id_namespaces::kNumIdNamespaces]; | 57 IdHandlerData id_handler_data_[static_cast<int>( |
58 SharedIdNamespaces::kNumSharedIdNamespaces)]; | |
51 }; | 59 }; |
52 | 60 |
53 // Base class for IdHandlers | 61 // Base class for IdHandlers |
54 class IdHandlerInterface { | 62 class IdHandlerInterface { |
55 public: | 63 public: |
56 IdHandlerInterface() { } | 64 IdHandlerInterface() { } |
57 virtual ~IdHandlerInterface() { } | 65 virtual ~IdHandlerInterface() { } |
58 | 66 |
59 // Makes some ids at or above id_offset. | 67 // Makes some ids at or above id_offset. |
60 virtual void MakeIds( | 68 virtual void MakeIds( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 | 138 |
131 RangeIdHandlerInterface* GetRangeIdHandler(int range_namespace_id) const { | 139 RangeIdHandlerInterface* GetRangeIdHandler(int range_namespace_id) const { |
132 return range_id_handlers_[range_namespace_id].get(); | 140 return range_id_handlers_[range_namespace_id].get(); |
133 } | 141 } |
134 | 142 |
135 ProgramInfoManager* program_info_manager() { | 143 ProgramInfoManager* program_info_manager() { |
136 return program_info_manager_.get(); | 144 return program_info_manager_.get(); |
137 } | 145 } |
138 | 146 |
139 void FreeContext(GLES2Implementation* gl_impl) { | 147 void FreeContext(GLES2Implementation* gl_impl) { |
140 for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) { | 148 for (int i = 0; i < ToInt(SharedIdNamespaces::kNumSharedIdNamespaces); |
149 ++i) { | |
141 id_handlers_[i]->FreeContext(gl_impl); | 150 id_handlers_[i]->FreeContext(gl_impl); |
142 } | 151 } |
143 for (auto& range_id_handler : range_id_handlers_) { | 152 for (auto& range_id_handler : range_id_handlers_) { |
144 range_id_handler->FreeContext(gl_impl); | 153 range_id_handler->FreeContext(gl_impl); |
145 } | 154 } |
146 } | 155 } |
147 | 156 |
148 uint64_t TracingGUID() const { return tracing_guid_; } | 157 uint64_t TracingGUID() const { return tracing_guid_; } |
149 | 158 |
150 // Mark the ShareGroup as lost when an error occurs on any context in the | 159 // Mark the ShareGroup as lost when an error occurs on any context in the |
151 // group. This is thread safe as contexts may be on different threads. | 160 // group. This is thread safe as contexts may be on different threads. |
152 void Lose(); | 161 void Lose(); |
153 // Report if any context in the ShareGroup has reported itself lost. This is | 162 // Report if any context in the ShareGroup has reported itself lost. This is |
154 // thread safe as contexts may be on different threads. | 163 // thread safe as contexts may be on different threads. |
155 bool IsLost() const; | 164 bool IsLost() const; |
156 | 165 |
157 private: | 166 private: |
158 friend class gpu::RefCountedThreadSafe<ShareGroup>; | 167 friend class gpu::RefCountedThreadSafe<ShareGroup>; |
159 friend class gpu::gles2::GLES2ImplementationTest; | 168 friend class gpu::gles2::GLES2ImplementationTest; |
160 ~ShareGroup(); | 169 ~ShareGroup(); |
161 | 170 |
162 // Install a new program info manager. Used for testing only; | 171 // Install a new program info manager. Used for testing only; |
163 void SetProgramInfoManagerForTesting(ProgramInfoManager* manager); | 172 void SetProgramInfoManagerForTesting(ProgramInfoManager* manager); |
164 | 173 |
165 std::unique_ptr<IdHandlerInterface> | 174 std::unique_ptr<IdHandlerInterface> id_handlers_[static_cast<int>( |
166 id_handlers_[id_namespaces::kNumIdNamespaces]; | 175 SharedIdNamespaces::kNumSharedIdNamespaces)]; |
167 std::unique_ptr<RangeIdHandlerInterface> | 176 std::unique_ptr<RangeIdHandlerInterface> |
168 range_id_handlers_[id_namespaces::kNumRangeIdNamespaces]; | 177 range_id_handlers_[id_namespaces::kNumRangeIdNamespaces]; |
169 std::unique_ptr<ProgramInfoManager> program_info_manager_; | 178 std::unique_ptr<ProgramInfoManager> program_info_manager_; |
170 | 179 |
171 bool bind_generates_resource_; | 180 bool bind_generates_resource_; |
172 uint64_t tracing_guid_; | 181 uint64_t tracing_guid_; |
173 | 182 |
174 mutable base::Lock lost_lock_; | 183 mutable base::Lock lost_lock_; |
175 bool lost_ = false; | 184 bool lost_ = false; |
176 | 185 |
177 DISALLOW_COPY_AND_ASSIGN(ShareGroup); | 186 DISALLOW_COPY_AND_ASSIGN(ShareGroup); |
178 }; | 187 }; |
179 | 188 |
180 } // namespace gles2 | 189 } // namespace gles2 |
181 } // namespace gpu | 190 } // namespace gpu |
182 | 191 |
183 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ | 192 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ |
OLD | NEW |