Skip to content

Commit 764b77a

Browse files
authored
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)
1 parent 3262ea3 commit 764b77a

5 files changed

Lines changed: 62 additions & 7 deletions

File tree

test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
VK_FUNC_DECL(vkGetImageSubresourceLayout) \
105105
VK_FUNC_DECL(vkCreateDebugUtilsMessengerEXT) \
106106
VK_FUNC_DECL(vkDestroyDebugUtilsMessengerEXT) \
107-
VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties)
107+
VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties) \
108+
VK_FUNC_DECL(vkGetPhysicalDeviceFeatures2)
108109
#define VK_WINDOWS_FUNC_LIST \
109110
VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \
110111
VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \
@@ -209,5 +210,6 @@
209210
#define vkDestroyDebugUtilsMessengerEXT _vkDestroyDebugUtilsMessengerEXT
210211
#define vkGetPhysicalDeviceExternalBufferProperties \
211212
_vkGetPhysicalDeviceExternalBufferProperties
213+
#define vkGetPhysicalDeviceFeatures2 _vkGetPhysicalDeviceFeatures2
212214

213215
#endif //_vulkan_api_list_hpp_

test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ VulkanInstance::VulkanInstance(bool useValidationLayers)
147147
// return WAIVED;
148148
}
149149

150+
VK_GET_NULL_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceFeatures2);
150151
VK_GET_NULL_INSTANCE_PROC_ADDR(vkEnumerateInstanceVersion);
151152
VK_GET_NULL_INSTANCE_PROC_ADDR(vkEnumerateInstanceLayerProperties);
152153
VK_GET_NULL_INSTANCE_PROC_ADDR(vkCreateInstance);
@@ -612,7 +613,8 @@ VulkanDevice::VulkanDevice(const VulkanDevice &device)
612613

613614
VulkanDevice::VulkanDevice(
614615
const VulkanPhysicalDevice &physicalDevice,
615-
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap)
616+
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap,
617+
bool useShaderInt8)
616618
: m_physicalDevice(physicalDevice), m_vkDevice(NULL)
617619
{
618620
uint32_t maxQueueCount = 0;
@@ -676,7 +678,55 @@ VulkanDevice::VulkanDevice(
676678
enabledExtensionNameList.data();
677679
vkDeviceCreateInfo.pEnabledFeatures = NULL;
678680

679-
vkCreateDevice(physicalDevice, &vkDeviceCreateInfo, NULL, &m_vkDevice);
681+
if (useShaderInt8)
682+
{
683+
VkPhysicalDeviceShaderFloat16Int8Features int8Features{};
684+
int8Features.sType =
685+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
686+
687+
VkPhysicalDevice8BitStorageFeatures storage8Features{};
688+
storage8Features.sType =
689+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
690+
691+
int8Features.pNext = &storage8Features;
692+
693+
VkPhysicalDeviceFeatures2 features2{};
694+
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
695+
features2.pNext = &int8Features;
696+
697+
vkGetPhysicalDeviceFeatures2(physicalDevice, &features2);
698+
699+
if (!int8Features.shaderInt8
700+
|| !storage8Features.storageBuffer8BitAccess)
701+
{
702+
throw std::runtime_error("shaderInt8 not supported!\n");
703+
}
704+
705+
VkPhysicalDevice8BitStorageFeatures storage8Enable{};
706+
storage8Enable.sType =
707+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
708+
storage8Enable.storageBuffer8BitAccess = VK_TRUE;
709+
710+
VkPhysicalDeviceShaderFloat16Int8Features int8Enable{};
711+
int8Enable.sType =
712+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
713+
int8Enable.shaderInt8 = VK_TRUE;
714+
int8Enable.pNext = &storage8Enable;
715+
716+
vkDeviceCreateInfo.pNext = &int8Enable;
717+
718+
enabledExtensionNameList.push_back(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
719+
vkDeviceCreateInfo.ppEnabledExtensionNames =
720+
enabledExtensionNameList.data();
721+
vkDeviceCreateInfo.enabledExtensionCount =
722+
(uint32_t)enabledExtensionNameList.size();
723+
724+
vkCreateDevice(physicalDevice, &vkDeviceCreateInfo, NULL, &m_vkDevice);
725+
}
726+
else
727+
{
728+
vkCreateDevice(physicalDevice, &vkDeviceCreateInfo, NULL, &m_vkDevice);
729+
}
680730

681731
for (uint32_t qfIdx = 0;
682732
qfIdx < (uint32_t)m_physicalDevice.getQueueFamilyList().size();

test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ class VulkanDevice {
148148
VulkanDevice(
149149
const VulkanPhysicalDevice &physicalDevice = getVulkanPhysicalDevice(),
150150
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap =
151-
getDefaultVulkanQueueFamilyToQueueCountMap());
151+
getDefaultVulkanQueueFamilyToQueueCountMap(),
152+
bool useShaderInt8 = false);
152153
virtual ~VulkanDevice();
153154
const VulkanPhysicalDevice &getPhysicalDevice() const;
154155
VulkanQueue &

test_conformance/vulkan/test_vulkan_interop_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ struct BufferTestBase : public VulkanTestBase
15861586
{
15871587
BufferTestBase(cl_device_id device, cl_context context,
15881588
cl_command_queue queue, cl_int nelems)
1589-
: VulkanTestBase(device, context, queue, nelems)
1589+
: VulkanTestBase(device, context, queue, nelems, true)
15901590
{}
15911591

15921592
int test_buffer_common(bool use_fence)

test_conformance/vulkan/vulkan_test_base.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ inline void params_reset()
3737
struct VulkanTestBase
3838
{
3939
VulkanTestBase(cl_device_id device, cl_context context,
40-
cl_command_queue queue, cl_int nelems)
40+
cl_command_queue queue, cl_int nelems,
41+
bool useShaderInt8 = false)
4142
: device(device), context(context), num_elems(nelems)
4243
{
4344
vkDevice.reset(new VulkanDevice(
44-
getAssociatedVulkanPhysicalDevice(device, useValidationLayers)));
45+
getAssociatedVulkanPhysicalDevice(device, useValidationLayers),
46+
getDefaultVulkanQueueFamilyToQueueCountMap(), useShaderInt8));
4547

4648
cl_platform_id platform;
4749
cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM,

0 commit comments

Comments
 (0)