anv: Implement physical device properties for VK_EXT_sample_locations
authorEleni Maria Stea <estea@igalia.com>
Thu, 14 Mar 2019 19:52:00 +0000 (21:52 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 27 Jan 2021 23:25:27 +0000 (23:25 +0000)
The VkPhysicalDeviceSampleLocationPropertiesEXT struct is filled with
implementation dependent values and according to the table from the
Vulkan Specification section [36.1. Limit Requirements]:

pname | max | min
pname:sampleLocationSampleCounts   |-            |ename:VK_SAMPLE_COUNT_4_BIT
pname:maxSampleLocationGridSize    |-            |(1, 1)
pname:sampleLocationCoordinateRange|(0.0, 0.9375)|(0.0, 0.9375)
pname:sampleLocationSubPixelBits   |-            |4
pname:variableSampleLocations      | true        |implementation dependent

The hardware only supports setting the same sample location for all the
pixels, so we only support 1x1 grids.

Also, variableSampleLocations is set to true because we can set sample
locations per draw.

Implement the vkGetPhysicalDeviceMultisamplePropertiesEXT according to
the Vulkan Specification section [36.2. Additional Multisampling
Capabilities].

v2: 1- Replaced false with VK_FALSE for consistency. (Sagar Ghuge)
    2- Used the isl_device_sample_count to take the number of samples
    per platform to avoid extra checks. (Sagar Ghuge)

v3: 1- Replaced VK_FALSE with false as Jason has sent a patch to replace
    VK_FALSE with false in other places. (Jason Ekstrand)
    2- Removed unecessary defines and set the grid size to 1 (Jason Ekstrand)

v4: Fix properties reporting in GetPhysicalDeviceProperties2, not
    GetPhysicalDeviceFeatures2 (Lionel)
    Use same alignment as other functions (Lionel)
    Report variableSampleLocations=true (Lionel)

v5: Don't overwrite the pNext in GetPhysicalDeviceMultisamplerPropertiesEXT

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com> (v3)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1887>

src/intel/vulkan/anv_device.c

index e1d77ea..813af4f 100644 (file)
@@ -2092,6 +2092,25 @@ void anv_GetPhysicalDeviceProperties2(
          break;
       }
 
+      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT: {
+         VkPhysicalDeviceSampleLocationsPropertiesEXT *props =
+            (VkPhysicalDeviceSampleLocationsPropertiesEXT *)ext;
+
+         props->sampleLocationSampleCounts =
+            isl_device_get_sample_counts(&pdevice->isl_dev);
+
+         /* See also anv_GetPhysicalDeviceMultisamplePropertiesEXT */
+         props->maxSampleLocationGridSize.width = 1;
+         props->maxSampleLocationGridSize.height = 1;
+
+         props->sampleLocationCoordinateRange[0] = 0;
+         props->sampleLocationCoordinateRange[1] = 0.9375;
+         props->sampleLocationSubPixelBits = 4;
+
+         props->variableSampleLocations = true;
+         break;
+      }
+
       case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT: {
          VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT *props =
             (VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT *)ext;
@@ -4615,6 +4634,30 @@ VkResult anv_GetCalibratedTimestampsEXT(
    return VK_SUCCESS;
 }
 
+void anv_GetPhysicalDeviceMultisamplePropertiesEXT(
+    VkPhysicalDevice                            physicalDevice,
+    VkSampleCountFlagBits                       samples,
+    VkMultisamplePropertiesEXT*                 pMultisampleProperties)
+{
+   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+
+   assert(pMultisampleProperties->sType ==
+          VK_STRUCTURE_TYPE_MULTISAMPLE_PROPERTIES_EXT);
+
+   VkExtent2D grid_size;
+   if (samples & isl_device_get_sample_counts(&physical_device->isl_dev)) {
+      grid_size.width = 1;
+      grid_size.height = 1;
+   } else {
+      grid_size.width = 0;
+      grid_size.height = 0;
+   }
+   pMultisampleProperties->maxSampleLocationGridSize = grid_size;
+
+   vk_foreach_struct(ext, pMultisampleProperties->pNext)
+      anv_debug_ignored_stype(ext->sType);
+}
+
 /* vk_icd.h does not declare this function, so we declare it here to
  * suppress Wmissing-prototypes.
  */