MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / prepare

Method prepare

samples/performance/subpasses/subpasses.cpp:106–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106bool Subpasses::prepare(const vkb::ApplicationOptions &options)
107{
108 if (!VulkanSample::prepare(options))
109 {
110 return false;
111 }
112
113 std::set<VkImageUsageFlagBits> usage = {VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT};
114 get_render_context().update_swapchain(usage);
115
116 load_scene("scenes/sponza/Sponza01.gltf");
117
118 get_scene().clear_components<vkb::sg::Light>();
119
120 auto light_pos = glm::vec3(0.0f, 128.0f, -225.0f);
121 auto light_color = glm::vec3(1.0, 1.0, 1.0);
122
123 // Magic numbers used to offset lights in the Sponza scene
124 for (int i = -4; i < 4; ++i)
125 {
126 for (int j = 0; j < 2; ++j)
127 {
128 glm::vec3 pos = light_pos;
129 pos.x += i * 400;
130 pos.z += j * (225 + 140);
131 pos.y = 8;
132
133 for (int k = 0; k < 3; ++k)
134 {
135 pos.y = pos.y + (k * 100);
136
137 light_color.x = static_cast<float>(rand()) / (RAND_MAX);
138 light_color.y = static_cast<float>(rand()) / (RAND_MAX);
139 light_color.z = static_cast<float>(rand()) / (RAND_MAX);
140
141 vkb::sg::LightProperties props;
142 props.color = light_color;
143 props.intensity = 0.2f;
144
145 vkb::add_point_light(get_scene(), pos, props);
146 }
147 }
148 }
149
150 auto &camera_node = vkb::add_free_camera(get_scene(), "main_camera", get_render_context().get_surface_extent());
151 camera = dynamic_cast<vkb::sg::PerspectiveCamera *>(&camera_node.get_component<vkb::sg::Camera>());
152
153 render_pipeline = create_one_renderpass_two_subpasses();
154
155 geometry_render_pipeline = create_geometry_renderpass();
156 lighting_render_pipeline = create_lighting_renderpass();
157
158 // Enable stats
159 get_stats().request_stats({vkb::StatIndex::frame_times,
160 vkb::StatIndex::gpu_fragment_jobs,
161 vkb::StatIndex::gpu_tiles,
162 vkb::StatIndex::gpu_ext_read_bytes,
163 vkb::StatIndex::gpu_ext_write_bytes});

Callers 1

Calls 2

update_swapchainMethod · 0.80
request_statsMethod · 0.80

Tested by

no test coverage detected