diff options
Diffstat (limited to 'linden/indra/newview/llviewerdisplay.cpp')
-rw-r--r-- | linden/indra/newview/llviewerdisplay.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/linden/indra/newview/llviewerdisplay.cpp b/linden/indra/newview/llviewerdisplay.cpp index cdffe33..47c9c32 100644 --- a/linden/indra/newview/llviewerdisplay.cpp +++ b/linden/indra/newview/llviewerdisplay.cpp | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "llviewerdisplay.h" | 34 | #include "llviewerdisplay.h" |
35 | 35 | ||
36 | #include "llgl.h" | 36 | #include "llgl.h" |
37 | #include "llglimmediate.h" | 37 | #include "llrender.h" |
38 | #include "llglheaders.h" | 38 | #include "llglheaders.h" |
39 | #include "llagent.h" | 39 | #include "llagent.h" |
40 | #include "llviewercontrol.h" | 40 | #include "llviewercontrol.h" |
@@ -99,6 +99,9 @@ BOOL gDisplaySwapBuffers = FALSE; | |||
99 | BOOL gResizeScreenTexture = FALSE; | 99 | BOOL gResizeScreenTexture = FALSE; |
100 | BOOL gSnapshot = FALSE; | 100 | BOOL gSnapshot = FALSE; |
101 | 101 | ||
102 | U32 gRecentFrameCount = 0; // number of 'recent' frames | ||
103 | LLFrameTimer gRecentTime; | ||
104 | |||
102 | // Rendering stuff | 105 | // Rendering stuff |
103 | void pre_show_depth_buffer(); | 106 | void pre_show_depth_buffer(); |
104 | void post_show_depth_buffer(); | 107 | void post_show_depth_buffer(); |
@@ -125,27 +128,24 @@ void display_startup() | |||
125 | 128 | ||
126 | // Required for HTML update in login screen | 129 | // Required for HTML update in login screen |
127 | static S32 frame_count = 0; | 130 | static S32 frame_count = 0; |
128 | #ifndef LL_RELEASE_FOR_DOWNLOAD | 131 | |
129 | LLGLState::checkStates(); | 132 | LLGLState::checkStates(); |
130 | LLGLState::checkTextureChannels(); | 133 | LLGLState::checkTextureChannels(); |
131 | #endif | ||
132 | 134 | ||
133 | if (frame_count++ > 1) // make sure we have rendered a frame first | 135 | if (frame_count++ > 1) // make sure we have rendered a frame first |
134 | { | 136 | { |
135 | LLDynamicTexture::updateAllInstances(); | 137 | LLDynamicTexture::updateAllInstances(); |
136 | } | 138 | } |
137 | 139 | ||
138 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
139 | LLGLState::checkStates(); | 140 | LLGLState::checkStates(); |
140 | LLGLState::checkTextureChannels(); | 141 | LLGLState::checkTextureChannels(); |
141 | #endif | ||
142 | 142 | ||
143 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 143 | glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
144 | LLGLSUIDefault gls_ui; | 144 | LLGLSUIDefault gls_ui; |
145 | gPipeline.disableLights(); | 145 | gPipeline.disableLights(); |
146 | 146 | ||
147 | gViewerWindow->setup2DRender(); | 147 | gViewerWindow->setup2DRender(); |
148 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 148 | gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); |
149 | 149 | ||
150 | gGL.color4f(1,1,1,1); | 150 | gGL.color4f(1,1,1,1); |
151 | gViewerWindow->draw(); | 151 | gViewerWindow->draw(); |
@@ -153,10 +153,8 @@ void display_startup() | |||
153 | 153 | ||
154 | LLVertexBuffer::unbind(); | 154 | LLVertexBuffer::unbind(); |
155 | 155 | ||
156 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
157 | LLGLState::checkStates(); | 156 | LLGLState::checkStates(); |
158 | LLGLState::checkTextureChannels(); | 157 | LLGLState::checkTextureChannels(); |
159 | #endif | ||
160 | 158 | ||
161 | gViewerWindow->mWindow->swapBuffers(); | 159 | gViewerWindow->mWindow->swapBuffers(); |
162 | glClear(GL_DEPTH_BUFFER_BIT); | 160 | glClear(GL_DEPTH_BUFFER_BIT); |
@@ -186,6 +184,18 @@ void display_update_camera() | |||
186 | LLWorld::getInstance()->setLandFarClip(final_far); | 184 | LLWorld::getInstance()->setLandFarClip(final_far); |
187 | } | 185 | } |
188 | 186 | ||
187 | // Write some stats to llinfos | ||
188 | void display_stats() | ||
189 | { | ||
190 | F32 log_freq = gSavedSettings.getF32("FPSLogFrequency"); | ||
191 | if (log_freq > 0.f && gRecentTime.getElapsedTimeF32() >= log_freq) | ||
192 | { | ||
193 | F32 fps = gRecentFrameCount / log_freq; | ||
194 | llinfos << llformat("FPS: %.02f", fps) << llendl; | ||
195 | gRecentFrameCount = 0; | ||
196 | gRecentTime.reset(); | ||
197 | } | ||
198 | } | ||
189 | 199 | ||
190 | // Paint the display! | 200 | // Paint the display! |
191 | void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | 201 | void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) |
@@ -204,10 +214,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
204 | 214 | ||
205 | LLVertexBuffer::unbind(); | 215 | LLVertexBuffer::unbind(); |
206 | 216 | ||
207 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
208 | LLGLState::checkStates(); | 217 | LLGLState::checkStates(); |
209 | LLGLState::checkTextureChannels(); | 218 | LLGLState::checkTextureChannels(); |
210 | #endif | ||
211 | 219 | ||
212 | gPipeline.disableLights(); | 220 | gPipeline.disableLights(); |
213 | 221 | ||
@@ -232,10 +240,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
232 | gViewerWindow->performPick(); | 240 | gViewerWindow->performPick(); |
233 | 241 | ||
234 | 242 | ||
235 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
236 | LLGLState::checkStates(); | 243 | LLGLState::checkStates(); |
237 | LLGLState::checkTextureChannels(); | 244 | LLGLState::checkTextureChannels(); |
238 | #endif | ||
239 | 245 | ||
240 | ////////////////////////////////////////////////////////// | 246 | ////////////////////////////////////////////////////////// |
241 | // | 247 | // |
@@ -286,6 +292,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
286 | 292 | ||
287 | gPipeline.mBackfaceCull = TRUE; | 293 | gPipeline.mBackfaceCull = TRUE; |
288 | gFrameCount++; | 294 | gFrameCount++; |
295 | gRecentFrameCount++; | ||
289 | if (gFocusMgr.getAppHasFocus()) | 296 | if (gFocusMgr.getAppHasFocus()) |
290 | { | 297 | { |
291 | gForegroundFrameCount++; | 298 | gForegroundFrameCount++; |
@@ -474,7 +481,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
474 | LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); | 481 | LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); |
475 | if (LLDynamicTexture::updateAllInstances()) | 482 | if (LLDynamicTexture::updateAllInstances()) |
476 | { | 483 | { |
477 | glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); | 484 | gGL.setColorMask(true, true); |
478 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 485 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
479 | } | 486 | } |
480 | } | 487 | } |
@@ -559,7 +566,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
559 | gPipeline.resizeScreenTexture(); | 566 | gPipeline.resizeScreenTexture(); |
560 | } | 567 | } |
561 | 568 | ||
562 | glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); | 569 | gGL.setColorMask(true, true); |
563 | glClearColor(0,0,0,0); | 570 | glClearColor(0,0,0,0); |
564 | 571 | ||
565 | if (!for_snapshot) | 572 | if (!for_snapshot) |
@@ -690,20 +697,20 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
690 | 697 | ||
691 | if (to_texture) | 698 | if (to_texture) |
692 | { | 699 | { |
693 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 700 | gGL.setColorMask(true, true); |
694 | gPipeline.mScreen.bindTarget(); | 701 | gPipeline.mScreen.bindTarget(); |
695 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 702 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
696 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); | 703 | gGL.setColorMask(true, false); |
697 | } | 704 | } |
698 | 705 | ||
699 | if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) | 706 | if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) |
700 | && !gRestoreGL) | 707 | && !gRestoreGL) |
701 | { | 708 | { |
702 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); | 709 | gGL.setColorMask(true, false); |
703 | LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; | 710 | LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; |
704 | gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); | 711 | gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); |
705 | LLPipeline::sUnderWaterRender = FALSE; | 712 | LLPipeline::sUnderWaterRender = FALSE; |
706 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 713 | gGL.setColorMask(true, true); |
707 | 714 | ||
708 | //store this frame's modelview matrix for use | 715 | //store this frame's modelview matrix for use |
709 | //when rendering next frame's occlusion queries | 716 | //when rendering next frame's occlusion queries |
@@ -741,6 +748,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) | |||
741 | send_agent_resume(); | 748 | send_agent_resume(); |
742 | LLPipeline::sRenderFrameTest = FALSE; | 749 | LLPipeline::sRenderFrameTest = FALSE; |
743 | } | 750 | } |
751 | |||
752 | display_stats(); | ||
744 | } | 753 | } |
745 | 754 | ||
746 | void render_hud_attachments() | 755 | void render_hud_attachments() |
@@ -880,9 +889,7 @@ BOOL setup_hud_matrices(BOOL for_select) | |||
880 | 889 | ||
881 | void render_ui_and_swap() | 890 | void render_ui_and_swap() |
882 | { | 891 | { |
883 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
884 | LLGLState::checkStates(); | 892 | LLGLState::checkStates(); |
885 | #endif | ||
886 | 893 | ||
887 | glPushMatrix(); | 894 | glPushMatrix(); |
888 | glLoadMatrixd(gGLLastModelView); | 895 | glLoadMatrixd(gGLLastModelView); |
@@ -918,15 +925,11 @@ void render_ui_and_swap() | |||
918 | if (!gDisconnected) | 925 | if (!gDisconnected) |
919 | { | 926 | { |
920 | render_ui_3d(); | 927 | render_ui_3d(); |
921 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
922 | LLGLState::checkStates(); | 928 | LLGLState::checkStates(); |
923 | #endif | ||
924 | } | 929 | } |
925 | 930 | ||
926 | render_ui_2d(); | 931 | render_ui_2d(); |
927 | #ifndef LL_RELEASE_FOR_DOWNLOAD | ||
928 | LLGLState::checkStates(); | 932 | LLGLState::checkStates(); |
929 | #endif | ||
930 | } | 933 | } |
931 | gGL.flush(); | 934 | gGL.flush(); |
932 | 935 | ||
@@ -1088,7 +1091,7 @@ void render_ui_2d() | |||
1088 | } | 1091 | } |
1089 | 1092 | ||
1090 | stop_glerror(); | 1093 | stop_glerror(); |
1091 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 1094 | gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); |
1092 | 1095 | ||
1093 | // render outline for HUD | 1096 | // render outline for HUD |
1094 | if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->mHUDCurZoom < 0.98f) | 1097 | if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->mHUDCurZoom < 0.98f) |
@@ -1115,7 +1118,6 @@ void render_ui_2d() | |||
1115 | LLFontGL::sCurOrigin.set(0, 0); | 1118 | LLFontGL::sCurOrigin.set(0, 0); |
1116 | } | 1119 | } |
1117 | 1120 | ||
1118 | |||
1119 | void render_disconnected_background() | 1121 | void render_disconnected_background() |
1120 | { | 1122 | { |
1121 | gGL.color4f(1,1,1,1); | 1123 | gGL.color4f(1,1,1,1); |