commit 458ab5d362b839df6d94cea858dec1a2f3c88040 parent e62c8e4976a510072b8755d4296791c3390205bf Author: Michael Savage <mikejsavage@gmail.com> Date: Tue Sep 12 22:54:36 +0300 Show drawcalls/verts per frame Diffstat:
hm.cc | | | 1 | + |
renderer.cc | | | 20 | ++++++++++++++++++++ |
renderer.h | | | 3 | +++ |
diff --git a/hm.cc b/hm.cc @@ -530,6 +530,7 @@ GAME_FRAME( game_frame ) { draw_text( status.c_str(), 2, 2, 16.0f ); draw_text( str< 128 >( "velocity = {.1}, speed = {.2}, sun_angle = {.2}", game->velocity, length( game->velocity.xy() ), game->sun_angle ).c_str(), 2, 20, 16 ); + draw_text( str< 128 >( "drawcalls = {}, verts = {}", renderer_num_draw_calls(), renderer_num_vertices() ).c_str(), 2, 38, 16 ); } renderer_end_pass(); diff --git a/renderer.cc b/renderer.cc @@ -64,6 +64,9 @@ static DynamicArray< DrawCall > draw_calls; static DynamicArray< RenderPass > render_passes; static DynamicArray< DeleteCommand > deletes; +static u32 draw_calls_this_frame; +static u32 vertices_this_frame; + static RenderPass current_render_pass; static bool in_frame; static bool in_pass; @@ -135,6 +138,9 @@ void renderer_begin_frame() { deletes.clear(); render_passes.clear(); + draw_calls_this_frame = 0; + vertices_this_frame = 0; + glBufferData( GL_UNIFORM_BUFFER, UNIFORM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW ); uniforms_buffer = ( u8 * ) glMapBuffer( GL_UNIFORM_BUFFER, GL_WRITE_ONLY ); ASSERT( uniforms_buffer != NULL ); @@ -210,6 +216,14 @@ void renderer_end_frame() { } } +u32 renderer_num_draw_calls() { + return draw_calls_this_frame; +} + +u32 renderer_num_vertices() { + return vertices_this_frame; +} + UniformBinding renderer_upload_uniforms( const void * data, size_t size, size_t alignment ) { alignment = max( alignment, ubo_offset_alignment ); @@ -948,6 +962,9 @@ void renderer_draw_mesh( const Mesh & mesh, const RenderState & render_state ) { dc.num_instances = 0; dc.instance_data = 0; draw_calls.append( dc ); + + draw_calls_this_frame++; + vertices_this_frame += mesh.num_vertices; } void renderer_draw_instances( const Mesh & mesh, const RenderState & render_state, u32 num_instances, VB instance_data ) { @@ -963,6 +980,9 @@ void renderer_draw_instances( const Mesh & mesh, const RenderState & render_stat dc.num_instances = num_instances; dc.instance_data = instance_data; draw_calls.append( dc ); + + draw_calls_this_frame++; + vertices_this_frame += mesh.num_vertices * num_instances; } static void renderer_draw_mesh_( const Mesh & mesh, const RenderState & state ) { diff --git a/renderer.h b/renderer.h @@ -196,6 +196,9 @@ void renderer_begin_pass( ClearColourBool clear_colour, ClearDepthBool clear_dep void renderer_end_pass(); void renderer_end_frame(); +u32 renderer_num_draw_calls(); +u32 renderer_num_vertices(); + Texture renderer_blue_noise(); UniformBinding renderer_upload_uniforms( const void * data, size_t size, size_t alignment );