|
18 | 18 | #include "llvm/IR/IntrinsicsDirectX.h"
|
19 | 19 | #include "llvm/IR/Module.h"
|
20 | 20 | #include "llvm/InitializePasses.h"
|
| 21 | +#include "llvm/Support/Casting.h" |
21 | 22 |
|
22 | 23 | #define DEBUG_TYPE "dxil-post-optimization-validation"
|
23 | 24 |
|
@@ -85,6 +86,16 @@ static void reportOverlappingBinding(Module &M, DXILResourceMap &DRM) {
|
85 | 86 | }
|
86 | 87 | }
|
87 | 88 |
|
| 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 | + |
88 | 99 | static void reportRegNotBound(Module &M, Twine Type,
|
89 | 100 | ResourceInfo::ResourceBinding Binding) {
|
90 | 101 | SmallString<128> Message;
|
@@ -155,24 +166,40 @@ static void reportErrors(Module &M, DXILResourceMap &DRM,
|
155 | 166 |
|
156 | 167 | for (const ResourceInfo &CBuf : DRM.cbuffers()) {
|
157 | 168 | ResourceInfo::ResourceBinding Binding = CBuf.getBinding();
|
| 169 | + |
| 170 | + if (auto *TB = dyn_cast<TextureExtType>(CBuf.getHandleTy())) |
| 171 | + reportTextureBoundInRs(M, "cbuffer", Binding); |
| 172 | + |
158 | 173 | if (!Validation.checkCRegBinding(Binding))
|
159 | 174 | reportRegNotBound(M, "cbuffer", Binding);
|
160 | 175 | }
|
161 | 176 |
|
162 | 177 | for (const ResourceInfo &SRV : DRM.srvs()) {
|
163 | 178 | ResourceInfo::ResourceBinding Binding = SRV.getBinding();
|
| 179 | + |
| 180 | + if (auto *TB = dyn_cast<TextureExtType>(SRV.getHandleTy())) |
| 181 | + reportTextureBoundInRs(M, "srv", Binding); |
| 182 | + |
164 | 183 | if (!Validation.checkTRegBinding(Binding))
|
165 | 184 | reportRegNotBound(M, "srv", Binding);
|
166 | 185 | }
|
167 | 186 |
|
168 | 187 | for (const ResourceInfo &UAV : DRM.uavs()) {
|
169 | 188 | ResourceInfo::ResourceBinding Binding = UAV.getBinding();
|
| 189 | + |
| 190 | + if (auto *TB = dyn_cast<TextureExtType>(UAV.getHandleTy())) |
| 191 | + reportTextureBoundInRs(M, "uav", Binding); |
| 192 | + |
170 | 193 | if (!Validation.checkURegBinding(Binding))
|
171 | 194 | reportRegNotBound(M, "uav", Binding);
|
172 | 195 | }
|
173 | 196 |
|
174 | 197 | for (const ResourceInfo &Sampler : DRM.samplers()) {
|
175 | 198 | ResourceInfo::ResourceBinding Binding = Sampler.getBinding();
|
| 199 | + |
| 200 | + if (auto *TB = dyn_cast<TextureExtType>(Sampler.getHandleTy())) |
| 201 | + reportTextureBoundInRs(M, "sampler", Binding); |
| 202 | + |
176 | 203 | if (!Validation.checkSamplerBinding(Binding))
|
177 | 204 | reportRegNotBound(M, "sampler", Binding);
|
178 | 205 | }
|
|
0 commit comments