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

Side by Side Diff: gpu/command_buffer/client/mapped_memory.cc

Issue 1186393004: gpu: Remove async texture uploads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 3 months 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "gpu/command_buffer/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/trace_event/memory_dump_manager.h" 14 #include "base/trace_event/memory_dump_manager.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 16 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
17 #include "gpu/command_buffer/common/buffer.h" 17 #include "gpu/command_buffer/common/buffer.h"
18 18
19 namespace gpu { 19 namespace gpu {
20 namespace { 20 namespace {
21 21
22 // Generates process-unique IDs to use for tracing a MappedMemoryManager's 22 // Generates process-unique IDs to use for tracing a MappedMemoryManager's
23 // chunks. 23 // chunks.
24 base::StaticAtomicSequenceNumber g_next_mapped_memory_manager_tracing_id; 24 base::StaticAtomicSequenceNumber g_next_mapped_memory_manager_tracing_id;
25 25
26 } // namespace 26 } // namespace
27 27
28 MemoryChunk::MemoryChunk(int32 shm_id, 28 MemoryChunk::MemoryChunk(int32 shm_id,
29 scoped_refptr<gpu::Buffer> shm, 29 scoped_refptr<gpu::Buffer> shm,
30 CommandBufferHelper* helper, 30 CommandBufferHelper* helper)
31 const base::Closure& poll_callback)
32 : shm_id_(shm_id), 31 : shm_id_(shm_id),
33 shm_(shm), 32 shm_(shm),
34 allocator_(shm->size(), helper, poll_callback, shm->memory()) {} 33 allocator_(shm->size(), helper, shm->memory()) {}
35 34
36 MemoryChunk::~MemoryChunk() {} 35 MemoryChunk::~MemoryChunk() {}
37 36
38 MappedMemoryManager::MappedMemoryManager(CommandBufferHelper* helper, 37 MappedMemoryManager::MappedMemoryManager(CommandBufferHelper* helper,
39 const base::Closure& poll_callback,
40 size_t unused_memory_reclaim_limit) 38 size_t unused_memory_reclaim_limit)
41 : chunk_size_multiple_(FencedAllocator::kAllocAlignment), 39 : chunk_size_multiple_(FencedAllocator::kAllocAlignment),
42 helper_(helper), 40 helper_(helper),
43 poll_callback_(poll_callback),
44 allocated_memory_(0), 41 allocated_memory_(0),
45 max_free_bytes_(unused_memory_reclaim_limit), 42 max_free_bytes_(unused_memory_reclaim_limit),
46 max_allocated_bytes_(kNoLimit), 43 max_allocated_bytes_(kNoLimit),
47 tracing_id_(g_next_mapped_memory_manager_tracing_id.GetNext()) { 44 tracing_id_(g_next_mapped_memory_manager_tracing_id.GetNext()) {
48 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). 45 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
49 // Don't register a dump provider in these cases. 46 // Don't register a dump provider in these cases.
50 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 47 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156
51 if (base::ThreadTaskRunnerHandle::IsSet()) { 48 if (base::ThreadTaskRunnerHandle::IsSet()) {
52 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 49 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
53 this, base::ThreadTaskRunnerHandle::Get()); 50 this, base::ThreadTaskRunnerHandle::Get());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 CommandBuffer* cmd_buf = helper_->command_buffer(); 111 CommandBuffer* cmd_buf = helper_->command_buffer();
115 unsigned int chunk_size = 112 unsigned int chunk_size =
116 ((size + chunk_size_multiple_ - 1) / chunk_size_multiple_) * 113 ((size + chunk_size_multiple_ - 1) / chunk_size_multiple_) *
117 chunk_size_multiple_; 114 chunk_size_multiple_;
118 int32 id = -1; 115 int32 id = -1;
119 scoped_refptr<gpu::Buffer> shm = 116 scoped_refptr<gpu::Buffer> shm =
120 cmd_buf->CreateTransferBuffer(chunk_size, &id); 117 cmd_buf->CreateTransferBuffer(chunk_size, &id);
121 if (id < 0) 118 if (id < 0)
122 return NULL; 119 return NULL;
123 DCHECK(shm.get()); 120 DCHECK(shm.get());
124 MemoryChunk* mc = new MemoryChunk(id, shm, helper_, poll_callback_); 121 MemoryChunk* mc = new MemoryChunk(id, shm, helper_);
125 allocated_memory_ += mc->GetSize(); 122 allocated_memory_ += mc->GetSize();
126 chunks_.push_back(mc); 123 chunks_.push_back(mc);
127 void* mem = mc->Alloc(size); 124 void* mem = mc->Alloc(size);
128 DCHECK(mem); 125 DCHECK(mem);
129 *shm_id = mc->shm_id(); 126 *shm_id = mc->shm_id();
130 *shm_offset = mc->GetOffset(mem); 127 *shm_offset = mc->GetOffset(mem);
131 return mem; 128 return mem;
132 } 129 }
133 130
134 void MappedMemoryManager::Free(void* pointer) { 131 void MappedMemoryManager::Free(void* pointer) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) { 212 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) {
216 Release(); 213 Release();
217 214
218 if (new_size) { 215 if (new_size) {
219 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_); 216 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_);
220 size_ = buffer_ ? new_size : 0; 217 size_ = buffer_ ? new_size : 0;
221 } 218 }
222 } 219 }
223 220
224 } // namespace gpu 221 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/mapped_memory.h ('k') | gpu/command_buffer/client/mapped_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698