10
10
#include " DXILShaderFlags.h"
11
11
#include " DirectX.h"
12
12
#include " llvm/ADT/SmallString.h"
13
+ #include " llvm/ADT/SmallVector.h"
13
14
#include " llvm/Analysis/DXILMetadataAnalysis.h"
14
15
#include " llvm/Analysis/DXILResource.h"
15
16
#include " llvm/IR/DiagnosticInfo.h"
@@ -136,8 +137,8 @@ static uint32_t parameterToRangeType(uint32_t Type) {
136
137
}
137
138
138
139
static RootSignatureBindingValidation
139
- initRsBindingValdation (const mcdxbc::RootSignatureDesc &RSD,
140
- dxbc::ShaderVisibility Visibility) {
140
+ initRSBindingValidation (const mcdxbc::RootSignatureDesc &RSD,
141
+ dxbc::ShaderVisibility Visibility) {
141
142
142
143
RootSignatureBindingValidation Validation;
143
144
@@ -199,15 +200,17 @@ getRootSignature(RootSignatureBindingInfo &RSBI,
199
200
200
201
static void reportUnboundRegisters (
201
202
Module &M,
202
- const std::vector<llvm::dxil::ResourceInfo::ResourceBinding> &Bindings,
203
- iterator_range<SmallVector<dxil::ResourceInfo>::iterator> &Resources) {
203
+ const llvm::ArrayRef<llvm::dxil::ResourceInfo::ResourceBinding> &Bindings,
204
+ const iterator_range<SmallVectorImpl<dxil::ResourceInfo>::iterator>
205
+ &Resources) {
204
206
for (auto Res = Resources.begin (), End = Resources.end (); Res != End; Res++) {
205
207
bool Bound = false ;
206
208
ResourceInfo::ResourceBinding ResBinding = Res->getBinding ();
207
209
for (const auto &Binding : Bindings) {
208
210
if (ResBinding.Space == Binding.Space &&
209
211
ResBinding.LowerBound >= Binding.LowerBound &&
210
- ResBinding.LowerBound < Binding.LowerBound + Binding.Size ) {
212
+ ResBinding.LowerBound + ResBinding.Size - 1 <
213
+ Binding.LowerBound + Binding.Size ) {
211
214
Bound = true ;
212
215
break ;
213
216
}
@@ -234,22 +237,20 @@ static void reportErrors(Module &M, DXILResourceMap &DRM,
234
237
if (auto RSD = getRootSignature (RSBI, MMI)) {
235
238
236
239
RootSignatureBindingValidation Validation =
237
- initRsBindingValdation (*RSD, tripleToVisibility (MMI.ShaderProfile ));
238
-
239
- auto Cbufs = DRM.cbuffers ();
240
- auto SRVs = DRM.srvs ();
241
- auto UAVs = DRM.uavs ();
242
- auto Samplers = DRM.samplers ();
240
+ initRSBindingValidation (*RSD, tripleToVisibility (MMI.ShaderProfile ));
243
241
244
242
reportUnboundRegisters (
245
- M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::CBV), Cbufs);
243
+ M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::CBV),
244
+ DRM.cbuffers ());
246
245
reportUnboundRegisters (
247
- M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::UAV), UAVs);
246
+ M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::UAV),
247
+ DRM.uavs ());
248
248
reportUnboundRegisters (
249
249
M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::Sampler),
250
- Samplers );
250
+ DRM. samplers () );
251
251
reportUnboundRegisters (
252
- M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::SRV), SRVs);
252
+ M, Validation.getBindingsOfType (dxbc::DescriptorRangeType::SRV),
253
+ DRM.srvs ());
253
254
}
254
255
}
255
256
} // namespace
@@ -307,6 +308,7 @@ INITIALIZE_PASS_BEGIN(DXILPostOptimizationValidationLegacy, DEBUG_TYPE,
307
308
INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
308
309
INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
309
310
INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
311
+ INITIALIZE_PASS_DEPENDENCY(DXILMetadataAnalysisWrapperPass)
310
312
INITIALIZE_PASS_DEPENDENCY(RootSignatureAnalysisWrapper)
311
313
INITIALIZE_PASS_END(DXILPostOptimizationValidationLegacy, DEBUG_TYPE,
312
314
" DXIL Post Optimization Validation" , false , false )
0 commit comments