From 1cc690fcc934e83a900db4752f78a73b16b894ca Mon Sep 17 00:00:00 2001 From: swinston Date: Sat, 5 Jul 2025 11:52:32 -0700 Subject: [PATCH 1/8] Add `vulkan_hpp_intellisense.h` for improved IDE support Included `vulkan_hpp_intellisense.h` across all attachment files to resolve C++20 module intellisense issues in IDEs. --- attachments/00_base_code.cpp | 1 + attachments/01_instance_creation.cpp | 1 + attachments/02_validation_layers.cpp | 1 + attachments/03_physical_device_selection.cpp | 1 + attachments/04_logical_device.cpp | 1 + attachments/05_window_surface.cpp | 1 + attachments/06_swap_chain_creation.cpp | 1 + attachments/07_image_views.cpp | 1 + attachments/08_graphics_pipeline.cpp | 1 + attachments/09_shader_modules.cpp | 1 + attachments/10_fixed_functions.cpp | 1 + attachments/12_graphics_pipeline_complete.cpp | 1 + attachments/14_command_buffers.cpp | 1 + attachments/15_hello_triangle.cpp | 1 + attachments/16_frames_in_flight.cpp | 1 + attachments/17_swap_chain_recreation.cpp | 1 + attachments/18_vertex_input.cpp | 1 + attachments/19_vertex_buffer.cpp | 1 + attachments/20_staging_buffer.cpp | 1 + attachments/21_index_buffer.cpp | 1 + attachments/22_descriptor_layout.cpp | 1 + attachments/23_descriptor_sets.cpp | 1 + attachments/24_texture_image.cpp | 1 + attachments/25_sampler.cpp | 1 + attachments/26_texture_mapping.cpp | 1 + attachments/27_depth_buffering.cpp | 1 + attachments/28_model_loading.cpp | 1 + attachments/29_mipmapping.cpp | 1 + attachments/30_multisampling.cpp | 1 + attachments/31_compute_shader.cpp | 1 + attachments/vulkan_hpp_intellisense.h | 19 +++++++++++++++++++ 31 files changed, 49 insertions(+) create mode 100644 attachments/vulkan_hpp_intellisense.h diff --git a/attachments/00_base_code.cpp b/attachments/00_base_code.cpp index 668ac686..dd1ee1f8 100644 --- a/attachments/00_base_code.cpp +++ b/attachments/00_base_code.cpp @@ -1,3 +1,4 @@ +#include "vulkan_hpp_intellisense.h" // Include for intellisense support import vulkan_hpp; #include diff --git a/attachments/01_instance_creation.cpp b/attachments/01_instance_creation.cpp index 5e8b2e11..6c6f965c 100644 --- a/attachments/01_instance_creation.cpp +++ b/attachments/01_instance_creation.cpp @@ -3,6 +3,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/02_validation_layers.cpp b/attachments/02_validation_layers.cpp index e79a8eca..ca96bc78 100644 --- a/attachments/02_validation_layers.cpp +++ b/attachments/02_validation_layers.cpp @@ -6,6 +6,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/03_physical_device_selection.cpp b/attachments/03_physical_device_selection.cpp index 79f986c6..3fc5fb5b 100644 --- a/attachments/03_physical_device_selection.cpp +++ b/attachments/03_physical_device_selection.cpp @@ -6,6 +6,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/04_logical_device.cpp b/attachments/04_logical_device.cpp index 38f2fd5d..7a6e6684 100644 --- a/attachments/04_logical_device.cpp +++ b/attachments/04_logical_device.cpp @@ -6,6 +6,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index 46f9b704..78d11c4b 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -6,6 +6,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index aa9381e3..d1bf8cd8 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -7,6 +7,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index c10f56be..ac8fed19 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -7,6 +7,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index db785526..24c5d2da 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -7,6 +7,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index 0177367f..5b7b22d3 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index 745a1875..34792bde 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index 823b4c2e..6f73a5d4 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index 513548ee..3abd15a6 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index 3371a244..f56d8bae 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index 7bf96b5b..9ba9d5e6 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index 81db35c1..92ba5a3e 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -8,6 +8,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/18_vertex_input.cpp b/attachments/18_vertex_input.cpp index 1fcf9326..56382275 100644 --- a/attachments/18_vertex_input.cpp +++ b/attachments/18_vertex_input.cpp @@ -9,6 +9,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index 0852ed38..f3651cb1 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -9,6 +9,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index 9035f2c7..420699ad 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -9,6 +9,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index 2e66763e..e8a62aee 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -9,6 +9,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index 683f1287..cba33cc8 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index 51a40adc..4130324c 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index d8c75da0..7997fb68 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index 7d0dfb47..240aae99 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 17320e97..04afd452 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index 4533a053..568b5d13 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 9e20ad9b..b285fe85 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 8603ffd1..291779c4 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index 28089087..5ff43581 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -10,6 +10,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 6cd04534..2f6581b3 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -14,6 +14,7 @@ #include #include +#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/vulkan_hpp_intellisense.h b/attachments/vulkan_hpp_intellisense.h new file mode 100644 index 00000000..26b9deeb --- /dev/null +++ b/attachments/vulkan_hpp_intellisense.h @@ -0,0 +1,19 @@ +// This header provides a solution for intellisense issues with C++20 modules +// It allows IDEs to use traditional includes for intellisense while still using modules for compilation + +#pragma once + +// When using an IDE with intellisense (like Visual Studio, VS Code, CLion, etc.) +// the IDE will use this include path instead of the module import +#ifdef __INTELLISENSE__ +#include +#endif + +// For actual compilation, the module import will be used +// This is just a dummy declaration to prevent intellisense errors +// The real definitions come from either the module or the include above +#ifdef __INTELLISENSE__ +namespace vk { + // Add any additional declarations needed for intellisense if required +} +#endif From 729d65b382f3b6677d32fa7edfd92c0cf167bcee Mon Sep 17 00:00:00 2001 From: swinston Date: Sat, 5 Jul 2025 13:22:43 -0700 Subject: [PATCH 2/8] Remove `vulkan_hpp_intellisense.h` and adapt CMake for conditional module import - Deleted `vulkan_hpp_intellisense.h` across all attachment files. - Updated CMake to support conditional Vulkan module import using `USE_DIRECT_MODULE_IMPORT` toggle. --- attachments/00_base_code.cpp | 2 -- attachments/01_instance_creation.cpp | 1 - attachments/02_validation_layers.cpp | 1 - attachments/03_physical_device_selection.cpp | 1 - attachments/04_logical_device.cpp | 1 - attachments/05_window_surface.cpp | 1 - attachments/06_swap_chain_creation.cpp | 1 - attachments/07_image_views.cpp | 1 - attachments/08_graphics_pipeline.cpp | 1 - attachments/09_shader_modules.cpp | 1 - attachments/10_fixed_functions.cpp | 1 - attachments/12_graphics_pipeline_complete.cpp | 1 - attachments/14_command_buffers.cpp | 1 - attachments/15_hello_triangle.cpp | 1 - attachments/16_frames_in_flight.cpp | 1 - attachments/17_swap_chain_recreation.cpp | 1 - attachments/18_vertex_input.cpp | 1 - attachments/19_vertex_buffer.cpp | 1 - attachments/20_staging_buffer.cpp | 1 - attachments/21_index_buffer.cpp | 1 - attachments/22_descriptor_layout.cpp | 1 - attachments/23_descriptor_sets.cpp | 1 - attachments/24_texture_image.cpp | 1 - attachments/25_sampler.cpp | 1 - attachments/26_texture_mapping.cpp | 1 - attachments/27_depth_buffering.cpp | 1 - attachments/28_model_loading.cpp | 1 - attachments/29_mipmapping.cpp | 1 - attachments/30_multisampling.cpp | 1 - attachments/31_compute_shader.cpp | 1 - attachments/CMakeLists.txt | 26 +++++++++++++++++-- attachments/vulkan_hpp_intellisense.h | 19 -------------- 32 files changed, 24 insertions(+), 52 deletions(-) delete mode 100644 attachments/vulkan_hpp_intellisense.h diff --git a/attachments/00_base_code.cpp b/attachments/00_base_code.cpp index dd710ec3..668ac686 100644 --- a/attachments/00_base_code.cpp +++ b/attachments/00_base_code.cpp @@ -1,5 +1,3 @@ -#include "vulkan_hpp_intellisense.h" -#include import vulkan_hpp; #include diff --git a/attachments/01_instance_creation.cpp b/attachments/01_instance_creation.cpp index 2054fc7b..f4f8e0fb 100644 --- a/attachments/01_instance_creation.cpp +++ b/attachments/01_instance_creation.cpp @@ -4,7 +4,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/02_validation_layers.cpp b/attachments/02_validation_layers.cpp index 042bdbfb..af38c374 100644 --- a/attachments/02_validation_layers.cpp +++ b/attachments/02_validation_layers.cpp @@ -6,7 +6,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/03_physical_device_selection.cpp b/attachments/03_physical_device_selection.cpp index 7f3c3d0b..5e1bed52 100644 --- a/attachments/03_physical_device_selection.cpp +++ b/attachments/03_physical_device_selection.cpp @@ -6,7 +6,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/04_logical_device.cpp b/attachments/04_logical_device.cpp index e6d156c7..6fba2f6b 100644 --- a/attachments/04_logical_device.cpp +++ b/attachments/04_logical_device.cpp @@ -6,7 +6,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index fad3cb77..98c26ee7 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -6,7 +6,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index 4ae9bad0..fb6ff0d4 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -7,7 +7,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index 368b984f..9189c850 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -7,7 +7,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index 0101546d..2d4e8995 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -7,7 +7,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index c35ae2f7..97dd33fe 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index 34f9b041..bec6cbc8 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index 544c20f9..7b581584 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index d9feaa1e..caf23abe 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index dca6513a..487022e7 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index 21d9d812..7da930c4 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index 84b0e381..66913ac8 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -8,7 +8,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/18_vertex_input.cpp b/attachments/18_vertex_input.cpp index d945d00f..e35067f9 100644 --- a/attachments/18_vertex_input.cpp +++ b/attachments/18_vertex_input.cpp @@ -9,7 +9,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index 32af786c..ef7d4cd8 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -9,7 +9,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index 35a86025..1361bfbe 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -9,7 +9,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index c6320edd..3fb574b0 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -9,7 +9,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index a3342571..dfef6e4e 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index 7e3da809..a2879e22 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index 237f826c..f41383e0 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index 2c91ea95..3c6583f3 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 1d04364b..824576a2 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index 30dfd698..8c0a9e14 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 64ff9576..509430f7 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 21d22ab7..1c487b8b 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index fb377a64..450406aa 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -10,7 +10,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 286f771b..e00243d3 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -14,7 +14,6 @@ #include #include -#include "vulkan_hpp_intellisense.h" import vulkan_hpp; #include diff --git a/attachments/CMakeLists.txt b/attachments/CMakeLists.txt index 935839d4..74df01ca 100644 --- a/attachments/CMakeLists.txt +++ b/attachments/CMakeLists.txt @@ -109,14 +109,36 @@ function (add_chapter CHAPTER_NAME) set_target_properties (${CHAPTER_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CHAPTER_NAME}) set_target_properties (${CHAPTER_NAME} PROPERTIES CXX_STANDARD 20) - target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw) + + if(USE_DIRECT_MODULE_IMPORT) + # Direct module import approach - add vulkan.cppm directly to each project + target_sources(${CHAPTER_NAME} + PRIVATE + FILE_SET cxx_modules TYPE CXX_MODULES + BASE_DIRS + "${Vulkan_INCLUDE_DIR}" + FILES + "${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm" + ) + target_compile_definitions(${CHAPTER_NAME} + PRIVATE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1 + ) + target_include_directories(${CHAPTER_NAME} + PRIVATE "${Vulkan_INCLUDE_DIR}" + ) + target_link_libraries (${CHAPTER_NAME} Vulkan::Vulkan glfw) + else() + # Default approach - link to VulkanCppModule + target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw) + endif() + target_include_directories (${CHAPTER_NAME} PRIVATE ${STB_INCLUDEDIR}) if(WIN32) if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*") set_target_properties(${CHAPTER_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${CHAPTER_NAME}") endif() - endif() + endif() if (DEFINED CHAPTER_SHADER) set (CHAPTER_SHADER_TARGET ${CHAPTER_NAME}_shader) diff --git a/attachments/vulkan_hpp_intellisense.h b/attachments/vulkan_hpp_intellisense.h deleted file mode 100644 index 26b9deeb..00000000 --- a/attachments/vulkan_hpp_intellisense.h +++ /dev/null @@ -1,19 +0,0 @@ -// This header provides a solution for intellisense issues with C++20 modules -// It allows IDEs to use traditional includes for intellisense while still using modules for compilation - -#pragma once - -// When using an IDE with intellisense (like Visual Studio, VS Code, CLion, etc.) -// the IDE will use this include path instead of the module import -#ifdef __INTELLISENSE__ -#include -#endif - -// For actual compilation, the module import will be used -// This is just a dummy declaration to prevent intellisense errors -// The real definitions come from either the module or the include above -#ifdef __INTELLISENSE__ -namespace vk { - // Add any additional declarations needed for intellisense if required -} -#endif From d7b29d75d217ed5998c62148b231a48c037219e3 Mon Sep 17 00:00:00 2001 From: swinston Date: Sat, 5 Jul 2025 13:30:52 -0700 Subject: [PATCH 3/8] Add `` include to `00_base_code.cpp` --- attachments/00_base_code.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/attachments/00_base_code.cpp b/attachments/00_base_code.cpp index 668ac686..62e62cad 100644 --- a/attachments/00_base_code.cpp +++ b/attachments/00_base_code.cpp @@ -1,3 +1,4 @@ +#include import vulkan_hpp; #include From cac8d997677c4a5f6c2a13dc9fdcd055388c5db1 Mon Sep 17 00:00:00 2001 From: swinston Date: Sat, 5 Jul 2025 13:35:39 -0700 Subject: [PATCH 4/8] Add `USE_DIRECT_MODULE_IMPORT` option to CMake for improved IDE support - Introduced `USE_DIRECT_MODULE_IMPORT` toggle in CMake to allow direct use of `vulkan.cppm`. - Provides an alternative for resolving Intellisense issues in VS2022 and other IDEs. --- attachments/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/attachments/CMakeLists.txt b/attachments/CMakeLists.txt index 74df01ca..f56bfd47 100644 --- a/attachments/CMakeLists.txt +++ b/attachments/CMakeLists.txt @@ -3,6 +3,20 @@ cmake_minimum_required (VERSION 3.29) # Enable C++ module dependency scanning set(CMAKE_CXX_SCAN_FOR_MODULES ON) +# Option to use direct module import instead of VulkanCppModule +# Set this to ON if you're having intellisense issues with VS2022 +# +# To enable this option, use one of the following methods: +# 1. Command line: cmake -DUSE_DIRECT_MODULE_IMPORT=ON .. +# 2. CMake GUI: Check the USE_DIRECT_MODULE_IMPORT option +# 3. Edit CMakeCache.txt: Set USE_DIRECT_MODULE_IMPORT:BOOL=ON +# +# This option changes how the Vulkan C++ module is included in the project: +# - When OFF (default): Uses a shared VulkanCppModule library that all projects link to +# - When ON: Adds the vulkan.cppm module directly to each project, which can help with +# intellisense in VS2022 and other IDEs that have issues with C++20 modules +option(USE_DIRECT_MODULE_IMPORT "Use direct vulkan-hpp module import instead of VulkanCppModule" OFF) + project (VulkanTutorial) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") @@ -12,6 +26,7 @@ find_package (glm REQUIRED) find_package (Vulkan REQUIRED) # set up Vulkan C++ module +if(NOT USE_DIRECT_MODULE_IMPORT) add_library(VulkanCppModule) add_library(Vulkan::cppm ALIAS VulkanCppModule) @@ -43,6 +58,7 @@ target_sources(VulkanCppModule PRIVATE "${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm" ) +endif() find_package (tinyobjloader REQUIRED) From c36e2901ea59e1086c033abba77f0993c4d9ebcf Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 8 Jul 2025 09:47:38 -0700 Subject: [PATCH 5/8] Remove `USE_DIRECT_MODULE_IMPORT` and standardize Vulkan module inclusion - Eliminated `USE_DIRECT_MODULE_IMPORT` toggle from CMake configuration. - Standardized conditional Vulkan module inclusion across all attachment files with `#ifdef __INTELLISENSE__` for improved IDE compatibility. --- attachments/00_base_code.cpp | 5 +++ attachments/01_instance_creation.cpp | 5 +++ attachments/02_validation_layers.cpp | 5 +++ attachments/03_physical_device_selection.cpp | 5 +++ attachments/04_logical_device.cpp | 5 +++ attachments/05_window_surface.cpp | 5 +++ attachments/06_swap_chain_creation.cpp | 5 +++ attachments/07_image_views.cpp | 5 +++ attachments/08_graphics_pipeline.cpp | 5 +++ attachments/09_shader_modules.cpp | 5 +++ attachments/10_fixed_functions.cpp | 5 +++ attachments/12_graphics_pipeline_complete.cpp | 5 +++ attachments/14_command_buffers.cpp | 5 +++ attachments/15_hello_triangle.cpp | 5 +++ attachments/16_frames_in_flight.cpp | 5 +++ attachments/17_swap_chain_recreation.cpp | 5 +++ attachments/18_vertex_input.cpp | 5 +++ attachments/19_vertex_buffer.cpp | 5 +++ attachments/20_staging_buffer.cpp | 5 +++ attachments/21_index_buffer.cpp | 5 +++ attachments/22_descriptor_layout.cpp | 5 +++ attachments/23_descriptor_sets.cpp | 5 +++ attachments/24_texture_image.cpp | 5 +++ attachments/25_sampler.cpp | 5 +++ attachments/26_texture_mapping.cpp | 5 +++ attachments/27_depth_buffering.cpp | 5 +++ attachments/28_model_loading.cpp | 5 +++ attachments/29_mipmapping.cpp | 5 +++ attachments/30_multisampling.cpp | 5 +++ attachments/31_compute_shader.cpp | 5 +++ attachments/CMakeLists.txt | 37 +------------------ 31 files changed, 151 insertions(+), 36 deletions(-) diff --git a/attachments/00_base_code.cpp b/attachments/00_base_code.cpp index 62e62cad..22c6b0a4 100644 --- a/attachments/00_base_code.cpp +++ b/attachments/00_base_code.cpp @@ -1,5 +1,10 @@ #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif +#include #include #include diff --git a/attachments/01_instance_creation.cpp b/attachments/01_instance_creation.cpp index f4f8e0fb..0094fac2 100644 --- a/attachments/01_instance_creation.cpp +++ b/attachments/01_instance_creation.cpp @@ -4,7 +4,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/02_validation_layers.cpp b/attachments/02_validation_layers.cpp index af38c374..d3a110a5 100644 --- a/attachments/02_validation_layers.cpp +++ b/attachments/02_validation_layers.cpp @@ -6,7 +6,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/03_physical_device_selection.cpp b/attachments/03_physical_device_selection.cpp index 5e1bed52..2cdb82fc 100644 --- a/attachments/03_physical_device_selection.cpp +++ b/attachments/03_physical_device_selection.cpp @@ -6,7 +6,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/04_logical_device.cpp b/attachments/04_logical_device.cpp index 6fba2f6b..53e28ab9 100644 --- a/attachments/04_logical_device.cpp +++ b/attachments/04_logical_device.cpp @@ -6,7 +6,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index 98c26ee7..b1e3ffbd 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -6,7 +6,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index fb6ff0d4..627a0858 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -7,7 +7,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index 9189c850..4dbd9feb 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -7,7 +7,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index 2d4e8995..eb78a853 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -7,7 +7,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index 97dd33fe..c4a8011d 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index bec6cbc8..f0084633 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index 7b581584..a5d64b70 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index caf23abe..f319389e 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index 487022e7..906ae135 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index 7da930c4..9ef9bcd9 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index 66913ac8..fa192f81 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -8,7 +8,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/18_vertex_input.cpp b/attachments/18_vertex_input.cpp index e35067f9..c31319df 100644 --- a/attachments/18_vertex_input.cpp +++ b/attachments/18_vertex_input.cpp @@ -9,7 +9,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index ef7d4cd8..e2fa56bf 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -9,7 +9,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index 1361bfbe..ad942ea5 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -9,7 +9,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index 3fb574b0..cb9c788e 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -9,7 +9,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index dfef6e4e..564cafc9 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index a2879e22..2587d59a 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index f41383e0..4801a814 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index 3c6583f3..07306ec6 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 824576a2..6942feea 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index 8c0a9e14..c833e70f 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 509430f7..4eb5f4a3 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 1c487b8b..acd2257c 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index 450406aa..9bda787d 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -10,7 +10,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index e00243d3..419cf267 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -14,7 +14,12 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif + #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/CMakeLists.txt b/attachments/CMakeLists.txt index f56bfd47..e43413c8 100644 --- a/attachments/CMakeLists.txt +++ b/attachments/CMakeLists.txt @@ -3,20 +3,6 @@ cmake_minimum_required (VERSION 3.29) # Enable C++ module dependency scanning set(CMAKE_CXX_SCAN_FOR_MODULES ON) -# Option to use direct module import instead of VulkanCppModule -# Set this to ON if you're having intellisense issues with VS2022 -# -# To enable this option, use one of the following methods: -# 1. Command line: cmake -DUSE_DIRECT_MODULE_IMPORT=ON .. -# 2. CMake GUI: Check the USE_DIRECT_MODULE_IMPORT option -# 3. Edit CMakeCache.txt: Set USE_DIRECT_MODULE_IMPORT:BOOL=ON -# -# This option changes how the Vulkan C++ module is included in the project: -# - When OFF (default): Uses a shared VulkanCppModule library that all projects link to -# - When ON: Adds the vulkan.cppm module directly to each project, which can help with -# intellisense in VS2022 and other IDEs that have issues with C++20 modules -option(USE_DIRECT_MODULE_IMPORT "Use direct vulkan-hpp module import instead of VulkanCppModule" OFF) - project (VulkanTutorial) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") @@ -125,28 +111,7 @@ function (add_chapter CHAPTER_NAME) set_target_properties (${CHAPTER_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CHAPTER_NAME}) set_target_properties (${CHAPTER_NAME} PROPERTIES CXX_STANDARD 20) - - if(USE_DIRECT_MODULE_IMPORT) - # Direct module import approach - add vulkan.cppm directly to each project - target_sources(${CHAPTER_NAME} - PRIVATE - FILE_SET cxx_modules TYPE CXX_MODULES - BASE_DIRS - "${Vulkan_INCLUDE_DIR}" - FILES - "${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm" - ) - target_compile_definitions(${CHAPTER_NAME} - PRIVATE VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1 - ) - target_include_directories(${CHAPTER_NAME} - PRIVATE "${Vulkan_INCLUDE_DIR}" - ) - target_link_libraries (${CHAPTER_NAME} Vulkan::Vulkan glfw) - else() - # Default approach - link to VulkanCppModule - target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw) - endif() + target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw) target_include_directories (${CHAPTER_NAME} PRIVATE ${STB_INCLUDEDIR}) From bf8ea12cfbde2ba4478aa1dc0ec675d9cd7dffe6 Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 8 Jul 2025 12:17:37 -0700 Subject: [PATCH 6/8] Switch to `vulkan_raii.hpp` for improved resource management. Updated all Vulkan-related files to replace `vulkan.hpp` with `vulkan_raii.hpp`, leveraging its enhanced RAII features for better resource handling and reduced manual management. Also updated CMake minimum version to 3.10 in tinygltf dependency. --- attachments/00_base_code.cpp | 2 +- attachments/01_instance_creation.cpp | 2 +- attachments/02_validation_layers.cpp | 2 +- attachments/03_physical_device_selection.cpp | 2 +- attachments/04_logical_device.cpp | 2 +- attachments/05_window_surface.cpp | 2 +- attachments/06_swap_chain_creation.cpp | 2 +- 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/15_hello_triangle.cpp | 2 +- attachments/16_frames_in_flight.cpp | 2 +- attachments/17_swap_chain_recreation.cpp | 2 +- attachments/18_vertex_input.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 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/attachments/00_base_code.cpp b/attachments/00_base_code.cpp index 22c6b0a4..cb52cc17 100644 --- a/attachments/00_base_code.cpp +++ b/attachments/00_base_code.cpp @@ -1,6 +1,6 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/01_instance_creation.cpp b/attachments/01_instance_creation.cpp index 0094fac2..7e68df7f 100644 --- a/attachments/01_instance_creation.cpp +++ b/attachments/01_instance_creation.cpp @@ -5,7 +5,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/02_validation_layers.cpp b/attachments/02_validation_layers.cpp index d3a110a5..6aef3863 100644 --- a/attachments/02_validation_layers.cpp +++ b/attachments/02_validation_layers.cpp @@ -7,7 +7,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/03_physical_device_selection.cpp b/attachments/03_physical_device_selection.cpp index 2cdb82fc..05b0534d 100644 --- a/attachments/03_physical_device_selection.cpp +++ b/attachments/03_physical_device_selection.cpp @@ -7,7 +7,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/04_logical_device.cpp b/attachments/04_logical_device.cpp index 53e28ab9..341c2010 100644 --- a/attachments/04_logical_device.cpp +++ b/attachments/04_logical_device.cpp @@ -7,7 +7,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index b1e3ffbd..9fade20a 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -7,7 +7,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index 627a0858..78904904 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -8,7 +8,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index 4dbd9feb..bb6f3876 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -8,7 +8,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index eb78a853..e0627df0 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -8,7 +8,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index c4a8011d..79db06c1 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index f0084633..502da17b 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index a5d64b70..86b82f5e 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index f319389e..d8ffccee 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index 906ae135..a42aa38c 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index 9ef9bcd9..7768485a 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index fa192f81..db6e52f6 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -9,7 +9,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/18_vertex_input.cpp b/attachments/18_vertex_input.cpp index c31319df..1c60b43f 100644 --- a/attachments/18_vertex_input.cpp +++ b/attachments/18_vertex_input.cpp @@ -10,7 +10,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index e2fa56bf..3ef28e62 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -10,7 +10,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index ad942ea5..31cb9086 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -10,7 +10,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index cb9c788e..93701bfd 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -10,7 +10,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index 564cafc9..29ba1f81 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index 2587d59a..154e8fd6 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index 4801a814..16f10557 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index 07306ec6..6db818e0 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 6942feea..866796ea 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index c833e70f..d1bc4cc3 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 4eb5f4a3..448c1b0a 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index acd2257c..c22a8e91 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index 9bda787d..55a1a098 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -11,7 +11,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 419cf267..8ada44fe 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -15,7 +15,7 @@ #include #ifdef __INTELLISENSE__ -#include +#include #else import vulkan_hpp; #endif From 1ee72ec786a38f5508979bc6c387314acbe16226 Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 8 Jul 2025 12:20:11 -0700 Subject: [PATCH 7/8] Standardize Vulkan module inclusion with conditional `vulkan_raii.hpp` import for improved IntelliSense compatibility across all attachment files. --- attachments/32_ecosystem_utilities.cpp | 4 ++++ attachments/33_vulkan_profiles.cpp | 4 ++++ attachments/34_android.cpp | 4 ++++ attachments/35_gltf_ktx.cpp | 4 ++++ attachments/36_multiple_objects.cpp | 4 ++++ attachments/37_multithreading.cpp | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/attachments/32_ecosystem_utilities.cpp b/attachments/32_ecosystem_utilities.cpp index afb10aa3..ced855ae 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -11,7 +11,11 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. diff --git a/attachments/33_vulkan_profiles.cpp b/attachments/33_vulkan_profiles.cpp index 44199bfe..a9bd7883 100644 --- a/attachments/33_vulkan_profiles.cpp +++ b/attachments/33_vulkan_profiles.cpp @@ -11,7 +11,11 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif #include #include diff --git a/attachments/34_android.cpp b/attachments/34_android.cpp index 3e74c805..e72c21f0 100644 --- a/attachments/34_android.cpp +++ b/attachments/34_android.cpp @@ -11,7 +11,11 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif #include #if defined(__ANDROID__) #include diff --git a/attachments/35_gltf_ktx.cpp b/attachments/35_gltf_ktx.cpp index 20cc665e..29b11304 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -11,7 +11,11 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif #include #if defined(__ANDROID__) #include diff --git a/attachments/36_multiple_objects.cpp b/attachments/36_multiple_objects.cpp index 2cf9b8bb..2260c1ce 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -11,7 +11,11 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif #include #if defined(__ANDROID__) #include diff --git a/attachments/37_multithreading.cpp b/attachments/37_multithreading.cpp index e658961d..db4dc7ff 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -16,7 +16,11 @@ #include #include +#ifdef __INTELLISENSE__ +#include +#else import vulkan_hpp; +#endif #include #define GLFW_INCLUDE_VULKAN // REQUIRED only for GLFW CreateWindowSurface. From 9b754c6ae30556266b78a5adcef2d07d2843090f Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 8 Jul 2025 12:24:19 -0700 Subject: [PATCH 8/8] revert CMakeLists.txt --- attachments/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/attachments/CMakeLists.txt b/attachments/CMakeLists.txt index c2cd4e8a..fd1630a2 100644 --- a/attachments/CMakeLists.txt +++ b/attachments/CMakeLists.txt @@ -15,7 +15,6 @@ find_package (TinyGLTF REQUIRED) find_package (KTX REQUIRED) # set up Vulkan C++ module -if(NOT USE_DIRECT_MODULE_IMPORT) add_library(VulkanCppModule) add_library(Vulkan::cppm ALIAS VulkanCppModule) @@ -48,7 +47,6 @@ target_sources(VulkanCppModule PRIVATE "${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm" ) -endif() find_package(stb REQUIRED) set(STB_INCLUDEDIR ${stb_INCLUDE_DIRS}) @@ -107,7 +105,6 @@ function (add_chapter CHAPTER_NAME) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CHAPTER_NAME}) set_target_properties (${CHAPTER_NAME} PROPERTIES CXX_STANDARD 20) target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw) - target_include_directories (${CHAPTER_NAME} PRIVATE ${STB_INCLUDEDIR}) if(WIN32)