-
Notifications
You must be signed in to change notification settings - Fork 844
Expand file tree
/
Copy pathCompilerTest.cpp
More file actions
4924 lines (4187 loc) · 175 KB
/
CompilerTest.cpp
File metadata and controls
4924 lines (4187 loc) · 175 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
///////////////////////////////////////////////////////////////////////////////
// //
// CompilerTest.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. //
// //
// Provides tests for the compiler API. //
// //
///////////////////////////////////////////////////////////////////////////////
#ifndef UNICODE
#define UNICODE
#endif
// clang-format off
// Includes on Windows are highly order dependent.
#include <memory>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <cfloat>
#include "dxc/DxilContainer/DxilContainer.h"
#include "dxc/Support/WinIncludes.h"
#include "dxc/Support/D3DReflection.h"
#include "dxc/dxcapi.h"
#ifdef _WIN32
#include "dxc/dxcpix.h"
#include <atlfile.h>
#include <d3dcompiler.h>
#include "dia2.h"
#else // _WIN32
#ifndef __ANDROID__
#include <execinfo.h>
#define CaptureStackBackTrace(FramesToSkip, FramesToCapture, BackTrace, \
BackTraceHash) \
backtrace(BackTrace, FramesToCapture)
#endif // __ANDROID__
#endif // _WIN32
#include "dxc/Test/HLSLTestData.h"
#include "dxc/Test/HlslTestUtils.h"
#include "dxc/Test/DxcTestUtils.h"
#include "llvm/Support/raw_os_ostream.h"
#include "dxc/Support/Global.h"
#include "dxc/Support/dxcapi.use.h"
#include "dxc/Support/microcom.h"
#include "dxc/Support/HLSLOptions.h"
#include "dxc/Support/Unicode.h"
#include <fstream>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MSFileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
// clang-format on
// These are helper macros for adding slashes down below
// based on platform. The PP_ prefixed ones are for matching
// slashes in preprocessed HLSLs, since backslashes that
// appear in #line directives are double backslashes.
#ifdef _WIN32
#define SLASH_W L"\\"
#define SLASH "\\"
#else
#define SLASH_W L"/"
#define SLASH "/"
#endif
using namespace std;
using namespace hlsl_test;
class TestIncludeHandler : public IDxcIncludeHandler {
DXC_MICROCOM_REF_FIELD(m_dwRef)
public:
DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef)
dxc::DxCompilerDllLoader &m_dllSupport;
HRESULT m_defaultErrorCode = E_FAIL;
TestIncludeHandler(dxc::DxCompilerDllLoader &dllSupport)
: m_dwRef(0), m_dllSupport(dllSupport), callIndex(0) {}
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
void **ppvObject) override {
return DoBasicQueryInterface<IDxcIncludeHandler>(this, iid, ppvObject);
}
struct LoadSourceCallInfo {
std::wstring Filename; // Filename as written in #include statement
LoadSourceCallInfo(LPCWSTR pFilename) : Filename(pFilename) {}
};
std::vector<LoadSourceCallInfo> CallInfos;
std::wstring GetAllFileNames() const {
std::wstringstream s;
for (size_t i = 0; i < CallInfos.size(); ++i) {
s << CallInfos[i].Filename << ';';
}
return s.str();
}
struct LoadSourceCallResult {
HRESULT hr;
std::string source;
UINT32 codePage;
LoadSourceCallResult() : hr(E_FAIL), codePage(0) {}
LoadSourceCallResult(const char *pSource, UINT32 codePage = CP_UTF8)
: hr(S_OK), source(pSource), codePage(codePage) {}
LoadSourceCallResult(const void *pSource, size_t size,
UINT32 codePage = CP_ACP)
: hr(S_OK), source((const char *)pSource, size), codePage(codePage) {}
};
std::vector<LoadSourceCallResult> CallResults;
size_t callIndex;
HRESULT STDMETHODCALLTYPE LoadSource(
LPCWSTR pFilename, // Filename as written in #include statement
IDxcBlob **ppIncludeSource // Resultant source object for included file
) override {
CallInfos.push_back(LoadSourceCallInfo(pFilename));
*ppIncludeSource = nullptr;
if (callIndex >= CallResults.size()) {
return m_defaultErrorCode;
}
if (FAILED(CallResults[callIndex].hr)) {
return CallResults[callIndex++].hr;
}
MultiByteStringToBlob(m_dllSupport, CallResults[callIndex].source,
CallResults[callIndex].codePage, ppIncludeSource);
return CallResults[callIndex++].hr;
}
};
#ifdef _WIN32
class CompilerTest {
#else
class CompilerTest : public ::testing::Test {
#endif
public:
BEGIN_TEST_CLASS(CompilerTest)
TEST_CLASS_PROPERTY(L"Parallel", L"true")
TEST_METHOD_PROPERTY(L"Priority", L"0")
END_TEST_CLASS()
TEST_CLASS_SETUP(InitSupport);
TEST_METHOD(CompileWhenDefinesThenApplied)
TEST_METHOD(CompileWhenDefinesManyThenApplied)
TEST_METHOD(CompileWhenEmptyThenFails)
TEST_METHOD(CompileWhenIncorrectThenFails)
TEST_METHOD(CompileWhenWorksThenDisassembleWorks)
TEST_METHOD(CompileWhenDebugWorksThenStripDebug)
TEST_METHOD(CompileWhenWorksThenAddRemovePrivate)
TEST_METHOD(CompileThenAddCustomDebugName)
TEST_METHOD(CompileThenTestReflectionWithProgramHeader)
TEST_METHOD(CompileThenTestPdbUtils)
TEST_METHOD(CompileThenTestPdbUtilsWarningOpt)
TEST_METHOD(CompileThenTestPdbInPrivate)
TEST_METHOD(CompileThenTestPdbUtilsStripped)
TEST_METHOD(CompileThenTestPdbUtilsEmptyEntry)
TEST_METHOD(CompileThenTestPdbUtilsRelativePath)
TEST_METHOD(CompileSameFilenameAndEntryThenTestPdbUtilsArgs)
TEST_METHOD(CompileWithRootSignatureThenStripRootSignature)
TEST_METHOD(CompileThenSetRootSignatureThenValidate)
TEST_METHOD(CompileSetPrivateThenWithStripPrivate)
TEST_METHOD(CompileWithMultiplePrivateOptionsThenFail)
TEST_METHOD(TestPdbUtilsWithEmptyDefine)
void CompileThenTestReflectionThreadSize(const char *source,
const WCHAR *target, UINT expectedX,
UINT expectedY, UINT expectedZ);
TEST_METHOD(CompileThenTestReflectionThreadSizeMS)
TEST_METHOD(CompileThenTestReflectionThreadSizeAS)
TEST_METHOD(CompileThenTestReflectionThreadSizeCS)
void TestResourceBindingImpl(const char *bindingFileContent,
const std::wstring &errors = std::wstring(),
bool noIncludeHandler = false);
TEST_METHOD(CompileWithResourceBindingFileThenOK)
TEST_METHOD(CompileWhenIncludeThenLoadInvoked)
TEST_METHOD(CompileWhenIncludeThenLoadUsed)
TEST_METHOD(CompileWhenIncludeAbsoluteThenLoadAbsolute)
TEST_METHOD(CompileWhenIncludeLocalThenLoadRelative)
TEST_METHOD(CompileWhenIncludeSystemThenLoadNotRelative)
TEST_METHOD(CompileWhenAllIncludeCombinations)
TEST_METHOD(TestPdbUtilsPathNormalizations)
TEST_METHOD(CompileWithIncludeThenTestNoLexicalBlockFile)
TEST_METHOD(CompileWhenIncludeSystemMissingThenLoadAttempt)
TEST_METHOD(CompileWhenIncludeFlagsThenIncludeUsed)
TEST_METHOD(CompileThenCheckDisplayIncludeProcess)
TEST_METHOD(CompileThenPrintTimeReport)
TEST_METHOD(CompileThenPrintTimeTrace)
TEST_METHOD(CompileWhenIncludeMissingThenFail)
TEST_METHOD(CompileWhenIncludeHasPathThenOK)
TEST_METHOD(CompileWhenIncludeEmptyThenOK)
TEST_METHOD(CompileWhenODumpThenPassConfig)
TEST_METHOD(CompileWhenODumpThenCheckNoSink)
TEST_METHOD(CompileWhenODumpThenOptimizerMatch)
TEST_METHOD(CompileWhenVdThenProducesDxilContainer)
void TestEncodingImpl(const void *sourceData, size_t sourceSize,
UINT32 codePage, const void *includedData,
size_t includedSize, const WCHAR *encoding = nullptr);
template <typename T1, typename T2>
void TestEncodingImpl(std::basic_string<T1> source, UINT32 codePage,
std::basic_string<T2> included,
const WCHAR *encoding = nullptr) {
TestEncodingImpl(source.data(), source.size() * sizeof(T1), codePage,
included.data(), included.size() * sizeof(T2), encoding);
}
TEST_METHOD(CompileWithEncodeFlagTestSource)
#if _ITERATOR_DEBUG_LEVEL == 0
// CompileWhenNoMemThenOOM can properly detect leaks only when debug iterators
// are disabled
BEGIN_TEST_METHOD(CompileWhenNoMemThenOOM)
// Disabled because there are problems where we try to allocate memory in
// destructors, which causes more bad_alloc() throws while unwinding
// bad_alloc(), which asserts If only failing one allocation, there are
// allocations where failing them is lost, such as in ~raw_string_ostream(),
// where it flushes, then eats bad_alloc(), if thrown.
TEST_METHOD_PROPERTY(L"Ignore", L"true")
END_TEST_METHOD()
#endif
TEST_METHOD(CompileWhenShaderModelMismatchAttributeThenFail)
TEST_METHOD(CompileBadHlslThenFail)
TEST_METHOD(CompileLegacyShaderModelThenFail)
TEST_METHOD(CompileWhenRecursiveAlbeitStaticTermThenFail)
TEST_METHOD(CompileWhenRecursiveThenFail)
TEST_METHOD(CompileHlsl2015ThenFail)
TEST_METHOD(CompileHlsl2016ThenOK)
TEST_METHOD(CompileHlsl2017ThenOK)
TEST_METHOD(CompileHlsl2018ThenOK)
TEST_METHOD(CompileHlsl2019ThenFail)
TEST_METHOD(CompileHlsl2020ThenFail)
TEST_METHOD(CompileHlsl2021ThenOK)
TEST_METHOD(CompileHlsl2022ThenFail)
TEST_METHOD(CodeGenFloatingPointEnvironment)
TEST_METHOD(CodeGenLibCsEntry)
TEST_METHOD(CodeGenLibCsEntry2)
TEST_METHOD(CodeGenLibCsEntry3)
TEST_METHOD(CodeGenLibEntries)
TEST_METHOD(CodeGenLibEntries2)
TEST_METHOD(CodeGenLibResource)
TEST_METHOD(CodeGenLibUnusedFunc)
TEST_METHOD(CodeGenRootSigProfile)
TEST_METHOD(CodeGenRootSigProfile2)
TEST_METHOD(CodeGenRootSigProfile5)
TEST_METHOD(CodeGenVectorIsnan)
TEST_METHOD(CodeGenVectorAtan2)
TEST_METHOD(PreprocessWhenValidThenOK)
TEST_METHOD(LibGVStore)
TEST_METHOD(PreprocessWhenExpandTokenPastingOperandThenAccept)
TEST_METHOD(PreprocessWithDebugOptsThenOk)
TEST_METHOD(PreprocessCheckBuiltinIsOk)
TEST_METHOD(WhenSigMismatchPCFunctionThenFail)
TEST_METHOD(CompileOtherModesWithDebugOptsThenOk)
TEST_METHOD(BatchSamples)
TEST_METHOD(BatchD3DReflect)
TEST_METHOD(BatchDxil)
TEST_METHOD(BatchHLSL)
TEST_METHOD(BatchInfra)
TEST_METHOD(BatchPasses)
TEST_METHOD(BatchShaderTargets)
TEST_METHOD(BatchValidation)
TEST_METHOD(BatchPIX)
TEST_METHOD(CodeGenHashStabilityD3DReflect)
TEST_METHOD(CodeGenHashStabilityDisassembler)
TEST_METHOD(CodeGenHashStabilityDXIL)
TEST_METHOD(CodeGenHashStabilityHLSL)
TEST_METHOD(CodeGenHashStabilityInfra)
TEST_METHOD(CodeGenHashStabilityPIX)
TEST_METHOD(CodeGenHashStabilityRewriter)
TEST_METHOD(CodeGenHashStabilitySamples)
TEST_METHOD(CodeGenHashStabilityShaderTargets)
TEST_METHOD(CodeGenHashStabilityValidation)
TEST_METHOD(SubobjectCodeGenErrors)
BEGIN_TEST_METHOD(ManualFileCheckTest)
TEST_METHOD_PROPERTY(L"Ignore", L"true")
END_TEST_METHOD()
dxc::DxCompilerDllLoader m_dllSupport;
VersionSupportInfo m_ver;
void CreateBlobPinned(LPCVOID data, SIZE_T size, UINT32 codePage,
IDxcBlobEncoding **ppBlob) {
CComPtr<IDxcLibrary> library;
IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
IFT(library->CreateBlobWithEncodingFromPinned(data, size, codePage,
ppBlob));
}
void CreateBlobFromFile(LPCWSTR name, IDxcBlobEncoding **ppBlob) {
CComPtr<IDxcLibrary> library;
IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
const std::wstring path = hlsl_test::GetPathToHlslDataFile(name);
IFT(library->CreateBlobFromFile(path.c_str(), nullptr, ppBlob));
}
void CreateBlobFromText(const char *pText, IDxcBlobEncoding **ppBlob) {
CreateBlobPinned(pText, strlen(pText) + 1, CP_UTF8, ppBlob);
}
HRESULT CreateCompiler(IDxcCompiler **ppResult) {
return m_dllSupport.CreateInstance(CLSID_DxcCompiler, ppResult);
}
void TestPdbUtils(bool bSlim, bool bLegacy, bool bStrip,
bool bTestEntryPoint);
HRESULT CreateContainerBuilder(IDxcContainerBuilder **ppResult) {
return m_dllSupport.CreateInstance(CLSID_DxcContainerBuilder, ppResult);
}
template <typename T, typename TDefault, typename TIface>
void WriteIfValue(TIface *pSymbol, std::wstringstream &o,
TDefault defaultValue, LPCWSTR valueLabel,
HRESULT (__stdcall TIface::*pFn)(T *)) {
T value;
HRESULT hr = (pSymbol->*(pFn))(&value);
if (SUCCEEDED(hr) && value != defaultValue) {
o << L", " << valueLabel << L": " << value;
}
}
std::string GetOption(std::string &cmd, char *opt) {
std::string option = cmd.substr(cmd.find(opt));
option = option.substr(option.find_first_of(' '));
option = option.substr(option.find_first_not_of(' '));
return option.substr(0, option.find_first_of(' '));
}
void CodeGenTest(std::wstring name) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
name.insert(0, L"..\\CodeGenHLSL\\");
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromFile(name.c_str(), &pSource);
std::string cmdLine = GetFirstLine(name.c_str());
llvm::StringRef argsRef = cmdLine;
llvm::SmallVector<llvm::StringRef, 8> splitArgs;
argsRef.split(splitArgs, " ");
hlsl::options::MainArgs argStrings(splitArgs);
std::string errorString;
llvm::raw_string_ostream errorStream(errorString);
hlsl::options::DxcOpts opts;
IFT(ReadDxcOpts(hlsl::options::getHlslOptTable(), /*flagsToInclude*/ 0,
argStrings, opts, errorStream));
std::wstring entry =
Unicode::UTF8ToWideStringOrThrow(opts.EntryPoint.str().c_str());
std::wstring profile =
Unicode::UTF8ToWideStringOrThrow(opts.TargetProfile.str().c_str());
std::vector<std::wstring> argLists;
CopyArgsToWStrings(opts.Args, hlsl::options::CoreOption, argLists);
std::vector<LPCWSTR> args;
args.reserve(argLists.size());
for (const std::wstring &a : argLists)
args.push_back(a.data());
VERIFY_SUCCEEDED(pCompiler->Compile(
pSource, name.c_str(), entry.c_str(), profile.c_str(), args.data(),
args.size(), opts.Defines.data(), opts.Defines.size(), nullptr,
&pResult));
VERIFY_IS_NOT_NULL(pResult, L"Failed to compile - pResult NULL");
HRESULT result;
VERIFY_SUCCEEDED(pResult->GetStatus(&result));
if (FAILED(result)) {
CComPtr<IDxcBlobEncoding> pErr;
IFT(pResult->GetErrorBuffer(&pErr));
std::string errString(BlobToUtf8(pErr));
CA2W errStringW(errString.c_str());
WEX::Logging::Log::Comment(L"Failed to compile - errors follow");
WEX::Logging::Log::Comment(errStringW);
}
VERIFY_SUCCEEDED(result);
CComPtr<IDxcBlob> pProgram;
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
if (opts.IsRootSignatureProfile())
return;
CComPtr<IDxcBlobEncoding> pDisassembleBlob;
VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembleBlob));
std::string disassembleString(BlobToUtf8(pDisassembleBlob));
VERIFY_ARE_NOT_EQUAL(0U, disassembleString.size());
}
void CodeGenTestHashFullPath(LPCWSTR fullPath) {
FileRunTestResult t =
FileRunTestResult::RunHashTestFromFileCommands(fullPath);
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 CodeGenTestHash(LPCWSTR name, bool implicitDir) {
std::wstring path = name;
if (implicitDir) {
path.insert(0, L"..\\CodeGenHLSL\\");
path = hlsl_test::GetPathToHlslDataFile(path.c_str());
}
CodeGenTestHashFullPath(path.c_str());
}
void CodeGenTestCheckBatchHash(std::wstring suitePath,
bool implicitDir = true) {
using namespace llvm;
using namespace WEX::TestExecution;
if (implicitDir)
suitePath.insert(0, L"..\\HLSLFileCheck\\");
::llvm::sys::fs::MSFileSystem *msfPtr;
VERIFY_SUCCEEDED(CreateMSFileSystemForDisk(&msfPtr));
std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr);
::llvm::sys::fs::AutoPerThreadSystem pts(msf.get());
IFTLLVM(pts.error_code());
CW2A pUtf8Filename(suitePath.c_str());
if (!llvm::sys::path::is_absolute(pUtf8Filename.m_psz)) {
suitePath = hlsl_test::GetPathToHlslDataFile(suitePath.c_str());
}
CW2A utf8SuitePath(suitePath.c_str());
unsigned numTestsRun = 0;
std::error_code EC;
llvm::SmallString<128> DirNative;
llvm::sys::path::native(utf8SuitePath.m_psz, DirNative);
for (llvm::sys::fs::recursive_directory_iterator Dir(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
// Check whether this entry has an extension typically associated with
// headers.
if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
.Cases(".hlsl", ".ll", true)
.Default(false))
continue;
StringRef filename = Dir->path();
std::string filetag = Dir->path();
filetag += "<HASH>";
CA2W wRelTag(filetag.data());
CA2W wRelPath(filename.data());
WEX::Logging::Log::StartGroup(wRelTag);
CodeGenTestHash(wRelPath, /*implicitDir*/ false);
WEX::Logging::Log::EndGroup(wRelTag);
numTestsRun++;
}
VERIFY_IS_GREATER_THAN(numTestsRun, (unsigned)0,
L"No test files found in batch directory.");
}
void CodeGenTestCheckFullPath(LPCWSTR fullPath, LPCWSTR dumpPath = nullptr) {
// Create file system if needed
llvm::sys::fs::MSFileSystem *msfPtr =
llvm::sys::fs::GetCurrentThreadFileSystem();
std::unique_ptr<llvm::sys::fs::MSFileSystem> msf;
if (!msfPtr) {
VERIFY_SUCCEEDED(CreateMSFileSystemForDisk(&msfPtr));
msf.reset(msfPtr);
}
llvm::sys::fs::AutoPerThreadSystem pts(msfPtr);
IFTLLVM(pts.error_code());
FileRunTestResult t = FileRunTestResult::RunFromFileCommands(
fullPath,
/*pPluginToolsPaths*/ nullptr, dumpPath);
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 CodeGenTestCheck(LPCWSTR name, bool implicitDir = true,
LPCWSTR dumpPath = nullptr) {
std::wstring path = name;
std::wstring dumpStr;
if (implicitDir) {
path.insert(0, L"..\\CodeGenHLSL\\");
path = hlsl_test::GetPathToHlslDataFile(path.c_str());
if (!dumpPath) {
dumpStr = hlsl_test::GetPathToHlslDataFile(path.c_str(),
FILECHECKDUMPDIRPARAM);
dumpPath = dumpStr.empty() ? nullptr : dumpStr.c_str();
}
}
CodeGenTestCheckFullPath(path.c_str(), dumpPath);
}
void CodeGenTestCheckBatchDir(std::wstring suitePath,
bool implicitDir = true) {
using namespace llvm;
using namespace WEX::TestExecution;
if (implicitDir)
suitePath.insert(0, L"..\\HLSLFileCheck\\");
::llvm::sys::fs::MSFileSystem *msfPtr;
VERIFY_SUCCEEDED(CreateMSFileSystemForDisk(&msfPtr));
std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr);
::llvm::sys::fs::AutoPerThreadSystem pts(msf.get());
IFTLLVM(pts.error_code());
std::wstring dumpPath;
CW2A pUtf8Filename(suitePath.c_str());
if (!llvm::sys::path::is_absolute(pUtf8Filename.m_psz)) {
dumpPath = hlsl_test::GetPathToHlslDataFile(suitePath.c_str(),
FILECHECKDUMPDIRPARAM);
suitePath = hlsl_test::GetPathToHlslDataFile(suitePath.c_str());
}
CW2A utf8SuitePath(suitePath.c_str());
unsigned numTestsRun = 0;
std::error_code EC;
llvm::SmallString<128> DirNative;
llvm::sys::path::native(utf8SuitePath.m_psz, DirNative);
for (llvm::sys::fs::recursive_directory_iterator Dir(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
// Check whether this entry has an extension typically associated with
// headers.
if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
.Cases(".hlsl", ".ll", true)
.Default(false))
continue;
StringRef filename = Dir->path();
CA2W wRelPath(filename.data());
std::wstring dumpStr;
if (!dumpPath.empty() &&
suitePath.compare(0, suitePath.size(), wRelPath.m_psz,
suitePath.size()) == 0) {
dumpStr = dumpPath + (wRelPath.m_psz + suitePath.size());
}
class ScopedLogGroup {
LPWSTR m_path;
public:
ScopedLogGroup(LPWSTR path) : m_path(path) {
WEX::Logging::Log::StartGroup(m_path);
}
~ScopedLogGroup() { WEX::Logging::Log::EndGroup(m_path); }
};
ScopedLogGroup cleanup(wRelPath);
CodeGenTestCheck(wRelPath, /*implicitDir*/ false,
dumpStr.empty() ? nullptr : dumpStr.c_str());
numTestsRun++;
}
VERIFY_IS_GREATER_THAN(numTestsRun, (unsigned)0,
L"No test files found in batch directory.");
}
std::string VerifyCompileFailed(LPCSTR pText, LPCWSTR pTargetProfile,
LPCSTR pErrorMsg) {
return VerifyCompileFailed(pText, pTargetProfile, pErrorMsg, L"main");
}
std::string VerifyCompileFailed(LPCSTR pText, LPCWSTR pTargetProfile,
LPCSTR pErrorMsg, LPCWSTR pEntryPoint) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
CComPtr<IDxcBlobEncoding> pErrors;
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText(pText, &pSource);
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", pEntryPoint,
pTargetProfile, nullptr, 0, nullptr, 0,
nullptr, &pResult));
HRESULT status;
VERIFY_SUCCEEDED(pResult->GetStatus(&status));
VERIFY_FAILED(status);
VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
if (pErrorMsg && *pErrorMsg) {
CheckOperationResultMsgs(pResult, &pErrorMsg, 1, false, false);
}
return BlobToUtf8(pErrors);
}
void VerifyOperationSucceeded(IDxcOperationResult *pResult) {
HRESULT result;
VERIFY_SUCCEEDED(pResult->GetStatus(&result));
if (FAILED(result)) {
CComPtr<IDxcBlobEncoding> pErrors;
VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
CA2W errorsWide(BlobToUtf8(pErrors).c_str());
WEX::Logging::Log::Comment(errorsWide);
}
VERIFY_SUCCEEDED(result);
}
std::string VerifyOperationFailed(IDxcOperationResult *pResult) {
HRESULT result;
VERIFY_SUCCEEDED(pResult->GetStatus(&result));
VERIFY_FAILED(result);
CComPtr<IDxcBlobEncoding> pErrors;
VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
return BlobToUtf8(pErrors);
}
#ifdef _WIN32 // - exclude dia stuff
HRESULT CreateDiaSourceForCompile(const char *hlsl,
IDiaDataSource **ppDiaSource) {
if (!ppDiaSource)
return E_POINTER;
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
CComPtr<IDxcBlob> pProgram;
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText(hlsl, &pSource);
LPCWSTR args[] = {L"/Zi", L"/Qembed_debug"};
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", args, _countof(args),
nullptr, 0, nullptr, &pResult));
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
// Disassemble the compiled (stripped) program.
{
CComPtr<IDxcBlobEncoding> pDisassembly;
VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembly));
std::string disText = BlobToUtf8(pDisassembly);
CA2W disTextW(disText.c_str());
// WEX::Logging::Log::Comment(disTextW);
}
// CONSIDER: have the dia data source look for the part if passed a whole
// container.
CComPtr<IDiaDataSource> pDiaSource;
CComPtr<IStream> pProgramStream;
CComPtr<IDxcLibrary> pLib;
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLib));
const hlsl::DxilContainerHeader *pContainer = hlsl::IsDxilContainerLike(
pProgram->GetBufferPointer(), pProgram->GetBufferSize());
VERIFY_IS_NOT_NULL(pContainer);
hlsl::DxilPartIterator partIter =
std::find_if(hlsl::begin(pContainer), hlsl::end(pContainer),
hlsl::DxilPartIsType(hlsl::DFCC_ShaderDebugInfoDXIL));
const hlsl::DxilProgramHeader *pProgramHeader =
(const hlsl::DxilProgramHeader *)hlsl::GetDxilPartData(*partIter);
uint32_t bitcodeLength;
const char *pBitcode;
CComPtr<IDxcBlob> pProgramPdb;
hlsl::GetDxilProgramBitcode(pProgramHeader, &pBitcode, &bitcodeLength);
VERIFY_SUCCEEDED(pLib->CreateBlobFromBlob(
pProgram, pBitcode - (char *)pProgram->GetBufferPointer(),
bitcodeLength, &pProgramPdb));
// Disassemble the program with debug information.
{
CComPtr<IDxcBlobEncoding> pDbgDisassembly;
VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgramPdb, &pDbgDisassembly));
std::string disText = BlobToUtf8(pDbgDisassembly);
CA2W disTextW(disText.c_str());
// WEX::Logging::Log::Comment(disTextW);
}
// Create a short text dump of debug information.
VERIFY_SUCCEEDED(
pLib->CreateStreamFromBlobReadOnly(pProgramPdb, &pProgramStream));
VERIFY_SUCCEEDED(
m_dllSupport.CreateInstance(CLSID_DxcDiaDataSource, &pDiaSource));
VERIFY_SUCCEEDED(pDiaSource->loadDataFromIStream(pProgramStream));
*ppDiaSource = pDiaSource.Detach();
return S_OK;
}
#endif // _WIN32 - exclude dia stuff
};
// Useful for debugging.
#if SUPPORT_FXC_PDB
#include <d3dcompiler.h>
#pragma comment(lib, "d3dcompiler.lib")
HRESULT GetBlobPdb(IDxcBlob *pBlob, IDxcBlob **ppDebugInfo) {
return D3DGetBlobPart(pBlob->GetBufferPointer(), pBlob->GetBufferSize(),
D3D_BLOB_PDB, 0, (ID3DBlob **)ppDebugInfo);
}
std::string FourCCStr(uint32_t val) {
std::stringstream o;
char c[5];
c[0] = val & 0xFF;
c[1] = (val & 0xFF00) >> 8;
c[2] = (val & 0xFF0000) >> 16;
c[3] = (val & 0xFF000000) >> 24;
c[4] = '\0';
o << c << " (" << std::hex << val << std::dec << ")";
return o.str();
}
std::string DumpParts(IDxcBlob *pBlob) {
std::stringstream o;
hlsl::DxilContainerHeader *pContainer =
(hlsl::DxilContainerHeader *)pBlob->GetBufferPointer();
o << "Container:" << std::endl
<< " Size: " << pContainer->ContainerSizeInBytes << std::endl
<< " FourCC: " << FourCCStr(pContainer->HeaderFourCC) << std::endl
<< " Part count: " << pContainer->PartCount << std::endl;
for (uint32_t i = 0; i < pContainer->PartCount; ++i) {
hlsl::DxilPartHeader *pPart = hlsl::GetDxilContainerPart(pContainer, i);
o << "Part " << i << std::endl
<< " FourCC: " << FourCCStr(pPart->PartFourCC) << std::endl
<< " Size: " << pPart->PartSize << std::endl;
}
return o.str();
}
HRESULT CreateDiaSourceFromDxbcBlob(IDxcLibrary *pLib, IDxcBlob *pDxbcBlob,
IDiaDataSource **ppDiaSource) {
HRESULT hr = S_OK;
CComPtr<IDxcBlob> pdbBlob;
CComPtr<IStream> pPdbStream;
CComPtr<IDiaDataSource> pDiaSource;
IFR(GetBlobPdb(pDxbcBlob, &pdbBlob));
IFR(pLib->CreateStreamFromBlobReadOnly(pdbBlob, &pPdbStream));
IFR(CoCreateInstance(CLSID_DiaSource, NULL, CLSCTX_INPROC_SERVER,
__uuidof(IDiaDataSource), (void **)&pDiaSource));
IFR(pDiaSource->loadDataFromIStream(pPdbStream));
*ppDiaSource = pDiaSource.Detach();
return hr;
}
#endif
bool CompilerTest::InitSupport() {
if (!m_dllSupport.IsEnabled()) {
VERIFY_SUCCEEDED(m_dllSupport.Initialize());
m_ver.Initialize(m_dllSupport);
}
return true;
}
TEST_F(CompilerTest, CompileWhenDefinesThenApplied) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
DxcDefine defines[] = {{L"F4", L"float4"}};
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("F4 main() : SV_Target { return 0; }", &pSource);
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", nullptr, 0, defines,
_countof(defines), nullptr, &pResult));
}
TEST_F(CompilerTest, CompileWhenDefinesManyThenApplied) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
LPCWSTR args[] = {L"/DVAL1=1", L"/DVAL2=2", L"/DVAL3=3", L"/DVAL4=2",
L"/DVAL5=4", L"/DNVAL1", L"/DNVAL2", L"/DNVAL3",
L"/DNVAL4", L"/DNVAL5", L"/DCVAL1=1", L"/DCVAL2=2",
L"/DCVAL3=3", L"/DCVAL4=2", L"/DCVAL5=4", L"/DCVALNONE="};
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("float4 main() : SV_Target {\r\n"
"#ifndef VAL1\r\n"
"#error VAL1 not defined\r\n"
"#endif\r\n"
"#ifndef NVAL5\r\n"
"#error NVAL5 not defined\r\n"
"#endif\r\n"
"#ifndef CVALNONE\r\n"
"#error CVALNONE not defined\r\n"
"#endif\r\n"
"return 0; }",
&pSource);
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", args, _countof(args), nullptr,
0, nullptr, &pResult));
HRESULT compileStatus;
VERIFY_SUCCEEDED(pResult->GetStatus(&compileStatus));
if (FAILED(compileStatus)) {
CComPtr<IDxcBlobEncoding> pErrors;
VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
OutputDebugStringA((LPCSTR)pErrors->GetBufferPointer());
}
VERIFY_SUCCEEDED(compileStatus);
}
TEST_F(CompilerTest, CompileWhenEmptyThenFails) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
CComPtr<IDxcBlobEncoding> pSourceBad;
LPCWSTR pProfile = L"ps_6_0";
LPCWSTR pEntryPoint = L"main";
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("float4 main() : SV_Target { return 0; }", &pSource);
CreateBlobFromText("float4 main() : SV_Target { return undef; }",
&pSourceBad);
// correct version
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", pEntryPoint,
pProfile, nullptr, 0, nullptr, 0, nullptr,
&pResult));
pResult.Release();
// correct version with compilation errors
VERIFY_SUCCEEDED(pCompiler->Compile(pSourceBad, L"source.hlsl", pEntryPoint,
pProfile, nullptr, 0, nullptr, 0, nullptr,
&pResult));
pResult.Release();
// null source
VERIFY_FAILED(pCompiler->Compile(nullptr, L"source.hlsl", pEntryPoint,
pProfile, nullptr, 0, nullptr, 0, nullptr,
&pResult));
// null profile
VERIFY_FAILED(pCompiler->Compile(pSourceBad, L"source.hlsl", pEntryPoint,
nullptr, nullptr, 0, nullptr, 0, nullptr,
&pResult));
// null source name succeeds
VERIFY_SUCCEEDED(pCompiler->Compile(pSourceBad, nullptr, pEntryPoint,
pProfile, nullptr, 0, nullptr, 0, nullptr,
&pResult));
pResult.Release();
// empty source name (as opposed to null) also suceeds
VERIFY_SUCCEEDED(pCompiler->Compile(pSourceBad, L"", pEntryPoint, pProfile,
nullptr, 0, nullptr, 0, nullptr,
&pResult));
pResult.Release();
// null result
VERIFY_FAILED(pCompiler->Compile(pSource, L"source.hlsl", pEntryPoint,
pProfile, nullptr, 0, nullptr, 0, nullptr,
nullptr));
}
TEST_F(CompilerTest, CompileWhenIncorrectThenFails) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("float4_undefined main() : SV_Target { return 0; }",
&pSource);
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", nullptr, 0, nullptr, 0,
nullptr, &pResult));
HRESULT result;
VERIFY_SUCCEEDED(pResult->GetStatus(&result));
VERIFY_FAILED(result);
CComPtr<IDxcBlobEncoding> pErrorBuffer;
VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrorBuffer));
std::string errorString(BlobToUtf8(pErrorBuffer));
VERIFY_ARE_NOT_EQUAL(0U, errorString.size());
// Useful for examining actual error message:
// CA2W errorStringW(errorString.c_str());
// WEX::Logging::Log::Comment(errorStringW.m_psz);
}
TEST_F(CompilerTest, CompileWhenWorksThenDisassembleWorks) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("float4 main() : SV_Target { return 0; }", &pSource);
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", nullptr, 0, nullptr, 0,
nullptr, &pResult));
HRESULT result;
VERIFY_SUCCEEDED(pResult->GetStatus(&result));
VERIFY_SUCCEEDED(result);
CComPtr<IDxcBlob> pProgram;
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
CComPtr<IDxcBlobEncoding> pDisassembleBlob;
VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembleBlob));
std::string disassembleString(BlobToUtf8(pDisassembleBlob));
VERIFY_ARE_NOT_EQUAL(0U, disassembleString.size());
// Useful for examining disassembly:
// CA2W disassembleStringW(disassembleString.c_str());
// WEX::Logging::Log::Comment(disassembleStringW.m_psz);
}
TEST_F(CompilerTest, CompileWhenDebugWorksThenStripDebug) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
CComPtr<IDxcBlob> pProgram;
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("float4 main(float4 pos : SV_Position) : SV_Target {\r\n"
" float4 local = abs(pos);\r\n"
" return local;\r\n"
"}",
&pSource);
LPCWSTR args[] = {L"/Zi", L"/Qembed_debug"};
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", args, _countof(args), nullptr,
0, nullptr, &pResult));
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
// Check if it contains debug blob
hlsl::DxilContainerHeader *pHeader = hlsl::IsDxilContainerLike(
pProgram->GetBufferPointer(), pProgram->GetBufferSize());
VERIFY_SUCCEEDED(
hlsl::IsValidDxilContainer(pHeader, pProgram->GetBufferSize()));
hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
pHeader, hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL);
VERIFY_IS_NOT_NULL(pPartHeader);
// Check debug info part does not exist after strip debug info
CComPtr<IDxcBlob> pNewProgram;
CComPtr<IDxcContainerBuilder> pBuilder;
VERIFY_SUCCEEDED(CreateContainerBuilder(&pBuilder));
VERIFY_SUCCEEDED(pBuilder->Load(pProgram));
VERIFY_SUCCEEDED(
pBuilder->RemovePart(hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL));
pResult.Release();
VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
pHeader = hlsl::IsDxilContainerLike(pNewProgram->GetBufferPointer(),
pNewProgram->GetBufferSize());
VERIFY_SUCCEEDED(
hlsl::IsValidDxilContainer(pHeader, pNewProgram->GetBufferSize()));
pPartHeader = hlsl::GetDxilPartByType(
pHeader, hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL);
VERIFY_IS_NULL(pPartHeader);
}
TEST_F(CompilerTest, CompileWhenWorksThenAddRemovePrivate) {
CComPtr<IDxcCompiler> pCompiler;
CComPtr<IDxcOperationResult> pResult;
CComPtr<IDxcBlobEncoding> pSource;
CComPtr<IDxcBlob> pProgram;
VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
CreateBlobFromText("float4 main() : SV_Target {\r\n"
" return 0;\r\n"
"}",
&pSource);
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
L"ps_6_0", nullptr, 0, nullptr, 0,
nullptr, &pResult));
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
// Append private data blob
CComPtr<IDxcContainerBuilder> pBuilder;
VERIFY_SUCCEEDED(CreateContainerBuilder(&pBuilder));
std::string privateTxt("private data");
CComPtr<IDxcBlobEncoding> pPrivate;
CreateBlobFromText(privateTxt.c_str(), &pPrivate);
VERIFY_SUCCEEDED(pBuilder->Load(pProgram));
VERIFY_SUCCEEDED(
pBuilder->AddPart(hlsl::DxilFourCC::DFCC_PrivateData, pPrivate));
pResult.Release();
VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
CComPtr<IDxcBlob> pNewProgram;
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
hlsl::DxilContainerHeader *pContainerHeader = hlsl::IsDxilContainerLike(
pNewProgram->GetBufferPointer(), pNewProgram->GetBufferSize());