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

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

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: jbauman's review Created 4 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
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // GL_BIND_GENERATES_RESOURCE_CHROMIUM state must be the same 255 // GL_BIND_GENERATES_RESOURCE_CHROMIUM state must be the same
256 // on Client & Service. 256 // on Client & Service.
257 if (capabilities_.bind_generates_resource_chromium != 257 if (capabilities_.bind_generates_resource_chromium !=
258 (share_group_->bind_generates_resource() ? 1 : 0)) { 258 (share_group_->bind_generates_resource() ? 1 : 0)) {
259 SetGLError(GL_INVALID_OPERATION, 259 SetGLError(GL_INVALID_OPERATION,
260 "Initialize", 260 "Initialize",
261 "Service bind_generates_resource mismatch."); 261 "Service bind_generates_resource mismatch.");
262 return false; 262 return false;
263 } 263 }
264 264
265 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
266 // Don't register a dump provider in these cases.
267 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
268 if (base::ThreadTaskRunnerHandle::IsSet()) {
269 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
270 this, "GLES2Implementation", base::ThreadTaskRunnerHandle::Get());
271 }
272
273 return true; 265 return true;
274 } 266 }
275 267
276 GLES2Implementation::~GLES2Implementation() { 268 GLES2Implementation::~GLES2Implementation() {
277 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
278 this);
279
280 // Make sure the queries are finished otherwise we'll delete the 269 // Make sure the queries are finished otherwise we'll delete the
281 // shared memory (mapped_memory_) which will free the memory used 270 // shared memory (mapped_memory_) which will free the memory used
282 // by the queries. The GPU process when validating that memory is still 271 // by the queries. The GPU process when validating that memory is still
283 // shared will fail and abort (ie, it will stop running). 272 // shared will fail and abort (ie, it will stop running).
284 WaitForCmd(); 273 WaitForCmd();
285 query_tracker_.reset(); 274 query_tracker_.reset();
286 275
287 // GLES2Implementation::Initialize() could fail before allocating 276 // GLES2Implementation::Initialize() could fail before allocating
288 // reserved_ids_, so we need delete them carefully. 277 // reserved_ids_, so we need delete them carefully.
289 if (support_client_side_arrays_ && reserved_ids_[0]) { 278 if (support_client_side_arrays_ && reserved_ids_[0]) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 intermediate_sync_token, 387 intermediate_sync_token,
399 base::Bind(&GLES2Implementation::RunIfContextNotLost, 388 base::Bind(&GLES2Implementation::RunIfContextNotLost,
400 weak_ptr_factory_.GetWeakPtr(), 389 weak_ptr_factory_.GetWeakPtr(),
401 callback)); 390 callback));
402 } else { 391 } else {
403 // Invalid sync token, just call the callback immediately. 392 // Invalid sync token, just call the callback immediately.
404 callback.Run(); 393 callback.Run();
405 } 394 }
406 } 395 }
407 396
397 // For some command buffer implementations this can be called from any thread.
398 // It's safe to access gpu_control_ without the lock because it is const.
399 bool GLES2Implementation::IsFenceSyncReleased(uint64_t release_count) {
400 return gpu_control_->IsFenceSyncReleased(release_count);
401 }
402
408 void GLES2Implementation::SignalQuery(uint32_t query, 403 void GLES2Implementation::SignalQuery(uint32_t query,
409 const base::Closure& callback) { 404 const base::Closure& callback) {
410 // Flush previously entered commands to ensure ordering with any 405 // Flush previously entered commands to ensure ordering with any
411 // glBeginQueryEXT() calls that may have been put into the context. 406 // glBeginQueryEXT() calls that may have been put into the context.
412 ShallowFlushCHROMIUM(); 407 ShallowFlushCHROMIUM();
413 gpu_control_->SignalQuery( 408 gpu_control_->SignalQuery(
414 query, 409 query,
415 base::Bind(&GLES2Implementation::RunIfContextNotLost, 410 base::Bind(&GLES2Implementation::RunIfContextNotLost,
416 weak_ptr_factory_.GetWeakPtr(), 411 weak_ptr_factory_.GetWeakPtr(),
417 callback)); 412 callback));
(...skipping 6612 matching lines...) Expand 10 before | Expand all | Expand 10 after
7030 cached_extensions_.clear(); 7025 cached_extensions_.clear();
7031 } 7026 }
7032 7027
7033 // Include the auto-generated part of this file. We split this because it means 7028 // Include the auto-generated part of this file. We split this because it means
7034 // we can easily edit the non-auto generated parts right here in this file 7029 // we can easily edit the non-auto generated parts right here in this file
7035 // instead of having to edit some template or the code generator. 7030 // instead of having to edit some template or the code generator.
7036 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 7031 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
7037 7032
7038 } // namespace gles2 7033 } // namespace gles2
7039 } // namespace gpu 7034 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gpu_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698