From 048d2318a09938f797abb253b49bee587268e932 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 13 Jul 2009 06:35:33 +0000 Subject: [PATCH] gfx3d: cache rendering params at flush time, instead of using values which happen to be current at scanline=0 when we do 3d rendering. fixes trouble pop bubble --- desmume/src/gfx3d.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 33fb89dea..414e49f17 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -1571,8 +1571,11 @@ void gfx3d_execute3D() void gfx3d_glFlush(u32 v) { flushPending = TRUE; - gfx3d.sortmode = BIT0(v); - gfx3d.wbuffer = BIT1(v); + if(!flushPending) + { + gfx3d.sortmode = BIT0(v); + gfx3d.wbuffer = BIT1(v); + } #ifdef USE_GEOMETRY_FIFO_EMULATION @@ -1630,10 +1633,20 @@ static void gfx3d_doFlush() clCmd = 0; #endif - //the renderer wil lget the lists we just built + //the renderer will get the lists we just built gfx3d.polylist = polylist; gfx3d.vertlist = vertlist; + //and also our current render state + if(BIT1(control)) gfx3d.shading = GFX3D::HIGHLIGHT; + else gfx3d.shading = GFX3D::TOON; + gfx3d.enableTexturing = BIT0(control); + gfx3d.enableAlphaTest = BIT2(control); + gfx3d.enableAlphaBlending = BIT3(control); + gfx3d.enableAntialiasing = BIT4(control); + gfx3d.enableEdgeMarking = BIT5(control); + gfx3d.enableClearImage = BIT14(control); + int polycount = polylist->count; //find the min and max y values for each poly. @@ -2337,26 +2350,9 @@ void gfx3d_sendCommand(u32 cmd, u32 param) } #endif -static void gfx3d_Control_cache() -{ - u32 v = control; - - if(BIT1(v)) gfx3d.shading = GFX3D::HIGHLIGHT; - else gfx3d.shading = GFX3D::TOON; - - gfx3d.enableTexturing = BIT0(v); - gfx3d.enableAlphaTest = BIT2(v); - gfx3d.enableAlphaBlending = BIT3(v); - gfx3d.enableAntialiasing = BIT4(v); - gfx3d.enableEdgeMarking = BIT5(v); - gfx3d.enableClearImage = BIT14(v); -} - void gfx3d_Control(u32 v) { control = v; - gfx3d_Control_cache(); - } //-------------- @@ -2500,7 +2496,6 @@ bool gfx3d_loadstate(std::istream* is, int size) gfx3d_glPolygonAttrib_cache(); gfx3d_glTexImage_cache(); - gfx3d_Control_cache(); gfx3d_glLightDirection_cache(0); gfx3d_glLightDirection_cache(1); gfx3d_glLightDirection_cache(2);