From a7cb36901ccaf8297136c58c1451d6e04420af73 Mon Sep 17 00:00:00 2001 From: aidanfnv Date: Tue, 8 Jul 2025 23:47:08 -0700 Subject: Avoid adding underscore to _snorm format if it has one (#7664) --- source/slang/slang-syntax.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source') 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); } -- cgit v1.2.3