| Flutter Impeller |

device_buffer_vk.h
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 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DEVICE_BUFFER_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DEVICE_BUFFER_VK_H_
7
8 #include <memory>
9
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/trace_event.h"
12 #include "impeller/base/backend_cast.h"
13 #include "impeller/core/device_buffer.h"
14 #include "impeller/renderer/backend/vulkan/context_vk.h"
15 #include "impeller/renderer/backend/vulkan/resource_manager_vk.h"
16 #include "impeller/renderer/backend/vulkan/vma.h"
17
18 namespace impeller {
19
20 class DeviceBufferVK final : public DeviceBuffer,
21 public BackendCast<DeviceBufferVK, Buffer> {
22 public:
23 DeviceBufferVK(DeviceBufferDescriptor desc,
24 std::weak_ptr<Context> context,
25 UniqueBufferVMA buffer,
26 VmaAllocationInfo info);
27
28 // |DeviceBuffer|
29 ~DeviceBufferVK() override;
30
31 vk::Buffer GetBuffer() const;
32
33 private:
34 friend class AllocatorVK;
35
36 struct BufferResource {
37 UniqueBufferVMA buffer;
38 VmaAllocationInfo info = {};
39
40 BufferResource() = default;
41
42 BufferResource(UniqueBufferVMA p_buffer, VmaAllocationInfo p_info)
43 : buffer(std::move(p_buffer)), info(p_info) {}
44
45 BufferResource(BufferResource&& o) {
46 std::swap(o.buffer, buffer);
47 std::swap(o.info, info);
48 }
49
50 BufferResource(const BufferResource&) = delete;
51
52 BufferResource& operator=(const BufferResource&) = delete;
53 };
54
55 std::weak_ptr<Context> context_;
56 UniqueResourceVKT<BufferResource> resource_;
57
58 // |DeviceBuffer|
59 uint8_t* OnGetContents() const override;
60
61 // |DeviceBuffer|
62 bool OnCopyHostBuffer(const uint8_t* source,
63 Range source_range,
64 size_t offset) override;
65
66 // |DeviceBuffer|
67 bool SetLabel(const std::string& label) override;
68
69 // |DeviceBuffer|
70 bool SetLabel(const std::string& label, Range range) override;
71
72 DeviceBufferVK(const DeviceBufferVK&) = delete;
73
74 DeviceBufferVK& operator=(const DeviceBufferVK&) = delete;
75 };
76
77 } // namespace impeller
78
79 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DEVICE_BUFFER_VK_H_
impeller::DeviceBufferVK::GetBuffer
vk::Buffer GetBuffer() const
Definition: device_buffer_vk.cc:70
impeller::DeviceBuffer
Definition: device_buffer.h:20
impeller::DeviceBufferVK::DeviceBufferVK
DeviceBufferVK(DeviceBufferDescriptor desc, std::weak_ptr< Context > context, UniqueBufferVMA buffer, VmaAllocationInfo info)
Definition: device_buffer_vk.cc:11
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
impeller::DeviceBufferVK::~DeviceBufferVK
~DeviceBufferVK() override
device_buffer.h
impeller::AllocatorVK
Definition: allocator_vk.h:22
backend_cast.h
resource_manager_vk.h
std
Definition: comparable.h:95
impeller::BackendCast
Definition: backend_cast.h:13
vma.h
impeller::DeviceBufferVK
Definition: device_buffer_vk.h:20
context_vk.h
impeller::UniqueBufferVMA
fml::UniqueObject< BufferVMA, BufferVMATraits > UniqueBufferVMA
Definition: vma.h:98
impeller
Definition: aiks_context.cc:10
impeller::BufferResource
Resource< BufferView > BufferResource
Definition: command.h:57