radv/video: don't supply an 8-bit format for a 10-bit dpb.
authorDave Airlie <airlied@redhat.com>
Tue, 30 May 2023 05:06:11 +0000 (15:06 +1000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 8 Jun 2023 05:34:06 +0000 (05:34 +0000)
The firmware can write an 8-bit output buffer, but still needs
a 10-bit dpb allocation.

This also puts the 8-bit format after the 10-bit format though
apps should be smart enough to pick the correct one.

Reviewed-by: Lynne <dev@lynne.ee>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23476>

src/amd/vulkan/radv_video.c

index e4f06a4..0d74596 100644 (file)
@@ -480,6 +480,7 @@ radv_GetPhysicalDeviceVideoFormatPropertiesKHR(VkPhysicalDevice physicalDevice,
                           pVideoFormatProperties,
                           pVideoFormatPropertyCount);
 
+   bool need_8bit = true;
    bool need_10bit = false;
    const struct VkVideoProfileListInfoKHR *prof_list = (struct VkVideoProfileListInfoKHR *)
       vk_find_struct_const(pVideoFormatInfo->pNext, VIDEO_PROFILE_LIST_INFO_KHR);
@@ -491,13 +492,6 @@ radv_GetPhysicalDeviceVideoFormatPropertiesKHR(VkPhysicalDevice physicalDevice,
       }
    }
 
-   vk_outarray_append_typed(VkVideoFormatPropertiesKHR, &out, p) {
-      p->format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
-      p->imageType = VK_IMAGE_TYPE_2D;
-      p->imageTiling = VK_IMAGE_TILING_OPTIMAL;
-      p->imageUsageFlags = pVideoFormatInfo->imageUsage;
-   }
-
    if (need_10bit) {
       vk_outarray_append_typed(VkVideoFormatPropertiesKHR, &out, p) {
          p->format = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16;
@@ -505,7 +499,20 @@ radv_GetPhysicalDeviceVideoFormatPropertiesKHR(VkPhysicalDevice physicalDevice,
          p->imageTiling = VK_IMAGE_TILING_OPTIMAL;
          p->imageUsageFlags = pVideoFormatInfo->imageUsage;
       }
+
+      if (pVideoFormatInfo->imageUsage & (VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR))
+         need_8bit = false;
    }
+
+   if (need_8bit) {
+         vk_outarray_append_typed(VkVideoFormatPropertiesKHR, &out, p) {
+            p->format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
+            p->imageType = VK_IMAGE_TYPE_2D;
+            p->imageTiling = VK_IMAGE_TILING_OPTIMAL;
+            p->imageUsageFlags = pVideoFormatInfo->imageUsage;
+         }
+   }
+
    return vk_outarray_status(&out);
 }