diff --git a/src/intel/vulkan/anv_video.c b/src/intel/vulkan/anv_video.c index f913456c322..656cca42b65 100644 --- a/src/intel/vulkan/anv_video.c +++ b/src/intel/vulkan/anv_video.c @@ -112,6 +112,8 @@ anv_GetPhysicalDeviceVideoCapabilitiesKHR(VkPhysicalDevice physicalDevice, const VkVideoProfileInfoKHR *pVideoProfile, VkVideoCapabilitiesKHR *pCapabilities) { + ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice); + pCapabilities->minBitstreamBufferOffsetAlignment = 32; pCapabilities->minBitstreamBufferSizeAlignment = 32; pCapabilities->maxCodedExtent.width = 4096; @@ -123,10 +125,21 @@ anv_GetPhysicalDeviceVideoCapabilitiesKHR(VkPhysicalDevice physicalDevice, if (dec_caps) dec_caps->flags = VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR; + /* H264 allows different luma and chroma bit depths */ + if (pVideoProfile->lumaBitDepth != pVideoProfile->chromaBitDepth) + return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR; + + if (pVideoProfile->chromaSubsampling != VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR) + return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR; + switch (pVideoProfile->videoCodecOperation) { case VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR: { struct VkVideoDecodeH264CapabilitiesKHR *ext = (struct VkVideoDecodeH264CapabilitiesKHR *) vk_find_struct(pCapabilities->pNext, VIDEO_DECODE_H264_CAPABILITIES_KHR); + + if (pVideoProfile->lumaBitDepth != VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR) + return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR; + pCapabilities->maxDpbSlots = 17; pCapabilities->maxActiveReferencePictures = ANV_VIDEO_H264_MAX_NUM_REF_FRAME; pCapabilities->pictureAccessGranularity.width = ANV_MB_WIDTH; @@ -145,6 +158,34 @@ anv_GetPhysicalDeviceVideoCapabilitiesKHR(VkPhysicalDevice physicalDevice, struct VkVideoDecodeH265CapabilitiesKHR *ext = (struct VkVideoDecodeH265CapabilitiesKHR *) vk_find_struct(pCapabilities->pNext, VIDEO_DECODE_H265_CAPABILITIES_KHR); + const struct VkVideoDecodeH265ProfileInfoKHR *h265_profile = + vk_find_struct_const(pVideoProfile->pNext, + VIDEO_DECODE_H265_PROFILE_INFO_KHR); + + /* No hardware supports the scc extension profile */ + if (h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN && + h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_10 && + h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE && + h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS) + return VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR; + + /* Skylake only supports the main profile */ + if (h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN && + h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE && + pdevice->info.ver <= 9) + return VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR; + + /* Gfx10 and under don't support the range extension profile */ + if (h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN && + h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_10 && + h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE && + pdevice->info.ver <= 10) + return VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR; + + if (pVideoProfile->lumaBitDepth != VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR && + pVideoProfile->lumaBitDepth != VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR) + return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR; + pCapabilities->pictureAccessGranularity.width = ANV_MAX_H265_CTB_SIZE; pCapabilities->pictureAccessGranularity.height = ANV_MAX_H265_CTB_SIZE; pCapabilities->minCodedExtent.width = ANV_MAX_H265_CTB_SIZE;