nvk: Unconditionally zero image format properties
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:51 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:55 +0000 (21:31 +0000)
It seems like this shouldn't be neded but some of the tests complain if
we don't because they call vkGetPhysicalDeviceImageFormatProperties()
and vkGetPhysicalDeviceImageFormatProperties2() and compare if they
return identical results even if they return error.  Zero is the
reasonable thing to do if you don't support a format anyway because then
it's a maximum extent, sample count, etc. of zero.

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

src/nouveau/vulkan/nvk_image.c

index 869d18c..451793b 100644 (file)
@@ -83,6 +83,10 @@ nvk_GetPhysicalDeviceImageFormatProperties2(
 {
    VK_FROM_HANDLE(nvk_physical_device, pdevice, physicalDevice);
 
+   /* Initialize to zero in case we return VK_ERROR_FORMAT_NOT_SUPPORTED */
+   memset(&pImageFormatProperties->imageFormatProperties, 0,
+          sizeof(pImageFormatProperties->imageFormatProperties));
+
    VkFormatFeatureFlags2KHR features =
       nvk_get_image_format_features(pdevice, pImageFormatInfo->format,
                                              pImageFormatInfo->tiling);