From 12c6467bc6ccaf073a8bd67ce0a858f8749c060f Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Sat, 22 Nov 2025 13:55:24 +0100 Subject: [PATCH] Make image in loop a referene --- attachments/07_image_views.cpp | 2 +- attachments/08_graphics_pipeline.cpp | 2 +- attachments/09_shader_modules.cpp | 2 +- attachments/10_fixed_functions.cpp | 2 +- attachments/12_graphics_pipeline_complete.cpp | 2 +- attachments/14_command_buffers.cpp | 2 +- attachments/16_frames_in_flight.cpp | 2 +- attachments/17_swap_chain_recreation.cpp | 2 +- attachments/19_vertex_buffer.cpp | 2 +- attachments/20_staging_buffer.cpp | 2 +- attachments/21_index_buffer.cpp | 2 +- attachments/22_descriptor_layout.cpp | 2 +- attachments/23_descriptor_sets.cpp | 2 +- attachments/24_texture_image.cpp | 2 +- attachments/25_sampler.cpp | 2 +- attachments/26_texture_mapping.cpp | 2 +- attachments/27_depth_buffering.cpp | 2 +- attachments/28_model_loading.cpp | 2 +- attachments/29_mipmapping.cpp | 2 +- attachments/30_multisampling.cpp | 2 +- attachments/31_compute_shader.cpp | 2 +- attachments/32_ecosystem_utilities.cpp | 2 +- attachments/35_gltf_ktx.cpp | 2 +- attachments/36_multiple_objects.cpp | 2 +- attachments/37_multithreading.cpp | 2 +- attachments/38_ray_tracing.cpp | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index a8d93cbc..c2a2a8e8 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -277,7 +277,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index 839429d7..8c6a60c8 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -278,7 +278,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index ab7964ce..24ddf95c 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -288,7 +288,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index 3cb74ff2..f90ee1ef 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -290,7 +290,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index 9231d9c0..06c19c1b 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -291,7 +291,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index db987bda..77c9d7ae 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -295,7 +295,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index f9798e15..70245bee 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -308,7 +308,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index da4356fd..266554a6 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -341,7 +341,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index 4a2bc61a..db73209b 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -362,7 +362,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index a9c058eb..4795ed30 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -362,7 +362,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index 913107a1..55b961d4 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -369,7 +369,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index c6994f12..18d21af7 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -387,7 +387,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index e6c5f93c..abfb0934 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -392,7 +392,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index a0d9ee99..2949ec95 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -399,7 +399,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index b107f5d6..ab82cfae 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -402,7 +402,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 8671a207..8353d574 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -404,7 +404,7 @@ class HelloTriangleApplication 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) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index 3a804d8b..dc1bcd78 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -420,7 +420,7 @@ class HelloTriangleApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 7db1bb9c..802657ec 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -429,7 +429,7 @@ class HelloTriangleApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 800523cf..e79e5e20 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -429,7 +429,7 @@ class HelloTriangleApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index 48deec83..353bd18c 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -438,7 +438,7 @@ class HelloTriangleApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 13a8b085..de534694 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -413,7 +413,7 @@ class ComputeShaderApplication .format = swapChainSurfaceFormat.format, .components = {vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity}, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/32_ecosystem_utilities.cpp b/attachments/32_ecosystem_utilities.cpp index d0c8c814..c1ffbfdb 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -568,7 +568,7 @@ class HelloTriangleApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/35_gltf_ktx.cpp b/attachments/35_gltf_ktx.cpp index 1b8853c1..06a5061d 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -639,7 +639,7 @@ class VulkanApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/36_multiple_objects.cpp b/attachments/36_multiple_objects.cpp index 19f85865..b66eafd7 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -712,7 +712,7 @@ class VulkanApplication .viewType = vk::ImageViewType::e2D, .format = swapChainSurfaceFormat.format, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/37_multithreading.cpp b/attachments/37_multithreading.cpp index 953b6493..8c5f83b4 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -704,7 +704,7 @@ class MultithreadedApplication .format = swapChainSurfaceFormat.format, .components = {vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity}, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo); diff --git a/attachments/38_ray_tracing.cpp b/attachments/38_ray_tracing.cpp index 05bf70ed..87d6325f 100644 --- a/attachments/38_ray_tracing.cpp +++ b/attachments/38_ray_tracing.cpp @@ -539,7 +539,7 @@ class VulkanRaytracingApplication .viewType = vk::ImageViewType::e2D, .format = swapChainImageFormat, .subresourceRange = {vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}}; - for (auto image : swapChainImages) + for (auto& image : swapChainImages) { imageViewCreateInfo.image = image; swapChainImageViews.emplace_back(device, imageViewCreateInfo);