Search
lxdream.org :: lxdream :: r1134:f502f3d32f90
lxdream 0.9.1
released Jun 29
Download Now
changeset1134:f502f3d32f90
parent1133:f3da7d810d5c
child1135:68daed8f38af
authornkeynes
dateFri Oct 22 20:55:32 2010 +1000 (13 years ago)
Dump more information with --gl-info, and print it a little more nicely
src/display.h
src/drivers/video_glx.c
src/drivers/video_nsgl.m
src/drivers/video_null.c
src/main.c
src/pvr2/gl_sl.c
src/pvr2/glutil.c
src/pvr2/glutil.h
1.1 --- a/src/display.h Wed Oct 20 17:56:59 2010 +1000
1.2 +++ b/src/display.h Fri Oct 22 20:55:32 2010 +1000
1.3 @@ -104,6 +104,7 @@
1.4 };
1.5
1.6 struct display_capabilities {
1.7 + gboolean has_gl;
1.8 int stencil_bits; /* 0 = no stencil buffer */
1.9 };
1.10
1.11 @@ -211,6 +212,11 @@
1.12 gboolean (*read_render_buffer)( unsigned char *target, render_buffer_t buffer,
1.13 int rowstride, int format );
1.14
1.15 + /**
1.16 + * Dump driver-specific information about the implementation to the given stream
1.17 + */
1.18 + void (*print_info)( FILE *out );
1.19 +
1.20 struct display_capabilities capabilities;
1.21 } *display_driver_t;
1.22
2.1 --- a/src/drivers/video_glx.c Wed Oct 20 17:56:59 2010 +1000
2.2 +++ b/src/drivers/video_glx.c Fri Oct 22 20:55:32 2010 +1000
2.3 @@ -43,6 +43,7 @@
2.4 static GLuint glx_pbuffer_texture = 0;
2.5
2.6 static void video_glx_swap_buffers( void );
2.7 +static void video_glx_print_info( FILE *out );
2.8
2.9 /* Prototypes for pbuffer support methods */
2.10 static void glx_pbuffer_init( display_driver_t driver );
2.11 @@ -167,6 +168,27 @@
2.12 return TRUE;
2.13 }
2.14
2.15 +static void video_glx_print_info( FILE *out )
2.16 +{
2.17 + XWindowAttributes attr;
2.18 +
2.19 + if( !XGetWindowAttributes(video_x11_display, video_x11_window, &attr) )
2.20 + return; /* Failed */
2.21 + int screen = XScreenNumberOfScreen(attr.screen);
2.22 +
2.23 + fprintf( out, "GLX Server: %s %s\n", glXQueryServerString(video_x11_display, screen, GLX_VENDOR),
2.24 + glXQueryServerString(video_x11_display, screen, GLX_VERSION) );
2.25 + fprintf( out, "GLX Client: %s %s\n", glXGetClientString(video_x11_display, GLX_VENDOR),
2.26 + glXGetClientString(video_x11_display, GLX_VERSION) );
2.27 + fprintf( out, "GLX Server Extensions:\n" );
2.28 + fprint_extensions( out, glXQueryServerString(video_x11_display, screen, GLX_EXTENSIONS) );
2.29 + fprintf( out, "GLX Client Extensions:\n" );
2.30 + fprint_extensions( out, glXGetClientString(video_x11_display, GLX_EXTENSIONS) );
2.31 + fprintf( out, "GLX Extensions:\n" );
2.32 + fprint_extensions( out, glXQueryExtensionsString(video_x11_display, screen) );
2.33 +
2.34 +}
2.35 +
2.36 gboolean video_glx_init_context( Display *display, Window window )
2.37 {
2.38 if( glx_fbconfig_supported ) {
2.39 @@ -210,6 +232,8 @@
2.40 gboolean video_glx_init_driver( display_driver_t driver )
2.41 {
2.42 driver->swap_buffers = video_glx_swap_buffers;
2.43 + driver->print_info = video_glx_print_info;
2.44 + driver->capabilities.has_gl = TRUE;
2.45 if( gl_fbo_is_supported() ) { // First preference
2.46 gl_fbo_init(driver);
2.47 } else if( glx_pbuffer_supported ) {
3.1 --- a/src/drivers/video_nsgl.m Wed Oct 20 17:56:59 2010 +1000
3.2 +++ b/src/drivers/video_nsgl.m Fri Oct 22 20:55:32 2010 +1000
3.3 @@ -41,6 +41,7 @@
3.4 [nsgl_context makeCurrentContext];
3.5 [pool release];
3.6 driver->swap_buffers = video_nsgl_swap_buffers;
3.7 + driver->capabilities.has_gl = TRUE;
3.8 if( gl_fbo_is_supported() ) {
3.9 gl_fbo_init(driver);
3.10 } else {
4.1 --- a/src/drivers/video_null.c Wed Oct 20 17:56:59 2010 +1000
4.2 +++ b/src/drivers/video_null.c Fri Oct 22 20:55:32 2010 +1000
4.3 @@ -76,4 +76,5 @@
4.4 video_null_display_render_buffer,
4.5 video_null_display_blank,
4.6 video_null_swap_buffers,
4.7 - video_null_read_render_buffer };
4.8 + video_null_read_render_buffer,
4.9 + NULL };
5.1 --- a/src/main.c Wed Oct 20 17:56:59 2010 +1000
5.2 +++ b/src/main.c Fri Oct 22 20:55:32 2010 +1000
5.3 @@ -254,6 +254,9 @@
5.4 ERROR( "Video driver '%s' failed to initialize (could not connect to display?)",
5.5 display_driver->name );
5.6 exit(2);
5.7 + } else if( display_driver->capabilities.has_gl == FALSE ) {
5.8 + ERROR( "Video driver '%s' has no GL capabilities.", display_driver_name );
5.9 + exit(2);
5.10 }
5.11 glPrintInfo(stdout);
5.12 exit(0);
6.1 --- a/src/pvr2/gl_sl.c Wed Oct 20 17:56:59 2010 +1000
6.2 +++ b/src/pvr2/gl_sl.c Fri Oct 22 20:55:32 2010 +1000
6.3 @@ -51,6 +51,11 @@
6.4 isGLExtensionSupported("GL_ARB_shading_language_100");
6.5 }
6.6
6.7 +const char *glsl_get_version()
6.8 +{
6.9 + return glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
6.10 +}
6.11 +
6.12 void glsl_print_error( char *msg, GLhandleARB obj )
6.13 {
6.14 char buf[MAX_ERROR_BUF];
6.15 @@ -156,6 +161,11 @@
6.16 isGLExtensionSupported("GL_ARB_shading_language_100");
6.17 }
6.18
6.19 +const char *glsl_get_version()
6.20 +{
6.21 + return glGetString(GL_SHADING_LANGUAGE_VERSION);
6.22 +}
6.23 +
6.24 gboolean glsl_check_shader_error( char *msg, GLuint shader )
6.25 {
6.26 GLint value;
6.27 @@ -256,6 +266,11 @@
6.28 return FALSE;
6.29 }
6.30
6.31 +int glsl_get_version()
6.32 +{
6.33 + return 0;
6.34 +}
6.35 +
6.36 gl_shader_t glsl_create_vertex_shader( const char *source )
6.37 {
6.38 return 0;
7.1 --- a/src/pvr2/glutil.c Wed Oct 20 17:56:59 2010 +1000
7.2 +++ b/src/pvr2/glutil.c Fri Oct 22 20:55:32 2010 +1000
7.3 @@ -41,6 +41,12 @@
7.4 return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");
7.5 }
7.6
7.7 +gboolean isGLVertexRangeSupported()
7.8 +{
7.9 + return isGLExtensionSupported("GL_APPLE_vertex_array_range") ||
7.10 + isGLExtensionSupported("GL_NV_vertex_array_range");
7.11 +}
7.12 +
7.13 /**
7.14 * Test if a specific extension is supported. From opengl.org
7.15 * @param extension extension name to check for
7.16 @@ -86,23 +92,66 @@
7.17 return strcmp(*ca, *cb);
7.18 }
7.19
7.20 -void glPrintInfo( FILE *out )
7.21 +#define DEFAULT_TERMINAL_COLUMNS 80
7.22 +#define DEFAULT_COLUMN_WIDTH 34
7.23 +
7.24 +/**
7.25 + * Format a GL extension list (or other space-separated string) nicely, and
7.26 + * print to the given output stream.
7.27 + */
7.28 +
7.29 +void fprint_extensions( FILE *out, const char *extensions )
7.30 {
7.31 - const gchar *extensions = (const gchar *)glGetString(GL_EXTENSIONS);
7.32 - gchar **ext_split = g_strsplit(extensions, " ", 0);
7.33 - unsigned int i, count;
7.34 + unsigned int i, j, count, maxlen = DEFAULT_COLUMN_WIDTH, columns, per_column, terminal_columns;
7.35 + const char *terminal_columns_str = getenv("COLUMNS");
7.36 + if( terminal_columns_str == NULL || (terminal_columns = strtol(terminal_columns_str,0,10)) == 0 )
7.37 + terminal_columns = DEFAULT_TERMINAL_COLUMNS;
7.38
7.39 - for( count = 0; ext_split[count] != NULL; count++ );
7.40 + if( extensions == NULL || extensions[0] == '\0' )
7.41 + return;
7.42 +
7.43 + gchar *ext_dup = g_strdup(extensions);
7.44 + gchar **ext_split = g_strsplit(g_strstrip(extensions), " ", 0);
7.45 + for( count = 0; ext_split[count] != NULL; count++ ) {
7.46 + unsigned len = strlen(ext_split[count]);
7.47 + if( len > maxlen )
7.48 + maxlen = len;
7.49 + }
7.50 +
7.51 + columns = terminal_columns / (maxlen+2);
7.52 + if( columns == 0 )
7.53 + columns = 1;
7.54 + per_column = (count+columns-1) / columns;
7.55
7.56 qsort(ext_split, count, sizeof(gchar *), compare_charp);
7.57
7.58 + for( i=0; i<per_column; i++ ) {
7.59 + for( j=0; j<columns; j++ ) {
7.60 + unsigned idx = i + (j*per_column);
7.61 + if( idx < count )
7.62 + fprintf( out, " %-*s", maxlen, ext_split[idx] );
7.63 + }
7.64 + fprintf( out, "\n" );
7.65 + }
7.66 + g_strfreev(ext_split);
7.67 + g_free(ext_dup);
7.68 +}
7.69 +
7.70 +void glPrintInfo( FILE *out )
7.71 +{
7.72 fprintf( out, "GL Vendor: %s\n", glGetString(GL_VENDOR) );
7.73 fprintf( out, "GL Renderer: %s\n", glGetString(GL_RENDERER) );
7.74 fprintf( out, "GL Version: %s\n", glGetString(GL_VERSION) );
7.75 + if( glsl_is_supported() ) {
7.76 + const char * version = glsl_get_version();
7.77 + fprintf( out, "SL Version: %s\n", version );
7.78 + }
7.79
7.80 - fprintf( out, "Supported GL Extensions:\n" );
7.81 - for( i=0; ext_split[i] != NULL; i++ ) {
7.82 - fprintf( out, " %s\n", ext_split[i] );
7.83 + fprintf( out, "GL Extensions:\n" );
7.84 +
7.85 + fprint_extensions( out, (const gchar *)glGetString(GL_EXTENSIONS) );
7.86 + if( display_driver && display_driver->print_info ) {
7.87 + fprintf( out, "\n");
7.88 + display_driver->print_info(out);
7.89 }
7.90 - g_strfreev(ext_split);
7.91 }
8.1 --- a/src/pvr2/glutil.h Wed Oct 20 17:56:59 2010 +1000
8.2 +++ b/src/pvr2/glutil.h Fri Oct 22 20:55:32 2010 +1000
8.3 @@ -45,16 +45,21 @@
8.4 gboolean isGLSecondaryColorSupported();
8.5
8.6 gboolean isGLVertexBufferSupported();
8.7 +gboolean isGLVertexRangeSupported();
8.8 gboolean isGLPixelBufferSupported();
8.9 gboolean isGLMirroredTextureSupported();
8.10
8.11 /****** Shader handling (gl_sl.c) *****/
8.12 gboolean glsl_is_supported(void);
8.13 +const char *glsl_get_version(void);
8.14 gboolean glsl_load_shaders( );
8.15 void glsl_unload_shaders(void);
8.16 gboolean glsl_set_shader( unsigned program_id );
8.17 void glsl_clear_shader();
8.18
8.19 +/* Convenience formatting function for driver use */
8.20 +void fprint_extensions( FILE *out, const char *extensions );
8.21 +
8.22 #ifdef __cplusplus
8.23 }
8.24 #endif
.