----- Original Message ----- > On Fri, May 18, 2012 at 11:28 AM, Brian Paul < [email protected] > > wrote:
> > On 05/18/2012 10:11 AM, Jose Fonseca wrote: > > > > ----- Original Message ----- > > > > > > > A while back I noticed that the piglit roundmode-pixelstore and > > > > > > > > > > roundmode-getinteger tests pass on my 64-bit Fedora system but > > > > fail > > > > > > > > > > on > > > > > > > > > > a 32-bit Ubuntu system. Both glGetIntegerv() and > > > > glPixelStoref() > > > > > > > > > > use > > > > > > > > > > the IROUND() function to convert floats to ints. > > > > > > > > > > The implementation if IROUND() that uses the x86 fistp > > > > instruction > > > > is > > > > > > > > > > protected with: > > > > > > > > > > #if defined(USE_X86_ASM)&& defined(__GNUC__)&& > > > > defined(__i386__) > > > > > > > > > > but that evaluates to 0 on x86-64 (neither USE_X86_ASM nor > > > > __i386__ > > > > > > > > > > are defined) so we use the C fallback: > > > > > > > > > > #define IROUND(f) ((int) (((f)>= 0.0F) ? ((f) + 0.5F) : ((f) - > > > > > > > > > > 0.5F))) > > > > > > > > > > The C version of IROUND() does what we want for the piglit > > > > tests > > > > but > > > > > > > > > > not the x86 version. I think the default x86 rounding mode is > > > > > > > > > > FE_UPWARD so that explains the failures. > > > > > > > > > > So I think I'd like to do the following: > > > > > > > > > > 1. Enable the x86 fistp-based functions in imports.h for > > > > x86-64. > > > > > > > > > It's illegal/inneficient to use x87 on x86-64. We should use the > > > appropriate SSE intrisinsic instead. > > > > The instruction is "cvtss2si". Yep. Thanks. > Even if you use SSE here, you depend > on the rounding mode in the MXCSR register, which means you'll have > to set that, because some applications change this mode to use a > faster or more precise rounding mode. It's the parallel problem that > you have with "fistp". I think it is unrealistic for application developers to tamper with rounding mode, and expect OpenGL implementations (or any C library for that matter) to be unaffected. Realistically, the only place where this stuff can be safely done is in self-contained application code. Furthermore, it would be a lot of work to reset it all the time, and the result slow. I think there's tones of more important stuff for us to worry about. Jose _______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
