diff options
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r-- | indra/newview/pipeline.cpp | 190 |
1 files changed, 66 insertions, 124 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5aad87630d..282eddf380 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -346,10 +346,7 @@ LLPipeline::LLPipeline() : mLightMovingMask(0), mLightingDetail(0), mScreenWidth(0), - mScreenHeight(0), - mViewportWidth(0), - mViewportHeight(0) - + mScreenHeight(0) { mNoiseMap = 0; mTrueNoiseMap = 0; @@ -517,46 +514,29 @@ void LLPipeline::resizeScreenTexture() LLFastTimer ft(FTM_RESIZE_SCREEN_TEXTURE); if (gPipeline.canUseVertexShaders() && assertInitialized()) { - GLuint resX = gViewerWindow->getWindowWidthRaw(); - GLuint resY = gViewerWindow->getWindowHeightRaw(); - GLuint view_width = gViewerWindow->getWorldViewWidthRaw(); - GLuint view_height = gViewerWindow->getWorldViewHeightRaw(); + GLuint resX = gViewerWindow->getWorldViewWidthRaw(); + GLuint resY = gViewerWindow->getWorldViewHeightRaw(); - allocateScreenBuffer(resX, resY, view_width, view_height); + allocateScreenBuffer(resX,resY); } } -void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 viewport_width, U32 viewport_height) +void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { - bool screen_size_changed = resX != mScreenWidth || resY != mScreenHeight; - bool viewport_size_changed = viewport_width != mViewportWidth || viewport_height != mViewportHeight; - - if (!screen_size_changed - && !viewport_size_changed) - { - // nothing to do - return; - } - // remember these dimensions mScreenWidth = resX; mScreenHeight = resY; - mViewportWidth = viewport_width; - mViewportHeight = viewport_height; - - llinfos << "RESIZED SCREEN TEXTURE: " << resX << "x" << resY << llendl; - + U32 samples = gSavedSettings.getU32("RenderFSAASamples"); - U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor"); + if (res_mod > 1 && res_mod < resX && res_mod < resY) { resX /= res_mod; resY /= res_mod; } - if (gSavedSettings.getBOOL("RenderUIBuffer") - && screen_size_changed) + if (gSavedSettings.getBOOL("RenderUIBuffer")) { mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); } @@ -564,51 +544,30 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 viewport_width, U3 if (LLPipeline::sRenderDeferred) { //allocate deferred rendering color buffers - if (screen_size_changed) - { - mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - addDeferredAttachments(mDeferredScreen); - } + mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + addDeferredAttachments(mDeferredScreen); + // always set viewport to desired size, since allocate resets the viewport - mDeferredScreen.setViewport(viewport_width, viewport_height); - mDeferredDepth.setViewport(viewport_width, viewport_height); - if (screen_size_changed) - { - mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - mEdgeMap.allocate(resX, resY, GL_ALPHA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - } - mScreen.setViewport(viewport_width, viewport_height); - mEdgeMap.setViewport(viewport_width, viewport_height); + mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); + mEdgeMap.allocate(resX, resY, GL_ALPHA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE); for (U32 i = 0; i < 3; i++) { - if (screen_size_changed) - { - mDeferredLight[i].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); - } - mDeferredLight[i].setViewport(viewport_width, viewport_height); + mDeferredLight[i].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); } for (U32 i = 0; i < 2; i++) { - if (screen_size_changed) - { - mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); - } - mGIMapPost[i].setViewport(viewport_width, viewport_height); + mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE); } F32 scale = gSavedSettings.getF32("RenderShadowResolutionScale"); for (U32 i = 0; i < 4; i++) { - if (screen_size_changed) - { - mShadow[i].allocate(U32(resX*scale),U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE); - } - mShadow[i].setViewport(viewport_width, viewport_height); + mShadow[i].allocate(U32(resX*scale),U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE); } @@ -617,52 +576,36 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 viewport_width, U3 for (U32 i = 4; i < 6; i++) { - if (screen_size_changed) - { - mShadow[i].allocate(width, height, 0, TRUE, FALSE); - } - mShadow[i].setViewport(viewport_width, viewport_height); + mShadow[i].allocate(width, height, 0, TRUE, FALSE); } width = nhpo2(resX)/2; height = nhpo2(resY)/2; - if (screen_size_changed) - { - mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE); - } - mLuminanceMap.setViewport(viewport_width, viewport_height); + mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE); } else { - if (screen_size_changed) - { - mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); - } - mScreen.setViewport(viewport_width, viewport_height); + mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE); } if (gGLManager.mHasFramebufferMultisample && samples > 1) { - if (screen_size_changed) + mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); + if (LLPipeline::sRenderDeferred) { - mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples); - if (LLPipeline::sRenderDeferred) - { - addDeferredAttachments(mSampleBuffer); - mDeferredScreen.setSampleBuffer(&mSampleBuffer); - } + addDeferredAttachments(mSampleBuffer); + mDeferredScreen.setSampleBuffer(&mSampleBuffer); } - mSampleBuffer.setViewport(viewport_width, viewport_height); + mScreen.setSampleBuffer(&mSampleBuffer); stop_glerror(); } - if (LLPipeline::sRenderDeferred - && screen_size_changed) + if (LLPipeline::sRenderDeferred) { //share depth buffer between deferred targets mDeferredScreen.shareDepthBuffer(mScreen); for (U32 i = 0; i < 3; i++) @@ -762,10 +705,8 @@ void LLPipeline::createGLBuffers() stop_glerror(); - GLuint resX = gViewerWindow->getWindowWidthRaw(); - GLuint resY = gViewerWindow->getWindowHeightRaw(); - GLuint viewport_width = gViewerWindow->getWorldViewWidthRaw(); - GLuint viewport_height = gViewerWindow->getWorldViewHeightRaw(); + GLuint resX = gViewerWindow->getWorldViewWidthRaw(); + GLuint resY = gViewerWindow->getWorldViewHeightRaw(); if (LLPipeline::sRenderGlow) { //screen space glow buffers @@ -777,11 +718,10 @@ void LLPipeline::createGLBuffers() mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE,FALSE); } - // force reallocation of buffers by clearing known dimensions + allocateScreenBuffer(resX,resY); mScreenWidth = 0; mScreenHeight = 0; - allocateScreenBuffer(resX,resY, viewport_width, viewport_height); } if (sRenderDeferred) @@ -3828,9 +3768,10 @@ void LLPipeline::renderForSelect(std::set<LLViewerObject*>& objects, BOOL render gGL.setColorMask(true, false); gPipeline.resetDrawOrders(); + LLViewerCamera* camera = LLViewerCamera::getInstance(); for (std::set<LLViewerObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter) { - stateSort((*iter)->mDrawable, *LLViewerCamera::getInstance()); + stateSort((*iter)->mDrawable, *camera); } LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_SELECT); @@ -6308,6 +6249,7 @@ void LLPipeline::renderDeferredLighting() { LLFastTimer ftm(FTM_RENDER_DEFERRED); + LLViewerCamera* camera = LLViewerCamera::getInstance(); { LLGLDepthTest depth(GL_TRUE); mDeferredDepth.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), @@ -6701,7 +6643,7 @@ void LLPipeline::renderDeferredLighting() continue; } - if (LLViewerCamera::getInstance()->AABBInFrustumNoFarClip(center, LLVector3(s,s,s)) == 0) + if (camera->AABBInFrustumNoFarClip(center, LLVector3(s,s,s)) == 0) { continue; } @@ -6725,12 +6667,12 @@ void LLPipeline::renderDeferredLighting() v[18] = c[0]+s; v[19] = c[1]+s; v[20] = c[2]-s; // 6 - 0110 v[21] = c[0]+s; v[22] = c[1]+s; v[23] = c[2]+s; // 7 - 0111 - if (LLViewerCamera::getInstance()->getOrigin().mV[0] > c[0] + s + 0.2f || - LLViewerCamera::getInstance()->getOrigin().mV[0] < c[0] - s - 0.2f || - LLViewerCamera::getInstance()->getOrigin().mV[1] > c[1] + s + 0.2f || - LLViewerCamera::getInstance()->getOrigin().mV[1] < c[1] - s - 0.2f || - LLViewerCamera::getInstance()->getOrigin().mV[2] > c[2] + s + 0.2f || - LLViewerCamera::getInstance()->getOrigin().mV[2] < c[2] - s - 0.2f) + if (camera->getOrigin().mV[0] > c[0] + s + 0.2f || + camera->getOrigin().mV[0] < c[0] - s - 0.2f || + camera->getOrigin().mV[1] > c[1] + s + 0.2f || + camera->getOrigin().mV[1] < c[1] - s - 0.2f || + camera->getOrigin().mV[2] > c[2] + s + 0.2f || + camera->getOrigin().mV[2] < c[2] - s - 0.2f) { //draw box if camera is outside box if (render_local) { @@ -6745,7 +6687,7 @@ void LLPipeline::renderDeferredLighting() glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, - GL_UNSIGNED_BYTE, get_box_fan_indices(LLViewerCamera::getInstance(), center)); + GL_UNSIGNED_BYTE, get_box_fan_indices(camera, center)); stop_glerror(); } } @@ -6810,7 +6752,7 @@ void LLPipeline::renderDeferredLighting() glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, - GL_UNSIGNED_BYTE, get_box_fan_indices(LLViewerCamera::getInstance(), center)); + GL_UNSIGNED_BYTE, get_box_fan_indices(camera, center)); } gDeferredSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); unbindDeferredShader(gDeferredSpotLightProgram); @@ -7247,6 +7189,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glClearColor(0,0,0,0); mWaterRef.bindTarget(); + gGL.setColorMask(true, true); + mWaterRef.clear(); + gGL.setColorMask(true, false); + mWaterRef.getViewport(gGLViewport); stop_glerror(); @@ -7279,6 +7225,21 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) U32 ref_mask = 0; if (LLDrawPoolWater::sNeedsDistortionUpdate) { + //initial sky pass (no user clip plane) + { //mask out everything but the sky + U32 tmp = mRenderTypeMask; + mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) | + (1 << LLPipeline::RENDER_TYPE_WL_SKY)); + static LLCullResult result; + updateCull(camera, result); + stateSort(camera, result); + mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) | + (1 << LLPipeline::RENDER_TYPE_CLOUDS) | + (1 << LLPipeline::RENDER_TYPE_WL_SKY)); + renderGeom(camera, TRUE); + mRenderTypeMask = tmp; + } + U32 mask = mRenderTypeMask; mRenderTypeMask &= ~((1<<LLPipeline::RENDER_TYPE_WATER) | (1<<LLPipeline::RENDER_TYPE_GROUND) | @@ -7306,10 +7267,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLGLDisable cull(GL_CULL_FACE); updateCull(camera, ref_result, 1); stateSort(camera, ref_result); - gGL.setColorMask(true, true); - mWaterRef.clear(); - gGL.setColorMask(true, false); - } else { @@ -7322,22 +7279,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) mRenderTypeMask = mask; } - //initial sky pass (no user clip plane) - { //mask out everything but the sky - U32 tmp = mRenderTypeMask; - mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) | - (1 << LLPipeline::RENDER_TYPE_WL_SKY)); - static LLCullResult result; - updateCull(camera, result); - stateSort(camera, result); - mRenderTypeMask = tmp & ((1 << LLPipeline::RENDER_TYPE_SKY) | - (1 << LLPipeline::RENDER_TYPE_CLOUDS) | - (1 << LLPipeline::RENDER_TYPE_WL_SKY)); - renderGeom(camera, TRUE); - mRenderTypeMask = tmp; - } - - if (LLDrawPoolWater::sNeedsDistortionUpdate) { mRenderTypeMask = ref_mask; @@ -8744,7 +8685,8 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) sShadowRender = TRUE; sImpostorRender = TRUE; - markVisible(avatar->mDrawable, *LLViewerCamera::getInstance()); + LLViewerCamera* viewer_camera = LLViewerCamera::getInstance(); + markVisible(avatar->mDrawable, *viewer_camera); LLVOAvatar::sUseImpostors = FALSE; LLVOAvatar::attachment_map_t::iterator iter; @@ -8759,7 +8701,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) { if (LLViewerObject* attached_object = (*attachment_iter)) { - markVisible(attached_object->mDrawable->getSpatialBridge(), *LLViewerCamera::getInstance()); + markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); } } } @@ -8769,9 +8711,9 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) const LLVector3* ext = avatar->mDrawable->getSpatialExtents(); LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset()); - LLCamera camera = *LLViewerCamera::getInstance(); + LLCamera camera = *viewer_camera; - camera.lookAt(LLViewerCamera::getInstance()->getOrigin(), pos, LLViewerCamera::getInstance()->getUpAxis()); + camera.lookAt(viewer_camera->getOrigin(), pos, viewer_camera->getUpAxis()); LLVector2 tdim; @@ -8814,7 +8756,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) glClearStencil(0); // get the number of pixels per angle - F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * LLViewerCamera::getInstance()->getView()); + F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView()); //get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing) U32 resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512); |