Vulkan: include backend name in deviceName * Add rr::BackendName() to dynamically return the name of the backend * Set VkPhysicalDeviceProperties::deviceName to include backend name Bug: b/130459196 Change-Id: I028f3607e4eda9de55bc4cec8af78e7b4793160d Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39552 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp index 7b06cb4..70ada9c 100644 --- a/src/Reactor/LLVMReactor.cpp +++ b/src/Reactor/LLVMReactor.cpp
@@ -1000,6 +1000,11 @@ namespace rr { +std::string BackendName() +{ + return std::string("LLVM ") + LLVM_VERSION_STRING; +} + const Capabilities Caps = { true, // CoroutinesSupported };
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp index 59b3d0a..95f0700 100644 --- a/src/Reactor/Reactor.hpp +++ b/src/Reactor/Reactor.hpp
@@ -50,6 +50,8 @@ namespace rr { +std::string BackendName(); + struct Capabilities { bool CoroutinesSupported; // Support for rr::Coroutine<F>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp index 2f3e9ee..54dcf93 100644 --- a/src/Reactor/SubzeroReactor.cpp +++ b/src/Reactor/SubzeroReactor.cpp
@@ -170,6 +170,11 @@ namespace rr { +std::string BackendName() +{ + return "Subzero"; +} + const Capabilities Caps = { false, // CoroutinesSupported };
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp index 3517cca..2635a57 100644 --- a/src/Vulkan/VkPhysicalDevice.cpp +++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -16,6 +16,7 @@ #include "VkConfig.h" #include "Pipeline/SpirvShader.hpp" // sw::SIMD::Width +#include "Reactor/Reactor.hpp" #include <cstring> #include <limits> @@ -286,18 +287,27 @@ const VkPhysicalDeviceProperties &PhysicalDevice::getProperties() const { - static const VkPhysicalDeviceProperties properties{ - API_VERSION, - DRIVER_VERSION, - VENDOR_ID, - DEVICE_ID, - VK_PHYSICAL_DEVICE_TYPE_CPU, // deviceType - SWIFTSHADER_DEVICE_NAME, // deviceName - SWIFTSHADER_UUID, // pipelineCacheUUID - getLimits(), // limits - {} // sparseProperties + auto getProperties = [&]() -> VkPhysicalDeviceProperties { + VkPhysicalDeviceProperties properties = { + API_VERSION, + DRIVER_VERSION, + VENDOR_ID, + DEVICE_ID, + VK_PHYSICAL_DEVICE_TYPE_CPU, // deviceType + "", // deviceName + SWIFTSHADER_UUID, // pipelineCacheUUID + getLimits(), // limits + {} // sparseProperties + }; + + // Append Reactor JIT backend name and version + snprintf(properties.deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE, + "%s (%s)", SWIFTSHADER_DEVICE_NAME, rr::BackendName().c_str()); + + return properties; }; + static const VkPhysicalDeviceProperties properties = getProperties(); return properties; }
diff --git a/tests/VulkanUnitTests/unittests.cpp b/tests/VulkanUnitTests/unittests.cpp index e7b954b..4055ce1 100644 --- a/tests/VulkanUnitTests/unittests.cpp +++ b/tests/VulkanUnitTests/unittests.cpp
@@ -102,7 +102,7 @@ EXPECT_EQ(physicalDeviceProperties.deviceID, 0xC0DEU); EXPECT_EQ(physicalDeviceProperties.deviceType, VK_PHYSICAL_DEVICE_TYPE_CPU); - EXPECT_EQ(strncmp(physicalDeviceProperties.deviceName, "SwiftShader Device", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE), 0); + EXPECT_NE(strstr(physicalDeviceProperties.deviceName, "SwiftShader Device"), nullptr); VkPhysicalDeviceProperties2 physicalDeviceProperties2; VkPhysicalDeviceDriverPropertiesKHR physicalDeviceDriverProperties;