Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
edf1de4
Added vk::present_mode enum for setting the swapchain presentation mode
SpinnerX Jan 31, 2026
3ce05a8
Added the clipped parameter to swapchain_params
SpinnerX Jan 31, 2026
40a04e6
Fixed the uint size types
SpinnerX Jan 31, 2026
593a97b
WIP in fixing demo 12 for working on mac
SpinnerX Jan 31, 2026
6854915
Added a fix to ensure to enable the enumerate portability enum and ad…
SpinnerX Jan 31, 2026
66e2853
Fix variable device_type to be set to physical device type integrated…
SpinnerX Jan 31, 2026
b02086c
Fix enumerate surface format utility function to use default format i…
SpinnerX Jan 31, 2026
65c5ac2
Fixing the debug build redirection
SpinnerX Jan 31, 2026
e448d0c
Fixing the debug directives
SpinnerX Feb 1, 2026
8074c77
Demo 6 update to support working on mac by enabling portability exten…
Feb 1, 2026
0af4aef
Update demos to work on mac by adding mac-specific extensions that ar…
Feb 1, 2026
681b035
Cleaned up dead commented code
Feb 1, 2026
abd04b2
Demos update to conform for handling macos platform specific extensio…
Feb 1, 2026
cb0dc43
Fixed demo 12 for specifying to integrated gpu for macos only
Feb 1, 2026
0cda5c7
Removed raw calls to the Vulkan API's to getting swapchain images and…
SpinnerX Feb 2, 2026
1d10597
Added enum value for specifying version 1.4
SpinnerX Feb 2, 2026
16bc5dc
Comments cleanup on demo 12
SpinnerX Feb 2, 2026
84aa947
Made changes from presentable_images() to get_images()
SpinnerX Feb 2, 2026
b0855af
Addded the API update for get_images to vk::swapchain
SpinnerX Feb 2, 2026
afcd3b4
Updated demos to using version 5.0 of vulkan-cpp
SpinnerX Feb 2, 2026
48221c7
Added mip and layer count parameters exposed for texture specifications
SpinnerX Feb 2, 2026
5593802
Update: clang-format the demos
SpinnerX Feb 2, 2026
f5f3414
Update: clang-format the demo 1
SpinnerX Feb 2, 2026
c7ab805
Reorder field designators in vk::texture
SpinnerX Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 14 additions & 28 deletions demos/1-instance/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,25 @@ debug_callback(
}

std::vector<const char*>
initialize_instance_extensions() {
get_instance_extensions() {
std::vector<const char*> extension_names;
uint32_t extension_count = 0;
const char** required_extensions =
glfwGetRequiredInstanceExtensions(&extension_count);

extension_names.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
for (uint32_t i = 0; i < extension_count; i++) {
std::println("Required Extension = {}", required_extensions[i]);
extension_names.emplace_back(required_extensions[i]);
}

extension_names.emplace_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);

// An additional surface extension needs to be loaded. This extension is
// platform-specific so needs to be selected based on the platform the
// example is going to be deployed to. Preprocessor directives are used
// here to select the correct platform.
#ifdef VK_USE_PLATFORM_WIN32_KHR
extension_names.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
extensionNames.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
extensionNames.emplace_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_ANDROID_KHR
extensionNames.emplace_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
extensionNames.emplace_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
extensionNames.emplace_back(VK_MVK_MACOS_SURFACE_EXTENSION_NAME);
#endif
#ifdef USE_PLATFORM_NULLWS
extensionNames.emplace_back(VK_KHR_DISPLAY_EXTENSION_NAME);
#if defined(__APPLE__)
extension_names.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
extension_names.emplace_back(
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
#endif

return extension_names;
}

Expand Down Expand Up @@ -90,8 +77,7 @@ main() {
};

// setting up extensions
std::vector<const char*> global_extensions =
initialize_instance_extensions();
std::vector<const char*> global_extensions = get_instance_extensions();

vk::debug_message_utility debug_callback_info = {
.severity =
Expand Down
2 changes: 1 addition & 1 deletion demos/1-instance/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def requirements(self):
self.requires("glm/1.0.1")
self.requires("stb/cci.20230920")
self.requires("tinyobjloader/2.0.0-rc10")
self.requires("vulkan-cpp/4.0")
self.requires("vulkan-cpp/5.0")

def build(self):
cmake = CMake(self)
Expand Down
92 changes: 33 additions & 59 deletions demos/10-textures/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import vk;
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <algorithm>
#include <cmath>

static VKAPI_ATTR VkBool32 VKAPI_CALL
debug_callback(
Expand All @@ -32,38 +34,25 @@ debug_callback(
}

std::vector<const char*>
initialize_instance_extensions() {
get_instance_extensions() {
std::vector<const char*> extension_names;
uint32_t extension_count = 0;
const char** required_extensions =
glfwGetRequiredInstanceExtensions(&extension_count);

extension_names.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
for (uint32_t i = 0; i < extension_count; i++) {
std::println("Required Extension = {}", required_extensions[i]);
extension_names.emplace_back(required_extensions[i]);
}

extension_names.emplace_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);

// An additional surface extension needs to be loaded. This extension is
// platform-specific so needs to be selected based on the platform the
// example is going to be deployed to. Preprocessor directives are used
// here to select the correct platform.
#ifdef VK_USE_PLATFORM_WIN32_KHR
extension_names.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
extensionNames.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
extensionNames.emplace_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_ANDROID_KHR
extensionNames.emplace_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
extensionNames.emplace_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
extensionNames.emplace_back(VK_MVK_MACOS_SURFACE_EXTENSION_NAME);
#endif
#ifdef USE_PLATFORM_NULLWS
extensionNames.emplace_back(VK_KHR_DISPLAY_EXTENSION_NAME);
#if defined(__APPLE__)
extension_names.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
extension_names.emplace_back(
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
#endif

return extension_names;
}

Expand Down Expand Up @@ -106,16 +95,11 @@ main() {
};

// setting up extensions
std::vector<const char*> global_extensions =
initialize_instance_extensions();
std::vector<const char*> global_extensions = get_instance_extensions();

vk::debug_message_utility debug_callback_info = {
// .severity essentially takes in vk::message::verbose,
// vk::message::warning, vk::message::error
.severity =
vk::message::verbose | vk::message::warning | vk::message::error,
// .message_type essentially takes in vk::debug. Like:
// vk::debug::general, vk::debug::validation, vk::debug::performance
.message_type =
vk::debug::general | vk::debug::validation | vk::debug::performance,
.callback = debug_callback
Expand All @@ -137,24 +121,18 @@ main() {
std::println("\napi_instance alive and initiated!!!");
}

// TODO: Implement this as a way to setup physical devices
// vk::enumerate_physical_devices(vk::instance) -> returns
// std::span<vk::physical_device>

// setting up physical device
// TODO: Probably enforce the use of
// vk::enumerate_physical_device({.device_type =
// vk::physical_gpu::discrete})
vk::physical_enumeration enumerate_devices{
.device_type = vk::physical_gpu::discrete,
};

#if defined(__APPLE__)
enumerate_devices.device_type = vk::physical_gpu::integrated;
#endif

vk::physical_device physical_device(api_instance, enumerate_devices);

// selecting depth format
std::array<vk::format, 3> format_support = {
// VK_FORMAT_D32_SFLOAT,
// VK_FORMAT_D32_SFLOAT_S8_UINT,
// VK_FORMAT_D24_UNORM_S8_UINT,
vk::format::d32_sfloat,
vk::format::d32_sfloat_s8_uint,
vk::format::d24_unorm_s8_uint
Expand All @@ -172,7 +150,14 @@ main() {

// setting up logical device
std::array<float, 1> priorities = { 0.f };

#if defined(__APPLE__)
std::array<const char*, 2> extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME,
"VK_KHR_portability_subset" };
#else
std::array<const char*, 1> extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
#endif

vk::device_params logical_device_params = {
.queue_priorities = priorities,
.extensions = extensions,
Expand Down Expand Up @@ -204,19 +189,8 @@ main() {
surface_properties);

// querying swapchain images
// TODO: Make the images and framebuffers contained within the vk::swapchain
// Considering if you have two display they will prob have their own set of
// images to display to the two separate screens
uint32_t image_count = 0;
vkGetSwapchainImagesKHR(logical_device,
main_swapchain,
&image_count,
nullptr); // used to get the amount of images
std::vector<VkImage> images(image_count);
vkGetSwapchainImagesKHR(logical_device,
main_swapchain,
&image_count,
images.data()); // used to store in the images
std::span<const VkImage> images = main_swapchain.get_images();
uint32_t image_count = static_cast<uint32_t>(images.size());

// Creating Images
std::vector<vk::sample_image> swapchain_images(image_count);
Expand Down Expand Up @@ -279,7 +253,7 @@ main() {
.layout = vk::image_layout::color_optimal,
.samples = vk::sample_bit::count_1,
.load = vk::attachment_load::clear,
.store = vk::attachment_store::dont_care,
.store = vk::attachment_store::store,
.stencil_load = vk::attachment_load::clear,
.stencil_store = vk::attachment_store::dont_care,
.initial_layout = vk::image_layout::undefined,
Expand All @@ -294,7 +268,7 @@ main() {
.stencil_load = vk::attachment_load::clear,
.stencil_store = vk::attachment_store::dont_care,
.initial_layout = vk::image_layout::undefined,
.final_layout = vk::image_layout::present_src_khr,
.final_layout = vk::image_layout::depth_stencil_read_only_optimal,
},
};

Expand Down Expand Up @@ -506,7 +480,7 @@ main() {
vk::texture_info config_texture = {
.phsyical_memory_properties = physical_device.memory_properties(),
.filepath =
std::filesystem::path("asset_samples/container_diffuse.png")
std::filesystem::path("asset_samples/container_diffuse.png"),
};
vk::texture texture1(logical_device, config_texture);

Expand Down
2 changes: 1 addition & 1 deletion demos/10-textures/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def requirements(self):
self.requires("glm/1.0.1")
self.requires("stb/cci.20230920")
self.requires("tinyobjloader/2.0.0-rc10")
self.requires("vulkan-cpp/4.0")
self.requires("vulkan-cpp/5.0")

def build(self):
cmake = CMake(self)
Expand Down
Loading
Loading