- Add MASM assembler files for MSVC x64 projects to support vm_x86 in x64 mode

- Clean up ftol()/snapvector() mess
- Make use of SSE instructions for ftol()/snapvector() if available
- move ftol/snapvector pure assembler to inline assembler, this will add x86_64 and improve support for different calling conventions
- Set FPU control word at program startup to get consistent behaviour on all platforms
This commit is contained in:
Thilo Schulz 2011-06-13 09:56:39 +00:00
parent 471182cba0
commit 03201aff22
22 changed files with 540 additions and 460 deletions

View file

@ -90,6 +90,14 @@ cvar_t *com_basegame;
cvar_t *com_homepath;
cvar_t *com_busyWait;
#if defined(idx64)
void (*Q_VMftol)(void);
#elif defined(id386)
long (QDECL *Q_ftol)(float f);
void (QDECL *Q_VMftol)(void);
void (QDECL *Q_SnapVector)(vec3_t vec);
#endif
// com_speeds times
int time_game;
int time_frontend; // renderer frontend time
@ -2565,6 +2573,53 @@ static void Com_DetectAltivec(void)
}
}
/*
=================
Com_DetectSSE
Find out whether we have SSE support for Q_ftol function
=================
*/
#if defined(id386) || defined(idx64)
static void Com_DetectSSE(void)
{
#ifndef idx64
cpuFeatures_t feat;
feat = Sys_GetProcessorFeatures();
if(feat & CF_SSE)
{
if(feat & CF_SSE2)
Q_SnapVector = qsnapvectorsse;
else
Q_SnapVector = qsnapvectorx87;
Q_ftol = qftolsse;
#endif
Q_VMftol = qvmftolsse;
Com_Printf("Have SSE support\n");
#ifndef idx64
}
else
{
Q_ftol = qftolx87;
Q_VMftol = qvmftolx87;
Q_SnapVector = qsnapvectorx87;
Com_Printf("No SSE support on this machine\n");
}
#endif
}
#else
#define Com_DetectSSE()
#endif
/*
=================
Com_InitRand
@ -2615,6 +2670,8 @@ void Com_Init( char *commandLine ) {
// Swap_Init ();
Cbuf_Init ();
Com_DetectSSE();
// override anything from the config files with command line args
Com_StartupVariable( NULL );