summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-syntax.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index 55ed224cb..bb5b574bb 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -1185,8 +1185,15 @@ bool findVkImageFormatByName(const UnownedStringSlice& name, ImageFormat* outFor
if (name.endsWith(kSNorm))
{
StringBuilder buf;
- // format names end with snormal after a '_', so replace with that
- buf << name.head(name.getLength() - kSNorm.getLength()) << "_" << kSNorm;
+ auto prefix = name.head(name.getLength() - kSNorm.getLength());
+ buf << prefix;
+ // format names end with snormal after a '_', so add an underscore
+ // if the prefix doesn't already end with one
+ if (prefix.getLength() == 0 || prefix[prefix.getLength() - 1] != '_')
+ {
+ buf << "_";
+ }
+ buf << kSNorm;
return findImageFormatByName(buf.getUnownedSlice(), outFormat);
}