Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 441:0ff0093f3088
prev433:a4f61551d79d
next477:9a373f2ff009
author nkeynes
date Sat Oct 13 03:59:32 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Track the last-displayed render buffer, so-as not to overwrite it while its
still on-screen
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Tue Oct 09 08:48:28 2007 +0000
1.2 +++ b/src/pvr2/pvr2.c Sat Oct 13 03:59:32 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: pvr2.c,v 1.46 2007-10-09 08:48:28 nkeynes Exp $
1.6 + * $Id: pvr2.c,v 1.47 2007-10-13 03:59:32 nkeynes Exp $
1.7 *
1.8 * PVR2 (Video) Core module implementation and MMIO registers.
1.9 *
1.10 @@ -85,8 +85,9 @@
1.11 gboolean interlaced;
1.12 } pvr2_state;
1.13
1.14 -render_buffer_t render_buffers[MAX_RENDER_BUFFERS];
1.15 -int render_buffer_count = 0;
1.16 +static render_buffer_t render_buffers[MAX_RENDER_BUFFERS];
1.17 +static int render_buffer_count = 0;
1.18 +static render_buffer_t displayed_render_buffer = NULL;
1.19
1.20 /**
1.21 * Event handler for the hpos callback
1.22 @@ -136,6 +137,7 @@
1.23 render_buffers[i] = NULL;
1.24 }
1.25 render_buffer_count = 0;
1.26 + displayed_render_buffer = NULL;
1.27 }
1.28
1.29 static void pvr2_reset( void )
1.30 @@ -245,10 +247,12 @@
1.31 } else if( !bEnabled ) {
1.32 /* Output disabled == black */
1.33 display_driver->display_blank( 0 );
1.34 + displayed_render_buffer = NULL;
1.35 } else if( MMIO_READ( PVR2, DISP_CFG2 ) & 0x08 ) {
1.36 /* Enabled but blanked - border colour */
1.37 uint32_t colour = MMIO_READ( PVR2, DISP_BORDER );
1.38 display_driver->display_blank( colour );
1.39 + displayed_render_buffer = NULL;
1.40 } else {
1.41 /* Real output - determine dimensions etc */
1.42 struct frame_buffer fbuf;
1.43 @@ -289,6 +293,7 @@
1.44 fbuf.address = (fbuf.address & 0x00FFFFFF) + PVR2_RAM_BASE;
1.45
1.46 render_buffer_t rbuf = pvr2_get_render_buffer( &fbuf );
1.47 + displayed_render_buffer = rbuf;
1.48 if( rbuf != NULL ) {
1.49 display_driver->display_render_buffer( rbuf );
1.50 } else {
1.51 @@ -744,12 +749,20 @@
1.52 if( render_buffers[i]->width == width && render_buffers[i]->height == height ) {
1.53 /* needs to be the right dimensions */
1.54 if( render_buffers[i]->address == render_addr ) {
1.55 - /* perfect */
1.56 - result = render_buffers[i];
1.57 - break;
1.58 - } else if( render_buffers[i]->address == -1 && result == NULL ) {
1.59 + if( displayed_render_buffer == render_buffers[i] ) {
1.60 + /* Same address, but we can't use it because the
1.61 + * display has it. Mark it as unaddressed for later.
1.62 + render_buffers[i]->address = -1;
1.63 + } else {
1.64 + /* perfect */
1.65 + result = render_buffers[i];
1.66 + break;
1.67 + }
1.68 + } else if( render_buffers[i]->address == -1 && result == NULL &&
1.69 + displayed_render_buffer != render_buffers[i] ) {
1.70 result = render_buffers[i];
1.71 }
1.72 +
1.73 } else if( render_buffers[i]->address == render_addr ) {
1.74 /* right address, wrong size - if it's larger, flush it, otherwise
1.75 * nuke it quietly */
1.76 @@ -769,7 +782,8 @@
1.77 uint32_t field2_addr = MMIO_READ( PVR2, DISP_ADDR2 );
1.78 for( i=0; i<render_buffer_count; i++ ) {
1.79 if( render_buffers[i]->address != field1_addr &&
1.80 - render_buffers[i]->address != field2_addr ) {
1.81 + render_buffers[i]->address != field2_addr &&
1.82 + render_buffers[i] != displayed_render_buffer ) {
1.83 /* Never throw away the current "front buffer(s)" */
1.84 result = render_buffers[i];
1.85 pvr2_render_buffer_copy_to_sh4( result );
.