Search
lxdream.org :: lxdream :: r219:dfd3292143f2
lxdream 0.9.1
released Jun 29
Download Now
changeset219:dfd3292143f2
parent218:cbad5a3f8387
child220:f72f8a7dff88
authornkeynes
dateTue Aug 29 08:12:13 2006 +0000 (17 years ago)
Initial implementation of new background support
src/Makefile.am
src/Makefile.in
src/pvr2/pvr2.h
src/pvr2/rendbkg.c
src/pvr2/render.c
1.1 --- a/src/Makefile.am Tue Aug 29 08:11:56 2006 +0000
1.2 +++ b/src/Makefile.am Tue Aug 29 08:12:13 2006 +0000
1.3 @@ -22,7 +22,7 @@
1.4 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \
1.5 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
1.6 pvr2/pvr2.c pvr2/pvr2.h \
1.7 - pvr2/tacore.c pvr2/render.c pvr2/rendcore.c \
1.8 + pvr2/tacore.c pvr2/render.c pvr2/rendcore.c pvr2/rendbkg.c \
1.9 pvr2/texcache.c \
1.10 maple/maple.c maple/maple.h \
1.11 maple/controller.c maple/controller.h \
2.1 --- a/src/Makefile.in Tue Aug 29 08:11:56 2006 +0000
2.2 +++ b/src/Makefile.in Tue Aug 29 08:12:13 2006 +0000
2.3 @@ -150,7 +150,7 @@
2.4 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \
2.5 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
2.6 pvr2/pvr2.c pvr2/pvr2.h \
2.7 - pvr2/tacore.c pvr2/render.c pvr2/rendcore.c \
2.8 + pvr2/tacore.c pvr2/render.c pvr2/rendcore.c pvr2/rendbkg.c \
2.9 pvr2/texcache.c \
2.10 maple/maple.c maple/maple.h \
2.11 maple/controller.c maple/controller.h \
2.12 @@ -186,13 +186,13 @@
2.13 scif.$(OBJEXT) armcore.$(OBJEXT) armdasm.$(OBJEXT) \
2.14 armmem.$(OBJEXT) aica.$(OBJEXT) audio.$(OBJEXT) pvr2.$(OBJEXT) \
2.15 tacore.$(OBJEXT) render.$(OBJEXT) rendcore.$(OBJEXT) \
2.16 - texcache.$(OBJEXT) maple.$(OBJEXT) controller.$(OBJEXT) \
2.17 - support.$(OBJEXT) interface.$(OBJEXT) callbacks.$(OBJEXT) \
2.18 - gui.$(OBJEXT) mmr_win.$(OBJEXT) debug_win.$(OBJEXT) \
2.19 - dump_win.$(OBJEXT) loader.$(OBJEXT) bootstrap.$(OBJEXT) \
2.20 - util.$(OBJEXT) display.$(OBJEXT) audio_null.$(OBJEXT) \
2.21 - audio_esd.$(OBJEXT) video_null.$(OBJEXT) video_gtk.$(OBJEXT) \
2.22 - video_x11.$(OBJEXT)
2.23 + rendbkg.$(OBJEXT) texcache.$(OBJEXT) maple.$(OBJEXT) \
2.24 + controller.$(OBJEXT) support.$(OBJEXT) interface.$(OBJEXT) \
2.25 + callbacks.$(OBJEXT) gui.$(OBJEXT) mmr_win.$(OBJEXT) \
2.26 + debug_win.$(OBJEXT) dump_win.$(OBJEXT) loader.$(OBJEXT) \
2.27 + bootstrap.$(OBJEXT) util.$(OBJEXT) display.$(OBJEXT) \
2.28 + audio_null.$(OBJEXT) audio_esd.$(OBJEXT) video_null.$(OBJEXT) \
2.29 + video_gtk.$(OBJEXT) video_x11.$(OBJEXT)
2.30 lxdream_OBJECTS = $(am_lxdream_OBJECTS)
2.31 lxdream_DEPENDENCIES =
2.32 lxdream_LDFLAGS =
2.33 @@ -215,15 +215,16 @@
2.34 @AMDEP_TRUE@ ./$(DEPDIR)/loader.Po ./$(DEPDIR)/main.Po \
2.35 @AMDEP_TRUE@ ./$(DEPDIR)/maple.Po ./$(DEPDIR)/mem.Po \
2.36 @AMDEP_TRUE@ ./$(DEPDIR)/mmr_win.Po ./$(DEPDIR)/nrg.Po \
2.37 -@AMDEP_TRUE@ ./$(DEPDIR)/pvr2.Po ./$(DEPDIR)/rendcore.Po \
2.38 -@AMDEP_TRUE@ ./$(DEPDIR)/render.Po ./$(DEPDIR)/scif.Po \
2.39 -@AMDEP_TRUE@ ./$(DEPDIR)/sh4core.Po ./$(DEPDIR)/sh4dasm.Po \
2.40 -@AMDEP_TRUE@ ./$(DEPDIR)/sh4mem.Po ./$(DEPDIR)/sh4mmio.Po \
2.41 -@AMDEP_TRUE@ ./$(DEPDIR)/support.Po ./$(DEPDIR)/syscall.Po \
2.42 -@AMDEP_TRUE@ ./$(DEPDIR)/tacore.Po ./$(DEPDIR)/texcache.Po \
2.43 -@AMDEP_TRUE@ ./$(DEPDIR)/timer.Po ./$(DEPDIR)/util.Po \
2.44 -@AMDEP_TRUE@ ./$(DEPDIR)/video_gtk.Po ./$(DEPDIR)/video_null.Po \
2.45 -@AMDEP_TRUE@ ./$(DEPDIR)/video_x11.Po ./$(DEPDIR)/watch.Po
2.46 +@AMDEP_TRUE@ ./$(DEPDIR)/pvr2.Po ./$(DEPDIR)/rendbkg.Po \
2.47 +@AMDEP_TRUE@ ./$(DEPDIR)/rendcore.Po ./$(DEPDIR)/render.Po \
2.48 +@AMDEP_TRUE@ ./$(DEPDIR)/scif.Po ./$(DEPDIR)/sh4core.Po \
2.49 +@AMDEP_TRUE@ ./$(DEPDIR)/sh4dasm.Po ./$(DEPDIR)/sh4mem.Po \
2.50 +@AMDEP_TRUE@ ./$(DEPDIR)/sh4mmio.Po ./$(DEPDIR)/support.Po \
2.51 +@AMDEP_TRUE@ ./$(DEPDIR)/syscall.Po ./$(DEPDIR)/tacore.Po \
2.52 +@AMDEP_TRUE@ ./$(DEPDIR)/texcache.Po ./$(DEPDIR)/timer.Po \
2.53 +@AMDEP_TRUE@ ./$(DEPDIR)/util.Po ./$(DEPDIR)/video_gtk.Po \
2.54 +@AMDEP_TRUE@ ./$(DEPDIR)/video_null.Po ./$(DEPDIR)/video_x11.Po \
2.55 +@AMDEP_TRUE@ ./$(DEPDIR)/watch.Po
2.56 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
2.57 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
2.58 CCLD = $(CC)
2.59 @@ -306,6 +307,7 @@
2.60 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmr_win.Po@am__quote@
2.61 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nrg.Po@am__quote@
2.62 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pvr2.Po@am__quote@
2.63 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rendbkg.Po@am__quote@
2.64 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rendcore.Po@am__quote@
2.65 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render.Po@am__quote@
2.66 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scif.Po@am__quote@
2.67 @@ -808,6 +810,28 @@
2.68 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.69 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rendcore.obj `if test -f 'pvr2/rendcore.c'; then $(CYGPATH_W) 'pvr2/rendcore.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/rendcore.c'; fi`
2.70
2.71 +rendbkg.o: pvr2/rendbkg.c
2.72 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rendbkg.o -MD -MP -MF "$(DEPDIR)/rendbkg.Tpo" \
2.73 +@am__fastdepCC_TRUE@ -c -o rendbkg.o `test -f 'pvr2/rendbkg.c' || echo '$(srcdir)/'`pvr2/rendbkg.c; \
2.74 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/rendbkg.Tpo" "$(DEPDIR)/rendbkg.Po"; \
2.75 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/rendbkg.Tpo"; exit 1; \
2.76 +@am__fastdepCC_TRUE@ fi
2.77 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/rendbkg.c' object='rendbkg.o' libtool=no @AMDEPBACKSLASH@
2.78 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/rendbkg.Po' tmpdepfile='$(DEPDIR)/rendbkg.TPo' @AMDEPBACKSLASH@
2.79 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.80 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rendbkg.o `test -f 'pvr2/rendbkg.c' || echo '$(srcdir)/'`pvr2/rendbkg.c
2.81 +
2.82 +rendbkg.obj: pvr2/rendbkg.c
2.83 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rendbkg.obj -MD -MP -MF "$(DEPDIR)/rendbkg.Tpo" \
2.84 +@am__fastdepCC_TRUE@ -c -o rendbkg.obj `if test -f 'pvr2/rendbkg.c'; then $(CYGPATH_W) 'pvr2/rendbkg.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/rendbkg.c'; fi`; \
2.85 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/rendbkg.Tpo" "$(DEPDIR)/rendbkg.Po"; \
2.86 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/rendbkg.Tpo"; exit 1; \
2.87 +@am__fastdepCC_TRUE@ fi
2.88 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/rendbkg.c' object='rendbkg.obj' libtool=no @AMDEPBACKSLASH@
2.89 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/rendbkg.Po' tmpdepfile='$(DEPDIR)/rendbkg.TPo' @AMDEPBACKSLASH@
2.90 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.91 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rendbkg.obj `if test -f 'pvr2/rendbkg.c'; then $(CYGPATH_W) 'pvr2/rendbkg.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/rendbkg.c'; fi`
2.92 +
2.93 texcache.o: pvr2/texcache.c
2.94 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT texcache.o -MD -MP -MF "$(DEPDIR)/texcache.Tpo" \
2.95 @am__fastdepCC_TRUE@ -c -o texcache.o `test -f 'pvr2/texcache.c' || echo '$(srcdir)/'`pvr2/texcache.c; \
3.1 --- a/src/pvr2/pvr2.h Tue Aug 29 08:11:56 2006 +0000
3.2 +++ b/src/pvr2/pvr2.h Tue Aug 29 08:12:13 2006 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: pvr2.h,v 1.15 2006-08-02 04:06:45 nkeynes Exp $
3.6 + * $Id: pvr2.h,v 1.16 2006-08-29 08:12:13 nkeynes Exp $
3.7 *
3.8 * PVR2 (video chip) functions and macros.
3.9 *
3.10 @@ -158,6 +158,14 @@
3.11 */
3.12 gboolean pvr2_render_display_frame( uint32_t address );
3.13
3.14 +
3.15 +void render_backplane( uint32_t *polygon, uint32_t width, uint32_t height, uint32_t mode );
3.16 +
3.17 +void render_set_context( uint32_t *context, int render_mode );
3.18 +
3.19 +void pvr2_render_tilebuffer( int width, int height, int clipx1, int clipy1,
3.20 + int clipx2, int clipy2 );
3.21 +
3.22 /****************************** Texture Cache ****************************/
3.23
3.24 /**
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/src/pvr2/rendbkg.c Tue Aug 29 08:12:13 2006 +0000
4.3 @@ -0,0 +1,117 @@
4.4 +/**
4.5 + * $Id: rendbkg.c,v 1.1 2006-08-29 08:12:13 nkeynes Exp $
4.6 + *
4.7 + * PVR2 background renderer.
4.8 + *
4.9 + * Yes, it uses the same basic data structure. Yes, it needs to be handled
4.10 + * completely differently.
4.11 + *
4.12 + * Copyright (c) 2005 Nathan Keynes.
4.13 + *
4.14 + * This program is free software; you can redistribute it and/or modify
4.15 + * it under the terms of the GNU General Public License as published by
4.16 + * the Free Software Foundation; either version 2 of the License, or
4.17 + * (at your option) any later version.
4.18 + *
4.19 + * This program is distributed in the hope that it will be useful,
4.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.22 + * GNU General Public License for more details.
4.23 + */
4.24 +
4.25 +#include <sys/time.h>
4.26 +#include "pvr2/pvr2.h"
4.27 +
4.28 +struct vertex_rgba {
4.29 + float x,y,z;
4.30 + uint32_t argb;
4.31 +};
4.32 +
4.33 +struct vertex_all {
4.34 + float x,y,z;
4.35 + float u,v;
4.36 + float rgba[4]; /* Note - RGBA order, as preferred by GL */
4.37 + float spec_rgba[4];
4.38 +};
4.39 +
4.40 +#define FARGB_A(x) (((float)(((x)>>24)+1))/256.0)
4.41 +#define FARGB_R(x) (((float)((((x)>>16)&0xFF)+1))/256.0)
4.42 +#define FARGB_G(x) (((float)((((x)>>8)&0xFF)+1))/256.0)
4.43 +#define FARGB_B(x) (((float)(((x)&0xFF)+1))/256.0)
4.44 +
4.45 +/**
4.46 + * Compute the values for an array of vertexes, given x,y for each
4.47 + * vertex and the base 3-vertex triple used to define the background
4.48 + * plane. Essentially the base vertexes are used to find the
4.49 + * plane equation for each of z,a,r,g,b,etc, which is then solved for
4.50 + * each of the required compute vertexes (normally the corner points).
4.51 + *
4.52 + * @param base The 3 vertexes supplied as the background definition
4.53 + * @param compute An array of vertexes to compute. x and y must be
4.54 + * preset, other values are computed.
4.55 + * @param num_compute number of vertexes in the compute array.
4.56 + */
4.57 +void compute_vertexes( struct vertex_rgba *base,
4.58 + struct vertex_all *compute,
4.59 + int num_compute )
4.60 +{
4.61 + struct vertex_all center;
4.62 + struct vertex_all diff0, diff1;
4.63 + int i;
4.64 +
4.65 + center.x = base[1].x;
4.66 + center.y = base[1].y;
4.67 + center.z = base[1].z;
4.68 + center.rgba[0] = FARGB_R(base[1].argb);
4.69 + center.rgba[1] = FARGB_G(base[1].argb);
4.70 + center.rgba[2] = FARGB_B(base[1].argb);
4.71 + center.rgba[3] = FARGB_A(base[1].argb);
4.72 + diff0.x = base[0].x - base[1].x;
4.73 + diff0.y = base[0].y - base[1].y;
4.74 + diff0.z = base[0].z - base[1].z;
4.75 + diff1.x = base[2].x - base[1].x;
4.76 + diff1.y = base[2].y - base[1].y;
4.77 + diff1.z = base[2].z - base[1].z;
4.78 + diff0.rgba[0] = FARGB_R(base[0].argb) - center.rgba[0];
4.79 + diff0.rgba[1] = FARGB_G(base[0].argb) - center.rgba[1];
4.80 + diff0.rgba[2] = FARGB_B(base[0].argb) - center.rgba[2];
4.81 + diff0.rgba[3] = FARGB_A(base[0].argb) - center.rgba[3];
4.82 + diff1.rgba[0] = FARGB_R(base[2].argb) - center.rgba[0];
4.83 + diff1.rgba[1] = FARGB_G(base[2].argb) - center.rgba[1];
4.84 + diff1.rgba[2] = FARGB_B(base[2].argb) - center.rgba[2];
4.85 + diff1.rgba[3] = FARGB_A(base[2].argb) - center.rgba[3];
4.86 +
4.87 + float divisor = ((diff1.y) * (diff0.x)) - ((diff0.y) * (diff1.x));
4.88 + if( divisor == 0 ) {
4.89 + /* The points lie on a single line - no plane for you. *shrugs* */
4.90 + } else {
4.91 + for( i=0; i<num_compute; i++ ) {
4.92 + float t = ((compute[i].x - center.x) * diff1.y -
4.93 + (compute[i].y - center.y) * diff1.x) / divisor;
4.94 + float s = ((compute[i].y - center.y) * diff0.x -
4.95 + (compute[i].x - center.x) * diff0.y) / divisor;
4.96 + compute[i].z = center.z + (t*diff0.z) + (s*diff1.z);
4.97 + compute[i].rgba[0] = center.rgba[0] + (t*diff0.rgba[0]) + (s*diff1.rgba[0]);
4.98 + compute[i].rgba[1] = center.rgba[1] + (t*diff0.rgba[1]) + (s*diff1.rgba[1]);
4.99 + compute[i].rgba[2] = center.rgba[2] + (t*diff0.rgba[2]) + (s*diff1.rgba[2]);
4.100 + compute[i].rgba[3] = center.rgba[3] + (t*diff0.rgba[3]) + (s*diff1.rgba[3]);
4.101 + }
4.102 + }
4.103 +}
4.104 +
4.105 +void render_backplane( uint32_t *polygon, uint32_t width, uint32_t height, uint32_t mode ) {
4.106 + struct vertex_rgba *vertex = (struct vertex_rgba *)(polygon + 3);
4.107 + struct vertex_all compute[4] = { {0.0,0.0}, {width,0.0}, {width, height}, {0.0,height} };
4.108 + int i;
4.109 +
4.110 + render_set_context(polygon, 0);
4.111 + compute_vertexes( vertex, compute, 4 );
4.112 + glBegin(GL_QUADS);
4.113 + for( i=0; i<4; i++ ) {
4.114 + glColor4fv(compute[i].rgba);
4.115 + glVertex3f(compute[i].x, compute[i].y, compute[i].z);
4.116 + fprintf( stderr, "BG %d,%d: %f %f %f\n", (int)compute[i].x, (int)compute[i].y,
4.117 + compute[i].rgba[0], compute[i].rgba[1], compute[i].rgba[2] );
4.118 + }
4.119 + glEnd();
4.120 +}
5.1 --- a/src/pvr2/render.c Tue Aug 29 08:11:56 2006 +0000
5.2 +++ b/src/pvr2/render.c Tue Aug 29 08:12:13 2006 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: render.c,v 1.12 2006-08-02 06:24:08 nkeynes Exp $
5.6 + * $Id: render.c,v 1.13 2006-08-29 08:12:13 nkeynes Exp $
5.7 *
5.8 * PVR2 Renderer support. This part is primarily
5.9 *
5.10 @@ -223,43 +223,6 @@
5.11 #define MAX3( a,b,c ) ((a) > (b) ? ( (a) > (c) ? (a) : (c) ) : ((b) > (c) ? (b) : (c)) )
5.12
5.13 /**
5.14 - * Render the background plane as best we can. Unfortunately information
5.15 - * is a little scant, to say the least.
5.16 - */
5.17 -void pvr2_render_draw_backplane( uint32_t mode, uint32_t *poly )
5.18 -{
5.19 -
5.20 - if( (mode >> 24) == 0x01 ) {
5.21 - /* Packed colour. I think */
5.22 - pvr2_bgplane_packed_t bg = (pvr2_bgplane_packed_t)poly;
5.23 - if( bg->colour1 != bg->colour2 || bg->colour2 != bg->colour3 ) {
5.24 - WARN( "Multiple background colours specified. Confused" );
5.25 - fprintf( stderr, "bgplane mode: %08X PBUF: %08X\n", mode,
5.26 - MMIO_READ( PVR2, RENDER_POLYBASE ) );
5.27 - fwrite_dump( poly, 80, stderr );
5.28 - }
5.29 - float x1 = MIN3( bg->x1, bg->x2, bg->x3 );
5.30 - float y1 = MIN3( bg->y1, bg->y2, bg->y3 );
5.31 - float x2 = MAX3( bg->x1, bg->x2, bg->x3 );
5.32 - float y2 = MAX3( bg->y1, bg->y2, bg->y3 );
5.33 - float z = MIN3( bg->z1, bg->z2, bg->z3 );
5.34 - glDisable( GL_TEXTURE_2D );
5.35 - glDisable( GL_DEPTH_TEST );
5.36 - glColor3ub( (uint8_t)(bg->colour1 >> 16), (uint8_t)(bg->colour1 >> 8),
5.37 - (uint8_t)bg->colour1 );
5.38 - glBegin( GL_QUADS );
5.39 - glVertex3f( x1, y1, z );
5.40 - glVertex3f( x2, y1, z );
5.41 - glVertex3f( x2, y2, z );
5.42 - glVertex3f( x1, y2, z );
5.43 - glEnd();
5.44 - } else {
5.45 - WARN( "Unknown bgplane mode: %08X", mode );
5.46 - fwrite_dump( poly, 48, stderr );
5.47 - }
5.48 -}
5.49 -
5.50 -/**
5.51 * Render a complete scene into the OpenGL back buffer.
5.52 * Note: this will probably need to be broken up eventually once timings are
5.53 * determined.
5.54 @@ -305,7 +268,7 @@
5.55 (uint32_t *)mem_get_region(PVR2_RAM_BASE + MMIO_READ( PVR2, RENDER_POLYBASE ));
5.56
5.57 uint32_t *bgplane = display_list + (((bgplane_mode & 0x00FFFFFF)) >> 3) ;
5.58 - pvr2_render_draw_backplane( bgplane_mode, bgplane );
5.59 + render_backplane( bgplane, width, height, bgplane_mode );
5.60
5.61 pvr2_render_tilebuffer( width, height, clip_x, clip_y,
5.62 clip_x + clip_width, clip_y + clip_height );
5.63 @@ -336,32 +299,33 @@
5.64 if( buffer->render_addr == -1 )
5.65 return;
5.66 GLenum type, format = GL_RGBA;
5.67 - int size = buffer->width * buffer->height;
5.68 + int line_size = buffer->width, size;
5.69
5.70 switch( buffer->colour_format ) {
5.71 case COLFMT_RGB565:
5.72 type = GL_UNSIGNED_SHORT_5_6_5;
5.73 format = GL_RGB;
5.74 - size <<= 1;
5.75 + line_size <<= 1;
5.76 break;
5.77 case COLFMT_RGB888:
5.78 type = GL_UNSIGNED_INT;
5.79 format = GL_RGB;
5.80 - size = (size<<1)+size;
5.81 + line_size = (line_size<<1)+line_size;
5.82 break;
5.83 case COLFMT_ARGB1555:
5.84 type = GL_UNSIGNED_SHORT_5_5_5_1;
5.85 - size <<= 1;
5.86 + line_size <<= 1;
5.87 break;
5.88 case COLFMT_ARGB4444:
5.89 type = GL_UNSIGNED_SHORT_4_4_4_4;
5.90 - size <<= 1;
5.91 + line_size <<= 1;
5.92 break;
5.93 case COLFMT_ARGB8888:
5.94 type = GL_UNSIGNED_INT_8_8_8_8;
5.95 - size <<= 2;
5.96 + line_size <<= 2;
5.97 break;
5.98 }
5.99 + size = line_size * buffer->height;
5.100
5.101 if( backBuffer ) {
5.102 glFinish();
5.103 @@ -376,9 +340,10 @@
5.104 glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
5.105 pvr2_vram64_write( buffer->render_addr, target, size );
5.106 } else {
5.107 - /* Regular buffer - go direct */
5.108 - char *target = mem_get_region( buffer->render_addr );
5.109 + /* Regular buffer */
5.110 + char target[size];
5.111 glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
5.112 + pvr2_vram_write_invert( buffer->render_addr, target, size, line_size );
5.113 }
5.114 }
5.115
.