Skip to content

Commit 5dad59f

Browse files
committed
Add Multi-Subpass
1 parent 5a7e535 commit 5dad59f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+34238
-182
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
/shaders export-ignore
88
/textures export-ignore
99
/src export-ignore
10+
/cmake export-ignore
1011
/CMakeLists.txt export-ignore
1112
/CMakePresets.json export-ignore

docs/codes/02/21_descriptor2/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ class HelloTriangleApplication {
988988

989989
/////////////////////////////////////////////////////////////////
990990
/// descriptor layout and buffer
991-
struct alignas(16) UniformBufferObject {
991+
struct UniformBufferObject {
992992
glm::mat4 model;
993993
glm::mat4 view;
994994
glm::mat4 proj;

docs/codes/02/21_descriptor2/main.diff

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ index 42439f0..2e9de97 100644
5252
commandBuffer.drawIndexed(static_cast<uint32_t>(indices.size()), 1, 0, 0, 0);
5353

5454
commandBuffer.endRenderPass();
55-
@@ -975,7 +988,7 @@ private:
56-
57-
/////////////////////////////////////////////////////////////////
58-
/// descriptor layout and buffer
59-
- struct UniformBufferObject {
60-
+ struct alignas(16) UniformBufferObject {
61-
glm::mat4 model;
62-
glm::mat4 view;
63-
glm::mat4 proj;
6455
@@ -1043,6 +1056,45 @@ private:
6556
memcpy(m_uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
6657
}

docs/codes/02/30_texture/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ class HelloTriangleApplication {
973973

974974
/////////////////////////////////////////////////////////////////
975975
/// descriptor layout and buffer
976-
struct alignas(16) UniformBufferObject {
976+
struct UniformBufferObject {
977977
glm::mat4 model;
978978
glm::mat4 view;
979979
glm::mat4 proj;

docs/codes/02/31_sampler/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ class HelloTriangleApplication {
970970

971971
/////////////////////////////////////////////////////////////////
972972
/// descriptor layout and buffer
973-
struct alignas(16) UniformBufferObject {
973+
struct UniformBufferObject {
974974
glm::mat4 model;
975975
glm::mat4 view;
976976
glm::mat4 proj;

docs/codes/02/32_combined/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ class HelloTriangleApplication {
976976

977977
/////////////////////////////////////////////////////////////////
978978
/// descriptor layout and buffer
979-
struct alignas(16) UniformBufferObject {
979+
struct UniformBufferObject {
980980
glm::mat4 model;
981981
glm::mat4 view;
982982
glm::mat4 proj;

docs/codes/02/40_depthbuffer/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ class HelloTriangleApplication {
10231023

10241024
/////////////////////////////////////////////////////////////////
10251025
/// descriptor layout and buffer
1026-
struct alignas(16) UniformBufferObject {
1026+
struct UniformBufferObject {
10271027
glm::mat4 model;
10281028
glm::mat4 view;
10291029
glm::mat4 proj;

docs/codes/03/00_loadmodel/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ class HelloTriangleApplication {
10241024

10251025
/////////////////////////////////////////////////////////////////
10261026
/// descriptor layout and buffer
1027-
struct alignas(16) UniformBufferObject {
1027+
struct UniformBufferObject {
10281028
glm::mat4 model;
10291029
glm::mat4 view;
10301030
glm::mat4 proj;

docs/codes/03/10_movecamera/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ class HelloTriangleApplication {
10301030

10311031
/////////////////////////////////////////////////////////////////
10321032
/// descriptor layout and buffer
1033-
struct alignas(16) UniformBufferObject {
1033+
struct UniformBufferObject {
10341034
glm::mat4 model;
10351035
glm::mat4 view;
10361036
glm::mat4 proj;

docs/codes/03/20_mipmaps/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class HelloTriangleApplication {
10361036

10371037
/////////////////////////////////////////////////////////////////
10381038
/// descriptor layout and buffer
1039-
struct alignas(16) UniformBufferObject {
1039+
struct UniformBufferObject {
10401040
glm::mat4 model;
10411041
glm::mat4 view;
10421042
glm::mat4 proj;

docs/codes/03/30_multisample/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ class HelloTriangleApplication {
10681068

10691069
/////////////////////////////////////////////////////////////////
10701070
/// descriptor layout and buffer
1071-
struct alignas(16) UniformBufferObject {
1071+
struct UniformBufferObject {
10721072
glm::mat4 model;
10731073
glm::mat4 view;
10741074
glm::mat4 proj;

docs/codes/03/40_instancedrendering/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ class HelloTriangleApplication {
11111111

11121112
/////////////////////////////////////////////////////////////////
11131113
/// descriptor layout and buffer
1114-
struct alignas(16) UniformBufferObject {
1114+
struct UniformBufferObject {
11151115
glm::mat4 view;
11161116
glm::mat4 proj;
11171117
};

docs/codes/03/40_instancedrendering/main.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ index 65aaf43..7b5d695 100644
141141
@@ -1069,7 +1112,6 @@ private:
142142
/////////////////////////////////////////////////////////////////
143143
/// descriptor layout and buffer
144-
struct alignas(16) UniformBufferObject {
144+
struct UniformBufferObject {
145145
- glm::mat4 model;
146146
glm::mat4 view;
147147
glm::mat4 proj;

docs/codes/03/50_pushconstant/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ class HelloTriangleApplication {
11331133

11341134
/////////////////////////////////////////////////////////////////
11351135
/// descriptor layout and buffer
1136-
struct alignas(16) UniformBufferObject {
1136+
struct UniformBufferObject {
11371137
glm::mat4 view;
11381138
glm::mat4 proj;
11391139
};

docs/codes/03/60_dynamicuniform/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ class HelloTriangleApplication {
11521152

11531153
/////////////////////////////////////////////////////////////////
11541154
/// descriptor layout and buffer
1155-
struct alignas(16) UniformBufferObject {
1155+
struct UniformBufferObject {
11561156
glm::mat4 view;
11571157
glm::mat4 proj;
11581158
};

docs/codes/03/70_separatesampler/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ class HelloTriangleApplication {
11791179

11801180
/////////////////////////////////////////////////////////////////
11811181
/// descriptor layout and buffer
1182-
struct alignas(16) UniformBufferObject {
1182+
struct UniformBufferObject {
11831183
glm::mat4 view;
11841184
glm::mat4 proj;
11851185
};

docs/codes/03/80_pipelinecache/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ class HelloTriangleApplication {
11821182

11831183
/////////////////////////////////////////////////////////////////
11841184
/// descriptor layout and buffer
1185-
struct alignas(16) UniformBufferObject {
1185+
struct UniformBufferObject {
11861186
glm::mat4 view;
11871187
glm::mat4 proj;
11881188
};
724 KB
Binary file not shown.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
module;
2+
3+
#include <iostream>
4+
#include <memory>
5+
6+
// #include <vulkan/vulkan.h>
7+
#include <GLFW/glfw3.h>
8+
9+
export module App;
10+
11+
import vulkan_hpp;
12+
13+
import DataLoader;
14+
import Context;
15+
import Window;
16+
import Device;
17+
import Swapchain;
18+
import DepthImage;
19+
import ShadowDepthImage;
20+
import ShadowRenderPass;
21+
import ShadowPipeline;
22+
import RenderPass;
23+
import GraphicsPipeline;
24+
import CommandPool;
25+
import InputAssembly;
26+
import UniformBuffer;
27+
import TextureSampler;
28+
import LightUniformBuffer;
29+
import Descriptor;
30+
import Drawer;
31+
32+
export namespace vht {
33+
class App {
34+
std::shared_ptr<vht::DataLoader> m_data_loader{ nullptr };
35+
std::shared_ptr<vht::Context> m_context{ nullptr };
36+
std::shared_ptr<vht::Window> m_window{ nullptr };
37+
std::shared_ptr<vht::Device> m_device{ nullptr };
38+
std::shared_ptr<vht::Swapchain> m_swapchain{ nullptr };
39+
std::shared_ptr<vht::DepthImage> m_depth_image{ nullptr };
40+
std::shared_ptr<vht::ShadowDepthImage> m_shadow_depth_image{ nullptr };
41+
std::shared_ptr<vht::ShadowRenderPass> m_shadow_render_pass{ nullptr };
42+
std::shared_ptr<vht::ShadowPipeline> m_shadow_pipeline{ nullptr };
43+
std::shared_ptr<vht::RenderPass> m_render_pass{ nullptr };
44+
std::shared_ptr<vht::GraphicsPipeline> m_graphics_pipeline{ nullptr };
45+
std::shared_ptr<vht::CommandPool> m_command_pool{ nullptr };
46+
std::shared_ptr<vht::InputAssembly> m_input_assembly{ nullptr };
47+
std::shared_ptr<vht::UniformBuffer> m_uniform_buffer{ nullptr };
48+
std::shared_ptr<vht::TextureSampler> m_texture_sampler{ nullptr };
49+
std::shared_ptr<vht::LightUniformBuffer> m_light_uniform_buffer{ nullptr };
50+
std::shared_ptr<vht::Descriptor> m_descriptor{ nullptr };
51+
std::shared_ptr<vht::Drawer> m_drawer{ nullptr };
52+
public:
53+
void run() {
54+
init();
55+
std::cout << "begin draw" << std::endl;
56+
while (!glfwWindowShouldClose(m_window->ptr())) {
57+
glfwPollEvents();
58+
m_drawer->draw();
59+
}
60+
std::cout << "device waitIdle" << std::endl;
61+
m_device->device().waitIdle();
62+
std::cout << "finished" << std::endl;
63+
}
64+
private:
65+
void init() {
66+
init_data_loader();
67+
init_vulkan();
68+
init_window();
69+
std::cout << "window created" << std::endl;
70+
init_device();
71+
std::cout << "device created" << std::endl;
72+
init_swapchain();
73+
std::cout << "swapchain created" << std::endl;
74+
init_depth_image();
75+
std::cout << "depth image created" << std::endl;
76+
init_shadow_depth_image();
77+
std::cout << "shadow depth image created" << std::endl;
78+
init_shadow_render_pass();
79+
std::cout << "shadow render pass created" << std::endl;
80+
init_shadow_pipeline();
81+
std::cout << "shadow pipeline created" << std::endl;
82+
init_render_pass();
83+
std::cout << "render pass created" << std::endl;
84+
init_graphics_pipeline();
85+
std::cout << "graphics pipeline created" << std::endl;
86+
init_command_pool();
87+
std::cout << "command pool created" << std::endl;
88+
init_input_assembly();
89+
std::cout << "input assembly created" << std::endl;
90+
init_uniform_buffer();
91+
std::cout << "uniform buffer created" << std::endl;
92+
init_texture_sampler();
93+
std::cout << "texture sampler created" << std::endl;
94+
init_light_uniform_buffer();
95+
std::cout << "light uniform buffer created" << std::endl;
96+
init_descriptor();
97+
std::cout << "descriptor created" << std::endl;
98+
init_drawer();
99+
std::cout << "drawer created" << std::endl;
100+
}
101+
void init_data_loader() { m_data_loader = std::make_shared<vht::DataLoader>(); }
102+
void init_vulkan() { m_context = std::make_shared<vht::Context>( true ); }
103+
void init_window() { m_window = std::make_shared<vht::Window>( m_context ); }
104+
void init_device() { m_device = std::make_shared<vht::Device>( m_context, m_window ); }
105+
void init_swapchain() { m_swapchain = std::make_shared<vht::Swapchain>( m_window, m_device ); }
106+
void init_depth_image() { m_depth_image = std::make_shared<vht::DepthImage>( m_device, m_swapchain ); }
107+
void init_shadow_depth_image() { m_shadow_depth_image = std::make_shared<vht::ShadowDepthImage>( m_device ); }
108+
void init_shadow_render_pass() { m_shadow_render_pass = std::make_shared<vht::ShadowRenderPass>( m_device, m_shadow_depth_image ); }
109+
void init_shadow_pipeline() { m_shadow_pipeline = std::make_shared<vht::ShadowPipeline>(m_device, m_shadow_render_pass); }
110+
void init_render_pass() { m_render_pass = std::make_shared<vht::RenderPass>( m_window, m_device, m_swapchain, m_depth_image ); }
111+
void init_graphics_pipeline() { m_graphics_pipeline = std::make_shared<vht::GraphicsPipeline>( m_device, m_render_pass ); }
112+
void init_command_pool() { m_command_pool = std::make_shared<vht::CommandPool>( m_device ); }
113+
void init_input_assembly() { m_input_assembly = std::make_shared<vht::InputAssembly>( m_data_loader, m_device, m_command_pool ); }
114+
void init_uniform_buffer() { m_uniform_buffer = std::make_shared<vht::UniformBuffer>( m_window, m_device, m_swapchain ); }
115+
void init_texture_sampler() { m_texture_sampler = std::make_shared<vht::TextureSampler>( m_device, m_command_pool ); }
116+
void init_light_uniform_buffer() { m_light_uniform_buffer = std::make_shared<vht::LightUniformBuffer>( m_device ); }
117+
void init_descriptor() {
118+
m_descriptor = std::make_shared<vht::Descriptor>(
119+
m_device,
120+
m_shadow_depth_image,
121+
m_shadow_pipeline,
122+
m_graphics_pipeline,
123+
m_uniform_buffer,
124+
m_texture_sampler,
125+
m_light_uniform_buffer
126+
);
127+
}
128+
void init_drawer() {
129+
m_drawer = std::make_shared<vht::Drawer>(
130+
m_data_loader,
131+
m_window,
132+
m_device,
133+
m_swapchain,
134+
m_shadow_render_pass,
135+
m_shadow_pipeline,
136+
m_render_pass,
137+
m_graphics_pipeline,
138+
m_command_pool,
139+
m_input_assembly,
140+
m_uniform_buffer,
141+
m_light_uniform_buffer,
142+
m_descriptor
143+
);
144+
}
145+
};
146+
}
147+
7.77 KB
Binary file not shown.

0 commit comments

Comments
 (0)