d3dx9: Implement D3DXFloat16to32Array and D3DXFloat32to16Array.

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

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)

Version: GnuPG/MacGPG2 v2.0.17 (Darwin)


More information about the wine-devel mailing list