-
Notifications
You must be signed in to change notification settings - Fork 722
/
Copy pathDxilContainerReflection.cpp
2829 lines (2458 loc) · 104 KB
/
DxilContainerReflection.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
///////////////////////////////////////////////////////////////////////////////
// //
// DxilContainerReflection.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 support for reading DXIL container structures. //
// //
///////////////////////////////////////////////////////////////////////////////
#include "llvm/ADT/STLExtras.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Operator.h"
#include "dxc/DxilContainer/DxilContainer.h"
#include "dxc/DXIL/DxilModule.h"
#include "dxc/DXIL/DxilShaderModel.h"
#include "dxc/DXIL/DxilOperations.h"
#include "dxc/DXIL/DxilInstructions.h"
#include "dxc/Support/Global.h"
#include "dxc/Support/Unicode.h"
#include "dxc/Support/WinIncludes.h"
#include "dxc/Support/microcom.h"
#include "dxc/Support/FileIOHelper.h"
#include "dxc/Support/dxcapi.impl.h"
#include "dxc/DXIL/DxilFunctionProps.h"
#include "dxc/DXIL/DxilPDB.h"
#include "dxc/DXIL/DxilUtil.h"
#include "dxc/HLSL/HLMatrixType.h"
#include "dxc/DXIL/DxilCounters.h"
#include <unordered_set>
#include "llvm/ADT/SetVector.h"
#include "dxc/dxcapi.h"
#ifdef LLVM_ON_WIN32
#include "d3d12shader.h" // for compatibility
#include "d3d11shader.h" // for compatibility
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
// Remove this workaround once newer version of d3dcommon.h can be compiled against
#define ADD_16_64_BIT_TYPES
const GUID IID_ID3D11ShaderReflection_43 = {
0x0a233719,
0x3960,
0x4578,
{0x9d, 0x7c, 0x20, 0x3b, 0x8b, 0x1d, 0x9c, 0xc1}};
const GUID IID_ID3D11ShaderReflection_47 = {
0x8d536ca1,
0x0cca,
0x4956,
{0xa8, 0x37, 0x78, 0x69, 0x63, 0x75, 0x55, 0x84}};
using namespace llvm;
using namespace hlsl;
using namespace hlsl::DXIL;
class DxilContainerReflection : public IDxcContainerReflection {
private:
DXC_MICROCOM_TM_REF_FIELDS()
CComPtr<IDxcBlob> m_container;
const DxilContainerHeader *m_pHeader = nullptr;
uint32_t m_headerLen = 0;
bool IsLoaded() const { return m_pHeader != nullptr; }
public:
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
DXC_MICROCOM_TM_CTOR(DxilContainerReflection)
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
return DoBasicQueryInterface<IDxcContainerReflection>(this, iid, ppvObject);
}
HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) override;
HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) override;
HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) override;
HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) override;
HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) override;
HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, _COM_Outptr_ void **ppvObject) override;
};
class CShaderReflectionConstantBuffer;
class CShaderReflectionType;
enum class PublicAPI { D3D12 = 0, D3D11_47 = 1, D3D11_43 = 2 };
#ifdef ADD_16_64_BIT_TYPES
// Disable warning about value not being valid in enum
#pragma warning( disable : 4063 )
#define D3D_SVT_INT16 ((D3D_SHADER_VARIABLE_TYPE)58)
#define D3D_SVT_UINT16 ((D3D_SHADER_VARIABLE_TYPE)59)
#define D3D_SVT_FLOAT16 ((D3D_SHADER_VARIABLE_TYPE)60)
#define D3D_SVT_INT64 ((D3D_SHADER_VARIABLE_TYPE)61)
#define D3D_SVT_UINT64 ((D3D_SHADER_VARIABLE_TYPE)62)
#endif // ADD_16_64_BIT_TYPES
class DxilModuleReflection {
public:
hlsl::RDAT::DxilRuntimeData m_RDAT;
LLVMContext Context;
std::unique_ptr<Module> m_pModule; // Must come after LLVMContext, otherwise unique_ptr will over-delete.
DxilModule *m_pDxilModule = nullptr;
bool m_bUsageInMetadata = false;
std::vector<std::unique_ptr<CShaderReflectionConstantBuffer>> m_CBs;
std::vector<D3D12_SHADER_INPUT_BIND_DESC> m_Resources;
std::vector<std::unique_ptr<CShaderReflectionType>> m_Types;
// Key strings owned by CShaderReflectionConstantBuffer objects
std::map<StringRef, UINT> m_CBsByName;
// Due to the possibility of overlapping names between CB and other resources,
// m_StructuredBufferCBsByName is the index into m_CBs corresponding to
// StructuredBuffer resources, separately from CB resources.
std::map<StringRef, UINT> m_StructuredBufferCBsByName;
void CreateReflectionObjects();
void CreateReflectionObjectForResource(DxilResourceBase *R);
HRESULT LoadRDAT(const DxilPartHeader *pPart);
HRESULT LoadProgramHeader(const DxilProgramHeader *pProgramHeader);
// Common code
ID3D12ShaderReflectionConstantBuffer* _GetConstantBufferByIndex(UINT Index);
ID3D12ShaderReflectionConstantBuffer* _GetConstantBufferByName(LPCSTR Name);
HRESULT _GetResourceBindingDesc(UINT ResourceIndex,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc,
PublicAPI api = PublicAPI::D3D12);
ID3D12ShaderReflectionVariable* _GetVariableByName(LPCSTR Name);
HRESULT _GetResourceBindingDescByName(LPCSTR Name,
D3D12_SHADER_INPUT_BIND_DESC *pDesc,
PublicAPI api = PublicAPI::D3D12);
};
class DxilShaderReflection : public DxilModuleReflection, public ID3D12ShaderReflection {
private:
DXC_MICROCOM_TM_REF_FIELDS()
std::vector<D3D12_SIGNATURE_PARAMETER_DESC> m_InputSignature;
std::vector<D3D12_SIGNATURE_PARAMETER_DESC> m_OutputSignature;
std::vector<D3D12_SIGNATURE_PARAMETER_DESC> m_PatchConstantSignature;
std::vector<std::unique_ptr<char[]>> m_UpperCaseNames;
D3D12_SHADER_DESC m_Desc = {};
void SetCBufferUsage();
void CreateReflectionObjectsForSignature(
const DxilSignature &Sig,
std::vector<D3D12_SIGNATURE_PARAMETER_DESC> &Descs);
LPCSTR CreateUpperCase(LPCSTR pValue);
void MarkUsedSignatureElements();
void InitDesc();
public:
PublicAPI m_PublicAPI;
void SetPublicAPI(PublicAPI value) { m_PublicAPI = value; }
static PublicAPI IIDToAPI(REFIID iid) {
PublicAPI api = PublicAPI::D3D12;
if (IsEqualIID(IID_ID3D11ShaderReflection_43, iid))
api = PublicAPI::D3D11_43;
else if (IsEqualIID(IID_ID3D11ShaderReflection_47, iid))
api = PublicAPI::D3D11_47;
return api;
}
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
DXC_MICROCOM_TM_CTOR(DxilShaderReflection)
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
HRESULT hr = DoBasicQueryInterface<ID3D12ShaderReflection>(this, iid, ppvObject);
if (hr == E_NOINTERFACE) {
// ID3D11ShaderReflection is identical to ID3D12ShaderReflection, except
// for some shorter data structures in some out parameters.
PublicAPI api = IIDToAPI(iid);
if (api == m_PublicAPI) {
*ppvObject = (ID3D12ShaderReflection *)this;
this->AddRef();
hr = S_OK;
}
}
return hr;
}
HRESULT Load(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart);
// ID3D12ShaderReflection
STDMETHODIMP GetDesc(THIS_ _Out_ D3D12_SHADER_DESC *pDesc);
STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByIndex(THIS_ _In_ UINT Index);
STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByName(THIS_ _In_ LPCSTR Name);
STDMETHODIMP GetResourceBindingDesc(THIS_ _In_ UINT ResourceIndex,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc);
STDMETHODIMP GetInputParameterDesc(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
STDMETHODIMP GetOutputParameterDesc(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
STDMETHODIMP GetPatchConstantParameterDesc(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
STDMETHODIMP_(ID3D12ShaderReflectionVariable*) GetVariableByName(THIS_ _In_ LPCSTR Name);
STDMETHODIMP GetResourceBindingDescByName(THIS_ _In_ LPCSTR Name,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc);
STDMETHODIMP_(UINT) GetMovInstructionCount(THIS);
STDMETHODIMP_(UINT) GetMovcInstructionCount(THIS);
STDMETHODIMP_(UINT) GetConversionInstructionCount(THIS);
STDMETHODIMP_(UINT) GetBitwiseInstructionCount(THIS);
STDMETHODIMP_(D3D_PRIMITIVE) GetGSInputPrimitive(THIS);
STDMETHODIMP_(BOOL) IsSampleFrequencyShader(THIS);
STDMETHODIMP_(UINT) GetNumInterfaceSlots(THIS);
STDMETHODIMP GetMinFeatureLevel(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel);
STDMETHODIMP_(UINT) GetThreadGroupSize(THIS_
_Out_opt_ UINT* pSizeX,
_Out_opt_ UINT* pSizeY,
_Out_opt_ UINT* pSizeZ);
STDMETHODIMP_(UINT64) GetRequiresFlags(THIS);
};
class CFunctionReflection;
class DxilLibraryReflection : public DxilModuleReflection, public ID3D12LibraryReflection {
private:
DXC_MICROCOM_TM_REF_FIELDS()
// Storage, and function by name:
typedef DenseMap<StringRef, std::unique_ptr<CFunctionReflection> > FunctionMap;
typedef DenseMap<const Function*, CFunctionReflection*> FunctionsByPtr;
FunctionMap m_FunctionMap;
FunctionsByPtr m_FunctionsByPtr;
// Enable indexing into functions in deterministic order:
std::vector<CFunctionReflection*> m_FunctionVector;
void AddResourceDependencies();
void SetCBufferUsage();
public:
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
DXC_MICROCOM_TM_CTOR(DxilLibraryReflection)
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
return DoBasicQueryInterface<ID3D12LibraryReflection>(this, iid, ppvObject);
}
HRESULT Load(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart);
// ID3D12LibraryReflection
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc);
STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex);
};
namespace hlsl {
HRESULT CreateDxilShaderReflection(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart, REFIID iid, void **ppvObject) {
if (!ppvObject)
return E_INVALIDARG;
CComPtr<DxilShaderReflection> pReflection = DxilShaderReflection::Alloc(DxcGetThreadMallocNoRef());
IFROOM(pReflection.p);
PublicAPI api = DxilShaderReflection::IIDToAPI(iid);
pReflection->SetPublicAPI(api);
// pRDATPart to be used for transition.
IFR(pReflection->Load(pProgramHeader, pRDATPart));
IFR(pReflection.p->QueryInterface(iid, ppvObject));
return S_OK;
}
HRESULT CreateDxilLibraryReflection(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart, REFIID iid, void **ppvObject) {
if (!ppvObject)
return E_INVALIDARG;
CComPtr<DxilLibraryReflection> pReflection = DxilLibraryReflection::Alloc(DxcGetThreadMallocNoRef());
IFROOM(pReflection.p);
// pRDATPart used for resource usage per-function.
IFR(pReflection->Load(pProgramHeader, pRDATPart));
IFR(pReflection.p->QueryInterface(iid, ppvObject));
return S_OK;
}
HRESULT CreateDxilShaderOrLibraryReflectionFromProgramHeader(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart, REFIID iid, void **ppvObject) {
// Detect whether library, or if unrecognized program version.
DXIL::ShaderKind SK = GetVersionShaderType(pProgramHeader->ProgramVersion);
if (!(SK < DXIL::ShaderKind::Invalid))
return E_INVALIDARG;
bool bIsLibrary = DXIL::ShaderKind::Library == SK;
if (bIsLibrary) {
IFR(hlsl::CreateDxilLibraryReflection(pProgramHeader, pRDATPart, iid, ppvObject));
} else {
IFR(hlsl::CreateDxilShaderReflection(pProgramHeader, pRDATPart, iid, ppvObject));
}
return S_OK;
}
bool IsValidReflectionModulePart(DxilFourCC fourCC) {
return fourCC == DFCC_DXIL || fourCC == DFCC_ShaderDebugInfoDXIL || fourCC == DFCC_ShaderStatistics;
}
HRESULT CreateDxilShaderOrLibraryReflectionFromModulePart(const DxilPartHeader *pModulePart, const DxilPartHeader *pRDATPart, REFIID iid, void **ppvObject) {
if (!pModulePart)
return E_INVALIDARG;
if (!IsValidReflectionModulePart((DxilFourCC)pModulePart->PartFourCC))
return E_INVALIDARG;
const DxilProgramHeader *pProgramHeader =
reinterpret_cast<const DxilProgramHeader*>(GetDxilPartData(pModulePart));
if (!IsValidDxilProgramHeader(pProgramHeader, pModulePart->PartSize))
return E_INVALIDARG;
// If bitcode is too small, it's probably been stripped, and we cannot create reflection with it.
if (pModulePart->PartSize - pProgramHeader->BitcodeHeader.BitcodeOffset < 4)
return DXC_E_MISSING_PART;
return CreateDxilShaderOrLibraryReflectionFromProgramHeader(pProgramHeader, pRDATPart, iid, ppvObject);
}
}
_Use_decl_annotations_
HRESULT DxilContainerReflection::Load(IDxcBlob *pContainer) {
if (pContainer == nullptr) {
m_container.Release();
m_pHeader = nullptr;
m_headerLen = 0;
return S_OK;
}
CComPtr<IDxcBlob> pPDBContainer;
try {
DxcThreadMalloc DxcMalloc(m_pMalloc);
CComPtr<IStream> pStream;
IFR(hlsl::CreateReadOnlyBlobStream(pContainer, &pStream));
if (SUCCEEDED(hlsl::pdb::LoadDataFromStream(m_pMalloc, pStream, &pPDBContainer))) {
pContainer = pPDBContainer;
}
}
CATCH_CPP_RETURN_HRESULT();
uint32_t bufLen = pContainer->GetBufferSize();
const DxilContainerHeader *pHeader =
IsDxilContainerLike(pContainer->GetBufferPointer(), bufLen);
if (pHeader == nullptr) {
return E_INVALIDARG;
}
if (!IsValidDxilContainer(pHeader, bufLen)) {
return E_INVALIDARG;
}
m_container = pContainer;
m_headerLen = bufLen;
m_pHeader = pHeader;
return S_OK;
}
_Use_decl_annotations_
HRESULT DxilContainerReflection::GetPartCount(UINT32 *pResult) {
if (pResult == nullptr) return E_POINTER;
if (!IsLoaded()) return E_NOT_VALID_STATE;
*pResult = m_pHeader->PartCount;
return S_OK;
}
_Use_decl_annotations_
HRESULT DxilContainerReflection::GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) {
if (pResult == nullptr) return E_POINTER;
if (!IsLoaded()) return E_NOT_VALID_STATE;
if (idx >= m_pHeader->PartCount) return E_BOUNDS;
const DxilPartHeader *pPart = GetDxilContainerPart(m_pHeader, idx);
*pResult = pPart->PartFourCC;
return S_OK;
}
_Use_decl_annotations_
HRESULT DxilContainerReflection::GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) {
if (ppResult == nullptr) return E_POINTER;
*ppResult = nullptr;
if (!IsLoaded()) return E_NOT_VALID_STATE;
if (idx >= m_pHeader->PartCount) return E_BOUNDS;
const DxilPartHeader *pPart = GetDxilContainerPart(m_pHeader, idx);
const char *pData = GetDxilPartData(pPart);
uint32_t offset = (uint32_t)(pData - (char*)m_container->GetBufferPointer()); // Offset from the beginning.
uint32_t length = pPart->PartSize;
DxcThreadMalloc TM(m_pMalloc);
return DxcCreateBlobFromBlob(m_container, offset, length, ppResult);
}
_Use_decl_annotations_
HRESULT DxilContainerReflection::FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) {
if (pResult == nullptr) return E_POINTER;
*pResult = 0;
if (!IsLoaded()) return E_NOT_VALID_STATE;
DxilPartIterator it = std::find_if(begin(m_pHeader), end(m_pHeader), DxilPartIsType(kind));
if (it == end(m_pHeader)) return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
*pResult = it.index;
return S_OK;
}
_Use_decl_annotations_
HRESULT DxilContainerReflection::GetPartReflection(UINT32 idx, REFIID iid, void **ppvObject) {
if (ppvObject == nullptr) return E_POINTER;
*ppvObject = nullptr;
if (!IsLoaded()) return E_NOT_VALID_STATE;
if (idx >= m_pHeader->PartCount) return E_BOUNDS;
const DxilPartHeader *pPart = GetDxilContainerPart(m_pHeader, idx);
if (!hlsl::IsValidReflectionModulePart((hlsl::DxilFourCC)pPart->PartFourCC))
return E_NOTIMPL;
// Use DFCC_ShaderStatistics for reflection instead of DXIL part, until switch
// to using RDAT for reflection instead of module.
const DxilPartHeader *pRDATPart = nullptr;
for (idx = 0; idx < m_pHeader->PartCount; ++idx) {
const DxilPartHeader *pPartTest = GetDxilContainerPart(m_pHeader, idx);
if (pPartTest->PartFourCC == DFCC_RuntimeData) {
pRDATPart = pPartTest;
}
if (pPart->PartFourCC != DFCC_ShaderStatistics) {
if (pPartTest->PartFourCC == DFCC_ShaderStatistics) {
const DxilProgramHeader *pProgramHeaderTest =
reinterpret_cast<const DxilProgramHeader*>(GetDxilPartData(pPartTest));
if (IsValidDxilProgramHeader(pProgramHeaderTest, pPartTest->PartSize)) {
pPart = pPartTest;
continue;
}
}
}
}
DxcThreadMalloc TM(m_pMalloc);
HRESULT hr = S_OK;
IFC(hlsl::CreateDxilShaderOrLibraryReflectionFromModulePart(pPart, pRDATPart, iid, ppvObject));
Cleanup:
return hr;
}
void hlsl::CreateDxcContainerReflection(IDxcContainerReflection **ppResult) {
CComPtr<DxilContainerReflection> pReflection = DxilContainerReflection::Alloc(DxcGetThreadMallocNoRef());
*ppResult = pReflection.Detach();
if (*ppResult == nullptr) throw std::bad_alloc();
}
///////////////////////////////////////////////////////////////////////////////
// DxilShaderReflection implementation - helper objects. //
class CShaderReflectionType;
class CShaderReflectionVariable;
class CShaderReflectionConstantBuffer;
class CShaderReflection;
struct D3D11_INTERNALSHADER_RESOURCE_DEF;
class CShaderReflectionType : public ID3D12ShaderReflectionType
{
friend class CShaderReflectionConstantBuffer;
protected:
D3D12_SHADER_TYPE_DESC m_Desc;
UINT m_SizeInCBuffer;
std::string m_Name;
std::vector<StringRef> m_MemberNames;
std::vector<CShaderReflectionType*> m_MemberTypes;
CShaderReflectionType* m_pSubType;
CShaderReflectionType* m_pBaseClass;
std::vector<CShaderReflectionType*> m_Interfaces;
ULONG_PTR m_Identity;
public:
// Internal
HRESULT InitializeEmpty();
HRESULT Initialize(
DxilModule &M,
llvm::Type *type,
DxilFieldAnnotation &typeAnnotation,
unsigned int baseOffset,
std::vector<std::unique_ptr<CShaderReflectionType>>& allTypes,
bool isCBuffer);
// ID3D12ShaderReflectionType
STDMETHOD(GetDesc)(D3D12_SHADER_TYPE_DESC *pDesc);
STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(UINT Index);
STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(LPCSTR Name);
STDMETHOD_(LPCSTR, GetMemberTypeName)(UINT Index);
STDMETHOD(IsEqual)(THIS_ ID3D12ShaderReflectionType* pType);
STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS);
STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS);
STDMETHOD_(UINT, GetNumInterfaces)(THIS);
STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ UINT uIndex);
STDMETHOD(IsOfType)(THIS_ ID3D12ShaderReflectionType* pType);
STDMETHOD(ImplementsInterface)(THIS_ ID3D12ShaderReflectionType* pBase);
bool CheckEqual(_In_ CShaderReflectionType *pOther) {
return m_Identity == pOther->m_Identity;
}
UINT GetCBufferSize() { return m_SizeInCBuffer; }
};
class CShaderReflectionVariable : public ID3D12ShaderReflectionVariable
{
protected:
D3D12_SHADER_VARIABLE_DESC m_Desc;
CShaderReflectionType *m_pType;
CShaderReflectionConstantBuffer *m_pBuffer;
BYTE *m_pDefaultValue;
public:
void Initialize(CShaderReflectionConstantBuffer *pBuffer,
D3D12_SHADER_VARIABLE_DESC *pDesc,
CShaderReflectionType *pType, BYTE *pDefaultValue);
LPCSTR GetName() { return m_Desc.Name; }
// ID3D12ShaderReflectionVariable
STDMETHOD(GetDesc)(D3D12_SHADER_VARIABLE_DESC *pDesc);
STDMETHOD_(ID3D12ShaderReflectionType*, GetType)();
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)();
STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT uArrayIndex);
};
class CShaderReflectionConstantBuffer : public ID3D12ShaderReflectionConstantBuffer
{
protected:
D3D12_SHADER_BUFFER_DESC m_Desc;
std::vector<CShaderReflectionVariable> m_Variables;
// For StructuredBuffer arrays, Name will have [0] appended for each dimension to match fxc behavior.
std::string m_ReflectionName;
public:
CShaderReflectionConstantBuffer() = default;
CShaderReflectionConstantBuffer(CShaderReflectionConstantBuffer &&other) {
m_Desc = other.m_Desc;
std::swap(m_Variables, other.m_Variables);
}
void Initialize(DxilModule &M,
DxilCBuffer &CB,
std::vector<std::unique_ptr<CShaderReflectionType>>& allTypes,
bool bUsageInMetadata);
void InitializeStructuredBuffer(DxilModule &M,
DxilResource &R,
std::vector<std::unique_ptr<CShaderReflectionType>>& allTypes);
void InitializeTBuffer(DxilModule &M,
DxilResource &R,
std::vector<std::unique_ptr<CShaderReflectionType>>& allTypes,
bool bUsageInMetadata);
LPCSTR GetName() { return m_Desc.Name; }
// ID3D12ShaderReflectionConstantBuffer
STDMETHOD(GetDesc)(D3D12_SHADER_BUFFER_DESC *pDesc);
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(UINT Index);
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(LPCSTR Name);
};
// Invalid type sentinel definitions
class CInvalidSRType;
class CInvalidSRVariable;
class CInvalidSRConstantBuffer;
class CInvalidSRLibraryFunction;
class CInvalidSRFunctionParameter;
class CInvalidSRType : public ID3D12ShaderReflectionType {
STDMETHOD(GetDesc)(D3D12_SHADER_TYPE_DESC *pDesc) { return E_FAIL; }
STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(UINT Index);
STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(LPCSTR Name);
STDMETHOD_(LPCSTR, GetMemberTypeName)(UINT Index) { return "$Invalid"; }
STDMETHOD(IsEqual)(THIS_ ID3D12ShaderReflectionType* pType) { return E_FAIL; }
STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS);
STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS);
STDMETHOD_(UINT, GetNumInterfaces)(THIS) { return 0; }
STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ UINT uIndex);
STDMETHOD(IsOfType)(THIS_ ID3D12ShaderReflectionType* pType) { return E_FAIL; }
STDMETHOD(ImplementsInterface)(THIS_ ID3D12ShaderReflectionType* pBase) { return E_FAIL; }
};
static CInvalidSRType g_InvalidSRType;
ID3D12ShaderReflectionType* CInvalidSRType::GetMemberTypeByIndex(UINT) { return &g_InvalidSRType; }
ID3D12ShaderReflectionType* CInvalidSRType::GetMemberTypeByName(LPCSTR) { return &g_InvalidSRType; }
ID3D12ShaderReflectionType* CInvalidSRType::GetSubType() { return &g_InvalidSRType; }
ID3D12ShaderReflectionType* CInvalidSRType::GetBaseClass() { return &g_InvalidSRType; }
ID3D12ShaderReflectionType* CInvalidSRType::GetInterfaceByIndex(UINT) { return &g_InvalidSRType; }
class CInvalidSRVariable : public ID3D12ShaderReflectionVariable {
STDMETHOD(GetDesc)(D3D12_SHADER_VARIABLE_DESC *pDesc) { return E_FAIL; }
STDMETHOD_(ID3D12ShaderReflectionType*, GetType)() { return &g_InvalidSRType; }
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)();
STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT uIndex) { return UINT_MAX; }
};
static CInvalidSRVariable g_InvalidSRVariable;
class CInvalidSRConstantBuffer : public ID3D12ShaderReflectionConstantBuffer {
STDMETHOD(GetDesc)(D3D12_SHADER_BUFFER_DESC *pDesc) { return E_FAIL; }
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(UINT Index) { return &g_InvalidSRVariable; }
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(LPCSTR Name) { return &g_InvalidSRVariable; }
};
static CInvalidSRConstantBuffer g_InvalidSRConstantBuffer;
class CInvalidFunctionParameter : public ID3D12FunctionParameterReflection {
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) { return E_FAIL; }
};
CInvalidFunctionParameter g_InvalidFunctionParameter;
class CInvalidFunction : public ID3D12FunctionReflection {
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) { return E_FAIL; }
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) { return &g_InvalidSRConstantBuffer; }
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) { return &g_InvalidSRConstantBuffer; }
STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
_Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) { return E_FAIL; }
STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) { return nullptr; }
STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
_Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) { return E_FAIL; }
// Use D3D_RETURN_PARAMETER_INDEX to get description of the return value.
STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) { return &g_InvalidFunctionParameter; }
};
CInvalidFunction g_InvalidFunction;
void CShaderReflectionVariable::Initialize(
CShaderReflectionConstantBuffer *pBuffer, D3D12_SHADER_VARIABLE_DESC *pDesc,
CShaderReflectionType *pType, BYTE *pDefaultValue) {
m_pBuffer = pBuffer;
memcpy(&m_Desc, pDesc, sizeof(m_Desc));
m_pType = pType;
m_pDefaultValue = pDefaultValue;
}
HRESULT CShaderReflectionVariable::GetDesc(D3D12_SHADER_VARIABLE_DESC *pDesc) {
if (!pDesc) return E_POINTER;
memcpy(pDesc, &m_Desc, sizeof(m_Desc));
return S_OK;
}
ID3D12ShaderReflectionType *CShaderReflectionVariable::GetType() {
return m_pType;
}
ID3D12ShaderReflectionConstantBuffer *CShaderReflectionVariable::GetBuffer() {
return m_pBuffer;
}
UINT CShaderReflectionVariable::GetInterfaceSlot(UINT uArrayIndex) {
return UINT_MAX;
}
ID3D12ShaderReflectionConstantBuffer *CInvalidSRVariable::GetBuffer() {
return &g_InvalidSRConstantBuffer;
}
STDMETHODIMP CShaderReflectionType::GetDesc(D3D12_SHADER_TYPE_DESC *pDesc)
{
if (!pDesc) return E_POINTER;
memcpy(pDesc, &m_Desc, sizeof(m_Desc));
return S_OK;
}
STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetMemberTypeByIndex(UINT Index)
{
if (Index >= m_MemberTypes.size()) {
return &g_InvalidSRType;
}
return m_MemberTypes[Index];
}
STDMETHODIMP_(LPCSTR) CShaderReflectionType::GetMemberTypeName(UINT Index)
{
if (Index >= m_MemberTypes.size()) {
return nullptr;
}
return (LPCSTR) m_MemberNames[Index].bytes_begin();
}
STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetMemberTypeByName(LPCSTR Name)
{
UINT memberCount = m_Desc.Members;
for( UINT mm = 0; mm < memberCount; ++mm ) {
if( m_MemberNames[mm] == Name ) {
return m_MemberTypes[mm];
}
}
return nullptr;
}
STDMETHODIMP CShaderReflectionType::IsEqual(THIS_ ID3D12ShaderReflectionType* pType)
{
// TODO: implement this check, if users actually depend on it
return S_FALSE;
}
STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetSubType(THIS)
{
// TODO: implement `class`-related features, if requested
return nullptr;
}
STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetBaseClass(THIS)
{
// TODO: implement `class`-related features, if requested
return nullptr;
}
STDMETHODIMP_(UINT) CShaderReflectionType::GetNumInterfaces(THIS)
{
// HLSL interfaces have been deprecated
return 0;
}
STDMETHODIMP_(ID3D12ShaderReflectionType*) CShaderReflectionType::GetInterfaceByIndex(THIS_ UINT uIndex)
{
// HLSL interfaces have been deprecated
return nullptr;
}
STDMETHODIMP CShaderReflectionType::IsOfType(THIS_ ID3D12ShaderReflectionType* pType)
{
// TODO: implement `class`-related features, if requested
return S_FALSE;
}
STDMETHODIMP CShaderReflectionType::ImplementsInterface(THIS_ ID3D12ShaderReflectionType* pBase)
{
// HLSL interfaces have been deprecated
return S_FALSE;
}
// Helper routine for types that don't have an obvious mapping
// to the existing shader reflection interface.
static bool ProcessUnhandledObjectType(
llvm::StructType *structType,
D3D_SHADER_VARIABLE_TYPE *outObjectType)
{
// Don't actually make this a hard error, but instead report the problem using a suitable debug message.
#ifndef NDEBUG
OutputDebugFormatA("DxilContainerReflection.cpp: error: unhandled object type '%s'.\n", structType->getName().str().c_str());
#endif
*outObjectType = D3D_SVT_VOID;
return true;
}
// Helper routine to try to detect if a type represents an HLSL "object" type
// (a texture, sampler, buffer, etc.), and to extract the coresponding shader
// reflection type.
static bool TryToDetectObjectType(
llvm::StructType *structType,
D3D_SHADER_VARIABLE_TYPE *outObjectType)
{
// Note: This logic is largely duplicated from `dxilutil::IsHLSLObjectType`
// with the addition of returning the appropriate reflection type tag.
//
// That logic looks error-prone, since it relies on string tests against
// type names, including cases that just test against a prefix.
// This code doesn't try to be any more robust.
StringRef name = structType->getName();
if(name.startswith("dx.types.wave_t") )
{
return ProcessUnhandledObjectType(structType, outObjectType);
}
// Strip off some prefixes we are likely to see.
name = name.ltrim("class.");
name = name.ltrim("struct.");
// Slice types occur as intermediates (they aren not objects)
if(name.endswith("_slice_type")) { return false; }
// We might check for an exact name match, or a prefix match
#define EXACT_MATCH(NAME, TAG) \
else if(name == #NAME) do { *outObjectType = TAG; return true; } while(0)
#define PREFIX_MATCH(NAME, TAG) \
else if(name.startswith(#NAME)) do { *outObjectType = TAG; return true; } while(0)
if(0) {}
EXACT_MATCH(SamplerState, D3D_SVT_SAMPLER);
EXACT_MATCH(SamplerComparisonState, D3D_SVT_SAMPLER);
// Note: GS output stream types are supported in the reflection interface.
else if(name.startswith("TriangleStream")) { return ProcessUnhandledObjectType(structType, outObjectType); }
else if(name.startswith("PointStream")) { return ProcessUnhandledObjectType(structType, outObjectType); }
else if(name.startswith("LineStream")) { return ProcessUnhandledObjectType(structType, outObjectType); }
PREFIX_MATCH(AppendStructuredBuffer, D3D_SVT_APPEND_STRUCTURED_BUFFER);
PREFIX_MATCH(ConsumeStructuredBuffer, D3D_SVT_CONSUME_STRUCTURED_BUFFER);
PREFIX_MATCH(ConstantBuffer, D3D_SVT_CBUFFER);
// Note: the `HLModule` code does this trick to avoid checking more names
// than it has to, but it doesn't seem 100% correct to do this.
// TODO: consider just listing the `RasterizerOrdered` cases explicitly,
// just as we do for the `RW` cases already.
name = name.ltrim("RasterizerOrdered");
if(0) {}
EXACT_MATCH(ByteAddressBuffer, D3D_SVT_BYTEADDRESS_BUFFER);
EXACT_MATCH(RWByteAddressBuffer, D3D_SVT_RWBYTEADDRESS_BUFFER);
PREFIX_MATCH(Buffer, D3D_SVT_BUFFER);
PREFIX_MATCH(RWBuffer, D3D_SVT_RWBUFFER);
PREFIX_MATCH(StructuredBuffer, D3D_SVT_STRUCTURED_BUFFER);
PREFIX_MATCH(RWStructuredBuffer, D3D_SVT_RWSTRUCTURED_BUFFER);
PREFIX_MATCH(Texture1D, D3D_SVT_TEXTURE1D);
PREFIX_MATCH(RWTexture1D, D3D_SVT_RWTEXTURE1D);
PREFIX_MATCH(Texture1DArray, D3D_SVT_TEXTURE1DARRAY);
PREFIX_MATCH(RWTexture1DArray, D3D_SVT_RWTEXTURE1DARRAY);
PREFIX_MATCH(Texture2D, D3D_SVT_TEXTURE2D);
PREFIX_MATCH(RWTexture2D, D3D_SVT_RWTEXTURE2D);
PREFIX_MATCH(Texture2DArray, D3D_SVT_TEXTURE2DARRAY);
PREFIX_MATCH(RWTexture2DArray, D3D_SVT_RWTEXTURE2DARRAY);
PREFIX_MATCH(Texture3D, D3D_SVT_TEXTURE3D);
PREFIX_MATCH(RWTexture3D, D3D_SVT_RWTEXTURE3D);
PREFIX_MATCH(TextureCube, D3D_SVT_TEXTURECUBE);
PREFIX_MATCH(TextureCubeArray, D3D_SVT_TEXTURECUBEARRAY);
PREFIX_MATCH(Texture2DMS, D3D_SVT_TEXTURE2DMS);
PREFIX_MATCH(Texture2DMSArray, D3D_SVT_TEXTURE2DMSARRAY);
#undef EXACT_MATCH
#undef PREFIX_MATCH
// Default: not an object type
return false;
}
// Helper to determine if an LLVM type represents an HLSL
// object type (uses the `TryToDetectObjectType()` function
// defined previously).
static bool IsObjectType(
llvm::Type* inType)
{
llvm::Type* type = inType;
while(type->isArrayTy())
{
type = type->getArrayElementType();
}
llvm::StructType* structType = dyn_cast<StructType>(type);
if(!structType)
return false;
D3D_SHADER_VARIABLE_TYPE ignored;
return TryToDetectObjectType(structType, &ignored);
}
HRESULT CShaderReflectionType::InitializeEmpty()
{
ZeroMemory(&m_Desc, sizeof(m_Desc));
return S_OK;
}
// Main logic for translating an LLVM type and associated
// annotations into a D3D shader reflection type.
HRESULT CShaderReflectionType::Initialize(
DxilModule &M,
llvm::Type *inType,
DxilFieldAnnotation &typeAnnotation,
unsigned int baseOffset,
std::vector<std::unique_ptr<CShaderReflectionType>>& allTypes,
bool isCBuffer)
{
DXASSERT_NOMSG(inType);
// Set a bunch of fields to default values, to avoid duplication.
m_Desc.Rows = 0;
m_Desc.Columns = 0;
m_Desc.Elements = 0;
m_Desc.Members = 0;
m_SizeInCBuffer = 0;
// Used for calculating size later
unsigned cbRows = 1;
unsigned cbCols = 1;
unsigned cbCompSize = 4; // or 8 for 64-bit types.
unsigned cbRowStride = 16; // or 32 if 64-bit and cols > 2.
if (isCBuffer) {
// Extract offset relative to parent.
// Note: the `baseOffset` is used in the case where the type in
// question is a field in a constant buffer, since then both the
// field and the variable store the same offset information, and
// we need to zero out the value in the type to avoid the user
// of the reflection interface seeing 2x the correct value.
m_Desc.Offset = typeAnnotation.GetCBufferOffset() - baseOffset;
} else {
m_Desc.Offset = baseOffset;
}
// Arrays don't seem to be represented directly in the reflection
// data, but only as the `Elements` field being non-zero.
// We "unwrap" any array type here, and then proceed to look
// at the element type.
llvm::Type* type = inType;
while(type->isArrayTy())
{
llvm::Type* elementType = type->getArrayElementType();
// Note: At this point an HLSL matrix type may appear as an ordinary
// array (not wrapped in a `struct`), so `dxilutil::IsHLSLMatrixType()`
// is not sufficient. Instead we need to check the field annotation.
//
// We might have an array of matrices, though, so we only exit if
// the field annotation says we have a matrix, and we've bottomed
// out at one array level, since matrix will be in the format:
// [rows x <cols x float>]
//
// This is in storage orientation, so rows/cols are swapped
// when the matrix is column_major.
//
// However, when the matrix has a row size of 1 in storage orientation,
// this array dimension appears to be missing.
// To properly count the array dimensions for this case,
// we must not break out of the loop one array early when rows == 1.
if(typeAnnotation.HasMatrixAnnotation() && !elementType->isArrayTy() &&
!HLMatrixType::isa(elementType)){
const DxilMatrixAnnotation &mat = typeAnnotation.GetMatrixAnnotation();
unsigned rows = mat.Orientation == MatrixOrientation::RowMajor ?
mat.Rows : mat.Cols;
// when rows == 1, in storage orientation, the row array is missing.
if (rows > 1)
break;
}
// Non-array types should have `Elements` be zero, so as soon as we
// find that we have our first real array (not a matrix), we initialize `Elements`
if(!m_Desc.Elements) m_Desc.Elements = 1;
// It isn't clear what is the desired behavior for multi-dimensional arrays,
// but for now we do the expedient thing of multiplying out all their
// dimensions.
m_Desc.Elements *= type->getArrayNumElements();
type = elementType;
}
// Default to a scalar type, just to avoid some duplication later.
m_Desc.Class = D3D_SVC_SCALAR;
// Look at the annotation to try to determine the basic type of value.
//
// Note that DXIL supports some types that don't currently have equivalents
// in the reflection interface, so we try to muddle through here.
bool bMinPrec = M.GetUseMinPrecision();
D3D_SHADER_VARIABLE_TYPE componentType = D3D_SVT_VOID;
switch(typeAnnotation.GetCompType().GetKind())
{
case hlsl::DXIL::ComponentType::Invalid:
break;
case hlsl::DXIL::ComponentType::I1:
componentType = D3D_SVT_BOOL;
m_Name = "bool";
break;
case hlsl::DXIL::ComponentType::I16:
if (bMinPrec) {
componentType = D3D_SVT_MIN16INT;
m_Name = "min16int";
} else {
componentType = D3D_SVT_INT16;
m_Name = "int16_t";
cbCompSize = 2;
}
break;
case hlsl::DXIL::ComponentType::U16:
if (bMinPrec) {
componentType = D3D_SVT_MIN16UINT;
m_Name = "min16uint";
} else {
componentType = D3D_SVT_UINT16;
m_Name = "uint16_t";
cbCompSize = 2;
}
break;
case hlsl::DXIL::ComponentType::I64:
componentType = D3D_SVT_INT64;
m_Name = "int64_t";
cbCompSize = 8;
break;
case hlsl::DXIL::ComponentType::I32:
componentType = D3D_SVT_INT;
m_Name = "int";
break;
case hlsl::DXIL::ComponentType::U64:
componentType = D3D_SVT_UINT64;
m_Name = "uint64_t";