Skip to content

Commit 01a558b

Browse files
author
joaosaffran
committed
add validation
1 parent e25ee87 commit 01a558b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/IR/IntrinsicsDirectX.h"
1919
#include "llvm/IR/Module.h"
2020
#include "llvm/InitializePasses.h"
21+
#include "llvm/Support/Casting.h"
2122

2223
#define DEBUG_TYPE "dxil-post-optimization-validation"
2324

@@ -85,6 +86,16 @@ static void reportOverlappingBinding(Module &M, DXILResourceMap &DRM) {
8586
}
8687
}
8788

89+
static void reportTextureBoundInRs(Module &M, Twine Type,
90+
ResourceInfo::ResourceBinding Binding) {
91+
SmallString<128> Message;
92+
raw_svector_ostream OS(Message);
93+
OS << "register " << Type << " (space=" << Binding.Space
94+
<< ", register=" << Binding.LowerBound << ")"
95+
<< " is bound to a texture.";
96+
M.getContext().diagnose(DiagnosticInfoGeneric(Message));
97+
}
98+
8899
static void reportRegNotBound(Module &M, Twine Type,
89100
ResourceInfo::ResourceBinding Binding) {
90101
SmallString<128> Message;
@@ -155,24 +166,40 @@ static void reportErrors(Module &M, DXILResourceMap &DRM,
155166

156167
for (const ResourceInfo &CBuf : DRM.cbuffers()) {
157168
ResourceInfo::ResourceBinding Binding = CBuf.getBinding();
169+
170+
if (auto *TB = dyn_cast<TextureExtType>(CBuf.getHandleTy()))
171+
reportTextureBoundInRs(M, "cbuffer", Binding);
172+
158173
if (!Validation.checkCRegBinding(Binding))
159174
reportRegNotBound(M, "cbuffer", Binding);
160175
}
161176

162177
for (const ResourceInfo &SRV : DRM.srvs()) {
163178
ResourceInfo::ResourceBinding Binding = SRV.getBinding();
179+
180+
if (auto *TB = dyn_cast<TextureExtType>(SRV.getHandleTy()))
181+
reportTextureBoundInRs(M, "srv", Binding);
182+
164183
if (!Validation.checkTRegBinding(Binding))
165184
reportRegNotBound(M, "srv", Binding);
166185
}
167186

168187
for (const ResourceInfo &UAV : DRM.uavs()) {
169188
ResourceInfo::ResourceBinding Binding = UAV.getBinding();
189+
190+
if (auto *TB = dyn_cast<TextureExtType>(UAV.getHandleTy()))
191+
reportTextureBoundInRs(M, "uav", Binding);
192+
170193
if (!Validation.checkURegBinding(Binding))
171194
reportRegNotBound(M, "uav", Binding);
172195
}
173196

174197
for (const ResourceInfo &Sampler : DRM.samplers()) {
175198
ResourceInfo::ResourceBinding Binding = Sampler.getBinding();
199+
200+
if (auto *TB = dyn_cast<TextureExtType>(Sampler.getHandleTy()))
201+
reportTextureBoundInRs(M, "sampler", Binding);
202+
176203
if (!Validation.checkSamplerBinding(Binding))
177204
reportRegNotBound(M, "sampler", Binding);
178205
}

0 commit comments

Comments
 (0)