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

Method resize

framework/api_vulkan_sample.cpp:118–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118bool ApiVulkanSample::resize(const uint32_t _width, const uint32_t _height)
119{
120 if (!prepared)
121 {
122 return false;
123 }
124
125 get_render_context().handle_surface_changes();
126
127 // Don't recreate the swapchain if the dimensions haven't changed
128 if (width == get_render_context().get_surface_extent().width && height == get_render_context().get_surface_extent().height)
129 {
130 return false;
131 }
132
133 width = get_render_context().get_surface_extent().width;
134 height = get_render_context().get_surface_extent().height;
135
136 prepared = false;
137
138 // Ensure all operations on the device have been finished before destroying resources
139 get_device().wait_idle();
140
141 create_swapchain_buffers();
142
143 // Recreate the frame buffers
144 vkDestroyImageView(get_device().get_handle(), depth_stencil.view, nullptr);
145 vkDestroyImage(get_device().get_handle(), depth_stencil.image, nullptr);
146 vkFreeMemory(get_device().get_handle(), depth_stencil.mem, nullptr);
147 setup_depth_stencil();
148 for (uint32_t i = 0; i < framebuffers.size(); i++)
149 {
150 vkDestroyFramebuffer(get_device().get_handle(), framebuffers[i], nullptr);
151 framebuffers[i] = VK_NULL_HANDLE;
152 }
153 setup_framebuffer();
154
155 if ((width > 0.0f) && (height > 0.0f))
156 {
157 if (has_gui())
158 {
159 get_gui().resize(width, height);
160 }
161 }
162
163 rebuild_command_buffers();
164
165 get_device().wait_idle();
166
167 if ((width > 0.0f) && (height > 0.0f))
168 {
169 camera.update_aspect_ratio(static_cast<float>(width) / static_cast<float>(height));
170 }
171
172 // Notify derived class
173 view_changed();
174
175 prepared = true;

Callers 4

setup_framebufferMethod · 0.45

Calls 5

sizeMethod · 0.80
update_aspect_ratioMethod · 0.80
wait_idleMethod · 0.45
get_handleMethod · 0.45

Tested by

no test coverage detected