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

Side by Side Diff: ppapi/proxy/ppapi_command_buffer_proxy.cc

Issue 2440093003: WIP GPU scheduler + delayed activation / tile draw
Patch Set: SignalSyncToken -> IsFenceSyncReleased 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
« no previous file with comments | « ppapi/proxy/ppapi_command_buffer_proxy.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 "ppapi/proxy/ppapi_command_buffer_proxy.h" 5 #include "ppapi/proxy/ppapi_command_buffer_proxy.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
(...skipping 11 matching lines...) Expand all
22 const SerializedHandle& shared_state, 22 const SerializedHandle& shared_state,
23 gpu::CommandBufferId command_buffer_id) 23 gpu::CommandBufferId command_buffer_id)
24 : command_buffer_id_(command_buffer_id), 24 : command_buffer_id_(command_buffer_id),
25 capabilities_(capabilities), 25 capabilities_(capabilities),
26 resource_(resource), 26 resource_(resource),
27 dispatcher_(dispatcher), 27 dispatcher_(dispatcher),
28 next_fence_sync_release_(1), 28 next_fence_sync_release_(1),
29 pending_fence_sync_release_(0), 29 pending_fence_sync_release_(0),
30 flushed_fence_sync_release_(0), 30 flushed_fence_sync_release_(0),
31 validated_fence_sync_release_(0) { 31 validated_fence_sync_release_(0) {
32 shared_state_shm_.reset( 32 shared_state_shm_.reset(new base::SharedMemory(shared_state.shmem(), false));
33 new base::SharedMemory(shared_state.shmem(), false));
34 shared_state_shm_->Map(shared_state.size()); 33 shared_state_shm_->Map(shared_state.size());
35 InstanceData* data = dispatcher->GetInstanceData(resource.instance()); 34 InstanceData* data = dispatcher->GetInstanceData(resource.instance());
36 flush_info_ = &data->flush_info_; 35 flush_info_ = &data->flush_info_;
37 } 36 }
38 37
39 PpapiCommandBufferProxy::~PpapiCommandBufferProxy() { 38 PpapiCommandBufferProxy::~PpapiCommandBufferProxy() {
40 // gpu::Buffers are no longer referenced, allowing shared memory objects to be 39 // gpu::Buffers are no longer referenced, allowing shared memory objects to be
41 // deleted, closing the handle in this process. 40 // deleted, closing the handle in this process.
42 } 41 }
43 42
(...skipping 23 matching lines...) Expand all
67 if (flush_info_->flush_pending && flush_info_->resource != resource_) { 66 if (flush_info_->flush_pending && flush_info_->resource != resource_) {
68 FlushInternal(); 67 FlushInternal();
69 } 68 }
70 69
71 flush_info_->flush_pending = true; 70 flush_info_->flush_pending = true;
72 flush_info_->resource = resource_; 71 flush_info_->resource = resource_;
73 flush_info_->put_offset = put_offset; 72 flush_info_->put_offset = put_offset;
74 pending_fence_sync_release_ = next_fence_sync_release_ - 1; 73 pending_fence_sync_release_ = next_fence_sync_release_ - 1;
75 } 74 }
76 75
77 void PpapiCommandBufferProxy::WaitForTokenInRange(int32_t start, int32_t end) { 76 gpu::CommandBuffer::State PpapiCommandBufferProxy::WaitForTokenInRange(
77 int32_t start,
78 int32_t end) {
78 TryUpdateState(); 79 TryUpdateState();
79 if (!InRange(start, end, last_state_.token) && 80 if (!InRange(start, end, last_state_.token) &&
80 last_state_.error == gpu::error::kNoError) { 81 last_state_.error == gpu::error::kNoError) {
81 bool success = false; 82 bool success = false;
82 gpu::CommandBuffer::State state; 83 gpu::CommandBuffer::State state;
83 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange( 84 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange(
84 ppapi::API_ID_PPB_GRAPHICS_3D, 85 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, start, end, &state,
85 resource_, 86 &success)))
86 start,
87 end,
88 &state,
89 &success)))
90 UpdateState(state, success); 87 UpdateState(state, success);
91 } 88 }
92 DCHECK(InRange(start, end, last_state_.token) || 89 DCHECK(InRange(start, end, last_state_.token) ||
93 last_state_.error != gpu::error::kNoError); 90 last_state_.error != gpu::error::kNoError);
91 return last_state_;
94 } 92 }
95 93
96 void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32_t start, 94 gpu::CommandBuffer::State PpapiCommandBufferProxy::WaitForGetOffsetInRange(
97 int32_t end) { 95 int32_t start,
96 int32_t end) {
98 TryUpdateState(); 97 TryUpdateState();
99 if (!InRange(start, end, last_state_.get_offset) && 98 if (!InRange(start, end, last_state_.get_offset) &&
100 last_state_.error == gpu::error::kNoError) { 99 last_state_.error == gpu::error::kNoError) {
101 bool success = false; 100 bool success = false;
102 gpu::CommandBuffer::State state; 101 gpu::CommandBuffer::State state;
103 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange( 102 if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange(
104 ppapi::API_ID_PPB_GRAPHICS_3D, 103 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, start, end, &state,
105 resource_, 104 &success)))
106 start,
107 end,
108 &state,
109 &success)))
110 UpdateState(state, success); 105 UpdateState(state, success);
111 } 106 }
112 DCHECK(InRange(start, end, last_state_.get_offset) || 107 DCHECK(InRange(start, end, last_state_.get_offset) ||
113 last_state_.error != gpu::error::kNoError); 108 last_state_.error != gpu::error::kNoError);
109 return last_state_;
114 } 110 }
115 111
116 void PpapiCommandBufferProxy::SetGetBuffer(int32_t transfer_buffer_id) { 112 void PpapiCommandBufferProxy::SetGetBuffer(int32_t transfer_buffer_id) {
117 if (last_state_.error == gpu::error::kNoError) { 113 if (last_state_.error == gpu::error::kNoError) {
118 Send(new PpapiHostMsg_PPBGraphics3D_SetGetBuffer( 114 Send(new PpapiHostMsg_PPBGraphics3D_SetGetBuffer(
119 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, transfer_buffer_id)); 115 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, transfer_buffer_id));
120 } 116 }
121 } 117 }
122 118
123 scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer( 119 scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer(
124 size_t size, 120 size_t size,
125 int32_t* id) { 121 int32_t* id) {
126 *id = -1; 122 *id = -1;
127 123
128 if (last_state_.error != gpu::error::kNoError) 124 if (last_state_.error != gpu::error::kNoError)
129 return NULL; 125 return NULL;
130 126
131 // Assuming we are in the renderer process, the service is responsible for 127 // Assuming we are in the renderer process, the service is responsible for
132 // duplicating the handle. This might not be true for NaCl. 128 // duplicating the handle. This might not be true for NaCl.
133 ppapi::proxy::SerializedHandle handle( 129 ppapi::proxy::SerializedHandle handle(
134 ppapi::proxy::SerializedHandle::SHARED_MEMORY); 130 ppapi::proxy::SerializedHandle::SHARED_MEMORY);
135 if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer( 131 if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer(
136 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, 132 ppapi::API_ID_PPB_GRAPHICS_3D, resource_,
137 base::checked_cast<uint32_t>(size), id, &handle))) { 133 base::checked_cast<uint32_t>(size), id, &handle))) {
138 if (last_state_.error == gpu::error::kNoError) 134 if (last_state_.error == gpu::error::kNoError)
139 last_state_.error = gpu::error::kLostContext; 135 last_state_.error = gpu::error::kLostContext;
140 return NULL; 136 return NULL;
141 } 137 }
142 138
143 if (*id <= 0 || !handle.is_shmem()) { 139 if (*id <= 0 || !handle.is_shmem()) {
144 if (last_state_.error == gpu::error::kNoError) 140 if (last_state_.error == gpu::error::kNoError)
145 last_state_.error = gpu::error::kOutOfBounds; 141 last_state_.error = gpu::error::kOutOfBounds;
146 return NULL; 142 return NULL;
147 } 143 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (!IsFenceSyncFlushed(release)) 202 if (!IsFenceSyncFlushed(release))
207 return false; 203 return false;
208 204
209 if (release <= validated_fence_sync_release_) 205 if (release <= validated_fence_sync_release_)
210 return true; 206 return true;
211 207
212 EnsureWorkVisible(); 208 EnsureWorkVisible();
213 return release <= validated_fence_sync_release_; 209 return release <= validated_fence_sync_release_;
214 } 210 }
215 211
212 bool PpapiCommandBufferProxy::IsFenceSyncReleased(uint64_t release) {
213 NOTIMPLEMENTED();
214 return false;
215 }
216
216 void PpapiCommandBufferProxy::SignalSyncToken(const gpu::SyncToken& sync_token, 217 void PpapiCommandBufferProxy::SignalSyncToken(const gpu::SyncToken& sync_token,
217 const base::Closure& callback) { 218 const base::Closure& callback) {
218 NOTIMPLEMENTED(); 219 NOTIMPLEMENTED();
219 } 220 }
220 221
221 bool PpapiCommandBufferProxy::CanWaitUnverifiedSyncToken( 222 bool PpapiCommandBufferProxy::CanWaitUnverifiedSyncToken(
222 const gpu::SyncToken* sync_token) { 223 const gpu::SyncToken* sync_token) {
223 return false; 224 return false;
224 } 225 }
225 226
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 message->set_unblock(true); 318 message->set_unblock(true);
318 Send(message); 319 Send(message);
319 320
320 flush_info_->flush_pending = false; 321 flush_info_->flush_pending = false;
321 flush_info_->resource.SetHostResource(0, 0); 322 flush_info_->resource.SetHostResource(0, 0);
322 flushed_fence_sync_release_ = pending_fence_sync_release_; 323 flushed_fence_sync_release_ = pending_fence_sync_release_;
323 } 324 }
324 325
325 } // namespace proxy 326 } // namespace proxy
326 } // namespace ppapi 327 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_command_buffer_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698