Search
lxdream.org :: lxdream/src/pvr2/render.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/render.c
changeset 161:408b9210395f
prev144:7f0714e89aaa
next169:abbdc6943587
author nkeynes
date Sun Jun 18 11:57:05 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change Implement render buffer invalidation
file annotate diff log raw
1.1 --- a/src/pvr2/render.c Mon May 15 08:28:52 2006 +0000
1.2 +++ b/src/pvr2/render.c Sun Jun 18 11:57:05 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: render.c,v 1.8 2006-05-15 08:28:52 nkeynes Exp $
1.6 + * $Id: render.c,v 1.9 2006-06-18 11:57:05 nkeynes Exp $
1.7 *
1.8 * PVR2 Renderer support. This is where the real work happens.
1.9 *
1.10 @@ -60,7 +60,8 @@
1.11 * to fetch the bits back to vram.
1.12 */
1.13 typedef struct pvr2_render_buffer {
1.14 - uint32_t render_addr; /* The actual address rendered to in pvr ram */
1.15 + sh4addr_t render_addr; /* The actual address rendered to in pvr ram */
1.16 + uint32_t size; /* Length of rendering region in bytes */
1.17 int width, height;
1.18 int colour_format;
1.19 } *pvr2_render_buffer_t;
1.20 @@ -176,6 +177,31 @@
1.21 }
1.22
1.23 /**
1.24 + * Invalidate any caching on the supplied address. Specifically, if it falls
1.25 + * within either the front buffer or back buffer, flush the buffer back to
1.26 + * PVR2 ram (note that front buffer flush may be corrupt under some
1.27 + * circumstances).
1.28 + */
1.29 +gboolean pvr2_render_invalidate( sh4addr_t address )
1.30 +{
1.31 + address = address & 0x1FFFFFFF;
1.32 + if( front_buffer.render_addr != -1 &&
1.33 + front_buffer.render_addr <= address &&
1.34 + (front_buffer.render_addr + front_buffer.size) > address ) {
1.35 + pvr2_render_copy_to_sh4( &front_buffer, FALSE );
1.36 + front_buffer.render_addr = -1;
1.37 + return TRUE;
1.38 + } else if( back_buffer.render_addr != -1 &&
1.39 + back_buffer.render_addr <= address &&
1.40 + (back_buffer.render_addr + back_buffer.size) > address ) {
1.41 + pvr2_render_copy_to_sh4( &back_buffer, TRUE );
1.42 + back_buffer.render_addr = -1;
1.43 + return TRUE;
1.44 + }
1.45 + return FALSE;
1.46 +}
1.47 +
1.48 +/**
1.49 * Display a rendered frame if one is available.
1.50 * @param address An address in PVR ram (0500000 range).
1.51 * @return TRUE if a frame was available to be displayed, otherwise false.
1.52 @@ -235,6 +261,7 @@
1.53 back_buffer.width = width;
1.54 back_buffer.height = height;
1.55 back_buffer.colour_format = colour_format;
1.56 + back_buffer.size = width * height * colour_format_bytes[colour_format];
1.57
1.58 /* Setup the display model */
1.59 glDrawBuffer(GL_BACK);
1.60 @@ -243,7 +270,7 @@
1.61 glViewport( 0, 0, width, height );
1.62 glMatrixMode(GL_PROJECTION);
1.63 glLoadIdentity();
1.64 - glOrtho( 0, width, height, 0, bgplanez, -1 );
1.65 + glOrtho( 0, width, height, 0, bgplanez, -10 );
1.66 glMatrixMode(GL_MODELVIEW);
1.67 glLoadIdentity();
1.68 glCullFace( GL_BACK );
.