Commit 657dd6cd by Nicolas Capens Committed by Nicolas Capens

Implement VK_KHR_driver_properties

This helps applications identify the driver. Bug: b/129792032 Test: dEQP-VK.api.driver_properties.properties Change-Id: I300fcc5dda6886b422fb64902b3eadf070b5eea8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/22690 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 50038d6d
...@@ -31,8 +31,8 @@ enum ...@@ -31,8 +31,8 @@ enum
{ {
API_VERSION = VK_API_VERSION_1_1, API_VERSION = VK_API_VERSION_1_1,
DRIVER_VERSION = VK_MAKE_VERSION(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION), DRIVER_VERSION = VK_MAKE_VERSION(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION),
VENDOR_ID = 0x1AE0, // Google VENDOR_ID = 0x1AE0, // Google, Inc.: https://pcisig.com/google-inc-1
DEVICE_ID = 0xC0DE, // SwiftShader DEVICE_ID = 0xC0DE, // SwiftShader (placeholder)
}; };
enum enum
......
...@@ -362,6 +362,14 @@ void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalSemaphoreInfo* ...@@ -362,6 +362,14 @@ void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalSemaphoreInfo*
pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; pExternalSemaphoreProperties->externalSemaphoreFeatures = 0;
} }
void PhysicalDevice::getProperties(VkPhysicalDeviceDriverPropertiesKHR* properties) const
{
properties->driverID = VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR;
strcpy(properties->driverName, "SwiftShader driver");
strcpy(properties->driverInfo, "");
properties->conformanceVersion = {0, 0, 0, 0};
}
bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures& requestedFeatures) const
{ {
const VkPhysicalDeviceFeatures& supportedFeatures = getFeatures(); const VkPhysicalDeviceFeatures& supportedFeatures = getFeatures();
......
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
void getProperties(const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties) const; void getProperties(const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties) const;
void getProperties(const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties) const; void getProperties(const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties) const;
void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties) const; void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties) const;
void getProperties(VkPhysicalDeviceDriverPropertiesKHR* properties) const;
void getFormatProperties(Format format, VkFormatProperties* pFormatProperties) const; void getFormatProperties(Format format, VkFormatProperties* pFormatProperties) const;
void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling, void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
......
...@@ -186,6 +186,8 @@ static const VkExtensionProperties instanceExtensionProperties[] = ...@@ -186,6 +186,8 @@ static const VkExtensionProperties instanceExtensionProperties[] =
static const VkExtensionProperties deviceExtensionProperties[] = static const VkExtensionProperties deviceExtensionProperties[] =
{ {
{ VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, VK_KHR_DRIVER_PROPERTIES_SPEC_VERSION },
// Vulkan 1.1 promoted extensions
{ VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VK_KHR_16BIT_STORAGE_SPEC_VERSION }, { VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VK_KHR_16BIT_STORAGE_SPEC_VERSION },
{ VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION }, { VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION },
{ VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION }, { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION },
...@@ -2418,6 +2420,12 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physi ...@@ -2418,6 +2420,12 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physi
ASSERT(!HasExtensionProperty(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, deviceExtensionProperties, ASSERT(!HasExtensionProperty(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, deviceExtensionProperties,
sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]))); sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
break; break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR:
{
auto& properties = *reinterpret_cast<VkPhysicalDeviceDriverPropertiesKHR*>(extensionProperties);
vk::Cast(physicalDevice)->getProperties(&properties);
}
break;
#ifdef __ANDROID__ #ifdef __ANDROID__
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID:
{ {
......
...@@ -58,6 +58,7 @@ VK_INSTANCE(vkFreeMemory, void, VkDevice, VkDeviceMemory, const VkAllocationCall ...@@ -58,6 +58,7 @@ VK_INSTANCE(vkFreeMemory, void, VkDevice, VkDeviceMemory, const VkAllocationCall
VK_INSTANCE(vkGetDeviceQueue, void, VkDevice, uint32_t, uint32_t, VkQueue*); VK_INSTANCE(vkGetDeviceQueue, void, VkDevice, uint32_t, uint32_t, VkQueue*);
VK_INSTANCE(vkGetPhysicalDeviceMemoryProperties, void, VkPhysicalDevice, VkPhysicalDeviceMemoryProperties*); VK_INSTANCE(vkGetPhysicalDeviceMemoryProperties, void, VkPhysicalDevice, VkPhysicalDeviceMemoryProperties*);
VK_INSTANCE(vkGetPhysicalDeviceProperties, void, VkPhysicalDevice, VkPhysicalDeviceProperties*); VK_INSTANCE(vkGetPhysicalDeviceProperties, void, VkPhysicalDevice, VkPhysicalDeviceProperties*);
VK_INSTANCE(vkGetPhysicalDeviceProperties2, void, VkPhysicalDevice, VkPhysicalDeviceProperties2*);
VK_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties, void, VkPhysicalDevice, uint32_t*, VkQueueFamilyProperties*); VK_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties, void, VkPhysicalDevice, uint32_t*, VkQueueFamilyProperties*);
VK_INSTANCE(vkMapMemory, VkResult, VkDevice, VkDeviceMemory, VkDeviceSize, VkDeviceSize, VkMemoryMapFlags, void**); VK_INSTANCE(vkMapMemory, VkResult, VkDevice, VkDeviceMemory, VkDeviceSize, VkDeviceSize, VkMemoryMapFlags, void**);
VK_INSTANCE(vkQueueSubmit, VkResult, VkQueue, uint32_t, const VkSubmitInfo*, VkFence); VK_INSTANCE(vkQueueSubmit, VkResult, VkQueue, uint32_t, const VkSubmitInfo*, VkFence);
......
...@@ -104,6 +104,16 @@ TEST_F(SwiftShaderVulkanTest, Version) ...@@ -104,6 +104,16 @@ TEST_F(SwiftShaderVulkanTest, Version)
EXPECT_EQ(strncmp(physicalDeviceProperties.deviceName, "SwiftShader Device", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE), 0); EXPECT_EQ(strncmp(physicalDeviceProperties.deviceName, "SwiftShader Device", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE), 0);
VkPhysicalDeviceProperties2 physicalDeviceProperties2;
VkPhysicalDeviceDriverPropertiesKHR physicalDeviceDriverProperties;
physicalDeviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
physicalDeviceProperties2.pNext = &physicalDeviceDriverProperties;
physicalDeviceDriverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR;
physicalDeviceDriverProperties.pNext = nullptr;
physicalDeviceDriverProperties.driverID = (VkDriverIdKHR)0;
driver.vkGetPhysicalDeviceProperties2(pPhysicalDevice, &physicalDeviceProperties2);
EXPECT_EQ(physicalDeviceDriverProperties.driverID, VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR);
driver.vkDestroyInstance(instance, nullptr); driver.vkDestroyInstance(instance, nullptr);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment