| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) | 24 CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
| 25 : command_buffer_(command_buffer), | 25 : command_buffer_(command_buffer), |
| 26 ring_buffer_id_(-1), | 26 ring_buffer_id_(-1), |
| 27 ring_buffer_size_(0), | 27 ring_buffer_size_(0), |
| 28 entries_(NULL), | 28 entries_(NULL), |
| 29 total_entry_count_(0), | 29 total_entry_count_(0), |
| 30 immediate_entry_count_(0), | 30 immediate_entry_count_(0), |
| 31 token_(0), | 31 token_(0), |
| 32 put_(0), | 32 put_(0), |
| 33 last_put_sent_(0), | 33 last_put_sent_(0), |
| 34 next_fence_sync_release_(1), |
| 35 flushed_fence_sync_release_(0), |
| 34 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) | 36 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) |
| 35 commands_issued_(0), | 37 commands_issued_(0), |
| 36 #endif | 38 #endif |
| 37 usable_(true), | 39 usable_(true), |
| 38 context_lost_(false), | 40 context_lost_(false), |
| 39 flush_automatically_(true), | 41 flush_automatically_(true), |
| 40 flush_generation_(0) { | 42 flush_generation_(0) { |
| 41 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 43 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
| 42 // Don't register a dump provider in these cases. | 44 // Don't register a dump provider in these cases. |
| 43 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 | 45 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ring_buffer_ = nullptr; | 141 ring_buffer_ = nullptr; |
| 140 } | 142 } |
| 141 } | 143 } |
| 142 | 144 |
| 143 void CommandBufferHelper::FreeRingBuffer() { | 145 void CommandBufferHelper::FreeRingBuffer() { |
| 144 CHECK((put_ == get_offset()) || | 146 CHECK((put_ == get_offset()) || |
| 145 error::IsError(command_buffer_->GetLastState().error)); | 147 error::IsError(command_buffer_->GetLastState().error)); |
| 146 FreeResources(); | 148 FreeResources(); |
| 147 } | 149 } |
| 148 | 150 |
| 151 uint32_t CommandBufferHelper::GenerateFenceSyncRelease() { |
| 152 // Enforce fence syncs generated are always inserted in the command buffer. |
| 153 const uint32_t release = next_fence_sync_release_++; |
| 154 return release; |
| 155 } |
| 156 |
| 149 bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { | 157 bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { |
| 150 ring_buffer_size_ = ring_buffer_size; | 158 ring_buffer_size_ = ring_buffer_size; |
| 151 return AllocateRingBuffer(); | 159 return AllocateRingBuffer(); |
| 152 } | 160 } |
| 153 | 161 |
| 154 CommandBufferHelper::~CommandBufferHelper() { | 162 CommandBufferHelper::~CommandBufferHelper() { |
| 155 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 163 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 156 this); | 164 this); |
| 157 FreeResources(); | 165 FreeResources(); |
| 158 } | 166 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 169 // Wrap put_ before flush. | 177 // Wrap put_ before flush. |
| 170 if (put_ == total_entry_count_) | 178 if (put_ == total_entry_count_) |
| 171 put_ = 0; | 179 put_ = 0; |
| 172 | 180 |
| 173 if (usable()) { | 181 if (usable()) { |
| 174 last_flush_time_ = base::TimeTicks::Now(); | 182 last_flush_time_ = base::TimeTicks::Now(); |
| 175 last_put_sent_ = put_; | 183 last_put_sent_ = put_; |
| 176 command_buffer_->Flush(put_); | 184 command_buffer_->Flush(put_); |
| 177 ++flush_generation_; | 185 ++flush_generation_; |
| 178 CalcImmediateEntries(0); | 186 CalcImmediateEntries(0); |
| 187 |
| 188 flushed_fence_sync_release_ = next_fence_sync_release_ - 1; |
| 179 } | 189 } |
| 180 } | 190 } |
| 181 | 191 |
| 182 void CommandBufferHelper::OrderingBarrier() { | 192 void CommandBufferHelper::OrderingBarrier() { |
| 183 // Wrap put_ before setting the barrier. | 193 // Wrap put_ before setting the barrier. |
| 184 if (put_ == total_entry_count_) | 194 if (put_ == total_entry_count_) |
| 185 put_ = 0; | 195 put_ = 0; |
| 186 | 196 |
| 187 if (usable()) { | 197 if (usable()) { |
| 188 command_buffer_->OrderingBarrier(put_); | 198 command_buffer_->OrderingBarrier(put_); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry)); | 363 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry)); |
| 354 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_); | 364 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_); |
| 355 const int kImportance = 2; | 365 const int kImportance = 2; |
| 356 pmd->CreateSharedGlobalAllocatorDump(guid); | 366 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 357 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 367 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 358 | 368 |
| 359 return true; | 369 return true; |
| 360 } | 370 } |
| 361 | 371 |
| 362 } // namespace gpu | 372 } // namespace gpu |
| OLD | NEW |