diff --git a/.gitignore b/.gitignore index 34a179d7..5a4347ec 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ temp_ebook.md ebook/*.pdf ebook/*.epub -convert.py \ No newline at end of file +convert.py + +attachments/build/ \ No newline at end of file diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index 8d6e740c..790832af 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -267,7 +267,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index c17ac744..58d09622 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -268,7 +268,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index 44c02678..e547e0ee 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -269,7 +269,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index 7b1ca2d6..e63602d2 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -271,7 +271,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index 21444daf..9062d84b 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -272,7 +272,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index 00c9b90a..9ecb70bb 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -276,7 +276,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index 2b1ea167..796d1507 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -285,7 +285,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index d98a8031..6321c631 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -289,7 +289,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index 94e1f581..16ac1343 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -316,7 +316,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/18_vertex_input.cpp b/attachments/18_vertex_input.cpp index e8dd513e..010059b4 100644 --- a/attachments/18_vertex_input.cpp +++ b/attachments/18_vertex_input.cpp @@ -340,7 +340,7 @@ class HelloTriangleApplication { } void createImageViews() { - swapChainImageViews.clear(); + assert(swapChainImageViews.empty()); vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index 48032fd1..d50a5e0c 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -344,6 +344,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index 7618e174..2b056975 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -344,6 +344,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index 7eab95c6..d727fce9 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -352,6 +352,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index 4eb2bdd5..4addf1ec 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -369,6 +369,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index 03add3f2..ed2839b4 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -374,6 +374,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index 901bfdcc..9773cceb 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -381,6 +381,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index af435325..b2571173 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -386,6 +386,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 16fc5cc2..30cda574 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -388,6 +388,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1 } }; for ( auto image : swapChainImages ) diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index 248345df..ebb596a6 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -401,6 +401,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 791a6539..5c72ab66 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -405,6 +405,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 6f941097..4a0455f0 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -405,6 +405,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index ed8132fb..bd5a4d06 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -414,6 +414,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 420dad15..e2ef808a 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -393,6 +393,8 @@ class ComputeShaderApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/32_ecosystem_utilities.cpp b/attachments/32_ecosystem_utilities.cpp index 18f9e914..ce1747e1 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -517,6 +517,8 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/33_vulkan_profiles.cpp b/attachments/33_vulkan_profiles.cpp index 4dee36c6..3f15a6dd 100644 --- a/attachments/33_vulkan_profiles.cpp +++ b/attachments/33_vulkan_profiles.cpp @@ -237,6 +237,7 @@ class HelloTriangleApplication { imageView = nullptr; } + swapChainImageViews.clear(); swapChain = nullptr; } @@ -493,6 +494,7 @@ class HelloTriangleApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); swapChainImageViews.reserve(swapChainImages.size()); for (const auto& image : swapChainImages) { diff --git a/attachments/34_android.cpp b/attachments/34_android.cpp index a4bf7396..10afe987 100644 --- a/attachments/34_android.cpp +++ b/attachments/34_android.cpp @@ -612,6 +612,7 @@ class HelloTriangleApplication { // Create image views void createImageViews() { + assert(swapChainImageViews.empty()); swapChainImageViews.reserve(swapChainImages.size()); for (const auto& image : swapChainImages) { @@ -1202,6 +1203,7 @@ class HelloTriangleApplication { imageView = nullptr; } + swapChainImageViews.clear(); swapChain = nullptr; } diff --git a/attachments/35_gltf_ktx.cpp b/attachments/35_gltf_ktx.cpp index b8db78b4..ea73cd51 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -587,6 +587,8 @@ class VulkanApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/36_multiple_objects.cpp b/attachments/36_multiple_objects.cpp index d23221cc..ec3df1a6 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -651,6 +651,8 @@ class VulkanApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, diff --git a/attachments/37_multithreading.cpp b/attachments/37_multithreading.cpp index b08274c6..49f1720a 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -608,6 +608,8 @@ class MultithreadedApplication { } void createImageViews() { + assert(swapChainImageViews.empty()); + vk::ImageViewCreateInfo imageViewCreateInfo{ .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format,