Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 856:02ac5f37bfc9
prev851:41e8ae2c114b
next867:3af8840d5d8c
author nkeynes
date Thu Sep 11 22:51:24 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Completely untested render-to-texture work in progress
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Mon Sep 08 11:23:32 2008 +0000
1.2 +++ b/src/pvr2/pvr2.c Thu Sep 11 22:51:24 2008 +0000
1.3 @@ -53,6 +53,10 @@
1.4 void pvr2_display_frame( void );
1.5
1.6 static int output_colour_formats[] = { COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGR888, COLFMT_BGRA8888 };
1.7 +static int render_colour_formats[8] = {
1.8 + COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGRA4444, COLFMT_BGRA1555,
1.9 + COLFMT_BGR888, COLFMT_BGRA8888, COLFMT_BGRA8888, COLFMT_BGRA4444 };
1.10 +
1.11
1.12 struct dreamcast_module pvr2_module = { "PVR2", pvr2_init, pvr2_reset, NULL,
1.13 pvr2_run_slice, NULL,
1.14 @@ -478,6 +482,7 @@
1.15 render_buffer_t buffer = pvr2_next_render_buffer();
1.16 if( buffer != NULL ) {
1.17 pvr2_scene_render( buffer );
1.18 + pvr2_finish_render_buffer( buffer );
1.19 }
1.20 asic_event( EVENT_PVR_RENDER_DONE );
1.21 break;
1.22 @@ -849,6 +854,28 @@
1.23 pvr2_ta_write( (unsigned char *)&val, sizeof(uint32_t) );
1.24 }
1.25
1.26 +render_buffer_t pvr2_create_render_buffer( sh4addr_t addr, int width, int height, GLuint tex_id )
1.27 +{
1.28 + if( display_driver != NULL && display_driver->create_render_buffer != NULL ) {
1.29 + render_buffer_t buffer = display_driver->create_render_buffer(width,height,tex_id);
1.30 + buffer->address = addr;
1.31 + return buffer;
1.32 + }
1.33 + return NULL;
1.34 +}
1.35 +
1.36 +void pvr2_destroy_render_buffer( render_buffer_t buffer )
1.37 +{
1.38 + if( !buffer->flushed )
1.39 + pvr2_render_buffer_copy_to_sh4( buffer );
1.40 + display_driver->destroy_render_buffer( buffer );
1.41 +}
1.42 +
1.43 +void pvr2_finish_render_buffer( render_buffer_t buffer )
1.44 +{
1.45 + display_driver->finish_render( buffer );
1.46 +}
1.47 +
1.48 /**
1.49 * Find the render buffer corresponding to the requested output frame
1.50 * (does not consider texture renders).
1.51 @@ -964,17 +991,18 @@
1.52 uint32_t render_scale = MMIO_READ( PVR2, RENDER_SCALER );
1.53 uint32_t render_stride = MMIO_READ( PVR2, RENDER_SIZE ) << 3;
1.54
1.55 + int width = pvr2_scene_buffer_width();
1.56 + int height = pvr2_scene_buffer_height();
1.57 + int colour_format = render_colour_formats[render_mode&0x07];
1.58 +
1.59 if( render_addr & 0x01000000 ) { /* vram64 */
1.60 render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE_INT;
1.61 + result = texcache_get_render_buffer( render_addr, colour_format, width, height );
1.62 } else { /* vram32 */
1.63 render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;
1.64 + result = pvr2_alloc_render_buffer( render_addr, width, height );
1.65 }
1.66
1.67 - int width = pvr2_scene_buffer_width();
1.68 - int height = pvr2_scene_buffer_height();
1.69 - int colour_format = pvr2_render_colour_format[render_mode&0x07];
1.70 -
1.71 - result = pvr2_alloc_render_buffer( render_addr, width, height );
1.72 /* Setup the buffer */
1.73 if( result != NULL ) {
1.74 result->rowstride = render_stride;
1.75 @@ -1018,7 +1046,6 @@
1.76 (bufaddr + render_buffers[i]->size) > address ) {
1.77 if( !render_buffers[i]->flushed ) {
1.78 pvr2_render_buffer_copy_to_sh4( render_buffers[i] );
1.79 - render_buffers[i]->flushed = TRUE;
1.80 }
1.81 if( isWrite ) {
1.82 render_buffers[i]->address = -1; /* Invalid */
.