r410 - in trunk/code: qcommon unix win32

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Dec 4 16:40:25 EST 2005


Author: icculus
Date: 2005-12-04 16:40:25 -0500 (Sun, 04 Dec 2005)
New Revision: 410

Modified:
   trunk/code/qcommon/common.c
   trunk/code/qcommon/qcommon.h
   trunk/code/unix/unix_main.c
   trunk/code/win32/win_main.c
Log:
Better altivec cvar handling. Should fix crashes at startup, or curious 
people that toggle it on at runtime on a G3.


Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2005-12-04 14:23:46 UTC (rev 409)
+++ trunk/code/qcommon/common.c	2005-12-04 21:40:25 UTC (rev 410)
@@ -2353,6 +2353,24 @@
 #endif
 
 
+static void Com_DetectAltivec(void)
+{
+	// Only detect if user hasn't forcibly disabled it.
+	if (com_altivec->integer) {
+		static qboolean altivec = qfalse;
+		static qboolean detected = qfalse;
+		if (!detected) {
+			altivec = Sys_DetectAltivec();
+			detected = qtrue;
+		}
+
+		if (!altivec) {
+			Cvar_Set( "com_altivec", "0" );  // we don't have it! Disable support!
+		}
+	}
+}
+
+
 /*
 =================
 Com_Init
@@ -2510,9 +2528,11 @@
 
 	com_fullyInitialized = qtrue;
 
-    #if idppc_altivec
+	// always set the cvar, but only print the info if it makes sense.
+	Com_DetectAltivec();
+	#if idppc
 	Com_Printf ("Altivec support is %s\n", com_altivec->integer ? "enabled" : "disabled");
-    #endif
+	#endif
 
 	Com_Printf ("--- Common Initialization Complete ---\n");
 }
@@ -2713,6 +2733,12 @@
 	} while ( msec < minMsec );
 	Cbuf_Execute ();
 
+	if (com_altivec->modified)
+	{
+		Com_DetectAltivec();
+		com_altivec->modified = qfalse;
+	}
+
 	lastTime = com_frameTime;
 
 	// mess with msec if needed

Modified: trunk/code/qcommon/qcommon.h
===================================================================
--- trunk/code/qcommon/qcommon.h	2005-12-04 14:23:46 UTC (rev 409)
+++ trunk/code/qcommon/qcommon.h	2005-12-04 21:40:25 UTC (rev 410)
@@ -1033,6 +1033,8 @@
 
 int Sys_MonkeyShouldBeSpanked( void );
 
+qboolean Sys_DetectAltivec( void );
+
 /* This is based on the Adaptive Huffman algorithm described in Sayood's Data
  * Compression book.  The ranks are not actually stored, but implicitly defined
  * by the location of a node within a doubly-linked list */

Modified: trunk/code/unix/unix_main.c
===================================================================
--- trunk/code/unix/unix_main.c	2005-12-04 14:23:46 UTC (rev 409)
+++ trunk/code/unix/unix_main.c	2005-12-04 21:40:25 UTC (rev 410)
@@ -377,12 +377,11 @@
 }
 #endif
 
-static void Sys_DetectAltivec(void)
+qboolean Sys_DetectAltivec( void )
 {
-  // Only detect if user hasn't forcibly disabled it.
-  if (com_altivec->integer) {
-#if idppc_altivec
     qboolean altivec = qfalse;
+
+#if idppc_altivec
     #ifdef MACOS_X
     long feat = 0;
     OSErr err = Gestalt(gestaltPowerPCProcessorFeatures, &feat);
@@ -401,12 +400,9 @@
     }
     signal(SIGILL, handler);
     #endif
-
-    if (!altivec) {
-      Cvar_Set( "com_altivec", "0" );  // we don't have it! Disable support!
-    }
 #endif
-  }
+
+    return altivec;
 }
 
 void Sys_Init(void)

Modified: trunk/code/win32/win_main.c
===================================================================
--- trunk/code/win32/win_main.c	2005-12-04 14:23:46 UTC (rev 409)
+++ trunk/code/win32/win_main.c	2005-12-04 21:40:25 UTC (rev 410)
@@ -1176,6 +1176,13 @@
 }
 
 
+qboolean Sys_DetectAltivec( void )
+{
+    return qfalse;  // never altivec on Windows...at least for now.  :)
+}
+
+
+
 //=======================================================================
 
 int	totalMsec, countMsec;




More information about the quake3-commits mailing list