1#pragma once
2
3#include <taichi/rhi/device.h>
4
5namespace taichi::ui {
6namespace vulkan {
7
8class TI_DLL_EXPORT SwapChain {
9 public:
10 void init(class AppContext *app_context);
11 ~SwapChain();
12
13 uint32_t width();
14 uint32_t height();
15
16 taichi::lang::Surface &surface();
17 taichi::lang::DeviceAllocation depth_allocation();
18
19 void resize(uint32_t width, uint32_t height);
20
21 bool copy_depth_buffer_to_ndarray(taichi::lang::DevicePtr &arr_dev_ptr);
22
23 std::vector<uint32_t> &dump_image_buffer();
24
25 void write_image(const std::string &filename);
26
27 private:
28 void create_depth_resources();
29
30 std::unique_ptr<taichi::lang::Surface> surface_{nullptr};
31 taichi::lang::DeviceImageUnique depth_allocation_{nullptr};
32
33 std::vector<uint32_t> image_buffer_data_;
34
35 class AppContext *app_context_;
36
37 uint32_t curr_width_;
38 uint32_t curr_height_;
39};
40
41} // namespace vulkan
42
43} // namespace taichi::ui
44