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:
@@ -1120,6 +1120,9 @@ void LLRender::refreshState(void)
|
||||
|
||||
setAlphaRejectSettings(mCurrAlphaFunc, mCurrAlphaFuncVal);
|
||||
|
||||
//Singu note: Also reset glBlendFunc
|
||||
blendFunc(mCurrBlendColorSFactor,mCurrBlendColorDFactor,mCurrBlendAlphaSFactor,mCurrBlendAlphaDFactor);
|
||||
|
||||
mDirty = false;
|
||||
}
|
||||
|
||||
@@ -1586,7 +1589,7 @@ void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB
|
||||
if (mCurrColorMask[0] != writeColorR ||
|
||||
mCurrColorMask[1] != writeColorG ||
|
||||
mCurrColorMask[2] != writeColorB ||
|
||||
mCurrColorMask[3] != writeAlpha)
|
||||
mCurrColorMask[3] != writeAlpha || mDirty)
|
||||
{
|
||||
mCurrColorMask[0] = writeColorR;
|
||||
mCurrColorMask[1] = writeColorG;
|
||||
@@ -1641,7 +1644,7 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
|
||||
}
|
||||
|
||||
if (mCurrAlphaFunc != func ||
|
||||
mCurrAlphaFuncVal != value)
|
||||
mCurrAlphaFuncVal != value || mDirty)
|
||||
{
|
||||
mCurrAlphaFunc = func;
|
||||
mCurrAlphaFuncVal = value;
|
||||
@@ -1685,7 +1688,7 @@ void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
|
||||
llassert(sfactor < BF_UNDEF);
|
||||
llassert(dfactor < BF_UNDEF);
|
||||
if (mCurrBlendColorSFactor != sfactor || mCurrBlendColorDFactor != dfactor ||
|
||||
mCurrBlendAlphaSFactor != sfactor || mCurrBlendAlphaDFactor != dfactor)
|
||||
mCurrBlendAlphaSFactor != sfactor || mCurrBlendAlphaDFactor != dfactor || mDirty)
|
||||
{
|
||||
mCurrBlendColorSFactor = sfactor;
|
||||
mCurrBlendAlphaSFactor = sfactor;
|
||||
@@ -1710,7 +1713,7 @@ void LLRender::blendFunc(eBlendFactor color_sfactor, eBlendFactor color_dfactor,
|
||||
return;
|
||||
}
|
||||
if (mCurrBlendColorSFactor != color_sfactor || mCurrBlendColorDFactor != color_dfactor ||
|
||||
mCurrBlendAlphaSFactor != alpha_sfactor || mCurrBlendAlphaDFactor != alpha_dfactor)
|
||||
mCurrBlendAlphaSFactor != alpha_sfactor || mCurrBlendAlphaDFactor != alpha_dfactor || mDirty)
|
||||
{
|
||||
mCurrBlendColorSFactor = color_sfactor;
|
||||
mCurrBlendAlphaSFactor = alpha_sfactor;
|
||||
|
||||
@@ -897,10 +897,14 @@ void LLPanelDisplay::apply()
|
||||
LLWindow* window = gViewerWindow->getWindow();
|
||||
LLCoordScreen size;
|
||||
window->getSize(&size);
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
gViewerWindow->changeDisplaySettings(window->getFullscreen(),
|
||||
size,
|
||||
gSavedSettings.getBOOL("DisableVerticalSync"),
|
||||
logged_in);
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -320,6 +320,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
|
||||
}
|
||||
|
||||
gViewerWindow->checkSettings();
|
||||
|
||||
if(gWindowResized) //Singu Note: gViewerWindow->checkSettings() can call LLViewerWindow::reshape(). If it has then skip this frame.
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
LLFastTimer ftm(FTM_PICK);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -449,7 +449,7 @@ protected:
|
||||
class LLDebugText* mDebugText; // Internal class for debug text
|
||||
|
||||
bool mResDirty;
|
||||
bool mStatesDirty;
|
||||
//bool mStatesDirty; //Singu Note: No longer needed. State update is now in restoreGL.
|
||||
bool mIsFullscreenChecked; // Did the user check the fullscreen checkbox in the display settings
|
||||
U32 mCurrResolutionIndex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user