-
Notifications
You must be signed in to change notification settings - Fork 878
Expand file tree
/
Copy pathValidationTest.cpp
More file actions
6819 lines (6302 loc) · 273 KB
/
Copy pathValidationTest.cpp
File metadata and controls
6819 lines (6302 loc) · 273 KB
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
///////////////////////////////////////////////////////////////////////////////
// //
// ValidationTest.cpp //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// //
///////////////////////////////////////////////////////////////////////////////
#define NOMINMAX
#include "dxc/Support/WinIncludes.h"
#include <algorithm>
#include <filesystem>
#include <memory>
#include <string>
#include <vector>
#include "dxc/DxilContainer/DxilContainer.h"
#include "dxc/DxilContainer/DxilContainerAssembler.h"
#include "dxc/DxilContainer/DxilPipelineStateValidation.h"
#include "dxc/DxilHash/DxilHash.h"
#include "dxc/Support/Unicode.h" // for wstring conversions like WideToUtf8String
#include "dxc/Support/WinIncludes.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Regex.h"
#include <wchar.h>
#ifdef _WIN32
#include <atlbase.h>
#endif
#include "dxc/Support/FileIOHelper.h"
#include "dxc/Support/Global.h"
#include "dxc/DXIL/DxilShaderModel.h"
#include "dxc/Test/DxcTestUtils.h"
#include "dxc/Test/HlslTestUtils.h"
using namespace std;
using namespace hlsl;
#ifdef _WIN32
class ValidationTest {
#else
class ValidationTest : public ::testing::Test {
#endif
public:
BEGIN_TEST_CLASS(ValidationTest)
TEST_CLASS_PROPERTY(L"Parallel", L"true")
TEST_METHOD_PROPERTY(L"Priority", L"0")
END_TEST_CLASS()
TEST_CLASS_SETUP(InitSupport);
TEST_METHOD(WhenCorrectThenOK)
TEST_METHOD(WhenMisalignedThenFail)
TEST_METHOD(WhenEmptyFileThenFail)
TEST_METHOD(WhenIncorrectMagicThenFail)
TEST_METHOD(WhenIncorrectTargetTripleThenFail)
TEST_METHOD(WhenIncorrectModelThenFail)
TEST_METHOD(WhenIncorrectPSThenFail)
TEST_METHOD(WhenWaveAffectsGradientThenFail)
TEST_METHOD(WhenMultipleModulesThenFail)
TEST_METHOD(WhenUnexpectedEOFThenFail)
TEST_METHOD(WhenUnknownBlocksThenFail)
TEST_METHOD(WhenZeroInputPatchCountWithInputThenFail)
TEST_METHOD(Float32DenormModeAttribute)
TEST_METHOD(LoadOutputControlPointNotInPatchConstantFunction)
TEST_METHOD(StorePatchControlNotInPatchConstantFunction)
TEST_METHOD(OutputControlPointIDInPatchConstantFunction)
TEST_METHOD(GsVertexIDOutOfBound)
TEST_METHOD(StreamIDOutOfBound)
TEST_METHOD(SignatureDataWidth)
TEST_METHOD(SignatureStreamIDForNonGS)
TEST_METHOD(TypedUAVStoreFullMask0)
TEST_METHOD(TypedUAVStoreFullMask1)
TEST_METHOD(UAVStoreMaskMatch)
TEST_METHOD(UAVStoreMaskGap)
TEST_METHOD(UAVStoreMaskGap2)
TEST_METHOD(UAVStoreMaskGap3)
TEST_METHOD(Recursive)
TEST_METHOD(ResourceRangeOverlap0)
TEST_METHOD(ResourceRangeOverlap1)
TEST_METHOD(ResourceRangeOverlap2)
TEST_METHOD(ResourceRangeOverlap3)
TEST_METHOD(CBufferOverlap0)
TEST_METHOD(CBufferOverlap1)
TEST_METHOD(ControlFlowHint)
TEST_METHOD(ControlFlowHint1)
TEST_METHOD(ControlFlowHint2)
TEST_METHOD(SemanticLength1)
TEST_METHOD(SemanticLength64)
TEST_METHOD(PullModelPosition)
TEST_METHOD(StructBufStrideAlign)
TEST_METHOD(StructBufStrideOutOfBound)
TEST_METHOD(StructBufGlobalCoherentAndCounter)
TEST_METHOD(StructBufLoadCoordinates)
TEST_METHOD(StructBufStoreCoordinates)
TEST_METHOD(TypedBufRetType)
TEST_METHOD(VsInputSemantic)
TEST_METHOD(VsOutputSemantic)
TEST_METHOD(HsInputSemantic)
TEST_METHOD(HsOutputSemantic)
TEST_METHOD(PatchConstSemantic)
TEST_METHOD(DsInputSemantic)
TEST_METHOD(DsOutputSemantic)
TEST_METHOD(GsInputSemantic)
TEST_METHOD(GsOutputSemantic)
TEST_METHOD(PsInputSemantic)
TEST_METHOD(PsOutputSemantic)
TEST_METHOD(ArrayOfSVTarget)
TEST_METHOD(InfiniteLog)
TEST_METHOD(InfiniteAsin)
TEST_METHOD(InfiniteAcos)
TEST_METHOD(InfiniteDdxDdy)
TEST_METHOD(IDivByZero)
TEST_METHOD(UDivByZero)
TEST_METHOD(UnusedMetadata)
TEST_METHOD(MemoryOutOfBound)
TEST_METHOD(LocalRes2)
TEST_METHOD(LocalRes3)
TEST_METHOD(LocalRes5)
TEST_METHOD(LocalRes5Dbg)
TEST_METHOD(LocalRes6)
TEST_METHOD(LocalRes6Dbg)
TEST_METHOD(AddrSpaceCast)
TEST_METHOD(PtrBitCast)
TEST_METHOD(MinPrecisionBitCast)
TEST_METHOD(StructBitCast)
TEST_METHOD(MultiDimArray)
TEST_METHOD(SimpleGs8)
TEST_METHOD(SimpleGs9)
TEST_METHOD(SimpleGs10)
TEST_METHOD(IllegalSampleOffset3)
TEST_METHOD(IllegalSampleOffset4)
TEST_METHOD(NoFunctionParam)
TEST_METHOD(I8Type)
// TODO: enable this.
// TEST_METHOD(TGSMRaceCond)
// TEST_METHOD(TGSMRaceCond2)
TEST_METHOD(AddUint64Odd)
TEST_METHOD(BarycentricFloat4Fail)
TEST_METHOD(BarycentricMaxIndexFail)
TEST_METHOD(BarycentricNoInterpolationFail)
TEST_METHOD(BarycentricSamePerspectiveFail)
TEST_METHOD(ClipCullMaxComponents)
TEST_METHOD(ClipCullMaxRows)
TEST_METHOD(DuplicateSysValue)
TEST_METHOD(FunctionAttributes)
TEST_METHOD(GSMainMissingAttributeFail)
TEST_METHOD(GSOtherMissingAttributeFail)
TEST_METHOD(GetAttributeAtVertexInVSFail)
TEST_METHOD(GetAttributeAtVertexIn60Fail)
TEST_METHOD(GetAttributeAtVertexInterpFail)
TEST_METHOD(SemTargetMax)
TEST_METHOD(SemTargetIndexMatchesRow)
TEST_METHOD(SemTargetCol0)
TEST_METHOD(SemIndexMax)
TEST_METHOD(SemTessFactorIndexMax)
TEST_METHOD(SemInsideTessFactorIndexMax)
TEST_METHOD(SemShouldBeAllocated)
TEST_METHOD(SemShouldNotBeAllocated)
TEST_METHOD(SemComponentOrder)
TEST_METHOD(SemComponentOrder2)
TEST_METHOD(SemComponentOrder3)
TEST_METHOD(SemIndexConflictArbSV)
TEST_METHOD(SemIndexConflictTessfactors)
TEST_METHOD(SemIndexConflictTessfactors2)
TEST_METHOD(SemRowOutOfRange)
TEST_METHOD(SemPackOverlap)
TEST_METHOD(SemPackOverlap2)
TEST_METHOD(SemMultiDepth)
TEST_METHOD(WhenInstrDisallowedThenFail)
TEST_METHOD(WhenDepthNotFloatThenFail)
TEST_METHOD(BarrierFail)
TEST_METHOD(CBufferLegacyOutOfBoundFail)
TEST_METHOD(CsThreadSizeFail)
TEST_METHOD(DeadLoopFail)
TEST_METHOD(EvalFail)
TEST_METHOD(GetDimCalcLODFail)
TEST_METHOD(HsAttributeFail)
TEST_METHOD(InnerCoverageFail)
TEST_METHOD(InterpChangeFail)
TEST_METHOD(InterpOnIntFail)
TEST_METHOD(InvalidSigCompTyFail)
TEST_METHOD(MultiStream2Fail)
TEST_METHOD(PhiTGSMFail)
TEST_METHOD(QuadOpInVS)
TEST_METHOD(ReducibleFail)
TEST_METHOD(SampleBiasFail)
TEST_METHOD(SamplerKindFail)
TEST_METHOD(SemaOverlapFail)
TEST_METHOD(SigOutOfRangeFail)
TEST_METHOD(SigOverlapFail)
TEST_METHOD(SimpleHs1Fail)
TEST_METHOD(SimpleHs3Fail)
TEST_METHOD(SimpleHs4Fail)
TEST_METHOD(SimpleDs1Fail)
TEST_METHOD(SimpleGs1Fail)
TEST_METHOD(UavBarrierFail)
TEST_METHOD(UndefValueFail)
TEST_METHOD(ValidationFailNoHash)
TEST_METHOD(UpdateCounterFail)
TEST_METHOD(LocalResCopy)
TEST_METHOD(ResCounter)
TEST_METHOD(WhenSmUnknownThenFail)
TEST_METHOD(WhenSmLegacyThenFail)
TEST_METHOD(WhenMetaFlagsUsageDeclThenOK)
TEST_METHOD(WhenMetaFlagsUsageThenFail)
TEST_METHOD(WhenRootSigMismatchThenFail)
TEST_METHOD(WhenRootSigCompatThenSucceed)
TEST_METHOD(WhenRootSigMatchShaderSucceed_RootConstVis)
TEST_METHOD(WhenRootSigMatchShaderFail_RootConstVis)
TEST_METHOD(WhenRootSigMatchShaderSucceed_RootCBV)
TEST_METHOD(WhenRootSigMatchShaderFail_RootCBV_Range)
TEST_METHOD(WhenRootSigMatchShaderFail_RootCBV_Space)
TEST_METHOD(WhenRootSigMatchShaderSucceed_RootSRV)
TEST_METHOD(WhenRootSigMatchShaderFail_RootSRV_ResType)
TEST_METHOD(WhenRootSigMatchShaderSucceed_RootUAV)
TEST_METHOD(WhenRootSigMatchShaderSucceed_DescTable)
TEST_METHOD(WhenRootSigMatchShaderSucceed_DescTable_GoodRange)
TEST_METHOD(WhenRootSigMatchShaderSucceed_DescTable_Unbounded)
TEST_METHOD(WhenRootSigMatchShaderFail_DescTable_Range1)
TEST_METHOD(WhenRootSigMatchShaderFail_DescTable_Range2)
TEST_METHOD(WhenRootSigMatchShaderFail_DescTable_Range3)
TEST_METHOD(WhenRootSigMatchShaderFail_DescTable_Space)
TEST_METHOD(WhenRootSigMatchShaderSucceed_Unbounded)
TEST_METHOD(WhenRootSigMatchShaderFail_Unbounded1)
TEST_METHOD(WhenRootSigMatchShaderFail_Unbounded2)
TEST_METHOD(WhenRootSigMatchShaderFail_Unbounded3)
TEST_METHOD(WhenProgramOutSigMissingThenFail)
TEST_METHOD(WhenProgramOutSigUnexpectedThenFail)
TEST_METHOD(WhenProgramSigMismatchThenFail)
TEST_METHOD(WhenProgramInSigMissingThenFail)
TEST_METHOD(WhenProgramSigMismatchThenFail2)
TEST_METHOD(WhenProgramPCSigMissingThenFail)
TEST_METHOD(WhenPSVMismatchThenFail)
TEST_METHOD(WhenRDATMismatchThenFail)
TEST_METHOD(WhenFeatureInfoMismatchThenFail)
TEST_METHOD(RayShaderWithSignaturesFail)
TEST_METHOD(ViewIDInCSFail)
TEST_METHOD(ViewIDIn60Fail)
TEST_METHOD(ViewIDNoSpaceFail)
TEST_METHOD(LibFunctionResInSig)
TEST_METHOD(RayPayloadIsStruct)
TEST_METHOD(RayAttrIsStruct)
TEST_METHOD(CallableParamIsStruct)
TEST_METHOD(RayShaderExtraArg)
TEST_METHOD(ResInShaderStruct)
TEST_METHOD(WhenPayloadSizeTooSmallThenFail)
TEST_METHOD(WhenMissingPayloadThenFail)
TEST_METHOD(ShaderFunctionReturnTypeVoid)
TEST_METHOD(WhenDisassembleInvalidBlobThenFail)
TEST_METHOD(MeshMultipleSetMeshOutputCounts)
TEST_METHOD(MeshMissingSetMeshOutputCounts)
TEST_METHOD(MeshNonDominatingSetMeshOutputCounts)
TEST_METHOD(MeshOversizePayload)
TEST_METHOD(MeshOversizeOutput)
TEST_METHOD(MeshOversizePayloadOutput)
TEST_METHOD(MeshMultipleGetMeshPayload)
TEST_METHOD(MeshOutofRangeMaxVertexCount)
TEST_METHOD(MeshOutofRangeMaxPrimitiveCount)
TEST_METHOD(MeshLessThanMinX)
TEST_METHOD(MeshGreaterThanMaxX)
TEST_METHOD(MeshLessThanMinY)
TEST_METHOD(MeshGreaterThanMaxY)
TEST_METHOD(MeshLessThanMinZ)
TEST_METHOD(MeshGreaterThanMaxZ)
TEST_METHOD(MeshGreaterThanMaxXYZ)
TEST_METHOD(MeshGreaterThanMaxVSigRowCount)
TEST_METHOD(MeshGreaterThanMaxPSigRowCount)
TEST_METHOD(MeshGreaterThanMaxTotalSigRowCount)
TEST_METHOD(MeshOversizeSM)
TEST_METHOD(AmplificationMultipleDispatchMesh)
TEST_METHOD(AmplificationMissingDispatchMesh)
TEST_METHOD(AmplificationNonDominatingDispatchMesh)
TEST_METHOD(AmplificationOversizePayload)
TEST_METHOD(AmplificationLessThanMinX)
TEST_METHOD(AmplificationGreaterThanMaxX)
TEST_METHOD(AmplificationLessThanMinY)
TEST_METHOD(AmplificationGreaterThanMaxY)
TEST_METHOD(AmplificationLessThanMinZ)
TEST_METHOD(AmplificationGreaterThanMaxZ)
TEST_METHOD(AmplificationGreaterThanMaxXYZ)
TEST_METHOD(ValidateRootSigContainer)
TEST_METHOD(ValidatePrintfNotAllowed)
TEST_METHOD(ValidateWithHash)
TEST_METHOD(ValidateVersionNotAllowed)
TEST_METHOD(ValidatePreviewBypassHash)
TEST_METHOD(ValidateProgramVersionAgainstDxilModule)
TEST_METHOD(CreateHandleNotAllowedSM66)
TEST_METHOD(AtomicsConsts)
TEST_METHOD(AtomicsInvalidDests)
TEST_METHOD(ComputeNodeCompatibility)
TEST_METHOD(NodeInputCompatibility)
TEST_METHOD(NodeInputMultiplicity)
TEST_METHOD(CacheInitWithMinPrec)
TEST_METHOD(CacheInitWithLowPrec)
TEST_METHOD(PSVStringTableReorder)
TEST_METHOD(PSVSemanticIndexTableReorder)
TEST_METHOD(PSVContentValidationVS)
TEST_METHOD(PSVContentValidationHS)
TEST_METHOD(PSVContentValidationDS)
TEST_METHOD(PSVContentValidationGS)
TEST_METHOD(PSVContentValidationPS)
TEST_METHOD(PSVContentValidationCS)
TEST_METHOD(PSVContentValidationMS)
TEST_METHOD(PSVContentValidationAS)
TEST_METHOD(UnitTestExtValidationSupport)
TEST_METHOD(WrongPSVSize)
TEST_METHOD(WrongPSVSizeOnZeros)
TEST_METHOD(WrongPSVVersion)
dxc::DxCompilerDllLoader m_dllSupport;
VersionSupportInfo m_ver;
void TestCheck(LPCWSTR name) {
std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
FileRunTestResult t =
FileRunTestResult::RunFromFileCommands(fullPath.c_str());
if (t.RunResult != 0) {
CA2W commentWide(t.ErrorMessage.c_str());
WEX::Logging::Log::Comment(commentWide);
WEX::Logging::Log::Error(L"Run result is not zero");
}
}
void CheckValidationMsgs(IDxcBlob *pBlob, llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false,
UINT32 Flags = DxcValidatorFlags_Default) {
CComPtr<IDxcValidator> pValidator;
CComPtr<IDxcOperationResult> pResult;
if (!IsDxilContainerLike(pBlob->GetBufferPointer(),
pBlob->GetBufferSize())) {
// Validation of raw bitcode as opposed to DxilContainer is not supported
// through DXIL.dll
if (!m_ver.m_InternalValidator) {
WEX::Logging::Log::Comment(
L"Test skipped due to validation of raw bitcode without container "
L"and use of external DXIL.dll validator.");
return;
}
Flags |= DxcValidatorFlags_ModuleOnly;
}
VERIFY_SUCCEEDED(
m_dllSupport.CreateInstance(CLSID_DxcValidator, &pValidator));
VERIFY_SUCCEEDED(pValidator->Validate(pBlob, Flags, &pResult));
CheckOperationResultMsgs(pResult, pErrorMsgs, false, bRegex);
}
void CheckValidationMsgs(const char *pBlob, size_t blobSize,
llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false,
UINT32 Flags = DxcValidatorFlags_Default) {
CComPtr<IDxcLibrary> pLibrary;
CComPtr<IDxcBlobEncoding>
pBlobEncoding; // Encoding doesn't actually matter, it's binary.
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
VERIFY_SUCCEEDED(pLibrary->CreateBlobWithEncodingFromPinned(
pBlob, blobSize, DXC_CP_ACP, &pBlobEncoding));
CheckValidationMsgs(pBlobEncoding, pErrorMsgs, bRegex, Flags);
}
bool CompileSource(IDxcBlobEncoding *pSource, LPCSTR pShaderModel,
LPCWSTR *pArguments, UINT32 argCount,
const DxcDefine *pDefines, UINT32 defineCount,
IDxcBlob **pResultBlob) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlob> pProgram;
CA2W shWide(pShaderModel);
const wchar_t *pEntryName = L"main";
llvm::StringRef stage;
unsigned RequiredDxilMajor = 1, RequiredDxilMinor = 0;
if (hlsl::ShaderModel::ParseTargetProfile(
pShaderModel, stage, RequiredDxilMajor, RequiredDxilMinor)) {
if (stage.compare("lib") == 0)
pEntryName = L"";
if (stage.compare("rootsig") != 0) {
RequiredDxilMajor = std::max(RequiredDxilMajor, (unsigned)6) - 5;
if (m_ver.SkipDxilVersion(RequiredDxilMajor, RequiredDxilMinor))
return false;
}
}
std::vector<LPCWSTR> args;
args.reserve(argCount + 1);
args.insert(args.begin(), pArguments, pArguments + argCount);
args.emplace_back(L"-Qkeep_reflect_in_dxil");
VERIFY_SUCCEEDED(
m_dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
VERIFY_SUCCEEDED(pCompiler->Compile(
pSource, L"hlsl.hlsl", pEntryName, shWide, args.data(),
(UINT32)args.size(), pDefines, defineCount, nullptr, &pResult));
CheckOperationResultMsgs(pResult, nullptr, false, false);
VERIFY_SUCCEEDED(pResult->GetResult(pResultBlob));
return true;
}
bool CompileFile(LPCWSTR fileName, LPCSTR pShaderModel,
IDxcBlob **pResultBlob) {
std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(fileName);
CComPtr<IDxcLibrary> pLibrary;
CComPtr<IDxcBlobEncoding> pSource;
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
VERIFY_SUCCEEDED(
pLibrary->CreateBlobFromFile(fullPath.c_str(), nullptr, &pSource));
return CompileSource(pSource, pShaderModel, nullptr, 0, nullptr, 0,
pResultBlob);
}
bool CompileFile(LPCWSTR fileName, LPCSTR pShaderModel, LPCWSTR *pArguments,
UINT32 argCount, IDxcBlob **pResultBlob) {
std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(fileName);
CComPtr<IDxcLibrary> pLibrary;
CComPtr<IDxcBlobEncoding> pSource;
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
VERIFY_SUCCEEDED(
pLibrary->CreateBlobFromFile(fullPath.c_str(), nullptr, &pSource));
return CompileSource(pSource, pShaderModel, pArguments, argCount, nullptr,
0, pResultBlob);
}
bool CompileSource(IDxcBlobEncoding *pSource, LPCSTR pShaderModel,
IDxcBlob **pResultBlob) {
return CompileSource(pSource, pShaderModel, nullptr, 0, nullptr, 0,
pResultBlob);
}
bool CompileSource(LPCSTR pSource, LPCSTR pShaderModel,
IDxcBlob **pResultBlob) {
CComPtr<IDxcBlobEncoding> pSourceBlob;
Utf8ToBlob(m_dllSupport, pSource, &pSourceBlob);
return CompileSource(pSourceBlob, pShaderModel, nullptr, 0, nullptr, 0,
pResultBlob);
}
void DisassembleProgram(IDxcBlob *pProgram, std::string *text) {
*text = ::DisassembleProgram(m_dllSupport, pProgram);
}
bool RewriteAssemblyCheckMsg(IDxcBlobEncoding *pSource, LPCSTR pShaderModel,
LPCWSTR *pArguments, UINT32 argCount,
const DxcDefine *pDefines, UINT32 defineCount,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false) {
CComPtr<IDxcBlob> pText;
if (!RewriteAssemblyToText(pSource, pShaderModel, pArguments, argCount,
pDefines, defineCount, pLookFors, pReplacements,
&pText, bRegex))
return false;
CComPtr<IDxcAssembler> pAssembler;
CComPtr<IDxcOperationResult> pAssembleResult;
VERIFY_SUCCEEDED(
m_dllSupport.CreateInstance(CLSID_DxcAssembler, &pAssembler));
VERIFY_SUCCEEDED(pAssembler->AssembleToContainer(pText, &pAssembleResult));
if (!CheckOperationResultMsgs(pAssembleResult, pErrorMsgs, true, bRegex)) {
// Assembly succeeded, try validation.
CComPtr<IDxcBlob> pBlob;
VERIFY_SUCCEEDED(pAssembleResult->GetResult(&pBlob));
CheckValidationMsgs(pBlob, pErrorMsgs, bRegex);
}
return true;
}
void RewriteAssemblyCheckMsg(LPCSTR pSource, LPCSTR pShaderModel,
LPCWSTR *pArguments, UINT32 argCount,
const DxcDefine *pDefines, UINT32 defineCount,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false) {
CComPtr<IDxcBlobEncoding> pSourceBlob;
Utf8ToBlob(m_dllSupport, pSource, &pSourceBlob);
RewriteAssemblyCheckMsg(pSourceBlob, pShaderModel, pArguments, argCount,
pDefines, defineCount, pLookFors, pReplacements,
pErrorMsgs, bRegex);
}
void RewriteAssemblyCheckMsg(LPCSTR pSource, LPCSTR pShaderModel,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false) {
RewriteAssemblyCheckMsg(pSource, pShaderModel, nullptr, 0, nullptr, 0,
pLookFors, pReplacements, pErrorMsgs, bRegex);
}
void RewriteAssemblyCheckMsg(LPCWSTR name, LPCSTR pShaderModel,
LPCWSTR *pArguments, UINT32 argCount,
const DxcDefine *pDefines, UINT32 defCount,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false) {
std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
CComPtr<IDxcLibrary> pLibrary;
CComPtr<IDxcBlobEncoding> pSource;
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
VERIFY_SUCCEEDED(
pLibrary->CreateBlobFromFile(fullPath.c_str(), nullptr, &pSource));
RewriteAssemblyCheckMsg(pSource, pShaderModel, pArguments, argCount,
pDefines, defCount, pLookFors, pReplacements,
pErrorMsgs, bRegex);
}
void RewriteAssemblyCheckMsg(LPCWSTR name, LPCSTR pShaderModel,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
llvm::ArrayRef<LPCSTR> pErrorMsgs,
bool bRegex = false) {
RewriteAssemblyCheckMsg(name, pShaderModel, nullptr, 0, nullptr, 0,
pLookFors, pReplacements, pErrorMsgs, bRegex);
}
void PerformReplacementOnDisassembly(std::string disassembly,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
IDxcBlob **pBlob, bool bRegex = false) {
for (unsigned i = 0; i < pLookFors.size(); ++i) {
LPCSTR pLookFor = pLookFors[i];
bool bOptional = false;
if (pLookFor[0] == '?') {
bOptional = true;
pLookFor++;
}
LPCSTR pReplacement = pReplacements[i];
if (pLookFor && *pLookFor) {
if (bRegex) {
llvm::Regex RE(pLookFor);
std::string reErrors;
if (!RE.isValid(reErrors)) {
WEX::Logging::Log::Comment(WEX::Common::String().Format(
L"Regex errors:\r\n%.*S\r\nWhile compiling expression '%S'",
(unsigned)reErrors.size(), reErrors.data(), pLookFor));
}
VERIFY_IS_TRUE(RE.isValid(reErrors));
std::string replaced = RE.sub(pReplacement, disassembly, &reErrors);
if (!bOptional) {
if (!reErrors.empty()) {
WEX::Logging::Log::Comment(WEX::Common::String().Format(
L"Regex errors:\r\n%.*S\r\nWhile searching for '%S' in "
L"text:\r\n%.*S",
(unsigned)reErrors.size(), reErrors.data(), pLookFor,
(unsigned)disassembly.size(), disassembly.data()));
}
VERIFY_ARE_NOT_EQUAL(disassembly, replaced);
VERIFY_IS_TRUE(reErrors.empty());
}
disassembly = std::move(replaced);
} else {
bool found = false;
size_t pos = 0;
size_t lookForLen = strlen(pLookFor);
size_t replaceLen = strlen(pReplacement);
for (;;) {
pos = disassembly.find(pLookFor, pos);
if (pos == std::string::npos)
break;
found = true; // at least once
disassembly.replace(pos, lookForLen, pReplacement);
pos += replaceLen;
}
if (!bOptional) {
if (!found) {
WEX::Logging::Log::Comment(WEX::Common::String().Format(
L"String not found: '%S' in text:\r\n%.*S", pLookFor,
(unsigned)disassembly.size(), disassembly.data()));
}
VERIFY_IS_TRUE(found);
}
}
}
}
Utf8ToBlob(m_dllSupport, disassembly.c_str(), pBlob);
}
bool RewriteAssemblyToText(IDxcBlobEncoding *pSource, LPCSTR pShaderModel,
LPCWSTR *pArguments, UINT32 argCount,
const DxcDefine *pDefines, UINT32 defineCount,
llvm::ArrayRef<LPCSTR> pLookFors,
llvm::ArrayRef<LPCSTR> pReplacements,
IDxcBlob **pBlob, bool bRegex = false) {
CComPtr<IDxcBlob> pProgram;
std::string disassembly;
if (!CompileSource(pSource, pShaderModel, pArguments, argCount, pDefines,
defineCount, &pProgram))
return false;
DisassembleProgram(pProgram, &disassembly);
PerformReplacementOnDisassembly(disassembly, pLookFors, pReplacements,
pBlob, bRegex);
return true;
}
// compile one or two sources, validate module from 1 with container parts
// from 2, check messages
bool ReplaceContainerPartsCheckMsgs(LPCSTR pSource1, LPCSTR pSource2,
LPCSTR pShaderModel,
llvm::ArrayRef<DxilFourCC> PartsToReplace,
llvm::ArrayRef<LPCSTR> pErrorMsgs) {
CComPtr<IDxcBlob> pProgram1, pProgram2;
if (!CompileSource(pSource1, pShaderModel, &pProgram1))
return false;
VERIFY_IS_NOT_NULL(pProgram1);
if (pSource2) {
if (!CompileSource(pSource2, pShaderModel, &pProgram2))
return false;
VERIFY_IS_NOT_NULL(pProgram2);
} else {
pProgram2 = pProgram1;
}
// construct container with module from pProgram1 with other parts from
// pProgram2:
const DxilContainerHeader *pHeader1 = IsDxilContainerLike(
pProgram1->GetBufferPointer(), pProgram1->GetBufferSize());
VERIFY_IS_NOT_NULL(pHeader1);
const DxilContainerHeader *pHeader2 = IsDxilContainerLike(
pProgram2->GetBufferPointer(), pProgram2->GetBufferSize());
VERIFY_IS_NOT_NULL(pHeader2);
unique_ptr<DxilContainerWriter> pContainerWriter(NewDxilContainerWriter(
DXIL::CompareVersions(m_ver.m_ValMajor, m_ver.m_ValMinor, 1, 7) < 0));
// Add desired parts from first container
for (auto pPart : pHeader1) {
for (auto dfcc : PartsToReplace) {
if (dfcc == pPart->PartFourCC) {
pPart = nullptr;
break;
}
}
if (!pPart)
continue;
pContainerWriter->AddPart(pPart->PartFourCC, pPart->PartSize,
[=](AbstractMemoryStream *pStream) {
ULONG cbWritten = 0;
pStream->Write(GetDxilPartData(pPart),
pPart->PartSize, &cbWritten);
});
}
// Add desired parts from second container
for (auto pPart : pHeader2) {
for (auto dfcc : PartsToReplace) {
if (dfcc == pPart->PartFourCC) {
pContainerWriter->AddPart(pPart->PartFourCC, pPart->PartSize,
[=](AbstractMemoryStream *pStream) {
ULONG cbWritten = 0;
pStream->Write(GetDxilPartData(pPart),
pPart->PartSize,
&cbWritten);
});
break;
}
}
}
// Write the container
CComPtr<IMalloc> pMalloc;
VERIFY_SUCCEEDED(DxcCoGetMalloc(1, &pMalloc));
CComPtr<AbstractMemoryStream> pOutputStream;
VERIFY_SUCCEEDED(CreateMemoryStream(pMalloc, &pOutputStream));
pOutputStream->Reserve(pContainerWriter->size());
pContainerWriter->write(pOutputStream);
CheckValidationMsgs((const char *)pOutputStream->GetPtr(),
pOutputStream->GetPtrSize(), pErrorMsgs,
/*bRegex*/ false);
return true;
}
};
bool ValidationTest::InitSupport() {
if (!m_dllSupport.IsEnabled()) {
VERIFY_SUCCEEDED(m_dllSupport.Initialize());
m_ver.Initialize(m_dllSupport);
}
return true;
}
TEST_F(ValidationTest, WhenCorrectThenOK) {
CComPtr<IDxcBlob> pProgram;
CompileSource("float4 main() : SV_Target { return 1; }", "ps_6_0", &pProgram);
CheckValidationMsgs(pProgram, nullptr);
}
// Lots of these going on below for simplicity in setting up payloads.
//
// warning C4838: conversion from 'int' to 'const char' requires a narrowing
// conversion warning C4309: 'initializing': truncation of constant value
#pragma warning(disable : 4838)
#pragma warning(disable : 4309)
TEST_F(ValidationTest, WhenMisalignedThenFail) {
// Bitcode size must 4-byte aligned
const char blob[] = {
'B',
'C',
};
CheckValidationMsgs(blob, _countof(blob), "Invalid bitcode size");
}
TEST_F(ValidationTest, WhenEmptyFileThenFail) {
// No blocks after signature.
const char blob[] = {'B', 'C', (char)0xc0, (char)0xde};
CheckValidationMsgs(blob, _countof(blob), "Malformed IR file");
}
TEST_F(ValidationTest, WhenIncorrectMagicThenFail) {
// Signature isn't 'B', 'C', 0xC0 0xDE
const char blob[] = {'B', 'C', (char)0xc0, (char)0xdd};
CheckValidationMsgs(blob, _countof(blob), "Invalid bitcode signature");
}
TEST_F(ValidationTest, WhenIncorrectTargetTripleThenFail) {
const char blob[] = {'B', 'C', (char)0xc0, (char)0xde};
CheckValidationMsgs(blob, _countof(blob), "Malformed IR file");
}
TEST_F(ValidationTest, WhenMultipleModulesThenFail) {
const char blob[] = {
'B', 'C', (char)0xc0, (char)0xde, 0x21, 0x0c, 0x00,
0x00, // Enter sub-block, BlockID = 8, Code Size=3, padding x2
0x00, 0x00, 0x00, 0x00, // NumWords = 0
0x08, 0x00, 0x00, 0x00, // End-of-block, padding
// At this point, this is valid bitcode (but missing required DXIL
// metadata) Trigger the case we're looking for now
0x21, 0x0c, 0x00,
0x00, // Enter sub-block, BlockID = 8, Code Size=3, padding x2
};
CheckValidationMsgs(blob, _countof(blob), "Unused bits in buffer");
}
TEST_F(ValidationTest, WhenUnexpectedEOFThenFail) {
// Importantly, this is testing the usage of report_fatal_error during
// deserialization.
const char blob[] = {
'B', 'C', (char)0xc0, (char)0xde, 0x21,
0x0c, 0x00, 0x00, // Enter sub-block, BlockID = 8, Code Size=3, padding x2
0x00, 0x00, 0x00, 0x00, // NumWords = 0
};
CheckValidationMsgs(blob, _countof(blob), "Invalid record");
}
TEST_F(ValidationTest, WhenUnknownBlocksThenFail) {
const char blob[] = {
'B', 'C', (char)0xc0, (char)0xde, // Signature
0x31, 0x00, 0x00, 0x00 // Enter sub-block, BlockID != 8
};
CheckValidationMsgs(blob, _countof(blob), "Unrecognized block found");
}
TEST_F(ValidationTest, WhenZeroInputPatchCountWithInputThenFail) {
RewriteAssemblyCheckMsg(L"..\\DXILValidation\\SimpleHs1.hlsl", "hs_6_0",
"void ()* "
"@\"\\01?HSPerPatchFunc@@YA?AUHSPerPatchData@@V?$"
"InputPatch@UPSSceneIn@@$02@@@Z\", i32 3, i32 3",
"void ()* "
"@\"\\01?HSPerPatchFunc@@YA?AUHSPerPatchData@@V?$"
"InputPatch@UPSSceneIn@@$02@@@Z\", i32 0, i32 3",
"When HS input control point count is 0, no input "
"signature should exist");
}
TEST_F(ValidationTest, WhenInstrDisallowedThenFail) {
RewriteAssemblyCheckMsg(
L"..\\DXILValidation\\abs2.hlsl", "ps_6_0",
{
"target triple = \"dxil-ms-dx\"",
"ret void",
"dx.op.loadInput.i32(i32 4, i32 0, i32 0, i8 3, i32 undef)",
"!\"ps\", i32 6, i32 0",
},
{
"target triple = \"dxil-ms-dx\"\n%dx.types.wave_t = type { i8* }",
"unreachable",
"dx.op.loadInput.i32(i32 4, i32 0, i32 0, i8 3, i32 "
"undef)\n%wave_local = alloca %dx.types.wave_t",
"!\"vs\", i32 6, i32 0",
},
{
"Semantic 'SV_Target' is invalid as vs Output",
"Declaration '%dx.types.wave_t = type { i8* }' uses a reserved "
"prefix",
"Instructions must be of an allowed type",
});
}
TEST_F(ValidationTest, WhenDepthNotFloatThenFail) {
RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\IntegerDepth2.hlsl", "ps_6_0",
{
"!\"SV_Depth\", i8 9",
},
{
"!\"SV_Depth\", i8 4",
},
{
"SV_Depth must be float",
});
}
TEST_F(ValidationTest, BarrierFail) {
if (m_ver.SkipIRSensitiveTest())
return;
RewriteAssemblyCheckMsg(
L"..\\CodeGenHLSL\\barrier.hlsl", "cs_6_0",
{
"dx.op.barrier(i32 80, i32 8)",
"dx.op.barrier(i32 80, i32 9)",
"dx.op.barrier(i32 80, i32 11)",
"%\"hostlayout.class.RWStructuredBuffer<matrix<float, 2, 2> >\" = "
"type { [2 x <2 x float>] }\n",
"call i32 @dx.op.flattenedThreadIdInGroup.i32(i32 96)",
},
{
"dx.op.barrier(i32 80, i32 15)",
"dx.op.barrier(i32 80, i32 0)",
"dx.op.barrier(i32 80, i32 %rem)",
"%\"hostlayout.class.RWStructuredBuffer<matrix<float, 2, 2> >\" = "
"type { [2 x <2 x float>] }\n"
"@dx.typevar.8 = external addrspace(1) constant "
"%\"hostlayout.class.RWStructuredBuffer<matrix<float, 2, 2> >\"\n"
"@\"internalGV\" = internal global [64 x <4 x float>] undef\n",
"call i32 @dx.op.flattenedThreadIdInGroup.i32(i32 96)\n"
"%load = load %\"hostlayout.class.RWStructuredBuffer<matrix<float, "
"2, 2> >\", %\"hostlayout.class.RWStructuredBuffer<matrix<float, 2, "
"2> >\" addrspace(1)* @dx.typevar.8",
},
{"Internal declaration 'internalGV' is unused",
"External declaration 'dx.typevar.8' is unused",
"Vector type '<4 x float>' is not allowed",
"Mode of Barrier must be an immediate constant",
"sync must include some form of memory barrier - _u (UAV) and/or _g "
"(Thread Group Shared Memory)",
"sync can't specify both _ugroup and _uglobal. If both are needed, just "
"specify _uglobal"});
}
TEST_F(ValidationTest, CBufferLegacyOutOfBoundFail) {
RewriteAssemblyCheckMsg(
L"..\\DXILValidation\\cbuffer1.50.hlsl", "ps_6_0",
"cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %Foo2_cbuffer, i32 0)",
"cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %Foo2_cbuffer, i32 6)",
"Cbuffer access out of bound");
}
TEST_F(ValidationTest, CsThreadSizeFail) {
RewriteAssemblyCheckMsg(
L"..\\DXILValidation\\share_mem1.hlsl", "cs_6_0",
{"!{i32 8, i32 8, i32 1", "[256 x float]"},
{"!{i32 1025, i32 1025, i32 1025", "[64000000 x float]"},
{
"Declared Thread Group X size 1025 outside valid range",
"Declared Thread Group Y size 1025 outside valid range",
"Declared Thread Group Z size 1025 outside valid range",
"Declared Thread Group Count 1076890625 (X*Y*Z) is beyond the valid "
"maximum",
"Total Thread Group Shared Memory used by 'main' is 256000000, "
"exceeding maximum: 32768",
});
}
TEST_F(ValidationTest, DeadLoopFail) {
if (m_ver.SkipIRSensitiveTest())
return;
RewriteAssemblyCheckMsg(
L"..\\DXILValidation\\loop1.hlsl", "ps_6_0",
{"br i1 %exitcond, label %for.end.loopexit, label %for.body, !llvm.loop "
"!([0-9]+)",
"?%add(\\.lcssa)? = phi float \\[ %add, %for.body \\]",
"!dx.entryPoints = !\\{!([0-9]+)\\}",
"\\[ %add(\\.lcssa)?, %for.end.loopexit \\]"},
{"br label %for.body", "",
"!dx.entryPoints = !\\{!\\1\\}\n!dx.unused = !\\{!\\1\\}",
"[ 0.000000e+00, %for.end.loopexit ]"},
{
"Loop must have break",
"Named metadata 'dx.unused' is unknown",
},
/*bRegex*/ true);
}
TEST_F(ValidationTest, EvalFail) {
RewriteAssemblyCheckMsg(
L"..\\DXILValidation\\eval.hlsl", "ps_6_0",
"!\"A\", i8 9, i8 0, !([0-9]+), i8 2, i32 1, i8 4",
"!\"A\", i8 9, i8 0, !\\1, i8 0, i32 1, i8 4",
"Interpolation mode on A used with eval_\\* instruction must be ",
/*bRegex*/ true);
}
TEST_F(ValidationTest, GetDimCalcLODFail) {
RewriteAssemblyCheckMsg(
L"..\\CodeGenHLSL\\GetDimCalcLOD.hlsl", "ps_6_0",
{"extractvalue %dx.types.Dimensions %([0-9]+), 1",
"float 1.000000e\\+00, i1 true"},
{"extractvalue %dx.types.Dimensions %\\1, 2", "float undef, i1 true"},
{"GetDimensions used undef dimension z on TextureCube",
"coord uninitialized"},
/*bRegex*/ true);
}
TEST_F(ValidationTest, HsAttributeFail) {
if (m_ver.SkipDxilVersion(1, 8))
return;
RewriteAssemblyCheckMsg(
L"..\\CodeGenHLSL\\hsAttribute.hlsl", "hs_6_0",
{"i32 3, i32 3, i32 2, i32 3, i32 3, float 6.400000e+01"},
{"i32 36, i32 36, i32 0, i32 0, i32 0, float 6.500000e+01"},
{"HS input control point count must be [0..32]. 36 specified",
"Invalid Tessellator Domain specified. Must be isoline, tri or quad",
"Invalid Tessellator Partitioning specified",
"Invalid Tessellator Output Primitive specified",
"Hull Shader MaxTessFactor must be [1.000000..64.000000]. 65.000000 "
"specified",
"output control point count must be [1..32]. 36 specified"});
}
TEST_F(ValidationTest, InnerCoverageFail) {
RewriteAssemblyCheckMsg(
L"..\\CodeGenHLSL\\InnerCoverage2.hlsl", "ps_6_0",
{"dx.op.coverage.i32(i32 91)", "declare i32 @dx.op.coverage.i32(i32)"},
{"dx.op.coverage.i32(i32 91)\n %inner = call i32 "
"@dx.op.innerCoverage.i32(i32 92)",
"declare i32 @dx.op.coverage.i32(i32)\n"
"declare i32 @dx.op.innerCoverage.i32(i32)"},
"InnerCoverage and Coverage are mutually exclusive.");
}
TEST_F(ValidationTest, InterpChangeFail) {
RewriteAssemblyCheckMsg(
L"..\\CodeGenHLSL\\interpChange.hlsl", "ps_6_0",
{"i32 1, i8 0, (.*)}", "?!dx.viewIdState ="},
{"i32 0, i8 2, \\1}", "!1012 ="},
"interpolation mode that differs from another element packed",
/*bRegex*/ true);
}
TEST_F(ValidationTest, InterpOnIntFail) {
RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\interpOnInt2.hlsl", "ps_6_0",
"!\"A\", i8 5, i8 0, !([0-9]+), i8 1",
"!\"A\", i8 5, i8 0, !\\1, i8 2",
"signature element A specifies invalid interpolation "
"mode for integer component type",
/*bRegex*/ true);
}
TEST_F(ValidationTest, InvalidSigCompTyFail) {
RewriteAssemblyCheckMsg(L"..\\DXILValidation\\abs2.hlsl", "ps_6_0",
"!\"A\", i8 4", "!\"A\", i8 0",
"A specifies unrecognized or invalid component type");
}
TEST_F(ValidationTest, MultiStream2Fail) {
if (m_ver.SkipDxilVersion(1, 7))
return;
// dxilver 1.7 because PSV0 data was incorrectly filled in before this point,
// making this test fail if running against prior validator versions.
RewriteAssemblyCheckMsg(
L"..\\DXILValidation\\multiStreamGS.hlsl", "gs_6_0",
"i32 1, i32 12, i32 7, i32 1, i32 1",
"i32 1, i32 12, i32 7, i32 2, i32 1",
"Multiple GS output streams are used but 'XXX' is not pointlist");
}
TEST_F(ValidationTest, PhiTGSMFail) {
if (m_ver.SkipIRSensitiveTest())
return;
RewriteAssemblyCheckMsg(
L"..\\CodeGenHLSL\\phiTGSM.hlsl", "cs_6_0", "ret void",
"%arrayPhi = phi i32 addrspace(3)* [ %arrayidx, %if.then ], [ "
"%arrayidx2, %if.else ]\n"
"%phiAtom = atomicrmw add i32 addrspace(3)* %arrayPhi, i32 1 seq_cst\n"
"ret void",
"TGSM pointers must originate from an unambiguous TGSM global variable");
}
TEST_F(ValidationTest, QuadOpInVS) {
if (m_ver.SkipDxilVersion(1, 5))
return;