| OLD | NEW |
| 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 // This file contains the implementation of the command buffer helper class. | 5 // This file contains the implementation of the command buffer helper class. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "gpu/command_buffer/common/command_buffer.h" | 10 #include "gpu/command_buffer/common/command_buffer.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 scoped_refptr<Buffer> buffer = | 98 scoped_refptr<Buffer> buffer = |
| 99 command_buffer_->CreateTransferBuffer(ring_buffer_size_, &id); | 99 command_buffer_->CreateTransferBuffer(ring_buffer_size_, &id); |
| 100 if (id < 0) { | 100 if (id < 0) { |
| 101 ClearUsable(); | 101 ClearUsable(); |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 | 104 |
| 105 ring_buffer_ = buffer; | 105 ring_buffer_ = buffer; |
| 106 ring_buffer_id_ = id; | 106 ring_buffer_id_ = id; |
| 107 command_buffer_->SetGetBuffer(id); | 107 command_buffer_->SetGetBuffer(id); |
| 108 | |
| 109 // TODO(gman): Do we really need to call GetState here? We know get & put = 0 | |
| 110 // Also do we need to check state.num_entries? | |
| 111 CommandBuffer::State state = command_buffer_->GetState(); | |
| 112 entries_ = static_cast<CommandBufferEntry*>(ring_buffer_->memory()); | 108 entries_ = static_cast<CommandBufferEntry*>(ring_buffer_->memory()); |
| 113 int32 num_ring_buffer_entries = | 109 total_entry_count_ = ring_buffer_size_ / sizeof(CommandBufferEntry); |
| 114 ring_buffer_size_ / sizeof(CommandBufferEntry); | 110 // Call to SetGetBuffer(id) above resets get and put offsets to 0. |
| 115 if (num_ring_buffer_entries > state.num_entries) { | 111 // No need to query it through IPC. |
| 116 ClearUsable(); | 112 put_ = 0; |
| 117 return false; | |
| 118 } | |
| 119 | |
| 120 total_entry_count_ = num_ring_buffer_entries; | |
| 121 put_ = state.put_offset; | |
| 122 CalcImmediateEntries(0); | 113 CalcImmediateEntries(0); |
| 123 return true; | 114 return true; |
| 124 } | 115 } |
| 125 | 116 |
| 126 void CommandBufferHelper::FreeResources() { | 117 void CommandBufferHelper::FreeResources() { |
| 127 if (HaveRingBuffer()) { | 118 if (HaveRingBuffer()) { |
| 128 command_buffer_->DestroyTransferBuffer(ring_buffer_id_); | 119 command_buffer_->DestroyTransferBuffer(ring_buffer_id_); |
| 129 ring_buffer_id_ = -1; | 120 ring_buffer_id_ = -1; |
| 130 CalcImmediateEntries(0); | 121 CalcImmediateEntries(0); |
| 131 } | 122 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if (!WaitForGetOffsetInRange(put_ + count + 1, put_)) | 282 if (!WaitForGetOffsetInRange(put_ + count + 1, put_)) |
| 292 return; | 283 return; |
| 293 CalcImmediateEntries(count); | 284 CalcImmediateEntries(count); |
| 294 DCHECK_GE(immediate_entry_count_, count); | 285 DCHECK_GE(immediate_entry_count_, count); |
| 295 } | 286 } |
| 296 } | 287 } |
| 297 } | 288 } |
| 298 | 289 |
| 299 | 290 |
| 300 } // namespace gpu | 291 } // namespace gpu |
| OLD | NEW |