Search
lxdream.org :: lxdream/src/pvr2/pvr2mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2mem.c
changeset 352:f0df7a6d4703
prev333:e29561c998f5
next429:e581b90c3fb3
author nkeynes
date Sun Feb 11 10:09:32 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Bug 27: Implement opengl framebuffer objects
Rewrite much of the final video output stage. Now uses generic "render
buffers", implemented on GL using framebuffer objects + textures.
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2mem.c Sat Jan 27 06:21:35 2007 +0000
1.2 +++ b/src/pvr2/pvr2mem.c Sun Feb 11 10:09:32 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: pvr2mem.c,v 1.8 2007-01-27 06:21:35 nkeynes Exp $
1.6 + * $Id: pvr2mem.c,v 1.9 2007-02-11 10:09:32 nkeynes Exp $
1.7 *
1.8 * PVR2 (Video) VRAM handling routines (mainly for the 64-bit region)
1.9 *
1.10 @@ -484,7 +484,7 @@
1.11 ERROR( "Unable to write to dump file '%s' (%s)", filename, strerror(errno) );
1.12 return;
1.13 }
1.14 - pvr2_vram64_read( tmp, addr, length );
1.15 + pvr2_vram64_read( (char *)tmp, addr, length );
1.16 fprintf( f, "%08X\n", addr );
1.17 for( i =0; i<length>>2; i+=8 ) {
1.18 for( j=i; j<i+8; j++ ) {
1.19 @@ -516,77 +516,23 @@
1.20 * @param backBuffer TRUE to flush the back buffer, FALSE for
1.21 * the front buffer.
1.22 */
1.23 -void pvr2_render_buffer_copy_to_sh4( pvr2_render_buffer_t buffer,
1.24 - gboolean backBuffer )
1.25 +void pvr2_render_buffer_copy_to_sh4( render_buffer_t buffer )
1.26 {
1.27 - if( buffer->render_addr == -1 )
1.28 - return;
1.29 - GLenum type = colour_formats[buffer->colour_format].type;
1.30 - GLenum format = colour_formats[buffer->colour_format].format;
1.31 - int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
1.32 - int size = line_size * buffer->height;
1.33 -
1.34 - if( backBuffer ) {
1.35 - glFinish();
1.36 - glReadBuffer( GL_BACK );
1.37 - } else {
1.38 - glReadBuffer( GL_FRONT );
1.39 - }
1.40 -
1.41 - if( buffer->render_addr & 0xFF000000 == 0x04000000 ) {
1.42 + if( buffer->address & 0xFF000000 == 0x04000000 ) {
1.43 /* Interlaced buffer. Go the double copy... :( */
1.44 - char target[size];
1.45 - glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
1.46 - pvr2_vram64_write( buffer->render_addr, target, size );
1.47 + char target[buffer->size];
1.48 + display_driver->read_render_buffer( buffer, target );
1.49 + pvr2_vram64_write( buffer->address, target, buffer->size );
1.50 } else {
1.51 /* Regular buffer */
1.52 - char target[size];
1.53 - glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
1.54 - if( (buffer->scale & 0xFFFF) == 0x0800 ) {
1.55 - pvr2_vram_write_invert( buffer->render_addr, target, size, line_size, line_size << 1 );
1.56 - } else {
1.57 - pvr2_vram_write_invert( buffer->render_addr, target, size, line_size, line_size );
1.58 - }
1.59 + char target[buffer->size];
1.60 + int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
1.61 + display_driver->read_render_buffer( buffer, target );
1.62 + if( (buffer->scale & 0xFFFF) == 0x0800 ) {
1.63 + pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size << 1 );
1.64 + } else {
1.65 + pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size );
1.66 + }
1.67 }
1.68 }
1.69
1.70 -
1.71 -/**
1.72 - * Copy data from PVR ram into the GL render buffer.
1.73 - *
1.74 - * @param buffer A render buffer indicating the address to read from, and the
1.75 - * format the data is in.
1.76 - * @param backBuffer TRUE to write the back buffer, FALSE for
1.77 - * the front buffer.
1.78 - */
1.79 -void pvr2_render_buffer_copy_from_sh4( pvr2_render_buffer_t buffer,
1.80 - gboolean backBuffer )
1.81 -{
1.82 - if( buffer->render_addr == -1 )
1.83 - return;
1.84 -
1.85 - GLenum type = colour_formats[buffer->colour_format].type;
1.86 - GLenum format = colour_formats[buffer->colour_format].format;
1.87 - int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
1.88 - int size = line_size * buffer->height;
1.89 -
1.90 - if( backBuffer ) {
1.91 - glDrawBuffer( GL_BACK );
1.92 - } else {
1.93 - glDrawBuffer( GL_FRONT );
1.94 - }
1.95 -
1.96 - glRasterPos2i( 0, 0 );
1.97 - if( buffer->render_addr & 0xFF000000 == 0x04000000 ) {
1.98 - /* Interlaced buffer. Go the double copy... :( */
1.99 - char target[size];
1.100 - pvr2_vram64_read( target, buffer->render_addr, size );
1.101 - glDrawPixels( buffer->width, buffer->height,
1.102 - format, type, target );
1.103 - } else {
1.104 - /* Regular buffer - go direct */
1.105 - char *target = mem_get_region( buffer->render_addr );
1.106 - glDrawPixels( buffer->width, buffer->height,
1.107 - format, type, target );
1.108 - }
1.109 -}
.