aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/viewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/viewer.cpp')
-rw-r--r--linden/indra/newview/viewer.cpp142
1 files changed, 139 insertions, 3 deletions
diff --git a/linden/indra/newview/viewer.cpp b/linden/indra/newview/viewer.cpp
index 7ff6cc3..48108bd 100644
--- a/linden/indra/newview/viewer.cpp
+++ b/linden/indra/newview/viewer.cpp
@@ -205,6 +205,7 @@
205#include "llviewerbuild.h" 205#include "llviewerbuild.h"
206#include "llviewercamera.h" 206#include "llviewercamera.h"
207#include "llviewercontrol.h" 207#include "llviewercontrol.h"
208#include "llviewerjointmesh.h"
208#include "llviewerimagelist.h" 209#include "llviewerimagelist.h"
209#include "llviewerkeyboard.h" 210#include "llviewerkeyboard.h"
210#include "llviewermenu.h" 211#include "llviewermenu.h"
@@ -1077,8 +1078,10 @@ int main( int argc, char **argv )
1077 // Initialize apple menubar and various callbacks 1078 // Initialize apple menubar and various callbacks
1078 init_apple_menu(gSecondLife.c_str()); 1079 init_apple_menu(gSecondLife.c_str());
1079 1080
1081#if __ppc__
1080 // If the CPU doesn't have Altivec (i.e. it's not at least a G4), don't go any further. 1082 // If the CPU doesn't have Altivec (i.e. it's not at least a G4), don't go any further.
1081 if(!gSysCPU.hasSSE()) 1083 // Only test PowerPC - all Intel Macs have SSE.
1084 if(!gSysCPU.hasAltivec())
1082 { 1085 {
1083 std::ostringstream msg; 1086 std::ostringstream msg;
1084 msg << gSecondLife << " requires a processor with AltiVec (G4 or later)."; 1087 msg << gSecondLife << " requires a processor with AltiVec (G4 or later).";
@@ -1089,6 +1092,7 @@ int main( int argc, char **argv )
1089 remove_marker_file(); 1092 remove_marker_file();
1090 return 1; 1093 return 1;
1091 } 1094 }
1095#endif
1092 1096
1093#endif // LL_DARWIN 1097#endif // LL_DARWIN
1094 1098
@@ -2447,7 +2451,7 @@ static inline bool being_debugged()
2447 if (ret != -1) 2451 if (ret != -1)
2448 { 2452 {
2449 char buf[1024]; 2453 char buf[1024];
2450 size_t n; 2454 ssize_t n;
2451 2455
2452 n = readlink(name, buf, sizeof(buf) - 1); 2456 n = readlink(name, buf, sizeof(buf) - 1);
2453 if (n != -1) 2457 if (n != -1)
@@ -2899,7 +2903,7 @@ OSErr AEQuitHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn)
2899{ 2903{
2900 OSErr result = noErr; 2904 OSErr result = noErr;
2901 2905
2902 app_request_quit(); 2906 app_user_quit();
2903 2907
2904 return(result); 2908 return(result);
2905} 2909}
@@ -3171,6 +3175,20 @@ void app_force_quit(const char* launch_file_on_quit)
3171 gQuit = TRUE; 3175 gQuit = TRUE;
3172} 3176}
3173 3177
3178static void finish_quit(S32 option, void *userdata)
3179{
3180 if (option == 0)
3181 {
3182 app_request_quit();
3183 }
3184}
3185
3186void app_user_quit()
3187{
3188 gViewerWindow->alertXml("ConfirmQuit", finish_quit, NULL);
3189}
3190
3191
3174// Don't quit instantly. Instead, request to be logged off. 3192// Don't quit instantly. Instead, request to be logged off.
3175// Called from control-Q handler, Windows(tm) close-window message (WM_CLOSE), and Mac Quit AppleEvent handler. 3193// Called from control-Q handler, Windows(tm) close-window message (WM_CLOSE), and Mac Quit AppleEvent handler.
3176void app_request_quit() 3194void app_request_quit()
@@ -4980,6 +4998,89 @@ class LLRenderLightingDetailListener: public LLSimpleListener
4980}; 4998};
4981static LLRenderLightingDetailListener render_lighting_detail_listener; 4999static LLRenderLightingDetailListener render_lighting_detail_listener;
4982 5000
5001
5002//-------------------------------------------------------------------
5003//-------------------------------------------------------------------
5004// Vector Performance Options
5005//-------------------------------------------------------------------
5006//-------------------------------------------------------------------
5007
5008// Initially, we test the performance of the vectorization code, then
5009// turn it off if it ends up being slower. JC
5010BOOL gVectorizePerfTest = TRUE;
5011BOOL gVectorizeEnable = FALSE;
5012U32 gVectorizeProcessor = 0;
5013BOOL gVectorizeSkin = FALSE;
5014
5015void update_vector_performances(void)
5016{
5017 char *vp;
5018
5019 switch(gVectorizeProcessor)
5020 {
5021 case 2: vp = "SSE2"; break; // *TODO: replace the magic #s
5022 case 1: vp = "SSE"; break;
5023 default: vp = "COMPILER DEFAULT"; break;
5024 }
5025 llinfos << "Vectorization : " << ( gVectorizeEnable ? "ENABLED" : "DISABLED" ) << llendl ;
5026 llinfos << "Vector Processor : " << vp << llendl ;
5027 llinfos << "Vectorized Skinning : " << ( gVectorizeSkin ? "ENABLED" : "DISABLED" ) << llendl ;
5028
5029 if(gVectorizeEnable && gVectorizeSkin)
5030 {
5031 switch(gVectorizeProcessor)
5032 {
5033 case 2:
5034 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometrySSE2;
5035 break;
5036 case 1:
5037 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometrySSE;
5038 break;
5039 default:
5040 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometryVectorized;
5041 break;
5042 }
5043 }
5044 else
5045 {
5046 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometryOriginal;
5047 }
5048}
5049
5050
5051class LLVectorizationEnableListener: public LLSimpleListener
5052{
5053 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
5054 {
5055 gVectorizeEnable = event->getValue().asBoolean();
5056 update_vector_performances();
5057 return true;
5058 }
5059};
5060static LLVectorizationEnableListener vectorization_enable_listener;
5061
5062class LLVectorizeSkinListener: public LLSimpleListener
5063{
5064 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
5065 {
5066 gVectorizeSkin = event->getValue().asBoolean();
5067 update_vector_performances();
5068 return true;
5069 }
5070};
5071static LLVectorizeSkinListener vectorize_skin_listener;
5072
5073class LLVectorProcessorListener: public LLSimpleListener
5074{
5075 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
5076 {
5077 gVectorizeProcessor = event->getValue().asInteger();
5078 update_vector_performances();
5079 return true;
5080 }
5081};
5082static LLVectorProcessorListener vector_processor_listener;
5083
4983// Use these strictly for things that are constructed at startup, 5084// Use these strictly for things that are constructed at startup,
4984// or for things that are performance critical. JC 5085// or for things that are performance critical. JC
4985void saved_settings_to_globals() 5086void saved_settings_to_globals()
@@ -5031,6 +5132,38 @@ void saved_settings_to_globals()
5031 gHandleKeysAsync = gSavedSettings.getBOOL("AsyncKeyboard"); 5132 gHandleKeysAsync = gSavedSettings.getBOOL("AsyncKeyboard");
5032 LLHoverView::sShowHoverTips = gSavedSettings.getBOOL("ShowHoverTips"); 5133 LLHoverView::sShowHoverTips = gSavedSettings.getBOOL("ShowHoverTips");
5033 5134
5135 if (gSysCPU.hasAltivec())
5136 {
5137 gSavedSettings.setBOOL("VectorizeEnable", TRUE );
5138 gSavedSettings.setU32("VectorizeProcessor", 0 );
5139 }
5140 else
5141 if (gSysCPU.hasSSE2())
5142 {
5143 gSavedSettings.setBOOL("VectorizeEnable", TRUE );
5144 gSavedSettings.setU32("VectorizeProcessor", 2 );
5145 }
5146 else
5147 if (gSysCPU.hasSSE())
5148 {
5149 gSavedSettings.setBOOL("VectorizeEnable", TRUE );
5150 gSavedSettings.setU32("VectorizeProcessor", 1 );
5151 }
5152 else
5153 {
5154 // Don't bother testing or running if CPU doesn't support it. JC
5155 gSavedSettings.setBOOL("VectorizePerfTest", FALSE );
5156 gSavedSettings.setBOOL("VectorizeEnable", FALSE );
5157 gSavedSettings.setU32("VectorizeProcessor", 0 );
5158 gSavedSettings.setBOOL("VectorizeSkin", FALSE);
5159 }
5160
5161 gVectorizePerfTest = gSavedSettings.getBOOL("VectorizePerfTest");
5162 gVectorizeEnable = gSavedSettings.getBOOL("VectorizeEnable");
5163 gVectorizeProcessor = gSavedSettings.getU32("VectorizeProcessor");
5164 gVectorizeSkin = gSavedSettings.getBOOL("VectorizeSkin");
5165 update_vector_performances();
5166
5034 // Into a global in case we corrupt the list on crash. 5167 // Into a global in case we corrupt the list on crash.
5035 gCrashBehavior = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); 5168 gCrashBehavior = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING);
5036 5169
@@ -5077,6 +5210,9 @@ void saved_settings_to_globals()
5077 gSavedSettings.getControl("FlycamAxis4")->addListener(&joystick_listener); 5210 gSavedSettings.getControl("FlycamAxis4")->addListener(&joystick_listener);
5078 gSavedSettings.getControl("FlycamAxis5")->addListener(&joystick_listener); 5211 gSavedSettings.getControl("FlycamAxis5")->addListener(&joystick_listener);
5079 gSavedSettings.getControl("FlycamAxis6")->addListener(&joystick_listener); 5212 gSavedSettings.getControl("FlycamAxis6")->addListener(&joystick_listener);
5213 gSavedSettings.getControl("VectorizeEnable")->addListener(&vectorization_enable_listener);
5214 gSavedSettings.getControl("VectorizeProcessor")->addListener(&vector_processor_listener);
5215 gSavedSettings.getControl("VectorizeSkin")->addListener(&vectorize_skin_listener);
5080 5216
5081 // gAgent.init() also loads from saved settings. 5217 // gAgent.init() also loads from saved settings.
5082} 5218}