macroquad icon indicating copy to clipboard operation
macroquad copied to clipboard

set_default_camera takes a long time, how to fix?

Open historydev opened this issue 8 months ago • 1 comments

perf("Game Draw", || {
    world.draw(); // Very much entities with shaders
}, true);

perf("Text Draw", || {
    set_default_camera(); 
}, true);

perf("Game Update", || {
    world.update();
}, true);

Debug build

Game Draw executed in: 3.3485ms <--
Text Draw executed in: 8.8616ms <--
Game Update executed in: 630.3µs

Release build

Game Draw executed in: 503.9µs <--
Text Draw executed in: 496.4µs <--
Game Update executed in: 324.7µs

I use set_default_camera() to draw text, like fps, but now it causes 10ms delay!

  • Maybe there is another way to do it?
  • Is this execution time normal? (I don't know how to test the execution time of each line of the set_default_camera function itself):
pub fn set_default_camera() {
    let context = get_context();
    
    context.perform_render_passes();
    
    context.gl.render_pass(None);
    context.gl.depth_test(false);
    context.camera_matrix = None;
}

historydev avatar Apr 15 '25 07:04 historydev