| Flutter Impeller |

tracked_objects_vk.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/renderer/backend/vulkan/tracked_objects_vk.h"
6
7 #include "impeller/renderer/backend/vulkan/gpu_tracer_vk.h"
8
9 namespace impeller {
10
11 TrackedObjectsVK::TrackedObjectsVK(
12 const std::weak_ptr<const ContextVK>& context,
13 const std::shared_ptr<CommandPoolVK>& pool,
14 std::unique_ptr<GPUProbe> probe)
15 : desc_pool_(context), probe_(std::move(probe)) {
16 if (!pool) {
17 return;
18 }
19 auto buffer = pool->CreateCommandBuffer();
20 if (!buffer) {
21 return;
22 }
23 pool_ = pool;
24 buffer_ = std::move(buffer);
25 is_valid_ = true;
26 }
27
28 TrackedObjectsVK::~TrackedObjectsVK() {
29 if (!buffer_) {
30 return;
31 }
32 pool_->CollectCommandBuffer(std::move(buffer_));
33 }
34
35 bool TrackedObjectsVK::IsValid() const {
36 return is_valid_;
37 }
38
39 void TrackedObjectsVK::Track(std::shared_ptr<SharedObjectVK> object) {
40 if (!object) {
41 return;
42 }
43 tracked_objects_.insert(std::move(object));
44 }
45
46 void TrackedObjectsVK::Track(std::shared_ptr<const DeviceBuffer> buffer) {
47 if (!buffer) {
48 return;
49 }
50 tracked_buffers_.insert(std::move(buffer));
51 }
52
53 bool TrackedObjectsVK::IsTracking(
54 const std::shared_ptr<const DeviceBuffer>& buffer) const {
55 if (!buffer) {
56 return false;
57 }
58 return tracked_buffers_.find(buffer) != tracked_buffers_.end();
59 }
60
61 void TrackedObjectsVK::Track(std::shared_ptr<const TextureSourceVK> texture) {
62 if (!texture) {
63 return;
64 }
65 tracked_textures_.insert(std::move(texture));
66 }
67
68 bool TrackedObjectsVK::IsTracking(
69 const std::shared_ptr<const TextureSourceVK>& texture) const {
70 if (!texture) {
71 return false;
72 }
73 return tracked_textures_.find(texture) != tracked_textures_.end();
74 }
75
76 vk::CommandBuffer TrackedObjectsVK::GetCommandBuffer() const {
77 return *buffer_;
78 }
79
80 DescriptorPoolVK& TrackedObjectsVK::GetDescriptorPool() {
81 return desc_pool_;
82 }
83
84 GPUProbe& TrackedObjectsVK::GetGPUProbe() const {
85 return *probe_.get();
86 }
87
88 } // namespace impeller
gpu_tracer_vk.h
tracked_objects_vk.h
impeller::TrackedObjectsVK::GetGPUProbe
GPUProbe & GetGPUProbe() const
Definition: tracked_objects_vk.cc:84
impeller::TrackedObjectsVK::~TrackedObjectsVK
~TrackedObjectsVK()
Definition: tracked_objects_vk.cc:28
impeller::TrackedObjectsVK::GetDescriptorPool
DescriptorPoolVK & GetDescriptorPool()
Definition: tracked_objects_vk.cc:80
impeller::TrackedObjectsVK::IsValid
bool IsValid() const
Definition: tracked_objects_vk.cc:35
impeller::DescriptorPoolVK
A per-frame descriptor pool. Descriptors from this pool don't need to be freed individually....
Definition: descriptor_pool_vk.h:27
impeller::TrackedObjectsVK::GetCommandBuffer
vk::CommandBuffer GetCommandBuffer() const
Definition: tracked_objects_vk.cc:76
impeller::GPUProbe
Definition: gpu_tracer_vk.h:101
impeller::TrackedObjectsVK::IsTracking
bool IsTracking(const std::shared_ptr< const DeviceBuffer > &buffer) const
Definition: tracked_objects_vk.cc:53
std
Definition: comparable.h:95
impeller::TrackedObjectsVK::TrackedObjectsVK
TrackedObjectsVK(const std::weak_ptr< const ContextVK > &context, const std::shared_ptr< CommandPoolVK > &pool, std::unique_ptr< GPUProbe > probe)
Definition: tracked_objects_vk.cc:11
impeller::TrackedObjectsVK::Track
void Track(std::shared_ptr< SharedObjectVK > object)
Definition: tracked_objects_vk.cc:39
impeller
Definition: allocation.cc:12