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

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

Issue 846943002: Improve BindBufferBase/BindBufferRange and a few other commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « gpu/command_buffer/client/share_group.h ('k') | gpu/command_buffer/service/context_group.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <stack> 5 #include <stack>
6 #include <vector> 6 #include <vector>
7 7
8 #include "gpu/command_buffer/client/share_group.h" 8 #include "gpu/command_buffer/client/share_group.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Overridden from IdHandlerInterface. 69 // Overridden from IdHandlerInterface.
70 bool MarkAsUsedForBind(GLES2Implementation* gl_impl, 70 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
71 GLenum target, 71 GLenum target,
72 GLuint id, 72 GLuint id,
73 BindFn bind_fn) override { 73 BindFn bind_fn) override {
74 base::AutoLock auto_lock(lock_); 74 base::AutoLock auto_lock(lock_);
75 bool result = id ? id_allocator_.MarkAsUsed(id) : true; 75 bool result = id ? id_allocator_.MarkAsUsed(id) : true;
76 (gl_impl->*bind_fn)(target, id); 76 (gl_impl->*bind_fn)(target, id);
77 return result; 77 return result;
78 } 78 }
79 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
80 GLenum target,
81 GLuint index,
82 GLuint id,
83 BindIndexedFn bind_fn) override {
84 base::AutoLock auto_lock(lock_);
85 bool result = id ? id_allocator_.MarkAsUsed(id) : true;
86 (gl_impl->*bind_fn)(target, index, id);
87 return result;
88 }
89 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
90 GLenum target,
91 GLuint index,
92 GLuint id,
93 GLintptr offset,
94 GLsizeiptr size,
95 BindIndexedRangeFn bind_fn) override {
96 base::AutoLock auto_lock(lock_);
97 bool result = id ? id_allocator_.MarkAsUsed(id) : true;
98 (gl_impl->*bind_fn)(target, index, id, offset, size);
99 return result;
100 }
79 101
80 void FreeContext(GLES2Implementation* gl_impl) override {} 102 void FreeContext(GLES2Implementation* gl_impl) override {}
81 103
82 private: 104 private:
83 base::Lock lock_; 105 base::Lock lock_;
84 IdAllocator id_allocator_; 106 IdAllocator id_allocator_;
85 }; 107 };
86 108
87 // An id handler that requires Gen before Bind. 109 // An id handler that requires Gen before Bind.
88 class StrictIdHandler : public IdHandlerInterface { 110 class StrictIdHandler : public IdHandlerInterface {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 base::AutoLock auto_lock(lock_); 181 base::AutoLock auto_lock(lock_);
160 DCHECK(id_states_[id - 1] == kIdInUse); 182 DCHECK(id_states_[id - 1] == kIdInUse);
161 } 183 }
162 #endif 184 #endif
163 // StrictIdHandler is used if |bind_generates_resource| is false. In that 185 // StrictIdHandler is used if |bind_generates_resource| is false. In that
164 // case, |bind_fn| will not use Flush() after helper->Bind*(), so it is OK 186 // case, |bind_fn| will not use Flush() after helper->Bind*(), so it is OK
165 // to call |bind_fn| without holding the lock. 187 // to call |bind_fn| without holding the lock.
166 (gl_impl->*bind_fn)(target, id); 188 (gl_impl->*bind_fn)(target, id);
167 return true; 189 return true;
168 } 190 }
191 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
192 GLenum target,
193 GLuint index,
194 GLuint id,
195 BindIndexedFn bind_fn) override {
196 #ifndef NDEBUG
197 if (id != 0) {
198 base::AutoLock auto_lock(lock_);
199 DCHECK(id_states_[id - 1] == kIdInUse);
200 }
201 #endif
202 // StrictIdHandler is used if |bind_generates_resource| is false. In that
203 // case, |bind_fn| will not use Flush() after helper->Bind*(), so it is OK
204 // to call |bind_fn| without holding the lock.
205 (gl_impl->*bind_fn)(target, index, id);
206 return true;
207 }
208 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
209 GLenum target,
210 GLuint index,
211 GLuint id,
212 GLintptr offset,
213 GLsizeiptr size,
214 BindIndexedRangeFn bind_fn) override {
215 #ifndef NDEBUG
216 if (id != 0) {
217 base::AutoLock auto_lock(lock_);
218 DCHECK(id_states_[id - 1] == kIdInUse);
219 }
220 #endif
221 // StrictIdHandler is used if |bind_generates_resource| is false. In that
222 // case, |bind_fn| will not use Flush() after helper->Bind*(), so it is OK
223 // to call |bind_fn| without holding the lock.
224 (gl_impl->*bind_fn)(target, index, id, offset, size);
225 return true;
226 }
169 227
170 // Overridden from IdHandlerInterface. 228 // Overridden from IdHandlerInterface.
171 void FreeContext(GLES2Implementation* gl_impl) override { 229 void FreeContext(GLES2Implementation* gl_impl) override {
172 base::AutoLock auto_lock(lock_); 230 base::AutoLock auto_lock(lock_);
173 CollectPendingFreeIds(gl_impl); 231 CollectPendingFreeIds(gl_impl);
174 } 232 }
175 233
176 private: 234 private:
177 enum IdState { kIdFree, kIdPendingFree, kIdInUse }; 235 enum IdState { kIdFree, kIdPendingFree, kIdInUse };
178 236
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 286 }
229 287
230 // Overridden from IdHandlerInterface. 288 // Overridden from IdHandlerInterface.
231 bool MarkAsUsedForBind(GLES2Implementation* /* gl_impl */, 289 bool MarkAsUsedForBind(GLES2Implementation* /* gl_impl */,
232 GLenum /* target */, 290 GLenum /* target */,
233 GLuint /* id */, 291 GLuint /* id */,
234 BindFn /* bind_fn */) override { 292 BindFn /* bind_fn */) override {
235 // This is only used for Shaders and Programs which have no bind. 293 // This is only used for Shaders and Programs which have no bind.
236 return false; 294 return false;
237 } 295 }
296 bool MarkAsUsedForBind(GLES2Implementation* /* gl_impl */,
297 GLenum /* target */,
298 GLuint /* index */,
299 GLuint /* id */,
300 BindIndexedFn /* bind_fn */) override {
301 // This is only used for Shaders and Programs which have no bind.
302 return false;
303 }
304 bool MarkAsUsedForBind(GLES2Implementation* /* gl_impl */,
305 GLenum /* target */,
306 GLuint /* index */,
307 GLuint /* id */,
308 GLintptr /* offset */,
309 GLsizeiptr /* size */,
310 BindIndexedRangeFn /* bind_fn */) override {
311 // This is only used for Shaders and Programs which have no bind.
312 return false;
313 }
238 314
239 void FreeContext(GLES2Implementation* gl_impl) override {} 315 void FreeContext(GLES2Implementation* gl_impl) override {}
240 316
241 private: 317 private:
242 base::Lock lock_; 318 base::Lock lock_;
243 GLuint last_id_; 319 GLuint last_id_;
244 }; 320 };
245 321
246 ShareGroup::ShareGroup(bool bind_generates_resource) 322 ShareGroup::ShareGroup(bool bind_generates_resource)
247 : bind_generates_resource_(bind_generates_resource) { 323 : bind_generates_resource_(bind_generates_resource) {
(...skipping 18 matching lines...) Expand all
266 } 342 }
267 343
268 void ShareGroup::set_program_info_manager(ProgramInfoManager* manager) { 344 void ShareGroup::set_program_info_manager(ProgramInfoManager* manager) {
269 program_info_manager_.reset(manager); 345 program_info_manager_.reset(manager);
270 } 346 }
271 347
272 ShareGroup::~ShareGroup() {} 348 ShareGroup::~ShareGroup() {}
273 349
274 } // namespace gles2 350 } // namespace gles2
275 } // namespace gpu 351 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/share_group.h ('k') | gpu/command_buffer/service/context_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698