|
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"
|
@@ -147,8 +148,8 @@ static uint32_t parameterToRangeType(uint32_t Type) {
|
147 | 148 | }
|
148 | 149 |
|
149 | 150 | static RootSignatureBindingValidation
|
150 |
| -initRsBindingValdation(const mcdxbc::RootSignatureDesc &RSD, |
151 |
| - dxbc::ShaderVisibility Visibility) { |
| 151 | +initRSBindingValidation(const mcdxbc::RootSignatureDesc &RSD, |
| 152 | + dxbc::ShaderVisibility Visibility) { |
152 | 153 |
|
153 | 154 | RootSignatureBindingValidation Validation;
|
154 | 155 |
|
@@ -210,15 +211,17 @@ getRootSignature(RootSignatureBindingInfo &RSBI,
|
210 | 211 |
|
211 | 212 | static void reportInvalidRegistersBinding(
|
212 | 213 | Module &M,
|
213 |
| - const std::vector<llvm::dxil::ResourceInfo::ResourceBinding> &Bindings, |
214 |
| - iterator_range<SmallVector<dxil::ResourceInfo>::iterator> &Resources) { |
| 214 | + const llvm::ArrayRef<llvm::dxil::ResourceInfo::ResourceBinding> &Bindings, |
| 215 | + const iterator_range<SmallVectorImpl<dxil::ResourceInfo>::iterator> |
| 216 | + &Resources) { |
215 | 217 | for (auto Res = Resources.begin(), End = Resources.end(); Res != End; Res++) {
|
216 | 218 | bool Bound = false;
|
217 | 219 | ResourceInfo::ResourceBinding ResBinding = Res->getBinding();
|
218 | 220 | for (const auto &Binding : Bindings) {
|
219 | 221 | if (ResBinding.Space == Binding.Space &&
|
220 | 222 | ResBinding.LowerBound >= Binding.LowerBound &&
|
221 |
| - ResBinding.LowerBound + ResBinding.Size - 1 < Binding.LowerBound + Binding.Size) { |
| 223 | + ResBinding.LowerBound + ResBinding.Size - 1 < |
| 224 | + Binding.LowerBound + Binding.Size) { |
222 | 225 | Bound = true;
|
223 | 226 | break;
|
224 | 227 | }
|
@@ -252,22 +255,20 @@ static void reportErrors(Module &M, DXILResourceMap &DRM,
|
252 | 255 | if (auto RSD = getRootSignature(RSBI, MMI)) {
|
253 | 256 |
|
254 | 257 | RootSignatureBindingValidation Validation =
|
255 |
| - initRsBindingValdation(*RSD, tripleToVisibility(MMI.ShaderProfile)); |
256 |
| - |
257 |
| - auto Cbufs = DRM.cbuffers(); |
258 |
| - auto SRVs = DRM.srvs(); |
259 |
| - auto UAVs = DRM.uavs(); |
260 |
| - auto Samplers = DRM.samplers(); |
| 258 | + initRSBindingValidation(*RSD, tripleToVisibility(MMI.ShaderProfile)); |
261 | 259 |
|
262 | 260 | reportInvalidRegistersBinding(
|
263 |
| - M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::CBV), Cbufs); |
| 261 | + M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::CBV), |
| 262 | + DRM.cbuffers()); |
264 | 263 | reportInvalidRegistersBinding(
|
265 |
| - M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::UAV), UAVs); |
| 264 | + M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::UAV), |
| 265 | + DRM.uavs()); |
266 | 266 | reportInvalidRegistersBinding(
|
267 | 267 | M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::Sampler),
|
268 |
| - Samplers); |
| 268 | + DRM.samplers()); |
269 | 269 | reportInvalidRegistersBinding(
|
270 |
| - M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::SRV), SRVs); |
| 270 | + M, Validation.getBindingsOfType(dxbc::DescriptorRangeType::SRV), |
| 271 | + DRM.srvs()); |
271 | 272 | }
|
272 | 273 | }
|
273 | 274 | } // namespace
|
@@ -325,6 +326,7 @@ INITIALIZE_PASS_BEGIN(DXILPostOptimizationValidationLegacy, DEBUG_TYPE,
|
325 | 326 | INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
|
326 | 327 | INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
|
327 | 328 | INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
|
| 329 | +INITIALIZE_PASS_DEPENDENCY(DXILMetadataAnalysisWrapperPass) |
328 | 330 | INITIALIZE_PASS_DEPENDENCY(RootSignatureAnalysisWrapper)
|
329 | 331 | INITIALIZE_PASS_END(DXILPostOptimizationValidationLegacy, DEBUG_TYPE,
|
330 | 332 | "DXIL Post Optimization Validation", false, false)
|
|
0 commit comments