Skip to content

Commit b96d712

Browse files
committed
Fix vulkan validation error for device init (llvm#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 9f63db7 commit b96d712

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
@@ -383,10 +383,13 @@ class VKDevice : public offloadtest::Device {
383383
#endif
384384

385385
Features.pNext = &Features11;
386-
Features11.pNext = &Features12;
387-
Features12.pNext = &Features13;
386+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 2, 0))
387+
Features11.pNext = &Features12;
388+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 3, 0))
389+
Features12.pNext = &Features13;
388390
#ifdef VK_VERSION_1_4
389-
Features13.pNext = &Features14;
391+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 4, 0))
392+
Features13.pNext = &Features14;
390393
#endif
391394
vkGetPhysicalDeviceFeatures2(Device, &Features);
392395

@@ -509,10 +512,13 @@ class VKDevice : public offloadtest::Device {
509512
#endif
510513

511514
Features.pNext = &Features11;
512-
Features11.pNext = &Features12;
513-
Features12.pNext = &Features13;
515+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 2, 0))
516+
Features11.pNext = &Features12;
517+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 3, 0))
518+
Features12.pNext = &Features13;
514519
#ifdef VK_VERSION_1_4
515-
Features13.pNext = &Features14;
520+
if (Props.apiVersion >= VK_MAKE_API_VERSION(0, 1, 4, 0))
521+
Features13.pNext = &Features14;
516522
#endif
517523
vkGetPhysicalDeviceFeatures2(Device, &Features);
518524

0 commit comments

Comments
 (0)