OLD | NEW |
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/gles2/command_buffer_client_impl.h" | 5 #include "mojo/gles2/command_buffer_client_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const std::vector<int32_t>& attribs, | 121 const std::vector<int32_t>& attribs, |
122 const MojoAsyncWaiter* async_waiter, | 122 const MojoAsyncWaiter* async_waiter, |
123 mojo::ScopedMessagePipeHandle command_buffer_handle) | 123 mojo::ScopedMessagePipeHandle command_buffer_handle) |
124 : delegate_(delegate), | 124 : delegate_(delegate), |
125 attribs_(attribs), | 125 attribs_(attribs), |
126 observer_binding_(this), | 126 observer_binding_(this), |
127 shared_state_(NULL), | 127 shared_state_(NULL), |
128 last_put_offset_(-1), | 128 last_put_offset_(-1), |
129 next_transfer_buffer_id_(0), | 129 next_transfer_buffer_id_(0), |
130 next_image_id_(0), | 130 next_image_id_(0), |
| 131 next_fence_sync_release_(1), |
| 132 flushed_fence_sync_release_(0), |
131 async_waiter_(async_waiter) { | 133 async_waiter_(async_waiter) { |
132 command_buffer_.Bind(mojo::InterfacePtrInfo<mojo::CommandBuffer>( | 134 command_buffer_.Bind(mojo::InterfacePtrInfo<mojo::CommandBuffer>( |
133 command_buffer_handle.Pass(), 0u), | 135 command_buffer_handle.Pass(), 0u), |
134 async_waiter); | 136 async_waiter); |
135 command_buffer_.set_connection_error_handler( | 137 command_buffer_.set_connection_error_handler( |
136 [this]() { DidLoseContext(gpu::error::kUnknown); }); | 138 [this]() { DidLoseContext(gpu::error::kUnknown); }); |
137 } | 139 } |
138 | 140 |
139 CommandBufferClientImpl::~CommandBufferClientImpl() {} | 141 CommandBufferClientImpl::~CommandBufferClientImpl() {} |
140 | 142 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 TryUpdateState(); | 185 TryUpdateState(); |
184 return last_state_.token; | 186 return last_state_.token; |
185 } | 187 } |
186 | 188 |
187 void CommandBufferClientImpl::Flush(int32 put_offset) { | 189 void CommandBufferClientImpl::Flush(int32 put_offset) { |
188 if (last_put_offset_ == put_offset) | 190 if (last_put_offset_ == put_offset) |
189 return; | 191 return; |
190 | 192 |
191 last_put_offset_ = put_offset; | 193 last_put_offset_ = put_offset; |
192 command_buffer_->Flush(put_offset); | 194 command_buffer_->Flush(put_offset); |
| 195 flushed_fence_sync_release_ = next_fence_sync_release_ - 1; |
193 } | 196 } |
194 | 197 |
195 void CommandBufferClientImpl::OrderingBarrier(int32_t put_offset) { | 198 void CommandBufferClientImpl::OrderingBarrier(int32_t put_offset) { |
196 // TODO(jamesr): Implement this more efficiently. | 199 // TODO(jamesr): Implement this more efficiently. |
197 Flush(put_offset); | 200 Flush(put_offset); |
198 } | 201 } |
199 | 202 |
200 void CommandBufferClientImpl::WaitForTokenInRange(int32 start, int32 end) { | 203 void CommandBufferClientImpl::WaitForTokenInRange(int32 start, int32 end) { |
201 TryUpdateState(); | 204 TryUpdateState(); |
202 while (!InRange(start, end, last_state_.token) && | 205 while (!InRange(start, end, last_state_.token) && |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 404 } |
402 | 405 |
403 uint64_t CommandBufferClientImpl::GetCommandBufferID() const { | 406 uint64_t CommandBufferClientImpl::GetCommandBufferID() const { |
404 // TODO (rjkroege): This must correspond to the command buffer ID on the | 407 // TODO (rjkroege): This must correspond to the command buffer ID on the |
405 // server side. Most likely a combination of the client-specific integer and | 408 // server side. Most likely a combination of the client-specific integer and |
406 // the connect id. | 409 // the connect id. |
407 NOTIMPLEMENTED(); | 410 NOTIMPLEMENTED(); |
408 return 0; | 411 return 0; |
409 } | 412 } |
410 | 413 |
| 414 uint64_t CommandBufferClientImpl::GenerateFenceSyncRelease() { |
| 415 return next_fence_sync_release_++; |
| 416 } |
| 417 |
| 418 bool CommandBufferClientImpl::IsFenceSyncRelease(uint64_t release) { |
| 419 return release != 0 && release < next_fence_sync_release_; |
| 420 } |
| 421 |
| 422 bool CommandBufferClientImpl::IsFenceSyncFlushed(uint64_t release) { |
| 423 return release != 0 && release <= flushed_fence_sync_release_; |
| 424 } |
| 425 |
411 } // namespace gles2 | 426 } // namespace gles2 |
OLD | NEW |