d3dx9: Implement D3DXFloat16to32Array and D3DXFloat32to16Array.

Stefan Dösinger stefandoesinger at gmx.at
Mon Feb 7 17:20:04 CST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Am 07.02.2011 um 23:49 schrieb Misha Koshelev:
I have no full explanation yet, just bits and pieces. By the way, if you haven't done so already I recommend a thorough study of http://en.wikipedia.org/wiki/Floating_point for background knowledge. http://en.wikipedia.org/wiki/IEEE_754-2008 may also be interesting, but I haven't read that wikipedia page so I don't really know what is in it.

> I believe I've found that the threshold value is actually 65520.0 for
> conversions from single to half precision
That makes sense, it is halfway between 65536 and 65604. At this threshold values are rounded up or down

> In any case, I have gotten the half to single precision conversion to
> work in Wine by extending to 16 bits for the exponent (changing < 31
> to < 32).
You may as well replace it with TRUE because the exponent won't be >= 32. Too few bits to express anything bigger than 31.

> However, I am still having trouble with the single to half precision
> and believe I am spinning my wheels a bit at this point.
I'm still trying to make sense of the Windows values :-/

> math.c:2249: Test failed: Got 7800, expected 7bff or 7bff for index 3.
Looks like the exponent is 1 too high and the mantissa zero instead of 1023. Probably a rounding / off by one bug in the code from wined3d. Different behavior wrt what happens when you exactly hit the rounding threshold. (Ie, do you round  an exact 5 up or down(to 0 or 10)?)

> math.c:2249: Test failed: Got ffff, expected fc00 or fce2 for index 8.
> math.c:2249: Test failed: Got ffff, expected fc00 or fc00 for index 12.
> math.c:2249: Test failed: Got ffff, expected fc00 or fc00 for index 13.
> math.c:2249: Test failed: Got ffff, expected fc00 or fc00 for index 14.
> math.c:2249: Test failed: Got ffff, expected fc00 or fc00 for index 15.
This is this statement:
+    if (*in < -65520) return 0xFFFF;
You probably wanted to return fc00 here, if you are trying to emulate case 1. Otherwise remove both CONFUSION HERE statements, change the if(exp > 30) case to exp > 31 and set ret = 0x7fff there. This will give you case 2.

> math.c:2249: Test failed: Got 6400, expected 7fff or 7fff for index 18.
> math.c:2249: Test failed: Got 6400, expected ffff or ffff for index 19.
Hmm, I am afraid you can't remove the check for NaN entirely. If you try to any float operation on NaN undefined things are going to happen(Well, you get NaN, and later try to pick its bits apart)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)

iQIcBAEBAgAGBQJNUH4mAAoJEN0/YqbEcdMwiNcP/R4sa+Z6L39FtN8qE1nX+Pwj
KER3a4MWQ8DWDQgjXR09l3kYua9tM8kH5XmZNNpthH5Uck/CCdFOfCx+j3+CLuJq
nbFkT5kwVA4qzv67o9qJxJhCaL2+9rXtB6ADOSU3QfLYn7L/UXzxwENzxgQlvFG5
+0GzkdlimMGB8+Rj8mYte/ORFEQQnLoCFe3d1UT9RQQhOCqQvlDuaptBWQCiFiAc
GgSQuBzC7YbZxLz8i0EDjfn50X5lW0iVo0p682RJzmod+oCeFztjY/G33wGyA1MA
45Ui6onTYpN1OES1esw/WtePkM8dKrSDlw+gu5rmU9c8JwhPFnNvs/1FUvHD1bGG
WjHkv3hLCf3XVjMk1aT70ItFQ8ph2b6IlU3GOSvQvrYbDB8jfb7lbJnuqzd4hrd4
ycTzAf5YULwuQ5m7Ie5QtWO+hG0iB/I0aqGIAnNj6tSO3b/bfmBlQKAauVnoUnDq
sYgIEmW0GO15Ndsd/ipfbh414qQsNPyGQNdnhivkJK2PrVaiyXb/ztJf/vLDKjEw
cRPoaAfQyIsfPD+cqKq4pnw2rwvr2tkOby11UQ8jfDeaTldp3redf0py0o37CGq1
520QC0CqC/A4MHawwbgcbFTi6XX/DCkHW4IOEirJvnweV8mw8V9IP4XyY/xmYepV
ukB4hwY8XvIe4/Zxj8IP
=bs4K
-----END PGP SIGNATURE-----



More information about the wine-devel mailing list