See this Tint bug. Basically, in HLSL, countbits and reversebits only accept and return uint - there are no int overloads. As a result, when the result of one of these calls was passed to a function that does have overloads, it would always call the uint overload.
For example, in WGSL, min(countOneBits(0), -1) should return -1, but was returning 0 because countOneBits (HLSL countbits)'s return type would be u32.
Similarly, min(reverseBits(-1), 0) should return -1, but was also returning 0 because reverseBits (HLSL reversebits)'s return type would be u32.
We need a couple of regression unit tests for these two cases. I quickly added two tests in countOneBits.spec.ts and reverseBits.spec.ts, but these are in the wrong place, and probably not how we want to write them. However, here they are as a guide:
See this Tint bug. Basically, in HLSL,
countbits
andreversebits
only accept and returnuint
- there are noint
overloads. As a result, when the result of one of these calls was passed to a function that does have overloads, it would always call theuint
overload.For example, in WGSL,
min(countOneBits(0), -1)
should return-1
, but was returning0
becausecountOneBits
(HLSLcountbits
)'s return type would be u32.Similarly,
min(reverseBits(-1), 0)
should return-1
, but was also returning0
becausereverseBits
(HLSLreversebits
)'s return type would be u32.We need a couple of regression unit tests for these two cases. I quickly added two tests in
countOneBits.spec.ts
andreverseBits.spec.ts
, but these are in the wrong place, and probably not how we want to write them. However, here they are as a guide:and