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:
Shyotl
2014-03-28 02:34:03 -05:00
parent 894261862d
commit d6fdaa93a4
20 changed files with 204 additions and 54 deletions

View File

@@ -442,6 +442,8 @@ LLGLManager::LLGLManager() :
mHasCubeMap(FALSE),
mHasDebugOutput(FALSE),
mHasAdaptiveVsync(FALSE),
mIsATI(FALSE),
mIsNVIDIA(FALSE),
mIsIntel(FALSE),
@@ -956,6 +958,12 @@ void LLGLManager::initExtensions()
mHasFragmentShader = ExtensionExists("GL_ARB_fragment_shader", gGLHExts.mSysExts) && (LLRender::sGLCoreProfile || ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts));
#endif
#if LL_WINDOWS
mHasAdaptiveVsync = ExtensionExists("WGL_EXT_swap_control_tear", gGLHExts.mSysExts);
#elif LL_LINUX
mHasAdaptiveVsync = ExtensionExists("GLX_EXT_swap_control_tear", gGLHExts.mSysExts);
#endif
#if LL_LINUX || LL_SOLARIS
llinfos << "initExtensions() checking shell variables to adjust features..." << llendl;
// Our extension support for the Linux Client is very young with some
@@ -980,6 +988,7 @@ void LLGLManager::initExtensions()
mHasShaderObjects = FALSE;
mHasVertexShader = FALSE;
mHasFragmentShader = FALSE;
mHasAdaptiveVsync = FALSE;
LL_WARNS("RenderInit") << "GL extension support DISABLED via LL_GL_NOEXT" << LL_ENDL;
}
else if (getenv("LL_GL_BASICEXT")) /* Flawfinder: ignore */

View File

@@ -113,6 +113,8 @@ public:
BOOL mHasCubeMap;
BOOL mHasDebugOutput;
BOOL mHasAdaptiveVsync;
// Vendor-specific extensions
BOOL mIsATI;
BOOL mIsNVIDIA;

View File

@@ -388,7 +388,7 @@ LLWindow* LLWindowManager::createWindow(
const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags,
BOOL fullscreen,
BOOL clearBg,
BOOL disable_vsync,
const S32 vsync_mode,
BOOL use_gl,
BOOL ignore_pixel_depth,
U32 fsaa_samples)
@@ -400,26 +400,26 @@ LLWindow* LLWindowManager::createWindow(
#if LL_MESA_HEADLESS
new_window = new LLWindowMesaHeadless(callbacks,
title, name, x, y, width, height, flags,
fullscreen, clearBg, disable_vsync, ignore_pixel_depth);
fullscreen, clearBg, vsync_mode, ignore_pixel_depth);
#elif LL_SDL
new_window = new LLWindowSDL(callbacks,
title, x, y, width, height, flags,
fullscreen, clearBg, disable_vsync, ignore_pixel_depth, fsaa_samples);
fullscreen, clearBg, vsync_mode, ignore_pixel_depth, fsaa_samples);
#elif LL_WINDOWS
new_window = new LLWindowWin32(callbacks,
title, name, x, y, width, height, flags,
fullscreen, clearBg, disable_vsync, ignore_pixel_depth, fsaa_samples);
fullscreen, clearBg, vsync_mode, ignore_pixel_depth, fsaa_samples);
#elif LL_DARWIN
new_window = new LLWindowMacOSX(callbacks,
title, name, x, y, width, height, flags,
fullscreen, clearBg, disable_vsync, ignore_pixel_depth, fsaa_samples);
fullscreen, clearBg, vsync_mode, ignore_pixel_depth, fsaa_samples);
#endif
}
else
{
new_window = new LLWindowHeadless(callbacks,
title, name, x, y, width, height, flags,
fullscreen, clearBg, disable_vsync, ignore_pixel_depth);
fullscreen, clearBg, vsync_mode, ignore_pixel_depth);
}
if (FALSE == new_window->isValid())

View File

@@ -82,7 +82,7 @@ public:
BOOL setSize(LLCoordScreen size);
BOOL setSize(LLCoordWindow size);
virtual void setMinSize(U32 min_width, U32 min_height, bool enforce_immediately = true);
virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) = 0;
virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp = NULL) = 0;
virtual BOOL setCursorPosition(LLCoordWindow position) = 0;
virtual BOOL getCursorPosition(LLCoordWindow *position) = 0;
virtual void showCursor() = 0;
@@ -121,6 +121,8 @@ public:
virtual BOOL setGamma(const F32 gamma) = 0; // Set the gamma
virtual void setFSAASamples(const U32 fsaa_samples) = 0; //set number of FSAA samples
virtual U32 getFSAASamples() = 0;
virtual void setVsyncMode(const S32 vsync_mode) = 0;
virtual S32 getVsyncMode() = 0;
virtual BOOL restoreGamma() = 0; // Restore original gamma table (before updating gamma)
virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
virtual void processMiscNativeEvents();
@@ -274,7 +276,7 @@ public:
U32 flags = 0,
BOOL fullscreen = FALSE,
BOOL clearBg = FALSE,
BOOL disable_vsync = TRUE,
const S32 vsync_mode = 0,
BOOL use_gl = TRUE,
BOOL ignore_pixel_depth = FALSE,
U32 fsaa_samples = 0);

View File

@@ -35,7 +35,7 @@
//
LLWindowHeadless::LLWindowHeadless(LLWindowCallbacks* callbacks, const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height,
U32 flags, BOOL fullscreen, BOOL clear_background,
BOOL disable_vsync, BOOL ignore_pixel_depth)
const S32 vsync_mode, BOOL ignore_pixel_depth)
: LLWindow(callbacks, fullscreen, flags)
{
// Initialize a headless keyboard.

View File

@@ -48,7 +48,7 @@ public:
/*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;};
/*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;};
/*virtual*/ BOOL setSizeImpl(LLCoordWindow size) {return FALSE;};
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;};
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp = NULL) {return FALSE;};
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;};
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;};
/*virtual*/ void showCursor() {};
@@ -69,6 +69,8 @@ public:
/*virtual*/ BOOL setGamma(const F32 gamma) {return FALSE; }; // Set the gamma
/*virtual*/ void setFSAASamples(const U32 fsaa_samples) { }
/*virtual*/ U32 getFSAASamples() { return 0; }
/*virtual*/ void setVsyncMode(const S32 vsync_mode) {}
/*virtual*/ S32 getVsyncMode() { return 0; }
/*virtual*/ BOOL restoreGamma() {return FALSE; }; // Restore original gamma table (before updating gamma)
//virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput() {};
@@ -96,7 +98,7 @@ public:
S32 x, S32 y,
S32 width, S32 height,
U32 flags, BOOL fullscreen, BOOL clear_background,
BOOL disable_vsync, BOOL ignore_pixel_depth);
const S32 vsync_mode, BOOL ignore_pixel_depth);
virtual ~LLWindowHeadless();
private:

View File

@@ -210,7 +210,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, 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(NULL, fullscreen, flags)
@@ -253,6 +253,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
mPreeditor = NULL;
mRawKeyEvent = NULL;
mFSAASamples = fsaa_samples;
mVsyncMode = vsync_mode;
mForceRebuild = FALSE;
// For reasons that aren't clear to me, LLTimers seem to be created in the "started" state.
@@ -283,7 +284,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
gWindowImplementation = this;
// 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))
{
if(mWindow != NULL)
{
@@ -323,7 +324,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
stop_glerror();
}
BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync)
BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, const S32 vsync_mode)
{
OSStatus err;
BOOL glNeedsInit = FALSE;
@@ -780,7 +781,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
// Disable vertical sync for swap
GLint frames_per_swap = 0;
if (disable_vsync)
if (vsync_mode != 1)
{
LL_DEBUGS("GLInit") << "Disabling vertical sync" << LL_ENDL;
frames_per_swap = 0;
@@ -816,7 +817,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
// changing fullscreen resolution, or switching between windowed and fullscreen mode.
BOOL LLWindowMacOSX::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp)
BOOL LLWindowMacOSX::switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp)
{
BOOL needsRebuild = FALSE;
BOOL result = true;
@@ -892,7 +893,7 @@ BOOL LLWindowMacOSX::switchContext(BOOL fullscreen, const LLCoordScreen &size, B
{
mForceRebuild = FALSE;
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)
{
if(mWindow != NULL)
@@ -1341,6 +1342,16 @@ void LLWindowMacOSX::setFSAASamples(const U32 samples)
mForceRebuild = TRUE;
}
S32 LLWindowMacOSX::getVsyncMode()
{
return mVsyncMode;
}
void LLWindowMacOSX::setVsyncMode(const S32 vsync_mode)
{
mVsyncMode = vsync_mode
mForceRebuild = TRUE;
}
BOOL LLWindowMacOSX::restoreGamma()
{
CGDisplayRestoreColorSyncSettings();

View File

@@ -60,7 +60,7 @@ public:
/*virtual*/ BOOL setPosition(LLCoordScreen position);
/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
/*virtual*/ BOOL setSizeImpl(LLCoordWindow size);
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp = NULL);
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
/*virtual*/ void showCursor();
@@ -81,6 +81,8 @@ public:
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
/*virtual*/ U32 getFSAASamples();
/*virtual*/ void setFSAASamples(const U32 fsaa_samples);
/*virtual*/ void setVsyncMode(const S32 vsync_mode);
/*virtual*/ S32 getVsyncMode();
/*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput();
@@ -124,7 +126,7 @@ public:
protected:
LLWindowMacOSX(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL disable_vsync,
BOOL fullscreen, BOOL clearBg, const S32 vsync_mode,
BOOL ignore_pixel_depth,
U32 fsaa_samples);
~LLWindowMacOSX();
@@ -152,7 +154,7 @@ protected:
//
// create or re-create the GL context/window. Called from the constructor and switchContext().
BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync);
BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, const S32 vsync_mode);
void destroyContext();
void setupFailure(const std::string& text, const std::string& caption, U32 type);
static pascal OSStatus staticEventHandler (EventHandlerCallRef myHandler, EventRef event, void* userData);
@@ -201,6 +203,7 @@ protected:
BOOL mMaximized;
BOOL mMinimized;
U32 mFSAASamples;
S32 mVsyncMode;
BOOL mForceRebuild;
S32 mDragOverrideCursor;

View File

@@ -41,7 +41,7 @@ U16 *gMesaBuffer = NULL;
LLWindowMesaHeadless::LLWindowMesaHeadless(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height,
U32 flags, BOOL fullscreen, BOOL clearBg,
BOOL disable_vsync, BOOL ignore_pixel_depth)
const S32 vsync_mode, BOOL ignore_pixel_depth)
: LLWindow(callbacks, fullscreen, flags)
{
llinfos << "MESA Init" << llendl;

View File

@@ -52,7 +52,7 @@ public:
/*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;};
/*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;};
/*virtual*/ BOOL setSizeImpl(LLCoordWindow size) {return FALSE;};
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;};
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp = NULL) {return FALSE;};
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;};
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;};
/*virtual*/ void showCursor() {};
@@ -74,6 +74,8 @@ public:
/*virtual*/ BOOL restoreGamma() {return FALSE; }; // Restore original gamma table (before updating gamma)
/*virtual*/ void setFSAASamples(const U32 fsaa_samples) { /* FSAA not supported yet on Mesa headless.*/ }
/*virtual*/ U32 getFSAASamples() { return 0; }
/*virtual*/ void setVsyncMode(const S32 vsync_mode) {}
/*virtual*/ S32 getVsyncMode() { return 0; }
//virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput() {};
/*virtual*/ void delayInputProcessing() {};
@@ -98,7 +100,7 @@ public:
LLWindowMesaHeadless(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height,
U32 flags, BOOL fullscreen, BOOL clearBg,
BOOL disable_vsync, BOOL ignore_pixel_depth);
const S32 vsync_mode, BOOL ignore_pixel_depth);
~LLWindowMesaHeadless();
private:

View File

@@ -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;

View File

@@ -65,7 +65,7 @@ public:
/*virtual*/ BOOL setPosition(LLCoordScreen position);
/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
/*virtual*/ BOOL setSizeImpl(LLCoordWindow size);
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp = NULL);
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
/*virtual*/ void showCursor();
@@ -92,6 +92,8 @@ public:
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
/*virtual*/ U32 getFSAASamples();
/*virtual*/ void setFSAASamples(const U32 samples);
/*virtual*/ void setVsyncMode(const S32 vsync_mode);
/*virtual*/ S32 getVsyncMode();
/*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void processMiscNativeEvents();
@@ -149,7 +151,7 @@ public:
protected:
LLWindowSDL(LLWindowCallbacks* callbacks,
const std::string& title, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL disable_vsync,
BOOL fullscreen, BOOL clearBg, const S32 vsync_mode,
BOOL ignore_pixel_depth, U32 fsaa_samples);
~LLWindowSDL();
@@ -174,7 +176,7 @@ protected:
//
// create or re-create the GL context/window. Called from the constructor and switchContext().
BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync);
BOOL createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, const S32 vsync_mode);
void destroyContext();
void setupFailure(const std::string& text, const std::string& caption, U32 type);
void fixWindowSize(void);
@@ -194,6 +196,7 @@ protected:
F32 mOverrideAspectRatio;
F32 mGamma;
U32 mFSAASamples;
S32 mVsyncMode;
int mSDLFlags;

View File

@@ -363,7 +363,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, 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)
@@ -903,7 +903,7 @@ BOOL LLWindowWin32::setSizeImpl(const LLCoordWindow size)
}
// changing fullscreen resolution
BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp)
BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp)
{
GLuint pixel_format;
DEVMODE dev_mode;
@@ -1650,14 +1650,27 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
}
// Disable vertical sync for swap
if (disable_vsync && wglSwapIntervalEXT)
if(wglSwapIntervalEXT)
{
LL_DEBUGS("Window") << "Disabling vertical sync" << LL_ENDL;
wglSwapIntervalEXT(0);
}
else
{
LL_DEBUGS("Window") << "Keeping vertical sync" << LL_ENDL;
if (vsync_mode == 0)
{
LL_DEBUGS("Window") << "Disabling vertical sync" << LL_ENDL;
wglSwapIntervalEXT(0);
}
else if(vsync_mode == -1)
{
LL_DEBUGS("Window") << "Enabling adaptive vertical sync" << LL_ENDL;
if(wglSwapIntervalEXT(-1) == 0)
{
LL_DEBUGS("Window") << "Failed to enable adaptive vertical sync. Disabling vsync." << LL_ENDL;
wglSwapIntervalEXT(0);
}
}
else
{
LL_DEBUGS("Window") << "Enabling vertical sync" << LL_ENDL;
wglSwapIntervalEXT(1);
}
}
SetWindowLongPtr(mWindowHandle, GWLP_USERDATA, (LONG_PTR)this);
@@ -3030,6 +3043,16 @@ U32 LLWindowWin32::getFSAASamples()
return mFSAASamples;
}
S32 LLWindowWin32::getVsyncMode()
{
return mVsyncMode;
}
void LLWindowWin32::setVsyncMode(const S32 vsync_mode)
{
mVsyncMode = vsync_mode;
}
LLWindow::LLWindowResolution* LLWindowWin32::getSupportedResolutions(S32 &num_resolutions)
{
if (!mSupportedResolutions)

View File

@@ -59,7 +59,7 @@ public:
/*virtual*/ BOOL setPosition(LLCoordScreen position);
/*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
/*virtual*/ BOOL setSizeImpl(LLCoordWindow size);
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
/*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, const S32 vsync_mode, const LLCoordScreen * const posp = NULL);
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
/*virtual*/ void showCursor();
@@ -80,6 +80,8 @@ public:
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
/*virtual*/ void setFSAASamples(const U32 fsaa_samples);
/*virtual*/ U32 getFSAASamples();
/*virtual*/ void setVsyncMode(const S32 vsync_mode);
/*virtual*/ S32 getVsyncMode();
/*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput();
@@ -121,7 +123,7 @@ public:
protected:
LLWindowWin32(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL disable_vsync,
BOOL fullscreen, BOOL clearBg, const S32 vsync_mode,
BOOL ignore_pixel_depth, U32 fsaa_samples);
~LLWindowWin32();
@@ -186,6 +188,7 @@ protected:
F32 mCurrentGamma;
U32 mFSAASamples;
S32 mVsyncMode;
WORD mPrevGammaRamp[256*3];
WORD mCurrentGammaRamp[256*3];

View File

@@ -251,5 +251,16 @@
<key>Value</key>
<real>1</real>
</map>
<key>SHRenderVsyncMode</key>
<map>
<key>Comment</key>
<string>Desired vertical sychronization method. (0 = Disabled, 1 = Standard [Double-buffered], -1 = Adaptive [if supported])</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<real>0</real>
</map>
</map>
</llsd>

View File

@@ -334,6 +334,16 @@ BOOL LLPanelDisplay::postBuild()
mVBOStream = getChild<LLCheckBoxCtrl>("vbo_stream");
if(gGLManager.mIsATI) //AMD gpus don't go beyond 8x fsaa.
{
LLComboBox* fsaa = getChild<LLComboBox>("fsaa");
fsaa->remove("16x");
}
if(!gGLManager.mHasAdaptiveVsync)
{
LLComboBox* vsync = getChild<LLComboBox>("vsync");
vsync->remove("VSyncAdaptive");
}
refresh();
@@ -447,8 +457,10 @@ void LLPanelDisplay::refresh()
mGamma = gSavedSettings.getF32("RenderGamma");
mVideoCardMem = gSavedSettings.getS32("TextureMemory");
mFogRatio = gSavedSettings.getF32("RenderFogRatio");
mVsyncMode = gSavedSettings.getS32("SHRenderVsyncMode");
childSetValue("fsaa", (LLSD::Integer) mFSAASamples);
childSetValue("vsync", (LLSD::Integer) mVsyncMode);
refreshEnabledState();
}
@@ -846,13 +858,22 @@ void LLPanelDisplay::cancel()
gSavedSettings.setF32("RenderGamma", mGamma);
gSavedSettings.setS32("TextureMemory", mVideoCardMem);
gSavedSettings.setF32("RenderFogRatio", mFogRatio);
gSavedSettings.setS32("SHRenderVsyncMode", mVsyncMode);
}
void LLPanelDisplay::apply()
{
U32 fsaa_value = childGetValue("fsaa").asInteger();
S32 vsync_value = childGetValue("vsync").asInteger();
if(vsync_value == -1 && !gGLManager.mHasAdaptiveVsync)
vsync_value = 0;
bool apply_fsaa_change = !gSavedSettings.getBOOL("RenderUseFBO") && (mFSAASamples != fsaa_value);
bool apply_vsync_change = vsync_value != mVsyncMode;
gSavedSettings.setU32("RenderFSAASamples", fsaa_value);
gSavedSettings.setS32("SHRenderVsyncMode", vsync_value);
applyResolution();
@@ -865,7 +886,7 @@ void LLPanelDisplay::apply()
// Hardware tab
//Still do a bit of voodoo here. V2 forces restart to change FSAA with FBOs off.
//Let's not do that, and instead do pre-V2 FSAA change handling for that particular case
if(apply_fsaa_change)
if(apply_fsaa_change || apply_vsync_change)
{
bool logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
LLWindow* window = gViewerWindow->getWindow();
@@ -875,7 +896,7 @@ void LLPanelDisplay::apply()
LLGLState::checkTextureChannels();
gViewerWindow->changeDisplaySettings(window->getFullscreen(),
size,
gSavedSettings.getBOOL("DisableVerticalSync"),
vsync_value,
logged_in);
LLGLState::checkStates();
LLGLState::checkTextureChannels();

View File

@@ -194,6 +194,7 @@ protected:
F32 mGamma;
S32 mVideoCardMem;
F32 mFogRatio;
S32 mVsyncMode;
// if the quality radio buttons are changed
void onChangeQuality(LLUICtrl* caller);

View File

@@ -1640,12 +1640,18 @@ LLViewerWindow::LLViewerWindow(
LLViewerWindow::sMovieBaseName = "SLmovie";
resetSnapshotLoc();
S32 vsync_mode = gSavedSettings.getS32("SHRenderVsyncMode");
if(vsync_mode == -1 && !gGLManager.mHasAdaptiveVsync)
{
vsync_mode = 0; //Disable vsync if adaptive is desired yet isn't supported.
}
// create window
mWindow = LLWindowManager::createWindow(this,
title, name, x, y, width, height, 0,
fullscreen,
gNoRender,
gSavedSettings.getBOOL("DisableVerticalSync"),
vsync_mode,
!gNoRender,
ignore_pixel_depth,
gSavedSettings.getBOOL("RenderUseFBO") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled
@@ -4436,14 +4442,20 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
BORDERHEIGHT = size.mY- y;
LLCoordScreen new_size(new_width + BORDERWIDTH,
new_height + BORDERHEIGHT);
BOOL disable_sync = gSavedSettings.getBOOL("DisableVerticalSync");
S32 vsync_mode = gSavedSettings.getS32("SHRenderVsyncMode");
if(vsync_mode == -1 && !gGLManager.mHasAdaptiveVsync)
{
vsync_mode = 0; //Disable vsync if adaptive is desired yet isn't supported.
}
if (gViewerWindow->getWindow()->getFullscreen())
{
LLGLState::checkStates();
LLGLState::checkTextureChannels();
gViewerWindow->changeDisplaySettings(FALSE,
new_size,
disable_sync,
vsync_mode,
TRUE);
LLGLState::checkStates();
LLGLState::checkTextureChannels();
@@ -5429,9 +5441,16 @@ BOOL LLViewerWindow::checkSettings()
LLGLState::checkStates();
LLGLState::checkTextureChannels();
S32 vsync_mode = gSavedSettings.getS32("SHRenderVsyncMode");
if(vsync_mode == -1 && !gGLManager.mHasAdaptiveVsync)
{
vsync_mode = 0; //Disable vsync if adaptive is desired yet isn't supported.
}
changeDisplaySettings(TRUE,
desired_screen_size,
gSavedSettings.getBOOL("DisableVerticalSync"),
vsync_mode,
mShowFullscreenProgress);
LLGLState::checkStates();
LLGLState::checkTextureChannels();
@@ -5472,7 +5491,7 @@ void LLViewerWindow::restartDisplay(BOOL show_progress_bar)
}
}
BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar)
BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, const S32 vsync_mode, BOOL show_progress_bar)
{
BOOL was_maximized = gSavedSettings.getBOOL("WindowMaximized");
mWantFullscreen = fullscreen;
@@ -5491,6 +5510,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
U32 fsaa = gSavedSettings.getU32("RenderFSAASamples");
U32 old_fsaa = mWindow->getFSAASamples();
// going from windowed to windowed
if (!old_fullscreen && !fullscreen)
{
@@ -5500,7 +5520,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
mWindow->setSize(size);
}
if (fsaa == old_fsaa)
if (fsaa == old_fsaa && vsync_mode == mWindow->getFSAASamples())
{
return TRUE;
}
@@ -5539,13 +5559,14 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
}
mWindow->setFSAASamples(fsaa);
mWindow->setVsyncMode(vsync_mode);
result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync, &new_pos);
result_first_try = mWindow->switchContext(fullscreen, size, vsync_mode, &new_pos);
if (!result_first_try)
{
// try to switch back
mWindow->setFSAASamples(old_fsaa);
result_second_try = mWindow->switchContext(old_fullscreen, old_size, disable_vsync, &new_pos);
result_second_try = mWindow->switchContext(old_fullscreen, old_size, vsync_mode, &new_pos);
if (!result_second_try)
{

View File

@@ -386,7 +386,7 @@ public:
void requestResolutionUpdate(bool fullscreen_checked);
BOOL checkSettings();
void restartDisplay(BOOL show_progress_bar);
BOOL changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, BOOL disable_vsync, BOOL show_progress_bar);
BOOL changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, const S32 vsync_mode, BOOL show_progress_bar);
BOOL getIgnoreDestroyWindow() { return mIgnoreActivate; }
F32 getDisplayAspectRatio() const;
const LLVector2& getDisplayScale() const { return mDisplayScale; }

View File

@@ -118,6 +118,12 @@
<combo_item name="4x" value="4">4x</combo_item>
<combo_item name="8x" value="8">8x</combo_item>
<combo_item name="16x" value="16">16x</combo_item>
</combo_box>
<text bottom="-57" height="12" left="10" name="VSync:" width="128">VSync:</text>
<combo_box bottom="-61" height="16" initial_value="false" label="VSync" left="148" name="vsync" width="64">
<combo_item name="VSyncDisabled" value="0">Disabled</combo_item>
<combo_item name="VSyncStandard" value="1">Standard</combo_item>
<combo_item name="VSyncAdaptive" value="-1">Adaptive</combo_item>
</combo_box>
<spinner bottom_delta="70" control_name="TextureMemory" decimal_digits="0" height="16" increment="16" initial_val="32" label="Texture Memory (MB):" label_width="138" left="10" max_val="4096" min_val="0" name="GrapicsCardTextureMemory" tool_tip="Amount of memory to allocate for textures. Defaults to Video Card Memory. Reducing this may improve performance but may also make textures blurry." width="202"/>
<check_box bottom_delta="-25" control_name="RenderVBOEnable" height="16" initial_value="true" label="Enable OpenGL Vertex Buffer Objects" left="5" name="vbo"
@@ -126,7 +132,7 @@
tool_tip="Disabling this may improve performance when VBOs are enabled. Disabling produced observable improvement on various AMD GPUs."/>
<check_box bottom_delta="-25" control_name="RenderUseFBO" height="16" initial_value="true" label="Enable OpenGL Frame Buffer Objects" left="5" name="fbo"
tool_tip="Enabling this on modern hardware can provide a performance gain. However, enabling this when combined with antialiasing on AMD GPUs may cause edge artifacts. This setting is required for deferred rendering."/>
<spinner bottom="-42" control_name="RenderGamma" decimal_digits="2" height="16" increment="0.01" initial_val="1" label="Gamma:" label_width="138" left="250" max_val="2" min_val="0.0" name="gamma" width="202" tool_tip="(brightness, lower is brighter)"/>
<spinner bottom="-41" control_name="RenderGamma" decimal_digits="2" height="16" increment="0.01" initial_val="1" label="Gamma:" label_width="138" left="250" max_val="2" min_val="0.0" name="gamma" width="202" tool_tip="(brightness, lower is brighter)"/>
<spinner bottom_delta="70" control_name="RenderFogRatio" decimal_digits="1" height="16" increment="0.1" initial_val="4" label="Fog Distance Ratio:" label_width="138" max_val="10" min_val="0.5" name="fog" width="202"/>
<text bottom_delta="-50" height="40" name="note">
Note: The Gamma and Fog Distance Ratio