Hello.
I have a problem with extract _bits()
in Metal shader returning wrong result in some cases. Here is one specific case: float variable gets its value from device memory, and extracting bits from this variable only returns correct data for the first 4 bits - the rest is either invalid or mostly returns zeroes.
To verify extract_bits()
usage I have hardcoded that float value in another variable in the same shader - in that case extract_bits()
returns correct values.
A few screenshots from shader debugger to illustrate.
Here paramsFloat
is read from device memory and equals 0.6549019814. It gets converted to uint packedParams
which is used to extract bits from it after that. Variables bits_*
are here to show that extract_bits()
gives incorrect result.
hardcodedParamsFloat
has the same value 0.6549019814. It also gets converted into uint and hardcoded_bits_*
variables are here to show that in this case, for the same value (but hardcoded instead of read from device memory) extract_bits()
gives correct results.
It all happens in a vertex shader:
With GrassPositions
being a simple struct:
That looks like a bug somewhere deep inside driver r Metal... Or do I miss something obvious?
It seems that this issue is present on MacBook Pros with AMD GPUs. OS is at the latest update 12.2.1.
Thank you!