aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llgl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llrender/llgl.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llgl.cpp (renamed from linden/indra/llwindow/llgl.cpp)147
1 files changed, 88 insertions, 59 deletions
diff --git a/linden/indra/llwindow/llgl.cpp b/linden/indra/llrender/llgl.cpp
index debf2e3..843bc79 100644
--- a/linden/indra/llwindow/llgl.cpp
+++ b/linden/indra/llrender/llgl.cpp
@@ -60,6 +60,8 @@ BOOL gClothRipple = FALSE;
60BOOL gNoRender = FALSE; 60BOOL gNoRender = FALSE;
61LLMatrix4 gGLObliqueProjectionInverse; 61LLMatrix4 gGLObliqueProjectionInverse;
62 62
63#define LL_GL_NAME_POOLING 0
64
63LLGLNamePool::pool_list_t LLGLNamePool::sInstances; 65LLGLNamePool::pool_list_t LLGLNamePool::sInstances;
64 66
65#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS 67#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
@@ -284,6 +286,7 @@ LLGLManager::LLGLManager() :
284 mIsGF3(FALSE), 286 mIsGF3(FALSE),
285 mIsGFFX(FALSE), 287 mIsGFFX(FALSE),
286 mATIOffsetVerticalLines(FALSE), 288 mATIOffsetVerticalLines(FALSE),
289 mATIOldDriver(FALSE),
287 290
288 mHasRequirements(TRUE), 291 mHasRequirements(TRUE),
289 292
@@ -350,11 +353,11 @@ bool LLGLManager::initGL()
350 353
351 // Extract video card strings and convert to upper case to 354 // Extract video card strings and convert to upper case to
352 // work around driver-to-driver variation in capitalization. 355 // work around driver-to-driver variation in capitalization.
353 mGLVendor = LLString((const char *)glGetString(GL_VENDOR)); 356 mGLVendor = std::string((const char *)glGetString(GL_VENDOR));
354 LLString::toUpper(mGLVendor); 357 LLStringUtil::toUpper(mGLVendor);
355 358
356 mGLRenderer = LLString((const char *)glGetString(GL_RENDERER)); 359 mGLRenderer = std::string((const char *)glGetString(GL_RENDERER));
357 LLString::toUpper(mGLRenderer); 360 LLStringUtil::toUpper(mGLRenderer);
358 361
359 parse_gl_version( &mDriverVersionMajor, 362 parse_gl_version( &mDriverVersionMajor,
360 &mDriverVersionMinor, 363 &mDriverVersionMinor,
@@ -369,7 +372,7 @@ bool LLGLManager::initGL()
369 { 372 {
370 mGLVendorShort = "ATI"; 373 mGLVendorShort = "ATI";
371 BOOL mobile = FALSE; 374 BOOL mobile = FALSE;
372 if (mGLRenderer.find("MOBILITY") != LLString::npos) 375 if (mGLRenderer.find("MOBILITY") != std::string::npos)
373 { 376 {
374 mobile = TRUE; 377 mobile = TRUE;
375 } 378 }
@@ -381,37 +384,48 @@ bool LLGLManager::initGL()
381 mATIOffsetVerticalLines = TRUE; 384 mATIOffsetVerticalLines = TRUE;
382 } 385 }
383#endif // LL_WINDOWS 386#endif // LL_WINDOWS
387
388#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
389 // release 7277 is a point at which we verify that ATI OpenGL
390 // drivers get pretty stable with SL, ~Catalyst 8.2,
391 // for both Win32 and Linux.
392 if (mDriverVersionRelease < 7277 &&
393 mDriverVersionRelease != 0) // 0 == Undetectable driver version - these get to pretend to be new ATI drivers, though that decision may be revisited.
394 {
395 mATIOldDriver = TRUE;
396 }
397#endif // (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
384 } 398 }
385 else if (mGLVendor.find("NVIDIA ") != LLString::npos) 399 else if (mGLVendor.find("NVIDIA ") != std::string::npos)
386 { 400 {
387 mGLVendorShort = "NVIDIA"; 401 mGLVendorShort = "NVIDIA";
388 mIsNVIDIA = TRUE; 402 mIsNVIDIA = TRUE;
389 if ( mGLRenderer.find("GEFORCE4 MX") != LLString::npos 403 if ( mGLRenderer.find("GEFORCE4 MX") != std::string::npos
390 || mGLRenderer.find("GEFORCE2") != LLString::npos 404 || mGLRenderer.find("GEFORCE2") != std::string::npos
391 || mGLRenderer.find("GEFORCE 2") != LLString::npos 405 || mGLRenderer.find("GEFORCE 2") != std::string::npos
392 || mGLRenderer.find("GEFORCE4 460 GO") != LLString::npos 406 || mGLRenderer.find("GEFORCE4 460 GO") != std::string::npos
393 || mGLRenderer.find("GEFORCE4 440 GO") != LLString::npos 407 || mGLRenderer.find("GEFORCE4 440 GO") != std::string::npos
394 || mGLRenderer.find("GEFORCE4 420 GO") != LLString::npos) 408 || mGLRenderer.find("GEFORCE4 420 GO") != std::string::npos)
395 { 409 {
396 mIsGF2or4MX = TRUE; 410 mIsGF2or4MX = TRUE;
397 } 411 }
398 else if (mGLRenderer.find("GEFORCE FX") != LLString::npos 412 else if (mGLRenderer.find("GEFORCE FX") != std::string::npos
399 || mGLRenderer.find("QUADRO FX") != LLString::npos 413 || mGLRenderer.find("QUADRO FX") != std::string::npos
400 || mGLRenderer.find("NV34") != LLString::npos) 414 || mGLRenderer.find("NV34") != std::string::npos)
401 { 415 {
402 mIsGFFX = TRUE; 416 mIsGFFX = TRUE;
403 } 417 }
404 else if(mGLRenderer.find("GEFORCE3") != LLString::npos) 418 else if(mGLRenderer.find("GEFORCE3") != std::string::npos)
405 { 419 {
406 mIsGF3 = TRUE; 420 mIsGF3 = TRUE;
407 } 421 }
408 422
409 } 423 }
410 else if (mGLVendor.find("INTEL") != LLString::npos 424 else if (mGLVendor.find("INTEL") != std::string::npos
411#if LL_LINUX 425#if LL_LINUX
412 // The Mesa-based drivers put this in the Renderer string, 426 // The Mesa-based drivers put this in the Renderer string,
413 // not the Vendor string. 427 // not the Vendor string.
414 || mGLRenderer.find("INTEL") != LLString::npos 428 || mGLRenderer.find("INTEL") != std::string::npos
415#endif //LL_LINUX 429#endif //LL_LINUX
416 ) 430 )
417 { 431 {
@@ -452,12 +466,12 @@ bool LLGLManager::initGL()
452 466
453void LLGLManager::getGLInfo(LLSD& info) 467void LLGLManager::getGLInfo(LLSD& info)
454{ 468{
455 info["GLInfo"]["GLVendor"] = LLString((const char *)glGetString(GL_VENDOR)); 469 info["GLInfo"]["GLVendor"] = std::string((const char *)glGetString(GL_VENDOR));
456 info["GLInfo"]["GLRenderer"] = LLString((const char *)glGetString(GL_RENDERER)); 470 info["GLInfo"]["GLRenderer"] = std::string((const char *)glGetString(GL_RENDERER));
457 info["GLInfo"]["GLVersion"] = LLString((const char *)glGetString(GL_VERSION)); 471 info["GLInfo"]["GLVersion"] = std::string((const char *)glGetString(GL_VERSION));
458 472
459#if !LL_MESA_HEADLESS 473#if !LL_MESA_HEADLESS
460 LLString all_exts = (const char *)gGLHExts.mSysExts; 474 std::string all_exts = ll_safe_string((const char *)gGLHExts.mSysExts);
461 boost::char_separator<char> sep(" "); 475 boost::char_separator<char> sep(" ");
462 boost::tokenizer<boost::char_separator<char> > tok(all_exts, sep); 476 boost::tokenizer<boost::char_separator<char> > tok(all_exts, sep);
463 for(boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i) 477 for(boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i)
@@ -467,19 +481,19 @@ void LLGLManager::getGLInfo(LLSD& info)
467#endif 481#endif
468} 482}
469 483
470LLString LLGLManager::getGLInfoString() 484std::string LLGLManager::getGLInfoString()
471{ 485{
472 LLString info_str; 486 std::string info_str;
473 LLString all_exts, line; 487 std::string all_exts, line;
474 488
475 info_str += LLString("GL_VENDOR ") + LLString((const char *)glGetString(GL_VENDOR)) + LLString("\n"); 489 info_str += std::string("GL_VENDOR ") + ll_safe_string((const char *)glGetString(GL_VENDOR)) + std::string("\n");
476 info_str += LLString("GL_RENDERER ") + LLString((const char *)glGetString(GL_RENDERER)) + LLString("\n"); 490 info_str += std::string("GL_RENDERER ") + ll_safe_string((const char *)glGetString(GL_RENDERER)) + std::string("\n");
477 info_str += LLString("GL_VERSION ") + LLString((const char *)glGetString(GL_VERSION)) + LLString("\n"); 491 info_str += std::string("GL_VERSION ") + ll_safe_string((const char *)glGetString(GL_VERSION)) + std::string("\n");
478 492
479#if !LL_MESA_HEADLESS 493#if !LL_MESA_HEADLESS
480 all_exts = (const char *)gGLHExts.mSysExts; 494 all_exts = (const char *)gGLHExts.mSysExts;
481 LLString::replaceChar(all_exts, ' ', '\n'); 495 LLStringUtil::replaceChar(all_exts, ' ', '\n');
482 info_str += LLString("GL_EXTENSIONS:\n") + all_exts + LLString("\n"); 496 info_str += std::string("GL_EXTENSIONS:\n") + all_exts + std::string("\n");
483#endif 497#endif
484 498
485 return info_str; 499 return info_str;
@@ -487,26 +501,24 @@ LLString LLGLManager::getGLInfoString()
487 501
488void LLGLManager::printGLInfoString() 502void LLGLManager::printGLInfoString()
489{ 503{
490 LLString info_str; 504 std::string info_str;
491 LLString all_exts, line; 505 std::string all_exts, line;
492 506
493 LL_INFOS("RenderInit") << "GL_VENDOR: " << ((const char *)glGetString(GL_VENDOR)) << LL_ENDL; 507 LL_INFOS("RenderInit") << "GL_VENDOR: " << ((const char *)glGetString(GL_VENDOR)) << LL_ENDL;
494 LL_INFOS("RenderInit") << "GL_RENDERER: " << ((const char *)glGetString(GL_RENDERER)) << LL_ENDL; 508 LL_INFOS("RenderInit") << "GL_RENDERER: " << ((const char *)glGetString(GL_RENDERER)) << LL_ENDL;
495 LL_INFOS("RenderInit") << "GL_VERSION: " << ((const char *)glGetString(GL_VERSION)) << LL_ENDL; 509 LL_INFOS("RenderInit") << "GL_VERSION: " << ((const char *)glGetString(GL_VERSION)) << LL_ENDL;
496 510
497#if !LL_MESA_HEADLESS 511#if !LL_MESA_HEADLESS
498 all_exts = (const char *)gGLHExts.mSysExts; 512 all_exts = std::string(gGLHExts.mSysExts);
499 LLString::replaceChar(all_exts, ' ', '\n'); 513 LLStringUtil::replaceChar(all_exts, ' ', '\n');
500 LL_DEBUGS("RenderInit") << "GL_EXTENSIONS:\n" << all_exts << LL_ENDL; 514 LL_DEBUGS("RenderInit") << "GL_EXTENSIONS:\n" << all_exts << LL_ENDL;
501#endif 515#endif
502} 516}
503 517
504LLString LLGLManager::getRawGLString() 518std::string LLGLManager::getRawGLString()
505{ 519{
506 LLString gl_string; 520 std::string gl_string;
507 gl_string.assign((char*)glGetString(GL_VENDOR)); 521 gl_string = ll_safe_string((char*)glGetString(GL_VENDOR)) + " " + ll_safe_string((char*)glGetString(GL_RENDERER));
508 gl_string.append(" ");
509 gl_string.append((char*)glGetString(GL_RENDERER));
510 return gl_string; 522 return gl_string;
511} 523}
512 524
@@ -991,11 +1003,12 @@ void LLGLState::initClass()
991 sStateMap[GL_DITHER] = GL_TRUE; 1003 sStateMap[GL_DITHER] = GL_TRUE;
992 sStateMap[GL_TEXTURE_2D] = GL_TRUE; 1004 sStateMap[GL_TEXTURE_2D] = GL_TRUE;
993 1005
994 //make sure vertex arrays are enabled 1006 //make sure multisample defaults to disabled
995 glEnableClientState(GL_VERTEX_ARRAY); 1007 sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE;
996
997 //make sure multi sampling is disabled by default
998 glDisable(GL_MULTISAMPLE_ARB); 1008 glDisable(GL_MULTISAMPLE_ARB);
1009
1010 //default vertex arrays to enabled.
1011 glEnableClientState(GL_VERTEX_ARRAY);
999} 1012}
1000 1013
1001//static 1014//static
@@ -1031,7 +1044,7 @@ void LLGLState::dumpStates()
1031 } 1044 }
1032} 1045}
1033 1046
1034void LLGLState::checkStates() 1047void LLGLState::checkStates(const std::string& msg)
1035{ 1048{
1036 if (!gDebugGL) 1049 if (!gDebugGL)
1037 { 1050 {
@@ -1055,7 +1068,7 @@ void LLGLState::checkStates()
1055 1068
1056 if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA) 1069 if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA)
1057 { 1070 {
1058 LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << LL_ENDL; 1071 LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << LL_ENDL;
1059 } 1072 }
1060 1073
1061 for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin(); 1074 for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
@@ -1074,7 +1087,7 @@ void LLGLState::checkStates()
1074 stop_glerror(); 1087 stop_glerror();
1075} 1088}
1076 1089
1077void LLGLState::checkTextureChannels() 1090void LLGLState::checkTextureChannels(const std::string& msg)
1078{ 1091{
1079 if (!gDebugGL) 1092 if (!gDebugGL)
1080 { 1093 {
@@ -1175,11 +1188,11 @@ void LLGLState::checkTextureChannels()
1175 1188
1176 if (error) 1189 if (error)
1177 { 1190 {
1178 LL_GL_ERRS << "GL texture state corruption detected." << LL_ENDL; 1191 LL_GL_ERRS << "GL texture state corruption detected. " << msg << LL_ENDL;
1179 } 1192 }
1180} 1193}
1181 1194
1182void LLGLState::checkClientArrays(U32 data_mask) 1195void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
1183{ 1196{
1184 if (!gDebugGL) 1197 if (!gDebugGL)
1185 { 1198 {
@@ -1291,7 +1304,7 @@ void LLGLState::checkClientArrays(U32 data_mask)
1291 1304
1292 if (error) 1305 if (error)
1293 { 1306 {
1294 LL_GL_ERRS << "GL client array corruption detected." << LL_ENDL; 1307 LL_GL_ERRS << "GL client array corruption detected. " << msg << LL_ENDL;
1295 } 1308 }
1296} 1309}
1297 1310
@@ -1456,7 +1469,7 @@ void set_palette(U8 *palette_data)
1456} 1469}
1457 1470
1458 1471
1459void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_specific ) 1472void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific )
1460{ 1473{
1461 // GL_VERSION returns a null-terminated string with the format: 1474 // GL_VERSION returns a null-terminated string with the format:
1462 // <major>.<minor>[.<release>] [<vendor specific>] 1475 // <major>.<minor>[.<release>] [<vendor specific>]
@@ -1472,7 +1485,7 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1472 return; 1485 return;
1473 } 1486 }
1474 1487
1475 LLString ver_copy( version ); 1488 std::string ver_copy( version );
1476 S32 len = (S32)strlen( version ); /* Flawfinder: ignore */ 1489 S32 len = (S32)strlen( version ); /* Flawfinder: ignore */
1477 S32 i = 0; 1490 S32 i = 0;
1478 S32 start; 1491 S32 start;
@@ -1485,8 +1498,8 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1485 break; 1498 break;
1486 } 1499 }
1487 } 1500 }
1488 LLString major_str = ver_copy.substr(start,i-start); 1501 std::string major_str = ver_copy.substr(start,i-start);
1489 LLString::convertToS32(major_str, *major); 1502 LLStringUtil::convertToS32(major_str, *major);
1490 1503
1491 if( '.' == version[i] ) 1504 if( '.' == version[i] )
1492 { 1505 {
@@ -1502,8 +1515,8 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1502 break; 1515 break;
1503 } 1516 }
1504 } 1517 }
1505 LLString minor_str = ver_copy.substr(start,i-start); 1518 std::string minor_str = ver_copy.substr(start,i-start);
1506 LLString::convertToS32(minor_str, *minor); 1519 LLStringUtil::convertToS32(minor_str, *minor);
1507 1520
1508 // Find the release number (optional) 1521 // Find the release number (optional)
1509 if( '.' == version[i] ) 1522 if( '.' == version[i] )
@@ -1519,8 +1532,8 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp
1519 } 1532 }
1520 } 1533 }
1521 1534
1522 LLString release_str = ver_copy.substr(start,i-start); 1535 std::string release_str = ver_copy.substr(start,i-start);
1523 LLString::convertToS32(release_str, *release); 1536 LLStringUtil::convertToS32(release_str, *release);
1524 } 1537 }
1525 1538
1526 // Skip over any white space 1539 // Skip over any white space
@@ -1616,6 +1629,7 @@ void LLGLNamePool::cleanup()
1616 1629
1617GLuint LLGLNamePool::allocate() 1630GLuint LLGLNamePool::allocate()
1618{ 1631{
1632#if LL_GL_NAME_POOLING
1619 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter) 1633 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
1620 { 1634 {
1621 if (!iter->used) 1635 if (!iter->used)
@@ -1631,18 +1645,33 @@ GLuint LLGLNamePool::allocate()
1631 mNameList.push_back(entry); 1645 mNameList.push_back(entry);
1632 1646
1633 return entry.name; 1647 return entry.name;
1648#else
1649 return allocateName();
1650#endif
1634} 1651}
1635 1652
1636void LLGLNamePool::release(GLuint name) 1653void LLGLNamePool::release(GLuint name)
1637{ 1654{
1655#if LL_GL_NAME_POOLING
1638 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter) 1656 for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
1639 { 1657 {
1640 if (iter->name == name) 1658 if (iter->name == name)
1641 { 1659 {
1642 iter->used = FALSE; 1660 if (iter->used)
1643 return; 1661 {
1662 iter->used = FALSE;
1663 return;
1664 }
1665 else
1666 {
1667 llerrs << "Attempted to release a pooled name that is not in use!" << llendl;
1668 }
1644 } 1669 }
1645 } 1670 }
1671 llerrs << "Attempted to release a non pooled name!" << llendl;
1672#else
1673 releaseName(name);
1674#endif
1646} 1675}
1647 1676
1648//static 1677//static