128
126
dec_caps->flags = VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR;
128
/* H264 allows different luma and chroma bit depths */
129
if (pVideoProfile->lumaBitDepth != pVideoProfile->chromaBitDepth)
130
return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR;
132
if (pVideoProfile->chromaSubsampling != VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR)
133
return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR;
130
135
switch (pVideoProfile->videoCodecOperation) {
131
136
case VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR: {
132
137
struct VkVideoDecodeH264CapabilitiesKHR *ext = (struct VkVideoDecodeH264CapabilitiesKHR *)
133
138
vk_find_struct(pCapabilities->pNext, VIDEO_DECODE_H264_CAPABILITIES_KHR);
140
if (pVideoProfile->lumaBitDepth != VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR)
141
return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR;
134
143
pCapabilities->maxDpbSlots = 17;
135
pCapabilities->maxActiveReferencePictures = 16;
144
pCapabilities->maxActiveReferencePictures = ANV_VIDEO_H264_MAX_NUM_REF_FRAME;
145
pCapabilities->pictureAccessGranularity.width = ANV_MB_WIDTH;
146
pCapabilities->pictureAccessGranularity.height = ANV_MB_HEIGHT;
147
pCapabilities->minCodedExtent.width = ANV_MB_WIDTH;
148
pCapabilities->minCodedExtent.height = ANV_MB_HEIGHT;
137
150
ext->fieldOffsetGranularity.x = 0;
138
151
ext->fieldOffsetGranularity.y = 0;
141
154
pCapabilities->stdHeaderVersion.specVersion = VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_SPEC_VERSION;
157
case VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR: {
158
struct VkVideoDecodeH265CapabilitiesKHR *ext = (struct VkVideoDecodeH265CapabilitiesKHR *)
159
vk_find_struct(pCapabilities->pNext, VIDEO_DECODE_H265_CAPABILITIES_KHR);
161
const struct VkVideoDecodeH265ProfileInfoKHR *h265_profile =
162
vk_find_struct_const(pVideoProfile->pNext,
163
VIDEO_DECODE_H265_PROFILE_INFO_KHR);
165
/* No hardware supports the scc extension profile */
166
if (h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN &&
167
h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_10 &&
168
h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE &&
169
h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS)
170
return VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR;
172
/* Skylake only supports the main profile */
173
if (h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN &&
174
h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE &&
175
pdevice->info.platform <= INTEL_PLATFORM_SKL)
176
return VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR;
178
/* Gfx10 and under don't support the range extension profile */
179
if (h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN &&
180
h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_10 &&
181
h265_profile->stdProfileIdc != STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE &&
182
pdevice->info.ver <= 10)
183
return VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR;
185
if (pVideoProfile->lumaBitDepth != VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR &&
186
pVideoProfile->lumaBitDepth != VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR)
187
return VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR;
189
pCapabilities->pictureAccessGranularity.width = ANV_MAX_H265_CTB_SIZE;
190
pCapabilities->pictureAccessGranularity.height = ANV_MAX_H265_CTB_SIZE;
191
pCapabilities->minCodedExtent.width = ANV_MAX_H265_CTB_SIZE;
192
pCapabilities->minCodedExtent.height = ANV_MAX_H265_CTB_SIZE;
193
pCapabilities->maxDpbSlots = ANV_VIDEO_H265_MAX_NUM_REF_FRAME;
194
pCapabilities->maxActiveReferencePictures = ANV_VIDEO_H265_HCP_NUM_REF_FRAME;
196
ext->maxLevelIdc = STD_VIDEO_H265_LEVEL_IDC_6_2;
198
strcpy(pCapabilities->stdHeaderVersion.extensionName, VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME);
199
pCapabilities->stdHeaderVersion.specVersion = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION;
153
211
uint32_t *pVideoFormatPropertyCount,
154
212
VkVideoFormatPropertiesKHR *pVideoFormatProperties)
156
*pVideoFormatPropertyCount = 1;
158
if (!pVideoFormatProperties)
161
pVideoFormatProperties[0].format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
162
pVideoFormatProperties[0].imageType = VK_IMAGE_TYPE_2D;
163
pVideoFormatProperties[0].imageTiling = VK_IMAGE_TILING_OPTIMAL;
164
pVideoFormatProperties[0].imageUsageFlags = pVideoFormatInfo->imageUsage;
214
VK_OUTARRAY_MAKE_TYPED(VkVideoFormatPropertiesKHR, out,
215
pVideoFormatProperties,
216
pVideoFormatPropertyCount);
218
bool need_10bit = false;
219
const struct VkVideoProfileListInfoKHR *prof_list = (struct VkVideoProfileListInfoKHR *)
220
vk_find_struct_const(pVideoFormatInfo->pNext, VIDEO_PROFILE_LIST_INFO_KHR);
223
for (unsigned i = 0; i < prof_list->profileCount; i++) {
224
const VkVideoProfileInfoKHR *profile = &prof_list->pProfiles[i];
225
if (profile->lumaBitDepth & VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR ||
226
profile->chromaBitDepth & VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR)
231
vk_outarray_append_typed(VkVideoFormatPropertiesKHR, &out, p) {
232
p->format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
233
p->imageType = VK_IMAGE_TYPE_2D;
234
p->imageTiling = VK_IMAGE_TILING_OPTIMAL;
235
p->imageUsageFlags = pVideoFormatInfo->imageUsage;
239
vk_outarray_append_typed(VkVideoFormatPropertiesKHR, &out, p) {
240
p->format = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16;
241
p->imageType = VK_IMAGE_TYPE_2D;
242
p->imageTiling = VK_IMAGE_TILING_OPTIMAL;
243
p->imageUsageFlags = pVideoFormatInfo->imageUsage;
247
return vk_outarray_status(&out);
251
get_h264_video_mem_size(struct anv_video_session *vid, uint32_t mem_idx)
253
uint32_t width_in_mb =
254
align(vid->vk.max_coded.width, ANV_MB_WIDTH) / ANV_MB_WIDTH;
257
case ANV_VID_MEM_H264_INTRA_ROW_STORE:
258
return width_in_mb * 64;
259
case ANV_VID_MEM_H264_DEBLOCK_FILTER_ROW_STORE:
260
return width_in_mb * 64 * 4;
261
case ANV_VID_MEM_H264_BSD_MPC_ROW_SCRATCH:
262
return width_in_mb * 64 * 2;
263
case ANV_VID_MEM_H264_MPR_ROW_SCRATCH:
264
return width_in_mb * 64 * 2;
266
unreachable("unknown memory");
271
get_h265_video_mem_size(struct anv_video_session *vid, uint32_t mem_idx)
274
vid->vk.h265.profile_idc == STD_VIDEO_H265_PROFILE_IDC_MAIN_10 ? 2 : 3;
276
/* TODO. these sizes can be determined dynamically depending on ctb sizes of each slice. */
277
uint32_t width_in_ctb =
278
align(vid->vk.max_coded.width, ANV_MAX_H265_CTB_SIZE) / ANV_MAX_H265_CTB_SIZE;
279
uint32_t height_in_ctb =
280
align(vid->vk.max_coded.height, ANV_MAX_H265_CTB_SIZE) / ANV_MAX_H265_CTB_SIZE;
284
case ANV_VID_MEM_H265_DEBLOCK_FILTER_ROW_STORE_LINE:
285
case ANV_VID_MEM_H265_DEBLOCK_FILTER_ROW_STORE_TILE_LINE:
286
size = align(vid->vk.max_coded.width, 32) >> bit_shift;
288
case ANV_VID_MEM_H265_DEBLOCK_FILTER_ROW_STORE_TILE_COLUMN:
289
size = align(vid->vk.max_coded.height + 6 * height_in_ctb, 32) >> bit_shift;
291
case ANV_VID_MEM_H265_METADATA_LINE:
292
size = (((vid->vk.max_coded.width + 15) >> 4) * 188 + width_in_ctb * 9 + 1023) >> 9;
294
case ANV_VID_MEM_H265_METADATA_TILE_LINE:
295
size = (((vid->vk.max_coded.width + 15) >> 4) * 172 + width_in_ctb * 9 + 1023) >> 9;
297
case ANV_VID_MEM_H265_METADATA_TILE_COLUMN:
298
size = (((vid->vk.max_coded.height + 15) >> 4) * 176 + height_in_ctb * 89 + 1023) >> 9;
300
case ANV_VID_MEM_H265_SAO_LINE:
301
size = align((vid->vk.max_coded.width >> 1) + width_in_ctb * 3, 16) >> bit_shift;
303
case ANV_VID_MEM_H265_SAO_TILE_LINE:
304
size = align((vid->vk.max_coded.width >> 1) + width_in_ctb * 6, 16) >> bit_shift;
306
case ANV_VID_MEM_H265_SAO_TILE_COLUMN:
307
size = align((vid->vk.max_coded.height >> 1) + height_in_ctb * 6, 16) >> bit_shift;
310
unreachable("unknown memory");
169
317
get_h264_video_session_mem_reqs(struct anv_video_session *vid,
170
318
VkVideoSessionMemoryRequirementsKHR *mem_reqs,
171
uint32_t memory_types)
173
uint32_t width_in_mb = align(vid->vk.max_coded.width, ANV_MB_WIDTH) / ANV_MB_WIDTH;
174
/* intra row store is width in macroblocks * 64 */
175
mem_reqs[0].memoryBindIndex = ANV_VID_MEM_H264_INTRA_ROW_STORE;
176
mem_reqs[0].memoryRequirements.size = width_in_mb * 64;
177
mem_reqs[0].memoryRequirements.alignment = 4096;
178
mem_reqs[0].memoryRequirements.memoryTypeBits = memory_types;
180
/* deblocking filter row store is width in macroblocks * 64 * 4*/
181
mem_reqs[1].memoryBindIndex = ANV_VID_MEM_H264_DEBLOCK_FILTER_ROW_STORE;
182
mem_reqs[1].memoryRequirements.size = width_in_mb * 64 * 4;
183
mem_reqs[1].memoryRequirements.alignment = 4096;
184
mem_reqs[1].memoryRequirements.memoryTypeBits = memory_types;
186
/* bsd mpc row scratch is width in macroblocks * 64 * 2 */
187
mem_reqs[2].memoryBindIndex = ANV_VID_MEM_H264_BSD_MPC_ROW_SCRATCH;
188
mem_reqs[2].memoryRequirements.size = width_in_mb * 64 * 2;
189
mem_reqs[2].memoryRequirements.alignment = 4096;
190
mem_reqs[2].memoryRequirements.memoryTypeBits = memory_types;
192
/* mpr row scratch is width in macroblocks * 64 * 2 */
193
mem_reqs[3].memoryBindIndex = ANV_VID_MEM_H264_MPR_ROW_SCRATCH;
194
mem_reqs[3].memoryRequirements.size = width_in_mb * 64 * 2;
195
mem_reqs[3].memoryRequirements.alignment = 4096;
196
mem_reqs[3].memoryRequirements.memoryTypeBits = memory_types;
319
uint32_t *pVideoSessionMemoryRequirementsCount,
320
uint32_t memory_types)
322
VK_OUTARRAY_MAKE_TYPED(VkVideoSessionMemoryRequirementsKHR,
325
pVideoSessionMemoryRequirementsCount);
327
for (unsigned i = 0; i < ANV_VIDEO_MEM_REQS_H264; i++) {
328
uint32_t bind_index = ANV_VID_MEM_H264_INTRA_ROW_STORE + i;
329
uint64_t size = get_h264_video_mem_size(vid, i);
331
vk_outarray_append_typed(VkVideoSessionMemoryRequirementsKHR, &out, p) {
332
p->memoryBindIndex = bind_index;
333
p->memoryRequirements.size = size;
334
p->memoryRequirements.alignment = 4096;
335
p->memoryRequirements.memoryTypeBits = memory_types;
341
get_h265_video_session_mem_reqs(struct anv_video_session *vid,
342
VkVideoSessionMemoryRequirementsKHR *mem_reqs,
343
uint32_t *pVideoSessionMemoryRequirementsCount,
344
uint32_t memory_types)
346
VK_OUTARRAY_MAKE_TYPED(VkVideoSessionMemoryRequirementsKHR,
349
pVideoSessionMemoryRequirementsCount);
351
for (unsigned i = 0; i < ANV_VIDEO_MEM_REQS_H265; i++) {
352
uint32_t bind_index =
353
ANV_VID_MEM_H265_DEBLOCK_FILTER_ROW_STORE_LINE + i;
354
uint64_t size = get_h265_video_mem_size(vid, i);
356
vk_outarray_append_typed(VkVideoSessionMemoryRequirementsKHR, &out, p) {
357
p->memoryBindIndex = bind_index;
358
p->memoryRequirements.size = size;
359
p->memoryRequirements.alignment = 4096;
360
p->memoryRequirements.memoryTypeBits = memory_types;