File: video_encode_intra_refresh.cpp

package info (click to toggle)
vulkan-validationlayers 1.4.321.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,412 kB
  • sloc: cpp: 594,175; python: 11,321; sh: 24; makefile: 20; xml: 14
file content (909 lines) | stat: -rw-r--r-- 37,638 bytes parent folder | download
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
/*
 * Copyright (c) 2025 The Khronos Group Inc.
 * Copyright (c) 2025 RasterGrid Kft.
 *
 * 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"
#include "generated/enum_flag_bits.h"

class NegativeVideoEncodeIntraRefresh : public VkVideoLayerTest {};

TEST_F(NegativeVideoEncodeIntraRefresh, CreateSessionVideoEncodeIntraRefreshNotEnabled) {
    TEST_DESCRIPTION("vkCreateVideoSession - creating session with intra refresh requires videoEncodeIntraRefresh feature");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    ForceDisableFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithIntraRefresh(GetConfigsEncode()));
    if (!config) {
        GTEST_SKIP() << "Test requires video encode support with intra refresh";
    }

    VkVideoSessionKHR session = VK_NULL_HANDLE;

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_NONE_KHR);
    VkVideoSessionCreateInfoKHR create_info = *config.SessionCreateInfo();
    create_info.pVideoProfile = config.Profile();
    create_info.pStdHeaderVersion = config.StdVersion();

    EXPECT_EQ(vk::CreateVideoSessionKHR(device(), &create_info, nullptr, &session), VK_SUCCESS);
    vk::DestroyVideoSessionKHR(device(), session, nullptr);

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());
    create_info = *config.SessionCreateInfo();
    create_info.pVideoProfile = config.Profile();
    create_info.pStdHeaderVersion = config.StdVersion();

    m_errorMonitor->SetDesiredError("VUID-VkVideoSessionCreateInfoKHR-pVideoProfile-10835");
    vk::CreateVideoSessionKHR(device(), &create_info, nullptr, &session);
    m_errorMonitor->VerifyFound();
}

TEST_F(NegativeVideoEncodeIntraRefresh, IntraRefreshUnsupportedMode) {
    TEST_DESCRIPTION("vkCreateVideoSession - intra refresh mode is not supported");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    // Try to find a config that does not support all intra refresh modes
    VkVideoEncodeIntraRefreshModeFlagsKHR all_ir_modes = AllVkVideoEncodeIntraRefreshModeFlagBitsKHR;
    VideoConfig config = GetConfig(FilterConfigs(GetConfigsEncode(), [all_ir_modes](const VideoConfig& config) {
        return (config.EncodeIntraRefreshCaps()->intraRefreshModes & all_ir_modes) < all_ir_modes;
    }));
    if (!config) {
        GTEST_SKIP() << "Test requires an encode profile that does not support all intra refresh modes";
    }

    auto unsupported_ir_modes = (config.EncodeIntraRefreshCaps()->intraRefreshModes & all_ir_modes) ^ all_ir_modes;

    VkVideoSessionKHR session = VK_NULL_HANDLE;

    config.SetVideoEncodeIntraRefreshMode(
        static_cast<VkVideoEncodeIntraRefreshModeFlagBitsKHR>(1 << static_cast<uint32_t>(log2(unsupported_ir_modes))));
    VkVideoSessionCreateInfoKHR create_info = *config.SessionCreateInfo();
    create_info.pVideoProfile = config.Profile();
    create_info.pStdHeaderVersion = config.StdVersion();

    m_errorMonitor->SetDesiredError("VUID-VkVideoSessionCreateInfoKHR-pVideoProfile-10836");
    vk::CreateVideoSessionKHR(device(), &create_info, nullptr, &session);
    m_errorMonitor->VerifyFound();
}

TEST_F(NegativeVideoEncodeIntraRefresh, InvalidIntraRefreshMode) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - intra refresh mode is invalid");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithIntraRefresh(GetConfigsEncode()));
    if (!config) {
        GTEST_SKIP() << "Test requires video encode support with intra refresh";
    }

    config.SessionCreateInfo()->maxDpbSlots = 2;
    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));

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10837");
    cb.EncodeVideo(context.EncodeFrame(0).IntraRefresh(2, 0));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, TooManyIntraRefreshActiveReferencePictures) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - too many active reference pictures when using intra refresh");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(FilterConfigs(GetConfigsWithIntraRefresh(GetConfigsEncode()), [](const VideoConfig& config) {
        const uint32_t max_intra_refresh_refs = config.EncodeIntraRefreshCaps()->maxIntraRefreshActiveReferencePictures;
        return config.Caps()->maxDpbSlots > max_intra_refresh_refs + 1 &&
               config.Caps()->maxActiveReferencePictures > max_intra_refresh_refs;
    }));
    if (!config) {
        GTEST_SKIP() << "Test requires video encode support with limited max intra refresh active references";
    }

    auto max_active_ref_plus1 = config.EncodeIntraRefreshCaps()->maxIntraRefreshActiveReferencePictures + 1;

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());
    config.SessionCreateInfo()->maxDpbSlots = max_active_ref_plus1 + 1;
    config.SessionCreateInfo()->maxActiveReferencePictures = max_active_ref_plus1;

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    auto begin_info = context.Begin();
    for (unsigned int i = 0; i < max_active_ref_plus1; ++i) {
        begin_info.AddResource(i, i);
    }
    begin_info.AddResource(-1, max_active_ref_plus1);

    cb.Begin();
    cb.BeginVideoCoding(begin_info);

    auto encode_info = context.EncodeFrame(max_active_ref_plus1).IntraRefresh(2, 0);
    for (unsigned int i = 0; i < max_active_ref_plus1; ++i) {
        encode_info.AddReferenceFrame(i);
    }

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10838");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, BlockBasedInvalidIntraRefreshInfo) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - intra refresh info is invalid for block-based intra refresh");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithBlockBasedIntraRefresh(GetConfigsEncode()));
    if (!config) {
        GTEST_SKIP() << "Test requires video encode support with block-based intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_BLOCK_BASED_BIT_KHR);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    auto encode_info = context.EncodeFrame();
    encode_info->flags |= VK_VIDEO_ENCODE_INTRA_REFRESH_BIT_KHR;

    auto ir_info = vku::InitStruct<VkVideoEncodeIntraRefreshInfoKHR>();

    // VkVideoEncodeInfo::pNext missing VkVideoEncodeIntraRefreshInfoKHR
    {
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10839");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    ir_info.pNext = encode_info->pNext;
    encode_info->pNext = &ir_info;

    // intraRefreshCycleDuration == 0
    {
        ir_info.intraRefreshCycleDuration = 0;

        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10840");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    // intraRefreshIndex > intraRefreshCycleDuration
    {
        ir_info.intraRefreshCycleDuration = 2;
        ir_info.intraRefreshIndex = 3;

        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10841");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    // intraRefreshCycleDuration out of supported range
    {
        ir_info.intraRefreshIndex = 0;

        ir_info.intraRefreshCycleDuration = 1;

        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10844");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();

        ir_info.intraRefreshCycleDuration = config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration + 1;

        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10844");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionInvalidIntraRefreshInfo) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - intra refresh info is invalid for per-picture-partition intra refresh");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncode()));
    if (!config) {
        GTEST_SKIP() << "Test requires video encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    auto encode_info = context.EncodeFrame();
    encode_info->flags |= VK_VIDEO_ENCODE_INTRA_REFRESH_BIT_KHR;

    // For per-picture-partition intra refresh mode we may indirectly violate other codec-specific VUs
    auto set_allowed_vuids = [&] {
        if (config.GetVideoEncodeIntraRefreshMode() == VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR) {
            switch (config.Profile()->videoCodecOperation) {
                case VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR:
                    m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10846");
                    break;
                case VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR:
                    m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10852");
                    break;
                default:
                    break;
            }
        }
    };

    auto ir_info = vku::InitStruct<VkVideoEncodeIntraRefreshInfoKHR>();

    // VkVideoEncodeInfo::pNext missing VkVideoEncodeIntraRefreshInfoKHR
    {
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10839");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    ir_info.pNext = encode_info->pNext;
    encode_info->pNext = &ir_info;

    // intraRefreshCycleDuration == 0
    {
        ir_info.intraRefreshCycleDuration = 0;

        set_allowed_vuids();
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10840");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    // intraRefreshIndex > intraRefreshCycleDuration
    {
        ir_info.intraRefreshCycleDuration = 2;
        ir_info.intraRefreshIndex = 3;

        set_allowed_vuids();
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10841");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    // intraRefreshCycleDuration out of supported range
    {
        ir_info.intraRefreshIndex = 0;

        ir_info.intraRefreshCycleDuration = 1;

        set_allowed_vuids();
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10844");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();

        ir_info.intraRefreshCycleDuration = config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration + 1;

        set_allowed_vuids();
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10844");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, InvalidDirtyRegions) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - intra refresh reference info contains invalid dirty intra refresh regions");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithIntraRefresh(GetConfigsEncode()));
    if (!config) {
        GTEST_SKIP() << "Test requires video encode support with intra refresh";
    }

    config.SessionCreateInfo()->maxDpbSlots = 2;
    config.SessionCreateInfo()->maxActiveReferencePictures = 1;

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin().AddResource(-1, 0).AddResource(1, 1));

    // dirtyIntraRefreshRegions is not zero but intra refresh is not enabled
    {
        auto encode_info = context.EncodeFrame(0).IntraRefresh(2, 1).AddReferenceFrameWithDirtyRegions(1, 1);
        encode_info->flags = encode_info->flags & (~VK_VIDEO_ENCODE_INTRA_REFRESH_BIT_KHR);

        // For per-picture-partition intra refresh mode we may indirectly violate other codec-specific VUs
        if (config.GetVideoEncodeIntraRefreshMode() == VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR) {
            switch (config.Profile()->videoCodecOperation) {
                case VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR:
                    if ((config.EncodeCapsH264()->flags & VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_KHR) == 0) {
                        m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdEncodeVideoKHR-flags-10850");
                    }
                    break;
                case VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR:
                    if ((config.EncodeCapsH265()->flags & VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_SEGMENT_TYPE_BIT_KHR) ==
                        0) {
                        m_errorMonitor->SetAllowedFailureMsg("VUID-vkCmdEncodeVideoKHR-flags-10856");
                    }
                    break;
                default:
                    break;
            }
        }

        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10842");
        cb.EncodeVideo(encode_info);
        m_errorMonitor->VerifyFound();
    }

    // dirtyIntraRefreshRegions != intraRefreshCycleDuration - intraRefreshIndex
    {
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10843");
        cb.EncodeVideo(context.EncodeFrame(0).IntraRefresh(2, 1).AddReferenceFrameWithDirtyRegions(1, 2));
        m_errorMonitor->VerifyFound();
    }
}

TEST_F(NegativeVideoEncodeIntraRefresh, BlockBasedSliceCountH264) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - cannot encode multiple H.264 slices with block-based intra refresh when partition independent intra "
        "refresh regions is not supported");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config =
        GetConfig(FilterConfigs(GetConfigsWithBlockBasedIntraRefresh(GetConfigsEncodeH264()), [](const VideoConfig& config) {
            return config.EncodeIntraRefreshCaps()->partitionIndependentIntraRefreshRegions == VK_FALSE &&
                   config.EncodeCapsH264()->maxSliceCount > 1;
        }));
    if (!config) {
        GTEST_SKIP() << "Test requires H.264 encode support without partition-independent intra refresh with block-based mode";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_BLOCK_BASED_BIT_KHR);

    // We use the largest coded extent to avoid hitting other limitations
    config.SessionCreateInfo()->maxCodedExtent = config.Caps()->maxCodedExtent;

    const uint32_t duration = config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration;

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10845");
    cb.EncodeVideo(context.EncodeFrame().IntraRefresh(duration, 0).SetPartitionCount(2));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionSliceCountH264) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - H.264 encode with per-picture-partition intra refresh requires matching slice count and duration");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncodeH264()));
    if (!config) {
        GTEST_SKIP() << "Test requires H.264 encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    // We use the largest coded extent to avoid hitting other limitations
    config.SessionCreateInfo()->maxCodedExtent = config.Caps()->maxCodedExtent;

    const uint32_t duration = std::min(config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration, 3u);
    const uint32_t slice_count =
        std::min(config.EncodeCapsH264()->maxSliceCount, config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration - 1);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10846");
    cb.EncodeVideo(context.EncodeFrame().IntraRefresh(duration, 0).SetPartitionCount(slice_count));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionSliceTypeH264) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - H.264 encode with per-picture-partition intra refresh requires I slice for refreshed slice");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config =
        GetConfig(FilterConfigs(GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncodeH264()),
                                [](const VideoConfig& config) { return config.EncodeCapsH264()->maxSliceCount > 1; }));
    if (!config) {
        GTEST_SKIP() << "Test requires H.264 encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    // We use the largest coded extent to avoid hitting other limitations
    config.SessionCreateInfo()->maxCodedExtent = config.Caps()->maxCodedExtent;

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    const uint32_t refreshed_slice_index = 1;
    auto encode_info = context.EncodeFrame().IntraRefresh(2, refreshed_slice_index);
    auto& slice_headers = encode_info.CodecInfo().encode_h264.std_slice_headers;

    slice_headers[refreshed_slice_index].slice_type = STD_VIDEO_H264_SLICE_TYPE_P;

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-intraRefreshH264SliceIndex-10847");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionNonRectTooManySlicesH264) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - H.264 per-picture-partition intra refresh with too many slices but no non-rectangular intra refresh "
        "regions");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    auto configs = GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncodeH264());
    VideoConfig config;
    uint32_t max_slice_count = 0;
    for (auto& cfg : configs) {
        if (cfg.EncodeIntraRefreshCaps()->nonRectangularIntraRefreshRegions == VK_FALSE &&
            cfg.EncodeCapsH264()->maxSliceCount <= cfg.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration &&
            cfg.EncodeCapsH264()->maxSliceCount > max_slice_count) {
            config = cfg;
            max_slice_count = cfg.EncodeCapsH264()->maxSliceCount;
        }
    }
    if (!config) {
        GTEST_SKIP() << "Test requires H.264 encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    const uint32_t slice_count = config.MaxEncodeH264MBRowCount() + 1;

    if (slice_count > config.EncodeCapsH264()->maxSliceCount) {
        m_errorMonitor->SetAllowedFailureMsg("VUID-VkVideoEncodeH264PictureInfoKHR-naluSliceEntryCount-08301");
    }
    if (slice_count > config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration) {
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10844");
    }
    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10848");
    cb.EncodeVideo(context.EncodeFrame().IntraRefresh(slice_count, 0));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, UnsupportedBPicH264) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - H.264 B picture encode with intra refresh without support");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(FilterConfigs(GetConfigsWithIntraRefresh(GetConfigsEncodeH264()), [](const VideoConfig& config) {
        return (config.EncodeCapsH264()->maxBPictureL0ReferenceCount > 0) &&
               (config.EncodeCapsH264()->flags & VK_VIDEO_ENCODE_H264_CAPABILITY_B_PICTURE_INTRA_REFRESH_BIT_KHR) == 0;
    }));
    if (!config) {
        GTEST_SKIP() << "Test requires H.264 encode support with no support for B picture encode with intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    auto encode_info = context.EncodeFrame().IntraRefresh(2, 0);
    encode_info.CodecInfo().encode_h264.std_picture_info.primary_pic_type = STD_VIDEO_H264_PICTURE_TYPE_B;

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-h264PictureType-10849");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, BlockBasedSliceSegmentCountH265) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - cannot encode multiple H.265 slice segments with block-based intra refresh when partition "
        "independent intra "
        "refresh regions is not supported");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config =
        GetConfig(FilterConfigs(GetConfigsWithBlockBasedIntraRefresh(GetConfigsEncodeH265()), [](const VideoConfig& config) {
            return config.EncodeIntraRefreshCaps()->partitionIndependentIntraRefreshRegions == VK_FALSE &&
                   config.EncodeCapsH265()->maxSliceSegmentCount > 1;
        }));
    if (!config) {
        GTEST_SKIP() << "Test requires H.265 encode support without partition-independent intra refresh with block-based mode";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_BLOCK_BASED_BIT_KHR);

    // We use the largest coded extent to avoid hitting other limitations
    config.SessionCreateInfo()->maxCodedExtent = config.Caps()->maxCodedExtent;

    const uint32_t duration = config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration;

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    // We want to test this VU, even in the absence of some capabilities
    if ((config.EncodeCapsH265()->flags & VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_SEGMENTS_PER_TILE_BIT_KHR) == 0) {
        m_errorMonitor->SetAllowedFailureMsg("VUID-VkVideoEncodeH265PictureInfoKHR-flags-08324");
    }
    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10851");
    cb.EncodeVideo(context.EncodeFrame().IntraRefresh(duration, 0).SetPartitionCount(2));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionSliceCountH265) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - H.265 encode with per-picture-partition intra refresh requires matching slice segment count and "
        "duration");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncodeH265()));
    if (!config) {
        GTEST_SKIP() << "Test requires H.265 encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    // We use the largest coded extent to avoid hitting other limitations
    config.SessionCreateInfo()->maxCodedExtent = config.Caps()->maxCodedExtent;

    const uint32_t duration = std::min(config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration, 3u);
    const uint32_t slice_segment_count =
        std::min(config.EncodeCapsH265()->maxSliceSegmentCount, config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration - 1);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10852");
    cb.EncodeVideo(context.EncodeFrame().IntraRefresh(duration, 0).SetPartitionCount(slice_segment_count));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionSliceTypeH265) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - H.265 encode with per-picture-partition intra refresh requires I slice segment for refreshed slice");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config =
        GetConfig(FilterConfigs(GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncodeH265()),
                                [](const VideoConfig& config) { return config.EncodeCapsH265()->maxSliceSegmentCount > 1; }));
    if (!config) {
        GTEST_SKIP() << "Test requires H.265 encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    const uint32_t refreshed_slice_segment_index = 1;
    auto encode_info = context.EncodeFrame().IntraRefresh(2, refreshed_slice_segment_index);
    auto& slice_segment_headers = encode_info.CodecInfo().encode_h265.std_slice_segment_headers;

    slice_segment_headers[refreshed_slice_segment_index].slice_type = STD_VIDEO_H265_SLICE_TYPE_P;

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-intraRefreshH265SliceSegmentIndex-10853");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, PerPicturePartitionNonRectTooManySliceSegmentsH265) {
    TEST_DESCRIPTION(
        "vkCmdEncodeVideoKHR - H.265 per-picture-partition intra refresh with too many slice segments but no non-rectangular intra "
        "refresh regions");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    auto configs = GetConfigsWithPerPartitionIntraRefresh(GetConfigsEncodeH265());
    VideoConfig config;
    uint32_t max_slice_count = 0;
    for (auto& cfg : configs) {
        if (cfg.EncodeIntraRefreshCaps()->nonRectangularIntraRefreshRegions == VK_FALSE &&
            cfg.EncodeCapsH265()->maxSliceSegmentCount <= cfg.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration &&
            cfg.EncodeCapsH265()->maxSliceSegmentCount > max_slice_count) {
            config = cfg;
            max_slice_count = cfg.EncodeCapsH265()->maxSliceSegmentCount;
        }
    }
    if (!config) {
        GTEST_SKIP() << "Test requires H.265 encode support with per-picture-partition intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(VK_VIDEO_ENCODE_INTRA_REFRESH_MODE_PER_PICTURE_PARTITION_BIT_KHR);

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    const uint32_t slice_segment_count = config.MaxEncodeH265CTBRowCount() + 1;

    if (slice_segment_count > config.EncodeCapsH265()->maxSliceSegmentCount) {
        m_errorMonitor->SetAllowedFailureMsg("VUID-VkVideoEncodeH265PictureInfoKHR-naluSliceSegmentEntryCount-08306");
    }
    if (slice_segment_count > config.EncodeIntraRefreshCaps()->maxIntraRefreshCycleDuration) {
        m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pNext-10844");
    }
    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-pEncodeInfo-10854");
    cb.EncodeVideo(context.EncodeFrame().IntraRefresh(slice_segment_count, 0));
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, UnsupportedBPicH265) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - H.265 B picture encode with intra refresh without support");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(FilterConfigs(GetConfigsWithIntraRefresh(GetConfigsEncodeH265()), [](const VideoConfig& config) {
        return (config.EncodeCapsH265()->maxBPictureL0ReferenceCount > 0) &&
               (config.EncodeCapsH265()->flags & VK_VIDEO_ENCODE_H265_CAPABILITY_B_PICTURE_INTRA_REFRESH_BIT_KHR) == 0;
    }));
    if (!config) {
        GTEST_SKIP() << "Test requires H.265 encode support with no support for B picture encode with intra refresh";
    }

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin());

    auto encode_info = context.EncodeFrame().IntraRefresh(2, 0);
    encode_info.CodecInfo().encode_h265.std_picture_info.pic_type = STD_VIDEO_H265_PICTURE_TYPE_B;

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-h265PictureType-10855");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, UnsupportedUnidirectionCompoundAV1) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - AV1 unidirectional compound prediction with intra refresh without support");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(FilterConfigs(GetConfigsWithIntraRefresh(GetConfigsEncodeAV1()), [](const VideoConfig& config) {
        return (config.EncodeCapsAV1()->maxUnidirectionalCompoundReferenceCount > 0) &&
               (config.EncodeCapsAV1()->flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_COMPOUND_PREDICTION_INTRA_REFRESH_BIT_KHR) == 0;
    }));
    if (!config) {
        GTEST_SKIP() << "Test requires AV1 encode support with unidirectional compound prediction mode support "
                        "but no support for compound prediction with intra refresh";
    }

    config.SessionCreateInfo()->maxDpbSlots = 2;
    config.SessionCreateInfo()->maxActiveReferencePictures = 1;

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin().AddResource(-1, 0).AddResource(1, 1));

    auto encode_info = context.EncodeFrame(0).IntraRefresh(2, 0).AddReferenceFrame(1, 1);
    encode_info.CodecInfo().encode_av1.picture_info.predictionMode =
        VK_VIDEO_ENCODE_AV1_PREDICTION_MODE_UNIDIRECTIONAL_COMPOUND_KHR;

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-predictionMode-10857");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}

TEST_F(NegativeVideoEncodeIntraRefresh, UnsupportedBidirectionCompoundAV1) {
    TEST_DESCRIPTION("vkCmdEncodeVideoKHR - AV1 bidirectional compound prediction with intra refresh without support");

    AddRequiredExtensions(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME);
    AddRequiredFeature(vkt::Feature::videoEncodeIntraRefresh);
    RETURN_IF_SKIP(Init());

    VideoConfig config = GetConfig(FilterConfigs(GetConfigsWithIntraRefresh(GetConfigsEncodeAV1()), [](const VideoConfig& config) {
        return (config.EncodeCapsAV1()->maxBidirectionalCompoundReferenceCount > 0) &&
               (config.EncodeCapsAV1()->flags & VK_VIDEO_ENCODE_AV1_CAPABILITY_COMPOUND_PREDICTION_INTRA_REFRESH_BIT_KHR) == 0;
    }));
    if (!config) {
        GTEST_SKIP() << "Test requires AV1 encode support with bidirectional compound prediction mode support "
                        "but no support for compound prediction with intra refresh";
    }

    config.SessionCreateInfo()->maxDpbSlots = 2;
    config.SessionCreateInfo()->maxActiveReferencePictures = 1;

    config.SetVideoEncodeIntraRefreshMode(config.GetAnySupportedIntraRefreshMode());

    VideoContext context(DeviceObj(), config);
    context.CreateAndBindSessionMemory();
    context.CreateResources();

    vkt::CommandBuffer& cb = context.CmdBuffer();

    cb.Begin();
    cb.BeginVideoCoding(context.Begin().AddResource(-1, 0).AddResource(1, 1));

    auto encode_info = context.EncodeFrame(0).IntraRefresh(2, 0).AddReferenceFrame(1, 1);
    encode_info.CodecInfo().encode_av1.picture_info.predictionMode = VK_VIDEO_ENCODE_AV1_PREDICTION_MODE_BIDIRECTIONAL_COMPOUND_KHR;

    m_errorMonitor->SetDesiredError("VUID-vkCmdEncodeVideoKHR-predictionMode-10857");
    cb.EncodeVideo(encode_info);
    m_errorMonitor->VerifyFound();

    cb.EndVideoCoding(context.End());
    cb.End();
}