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:
@@ -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())
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user