nvk: Fix support for VK_EXT_sample_locations
authorGeorge Ouzounoudis <geothrock@gmail.com>
Wed, 9 Aug 2023 19:05:14 +0000 (22:05 +0300)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 19:27:24 +0000 (19:27 +0000)
Fixes some crashes on sample locations pipeline tests.
The implementation was already there but the device properties were
missing.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24592>

src/nouveau/vulkan/nvk_physical_device.c

index 13b0815..aa9b3a9 100644 (file)
@@ -371,10 +371,10 @@ nvk_get_device_properties(const struct nvk_instance *instance,
                           const struct nv_device_info *info,
                           struct vk_properties *properties)
 {
-   VkSampleCountFlagBits sample_counts = VK_SAMPLE_COUNT_1_BIT |
-                                         VK_SAMPLE_COUNT_2_BIT |
-                                         VK_SAMPLE_COUNT_4_BIT |
-                                         VK_SAMPLE_COUNT_8_BIT;
+   const VkSampleCountFlagBits sample_counts = VK_SAMPLE_COUNT_1_BIT |
+                                               VK_SAMPLE_COUNT_2_BIT |
+                                               VK_SAMPLE_COUNT_4_BIT |
+                                               VK_SAMPLE_COUNT_8_BIT;
 
    *properties = (struct vk_properties) {
       .apiVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION),
@@ -585,6 +585,14 @@ nvk_get_device_properties(const struct nvk_instance *instance,
       .robustStorageBufferAccessSizeAlignment = NVK_SSBO_BOUNDS_CHECK_ALIGNMENT,
       .robustUniformBufferAccessSizeAlignment = NVK_MIN_UBO_ALIGNMENT,
 
+      /* VK_EXT_sample_locations */
+      .sampleLocationSampleCounts = sample_counts,
+      .maxSampleLocationGridSize = (VkExtent2D){ 1, 1 },
+      .sampleLocationCoordinateRange[0] = 0.0f,
+      .sampleLocationCoordinateRange[1] = 0.9375f,
+      .sampleLocationSubPixelBits = 4,
+      .variableSampleLocations = true,
+
       /* VK_EXT_transform_feedback */
       .maxTransformFeedbackStreams = 4,
       .maxTransformFeedbackBuffers = 4,
@@ -866,3 +874,18 @@ nvk_GetPhysicalDeviceQueueFamilyProperties2(
       p->queueFamilyProperties.minImageTransferGranularity = (VkExtent3D){1, 1, 1};
    }
 }
+
+VKAPI_ATTR void VKAPI_CALL
+nvk_GetPhysicalDeviceMultisamplePropertiesEXT(
+   VkPhysicalDevice physicalDevice,
+   VkSampleCountFlagBits samples,
+   VkMultisamplePropertiesEXT *pMultisampleProperties)
+{
+   VK_FROM_HANDLE(nvk_physical_device, pdev, physicalDevice);
+
+   if (samples & pdev->vk.properties.sampleLocationSampleCounts) {
+      pMultisampleProperties->maxSampleLocationGridSize = (VkExtent2D){1, 1};
+   } else {
+      pMultisampleProperties->maxSampleLocationGridSize = (VkExtent2D){0, 0};
+   }
+}