Skip unchanged frames by default
A frame whose draw commands equal the last presented one is skipped, and on the software renderer a changed frame is redrawn only where it changed, for every app. The launch field .skip_same_frames becomes .draw_every_frame, which turns both off; bench sets it so it keeps measuring full frames. The launch struct an app sees changed, so libreaktor's SOVERSION is now 1, and the runtime package libreaktor0 becomes libreaktor1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ef4383319b
commit
b5bbe962ed
@@ -197,7 +197,7 @@ jobs:
|
||||
cmake --build build-arm64-shared --parallel 4 --target libreaktor </dev/null
|
||||
shared="libreaktor-shared-${version}-${{ matrix.os }}-arm64"
|
||||
cmake --install build-arm64-shared --prefix "dist/$shared" --component libreaktor --strip </dev/null
|
||||
file "dist/$shared"/lib/libreaktor.so.0.* | grep -qi aarch64
|
||||
file "dist/$shared"/lib/libreaktor.so.1.* | grep -qi aarch64
|
||||
if grep -rq "$sysroot" "dist/$shared/lib/cmake" "dist/$shared/lib/pkgconfig"; then
|
||||
echo "the shared package carries the sysroot's path"; exit 1
|
||||
fi
|
||||
|
||||
@@ -300,7 +300,7 @@ jobs:
|
||||
-DCMAKE_PREFIX_PATH=/opt/reaktor -DCONSUMER_SHARED=ON </dev/null
|
||||
cmake --build build-pkg-shared </dev/null
|
||||
dpkg -r libreaktor-shared </dev/null
|
||||
dpkg -s libreaktor0 libreaktor-sdl3-0 | grep -c '^Status: install ok installed' | grep -q 2
|
||||
dpkg -s libreaktor1 libreaktor-sdl3-0 | grep -c '^Status: install ok installed' | grep -q 2
|
||||
timeout 600 build-pkg-shared/simple --theme light --video dummy \
|
||||
--shot check/lib-packaged-shared.bmp --a11y-dump check/lib-packaged-shared.txt </dev/null
|
||||
for e in bmp txt; do cmp "check/lib-built.$e" "check/lib-packaged-shared.$e"; done
|
||||
@@ -398,7 +398,7 @@ jobs:
|
||||
rpm -e libreaktor
|
||||
rm -rf build-pkg
|
||||
sh tools/libreaktor-pkg.sh -s -i -o dist-pkg-shared </dev/null
|
||||
rpm -q libreaktor0 libreaktor-sdl3-0 libreaktor-shared
|
||||
rpm -q libreaktor1 libreaktor-sdl3-0 libreaktor-shared
|
||||
cmake -S examples/consumer -B build-pkg-shared -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=/opt/reaktor -DCONSUMER_SHARED=ON </dev/null
|
||||
cmake --build build-pkg-shared </dev/null
|
||||
|
||||
@@ -170,15 +170,15 @@ jobs:
|
||||
|
||||
On Linux and the BSDs the library also comes shared, so
|
||||
several apps can share one copy in memory:
|
||||
\`libreaktor-shared-$v-<system>-<arch>.tar.gz\` holds \`libreaktor.so.0\`,
|
||||
\`libreaktor-shared-$v-<system>-<arch>.tar.gz\` holds \`libreaktor.so.1\`,
|
||||
our own SDL as \`libreaktor-sdl3.so.0\`, \`libreaktor-modules.a\` (the
|
||||
modules, which go into each app), everything the static one has, and
|
||||
\`reaktor-shared.pc\`. Link with \`reaktor::shared\` in CMake or
|
||||
\`pkg-config --cflags --libs reaktor-shared\`; the app records where the
|
||||
libraries are. As system packages it splits in three:
|
||||
\`libreaktor-sdl3-0\` and \`libreaktor0\`, all an app needs to run, and
|
||||
\`libreaktor-sdl3-0\` and \`libreaktor1\`, all an app needs to run, and
|
||||
\`libreaktor-shared\` to build one:
|
||||
\`libreaktor0_${v}_<arch>.deb\`, \`libreaktor-sdl3-0_${v}_<arch>.deb\` and
|
||||
\`libreaktor1_${v}_<arch>.deb\`, \`libreaktor-sdl3-0_${v}_<arch>.deb\` and
|
||||
the \`.rpm\`s beside them. The static library stays the default.
|
||||
|
||||
**Upgrading:** the static package was \`libreaktor-dev\` as a \`.deb\`
|
||||
|
||||
@@ -15,7 +15,7 @@ CMake options pass through: `./build.ps1 -DREAKTOR_A11Y=OFF`,
|
||||
`REAKTOR_SHARED=ON` left in `build/` makes every sample a shared one.
|
||||
|
||||
Shipping: `tools/package.sh` packs a release folder, `tools/libreaktor-pkg.sh`
|
||||
a system package (`libreaktor` static; with `-s`, `libreaktor0`,
|
||||
a system package (`libreaktor` static; with `-s`, `libreaktor1`,
|
||||
`libreaktor-sdl3-0` and `libreaktor-shared`). A version tag such as `1.2.3`
|
||||
publishes through `release.yml`.
|
||||
|
||||
@@ -62,7 +62,8 @@ on every run.
|
||||
the present; the Diagnostics page and `bench --no-vsync` split them. Vsync
|
||||
sits in the present, so a total that matches the refresh rate measures it.
|
||||
- **`--shot` never skips a frame.** It and a capture force the draw, so a pixel
|
||||
diff cannot see what `.skip_same_frames` breaks; `tests/skiptest.c` can.
|
||||
diff cannot see what skipping an unchanged frame breaks; `tests/skiptest.c`
|
||||
can. Skipping is the default; `.draw_every_frame` turns it off.
|
||||
- **Text the atlas lacks is not Nuklear's.** Strings with Japanese, Arabic and
|
||||
the like are measured and drawn by `core/text/text.c` through a custom
|
||||
command. mojibake 0.5.0 records `byte_offset` at a character's last byte.
|
||||
|
||||
+1
-1
@@ -710,7 +710,7 @@ if(REAKTOR_SHARED)
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/reaktor_so.c" CONTENT "")
|
||||
add_library(reaktor_shared SHARED "${CMAKE_BINARY_DIR}/reaktor_so.c")
|
||||
set_target_properties(reaktor_shared PROPERTIES
|
||||
VERSION ${PROJECT_VERSION} SOVERSION 0
|
||||
VERSION ${PROJECT_VERSION} SOVERSION 1
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tools/reaktor.map")
|
||||
add_dependencies(reaktor_shared ${_so_parts})
|
||||
|
||||
@@ -92,7 +92,7 @@ with `-DCMAKE_PREFIX_PATH=/opt/reaktor`, or `pkg-config` with
|
||||
`PKG_CONFIG_PATH=/opt/reaktor/lib/pkgconfig`. Remove it with the system's
|
||||
package manager: it is `libreaktor` everywhere. With `-s` it also
|
||||
builds `libreaktor.so` and packs three packages instead: `libreaktor-sdl3-0`
|
||||
and `libreaktor0`, which an app needs to run, and `libreaktor-shared` to
|
||||
and `libreaktor1`, which an app needs to run, and `libreaktor-shared` to
|
||||
build one. `libreaktor` and `libreaktor-shared` conflict; install one or the
|
||||
other.
|
||||
|
||||
|
||||
+22
-22
@@ -1000,31 +1000,31 @@ While a mouse button is held, frames follow the display's refresh, with two
|
||||
more after the release. A turn of the wheel takes two frames, because Nuklear
|
||||
scrolls a panel after drawing it.
|
||||
|
||||
**A frame that draws what is already on screen** is still rendered and
|
||||
presented, unless the launch sets `.skip_same_frames`. Then each frame's draw
|
||||
**A frame that draws what is already on screen** is skipped. Each frame's draw
|
||||
commands are hashed field by field, and one that matches the last presented
|
||||
frame is neither rendered nor presented. A key nothing takes, or a focus
|
||||
change that moves no ring, then costs the build and nothing more. A window
|
||||
uncovered, shown, resized, restored or moved to another scale is always drawn,
|
||||
and so is a frame a `--shot` or a capture waits for. A tween that changes
|
||||
nothing on screen follows the display's refresh. It is off by default; the
|
||||
showcase turns it on, and its Diagnostics page counts the frames drawn and
|
||||
skipped.
|
||||
nothing on screen follows the display's refresh. A launch that sets
|
||||
`.draw_every_frame` renders and presents every frame, whole; the bench sample
|
||||
does, to measure drawing. The showcase's Diagnostics page counts the frames
|
||||
drawn and skipped.
|
||||
|
||||
On the software renderer at a whole-number scale, a launch with
|
||||
`.skip_same_frames` also redraws a changed frame only where its commands
|
||||
changed. The window is drawn into a texture that keeps the last frame; the
|
||||
commands that differ from it mark up to four rectangles, and only those are
|
||||
cleared and drawn again, through every command, before the texture is copied
|
||||
to the window. A frame that would redraw more than half the window, a new
|
||||
window size, scale, theme or clear color, an evicted icon or a new font atlas,
|
||||
the first frame, and a frame a `--shot` or a capture waits for are drawn whole.
|
||||
Every frame comes out pixel for pixel as a full redraw would draw it;
|
||||
`tests/damagetest.c` checks each one. A GPU renderer, whose back buffer is not
|
||||
kept, or a fractional scale, draws every frame whole. A texture an app changes
|
||||
in place through `reaktor_sdl_renderer` is not among the commands, so a frame
|
||||
that only changes its pixels is skipped, or leaves them where they were: draw
|
||||
it from a new texture, or at a new rectangle, for the change to show.
|
||||
On the software renderer at a whole-number scale, a changed frame is redrawn
|
||||
only where its commands changed. The window is drawn into a texture that keeps
|
||||
the last frame; the commands that differ from it mark up to four rectangles,
|
||||
and only those are cleared and drawn again, through every command, before the
|
||||
texture is copied to the window. A frame that would redraw more than half the
|
||||
window, a new window size, scale, theme or clear color, an evicted icon or a
|
||||
new font atlas, the first frame, and a frame a `--shot` or a capture waits for
|
||||
are drawn whole. Every frame comes out pixel for pixel as a full redraw would
|
||||
draw it; `tests/damagetest.c` checks each one. A GPU renderer, whose back
|
||||
buffer is not kept, or a fractional scale, draws every frame whole. A texture
|
||||
an app changes in place through `reaktor_sdl_renderer` is not among the
|
||||
commands, so a frame that only changes its pixels is skipped, or leaves them
|
||||
where they were: draw it from a new texture, or at a new rectangle, or set
|
||||
`.draw_every_frame`, for the change to show.
|
||||
|
||||
A finger that moves mostly up or down, by more than 8 pixels, scrolls the
|
||||
panel under it: the runtime releases what the finger pressed away from every
|
||||
@@ -1147,7 +1147,7 @@ the library shared, so several apps map one copy: `libreaktor.so` with SDL as
|
||||
stay in each app, from `libreaktor-modules.a`. Link `reaktor::shared`, or on
|
||||
Linux and the BSDs `pkg-config --cflags --libs reaktor-shared`; the framework
|
||||
has no `.pc`. Releases carry it as
|
||||
`libreaktor-shared-<version>-<system>-<arch>`. Its soname is `libreaktor.so.0`
|
||||
`libreaktor-shared-<version>-<system>-<arch>`. Its soname is `libreaktor.so.1`
|
||||
(OpenBSD installs no unversioned `libreaktor.so`), and it exports only what
|
||||
`tools/reaktor.map` names: the public calls, with Nuklear's and NukAnim's,
|
||||
under `LIBREAKTOR_0`, and what the modules call under `LIBREAKTOR_PRIVATE_0`,
|
||||
@@ -1157,7 +1157,7 @@ which an application must not reach.
|
||||
it for the system it runs on: a `.deb` where `dpkg-deb` exists, an `.rpm`
|
||||
where `rpmbuild` does, a FreeBSD, OpenBSD or NetBSD package, or a `.tar.gz`.
|
||||
`-i` installs it, `-s` builds the shared library too and splits the package
|
||||
in three: `libreaktor0` and `libreaktor-sdl3-0` to run an app
|
||||
in three: `libreaktor1` and `libreaktor-sdl3-0` to run an app
|
||||
(`libreaktor-sdl3` on OpenBSD, whose package names read a dash before a digit
|
||||
as the version) and `libreaktor-shared`, with the headers and both
|
||||
libraries, to build one,
|
||||
@@ -1175,7 +1175,7 @@ apart from the system's include directory, because the package carries SDL's
|
||||
and Nuklear's headers. Point `CMAKE_PREFIX_PATH` or `PKG_CONFIG_PATH` (its
|
||||
`lib/pkgconfig`) there. No package depends on a system library — link the
|
||||
ones `pkg-config --libs reaktor` names — only on the others of a split:
|
||||
`libreaktor0` needs `libreaktor-sdl3-0`, and `libreaktor-shared` both.
|
||||
`libreaktor1` needs `libreaktor-sdl3-0`, and `libreaktor-shared` both.
|
||||
`libreaktor` and `libreaktor-shared` install the same headers, so each
|
||||
conflicts with the other.
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ typedef struct reaktor_launch {
|
||||
void *user;
|
||||
int remember_window;
|
||||
int single_instance;
|
||||
int skip_same_frames;
|
||||
int draw_every_frame;
|
||||
reaktor_save save_settings;
|
||||
int save_ms;
|
||||
const char *renderer;
|
||||
|
||||
+1
-1
@@ -1371,7 +1371,7 @@ same_frame(App *app, struct nk_context *ctx)
|
||||
unsigned h;
|
||||
int same;
|
||||
|
||||
if (!g_launch.skip_same_frames) return 0;
|
||||
if (g_launch.draw_every_frame) return 0;
|
||||
h = reaktor_damage_collect(app, ctx);
|
||||
h = reaktor_fnv_n(h, &app->laid_w, sizeof app->laid_w);
|
||||
h = reaktor_fnv_n(h, &app->laid_h, sizeof app->laid_h);
|
||||
|
||||
@@ -138,10 +138,11 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
return launchApp(argc, argv, &(reaktor_launch){
|
||||
.name = "Bench",
|
||||
.window = { .w = 800, .h = 600 },
|
||||
.console = REAKTOR_CONSOLE_PARENT,
|
||||
.page = page_shell,
|
||||
.key = sample_key,
|
||||
.start = sample_start });
|
||||
.name = "Bench",
|
||||
.window = { .w = 800, .h = 600 },
|
||||
.console = REAKTOR_CONSOLE_PARENT,
|
||||
.draw_every_frame = 1,
|
||||
.page = page_shell,
|
||||
.key = sample_key,
|
||||
.start = sample_start });
|
||||
}
|
||||
|
||||
@@ -806,7 +806,6 @@ main(int argc, char **argv)
|
||||
.font_fallbacks = { { .path = "assets/fonts/MPLUS1p-Regular.ttf" } },
|
||||
.confirm_close = SC_CLOSE_QUESTION,
|
||||
.single_instance = 1,
|
||||
.skip_same_frames = 1,
|
||||
.inspector = { .attach = 1 },
|
||||
.page = page_shell,
|
||||
.key = sample_key,
|
||||
|
||||
+5
-6
@@ -511,10 +511,9 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
return reaktor_test_app(argc, argv, &(reaktor_launch){
|
||||
.name = "Damagetest",
|
||||
.window = { .w = 640, .h = 480 },
|
||||
.console = REAKTOR_CONSOLE_PARENT,
|
||||
.skip_same_frames = 1,
|
||||
.font_fallbacks = { { .path = "assets/fonts/MPLUS1p-Regular.ttf" } },
|
||||
.page = page }, script, NULL);
|
||||
.name = "Damagetest",
|
||||
.window = { .w = 640, .h = 480 },
|
||||
.console = REAKTOR_CONSOLE_PARENT,
|
||||
.font_fallbacks = { { .path = "assets/fonts/MPLUS1p-Regular.ttf" } },
|
||||
.page = page }, script, NULL);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,5 @@ main(int argc, char **argv)
|
||||
.name = "Skiptest",
|
||||
.window = { .w = 400, .h = 300 },
|
||||
.console = REAKTOR_CONSOLE_PARENT,
|
||||
.skip_same_frames = 1,
|
||||
.page = page }, script, NULL);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ dev=libreaktor-shared
|
||||
# The runtime packages carry the SOVERSION, as Debian's do. OpenBSD reads a
|
||||
# package name's version from its first dash followed by a digit, so there
|
||||
# the SDL one has no dash before its 0.
|
||||
lib=libreaktor0
|
||||
lib=libreaktor1
|
||||
sdl=libreaktor-sdl3-0
|
||||
[ "$format" = openbsd ] && sdl=libreaktor-sdl3
|
||||
conflicts=""
|
||||
@@ -239,7 +239,7 @@ pack() {
|
||||
}
|
||||
|
||||
# A REAKTOR_SHARED build splits in three, so an app can install the libraries
|
||||
# alone: libreaktor-sdl3-0 (our SDL), libreaktor0 (libreaktor.so, which needs
|
||||
# alone: libreaktor-sdl3-0 (our SDL), libreaktor1 (libreaktor.so, which needs
|
||||
# it) and the development package with everything else, which needs both.
|
||||
split=0
|
||||
ls "$stage$prefix"/lib/libreaktor.so* >/dev/null 2>&1 && split=1
|
||||
|
||||
Reference in New Issue
Block a user