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

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

Issue 1168853002: Use mapped memory for uploading large textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Discard blocks by simply marking them as padding. Created 5 years, 6 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/logging.h" 10 #include "base/logging.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void* mem = chunk->Alloc(size); 74 void* mem = chunk->Alloc(size);
75 DCHECK(mem); 75 DCHECK(mem);
76 *shm_id = chunk->shm_id(); 76 *shm_id = chunk->shm_id();
77 *shm_offset = chunk->GetOffset(mem); 77 *shm_offset = chunk->GetOffset(mem);
78 return mem; 78 return mem;
79 } 79 }
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 if (max_free_bytes_ != kNoLimit &&
85 (allocated_memory_ + size) > max_free_bytes_) {
jbauman 2015/06/09 02:30:13 This wasn't intended to be a hard limit, but rathe
David Yen 2015/06/09 17:07:08 Ok, I've separated out this concept and added max_
86 return NULL;
87 }
88
84 // Make a new chunk to satisfy the request. 89 // Make a new chunk to satisfy the request.
85 CommandBuffer* cmd_buf = helper_->command_buffer(); 90 CommandBuffer* cmd_buf = helper_->command_buffer();
86 unsigned int chunk_size = 91 unsigned int chunk_size =
87 ((size + chunk_size_multiple_ - 1) / chunk_size_multiple_) * 92 ((size + chunk_size_multiple_ - 1) / chunk_size_multiple_) *
88 chunk_size_multiple_; 93 chunk_size_multiple_;
89 int32 id = -1; 94 int32 id = -1;
90 scoped_refptr<gpu::Buffer> shm = 95 scoped_refptr<gpu::Buffer> shm =
91 cmd_buf->CreateTransferBuffer(chunk_size, &id); 96 cmd_buf->CreateTransferBuffer(chunk_size, &id);
92 if (id < 0) 97 if (id < 0)
93 return NULL; 98 return NULL;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (!chunk->InUse()) { 138 if (!chunk->InUse()) {
134 cmd_buf->DestroyTransferBuffer(chunk->shm_id()); 139 cmd_buf->DestroyTransferBuffer(chunk->shm_id());
135 allocated_memory_ -= chunk->GetSize(); 140 allocated_memory_ -= chunk->GetSize();
136 iter = chunks_.erase(iter); 141 iter = chunks_.erase(iter);
137 } else { 142 } else {
138 ++iter; 143 ++iter;
139 } 144 }
140 } 145 }
141 } 146 }
142 147
148 void ScopedMappedMemoryPtr::Release() {
149 if (buffer_) {
150 mapped_memory_manager_->FreePendingToken(buffer_, helper_->InsertToken());
151 buffer_ = nullptr;
152 size_ = 0;
153 shm_id_ = 0;
154 shm_offset_ = 0;
155
156 if (flush_after_release_)
157 helper_->CommandBufferHelper::Flush();
158 }
159 }
160
161 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) {
162 Release();
163
164 if (new_size) {
165 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_);
166 size_ = buffer_ ? new_size : 0;
167 }
168 }
169
143 } // namespace gpu 170 } // 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