Search
lxdream.org :: lxdream :: r649:620c5c6496b5
lxdream 0.9.1
released Jun 29
Download Now
changeset649:620c5c6496b5 lxdream-render
parent648:ef9aa5cba86f
child650:80568a7a1ec7
authornkeynes
dateTue Mar 11 08:50:16 2008 +0000 (11 years ago)
branchlxdream-render
Use maxz rather than minz for tri sorting (better results atm)
Change depth-test-disable to depth-mask (more correct)
Implement alpha test for punchthru polys
src/pvr2/glrender.c
src/pvr2/pvr2.c
src/pvr2/pvr2.h
src/pvr2/pvr2mmio.h
src/pvr2/rendbkg.c
1.1 --- a/src/pvr2/glrender.c Sat Mar 08 04:21:42 2008 +0000
1.2 +++ b/src/pvr2/glrender.c Tue Mar 11 08:50:16 2008 +0000
1.3 @@ -87,6 +87,7 @@
1.4 texcache_gl_init(); // Allocate texture IDs
1.5 glCullFace( GL_BACK );
1.6 glEnable( GL_BLEND );
1.7 + glEnable( GL_DEPTH_TEST );
1.8 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1.9 glMatrixMode(GL_MODELVIEW);
1.10 glLoadIdentity();
1.11 @@ -118,12 +119,8 @@
1.12 texture = context[2];
1.13 }
1.14
1.15 - if( POLY1_DEPTH_ENABLE(poly1) ) {
1.16 - glEnable( GL_DEPTH_TEST );
1.17 - glDepthFunc( POLY1_DEPTH_MODE(poly1) );
1.18 - } else {
1.19 - glDisable( GL_DEPTH_TEST );
1.20 - }
1.21 + glDepthFunc( POLY1_DEPTH_MODE(poly1) );
1.22 + glDepthMask( POLY1_DEPTH_WRITE(poly1) ? GL_TRUE : GL_FALSE );
1.23
1.24 switch( POLY1_CULL_MODE(poly1) ) {
1.25 case CULL_NONE:
1.26 @@ -186,7 +183,6 @@
1.27 }
1.28 render_set_context( poly->context, RENDER_NORMAL );
1.29 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
1.30 -
1.31 }
1.32
1.33 void gl_render_tilelist( pvraddr_t tile_entry )
1.34 @@ -251,6 +247,8 @@
1.35 }
1.36 glOrtho( 0, pvr2_scene.buffer_width, pvr2_scene.buffer_height, 0,
1.37 -farz, -nearz );
1.38 + float alphaRef = ((float)(MMIO_READ(PVR2, RENDER_ALPHA_REF)&0xFF)+1)/256.0;
1.39 + glAlphaFunc( GL_GEQUAL, alphaRef );
1.40
1.41 /* Clear the buffer (FIXME: May not want always want to do this) */
1.42 glDisable( GL_SCISSOR_TEST );
1.43 @@ -292,7 +290,9 @@
1.44 }
1.45 }
1.46 if( IS_TILE_PTR(segment->punchout_ptr) ) {
1.47 - gl_render_tilelist(segment->punchout_ptr);
1.48 + glEnable(GL_ALPHA_TEST );
1.49 + render_autosort_tile(segment->punchout_ptr, RENDER_NORMAL );
1.50 + glDisable(GL_ALPHA_TEST );
1.51 }
1.52 } while( !IS_LAST_SEGMENT(segment++) );
1.53 glDisable( GL_SCISSOR_TEST );
2.1 --- a/src/pvr2/pvr2.c Sat Mar 08 04:21:42 2008 +0000
2.2 +++ b/src/pvr2/pvr2.c Tue Mar 11 08:50:16 2008 +0000
2.3 @@ -585,7 +585,9 @@
2.4 case RENDER_PALETTE:
2.5 MMIO_WRITE( PVR2, reg, val&0x00000003 );
2.6 break;
2.7 -
2.8 + case RENDER_ALPHA_REF:
2.9 + MMIO_WRITE( PVR2, reg, val&0x000000FF );
2.10 + break;
2.11 /********** CRTC registers *************/
2.12 case DISP_HBORDER:
2.13 case DISP_VBORDER:
2.14 @@ -681,9 +683,6 @@
2.15 case PVRUNK5:
2.16 MMIO_WRITE( PVR2, reg, val&0x0000FFFF );
2.17 break;
2.18 - case PVRUNK6:
2.19 - MMIO_WRITE( PVR2, reg, val&0x000000FF );
2.20 - break;
2.21 case PVRUNK7:
2.22 MMIO_WRITE( PVR2, reg, val&0x00000001 );
2.23 break;
3.1 --- a/src/pvr2/pvr2.h Sat Mar 08 04:21:42 2008 +0000
3.2 +++ b/src/pvr2/pvr2.h Tue Mar 11 08:50:16 2008 +0000
3.3 @@ -334,7 +334,7 @@
3.4
3.5 /************************* Rendering support macros **************************/
3.6 #define POLY1_DEPTH_MODE(poly1) ( pvr2_poly_depthmode[(poly1)>>29] )
3.7 -#define POLY1_DEPTH_ENABLE(poly1) (((poly1)&0x04000000) == 0 )
3.8 +#define POLY1_DEPTH_WRITE(poly1) (((poly1)&0x04000000) == 0 )
3.9 #define POLY1_CULL_MODE(poly1) (((poly1)>>27)&0x03)
3.10 #define POLY1_CULL_ENABLE(poly1) (((poly1)>>28)&0x01)
3.11 #define POLY1_TEXTURED(poly1) (((poly1)&0x02000000))
4.1 --- a/src/pvr2/pvr2mmio.h Sat Mar 08 04:21:42 2008 +0000
4.2 +++ b/src/pvr2/pvr2mmio.h Tue Mar 11 08:50:16 2008 +0000
4.3 @@ -72,7 +72,7 @@
4.4 LONG_PORT( 0x110, PVRUNK3, PORT_MRW, 0, "PVR2 unknown register 3" )
4.5 LONG_PORT( 0x114, PVRUNK4, PORT_MRW, 0, "PVR2 unknown register 4" )
4.6 LONG_PORT( 0x118, PVRUNK5, PORT_MRW, 0, "PVR2 unkown register 5" )
4.7 - LONG_PORT( 0x11C, PVRUNK6, PORT_MRW, 0, "PVR2 unkown register 6" )
4.8 + LONG_PORT( 0x11C, RENDER_ALPHA_REF, PORT_MRW, 0, "PVR2 reference alpha" )
4.9 LONG_PORT( 0x124, TA_TILEBASE, PORT_MRW, 0, "TA Tile matrix start" )
4.10 LONG_PORT( 0x128, TA_POLYBASE, PORT_MRW, 0, "TA Polygon buffer start" )
4.11 LONG_PORT( 0x12C, TA_LISTEND, PORT_MRW, 0, "TA Tile matrix end" )
5.1 --- a/src/pvr2/rendbkg.c Sat Mar 08 04:21:42 2008 +0000
5.2 +++ b/src/pvr2/rendbkg.c Tue Mar 11 08:50:16 2008 +0000
5.3 @@ -672,4 +672,6 @@
5.4 glDisable(GL_DEPTH_TEST);
5.5 glBlendFunc(GL_ONE, GL_ZERO); /* For now, just disable alpha blending on the bkg */
5.6 bkg_render_region(&scene, 0, screen_vertexes, 4, *polygon);
5.7 + glEnable(GL_CULL_FACE);
5.8 + glEnable(GL_DEPTH_TEST);
5.9 }
.