* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file utils.c
+ * Utility functions for DRI drivers.
*
- * Authors:
- * Ian Romanick <idr@us.ibm.com>
+ * \author Ian Romanick <idr@us.ibm.com>
*/
-/* $XFree86:$ */
#include <string.h>
#include <stdlib.h>
#include "extensions.h"
#include "utils.h"
-#if !defined( DRI_NEW_INTERFACE_ONLY ) && !defined( _SOLO )
+#if !defined( DRI_NEW_INTERFACE_ONLY )
#include "xf86dri.h" /* For XF86DRIQueryVersion prototype. */
#endif
#include "x86/common_x86_asm.h"
#endif
+#if defined(USE_PPC_ASM)
+#include "ppc/common_ppc_features.h"
+#endif
+
unsigned
driParseDebugString( const char * debug,
const struct dri_debug_control * control )
-
+/**
+ * Create the \c GL_RENDERER string for DRI drivers.
+ *
+ * Almost all DRI drivers use a \c GL_RENDERER string of the form:
+ *
+ * "Mesa DRI <chip> <driver date> <AGP speed) <CPU information>"
+ *
+ * Using the supplied chip name, driver data, and AGP speed, this function
+ * creates the string.
+ *
+ * \param buffer Buffer to hold the \c GL_RENDERER string.
+ * \param hardware_name Name of the hardware.
+ * \param driver_date Driver date.
+ * \param agp_mode AGP mode (speed).
+ *
+ * \returns
+ * The length of the string stored in \c buffer. This does \b not include
+ * the terminating \c NUL character.
+ */
unsigned
driGetRendererString( char * buffer, const char * hardware_name,
const char * driver_date, GLuint agp_mode )
{
-#ifdef USE_X86_ASM
- char * x86_str = "";
- char * mmx_str = "";
- char * tdnow_str = "";
- char * sse_str = "";
-#endif
+#define MAX_INFO 4
+ const char * cpu[MAX_INFO];
+ unsigned next = 0;
+ unsigned i;
unsigned offset;
*/
#ifdef USE_X86_ASM
if ( _mesa_x86_cpu_features ) {
- x86_str = " x86";
+ cpu[next] = " x86";
+ next++;
}
# ifdef USE_MMX_ASM
if ( cpu_has_mmx ) {
- mmx_str = (cpu_has_mmxext) ? "/MMX+" : "/MMX";
+ cpu[next] = (cpu_has_mmxext) ? "/MMX+" : "/MMX";
+ next++;
}
# endif
# ifdef USE_3DNOW_ASM
if ( cpu_has_3dnow ) {
- tdnow_str = (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!";
+ cpu[next] = (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!";
+ next++;
}
# endif
# ifdef USE_SSE_ASM
if ( cpu_has_xmm ) {
- sse_str = (cpu_has_xmm2) ? "/SSE2" : "/SSE";
+ cpu[next] = (cpu_has_xmm2) ? "/SSE2" : "/SSE";
+ next++;
}
# endif
- offset += sprintf( & buffer[ offset ], "%s%s%s%s",
- x86_str, mmx_str, tdnow_str, sse_str );
-
#elif defined(USE_SPARC_ASM)
- offset += sprintf( & buffer[ offset ], " Sparc" );
+ cpu[0] = " SPARC";
+ next = 1;
+
+#elif defined(USE_PPC_ASM)
+ if ( _mesa_ppc_cpu_features ) {
+ cpu[next] = (cpu_has_64) ? " PowerPC 64" : " PowerPC";
+ next++;
+ }
+
+# ifdef USE_VMX_ASM
+ if ( cpu_has_vmx ) {
+ cpu[next] = "/Altivec";
+ next++;
+ }
+# endif
+ if ( ! cpu_has_fpu ) {
+ cpu[next] = "/No FPU";
+ next++;
+ }
#endif
+ for ( i = 0 ; i < next ; i++ ) {
+ const size_t len = strlen( cpu[i] );
+
+ strncpy( & buffer[ offset ], cpu[i], len );
+ offset += len;
+ }
+
return offset;
}
"but got version %d.%d.%d";
int major, minor, patch;
-#ifndef _SOLO
/* Check the DRI version */
if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
if (major != dri_major || minor < dri_minor) {
sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
return GL_FALSE;
}
-#else
- (void)major;(void)minor;(void)patch;
-#endif
/* Check that the DRM driver version is compatible */
if (sPriv->drmMajor != drm_major || sPriv->drmMinor < drm_minor) {