Added adaptive vsync support (selectable in preferences->graphics->hardware, provided the driver supports it). Also hide 16x fsaa on amd hardware, as it is not supported on said hardware (unsure about intel).
This commit is contained in:
@@ -192,7 +192,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
|
||||
const std::string& title, S32 x, S32 y, S32 width,
|
||||
S32 height, U32 flags,
|
||||
BOOL fullscreen, BOOL clearBg,
|
||||
BOOL disable_vsync,
|
||||
const S32 vsync_mode,
|
||||
BOOL ignore_pixel_depth, U32 fsaa_samples)
|
||||
: LLWindow(callbacks, fullscreen, flags),
|
||||
Lock_Display(NULL),
|
||||
@@ -233,7 +233,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
|
||||
mWindowTitle = title;
|
||||
|
||||
// Create the GL context and set it up for windowed or fullscreen, as appropriate.
|
||||
if(createContext(x, y, width, height, 32, fullscreen, disable_vsync))
|
||||
if(createContext(x, y, width, height, 32, fullscreen, vsync_mode))
|
||||
{
|
||||
gGLManager.initGL();
|
||||
|
||||
@@ -373,7 +373,7 @@ static int x11_detect_VRAM_kb()
|
||||
}
|
||||
#endif // LL_X11
|
||||
|
||||
BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync)
|
||||
BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, const S32 vsync_mode, S32 vsync_mode)
|
||||
{
|
||||
//bool glneedsinit = false;
|
||||
|
||||
@@ -721,6 +721,26 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
|
||||
}
|
||||
#endif // LL_X11
|
||||
|
||||
// Disable vertical sync for swap
|
||||
if (vsync_mode == 0)
|
||||
{
|
||||
LL_DEBUGS("Window") << "Disabling vertical sync" << LL_ENDL;
|
||||
SDL_GL_SetSwapInterval(0);
|
||||
}
|
||||
else if(vsync_mode == -1)
|
||||
{
|
||||
LL_DEBUGS("Window") << "Enabling adaptive vertical sync" << LL_ENDL;
|
||||
if(SDL_GL_SetSwapInterval(-1) == -1)
|
||||
{
|
||||
LL_DEBUGS("Window") << "Failed to enable adaptive vertical sync. Disabling vsync." << LL_ENDL;
|
||||
SDL_GL_SetSwapInterval(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS("Window") << "Enabling vertical sync" << LL_ENDL;
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
}
|
||||
|
||||
//make sure multisampling is disabled by default
|
||||
glDisable(GL_MULTISAMPLE_ARB);
|
||||
@@ -736,7 +756,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
|
||||
|
||||
|
||||
// changing fullscreen resolution, or switching between windowed and fullscreen mode.
|
||||
BOOL LLWindowSDL::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp)
|
||||
BOOL LLWindowSDL::switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp)
|
||||
{
|
||||
const BOOL needsRebuild = TRUE; // Just nuke the context and start over.
|
||||
BOOL result = true;
|
||||
@@ -746,7 +766,7 @@ BOOL LLWindowSDL::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL
|
||||
if(needsRebuild)
|
||||
{
|
||||
destroyContext();
|
||||
result = createContext(0, 0, size.mX, size.mY, 0, fullscreen, disable_vsync);
|
||||
result = createContext(0, 0, size.mX, size.mY, 0, fullscreen, vsync_mode);
|
||||
if (result)
|
||||
{
|
||||
gGLManager.initGL();
|
||||
@@ -987,6 +1007,16 @@ void LLWindowSDL::setFSAASamples(const U32 samples)
|
||||
mFSAASamples = samples;
|
||||
}
|
||||
|
||||
S32 LLWindowSDL::getVsyncMode()
|
||||
{
|
||||
return mVsyncMode;
|
||||
}
|
||||
|
||||
void LLWindowSDL::setVsyncMode(const S32 vsync_mode)
|
||||
{
|
||||
mVsyncMode = vsync_mode
|
||||
}
|
||||
|
||||
F32 LLWindowSDL::getGamma()
|
||||
{
|
||||
return 1/mGamma;
|
||||
|
||||
Reference in New Issue
Block a user