implement concurrent rendering on X11. Still a little flickery when switching in and out of threaded mode; not sure why yet.
This commit is contained in:
@@ -20,6 +20,10 @@
|
|||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static GLXContext g_pContext = NULL;
|
||||||
|
static GLXContext g_pBackgroundContext = NULL;
|
||||||
|
static Window g_AltWindow = 0;
|
||||||
|
|
||||||
static LocalizedString FAILED_CONNECTION_XSERVER( "LowLevelWindow_X11", "Failed to establish a connection with the X server'" );
|
static LocalizedString FAILED_CONNECTION_XSERVER( "LowLevelWindow_X11", "Failed to establish a connection with the X server'" );
|
||||||
LowLevelWindow_X11::LowLevelWindow_X11()
|
LowLevelWindow_X11::LowLevelWindow_X11()
|
||||||
{
|
{
|
||||||
@@ -131,15 +135,19 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
if( !X11Helper::MakeWindow(xvi->screen, xvi->depth, xvi->visual, p.width, p.height, !p.windowed) )
|
if( !X11Helper::MakeWindow(xvi->screen, xvi->depth, xvi->visual, p.width, p.height, !p.windowed) )
|
||||||
return "Failed to create the window.";
|
return "Failed to create the window.";
|
||||||
|
|
||||||
|
g_AltWindow = X11Helper::CreateWindow(xvi->screen, xvi->depth, xvi->visual, p.width, p.height, !p.windowed);
|
||||||
|
ASSERT( g_AltWindow );
|
||||||
|
|
||||||
m_bWindowIsOpen = true;
|
m_bWindowIsOpen = true;
|
||||||
|
|
||||||
char *szWindowTitle = const_cast<char *>( p.sWindowTitle.c_str() );
|
char *szWindowTitle = const_cast<char *>( p.sWindowTitle.c_str() );
|
||||||
XChangeProperty( X11Helper::Dpy, X11Helper::Win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
|
XChangeProperty( X11Helper::Dpy, X11Helper::Win, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
|
||||||
reinterpret_cast<unsigned char*>(szWindowTitle), strlen(szWindowTitle) );
|
reinterpret_cast<unsigned char*>(szWindowTitle), strlen(szWindowTitle) );
|
||||||
|
|
||||||
GLXContext ctxt = glXCreateContext( X11Helper::Dpy, xvi, NULL, True );
|
g_pContext = glXCreateContext( X11Helper::Dpy, xvi, NULL, True );
|
||||||
|
g_pBackgroundContext = glXCreateContext( X11Helper::Dpy, xvi, g_pContext, True );
|
||||||
|
|
||||||
glXMakeCurrent( X11Helper::Dpy, X11Helper::Win, ctxt );
|
glXMakeCurrent( X11Helper::Dpy, X11Helper::Win, g_pContext );
|
||||||
|
|
||||||
XMapWindow( X11Helper::Dpy, X11Helper::Win );
|
XMapWindow( X11Helper::Dpy, X11Helper::Win );
|
||||||
|
|
||||||
@@ -296,6 +304,38 @@ void LowLevelWindow_X11::GetDisplayResolutions( DisplayResolutions &out ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LowLevelWindow_X11::SupportsThreadedRendering()
|
||||||
|
{
|
||||||
|
return g_pBackgroundContext != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelWindow_X11::BeginConcurrentRenderingMainThread()
|
||||||
|
{
|
||||||
|
/* Move the main thread, which is going to be loading textures, etc. but
|
||||||
|
* not rendering, to an undisplayed window. This results in smoother
|
||||||
|
* rendering. */
|
||||||
|
bool b = glXMakeCurrent( X11Helper::Dpy, g_AltWindow, g_pContext );
|
||||||
|
ASSERT(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelWindow_X11::EndConcurrentRenderingMainThread()
|
||||||
|
{
|
||||||
|
bool b = glXMakeCurrent( X11Helper::Dpy, X11Helper::Win, g_pContext );
|
||||||
|
ASSERT(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelWindow_X11::BeginConcurrentRendering()
|
||||||
|
{
|
||||||
|
bool b = glXMakeCurrent( X11Helper::Dpy, X11Helper::Win, g_pBackgroundContext );
|
||||||
|
ASSERT(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelWindow_X11::EndConcurrentRendering()
|
||||||
|
{
|
||||||
|
bool b = glXMakeCurrent( X11Helper::Dpy, None, NULL );
|
||||||
|
ASSERT(b);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2005 Ben Anderson
|
* (c) 2005 Ben Anderson
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ public:
|
|||||||
|
|
||||||
void GetDisplayResolutions( DisplayResolutions &out ) const;
|
void GetDisplayResolutions( DisplayResolutions &out ) const;
|
||||||
|
|
||||||
|
bool SupportsThreadedRendering();
|
||||||
|
void BeginConcurrentRenderingMainThread();
|
||||||
|
void EndConcurrentRenderingMainThread();
|
||||||
|
void BeginConcurrentRendering();
|
||||||
|
void EndConcurrentRendering();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bWindowIsOpen;
|
bool m_bWindowIsOpen;
|
||||||
bool m_bWasWindowed;
|
bool m_bWasWindowed;
|
||||||
|
|||||||
Reference in New Issue
Block a user