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

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

Issue 763383002: GPU: Flush in glBind* to avoid being executed after future glDelete* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review issues Created 6 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
« no previous file with comments | « gpu/command_buffer/client/share_group.h ('k') | no next file » | 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 (gl_impl->*delete_fn)(n, ids); 60 (gl_impl->*delete_fn)(n, ids);
61 // We need to ensure that the delete call is evaluated on the service side 61 // We need to ensure that the delete call is evaluated on the service side
62 // before any other contexts issue commands using these client ids. 62 // before any other contexts issue commands using these client ids.
63 // TODO(vmiura): Can remove this by virtualizing internal ids, however 63 // TODO(vmiura): Can remove this by virtualizing internal ids, however
64 // this code only affects PPAPI for now. 64 // this code only affects PPAPI for now.
65 gl_impl->helper()->CommandBufferHelper::Flush(); 65 gl_impl->helper()->CommandBufferHelper::Flush();
66 return true; 66 return true;
67 } 67 }
68 68
69 // Overridden from IdHandlerInterface. 69 // Overridden from IdHandlerInterface.
70 bool MarkAsUsedForBind(GLuint id) override { 70 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
71 if (id == 0) 71 GLenum target,
72 return true; 72 GLuint id,
73 BindFn bind_fn) override {
73 base::AutoLock auto_lock(lock_); 74 base::AutoLock auto_lock(lock_);
74 return id_allocator_.MarkAsUsed(id); 75 bool result = id ? id_allocator_.MarkAsUsed(id) : true;
76 (gl_impl->*bind_fn)(target, id);
77 return result;
75 } 78 }
76 79
77 void FreeContext(GLES2Implementation* gl_impl) override {} 80 void FreeContext(GLES2Implementation* gl_impl) override {}
78 81
79 private: 82 private:
80 base::Lock lock_; 83 base::Lock lock_;
81 IdAllocator id_allocator_; 84 IdAllocator id_allocator_;
82 }; 85 };
83 86
84 // An id handler that requires Gen before Bind. 87 // An id handler that requires Gen before Bind.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 id_states_[id - 1] = kIdPendingFree; 143 id_states_[id - 1] = kIdPendingFree;
141 ctxt_data->freed_ids_.push_back(id); 144 ctxt_data->freed_ids_.push_back(id);
142 } 145 }
143 } 146 }
144 } 147 }
145 148
146 return true; 149 return true;
147 } 150 }
148 151
149 // Overridden from IdHandler. 152 // Overridden from IdHandler.
150 bool MarkAsUsedForBind(GLuint id) override { 153 bool MarkAsUsedForBind(GLES2Implementation* gl_impl,
154 GLenum target,
155 GLuint id,
156 BindFn bind_fn) override {
157 base::AutoLock auto_lock(lock_);
piman 2014/12/05 20:31:13 You don't need to take the lock in the release pat
Peng 2014/12/05 21:04:39 Done.
151 #ifndef NDEBUG 158 #ifndef NDEBUG
152 if (id != 0) { 159 if (id != 0) {
153 base::AutoLock auto_lock(lock_);
154 DCHECK(id_states_[id - 1] == kIdInUse); 160 DCHECK(id_states_[id - 1] == kIdInUse);
155 } 161 }
156 #endif 162 #endif
163 (gl_impl->*bind_fn)(target, id);
157 return true; 164 return true;
158 } 165 }
159 166
160 // Overridden from IdHandlerInterface. 167 // Overridden from IdHandlerInterface.
161 void FreeContext(GLES2Implementation* gl_impl) override { 168 void FreeContext(GLES2Implementation* gl_impl) override {
162 base::AutoLock auto_lock(lock_); 169 base::AutoLock auto_lock(lock_);
163 CollectPendingFreeIds(gl_impl); 170 CollectPendingFreeIds(gl_impl);
164 } 171 }
165 172
166 private: 173 private:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 bool FreeIds(GLES2Implementation* gl_impl, 218 bool FreeIds(GLES2Implementation* gl_impl,
212 GLsizei n, 219 GLsizei n,
213 const GLuint* ids, 220 const GLuint* ids,
214 DeleteFn delete_fn) override { 221 DeleteFn delete_fn) override {
215 // Ids are never freed. 222 // Ids are never freed.
216 (gl_impl->*delete_fn)(n, ids); 223 (gl_impl->*delete_fn)(n, ids);
217 return true; 224 return true;
218 } 225 }
219 226
220 // Overridden from IdHandlerInterface. 227 // Overridden from IdHandlerInterface.
221 bool MarkAsUsedForBind(GLuint /* id */) override { 228 bool MarkAsUsedForBind(GLES2Implementation* /* gl_impl */,
229 GLenum /* target */,
230 GLuint /* id */,
231 BindFn /* bind_fn */) override {
222 // This is only used for Shaders and Programs which have no bind. 232 // This is only used for Shaders and Programs which have no bind.
223 return false; 233 return false;
224 } 234 }
225 235
226 void FreeContext(GLES2Implementation* gl_impl) override {} 236 void FreeContext(GLES2Implementation* gl_impl) override {}
227 237
228 private: 238 private:
229 base::Lock lock_; 239 base::Lock lock_;
230 GLuint last_id_; 240 GLuint last_id_;
231 }; 241 };
(...skipping 21 matching lines...) Expand all
253 } 263 }
254 264
255 void ShareGroup::set_program_info_manager(ProgramInfoManager* manager) { 265 void ShareGroup::set_program_info_manager(ProgramInfoManager* manager) {
256 program_info_manager_.reset(manager); 266 program_info_manager_.reset(manager);
257 } 267 }
258 268
259 ShareGroup::~ShareGroup() {} 269 ShareGroup::~ShareGroup() {}
260 270
261 } // namespace gles2 271 } // namespace gles2
262 } // namespace gpu 272 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/share_group.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698