SL-17124 switchContext and loadShaderFile crashes

- Do not try initializing shaders if requirements are not met or if window does not exist
- Warn user before closing window. Situation is unexpected, there is chance of more issues, like a freeze or a crash on close()
- mHasMultitexture is a solid requirement, if it is not present, we won't be able to run
master
Andrey Kleshchev 2020-09-29 23:39:00 +03:00
parent ac0c9a7412
commit 904b16a0a7
6 changed files with 44 additions and 52 deletions

View File

@ -722,20 +722,23 @@ bool LLGLManager::initGL()
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &num_tex_image_units);
mNumTextureImageUnits = llmin(num_tex_image_units, 32);
if (LLRender::sGLCoreProfile)
{
mNumTextureUnits = llmin(mNumTextureImageUnits, MAX_GL_TEXTURE_UNITS);
}
else if (mHasMultitexture)
{
GLint num_tex_units;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num_tex_units);
mNumTextureUnits = llmin(num_tex_units, (GLint)MAX_GL_TEXTURE_UNITS);
if (mIsIntel)
{
mNumTextureUnits = llmin(mNumTextureUnits, 2);
}
}
if (mHasMultitexture)
{
if (LLRender::sGLCoreProfile)
{
mNumTextureUnits = llmin(mNumTextureImageUnits, MAX_GL_TEXTURE_UNITS);
}
else
{
GLint num_tex_units;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num_tex_units);
mNumTextureUnits = llmin(num_tex_units, (GLint)MAX_GL_TEXTURE_UNITS);
if (mIsIntel)
{
mNumTextureUnits = llmin(mNumTextureUnits, 2);
}
}
}
else
{
mHasRequirements = FALSE;

View File

@ -1251,9 +1251,9 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen& size, BO
if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
{
close();
OSMessageBox(mCallbacks->translateString("MBPixelFmtDescErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
@ -1290,42 +1290,42 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen& size, BO
if (pfd.cColorBits < 32)
{
close();
OSMessageBox(mCallbacks->translateString("MBTrueColorWindow"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
if (pfd.cAlphaBits < 8)
{
close();
OSMessageBox(mCallbacks->translateString("MBAlpha"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
if (!SetPixelFormat(mhDC, pixel_format, &pfd))
{
close();
OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
if (!(mhRC = SafeCreateContext(mhDC)))
{
close();
OSMessageBox(mCallbacks->translateString("MBGLContextErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
if (!wglMakeCurrent(mhDC, mhRC))
{
close();
OSMessageBox(mCallbacks->translateString("MBGLContextActErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
@ -1532,16 +1532,16 @@ const S32 max_format = (S32)num_formats - 1;
if (!mhDC)
{
close();
OSMessageBox(mCallbacks->translateString("MBDevContextErr"), mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
if (!SetPixelFormat(mhDC, pixel_format, &pfd))
{
close();
OSMessageBox(mCallbacks->translateString("MBPixelFmtSetErr"),
mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
@ -1577,8 +1577,8 @@ const S32 max_format = (S32)num_formats - 1;
if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
{
close();
OSMessageBox(mCallbacks->translateString("MBPixelFmtDescErr"), mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
@ -1590,15 +1590,15 @@ const S32 max_format = (S32)num_formats - 1;
// make sure we have 32 bits per pixel
if (pfd.cColorBits < 32 || GetDeviceCaps(mhDC, BITSPIXEL) < 32)
{
close();
OSMessageBox(mCallbacks->translateString("MBTrueColorWindow"), mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
if (pfd.cAlphaBits < 8)
{
close();
OSMessageBox(mCallbacks->translateString("MBAlpha"), mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
@ -1614,8 +1614,8 @@ const S32 max_format = (S32)num_formats - 1;
if (!wglMakeCurrent(mhDC, mhRC))
{
close();
OSMessageBox(mCallbacks->translateString("MBGLContextActErr"), mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}
@ -1623,8 +1623,8 @@ const S32 max_format = (S32)num_formats - 1;
if (!gGLManager.initGL())
{
close();
OSMessageBox(mCallbacks->translateString("MBVideoDrvErr"), mCallbacks->translateString("MBError"), OSMB_OK);
close();
return FALSE;
}

View File

@ -957,13 +957,7 @@ bool LLAppViewer::init()
// If we don't have the right GL requirements, exit.
if (!gGLManager.mHasRequirements)
{
// can't use an alert here since we're exiting and
// all hell breaks lose.
LLUIString details = LLNotifications::instance().getGlobalString("UnsupportedGLRequirements");
OSMessageBox(
details.getString(),
LLStringUtil::null,
OSMB_OK);
// already handled with a MBVideoDrvErr
return 0;
}

View File

@ -426,6 +426,13 @@ void LLViewerShaderMgr::setShaders()
return;
}
if (!gGLManager.mHasRequirements)
{
// Viewer will show 'hardware requirements' warning later
LL_INFOS("ShaderLoading") << "Not supported hardware/software" << LL_ENDL;
return;
}
static LLCachedControl<U32> max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16);
LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits, (S32) max_texture_index), 1);

View File

@ -1914,12 +1914,6 @@ LLViewerWindow::LLViewerWindow(const Params& p)
p.ignore_pixel_depth,
gSavedSettings.getBOOL("RenderDeferred") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled
if (!LLViewerShaderMgr::sInitialized)
{ //immediately initialize shaders
LLViewerShaderMgr::sInitialized = TRUE;
LLViewerShaderMgr::instance()->setShaders();
}
if (NULL == mWindow)
{
LLSplashScreen::update(LLTrans::getString("StartupRequireDriverUpdate"));
@ -1938,6 +1932,12 @@ LLViewerWindow::LLViewerWindow(const Params& p)
#endif
LLAppViewer::instance()->fastQuit(1);
}
else if (!LLViewerShaderMgr::sInitialized)
{
//immediately initialize shaders
LLViewerShaderMgr::sInitialized = TRUE;
LLViewerShaderMgr::instance()->setShaders();
}
if (!LLAppViewer::instance()->restoreErrorTrap())
{

View File

@ -9634,18 +9634,6 @@ Do you wish to continue?
yestext="OK"/>
</notification>
<global name="UnsupportedShaderRequirements">
You do not appear to meet the hardware requirements for [APP_NAME]. [APP_NAME] requires OpenGL 2.0 or later shader support. If this is the case, you may want to make sure that you have the latest drivers for your graphics card, and service packs and patches for your operating system.
If you continue to have problems, please visit the [SUPPORT_SITE].
</global>
<global name="UnsupportedGLRequirements">
You do not appear to have the proper hardware requirements for [APP_NAME]. [APP_NAME] requires an OpenGL graphics card that has multitexture support. If this is the case, you may want to make sure that you have the latest drivers for your graphics card, and service packs and patches for your operating system.
If you continue to have problems, please visit the [SUPPORT_SITE].
</global>
<global name="UnsupportedIntelDriver">
The installed Intel graphics driver for [GPUNAME], version [VERSION], is significantly out of date and is known to cause excessive rates of program crashes. You are strongly advised to update to a current Intel driver