mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-03 09:22:45 +00:00
Removed obsolete old renderer SMP code
This commit is contained in:
parent
a916fd71fc
commit
75f7fa3aa8
3 changed files with 6 additions and 239 deletions
|
@ -1069,46 +1069,27 @@ struct glimpParms_t
|
|||
// So add PreInit for platforms that need it, others can just stub it.
|
||||
void GLimp_PreInit();
|
||||
|
||||
bool GLimp_Init( glimpParms_t parms );
|
||||
// If the desired mode can't be set satisfactorily, false will be returned.
|
||||
// If succesful, sets glConfig.nativeScreenWidth, glConfig.nativeScreenHeight, and glConfig.pixelAspect
|
||||
|
||||
// The renderer will then reset the glimpParms to "safe mode" of 640x480
|
||||
// fullscreen and try again. If that also fails, the error will be fatal.
|
||||
bool GLimp_Init( glimpParms_t parms );
|
||||
|
||||
bool GLimp_SetScreenParms( glimpParms_t parms );
|
||||
// will set up gl up with the new parms
|
||||
bool GLimp_SetScreenParms( glimpParms_t parms );
|
||||
|
||||
void GLimp_Shutdown();
|
||||
// Destroys the rendering context, closes the window, resets the resolution,
|
||||
// and resets the gamma ramps.
|
||||
void GLimp_Shutdown();
|
||||
|
||||
void GLimp_SetGamma( unsigned short red[256],
|
||||
unsigned short green[256],
|
||||
unsigned short blue[256] );
|
||||
// Sets the hardware gamma ramps for gamma and brightness adjustment.
|
||||
// These are now taken as 16 bit values, so we can take full advantage
|
||||
// of dacs with >8 bits of precision
|
||||
void GLimp_SetGamma( unsigned short red[256],
|
||||
unsigned short green[256],
|
||||
unsigned short blue[256] );
|
||||
|
||||
|
||||
bool GLimp_SpawnRenderThread( void ( *function )() );
|
||||
// Returns false if the system only has a single processor
|
||||
|
||||
void* GLimp_BackEndSleep();
|
||||
void GLimp_FrontEndSleep();
|
||||
void GLimp_WakeBackEnd( void* data );
|
||||
// these functions implement the dual processor syncronization
|
||||
|
||||
void GLimp_ActivateContext();
|
||||
void GLimp_DeactivateContext();
|
||||
// These are used for managing SMP handoffs of the OpenGL context
|
||||
// between threads, and as a performance tunining aid. Setting
|
||||
// 'r_skipRenderContext 1' will call GLimp_DeactivateContext() before
|
||||
// the 3D rendering code, and GLimp_ActivateContext() afterwards. On
|
||||
// most OpenGL implementations, this will result in all OpenGL calls
|
||||
// being immediate returns, which lets us guage how much time is
|
||||
// being spent inside OpenGL.
|
||||
|
||||
void GLimp_EnableLogging( bool enable );
|
||||
|
||||
|
||||
|
|
|
@ -1479,14 +1479,6 @@ void GLimp_Shutdown()
|
|||
win32.cdsFullscreen = 0;
|
||||
}
|
||||
|
||||
// close the thread so the handle doesn't dangle
|
||||
if( win32.renderThreadHandle )
|
||||
{
|
||||
common->Printf( "...closing smp thread\n" );
|
||||
CloseHandle( win32.renderThreadHandle );
|
||||
win32.renderThreadHandle = NULL;
|
||||
}
|
||||
|
||||
// restore gamma
|
||||
GLimp_RestoreGamma();
|
||||
|
||||
|
@ -1524,202 +1516,6 @@ void GLimp_SwapBuffers()
|
|||
qwglSwapBuffers( win32.hDC );
|
||||
}
|
||||
|
||||
/*
|
||||
===========================================================
|
||||
|
||||
SMP acceleration
|
||||
|
||||
===========================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
===================
|
||||
GLimp_ActivateContext
|
||||
===================
|
||||
*/
|
||||
void GLimp_ActivateContext()
|
||||
{
|
||||
if( !qwglMakeCurrent( win32.hDC, win32.hGLRC ) )
|
||||
{
|
||||
win32.wglErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
GLimp_DeactivateContext
|
||||
===================
|
||||
*/
|
||||
void GLimp_DeactivateContext()
|
||||
{
|
||||
qglFinish();
|
||||
if( !qwglMakeCurrent( win32.hDC, NULL ) )
|
||||
{
|
||||
win32.wglErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
GLimp_RenderThreadWrapper
|
||||
===================
|
||||
*/
|
||||
static void GLimp_RenderThreadWrapper()
|
||||
{
|
||||
win32.glimpRenderThread();
|
||||
|
||||
// unbind the context before we die
|
||||
qwglMakeCurrent( win32.hDC, NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
GLimp_SpawnRenderThread
|
||||
|
||||
Returns false if the system only has a single processor
|
||||
=======================
|
||||
*/
|
||||
bool GLimp_SpawnRenderThread( void ( *function )() )
|
||||
{
|
||||
SYSTEM_INFO info;
|
||||
|
||||
// check number of processors
|
||||
GetSystemInfo( &info );
|
||||
if( info.dwNumberOfProcessors < 2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// create the IPC elements
|
||||
win32.renderCommandsEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
win32.renderCompletedEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
win32.renderActiveEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
|
||||
|
||||
win32.glimpRenderThread = function;
|
||||
|
||||
win32.renderThreadHandle = CreateThread(
|
||||
NULL, // LPSECURITY_ATTRIBUTES lpsa,
|
||||
0, // DWORD cbStack,
|
||||
( LPTHREAD_START_ROUTINE )GLimp_RenderThreadWrapper, // LPTHREAD_START_ROUTINE lpStartAddr,
|
||||
0, // LPVOID lpvThreadParm,
|
||||
0, // DWORD fdwCreate,
|
||||
&win32.renderThreadId );
|
||||
|
||||
if( !win32.renderThreadHandle )
|
||||
{
|
||||
common->Error( "GLimp_SpawnRenderThread: failed" );
|
||||
}
|
||||
|
||||
SetThreadPriority( win32.renderThreadHandle, THREAD_PRIORITY_ABOVE_NORMAL );
|
||||
#if 0
|
||||
// make sure they always run on different processors
|
||||
SetThreadAffinityMask( GetCurrentThread, 1 );
|
||||
SetThreadAffinityMask( win32.renderThreadHandle, 2 );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//#define DEBUG_PRINTS
|
||||
|
||||
/*
|
||||
===================
|
||||
GLimp_BackEndSleep
|
||||
===================
|
||||
*/
|
||||
void* GLimp_BackEndSleep()
|
||||
{
|
||||
void* data;
|
||||
|
||||
#ifdef DEBUG_PRINTS
|
||||
OutputDebugString( "-->GLimp_BackEndSleep\n" );
|
||||
#endif
|
||||
ResetEvent( win32.renderActiveEvent );
|
||||
|
||||
// after this, the front end can exit GLimp_FrontEndSleep
|
||||
SetEvent( win32.renderCompletedEvent );
|
||||
|
||||
WaitForSingleObject( win32.renderCommandsEvent, INFINITE );
|
||||
|
||||
ResetEvent( win32.renderCompletedEvent );
|
||||
ResetEvent( win32.renderCommandsEvent );
|
||||
|
||||
data = win32.smpData;
|
||||
|
||||
// after this, the main thread can exit GLimp_WakeRenderer
|
||||
SetEvent( win32.renderActiveEvent );
|
||||
|
||||
#ifdef DEBUG_PRINTS
|
||||
OutputDebugString( "<--GLimp_BackEndSleep\n" );
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
GLimp_FrontEndSleep
|
||||
===================
|
||||
*/
|
||||
void GLimp_FrontEndSleep()
|
||||
{
|
||||
#ifdef DEBUG_PRINTS
|
||||
OutputDebugString( "-->GLimp_FrontEndSleep\n" );
|
||||
#endif
|
||||
WaitForSingleObject( win32.renderCompletedEvent, INFINITE );
|
||||
|
||||
#ifdef DEBUG_PRINTS
|
||||
OutputDebugString( "<--GLimp_FrontEndSleep\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
volatile bool renderThreadActive;
|
||||
|
||||
/*
|
||||
===================
|
||||
GLimp_WakeBackEnd
|
||||
===================
|
||||
*/
|
||||
void GLimp_WakeBackEnd( void* data )
|
||||
{
|
||||
int r;
|
||||
|
||||
#ifdef DEBUG_PRINTS
|
||||
OutputDebugString( "-->GLimp_WakeBackEnd\n" );
|
||||
#endif
|
||||
win32.smpData = data;
|
||||
|
||||
if( renderThreadActive )
|
||||
{
|
||||
common->FatalError( "GLimp_WakeBackEnd: already active" );
|
||||
}
|
||||
|
||||
r = WaitForSingleObject( win32.renderActiveEvent, 0 );
|
||||
if( r == WAIT_OBJECT_0 )
|
||||
{
|
||||
common->FatalError( "GLimp_WakeBackEnd: already signaled" );
|
||||
}
|
||||
|
||||
r = WaitForSingleObject( win32.renderCommandsEvent, 0 );
|
||||
if( r == WAIT_OBJECT_0 )
|
||||
{
|
||||
common->FatalError( "GLimp_WakeBackEnd: commands already signaled" );
|
||||
}
|
||||
|
||||
// after this, the renderer can continue through GLimp_RendererSleep
|
||||
SetEvent( win32.renderCommandsEvent );
|
||||
|
||||
r = WaitForSingleObject( win32.renderActiveEvent, 5000 );
|
||||
|
||||
if( r == WAIT_TIMEOUT )
|
||||
{
|
||||
common->FatalError( "GLimp_WakeBackEnd: WAIT_TIMEOUT" );
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PRINTS
|
||||
OutputDebugString( "<--GLimp_WakeBackEnd\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
|
|
|
@ -150,16 +150,6 @@ typedef struct
|
|||
LPDIRECTINPUTDEVICE8 g_pKeyboard;
|
||||
idJoystickWin32 g_Joystick;
|
||||
|
||||
HANDLE renderCommandsEvent;
|
||||
HANDLE renderCompletedEvent;
|
||||
HANDLE renderActiveEvent;
|
||||
HANDLE renderThreadHandle;
|
||||
unsigned long renderThreadId;
|
||||
void ( *glimpRenderThread )();
|
||||
void* smpData;
|
||||
int wglErrors;
|
||||
// SMP acceleration vars
|
||||
|
||||
} Win32Vars_t;
|
||||
|
||||
extern Win32Vars_t win32;
|
||||
|
|
Loading…
Reference in a new issue