Search
lxdream.org :: lxdream :: r857:3d8944884eaa
lxdream 0.9.1
released Jun 29
Download Now
changeset857:3d8944884eaa
parent856:02ac5f37bfc9
child858:368fc0dcd57c
authornkeynes
dateFri Sep 12 05:36:00 2008 +0000 (11 years ago)
Implement write-back with the hscaler enabled
src/drivers/gl_fbo.c
src/pvr2/pvr2mem.c
1.1 --- a/src/drivers/gl_fbo.c Thu Sep 11 22:51:24 2008 +0000
1.2 +++ b/src/drivers/gl_fbo.c Fri Sep 12 05:36:00 2008 +0000
1.3 @@ -319,6 +319,7 @@
1.4 static gboolean gl_fbo_read_render_buffer( unsigned char *target, render_buffer_t buffer,
1.5 int rowstride, int format )
1.6 {
1.7 + glGetError();
1.8 int fb = gl_fbo_get_framebuffer( buffer->width, buffer->height );
1.9 gl_fbo_attach_texture( fb, buffer->buf_id );
1.10 return gl_read_render_buffer( target, buffer, rowstride, format );
2.1 --- a/src/pvr2/pvr2mem.c Thu Sep 11 22:51:24 2008 +0000
2.2 +++ b/src/pvr2/pvr2mem.c Fri Sep 12 05:36:00 2008 +0000
2.3 @@ -430,15 +430,40 @@
2.4 }
2.5 }
2.6
2.7 -void pvr2_vram_write_invert( sh4addr_t destaddr, unsigned char *src, uint32_t length, uint32_t line_length,
2.8 +static void pvr2_vram_write_invert( sh4addr_t destaddr, unsigned char *src, uint32_t src_size,
2.9 + uint32_t line_size, uint32_t dest_stride,
2.10 uint32_t src_stride )
2.11 {
2.12 unsigned char *dest = video_base + (destaddr & 0x007FFFFF);
2.13 - unsigned char *p = src + length - src_stride;
2.14 + unsigned char *p = src + src_size - src_stride;
2.15 while( p >= src ) {
2.16 - memcpy( dest, p, line_length );
2.17 + memcpy( dest, p, line_size );
2.18 p -= src_stride;
2.19 - dest += line_length;
2.20 + dest += dest_stride;
2.21 + }
2.22 +}
2.23 +
2.24 +/**
2.25 + * Copy a pixel buffer to vram, flipping and scaling at the same time. This
2.26 + * is not massively efficient, but it's used pretty rarely.
2.27 + */
2.28 +static void pvr2_vram_write_invert_hscale( sh4addr_t destaddr, unsigned char *src, uint32_t src_size,
2.29 + uint32_t line_size, uint32_t dest_stride,
2.30 + uint32_t src_stride, int bpp )
2.31 +{
2.32 + unsigned char *dest = video_base + (destaddr & 0x007FFFFF);
2.33 + unsigned char *p = src + src_size - src_stride;
2.34 + while( p >= src ) {
2.35 + unsigned char *s = p, *d = dest;
2.36 + int i;
2.37 + while( s < p+line_size ) {
2.38 + for( i=0; i<bpp; i++ ) {
2.39 + *d++ = *s++;
2.40 + }
2.41 + s+= bpp;
2.42 + }
2.43 + p -= src_stride;
2.44 + dest += dest_stride;
2.45 }
2.46 }
2.47
2.48 @@ -535,13 +560,21 @@
2.49 pvr2_vram64_write( buffer->address, target, buffer->size );
2.50 } else {
2.51 /* Regular buffer */
2.52 - unsigned char target[buffer->size];
2.53 int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
2.54 - display_driver->read_render_buffer( target, buffer, buffer->rowstride, buffer->colour_format );
2.55 - if( (buffer->scale & 0xFFFF) == 0x0800 ) {
2.56 - pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size << 1 );
2.57 + int src_stride = line_size;
2.58 + if( (buffer->scale & 0xFFFF) == 0x0800 )
2.59 + src_stride <<= 1;
2.60 +
2.61 + if( buffer->scale & SCALER_HSCALE ) {
2.62 + unsigned char target[buffer->size];
2.63 + display_driver->read_render_buffer( target, buffer, line_size, buffer->colour_format );
2.64 + pvr2_vram_write_invert_hscale( buffer->address, target, buffer->size, line_size, buffer->rowstride,
2.65 + src_stride, colour_formats[buffer->colour_format].bpp );
2.66 } else {
2.67 - pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size );
2.68 + unsigned char target[buffer->size];
2.69 + display_driver->read_render_buffer( target, buffer, line_size, buffer->colour_format );
2.70 + pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, buffer->rowstride,
2.71 + src_stride );
2.72 }
2.73 }
2.74 buffer->flushed = TRUE;
.