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

Side by Side Diff: gpu/command_buffer/client/share_group.h

Issue 2826043002: Do not share FBOs/VAOs/Transform feedback objects across contexts (Closed)
Patch Set: added DeleteFramebuffers() expectation Created 3 years, 7 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
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_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
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 using SharedIdNamespaces = id_namespaces::SharedIdNamespaces;
36
35 class ShareGroupContextData { 37 class ShareGroupContextData {
36 public: 38 public:
37 struct IdHandlerData { 39 struct IdHandlerData {
38 IdHandlerData(); 40 IdHandlerData();
39 ~IdHandlerData(); 41 ~IdHandlerData();
40 42
41 std::vector<GLuint> freed_ids_; 43 std::vector<GLuint> freed_ids_;
42 uint32_t flush_generation_; 44 uint32_t flush_generation_;
43 }; 45 };
44 46
45 IdHandlerData* id_handler_data(int namespace_id) { 47 IdHandlerData* id_handler_data(int namespace_id) {
46 return &id_handler_data_[namespace_id]; 48 return &id_handler_data_[namespace_id];
47 } 49 }
48 50
49 private: 51 private:
50 IdHandlerData id_handler_data_[id_namespaces::kNumIdNamespaces]; 52 IdHandlerData id_handler_data_[static_cast<int>(
53 SharedIdNamespaces::kNumSharedIdNamespaces)];
51 }; 54 };
52 55
53 // Base class for IdHandlers 56 // Base class for IdHandlers
54 class IdHandlerInterface { 57 class IdHandlerInterface {
55 public: 58 public:
56 IdHandlerInterface() { } 59 IdHandlerInterface() { }
57 virtual ~IdHandlerInterface() { } 60 virtual ~IdHandlerInterface() { }
58 61
59 // Makes some ids at or above id_offset. 62 // Makes some ids at or above id_offset.
60 virtual void MakeIds( 63 virtual void MakeIds(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // ShareGroup manages shared resources for contexts that are sharing resources. 120 // ShareGroup manages shared resources for contexts that are sharing resources.
118 class GLES2_IMPL_EXPORT ShareGroup 121 class GLES2_IMPL_EXPORT ShareGroup
119 : public gpu::RefCountedThreadSafe<ShareGroup> { 122 : public gpu::RefCountedThreadSafe<ShareGroup> {
120 public: 123 public:
121 ShareGroup(bool bind_generates_resource, uint64_t tracing_guid); 124 ShareGroup(bool bind_generates_resource, uint64_t tracing_guid);
122 125
123 bool bind_generates_resource() const { 126 bool bind_generates_resource() const {
124 return bind_generates_resource_; 127 return bind_generates_resource_;
125 } 128 }
126 129
127 IdHandlerInterface* GetIdHandler(int namespace_id) const { 130 IdHandlerInterface* GetIdHandler(SharedIdNamespaces namespace_id) const {
128 return id_handlers_[namespace_id].get(); 131 return id_handlers_[static_cast<int>(namespace_id)].get();
129 } 132 }
130 133
131 RangeIdHandlerInterface* GetRangeIdHandler(int range_namespace_id) const { 134 RangeIdHandlerInterface* GetRangeIdHandler(int range_namespace_id) const {
132 return range_id_handlers_[range_namespace_id].get(); 135 return range_id_handlers_[range_namespace_id].get();
133 } 136 }
134 137
135 ProgramInfoManager* program_info_manager() { 138 ProgramInfoManager* program_info_manager() {
136 return program_info_manager_.get(); 139 return program_info_manager_.get();
137 } 140 }
138 141
139 void FreeContext(GLES2Implementation* gl_impl) { 142 void FreeContext(GLES2Implementation* gl_impl) {
140 for (int i = 0; i < id_namespaces::kNumIdNamespaces; ++i) { 143 for (int i = 0;
144 i < static_cast<int>(SharedIdNamespaces::kNumSharedIdNamespaces);
145 ++i) {
141 id_handlers_[i]->FreeContext(gl_impl); 146 id_handlers_[i]->FreeContext(gl_impl);
142 } 147 }
143 for (auto& range_id_handler : range_id_handlers_) { 148 for (auto& range_id_handler : range_id_handlers_) {
144 range_id_handler->FreeContext(gl_impl); 149 range_id_handler->FreeContext(gl_impl);
145 } 150 }
146 } 151 }
147 152
148 uint64_t TracingGUID() const { return tracing_guid_; } 153 uint64_t TracingGUID() const { return tracing_guid_; }
149 154
150 // Mark the ShareGroup as lost when an error occurs on any context in the 155 // 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. 156 // group. This is thread safe as contexts may be on different threads.
152 void Lose(); 157 void Lose();
153 // Report if any context in the ShareGroup has reported itself lost. This is 158 // Report if any context in the ShareGroup has reported itself lost. This is
154 // thread safe as contexts may be on different threads. 159 // thread safe as contexts may be on different threads.
155 bool IsLost() const; 160 bool IsLost() const;
156 161
157 private: 162 private:
158 friend class gpu::RefCountedThreadSafe<ShareGroup>; 163 friend class gpu::RefCountedThreadSafe<ShareGroup>;
159 friend class gpu::gles2::GLES2ImplementationTest; 164 friend class gpu::gles2::GLES2ImplementationTest;
160 ~ShareGroup(); 165 ~ShareGroup();
161 166
162 // Install a new program info manager. Used for testing only; 167 // Install a new program info manager. Used for testing only;
163 void SetProgramInfoManagerForTesting(ProgramInfoManager* manager); 168 void SetProgramInfoManagerForTesting(ProgramInfoManager* manager);
164 169
165 std::unique_ptr<IdHandlerInterface> 170 std::unique_ptr<IdHandlerInterface> id_handlers_[static_cast<int>(
166 id_handlers_[id_namespaces::kNumIdNamespaces]; 171 SharedIdNamespaces::kNumSharedIdNamespaces)];
167 std::unique_ptr<RangeIdHandlerInterface> 172 std::unique_ptr<RangeIdHandlerInterface>
168 range_id_handlers_[id_namespaces::kNumRangeIdNamespaces]; 173 range_id_handlers_[id_namespaces::kNumRangeIdNamespaces];
169 std::unique_ptr<ProgramInfoManager> program_info_manager_; 174 std::unique_ptr<ProgramInfoManager> program_info_manager_;
170 175
171 bool bind_generates_resource_; 176 bool bind_generates_resource_;
172 uint64_t tracing_guid_; 177 uint64_t tracing_guid_;
173 178
174 mutable base::Lock lost_lock_; 179 mutable base::Lock lost_lock_;
175 bool lost_ = false; 180 bool lost_ = false;
176 181
177 DISALLOW_COPY_AND_ASSIGN(ShareGroup); 182 DISALLOW_COPY_AND_ASSIGN(ShareGroup);
178 }; 183 };
179 184
180 } // namespace gles2 185 } // namespace gles2
181 } // namespace gpu 186 } // namespace gpu
182 187
183 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_ 188 #endif // GPU_COMMAND_BUFFER_CLIENT_SHARE_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698