| 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/command_pool_vk.h"
8 #include "impeller/renderer/backend/vulkan/gpu_tracer_vk.h"
9
10 namespace impeller {
11
12 TrackedObjectsVK::TrackedObjectsVK(
13 const std::weak_ptr<const ContextVK>& context,
14 const std::shared_ptr<CommandPoolVK>& pool,
15 std::shared_ptr<DescriptorPoolVK> descriptor_pool,
16 std::unique_ptr<GPUProbe> probe)
17 : desc_pool_(std::move(descriptor_pool)), probe_(std::move(probe)) {
18 if (!pool) {
19 return;
20 }
21 auto buffer = pool->CreateCommandBuffer();
22 if (!buffer) {
23 return;
24 }
25 pool_ = pool;
26 buffer_ = std::move(buffer);
27 is_valid_ = true;
28 // Starting values were selected by looking at values from
29 // AiksTest.CanRenderMultipleBackdropBlurWithSingleBackdropId.
30 tracked_objects_.reserve(5);
31 tracked_buffers_.reserve(5);
32 tracked_textures_.reserve(5);
33 }
34
35 TrackedObjectsVK::~TrackedObjectsVK() {
36 if (!buffer_) {
37 return;
38 }
39 pool_->CollectCommandBuffer(std::move(buffer_));
40 }
41
42 bool TrackedObjectsVK::IsValid() const {
43 return is_valid_;
44 }
45
46 void TrackedObjectsVK::Track(const std::shared_ptr<SharedObjectVK>& object) {
47 if (!object || (!tracked_objects_.empty() &&
48 object.get() == tracked_objects_.back().get())) {
49 return;
50 }
51 tracked_objects_.emplace_back(object);
52 }
53
54 void TrackedObjectsVK::Track(
55 const std::shared_ptr<const DeviceBuffer>& buffer) {
56 if (!buffer || (!tracked_buffers_.empty() &&
57 buffer.get() == tracked_buffers_.back().get())) {
58 return;
59 }
60 tracked_buffers_.emplace_back(buffer);
61 }
62
63 void TrackedObjectsVK::Track(
64 const std::shared_ptr<const TextureSourceVK>& texture) {
65 if (!texture || (!tracked_textures_.empty() &&
66 texture.get() == tracked_textures_.back().get())) {
67 return;
68 }
69 tracked_textures_.emplace_back(texture);
70 }
71
72 vk::CommandBuffer TrackedObjectsVK::GetCommandBuffer() const {
73 return *buffer_;
74 }
75
76 DescriptorPoolVK& TrackedObjectsVK::GetDescriptorPool() {
77 return *desc_pool_;
78 }
79
80 GPUProbe& TrackedObjectsVK::GetGPUProbe() const {
81 return *probe_.get();
82 }
83
84 } // namespace impeller
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::GPUProbe
Definition: gpu_tracer_vk.h:101
impeller::TrackedObjectsVK::Track
void Track(const std::shared_ptr< SharedObjectVK > &object)
Definition: tracked_objects_vk.cc:46
impeller::TrackedObjectsVK::GetGPUProbe
GPUProbe & GetGPUProbe() const
Definition: tracked_objects_vk.cc:80
impeller::TrackedObjectsVK::GetDescriptorPool
DescriptorPoolVK & GetDescriptorPool()
Definition: tracked_objects_vk.cc:76
impeller::TrackedObjectsVK::~TrackedObjectsVK
~TrackedObjectsVK()
Definition: tracked_objects_vk.cc:35
impeller::TrackedObjectsVK::IsValid
bool IsValid() const
Definition: tracked_objects_vk.cc:42
impeller::TrackedObjectsVK::GetCommandBuffer
vk::CommandBuffer GetCommandBuffer() const
Definition: tracked_objects_vk.cc:72
impeller::TrackedObjectsVK::TrackedObjectsVK
TrackedObjectsVK(const std::weak_ptr< const ContextVK > &context, const std::shared_ptr< CommandPoolVK > &pool, std::shared_ptr< DescriptorPoolVK > descriptor_pool, std::unique_ptr< GPUProbe > probe)
Definition: tracked_objects_vk.cc:12
command_pool_vk.h
gpu_tracer_vk.h
impeller
Definition: allocation.cc:12
std
Definition: comparable.h:95
tracked_objects_vk.h