Search
lxdream.org :: lxdream :: r1076:18c164e8aec4
lxdream 0.9.1
released Jun 29
Download Now
changeset1076:18c164e8aec4
parent1075:1a21750d300c
child1077:136fc24d17ef
authornkeynes
dateMon Aug 03 08:41:11 2009 +1000 (10 years ago)
Rearrange frame output slightly.
pvr2_display_frame renamed to pvr2_next_frame and changed to update the
frame data without displaying it.
pvr2_redraw_display renamed to pvr2_draw_frame, called internally after
pvr2_next_frame
Add swap_buffers() method to the display driver
Remove explicit glDrawBuffer() calls where they're referencing the window.
pvr2_draw_frame now gets to decide where to draw.
Add force_vsync flag to force double-buffering (not configurable yet)
src/display.h
src/drivers/gl_fbo.c
src/drivers/video_gl.c
src/drivers/video_glx.c
src/drivers/video_gtk.c
src/drivers/video_nsgl.m
src/drivers/video_osx.m
src/pvr2/pvr2.c
src/pvr2/pvr2.h
1.1 --- a/src/display.h Fri Jul 31 13:45:32 2009 +1000
1.2 +++ b/src/display.h Mon Aug 03 08:41:11 2009 +1000
1.3 @@ -194,6 +194,11 @@
1.4 void (*display_blank)( uint32_t rgb );
1.5
1.6 /**
1.7 + * Swap front/back window buffers
1.8 + */
1.9 + void (*swap_buffers)();
1.10 +
1.11 + /**
1.12 * Copy the image data from the GL buffer to the target memory buffer,
1.13 * using the format etc from the buffer. This may force a glFinish()
1.14 * but does not invalidate the buffer.
2.1 --- a/src/drivers/gl_fbo.c Fri Jul 31 13:45:32 2009 +1000
2.2 +++ b/src/drivers/gl_fbo.c Mon Aug 03 08:41:11 2009 +1000
2.3 @@ -113,8 +113,6 @@
2.4 driver->read_render_buffer = gl_fbo_read_render_buffer;
2.5
2.6 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
2.7 - glDrawBuffer(GL_FRONT);
2.8 - glReadBuffer(GL_FRONT);
2.9 }
2.10
2.11 void gl_fbo_shutdown()
2.12 @@ -341,6 +339,7 @@
2.13 void gl_fbo_detach()
2.14 {
2.15 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
2.16 + /* Make sure texture attachment is not a current draw/read buffer */
2.17 glDrawBuffer( GL_FRONT );
2.18 glReadBuffer( GL_FRONT );
2.19 }
3.1 --- a/src/drivers/video_gl.c Fri Jul 31 13:45:32 2009 +1000
3.2 +++ b/src/drivers/video_gl.c Mon Aug 03 08:41:11 2009 +1000
3.3 @@ -43,7 +43,6 @@
3.4 glDisable( GL_DEPTH_TEST );
3.5 glDisable( GL_SCISSOR_TEST );
3.6 glDisable( GL_CULL_FACE );
3.7 - glDrawBuffer( GL_FRONT );
3.8 }
3.9
3.10 void gl_display_render_buffer( render_buffer_t buffer )
4.1 --- a/src/drivers/video_glx.c Fri Jul 31 13:45:32 2009 +1000
4.2 +++ b/src/drivers/video_glx.c Mon Aug 03 08:41:11 2009 +1000
4.3 @@ -42,6 +42,8 @@
4.4 static gboolean glx_pbuffer_supported = FALSE;
4.5 static GLuint glx_pbuffer_texture = 0;
4.6
4.7 +static void video_glx_swap_buffers( void );
4.8 +
4.9 /* Prototypes for pbuffer support methods */
4.10 static void glx_pbuffer_init( display_driver_t driver );
4.11 static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height, GLuint tex_id );
4.12 @@ -207,6 +209,7 @@
4.13
4.14 gboolean video_glx_init_driver( display_driver_t driver )
4.15 {
4.16 + driver->swap_buffers = video_glx_swap_buffers;
4.17 if( gl_fbo_is_supported() ) { // First preference
4.18 gl_fbo_init(driver);
4.19 } else if( glx_pbuffer_supported ) {
4.20 @@ -255,7 +258,7 @@
4.21 }
4.22
4.23
4.24 -void video_glx_swap_buffers( void )
4.25 +static void video_glx_swap_buffers( void )
4.26 {
4.27 glXSwapBuffers( video_x11_display, video_x11_window );
4.28 }
4.29 @@ -353,7 +356,6 @@
4.30 {
4.31 glFinish();
4.32 glReadBuffer( GL_FRONT );
4.33 - glDrawBuffer( GL_FRONT );
4.34 glXMakeContextCurrent( video_x11_display, (GLXPbuffer)buffer->buf_id, (GLXPbuffer)buffer->buf_id, glx_context );
4.35 glBindTexture( GL_TEXTURE_RECTANGLE_ARB, glx_pbuffer_texture );
4.36 glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, buffer->width, buffer->height, 0 );
5.1 --- a/src/drivers/video_gtk.c Fri Jul 31 13:45:32 2009 +1000
5.2 +++ b/src/drivers/video_gtk.c Mon Aug 03 08:41:11 2009 +1000
5.3 @@ -136,11 +136,11 @@
5.4 video_gtk_keycode_to_dckeysym,
5.5 video_gtk_keycode_to_keysym,
5.6 NULL, NULL, NULL, NULL, NULL, NULL,
5.7 - video_gtk_display_blank, NULL };
5.8 + video_gtk_display_blank, NULL, NULL };
5.9
5.10 gboolean video_gtk_expose_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data )
5.11 {
5.12 - pvr2_redraw_display();
5.13 + pvr2_draw_frame();
5.14 return TRUE;
5.15 }
5.16
5.17 @@ -148,7 +148,7 @@
5.18 {
5.19 video_width = event->width;
5.20 video_height = event->height;
5.21 - pvr2_redraw_display();
5.22 + pvr2_draw_frame();
5.23 return TRUE;
5.24 }
5.25
6.1 --- a/src/drivers/video_nsgl.m Fri Jul 31 13:45:32 2009 +1000
6.2 +++ b/src/drivers/video_nsgl.m Mon Aug 03 08:41:11 2009 +1000
6.3 @@ -40,9 +40,14 @@
6.4 [nsgl_context setView: view];
6.5 [nsgl_context makeCurrentContext];
6.6 [pool release];
6.7 + driver->swap_buffers = video_nsgl_swap_buffers;
6.8 if( gl_fbo_is_supported() ) {
6.9 gl_fbo_init(driver);
6.10 } else {
6.11 + /* Note there is a 'native' buffer framework, but since all current
6.12 + * Apple drivers appear to support FBO, there's not much point in
6.13 + * doing the work to support them.
6.14 + */
6.15 ERROR( "FBO not supported" );
6.16 return FALSE;
6.17 }
7.1 --- a/src/drivers/video_osx.m Fri Jul 31 13:45:32 2009 +1000
7.2 +++ b/src/drivers/video_osx.m Mon Aug 03 08:41:11 2009 +1000
7.3 @@ -126,7 +126,7 @@
7.4 video_height = size.height;
7.5 video_nsgl_update();
7.6 }
7.7 - pvr2_redraw_display();
7.8 + pvr2_draw_frame();
7.9 }
7.10 - (void)keyDown: (NSEvent *) event
7.11 {
8.1 --- a/src/pvr2/pvr2.c Fri Jul 31 13:45:32 2009 +1000
8.2 +++ b/src/pvr2/pvr2.c Mon Aug 03 08:41:11 2009 +1000
8.3 @@ -47,9 +47,7 @@
8.4 static render_buffer_t pvr2_next_render_buffer( );
8.5 static render_buffer_t pvr2_frame_buffer_to_render_buffer( frame_buffer_t frame );
8.6 uint32_t pvr2_get_sync_status();
8.7 -
8.8 -void pvr2_display_frame( void );
8.9 -
8.10 +static gboolean force_vsync = FALSE;
8.11 static int output_colour_formats[] = { COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGR888, COLFMT_BGRA8888 };
8.12 static int render_colour_formats[8] = {
8.13 COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGRA4444, COLFMT_BGRA1555,
8.14 @@ -341,7 +339,8 @@
8.15 (old_line_count < pvr2_state.retrace_end_line ||
8.16 old_line_count > pvr2_state.line_count) ) {
8.17 pvr2_state.frame_count++;
8.18 - pvr2_display_frame();
8.19 + pvr2_next_frame();
8.20 + pvr2_draw_frame();
8.21 }
8.22 }
8.23
8.24 @@ -357,13 +356,28 @@
8.25 return pvr2_state.frame_count;
8.26 }
8.27
8.28 -void pvr2_redraw_display()
8.29 +/**
8.30 + * Draw the base (emulated) frame only.
8.31 + */
8.32 +static void pvr2_draw_base_frame()
8.33 +{
8.34 + if( displayed_render_buffer == NULL ) {
8.35 + display_driver->display_blank(displayed_border_colour);
8.36 + } else {
8.37 + display_driver->display_render_buffer(displayed_render_buffer);
8.38 + }
8.39 +}
8.40 +
8.41 +void pvr2_draw_frame()
8.42 {
8.43 if( display_driver != NULL ) {
8.44 - if( displayed_render_buffer == NULL ) {
8.45 - display_driver->display_blank(displayed_border_colour);
8.46 + if( force_vsync ) {
8.47 + glDrawBuffer( GL_BACK );
8.48 + pvr2_draw_base_frame();
8.49 + display_driver->swap_buffers();
8.50 } else {
8.51 - display_driver->display_render_buffer(displayed_render_buffer);
8.52 + glDrawBuffer( GL_FRONT );
8.53 + pvr2_draw_base_frame();
8.54 }
8.55 }
8.56 }
8.57 @@ -380,28 +394,24 @@
8.58
8.59
8.60 /**
8.61 - * Display the next frame, copying the current contents of video ram to
8.62 + * Advance to the next frame, copying the current contents of video ram to
8.63 * the window. If the video configuration has changed, first recompute the
8.64 * new frame size/depth.
8.65 */
8.66 -void pvr2_display_frame( void )
8.67 +void pvr2_next_frame( void )
8.68 {
8.69 int dispmode = MMIO_READ( PVR2, DISP_MODE );
8.70 int vidcfg = MMIO_READ( PVR2, DISP_SYNCCFG );
8.71 gboolean bEnabled = (dispmode & DISPMODE_ENABLE) && (vidcfg & DISPCFG_VO ) ? TRUE : FALSE;
8.72
8.73 - if( display_driver == NULL ) {
8.74 - return; /* can't really do anything much */
8.75 - } else if( !bEnabled ) {
8.76 + if( !bEnabled ) {
8.77 /* Output disabled == black */
8.78 displayed_render_buffer = NULL;
8.79 displayed_border_colour = 0;
8.80 - display_driver->display_blank( 0 );
8.81 } else if( MMIO_READ( PVR2, DISP_CFG2 ) & 0x08 ) {
8.82 /* Enabled but blanked - border colour */
8.83 displayed_border_colour = MMIO_READ( PVR2, DISP_BORDER );
8.84 displayed_render_buffer = NULL;
8.85 - display_driver->display_blank( displayed_border_colour );
8.86 } else {
8.87 /* Real output - determine dimensions etc */
8.88 struct frame_buffer fbuf;
8.89 @@ -448,9 +458,6 @@
8.90 rbuf = pvr2_frame_buffer_to_render_buffer( &fbuf );
8.91 }
8.92 displayed_render_buffer = rbuf;
8.93 - if( rbuf != NULL ) {
8.94 - display_driver->display_render_buffer( rbuf );
8.95 - }
8.96 }
8.97 }
8.98
9.1 --- a/src/pvr2/pvr2.h Fri Jul 31 13:45:32 2009 +1000
9.2 +++ b/src/pvr2/pvr2.h Mon Aug 03 08:41:11 2009 +1000
9.3 @@ -71,10 +71,17 @@
9.4 #define RENDER_CHEAPMOD 2 /* Render cheap-modified polygons */
9.5 #define RENDER_FULLMOD 3 /* Render the fully-modified version of the polygons */
9.6
9.7 +/**
9.8 + * Advance to the next frame
9.9 + */
9.10 void pvr2_next_frame( void );
9.11 +
9.12 +/**
9.13 + * Draw the current frame on the output window.
9.14 + */
9.15 +void pvr2_draw_frame();
9.16 void pvr2_set_base_address( uint32_t );
9.17 int pvr2_get_frame_count( void );
9.18 -void pvr2_redraw_display();
9.19 gboolean pvr2_save_next_scene( const gchar *filename );
9.20
9.21 #define PVR2_CMD_END_OF_LIST 0x00
.