@@ -1252,6 +1252,19 @@ class VulkanDevice : public offloadtest::Device {
12521252 VkPhysicalDeviceVulkan14Features Features14{};
12531253 Features14.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_FEATURES ;
12541254#endif
1255+ #ifdef VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME
1256+ // Opt-in extension features: query and enable
1257+ // VK_EXT_shader_image_atomic_int64 when the device advertises it so that
1258+ // tests using 64-bit atomics on RWBuffer / RWTexture (SPIR-V image storage
1259+ // class) can run.
1260+ const auto AvailableExts = queryDeviceExtensions (PhysicalDevice);
1261+ const bool HasShaderImageAtomicInt64Ext = isExtensionSupported (
1262+ AvailableExts, VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME );
1263+ VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT
1264+ FeaturesImageAtomicInt64{};
1265+ FeaturesImageAtomicInt64.sType =
1266+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT ;
1267+ #endif
12551268
12561269 Features.pNext = &Features11;
12571270 if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 2 , 0 ))
@@ -1261,6 +1274,24 @@ class VulkanDevice : public offloadtest::Device {
12611274#ifdef VK_VERSION_1_4
12621275 if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 4 , 0 ))
12631276 Features13.pNext = &Features14;
1277+ #endif
1278+ #ifdef VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME
1279+ // Attach the extension features struct to the tail of the version-gated
1280+ // chain so vkGetPhysicalDeviceFeatures2 populates it and vkCreateDevice
1281+ // sees it enabled.
1282+ if (HasShaderImageAtomicInt64Ext) {
1283+ #ifdef VK_VERSION_1_4
1284+ if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 4 , 0 ))
1285+ Features14.pNext = &FeaturesImageAtomicInt64;
1286+ else
1287+ #endif
1288+ if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 3 , 0 ))
1289+ Features13.pNext = &FeaturesImageAtomicInt64;
1290+ else if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 2 , 0 ))
1291+ Features12.pNext = &FeaturesImageAtomicInt64;
1292+ else
1293+ Features11.pNext = &FeaturesImageAtomicInt64;
1294+ }
12641295#endif
12651296 vkGetPhysicalDeviceFeatures2 (PhysicalDevice, &Features);
12661297
@@ -1290,6 +1321,16 @@ class VulkanDevice : public offloadtest::Device {
12901321 DeviceInfo.pEnabledFeatures = &Features.features ;
12911322 DeviceInfo.pNext = Features.pNext ;
12921323
1324+ #ifdef VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME
1325+ llvm::SmallVector<const char *, 1 > EnabledDeviceExtensions;
1326+ if (HasShaderImageAtomicInt64Ext &&
1327+ FeaturesImageAtomicInt64.shaderImageInt64Atomics )
1328+ EnabledDeviceExtensions.push_back (
1329+ VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME );
1330+ DeviceInfo.enabledExtensionCount = EnabledDeviceExtensions.size ();
1331+ DeviceInfo.ppEnabledExtensionNames = EnabledDeviceExtensions.data ();
1332+ #endif
1333+
12931334 VkDevice Device = VK_NULL_HANDLE ;
12941335 if (auto Err = VK::toError (
12951336 vkCreateDevice (PhysicalDevice, &DeviceInfo, nullptr , &Device),
@@ -2197,6 +2238,14 @@ class VulkanDevice : public offloadtest::Device {
21972238 VkPhysicalDeviceVulkan14Features Features14{};
21982239 Features14.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_FEATURES ;
21992240#endif
2241+ #ifdef VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME
2242+ VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT
2243+ FeaturesImageAtomicInt64{};
2244+ FeaturesImageAtomicInt64.sType =
2245+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT ;
2246+ const bool HasShaderImageAtomicInt64Ext = isExtensionSupported (
2247+ DeviceExtensions, VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME );
2248+ #endif
22002249
22012250 Features.pNext = &Features11;
22022251 if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 2 , 0 ))
@@ -2206,6 +2255,27 @@ class VulkanDevice : public offloadtest::Device {
22062255#ifdef VK_VERSION_1_4
22072256 if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 4 , 0 ))
22082257 Features13.pNext = &Features14;
2258+ #endif
2259+ #ifdef VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME
2260+ // Append the VK_EXT_shader_image_atomic_int64 features struct to the
2261+ // pNext chain, but only if the device advertises the extension --
2262+ // otherwise drivers may reject the unknown sType. The chain above is
2263+ // built version-by-version (11 -> 12 -> 13 -> 14), so the correct
2264+ // attachment point is whichever Features1X struct is currently the
2265+ // tail for this device's apiVersion.
2266+ if (HasShaderImageAtomicInt64Ext) {
2267+ #ifdef VK_VERSION_1_4
2268+ if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 4 , 0 ))
2269+ Features14.pNext = &FeaturesImageAtomicInt64;
2270+ else
2271+ #endif
2272+ if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 3 , 0 ))
2273+ Features13.pNext = &FeaturesImageAtomicInt64;
2274+ else if (Props.apiVersion >= VK_MAKE_API_VERSION (0 , 1 , 2 , 0 ))
2275+ Features12.pNext = &FeaturesImageAtomicInt64;
2276+ else
2277+ Features11.pNext = &FeaturesImageAtomicInt64;
2278+ }
22092279#endif
22102280 vkGetPhysicalDeviceFeatures2 (PhysicalDevice, &Features);
22112281
@@ -2239,6 +2309,12 @@ class VulkanDevice : public offloadtest::Device {
22392309 Caps.insert ( \
22402310 std::make_pair (#Name, makeCapability<bool >(#Name, Features14.Name )));
22412311#endif
2312+ #ifdef VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME
2313+ #define VULKAN_EXT_SHADER_IMAGE_ATOMIC_INT64_FEATURE_BOOL (Name ) \
2314+ Caps.insert (std::make_pair ( \
2315+ #Name, makeCapability<bool >(#Name, HasShaderImageAtomicInt64Ext && \
2316+ FeaturesImageAtomicInt64.Name )));
2317+ #endif
22422318#include " VKFeatures.def"
22432319 }
22442320
0 commit comments