<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src/pvr2</tt></b></td></tr>
<tr><td><tt><a href="#file1">glrender.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+24</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-8</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00e507e4025c -> 5225c7c059ce</td></tr>
<tr class="alt" style=";" ><td><tt><a href="#file2">pvr2.h</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+2</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-2</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00e507e4025c -> 5225c7c059ce</td></tr>
<tr><td><tt><a href="#file3">rendsort.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+1</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-3</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">00e507e4025c -> 5225c7c059ce</td></tr>
<tr><td></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+27</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-13</td><td></td></tr>
</table>
<small id="info" style="color: #888888;" >3 modified files</small><br />
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Avoid rebinding textures unnecessarily (actually saves a surprising amount
of runtime)
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/pvr2</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>glrender.c</b></big> <small id="info" style="color: #888888;" >00e507e4025c -> 5225c7c059ce</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/glrender.c
+++ lxdream/src/pvr2/glrender.c
@@ -46,6 +46,15 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > };
 
 static gboolean have_shaders = FALSE;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+static int currentTexId = -1;
+
+static inline void bind_texture(int texid)
+{
+    if( currentTexId != texid ) {
+        currentTexId = texid;
+        glBindTexture(GL_TEXTURE_2D, texid);
+    }
+}
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 /**
  * Clip the tile bounds to the clipping plane. 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -70,7 +79,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     glEnd();
 }
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void pvr2_scene_load_textures()
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >static </span>void pvr2_scene_load_textures()
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     int i;
     
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -164,7 +173,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > /**
  * Setup the texture/shading settings (TSP) which vary between mod/unmod modes.
  */
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void render_set_tsp_context( uint32_t poly1, uint32_t poly2 )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >static </span>void render_set_tsp_context( uint32_t poly1, uint32_t poly2 )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     glShadeModel( POLY1_SHADE_MODEL(poly1) );
 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -200,7 +209,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  * @param depth_mode force depth mode, or 0 to use the polygon's
  * depth mode.
  */
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void render_set_context( uint32_t *context, gboolean set_depth )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+<span id="addedchars" style="background-color:#99ff99;font-weight:bolder;" >static </span>void render_set_context( uint32_t *context, gboolean set_depth )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > {
     render_set_base_context(context[0], set_depth);
     render_set_tsp_context(context[0],context[1]);
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -227,7 +236,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     if( poly->vertex_count == 0 )
         return; /* Culled */
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    glBindTexture(GL_TEXTURE_2D, poly->tex_id);
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    bind_texture(poly->tex_id);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     if( poly->mod_vertex_index == -1 ) {
         render_set_context( poly->context, set_depth );
         gl_draw_vertexes(poly);
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -239,9 +248,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         gl_draw_vertexes(poly);
 
         if( pvr2_scene.shadow_mode == SHADOW_FULL ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-            if( poly->mod_tex_id != poly->tex_id ) {
-                glBindTexture(GL_TEXTURE_2D, poly->mod_tex_id);
-            }
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            bind_texture(poly->mod_tex_id);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             render_set_tsp_context( poly->context[0], poly->context[3] );
         }
         glStencilFunc(GL_EQUAL, 2, 2);
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -319,7 +326,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 static void gl_render_bkgnd( struct polygon_struct *poly )
 {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-    glBindTexture(GL_TEXTURE_2D, poly->tex_id);
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    bind_texture(poly->tex_id);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     render_set_tsp_context( poly->context[0], poly->context[1] );
     glDisable( GL_DEPTH_TEST );
     glBlendFunc( GL_ONE, GL_ZERO );
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -327,6 +334,14 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     glEnable( GL_DEPTH_TEST );
 }
 
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+void gl_render_triangle( struct polygon_struct *poly, int index )
+{
+    bind_texture(poly->tex_id);
+    render_set_tsp_context( poly->context[0], poly->context[1] );
+    glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + index, 3 );
+
+}
+
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > void gl_render_tilelist( pvraddr_t tile_entry, gboolean set_depth )
 {
     tileentryiter list;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -402,6 +417,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     display_driver->set_render_target(buffer);
     pvr2_check_palette_changed();
     pvr2_scene_load_textures();
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    currentTexId = -1;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
     gettimeofday( &tex_tv, NULL );
     uint32_t ms = (tex_tv.tv_sec - start_tv.tv_sec) * 1000 +
</pre></div>
<hr /><a name="file2" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/pvr2</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>pvr2.h</b></big> <small id="info" style="color: #888888;" >00e507e4025c -> 5225c7c059ce</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/pvr2.h
+++ lxdream/src/pvr2/pvr2.h
@@ -283,8 +283,8 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 void render_autosort_tile( pvraddr_t tile_entry, int render_mode );
 
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-void render_set_context( uint32_t *context, gboolean set_depth );
-void render_set_tsp_context( uint32_t poly1, uint32_t poly2 );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+struct polygon_struct;
+void gl_render_triangle( struct polygon_struct *poly, int index );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 void gl_render_tilelist( pvraddr_t tile_entry, gboolean set_depth );
 
</pre></div>
<hr /><a name="file3" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/pvr2</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>rendsort.c</b></big> <small id="info" style="color: #888888;" >00e507e4025c -> 5225c7c059ce</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/pvr2/rendsort.c
+++ lxdream/src/pvr2/rendsort.c
@@ -172,9 +172,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     int i;
     for( i=0; i<num_triangles; i++ ) {
         struct polygon_struct *poly = triangles[i]->poly;
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        glBindTexture(GL_TEXTURE_2D, poly->tex_id);
-        render_set_tsp_context( poly->context[0], poly->context[1] );
-        glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i]->triangle_num, 3 );
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        gl_render_triangle(triangles[i]->poly, triangles[i]->triangle_num);
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
 }
 
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>