Skip to content

Commit cdc5603

Browse files
authored
[SPIR-V] Add error message for SamplerFeedback (microsoft#6640)
Sampler feedback resource types are not supported by the SPIR-V backend, but they would previously fail silently until a function was called on them. This change makes the error message more explicit on the type. Related to microsoft#6614
1 parent a1b945c commit cdc5603

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,15 @@ SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var) {
12401240
spvContext.registerVkImageFeaturesForSpvVariable(varInstr, vkImgFeatures);
12411241
}
12421242

1243+
if (const auto *recordType = type->getAs<RecordType>()) {
1244+
StringRef typeName = recordType->getDecl()->getName();
1245+
if (typeName.startswith("FeedbackTexture")) {
1246+
emitError("Texture resource type '%0' is not supported with -spirv", loc)
1247+
<< typeName;
1248+
return nullptr;
1249+
}
1250+
}
1251+
12431252
if (hlsl::IsHLSLResourceType(type)) {
12441253
if (!areFormatAndTypeCompatible(vkImgFeatures.format,
12451254
hlsl::GetHLSLResourceResultType(type))) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: not %dxc -DTEST0 -T ps_6_5 -fcgl -spirv %s 2>&1 | FileCheck %s --check-prefix=CHECK0
2+
// RUN: not %dxc -DTEST1 -T ps_6_5 -fcgl -spirv %s 2>&1 | FileCheck %s --check-prefix=CHECK1
3+
// RUN: not %dxc -DTEST2 -T ps_6_5 -fcgl -spirv %s 2>&1 | FileCheck %s --check-prefix=CHECK2
4+
// RUN: not %dxc -DTEST3 -T ps_6_5 -fcgl -spirv %s 2>&1 | FileCheck %s --check-prefix=CHECK3
5+
6+
#ifdef TEST0
7+
// CHECK0: error: Texture resource type 'FeedbackTexture2D' is not supported with -spirv
8+
FeedbackTexture2D<SAMPLER_FEEDBACK_MIN_MIP> feedbackMinMip;
9+
10+
#elif TEST1
11+
// CHECK1: error: Texture resource type 'FeedbackTexture2D' is not supported with -spirv
12+
FeedbackTexture2D<SAMPLER_FEEDBACK_MIP_REGION_USED> feedbackMipRegionUsed;
13+
14+
#elif TEST2
15+
// CHECK2: error: Texture resource type 'FeedbackTexture2DArray' is not supported with -spirv
16+
FeedbackTexture2DArray<SAMPLER_FEEDBACK_MIN_MIP> feedbackMinMipArray;
17+
18+
#elif TEST3
19+
// CHECK3: error: Texture resource type 'FeedbackTexture2DArray' is not supported with -spirv
20+
FeedbackTexture2DArray<SAMPLER_FEEDBACK_MIP_REGION_USED> feebackMipRegionUsedArray;
21+
22+
#endif
23+
24+
float main() : SV_Target
25+
{
26+
return 0;
27+
}

0 commit comments

Comments
 (0)