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

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 a review issue 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 {
151 #ifndef NDEBUG 157 #ifndef NDEBUG
152 if (id != 0) { 158 if (id != 0) {
153 base::AutoLock auto_lock(lock_); 159 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 // 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
165 // to call |bind_fn| without holding the lock.
166 (gl_impl->*bind_fn)(target, id);
157 return true; 167 return true;
158 } 168 }
159 169
160 // Overridden from IdHandlerInterface. 170 // Overridden from IdHandlerInterface.
161 void FreeContext(GLES2Implementation* gl_impl) override { 171 void FreeContext(GLES2Implementation* gl_impl) override {
162 base::AutoLock auto_lock(lock_); 172 base::AutoLock auto_lock(lock_);
163 CollectPendingFreeIds(gl_impl); 173 CollectPendingFreeIds(gl_impl);
164 } 174 }
165 175
166 private: 176 private:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 bool FreeIds(GLES2Implementation* gl_impl, 221 bool FreeIds(GLES2Implementation* gl_impl,
212 GLsizei n, 222 GLsizei n,
213 const GLuint* ids, 223 const GLuint* ids,
214 DeleteFn delete_fn) override { 224 DeleteFn delete_fn) override {
215 // Ids are never freed. 225 // Ids are never freed.
216 (gl_impl->*delete_fn)(n, ids); 226 (gl_impl->*delete_fn)(n, ids);
217 return true; 227 return true;
218 } 228 }
219 229
220 // Overridden from IdHandlerInterface. 230 // Overridden from IdHandlerInterface.
221 bool MarkAsUsedForBind(GLuint /* id */) override { 231 bool MarkAsUsedForBind(GLES2Implementation* /* gl_impl */,
232 GLenum /* target */,
233 GLuint /* id */,
234 BindFn /* bind_fn */) override {
222 // This is only used for Shaders and Programs which have no bind. 235 // This is only used for Shaders and Programs which have no bind.
223 return false; 236 return false;
224 } 237 }
225 238
226 void FreeContext(GLES2Implementation* gl_impl) override {} 239 void FreeContext(GLES2Implementation* gl_impl) override {}
227 240
228 private: 241 private:
229 base::Lock lock_; 242 base::Lock lock_;
230 GLuint last_id_; 243 GLuint last_id_;
231 }; 244 };
(...skipping 21 matching lines...) Expand all
253 } 266 }
254 267
255 void ShareGroup::set_program_info_manager(ProgramInfoManager* manager) { 268 void ShareGroup::set_program_info_manager(ProgramInfoManager* manager) {
256 program_info_manager_.reset(manager); 269 program_info_manager_.reset(manager);
257 } 270 }
258 271
259 ShareGroup::~ShareGroup() {} 272 ShareGroup::~ShareGroup() {}
260 273
261 } // namespace gles2 274 } // namespace gles2
262 } // namespace gpu 275 } // 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