not-fl3 / miniquad

Cross platform rendering in Rust
Apache License 2.0
1.57k stars 173 forks source link

strange rate of draw calls on low-end hardware #302

Open TwilightFlower opened 2 years ago

TwilightFlower commented 2 years ago

I wrote a simple program using miniquad, and sent it to my friend with a low-end computer running Windows 10. It was lagging some, which I wasn't too surprised by, so I started dummying things out. With everything in draw and update dummied out except for a basic function to print the FPS to console every second, it was only hitting ~35 fps. I tried simply putting the same counter code in a loop {...} and it got ~2 million iterations per second, so it seems to be some overhead within miniquad. I know there will be some overhead no matter what, but for not making any calls on Context this seems surprisingly high.

TwilightFlower commented 2 years ago

The code I was using to count FPS, by the way:

struct FPSCounter {
    last_fps: u32,
    last_instant: Instant,
    frames: u32
}

impl FPSCounter {
    fn count_frame(&mut self) {
        let now = Instant::now();
        let elapsed = now - self.last_instant;
        if elapsed > SECOND {
            self.last_fps = self.frames;
            self.last_instant = now;
            self.frames = 0;
            println!("FPS: {}", self.last_fps);
        }
        self.frames += 1;
    }

    fn get_frames(&self) -> u32 {
        self.frames
    }

    fn new() -> Self {
        FPSCounter {
            last_fps: 0,
            last_instant: Instant::now(),
            frames: 0
        }
    }
}
skydig commented 2 years ago

@TwilightFlower , to test under windows, you can calculate fps using hrstoptimer crate. I test the FPS is around 60.