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/memory/shared_memory_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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 base::trace_event::ProcessMemoryDump* pmd) { | 436 base::trace_event::ProcessMemoryDump* pmd) { |
436 using base::trace_event::MemoryAllocatorDump; | 437 using base::trace_event::MemoryAllocatorDump; |
437 using base::trace_event::MemoryDumpLevelOfDetail; | 438 using base::trace_event::MemoryDumpLevelOfDetail; |
438 | 439 |
439 // Dump owned MappedMemoryManager memory as well. | 440 // Dump owned MappedMemoryManager memory as well. |
440 mapped_memory_->OnMemoryDump(args, pmd); | 441 mapped_memory_->OnMemoryDump(args, pmd); |
441 | 442 |
442 if (!transfer_buffer_->HaveBuffer()) | 443 if (!transfer_buffer_->HaveBuffer()) |
443 return true; | 444 return true; |
444 | 445 |
445 const uint64_t tracing_process_id = | |
446 base::trace_event::MemoryDumpManager::GetInstance() | |
447 ->GetTracingProcessId(); | |
448 | |
449 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( | 446 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( |
450 "gpu/transfer_buffer_memory/buffer_%d", transfer_buffer_->GetShmId())); | 447 "gpu/transfer_buffer_memory/buffer_%d", transfer_buffer_->GetShmId())); |
451 dump->AddScalar(MemoryAllocatorDump::kNameSize, | 448 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
452 MemoryAllocatorDump::kUnitsBytes, | 449 MemoryAllocatorDump::kUnitsBytes, |
453 transfer_buffer_->GetSize()); | 450 transfer_buffer_->GetSize()); |
454 | 451 |
455 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { | 452 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { |
456 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, | 453 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, |
457 transfer_buffer_->GetFreeSize()); | 454 transfer_buffer_->GetFreeSize()); |
458 auto guid = GetBufferGUIDForTracing(tracing_process_id, | 455 auto* shared_memory = transfer_buffer_->GetSharedMemory(); |
459 transfer_buffer_->GetShmId()); | 456 if (shared_memory) { |
460 const int kImportance = 2; | 457 base::SharedMemoryTracker::AddOwnershipEdges( |
461 pmd->CreateSharedGlobalAllocatorDump(guid); | 458 pmd, dump->guid(), shared_memory->handle(), |
462 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 459 shared_memory->mapped_size()); |
| 460 } |
463 } | 461 } |
464 | 462 |
465 return true; | 463 return true; |
466 } | 464 } |
467 | 465 |
468 void GLES2Implementation::WaitForCmd() { | 466 void GLES2Implementation::WaitForCmd() { |
469 TRACE_EVENT0("gpu", "GLES2::WaitForCmd"); | 467 TRACE_EVENT0("gpu", "GLES2::WaitForCmd"); |
470 helper_->CommandBufferHelper::Finish(); | 468 helper_->CommandBufferHelper::Finish(); |
471 } | 469 } |
472 | 470 |
(...skipping 6594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7067 CheckGLError(); | 7065 CheckGLError(); |
7068 } | 7066 } |
7069 | 7067 |
7070 // Include the auto-generated part of this file. We split this because it means | 7068 // 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 | 7069 // 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. | 7070 // instead of having to edit some template or the code generator. |
7073 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 7071 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
7074 | 7072 |
7075 } // namespace gles2 | 7073 } // namespace gles2 |
7076 } // namespace gpu | 7074 } // namespace gpu |
OLD | NEW |