Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing VK_KHR_portability_subset extension to [hpp_]hello_triangle[*] samples #1284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions samples/api/hello_triangle/hello_triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ void HelloTriangle::init_device()
throw std::runtime_error("Required device extensions are missing.");
}

#if (defined(VKB_ENABLE_PORTABILITY))
// VK_KHR_portability_subset must be enabled if present in the implementation (e.g on macOS/iOS with beta extensions enabled)
if (std::any_of(device_extensions.begin(),
device_extensions.end(),
[](VkExtensionProperties const &extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) == 0; }))
{
required_device_extensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
}
#endif

// The sample uses a single graphics queue
const float queue_priority = 1.0f;

Expand Down
10 changes: 10 additions & 0 deletions samples/api/hello_triangle_1_3/hello_triangle_1_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,16 @@ void HelloTriangleV13::init_device()
throw std::runtime_error("Required device extensions are missing");
}

#if (defined(VKB_ENABLE_PORTABILITY))
// VK_KHR_portability_subset must be enabled if present in the implementation (e.g on macOS/iOS with beta extensions enabled)
if (std::any_of(device_extensions.begin(),
device_extensions.end(),
[](VkExtensionProperties const &extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) == 0; }))
{
required_device_extensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
}
#endif

// Query for Vulkan 1.3 features
VkPhysicalDeviceFeatures2 query_device_features2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
VkPhysicalDeviceVulkan13Features query_vulkan13_features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES};
Expand Down
14 changes: 13 additions & 1 deletion samples/api/hpp_hello_triangle/hpp_hello_triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,22 @@ vk::Device HPPHelloTriangle::create_device(const std::vector<const char *> &requ
throw std::runtime_error("Required device extensions are missing, will try without.");
}

std::vector<const char *> active_device_extensions(required_device_extensions);

#if (defined(VKB_ENABLE_PORTABILITY))
// VK_KHR_portability_subset must be enabled if present in the implementation (e.g on macOS/iOS with beta extensions enabled)
if (std::any_of(device_extensions.begin(),
device_extensions.end(),
[](vk::ExtensionProperties const &extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) == 0; }))
{
active_device_extensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
}
#endif

// Create a device with one queue
float queue_priority = 1.0f;
vk::DeviceQueueCreateInfo queue_info({}, graphics_queue_index, 1, &queue_priority);
vk::DeviceCreateInfo device_info({}, queue_info, {}, required_device_extensions);
vk::DeviceCreateInfo device_info({}, queue_info, {}, active_device_extensions);
vk::Device device = gpu.createDevice(device_info);

// initialize function pointers for device
Expand Down
Loading