Skip to content

Commit 6b7fab5

Browse files
committed
update string matching
1 parent 7962053 commit 6b7fab5

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

tools/clang/lib/SPIRV/AstTypeProbe.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ bool isTexture(QualType type) {
929929
bool isSampledTexture(QualType type) {
930930
if (const auto *rt = type->getAs<RecordType>()) {
931931
const auto name = rt->getDecl()->getName();
932+
if (!name.starts_with("SampledTexture"))
933+
return false;
932934
// TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Add
933935
// other sampled texture types as needed.
934936

@@ -952,6 +954,9 @@ bool isTextureMS(QualType type) {
952954
bool isSampledTextureMS(QualType type) {
953955
if (const auto *rt = type->getAs<RecordType>()) {
954956
const auto name = rt->getDecl()->getName();
957+
if (!name.starts_with("SampledTexture"))
958+
return false;
959+
955960
if (name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray")
956961
return true;
957962
}

tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,7 @@ const SpirvType *LowerTypeVisitor::lowerVkTypeInVkNamespace(
849849
assert(visitedTypeStack.size() == visitedTypeStackSize);
850850
return pointerType;
851851
}
852-
if (name == "SampledTexture1D" || name == "SampledTexture1DArray" ||
853-
name == "SampledTexture2D" || name == "SampledTexture2DArray" ||
854-
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") {
852+
if (name.startswith("SampledTexture")) {
855853
const auto sampledType = hlsl::GetHLSLResourceResultType(type);
856854
auto loweredType = lowerType(getElementType(astContext, sampledType), rule,
857855
/*isRowMajor*/ llvm::None, srcLoc);

0 commit comments

Comments
 (0)