1 | #pragma once |
---|---|
2 | |
3 | #include <iostream> |
4 | #include <fstream> |
5 | #include <stdexcept> |
6 | #include <algorithm> |
7 | #include <chrono> |
8 | #include <vector> |
9 | #include <cstring> |
10 | #include <cstdlib> |
11 | #include <cstdint> |
12 | #include <array> |
13 | #include <optional> |
14 | #include <set> |
15 | #include "taichi/ui/utils/utils.h" |
16 | #include "taichi/ui/backends/vulkan/vertex.h" |
17 | |
18 | #include "taichi/ui/backends/vulkan/app_context.h" |
19 | #include "taichi/ui/backends/vulkan/swap_chain.h" |
20 | #include "taichi/ui/backends/vulkan/renderable.h" |
21 | #include "taichi/program/field_info.h" |
22 | #include "taichi/ui/common/canvas_base.h" |
23 | #include "taichi/rhi/device.h" |
24 | |
25 | namespace taichi::ui { |
26 | |
27 | namespace vulkan { |
28 | |
29 | class SetImage final : public Renderable { |
30 | public: |
31 | struct UniformBufferObject { |
32 | // in non_packed_mode, |
33 | // the actual image is only a corner of the whole image |
34 | float x_factor{1.0}; |
35 | float y_factor{1.0}; |
36 | int transpose{0}; |
37 | }; |
38 | |
39 | SetImage(AppContext *app_context, VertexAttributes vbo_attrs); |
40 | |
41 | void record_this_frame_commands( |
42 | taichi::lang::CommandList *command_list) final; |
43 | |
44 | void update_data(const SetImageInfo &info); |
45 | |
46 | void update_data(taichi::lang::Texture *tex); |
47 | |
48 | private: |
49 | int width_{0}; |
50 | int height_{0}; |
51 | |
52 | taichi::lang::DeviceImageUnique texture_{nullptr}; |
53 | |
54 | taichi::lang::BufferFormat format_; |
55 | |
56 | private: |
57 | void resize_texture(int width, int height, taichi::lang::BufferFormat format); |
58 | |
59 | void update_ubo(float x_factor, float y_factor, bool transpose); |
60 | }; |
61 | |
62 | } // namespace vulkan |
63 | |
64 | } // namespace taichi::ui |
65 |