Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.cc |
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
| index e91bbd6b3c99a5cad780f0532252847ed52bb752..82fc15734a6cc20f27a63f25cd5f5d843b9a1d3a 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.cc |
| +++ b/gpu/command_buffer/client/gles2_implementation.cc |
| @@ -17,6 +17,7 @@ |
| #include <string> |
| #include "base/compiler_specific.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/sys_info.h" |
| #include "base/thread_task_runner_handle.h" |
| #include "base/trace_event/memory_allocator_dump.h" |
| #include "base/trace_event/memory_dump_manager.h" |
| @@ -2302,11 +2303,19 @@ void GLES2Implementation::TexImage2D( |
| ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); |
| ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); |
| + // Do not use more than 5% of extra shared memory, and do not use any |
| + // extra for memory contrained devices (<1GB). |
| + const int64_t physical_memory = base::SysInfo::AmountOfPhysicalMemory(); |
| + const uint32_t max_extra_transfer_buffer_size = |
| + physical_memory > 1024 * 1024 * 1024 |
| + ? static_cast<uint32_t>(physical_memory / 20) |
| + : 0; |
| + |
| if (transfer_alloc.valid() && transfer_alloc.size() >= size) { |
| shm_id = transfer_alloc.shm_id(); |
| shm_offset = transfer_alloc.offset(); |
| buffer_pointer = transfer_alloc.address(); |
| - } else { |
| + } else if (size < max_extra_transfer_buffer_size) { |
| mapped_alloc.Reset(size); |
| if (mapped_alloc.valid()) { |
| transfer_alloc.Discard(); |
| @@ -2428,11 +2437,19 @@ void GLES2Implementation::TexImage3D( |
| ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); |
| ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); |
| + // Do not use more than 5% of extra shared memory, and do not use any |
| + // extra for memory contrained devices (<1GB). |
| + const int64_t physical_memory = base::SysInfo::AmountOfPhysicalMemory(); |
| + const uint32_t max_extra_transfer_buffer_size = |
|
no sievers
2015/10/15 22:33:30
can you make it a constant in this class?
David Yen
2015/10/15 23:01:54
I made it a static constant instead for the file.
|
| + physical_memory > 1024 * 1024 * 1024 |
| + ? static_cast<uint32_t>(physical_memory / 20) |
| + : 0; |
| + |
| if (transfer_alloc.valid() && transfer_alloc.size() >= size) { |
| shm_id = transfer_alloc.shm_id(); |
| shm_offset = transfer_alloc.offset(); |
| buffer_pointer = transfer_alloc.address(); |
| - } else { |
| + } else if (size < max_extra_transfer_buffer_size) { |
| mapped_alloc.Reset(size); |
| if (mapped_alloc.valid()) { |
| transfer_alloc.Discard(); |