Skip to content

Commit cf7ddda

Browse files
author
Theresa Foley
authored
Two small fixes. (shader-slang#1928)
* Fix mangling logic for the case where a symbol name contains characters that aren't permitted (this usually occurs when a module name consists of the actual path to the module). There were multiple early-out `if` cases that accidentally fell through to the fallback path, so that symbol names would end up being excessively long. * Fix type conversion cost lookup cache, by allowing single-element vectors (e.g., `vector<float,1>`) and single row/column matrix types to be distinguished from types of lower rank. Previously, `float` and `float1` and `float1x1` would share a single cache entry, even though each (currently) has very different conversion rules.
1 parent caf4642 commit cf7ddda

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

source/slang/slang-check-impl.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ namespace Slang
2323

2424
// A flat representation of basic types (scalars, vectors and matrices)
2525
// that can be used as lookup key in caches
26-
enum class BasicTypeKey : uint8_t
26+
enum class BasicTypeKey : uint16_t
2727
{
28-
Invalid = 0xff, ///< Value that can never be a valid type
28+
Invalid = 0xffff, ///< Value that can never be a valid type
2929
};
3030

31-
SLANG_FORCE_INLINE BasicTypeKey makeBasicTypeKey(BaseType baseType, IntegerLiteralValue dim1 = 1, IntegerLiteralValue dim2 = 1)
31+
SLANG_FORCE_INLINE BasicTypeKey makeBasicTypeKey(BaseType baseType, IntegerLiteralValue dim1 = 0, IntegerLiteralValue dim2 = 0)
3232
{
33-
SLANG_ASSERT(dim1 > 0 && dim2 > 0);
34-
return BasicTypeKey((uint8_t(baseType) << 4) | ((uint8_t(dim1) - 1) << 2) | (uint8_t(dim2) - 1));
33+
SLANG_ASSERT(dim1 >= 0 && dim2 >= 0);
34+
return BasicTypeKey((uint8_t(baseType) << 8) | (uint8_t(dim1) << 4) | uint8_t(dim2));
3535
}
3636

3737
inline BasicTypeKey makeBasicTypeKey(Type* typeIn)

source/slang/slang-mangle.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ namespace Slang
8383
//
8484
for (auto c : str)
8585
{
86-
if (('a' <= c) && (c <= 'z')) { encoded.append(c); }
87-
if (('A' <= c) && (c <= 'Z')) { encoded.append(c); }
88-
if (('0' <= c) && (c <= '9')) { encoded.append(c); }
89-
90-
if (c == '_')
86+
if (('a' <= c) && (c <= 'z')
87+
|| ('A' <= c) && (c <= 'Z')
88+
|| ('0' <= c) && (c <= '9'))
89+
{
90+
encoded.append(c);
91+
}
92+
else if (c == '_')
9193
{
9294
encoded.append("_u");
9395
}

0 commit comments

Comments
 (0)