forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vksyncvaltests.cpp
3670 lines (3102 loc) · 186 KB
/
vksyncvaltests.cpp
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
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2015-2021 The Khronos Group Inc.
* Copyright (c) 2015-2021 Valve Corporation
* Copyright (c) 2015-2021 LunarG, Inc.
* Copyright (c) 2015-2021 Google, Inc.
*
* 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
*
* Author: Chia-I Wu <[email protected]>
* Author: Chris Forbes <[email protected]>
* Author: Courtney Goeltzenleuchter <[email protected]>
* Author: Mark Lobodzinski <[email protected]>
* Author: Mike Stroyan <[email protected]>
* Author: Tobin Ehlis <[email protected]>
* Author: Tony Barbour <[email protected]>
* Author: Cody Northrop <[email protected]>
* Author: Dave Houlton <[email protected]>
* Author: Jeremy Kniager <[email protected]>
* Author: Shannon McPherson <[email protected]>
* Author: John Zulauf <[email protected]>
*/
#include <type_traits>
#include "cast_utils.h"
#include "layer_validation_tests.h"
TEST_F(VkSyncValTest, SyncBufferCopyHazards) {
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
if (DeviceExtensionSupported(gpu(), nullptr, VK_AMD_BUFFER_MARKER_EXTENSION_NAME)) {
m_device_extension_names.push_back(VK_AMD_BUFFER_MARKER_EXTENSION_NAME);
}
ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
bool has_amd_buffer_maker = DeviceExtensionEnabled(VK_AMD_BUFFER_MARKER_EXTENSION_NAME);
VkBufferObj buffer_a;
VkBufferObj buffer_b;
VkBufferObj buffer_c;
VkMemoryPropertyFlags mem_prop = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
buffer_a.init_as_src_and_dst(*m_device, 256, mem_prop);
buffer_b.init_as_src_and_dst(*m_device, 256, mem_prop);
buffer_c.init_as_src_and_dst(*m_device, 256, mem_prop);
VkBufferCopy region = {0, 0, 256};
VkBufferCopy front2front = {0, 0, 128};
VkBufferCopy front2back = {0, 128, 128};
VkBufferCopy back2back = {128, 128, 128};
auto cb = m_commandBuffer->handle();
m_commandBuffer->begin();
vk::CmdCopyBuffer(cb, buffer_a.handle(), buffer_b.handle(), 1, ®ion);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, ®ion);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto buffer_barrier = LvlInitStruct<VkBufferMemoryBarrier>();
buffer_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
buffer_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
buffer_barrier.buffer = buffer_a.handle();
buffer_barrier.offset = 0;
buffer_barrier.size = 256;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, &buffer_barrier, 0,
nullptr);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &front2front);
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &back2back);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &front2back);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_b.handle(), 1, ®ion);
m_errorMonitor->VerifyFound();
// NOTE: Since the previous command skips in validation, the state update is never done, and the validation layer thus doesn't
// record the write operation to b. So we'll need to repeat it successfully to set up for the *next* test.
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto mem_barrier = LvlInitStruct<VkMemoryBarrier>();
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyBuffer(m_commandBuffer->handle(), buffer_c.handle(), buffer_b.handle(), 1, ®ion);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; // Protect C but not B
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
vk::CmdCopyBuffer(m_commandBuffer->handle(), buffer_b.handle(), buffer_c.handle(), 1, ®ion);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
// CmdFillBuffer
m_errorMonitor->ExpectSuccess();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdFillBuffer(m_commandBuffer->handle(), buffer_a.handle(), 0, 256, 1);
m_commandBuffer->end();
m_errorMonitor->VerifyNotFound();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdCopyBuffer(cb, buffer_b.handle(), buffer_a.handle(), 1, ®ion);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdFillBuffer(m_commandBuffer->handle(), buffer_a.handle(), 0, 256, 1);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
// CmdUpdateBuffer
int i = 10;
m_errorMonitor->ExpectSuccess();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdUpdateBuffer(m_commandBuffer->handle(), buffer_a.handle(), 0, sizeof(i), &i);
m_commandBuffer->end();
m_errorMonitor->VerifyNotFound();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdCopyBuffer(cb, buffer_b.handle(), buffer_a.handle(), 1, ®ion);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdUpdateBuffer(m_commandBuffer->handle(), buffer_a.handle(), 0, sizeof(i), &i);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
// Create secondary buffers to use
m_errorMonitor->ExpectSuccess();
VkCommandBufferObj secondary_cb1(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
VkCommandBuffer scb1 = secondary_cb1.handle();
secondary_cb1.begin();
vk::CmdCopyBuffer(scb1, buffer_c.handle(), buffer_a.handle(), 1, &front2front);
secondary_cb1.end();
m_errorMonitor->VerifyNotFound();
m_errorMonitor->ExpectSuccess();
VkCommandBufferObj secondary_cb2(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
VkCommandBuffer scb2 = secondary_cb2.handle();
secondary_cb2.begin();
vk::CmdCopyBuffer(scb2, buffer_a.handle(), buffer_c.handle(), 1, &front2front);
secondary_cb2.end();
m_errorMonitor->VerifyNotFound();
m_errorMonitor->ExpectSuccess();
VkCommandBufferObj secondary_cb3(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
VkCommandBuffer scb3 = secondary_cb3.handle();
secondary_cb3.begin();
secondary_cb3.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 0,
nullptr);
secondary_cb3.end();
m_errorMonitor->VerifyNotFound();
m_errorMonitor->ExpectSuccess();
VkCommandBufferObj secondary_cb4(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
VkCommandBuffer scb4 = secondary_cb4.handle();
secondary_cb4.begin();
vk::CmdCopyBuffer(scb4, buffer_b.handle(), buffer_c.handle(), 1, &front2front);
secondary_cb4.end();
m_errorMonitor->VerifyNotFound();
// One secondary CB hazard with active command buffer
m_errorMonitor->ExpectSuccess();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &front2front);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdExecuteCommands(cb, 1, &scb1);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
// Two secondary CB hazard with each other
m_commandBuffer->reset();
m_commandBuffer->begin();
m_errorMonitor->VerifyNotFound();
// This is also a "SYNC-HAZARD-WRITE_AFTER_WRITE" present, but only the first hazard is reported.
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
{
VkCommandBuffer two_cbs[2] = {scb1, scb2};
vk::CmdExecuteCommands(cb, 2, two_cbs);
}
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
// Two secondary CB hazard with each other
m_commandBuffer->reset();
m_commandBuffer->begin();
m_errorMonitor->VerifyNotFound();
{
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
VkCommandBuffer two_cbs[2] = {scb1, scb4};
vk::CmdExecuteCommands(cb, 2, two_cbs);
m_errorMonitor->VerifyFound();
}
m_commandBuffer->end();
// Add a secondary CB with a barrier
m_commandBuffer->reset();
m_commandBuffer->begin();
{
m_errorMonitor->ExpectSuccess();
VkCommandBuffer three_cbs[3] = {scb1, scb3, scb4};
vk::CmdExecuteCommands(cb, 3, three_cbs);
m_errorMonitor->VerifyNotFound();
}
m_commandBuffer->end();
m_commandBuffer->reset();
// CmdWriteBufferMarkerAMD
if (has_amd_buffer_maker) {
auto fpCmdWriteBufferMarkerAMD =
(PFN_vkCmdWriteBufferMarkerAMD)vk::GetDeviceProcAddr(m_device->device(), "vkCmdWriteBufferMarkerAMD");
if (!fpCmdWriteBufferMarkerAMD) {
printf("%s Test requires unsupported vkCmdWriteBufferMarkerAMD feature. Skipped.\n", kSkipPrefix);
} else {
m_errorMonitor->ExpectSuccess();
m_commandBuffer->reset();
m_commandBuffer->begin();
fpCmdWriteBufferMarkerAMD(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, buffer_a.handle(), 0, 1);
m_commandBuffer->end();
m_errorMonitor->VerifyNotFound();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdCopyBuffer(cb, buffer_b.handle(), buffer_a.handle(), 1, ®ion);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
fpCmdWriteBufferMarkerAMD(m_commandBuffer->handle(), VK_PIPELINE_STAGE_TRANSFER_BIT, buffer_a.handle(), 0, 1);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
}
} else {
printf("%s Test requires unsupported vkCmdWriteBufferMarkerAMD feature. Skipped.\n", kSkipPrefix);
}
}
TEST_F(VkSyncValTest, Sync2BufferCopyHazards) {
SetTargetApiVersion(VK_API_VERSION_1_2);
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME)) {
m_device_extension_names.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
} else {
printf("%s Synchronization2 not supported, skipping test\n", kSkipPrefix);
return;
}
if (!CheckSynchronization2SupportAndInitState(this)) {
printf("%s Synchronization2 not supported, skipping test\n", kSkipPrefix);
return;
}
auto fpCmdPipelineBarrier2KHR = (PFN_vkCmdPipelineBarrier2KHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdPipelineBarrier2KHR");
VkBufferObj buffer_a;
VkBufferObj buffer_b;
VkBufferObj buffer_c;
VkMemoryPropertyFlags mem_prop = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
buffer_a.init_as_src_and_dst(*m_device, 256, mem_prop);
buffer_b.init_as_src_and_dst(*m_device, 256, mem_prop);
buffer_c.init_as_src_and_dst(*m_device, 256, mem_prop);
VkBufferCopy region = {0, 0, 256};
VkBufferCopy front2front = {0, 0, 128};
VkBufferCopy front2back = {0, 128, 128};
VkBufferCopy back2back = {128, 128, 128};
auto cb = m_commandBuffer->handle();
m_commandBuffer->begin();
vk::CmdCopyBuffer(cb, buffer_a.handle(), buffer_b.handle(), 1, ®ion);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, ®ion);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
{
auto buffer_barrier = lvl_init_struct<VkBufferMemoryBarrier2KHR>();
buffer_barrier.srcStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
buffer_barrier.dstStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
buffer_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT_KHR;
buffer_barrier.dstAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR;
buffer_barrier.buffer = buffer_a.handle();
buffer_barrier.offset = 0;
buffer_barrier.size = 256;
auto dep_info = lvl_init_struct<VkDependencyInfoKHR>();
dep_info.bufferMemoryBarrierCount = 1;
dep_info.pBufferMemoryBarriers = &buffer_barrier;
fpCmdPipelineBarrier2KHR(cb, &dep_info);
}
m_errorMonitor->ExpectSuccess();
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &front2front);
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &back2back);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_a.handle(), 1, &front2back);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyBuffer(cb, buffer_c.handle(), buffer_b.handle(), 1, ®ion);
m_errorMonitor->VerifyFound();
// NOTE: Since the previous command skips in validation, the state update is never done, and the validation layer thus doesn't
// record the write operation to b. So we'll need to repeat it successfully to set up for the *next* test.
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
{
auto mem_barrier = lvl_init_struct<VkMemoryBarrier2KHR>();
mem_barrier.srcStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
mem_barrier.dstStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
mem_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR;
mem_barrier.dstAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR;
auto dep_info = lvl_init_struct<VkDependencyInfoKHR>();
dep_info.memoryBarrierCount = 1;
dep_info.pMemoryBarriers = &mem_barrier;
fpCmdPipelineBarrier2KHR(cb, &dep_info);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyBuffer(m_commandBuffer->handle(), buffer_c.handle(), buffer_b.handle(), 1, ®ion);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
mem_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT_KHR; // Protect C but not B
mem_barrier.dstAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR;
fpCmdPipelineBarrier2KHR(cb, &dep_info);
vk::CmdCopyBuffer(m_commandBuffer->handle(), buffer_b.handle(), buffer_c.handle(), 1, ®ion);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
}
}
TEST_F(VkSyncValTest, SyncCopyOptimalImageHazards) {
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
ASSERT_NO_FATAL_FAILURE(InitState(nullptr, nullptr, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT));
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
VkImageObj image_a(m_device);
auto image_ci = VkImageObj::ImageCreateInfo2D(128, 128, 1, 2, format, usage, VK_IMAGE_TILING_OPTIMAL);
image_a.Init(image_ci);
ASSERT_TRUE(image_a.initialized());
VkImageObj image_b(m_device);
image_b.Init(image_ci);
ASSERT_TRUE(image_b.initialized());
VkImageObj image_c(m_device);
image_c.Init(image_ci);
ASSERT_TRUE(image_c.initialized());
VkImageSubresourceLayers layers_all{VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 2};
VkImageSubresourceLayers layers_0{VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
VkImageSubresourceLayers layers_1{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 1};
VkImageSubresourceRange full_subresource_range{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2};
VkOffset3D zero_offset{0, 0, 0};
VkOffset3D half_offset{64, 64, 0};
VkExtent3D full_extent{128, 128, 1}; // <-- image type is 2D
VkExtent3D half_extent{64, 64, 1}; // <-- image type is 2D
VkImageCopy full_region = {layers_all, zero_offset, layers_all, zero_offset, full_extent};
VkImageCopy region_0_to_0 = {layers_0, zero_offset, layers_0, zero_offset, full_extent};
VkImageCopy region_0_to_1 = {layers_0, zero_offset, layers_1, zero_offset, full_extent};
VkImageCopy region_1_to_1 = {layers_1, zero_offset, layers_1, zero_offset, full_extent};
VkImageCopy region_0_front = {layers_0, zero_offset, layers_0, zero_offset, half_extent};
VkImageCopy region_0_back = {layers_0, half_offset, layers_0, half_offset, half_extent};
m_commandBuffer->begin();
image_c.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_b.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_a.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
auto cb = m_commandBuffer->handle();
vk::CmdCopyImage(cb, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto image_barrier = LvlInitStruct<VkImageMemoryBarrier>();
image_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
image_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
image_barrier.image = image_a.handle();
image_barrier.subresourceRange = full_subresource_range;
image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
image_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1,
&image_barrier);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_to_0);
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_1_to_1);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_to_1);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
// NOTE: Since the previous command skips in validation, the state update is never done, and the validation layer thus doesn't
// record the write operation to b. So we'll need to repeat it successfully to set up for the *next* test.
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto mem_barrier = LvlInitStruct<VkMemoryBarrier>();
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyNotFound();
// Use barrier to protect last reader, but not last writer...
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; // Protects C but not B
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
vk::CmdCopyImage(cb, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_front);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_front);
m_errorMonitor->VerifyFound();
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_back);
m_errorMonitor->VerifyNotFound();
m_commandBuffer->end();
// Test secondary command buffers
// Create secondary buffers to use
m_errorMonitor->ExpectSuccess();
VkCommandBufferObj secondary_cb1(m_device, m_commandPool, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
VkCommandBuffer scb1 = secondary_cb1.handle();
secondary_cb1.begin();
vk::CmdCopyImage(scb1, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
secondary_cb1.end();
m_errorMonitor->VerifyNotFound();
auto record_primary = [&]() {
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdCopyImage(cb, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
vk::CmdExecuteCommands(cb, 1, &scb1);
m_commandBuffer->end();
};
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
record_primary();
m_errorMonitor->VerifyFound();
m_errorMonitor->ExpectSuccess();
// With a barrier...
secondary_cb1.reset();
secondary_cb1.begin();
vk::CmdPipelineBarrier(scb1, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
vk::CmdCopyImage(scb1, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
secondary_cb1.end();
record_primary();
m_errorMonitor->VerifyNotFound();
auto image_transition_barrier = image_barrier;
image_transition_barrier.image = image_a.handle();
image_transition_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
image_transition_barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
m_errorMonitor->ExpectSuccess();
secondary_cb1.reset();
secondary_cb1.begin();
// Use the wrong stage, get an error
vk::CmdPipelineBarrier(scb1, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1,
&image_transition_barrier);
secondary_cb1.end();
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
record_primary();
m_errorMonitor->VerifyFound();
// CmdResolveImage hazard testing
VkImageFormatProperties formProps = {{0, 0, 0}, 0, 0, 0, 0};
vk::GetPhysicalDeviceImageFormatProperties(m_device->phy().handle(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &formProps);
if (!(formProps.sampleCounts & VK_SAMPLE_COUNT_2_BIT)) {
printf("%s CmdResolveImage Test requires unsupported VK_SAMPLE_COUNT_2_BIT feature. Skipped.\n", kSkipPrefix);
} else {
m_errorMonitor->ExpectSuccess();
VkImageObj image_s2_a(m_device), image_s2_b(m_device);
image_ci.samples = VK_SAMPLE_COUNT_2_BIT;
image_s2_a.Init(image_ci);
ASSERT_TRUE(image_s2_a.initialized());
image_s2_b.Init(image_ci);
ASSERT_TRUE(image_s2_b.initialized());
VkImageResolve r_full_region = {layers_all, zero_offset, layers_all, zero_offset, full_extent};
m_commandBuffer->reset();
m_commandBuffer->begin();
image_s2_a.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_s2_b.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
vk::CmdResolveImage(cb, image_s2_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
&r_full_region);
m_commandBuffer->end();
m_errorMonitor->VerifyNotFound();
m_commandBuffer->reset();
m_commandBuffer->begin();
vk::CmdCopyImage(cb, image_s2_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_s2_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
&full_region);
vk::CmdCopyImage(cb, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdResolveImage(cb, image_s2_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
&r_full_region);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdResolveImage(cb, image_s2_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
&r_full_region);
m_errorMonitor->VerifyFound();
m_commandBuffer->end();
}
}
TEST_F(VkSyncValTest, Sync2CopyOptimalImageHazards) {
SetTargetApiVersion(VK_API_VERSION_1_2);
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME)) {
m_device_extension_names.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
} else {
printf("%s Synchronization2 not supported, skipping test\n", kSkipPrefix);
return;
}
if (!CheckSynchronization2SupportAndInitState(this)) {
printf("%s Synchronization2 not supported, skipping test\n", kSkipPrefix);
return;
}
auto fpCmdPipelineBarrier2KHR = (PFN_vkCmdPipelineBarrier2KHR)vk::GetDeviceProcAddr(m_device->device(), "vkCmdPipelineBarrier2KHR");
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
VkImageObj image_a(m_device);
auto image_ci = VkImageObj::ImageCreateInfo2D(128, 128, 1, 2, format, usage, VK_IMAGE_TILING_OPTIMAL);
image_a.Init(image_ci);
ASSERT_TRUE(image_a.initialized());
VkImageObj image_b(m_device);
image_b.Init(image_ci);
ASSERT_TRUE(image_b.initialized());
VkImageObj image_c(m_device);
image_c.Init(image_ci);
ASSERT_TRUE(image_c.initialized());
VkImageSubresourceLayers layers_all{VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 2};
VkImageSubresourceLayers layers_0{VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
VkImageSubresourceLayers layers_1{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 1};
VkImageSubresourceRange full_subresource_range{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 2};
VkOffset3D zero_offset{0, 0, 0};
VkOffset3D half_offset{64, 64, 0};
VkExtent3D full_extent{128, 128, 1}; // <-- image type is 2D
VkExtent3D half_extent{64, 64, 1}; // <-- image type is 2D
VkImageCopy full_region = {layers_all, zero_offset, layers_all, zero_offset, full_extent};
VkImageCopy region_0_to_0 = {layers_0, zero_offset, layers_0, zero_offset, full_extent};
VkImageCopy region_0_to_1 = {layers_0, zero_offset, layers_1, zero_offset, full_extent};
VkImageCopy region_1_to_1 = {layers_1, zero_offset, layers_1, zero_offset, full_extent};
VkImageCopy region_0_front = {layers_0, zero_offset, layers_0, zero_offset, half_extent};
VkImageCopy region_0_back = {layers_0, half_offset, layers_0, half_offset, half_extent};
m_commandBuffer->begin();
image_c.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_b.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_a.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
auto cb = m_commandBuffer->handle();
vk::CmdCopyImage(cb, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
{
auto image_barrier = lvl_init_struct<VkImageMemoryBarrier2KHR>();
image_barrier.srcStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
image_barrier.dstStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
image_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT_KHR;
image_barrier.dstAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR;
image_barrier.image = image_a.handle();
image_barrier.subresourceRange = full_subresource_range;
image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
image_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
auto dep_info = lvl_init_struct<VkDependencyInfoKHR>();
dep_info.imageMemoryBarrierCount = 1;
dep_info.pImageMemoryBarriers = &image_barrier;
fpCmdPipelineBarrier2KHR(cb, &dep_info);
}
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_to_0);
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_1_to_1);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_to_1);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
// NOTE: Since the previous command skips in validation, the state update is never done, and the validation layer thus doesn't
// record the write operation to b. So we'll need to repeat it successfully to set up for the *next* test.
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
{
auto mem_barrier = lvl_init_struct<VkMemoryBarrier2KHR>();
mem_barrier.srcStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
mem_barrier.dstStageMask = VK_PIPELINE_STAGE_2_COPY_BIT_KHR;
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
auto dep_info = lvl_init_struct<VkDependencyInfoKHR>();
dep_info.memoryBarrierCount = 1;
dep_info.pMemoryBarriers = &mem_barrier;
fpCmdPipelineBarrier2KHR(cb, &dep_info);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyNotFound();
// Use barrier to protect last reader, but not last writer...
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
mem_barrier.srcAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT_KHR; // Protects C but not B
mem_barrier.dstAccessMask = VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR;
fpCmdPipelineBarrier2KHR(cb, &dep_info);
vk::CmdCopyImage(cb, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
}
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_front);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_front);
m_errorMonitor->VerifyFound();
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_0_back);
m_errorMonitor->VerifyNotFound();
m_commandBuffer->end();
}
TEST_F(VkSyncValTest, SyncCopyOptimalMultiPlanarHazards) {
// TODO: Add code to enable sync validation
// Enable KHR multiplane req'd extensions
bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION);
if (mp_extensions) {
m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
}
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME);
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
if (mp_extensions) {
m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME);
m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
} else {
printf("%s test requires KHR multiplane extensions, not available. Skipping.\n", kSkipPrefix);
return;
}
ASSERT_NO_FATAL_FAILURE(InitState());
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VkFormat format = VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM;
VkImageObj image_a(m_device);
const auto image_ci = VkImageObj::ImageCreateInfo2D(128, 128, 1, 2, format, usage, VK_IMAGE_TILING_OPTIMAL);
// Verify format
bool supported = ImageFormatAndFeaturesSupported(instance(), gpu(), image_ci,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT);
if (!supported) {
printf("%s Multiplane image format not supported. Skipping test.\n", kSkipPrefix);
return; // Assume there's low ROI on searching for different mp formats
}
image_a.Init(image_ci);
VkImageObj image_b(m_device);
image_b.Init(image_ci);
VkImageObj image_c(m_device);
image_c.Init(image_ci);
VkImageSubresourceLayers layer_all_plane0{VK_IMAGE_ASPECT_PLANE_0_BIT_KHR, 0, 0, 2};
VkImageSubresourceLayers layer0_plane0{VK_IMAGE_ASPECT_PLANE_0_BIT_KHR, 0, 0, 1};
VkImageSubresourceLayers layer0_plane1{VK_IMAGE_ASPECT_PLANE_1_BIT_KHR, 0, 0, 1};
VkImageSubresourceLayers layer1_plane1{VK_IMAGE_ASPECT_PLANE_1_BIT_KHR, 0, 1, 1};
VkImageSubresourceRange full_subresource_range{
VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR, 0, 1, 0, 2};
VkOffset3D zero_offset{0, 0, 0};
VkOffset3D one_four_offset{32, 32, 0};
VkExtent3D full_extent{128, 128, 1}; // <-- image type is 2D
VkExtent3D half_extent{64, 64, 1}; // <-- image type is 2D
VkExtent3D one_four_extent{32, 32, 1}; // <-- image type is 2D
VkImageCopy region_all_plane0_to_all_plane0 = {layer_all_plane0, zero_offset, layer_all_plane0, zero_offset, full_extent};
VkImageCopy region_layer0_plane0_to_layer0_plane0 = {layer0_plane0, zero_offset, layer0_plane0, zero_offset, full_extent};
VkImageCopy region_layer0_plane0_to_layer0_plane1 = {layer0_plane0, zero_offset, layer0_plane1, zero_offset, half_extent};
VkImageCopy region_layer1_plane1_to_layer1_plane1_front = {layer1_plane1, zero_offset, layer1_plane1, zero_offset,
one_four_extent};
VkImageCopy region_layer1_plane1_to_layer1_plane1_back = {layer1_plane1, one_four_offset, layer1_plane1, one_four_offset,
one_four_extent};
m_commandBuffer->begin();
image_c.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_b.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_a.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
auto cb = m_commandBuffer->handle();
vk::CmdCopyImage(cb, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_all_plane0_to_all_plane0);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_all_plane0_to_all_plane0);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto image_barrier = LvlInitStruct<VkImageMemoryBarrier>();
image_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
image_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
image_barrier.image = image_a.handle();
image_barrier.subresourceRange = full_subresource_range;
image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
image_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1,
&image_barrier);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_layer0_plane0_to_layer0_plane0);
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_layer0_plane0_to_layer0_plane1);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_layer0_plane0_to_layer0_plane1);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_all_plane0_to_all_plane0);
m_errorMonitor->VerifyFound();
// NOTE: Since the previous command skips in validation, the state update is never done, and the validation layer thus doesn't
// record the write operation to b. So we'll need to repeat it successfully to set up for the *next* test.
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto mem_barrier = LvlInitStruct<VkMemoryBarrier>();
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_all_plane0_to_all_plane0);
m_errorMonitor->VerifyNotFound();
// Use barrier to protect last reader, but not last writer...
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
mem_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; // Protects C but not B
mem_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &mem_barrier, 0, nullptr, 0,
nullptr);
vk::CmdCopyImage(cb, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_all_plane0_to_all_plane0);
m_errorMonitor->VerifyFound();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_layer1_plane1_to_layer1_plane1_front);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_layer1_plane1_to_layer1_plane1_front);
m_errorMonitor->VerifyFound();
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_layer1_plane1_to_layer1_plane1_back);
m_errorMonitor->VerifyNotFound();
m_commandBuffer->end();
}
TEST_F(VkSyncValTest, SyncCopyLinearImageHazards) {
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
ASSERT_NO_FATAL_FAILURE(InitState());
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
VkImageObj image_a(m_device);
const auto image_ci = VkImageObj::ImageCreateInfo2D(128, 128, 1, 1, format, usage, VK_IMAGE_TILING_LINEAR);
image_a.Init(image_ci);
VkImageObj image_b(m_device);
image_b.Init(image_ci);
VkImageObj image_c(m_device);
image_c.Init(image_ci);
VkImageSubresourceLayers layers_all{VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
VkImageSubresourceRange full_subresource_range{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
VkOffset3D zero_offset{0, 0, 0};
VkOffset3D half_offset{64, 64, 0};
VkExtent3D full_extent{128, 128, 1}; // <-- image type is 2D
VkExtent3D half_extent{64, 64, 1}; // <-- image type is 2D
VkImageCopy full_region = {layers_all, zero_offset, layers_all, zero_offset, full_extent};
VkImageCopy region_front = {layers_all, zero_offset, layers_all, zero_offset, half_extent};
VkImageCopy region_back = {layers_all, half_offset, layers_all, half_offset, half_extent};
m_commandBuffer->begin();
image_c.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_b.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_a.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
auto cb = m_commandBuffer->handle();
vk::CmdCopyImage(cb, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto image_barrier = LvlInitStruct<VkImageMemoryBarrier>();
image_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
image_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
image_barrier.image = image_b.handle();
image_barrier.subresourceRange = full_subresource_range;
image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
image_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1,
&image_barrier);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyNotFound();
// Use barrier to protect last reader, but not last writer...
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-READ_AFTER_WRITE");
image_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; // Protects C but not B
image_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1,
&image_barrier);
vk::CmdCopyImage(cb, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &full_region);
m_errorMonitor->VerifyFound();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_front);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_front);
m_errorMonitor->VerifyFound();
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, ®ion_back);
m_errorMonitor->VerifyNotFound();
}
TEST_F(VkSyncValTest, SyncCopyLinearMultiPlanarHazards) {
// TODO: Add code to enable sync validation
// Enable KHR multiplane req'd extensions
bool mp_extensions = InstanceExtensionSupported(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION);
if (mp_extensions) {
m_instance_extension_names.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
}
ASSERT_NO_FATAL_FAILURE(InitSyncValFramework());
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_MAINTENANCE_1_EXTENSION_NAME);
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
mp_extensions = mp_extensions && DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
if (mp_extensions) {
m_device_extension_names.push_back(VK_KHR_MAINTENANCE_1_EXTENSION_NAME);
m_device_extension_names.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
m_device_extension_names.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
m_device_extension_names.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
} else {
printf("%s test requires KHR multiplane extensions, not available. Skipping.\n", kSkipPrefix);
return;
}
ASSERT_NO_FATAL_FAILURE(InitState());
VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VkFormat format = VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM;
VkImageObj image_a(m_device);
const auto image_ci = VkImageObj::ImageCreateInfo2D(128, 128, 1, 1, format, usage, VK_IMAGE_TILING_LINEAR);
// Verify format
bool supported = ImageFormatAndFeaturesSupported(instance(), gpu(), image_ci,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT);
if (!supported) {
printf("%s Multiplane image format not supported. Skipping test.\n", kSkipPrefix);
return; // Assume there's low ROI on searching for different mp formats
}
image_a.Init(image_ci);
VkImageObj image_b(m_device);
image_b.Init(image_ci);
VkImageObj image_c(m_device);
image_c.Init(image_ci);
VkImageSubresourceLayers layer_all_plane0{VK_IMAGE_ASPECT_PLANE_0_BIT_KHR, 0, 0, 1};
VkImageSubresourceLayers layer_all_plane1{VK_IMAGE_ASPECT_PLANE_1_BIT_KHR, 0, 0, 1};
VkImageSubresourceRange full_subresource_range{
VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR, 0, 1, 0, 1};
VkOffset3D zero_offset{0, 0, 0};
VkOffset3D one_four_offset{32, 32, 0};
VkExtent3D full_extent{128, 128, 1}; // <-- image type is 2D
VkExtent3D half_extent{64, 64, 1}; // <-- image type is 2D
VkExtent3D one_four_extent{32, 32, 1}; // <-- image type is 2D
VkImageCopy region_plane0_to_plane0 = {layer_all_plane0, zero_offset, layer_all_plane0, zero_offset, full_extent};
VkImageCopy region_plane0_to_plane1 = {layer_all_plane0, zero_offset, layer_all_plane1, zero_offset, half_extent};
VkImageCopy region_plane1_to_plane1_front = {layer_all_plane1, zero_offset, layer_all_plane1, zero_offset, one_four_extent};
VkImageCopy region_plane1_to_plane1_back = {layer_all_plane1, one_four_offset, layer_all_plane1, one_four_offset,
one_four_extent};
m_commandBuffer->begin();
image_c.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_b.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
image_a.SetLayout(m_commandBuffer, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL);
auto cb = m_commandBuffer->handle();
vk::CmdCopyImage(cb, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_plane0_to_plane0);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_READ");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_plane0_to_plane0);
m_errorMonitor->VerifyFound();
// Use the barrier to clean up the WAW, and try again. (and show that validation is accounting for the barrier effect too.)
auto image_barrier = LvlInitStruct<VkImageMemoryBarrier>();
image_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
image_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
image_barrier.image = image_a.handle();
image_barrier.subresourceRange = full_subresource_range;
image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
image_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
vk::CmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1,
&image_barrier);
m_errorMonitor->ExpectSuccess();
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_plane0_to_plane0);
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_plane0_to_plane1);
m_errorMonitor->VerifyNotFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_a.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,
®ion_plane0_to_plane1);
m_errorMonitor->VerifyFound();
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SYNC-HAZARD-WRITE_AFTER_WRITE");
vk::CmdCopyImage(cb, image_c.handle(), VK_IMAGE_LAYOUT_GENERAL, image_b.handle(), VK_IMAGE_LAYOUT_GENERAL, 1,