Skip to content

Commit

Permalink
Add frame counter to latency-test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Oct 22, 2023
1 parent 5479a63 commit f8fc916
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/latency_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct LatencyTest : Granite::Application, Granite::EventHandler
return true;
}

void render_frame(double frame_time, double) override
void render_frame(double frame_time, double elapsed_time) override
{
auto &wsi = get_wsi();
auto &device = wsi.get_device();
Expand Down Expand Up @@ -143,6 +143,12 @@ struct LatencyTest : Granite::Application, Granite::EventHandler
}
flat.render_line_strip(offsets, 0.0f, 100, vec4(1.0f, 1.0f, 0.0f, 1.0f));

char elapsed_text[256];
snprintf(elapsed_text, sizeof(elapsed_text), "Elapsed: %.3f, Frame: %u", elapsed_time, counter++);
flat.render_text(GRANITE_UI_MANAGER()->get_font(UI::FontSize::Large),
elapsed_text, { 0, 0, 0 }, { cmd->get_viewport().width, cmd->get_viewport().height },
vec4(1.0f), Font::Alignment::Center, 1.0f);

flat.flush(*cmd, vec3(0.0f), { cmd->get_viewport().width, cmd->get_viewport().height, 5.0f });

cmd->end_render_pass();
Expand All @@ -151,6 +157,7 @@ struct LatencyTest : Granite::Application, Granite::EventHandler
device.submit(cmd);
}

unsigned counter = 0;
std::vector<double> frame_times;
bool state = false;
FlatRenderer flat;
Expand Down

0 comments on commit f8fc916

Please sign in to comment.