Blender's GPU Accelerated UI, Decoupled from it's original codebase. Supports Rust, Python, JS, React, C & C++. Twice as good as GPUI
x11: pace frames at a fixed 60 Hz
nusaturnd2505c81591a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ea65bfe..8d950e7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -34,7 +34,7 @@ All notable changes to **blenderui** (BUI). The format follows`_buiimgui` extension is gone (the module is still named `_buiimgui`, created by`buipy.imgui_module()`). The public API is unchanged.- **CI:** the Apple Silicon runner is `macos-15` (GitHub retired `macos-14`).-- **Linux frame pacing:** an animation frame is due one refresh after the previous frame started, at the screen's refresh rate (XRandR). Before, the X11 loop slept 16.7 ms after each frame.+- **Linux frame pacing:** an animation frame is due 16.7 ms (60 Hz) after the previous frame started, so the render time is part of the interval. Before, the X11 loop slept 16.7 ms after each frame.- **Linux GPU start:** the OpenGL context and device are created on a worker thread, as on Direct3D 11. The first frames draw on the CPU.- **Benchmarks on Linux:** `bindings/rust/bench/common/measure.rs` measures CPU time (`CLOCK_PROCESS_CPUTIME_ID`) and memory (`/proc/self/status`) on Linux, so `bui-bench`, `bench_frames` and `cargo test` build there; Windows is unchanged.diff --git a/kit/intern/kit_window_x11.c b/kit/intern/kit_window_x11.cindex 09da13c..068a00c 100644--- a/kit/intern/kit_window_x11.c+++ b/kit/intern/kit_window_x11.c@@ -458,31 +458,9 @@ static void do_render(BKWindow *win)}}-/* The screen refresh interval in ms. XRandR is optional. Without it, use 60 Hz. */static double refresh_ms(void){- static double ms = 0.0;- if (ms <= 0.0) {- int hz = 0;- void *lib = dlopen("libXrandr.so.2", RTLD_NOW | RTLD_LOCAL);- if (lib) {- typedef void *(*InfoFn)(Display *, Window);- typedef short (*RateFn)(void *);- typedef void (*FreeFn)(void *);- const InfoFn info_get = (InfoFn)dlsym(lib, "XRRGetScreenInfo");- const RateFn rate = (RateFn)dlsym(lib, "XRRConfigCurrentRate");- const FreeFn info_free = (FreeFn)dlsym(lib, "XRRFreeScreenConfigInfo");- void *info = (info_get && rate && info_free) ? info_get(g_dpy, DefaultRootWindow(g_dpy)) :- NULL;- if (info) {- hz = rate(info);- info_free(info);- }- dlclose(lib);- }- ms = 1000.0 / (hz > 1 ? hz : 60);- }- return ms;+ return 1000.0 / 60.0;}static void render_window(BKWindow *win)diff --git a/website/src/content/docs/concepts/damage-rendering.mdx b/website/src/content/docs/concepts/damage-rendering.mdxindex 2d498be..b081fc8 100644--- a/website/src/content/docs/concepts/damage-rendering.mdx+++ b/website/src/content/docs/concepts/damage-rendering.mdx@@ -62,7 +62,7 @@ On the full components demo (520×900, Ryzen 7 5800U laptop), that's the differeSome things do need frames over time: a panel collapsing, a CSS transition, a React app calling `requestAnimationFrame`. BUI renders frames **only while something animates**, and stops as soon as it's done.-- **Paced to the display.** On Windows, animation frames wait for the display's next refresh (`DwmFlush`), at its refresh rate. On Linux, the next frame is due one refresh after the previous frame started, at the screen's refresh rate (XRandR), and the event loop waits for it. On macOS, the event loop paces them with a timer.+- **Paced to the display.** On Windows, animation frames wait for the display's next refresh (`DwmFlush`), at its refresh rate. On Linux, the next frame is due 16.7 ms (60 Hz) after the previous frame started, and the event loop waits for it. On macOS, the event loop paces them with a timer.- **Late frames don't wait.** A frame that's already late starts right away instead of waiting for another refresh.- **One rebuild per frame.** Rust and JavaScript rebuild the scene right before the render (`BK_window_request_frame` in C), so changes made in an animation callback join that same frame.- **Damage still applies.** If one cell of a grid animates, only that cell is redrawn each frame.diff --git a/website/src/content/docs/concepts/window-hosts.mdx b/website/src/content/docs/concepts/window-hosts.mdxindex 19319a1..2b08e59 100644--- a/website/src/content/docs/concepts/window-hosts.mdx+++ b/website/src/content/docs/concepts/window-hosts.mdx@@ -41,7 +41,7 @@ A plain Win32 window. Redraw requests coalesce into one render message, and the### Linux (X11)-The same API on Xlib. Button and key mapping follow Blender's `GHOST_SystemX11`. Damaged rectangles go to the window with `XPutImage`, or through GLX with the [GPU renderer](../rendering/). Timers, cross-thread wakes and frame pacing all run in one `select()` loop. An animation frame is due one refresh after the previous frame started, at the screen's refresh rate (XRandR).+The same API on Xlib. Button and key mapping follow Blender's `GHOST_SystemX11`. Damaged rectangles go to the window with `XPutImage`, or through GLX with the [GPU renderer](../rendering/). Timers, cross-thread wakes and frame pacing all run in one `select()` loop. An animation frame is due 16.7 ms (60 Hz) after the previous frame started.Wayland sessions run it through XWayland, which every mainstream desktop provides.