diff options
| author | aidanfnv <aidanf@nvidia.com> | 2025-07-08 23:47:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-09 06:47:08 +0000 |
| commit | a7cb36901ccaf8297136c58c1451d6e04420af73 (patch) | |
| tree | eb5bfb53e3a0e9a0bf20c03b2b200809637d1d13 /source | |
| parent | 43d0c2100ef1a5df4b54525e50eb29fe7c39ec16 (diff) | |
Avoid adding underscore to _snorm format if it has one (#7664)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-syntax.cpp | 11 |
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); } |
