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