aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolbump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lldrawpoolbump.cpp')
-rw-r--r--linden/indra/newview/lldrawpoolbump.cpp69
1 files changed, 34 insertions, 35 deletions
diff --git a/linden/indra/newview/lldrawpoolbump.cpp b/linden/indra/newview/lldrawpoolbump.cpp
index 73d88f7..f345282 100644
--- a/linden/indra/newview/lldrawpoolbump.cpp
+++ b/linden/indra/newview/lldrawpoolbump.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2003&license=viewergpl$ 5 * $LicenseInfo:firstyear=2003&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2003-2008, Linden Research, Inc. 7 * Copyright (c) 2003-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -73,7 +73,6 @@ const U32 VERTEX_MASK_SHINY = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_N
73const U32 VERTEX_MASK_BUMP = LLVertexBuffer::MAP_VERTEX |LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_TEXCOORD2; 73const U32 VERTEX_MASK_BUMP = LLVertexBuffer::MAP_VERTEX |LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_TEXCOORD2;
74 74
75U32 LLDrawPoolBump::sVertexMask = VERTEX_MASK_SHINY; 75U32 LLDrawPoolBump::sVertexMask = VERTEX_MASK_SHINY;
76static LLPointer<LLCubeMap> sCubeMap;
77 76
78static LLGLSLShader* shader = NULL; 77static LLGLSLShader* shader = NULL;
79static S32 cube_channel = -1; 78static S32 cube_channel = -1;
@@ -349,27 +348,29 @@ void LLDrawPoolBump::beginShiny(bool invisible)
349 cube_map->setMatrix(1); 348 cube_map->setMatrix(1);
350 // Make sure that texture coord generation happens for tex unit 1, as that's the one we use for 349 // Make sure that texture coord generation happens for tex unit 1, as that's the one we use for
351 // the cube map in the one pass shiny shaders 350 // the cube map in the one pass shiny shaders
352 cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); 351 cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
353 cube_map->enableTexture(cube_channel); 352 cube_map->enableTexture(cube_channel);
354 cube_map->enableTextureCoords(1); 353 cube_map->enableTextureCoords(1);
355 diffuse_channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); 354 diffuse_channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
356 } 355 }
357 else 356 else
358 { 357 {
359 cube_channel = 0; 358 cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
360 diffuse_channel = -1; 359 diffuse_channel = -1;
361 cube_map->setMatrix(0); 360 cube_map->setMatrix(0);
362 cube_map->enable(shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB)); 361 cube_map->enable(cube_channel);
363 } 362 }
364 cube_map->bind(); 363 gGL.getTexUnit(cube_channel)->bind(cube_map);
364 gGL.getTexUnit(0)->activate();
365 } 365 }
366 else 366 else
367 { 367 {
368 cube_channel = 0; 368 cube_channel = 0;
369 diffuse_channel = -1; 369 diffuse_channel = -1;
370 gGL.getTexUnit(0)->disable();
370 cube_map->enable(0); 371 cube_map->enable(0);
371 cube_map->setMatrix(0); 372 cube_map->setMatrix(0);
372 cube_map->bind(); 373 gGL.getTexUnit(0)->bind(cube_map);
373 374
374 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); 375 gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR);
375 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_ALPHA); 376 gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_VERT_ALPHA);
@@ -386,8 +387,6 @@ void LLDrawPoolBump::renderShiny(bool invisible)
386 return; 387 return;
387 } 388 }
388 389
389 sCubeMap = NULL;
390
391 if( gSky.mVOSkyp->getCubeMap() ) 390 if( gSky.mVOSkyp->getCubeMap() )
392 { 391 {
393 LLGLEnable blend_enable(GL_BLEND); 392 LLGLEnable blend_enable(GL_BLEND);
@@ -423,7 +422,7 @@ void LLDrawPoolBump::endShiny(bool invisible)
423 422
424 if (!invisible && mVertexShaderLevel > 1) 423 if (!invisible && mVertexShaderLevel > 1)
425 { 424 {
426 shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); 425 shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
427 426
428 if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0) 427 if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0)
429 { 428 {
@@ -435,18 +434,20 @@ void LLDrawPoolBump::endShiny(bool invisible)
435 434
436 shader->unbind(); 435 shader->unbind();
437 gGL.getTexUnit(0)->activate(); 436 gGL.getTexUnit(0)->activate();
438 glEnable(GL_TEXTURE_2D); 437 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
439 } 438 }
440 if (cube_channel >= 0) 439 if (cube_channel >= 0)
441 { 440 {
441 gGL.getTexUnit(cube_channel)->enable(LLTexUnit::TT_TEXTURE);
442 gGL.getTexUnit(cube_channel)->setTextureBlendType(LLTexUnit::TB_MULT); 442 gGL.getTexUnit(cube_channel)->setTextureBlendType(LLTexUnit::TB_MULT);
443 } 443 }
444 } 444 }
445 445 gGL.getTexUnit(diffuse_channel)->disable();
446 gGL.getTexUnit(0)->activate(); 446 gGL.getTexUnit(cube_channel)->disable();
447 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 447
448 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
448 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); 449 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
449 450
450 diffuse_channel = -1; 451 diffuse_channel = -1;
451 cube_channel = 0; 452 cube_channel = 0;
452 mShiny = FALSE; 453 mShiny = FALSE;
@@ -489,12 +490,14 @@ void LLDrawPoolBump::beginFullbrightShiny()
489 cube_map->setMatrix(1); 490 cube_map->setMatrix(1);
490 // Make sure that texture coord generation happens for tex unit 1, as that's the one we use for 491 // Make sure that texture coord generation happens for tex unit 1, as that's the one we use for
491 // the cube map in the one pass shiny shaders 492 // the cube map in the one pass shiny shaders
492 cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB); 493 gGL.getTexUnit(1)->disable();
494 cube_channel = shader->enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
493 cube_map->enableTexture(cube_channel); 495 cube_map->enableTexture(cube_channel);
494 cube_map->enableTextureCoords(1); 496 cube_map->enableTextureCoords(1);
495 diffuse_channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); 497 diffuse_channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
496 498
497 cube_map->bind(); 499 gGL.getTexUnit(cube_channel)->bind(cube_map);
500 gGL.getTexUnit(0)->activate();
498 } 501 }
499 mShiny = TRUE; 502 mShiny = TRUE;
500} 503}
@@ -507,8 +510,6 @@ void LLDrawPoolBump::renderFullbrightShiny()
507 return; 510 return;
508 } 511 }
509 512
510 sCubeMap = NULL;
511
512 if( gSky.mVOSkyp->getCubeMap() ) 513 if( gSky.mVOSkyp->getCubeMap() )
513 { 514 {
514 LLGLEnable blend_enable(GL_BLEND); 515 LLGLEnable blend_enable(GL_BLEND);
@@ -535,14 +536,13 @@ void LLDrawPoolBump::endFullbrightShiny()
535 shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); 536 shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
536 } 537 }
537 gGL.getTexUnit(0)->activate(); 538 gGL.getTexUnit(0)->activate();
538 glEnable(GL_TEXTURE_2D); 539 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
539 540
540 shader->unbind(); 541 shader->unbind();
541
542 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); 542 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
543 } 543 }
544 544
545 LLImageGL::unbindTexture(0, GL_TEXTURE_2D); 545 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
546 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); 546 gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
547 547
548 diffuse_channel = -1; 548 diffuse_channel = -1;
@@ -561,7 +561,7 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL
561 applyModelMatrix(params); 561 applyModelMatrix(params);
562 562
563 params.mVertexBuffer->setBuffer(mask); 563 params.mVertexBuffer->setBuffer(mask);
564 params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); 564 params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
565 gPipeline.addTrianglesDrawn(params.mCount/3); 565 gPipeline.addTrianglesDrawn(params.mCount/3);
566 } 566 }
567} 567}
@@ -592,15 +592,15 @@ BOOL LLDrawPoolBump::bindBumpMap(LLDrawInfo& params)
592 if( bump_code < LLStandardBumpmap::sStandardBumpmapCount ) 592 if( bump_code < LLStandardBumpmap::sStandardBumpmapCount )
593 { 593 {
594 bump = gStandardBumpmapList[bump_code].mImage; 594 bump = gStandardBumpmapList[bump_code].mImage;
595 gBumpImageList.addTextureStats(bump_code, tex->getID(), params.mVSize, 1, 1); 595 gBumpImageList.addTextureStats(bump_code, tex->getID(), params.mVSize);
596 } 596 }
597 break; 597 break;
598 } 598 }
599 599
600 if (bump) 600 if (bump)
601 { 601 {
602 bump->bind(1); 602 gGL.getTexUnit(1)->bind(bump);
603 bump->bind(0); 603 gGL.getTexUnit(0)->bind(bump);
604 return TRUE; 604 return TRUE;
605 } 605 }
606 return FALSE; 606 return FALSE;
@@ -629,7 +629,7 @@ void LLDrawPoolBump::beginBump()
629 // TEXTURE UNIT 1 629 // TEXTURE UNIT 1
630 gGL.getTexUnit(1)->activate(); 630 gGL.getTexUnit(1)->activate();
631 631
632 glEnable(GL_TEXTURE_2D); // Texture unit 1 632 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
633 633
634 gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA); 634 gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA);
635 gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); 635 gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA);
@@ -648,7 +648,7 @@ void LLDrawPoolBump::beginBump()
648 gGL.getTexUnit(0)->activate(); 648 gGL.getTexUnit(0)->activate();
649 stop_glerror(); 649 stop_glerror();
650 650
651 LLViewerImage::unbindTexture(1, GL_TEXTURE_2D); 651 gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
652} 652}
653 653
654//static 654//static
@@ -680,7 +680,7 @@ void LLDrawPoolBump::endBump()
680 680
681 // Disable texture unit 1 681 // Disable texture unit 1
682 gGL.getTexUnit(1)->activate(); 682 gGL.getTexUnit(1)->activate();
683 glDisable(GL_TEXTURE_2D); // Texture unit 1 683 gGL.getTexUnit(1)->disable();
684 gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); 684 gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT);
685 685
686 // Disable texture unit 0 686 // Disable texture unit 0
@@ -734,14 +734,13 @@ LLBumpImageList::~LLBumpImageList()
734 734
735 735
736// Note: Does nothing for entries in gStandardBumpmapList that are not actually standard bump images (e.g. none, brightness, and darkness) 736// Note: Does nothing for entries in gStandardBumpmapList that are not actually standard bump images (e.g. none, brightness, and darkness)
737void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, 737void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size)
738 F32 pixel_area, F32 texel_area_ratio, F32 cos_center_angle)
739{ 738{
740 bump &= TEM_BUMP_MASK; 739 bump &= TEM_BUMP_MASK;
741 LLViewerImage* bump_image = gStandardBumpmapList[bump].mImage; 740 LLViewerImage* bump_image = gStandardBumpmapList[bump].mImage;
742 if( bump_image ) 741 if( bump_image )
743 { 742 {
744 bump_image->addTextureStats(pixel_area, texel_area_ratio, cos_center_angle); 743 bump_image->addTextureStats(virtual_size);
745 } 744 }
746} 745}
747 746
@@ -1083,17 +1082,17 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture)
1083 { 1082 {
1084 if (params.mTexture.notNull()) 1083 if (params.mTexture.notNull())
1085 { 1084 {
1086 params.mTexture->bind(diffuse_channel); 1085 gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
1087 params.mTexture->addTextureStats(params.mVSize); 1086 params.mTexture->addTextureStats(params.mVSize);
1088 } 1087 }
1089 else 1088 else
1090 { 1089 {
1091 LLImageGL::unbindTexture(0); 1090 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
1092 } 1091 }
1093 } 1092 }
1094 1093
1095 params.mVertexBuffer->setBuffer(mask); 1094 params.mVertexBuffer->setBuffer(mask);
1096 params.mVertexBuffer->drawRange(LLVertexBuffer::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); 1095 params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
1097 gPipeline.addTrianglesDrawn(params.mCount/3); 1096 gPipeline.addTrianglesDrawn(params.mCount/3);
1098 if (params.mTextureMatrix) 1097 if (params.mTextureMatrix)
1099 { 1098 {