Skip to content

Commit 492a7cb

Browse files
authored
Fix vulkan validation error for device init (#383)
The valdiation layer produces a warning if we use a features structure that is higher version than the device's API version.
1 parent 36a87a8 commit 492a7cb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/API/VK/Device.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,13 @@ class VKDevice : public offloadtest::Device {
330330
#endif
331331

332332
Features.pNext = &Features11;
333-
Features11.pNext = &Features12;
334-
Features12.pNext = &Features13;
333+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 2, 0))
334+
Features11.pNext = &Features12;
335+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 3, 0))
336+
Features12.pNext = &Features13;
335337
#ifdef VK_VERSION_1_4
336-
Features13.pNext = &Features14;
338+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 4, 0))
339+
Features13.pNext = &Features14;
337340
#endif
338341
vkGetPhysicalDeviceFeatures2(Device, &Features);
339342

@@ -437,10 +440,13 @@ class VKDevice : public offloadtest::Device {
437440
#endif
438441

439442
Features.pNext = &Features11;
440-
Features11.pNext = &Features12;
441-
Features12.pNext = &Features13;
443+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 2, 0))
444+
Features11.pNext = &Features12;
445+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 3, 0))
446+
Features12.pNext = &Features13;
442447
#ifdef VK_VERSION_1_4
443-
Features13.pNext = &Features14;
448+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 4, 0))
449+
Features13.pNext = &Features14;
444450
#endif
445451
vkGetPhysicalDeviceFeatures2(Device, &Features);
446452

0 commit comments

Comments
 (0)