1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
|
/*
* Copyright (c) 2022-2025 The Khronos Group Inc.
* Copyright (c) 2022-2025 RasterGrid Kft.
* Modifications Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
#include "../framework/video_objects.h"
class NegativeVideoDecodeAV1 : public VkVideoLayerTest {};
TEST_F(NegativeVideoDecodeAV1, ProfileMissingCodecInfo) {
TEST_DESCRIPTION("Test missing codec-specific structure in profile definition");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
VkVideoProfileInfoKHR profile = *config.Profile();
profile.pNext = nullptr;
// Missing codec-specific info for AV1 decode profile
m_errorMonitor->SetDesiredError("VUID-VkVideoProfileInfoKHR-videoCodecOperation-09256");
vk::GetPhysicalDeviceVideoCapabilitiesKHR(Gpu(), &profile, config.Caps());
m_errorMonitor->VerifyFound();
}
TEST_F(NegativeVideoDecodeAV1, CapabilityQueryMissingChain) {
TEST_DESCRIPTION("vkGetPhysicalDeviceVideoCapabilitiesKHR - missing return structures in chain");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
auto caps = vku::InitStruct<VkVideoCapabilitiesKHR>();
auto decode_caps = vku::InitStruct<VkVideoDecodeCapabilitiesKHR>();
auto decode_av1_caps = vku::InitStruct<VkVideoDecodeAV1CapabilitiesKHR>();
// Missing decode caps struct for decode profile
m_errorMonitor->SetDesiredError("VUID-vkGetPhysicalDeviceVideoCapabilitiesKHR-pVideoProfile-07183");
caps.pNext = &decode_av1_caps;
vk::GetPhysicalDeviceVideoCapabilitiesKHR(Gpu(), config.Profile(), &caps);
m_errorMonitor->VerifyFound();
// Missing AV1 decode caps struct for AV1 decode profile
m_errorMonitor->SetDesiredError("VUID-vkGetPhysicalDeviceVideoCapabilitiesKHR-pVideoProfile-09257");
caps.pNext = &decode_caps;
vk::GetPhysicalDeviceVideoCapabilitiesKHR(Gpu(), config.Profile(), &caps);
m_errorMonitor->VerifyFound();
}
TEST_F(NegativeVideoDecodeAV1, CreateSessionParamsMissingCodecInfo) {
TEST_DESCRIPTION("vkCreateVideoSessionParametersKHR - missing codec-specific chained structure");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
VideoContext context(DeviceObj(), config);
VkVideoSessionParametersKHR params;
VkVideoSessionParametersCreateInfoKHR create_info = *config.SessionParamsCreateInfo();
auto other_codec_info = vku::InitStruct<VkVideoDecodeH264SessionParametersCreateInfoKHR>();
other_codec_info.maxStdSPSCount = 1;
other_codec_info.maxStdPPSCount = 1;
create_info.pNext = &other_codec_info;
create_info.videoSession = context.Session();
m_errorMonitor->SetDesiredError("VUID-VkVideoSessionParametersCreateInfoKHR-videoSession-09259");
vk::CreateVideoSessionParametersKHR(device(), &create_info, nullptr, ¶ms);
m_errorMonitor->VerifyFound();
}
TEST_F(NegativeVideoDecodeAV1, CreateSessionParamsTemplateNotAllowed) {
TEST_DESCRIPTION("vkCreateVideoSessionParametersKHR - AV1 decode does not allow using parameters templates");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
VideoContext context(DeviceObj(), config);
StdVideoAV1SequenceHeader seq_header{};
auto av1_ci = vku::InitStruct<VkVideoDecodeAV1SessionParametersCreateInfoKHR>();
av1_ci.pStdSequenceHeader = &seq_header;
VkVideoSessionParametersKHR params, params2;
VkVideoSessionParametersCreateInfoKHR create_info = *config.SessionParamsCreateInfo();
create_info.pNext = &av1_ci;
create_info.videoSession = context.Session();
vk::CreateVideoSessionParametersKHR(device(), &create_info, nullptr, ¶ms);
create_info.videoSessionParametersTemplate = params;
m_errorMonitor->SetDesiredError("VUID-VkVideoSessionParametersCreateInfoKHR-videoSession-09258");
vk::CreateVideoSessionParametersKHR(device(), &create_info, nullptr, ¶ms2);
m_errorMonitor->VerifyFound();
vk::DestroyVideoSessionParametersKHR(device(), params, nullptr);
}
TEST_F(NegativeVideoDecodeAV1, UpdateSessionParams) {
TEST_DESCRIPTION("vkUpdateVideoSessionParametersKHR - not supported for AV1 decode");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
VideoContext context(DeviceObj(), config);
auto update_info = vku::InitStruct<VkVideoSessionParametersUpdateInfoKHR>();
update_info.updateSequenceCount = 1;
m_errorMonitor->SetDesiredError("VUID-vkUpdateVideoSessionParametersKHR-videoSessionParameters-09260");
vk::UpdateVideoSessionParametersKHR(device(), context.SessionParams(), &update_info);
m_errorMonitor->VerifyFound();
}
TEST_F(NegativeVideoDecodeAV1, BeginCodingRequiresSessionParams) {
TEST_DESCRIPTION("vkCmdBeginVideoCodingKHR - AV1 decode requires session parameters");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
VideoContext context(DeviceObj(), config);
context.CreateAndBindSessionMemory();
vkt::CommandBuffer& cb = context.CmdBuffer();
VkVideoBeginCodingInfoKHR begin_info = context.Begin();
begin_info.videoSessionParameters = VK_NULL_HANDLE;
cb.Begin();
m_errorMonitor->SetDesiredError("VUID-VkVideoBeginCodingInfoKHR-videoSession-09261");
cb.BeginVideoCoding(begin_info);
m_errorMonitor->VerifyFound();
cb.End();
}
TEST_F(NegativeVideoDecodeAV1, DecodeMissingInlineSessionParams) {
TEST_DESCRIPTION("vkCmdBeginVideoCodingKHR - AV1 decode requires bound params object when not all params are specified inline");
AddRequiredExtensions(VK_KHR_VIDEO_MAINTENANCE_2_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::videoMaintenance2);
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfigDecodeAV1();
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support";
}
// Session has no VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR
{
VideoContext context(m_device, config);
context.CreateAndBindSessionMemory();
context.CreateResources();
vkt::CommandBuffer& cb = context.CmdBuffer();
StdVideoAV1SequenceHeader std_seq_header{};
cb.Begin();
cb.BeginVideoCoding(context.Begin().SetSessionParams(VK_NULL_HANDLE));
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-None-10407");
cb.DecodeVideo(context.DecodeFrame().InlineParamsAV1(&std_seq_header));
m_errorMonitor->VerifyFound();
cb.EndVideoCoding(context.End());
cb.End();
}
// Missing inline sequence header
{
config.SessionCreateInfo()->flags |= VK_VIDEO_SESSION_CREATE_INLINE_SESSION_PARAMETERS_BIT_KHR;
VideoContext context(m_device, config);
context.CreateAndBindSessionMemory();
context.CreateResources();
vkt::CommandBuffer& cb = context.CmdBuffer();
cb.Begin();
cb.BeginVideoCoding(context.Begin().SetSessionParams(VK_NULL_HANDLE));
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-None-10407");
cb.DecodeVideo(context.DecodeFrame().InlineParamsAV1(nullptr));
m_errorMonitor->VerifyFound();
cb.EndVideoCoding(context.End());
cb.End();
}
}
TEST_F(NegativeVideoDecodeAV1, DecodeInvalidCodecInfo) {
TEST_DESCRIPTION("vkCmdDecodeVideoKHR - invalid/missing AV1 codec-specific information");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfig(GetConfigsWithDpbSlots(GetConfigsWithReferences(GetConfigsDecodeAV1(), 2), 2));
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support with 2 reference pictures and 2 DPB slots";
}
config.SessionCreateInfo()->maxDpbSlots = 2;
config.SessionCreateInfo()->maxActiveReferencePictures = 2;
VideoContext context(DeviceObj(), config);
context.CreateAndBindSessionMemory();
context.CreateResources();
vkt::CommandBuffer& cb = context.CmdBuffer();
VideoDecodeInfo decode_info = context.DecodeFrame(0);
StdVideoDecodeAV1PictureInfo std_picture_info{};
auto picture_info = vku::InitStruct<VkVideoDecodeAV1PictureInfoKHR>();
uint32_t tile_offset = 0;
uint32_t tile_size = (uint32_t)decode_info->srcBufferRange;
picture_info.pStdPictureInfo = &std_picture_info;
for (uint32_t i = 0; i < VK_MAX_VIDEO_AV1_REFERENCES_PER_FRAME_KHR; ++i) {
picture_info.referenceNameSlotIndices[i] = -1;
}
picture_info.tileCount = 1;
picture_info.pTileOffsets = &tile_offset;
picture_info.pTileSizes = &tile_size;
cb.Begin();
cb.BeginVideoCoding(context.Begin().AddResource(0, 0).AddResource(-1, 1));
// Missing AV1 picture info
{
decode_info = context.DecodeFrame(0);
decode_info->pNext = nullptr;
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pNext-09250");
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
}
// Frame header offset must be within buffer range
{
decode_info = context.DecodeFrame(0);
decode_info->pNext = &picture_info;
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-frameHeaderOffset-09251");
picture_info.frameHeaderOffset = (uint32_t)decode_info->srcBufferRange;
cb.DecodeVideo(decode_info);
picture_info.frameHeaderOffset = 0;
m_errorMonitor->VerifyFound();
}
// Tile offsets must be within buffer range
{
decode_info = context.DecodeFrame(0);
decode_info->pNext = &picture_info;
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pTileOffsets-09252");
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pTileOffsets-09253");
tile_offset = (uint32_t)decode_info->srcBufferRange;
cb.DecodeVideo(decode_info);
tile_offset = 0;
m_errorMonitor->VerifyFound();
}
// Tile offset plus size must be within buffer range
{
decode_info = context.DecodeFrame(0);
decode_info->pNext = &picture_info;
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pTileOffsets-09252");
tile_size = (uint32_t)decode_info->srcBufferRange + 1;
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pTileOffsets-09252");
tile_offset = 1;
tile_size = (uint32_t)decode_info->srcBufferRange;
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
tile_offset = 0;
tile_size = (uint32_t)decode_info->srcBufferRange;
}
// Film grain cannot be used if the video profile did not enable support for it
{
decode_info = context.DecodeFrame(0);
decode_info->pNext = &picture_info;
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-09249");
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-filmGrainSupport-09248");
std_picture_info.flags.apply_grain = 1;
cb.DecodeVideo(decode_info);
std_picture_info.flags.apply_grain = 0;
m_errorMonitor->VerifyFound();
}
// Missing AV1 setup reference info
{
auto slot = vku::InitStruct<VkVideoReferenceSlotInfoKHR>();
slot.pNext = nullptr;
slot.slotIndex = 0;
slot.pPictureResource = &context.Dpb()->Picture(0);
decode_info = context.DecodeFrame(1);
decode_info->pNext = &picture_info;
decode_info->pSetupReferenceSlot = &slot;
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07141");
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-09254");
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
}
// Missing AV1 reference info
{
auto slot = vku::InitStruct<VkVideoReferenceSlotInfoKHR>();
slot.pNext = nullptr;
slot.slotIndex = 0;
slot.pPictureResource = &context.Dpb()->Picture(0);
decode_info = context.DecodeFrame(1);
decode_info->pNext = &picture_info;
decode_info->referenceSlotCount = 1;
decode_info->pReferenceSlots = &slot;
picture_info.referenceNameSlotIndices[3] = 0;
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pNext-09255");
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
picture_info.referenceNameSlotIndices[3] = -1;
}
// Missing reference in referenceNameSlotIndices to reference slot
{
auto slot = vku::InitStruct<VkVideoReferenceSlotInfoKHR>();
slot.pNext = nullptr;
slot.slotIndex = 0;
slot.pPictureResource = &context.Dpb()->Picture(0);
decode_info = context.DecodeFrame(1);
decode_info->pNext = &picture_info;
decode_info->referenceSlotCount = 1;
decode_info->pReferenceSlots = &slot;
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pNext-09255");
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-slotIndex-09263");
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
}
// Missing reference slot for DPB slot index referred to by referenceNameSlotIndices
{
decode_info = context.DecodeFrame(0);
decode_info->pNext = &picture_info;
picture_info.referenceNameSlotIndices[3] = 0;
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-referenceNameSlotIndices-09262");
cb.DecodeVideo(decode_info);
m_errorMonitor->VerifyFound();
picture_info.referenceNameSlotIndices[3] = -1;
}
cb.EndVideoCoding(context.End());
cb.End();
}
TEST_F(NegativeVideoDecodeAV1, DecodeFilmGrainRequiresDistinct) {
TEST_DESCRIPTION("vkCmdDecodeVideoKHR - AV1 film grain requires distinct reconstructed picture");
RETURN_IF_SKIP(Init());
VideoConfig config = GetConfig(GetConfigsWithReferences(GetConfigsDecodeAV1FilmGrain()));
if (!config) {
GTEST_SKIP() << "Test requires AV1 decode support with reference pictures and film grain";
}
config.SessionCreateInfo()->maxDpbSlots = 1;
config.SessionCreateInfo()->maxActiveReferencePictures = 1;
VideoContext context(DeviceObj(), config);
context.CreateAndBindSessionMemory();
context.CreateResources();
vkt::CommandBuffer& cb = context.CmdBuffer();
cb.Begin();
cb.BeginVideoCoding(context.Begin().AddResource(-1, 0));
// It is possible that the DPB uses a different format, so ignore format mismatch errors
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07143");
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07140");
m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07146");
m_errorMonitor->SetDesiredError("VUID-vkCmdDecodeVideoKHR-pDecodeInfo-09249");
cb.DecodeVideo(context.DecodeFrame(0).ApplyFilmGrain().SetDecodeOutput(context.Dpb()->Picture(0)));
m_errorMonitor->VerifyFound();
cb.EndVideoCoding(context.End());
cb.End();
}
|