Flutter Engine
 
Loading...
Searching...
No Matches
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
14
15namespace impeller {
16
17class DeviceBufferVK final : public DeviceBuffer,
18 public BackendCast<DeviceBufferVK, DeviceBuffer> {
19 public:
21 std::weak_ptr<Context> context,
22 UniqueBufferVMA buffer,
23 VmaAllocationInfo info,
24 bool is_host_coherent);
25
26 // |DeviceBuffer|
27 ~DeviceBufferVK() override;
28
29 vk::Buffer GetBuffer() const;
30
31 // Visible for testing.
32 bool IsHostCoherent() const;
33
34 private:
35 friend class AllocatorVK;
36
37 struct BufferResource {
38 UniqueBufferVMA buffer;
39 VmaAllocationInfo info = {};
40
41 BufferResource() = default;
42
43 BufferResource(UniqueBufferVMA p_buffer, VmaAllocationInfo p_info)
44 : buffer(std::move(p_buffer)), info(p_info) {}
45
46 BufferResource(BufferResource&& o) {
47 std::swap(o.buffer, buffer);
48 std::swap(o.info, info);
49 }
50
51 BufferResource(const BufferResource&) = delete;
52
53 BufferResource& operator=(const BufferResource&) = delete;
54 };
55
56 std::weak_ptr<Context> context_;
57 UniqueResourceVKT<BufferResource> resource_;
58 bool is_host_coherent_ = false;
59
60 // |DeviceBuffer|
61 uint8_t* OnGetContents() const override;
62
63 // |DeviceBuffer|
64 bool OnCopyHostBuffer(const uint8_t* source,
65 Range source_range,
66 size_t offset) override;
67
68 // |DeviceBuffer|
69 bool SetLabel(std::string_view label) override;
70
71 // |DeviceBuffer|
72 bool SetLabel(std::string_view label, Range range) override;
73
74 // |DeviceBuffer|
75 void Flush(std::optional<Range> range) const override;
76
77 // |DeviceBuffer|
78 void Invalidate(std::optional<Range> range) const override;
79
80 DeviceBufferVK(const DeviceBufferVK&) = delete;
81
82 DeviceBufferVK& operator=(const DeviceBufferVK&) = delete;
83};
84
85} // namespace impeller
86
87#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_DEVICE_BUFFER_VK_H_
DeviceBufferVK(DeviceBufferDescriptor desc, std::weak_ptr< Context > context, UniqueBufferVMA buffer, VmaAllocationInfo info, bool is_host_coherent)
vk::Buffer GetBuffer() const
Resource< BufferView > BufferResource
Definition command.h:55
Definition ref_ptr.h:261