2009/3/11 Matthias Hopf
On Mar 11, 09 08:31:13 -0700, Yang Zhao wrote:
Ack, I *just* noticed that the specification actually calls for S3.1 fixed-point float instead of signed int(5)... ... Suggestions on the sanest way to handle this?
Using a float input - and AFAIR S3.1 means sign + magnitude:
#define ABS(x) ((x) < 0 ? -(x) : (x)) #define OFFSET_X(x) (((x) < 0 ? 0x10 : 0) | ((ABS(x)*2) & 0x0f)) /* S3.1 fix point */
I think what we want is shifted two's complement, since the expected range is [-8, 8), which, with just 1 bit to the right of decimal point, gives [-8.0, 7.5] in 0.5 increments. So, #define OFFSET_X(x) ((int)((x) * 2) & 0x1f) /* S3.1 fixed point, two's complement*/ The small test code I wrote seems to be behaving sanely for the values that are exactly representable, and rounding towards 0 for those that aren't. I'll verify that this behaves as expected on the shader hardware sometime later today. Cheers, -- Yang Zhao http://yangman.ca -- To unsubscribe, e-mail: radeonhd+unsubscribe@opensuse.org For additional commands, e-mail: radeonhd+help@opensuse.org