Add support for Vulkan12Properties
VkPhysicalDeviceVulkan12Properties was added to the core spec by Vulkan
1.2. It allows users to query the following properties simultaneously:
* VkPhysicalDeviceDriverProperties
* VkPhysicalDeviceFloatControlsProperties
* VkPhysicalDeviceDescriptorIndexingProperties
* VkPhysicalDeviceDepthStencilResolveProperties
* VkPhysicalDeviceSamplerFilterMinmaxProperties
* VkPhysicalDeviceTimelineSemaphoreProperties
* and framebufferIntegerColorSampleCounts
All these structs are a part of the core spec and must be supported.
Bug: b/176498010
Change-Id: I82b06f219d2ee091139964ee8b19f05e1c64e3a8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51408
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Sean Risser <srisser@google.com>
Commit-Queue: Sean Risser <srisser@google.com>
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 836e296..8a1b138 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -238,16 +238,8 @@
}
template<typename T>
-static void getPhysicalDeviceVulkan12Features(T *features)
+static void getPhysicalDeviceDescriptorIndexingFeatures(T *features)
{
- features->samplerMirrorClampToEdge = VK_FALSE;
- features->drawIndirectCount = VK_FALSE;
- getPhysicalDevice8BitStorageFeaturesKHR(features);
- features->shaderBufferInt64Atomics = VK_FALSE;
- features->shaderSharedInt64Atomics = VK_FALSE;
- features->shaderFloat16 = VK_FALSE;
- features->shaderInt8 = VK_FALSE;
- features->descriptorIndexing = VK_FALSE;
features->shaderInputAttachmentArrayDynamicIndexing = VK_FALSE;
features->shaderUniformTexelBufferArrayDynamicIndexing = VK_FALSE;
features->shaderStorageTexelBufferArrayDynamicIndexing = VK_FALSE;
@@ -267,6 +259,20 @@
features->descriptorBindingPartiallyBound = VK_FALSE;
features->descriptorBindingVariableDescriptorCount = VK_FALSE;
features->runtimeDescriptorArray = VK_FALSE;
+}
+
+template<typename T>
+static void getPhysicalDeviceVulkan12Features(T *features)
+{
+ features->samplerMirrorClampToEdge = VK_FALSE;
+ features->drawIndirectCount = VK_FALSE;
+ getPhysicalDevice8BitStorageFeaturesKHR(features);
+ features->shaderBufferInt64Atomics = VK_FALSE;
+ features->shaderSharedInt64Atomics = VK_FALSE;
+ features->shaderFloat16 = VK_FALSE;
+ features->shaderInt8 = VK_FALSE;
+ features->descriptorIndexing = VK_FALSE;
+ getPhysicalDeviceDescriptorIndexingFeatures(features);
features->samplerFilterMinmax = VK_FALSE;
getPhysicalDeviceScalarBlockLayoutFeatures(features);
getPhysicalDeviceImagelessFramebufferFeatures(features);
@@ -714,7 +720,8 @@
properties->minImportedHostPointerAlignment = REQUIRED_MEMORY_ALIGNMENT;
}
-void PhysicalDevice::getProperties(VkPhysicalDeviceDriverPropertiesKHR *properties) const
+template<typename T>
+static void getDriverProperties(T *properties)
{
properties->driverID = VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR;
strcpy(properties->driverName, "SwiftShader driver");
@@ -722,6 +729,11 @@
properties->conformanceVersion = { 1, 1, 3, 3 };
}
+void PhysicalDevice::getProperties(VkPhysicalDeviceDriverPropertiesKHR *properties) const
+{
+ getDriverProperties(properties);
+}
+
void PhysicalDevice::getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const
{
properties->lineSubPixelPrecisionBits = vk::SUBPIXEL_PRECISION_BITS;
@@ -732,7 +744,8 @@
properties->provokingVertexModePerPipeline = VK_TRUE;
}
-void PhysicalDevice::getProperties(VkPhysicalDeviceFloatControlsProperties *properties) const
+template<typename T>
+static void getFloatControlsProperties(T *properties)
{
// The spec states:
// shaderSignedZeroInfNanPreserveFloat32 is a boolean value indicating whether
@@ -764,6 +777,92 @@
properties->shaderRoundingModeRTEFloat64 = VK_FALSE;
}
+void PhysicalDevice::getProperties(VkPhysicalDeviceFloatControlsProperties *properties) const
+{
+ getFloatControlsProperties(properties);
+}
+
+template<typename T>
+static void getDescriptorIndexingProperties(T *properties)
+{
+ properties->maxUpdateAfterBindDescriptorsInAllPools = 0;
+ properties->shaderUniformBufferArrayNonUniformIndexingNative = VK_FALSE;
+ properties->shaderSampledImageArrayNonUniformIndexingNative = VK_FALSE;
+ properties->shaderStorageBufferArrayNonUniformIndexingNative = VK_FALSE;
+ properties->shaderStorageImageArrayNonUniformIndexingNative = VK_FALSE;
+ properties->shaderInputAttachmentArrayNonUniformIndexingNative = VK_FALSE;
+ properties->robustBufferAccessUpdateAfterBind = VK_FALSE;
+ properties->quadDivergentImplicitLod = VK_FALSE;
+ properties->maxPerStageDescriptorUpdateAfterBindSamplers = 0;
+ properties->maxPerStageDescriptorUpdateAfterBindUniformBuffers = 0;
+ properties->maxPerStageDescriptorUpdateAfterBindStorageBuffers = 0;
+ properties->maxPerStageDescriptorUpdateAfterBindSampledImages = 0;
+ properties->maxPerStageDescriptorUpdateAfterBindStorageImages = 0;
+ properties->maxPerStageDescriptorUpdateAfterBindInputAttachments = 0;
+ properties->maxPerStageUpdateAfterBindResources = 0;
+ properties->maxDescriptorSetUpdateAfterBindSamplers = 0;
+ properties->maxDescriptorSetUpdateAfterBindUniformBuffers = 0;
+ properties->maxDescriptorSetUpdateAfterBindUniformBuffersDynamic = 0;
+ properties->maxDescriptorSetUpdateAfterBindStorageBuffers = 0;
+ properties->maxDescriptorSetUpdateAfterBindStorageBuffersDynamic = 0;
+ properties->maxDescriptorSetUpdateAfterBindSampledImages = 0;
+ properties->maxDescriptorSetUpdateAfterBindStorageImages = 0;
+ properties->maxDescriptorSetUpdateAfterBindInputAttachments = 0;
+}
+
+void PhysicalDevice::getProperties(VkPhysicalDeviceDescriptorIndexingProperties *properties) const
+{
+ getDescriptorIndexingProperties(properties);
+}
+
+template<typename T>
+static void getDepthStencilResolveProperties(T *properties)
+{
+ properties->supportedDepthResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT | VK_RESOLVE_MODE_NONE;
+ properties->supportedStencilResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT | VK_RESOLVE_MODE_NONE;
+ properties->independentResolveNone = VK_FALSE;
+ properties->independentResolve = VK_FALSE;
+}
+
+void PhysicalDevice::getProperties(VkPhysicalDeviceDepthStencilResolveProperties *properties) const
+{
+ getDepthStencilResolveProperties(properties);
+}
+
+template<typename T>
+static void getSamplerFilterMinmaxProperties(T *properties)
+{
+ properties->filterMinmaxSingleComponentFormats = VK_FALSE;
+ properties->filterMinmaxImageComponentMapping = VK_FALSE;
+}
+
+void PhysicalDevice::getProperties(VkPhysicalDeviceSamplerFilterMinmaxProperties *properties) const
+{
+ getSamplerFilterMinmaxProperties(properties);
+}
+
+template<typename T>
+static void getTimelineSemaphoreProperties(T *properties)
+{
+ properties->maxTimelineSemaphoreValueDifference = 0x7FFFFFFFull;
+}
+
+void PhysicalDevice::getProperties(VkPhysicalDeviceTimelineSemaphoreProperties *properties) const
+{
+ getTimelineSemaphoreProperties(properties);
+}
+
+void PhysicalDevice::getProperties(VkPhysicalDeviceVulkan12Properties *properties) const
+{
+ getDriverProperties(properties);
+ getFloatControlsProperties(properties);
+ getDescriptorIndexingProperties(properties);
+ getDepthStencilResolveProperties(properties);
+ getSamplerFilterMinmaxProperties(properties);
+ getTimelineSemaphoreProperties(properties);
+ properties->framebufferIntegerColorSampleCounts = VK_SAMPLE_COUNT_1_BIT;
+}
+
bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatures) const
{
const VkPhysicalDeviceFeatures &supportedFeatures = getFeatures();
diff --git a/src/Vulkan/VkPhysicalDevice.hpp b/src/Vulkan/VkPhysicalDevice.hpp
index 40b06c3..8ff2abd 100644
--- a/src/Vulkan/VkPhysicalDevice.hpp
+++ b/src/Vulkan/VkPhysicalDevice.hpp
@@ -60,6 +60,11 @@
void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
void getProperties(VkPhysicalDeviceFloatControlsProperties *) const;
+ void getProperties(VkPhysicalDeviceSamplerFilterMinmaxProperties *properties) const;
+ void getProperties(VkPhysicalDeviceTimelineSemaphoreProperties *properties) const;
+ void getProperties(VkPhysicalDeviceVulkan12Properties *properties) const;
+ void getProperties(VkPhysicalDeviceDescriptorIndexingProperties *properties) const;
+ void getProperties(VkPhysicalDeviceDepthStencilResolveProperties *properties) const;
static void GetFormatProperties(Format format, VkFormatProperties *pFormatProperties);
void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 9bb6ba4..f1054fe 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -2964,6 +2964,36 @@
vk::Cast(physicalDevice)->getProperties(properties);
}
break;
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES:
+ {
+ auto properties = reinterpret_cast<VkPhysicalDeviceSamplerFilterMinmaxProperties *>(extensionProperties);
+ vk::Cast(physicalDevice)->getProperties(properties);
+ }
+ break;
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES:
+ {
+ auto properties = reinterpret_cast<VkPhysicalDeviceTimelineSemaphoreProperties *>(extensionProperties);
+ vk::Cast(physicalDevice)->getProperties(properties);
+ }
+ break;
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES:
+ {
+ auto properties = reinterpret_cast<VkPhysicalDeviceVulkan12Properties *>(extensionProperties);
+ vk::Cast(physicalDevice)->getProperties(properties);
+ }
+ break;
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES:
+ {
+ auto properties = reinterpret_cast<VkPhysicalDeviceDescriptorIndexingProperties *>(extensionProperties);
+ vk::Cast(physicalDevice)->getProperties(properties);
+ }
+ break;
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES:
+ {
+ auto properties = reinterpret_cast<VkPhysicalDeviceDepthStencilResolveProperties *>(extensionProperties);
+ vk::Cast(physicalDevice)->getProperties(properties);
+ }
+ break;
default:
// "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
LOG_TRAP("pProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());