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

Side by Side Diff: mojo/services/gles2/command_buffer_impl.cc

Issue 745043002: Implement future sync points in gpu service (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/gles2/command_buffer_impl.h" 5 #include "mojo/services/gles2/command_buffer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "gpu/command_buffer/service/sync_point_manager.h" 9 #include "gpu/command_buffer/service/sync_point_manager.h"
10 #include "mojo/services/gles2/command_buffer_driver.h" 10 #include "mojo/services/gles2/command_buffer_driver.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace { 13 namespace {
14 void DestroyDriver(scoped_ptr<CommandBufferDriver> driver) { 14 void DestroyDriver(scoped_ptr<CommandBufferDriver> driver) {
15 // Just let ~scoped_ptr run. 15 // Just let ~scoped_ptr run.
16 } 16 }
17 17
18 void RunCallback(const Callback<void()>& callback) { 18 void RunCallback(const Callback<void()>& callback) {
19 callback.Run(); 19 callback.Run();
20 } 20 }
21
22 void RetireSyncPoint(scoped_refptr<gpu::SyncPointManager> sync_point_manager,
23 uint32_t sync_point) {
24 sync_point_manager->RetireSyncPoint(sync_point);
25 }
26 } 21 }
27 22
28 CommandBufferImpl::CommandBufferImpl( 23 CommandBufferImpl::CommandBufferImpl(
29 InterfaceRequest<CommandBuffer> request, 24 InterfaceRequest<CommandBuffer> request,
30 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner, 25 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner,
31 gpu::SyncPointManager* sync_point_manager, 26 gpu::SyncPointManager* sync_point_manager,
32 scoped_ptr<CommandBufferDriver> driver) 27 scoped_ptr<CommandBufferDriver> driver)
33 : sync_point_manager_(sync_point_manager), 28 : sync_point_manager_(sync_point_manager),
34 driver_task_runner_(base::MessageLoop::current()->task_runner()), 29 driver_task_runner_(base::MessageLoop::current()->task_runner()),
35 driver_(driver.Pass()), 30 driver_(driver.Pass()),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 base::Unretained(driver_.get()), id, 84 base::Unretained(driver_.get()), id,
90 base::Passed(&transfer_buffer), size)); 85 base::Passed(&transfer_buffer), size));
91 } 86 }
92 87
93 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) { 88 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) {
94 driver_task_runner_->PostTask( 89 driver_task_runner_->PostTask(
95 FROM_HERE, base::Bind(&CommandBufferDriver::DestroyTransferBuffer, 90 FROM_HERE, base::Bind(&CommandBufferDriver::DestroyTransferBuffer,
96 base::Unretained(driver_.get()), id)); 91 base::Unretained(driver_.get()), id));
97 } 92 }
98 93
99 void CommandBufferImpl::InsertSyncPoint() { 94 void CommandBufferImpl::InsertSyncPoint(bool retire) {
100 uint32_t sync_point = sync_point_manager_->GenerateSyncPoint(); 95 uint32_t sync_point = sync_point_manager_->GenerateSyncPoint();
101 sync_point_client_->DidInsertSyncPoint(sync_point); 96 sync_point_client_->DidInsertSyncPoint(sync_point);
97 if (retire) {
98 driver_task_runner_->PostTask(
99 FROM_HERE, base::Bind(&gpu::SyncPointManager::RetireSyncPoint,
100 sync_point_manager_, sync_point));
101 }
102 }
103
104 void CommandBufferImpl::RetireSyncPoint(uint32_t sync_point) {
102 driver_task_runner_->PostTask( 105 driver_task_runner_->PostTask(
103 FROM_HERE, base::Bind(&RetireSyncPoint, sync_point_manager_, sync_point)); 106 FROM_HERE, base::Bind(&gpu::SyncPointManager::RetireSyncPoint,
107 sync_point_manager_, sync_point));
104 } 108 }
105 109
106 void CommandBufferImpl::Echo(const Callback<void()>& callback) { 110 void CommandBufferImpl::Echo(const Callback<void()>& callback) {
107 driver_task_runner_->PostTaskAndReply(FROM_HERE, base::Bind(&base::DoNothing), 111 driver_task_runner_->PostTaskAndReply(FROM_HERE, base::Bind(&base::DoNothing),
108 base::Bind(&RunCallback, callback)); 112 base::Bind(&RunCallback, callback));
109 } 113 }
110 114
111 void CommandBufferImpl::BindToRequest(InterfaceRequest<CommandBuffer> request) { 115 void CommandBufferImpl::BindToRequest(InterfaceRequest<CommandBuffer> request) {
112 binding_.Bind(request.Pass()); 116 binding_.Bind(request.Pass());
113 } 117 }
114 118
115 void CommandBufferImpl::OnContextLost(int32_t reason) { 119 void CommandBufferImpl::OnContextLost(int32_t reason) {
116 binding_.client()->LostContext(reason); 120 binding_.client()->LostContext(reason);
117 } 121 }
118 122
119 } // namespace mojo 123 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/gles2/command_buffer_impl.h ('k') | mojo/services/public/interfaces/gpu/command_buffer.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698