Fixed LLGLState::checkStates() failing upon context re-creation:
-After new context creation, immediately call LLRender::refreshState() after LLViewerWindow::initGLDefaults() in order to force states to apply. --LLRender::initGLDefaults optimizes out gl calls by caching states, but the cached values are only applicable to the old context, not the new, so this optimization must be skipped (LLRender::mDirty). -LLViewerWindow::mStatesDirty also triggered a redundant shader reload, since restoreGL also called setShaders(). Fixed somewhat annoying flicker of a single frame whilst recovering from screen resizing. -Skip frame if LLViewerWindow::checkSettings() called LLViewerWindow::reshape. (reshape will set gWindowResized to true) --True optimal fix will require some refactoring. Reworked how window position is saved in LLViewerWindow::changeDisplaySettings. Hopefully reduces chances of odd behavior (had WindowX and WindowY get stuck at massive negative values before)
This commit is contained in:
@@ -1467,7 +1467,7 @@ LLViewerWindow::LLViewerWindow(
|
||||
mIgnoreActivate( FALSE ),
|
||||
mHoverPick(),
|
||||
mResDirty(false),
|
||||
mStatesDirty(false),
|
||||
//mStatesDirty(false), //Singu Note: No longer needed. State update is now in restoreGL.
|
||||
mIsFullscreenChecked(false),
|
||||
mCurrResolutionIndex(0)
|
||||
{
|
||||
@@ -4093,10 +4093,14 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
|
||||
BOOL disable_sync = gSavedSettings.getBOOL("DisableVerticalSync");
|
||||
if (gViewerWindow->mWindow->getFullscreen())
|
||||
{
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
gViewerWindow->changeDisplaySettings(FALSE,
|
||||
new_size,
|
||||
disable_sync,
|
||||
TRUE);
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4879,6 +4883,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
|
||||
gGLManager.mIsDisabled = FALSE;
|
||||
|
||||
initGLDefaults();
|
||||
gGL.refreshState(); //Singu Note: Call immediately. Cached states may have prevented initGLDefaults from actually applying changes.
|
||||
LLGLState::restoreGL();
|
||||
gTextureList.restoreGL();
|
||||
|
||||
@@ -4974,12 +4979,15 @@ void LLViewerWindow::requestResolutionUpdate(bool fullscreen_checked)
|
||||
|
||||
BOOL LLViewerWindow::checkSettings()
|
||||
{
|
||||
if (mStatesDirty)
|
||||
//Singu Note: Don't do the following.
|
||||
//setShaders is already called in restoreGL(), and gGL.refreshState() is too as to maintain blend states.
|
||||
//This maintaining of blend states is needed for LLGLState::checkStates() to not error out.
|
||||
/*if (mStatesDirty)
|
||||
{
|
||||
gGL.refreshState();
|
||||
LLViewerShaderMgr::instance()->setShaders();
|
||||
mStatesDirty = false;
|
||||
}
|
||||
}*/
|
||||
|
||||
// We want to update the resolution AFTER the states getting refreshed not before.
|
||||
if (mResDirty)
|
||||
@@ -5026,10 +5034,8 @@ BOOL LLViewerWindow::checkSettings()
|
||||
desired_screen_size,
|
||||
gSavedSettings.getBOOL("DisableVerticalSync"),
|
||||
mShowFullscreenProgress);
|
||||
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
mStatesDirty = true;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -5038,12 +5044,15 @@ BOOL LLViewerWindow::checkSettings()
|
||||
if(is_fullscreen)
|
||||
{
|
||||
// Changing to windowed mode.
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
changeDisplaySettings(FALSE,
|
||||
LLCoordScreen(gSavedSettings.getS32("WindowWidth"),
|
||||
gSavedSettings.getS32("WindowHeight")),
|
||||
TRUE,
|
||||
mShowFullscreenProgress);
|
||||
mStatesDirty = true;
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -5111,24 +5120,33 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
|
||||
mIgnoreActivate = TRUE;
|
||||
LLCoordScreen old_size;
|
||||
LLCoordScreen old_pos;
|
||||
LLCoordScreen new_pos;
|
||||
mWindow->getSize(&old_size);
|
||||
BOOL got_position = mWindow->getPosition(&old_pos);
|
||||
|
||||
if (!old_fullscreen && fullscreen && got_position)
|
||||
//Singu Note: ALWAYS Save old values if we can.
|
||||
if(!old_fullscreen && !mWindow->getMaximized() && got_position)
|
||||
{
|
||||
// switching from windowed to fullscreen, so save window position
|
||||
//Always save the current position if we can
|
||||
gSavedSettings.setS32("WindowX", old_pos.mX);
|
||||
gSavedSettings.setS32("WindowY", old_pos.mY);
|
||||
}
|
||||
|
||||
//Singu Note: Try to feed switchcontext a posp pointer right off the bat. Looks less clunky on systems that implemented it.
|
||||
if (!fullscreen && !mWindow->getMaximized())
|
||||
{
|
||||
new_pos.mX = gSavedSettings.getS32("WindowX");
|
||||
new_pos.mY = gSavedSettings.getS32("WindowY");
|
||||
}
|
||||
|
||||
mWindow->setFSAASamples(fsaa);
|
||||
|
||||
result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync);
|
||||
result_first_try = mWindow->switchContext(fullscreen, size, disable_vsync, &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);
|
||||
result_second_try = mWindow->switchContext(old_fullscreen, old_size, disable_vsync, &new_pos);
|
||||
|
||||
if (!result_second_try)
|
||||
{
|
||||
@@ -5181,10 +5199,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
|
||||
}
|
||||
else
|
||||
{
|
||||
S32 windowX = gSavedSettings.getS32("WindowX");
|
||||
S32 windowY = gSavedSettings.getS32("WindowY");
|
||||
|
||||
mWindow->setPosition(LLCoordScreen ( windowX, windowY ) );
|
||||
mWindow->setPosition(new_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5193,6 +5208,7 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size,
|
||||
mWantFullscreen = mWindow->getFullscreen();
|
||||
mShowFullscreenProgress = FALSE;
|
||||
|
||||
//mStatesDirty = true; //Singu Note: No longer needed. State update is now in restoreGL.
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user