From 8321c7baff81c5477a1ddbf1d2cc94b0900f27de Mon Sep 17 00:00:00 2001 From: theoddone33 Date: Sat, 31 Aug 2002 01:39:13 +0000 Subject: [PATCH] Speed up the renderer a tad --- src/freespace2/freespace.cpp | 13 +++++++++++-- src/graphics/2d.cpp | 7 +++++-- src/graphics/gropengl.cpp | 19 ++++++++++++------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index f19fffd..6918376 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -15,6 +15,9 @@ * Freespace main body * * $Log$ + * Revision 1.24 2002/08/31 01:39:13 theoddone33 + * Speed up the renderer a tad + * * Revision 1.23 2002/08/04 02:31:00 relnev * make numlock not overlap with pause * @@ -3839,14 +3842,20 @@ extern int Player_dead_state; // Flip the page and time how long it took. void game_flip_page_and_time_it() { +#ifndef NDEBUG fix t1, t2,d; int t; t1 = timer_get_fixed_seconds(); gr_flip(); t2 = timer_get_fixed_seconds(); d = t2 - t1; - t = (gr_screen.max_w*gr_screen.max_h*gr_screen.bytes_per_pixel)/1024; - sprintf( transfer_text, NOX("%ld MB/s"), fixmuldiv(t,65,d) ); + if (d != 0) { + t = (gr_screen.max_w*gr_screen.max_h*gr_screen.bytes_per_pixel)/1024; + sprintf( transfer_text, NOX("%ld MB/s"), fixmuldiv(t,65,d) ); + } +#else + gr_flip (); +#endif } void game_simulation_frame() diff --git a/src/graphics/2d.cpp b/src/graphics/2d.cpp index 10f60df..8ae89c5 100644 --- a/src/graphics/2d.cpp +++ b/src/graphics/2d.cpp @@ -15,6 +15,9 @@ * Main file for 2d primitives. * * $Log$ + * Revision 1.11 2002/08/31 01:39:13 theoddone33 + * Speed up the renderer a tad + * * Revision 1.10 2002/06/17 06:33:09 relnev * ryan's struct patch for gcc 2.95 * @@ -1228,8 +1231,8 @@ void gr_bitmap(int x, int y) #endif /* don't want opengl bitmap to be called -- slow! */ //case GR_OPENGL: - // gr_opengl_bitmap(x, y); - // break; + //gr_opengl_bitmap(x, y); + //break; default: Int3(); } diff --git a/src/graphics/gropengl.cpp b/src/graphics/gropengl.cpp index 85c6d35..53831d3 100644 --- a/src/graphics/gropengl.cpp +++ b/src/graphics/gropengl.cpp @@ -15,6 +15,9 @@ * Code that uses the OpenGL graphics library * * $Log$ + * Revision 1.57 2002/08/31 01:39:13 theoddone33 + * Speed up the renderer a tad + * * Revision 1.56 2002/08/01 05:03:11 relnev * minor change * @@ -1670,7 +1673,7 @@ typedef struct tcache_slot_opengl { float u_scale, v_scale; int bitmap_id; int size; - char used_this_frame; + int used_this_frame; int time_created; ushort w,h; @@ -1883,6 +1886,7 @@ void opengl_tcache_frame () GL_frame_count++; + /* int i; for( i=0; ibitmap_id > -1 ) { // if I, or any of my children have been used this frame, bail - if(t->used_this_frame){ + if(t->used_this_frame == GL_frame_count){ return 0; } for(idx=0; idxdata_sections[idx][s_idx] != NULL) && (t->data_sections[idx][s_idx]->used_this_frame)){ + if((t->data_sections[idx][s_idx] != NULL) && (t->data_sections[idx][s_idx]->used_this_frame == GL_frame_count)){ return 0; } } @@ -2027,7 +2032,7 @@ int opengl_create_texture_sub(int bitmap_type, int texture_handle, ushort *data, return 0; } - if ( t->used_this_frame ) { + if ( t->used_this_frame == GL_frame_count ) { mprintf(( "ARGHH!!! Texture already used this frame! Cannot free it!\n" )); return 0; } @@ -2375,14 +2380,14 @@ int gr_opengl_tcache_set(int bitmap_id, int bitmap_type, float *u_scale, float * tcache_slot_opengl *t = &Textures[n]; if ( (GL_last_bitmap_id == bitmap_id) && (GL_last_bitmap_type==bitmap_type) && (t->bitmap_id == bitmap_id) && (GL_last_section_x == sx) && (GL_last_section_y == sy)) { - t->used_this_frame++; + t->used_this_frame = GL_frame_count; // mark all children as used if(GL_texture_sections){ for(idx=0; idxdata_sections[idx][s_idx] != NULL){ - t->data_sections[idx][s_idx]->used_this_frame++; + t->data_sections[idx][s_idx]->used_this_frame = GL_frame_count; } } } @@ -2466,7 +2471,7 @@ int gr_opengl_tcache_set(int bitmap_id, int bitmap_type, float *u_scale, float * GL_last_section_x = sx; GL_last_section_y = sy; - t->used_this_frame++; + t->used_this_frame = GL_frame_count; } // gah else { -- 2.39.2