diff options
author | Ian Romanick <[email protected]> | 2004-10-13 19:23:26 +0000 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2004-10-13 19:23:26 +0000 |
commit | b72ed81818e63a70c1ded2789b9e22ee4c516aae (patch) | |
tree | d2ba7ad2ecd242e31127aa66d56a26d50983d42e /src/mesa/drivers/dri | |
parent | f599716b93433f423cd2e1be34ec0114a9861d3c (diff) |
Refactor the code in driGetRendererString a bit to make it easier to
add support for features of non-x86 CPU types.
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/common/utils.c | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index 99dc064826a..59401073ece 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -64,17 +64,33 @@ driParseDebugString( const char * debug, - +/** + * 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; @@ -98,33 +114,42 @@ driGetRendererString( char * buffer, const char * hardware_name, */ #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; #endif + for ( i = 0 ; i < next ; i++ ) { + const size_t len = strlen( cpu[i] ); + + strncpy( & buffer[ offset ], cpu[i], len ); + offset += len; + } + return offset; } |