10
10
#include " DXILRootSignature.h"
11
11
#include " DXILShaderFlags.h"
12
12
#include " DirectX.h"
13
+ #include " llvm/ADT/IntervalMap.h"
13
14
#include " llvm/ADT/STLForwardCompat.h"
14
15
#include " llvm/ADT/SmallString.h"
15
16
#include " llvm/Analysis/DXILMetadataAnalysis.h"
@@ -86,7 +87,9 @@ static void reportOverlappingBinding(Module &M, DXILResourceMap &DRM) {
86
87
}
87
88
}
88
89
}
89
-
90
+ uint64_t combine_uint32_to_uint64 (uint32_t high, uint32_t low) {
91
+ return (static_cast <uint64_t >(high) << 32 ) | low;
92
+ }
90
93
static void reportErrors (Module &M, DXILResourceMap &DRM,
91
94
DXILResourceBindingInfo &DRBI,
92
95
RootSignatureBindingInfo &RSBI,
@@ -101,27 +104,52 @@ static void reportErrors(Module &M, DXILResourceMap &DRM,
101
104
" DXILResourceImplicitBinding pass" );
102
105
// Assuming this is used to validate only the root signature assigned to the
103
106
// entry function.
107
+ // Start test stuff
108
+ if (MMI.EntryPropertyVec .size () == 0 )
109
+ return ;
110
+
104
111
std::optional<mcdxbc::RootSignatureDesc> RootSigDesc =
105
112
RSBI.getDescForFunction (MMI.EntryPropertyVec [0 ].Entry );
106
113
if (!RootSigDesc)
107
114
return ;
108
115
109
- for (const mcdxbc::RootParameterInfo &Info :
110
- RootSigDesc->ParametersContainer ) {
116
+ using MapT = llvm::IntervalMap<uint64_t , llvm::dxil::ResourceInfo::ResourceBinding, sizeof (llvm::dxil::ResourceInfo::ResourceBinding), llvm::IntervalMapInfo<uint64_t >>;
117
+ MapT::Allocator Allocator;
118
+ MapT BindingsMap (Allocator);
119
+ auto RSD = *RootSigDesc;
120
+ for (size_t I = 0 ; I < RSD.ParametersContainer .size (); I++) {
111
121
const auto &[Type, Loc] =
112
- RootSigDesc->ParametersContainer .getTypeAndLocForParameter (
113
- Info.Location );
122
+ RootSigDesc->ParametersContainer .getTypeAndLocForParameter (I);
114
123
switch (Type) {
115
- case llvm::to_underlying (dxbc::RootParameterType::CBV):
124
+ case llvm::to_underlying (dxbc::RootParameterType::CBV):{
116
125
dxbc::RTS0::v2::RootDescriptor Desc =
117
126
RootSigDesc->ParametersContainer .getRootDescriptor (Loc);
118
127
119
128
llvm::dxil::ResourceInfo::ResourceBinding Binding;
120
129
Binding.LowerBound = Desc.ShaderRegister ;
121
130
Binding.Space = Desc.RegisterSpace ;
122
131
Binding.Size = 1 ;
132
+
133
+ BindingsMap.insert (combine_uint32_to_uint64 (Binding.Space , Binding.LowerBound ), combine_uint32_to_uint64 (Binding.Space , Binding.LowerBound + Binding.Size -1 ), Binding);
123
134
break ;
124
135
}
136
+ // case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):{
137
+ // mcdxbc::DescriptorTable Table =
138
+ // RootSigDesc->ParametersContainer.getDescriptorTable(Loc);
139
+ // for (const dxbc::RTS0::v2::DescriptorRange &Range : Table){
140
+ // Range.
141
+ // }
142
+
143
+ // break;
144
+ // }
145
+ }
146
+
147
+ }
148
+
149
+ for (const auto &CBuf : DRM.cbuffers ()) {
150
+ auto Binding = CBuf.getBinding ();
151
+ if (!BindingsMap.overlaps (combine_uint32_to_uint64 (Binding.Space , Binding.LowerBound ), combine_uint32_to_uint64 (Binding.Space , Binding.LowerBound + Binding.Size -1 )))
152
+ auto X = 1 ;
125
153
}
126
154
}
127
155
} // namespace
@@ -146,7 +174,7 @@ class DXILPostOptimizationValidationLegacy : public ModulePass {
146
174
DXILResourceBindingInfo &DRBI =
147
175
getAnalysis<DXILResourceBindingWrapperPass>().getBindingInfo ();
148
176
149
- RootSignatureBindingInfo & RSBI =
177
+ RootSignatureBindingInfo& RSBI =
150
178
getAnalysis<RootSignatureAnalysisWrapper>().getRSInfo ();
151
179
dxil::ModuleMetadataInfo &MMI =
152
180
getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata ();
0 commit comments