slight optimization
This commit is contained in:
parent
83b45a0dea
commit
4793d6f26a
6 changed files with 39 additions and 25 deletions
|
|
@ -252,21 +252,30 @@ void WindowWayland::xdg_wm_base_handle_ping(void* data, xdg_wm_base* xdg_wm_base
|
|||
xdg_wm_base_pong(xdg_wm_base, serial);
|
||||
}
|
||||
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> framEnd;
|
||||
|
||||
void WindowWayland::wl_surface_frame_done(void* data, struct wl_callback *cb, uint32_t time)
|
||||
{
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
auto vblank = duration_cast<std::chrono::milliseconds>(start - framEnd);
|
||||
wl_callback_destroy(cb);
|
||||
WindowWayland* window = reinterpret_cast<WindowWayland*>(data);
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if(window->updating) {
|
||||
cb = wl_surface_frame(window->surface);
|
||||
wl_callback_add_listener(cb, &WindowWayland::wl_callback_listener, window);
|
||||
auto startUpdate = std::chrono::high_resolution_clock::now();
|
||||
window->onUpdate.Invoke({start, start-window->lastFrameEnd});
|
||||
auto endUpdate = std::chrono::high_resolution_clock::now();
|
||||
auto startRender = std::chrono::high_resolution_clock::now();
|
||||
window->Render();
|
||||
auto endRender = std::chrono::high_resolution_clock::now();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
std::cout << std::format("Update: {}, Render: {}, Vblank: {}, Total: {}", duration_cast<std::chrono::milliseconds>(endUpdate - startUpdate), duration_cast<std::chrono::milliseconds>(endRender - startRender), vblank, duration_cast<std::chrono::milliseconds>((endUpdate - startUpdate)+(endRender - startRender)+vblank)) << std::endl;
|
||||
}
|
||||
|
||||
window->Render();
|
||||
|
||||
framEnd = std::chrono::high_resolution_clock::now();
|
||||
window->lastFrameEnd = start;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue