Use a more modern way to set the fpu precision

This commit is contained in:
dhewg 2012-07-05 21:53:00 +02:00
parent a4558bb080
commit 65b13cb73e
6 changed files with 17 additions and 35 deletions

View file

@ -2805,6 +2805,9 @@ void idCommonLocal::Init( int argc, char **argv ) {
// override cvars from command line
StartupVariable( NULL, false );
// set fpu double extended precision
Sys_FPU_SetPrecision();
// initialize processor specific SIMD implementation
InitSIMD();

View file

@ -26,6 +26,8 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/
#include <float.h>
#include <SDL_cpuinfo.h>
// MSVC header intrin.h uses strcmp and errors out when not set
@ -221,3 +223,14 @@ int Sys_GetProcessorId( void ) {
return flags;
}
/*
===============
Sys_FPU_SetPrecision
===============
*/
void Sys_FPU_SetPrecision() {
#if defined(_MSC_VER) && defined(_M_IX86)
_controlfp(_PC_64, _MCW_PC);
#endif
}

View file

@ -323,9 +323,6 @@ const char *Sys_FPU_GetState( void ) {
return "";
}
void Sys_FPU_SetPrecision( int precision ) {
}
/*
================
Sys_LockMemory

View file

@ -52,12 +52,6 @@ typedef enum {
FPU_EXCEPTION_INEXACT_RESULT = 32
} fpuExceptions_t;
typedef enum {
FPU_PRECISION_SINGLE = 0,
FPU_PRECISION_DOUBLE = 1,
FPU_PRECISION_DOUBLE_EXTENDED = 2
} fpuPrecision_t;
typedef enum {
AXIS_SIDE,
AXIS_FORWARD,
@ -158,7 +152,7 @@ const char * Sys_FPU_GetState( void );
void Sys_FPU_EnableExceptions( int exceptions );
// sets the FPU precision
void Sys_FPU_SetPrecision( int precision );
void Sys_FPU_SetPrecision();
// sets Flush-To-Zero mode
void Sys_FPU_SetFTZ( bool enable );

View file

@ -273,27 +273,3 @@ void Sys_FPU_EnableExceptions( int exceptions ) {
}
#endif
}
/*
===============
Sys_FPU_SetPrecision
===============
*/
void Sys_FPU_SetPrecision( int precision ) {
#ifdef _MSC_VER
short precisionBitTable[4] = { 0, 1, 3, 0 };
short precisionBits = precisionBitTable[precision & 3] << 8;
short precisionMask = ~( ( 1 << 9 ) | ( 1 << 8 ) );
__asm {
mov eax, statePtr
mov cx, precisionBits
fnstcw word ptr [eax]
mov bx, word ptr [eax]
and bx, precisionMask
or bx, cx
mov word ptr [eax], bx
fldcw word ptr [eax]
}
#endif
}

View file

@ -653,7 +653,6 @@ int main(int argc, char *argv[]) {
#endif
// Sys_FPU_EnableExceptions( TEST_FPU_EXCEPTIONS );
Sys_FPU_SetPrecision( FPU_PRECISION_DOUBLE_EXTENDED );
if ( argc > 1 ) {
common->Init( argc-1, &argv[1] );