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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
12 #include <GLES3/gl3.h> | 12 #include <GLES3/gl3.h> |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <map> | 14 #include <map> |
15 #include <set> | 15 #include <set> |
16 #include <sstream> | 16 #include <sstream> |
17 #include <string> | 17 #include <string> |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/sys_info.h" |
20 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
21 #include "base/trace_event/memory_allocator_dump.h" | 22 #include "base/trace_event/memory_allocator_dump.h" |
22 #include "base/trace_event/memory_dump_manager.h" | 23 #include "base/trace_event/memory_dump_manager.h" |
23 #include "base/trace_event/process_memory_dump.h" | 24 #include "base/trace_event/process_memory_dump.h" |
24 #include "gpu/command_buffer/client/buffer_tracker.h" | 25 #include "gpu/command_buffer/client/buffer_tracker.h" |
25 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 26 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
26 #include "gpu/command_buffer/client/gpu_control.h" | 27 #include "gpu/command_buffer/client/gpu_control.h" |
27 #include "gpu/command_buffer/client/program_info_manager.h" | 28 #include "gpu/command_buffer/client/program_info_manager.h" |
28 #include "gpu/command_buffer/client/query_tracker.h" | 29 #include "gpu/command_buffer/client/query_tracker.h" |
29 #include "gpu/command_buffer/client/transfer_buffer.h" | 30 #include "gpu/command_buffer/client/transfer_buffer.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 bound_pixel_unpack_buffer_(0), | 105 bound_pixel_unpack_buffer_(0), |
105 bound_transform_feedback_buffer_(0), | 106 bound_transform_feedback_buffer_(0), |
106 bound_uniform_buffer_(0), | 107 bound_uniform_buffer_(0), |
107 bound_pixel_pack_transfer_buffer_id_(0), | 108 bound_pixel_pack_transfer_buffer_id_(0), |
108 bound_pixel_unpack_transfer_buffer_id_(0), | 109 bound_pixel_unpack_transfer_buffer_id_(0), |
109 error_bits_(0), | 110 error_bits_(0), |
110 debug_(false), | 111 debug_(false), |
111 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), | 112 lose_context_when_out_of_memory_(lose_context_when_out_of_memory), |
112 support_client_side_arrays_(support_client_side_arrays), | 113 support_client_side_arrays_(support_client_side_arrays), |
113 use_count_(0), | 114 use_count_(0), |
| 115 max_extra_transfer_buffer_size_( |
| 116 #if defined(OS_NACL) |
| 117 0), |
| 118 #else |
| 119 // Do not use more than 5% of extra shared memory, and do not |
| 120 // use any extra for memory contrained devices (<=1GB). |
| 121 base::SysInfo::AmountOfPhysicalMemory() > 1024 * 1024 * 1024 |
| 122 ? base::saturated_cast<uint32_t>( |
| 123 base::SysInfo::AmountOfPhysicalMemory() / 20) |
| 124 : 0), |
| 125 #endif |
114 error_message_callback_(NULL), | 126 error_message_callback_(NULL), |
115 current_trace_stack_(0), | 127 current_trace_stack_(0), |
116 gpu_control_(gpu_control), | 128 gpu_control_(gpu_control), |
117 capabilities_(gpu_control->GetCapabilities()), | 129 capabilities_(gpu_control->GetCapabilities()), |
118 aggressively_free_resources_(false), | 130 aggressively_free_resources_(false), |
119 weak_ptr_factory_(this) { | 131 weak_ptr_factory_(this) { |
120 DCHECK(helper); | 132 DCHECK(helper); |
121 DCHECK(transfer_buffer); | 133 DCHECK(transfer_buffer); |
122 DCHECK(gpu_control); | 134 DCHECK(gpu_control); |
123 | 135 |
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 uint32_t shm_offset = 0; | 2311 uint32_t shm_offset = 0; |
2300 void* buffer_pointer = nullptr; | 2312 void* buffer_pointer = nullptr; |
2301 | 2313 |
2302 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); | 2314 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); |
2303 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); | 2315 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); |
2304 | 2316 |
2305 if (transfer_alloc.valid() && transfer_alloc.size() >= size) { | 2317 if (transfer_alloc.valid() && transfer_alloc.size() >= size) { |
2306 shm_id = transfer_alloc.shm_id(); | 2318 shm_id = transfer_alloc.shm_id(); |
2307 shm_offset = transfer_alloc.offset(); | 2319 shm_offset = transfer_alloc.offset(); |
2308 buffer_pointer = transfer_alloc.address(); | 2320 buffer_pointer = transfer_alloc.address(); |
2309 } else { | 2321 } else if (size < max_extra_transfer_buffer_size_) { |
2310 mapped_alloc.Reset(size); | 2322 mapped_alloc.Reset(size); |
2311 if (mapped_alloc.valid()) { | 2323 if (mapped_alloc.valid()) { |
2312 transfer_alloc.Discard(); | 2324 transfer_alloc.Discard(); |
2313 | 2325 |
2314 mapped_alloc.SetFlushAfterRelease(true); | 2326 mapped_alloc.SetFlushAfterRelease(true); |
2315 shm_id = mapped_alloc.shm_id(); | 2327 shm_id = mapped_alloc.shm_id(); |
2316 shm_offset = mapped_alloc.offset(); | 2328 shm_offset = mapped_alloc.offset(); |
2317 buffer_pointer = mapped_alloc.address(); | 2329 buffer_pointer = mapped_alloc.address(); |
2318 } | 2330 } |
2319 } | 2331 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 uint32_t shm_offset = 0; | 2437 uint32_t shm_offset = 0; |
2426 void* buffer_pointer = nullptr; | 2438 void* buffer_pointer = nullptr; |
2427 | 2439 |
2428 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); | 2440 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); |
2429 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); | 2441 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); |
2430 | 2442 |
2431 if (transfer_alloc.valid() && transfer_alloc.size() >= size) { | 2443 if (transfer_alloc.valid() && transfer_alloc.size() >= size) { |
2432 shm_id = transfer_alloc.shm_id(); | 2444 shm_id = transfer_alloc.shm_id(); |
2433 shm_offset = transfer_alloc.offset(); | 2445 shm_offset = transfer_alloc.offset(); |
2434 buffer_pointer = transfer_alloc.address(); | 2446 buffer_pointer = transfer_alloc.address(); |
2435 } else { | 2447 } else if (size < max_extra_transfer_buffer_size_) { |
2436 mapped_alloc.Reset(size); | 2448 mapped_alloc.Reset(size); |
2437 if (mapped_alloc.valid()) { | 2449 if (mapped_alloc.valid()) { |
2438 transfer_alloc.Discard(); | 2450 transfer_alloc.Discard(); |
2439 | 2451 |
2440 mapped_alloc.SetFlushAfterRelease(true); | 2452 mapped_alloc.SetFlushAfterRelease(true); |
2441 shm_id = mapped_alloc.shm_id(); | 2453 shm_id = mapped_alloc.shm_id(); |
2442 shm_offset = mapped_alloc.offset(); | 2454 shm_offset = mapped_alloc.offset(); |
2443 buffer_pointer = mapped_alloc.address(); | 2455 buffer_pointer = mapped_alloc.address(); |
2444 } | 2456 } |
2445 } | 2457 } |
(...skipping 3509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5955 CheckGLError(); | 5967 CheckGLError(); |
5956 } | 5968 } |
5957 | 5969 |
5958 // Include the auto-generated part of this file. We split this because it means | 5970 // Include the auto-generated part of this file. We split this because it means |
5959 // we can easily edit the non-auto generated parts right here in this file | 5971 // we can easily edit the non-auto generated parts right here in this file |
5960 // instead of having to edit some template or the code generator. | 5972 // instead of having to edit some template or the code generator. |
5961 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 5973 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
5962 | 5974 |
5963 } // namespace gles2 | 5975 } // namespace gles2 |
5964 } // namespace gpu | 5976 } // namespace gpu |
OLD | NEW |