Fix test_vulkan_interop_buffer validation errors for Int8 storage shader (#2603)

Fixes vulkan validation layer error:

Vulkan validation layer: Validation Error: [
VUID-VkShaderModuleCreateInfo-pCode-08740 ] | MessageID = 0x6e224e9 |
vkCreateComputePipelines(): pCreateInfos[0].stage SPIR-V Capability Int8
was declared, but one of the following requirements is required
(VkPhysicalDeviceVulkan12Features::shaderInt8). The Vulkan spec states:
If pCode is a pointer to SPIR-V code, and pCode declares any of the
capabilities listed in the SPIR-V Environment appendix, one of the
corresponding requirements must be satisfied
(https://vulkan.lunarg.com/doc/view/1.3.275.0/linux/1.3-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-08740)
This commit is contained in:
Marcin Hajder
2026-02-17 17:45:07 +01:00
committed by GitHub
parent 3262ea3f45
commit 764b77ad83
5 changed files with 62 additions and 7 deletions

View File

@@ -104,7 +104,8 @@
VK_FUNC_DECL(vkGetImageSubresourceLayout) \
VK_FUNC_DECL(vkCreateDebugUtilsMessengerEXT) \
VK_FUNC_DECL(vkDestroyDebugUtilsMessengerEXT) \
VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties)
VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties) \
VK_FUNC_DECL(vkGetPhysicalDeviceFeatures2)
#define VK_WINDOWS_FUNC_LIST \
VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \
VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \
@@ -209,5 +210,6 @@
#define vkDestroyDebugUtilsMessengerEXT _vkDestroyDebugUtilsMessengerEXT
#define vkGetPhysicalDeviceExternalBufferProperties \
_vkGetPhysicalDeviceExternalBufferProperties
#define vkGetPhysicalDeviceFeatures2 _vkGetPhysicalDeviceFeatures2
#endif //_vulkan_api_list_hpp_

View File

@@ -147,6 +147,7 @@ VulkanInstance::VulkanInstance(bool useValidationLayers)
// return WAIVED;
}
VK_GET_NULL_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceFeatures2);
VK_GET_NULL_INSTANCE_PROC_ADDR(vkEnumerateInstanceVersion);
VK_GET_NULL_INSTANCE_PROC_ADDR(vkEnumerateInstanceLayerProperties);
VK_GET_NULL_INSTANCE_PROC_ADDR(vkCreateInstance);
@@ -612,7 +613,8 @@ VulkanDevice::VulkanDevice(const VulkanDevice &device)
VulkanDevice::VulkanDevice(
const VulkanPhysicalDevice &physicalDevice,
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap)
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap,
bool useShaderInt8)
: m_physicalDevice(physicalDevice), m_vkDevice(NULL)
{
uint32_t maxQueueCount = 0;
@@ -676,7 +678,55 @@ VulkanDevice::VulkanDevice(
enabledExtensionNameList.data();
vkDeviceCreateInfo.pEnabledFeatures = NULL;
vkCreateDevice(physicalDevice, &vkDeviceCreateInfo, NULL, &m_vkDevice);
if (useShaderInt8)
{
VkPhysicalDeviceShaderFloat16Int8Features int8Features{};
int8Features.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
VkPhysicalDevice8BitStorageFeatures storage8Features{};
storage8Features.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
int8Features.pNext = &storage8Features;
VkPhysicalDeviceFeatures2 features2{};
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
features2.pNext = &int8Features;
vkGetPhysicalDeviceFeatures2(physicalDevice, &features2);
if (!int8Features.shaderInt8
|| !storage8Features.storageBuffer8BitAccess)
{
throw std::runtime_error("shaderInt8 not supported!\n");
}
VkPhysicalDevice8BitStorageFeatures storage8Enable{};
storage8Enable.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
storage8Enable.storageBuffer8BitAccess = VK_TRUE;
VkPhysicalDeviceShaderFloat16Int8Features int8Enable{};
int8Enable.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
int8Enable.shaderInt8 = VK_TRUE;
int8Enable.pNext = &storage8Enable;
vkDeviceCreateInfo.pNext = &int8Enable;
enabledExtensionNameList.push_back(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
vkDeviceCreateInfo.ppEnabledExtensionNames =
enabledExtensionNameList.data();
vkDeviceCreateInfo.enabledExtensionCount =
(uint32_t)enabledExtensionNameList.size();
vkCreateDevice(physicalDevice, &vkDeviceCreateInfo, NULL, &m_vkDevice);
}
else
{
vkCreateDevice(physicalDevice, &vkDeviceCreateInfo, NULL, &m_vkDevice);
}
for (uint32_t qfIdx = 0;
qfIdx < (uint32_t)m_physicalDevice.getQueueFamilyList().size();

View File

@@ -148,7 +148,8 @@ public:
VulkanDevice(
const VulkanPhysicalDevice &physicalDevice = getVulkanPhysicalDevice(),
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap =
getDefaultVulkanQueueFamilyToQueueCountMap());
getDefaultVulkanQueueFamilyToQueueCountMap(),
bool useShaderInt8 = false);
virtual ~VulkanDevice();
const VulkanPhysicalDevice &getPhysicalDevice() const;
VulkanQueue &

View File

@@ -1586,7 +1586,7 @@ struct BufferTestBase : public VulkanTestBase
{
BufferTestBase(cl_device_id device, cl_context context,
cl_command_queue queue, cl_int nelems)
: VulkanTestBase(device, context, queue, nelems)
: VulkanTestBase(device, context, queue, nelems, true)
{}
int test_buffer_common(bool use_fence)

View File

@@ -37,11 +37,13 @@ inline void params_reset()
struct VulkanTestBase
{
VulkanTestBase(cl_device_id device, cl_context context,
cl_command_queue queue, cl_int nelems)
cl_command_queue queue, cl_int nelems,
bool useShaderInt8 = false)
: device(device), context(context), num_elems(nelems)
{
vkDevice.reset(new VulkanDevice(
getAssociatedVulkanPhysicalDevice(device, useValidationLayers)));
getAssociatedVulkanPhysicalDevice(device, useValidationLayers),
getDefaultVulkanQueueFamilyToQueueCountMap(), useShaderInt8));
cl_platform_id platform;
cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM,