anv: support HEVC 10-bit decoding
Signed-off-by: Hyunjun Ko <zzoon@igalia.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22202>
This commit is contained in:
@@ -172,6 +172,22 @@ anv_GetPhysicalDeviceVideoFormatPropertiesKHR(VkPhysicalDevice physicalDevice,
|
||||
{
|
||||
*pVideoFormatPropertyCount = 1;
|
||||
|
||||
bool need_10bit = false;
|
||||
const struct VkVideoProfileListInfoKHR *prof_list = (struct VkVideoProfileListInfoKHR *)
|
||||
vk_find_struct_const(pVideoFormatInfo->pNext, VIDEO_PROFILE_LIST_INFO_KHR);
|
||||
|
||||
if (prof_list) {
|
||||
for (unsigned i = 0; i < prof_list->profileCount; i++) {
|
||||
const VkVideoProfileInfoKHR *profile = &prof_list->pProfiles[i];
|
||||
if (profile->lumaBitDepth & VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR ||
|
||||
profile->chromaBitDepth & VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR)
|
||||
need_10bit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (need_10bit)
|
||||
(*pVideoFormatPropertyCount)++;
|
||||
|
||||
if (!pVideoFormatProperties)
|
||||
return VK_SUCCESS;
|
||||
|
||||
@@ -179,6 +195,14 @@ anv_GetPhysicalDeviceVideoFormatPropertiesKHR(VkPhysicalDevice physicalDevice,
|
||||
pVideoFormatProperties[0].imageType = VK_IMAGE_TYPE_2D;
|
||||
pVideoFormatProperties[0].imageTiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
pVideoFormatProperties[0].imageUsageFlags = pVideoFormatInfo->imageUsage;
|
||||
|
||||
if (need_10bit) {
|
||||
pVideoFormatProperties[1].format = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16;
|
||||
pVideoFormatProperties[1].imageType = VK_IMAGE_TYPE_2D;
|
||||
pVideoFormatProperties[1].imageTiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
pVideoFormatProperties[1].imageUsageFlags = pVideoFormatInfo->imageUsage;
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -218,8 +242,10 @@ get_h265_video_session_mem_reqs(struct anv_video_session *vid,
|
||||
VkVideoSessionMemoryRequirementsKHR *mem_reqs,
|
||||
uint32_t memory_types)
|
||||
{
|
||||
uint32_t bit_shift = vid->vk.h265.profile_idc == STD_VIDEO_H265_PROFILE_IDC_MAIN_10 ? 2 : 3;
|
||||
|
||||
/* TODO. these sizes can be determined dynamically depending on ctb sizes of each slice. */
|
||||
uint32_t size = align(vid->vk.max_coded.width, 32) >> 3;
|
||||
uint32_t size = align(vid->vk.max_coded.width, 32) >> bit_shift;
|
||||
uint32_t width_in_ctb = align(vid->vk.max_coded.width, ANV_MAX_H265_CTB_SIZE) / ANV_MAX_H265_CTB_SIZE;
|
||||
uint32_t height_in_ctb = align(vid->vk.max_coded.height, ANV_MAX_H265_CTB_SIZE) / ANV_MAX_H265_CTB_SIZE;
|
||||
|
||||
@@ -233,7 +259,7 @@ get_h265_video_session_mem_reqs(struct anv_video_session *vid,
|
||||
mem_reqs[1].memoryRequirements.alignment = 4096;
|
||||
mem_reqs[1].memoryRequirements.memoryTypeBits = memory_types;
|
||||
|
||||
size = align(vid->vk.max_coded.height + 6 * height_in_ctb, 32) >> 3;
|
||||
size = align(vid->vk.max_coded.height + 6 * height_in_ctb, 32) >> bit_shift;
|
||||
mem_reqs[2].memoryBindIndex = ANV_VID_MEM_H265_DEBLOCK_FILTER_ROW_STORE_TILE_COLUMN;
|
||||
mem_reqs[2].memoryRequirements.size = size << 6;
|
||||
mem_reqs[2].memoryRequirements.alignment = 4096;
|
||||
@@ -257,19 +283,19 @@ get_h265_video_session_mem_reqs(struct anv_video_session *vid,
|
||||
mem_reqs[5].memoryRequirements.alignment = 4096;
|
||||
mem_reqs[5].memoryRequirements.memoryTypeBits = memory_types;
|
||||
|
||||
size = align((vid->vk.max_coded.width >> 1) + width_in_ctb * 3, 16) >> 3;
|
||||
size = align((vid->vk.max_coded.width >> 1) + width_in_ctb * 3, 16) >> bit_shift;
|
||||
mem_reqs[6].memoryBindIndex = ANV_VID_MEM_H265_SAO_LINE;
|
||||
mem_reqs[6].memoryRequirements.size = size << 6;
|
||||
mem_reqs[6].memoryRequirements.alignment = 4096;
|
||||
mem_reqs[6].memoryRequirements.memoryTypeBits = memory_types;
|
||||
|
||||
size = align((vid->vk.max_coded.width >> 1) + width_in_ctb * 6, 16) >> 3;
|
||||
size = align((vid->vk.max_coded.width >> 1) + width_in_ctb * 6, 16) >> bit_shift;
|
||||
mem_reqs[7].memoryBindIndex = ANV_VID_MEM_H265_SAO_TILE_LINE;
|
||||
mem_reqs[7].memoryRequirements.size = size << 6;
|
||||
mem_reqs[7].memoryRequirements.alignment = 4096;
|
||||
mem_reqs[7].memoryRequirements.memoryTypeBits = memory_types;
|
||||
|
||||
size = align((vid->vk.max_coded.height >> 1) + height_in_ctb * 6, 16) >> 3;
|
||||
size = align((vid->vk.max_coded.height >> 1) + height_in_ctb * 6, 16) >> bit_shift;
|
||||
mem_reqs[8].memoryBindIndex = ANV_VID_MEM_H265_SAO_TILE_COLUMN;
|
||||
mem_reqs[8].memoryRequirements.size = size << 6;
|
||||
mem_reqs[8].memoryRequirements.alignment = 4096;
|
||||
|
@@ -128,6 +128,7 @@ anv_h265_decode_video(struct anv_cmd_buffer *cmd_buffer,
|
||||
|
||||
struct vk_video_h265_reference ref_slots[2][8] = { 0 };
|
||||
uint8_t dpb_idx[ANV_VIDEO_H265_MAX_NUM_REF_FRAME] = { 0,};
|
||||
bool is_10bit = sps->bit_depth_chroma_minus8 || sps->bit_depth_luma_minus8;
|
||||
|
||||
anv_batch_emit(&cmd_buffer->batch, GENX(MI_FLUSH_DW), flush) {
|
||||
flush.VideoPipelineCacheInvalidate = 1;
|
||||
@@ -166,7 +167,7 @@ anv_h265_decode_video(struct anv_cmd_buffer *cmd_buffer,
|
||||
anv_batch_emit(&cmd_buffer->batch, GENX(HCP_SURFACE_STATE), ss) {
|
||||
ss.SurfacePitch = img->planes[0].primary_surface.isl.row_pitch_B - 1;
|
||||
ss.SurfaceID = HCP_CurrentDecodedPicture;
|
||||
ss.SurfaceFormat = PLANAR_420_8;
|
||||
ss.SurfaceFormat = is_10bit ? P010 : PLANAR_420_8;
|
||||
|
||||
ss.YOffsetforUCb = img->planes[1].primary_surface.memory_range.offset /
|
||||
img->planes[0].primary_surface.isl.row_pitch_B;
|
||||
|
Reference in New Issue
Block a user