Open manon-traverse opened 1 year ago
FindUMsb
and a few similar GLSL derived instructions do not support 64bit (see https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html). glslang has (or had) similar issues. I think Khronos should extend the instructions to support 64bit and in the meantime DXC should apply your workaround.
DXC now emits an appropriate error message when firstbithigh
is used on a uint64_t
. Eventually we should support this, but it's not currently a priority to implement so the workaround in HLSL should be used until then.
int firstbithigh64(uint64_t v) {
int high = firstbithigh(uint(v >> 32));
if (high != -1) {
return high + 32;
}
return firstbithigh(uint(v));
}
The fix b7a50ba introduced a new issue at astContext.getTypeSize(argType) == 64 when used on int2
types. This reproduces the issue (see godbolt.org):
// -T vs_6_0 -E VSMain -spirv
int2 Foo;
void VSMain() {
firstbithigh(Foo);
}
Thanks for catching that @LukasBanana! Submitting a fix now.
Calling this function causes the error when targeting SPIR-V. It works fine when targeting DXIL.
It does work with the following workaround: