Skip to content

Commit baa7f2b

Browse files
committed
Refactor Vulkan physical device property queries to use templated getProperties2/getFeatures2
Replace manual pNext chaining with type-safe templated Vulkan-Hpp methods for querying PhysicalDeviceIDProperties and PhysicalDevicePresentBarrierFeaturesNV. Update code examples in hardware alignment, CAVE architecture, and renderer_core.cpp to use getProperties2<>/getFeatures2<> with compile-time type specification and .get<>() accessor pattern.
1 parent e251a24 commit baa7f2b

4 files changed

Lines changed: 8 additions & 15 deletions

File tree

attachments/openxr_engine/renderer_core.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,8 @@ bool Renderer::pickPhysicalDevice() {
715715

716716
if (xrMode) {
717717
// Match the LUID provided by OpenXR
718-
vk::PhysicalDeviceIDProperties idProps;
719-
vk::PhysicalDeviceProperties2 props2;
720-
props2.pNext = &idProps;
721-
_device.getProperties2(&props2);
718+
auto props2 = _device.getProperties2<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties>();
719+
const auto& idProps = props2.get<vk::PhysicalDeviceIDProperties>();
722720

723721
const uint8_t* requiredLuid = xrContext.getRequiredLUID();
724722
if (requiredLuid && std::memcmp(idProps.deviceLUID, requiredLuid, VK_LUID_SIZE) != 0) {

en/OpenXR_Vulkan_Spatial_Computing/02_OpenXR_Vulkan_Handshake/03_hardware_alignment_luid.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ To find the LUID of a Vulkan physical device, we query the `VkPhysicalDeviceIDPr
4040
----
4141
// Iterating through physical devices to find a match
4242
for (const auto& physicalDevice : instance.enumeratePhysicalDevices()) {
43-
vk::PhysicalDeviceIDProperties idProps;
44-
vk::PhysicalDeviceProperties2 props2;
45-
props2.pNext = &idProps;
46-
physicalDevice.getProperties2(&props2);
43+
auto props2 = physicalDevice.getProperties2<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties>();
44+
const auto& idProps = props2.get<vk::PhysicalDeviceIDProperties>();
4745
4846
if (idProps.deviceLUIDValid) {
4947
// Compare the 8-byte LUID against the target from OpenXR

en/OpenXR_Vulkan_Spatial_Computing/02_OpenXR_Vulkan_Handshake/05_incorporating_into_the_engine.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ bool Renderer::pickPhysicalDevice() {
134134
for (auto& _device : devices) {
135135
if (xrMode) {
136136
// Match the LUID provided by OpenXR
137-
vk::PhysicalDeviceIDProperties idProps;
138-
vk::PhysicalDeviceProperties2 props2;
139-
props2.pNext = &idProps;
140-
_device.getProperties2(&props2);
137+
auto props2 = _device.getProperties2<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties>();
138+
const auto& idProps = props2.get<vk::PhysicalDeviceIDProperties>();
141139
142140
const uint8_t* requiredLuid = xrContext.getRequiredLUID();
143141
if (requiredLuid && std::memcmp(idProps.deviceLUID, requiredLuid, VK_LUID_SIZE) != 0) {

en/OpenXR_Vulkan_Spatial_Computing/12_CAVE_Architecture/03_hardware_sync.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ We use the **VK_NV_present_barrier** extension to join these hardware groups.
2525
[source,cpp]
2626
----
2727
// Checking for Present Barrier support and joining a group
28-
vk::PhysicalDevicePresentBarrierFeaturesNV barrierFeatures{};
29-
vk::PhysicalDeviceFeatures2 features2{ &barrierFeatures };
30-
physicalDevice.getFeatures2(&features2);
28+
auto features2 = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDevicePresentBarrierFeaturesNV>();
29+
const auto& barrierFeatures = features2.get<vk::PhysicalDevicePresentBarrierFeaturesNV>();
3130
3231
if (barrierFeatures.presentBarrier) {
3332
// When creating the swapchain, we join Barrier 1

0 commit comments

Comments
 (0)