From cc93e2c3523f558ee85281f7fe98e220f058f5ed Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 09:29:23 -0700 Subject: Fix constructor overload ambiguity with scalar and vector parameters (#8109) Close #8090. When we do type coerce, we use a cache to store the conversion cost of different type. The key of the cache is defined by struct BasicTypeKey { uint32_t baseType : 8; uint32_t dim1 : 4; uint32_t dim2 : 4; ... } where dim1 and dim2 is used for dimension of vector and matrix. However the dim is only 4 bits, so `vector` will have the same key as `int`, which is wrong. Fix the issue by extending it to 8 bit. Also to make the hash key still within 32 bits, we adjust baseType to 5 bits, and knownConstantBitCount to 6 bits. --------- Co-authored-by: kaizhangNV --- source/slang/slang-check-impl.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h index d08cae66f..523041697 100644 --- a/source/slang/slang-check-impl.h +++ b/source/slang/slang-check-impl.h @@ -70,13 +70,13 @@ int getTypeBitSize(Type* t); // that can be used as lookup key in caches struct BasicTypeKey { - uint32_t baseType : 8; - uint32_t dim1 : 4; - uint32_t dim2 : 4; - uint32_t knownConstantBitCount : 8; + uint32_t baseType : 5; + uint32_t dim1 : 8; + uint32_t dim2 : 8; + uint32_t knownConstantBitCount : 6; uint32_t knownNegative : 1; uint32_t isLValue : 1; - uint32_t reserved : 6; + uint32_t reserved : 3; uint32_t getRaw() const { uint32_t val; @@ -84,7 +84,7 @@ struct BasicTypeKey return val; } bool operator==(BasicTypeKey other) const { return getRaw() == other.getRaw(); } - static BasicTypeKey invalid() { return BasicTypeKey{0xff, 0, 0, 0, 0, 0, 0}; } + static BasicTypeKey invalid() { return BasicTypeKey{0x1f, 0, 0, 0, 0, 0, 0}; } }; SLANG_FORCE_INLINE BasicTypeKey makeBasicTypeKey( -- cgit v1.2.3