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 <stddef.h> | 13 #include <stddef.h> |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <map> | 16 #include <map> |
17 #include <set> | 17 #include <set> |
18 #include <sstream> | 18 #include <sstream> |
19 #include <string> | 19 #include <string> |
20 #include "base/atomic_sequence_num.h" | 20 #include "base/atomic_sequence_num.h" |
21 #include "base/bits.h" | 21 #include "base/bits.h" |
22 #include "base/compiler_specific.h" | 22 #include "base/compiler_specific.h" |
| 23 #include "base/debug/activity_tracker.h" |
23 #include "base/numerics/safe_math.h" | 24 #include "base/numerics/safe_math.h" |
24 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
26 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
28 #include "base/trace_event/memory_allocator_dump.h" | 29 #include "base/trace_event/memory_allocator_dump.h" |
29 #include "base/trace_event/memory_dump_manager.h" | 30 #include "base/trace_event/memory_dump_manager.h" |
30 #include "base/trace_event/process_memory_dump.h" | 31 #include "base/trace_event/process_memory_dump.h" |
31 #include "base/trace_event/trace_event.h" | 32 #include "base/trace_event/trace_event.h" |
32 #include "gpu/command_buffer/client/buffer_tracker.h" | 33 #include "gpu/command_buffer/client/buffer_tracker.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 weak_ptr_factory_.GetWeakPtr(), | 412 weak_ptr_factory_.GetWeakPtr(), |
412 callback)); | 413 callback)); |
413 } | 414 } |
414 | 415 |
415 void GLES2Implementation::SetAggressivelyFreeResources( | 416 void GLES2Implementation::SetAggressivelyFreeResources( |
416 bool aggressively_free_resources) { | 417 bool aggressively_free_resources) { |
417 TRACE_EVENT1("gpu", "GLES2Implementation::SetAggressivelyFreeResources", | 418 TRACE_EVENT1("gpu", "GLES2Implementation::SetAggressivelyFreeResources", |
418 "aggressively_free_resources", aggressively_free_resources); | 419 "aggressively_free_resources", aggressively_free_resources); |
419 aggressively_free_resources_ = aggressively_free_resources; | 420 aggressively_free_resources_ = aggressively_free_resources; |
420 | 421 |
| 422 // TODO(manzagop): remove ScopedActivity once crbug.com/703342 is fixed. |
| 423 const uint32_t kActivityId = |
| 424 0x92094cf4; // SHA1(GLES2Implementation::SetAggressivelyFreeResources) |
| 425 |
421 if (aggressively_free_resources_ && helper_->HaveRingBuffer()) { | 426 if (aggressively_free_resources_ && helper_->HaveRingBuffer()) { |
| 427 // TODO(manzagop): remove ScopedActivity once crbug.com/703342 is fixed. |
| 428 base::debug::ScopedActivity activity_flush(0, kActivityId, |
| 429 aggressively_free_resources); |
| 430 |
422 // Ensure that we clean up as much cache memory as possible and fully flush. | 431 // Ensure that we clean up as much cache memory as possible and fully flush. |
423 FlushDriverCachesCHROMIUM(); | 432 FlushDriverCachesCHROMIUM(); |
424 | 433 |
425 // Flush will delete transfer buffer resources if | 434 // Flush will delete transfer buffer resources if |
426 // |aggressively_free_resources_| is true. | 435 // |aggressively_free_resources_| is true. |
427 Flush(); | 436 Flush(); |
428 } else { | 437 } else { |
| 438 // TODO(manzagop): remove ScopedActivity once crbug.com/703342 is fixed. |
| 439 base::debug::ScopedActivity activity_shallow_flush( |
| 440 0, kActivityId + 1, aggressively_free_resources); |
429 ShallowFlushCHROMIUM(); | 441 ShallowFlushCHROMIUM(); |
430 } | 442 } |
431 } | 443 } |
432 | 444 |
433 bool GLES2Implementation::OnMemoryDump( | 445 bool GLES2Implementation::OnMemoryDump( |
434 const base::trace_event::MemoryDumpArgs& args, | 446 const base::trace_event::MemoryDumpArgs& args, |
435 base::trace_event::ProcessMemoryDump* pmd) { | 447 base::trace_event::ProcessMemoryDump* pmd) { |
436 using base::trace_event::MemoryAllocatorDump; | 448 using base::trace_event::MemoryAllocatorDump; |
437 using base::trace_event::MemoryDumpLevelOfDetail; | 449 using base::trace_event::MemoryDumpLevelOfDetail; |
438 | 450 |
(...skipping 6628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7067 CheckGLError(); | 7079 CheckGLError(); |
7068 } | 7080 } |
7069 | 7081 |
7070 // Include the auto-generated part of this file. We split this because it means | 7082 // Include the auto-generated part of this file. We split this because it means |
7071 // we can easily edit the non-auto generated parts right here in this file | 7083 // we can easily edit the non-auto generated parts right here in this file |
7072 // instead of having to edit some template or the code generator. | 7084 // instead of having to edit some template or the code generator. |
7073 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 7085 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
7074 | 7086 |
7075 } // namespace gles2 | 7087 } // namespace gles2 |
7076 } // namespace gpu | 7088 } // namespace gpu |
OLD | NEW |