[Mesa-dev] [PATCH 08/16] st/nine: Change x86 FPU Control word on device creation as on wined3d and windows
Roland Scheidegger
sroland at vmware.com
Sat Apr 25 07:28:17 PDT 2015
Am 25.04.2015 um 09:58 schrieb Axel Davy:
> Le 24/04/2015 23:42, Henri Verbeet a écrit :
>> On 24 April 2015 at 22:09, Axel Davy <axel.davy at ens.fr> wrote:
>>> +static void nine_setup_fpu(void)
>>> +{
>>> +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
>>> + WORD cw;
>>> + __asm__ volatile ("fnstcw %0" : "=m" (cw));
>>> + cw = (cw & ~0xf3f) | 0x3f;
>>> + __asm__ volatile ("fldcw %0" : : "m" (cw));
>>> +#else
>>> + WARN_ONCE("FPU setup not supported on non-x86 platforms\n");
>>> +#endif
>>> +}
>>> +
>> This is once again similar enough to the corresponding Wine source
>> that I feel the need to remind you, this time more strongly, that Wine
>> is licensed under LGPL 2.1+. ( For the curious, (warning, LGPL)
>> https://source.winehq.org/git/wine.git/blob/25f0606e84bef7d60ea5c681d19b368660cab8e3:/dlls/d3d9/device.c#l3604)
>> Besides, proper Gallium style would have been to use PIPE_CC_GCC and
>> PIPE_ARCH_X86/PIPE_ARCH_X86_64.
>>
> Thanks for the warning.
>
> I think something like that would be more appropriate:
>
> #if defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) ||
> defined(PIPE_ARCH_X86_64))
>
> #include <fpu_control.h>
>
> static void nine_setup()
> {
> fpu_control_t c;
>
> _FPU_GETCW(c);
> /* clear the control word */
> c &= _FPU_RESERVED;
> /* enable interrupts (d3d9 doc, wine tests) */
> c |= _FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM |
> _FPU_MASK_UM | _FPU_MASK_PM;
> _FPU_SETCW(c);
> }
> #else
> static void nine_setup()
> {
> WARN_ONCE("Ignoring FPU setup for this configuration\n");
> }
> #endif
>
>
The comment seems misleading, as far as I can tell this doesn't enable
interrupts but disables all exceptions. That should be the default
anyway so is probably fine. The changed precision (which is definitely
not default) I guess ought to be fine too since generally just about
everything in gallium really only does float math and doesn't really
want double precision. Though if for some reason sse is used this won't
really do anything anyway.
Roland
More information about the mesa-dev
mailing list