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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 2722883002: gpu: Allow waiting on sync tokens without sync token client. (Closed)
Patch Set: review Created 3 years, 9 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/tests/gl_manager.h ('k') | gpu/ipc/in_process_command_buffer.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 "gpu/command_buffer/tests/gl_manager.h" 5 #include "gpu/command_buffer/tests/gl_manager.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 }; 178 };
179 #endif // defined(OS_MACOSX) 179 #endif // defined(OS_MACOSX)
180 180
181 } // namespace 181 } // namespace
182 182
183 int GLManager::use_count_; 183 int GLManager::use_count_;
184 scoped_refptr<gl::GLShareGroup>* GLManager::base_share_group_; 184 scoped_refptr<gl::GLShareGroup>* GLManager::base_share_group_;
185 scoped_refptr<gl::GLSurface>* GLManager::base_surface_; 185 scoped_refptr<gl::GLSurface>* GLManager::base_surface_;
186 scoped_refptr<gl::GLContext>* GLManager::base_context_; 186 scoped_refptr<gl::GLContext>* GLManager::base_context_;
187 187
188 GLManager::Options::Options() 188 GLManager::Options::Options() = default;
189 : size(4, 4),
190 sync_point_manager(NULL),
191 share_group_manager(NULL),
192 share_mailbox_manager(NULL),
193 virtual_manager(NULL),
194 bind_generates_resource(false),
195 lose_context_when_out_of_memory(false),
196 context_lost_allowed(false),
197 context_type(gles2::CONTEXT_TYPE_OPENGLES2),
198 force_shader_name_hashing(false),
199 multisampled(false),
200 backbuffer_alpha(true),
201 image_factory(nullptr),
202 preserve_backbuffer(false) {}
203 189
204 GLManager::GLManager() 190 GLManager::GLManager()
205 : sync_point_manager_(nullptr), 191 : command_buffer_id_(
206 context_lost_allowed_(false), 192 CommandBufferId::FromUnsafeValue(g_next_command_buffer_id++)) {
207 pause_commands_(false),
208 paused_order_num_(0),
209 command_buffer_id_(
210 CommandBufferId::FromUnsafeValue(g_next_command_buffer_id++)),
211 next_fence_sync_release_(1) {
212 SetupBaseContext(); 193 SetupBaseContext();
213 } 194 }
214 195
215 GLManager::~GLManager() { 196 GLManager::~GLManager() {
216 --use_count_; 197 --use_count_;
217 if (!use_count_) { 198 if (!use_count_) {
218 if (base_share_group_) { 199 if (base_share_group_) {
219 delete base_context_; 200 delete base_context_;
220 base_context_ = NULL; 201 base_context_ = NULL;
221 } 202 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); 343 ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
363 344
364 if (!decoder_->Initialize(surface_.get(), context_.get(), true, 345 if (!decoder_->Initialize(surface_.get(), context_.get(), true,
365 ::gpu::gles2::DisallowedFeatures(), attribs)) { 346 ::gpu::gles2::DisallowedFeatures(), attribs)) {
366 return; 347 return;
367 } 348 }
368 349
369 if (options.sync_point_manager) { 350 if (options.sync_point_manager) {
370 sync_point_manager_ = options.sync_point_manager; 351 sync_point_manager_ = options.sync_point_manager;
371 sync_point_order_data_ = SyncPointOrderData::Create(); 352 sync_point_order_data_ = SyncPointOrderData::Create();
372 sync_point_client_ = sync_point_manager_->CreateSyncPointClient( 353 sync_point_client_ = base::MakeUnique<SyncPointClient>(
373 sync_point_order_data_, GetNamespaceID(), GetCommandBufferID()); 354 sync_point_manager_, sync_point_order_data_, GetNamespaceID(),
355 GetCommandBufferID());
374 356
375 decoder_->SetFenceSyncReleaseCallback( 357 decoder_->SetFenceSyncReleaseCallback(
376 base::Bind(&GLManager::OnFenceSyncRelease, base::Unretained(this))); 358 base::Bind(&GLManager::OnFenceSyncRelease, base::Unretained(this)));
377 decoder_->SetWaitFenceSyncCallback( 359 decoder_->SetWaitSyncTokenCallback(
378 base::Bind(&GLManager::OnWaitFenceSync, base::Unretained(this))); 360 base::Bind(&GLManager::OnWaitSyncToken, base::Unretained(this)));
379 } else { 361 } else {
380 sync_point_manager_ = nullptr; 362 sync_point_manager_ = nullptr;
381 sync_point_order_data_ = nullptr; 363 sync_point_order_data_ = nullptr;
382 sync_point_client_ = nullptr; 364 sync_point_client_ = nullptr;
383 } 365 }
384 366
385 command_buffer_->SetPutOffsetChangeCallback( 367 command_buffer_->SetPutOffsetChangeCallback(
386 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); 368 base::Bind(&GLManager::PumpCommands, base::Unretained(this)));
387 command_buffer_->SetGetBufferChangeCallback( 369 command_buffer_->SetGetBufferChangeCallback(
388 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); 370 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this)));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 base_context_ = new scoped_refptr<gl::GLContext>(gl::init::CreateGLContext( 403 base_context_ = new scoped_refptr<gl::GLContext>(gl::init::CreateGLContext(
422 base_share_group_->get(), base_surface_->get(), 404 base_share_group_->get(), base_surface_->get(),
423 gl::GLContextAttribs())); 405 gl::GLContextAttribs()));
424 #endif 406 #endif
425 } 407 }
426 ++use_count_; 408 ++use_count_;
427 } 409 }
428 410
429 void GLManager::OnFenceSyncRelease(uint64_t release) { 411 void GLManager::OnFenceSyncRelease(uint64_t release) {
430 DCHECK(sync_point_client_); 412 DCHECK(sync_point_client_);
431 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release));
432 command_buffer_->SetReleaseCount(release); 413 command_buffer_->SetReleaseCount(release);
433 sync_point_client_->ReleaseFenceSync(release); 414 sync_point_client_->ReleaseFenceSync(release);
434 } 415 }
435 416
436 bool GLManager::OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, 417 bool GLManager::OnWaitSyncToken(const SyncToken& sync_token) {
437 gpu::CommandBufferId command_buffer_id, 418 DCHECK(sync_point_manager_);
438 uint64_t release) {
439 DCHECK(sync_point_client_);
440 scoped_refptr<gpu::SyncPointClientState> release_state =
441 sync_point_manager_->GetSyncPointClientState(namespace_id,
442 command_buffer_id);
443 if (!release_state)
444 return true;
445
446 // GLManager does not support being multithreaded at this point, so the fence 419 // GLManager does not support being multithreaded at this point, so the fence
447 // sync must be released by the time wait is called. 420 // sync must be released by the time wait is called.
448 DCHECK(release_state->IsFenceSyncReleased(release)); 421 DCHECK(sync_point_manager_->IsSyncTokenReleased(sync_token));
449 return true; 422 return false;
450 } 423 }
451 424
452 void GLManager::MakeCurrent() { 425 void GLManager::MakeCurrent() {
453 ::gles2::SetGLContext(gles2_implementation_.get()); 426 ::gles2::SetGLContext(gles2_implementation_.get());
454 } 427 }
455 428
456 void GLManager::SetSurface(gl::GLSurface* surface) { 429 void GLManager::SetSurface(gl::GLSurface* surface) {
457 decoder_->SetSurface(surface); 430 decoder_->SetSurface(surface);
458 } 431 }
459 432
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 return IsFenceSyncRelease(release); 602 return IsFenceSyncRelease(release);
630 } 603 }
631 604
632 bool GLManager::IsFenceSyncReleased(uint64_t release) { 605 bool GLManager::IsFenceSyncReleased(uint64_t release) {
633 return release <= command_buffer_->GetLastState().release_count; 606 return release <= command_buffer_->GetLastState().release_count;
634 } 607 }
635 608
636 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token, 609 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token,
637 const base::Closure& callback) { 610 const base::Closure& callback) {
638 if (sync_point_manager_) { 611 if (sync_point_manager_) {
639 scoped_refptr<gpu::SyncPointClientState> release_state = 612 DCHECK(!paused_order_num_);
640 sync_point_manager_->GetSyncPointClientState( 613 uint32_t order_num = sync_point_order_data_->GenerateUnprocessedOrderNumber(
641 sync_token.namespace_id(), sync_token.command_buffer_id()); 614 sync_point_manager_);
642 615 sync_point_order_data_->BeginProcessingOrderNumber(order_num);
643 if (release_state) { 616 if (!sync_point_client_->Wait(sync_token, callback))
644 sync_point_client_->WaitOutOfOrder(release_state.get(), 617 callback.Run();
645 sync_token.release_count(), callback); 618 sync_point_order_data_->FinishProcessingOrderNumber(order_num);
646 return; 619 } else {
647 } 620 callback.Run();
648 } 621 }
649
650 // Something went wrong, just run the callback now.
651 callback.Run();
652 } 622 }
653 623
654 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 624 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
655 return false; 625 return false;
656 } 626 }
657 627
658 } // namespace gpu 628 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/ipc/in_process_command_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698