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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/mapped_memory.cc
diff --git a/gpu/command_buffer/client/mapped_memory.cc b/gpu/command_buffer/client/mapped_memory.cc
index 6d57af4ed57204e62156f215d3af59143b658da7..0151c43d2369560a952630fa80632ad38bc5dd5c 100644
--- a/gpu/command_buffer/client/mapped_memory.cc
+++ b/gpu/command_buffer/client/mapped_memory.cc
@@ -81,6 +81,11 @@ void* MappedMemoryManager::Alloc(
}
}
+ if (max_free_bytes_ != kNoLimit &&
+ (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_
+ return NULL;
+ }
+
// Make a new chunk to satisfy the request.
CommandBuffer* cmd_buf = helper_->command_buffer();
unsigned int chunk_size =
@@ -140,4 +145,26 @@ void MappedMemoryManager::FreeUnused() {
}
}
+void ScopedMappedMemoryPtr::Release() {
+ if (buffer_) {
+ mapped_memory_manager_->FreePendingToken(buffer_, helper_->InsertToken());
+ buffer_ = nullptr;
+ size_ = 0;
+ shm_id_ = 0;
+ shm_offset_ = 0;
+
+ if (flush_after_release_)
+ helper_->CommandBufferHelper::Flush();
+ }
+}
+
+void ScopedMappedMemoryPtr::Reset(uint32_t new_size) {
+ Release();
+
+ if (new_size) {
+ buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_);
+ size_ = buffer_ ? new_size : 0;
+ }
+}
+
} // namespace gpu
« 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