Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Rename the G0 codename to GPU drag (identifiers g0_*/G0_* to gdrag_*/GDRAG_*, LORD_G0 to LORD_GPU_DRAG, LordBench's gpuDrag keys, engine-test's gpu-drag runs, log lines, comments, docs and CHANGELOG)

Federico Pereira2f8cf30839b5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f9a2f6..d39585b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -364,7 +364,7 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
- Not done: skipping the copy under the window's opaque middle (it would have to know, before the layer is
painted this frame, that the layer stays opaque there and that no ancestor's rounded corner reads it). The time
saved has not been measured yet.
- - **The dragged window composited on the GPU, with the CPU's pixels ("G0", step 10, approved by the maintainer on
+ - **The dragged window composited on the GPU, with the CPU's pixels ("GPU drag", step 10, approved by the maintainer on
2026-10-28; `ui/paint.c`, `gpu/gpu.c`, `main.c`; `docs/GPU.md`, "The dragged window on the GPU").** On the GPU
path a frame that uses the copy of what is below the window paints only the strips of its damaged box around
the window's rectangle W; the GPU writes W itself, from two textures of its own (the layer and the copy of what
@@ -386,24 +386,24 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
(`glGetShaderPrecisionFormat`), then a self-test in `gpu_init` that draws every valid premultiplied (alpha,
colour ≤ alpha) over every destination value, and every source alpha over every destination alpha, into a
framebuffer (3,145,728 pixels in three 1024 × 1024 tiles), then a placement pass (below), and compares each
- pixel with `canvas_blit` on the CPU (NEON on the Pi). One differing pixel turns G0 off. `LORD_G0=0` turns it
- off. `LORD_GPU_VERIFY=N` paints W on the CPU too every N-th G0 frame
+ pixel with `canvas_blit` on the CPU (NEON on the Pi). One differing pixel turns GPU drag off. `LORD_GPU_DRAG=0` turns it
+ off. `LORD_GPU_VERIFY=N` paints W on the CPU too every N-th GPU drag frame
and compares it with the framebuffer read back (`gpu-verify: frame N W=wxh differ=K worst=D`).
- - **`main.c`** keeps, per display, that the scene and the UI texture are stale in W (`g0on`, `g0w`): W joins the
+ - **`main.c`** keeps, per display, that the scene and the UI texture are stale in W (`gdrag_on`, `gdragw`): W joins the
next frame's damage; a frame with no UI damage (the cursor, an app's new frame) draws the window again from the
textures if they are still that display's, else paints W on the CPU; direct scanout, a failed frame or the GPU
- going away paint it again. A frame whose quad cannot be drawn (a failed upload, G0 turned off) is not shown
- at all (`gpu_frame_ex` returns -2): the display keeps the frame before and the next one paints W on the CPU. `LORD_PAINT_VERIFY` leaves W out on G0 frames (`LORD_GPU_VERIFY` checks it). The
- `drag: …` and `drag (scripted): …` lines end with `G0: N of M frames (Q quads), strips … Mpx, uploaded below …
+ going away paint it again. A frame whose quad cannot be drawn (a failed upload, GPU drag turned off) is not shown
+ at all (`gpu_frame_ex` returns -2): the display keeps the frame before and the next one paints W on the CPU. `LORD_PAINT_VERIFY` leaves W out on GPU drag frames (`LORD_GPU_VERIFY` checks it). The
+ `drag: …` and `drag (scripted): …` lines end with `GPU drag: N of M frames (Q quads), strips … Mpx, uploaded below …
Mpx, layer … Mpx (not: … layer, … clip, … ancestor, … app, … after, … post)`.
- - Checked on VM 116 (x86_64): `canvas-test` compares G0's shader written in C (`canvas_g0_model`) with
+ - Checked on VM 116 (x86_64): `canvas-test` compares GPU drag's shader written in C (`canvas_gdrag_model`) with
`blit_row_c` and the SIMD row over all 8,421,376 valid (alpha, colour, destination) combinations, every alpha
pair, and 200,000 random pixels: 0 differ (NEON not run: no ARM machine was used). `engine-test` has a third
- path, `g0`: the GPU path with G0 and a stub GPU that keeps the UI texture, the two textures (only their dirty
- rectangles) and `main.c`'s bookkeeping, and writes W with `canvas_g0_model`; all 2,417 frames equal
+ path, `gpu-drag`: the GPU path with GPU drag and a stub GPU that keeps the UI texture, the two textures (only their dirty
+ rectangles) and `main.c`'s bookkeeping, and writes W with `canvas_gdrag_model`; all 2,417 frames equal
`drag_golden_gpu.txt`, 250 of the 1,856 frames that use the copy are composited this way (refused: 436 layer,
287 app, 883 after: the big scene's window is mostly near the menu bar or the Dock). Four runs without goldens
- are compared frame by frame with the GPU path: a 30-frame pause with no damage (54 of 61 G0), two displays side
+ are compared frame by frame with the GPU path: a 30-frame pause with no damage (54 of 61 GPU drag), two displays side
by side (150 of 240), the window over an app window below (5 of 180), and the window against a rounded,
bordered container's corner (15 of 90; 44 refused for the ancestor); the single-display ones as the GPU shows
them (the app windows under the UI texture, W written over both). Taking out the after-node, app-window or
@@ -413,70 +413,70 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
- On VM 116 at runtime (llvmpipe forced with `LORD_GPU=1`, an isolated session lent the card by
`tests/seat_cycle.c`, a test scene moved by `lord.wm.script`): the self-test of that time (tiles only, in the
first drag frame) passes (75–113 ms); with
- `LORD_GPU_VERIFY=1`, 1,481 of 1,483 frames were G0 and 0 pixels differed in any; across 4 GPU context
- re-creations during the move, 1,328 G0 frames, 0 differ; with `LORD_PAINT_VERIFY=16`, 0 pixels differ from a
- full repaint outside W in 92 checks. Layout and paint of a drag frame: 0.29–0.35 ms with G0, 0.92 ms without
+ `LORD_GPU_VERIFY=1`, 1,481 of 1,483 frames were GPU drag and 0 pixels differed in any; across 4 GPU context
+ re-creations during the move, 1,328 GPU drag frames, 0 differ; with `LORD_PAINT_VERIFY=16`, 0 pixels differ from a
+ full repaint outside W in 92 checks. Layout and paint of a drag frame: 0.29–0.35 ms with GPU drag, 0.92 ms without
(llvmpipe's own composition dominates the rest, so this says nothing yet about the Pi). `tests/gpu_cycle.sh` 10
- cycles: 38 fds and 226.6–227.6 MB throughout. A real screenshot of G0 frames was taken (seat-cycle's snapshot).
+ cycles: 38 fds and 226.6–227.6 MB throughout. A real screenshot of GPU drag frames was taken (seat-cycle's snapshot).
Not measured yet: the Pi 5 (V3D), where the self-test and `LORD_GPU_VERIFY` must pass before the gain is
claimed.
- - **With the real desktop G0 never composed a frame, fixed:** the list of nodes painted after the window
+ - **With the real desktop GPU drag never composed a frame, fixed:** the list of nodes painted after the window
held 128 boxes and refused every frame once it was full, and LordOS's menu bar and Dock alone fill it
- (`drag: … G0: 0 of 250 frames … 248 after`). The list now grows as needed (up to 65,536 boxes, then the
+ (`drag: … GPU drag: 0 of 250 frames … 248 after`). The list now grows as needed (up to 65,536 boxes, then the
frame is refused as before) and skips a box inside the one noted just before it (an icon inside its bar:
it meets the damaged box only if the bar does), so the menu bar and the Dock are 2 boxes. The decision is
the same for every frame that fit before. `engine-test`'s `pause` run now has 300 more nodes painted after
- the window, each in its own box: with the old 128-box list it fails (`G0 composed 0 of 61`), with this one
+ the window, each in its own box: with the old 128-box list it fails (`GPU drag composed 0 of 61`), with this one
54 of 61 frames, the same as the GPU path frame by frame.
- Checked again on VM 116 with the default theme (an isolated 1280 × 800 session lent the card by
`seat-cycle`, llvmpipe, driven over the remote desktop socket; real screenshots with QMP `screendump`):
the self-test of that time (tiles only) passes (3,145,728 pixels, 127–146 ms). Calculator dragged sideways in the band the menu bar
- and the Dock leave free: 152 of 153 frames G0, and along a figure of eight that reaches them, 7 of 153;
- `LORD_GPU_VERIFY=1` compared 160 G0 frames with the CPU (W up to 462 × 592), 0 pixels differ in any.
- LordBench's Desktop impact gets 1 G0 frame of 2,024 at 1280 × 800: its window, with its shadow, always
+ and the Dock leave free: 152 of 153 frames GPU drag, and along a figure of eight that reaches them, 7 of 153;
+ `LORD_GPU_VERIFY=1` compared 160 GPU drag frames with the CPU (W up to 462 × 592), 0 pixels differ in any.
+ LordBench's Desktop impact gets 1 GPU drag frame of 2,024 at 1280 × 800: its window, with its shadow, always
reaches the Dock's or the menu bar's blurred backdrop (1,377 refused for that) and its turning square
- makes the layer be painted whole (646); result with G0 on: 72.3 fps alone (p50 12.0 ms, p99 16.7 ms),
- 63.8 fps under load (p50 14.4, p99 27.8 ms, 10.8 % late); `LORD_G0=0`: 73.9 fps, 12.0 / 16.7 ms alone,
+ makes the layer be painted whole (646); result with GPU drag on: 72.3 fps alone (p50 12.0 ms, p99 16.7 ms),
+ 63.8 fps under load (p50 14.4, p99 27.8 ms, 10.8 % late); `LORD_GPU_DRAG=0`: 73.9 fps, 12.0 / 16.7 ms alone,
62.0 fps, 14.8 / 26.3 ms, 15.6 % late under load (the same within llvmpipe's noise). `LORD_GPU=0` (CPU
- composition): the same drags paint as before (no G0 tried) and LordBench gives 75.0 fps alone and under load
+ composition): the same drags paint as before (no GPU drag tried) and LordBench gives 75.0 fps alone and under load
(p50 5.1 / 5.7 ms). After the runs the VM's normal session (`lordos.service`) was started again.
- **Fixed after an adversarial review of step 10** (on VM 116; the runtime runs above came before these fixes
and were not repeated, the VM's own session was left alone):
- *Wrong pixels under a rounded clipping box painted after the window.* A view with `overflow: hidden` and
rounded corners that paints nothing itself still saves and restores its corners around its children, which
- darkens what is below them by about 1 level; `node_paints` did not count it, so G0 left it out inside W. It
+ darkens what is below them by about 1 level; `node_paints` did not count it, so GPU drag left it out inside W. It
now counts (`ui/paint.c`). New `engine-test` run `corner` (such a 200 × 150 box, radius 60, over the
window's path), compared frame by frame with the GPU path: without the fix 59 of its 91 frames differ; with
it 0 differ (its box is in every frame's damage: of 90 frames that use the copy, 89 are refused as `after`,
1 for the layer).
- *The pixel position no longer comes from `gl_FragCoord`*, which GLSL ES 1.00 makes `mediump`: with 16-bit
- floats it cannot tell x or y from the next pixel past 1024. G0 has its own vertex shader that passes a
+ floats it cannot tell x or y from the next pixel past 1024. GPU drag has its own vertex shader that passes a
`highp` varying in pixels (`v_px`, the quad's corners on pixel edges) and the shader uses `floor(v_px)`. The
self-test gained a placement pass: a framebuffer as large as the largest output and at least 4096 × 2048
(else the largest the GPU allows, and the log says so), a copy of what is below that size and a layer at an
odd offset (37, 21) reaching its far edges, every pixel a different random value, compared with the CPU. A
- layer or output past what it covered turns G0 off (`gpu_g0_ready(out)` refuses such an output up front).
+ layer or output past what it covered turns GPU drag off (`gpu_gdrag_ready(out)` refuses such an output up front).
Checked headless on VM 116 (a test driver that includes `gpu.c`, a surfaceless GLES2 context on llvmpipe):
the full self-test passes (11,373,321 pixels at 1920 × 1080, 17,678,025 for a 5120 × 2880 output); with the
same shader rounding `v_px` as 16-bit floats would, the tiles pass and the placement pass fails from x = 1024
on (6,207,545 pixels differ), so the old test alone would have passed it.
- - *A failed G0 upload no longer shows a frame with a stale W:* when the quad cannot be drawn `gpu_frame_ex`
+ - *A failed GPU drag upload no longer shows a frame with a stale W:* when the quad cannot be drawn `gpu_frame_ex`
returns -2 before presenting, and `main.c` joins W to the damage and paints it on the CPU in the next frame
- without trying G0 (`g0cpu`), keeping the GPU on. Headless, with a layer larger than the self-test covered:
- -2, nothing presented, G0 off; again with G0 off: -2. A real failed upload was not provoked, and `main.c`'s
+ without trying GPU drag (`gdragcpu`), keeping the GPU on. Headless, with a layer larger than the self-test covered:
+ -2, nothing presented, GPU drag off; again with GPU drag off: -2. A real failed upload was not provoked, and `main.c`'s
side has only been built, not run.
- *`layer.premul_bad` on a layer rendered on the CPU path* (no hole map) was never computed: it is now set,
- so G0 never trusts such a layer after the GPU comes back.
+ so GPU drag never trusts such a layer after the GPU comes back.
- `LORD_GPU_VERIFY`'s CPU reference walk paints on a scratch canvas of the scene's size (an ancestor's rounded
corner above or left of W read before its old W-sized buffer).
- The self-test runs in `gpu_init`, not in the first drag frame, and its outcome is kept per GL renderer and
version across contexts (a GPU restart does not run it again): 311–406 ms on llvmpipe the first time
(it was 75–146 ms without the placement pass), about 1 ms after. Stale GL errors are drained before it,
- dithering is off for the quad, the error drain before an upload is bounded, and G0's program and textures
+ dithering is off for the quad, the error drain before an upload is bounded, and GPU drag's program and textures
are freed when it does not turn on.
- `make -j8` (GPU=1) and lord-server with GPU=0: no warnings; `make test`: 23 passed, 0 failed, 13 skipped;
`engine-test`: 3,690 checks, 0 failures, `drag_golden_{cpu,gpu}.txt` unchanged (250 of 1,856 frames that
- use the copy still G0); `canvas-test`: 8,621,376 cases, 0 differ.
+ use the copy still GPU drag); `canvas-test`: 8,621,376 cases, 0 differ.
- **Where a frame's time goes, measured per frame** (0.8.6, in development; `docs/BENCHMARK.md`, "Frame phases").
On the Pi 5 with its monitor a loaded frame is built in about 13 ms and still the monitor shows 30 frames a
second, 98 % of them late: the time outside the "build" number (JS before the frame, the GPU's own work, the wait
@@ -484,7 +484,7 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
LordBench records or a scripted move runs (`bench/lbframes.c`, filled only by `main.c` and `gpu.c`; nothing comes
from a helper, and `lb_msg_valid` is unchanged since no new result id exists):
- the flip event to lord-server running (`wake`), that wake to `render()` (input, LordBench's scripted step, JS),
- `render()` itself, its layout and paint, the UI texture's upload (time and pixels), G0's texture uploads (time,
+ `render()` itself, its layout and paint, the UI texture's upload (time and pixels), GPU drag's texture uploads (time,
pixels, whether one was whole), `eglSwapBuffers`, the framebuffer and page flip ioctl, the GPU's finish time
after the flip was queued, the wait to the vblank, and wake to flip;
- the GPU's finish time is a native fence taken after `eglSwapBuffers` (`EGL_ANDROID_native_fence_sync`) and read
@@ -494,12 +494,12 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
fence left from before instead of reporting the last composed frame's;
- each frame against the first vblank after it started: on time (shown within half a period of it), CPU-late
(the flip was queued after that vblank), GPU-late (queued before it, the GPU finished after it) or other;
- - per frame whether the paint threads were on, whether G0 composed it or why not (each refusal and, for `layer`,
- its cause: `invalid`, `rendering`, `holes`, `surfaces`, `premul`, `opacity`, `part` and the rest, `G0L_*` in
- `ui/ui.h`), G0's whole uploads and their pixels, and frames not shown (`gpu_frame_ex`'s -2).
+ - per frame whether the paint threads were on, whether GPU drag composed it or why not (each refusal and, for `layer`,
+ its cause: `invalid`, `rendering`, `holes`, `surfaces`, `premul`, `opacity`, `part` and the rest, `GDRAG_L_*` in
+ `ui/ui.h`), GPU drag's whole uploads and their pixels, and frames not shown (`gpu_frame_ex`'s -2).
LordBench's desktop result has them as `frames.phases.alone` and `frames.phases.load` (p50 and p99 in ms, and
counts), and the session log gets `lordbench: desktop alone|under load: phases, …`; the `drag (scripted): …` line
- ends with the same text, and its G0 part now lists `… catching up` and the layer's causes. Without a monitor the
+ ends with the same text, and its GPU drag part now lists `… catching up` and the layer's causes. Without a monitor the
frame's end is its presentation, on the pacing grid. The System Information page is unchanged (it does not show
them). Checked on VM 116: `lordbench-test` (1,192 ok) feeds known frames and checks each class, percentile and
count, the text and a short buffer; and a desktop run in an isolated headless session of the worktree's
@@ -507,24 +507,24 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
`remote.sock`) wrote both phase objects in three runs (alone 601 frames, all on time; under load 720–721, 715–721 on time) and
the drag line. The
GPU fields (uploads, swap, fence) were 0 there: that path was built, not run.
- - **G0's textures catch up between frames instead of inside one** (0.8.6, in development; `docs/GPU.md`, "Uploads without a
- stall"). A drag's start, or a copy of what is below built again whole, made the first G0 frame send the whole
+ - **GPU drag's textures catch up between frames instead of inside one** (0.8.6, in development; `docs/GPU.md`, "Uploads without a
+ stall"). A drag's start, or a copy of what is below built again whole, made the first GPU drag frame send the whole
copy (a screen, 8.3 MB at 1920 × 1080) and the layer; on V3D `glTexSubImage2D` converts to the GPU's tiled layout
- on the CPU, inside the frame. Now a frame G0 would compose but whose textures lack more than 262,144 pixels
- (`G0_FEED_PX`, 1 MB) is painted by the CPU (`G0R_FEED`, "catching up"; the same pixels), and after its flip is
- queued, while the CPU waits for the vblank, a slice of up to that many pixels goes up (`paint_g0_feed`,
- `gpu_g0_feed`: rectangles cut by rows; each texture is asked first whether it holds that display's pixels at that
+ on the CPU, inside the frame. Now a frame GPU drag would compose but whose textures lack more than 262,144 pixels
+ (`GDRAG_FEED_PX`, 1 MB) is painted by the CPU (`GDRAG_R_FEED`, "catching up"; the same pixels), and after its flip is
+ queued, while the CPU waits for the vblank, a slice of up to that many pixels goes up (`paint_gdrag_feed`,
+ `gpu_gdrag_feed`: rectangles cut by rows; each texture is asked first whether it holds that display's pixels at that
size, else it is allocated and all of it is sent in slices; GL errors left by earlier calls are cleared first, so
- they cannot turn G0 off there). Only frames refused for that reason send slices. A G0 frame can still send a
+ they cannot turn GPU drag off there). Only frames refused for that reason send slices. A GPU drag frame can still send a
texture whole when it finds one that is another display's or the wrong size (after the GPU context is made
again, or the layer's first frame within the budget), as before.
Each texture now knows whose pixels it holds; the dirty list keeps 16 rectangles and, when full, merges the two
whose box adds the fewest pixels (the last one used to grow, which could make a few small changes most of the
screen). Frames don't overlap (the next starts after the flip), so the textures need no second copy. Checked on
VM 116: `engine-test`'s stub GPU does the same (a texture made again is filled with a pattern no frame has); all
- 2,417 frames of `drag_golden_gpu.txt` match and the five extra runs match the GPU path frame by frame; no G0
- frame sent a texture whole, and the most one G0 frame sent fell from 934,022 to 170,330 pixels in the long run
- (1024 × 640); 241 of 1,856 frames that use the copy are G0 (250 before: 9 catch up), 2,358,312 pixels went up
+ 2,417 frames of `drag_golden_gpu.txt` match and the five extra runs match the GPU path frame by frame; no GPU drag
+ frame sent a texture whole, and the most one GPU drag frame sent fell from 934,022 to 170,330 pixels in the long run
+ (1024 × 640); 241 of 1,856 frames that use the copy are GPU drag (250 before: 9 catch up), 2,358,312 pixels went up
between frames; `pause` 45 of 61 (54), `two` 148 of 240 (150), `app` 2 of 180 (5), `ancedge` 12 of 90 (15),
`corner` 0 of 90. Not run on a GPU yet.
- **The paint threads turn on by the whole frame too** (0.8.6, in development): on when the frame (`render_frame`:
@@ -542,7 +542,7 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
scripted step are dispatched, the JS frame callbacks and the layout run and its damage is painted into the
display's scene (`out_prepare`), and at N's flip event only its upload, `gpu_frame_ex` (or the copy into the dumb
buffer) and the page flip are left (`out_submit`, through the same `out_present` a frame built at once uses;
- `render_frame` is split into `out_paint` and `out_present`). G0's textures catch up after the submission and
+ `render_frame` is split into `out_paint` and `out_present`). GPU drag's textures catch up after the submission and
before the next frame is painted. At most one frame is prepared; with nothing pending a frame is still built and
flipped at once, so an idle desktop answers input as before.
- Only with one display that has real page flips, on the GPU and the CPU path; never without a monitor, with a
@@ -555,14 +555,14 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
is shown as a frame painted at that moment would have been; the cursor and a Linux app's new buffer are still
taken at submission). A prepare that paints nothing tries nothing more until the flip (no busy loop). A
prepared frame that can't be submitted as painted (the scene reallocated, the GPU context or output changed, or
- for a G0 frame the drag layer began, ended, changed display or reallocated: the new `paint_g0_epoch`) is undone
- into the next frame's damage, its G0 rectangle included, and that frame is built at once; `cpu_takeover`
+ for a GPU drag frame the drag layer began, ended, changed display or reallocated: the new `paint_gdrag_epoch`) is undone
+ into the next frame's damage, its GPU drag rectangle included, and that frame is built at once; `cpu_takeover`
(recording, protected windows for a remote viewer, a failed frame), `gpu_start`, `outputs_apply` (hotplug,
Settings → Displays) and `display_detach` (a session switch, before the card's master goes) undo it first, and
so does the screen going off (DPMS), so it is never shown stale when it comes back. Stopping the GPU for a
recording or protected windows (`cpu_switch`, whose `cpu_takeover` sets the dumb buffer with a modeset) never
runs in a render that only prepares, while the flip is pending; and nothing is prepared in a render whose
- built frame still has G0's catch-up queued (it would run between that prepared frame's paint and its upload).
+ built frame still has GPU drag's catch-up queued (it would run between that prepared frame's paint and its upload).
Direct scanout, the remote desktop's read-back, the protected windows' black, `LORD_GPU_VERIFY` and the -2
path are decided at submission by the same code. The Linux apps' frame callbacks go with a submitted frame,
never with one only prepared.
@@ -578,7 +578,7 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),
without the pipeline and 598 with it, a 20 ms frame 299 and 475, and a light frame 599 either way with auto
never engaging); `engine-test` (6,883 checks, 0 failures) runs every drag case again with each frame presented
only after the next frame's changes, as a prepared frame is, and all 2,417 frames match
- `drag_golden_gpu.txt`, unchanged, with no change between paint and submission moving the G0 epoch;
+ `drag_golden_gpu.txt`, unchanged, with no change between paint and submission moving the GPU drag epoch;
`lordbench-test` (1,197 ok) checks a prepared frame's phases, its class, a late one and the pointer's latency
across the pipeline. LordBench's desktop test in an isolated headless session with `LORD_PIPELINE=1` and `=0`:
the same results (60 fps alone and under load, `prepared 0`: no flips without a monitor). VM 116 has no free
diff --git a/docs/BENCHMARK.md b/docs/BENCHMARK.md
index 89115a0..f7e94b7 100644
--- a/docs/BENCHMARK.md
+++ b/docs/BENCHMARK.md
@@ -593,12 +593,12 @@ by lord-server itself, never by a helper):
| `beforeRenderMs` | that wake → `render()`: pointer motion, LordBench's scripted step, the JS timers |
| `renderMs` | `render()` itself (the same as the build time) |
| `paintMs` | its layout and paint |
-| `uploadMs`, `g0UploadMs` | the UI texture's upload; G0's texture uploads in a G0 frame (`docs/GPU.md`) |
+| `uploadMs`, `gpuDragUploadMs` | the UI texture's upload; GPU drag's texture uploads in a GPU drag frame (`docs/GPU.md`) |
| `swapMs`, `flipIoctlMs` | `eglSwapBuffers`; the front buffer, its framebuffer and the page flip ioctl |
| `gpuMs` | the flip queued → the GPU finished the frame (below) |
| `vblankWaitMs` | the later of those two → the flip |
| `wakeToFlipMs` | the wake → the flip |
-| `catchUpMs` | G0's textures catching up after the flip was queued (`docs/GPU.md`, "Uploads without a stall") |
+| `catchUpMs` | GPU drag's textures catching up after the flip was queued (`docs/GPU.md`, "Uploads without a stall") |
| `heldMs` | a prepared frame (the frame pipeline, `docs/GPU.md`): its paint done → its submission at the flip before it |
A frame the pipeline prepared (counted in `prepared`) is painted while the previous flip is pending and submitted at
@@ -621,7 +621,7 @@ since its paint was done before):
- `otherLate`: late with both before it, or with the GPU time unknown.
And counted per frame: `paintThreads` (the pool was on), `unshown` (`gpu_frame_ex` returned -2), `uploadMpx`,
-`g0UploadMpx` and `catchUpMpx` (pixels per frame, average), and `g0`: `tried`, `taken`, `refused` by reason
+`gpuDragUploadMpx` and `catchUpMpx` (pixels per frame, average), and `gpuDrag`: `tried`, `taken`, `refused` by reason
(`layer`, `clip`, `ancestor`, `app`, `after`, `post`, `feed`), `layer` refusals by cause (`invalid`, `rendering`,
`holes`, `surfaces`, `premul`, `opacity`, `part`…), `wholeUploads` and `wholeMpx`. The result's `frames` object has
`phases.alone` and `phases.load`; the session log gets `lordbench: desktop alone: phases, N frames (ms p50/p99): …`
@@ -635,17 +635,17 @@ worktree's lord-server in an isolated headless session (a test theme moving one
40 cards, CPU composition, one viewer on its `remote.sock`) wrote both objects: alone 601 frames, all on time,
render 0.84/1.78 ms, paint 0.55/1.21 ms; under load 720–721 frames, 715–721 on time (three runs). Those are a check
that it works, not a measurement (a small scene, no GPU). The GPU fields were not exercised: VM 116 sessions are
-headless, so the fence, the uploads' times and G0's counts have been built, not run.
+headless, so the fence, the uploads' times and GPU drag's counts have been built, not run.
**What to run on the Pi 5 next** (the package from this work installed, the monitor on, logged in):
-1. LordBench → Desktop impact, twice with G0 (default) and twice with `LORD_G0=0` in the session's environment.
+1. LordBench → Desktop impact, twice with GPU drag (default) and twice with `LORD_GPU_DRAG=0` in the session's environment.
2. From `~/.cache/lordos/session.log`: the `lordbench: desktop … phases` lines and the `drag (scripted):` line, and
from `~/.local/state/lordos/lordbench-desktop.json` `frames.phases`.
3. Read under load: if most frames are `cpuLate`, the build is too long (`paintMs`, `uploadMs`, `beforeRenderMs`
say which part, and `paintThreads` whether the pool helped); if `gpuLate`, the GPU's own work (`gpuMs`) is; if
`onTime` is high and the rate still 30, the classification is wrong and the flip times must be looked at.
- With G0, `g0.refused`/`g0.layer` say what keeps it off and `catchUpMpx` what the slices cost.
-4. `LORD_GPU_VERIFY=1` once with G0 over a Desktop impact run: `gpu-verify: … differ=0` on every line.
+ With GPU drag, `gpuDrag.refused`/`gpuDrag.layer` say what keeps it off and `catchUpMpx` what the slices cost.
+4. `LORD_GPU_VERIFY=1` once with GPU drag over a Desktop impact run: `gpu-verify: … differ=0` on every line.
Boot: the Pi 5 reaches the login screen on its monitor 5.99 s after the kernel starts (lord-sessiond's record;
systemd-analyze gives 2.1 s kernel + 4.2 s userspace). Boots where the monitor was connected late took 61 and
diff --git a/docs/GPU.md b/docs/GPU.md
index 692ca47..a846328 100644
--- a/docs/GPU.md
+++ b/docs/GPU.md
@@ -105,16 +105,16 @@ milliseconds no longer turns 60 frames a second into 57.
moving the mouse composites nothing. If the driver has no cursor plane, it's drawn as a quad
(`LORD_SW_CURSOR=1` forces it).
-## The dragged window on the GPU ("G0", 0.8.6, in development)
+## The dragged window on the GPU ("GPU drag", 0.8.6, in development)
While a window is dragged its pixels are a cached layer blitted over a copy of what is below it
(`docs/WINDOWS.md`, "The moving window is a layer"). On the GPU path, a frame that uses that copy no
longer paints and uploads the window's rectangle: the GPU writes it, with exactly the pixels the CPU would
have written. Approved by the maintainer on 2026-10-28 (step 10 of the drag-frame work).
-**What the frame does** (`paint_root_g0` in `ui/paint.c`, `gpu_frame_ex` in `gpu/gpu.c`):
+**What the frame does** (`paint_root_gdrag` in `ui/paint.c`, `gpu_frame_ex` in `gpu/gpu.c`):
-1. `below_ready` decides, as before, whether the frame uses the copy. G0 only acts on those frames.
+1. `below_ready` decides, as before, whether the frame uses the copy. GPU drag only acts on those frames.
2. W is where `layer_paint` would blit the layer, cut by the window's ancestors' clips and by the
frame's damaged box D. The CPU paints only D minus W (up to four strips), each a walk of the tree
clipped to the strip (the copy, then from the window on); the scene keeps its stale W.
@@ -123,7 +123,7 @@ have written. Approved by the maintainer on 2026-10-28 (step 10 of the drag-fram
the copy's partial rebuilds; all of it after a full render, a new size, another display or a new
context), and draws one quad over W, after the UI texture and before the menus and the cursor
(layer 1), with blending off.
-4. The shader (`fs_g0`) does `blit_row`'s arithmetic at k = 256 (`canvas.c`): where the layer's alpha
+4. The shader (`fs_gdrag`) does `blit_row`'s arithmetic at k = 256 (`canvas.c`): where the layer's alpha
is 0 the copy's pixel; else `s + floor(d·(255−a)/256)` per colour and `a + floor(((d_a·(255−a) +
128)·257) / 65536)` for alpha, with integers held in `highp` floats. Every intermediate value is an
integer below 2^24 (the largest is 16,744,321) and every scaling is by 2^-8 or 2^-16, so a 24-bit
@@ -131,7 +131,7 @@ have written. Approved by the maintainer on 2026-10-28 (step 10 of the drag-fram
through 16-bit floats) and the output c/255 is converted to c by the framebuffer as the UI
texture's own pixels are. Over a framebuffer that is black under W (no app window is drawn there),
writing the result is what blending the UI texture gave. The pixel it works on comes from `v_px`, a
- `highp` varying in pixels that G0's own vertex shader (`vs_g0`) passes from the quad's corners, not
+ `highp` varying in pixels that GPU drag's own vertex shader (`vs_gdrag`) passes from the quad's corners, not
from `gl_FragCoord`: GLSL ES 1.00 makes that `mediump`, and with 16-bit floats it cannot tell x or y
from the next pixel past 1024. Dithering is off for the quad.
@@ -147,42 +147,42 @@ D is cut into strips); or something changed while the strips were painted, and t
CPU in the same frame (post). Also not with several damaged rectangles, a rotated display, a fullscreen
app, or on another display than the one that owns the layer.
-**The stale rectangle** (`main.c`, `g0on`/`g0w` per display): the next frame that paints the display
+**The stale rectangle** (`main.c`, `gdrag_on`/`gdragw` per display): the next frame that paints the display
joins W to its damage; a frame with no UI damage (the cursor, an app's new frame) draws the window again
from the textures while they are still that display's, else paints W on the CPU; direct scanout, a
failed frame and the GPU going away (`cpu_takeover`) paint it again; the frame after the drag ends
(`paint_layer_end` damages the window's box) paints it on the CPU. When the quad cannot be drawn (an
-upload failed, or the layer or output is larger than the self-test covered: G0 turns off) `gpu_frame_ex`
+upload failed, or the layer or output is larger than the self-test covered: GPU drag turns off) `gpu_frame_ex`
returns -2 before presenting: no frame is shown with a stale W, the display keeps the one before, and
-`main.c` paints W on the CPU in the next frame without trying G0 (`g0cpu`). `LORD_PAINT_VERIFY` leaves W
-out of its count on G0 frames.
+`main.c` paints W on the CPU in the next frame without trying GPU drag (`gdragcpu`). `LORD_PAINT_VERIFY` leaves W
+out of its count on GPU drag frames.
**Uploads without a stall (0.8.6, in development).** The two textures get only what changed (paint.c's dirty
rectangles, in their own pixels). A drag's start, or the copy of what is below built again whole, changes all of the
copy: a screen of pixels (8.3 MB at 1920 × 1080), and on V3D `glTexSubImage2D` converts it to the GPU's tiled layout
-on the CPU inside the call, so the first G0 frame after such a change missed its vblank. Now:
+on the CPU inside the call, so the first GPU drag frame after such a change missed its vblank. Now:
-- `paint_root_body` refuses a frame G0 would compose when the textures still lack more than `G0_FEED_PX` pixels
- (262,144, 1 MB; both textures counted) as `G0R_FEED` ("catching up"): the CPU paints W, the same pixels.
+- `paint_root_body` refuses a frame GPU drag would compose when the textures still lack more than `GDRAG_FEED_PX` pixels
+ (262,144, 1 MB; both textures counted) as `GDRAG_R_FEED` ("catching up"): the CPU paints W, the same pixels.
- After such a frame's flip is queued (`main.c`, after `gpu_frame_ex`), while the CPU waits for the vblank anyway,
- `paint_g0_feed` sends up to `G0_FEED_PX` pixels of what is missing through `gpu_g0_feed`: the copy first, then the
+ `paint_gdrag_feed` sends up to `GDRAG_FEED_PX` pixels of what is missing through `gpu_gdrag_feed`: the copy first, then the
layer, rectangles cut by rows, each sent rectangle (or part) dropped from the dirty list. Each texture is asked
first with an empty rectangle whether it holds that display's pixels at that size; if not, it is allocated
(`glTexImage2D` with no data), marked as that display's, and all of it is sent in slices. Only frames refused for
- `G0R_FEED` send slices: sent while G0 is refused for another reason (the menu bar or the Dock in the damage),
+ `GDRAG_R_FEED` send slices: sent while GPU drag is refused for another reason (the menu bar or the Dock in the damage),
most of it would change again before it is used (`engine-test`: 162.8 million pixels against 2.4 million).
-- Each texture knows whose pixels it holds (`g0tout[2]`); a G0 frame that would find another display's or the
- wrong size still sends all of it (correct, and rare now). The dirty list keeps `G0_DIRTY` (16) rectangles and,
+- Each texture knows whose pixels it holds (`gdragtout[2]`); a GPU drag frame that would find another display's or the
+ wrong size still sends all of it (correct, and rare now). The dirty list keeps `GDRAG_DIRTY` (16) rectangles and,
when full, merges the two whose box adds the fewest pixels (it used to grow the last one).
- Frames don't overlap (a frame starts after the last flip), so the job that read the textures has finished when
they are written: no second copy of them is needed. If frames are ever built while a flip is pending, each
texture needs a pair, each with its own dirty list. GLES3 pixel buffers (the GPU doing the tiling) are not used.
`engine-test`'s stub GPU does the same as `main.c` and `gpu.c` (a texture made again is filled with a pattern no
-frame has, so a pixel the slices missed shows): every frame matches, and it checks that no G0 frame has more than
-`G0_FEED_PX` of the copy left to send.
+frame has, so a pixel the slices missed shows): every frame matches, and it checks that no GPU drag frame has more than
+`GDRAG_FEED_PX` of the copy left to send.
-**Off unless it proves itself:** `gpu_init` sets G0 up. It needs a fragment shader with at least 24-bit
+**Off unless it proves itself:** `gpu_init` sets GPU drag up. It needs a fragment shader with at least 24-bit
`highp` floats (`glGetShaderPrecisionFormat`) and then a self-test, drawn into a framebuffer, read back
and compared with `canvas_blit` on the CPU (the NEON row on the Pi):
- arithmetic: every valid premultiplied (alpha, colour ≤ alpha) over every destination value (three of
@@ -192,34 +192,34 @@ and compared with `canvas_blit` on the CPU (the NEON row on the Pi):
the GPU allows, and the log says `placement in WxH, the largest framebuffer the GPU allows`), a copy
of what is below of that size and a layer at an odd offset (37, 21) that reaches its far edges, every
pixel a different random value, so a texel read from the wrong place shows. An output larger than
- that is refused (`gpu_g0_ready(out)`), and a layer larger than it turns G0 off.
+ that is refused (`gpu_gdrag_ready(out)`), and a layer larger than it turns GPU drag off.
One differing pixel turns it off. The outcome is kept per GL renderer and version across contexts, so a
-GPU restart doesn't run it again. The log says `gpu: G0 on: … self-test: N pixels, every valid
-premultiplied combination and a WxH placement pass, the same as the CPU's, T ms` or `gpu: G0 off: …`
+GPU restart doesn't run it again. The log says `gpu: GPU drag on: … self-test: N pixels, every valid
+premultiplied combination and a WxH placement pass, the same as the CPU's, T ms` or `gpu: GPU drag off: …`
with the reason.
| Switch | Effect |
|---|---|
-| `LORD_G0=0` | G0 off: the dragged window is painted by the CPU as before |
-| `LORD_GPU_VERIFY=N` | every N-th G0 frame W is also painted on the CPU (a walk clipped to W on a scratch canvas) and compared with the framebuffer read back: `gpu-verify: frame N W=wxh differ=K worst=D` |
+| `LORD_GPU_DRAG=0` | GPU drag off: the dragged window is painted by the CPU as before |
+| `LORD_GPU_VERIFY=N` | every N-th GPU drag frame W is also painted on the CPU (a walk clipped to W on a scratch canvas) and compared with the framebuffer read back: `gpu-verify: frame N W=wxh differ=K worst=D` |
-The `drag: …` and `drag (scripted): …` lines end with `G0: N of M frames (Q quads), strips … Mpx,
+The `drag: …` and `drag (scripted): …` lines end with `GPU drag: N of M frames (Q quads), strips … Mpx,
uploaded below … Mpx, layer … Mpx (not: … layer, … clip, … ancestor, … app, … after, … post, … catching up;
layer: invalid …, holes …, …)`: frames composited, of those that used the copy; quads drawn; what the CPU painted
-around W; what went up to the two textures (in G0 frames and in slices between frames); why the others were not;
-and the `layer` refusals by cause (`G0L_*` in `ui/ui.h`: `gone`, `invalid`, `resize`, `rendering`, `capture`,
+around W; what went up to the two textures (in GPU drag frames and in slices between frames); why the others were not;
+and the `layer` refusals by cause (`GDRAG_L_*` in `ui/ui.h`: `gone`, `invalid`, `resize`, `rendering`, `capture`,
`view`, `transform`, `raw`, `holes`, `surfaces`, `premul`, `nobuf`, `tree`, `opacity`, `part`). The
`drag (scripted): …` line then ends with the frames' phases (`docs/BENCHMARK.md`, "Frame phases").
**Checked** (VM 116, x86_64):
-- `canvas-test`: the shader written in C with the same float operations (`canvas_g0_model`) against
+- `canvas-test`: the shader written in C with the same float operations (`canvas_gdrag_model`) against
`blit_row_c` and the SIMD row: all 8,421,376 valid (alpha, colour, destination) combinations, every
alpha pair, and 200,000 random pixels, 0 differ. The NEON row was not run (no ARM machine was used).
-- `engine-test`'s `g0` path: `test_drag_exact` with G0 and a stub GPU (the UI texture, the two textures
- with only their dirty rectangles, `main.c`'s bookkeeping, W written by `canvas_g0_model`) gives every
- one of the 2,417 frames of `drag_golden_gpu.txt`; 250 of 1,856 frames that use the copy are G0 frames
- there (241 with the uploads in slices: 9 frames catch up; no G0 frame sends a texture whole, and the most one
+- `engine-test`'s `gpu-drag` path: `test_drag_exact` with GPU drag and a stub GPU (the UI texture, the two textures
+ with only their dirty rectangles, `main.c`'s bookkeeping, W written by `canvas_gdrag_model`) gives every
+ one of the 2,417 frames of `drag_golden_gpu.txt`; 250 of 1,856 frames that use the copy are GPU drag frames
+ there (241 with the uploads in slices: 9 frames catch up; no GPU drag frame sends a texture whole, and the most one
sends fell from 934,022 to 170,330 pixels). Five more runs are compared frame by frame with the GPU path: a pause with no damage, two
displays side by side, the window over an app window below, the window against a rounded,
bordered container's corner, and (`corner`) a rounded `overflow: hidden` box with no colour painted
@@ -231,23 +231,23 @@ and the `layer` refusals by cause (`G0L_*` in `ui/ui.h`: `gone`, `invalid`, `res
earlier context. With the shader changed to round `v_px` as 16-bit floats would, the tiles pass and the
placement pass fails from x = 1024 on (6,207,545 pixels differ): the tiles alone would not catch it.
With a layer larger than the placement covered, `gpu_frame_ex` returns -2, presents nothing and turns
- G0 off. `main.c`'s side of -2 has been built, not run.
+ GPU drag off. `main.c`'s side of -2 has been built, not run.
- At runtime with llvmpipe (`LORD_GPU=1`; an isolated session lent the card by `tests/seat_cycle.c`, a
scene moved by `lord.wm.script`; before the fixes above, with the self-test of that time: tiles only,
run in the first drag frame): the self-test passes in 75–113 ms; with `LORD_GPU_VERIFY=1`, 1,481
- G0 frames of 1,483 and 0 pixels differ; across 4 context re-creations during the move, 1,328 G0 frames,
+ GPU drag frames of 1,483 and 0 pixels differ; across 4 context re-creations during the move, 1,328 GPU drag frames,
0 differ; `tests/gpu_cycle.sh` (10 cycles) keeps 38 fds and the same memory. Layout and paint of a
- drag frame: 0.29–0.35 ms with G0, 0.92 ms without (llvmpipe's composition is most of the frame, so
+ drag frame: 0.29–0.35 ms with GPU drag, 0.92 ms without (llvmpipe's composition is most of the frame, so
this is no measure of the gain on a real GPU).
- With the default theme (the same kind of session, Calculator dragged over the remote desktop socket,
- real screenshots with QMP `screendump`): 152 of 153 frames G0 while the window stays in the band the
+ real screenshots with QMP `screendump`): 152 of 153 frames GPU drag while the window stays in the band the
menu bar and the Dock leave free, 7 of 153 along a figure of eight that reaches them; `LORD_GPU_VERIFY=1`
- over 160 G0 frames (W up to 462 × 592): 0 pixels differ. The nodes painted after the window are kept
+ over 160 GPU drag frames (W up to 462 × 592): 0 pixels differ. The nodes painted after the window are kept
as a list that grows as needed (up to 65,536 boxes; a box inside the one noted before it is skipped, so
- the menu bar and the Dock are 2 boxes): a fixed list of 128 was full with LordOS's own shell and G0
- refused every frame. LordBench's Desktop impact at 1280 × 800 gets 1 G0 frame of 2,024: its window,
+ the menu bar and the Dock are 2 boxes): a fixed list of 128 was full with LordOS's own shell and GPU drag
+ refused every frame. LordBench's Desktop impact at 1280 × 800 gets 1 GPU drag frame of 2,024: its window,
with its shadow, always reaches the Dock's or the menu bar's blurred backdrop, and its turning square
- makes the layer be painted whole. Its numbers with G0 on and with `LORD_G0=0` are the same within
+ makes the layer be painted whole. Its numbers with GPU drag on and with `LORD_GPU_DRAG=0` are the same within
llvmpipe's noise.
**Not checked yet:** the Raspberry Pi 5 (V3D), the machine this is for: its self-test, `LORD_GPU_VERIFY=1`
@@ -268,17 +268,17 @@ second vblank and the rate locks at half the refresh. That is the Raspberry Pi 5
of frame N is pending, the CPU part of frame N+1 is done ahead (it is *prepared*): pointer input and LordBench's
scripted step are dispatched, the JS frame callbacks and the layout run (`paint_ui`) and its damage is painted into
the display's scene (`paint_out`, `out_prepare`), keeping what the submission needs on the display (`Out`): the rect
-it painted, its painted rectangles for the CPU path, its G0 result (`g0taken`, `g0`), the cursor and app flags
+it painted, its painted rectangles for the CPU path, its GPU drag result (`gdragtaken`, `gdrag`), the cursor and app flags
(`cdirty`, `wl_new`). When N's flip event arrives, only what is left is done for N+1 (`out_submit` →
`out_present`, the same code a frame built at once uses): the texture upload, `gpu_frame_ex` (or the copy into the
-dumb buffer on the CPU path) and the page flip. Then G0's textures catch up and N+2 is prepared. The upload copies
+dumb buffer on the CPU path) and the page flip. Then GPU drag's textures catch up and N+2 is prepared. The upload copies
the scene when it is called (`glTexSubImage2D` from client memory), so painting the next frame into the scene
right after it is safe; the dumb buffers are written only at submission, when the flip has freed one.
**When it applies** (`pipe_on`): one display with real page flips. Not without a monitor (no flip: the headless
path is unchanged), not when the driver completes flips at once and frames are paced in software (`soft`, a
virtual card: the wait there is the pacing slot, not the flip), and not with several displays (paint.c's drag
-layer and G0 state are shared between them; each frame is built and submitted at once there, as before). Both the
+layer and GPU drag state are shared between them; each frame is built and submitted at once there, as before). Both the
GPU and the CPU composition paths use it.
**The switch** `LORD_PIPELINE`, read once at startup (the session log says which): `0` off (exactly the previous
@@ -303,10 +303,10 @@ before the flips themselves came every other vblank) and the rate can double.
pointer is the exception it always was: the cursor is drawn at submission (CPU path) or moved on its plane at
once. A Linux app's new buffer is drawn at submission (GPU path: its texture), so it is never older than before.
- **A prepared frame that can no longer be submitted as painted** is undone (`prep_undo`): what it painted, and the
- window rectangle it left to G0, join the next frame's damage, and that frame is built at once. That happens when
- the scene was reallocated, the GPU context or output changed (`gpu_generation`), or, for a G0 frame, the drag
- layer began, ended, moved to another display or reallocated its buffers (`paint_g0_epoch`, `ui/paint.c`; the
- frame's `GpuG0` points into those buffers). Every path that changes the GPU or the displays also undoes it first:
+ window rectangle it left to GPU drag, join the next frame's damage, and that frame is built at once. That happens when
+ the scene was reallocated, the GPU context or output changed (`gpu_generation`), or, for a GPU drag frame, the drag
+ layer began, ended, moved to another display or reallocated its buffers (`paint_gdrag_epoch`, `ui/paint.c`; the
+ frame's `GpuDrag` points into those buffers). Every path that changes the GPU or the displays also undoes it first:
`cpu_takeover` (screen recording, a remote viewer with protected windows, a failed frame), `gpu_start`,
`outputs_apply` (hotplug, Settings → Displays) and `display_detach` (a session switch: the card's master is
dropped with nothing left prepared). A frame prepared before the screen went off (idle, DPMS) is undone too, so it
@@ -314,12 +314,12 @@ before the flips themselves came every other vblank) and the rate can double.
- **Never while the flip is pending:** stopping the GPU for a recording or a remote viewer with protected windows
(`cpu_switch`: `gpu_shutdown`, and `cpu_takeover` sets the dumb buffer with a modeset) waits for the flip, as it
did before; a frame prepared for the GPU meanwhile is undone there and painted again on the CPU path.
-- **G0:** the prepared frame keeps its `GpuG0` (dirty rectangles, strips, `LORD_GPU_VERIFY`'s reference) until its
- submission, and `paint_g0_done` runs only when its quad is drawn, as before. G0's textures catch up
- (`paint_g0_feed`) after the submission and before the next frame is painted, so the feed never runs between a
+- **GPU drag:** the prepared frame keeps its `GpuDrag` (dirty rectangles, strips, `LORD_GPU_VERIFY`'s reference) until its
+ submission, and `paint_gdrag_done` runs only when its quad is drawn, as before. GPU drag's textures catch up
+ (`paint_gdrag_feed`) after the submission and before the next frame is painted, so the feed never runs between a
frame's paint and its upload (a frame built at once queues its catch-up for the end of `render`, so nothing is
prepared in the same call after it). `engine-test` runs every drag case again with each frame presented only after the
- next frame's changes are made ("g0 pipelined") and checks the same golden hashes, and that those changes never
+ next frame's changes are made ("gpu-drag pipelined") and checks the same golden hashes, and that those changes never
move the epoch.
- **-2 (unshown)**, direct scanout of a fullscreen app, the remote desktop's read-back and the protected windows'
black: decided at submission, by the same code as before.
diff --git a/docs/WINDOWS.md b/docs/WINDOWS.md
index 1ce2f97..4d31e79 100644
--- a/docs/WINDOWS.md
+++ b/docs/WINDOWS.md
@@ -137,14 +137,14 @@ wm.beginResize(id, edges) // edges as in xdg_toplevel.resize: 1 top, 2 botto
0 and `layer_paint` doesn't walk the map. A part that brings the first hole into such a map zeroes
the rest of it first, so what is read is always what the full walk would have written. The
sentinel fill writes one row and copies it.
- - **the GPU composites the window itself** (G0, 0.8.6, in development; `docs/GPU.md`, "The dragged
+ - **the GPU composites the window itself** (GPU drag, 0.8.6, in development; `docs/GPU.md`, "The dragged
window on the GPU"): on a frame that uses the copy of what is below, the CPU paints only the strips
of the damaged box around the window's rectangle, and the GPU writes the rectangle from the layer
and the copy (two textures uploaded only where they changed) with `blit_row`'s own arithmetic, so
the pixels are the same. Not when an ancestor paints over the window, an app window is under it,
a node painted after it (the menu bar, the Dock) meets the box, or the layer has an app window or
- would be painted whole; then the frame is painted as before. `LORD_G0=0` turns it off,
- `LORD_GPU_VERIFY=N` compares it with the CPU every N-th frame. `engine-test`'s `g0` path checks it
+ would be painted whole; then the frame is painted as before. `LORD_GPU_DRAG=0` turns it off,
+ `LORD_GPU_VERIFY=N` compares it with the CPU every N-th frame. `engine-test`'s `gpu-drag` path checks it
against the GPU path's golden hashes.
- **There's no layer** if there is a backdrop blur inside (`backdropFilter`), or a video on the GPU
path.
diff --git a/server/src/bench/lbframes.c b/server/src/bench/lbframes.c
index ce3583b..c4e0285 100644
--- a/server/src/bench/lbframes.c
+++ b/server/src/bench/lbframes.c
@@ -35,14 +35,14 @@ static double pct(const double *v, int n, double p) {
/* ---- frame phases (lbframes.h) ---- */
-enum { PH_WAKE, PH_PRE, PH_PAINT, PH_UP, PH_G0UP, PH_SWAP, PH_SUBC, PH_BUILD, PH_GPU, PH_WAIT, PH_CHAIN, PH_FEED, PH_HELD, PH_N };
+enum { PH_WAKE, PH_PRE, PH_PAINT, PH_UP, PH_GDRAG_UP, PH_SWAP, PH_SUBC, PH_BUILD, PH_GPU, PH_WAIT, PH_CHAIN, PH_FEED, PH_HELD, PH_N };
typedef struct {
atomic_int on;
float v[PH_N][MAXF]; /* ms */
int nv[PH_N];
int n, on_time, cpu_late, gpu_late, other_late, gpu_known;
- int built, par, g0_tried, g0_taken, g0_refused[LBF_G0R], g0_layer[LBF_G0L], g0_full, unshown, piped;
- double up_px, g0_px, feed_px, g0_full_px;
+ int built, par, gdrag_tried, gdrag_taken, gdrag_refused[LBF_GDRAG_R], gdrag_layer[LBF_GDRAG_L], gdrag_full, unshown, piped;
+ double up_px, gdrag_px, feed_px, gdrag_full_px;
} Rec;
static Rec rec_lb, rec_drag; /* LordBench's recording, the scripted drag's */
static LbPhase pend; /* the main display's frame waiting for its flip */
@@ -51,10 +51,10 @@ static int have_pend;
static void rec_clear(Rec *r) { /* everything but on and the values (nv says how many count) */
memset(r->nv, 0, sizeof r->nv);
r->n = r->on_time = r->cpu_late = r->gpu_late = r->other_late = r->gpu_known = 0;
- r->built = r->par = r->g0_tried = r->g0_taken = r->g0_full = r->unshown = r->piped = 0;
- memset(r->g0_refused, 0, sizeof r->g0_refused);
- memset(r->g0_layer, 0, sizeof r->g0_layer);
- r->up_px = r->g0_px = r->feed_px = r->g0_full_px = 0;
+ r->built = r->par = r->gdrag_tried = r->gdrag_taken = r->gdrag_full = r->unshown = r->piped = 0;
+ memset(r->gdrag_refused, 0, sizeof r->gdrag_refused);
+ memset(r->gdrag_layer, 0, sizeof r->gdrag_layer);
+ r->up_px = r->gdrag_px = r->feed_px = r->gdrag_full_px = 0;
}
static void rec_put(Rec *r, int ph, double ms) {
if (ms >= 0 && r->nv[ph] < MAXF) r->v[ph][r->nv[ph]++] = (float)ms;
@@ -68,17 +68,17 @@ static void rec_built(Rec *r, const LbPhase *p) {
r->par += p->par != 0;
r->unshown += p->unshown != 0;
r->piped += p->piped != 0;
- if (p->g0 >= 0) {
- r->g0_tried++;
- if (p->g0 > 0) r->g0_taken++;
- else if (p->g0_why >= 0 && p->g0_why < LBF_G0R) {
- r->g0_refused[p->g0_why]++;
- if (p->g0_sub >= 0 && p->g0_sub < LBF_G0L) r->g0_layer[p->g0_sub]++;
+ if (p->gdrag >= 0) {
+ r->gdrag_tried++;
+ if (p->gdrag > 0) r->gdrag_taken++;
+ else if (p->gdrag_why >= 0 && p->gdrag_why < LBF_GDRAG_R) {
+ r->gdrag_refused[p->gdrag_why]++;
+ if (p->gdrag_sub >= 0 && p->gdrag_sub < LBF_GDRAG_L) r->gdrag_layer[p->gdrag_sub]++;
}
}
- if (p->g0_full) { r->g0_full++; r->g0_full_px += (double)p->g0_px; }
+ if (p->gdrag_full) { r->gdrag_full++; r->gdrag_full_px += (double)p->gdrag_px; }
r->up_px += (double)p->up_px;
- r->g0_px += (double)p->g0_px;
+ r->gdrag_px += (double)p->gdrag_px;
r->feed_px += (double)p->feed_px;
rec_put(r, PH_FEED, p->feed_ms);
}
@@ -105,7 +105,7 @@ static void rec_shown(Rec *r, const LbPhase *p, uint64_t flip, uint64_t gpu) {
rec_put(r, PH_PRE, ms_between(p->wake, p->piped ? p->pre_end : p->render0));
rec_put(r, PH_PAINT, p->paint_ms);
rec_put(r, PH_UP, p->up_ms);
- if (p->g0 > 0) rec_put(r, PH_G0UP, p->g0_ms);
+ if (p->gdrag > 0) rec_put(r, PH_GDRAG_UP, p->gdrag_ms);
rec_put(r, PH_SWAP, p->swap_ms);
rec_put(r, PH_SUBC, p->submit_ms);
double build = ms_between(p->render0, p->built);
@@ -159,7 +159,7 @@ static void rec_stats(const Rec *r, LbPhaseStats *st) {
st->pre = rec_pct(r, PH_PRE);
st->paint = rec_pct(r, PH_PAINT);
st->up = rec_pct(r, PH_UP);
- st->g0up = rec_pct(r, PH_G0UP);
+ st->gdragup = rec_pct(r, PH_GDRAG_UP);
st->swap = rec_pct(r, PH_SWAP);
st->submit_call = rec_pct(r, PH_SUBC);
st->build = rec_pct(r, PH_BUILD);
@@ -170,7 +170,7 @@ static void rec_stats(const Rec *r, LbPhaseStats *st) {
st->held = rec_pct(r, PH_HELD);
int b = r->built ? r->built : 1;
st->up_mpx = r->up_px / b / 1e6;
- st->g0_mpx = r->g0_px / b / 1e6;
+ st->gdrag_mpx = r->gdrag_px / b / 1e6;
st->feed_mpx = r->feed_px / b / 1e6;
st->on_time = r->on_time;
st->cpu_late = r->cpu_late;
@@ -178,12 +178,12 @@ static void rec_stats(const Rec *r, LbPhaseStats *st) {
st->other_late = r->other_late;
st->gpu_known = r->gpu_known;
st->par = r->par;
- st->g0_tried = r->g0_tried;
- st->g0_taken = r->g0_taken;
- memcpy(st->g0_refused, r->g0_refused, sizeof st->g0_refused);
- memcpy(st->g0_layer, r->g0_layer, sizeof st->g0_layer);
- st->g0_full = r->g0_full;
- st->g0_full_px = (long)r->g0_full_px;
+ st->gdrag_tried = r->gdrag_tried;
+ st->gdrag_taken = r->gdrag_taken;
+ memcpy(st->gdrag_refused, r->gdrag_refused, sizeof st->gdrag_refused);
+ memcpy(st->gdrag_layer, r->gdrag_layer, sizeof st->gdrag_layer);
+ st->gdrag_full = r->gdrag_full;
+ st->gdrag_full_px = (long)r->gdrag_full_px;
st->unshown = r->unshown;
st->piped = r->piped;
}
@@ -217,38 +217,38 @@ void lbf_drag_end(LbPhaseStats *st) {
pthread_mutex_unlock(&mu);
}
-static const char *const g0r_names[LBF_G0R] = { "layer", "clip", "ancestor", "app", "after", "post", "feed", "" };
-static const char *const g0l_names[LBF_G0L] = { "gone", "invalid", "resize", "rendering", "capture", "view", "transform", "raw",
+static const char *const gdrag_r_names[LBF_GDRAG_R] = { "layer", "clip", "ancestor", "app", "after", "post", "feed", "" };
+static const char *const gdrag_l_names[LBF_GDRAG_L] = { "gone", "invalid", "resize", "rendering", "capture", "view", "transform", "raw",
"holes", "surfaces", "premul", "nobuf", "tree", "opacity", "part", "" };
-const char *lbf_g0r_name(int i) { return i >= 0 && i < LBF_G0R && g0r_names[i][0] ? g0r_names[i] : NULL; }
-const char *lbf_g0l_name(int i) { return i >= 0 && i < LBF_G0L && g0l_names[i][0] ? g0l_names[i] : NULL; }
+const char *lbf_gdrag_r_name(int i) { return i >= 0 && i < LBF_GDRAG_R && gdrag_r_names[i][0] ? gdrag_r_names[i] : NULL; }
+const char *lbf_gdrag_l_name(int i) { return i >= 0 && i < LBF_GDRAG_L && gdrag_l_names[i][0] ? gdrag_l_names[i] : NULL; }
void lbf_phases_text(const LbPhaseStats *st, char *buf, size_t n) {
size_t k = 0;
#define PUT(...) do { if (k < n) { int w_ = snprintf(buf + k, n - k, __VA_ARGS__); if (w_ > 0) k += (size_t)w_; } } while (0)
PUT("phases, %d frames (ms p50/p99): wake %.2f/%.2f, before render %.2f/%.2f, render %.2f/%.2f (paint %.2f/%.2f, "
- "upload %.2f/%.2f, G0 upload %.2f/%.2f, swap %.2f/%.2f, flip ioctl %.2f/%.2f), GPU after the flip was queued "
- "%.2f/%.2f, to the vblank %.2f/%.2f, wake to flip %.2f/%.2f, G0 catch-up %.2f/%.2f; per frame upload %.3f Mpx, "
- "G0 %.3f, catch-up %.3f; on time %d, CPU-late %d, GPU-late %d, other %d (GPU time known for %d); paint threads "
- "on %d; G0 %d of %d (", st->n, st->wake.p50, st->wake.p99, st->pre.p50, st->pre.p99, st->build.p50, st->build.p99,
- st->paint.p50, st->paint.p99, st->up.p50, st->up.p99, st->g0up.p50, st->g0up.p99, st->swap.p50, st->swap.p99,
+ "upload %.2f/%.2f, GPU drag upload %.2f/%.2f, swap %.2f/%.2f, flip ioctl %.2f/%.2f), GPU after the flip was queued "
+ "%.2f/%.2f, to the vblank %.2f/%.2f, wake to flip %.2f/%.2f, GPU drag catch-up %.2f/%.2f; per frame upload %.3f Mpx, "
+ "GPU drag %.3f, catch-up %.3f; on time %d, CPU-late %d, GPU-late %d, other %d (GPU time known for %d); paint threads "
+ "on %d; GPU drag %d of %d (", st->n, st->wake.p50, st->wake.p99, st->pre.p50, st->pre.p99, st->build.p50, st->build.p99,
+ st->paint.p50, st->paint.p99, st->up.p50, st->up.p99, st->gdragup.p50, st->gdragup.p99, st->swap.p50, st->swap.p99,
st->submit_call.p50, st->submit_call.p99, st->gpu.p50, st->gpu.p99, st->wait.p50, st->wait.p99, st->chain.p50,
- st->chain.p99, st->feed.p50, st->feed.p99, st->up_mpx, st->g0_mpx, st->feed_mpx, st->on_time, st->cpu_late,
- st->gpu_late, st->other_late, st->gpu_known, st->par, st->g0_taken, st->g0_tried);
+ st->chain.p99, st->feed.p50, st->feed.p99, st->up_mpx, st->gdrag_mpx, st->feed_mpx, st->on_time, st->cpu_late,
+ st->gpu_late, st->other_late, st->gpu_known, st->par, st->gdrag_taken, st->gdrag_tried);
int first = 1;
- for (int i = 0; i < LBF_G0R; i++) {
- if (!st->g0_refused[i] || !lbf_g0r_name(i)) continue;
- PUT("%snot %s %d", first ? "" : ", ", lbf_g0r_name(i), st->g0_refused[i]);
+ for (int i = 0; i < LBF_GDRAG_R; i++) {
+ if (!st->gdrag_refused[i] || !lbf_gdrag_r_name(i)) continue;
+ PUT("%snot %s %d", first ? "" : ", ", lbf_gdrag_r_name(i), st->gdrag_refused[i]);
first = 0;
- if (i == 0) { /* G0R_LAYER: its causes */
+ if (i == 0) { /* GDRAG_R_LAYER: its causes */
int f2 = 1;
- for (int j = 0; j < LBF_G0L; j++)
- if (st->g0_layer[j] && lbf_g0l_name(j)) { PUT("%s%s %d", f2 ? " [" : ", ", lbf_g0l_name(j), st->g0_layer[j]); f2 = 0; }
+ for (int j = 0; j < LBF_GDRAG_L; j++)
+ if (st->gdrag_layer[j] && lbf_gdrag_l_name(j)) { PUT("%s%s %d", f2 ? " [" : ", ", lbf_gdrag_l_name(j), st->gdrag_layer[j]); f2 = 0; }
if (!f2) PUT("]");
}
}
- PUT("), whole G0 uploads %d (%.2f Mpx), unshown %d; prepared ahead %d (held for the flip %.2f/%.2f)", st->g0_full,
- st->g0_full_px / 1e6, st->unshown, st->piped, st->held.p50, st->held.p99);
+ PUT("), whole GPU drag uploads %d (%.2f Mpx), unshown %d; prepared ahead %d (held for the flip %.2f/%.2f)", st->gdrag_full,
+ st->gdrag_full_px / 1e6, st->unshown, st->piped, st->held.p50, st->held.p99);
#undef PUT
if (n) buf[k < n ? k : n - 1] = 0;
}
diff --git a/server/src/bench/lbframes.h b/server/src/bench/lbframes.h
index 15e9b04..7321aa5 100644
--- a/server/src/bench/lbframes.h
+++ b/server/src/bench/lbframes.h
@@ -47,25 +47,25 @@ int lbf_end(LbFrameStats *st);
* unknown. All measured by lord-server itself; nothing comes from a helper. Two recorders take them:
* LordBench's (lbf_begin/lbf_end, lbf_phases) and the scripted drag's (lbf_drag_begin/lbf_drag_end), for
* its "drag (scripted):" line. Off, each call is one atomic read. */
-#define LBF_G0R 8 /* G0R_N (ui/ui.h), checked in main.c */
-#define LBF_G0L 16 /* G0L_N */
+#define LBF_GDRAG_R 8 /* GDRAG_R_N (ui/ui.h), checked in main.c */
+#define LBF_GDRAG_L 16 /* GDRAG_L_N */
typedef struct {
uint64_t prev_flip; /* the main display's presentation before this frame */
uint64_t wake; /* poll() returned, before this frame was started */
int from_flip; /* that wake handled the main display's flip (else input or a timer) */
uint64_t render0, built; /* render() started and ended */
double paint_ms; /* layout and paint */
- double up_ms, g0_ms, swap_ms, submit_ms; /* the UI texture's upload, the G0 textures', eglSwapBuffers,
+ double up_ms, gdrag_ms, swap_ms, submit_ms; /* the UI texture's upload, the GPU drag textures', eglSwapBuffers,
* the buffer's framebuffer and the page flip ioctl */
- long up_px, g0_px;
- int g0_full; /* a G0 texture was sent whole in this frame */
- double feed_ms; /* G0's textures catching up after the flip was queued */
+ long up_px, gdrag_px;
+ int gdrag_full; /* a GPU drag texture was sent whole in this frame */
+ double feed_ms; /* GPU drag's textures catching up after the flip was queued */
long feed_px;
uint64_t submit; /* the page flip was queued (0: none, a modeset or no monitor) */
uint32_t period; /* the refresh period, ns */
int par; /* the paint threads were on */
- int g0; /* 1 G0 composed it, 0 refused (g0_why, g0_sub), -1 not tried */
- int g0_why, g0_sub;
+ int gdrag; /* 1 GPU drag composed it, 0 refused (gdrag_why, gdrag_sub), -1 not tried */
+ int gdrag_why, gdrag_sub;
int unshown; /* gpu_frame_ex's -2: nothing shown, a vblank lost */
/* the frame pipeline (fpipe.h): piped = painted ahead while the previous flip was pending, then submitted
* at that flip. Then wake/from_flip/render0/built are its prepare's (render0..built: JS frame callbacks,
@@ -80,22 +80,22 @@ typedef struct {
int n; /* frames with their phases */
LbPct wake; /* the flip to lord-server running (frames started by a flip) */
LbPct pre; /* that wake to render(): input, LordBench's scripted step, JS */
- LbPct paint, up, g0up, swap, submit_call;
+ LbPct paint, up, gdragup, swap, submit_call;
LbPct build; /* render() */
LbPct gpu; /* the flip queued to the GPU done (the fence's signal time) */
LbPct wait; /* the later of the two to the flip: the vblank */
LbPct chain; /* the wake to the flip */
LbPct feed;
LbPct held; /* piped frames: prepared until submitted (the previous flip's wait) */
- double up_mpx, g0_mpx, feed_mpx; /* pixels sent per frame, average, millions */
+ double up_mpx, gdrag_mpx, feed_mpx; /* pixels sent per frame, average, millions */
int on_time; /* shown by the first vblank after the frame started (+ half a period) */
int cpu_late; /* late, and queued after that vblank */
int gpu_late; /* late, queued before it but the GPU finished after it */
int other_late; /* late with both before it (or the GPU time unknown) */
int gpu_known; /* frames with the GPU's finish time */
int par; /* frames with the paint threads on */
- int g0_tried, g0_taken, g0_refused[LBF_G0R], g0_layer[LBF_G0L], g0_full;
- long g0_full_px;
+ int gdrag_tried, gdrag_taken, gdrag_refused[LBF_GDRAG_R], gdrag_layer[LBF_GDRAG_L], gdrag_full;
+ long gdrag_full_px;
int unshown;
int piped; /* frames prepared ahead (fpipe.h) */
} LbPhaseStats;
@@ -105,9 +105,9 @@ int lbf_recording(void); /* either recorder is on (main.c takes t
void lbf_phases(LbPhaseStats *st); /* LordBench's, of the recording lbf_end just stopped */
void lbf_drag_begin(void);
void lbf_drag_end(LbPhaseStats *st);
-/* names of G0R_* and G0L_* (ui/ui.h's order) and the phases as text for a log line */
-const char *lbf_g0r_name(int i);
-const char *lbf_g0l_name(int i);
+/* names of GDRAG_R_* and GDRAG_L_* (ui/ui.h's order) and the phases as text for a log line */
+const char *lbf_gdrag_r_name(int i);
+const char *lbf_gdrag_l_name(int i);
void lbf_phases_text(const LbPhaseStats *st, char *buf, size_t n);
#endif
diff --git a/server/src/bench/lbrun.c b/server/src/bench/lbrun.c
index f6abfe5..d81596f 100644
--- a/server/src/bench/lbrun.c
+++ b/server/src/bench/lbrun.c
@@ -141,22 +141,22 @@ static void cond_json(HBuf *b, const LbCond *c) {
static void phases_json(HBuf *b, const LbPhaseStats *p) {
const struct { const char *k; LbPct v; } t[] = {
{ "wakeMs", p->wake }, { "beforeRenderMs", p->pre }, { "renderMs", p->build }, { "paintMs", p->paint },
- { "uploadMs", p->up }, { "g0UploadMs", p->g0up }, { "swapMs", p->swap }, { "flipIoctlMs", p->submit_call },
+ { "uploadMs", p->up }, { "gpuDragUploadMs", p->gdragup }, { "swapMs", p->swap }, { "flipIoctlMs", p->submit_call },
{ "gpuMs", p->gpu }, { "vblankWaitMs", p->wait }, { "wakeToFlipMs", p->chain }, { "catchUpMs", p->feed },
{ "heldMs", p->held },
};
hb_printf(b, "{\"frames\":%d", p->n);
for (size_t i = 0; i < sizeof t / sizeof *t; i++) hb_printf(b, ",\"%s\":[%.3f,%.3f]", t[i].k, t[i].v.p50, t[i].v.p99);
- hb_printf(b, ",\"uploadMpx\":%.4f,\"g0UploadMpx\":%.4f,\"catchUpMpx\":%.4f,\"onTime\":%d,\"cpuLate\":%d,\"gpuLate\":%d,"
- "\"otherLate\":%d,\"gpuKnown\":%d,\"paintThreads\":%d,\"unshown\":%d,\"prepared\":%d,\"g0\":{\"tried\":%d,\"taken\":%d,"
+ hb_printf(b, ",\"uploadMpx\":%.4f,\"gpuDragUploadMpx\":%.4f,\"catchUpMpx\":%.4f,\"onTime\":%d,\"cpuLate\":%d,\"gpuLate\":%d,"
+ "\"otherLate\":%d,\"gpuKnown\":%d,\"paintThreads\":%d,\"unshown\":%d,\"prepared\":%d,\"gpuDrag\":{\"tried\":%d,\"taken\":%d,"
"\"wholeUploads\":%d,\"wholeMpx\":%.3f,\"refused\":{",
- p->up_mpx, p->g0_mpx, p->feed_mpx, p->on_time, p->cpu_late, p->gpu_late, p->other_late, p->gpu_known, p->par,
- p->unshown, p->piped, p->g0_tried, p->g0_taken, p->g0_full, p->g0_full_px / 1e6);
- for (int i = 0, k = 0; i < LBF_G0R; i++)
- if (p->g0_refused[i] && lbf_g0r_name(i)) hb_printf(b, "%s\"%s\":%d", k++ ? "," : "", lbf_g0r_name(i), p->g0_refused[i]);
+ p->up_mpx, p->gdrag_mpx, p->feed_mpx, p->on_time, p->cpu_late, p->gpu_late, p->other_late, p->gpu_known, p->par,
+ p->unshown, p->piped, p->gdrag_tried, p->gdrag_taken, p->gdrag_full, p->gdrag_full_px / 1e6);
+ for (int i = 0, k = 0; i < LBF_GDRAG_R; i++)
+ if (p->gdrag_refused[i] && lbf_gdrag_r_name(i)) hb_printf(b, "%s\"%s\":%d", k++ ? "," : "", lbf_gdrag_r_name(i), p->gdrag_refused[i]);
hb_printf(b, "},\"layer\":{");
- for (int i = 0, k = 0; i < LBF_G0L; i++)
- if (p->g0_layer[i] && lbf_g0l_name(i)) hb_printf(b, "%s\"%s\":%d", k++ ? "," : "", lbf_g0l_name(i), p->g0_layer[i]);
+ for (int i = 0, k = 0; i < LBF_GDRAG_L; i++)
+ if (p->gdrag_layer[i] && lbf_gdrag_l_name(i)) hb_printf(b, "%s\"%s\":%d", k++ ? "," : "", lbf_gdrag_l_name(i), p->gdrag_layer[i]);
hb_printf(b, "}}}");
}
diff --git a/server/src/canvas.c b/server/src/canvas.c
index 1b153f8..f3f6e51 100644
--- a/server/src/canvas.c
+++ b/server/src/canvas.c
@@ -126,14 +126,14 @@ static void mask_row_neon(uint32_t *row, const uint8_t *m, int n, uint32_t argb,
# define CANVAS_SIMD "C"
#endif
-/* G0's shader (gpu/gpu.c, fs_g0) in C, with the same float operations in the same order: a texel read
+/* GPU drag's shader (gpu/gpu.c, fs_gdrag) in C, with the same float operations in the same order: a texel read
* back as c/255 and rounded, then the layer over the copy of what is below with integers held in
* floats. tests/canvas_test.c checks it against blit_row_c (and blit_row_neon) over every valid
* premultiplied combination; engine-test composes with it where the GPU would. */
-static float g0_fetch(uint32_t v) { return floorf((float)v / 255.0f * 255.0f + 0.5f); }
-uint32_t canvas_g0_model(uint32_t s, uint32_t d) {
+static float gdrag_fetch(uint32_t v) { return floorf((float)v / 255.0f * 255.0f + 0.5f); }
+uint32_t canvas_gdrag_model(uint32_t s, uint32_t d) {
float sc[4], dc[4], o[4];
- for (int i = 0; i < 4; i++) { sc[i] = g0_fetch(s >> (8 * i) & 255); dc[i] = g0_fetch(d >> (8 * i) & 255); o[i] = dc[i]; }
+ for (int i = 0; i < 4; i++) { sc[i] = gdrag_fetch(s >> (8 * i) & 255); dc[i] = gdrag_fetch(d >> (8 * i) & 255); o[i] = dc[i]; }
if (sc[3] > 0.0f) { /* [3]: alpha, [0..2]: blue, green, red */
float ia = 255.0f - sc[3];
for (int i = 0; i < 3; i++) o[i] = sc[i] + floorf(dc[i] * ia * 0.00390625f);
diff --git a/server/src/canvas.h b/server/src/canvas.h
index 469755a..4d565bb 100644
--- a/server/src/canvas.h
+++ b/server/src/canvas.h
@@ -62,7 +62,7 @@ int canvas_affine_cut(void); /* 1 if one was cut since canvas_affine_
void canvas_alpha_mask(Canvas *c, int x, int y, const uint8_t *a, int w, int h, int stride, uint32_t argb);
/* Premultiplied ARGB image, with rounded corners and opacity. */
void canvas_blit(Canvas *c, const uint32_t *src, int sw, int sh, int x, int y, float r, float opacity, int opaque);
-uint32_t canvas_g0_model(uint32_t src, uint32_t dst); /* G0's shader in C: src (valid premultiplied) over dst, as blit_row at k = 256 */
+uint32_t canvas_gdrag_model(uint32_t src, uint32_t dst); /* GPU drag's shader in C: src (valid premultiplied) over dst, as blit_row at k = 256 */
/* Character bitmap: 'X' = fg, 'o' = bg, rest transparent (cursor). */
/* Scaled, bilinear: source rect (sx, sy, sw, sh) of an image sw_px × sh_px (stride in pixels) into the
* destination rect (dx, dy, dw, dh). Wayland buffers at another scale and wp_viewporter (CPU path). */
diff --git a/server/src/gpu/gpu.c b/server/src/gpu/gpu.c
index 24fc152..5fad89f 100644
--- a/server/src/gpu/gpu.c
+++ b/server/src/gpu/gpu.c
@@ -38,15 +38,15 @@ void gpu_set_hooks(void (*lost)(void), void (*changed)(void)) { (void)lost; (voi
int gpu_tex_read(const GpuTex *t, uint32_t *px, int w, int h) { (void)t; (void)px; (void)w; (void)h; return -1; }
int gpu_add_output(Kms *k) { (void)k; return -1; }
int gpu_frame(int out, const Canvas *s, Rect d, void (*f)(int)) { (void)out; (void)s; (void)d; (void)f; return -1; }
-int gpu_g0_ready(int out) { (void)out; return 0; }
-int gpu_frame_ex(int out, const Canvas *s, const Rect *d, int n, const GpuG0 *g, int *drawn, void (*f)(int)) {
+int gpu_gdrag_ready(int out) { (void)out; return 0; }
+int gpu_frame_ex(int out, const Canvas *s, const Rect *d, int n, const GpuDrag *g, int *drawn, void (*f)(int)) {
(void)out; (void)s; (void)d; (void)n; (void)g; (void)f;
if (drawn) *drawn = 0;
return -1;
}
-int gpu_g0_holds(int out) { (void)out; return 0; }
-void gpu_g0_stats(long *b, long *l, long *q) { *b = *l = *q = 0; }
-int gpu_g0_feed(int out, int which, const uint32_t *px, int w, int h, Rect r) {
+int gpu_gdrag_holds(int out) { (void)out; return 0; }
+void gpu_gdrag_stats(long *b, long *l, long *q) { *b = *l = *q = 0; }
+int gpu_gdrag_feed(int out, int which, const uint32_t *px, int w, int h, Rect r) {
(void)out; (void)which; (void)px; (void)w; (void)h; (void)r;
return -1;
}
@@ -155,13 +155,13 @@ static struct {
long frames, scanouts;
char render_node[64]; /* where Mesa renders (on the Pi 5: v3d, not vc4) */
unsigned gen; /* this context's generation (0 = none) */
- /* G0, the dragged window composited here (gpu_g0_ready): 0 off, 1 on (g0_setup, at gpu_init) */
- int g0;
- int g0tout[2]; /* the output whose pixels each texture holds (-1: none); what it
+ /* GPU drag, the dragged window composited here (gpu_gdrag_ready): 0 off, 1 on (gdrag_setup, at gpu_init) */
+ int gdrag;
+ int gdragtout[2]; /* the output whose pixels each texture holds (-1: none); what it
* still lacks is paint.c's dirty rectangles */
- GLuint g0prog, g0tex[2]; /* 0: the copy of what is below, 1: the layer */
- int g0tw[2], g0th[2]; /* their sizes (0: nothing uploaded) */
- int g0lw, g0lh; /* the largest output the self-test's placement covered */
+ GLuint gdragprog, gdragtex[2]; /* 0: the copy of what is below, 1: the layer */
+ int gdragtw[2], gdragth[2]; /* their sizes (0: nothing uploaded) */
+ int gdraglw, gdraglh; /* the largest output the self-test's placement covered */
GLint gu_below, gu_layer, gu_bsize, gu_lrect, gu_swap;
/* EGL_ANDROID_native_fence_sync: when the GPU finished a frame (gpu_fence_on) */
PFNEGLCREATESYNCKHRPROC create_sync;
@@ -175,7 +175,7 @@ static unsigned last_gen;
static const char *last_why = ""; /* gpu_info: the last gpu_init's outcome */
static unsigned long total_scanouts;
static char last_renderer[160]; /* the software renderer that was turned down */
-static long g0_bpx, g0_lpx, g0_quads; /* G0's uploads and quads since gpu_g0_stats (across contexts) */
+static long gdrag_bpx, gdrag_lpx, gdrag_quads; /* GPU drag's uploads and quads since gpu_gdrag_stats (across contexts) */
static void (*hook_lost)(void), (*hook_changed)(void);
void gpu_set_hooks(void (*lost)(void), void (*changed)(void)) { hook_lost = lost; hook_changed = changed; }
@@ -235,7 +235,7 @@ static void query_render_node(void) {
/* ---- shaders ---- */
-static int g0_setup(void);
+static int gdrag_setup(void);
static const char *vs_src =
"attribute vec2 a_pos; attribute vec2 a_uv; varying vec2 v_uv;\n"
@@ -252,21 +252,21 @@ static const char *fs_ext =
"void main() { vec4 c = texture2D(u_tex, v_uv);\n"
" if (u_opaque > 0.5) c.a = 1.0; gl_FragColor = c * u_op; }\n";
-/* G0: the layer over the copy of what is below, with blit_row's integer arithmetic (canvas.c, k = 256)
+/* GPU drag: the layer over the copy of what is below, with blit_row's integer arithmetic (canvas.c, k = 256)
* in 24-bit floats: every value is an integer below 2^24 and scaling by 2^-8 or 2^-16 is exact, so
* floor gives the CPU's result bit for bit (docs/GPU.md, "The dragged window on the GPU"). Texels come
* back as c/255 even through 16-bit floats close enough that floor(c·255 + 0.5) is c again; the
* output c/255 is converted back to c by the framebuffer as the UI texture's is. The pixel comes from
- * v_px, a highp varying in pixels (top-down) that vs_g0 passes from the quad's corners, not from
+ * v_px, a highp varying in pixels (top-down) that vs_gdrag passes from the quad's corners, not from
* gl_FragCoord, which GLSL ES 1.00 makes mediump: with 16-bit floats it can't tell x or y from x + 1 past
* 1024. The self-test's placement part checks it. */
-#define G0_TILE 1024 /* the self-test's arithmetic tiles (G0_TILE²) */
-#define G0_LX 37 /* and where its placement part puts the layer (odd) */
-#define G0_LY 21
-static const char *vs_g0 =
+#define GDRAG_TILE 1024 /* the self-test's arithmetic tiles (GDRAG_TILE²) */
+#define GDRAG_LX 37 /* and where its placement part puts the layer (odd) */
+#define GDRAG_LY 21
+static const char *vs_gdrag =
"attribute vec2 a_pos; attribute vec2 a_px; varying highp vec2 v_px;\n"
"void main() { v_px = a_px; gl_Position = vec4(a_pos, 0.0, 1.0); }\n";
-static const char *fs_g0 =
+static const char *fs_gdrag =
"#ifndef GL_FRAGMENT_PRECISION_HIGH\n#error no highp float\n#endif\n"
"precision highp float;\n"
"uniform highp sampler2D u_below, u_layer;\n"
@@ -542,7 +542,7 @@ int gpu_init(Kms *k) {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
G.on = 1;
- G.g0tout[0] = G.g0tout[1] = -1;
+ G.gdragtout[0] = G.gdragtout[1] = -1;
last_why = "on";
if (G.debug) {
GpuFormat f[64];
@@ -552,8 +552,8 @@ int gpu_init(Kms *k) {
fprintf(stderr, "gpu: GPU composition (%s, EGL %d.%d, dmabuf %s, render %s, display %s)\n", G.renderer, maj, min,
G.create_image ? (G.query_modifiers ? "with modifiers" : "yes") : "no",
G.render_node[0] ? G.render_node : "the card's", k->driver[0] ? k->driver : drv);
- /* G0's self-test runs here, not in the first drag frame (once per renderer: g0_memo) */
- G.g0 = g0_setup();
+ /* GPU drag's self-test runs here, not in the first drag frame (once per renderer: gdrag_memo) */
+ G.gdrag = gdrag_setup();
if (hook_changed) hook_changed(); /* windows re-import their buffers in this context */
return 0;
fail:
@@ -855,9 +855,9 @@ static long upload_rect(const uint32_t *px, int stride, int sw, int texw, Rect r
return (long)(r.x1 - r.x0) * (r.y1 - r.y0);
}
-/* ---- G0: the dragged window on the GPU ---- */
+/* ---- GPU drag: the dragged window on the GPU ---- */
-static GLuint g0_texture(void) {
+static GLuint gdrag_texture(void) {
GLuint t = 0;
glGenTextures(1, &t);
glBindTexture(GL_TEXTURE_2D, t);
@@ -870,16 +870,16 @@ static GLuint g0_texture(void) {
/* Texture i gets output out's px (w × h, stride w): all of it if its size changed, it held another
* output's (or nothing) or full, else the n rectangles. */
-static long g0_upload(int i, int out, const uint32_t *px, int w, int h, const Rect *r, int n, int full) {
- glBindTexture(GL_TEXTURE_2D, G.g0tex[i]);
- int other = G.g0tout[i] != out;
- G.g0tout[i] = out;
- if (full || other || G.g0tw[i] != w || G.g0th[i] != h) {
+static long gdrag_upload(int i, int out, const uint32_t *px, int w, int h, const Rect *r, int n, int full) {
+ glBindTexture(GL_TEXTURE_2D, G.gdragtex[i]);
+ int other = G.gdragtout[i] != out;
+ G.gdragtout[i] = out;
+ if (full || other || G.gdragtw[i] != w || G.gdragth[i] != h) {
GLenum fmt = G.bgra ? GL_BGRA_EXT : GL_RGBA;
- if (G.g0tw[i] != w || G.g0th[i] != h) glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, px);
+ if (G.gdragtw[i] != w || G.gdragth[i] != h) glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, px);
else glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, fmt, GL_UNSIGNED_BYTE, px);
- G.g0tw[i] = w;
- G.g0th[i] = h;
+ G.gdragtw[i] = w;
+ G.gdragth[i] = h;
return (long)w * h;
}
long sent = 0;
@@ -894,14 +894,14 @@ static long g0_upload(int i, int out, const uint32_t *px, int w, int h, const Re
return sent;
}
-/* The G0 quad: the shader inside w (a framebuffer W × H px), blending and dithering off (it writes the
+/* The GPU drag quad: the shader inside w (a framebuffer W × H px), blending and dithering off (it writes the
* result). The quad covers the framebuffer and carries each corner's pixel position (top-down) for v_px. */
-static void g0_draw(int W, int H, Rect w, float lx, float ly, float lw, float lh, float bw, float bh) {
- glUseProgram(G.g0prog);
+static void gdrag_draw(int W, int H, Rect w, float lx, float ly, float lw, float lh, float bw, float bh) {
+ glUseProgram(G.gdragprog);
glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, G.g0tex[1]);
+ glBindTexture(GL_TEXTURE_2D, G.gdragtex[1]);
glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, G.g0tex[0]);
+ glBindTexture(GL_TEXTURE_2D, G.gdragtex[0]);
glUniform1i(G.gu_below, 0);
glUniform1i(G.gu_layer, 1);
glUniform2f(G.gu_bsize, bw, bh);
@@ -925,9 +925,9 @@ static void g0_draw(int W, int H, Rect w, float lx, float ly, float lw, float lh
/* The self-test's cases, in order: every valid premultiplied (alpha a, channel c ≤ a) with every
* destination channel d (three cases a pixel, one per colour channel, the destination alpha varying),
* then every (source alpha, destination alpha), then random valid pixels to fill the last tile. */
-typedef struct { int a, j, grid; uint32_t p, rng; } G0Gen;
-static int g0_gen_done(const G0Gen *g) { return g->a > 255 && g->grid >= 65536; }
-static void g0_gen(G0Gen *g, uint32_t *s, uint32_t *d) {
+typedef struct { int a, j, grid; uint32_t p, rng; } GdragGen;
+static int gdrag_gen_done(const GdragGen *g) { return g->a > 255 && g->grid >= 65536; }
+static void gdrag_gen(GdragGen *g, uint32_t *s, uint32_t *d) {
g->p++;
g->rng ^= g->rng << 13; g->rng ^= g->rng >> 17; g->rng ^= g->rng << 5;
if (g->a <= 255) {
@@ -959,7 +959,7 @@ static void g0_gen(G0Gen *g, uint32_t *s, uint32_t *d) {
* over bel (fw × fh), drawn where the layer is and compared with canvas_blit on the CPU into ref; the rest
* of the framebuffer must stay as cleared (0). rd (fw × fh × 4 bytes) may be bel's memory: it is read
* back after the upload. -1 on a GL error, else the pixels that differ (the first few logged). */
-static long g0_pass(int fw, int fh, const uint32_t *bel, const uint32_t *lay, int lx, int ly, int lw,
+static long gdrag_pass(int fw, int fh, const uint32_t *bel, const uint32_t *lay, int lx, int ly, int lw,
int lh, uint32_t *ref, uint8_t *rd, const char *what) {
memcpy(ref, bel, (size_t)fw * fh * 4);
Canvas c;
@@ -969,12 +969,12 @@ static long g0_pass(int fw, int fh, const uint32_t *bel, const uint32_t *lay, in
for (int y = 0; y < fh; y++)
for (int x = 0; x < fw; x++)
if (x < w.x0 || x >= w.x1 || y < w.y0 || y >= w.y1) ref[(size_t)y * fw + x] = 0;
- g0_upload(0, -1, bel, fw, fh, NULL, 0, 1);
- g0_upload(1, -1, lay, lw, lh, NULL, 0, 1);
+ gdrag_upload(0, -1, bel, fw, fh, NULL, 0, 1);
+ gdrag_upload(1, -1, lay, lw, lh, NULL, 0, 1);
glViewport(0, 0, fw, fh);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
- g0_draw(fw, fh, w, (float)lx, (float)ly, (float)lw, (float)lh, (float)fw, (float)fh);
+ gdrag_draw(fw, fh, w, (float)lx, (float)ly, (float)lw, (float)lh, (float)fw, (float)fh);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glReadPixels(0, 0, fw, fh, GL_RGBA, GL_UNSIGNED_BYTE, rd);
if (glGetError() != GL_NO_ERROR) return -1;
@@ -985,19 +985,19 @@ static long g0_pass(int fw, int fh, const uint32_t *bel, const uint32_t *lay, in
for (int x = 0; x < fw; x++) {
uint32_t v = (uint32_t)b[4 * x + 3] << 24 | (uint32_t)b[4 * x] << 16 | (uint32_t)b[4 * x + 1] << 8 | b[4 * x + 2];
if (v != e[x] && differ++ < 4)
- fprintf(stderr, "gpu: G0 self-test (%s): pixel (%d, %d): CPU %08x, GPU %08x\n", what, x, y, e[x], v);
+ fprintf(stderr, "gpu: GPU drag self-test (%s): pixel (%d, %d): CPU %08x, GPU %08x\n", what, x, y, e[x], v);
}
}
return differ;
}
-/* The self-test, two parts. Arithmetic: every case of g0_gen in 1024 × 1024 tiles (the layer over the
+/* The self-test, two parts. Arithmetic: every case of gdrag_gen in 1024 × 1024 tiles (the layer over the
* copy, pixel for pixel). Placement: an fw × fh framebuffer (the output's size, at least 4096 × 2048 when
* the GPU allows it) and a copy of that size, with the layer at an odd offset reaching its far edges,
* every pixel a different random value: a texel read from the wrong place (gl_FragCoord or a varying
* with too few bits, the far rows and columns) shows. 0 if every pixel is the CPU's. */
-static int g0_selftest(int fw, int fh, long *cases, long *differ) {
- enum { T = G0_TILE, LX = G0_LX, LY = G0_LY };
+static int gdrag_selftest(int fw, int fh, long *cases, long *differ) {
+ enum { T = GDRAG_TILE, LX = GDRAG_LX, LY = GDRAG_LY };
*cases = *differ = 0;
size_t n = (size_t)fw * fh > (size_t)T * T ? (size_t)fw * fh : (size_t)T * T;
uint32_t *s = malloc(n * 4), *d = malloc(n * 4), *ref = malloc(n * 4);
@@ -1015,10 +1015,10 @@ static int g0_selftest(int fw, int fh, long *cases, long *differ) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ft, 0);
ok = glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
}
- G0Gen g = { 0, 0, 0, 0, 2463534242u };
- while (ok && !g0_gen_done(&g)) {
- for (size_t i = 0; i < (size_t)T * T; i++) g0_gen(&g, &s[i], &d[i]);
- long k = g0_pass(T, T, d, s, 0, 0, T, T, ref, (uint8_t *)d, "arithmetic");
+ GdragGen g = { 0, 0, 0, 0, 2463534242u };
+ while (ok && !gdrag_gen_done(&g)) {
+ for (size_t i = 0; i < (size_t)T * T; i++) gdrag_gen(&g, &s[i], &d[i]);
+ long k = gdrag_pass(T, T, d, s, 0, 0, T, T, ref, (uint8_t *)d, "arithmetic");
if (k < 0) { ok = 0; break; }
*differ += k;
*cases += (long)T * T;
@@ -1036,7 +1036,7 @@ static int g0_selftest(int fw, int fh, long *cases, long *differ) {
uint32_t a = r >> 24;
s[i] = a << 24 | (a ? (r % (a + 1)) << 16 | ((r >> 8) % (a + 1)) << 8 | (r >> 16) % (a + 1) : 0);
}
- long k = g0_pass(fw, fh, d, s, LX, LY, fw - LX, fh - LY, ref, (uint8_t *)d, "placement");
+ long k = gdrag_pass(fw, fh, d, s, LX, LY, fw - LX, fh - LY, ref, (uint8_t *)d, "placement");
if (k < 0) ok = 0;
else {
*differ += k;
@@ -1046,59 +1046,59 @@ static int g0_selftest(int fw, int fh, long *cases, long *differ) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (fbo) glDeleteFramebuffers(1, &fbo);
if (ft) glDeleteTextures(1, &ft);
- G.g0tw[0] = G.g0tw[1] = G.g0th[0] = G.g0th[1] = 0; /* hold nothing of an output */
- G.g0tout[0] = G.g0tout[1] = -1;
- glDeleteTextures(2, G.g0tex);
- G.g0tex[0] = g0_texture();
- G.g0tex[1] = g0_texture();
+ G.gdragtw[0] = G.gdragtw[1] = G.gdragth[0] = G.gdragth[1] = 0; /* hold nothing of an output */
+ G.gdragtout[0] = G.gdragtout[1] = -1;
+ glDeleteTextures(2, G.gdragtex);
+ G.gdragtex[0] = gdrag_texture();
+ G.gdragtex[1] = gdrag_texture();
free(s); free(d); free(ref);
return ok && !*differ ? 0 : -1;
}
/* The self-test's outcome per GL renderer and version, kept across contexts (gpu_shutdown wipes G): a
* GPU restart, or a later context on the same driver, does not run it again. */
-static struct { char key[320]; int pass, w, h; } g0_memo;
+static struct { char key[320]; int pass, w, h; } gdrag_memo;
-static void g0_teardown(void) {
- if (G.g0prog) glDeleteProgram(G.g0prog);
- glDeleteTextures(2, G.g0tex);
- G.g0prog = G.g0tex[0] = G.g0tex[1] = 0;
+static void gdrag_teardown(void) {
+ if (G.gdragprog) glDeleteProgram(G.gdragprog);
+ glDeleteTextures(2, G.gdragtex);
+ G.gdragprog = G.gdragtex[0] = G.gdragtex[1] = 0;
}
-/* G0's program and textures in this context, and the self-test (or its earlier outcome). 1 = on. */
-static int g0_setup(void) {
- const char *e = getenv("LORD_G0");
- if (e && !strcmp(e, "0")) { fprintf(stderr, "gpu: G0 off (LORD_G0=0): the dragged window is composed by the CPU\n"); return 0; }
+/* GPU drag's program and textures in this context, and the self-test (or its earlier outcome). 1 = on. */
+static int gdrag_setup(void) {
+ const char *e = getenv("LORD_GPU_DRAG");
+ if (e && !strcmp(e, "0")) { fprintf(stderr, "gpu: GPU drag off (LORD_GPU_DRAG=0): the dragged window is composed by the CPU\n"); return 0; }
GOut *o = G.cur && G.cur->used ? G.cur : &G.out[0];
if (!o->used || !eglMakeCurrent(G.dpy, o->surf, o->surf, G.ctx)) return 0;
GLint range[2] = { 0, 0 }, prec = 0;
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, range, &prec);
if (prec < 23 || range[1] < 24) {
- fprintf(stderr, "gpu: G0 off: the fragment shader's floats have %d bits (24 needed)\n", (int)prec + 1);
+ fprintf(stderr, "gpu: GPU drag off: the fragment shader's floats have %d bits (24 needed)\n", (int)prec + 1);
return 0;
}
- GLuint v = compile(GL_VERTEX_SHADER, vs_g0), f = compile(GL_FRAGMENT_SHADER, fs_g0);
+ GLuint v = compile(GL_VERTEX_SHADER, vs_gdrag), f = compile(GL_FRAGMENT_SHADER, fs_gdrag);
GLint linked = 0;
if (v && f) {
- G.g0prog = glCreateProgram();
- glAttachShader(G.g0prog, v);
- glAttachShader(G.g0prog, f);
- glBindAttribLocation(G.g0prog, 0, "a_pos");
- glBindAttribLocation(G.g0prog, 1, "a_px");
- glLinkProgram(G.g0prog);
- glGetProgramiv(G.g0prog, GL_LINK_STATUS, &linked);
+ G.gdragprog = glCreateProgram();
+ glAttachShader(G.gdragprog, v);
+ glAttachShader(G.gdragprog, f);
+ glBindAttribLocation(G.gdragprog, 0, "a_pos");
+ glBindAttribLocation(G.gdragprog, 1, "a_px");
+ glLinkProgram(G.gdragprog);
+ glGetProgramiv(G.gdragprog, GL_LINK_STATUS, &linked);
}
if (v) glDeleteShader(v);
if (f) glDeleteShader(f);
- if (!linked) { g0_teardown(); fprintf(stderr, "gpu: G0 off: its shader did not build\n"); return 0; }
- G.gu_below = glGetUniformLocation(G.g0prog, "u_below");
- G.gu_layer = glGetUniformLocation(G.g0prog, "u_layer");
- G.gu_bsize = glGetUniformLocation(G.g0prog, "u_bsize");
- G.gu_lrect = glGetUniformLocation(G.g0prog, "u_lrect");
- G.gu_swap = glGetUniformLocation(G.g0prog, "u_swap");
- G.g0tex[0] = g0_texture();
- G.g0tex[1] = g0_texture();
- G.g0tout[0] = G.g0tout[1] = -1;
+ if (!linked) { gdrag_teardown(); fprintf(stderr, "gpu: GPU drag off: its shader did not build\n"); return 0; }
+ G.gu_below = glGetUniformLocation(G.gdragprog, "u_below");
+ G.gu_layer = glGetUniformLocation(G.gdragprog, "u_layer");
+ G.gu_bsize = glGetUniformLocation(G.gdragprog, "u_bsize");
+ G.gu_lrect = glGetUniformLocation(G.gdragprog, "u_lrect");
+ G.gu_swap = glGetUniformLocation(G.gdragprog, "u_swap");
+ G.gdragtex[0] = gdrag_texture();
+ G.gdragtex[1] = gdrag_texture();
+ G.gdragtout[0] = G.gdragtout[1] = -1;
/* the placement part's size: the largest output now, at least 4096 × 2048, within the GPU's limits */
GLint maxtex = 0, vp[2] = { 0, 0 };
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtex);
@@ -1113,65 +1113,65 @@ static int g0_setup(void) {
if (fw > lw) fw = lw;
if (fh > lh) fh = lh;
const char *ver = (const char *)glGetString(GL_VERSION);
- char key[sizeof g0_memo.key];
+ char key[sizeof gdrag_memo.key];
snprintf(key, sizeof key, "%s|%s", G.renderer, ver ? ver : "?");
- if (!strcmp(key, g0_memo.key) && (!g0_memo.pass || (g0_memo.w >= fw && g0_memo.h >= fh))) {
- if (!g0_memo.pass) {
- g0_teardown();
- fprintf(stderr, "gpu: G0 off: its self-test failed earlier with this renderer\n");
+ if (!strcmp(key, gdrag_memo.key) && (!gdrag_memo.pass || (gdrag_memo.w >= fw && gdrag_memo.h >= fh))) {
+ if (!gdrag_memo.pass) {
+ gdrag_teardown();
+ fprintf(stderr, "gpu: GPU drag off: its self-test failed earlier with this renderer\n");
return 0;
}
- G.g0lw = g0_memo.w;
- G.g0lh = g0_memo.h;
- dbg("G0 on: its self-test passed earlier with this renderer (%dx%d)", G.g0lw, G.g0lh);
+ G.gdraglw = gdrag_memo.w;
+ G.gdraglh = gdrag_memo.h;
+ dbg("GPU drag on: its self-test passed earlier with this renderer (%dx%d)", G.gdraglw, G.gdraglh);
return 1;
}
if (fw < 4096 || fh < 2048)
- fprintf(stderr, "gpu: G0 self-test: placement in %dx%d, the largest framebuffer the GPU allows\n", fw, fh);
+ fprintf(stderr, "gpu: GPU drag self-test: placement in %dx%d, the largest framebuffer the GPU allows\n", fw, fh);
long cases = 0, differ = 0;
struct timespec t0, t1;
clock_gettime(CLOCK_MONOTONIC, &t0);
- int bad = fw < G0_TILE || fh < G0_TILE ? -1 : g0_selftest(fw, fh, &cases, &differ);
+ int bad = fw < GDRAG_TILE || fh < GDRAG_TILE ? -1 : gdrag_selftest(fw, fh, &cases, &differ);
clock_gettime(CLOCK_MONOTONIC, &t1);
double ms = (t1.tv_sec - t0.tv_sec) * 1e3 + (t1.tv_nsec - t0.tv_nsec) / 1e6;
if (bad && !differ) { /* no pixel differs: it did not run to the end */
- g0_teardown();
- fprintf(stderr, "gpu: G0 off: its self-test could not run (texture size, memory or framebuffer)\n");
+ gdrag_teardown();
+ fprintf(stderr, "gpu: GPU drag off: its self-test could not run (texture size, memory or framebuffer)\n");
return 0;
}
- snprintf(g0_memo.key, sizeof g0_memo.key, "%s", key);
- g0_memo.pass = !bad;
- g0_memo.w = fw;
- g0_memo.h = fh;
+ snprintf(gdrag_memo.key, sizeof gdrag_memo.key, "%s", key);
+ gdrag_memo.pass = !bad;
+ gdrag_memo.w = fw;
+ gdrag_memo.h = fh;
if (bad) {
- g0_teardown();
- fprintf(stderr, "gpu: G0 off: the self-test failed (%ld of %ld pixels differ from the CPU's, %.0f ms)\n", differ, cases, ms);
+ gdrag_teardown();
+ fprintf(stderr, "gpu: GPU drag off: the self-test failed (%ld of %ld pixels differ from the CPU's, %.0f ms)\n", differ, cases, ms);
return 0;
}
- G.g0lw = fw;
- G.g0lh = fh;
- fprintf(stderr, "gpu: G0 on: the dragged window is composed on the GPU (self-test: %ld pixels, every valid "
+ G.gdraglw = fw;
+ G.gdraglh = fh;
+ fprintf(stderr, "gpu: GPU drag on: the dragged window is composed on the GPU (self-test: %ld pixels, every valid "
"premultiplied combination and a %dx%d placement pass, the same as the CPU's, %.0f ms)\n", cases, fw, fh, ms);
return 1;
}
-int gpu_g0_ready(int out) {
- return G.on && G.g0 == 1 && out >= 0 && out < OUT_MAX && G.out[out].used && G.out[out].W <= G.g0lw &&
- G.out[out].H <= G.g0lh;
+int gpu_gdrag_ready(int out) {
+ return G.on && G.gdrag == 1 && out >= 0 && out < OUT_MAX && G.out[out].used && G.out[out].W <= G.gdraglw &&
+ G.out[out].H <= G.gdraglh;
}
-int gpu_g0_holds(int out) { return G.on && G.g0 == 1 && out >= 0 && G.g0tout[0] == out && G.g0tout[1] == out; }
+int gpu_gdrag_holds(int out) { return G.on && G.gdrag == 1 && out >= 0 && G.gdragtout[0] == out && G.gdragtout[1] == out; }
-void gpu_g0_stats(long *below_px, long *layer_px, long *quads) {
- *below_px = g0_bpx;
- *layer_px = g0_lpx;
- *quads = g0_quads;
- g0_bpx = g0_lpx = g0_quads = 0;
+void gpu_gdrag_stats(long *below_px, long *layer_px, long *quads) {
+ *below_px = gdrag_bpx;
+ *layer_px = gdrag_lpx;
+ *quads = gdrag_quads;
+ gdrag_bpx = gdrag_lpx = gdrag_quads = 0;
}
/* LORD_GPU_VERIFY: what the quad wrote in w, read back, against the CPU's pixels (RGB: the
* framebuffer has no alpha; a frame painted by the CPU shows "premultiplied over black", its RGB). */
-static void g0_verify(GOut *o, const GpuG0 *g) {
+static void gdrag_verify(GOut *o, const GpuDrag *g) {
int ww = g->w.x1 - g->w.x0, wh = g->w.y1 - g->w.y0;
uint8_t *rd = malloc((size_t)ww * wh * 4);
if (!rd) return;
@@ -1196,49 +1196,49 @@ static void g0_verify(GOut *o, const GpuG0 *g) {
free(rd);
}
-/* G0 off for this context, for a reason that would come back every frame */
-static int g0_off(const char *why) {
- G.g0tout[0] = G.g0tout[1] = -1;
- G.g0 = 0;
- fprintf(stderr, "gpu: G0 off: %s\n", why);
+/* GPU drag off for this context, for a reason that would come back every frame */
+static int gdrag_off(const char *why) {
+ G.gdragtout[0] = G.gdragtout[1] = -1;
+ G.gdrag = 0;
+ fprintf(stderr, "gpu: GPU drag off: %s\n", why);
return 0;
}
-/* The G0 part of a frame: the textures brought up to date, then the quad. 0 if it was not drawn. */
-static int g0_frame(GOut *o, int out, const GpuG0 *g) {
- if (G.g0 != 1) return 0;
+/* The GPU drag part of a frame: the textures brought up to date, then the quad. 0 if it was not drawn. */
+static int gdrag_frame(GOut *o, int out, const GpuDrag *g) {
+ if (G.gdrag != 1) return 0;
int sane = g->w.x0 >= 0 && g->w.y0 >= 0 && g->w.x1 <= o->W && g->w.y1 <= o->H && g->w.x1 > g->w.x0 && g->w.y1 > g->w.y0;
/* coordinates past what the self-test's placement covered are not trusted */
- int tested = o->W <= G.g0lw && o->H <= G.g0lh && g->lw <= G.g0lw - G0_LX && g->lh <= G.g0lh - G0_LY &&
- g->bw <= G.g0lw && g->bh <= G.g0lh;
+ int tested = o->W <= G.gdraglw && o->H <= G.gdraglh && g->lw <= G.gdraglw - GDRAG_LX && g->lh <= G.gdraglh - GDRAG_LY &&
+ g->bw <= G.gdraglw && g->bh <= G.gdraglh;
if (g->lpx && g->bpx) {
- if (!sane) return g0_off("a window rectangle outside the output");
- if (!tested) return g0_off("a layer or output larger than its self-test covered");
+ if (!sane) return gdrag_off("a window rectangle outside the output");
+ if (!tested) return gdrag_off("a layer or output larger than its self-test covered");
for (int i = 0; i < 16 && glGetError() != GL_NO_ERROR; i++) {}
double t0 = mono_ms();
/* another output's texture (or nothing yet), or full: all of it (paint.c sends what the textures
* lack between frames first, so this is rare) */
- o->times.g0_full = g->bfull || g->lfull || G.g0tout[0] != out || G.g0tout[1] != out || G.g0tw[0] != g->bw ||
- G.g0th[0] != g->bh || G.g0tw[1] != g->lw || G.g0th[1] != g->lh;
- long b = g0_upload(0, out, g->bpx, g->bw, g->bh, g->bdirty, g->nb, g->bfull);
- long l = g0_upload(1, out, g->lpx, g->lw, g->lh, g->ldirty, g->nl, g->lfull);
- g0_bpx += b;
- g0_lpx += l;
- o->times.g0_px = b + l;
- o->times.g0_ms = mono_ms() - t0;
- if (glGetError() != GL_NO_ERROR) return g0_off("an upload failed");
- } else if (!sane || !tested || !gpu_g0_holds(out) || G.g0tw[1] != g->lw || G.g0th[1] != g->lh ||
- G.g0tw[0] != g->bw || G.g0th[0] != g->bh)
+ o->times.gdrag_full = g->bfull || g->lfull || G.gdragtout[0] != out || G.gdragtout[1] != out || G.gdragtw[0] != g->bw ||
+ G.gdragth[0] != g->bh || G.gdragtw[1] != g->lw || G.gdragth[1] != g->lh;
+ long b = gdrag_upload(0, out, g->bpx, g->bw, g->bh, g->bdirty, g->nb, g->bfull);
+ long l = gdrag_upload(1, out, g->lpx, g->lw, g->lh, g->ldirty, g->nl, g->lfull);
+ gdrag_bpx += b;
+ gdrag_lpx += l;
+ o->times.gdrag_px = b + l;
+ o->times.gdrag_ms = mono_ms() - t0;
+ if (glGetError() != GL_NO_ERROR) return gdrag_off("an upload failed");
+ } else if (!sane || !tested || !gpu_gdrag_holds(out) || G.gdragtw[1] != g->lw || G.gdragth[1] != g->lh ||
+ G.gdragtw[0] != g->bw || G.gdragth[0] != g->bh)
return 0;
- g0_draw(o->W, o->H, g->w, (float)g->lx, (float)g->ly, (float)g->lw, (float)g->lh, (float)g->bw, (float)g->bh);
- g0_quads++;
- if (g->ref) g0_verify(o, g);
+ gdrag_draw(o->W, o->H, g->w, (float)g->lx, (float)g->ly, (float)g->lw, (float)g->lh, (float)g->bw, (float)g->bh);
+ gdrag_quads++;
+ if (g->ref) gdrag_verify(o, g);
return 1;
}
-int gpu_frame_ex(int out, const Canvas *scene, const Rect *dmg, int n, const GpuG0 *g0, int *g0_drawn,
+int gpu_frame_ex(int out, const Canvas *scene, const Rect *dmg, int n, const GpuDrag *gdrag, int *gdrag_drawn,
void (*draw_layer)(int layer)) {
- if (g0_drawn) *g0_drawn = 0;
+ if (gdrag_drawn) *gdrag_drawn = 0;
if (!G.on || out < 0 || out >= OUT_MAX || !G.out[out].used) return -1;
GOut *o = &G.out[out];
o->times = (GpuFrameTimes){ 0 };
@@ -1257,12 +1257,12 @@ int gpu_frame_ex(int out, const Canvas *scene, const Rect *dmg, int n, const Gpu
gpu_draw(&o->canvas, 0, 0, (float)o->W, (float)o->H, 0, 0, (float)o->W, (float)o->H, all, 1);
/* the dragged window over the UI's stale rectangle: nothing of layer 0 is under it (paint.c checks).
* Not drawn, that rectangle is stale in the UI texture: nothing is shown (-2), the caller paints it */
- if (g0) {
- if (!g0_frame(o, out, g0)) {
+ if (gdrag) {
+ if (!gdrag_frame(o, out, gdrag)) {
rb.px = NULL;
return -2;
}
- if (g0_drawn) *g0_drawn = 1;
+ if (gdrag_drawn) *gdrag_drawn = 1;
}
if (draw_layer) draw_layer(1);
if (rb.px) {
@@ -1288,10 +1288,10 @@ void gpu_frame_times(int out, GpuFrameTimes *t) {
*t = G.on && out >= 0 && out < OUT_MAX && G.out[out].used ? G.out[out].times : (GpuFrameTimes){ 0 };
}
-/* ---- G0's textures between frames (paint_g0_feed) ---- */
+/* ---- GPU drag's textures between frames (paint_gdrag_feed) ---- */
-int gpu_g0_feed(int out, int which, const uint32_t *px, int w, int h, Rect r) {
- if (!G.on || G.g0 != 1 || out < 0 || out >= OUT_MAX || !G.out[out].used || which < 0 || which > 1) return -1;
+int gpu_gdrag_feed(int out, int which, const uint32_t *px, int w, int h, Rect r) {
+ if (!G.on || G.gdrag != 1 || out < 0 || out >= OUT_MAX || !G.out[out].used || which < 0 || which > 1) return -1;
GOut *o = &G.out[out];
/* a texture upload needs the context, not a given surface (G.cur is not updated by every
* eglMakeCurrent, so the context actually current is asked) */
@@ -1300,25 +1300,25 @@ int gpu_g0_feed(int out, int which, const uint32_t *px, int w, int h, Rect r) {
G.cur = o;
}
/* errors left by earlier calls (an import, the cursor) are not this upload's: without this one
- * of them would turn G0 off below */
+ * of them would turn GPU drag off below */
for (int i = 0; i < 16 && glGetError() != GL_NO_ERROR; i++) {}
- glBindTexture(GL_TEXTURE_2D, G.g0tex[which]);
- if (G.g0tout[which] != out || G.g0tw[which] != w || G.g0th[which] != h) {
- if (G.g0tw[which] != w || G.g0th[which] != h) { /* its storage, filled by the slices that follow */
+ glBindTexture(GL_TEXTURE_2D, G.gdragtex[which]);
+ if (G.gdragtout[which] != out || G.gdragtw[which] != w || G.gdragth[which] != h) {
+ if (G.gdragtw[which] != w || G.gdragth[which] != h) { /* its storage, filled by the slices that follow */
GLenum fmt = G.bgra ? GL_BGRA_EXT : GL_RGBA;
glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, NULL);
- G.g0tw[which] = w;
- G.g0th[which] = h;
+ G.gdragtw[which] = w;
+ G.gdragth[which] = h;
}
- G.g0tout[which] = out;
- if (glGetError() != GL_NO_ERROR) { g0_off("a texture could not be made"); return -1; }
+ G.gdragtout[which] = out;
+ if (glGetError() != GL_NO_ERROR) { gdrag_off("a texture could not be made"); return -1; }
return 1;
}
Rect q = { r.x0 < 0 ? 0 : r.x0, r.y0 < 0 ? 0 : r.y0, r.x1 > w ? w : r.x1, r.y1 > h ? h : r.y1 };
long sent = upload_rect(px, w, w, w, q);
- if (which) g0_lpx += sent;
- else g0_bpx += sent;
- if (sent && glGetError() != GL_NO_ERROR) { g0_off("an upload failed"); return -1; }
+ if (which) gdrag_lpx += sent;
+ else gdrag_bpx += sent;
+ if (sent && glGetError() != GL_NO_ERROR) { gdrag_off("an upload failed"); return -1; }
return 0;
}
diff --git a/server/src/gpu/gpu.h b/server/src/gpu/gpu.h
index 1712f25..f049d47 100644
--- a/server/src/gpu/gpu.h
+++ b/server/src/gpu/gpu.h
@@ -67,53 +67,53 @@ int gpu_tex_read(const GpuTex *t, uint32_t *px, int w, int h);
* fullscreen (on top). */
int gpu_frame(int out, const Canvas *scene, Rect damage, void (*draw_layer)(int layer));
-/* G0: the dragged window composited on the GPU with the CPU's own arithmetic (docs/GPU.md, "The
- * dragged window on the GPU"). paint_root_g0 (ui/paint.c) leaves the window's rectangle w out of the
+/* GPU drag: the dragged window composited on the GPU with the CPU's own arithmetic (docs/GPU.md, "The
+ * dragged window on the GPU"). paint_root_gdrag (ui/paint.c) leaves the window's rectangle w out of the
* scene and fills this; one shader then writes, inside w, the layer (lpx) over the copy of what is
* below (bpx) exactly as canvas_blit's blit_row does. The two are textures of their own, uploaded
* only where they changed (ldirty, bdirty; *full: all of it). */
-#define G0_DIRTY 16
+#define GDRAG_DIRTY 16
/* At most this many pixels of the two textures are sent in one frame: a frame that would need more is
- * painted by the CPU, and the rest is sent after its flip is queued (paint_g0_feed, gpu_g0_feed), a slice
+ * painted by the CPU, and the rest is sent after its flip is queued (paint_gdrag_feed, gpu_gdrag_feed), a slice
* a frame, so no frame uploads a whole screen (docs/GPU.md, "Uploads without a stall"). 1 MB. */
-#define G0_FEED_PX 262144L
-typedef struct GpuG0 {
+#define GDRAG_FEED_PX 262144L
+typedef struct GpuDrag {
Rect w; /* where the shader writes (the output's physical px, top-down) */
const uint32_t *lpx; /* the layer: lw × lh, its pixel (0, 0) at (lx, ly) */
int lw, lh, lx, ly;
const uint32_t *bpx; /* the copy of what is below: bw × bh, the scene's size */
int bw, bh;
- Rect ldirty[G0_DIRTY], bdirty[G0_DIRTY]; /* in the layer's and the copy's pixels */
+ Rect ldirty[GDRAG_DIRTY], bdirty[GDRAG_DIRTY]; /* in the layer's and the copy's pixels */
int nl, nb, lfull, bfull;
Rect strip[4]; /* what the CPU painted around w this frame (uploaded to the UI texture) */
int nstrip;
const uint32_t *ref; /* LORD_GPU_VERIFY: the CPU's pixels for w (w's width a row), or NULL */
long frame; /* its number, for the log */
-} GpuG0;
-/* 1 if G0 may be used on that output: the shader has 24-bit floats, LORD_G0 is not 0, the self-test
+} GpuDrag;
+/* 1 if GPU drag may be used on that output: the shader has 24-bit floats, LORD_GPU_DRAG is not 0, the self-test
* (every valid premultiplied combination, and a placement pass at least as large as the output, drawn
* into a framebuffer and read back) gave the CPU's pixels. gpu_init runs that test, once per GL renderer
* and version. */
-int gpu_g0_ready(int out);
-/* gpu_frame with several UI rectangles to upload and, with g0, the window composited over w (g0
+int gpu_gdrag_ready(int out);
+/* gpu_frame with several UI rectangles to upload and, with gdrag, the window composited over w (gdrag
* without dirty rectangles redraws the last one: a frame with no UI damage while the scene's w is
- * stale). Returns -1 like gpu_frame; *g0_drawn says whether the G0 quad was drawn. -2: g0 was given but
- * its quad could not be drawn (G0 turned off, or its textures are not that output's): nothing was
+ * stale). Returns -1 like gpu_frame; *gdrag_drawn says whether the GPU drag quad was drawn. -2: gdrag was given but
+ * its quad could not be drawn (GPU drag turned off, or its textures are not that output's): nothing was
* shown, and the caller paints w on the CPU in its next frame. */
-int gpu_frame_ex(int out, const Canvas *scene, const Rect *dmg, int n, const GpuG0 *g0, int *g0_drawn,
+int gpu_frame_ex(int out, const Canvas *scene, const Rect *dmg, int n, const GpuDrag *gdrag, int *gdrag_drawn,
void (*draw_layer)(int layer));
-int gpu_g0_holds(int out); /* the G0 textures hold that output's last upload, in this context */
+int gpu_gdrag_holds(int out); /* the GPU drag textures hold that output's last upload, in this context */
/* Texture which (0 the copy of what is below, 1 the layer) of output out gets r of px (w × h, stride w),
- * between frames (paint_g0_feed's up). 1: it held nothing of that output at that size: it is now that
- * output's, and the caller sends all of it again; 0 sent; -1 failed (G0 is then off). */
-int gpu_g0_feed(int out, int which, const uint32_t *px, int w, int h, Rect r);
+ * between frames (paint_gdrag_feed's up). 1: it held nothing of that output at that size: it is now that
+ * output's, and the caller sends all of it again; 0 sent; -1 failed (GPU drag is then off). */
+int gpu_gdrag_feed(int out, int which, const uint32_t *px, int w, int h, Rect r);
/* Where the last gpu_frame_ex of an output spent its time (LordBench's frame phases, bench/lbframes.h) */
typedef struct {
double up_ms; /* the UI texture's rectangles */
long up_px;
- double g0_ms; /* the G0 textures' uploads for the quad */
- long g0_px;
- int g0_full; /* one of them was sent whole */
+ double gdrag_ms; /* the GPU drag textures' uploads for the quad */
+ long gdrag_px;
+ int gdrag_full; /* one of them was sent whole */
double swap_ms; /* eglSwapBuffers */
double submit_ms; /* the front buffer, its framebuffer and the page flip */
} GpuFrameTimes;
@@ -123,8 +123,8 @@ void gpu_frame_times(int out, GpuFrameTimes *t);
* 0 unknown (no fence, or not signalled yet). Each fence is read once and closed. Off: nothing is taken. */
void gpu_fence_on(int on);
int gpu_fence_time(int out, uint64_t *ns);
-/* uploaded pixels of the copy of what is below and of the layer, and G0 quads drawn, since the last call */
-void gpu_g0_stats(long *below_px, long *layer_px, long *quads);
+/* uploaded pixels of the copy of what is below and of the layer, and GPU drag quads drawn, since the last call */
+void gpu_gdrag_stats(long *below_px, long *layer_px, long *quads);
/* Another display (docs/DISPLAYS.md): its own GBM/EGL surface on the same context; gpu_init made
* output 0. Returns the output index for gpu_frame, or -1 (then that display goes by the CPU). */
int gpu_add_output(Kms *k);
diff --git a/server/src/main.c b/server/src/main.c
index a43768b..186fd04 100644
--- a/server/src/main.c
+++ b/server/src/main.c
@@ -109,28 +109,28 @@ static void below_stats_text(char *buf, size_t len) {
b.refused[BR_BLUR], b.refused[BR_TRANSFORM], b.refused[BR_UNREACHED], b.refused[BR_COST]);
}
-/* G0, the dragged window composited on the GPU (docs/GPU.md): frames, the strips the CPU painted
+/* GPU drag, the dragged window composited on the GPU (docs/GPU.md): frames, the strips the CPU painted
* around it, what was uploaded of the copy of what is below and of the layer, and why other frames that
* used the copy were painted by the CPU. Appended to the "drag: …" lines. */
-static void g0_stats_text(char *buf, size_t len) {
- G0Stats g;
+static void gdrag_stats_text(char *buf, size_t len) {
+ GdragStats g;
long bpx, lpx, quads;
- paint_g0_stats(&g);
- gpu_g0_stats(&bpx, &lpx, &quads);
- int k = snprintf(buf, len, "G0: %ld of %ld frames (%ld quads), strips %.2f Mpx, uploaded below %.2f Mpx, layer %.2f Mpx "
+ paint_gdrag_stats(&g);
+ gpu_gdrag_stats(&bpx, &lpx, &quads);
+ int k = snprintf(buf, len, "GPU drag: %ld of %ld frames (%ld quads), strips %.2f Mpx, uploaded below %.2f Mpx, layer %.2f Mpx "
"(not: %ld layer, %ld clip, %ld ancestor, %ld app, %ld after, %ld post, %ld catching up",
- g.frames, g.tried, quads, g.strip_px / 1e6, bpx / 1e6, lpx / 1e6, g.refused[G0R_LAYER], g.refused[G0R_CLIP],
- g.refused[G0R_ANCESTOR], g.refused[G0R_APP], g.refused[G0R_AFTER], g.refused[G0R_POST], g.refused[G0R_FEED]);
- /* the layer's refusals by cause (G0L_*) */
- for (int i = 0, first = 1; i < G0L_N && k > 0 && (size_t)k < len; i++)
+ g.frames, g.tried, quads, g.strip_px / 1e6, bpx / 1e6, lpx / 1e6, g.refused[GDRAG_R_LAYER], g.refused[GDRAG_R_CLIP],
+ g.refused[GDRAG_R_ANCESTOR], g.refused[GDRAG_R_APP], g.refused[GDRAG_R_AFTER], g.refused[GDRAG_R_POST], g.refused[GDRAG_R_FEED]);
+ /* the layer's refusals by cause (GDRAG_L_*) */
+ for (int i = 0, first = 1; i < GDRAG_L_N && k > 0 && (size_t)k < len; i++)
if (g.layer[i]) {
- int w = snprintf(buf + k, len - (size_t)k, "%s%s %ld", first ? "; layer: " : ", ", lbf_g0l_name(i), g.layer[i]);
+ int w = snprintf(buf + k, len - (size_t)k, "%s%s %ld", first ? "; layer: " : ", ", lbf_gdrag_l_name(i), g.layer[i]);
if (w > 0) k += w;
first = 0;
}
if (k > 0 && (size_t)k < len) snprintf(buf + k, len - (size_t)k, ")");
}
-_Static_assert(G0R_N <= LBF_G0R && G0L_N <= LBF_G0L, "lbframes.c names every G0R_* and G0L_*");
+_Static_assert(GDRAG_R_N <= LBF_GDRAG_R && GDRAG_L_N <= LBF_GDRAG_L, "lbframes.c names every GDRAG_R_* and GDRAG_L_*");
/* One display (docs/DISPLAYS.md): its KMS head, where it sits in the global logical space, and the
* frame the UI paints for it at its own resolution. out[0]'s head owns the card's fd; the main display
@@ -158,17 +158,17 @@ typedef struct {
int full_copy, was_fs;
int gpu; /* its GPU output (gpu_frame), -1 = composed by the CPU */
int wl_new; /* GPU path: a Linux app's window has new content not presented here yet */
- /* G0 (paint_root_g0, docs/GPU.md): this frame left the dragged window's rectangle to the GPU
- * (g0taken, g0); the last frame shown has it there, so the scene and the UI texture are stale in g0w
- * (g0on) until a frame paints it on the CPU; g0cpu: the GPU could not draw it, the next frame paints
- * it on the CPU without trying G0 */
- int g0taken, g0on, g0cpu;
- Rect g0w;
- GpuG0 g0;
- int pg0, pg0why, pg0sub; /* what the frame painted last got from G0 (paint_g0_last), until it is submitted */
+ /* GPU drag (paint_root_gdrag, docs/GPU.md): this frame left the dragged window's rectangle to the GPU
+ * (gdragtaken, gdrag); the last frame shown has it there, so the scene and the UI texture are stale in gdragw
+ * (gdrag_on) until a frame paints it on the CPU; gdragcpu: the GPU could not draw it, the next frame paints
+ * it on the CPU without trying GPU drag */
+ int gdragtaken, gdrag_on, gdragcpu;
+ Rect gdragw;
+ GpuDrag gdrag;
+ int pgdrag, pgdragwhy, pgdragsub; /* what the frame painted last got from GPU drag (paint_gdrag_last), until it is submitted */
/* the frame pipeline (fpipe.h, docs/GPU.md "The frame pipeline"): a frame painted into the scene while the
* flip was pending (prep, an FPIPE_*), what it painted (prep_r; prep_whole: all of it) and what it was painted
- * against, checked before it is submitted (the scene's pixels, the GPU context and output, paint.c's G0
+ * against, checked before it is submitted (the scene's pixels, the GPU context and output, paint.c's GPU drag
* epoch); its CPU time so far and its phases for LordBench (main display) */
int prep, prep_whole, prep_gpu;
Rect prep_r;
@@ -224,22 +224,22 @@ static Box box_join(Box a, Box b) {
}
static int box_empty(Box b) { return b.x1 <= b.x0 || b.y1 <= b.y0; }
-/* The scene's G0 rectangle (still the GPU's) is painted again on the CPU in the next frame of the display */
-static void g0_stale(Out *o) {
+/* The scene's GPU drag rectangle (still the GPU's) is painted again on the CPU in the next frame of the display */
+static void gdrag_stale(Out *o) {
float x0, y0, x1, y1;
- out_logical_box(&o->v, o->g0w, &x0, &y0, &x1, &y1);
+ out_logical_box(&o->v, o->gdragw, &x0, &y0, &x1, &y1);
if (box_empty(o->pend)) o->pl.n = 0;
o->pend = box_join(o->pend, (Box){ x0, y0, x1, y1 });
- o->g0on = 0;
+ o->gdrag_on = 0;
}
-/* The frame pipeline: a prepared frame that will not be submitted (the GPU, the displays or G0's layer changed
+/* The frame pipeline: a prepared frame that will not be submitted (the GPU, the displays or GPU drag's layer changed
* under it). What it painted is in the scene but not on the screen, so it joins the next frame's damage (with
- * the rectangle it left to G0, stale in the scene). */
+ * the rectangle it left to GPU drag, stale in the scene). */
static void prep_undo(Out *o) {
if (o->prep == FPIPE_READY) {
Rect r = o->prep_r;
- if (o->g0taken) r = rect_join(r, o->g0.w);
+ if (o->gdragtaken) r = rect_join(r, o->gdrag.w);
if (o->prep_whole) o->full = 1;
else if (r.x1 > r.x0 && r.y1 > r.y0) {
float x0, y0, x1, y1;
@@ -247,7 +247,7 @@ static void prep_undo(Out *o) {
if (box_empty(o->pend)) o->pl.n = 0;
o->pend = box_join(o->pend, (Box){ x0, y0, x1, y1 });
}
- o->g0taken = 0;
+ o->gdragtaken = 0;
}
o->prep = FPIPE_NONE;
}
@@ -470,7 +470,7 @@ static void dispatch_pointer(Server *s) {
paint_layer_stats(&lr, &lb);
char bs[192], gs[512];
below_stats_text(bs, sizeof bs);
- g0_stats_text(gs, sizeof gs);
+ gdrag_stats_text(gs, sizeof gs);
fprintf(stderr, "drag: %ld frames in %.0f ms = %.1f FPS (%ld moves); per frame: work %.2f ms "
"(max %.2f; JS %.2f, layout %.2f, paint %.2f, present %.2f), max gap %.1f ms; "
"layer: %ld painted (%ld of them a part), %ld copied (%s); %s; %s\n",
@@ -658,8 +658,8 @@ static void cpu_takeover(Server *s) {
o->gpu = -1;
o->full_copy = 2;
o->wl_new = 0;
- if (o->g0on) o->full = 1; /* the scene's G0 rectangle is stale */
- o->g0on = o->g0taken = 0;
+ if (o->gdrag_on) o->full = 1; /* the scene's GPU drag rectangle is stale */
+ o->gdrag_on = o->gdragtaken = 0;
}
s->hw_cursor = 0;
}
@@ -1111,7 +1111,7 @@ static Box paint_ui(Server *s) {
* differ from the display's frame are counted on stderr. Off by default; it only reads the frame. The
* terminals and Linux apps note where they were painted, so with N = 1 a terminal's change during a
* drag always repaints the whole layer: use N > 1 to check the layer's partial repaints. On a frame
- * whose dragged window the GPU composites (G0, skip) the scene is stale there and skip is left out:
+ * whose dragged window the GPU composites (GPU drag, skip) the scene is stale there and skip is left out:
* LORD_GPU_VERIFY checks those pixels against the CPU's. */
static void paint_verify(Out *o, int index, Rect skip) {
static int every = -1;
@@ -1166,12 +1166,12 @@ static Rect paint_out(Server *s, Out *o, int index, int feed) {
int whole = o->full;
o->full = 0;
o->pend = (Box){ 0, 0, 0, 0 };
- o->g0taken = 0;
+ o->gdragtaken = 0;
if (box_empty(b) || !o->scene.px) return r;
- /* G0: the rectangle the GPU composed last frame is stale in the scene: painted again with this damage */
- if (o->g0on && !whole) {
+ /* GPU drag: the rectangle the GPU composed last frame is stale in the scene: painted again with this damage */
+ if (o->gdrag_on && !whole) {
float gx0, gy0, gx1, gy1;
- out_logical_box(&o->v, o->g0w, &gx0, &gy0, &gx1, &gy1);
+ out_logical_box(&o->v, o->gdragw, &gx0, &gy0, &gx1, &gy1);
b = box_join(b, (Box){ gx0, gy0, gx1, gy1 });
}
/* several damaged rectangles (paint.c, "Several damaged rectangles"): each one painted on its
@@ -1191,10 +1191,10 @@ static Rect paint_out(Server *s, Out *o, int index, int feed) {
}
multi = !whole && !gpu_active() && l.n > 1;
int nparts = multi ? l.n : 1;
- /* G0 (paint_root_g0): one box on a GPU display while a window is dragged */
- int g0 = !whole && nparts == 1 && index < OUT_MAX && o->gpu >= 0 && gpu_active() && !(o->d.rot & 3) &&
- !wl_fullscreen_active() && !o->g0cpu && paint_layer_node() && gpu_g0_ready(o->gpu);
- o->g0cpu = 0;
+ /* GPU drag (paint_root_gdrag): one box on a GPU display while a window is dragged */
+ int gdrag = !whole && nparts == 1 && index < OUT_MAX && o->gpu >= 0 && gpu_active() && !(o->d.rot & 3) &&
+ !wl_fullscreen_active() && !o->gdragcpu && paint_layer_node() && gpu_gdrag_ready(o->gpu);
+ o->gdragcpu = 0;
Box parts[DAMAGE_MAX];
if (multi) memcpy(parts, l.r, sizeof(Box) * (size_t)nparts);
else parts[0] = b;
@@ -1210,13 +1210,13 @@ static Rect paint_out(Server *s, Out *o, int index, int feed) {
out_logical_box(&o->v, pr, &lx0, &ly0, &lx1, &ly1);
ui.damage = (Box){ lx0, ly0, lx1, ly1 }; /* paint_root skips what this region does not need */
canvas_set_clip(&o->scene, pr);
- if (g0) o->g0taken = paint_root_g0(&o->scene, ui.root, &o->g0);
+ if (gdrag) o->gdragtaken = paint_root_gdrag(&o->scene, ui.root, &o->gdrag);
else paint_root_clear(&o->scene, ui.root, 0x000000);
if (feed) media_scene_painted(&o->scene); /* recording/remote desktop with protected windows */
r = rect_join(r, pr);
- if (o->g0taken) { /* only the strips around the window were painted */
- for (int i = 0; i < o->g0.nstrip; i++) {
- Rect q = o->g0.strip[i];
+ if (o->gdragtaken) { /* only the strips around the window were painted */
+ for (int i = 0; i < o->gdrag.nstrip; i++) {
+ Rect q = o->gdrag.strip[i];
o->painted[o->npainted++] = (Box){ (float)q.x0, (float)q.y0, (float)q.x1, (float)q.y1 };
px += (double)(q.x1 - q.x0) * (q.y1 - q.y0);
}
@@ -1236,7 +1236,7 @@ static Rect paint_out(Server *s, Out *o, int index, int feed) {
if (s->debug || paint_profile)
fprintf(stderr, "render %ld: display %d, layout %.2f ms, paint %.2f ms, repainted %.1f%% in %d rect%s\n", s->renders, index, ui.layout_ms, ms,
100.0 * px / ((double)o->scene.w * o->scene.h), nparts, nparts == 1 ? "" : "s");
- paint_verify(o, index, o->g0taken ? o->g0.w : (Rect){ 0, 0, 0, 0 });
+ paint_verify(o, index, o->gdragtaken ? o->gdrag.w : (Rect){ 0, 0, 0, 0 });
return r;
}
@@ -1338,13 +1338,13 @@ static uint64_t render_r0;
static int call_piped;
static int render_frame(Server *s);
-static void g0_feed_now(Server *s, LbPhase *ph);
+static void gdrag_feed_now(Server *s, LbPhase *ph);
static void render(Server *s) {
int phases = lbf_recording();
gpu_fence_on(phases); /* the GPU's finish time of each frame, only while recording */
uint64_t r0 = phases ? mono_ns() : 0;
double t0 = now_ms();
- fph = (LbPhase){ .g0 = -1, .g0_why = -1, .g0_sub = -1 };
+ fph = (LbPhase){ .gdrag = -1, .gdrag_why = -1, .gdrag_sub = -1 };
fph_main = 0;
render_r0 = r0;
call_piped = 0;
@@ -1353,7 +1353,7 @@ static void render(Server *s) {
uint64_t r1 = phases ? mono_ns() : 0;
/* LordBench's compositor measurement (bench/lbframes.c); a prepared frame's goes at its submission */
if (shown && !call_piped) lbf_frame(t1 - t0);
- g0_feed_now(s, &fph); /* after the frame's time: its flip is queued already */
+ gdrag_feed_now(s, &fph); /* after the frame's time: its flip is queued already */
if (phases && fph_main) {
fph.wake = loop_wake;
fph.from_flip = loop_wake_flip;
@@ -1559,19 +1559,19 @@ static int outs_have_work(const Server *s) {
return 0;
}
-/* paint_g0_feed's way to the GPU: ctx is the display's GPU output */
-static int g0_feed_up(void *ctx, int which, const uint32_t *px, int w, int h, Rect r) {
- return gpu_g0_feed(*(const int *)ctx, which, px, w, h, r);
+/* paint_gdrag_feed's way to the GPU: ctx is the display's GPU output */
+static int gdrag_feed_up(void *ctx, int which, const uint32_t *px, int w, int h, Rect r) {
+ return gpu_gdrag_feed(*(const int *)ctx, which, px, w, h, r);
}
-/* the displays whose G0 textures catch up after this frame: after its flips are queued and its time is
+/* the displays whose GPU drag textures catch up after this frame: after its flips are queued and its time is
* taken, while the CPU would wait for the vblank anyway (docs/GPU.md, "Uploads without a stall") */
static int feed_idx[OUT_MAX], nfeed;
-static void g0_feed_now(Server *s, LbPhase *ph) {
+static void gdrag_feed_now(Server *s, LbPhase *ph) {
for (int k = 0; k < nfeed; k++) {
Out *o = &s->out[feed_idx[k]];
- if (!o->on || o->gpu < 0 || !gpu_g0_ready(o->gpu) || paint_g0_backlog(feed_idx[k]) <= 0) continue;
+ if (!o->on || o->gpu < 0 || !gpu_gdrag_ready(o->gpu) || paint_gdrag_backlog(feed_idx[k]) <= 0) continue;
double f0 = now_ms();
- long sent = paint_g0_feed(feed_idx[k], G0_FEED_PX, g0_feed_up, &o->gpu);
+ long sent = paint_gdrag_feed(feed_idx[k], GDRAG_FEED_PX, gdrag_feed_up, &o->gpu);
if (o == main_out(s)) { ph->feed_ms = now_ms() - f0; ph->feed_px = sent; }
}
nfeed = 0;
@@ -1579,7 +1579,7 @@ static void g0_feed_now(Server *s, LbPhase *ph) {
/* the frame pipeline (fpipe.h): it applies to this display now. One display with real page flips: without a
* monitor there is no flip, a driver paced in software waits for its slot rather than the flip, and with
- * several displays paint.c's drag layer and G0 state are shared between them (each frame is built and
+ * several displays paint.c's drag layer and GPU drag state are shared between them (each frame is built and
* submitted at once there, as before). */
static int pipe_on(const Server *s, const Out *o) {
return fpipe_engaged(&fpipe) && !s->headless && flip_instant < 3 && o->on && out_count(s) == 1;
@@ -1606,10 +1606,10 @@ static int prep_ready(const Server *s) {
return 0;
}
/* the prepared frame can be submitted as it was painted: the same scene, GPU context and output, and with
- * G0 the same layer buffers and textures' bookkeeping (paint_g0_epoch) */
+ * GPU drag the same layer buffers and textures' bookkeeping (paint_gdrag_epoch) */
static int prep_valid(const Out *o) {
if (o->prep_px != o->scene.px || o->prep_gen != gpu_generation() || o->prep_gpu != (gpu_active() ? o->gpu : -1)) return 0;
- return !o->g0taken || (o->prep_epoch == paint_g0_epoch() && gpu_g0_ready(o->gpu));
+ return !o->gdragtaken || (o->prep_epoch == paint_gdrag_epoch() && gpu_gdrag_ready(o->gpu));
}
static int par_on, par_light; /* the paint threads (render_frame) */
@@ -1634,22 +1634,22 @@ static void cursor_mark(Server *s) {
s->cursor_dirty = 0;
}
-/* The CPU part of a display's frame: its damage painted into the scene (paint_out), and what G0 did. */
+/* The CPU part of a display's frame: its damage painted into the scene (paint_out), and what GPU drag did. */
static Rect out_paint(Server *s, Out *o, int i, const Out *feed) {
- /* G0 with no UI damage: the GPU draws the window again from its textures, if they are still this
+ /* GPU drag with no UI damage: the GPU draws the window again from its textures, if they are still this
* display's; otherwise its rectangle is painted by the CPU now */
- if (o->g0on && box_empty(o->pend) && !o->full && !gpu_g0_holds(o->gpu)) g0_stale(o);
+ if (o->gdrag_on && box_empty(o->pend) && !o->full && !gpu_gdrag_holds(o->gpu)) gdrag_stale(o);
Rect r = paint_out(s, o, i, o == feed);
- o->pg0why = o->pg0sub = -1;
- o->pg0 = r.x1 > r.x0 ? paint_g0_last(&o->pg0why, &o->pg0sub) : -1;
+ o->pgdragwhy = o->pgdragsub = -1;
+ o->pgdrag = r.x1 > r.x0 ? paint_gdrag_last(&o->pgdragwhy, &o->pgdragsub) : -1;
return r;
}
/* The rest of the frame: what paint_out painted (r) and the layers go to the display (GPU: upload, draw, swap
* and page flip; CPU: copied into its KMS buffer, then the flip). ph: the main display's phases, else NULL. */
static void out_present(Server *s, Out *o, int i, Rect r, const Out *feed, LbPhase *ph) {
- int g0why = o->pg0why, g0sub = o->pg0sub, g0last = o->pg0;
- if (ph) { ph->g0 = g0last; ph->g0_why = g0why; ph->g0_sub = g0sub; }
+ int gdragwhy = o->pgdragwhy, gdragsub = o->pgdragsub, gdraglast = o->pgdrag;
+ if (ph) { ph->gdrag = gdraglast; ph->gdrag_why = gdragwhy; ph->gdrag_sub = gdragsub; }
if (gpu_active() && o->gpu >= 0) {
update_cursor(s);
gpu_server = s;
@@ -1667,27 +1667,27 @@ static void out_present(Server *s, Out *o, int i, Rect r, const Out *feed, LbPha
}
/* compatible fullscreen (one display): straight to the card; otherwise composed (always
* composed while the remote desktop reads it back) */
- /* G0: the strips around the window, and the window from its textures (gpu_frame_ex); a frame
+ /* GPU drag: the strips around the window, and the window from its textures (gpu_frame_ex); a frame
* with nothing painted while the last one had it draws it again (its rectangle is stale) */
Rect up[4] = { r };
- int nup = 1, g0drawn = 0;
- GpuG0 again;
- const GpuG0 *g0 = NULL;
- if (o->g0taken) {
- g0 = &o->g0;
- nup = o->g0.nstrip;
- memcpy(up, o->g0.strip, sizeof up);
- } else if (o->g0on && r.x1 <= r.x0) {
- again = o->g0;
+ int nup = 1, gdragdrawn = 0;
+ GpuDrag again;
+ const GpuDrag *gdrag = NULL;
+ if (o->gdragtaken) {
+ gdrag = &o->gdrag;
+ nup = o->gdrag.nstrip;
+ memcpy(up, o->gdrag.strip, sizeof up);
+ } else if (o->gdrag_on && r.x1 <= r.x0) {
+ again = o->gdrag;
again.lpx = again.bpx = NULL;
again.nl = again.nb = again.lfull = again.bfull = 0;
again.ref = NULL;
- g0 = &again;
+ gdrag = &again;
}
int scanned = !readback && out_count(s) == 1 && wl_try_scanout(s->hw_cursor || s->cursor_mode == 2);
- int res = scanned ? 0 : gpu_frame_ex(o->gpu, &o->scene, up, nup, g0, &g0drawn, gpu_layer);
+ int res = scanned ? 0 : gpu_frame_ex(o->gpu, &o->scene, up, nup, gdrag, &gdragdrawn, gpu_layer);
int failed = res == -1, unshown = res == -2;
- if (o->g0taken && g0drawn) paint_g0_done(); /* the textures have what paint.c had */
+ if (o->gdragtaken && gdragdrawn) paint_gdrag_done(); /* the textures have what paint.c had */
if (ph) {
/* a frame scanned out straight has no times of its own (gpu_frame_times keeps the last
* composed frame's) and no fence (one left from before would give an old GPU time) */
@@ -1696,32 +1696,32 @@ static void out_present(Server *s, Out *o, int i, Rect r, const Out *feed, LbPha
else if (lbf_recording()) { uint64_t old; gpu_fence_time(o->gpu, &old); }
ph->up_ms = ft.up_ms;
ph->up_px = ft.up_px;
- ph->g0_ms = ft.g0_ms;
- ph->g0_px = ft.g0_px;
- ph->g0_full = ft.g0_full;
+ ph->gdrag_ms = ft.gdrag_ms;
+ ph->gdrag_px = ft.gdrag_px;
+ ph->gdrag_full = ft.gdrag_full;
ph->swap_ms = ft.swap_ms;
ph->submit_ms = ft.submit_ms;
ph->unshown = unshown;
}
- /* G0's textures catch up after the frame (render, g0_feed_now): only when this frame
- * would have been G0's but for what they lack (paint.c, paint_g0_feed); sent while G0 is
+ /* GPU drag's textures catch up after the frame (render, gdrag_feed_now): only when this frame
+ * would have been GPU drag's but for what they lack (paint.c, paint_gdrag_feed); sent while GPU drag is
* refused for another reason, most of it would be sent again before it is used */
- if (!failed && !g0drawn && g0last == 0 && g0why == G0R_FEED && nfeed < OUT_MAX) feed_idx[nfeed++] = i;
+ if (!failed && !gdragdrawn && gdraglast == 0 && gdragwhy == GDRAG_R_FEED && nfeed < OUT_MAX) feed_idx[nfeed++] = i;
if (unshown) {
/* the quad could not be drawn: nothing was shown (the display keeps the frame before,
* which was right); W joins the damage and the next frame paints it on the CPU */
- o->g0w = g0->w;
- g0_stale(o);
- o->g0cpu = 1;
- } else if (g0 && !g0drawn && !failed) {
- /* shown without the quad (direct scanout, or G0 turned off): painted next frame */
- o->g0w = g0->w;
- g0_stale(o);
+ o->gdragw = gdrag->w;
+ gdrag_stale(o);
+ o->gdragcpu = 1;
+ } else if (gdrag && !gdragdrawn && !failed) {
+ /* shown without the quad (direct scanout, or GPU drag turned off): painted next frame */
+ o->gdragw = gdrag->w;
+ gdrag_stale(o);
} else {
- o->g0on = g0drawn;
- if (g0drawn) o->g0w = g0->w;
+ o->gdrag_on = gdragdrawn;
+ if (gdragdrawn) o->gdragw = gdrag->w;
}
- o->g0taken = 0;
+ o->gdragtaken = 0;
if (readback && !res && gpu_read_done()) {
static int said;
if (!said++) fprintf(stderr, "remote: composing on the GPU; frames read back for the remote desktop\n");
@@ -1777,7 +1777,7 @@ static void out_prepare(Server *s, Out *o, int i, const Out *feed, int is_main,
o->prep_px = o->scene.px;
o->prep_gen = gpu_generation();
o->prep_gpu = gpu_active() ? o->gpu : -1;
- o->prep_epoch = paint_g0_epoch();
+ o->prep_epoch = paint_gdrag_epoch();
o->prep_ms = now_ms() - ui0;
if (!is_main) return;
lbf_painted(); /* the synthetic pointer's events so far are in it */
@@ -1821,7 +1821,7 @@ static int render_frame(Server *s) {
int main_shown = 0, main_built = 0; /* the main display got this frame; built here (not prepared before) */
int done[OUT_MAX] = { 0 }; /* submitted or built in this render */
/* The frame pipeline: the prepared frames are submitted first, before the JS frame callbacks and the
- * layout of the next one; G0's textures catch up before that one is painted. One that can no longer be
+ * layout of the next one; GPU drag's textures catch up before that one is painted. One that can no longer be
* submitted as painted is undone and built below like any frame. */
int ready = !s->headless && prep_ready(s);
if (ready) {
@@ -1836,7 +1836,7 @@ static int render_frame(Server *s) {
if (o == mo) main_shown = 1;
}
if (call_piped) {
- g0_feed_now(s, &mo->pph);
+ gdrag_feed_now(s, &mo->pph);
lbf_phase_built(&mo->pph);
}
}
@@ -1851,7 +1851,7 @@ static int render_frame(Server *s) {
if (s->headless) {
Out *o = &s->out[0];
Rect drawn = paint_out(s, o, 0, 1);
- if (drawn.x1 > drawn.x0) fph.g0 = paint_g0_last(&fph.g0_why, &fph.g0_sub);
+ if (drawn.x1 > drawn.x0) fph.gdrag = paint_gdrag_last(&fph.gdrag_why, &fph.gdrag_sub);
present_memory(s, o, 0, 1, drawn);
fph_main = 1; /* presented at the end of this frame (below) */
} else {
@@ -1876,7 +1876,7 @@ static int render_frame(Server *s) {
Out *o = &s->out[i];
if (!o->on) continue;
int work = prep_only || o->full || !box_empty(o->pend);
- /* (not with G0's catch-up still queued by a frame built here: it runs after render_frame, and must
+ /* (not with GPU drag's catch-up still queued by a frame built here: it runs after render_frame, and must
* never run between a frame's paint and its upload) */
if (nfeed) continue;
if (fpipe_step(pipe_on(s, o), o->kms.flip_pending, o->prep, 0, work) == FPIPE_PREPARE)
@@ -2271,7 +2271,7 @@ int main(int argc, char **argv) {
paint_layer_stats(&lr, &lb);
char bs[192], gs[512], ps[1536];
below_stats_text(bs, sizeof bs);
- g0_stats_text(gs, sizeof gs);
+ gdrag_stats_text(gs, sizeof gs);
LbPhaseStats ph;
lbf_drag_end(&ph);
lbf_phases_text(&ph, ps, sizeof ps);
@@ -2281,13 +2281,13 @@ int main(int argc, char **argv) {
if (!scripted && grab_scripted()) { /* its start: what came before is not counted */
long lr, lb;
BelowStats b;
- G0Stats g;
+ GdragStats g;
paint_layer_stats(&lr, &lb);
paint_layer_parts();
paint_below_stats(&b);
- paint_g0_stats(&g);
+ paint_gdrag_stats(&g);
long q[3];
- gpu_g0_stats(&q[0], &q[1], &q[2]);
+ gpu_gdrag_stats(&q[0], &q[1], &q[2]);
lbf_drag_begin(); /* its frames' phases (bench/lbframes.h) */
}
scripted = grab_scripted();
diff --git a/server/src/ui/paint.c b/server/src/ui/paint.c
index 4e21d0d..dbb65ee 100644
--- a/server/src/ui/paint.c
+++ b/server/src/ui/paint.c
@@ -516,55 +516,55 @@ static struct {
* shift-exact across 0: roundf, (int) truncation, canvas_corners_save) */
int ext_part; /* outside damage went into layer.part through layer.at since then */
int odd_text; /* text in it took a path that may not move exactly (text_drew_inexact) */
- int premul_bad; /* GPU path: a pixel of it has a colour above its alpha (layer_holes; G0 needs none) */
+ int premul_bad; /* GPU path: a pixel of it has a colour above its alpha (layer_holes; GPU drag needs none) */
} layer;
-/* ---- G0: the dragged window composited on the GPU (paint_root_g0, docs/GPU.md) ----
+/* ---- GPU drag: the dragged window composited on the GPU (paint_root_gdrag, docs/GPU.md) ----
* What of the layer and of the copy of what is below changed since the GPU last got them: the
- * rectangles (in their own pixels) or all of it. They add up over frames that don't use G0 and are
- * consumed only when one does (paint_g0_done). */
-typedef struct { Rect r[G0_DIRTY]; int n, full; } G0Dirty;
-static G0Dirty g0_ld, g0_bd;
-static G0Stats g0stat;
-static Rect g0_join(Rect a, Rect b) {
+ * rectangles (in their own pixels) or all of it. They add up over frames that don't use GPU drag and are
+ * consumed only when one does (paint_gdrag_done). */
+typedef struct { Rect r[GDRAG_DIRTY]; int n, full; } GdragDirty;
+static GdragDirty gdrag_ld, gdrag_bd;
+static GdragStats gdragstat;
+static Rect gdrag_join(Rect a, Rect b) {
return (Rect){ a.x0 < b.x0 ? a.x0 : b.x0, a.y0 < b.y0 ? a.y0 : b.y0, a.x1 > b.x1 ? a.x1 : b.x1, a.y1 > b.y1 ? a.y1 : b.y1 };
}
-static long g0_area(Rect r) { return r.x1 > r.x0 && r.y1 > r.y0 ? (long)(r.x1 - r.x0) * (r.y1 - r.y0) : 0; }
-static void g0_dirty(G0Dirty *d, Rect r) {
+static long gdrag_area(Rect r) { return r.x1 > r.x0 && r.y1 > r.y0 ? (long)(r.x1 - r.x0) * (r.y1 - r.y0) : 0; }
+static void gdrag_dirty(GdragDirty *d, Rect r) {
if (d->full || r.x1 <= r.x0 || r.y1 <= r.y0) return;
for (int i = 0; i < d->n; i++) /* already inside one */
if (r.x0 >= d->r[i].x0 && r.y0 >= d->r[i].y0 && r.x1 <= d->r[i].x1 && r.y1 <= d->r[i].y1) return;
- if (d->n < G0_DIRTY) { d->r[d->n++] = r; return; }
+ if (d->n < GDRAG_DIRTY) { d->r[d->n++] = r; return; }
/* no room: of the rectangles and r, the two whose box adds the fewest pixels become that box (the
* last one growing, as before, could turn a few small changes into most of the screen) */
- int bi = 0, bj = G0_DIRTY; /* bj == G0_DIRTY: r itself */
+ int bi = 0, bj = GDRAG_DIRTY; /* bj == GDRAG_DIRTY: r itself */
long best = -1;
- for (int i = 0; i < G0_DIRTY; i++)
- for (int j = i + 1; j <= G0_DIRTY; j++) {
- Rect b = j < G0_DIRTY ? d->r[j] : r;
- long w = g0_area(g0_join(d->r[i], b)) - g0_area(d->r[i]) - g0_area(b);
+ for (int i = 0; i < GDRAG_DIRTY; i++)
+ for (int j = i + 1; j <= GDRAG_DIRTY; j++) {
+ Rect b = j < GDRAG_DIRTY ? d->r[j] : r;
+ long w = gdrag_area(gdrag_join(d->r[i], b)) - gdrag_area(d->r[i]) - gdrag_area(b);
if (best < 0 || w < best) { best = w; bi = i; bj = j; }
}
- if (bj == G0_DIRTY) { d->r[bi] = g0_join(d->r[bi], r); return; }
- d->r[bi] = g0_join(d->r[bi], d->r[bj]);
+ if (bj == GDRAG_DIRTY) { d->r[bi] = gdrag_join(d->r[bi], r); return; }
+ d->r[bi] = gdrag_join(d->r[bi], d->r[bj]);
d->r[bj] = r;
}
-/* bumped whenever a GpuG0 filled earlier may no longer be submitted as it is (its buffers or the textures'
- * bookkeeping changed): see paint_g0_epoch */
-static unsigned g0_epoch;
-unsigned paint_g0_epoch(void) { return g0_epoch; }
-static void g0_dirty_all(void) { g0_ld = (G0Dirty){ .full = 1 }; g0_bd = (G0Dirty){ .full = 1 }; g0_epoch++; }
-void paint_g0_done(void) { g0_ld = (G0Dirty){ 0 }; g0_bd = (G0Dirty){ 0 }; }
-void paint_g0_stats(G0Stats *out) {
- *out = g0stat;
- memset(&g0stat, 0, sizeof g0stat);
+/* bumped whenever a GpuDrag filled earlier may no longer be submitted as it is (its buffers or the textures'
+ * bookkeeping changed): see paint_gdrag_epoch */
+static unsigned gdrag_epoch;
+unsigned paint_gdrag_epoch(void) { return gdrag_epoch; }
+static void gdrag_dirty_all(void) { gdrag_ld = (GdragDirty){ .full = 1 }; gdrag_bd = (GdragDirty){ .full = 1 }; gdrag_epoch++; }
+void paint_gdrag_done(void) { gdrag_ld = (GdragDirty){ 0 }; gdrag_bd = (GdragDirty){ 0 }; }
+void paint_gdrag_stats(GdragStats *out) {
+ *out = gdragstat;
+ memset(&gdragstat, 0, sizeof gdragstat);
}
-typedef struct { int taken, why, sub; } G0Last;
-static G0Last g0_last = { -1, -1, -1 };
-int paint_g0_last(int *why, int *sub) {
- *why = g0_last.why;
- *sub = g0_last.sub;
- return g0_last.taken;
+typedef struct { int taken, why, sub; } GdragLast;
+static GdragLast gdrag_last = { -1, -1, -1 };
+int paint_gdrag_last(int *why, int *sub) {
+ *why = gdrag_last.why;
+ *sub = gdrag_last.sub;
+ return gdrag_last.taken;
}
void paint_layer_begin(int node, int resize) {
@@ -574,7 +574,7 @@ void paint_layer_begin(int node, int resize) {
layer.valid = 0;
layer.lg_valid = 0;
layer.bdmg_full = 1;
- g0_dirty_all();
+ gdrag_dirty_all();
}
void paint_layer_end(void) {
@@ -585,7 +585,7 @@ void paint_layer_end(void) {
free(layer.below);
free(layer.hole);
memset(&layer, 0, sizeof layer);
- g0_dirty_all();
+ gdrag_dirty_all();
}
void paint_layer_external_damage(void) { layer.valid = 0; }
@@ -597,7 +597,7 @@ int paint_layer_node(void) { return layer.want ? layer.node : 0; }
void paint_layer_view(int index) {
if (layer.view == index) return;
- g0_epoch++;
+ gdrag_epoch++;
layer.view = index;
layer.valid = 0;
layer.lg_valid = 0;
@@ -674,13 +674,13 @@ static int in_surface(int x, int y) {
* with no app surfaces: then it neither writes the map nor does layer_paint walk it. The bytes it
* left are made zeros only when a part brings a hole into a map that had none. */
/* A valid premultiplied pixel has no colour above its alpha; with one that does, blit_row's sum
- * carries into the next channel (C) or wraps (NEON), and G0 would not match: noted, G0 refuses. */
+ * carries into the next channel (C) or wraps (NEON), and GPU drag would not match: noted, GPU drag refuses. */
static inline int premul_bad(uint32_t p) {
uint32_t a = p >> 24;
return (p >> 16 & 255) > a || (p >> 8 & 255) > a || (p & 255) > a;
}
static void layer_holes(int x0, int y0, int x1, int y1) {
- /* no map (the CPU path): the pixels are not checked either, so G0 must not trust them */
+ /* no map (the CPU path): the pixels are not checked either, so GPU drag must not trust them */
if (!gpu_active() || !layer.hole) { layer.premul_bad = 1; return; }
int any = nlsurf || lsurf_all, bad = 0;
if (!any && !layer.has_holes) {
@@ -787,7 +787,7 @@ static int layer_render(Node *n, float opacity) {
uint8_t *hole = realloc(layer.hole, (size_t)w * h);
if (px) layer.px = px;
if (hole) layer.hole = hole;
- g0_epoch++;
+ gdrag_epoch++;
if (!px || !hole) { layer.want = 0; return 0; }
layer.cap = w * h;
}
@@ -823,55 +823,55 @@ static int layer_render(Node *n, float opacity) {
layer_surfaces(n, x0, y0);
layer.premul_bad = 0;
layer_holes(0, 0, w, h);
- g0_ld = (G0Dirty){ .full = 1 };
+ gdrag_ld = (GdragDirty){ .full = 1 };
layer.valid = 1;
layer.painted = 1;
layer_renders++;
return 1;
}
-/* ---- G0's textures catching up between frames (docs/GPU.md, "Uploads without a stall") ----
+/* ---- GPU drag's textures catching up between frames (docs/GPU.md, "Uploads without a stall") ----
* A whole copy of what is below (a drag's start, a copy built again whole) is a screen of pixels: sent in
- * one frame it took that frame past its vblank. Now a frame that uses G0 sends at most G0_FEED_PX
- * (g0_backlog_now; else the CPU paints it, the same pixels), and what is left is sent after a frame's
- * flip is queued, a slice a frame (paint_g0_feed), while the CPU waits for the vblank anyway. */
-static long g0_backlog_one(const G0Dirty *d, int w, int h) {
+ * one frame it took that frame past its vblank. Now a frame that uses GPU drag sends at most GDRAG_FEED_PX
+ * (gdrag_backlog_now; else the CPU paints it, the same pixels), and what is left is sent after a frame's
+ * flip is queued, a slice a frame (paint_gdrag_feed), while the CPU waits for the vblank anyway. */
+static long gdrag_backlog_one(const GdragDirty *d, int w, int h) {
if (d->full) return (long)w * h;
long a = 0;
for (int i = 0; i < d->n; i++) {
Rect q = d->r[i];
- a += g0_area((Rect){ q.x0 < 0 ? 0 : q.x0, q.y0 < 0 ? 0 : q.y0, q.x1 > w ? w : q.x1, q.y1 > h ? h : q.y1 });
+ a += gdrag_area((Rect){ q.x0 < 0 ? 0 : q.x0, q.y0 < 0 ? 0 : q.y0, q.x1 > w ? w : q.x1, q.y1 > h ? h : q.y1 });
}
return a;
}
-static long g0_backlog_now(void) {
- return g0_backlog_one(&g0_bd, layer.bw, layer.bh) + (layer.px ? g0_backlog_one(&g0_ld, layer.w, layer.h) : 0);
+static long gdrag_backlog_now(void) {
+ return gdrag_backlog_one(&gdrag_bd, layer.bw, layer.bh) + (layer.px ? gdrag_backlog_one(&gdrag_ld, layer.w, layer.h) : 0);
}
-/* whether G0 could use the layer on display view soon: else sending it is wasted work */
-static int g0_feedable(int view) {
+/* whether GPU drag could use the layer on display view soon: else sending it is wasted work */
+static int gdrag_feedable(int view) {
return gpu_active() && layer.want && layer.node && layer.view == view && !layer.resize && !layer.rendering &&
layer.below && !layer.bdmg_full && !layer.has_holes && !layer.premul_bad && !nlsurf && !lsurf_all;
}
-long paint_g0_backlog(int view) { return g0_feedable(view) ? g0_backlog_now() : 0; }
+long paint_gdrag_backlog(int view) { return gdrag_feedable(view) ? gdrag_backlog_now() : 0; }
-long paint_g0_feed(int view, long budget, int (*up)(void *ctx, int which, const uint32_t *px, int w, int h, Rect r),
+long paint_gdrag_feed(int view, long budget, int (*up)(void *ctx, int which, const uint32_t *px, int w, int h, Rect r),
void *ctx) {
- if (!g0_feedable(view)) return 0;
+ if (!gdrag_feedable(view)) return 0;
long sent = 0;
for (int which = 0; which < 2 && sent < budget; which++) {
- G0Dirty *d = which ? &g0_ld : &g0_bd;
+ GdragDirty *d = which ? &gdrag_ld : &gdrag_bd;
const uint32_t *px = which ? layer.px : layer.below;
int w = which ? layer.w : layer.bw, h = which ? layer.h : layer.bh;
if (!px || w <= 0 || h <= 0 || (which && !layer.valid)) continue;
/* an empty rectangle first: does the texture hold this at all? */
int k = up(ctx, which, px, w, h, (Rect){ 0, 0, 0, 0 });
if (k < 0) return sent;
- if (k > 0) *d = (G0Dirty){ .full = 1 };
+ if (k > 0) *d = (GdragDirty){ .full = 1 };
while (d->full || d->n) {
- if (d->full) *d = (G0Dirty){ .r = { { 0, 0, w, h } }, .n = 1 };
+ if (d->full) *d = (GdragDirty){ .r = { { 0, 0, w, h } }, .n = 1 };
Rect *l = &d->r[d->n - 1];
Rect q = { l->x0 < 0 ? 0 : l->x0, l->y0 < 0 ? 0 : l->y0, l->x1 > w ? w : l->x1, l->y1 > h ? h : l->y1 };
- long a = g0_area(q), room = budget - sent;
+ long a = gdrag_area(q), room = budget - sent;
if (!a) { d->n--; continue; }
if (room <= 0) break;
Rect part = q;
@@ -882,8 +882,8 @@ long paint_g0_feed(int view, long budget, int (*up)(void *ctx, int which, const
}
k = up(ctx, which, px, w, h, part);
if (k < 0) return sent;
- if (k > 0) { *d = (G0Dirty){ .full = 1 }; break; } /* lost meanwhile: all again, next time */
- sent += g0_area(part);
+ if (k > 0) { *d = (GdragDirty){ .full = 1 }; break; } /* lost meanwhile: all again, next time */
+ sent += gdrag_area(part);
if (part.y1 >= q.y1) d->n--;
else *l = (Rect){ q.x0, part.y1, q.x1, q.y1 };
}
@@ -921,7 +921,7 @@ static int layer_render_part(Node *n, float opacity) {
nlsurf = lsurf_all = 0;
layer_surfaces(n, x0, y0);
layer_holes(px0, py0, px1, py1);
- g0_dirty(&g0_ld, (Rect){ px0, py0, px1, py1 });
+ gdrag_dirty(&gdrag_ld, (Rect){ px0, py0, px1, py1 });
layer.painted = 1;
float k = paint_view.k, lx = (x0 - paint_view.dx) / k + paint_view.x, ly = (y0 - paint_view.dy) / k + paint_view.y;
layer.at = (Box){ lx, ly, lx + layer.w / k, ly + layer.h / k };
@@ -1048,12 +1048,12 @@ static int view_eq(PaintView a, PaintView b) { return a.x == b.x && a.y == b.y &
static int below_alloc(const Canvas *c) {
if (layer.below && layer.bw == c->w && layer.bh == c->h) return 1;
free(layer.below);
- g0_epoch++;
+ gdrag_epoch++;
layer.below = malloc((size_t)c->w * c->h * 4);
layer.bw = layer.below ? c->w : 0;
layer.bh = layer.below ? c->h : 0;
layer.bdmg_full = 1;
- g0_bd = (G0Dirty){ .full = 1 };
+ gdrag_bd = (GdragDirty){ .full = 1 };
return layer.below != NULL;
}
@@ -1144,10 +1144,10 @@ static void below_build(const Canvas *c, Node *root, const Rect *r, int n) {
layer.bsig = layer.osig;
layer.bview = paint_view;
bstat.full++;
- g0_bd = (G0Dirty){ .full = 1 };
+ gdrag_bd = (GdragDirty){ .full = 1 };
} else {
bstat.part++;
- for (int i = 0; i < n; i++) g0_dirty(&g0_bd, r[i]);
+ for (int i = 0; i < n; i++) gdrag_dirty(&gdrag_bd, r[i]);
}
paint_cull = cull;
layer.bdmg.n = 0;
@@ -1340,12 +1340,12 @@ static int below_order(Node *root) {
return ord_n ? ORD_PATH : ORD_BEFORE;
}
-/* G0: the nodes painted after the window that paint something (their box on screen, grown by what a
- * backdrop blur reads around it or a turned image's bilinear edge, logical px). A frame G0 composes
- * must have none of them in its damaged box (paint_root_g0). */
-#define G0_AFTER_MAX 65536 /* the menu bar and the Dock alone are a few hundred */
-static Box *g0_after;
-static int ng0_after, g0_after_cap, g0_after_over;
+/* GPU drag: the nodes painted after the window that paint something (their box on screen, grown by what a
+ * backdrop blur reads around it or a turned image's bilinear edge, logical px). A frame GPU drag composes
+ * must have none of them in its damaged box (paint_root_gdrag). */
+#define GDRAG_AFTER_MAX 65536 /* the menu bar and the Dock alone are a few hundred */
+static Box *gdrag_after;
+static int ngdrag_after, gdrag_after_cap, gdrag_after_over;
static int node_paints(const Node *n) {
const Style *s = &n->s;
if (n->type != NODE_VIEW) return 1; /* text, image, terminal, app window, video */
@@ -1356,25 +1356,25 @@ static int node_paints(const Node *n) {
if (s->overflow_hidden && (node_edges_plain(n) ? s->radius : max4(s->ext->r.rad)) > 0) return 1;
return 0;
}
-static void g0_note_after(const Node *n, Box cur) {
+static void gdrag_note_after(const Node *n, Box cur) {
if (cur.x1 <= cur.x0 || cur.y1 <= cur.y0 || !node_paints(n)) return;
- if (g0_after_over) return;
+ if (gdrag_after_over) return;
float m = 0;
if (n->s.backdrop_blur >= 1) m = ceilf(n->s.backdrop_blur * 2) + 1;
if (n->has_tf && m < 4) m = 4;
Box b = { cur.x0 - m, cur.y0 - m, cur.x1 + m, cur.y1 + m };
- if (ng0_after) { /* inside the box noted last (a child in its bar): meets D only if that one does */
- const Box *p = &g0_after[ng0_after - 1];
+ if (ngdrag_after) { /* inside the box noted last (a child in its bar): meets D only if that one does */
+ const Box *p = &gdrag_after[ngdrag_after - 1];
if (b.x0 >= p->x0 && b.y0 >= p->y0 && b.x1 <= p->x1 && b.y1 <= p->y1) return;
}
- if (ng0_after == g0_after_cap) {
- int cap = g0_after_cap ? g0_after_cap * 2 : 256;
- Box *nb = cap <= G0_AFTER_MAX ? realloc(g0_after, (size_t)cap * sizeof *nb) : NULL;
- if (!nb) { g0_after_over = 1; return; }
- g0_after = nb;
- g0_after_cap = cap;
+ if (ngdrag_after == gdrag_after_cap) {
+ int cap = gdrag_after_cap ? gdrag_after_cap * 2 : 256;
+ Box *nb = cap <= GDRAG_AFTER_MAX ? realloc(gdrag_after, (size_t)cap * sizeof *nb) : NULL;
+ if (!nb) { gdrag_after_over = 1; return; }
+ gdrag_after = nb;
+ gdrag_after_cap = cap;
}
- g0_after[ng0_after++] = b;
+ gdrag_after[ngdrag_after++] = b;
}
/* ord: ORD_PATH for the window's ancestors, else whether the node is painted before or after it */
@@ -1407,7 +1407,7 @@ static void damage_walk(Node *n, int parent_dirty, int visible, int in_layer, Bo
layer.gdy = cur.y0 - n->prev_box.y0;
}
if (in_layer && vis) layer_note_exact(n, dirty);
- if (ord == ORD_AFTER && vis) g0_note_after(n, cur);
+ if (ord == ORD_AFTER && vis) gdrag_note_after(n, cur);
if (dirty || !box_eq(cur, n->prev_box)) {
damage_add(n->prev_box);
damage_add(cur);
@@ -1683,7 +1683,7 @@ int paint_damage(Node *root) {
below_damage(ext);
}
int ord = below_order(root);
- ng0_after = g0_after_over = 0;
+ ngdrag_after = gdrag_after_over = 0;
if (root) damage_walk(root, 0, 1, 0, (Box){ -1e9f, -1e9f, 1e9f, 1e9f }, ord);
ndrects = 0;
if (multi_rects(root)) return 1;
@@ -1767,7 +1767,7 @@ static void below_verify(const Canvas *c, Node *root, uint32_t *pre) {
free(pre);
}
-/* ---- G0: the dragged window composited on the GPU (docs/GPU.md, "The dragged window on the GPU") ----
+/* ---- GPU drag: the dragged window composited on the GPU (docs/GPU.md, "The dragged window on the GPU") ----
* On a frame that uses the copy of what is below (below_ready), the CPU's pixels inside the window's
* rectangle W are the layer blitted over that copy (canvas_blit, k = 256: blit_row) and nothing else,
* when: the layer is painted as it is (valid, the same opacity, no full render pending, no app window
@@ -1786,35 +1786,35 @@ static Rect rect_and(Rect a, Rect b) {
return r;
}
static int rect_eq(Rect a, Rect b) { return a.x0 == b.x0 && a.y0 == b.y0 && a.x1 == b.x1 && a.y1 == b.y1; }
-static int g0_bx, g0_by; /* where the layer's pixel (0, 0) lands (layer_paint's bx, by) */
+static int gdrag_bx, gdrag_by; /* where the layer's pixel (0, 0) lands (layer_paint's bx, by) */
-/* W for this frame (-1), or why there is none (G0R_*): where layer_paint's blit lands, cut by the
+/* W for this frame (-1), or why there is none (GDRAG_R_*): where layer_paint's blit lands, cut by the
* ancestors' clips and by c->clip, the frame's box (inside the canvas). */
-static int g0_sub; /* the G0L_* of g0_gate's last G0R_LAYER */
-#define G0_NO_LAYER(why) do { g0_sub = (why); return G0R_LAYER; } while (0)
-static int g0_gate(const Canvas *c, Node *root, Rect *wout) {
+static int gdrag_sub; /* the GDRAG_L_* of gdrag_gate's last GDRAG_R_LAYER */
+#define GDRAG_NO_LAYER(why) do { gdrag_sub = (why); return GDRAG_R_LAYER; } while (0)
+static int gdrag_gate(const Canvas *c, Node *root, Rect *wout) {
Node *w = node_get(layer.node);
- g0_sub = -1;
- if (!w || !layer.want) G0_NO_LAYER(G0L_GONE);
- if (!layer.valid) G0_NO_LAYER(G0L_INVALID);
- if (layer.resize) G0_NO_LAYER(G0L_RESIZE);
- if (layer.rendering) G0_NO_LAYER(G0L_RENDERING);
- if (paint_capture_mode) G0_NO_LAYER(G0L_CAPTURE);
- if (paint_view.index != layer.view) G0_NO_LAYER(G0L_VIEW);
- if (w->has_tf) G0_NO_LAYER(G0L_TRANSFORM);
- if (w->type == NODE_RAW || w->s.display_none) G0_NO_LAYER(G0L_RAW);
- if (layer.has_holes) G0_NO_LAYER(G0L_HOLES);
- if (nlsurf || lsurf_all) G0_NO_LAYER(G0L_SURFACES);
- if (layer.premul_bad) G0_NO_LAYER(G0L_PREMUL);
- if (!layer.px || !layer.below) G0_NO_LAYER(G0L_NOBUF);
+ gdrag_sub = -1;
+ if (!w || !layer.want) GDRAG_NO_LAYER(GDRAG_L_GONE);
+ if (!layer.valid) GDRAG_NO_LAYER(GDRAG_L_INVALID);
+ if (layer.resize) GDRAG_NO_LAYER(GDRAG_L_RESIZE);
+ if (layer.rendering) GDRAG_NO_LAYER(GDRAG_L_RENDERING);
+ if (paint_capture_mode) GDRAG_NO_LAYER(GDRAG_L_CAPTURE);
+ if (paint_view.index != layer.view) GDRAG_NO_LAYER(GDRAG_L_VIEW);
+ if (w->has_tf) GDRAG_NO_LAYER(GDRAG_L_TRANSFORM);
+ if (w->type == NODE_RAW || w->s.display_none) GDRAG_NO_LAYER(GDRAG_L_RAW);
+ if (layer.has_holes) GDRAG_NO_LAYER(GDRAG_L_HOLES);
+ if (nlsurf || lsurf_all) GDRAG_NO_LAYER(GDRAG_L_SURFACES);
+ if (layer.premul_bad) GDRAG_NO_LAYER(GDRAG_L_PREMUL);
+ if (!layer.px || !layer.below) GDRAG_NO_LAYER(GDRAG_L_NOBUF);
const Node *anc[SKIP_PATH_MAX];
int na = 0;
for (const Node *a = w->parent; a; a = a->parent) {
- if (na == SKIP_PATH_MAX) return G0R_ANCESTOR;
- if (a->type == NODE_RAW || a->s.display_none) G0_NO_LAYER(G0L_RAW);
+ if (na == SKIP_PATH_MAX) return GDRAG_R_ANCESTOR;
+ if (a->type == NODE_RAW || a->s.display_none) GDRAG_NO_LAYER(GDRAG_L_RAW);
anc[na++] = a;
}
- if (!na || anc[na - 1] != root) G0_NO_LAYER(G0L_TREE);
+ if (!na || anc[na - 1] != root) GDRAG_NO_LAYER(GDRAG_L_TREE);
const float k = paint_view.k;
int bx = (int)lroundf(VX(w->ax) + layer.pox), by = (int)lroundf(VY(w->ay) + layer.poy);
Rect r = { bx, by, bx + layer.w, by + layer.h };
@@ -1823,33 +1823,33 @@ static int g0_gate(const Canvas *c, Node *root, Rect *wout) {
for (int i = na - 1; i >= 0; i--) {
const Node *a = anc[i];
op = op * a->s.opacity;
- if (op < 0.004f) G0_NO_LAYER(G0L_OPACITY);
+ if (op < 0.004f) GDRAG_NO_LAYER(GDRAG_L_OPACITY);
if (a->s.overflow_hidden) {
float x = VX(a->ax), y = VY(a->ay), aw = a->w * k, ah = a->h * k;
r = rect_and(r, (Rect){ (int)floorf(x), (int)floorf(y), (int)ceilf(x + aw), (int)ceilf(y + ah) });
}
}
- if (op != layer.op) G0_NO_LAYER(G0L_OPACITY);
+ if (op != layer.op) GDRAG_NO_LAYER(GDRAG_L_OPACITY);
Box pb;
- if (layer.tree_part && !layer_part_exact(w, &pb)) G0_NO_LAYER(G0L_PART); /* it would be painted whole */
+ if (layer.tree_part && !layer_part_exact(w, &pb)) GDRAG_NO_LAYER(GDRAG_L_PART); /* it would be painted whole */
r = rect_and(r, c->clip); /* the blit is clipped to the frame's box too */
- if (!rect_area(r)) return G0R_CLIP;
- if (!below_ancestors_ok(w, r)) return G0R_ANCESTOR;
- if (wl_draws_meet(r)) return G0R_APP;
- if (!ord_n || g0_after_over) return G0R_AFTER;
- for (int i = 0; i < ng0_after; i++) {
- Box b = g0_after[i];
+ if (!rect_area(r)) return GDRAG_R_CLIP;
+ if (!below_ancestors_ok(w, r)) return GDRAG_R_ANCESTOR;
+ if (wl_draws_meet(r)) return GDRAG_R_APP;
+ if (!ord_n || gdrag_after_over) return GDRAG_R_AFTER;
+ for (int i = 0; i < ngdrag_after; i++) {
+ Box b = gdrag_after[i];
Rect q = { (int)floorf(VX(b.x0)) - 1, (int)floorf(VY(b.y0)) - 1, (int)ceilf(VX(b.x1)) + 1, (int)ceilf(VY(b.y1)) + 1 };
- if (rect_meets(q, c->clip)) return G0R_AFTER;
+ if (rect_meets(q, c->clip)) return GDRAG_R_AFTER;
}
- g0_bx = bx;
- g0_by = by;
+ gdrag_bx = bx;
+ gdrag_by = by;
*wout = r;
return -1;
}
/* One walk of a frame that uses the copy, clipped to c->clip: the copy, then from the window on */
-static void g0_walk(Canvas *c, Node *root) {
+static void gdrag_walk(Canvas *c, Node *root) {
wl_paint_begin();
wl_paint_kept();
below_copy(c);
@@ -1859,11 +1859,11 @@ static void g0_walk(Canvas *c, Node *root) {
paint_node(c, root, 1);
}
-/* LORD_GPU_VERIFY=N: every N-th G0 frame, W painted by the CPU (a walk clipped to W on a scratch
+/* LORD_GPU_VERIFY=N: every N-th GPU drag frame, W painted by the CPU (a walk clipped to W on a scratch
* canvas the scene's size: the save of an ancestor's rounded corners reads outside the clip), leaving
* the frame's list of app windows and the counters as they were. W's rows are returned packed (W's
* width a row). */
-static const uint32_t *g0_reference(const Canvas *c, Node *root, Rect w) {
+static const uint32_t *gdrag_reference(const Canvas *c, Node *root, Rect w) {
static uint32_t *buf;
static size_t cap;
size_t n = (size_t)c->w * c->h;
@@ -1878,7 +1878,7 @@ static const uint32_t *g0_reference(const Canvas *c, Node *root, Rect w) {
canvas_set_clip(&rc, w);
long lb = layer_blits, lr = layer_renders, tr = tf_renders, tc = tf_composites;
wl_paint_save();
- g0_walk(&rc, root);
+ gdrag_walk(&rc, root);
wl_paint_restore();
layer_blits = lb; layer_renders = lr; tf_renders = tr; tf_composites = tc;
int ww = w.x1 - w.x0;
@@ -1888,8 +1888,8 @@ static const uint32_t *g0_reference(const Canvas *c, Node *root, Rect w) {
}
/* The strips around w, then the post-check. 1: g is filled and w is left to the GPU; 0: w was painted
- * too (the frame is the same as without G0). */
-static int g0_paint(Canvas *c, Node *root, Rect w, GpuG0 *g) {
+ * too (the frame is the same as without GPU drag). */
+static int gdrag_paint(Canvas *c, Node *root, Rect w, GpuDrag *g) {
static int every = -1;
static long frames;
if (every < 0) {
@@ -1907,34 +1907,34 @@ static int g0_paint(Canvas *c, Node *root, Rect w, GpuG0 *g) {
for (int i = 0; i < (ns ? ns : 1); i++) {
/* no strip: one walk with nothing to paint (the layer's part is rendered, app windows noted) */
canvas_set_clip(c, ns ? st[i] : (Rect){ w.x0, w.y0, w.x0, w.y0 });
- g0_walk(c, root);
+ gdrag_walk(c, root);
}
layer_blits = lb + 1;
canvas_set_clip(c, d);
Rect w2;
- if (g0_gate(c, root, &w2) >= 0 || !rect_eq(w, w2)) {
+ if (gdrag_gate(c, root, &w2) >= 0 || !rect_eq(w, w2)) {
canvas_set_clip(c, w);
- g0_walk(c, root);
+ gdrag_walk(c, root);
canvas_set_clip(c, d);
return 0;
}
- *g = (GpuG0){ .w = w, .lpx = layer.px, .lw = layer.w, .lh = layer.h, .lx = g0_bx, .ly = g0_by,
- .bpx = layer.below, .bw = layer.bw, .bh = layer.bh, .nl = g0_ld.n, .nb = g0_bd.n,
- .lfull = g0_ld.full, .bfull = g0_bd.full, .nstrip = ns };
- memcpy(g->ldirty, g0_ld.r, sizeof g0_ld.r);
- memcpy(g->bdirty, g0_bd.r, sizeof g0_bd.r);
+ *g = (GpuDrag){ .w = w, .lpx = layer.px, .lw = layer.w, .lh = layer.h, .lx = gdrag_bx, .ly = gdrag_by,
+ .bpx = layer.below, .bw = layer.bw, .bh = layer.bh, .nl = gdrag_ld.n, .nb = gdrag_bd.n,
+ .lfull = gdrag_ld.full, .bfull = gdrag_bd.full, .nstrip = ns };
+ memcpy(g->ldirty, gdrag_ld.r, sizeof gdrag_ld.r);
+ memcpy(g->bdirty, gdrag_bd.r, sizeof gdrag_bd.r);
memcpy(g->strip, st, sizeof st);
g->frame = ++frames;
- g->ref = every && frames % every == 0 ? g0_reference(c, root, w) : NULL;
- g0stat.frames++;
- for (int i = 0; i < ns; i++) g0stat.strip_px += rect_area(st[i]);
+ g->ref = every && frames % every == 0 ? gdrag_reference(c, root, w) : NULL;
+ gdragstat.frames++;
+ for (int i = 0; i < ns; i++) gdragstat.strip_px += rect_area(st[i]);
return 1;
}
/* clear: fill the clip with rgb first, unless the copy of what is below the dragged window is
* about to write every pixel of that same clip (below_copy), which makes the fill wasted work.
- * g (G0, paint_root_g0): the window's rectangle may be left to the GPU; 1 if it was. */
-static int paint_root_body(Canvas *c, Node *root, int clear, uint32_t rgb, GpuG0 *g) {
+ * g (GPU drag, paint_root_gdrag): the window's rectangle may be left to the GPU; 1 if it was. */
+static int paint_root_body(Canvas *c, Node *root, int clear, uint32_t rgb, GpuDrag *g) {
if (!root) { if (clear) canvas_clear(c, rgb); return 0; }
wl_paint_begin();
/* solo cambió un cuadro de video que tapa esa región: se pinta desde ese nodo (no en el camino
@@ -1949,24 +1949,24 @@ static int paint_root_body(Canvas *c, Node *root, int clear, uint32_t rgb, GpuG0
int below = !skip_until && below_ready(c, root, clear && rgb == 0x000000);
uint32_t *pre = below && layer.switched && paint_below_verify ? below_snapshot(c) : NULL;
int done = 0, taken = 0;
- g0_last = (G0Last){ -1, -1, -1 };
- if (below && g && gpu_active()) { /* G0: only after below_ready, so its decisions are the same */
+ gdrag_last = (GdragLast){ -1, -1, -1 };
+ if (below && g && gpu_active()) { /* GPU drag: only after below_ready, so its decisions are the same */
Rect w;
- int why = g0_gate(c, root, &w);
- /* what the textures still lack goes first, a slice a frame after the flip (paint_g0_feed): a
+ int why = gdrag_gate(c, root, &w);
+ /* what the textures still lack goes first, a slice a frame after the flip (paint_gdrag_feed): a
* frame that would have to send more is painted here, the same pixels */
- if (why < 0 && g0_backlog_now() > G0_FEED_PX) why = G0R_FEED;
- g0stat.tried++;
+ if (why < 0 && gdrag_backlog_now() > GDRAG_FEED_PX) why = GDRAG_R_FEED;
+ gdragstat.tried++;
if (why < 0) {
done = 1;
- taken = g0_paint(c, root, w, g);
- if (!taken) why = G0R_POST;
+ taken = gdrag_paint(c, root, w, g);
+ if (!taken) why = GDRAG_R_POST;
}
if (!taken) {
- g0stat.refused[why]++;
- if (why == G0R_LAYER && g0_sub >= 0) g0stat.layer[g0_sub]++;
+ gdragstat.refused[why]++;
+ if (why == GDRAG_R_LAYER && gdrag_sub >= 0) gdragstat.layer[gdrag_sub]++;
}
- g0_last = (G0Last){ taken, taken ? -1 : why, !taken && why == G0R_LAYER ? g0_sub : -1 };
+ gdrag_last = (GdragLast){ taken, taken ? -1 : why, !taken && why == GDRAG_R_LAYER ? gdrag_sub : -1 };
}
if (!done) {
if (below) {
@@ -2001,8 +2001,8 @@ void paint_root_clear(Canvas *c, Node *root, uint32_t rgb) {
paint_root_body(c, root, 1, rgb, NULL);
}
-/* paint_root_clear(c, root, 0) with the dragged window's rectangle left to the GPU when exact (G0, above) */
-int paint_root_g0(Canvas *c, Node *root, GpuG0 *g) {
+/* paint_root_clear(c, root, 0) with the dragged window's rectangle left to the GPU when exact (GPU drag, above) */
+int paint_root_gdrag(Canvas *c, Node *root, GpuDrag *g) {
return paint_root_body(c, root, 1, 0x000000, g);
}
diff --git a/server/src/ui/ui.h b/server/src/ui/ui.h
index 9372600..34c6f8a 100644
--- a/server/src/ui/ui.h
+++ b/server/src/ui/ui.h
@@ -310,47 +310,47 @@ extern long paint_below_bad, paint_below_checked;
enum { BR_OK, BR_ANCESTOR, BR_BLUR, BR_TRANSFORM, BR_UNREACHED, BR_COST, BR_N };
typedef struct { long full, part, switched, refused[BR_N]; } BelowStats;
void paint_below_stats(BelowStats *s); /* builds (whole, part) and switched frames since the last call */
-/* G0 (docs/GPU.md, "The dragged window on the GPU"): paint_root_clear's frame, except that where
+/* GPU drag (docs/GPU.md, "The dragged window on the GPU"): paint_root_clear's frame, except that where
* the dragged window lands (g->w) nothing is painted: the GPU composites the layer over the copy of what
* is below there, with the CPU's arithmetic. Only on frames that use that copy and only when nothing
* else would paint there (see paint.c); 1 if it was taken (the scene's g->w is then stale and only
* g->strip were painted), 0 if the whole clip was painted as paint_root_clear(c, root, 0) does.
- * paint_g0_done: the GPU got g's textures (the dirty rectangles start again). LORD_GPU_VERIFY=N: every
+ * paint_gdrag_done: the GPU got g's textures (the dirty rectangles start again). LORD_GPU_VERIFY=N: every
* N-th taken frame also paints g->w on the CPU into g->ref, for the GPU to compare. */
-struct GpuG0;
-int paint_root_g0(Canvas *c, Node *root, struct GpuG0 *g);
-void paint_g0_done(void);
-/* changes whenever a GpuG0 that paint_root_g0 filled may no longer be submitted as it is: the drag layer began,
+struct GpuDrag;
+int paint_root_gdrag(Canvas *c, Node *root, struct GpuDrag *g);
+void paint_gdrag_done(void);
+/* changes whenever a GpuDrag that paint_root_gdrag filled may no longer be submitted as it is: the drag layer began,
* ended or moved to another display, its buffers were reallocated or the textures need everything again. The
- * frame pipeline (main.c) checks it before submitting a prepared G0 frame. */
-unsigned paint_g0_epoch(void);
+ * frame pipeline (main.c) checks it before submitting a prepared GPU drag frame. */
+unsigned paint_gdrag_epoch(void);
/* why a frame that used the copy was not composited on the GPU: the layer (invalid, re-rendered, app
* windows or invalid pixels in it, other opacity, a transform), its rectangle not inside the damage,
* an ancestor painting over it, an app window under it, a node painted after the window in the
* damage, or something changed while painting (post) */
-enum { G0R_LAYER, G0R_CLIP, G0R_ANCESTOR, G0R_APP, G0R_AFTER, G0R_POST,
- G0R_FEED, /* the textures still lack more than G0_FEED_PX (paint_g0_feed) */
- G0R_N };
-/* G0R_LAYER split by its cause, in g0_gate's order: no window or not wanted, not valid (painted whole
+enum { GDRAG_R_LAYER, GDRAG_R_CLIP, GDRAG_R_ANCESTOR, GDRAG_R_APP, GDRAG_R_AFTER, GDRAG_R_POST,
+ GDRAG_R_FEED, /* the textures still lack more than GDRAG_FEED_PX (paint_gdrag_feed) */
+ GDRAG_R_N };
+/* GDRAG_R_LAYER split by its cause, in gdrag_gate's order: no window or not wanted, not valid (painted whole
* next), being resized, being rendered, capture mode, another display's, transformed, the window or an
* ancestor raw or hidden, app holes in it, app surfaces in it, a colour above its alpha, no buffer, not
* under the root, another opacity, a part that would make it paint whole */
-enum { G0L_GONE, G0L_INVALID, G0L_RESIZE, G0L_RENDERING, G0L_CAPTURE, G0L_VIEW, G0L_TRANSFORM, G0L_RAW,
- G0L_HOLES, G0L_SURFACES, G0L_PREMUL, G0L_NOBUF, G0L_TREE, G0L_OPACITY, G0L_PART, G0L_N };
-typedef struct { long frames, strip_px, tried, refused[G0R_N], layer[G0L_N]; } G0Stats;
-void paint_g0_stats(G0Stats *s); /* since the last call */
-/* The last paint_root_* call: -1 G0 not tried (no copy used, or not a G0 call), 1 taken, 0 refused
- * (*why a G0R_*, *sub a G0L_* when it is G0R_LAYER, else -1) */
-int paint_g0_last(int *why, int *sub);
-/* G0's textures catching up (docs/GPU.md, "Uploads without a stall"): what of the layer and of the copy
+enum { GDRAG_L_GONE, GDRAG_L_INVALID, GDRAG_L_RESIZE, GDRAG_L_RENDERING, GDRAG_L_CAPTURE, GDRAG_L_VIEW, GDRAG_L_TRANSFORM, GDRAG_L_RAW,
+ GDRAG_L_HOLES, GDRAG_L_SURFACES, GDRAG_L_PREMUL, GDRAG_L_NOBUF, GDRAG_L_TREE, GDRAG_L_OPACITY, GDRAG_L_PART, GDRAG_L_N };
+typedef struct { long frames, strip_px, tried, refused[GDRAG_R_N], layer[GDRAG_L_N]; } GdragStats;
+void paint_gdrag_stats(GdragStats *s); /* since the last call */
+/* The last paint_root_* call: -1 GPU drag not tried (no copy used, or not a GPU drag call), 1 taken, 0 refused
+ * (*why a GDRAG_R_*, *sub a GDRAG_L_* when it is GDRAG_R_LAYER, else -1) */
+int paint_gdrag_last(int *why, int *sub);
+/* GPU drag's textures catching up (docs/GPU.md, "Uploads without a stall"): what of the layer and of the copy
* of what is below the GPU still lacks, in pixels (both; 0 nothing, or no layer on display view) */
-long paint_g0_backlog(int view);
+long paint_gdrag_backlog(int view);
/* Sends at most budget pixels of it, rectangles cut by rows, through up(ctx, which, px, w, h, r) (which:
* 0 the copy, 1 the layer; px w × h, stride w), and forgets what was sent. Each texture is asked first
* with an empty r. up returns 0 sent, 1 its texture held nothing of this (now it is ready for it: all of
- * it is needed again), -1 failed (stop). Only the display that has the layer (view), and only while G0
+ * it is needed again), -1 failed (stop). Only the display that has the layer (view), and only while GPU drag
* could use it. Returns the pixels sent. */
-long paint_g0_feed(int view, long budget, int (*up)(void *ctx, int which, const uint32_t *px, int w, int h, Rect r),
+long paint_gdrag_feed(int view, long budget, int (*up)(void *ctx, int which, const uint32_t *px, int w, int h, Rect r),
void *ctx);
Node *hit_test(Node *root, float x, float y);
/* Capture mode (media/capture.c): protected nodes are painted black and app windows
diff --git a/server/src/wl/wl.c b/server/src/wl/wl.c
index 4b2ff76..3e8897a 100644
--- a/server/src/wl/wl.c
+++ b/server/src/wl/wl.c
@@ -2144,7 +2144,7 @@ void wl_paint_restore(void) {
memcpy(ndraws, verify_n, sizeof ndraws);
}
-/* G0 (ui/paint.c): whether an app window noted so far for layer 0 is drawn into r (physical px of the
+/* GPU drag (ui/paint.c): whether an app window noted so far for layer 0 is drawn into r (physical px of the
* display being painted): its box as draw_surface gives it, one pixel more on each side for the
* filtering, cut by its clip. A window that is gone is not drawn. */
int wl_draws_meet(Rect r) {
diff --git a/server/tests/canvas_test.c b/server/tests/canvas_test.c
index a0f9817..158e7eb 100644
--- a/server/tests/canvas_test.c
+++ b/server/tests/canvas_test.c
@@ -1,7 +1,7 @@
/* canvas_test.c — the SIMD rows of canvas.c (NEON on ARM64, NEON=1) must give the same result,
* bit for bit, as the portable C ones. On x86-64 (no SIMD of its own) it compares C against C and also
* checks the exact division by 255 that the NEON version uses. See docs/RASPBERRY.md.
- * G0's shader in C (canvas_g0_model, docs/GPU.md "The dragged window on the GPU") must give blit_row's
+ * GPU drag's shader in C (canvas_gdrag_model, docs/GPU.md "The dragged window on the GPU") must give blit_row's
* pixel at k = 256 for every valid premultiplied source channel (c ≤ alpha) over every destination
* channel, and every source alpha over every destination alpha: checked exhaustively against both.
*
@@ -16,7 +16,7 @@
const char *canvas_test_simd(void);
void canvas_test_blit_row(int simd, uint32_t *row, const uint32_t *s, int n, uint32_t k);
void canvas_test_mask_row(int simd, uint32_t *row, const uint8_t *m, int n, uint32_t argb);
-uint32_t canvas_g0_model(uint32_t src, uint32_t dst);
+uint32_t canvas_gdrag_model(uint32_t src, uint32_t dst);
static uint32_t rng = 12345;
static uint32_t rnd(void) { rng ^= rng << 13; rng ^= rng >> 17; rng ^= rng << 5; return rng; }
@@ -70,10 +70,10 @@ int main(void) {
}
}
- /* G0's model against blit_row_c and the SIMD row, exhaustively: for every alpha a and colour c ≤ a,
+ /* GPU drag's model against blit_row_c and the SIMD row, exhaustively: for every alpha a and colour c ≤ a,
* a row of 256 destinations with every channel value d (all three channels, so each sum is checked
* on each), the destination alpha (7d + a) & 255 (every value once per a) */
- long g0cases = 0, g0bad = 0;
+ long gdragcases = 0, gdragbad = 0;
for (uint32_t a = 0; a < 256; a++)
for (uint32_t c = 0; c <= a; c++) {
static uint32_t gs[256], gd[256], gc[256], gn[256];
@@ -86,10 +86,10 @@ int main(void) {
canvas_test_blit_row(0, gc, gs, 256, 256);
canvas_test_blit_row(1, gn, gs, 256, 256);
for (int i = 0; i < 256; i++) {
- uint32_t m = canvas_g0_model(gs[i], gd[i]);
- g0cases++;
+ uint32_t m = canvas_gdrag_model(gs[i], gd[i]);
+ gdragcases++;
if (m != gc[i] || m != gn[i]) {
- if (g0bad++ < 10) printf("G0 model: src=%08x dst=%08x C=%08x SIMD=%08x model=%08x\n", gs[i], gd[i], gc[i], gn[i], m);
+ if (gdragbad++ < 10) printf("GPU drag model: src=%08x dst=%08x C=%08x SIMD=%08x model=%08x\n", gs[i], gd[i], gc[i], gn[i], m);
}
}
}
@@ -98,12 +98,12 @@ int main(void) {
uint32_t sp = premul(), dp = rnd(), cr = dp, nr = dp;
canvas_test_blit_row(0, &cr, &sp, 1, 256);
canvas_test_blit_row(1, &nr, &sp, 1, 256);
- uint32_t m = canvas_g0_model(sp, dp);
- g0cases++;
- if ((m != cr || m != nr) && g0bad++ < 10) printf("G0 model: src=%08x dst=%08x C=%08x SIMD=%08x model=%08x\n", sp, dp, cr, nr, m);
+ uint32_t m = canvas_gdrag_model(sp, dp);
+ gdragcases++;
+ if ((m != cr || m != nr) && gdragbad++ < 10) printf("GPU drag model: src=%08x dst=%08x C=%08x SIMD=%08x model=%08x\n", sp, dp, cr, nr, m);
}
- printf("canvas-test: G0 model: %ld cases, %ld differ\n", g0cases, g0bad);
- fails += (int)g0bad;
+ printf("canvas-test: GPU drag model: %ld cases, %ld differ\n", gdragcases, gdragbad);
+ fails += (int)gdragbad;
/* time for one 1920×1080 screen with each (not a test: it measures) */
static uint32_t big_s[1920], big_d[1920];
diff --git a/server/tests/engine_test.c b/server/tests/engine_test.c
index f4019fd..f457b75 100644
--- a/server/tests/engine_test.c
+++ b/server/tests/engine_test.c
@@ -61,7 +61,7 @@ void wl_paint_begin(void) { nwdraw = 0; }
void wl_paint_save(void) { nwsaved = nwdraw; memcpy(wsaved, wdraw, sizeof *wdraw * (size_t)nwdraw); }
void wl_paint_restore(void) { nwdraw = nwsaved; memcpy(wdraw, wsaved, sizeof *wdraw * (size_t)nwsaved); }
void wl_paint_popups(Canvas *c) { (void)c; }
-/* G0 (paint_root_g0): an app window in the list is drawn below the UI where its box is, as wl.c's */
+/* GPU drag (paint_root_gdrag): an app window in the list is drawn below the UI where its box is, as wl.c's */
int wl_draws_meet(Rect r) {
const float k = paint_view.k;
for (int i = 0; i < nwdraw; i++) {
@@ -1513,9 +1513,9 @@ static void test_overlay_scrollbar(void) {
* backdrop blur with one of those squares within its reach differed, in 2,386 of 2,417 frames (GPU
* path: 498,692 and 431,316 in 2,387), none anywhere else. "gpu" is the same run with
* gpu_active() on: paint.c's GPU path (the layer's sentinel, the app holes, no skipped nodes) on the
- * same CPU canvas the GPU uploads. "g0" is the GPU path with G0 (paint_root_g0, docs/GPU.md): a stub GPU
+ * same CPU canvas the GPU uploads. "gpu-drag" is the GPU path with GPU drag (paint_root_gdrag, docs/GPU.md): a stub GPU
* keeps the UI texture (what was uploaded of the canvas) and the layer's and the copy's textures (only
- * their dirty rectangles), and writes the window's rectangle with canvas_g0_model (gpu.c's shader in C);
+ * their dirty rectangles), and writes the window's rectangle with canvas_gdrag_model (gpu.c's shader in C);
* what it shows must hash as drag_golden_gpu.txt. Shorter runs cover what makes the layer paint again: a text
* that changes a child's size, a child moving inside the window, a terminal whose cursor blinks
* (damage from outside the tree), a square turning across the window's edge, the window crossing
@@ -1555,14 +1555,14 @@ enum { DW = 1024, DH = 640, DRAG_FRAMES = 480, CASE_FRAMES = 60, FULL_EVERY = 16
* "anc" the bar and the panel, with both windows in a rounded container that clips them and has a
* border (an ancestor painted around the dragged window); "tfgrow" the still square, and a dot on it
* that changes color every 20 frames (a part of the copy that cuts the square's image). */
-/* The runs after DC_N have no golden hashes: G0 (paint_root_g0) is compared with the GPU path itself
- * in them (test_g0_extra): "pause" stops the drag for 30 frames with nothing changing (frames with no UI
+/* The runs after DC_N have no golden hashes: GPU drag (paint_root_gdrag) is compared with the GPU path itself
+ * in them (test_gdrag_extra): "pause" stops the drag for 30 frames with nothing changing (frames with no UI
* damage, which only draw the window again on the GPU), "two" is the drag on two displays side by side
- * (the window crosses from one to the other: the layer, the copy and G0 follow the one with most of it),
+ * (the window crosses from one to the other: the layer, the copy and GPU drag follow the one with most of it),
* "app" drags over the window below with its app window, "ancedge" slowly away from the rounded,
* bordered container's top-left corner, "corner" over a rounded overflow:hidden box painted after the
* window that paints nothing itself (its corners' save and restore still change the pixels below). Their frames are compared as the GPU shows them: the app
- * windows below the UI texture, the UI blended over them, G0's rectangle written over both. */
+ * windows below the UI texture, the UI blended over them, GPU drag's rectangle written over both. */
enum { DC_DRAG, DC_TEXT, DC_CHILD, DC_TERM, DC_EDGE, DC_NEG, DC_REMOVE, DC_K2,
DC_BELOW, DC_AFTER, DC_BELOWTF, DC_BLUR, DC_ZRAISE, DC_MIX, DC_K2MIX, DC_ANC, DC_TFGROW, DC_N,
DC_PAUSE = DC_N, DC_TWO, DC_APP, DC_ANCEDGE, DC_CORNER, DC_ALL };
@@ -1585,29 +1585,29 @@ static int dc_hashes(void) { /* each run: its frames and
return n;
}
-/* G0 (test_g0): the frame as the GPU shows it. tex is the GPU's UI texture (what was uploaded of the
- * scene c), fb the composed frame: tex with the window's rectangle written by canvas_g0_model (gpu.c's
- * shader in C) from two textures that get only paint.c's dirty rectangles, as gpu.c's. g0on, g0w:
+/* GPU drag (test_gdrag): the frame as the GPU shows it. tex is the GPU's UI texture (what was uploaded of the
+ * scene c), fb the composed frame: tex with the window's rectangle written by canvas_gdrag_model (gpu.c's
+ * shader in C) from two textures that get only paint.c's dirty rectangles, as gpu.c's. gdrag_on, gdragw:
* main.c's bookkeeping of the scene's stale rectangle. */
typedef struct {
OutView v;
Canvas c, ref, fbc;
uint32_t *px, *rpx, *tex, *fb, *cmp;
- int g0on;
- Rect g0w;
- GpuG0 g;
+ int gdrag_on;
+ Rect gdragw;
+ GpuDrag g;
} DOut;
-static int test_g0;
+static int test_gdrag;
/* the frame pipeline (main.c, fpipe.h): each frame painted is presented only after the next frame's changes
* (the pointer, JS) are made, right before that frame is painted, as a frame prepared during a pending flip
* is submitted at the flip; its pixels must be the same */
static int test_pipe;
typedef struct { int on, taken, last, why; Rect pr; } DPend;
static DPend dpend[4];
-static struct { uint32_t *b, *l; int bw, bh, lw, lh, owner[2]; } g0tex; /* the stub GPU's G0 textures (owner: 0 the copy, 1 the layer) */
-static long g0_fed; /* pixels sent between frames (paint_g0_feed) */
-static long g0_whole; /* G0 frames that had to send a texture whole */
-static long g0_quads;
+static struct { uint32_t *b, *l; int bw, bh, lw, lh, owner[2]; } gdragtex; /* the stub GPU's GPU drag textures (owner: 0 the copy, 1 the layer) */
+static long gdrag_fed; /* pixels sent between frames (paint_gdrag_feed) */
+static long gdrag_whole; /* GPU drag frames that had to send a texture whole */
+static long gdrag_quads;
typedef struct { Node *root, *win, *spin, *edge, *child, *term, *caption, *below, *btitle, *fill, *mtext, *square, *ptext, *dot; } DScene;
static uint64_t frame_hash(const Canvas *c) {
@@ -1637,9 +1637,9 @@ static void copy_rect(uint32_t *dst, int dstride, const uint32_t *src, int sstri
}
/* The stub GPU's texture t (*tw × *th): all of px if its size changed, it was another display's or
- * full, else the dirty rectangles (gpu.c's g0_upload). */
-static long g0_frame_px, g0_frame_max; /* pixels the G0 frames sent: this one, the most one did */
-static void g0_tex_up(uint32_t **t, int *tw, int *th, const uint32_t *px, int w, int h, const Rect *r, int n, int full) {
+ * full, else the dirty rectangles (gpu.c's gdrag_upload). */
+static long gdrag_frame_px, gdrag_frame_max; /* pixels the GPU drag frames sent: this one, the most one did */
+static void gdrag_tex_up(uint32_t **t, int *tw, int *th, const uint32_t *px, int w, int h, const Rect *r, int n, int full) {
if (*tw != w || *th != h) {
free(*t);
*t = malloc((size_t)w * h * 4);
@@ -1648,20 +1648,20 @@ static void g0_tex_up(uint32_t **t, int *tw, int *th, const uint32_t *px, int w,
full = 1;
}
if (!*t) return;
- if (full) { memcpy(*t, px, (size_t)w * h * 4); g0_frame_px += (long)w * h; return; }
+ if (full) { memcpy(*t, px, (size_t)w * h * 4); gdrag_frame_px += (long)w * h; return; }
for (int i = 0; i < n; i++) {
Rect q = { r[i].x0 < 0 ? 0 : r[i].x0, r[i].y0 < 0 ? 0 : r[i].y0, r[i].x1 > w ? w : r[i].x1, r[i].y1 > h ? h : r[i].y1 };
- if (q.x1 > q.x0 && q.y1 > q.y0) { copy_rect(*t, w, px, w, q); g0_frame_px += (long)(q.x1 - q.x0) * (q.y1 - q.y0); }
+ if (q.x1 > q.x0 && q.y1 > q.y0) { copy_rect(*t, w, px, w, q); gdrag_frame_px += (long)(q.x1 - q.x0) * (q.y1 - q.y0); }
}
}
-/* gpu.c's gpu_g0_feed on the stub GPU (ctx: the display's index): a texture that is not this display's
+/* gpu.c's gpu_gdrag_feed on the stub GPU (ctx: the display's index): a texture that is not this display's
* at this size is made again, filled with a pattern no frame has (so a pixel the feed missed shows) */
-static int g0_tex_feed(void *ctx, int which, const uint32_t *px, int w, int h, Rect r) {
+static int gdrag_tex_feed(void *ctx, int which, const uint32_t *px, int w, int h, Rect r) {
int index = *(const int *)ctx;
- uint32_t **t = which ? &g0tex.l : &g0tex.b;
- int *tw = which ? &g0tex.lw : &g0tex.bw, *th = which ? &g0tex.lh : &g0tex.bh;
- if (g0tex.owner[which] != index || *tw != w || *th != h) {
+ uint32_t **t = which ? &gdragtex.l : &gdragtex.b;
+ int *tw = which ? &gdragtex.lw : &gdragtex.bw, *th = which ? &gdragtex.lh : &gdragtex.bh;
+ if (gdragtex.owner[which] != index || *tw != w || *th != h) {
if (*tw != w || *th != h) {
free(*t);
*t = malloc((size_t)w * h * 4);
@@ -1670,67 +1670,67 @@ static int g0_tex_feed(void *ctx, int which, const uint32_t *px, int w, int h, R
if (!*t) return -1;
for (size_t i = 0; i < (size_t)w * h; i++) (*t)[i] = 0x7f13ff13u;
}
- g0tex.owner[which] = index;
+ gdragtex.owner[which] = index;
return 1;
}
Rect q = { r.x0 < 0 ? 0 : r.x0, r.y0 < 0 ? 0 : r.y0, r.x1 > w ? w : r.x1, r.y1 > h ? h : r.y1 };
if (q.x1 > q.x0 && q.y1 > q.y0) {
copy_rect(*t, w, px, w, q);
- g0_fed += (long)(q.x1 - q.x0) * (q.y1 - q.y0);
+ gdrag_fed += (long)(q.x1 - q.x0) * (q.y1 - q.y0);
}
return 0;
}
/* main.c's presentation on the GPU (render_frame, gpu_frame_ex): the painted rectangles (pr, or the
- * strips) go to the UI texture; with G0 the two textures get their dirty rectangles and the window is
+ * strips) go to the UI texture; with GPU drag the two textures get their dirty rectangles and the window is
* written over the texture's stale rectangle in the composed frame. A frame refused only for what the
- * textures lack (G0R_FEED) then sends a slice of it (paint_g0_feed), as main.c does after queueing the flip. */
-static void g0_present(DOut *o, int index, Rect pr, int taken, int last, int why) {
+ * textures lack (GDRAG_R_FEED) then sends a slice of it (paint_gdrag_feed), as main.c does after queueing the flip. */
+static void gdrag_present(DOut *o, int index, Rect pr, int taken, int last, int why) {
int W = o->c.w, H = o->c.h;
if (!taken) {
copy_rect(o->tex, W, o->c.px, o->c.stride, pr);
- if (last == 0 && why == G0R_FEED && paint_g0_backlog(index) > 0)
- paint_g0_feed(index, G0_FEED_PX, g0_tex_feed, &index);
+ if (last == 0 && why == GDRAG_R_FEED && paint_gdrag_backlog(index) > 0)
+ paint_gdrag_feed(index, GDRAG_FEED_PX, gdrag_tex_feed, &index);
} else {
- const GpuG0 *g = &o->g;
+ const GpuDrag *g = &o->g;
for (int i = 0; i < g->nstrip; i++) copy_rect(o->tex, W, o->c.px, o->c.stride, g->strip[i]);
- /* paint.c sent the rest first: a G0 frame never has more than G0_FEED_PX left */
+ /* paint.c sent the rest first: a GPU drag frame never has more than GDRAG_FEED_PX left */
long left = 0;
if (g->bfull) left += (long)g->bw * g->bh;
else for (int i = 0; i < g->nb; i++) left += (long)(g->bdirty[i].x1 - g->bdirty[i].x0) * (g->bdirty[i].y1 - g->bdirty[i].y0);
- CHECK(left <= G0_FEED_PX, "a G0 frame with %ld px of the copy left to send", left);
- int bother = g0tex.owner[0] != index, lother = g0tex.owner[1] != index;
- if (bother || lother || g->bfull || g->lfull) g0_whole++;
- g0_tex_up(&g0tex.b, &g0tex.bw, &g0tex.bh, g->bpx, g->bw, g->bh, g->bdirty, g->nb, g->bfull || bother);
- g0_tex_up(&g0tex.l, &g0tex.lw, &g0tex.lh, g->lpx, g->lw, g->lh, g->ldirty, g->nl, g->lfull || lother);
- g0tex.owner[0] = g0tex.owner[1] = index;
- if (g0_frame_px > g0_frame_max) g0_frame_max = g0_frame_px;
- g0_frame_px = 0;
- paint_g0_done();
- g0_quads++;
+ CHECK(left <= GDRAG_FEED_PX, "a GPU drag frame with %ld px of the copy left to send", left);
+ int bother = gdragtex.owner[0] != index, lother = gdragtex.owner[1] != index;
+ if (bother || lother || g->bfull || g->lfull) gdrag_whole++;
+ gdrag_tex_up(&gdragtex.b, &gdragtex.bw, &gdragtex.bh, g->bpx, g->bw, g->bh, g->bdirty, g->nb, g->bfull || bother);
+ gdrag_tex_up(&gdragtex.l, &gdragtex.lw, &gdragtex.lh, g->lpx, g->lw, g->lh, g->ldirty, g->nl, g->lfull || lother);
+ gdragtex.owner[0] = gdragtex.owner[1] = index;
+ if (gdrag_frame_px > gdrag_frame_max) gdrag_frame_max = gdrag_frame_px;
+ gdrag_frame_px = 0;
+ paint_gdrag_done();
+ gdrag_quads++;
}
memcpy(o->fb, o->tex, (size_t)W * H * 4);
if (taken) {
- const GpuG0 *g = &o->g;
+ const GpuDrag *g = &o->g;
for (int y = g->w.y0; y < g->w.y1; y++)
for (int x = g->w.x0; x < g->w.x1; x++)
- o->fb[(size_t)y * W + x] = canvas_g0_model(g0tex.l[(size_t)(y - g->ly) * g0tex.lw + (x - g->lx)],
- g0tex.b[(size_t)y * g0tex.bw + x]);
- o->g0w = g->w;
+ o->fb[(size_t)y * W + x] = canvas_gdrag_model(gdragtex.l[(size_t)(y - g->ly) * gdragtex.lw + (x - g->lx)],
+ gdragtex.b[(size_t)y * gdragtex.bw + x]);
+ o->gdragw = g->w;
}
- o->g0on = taken;
+ o->gdrag_on = taken;
}
/* One display's paint_out (the damaged box in physical px, cleared and painted with paint_root_clear;
- * with G0, main.c's paint_out and render_frame: the stale rectangle joins the damage, a display with no
- * damage keeps its frame, unless the G0 textures are another display's) */
+ * with GPU drag, main.c's paint_out and render_frame: the stale rectangle joins the damage, a display with no
+ * damage keeps its frame, unless the GPU drag textures are another display's) */
static void drag_paint_out(Node *root, DOut *o, int index, Box d) {
int empty = d.x1 <= d.x0 || d.y1 <= d.y0;
- if (test_g0 && o->g0on) {
+ if (test_gdrag && o->gdrag_on) {
float gx0, gy0, gx1, gy1;
- out_logical_box(&o->v, o->g0w, &gx0, &gy0, &gx1, &gy1);
+ out_logical_box(&o->v, o->gdragw, &gx0, &gy0, &gx1, &gy1);
if (!empty) d = (Box){ fminf(d.x0, gx0), fminf(d.y0, gy0), fmaxf(d.x1, gx1), fmaxf(d.y1, gy1) };
- else if (g0tex.owner[0] != index || g0tex.owner[1] != index) { d = (Box){ gx0, gy0, gx1, gy1 }; o->g0on = 0; } /* g0_stale */
+ else if (gdragtex.owner[0] != index || gdragtex.owner[1] != index) { d = (Box){ gx0, gy0, gx1, gy1 }; o->gdrag_on = 0; } /* gdrag_stale */
/* else: drawn again from the textures, the frame stays as it is */
}
if (d.x1 <= d.x0 || d.y1 <= d.y0) return;
@@ -1742,15 +1742,15 @@ static void drag_paint_out(Node *root, DOut *o, int index, Box d) {
ui.damage = (Box){ lx0, ly0, lx1, ly1 };
canvas_set_clip(&o->c, pr);
int taken = 0;
- if (test_g0) taken = paint_root_g0(&o->c, root, &o->g);
+ if (test_gdrag) taken = paint_root_gdrag(&o->c, root, &o->g);
else paint_root_clear(&o->c, root, 0x000000);
canvas_set_clip(&o->c, (Rect){ 0, 0, o->c.w, o->c.h });
ui.damage = (Box){ 0, 0, 0, 0 };
paint_view = (PaintView){ 0, 0, 1, 0, 0, 0 };
- if (!test_g0) return;
- int why, sub, last = paint_g0_last(&why, &sub);
+ if (!test_gdrag) return;
+ int why, sub, last = paint_gdrag_last(&why, &sub);
if (test_pipe && index < 4) dpend[index] = (DPend){ 1, taken, last, why, pr };
- else g0_present(o, index, pr, taken, last, why);
+ else gdrag_present(o, index, pr, taken, last, why);
}
/* the frame pipeline: the frames painted are presented now (main.c's out_submit) */
@@ -1758,7 +1758,7 @@ static void drag_present(DOut *const *os, int n) {
for (int i = 0; i < n && i < 4; i++)
if (dpend[i].on) {
dpend[i].on = 0;
- g0_present(os[i], i, dpend[i].pr, dpend[i].taken, dpend[i].last, dpend[i].why);
+ gdrag_present(os[i], i, dpend[i].pr, dpend[i].taken, dpend[i].last, dpend[i].why);
}
}
@@ -1794,7 +1794,7 @@ static long drag_full_diff(Node *root, DOut *o, int *worst) {
paint_view = (PaintView){ 0, 0, 1, 0, 0, 0 };
term_at = keep;
long n = 0;
- const uint32_t *px = test_g0 ? o->fb : o->px; /* G0: the frame as shown */
+ const uint32_t *px = test_gdrag ? o->fb : o->px; /* GPU drag: the frame as shown */
for (size_t i = 0; i < (size_t)o->c.w * o->c.h; i++) {
if (px[i] == o->rpx[i]) continue;
n++;
@@ -1983,7 +1983,7 @@ static DScene drag_scene(int dc, float x, float y) {
sn(dock, "backdropBlur", 20);
for (int i = 0; i < 6; i++) dview(dock, 48, 48, accents[i], 12);
/* pause: 300 more nodes painted after the window, each in its own box below the Dock (LordOS's real
- * menu bar and Dock are a few hundred; G0's list of them once held 128 and refused every frame) */
+ * menu bar and Dock are a few hundred; GPU drag's list of them once held 128 and refused every frame) */
if (dc == DC_PAUSE) for (int i = 0; i < 300; i++) box_in(dockl, 12 + 3 * i, DH - 6, 2, 2, accents[i % 6]);
ss(dock, "flexDirection", "row"); ss(dock, "alignItems", "center"); ss(dock, "justifyContent", "center");
sn(dock, "gap", 12);
@@ -1999,12 +1999,12 @@ static DScene drag_scene(int dc, float x, float y) {
}
/* What the GPU shows (test_compose): the app windows of the list (a solid colour each) below the UI
- * texture, the texture blended over them (ONE, ONE_MINUS_SRC_ALPHA, rounded), and with G0 the window's
+ * texture, the texture blended over them (ONE, ONE_MINUS_SRC_ALPHA, rounded), and with GPU drag the window's
* rectangle written over both (blending off: its colour, opaque). */
static int test_compose;
static uint64_t composed_hash(DOut *o) {
int W = o->c.w, H = o->c.h;
- const uint32_t *t = test_g0 ? o->tex : o->c.px; /* without G0 every painted pixel was uploaded */
+ const uint32_t *t = test_gdrag ? o->tex : o->c.px; /* without GPU drag every painted pixel was uploaded */
uint32_t *f = o->cmp;
memset(f, 0, (size_t)W * H * 4);
const float k = (float)o->v.k;
@@ -2023,19 +2023,19 @@ static uint64_t composed_hash(DOut *o) {
}
f[i] = o2;
}
- if (test_g0 && o->g0on)
- for (int y = o->g0w.y0; y < o->g0w.y1; y++)
- for (int x = o->g0w.x0; x < o->g0w.x1; x++) f[(size_t)y * W + x] = 0xff000000u | (o->fb[(size_t)y * W + x] & 0xffffff);
+ if (test_gdrag && o->gdrag_on)
+ for (int y = o->gdragw.y0; y < o->gdragw.y1; y++)
+ for (int x = o->gdragw.x0; x < o->gdragw.x1; x++) f[(size_t)y * W + x] = 0xff000000u | (o->fb[(size_t)y * W + x] & 0xffffff);
Canvas c;
canvas_init(&c, f, W, H, W);
return frame_hash(&c);
}
-/* The hash of what the displays show (with G0, the composed frames) */
+/* The hash of what the displays show (with GPU drag, the composed frames) */
static uint64_t outs_hash(DOut *const *os, int nos) {
uint64_t h = 0;
for (int i = 0; i < nos; i++)
- h = h * 1099511628211ull ^ (test_compose ? composed_hash(os[i]) : frame_hash(test_g0 ? &os[i]->fbc : &os[i]->c));
+ h = h * 1099511628211ull ^ (test_compose ? composed_hash(os[i]) : frame_hash(test_gdrag ? &os[i]->fbc : &os[i]->c));
return h;
}
@@ -2057,16 +2057,16 @@ static void drag_run_n(int dc, DOut *const *os, int nos, uint64_t *hash, long *f
for (int i = 0; i < nos; i++) {
canvas_set_clip(&os[i]->c, (Rect){ 0, 0, os[i]->c.w, os[i]->c.h });
canvas_clear(&os[i]->c, 0x000000);
- os[i]->g0on = 0;
+ os[i]->gdrag_on = 0;
}
- g0tex.owner[0] = g0tex.owner[1] = -1;
+ gdragtex.owner[0] = gdragtex.owner[1] = -1;
damage_add((Box){ 0, 0, DW, DH });
ui.dirty = 1;
drag_paint_n(s.root, os, nos);
drag_present(os, nos);
paint_layer_begin(s.win->id, 0); /* grab.c's setup */
float gx = x0, gy = y0, rot = 0;
- unsigned pipe_epoch = paint_g0_epoch();
+ unsigned pipe_epoch = paint_gdrag_epoch();
*full = 0;
*worst = 0;
for (int f = 0; f < n; f++) {
@@ -2112,12 +2112,12 @@ static void drag_run_n(int dc, DOut *const *os, int nos, uint64_t *hash, long *f
}
if (test_pipe) {
/* the frame before is submitted only now, after this frame's changes: they must not touch what it
- * hands the GPU (paint_g0_epoch, else main.c paints it again) */
- CHECK(paint_g0_epoch() == pipe_epoch, "pipelined: frame %d's changes moved G0's epoch", f);
+ * hands the GPU (paint_gdrag_epoch, else main.c paints it again) */
+ CHECK(paint_gdrag_epoch() == pipe_epoch, "pipelined: frame %d's changes moved GPU drag's epoch", f);
drag_present(os, nos);
if (f) hash[f - 1] = outs_hash(os, nos);
drag_paint_n(s.root, os, nos);
- pipe_epoch = paint_g0_epoch();
+ pipe_epoch = paint_gdrag_epoch();
continue; /* (a full repaint now would be of the next frame's tree) */
}
drag_paint_n(s.root, os, nos);
@@ -2128,9 +2128,9 @@ static void drag_run_n(int dc, DOut *const *os, int nos, uint64_t *hash, long *f
drag_present(os, nos);
hash[n - 1] = outs_hash(os, nos);
}
- unsigned before_end = paint_g0_epoch();
+ unsigned before_end = paint_gdrag_epoch();
paint_layer_end(); /* grab_finish */
- CHECK(paint_g0_epoch() != before_end, "the drag's end moves G0's epoch (a prepared G0 frame is painted again)");
+ CHECK(paint_gdrag_epoch() != before_end, "the drag's end moves GPU drag's epoch (a prepared GPU drag frame is painted again)");
ui.dirty = 1;
drag_paint_n(s.root, os, nos);
drag_present(os, nos);
@@ -2216,28 +2216,28 @@ static int dout_init(DOut *o, OutView v) {
}
static void dout_free(DOut *o) { free(o->px); free(o->rpx); free(o->tex); free(o->fb); free(o->cmp); }
-/* G0's frames counted since the last call, printed for a run (some_g0: at least one is expected) */
-static void g0_report(const char *what, int some_g0) {
- G0Stats g;
- paint_g0_stats(&g);
- printf("drag-exact %s: G0 composed %ld of %ld frames that used the copy (%ld presented), strips %ld px "
+/* GPU drag's frames counted since the last call, printed for a run (some_gdrag: at least one is expected) */
+static void gdrag_report(const char *what, int some_gdrag) {
+ GdragStats g;
+ paint_gdrag_stats(&g);
+ printf("drag-exact %s: GPU drag composed %ld of %ld frames that used the copy (%ld presented), strips %ld px "
"(not: %ld layer, %ld clip, %ld ancestor, %ld app, %ld after, %ld post, %ld catching up); %ld px sent between "
- "frames, %ld G0 frames sent a texture whole, the most one G0 frame sent %ld px\n", what, g.frames, g.tried, g0_quads,
- g.strip_px, g.refused[G0R_LAYER], g.refused[G0R_CLIP], g.refused[G0R_ANCESTOR], g.refused[G0R_APP],
- g.refused[G0R_AFTER], g.refused[G0R_POST], g.refused[G0R_FEED], g0_fed, g0_whole, g0_frame_max);
- CHECK((g.frames > 0 || !some_g0) && g.frames == g0_quads, "drag-exact %s: G0 frames %ld, presented %ld", what, g.frames,
- g0_quads);
- g0_quads = g0_fed = g0_whole = g0_frame_max = 0;
+ "frames, %ld GPU drag frames sent a texture whole, the most one GPU drag frame sent %ld px\n", what, g.frames, g.tried, gdrag_quads,
+ g.strip_px, g.refused[GDRAG_R_LAYER], g.refused[GDRAG_R_CLIP], g.refused[GDRAG_R_ANCESTOR], g.refused[GDRAG_R_APP],
+ g.refused[GDRAG_R_AFTER], g.refused[GDRAG_R_POST], g.refused[GDRAG_R_FEED], gdrag_fed, gdrag_whole, gdrag_frame_max);
+ CHECK((g.frames > 0 || !some_gdrag) && g.frames == gdrag_quads, "drag-exact %s: GPU drag frames %ld, presented %ld", what, g.frames,
+ gdrag_quads);
+ gdrag_quads = gdrag_fed = gdrag_whole = gdrag_frame_max = 0;
}
-/* The runs without golden hashes (pause, two displays): G0 must show what the GPU path shows, frame by
+/* The runs without golden hashes (pause, two displays): GPU drag must show what the GPU path shows, frame by
* frame (that path is the one the golden hashes check in the other runs). */
-static void test_g0_extra(void) {
+static void test_gdrag_extra(void) {
DOut a, b, c;
int ok = dout_init(&a, out_view(0, 0, DW, DH, 100)) && dout_init(&b, out_view(0, 0, DW / 2, DH, 100)) &&
dout_init(&c, out_view(DW / 2, 0, DW / 2, DH, 100));
uint64_t *h0 = malloc(sizeof *h0 * 1024), *h1 = malloc(sizeof *h1 * 1024);
- if (!ok || !h0 || !h1) { CHECK(0, "g0-extra: out of memory"); goto done; }
+ if (!ok || !h0 || !h1) { CHECK(0, "gpu-drag-extra: out of memory"); goto done; }
for (int dc = DC_N; dc < DC_ALL; dc++) {
DOut *two[2] = { &b, &c }, *one[1] = { &a };
DOut *const *os = dc == DC_TWO ? two : one;
@@ -2245,23 +2245,23 @@ static void test_g0_extra(void) {
long full;
int worst;
test_gpu = 1;
- test_g0 = 0;
+ test_gdrag = 0;
test_compose = nos == 1;
drag_run_n(dc, os, nos, h0, &full, &worst);
- test_g0 = 1;
- G0Stats st;
- paint_g0_stats(&st);
- g0_quads = 0;
+ test_gdrag = 1;
+ GdragStats st;
+ paint_gdrag_stats(&st);
+ gdrag_quads = 0;
drag_run_n(dc, os, nos, h1, &full, &worst);
- test_g0 = test_compose = 0;
+ test_gdrag = test_compose = 0;
int bad = 0, first = -1;
for (int f = 0; f <= dc_frames[dc]; f++) if (h0[f] != h1[f]) { if (first < 0) first = f; bad++; }
char what[32];
- snprintf(what, sizeof what, "g0 %s", dc_name[dc]);
- /* corner: the box is in every frame's damage, so G0 refuses them all (without that refusal the
+ snprintf(what, sizeof what, "gpu-drag %s", dc_name[dc]);
+ /* corner: the box is in every frame's damage, so GPU drag refuses them all (without that refusal the
* frames differ from the GPU path) */
- g0_report(what, dc != DC_CORNER);
- CHECK(!bad, "drag-exact g0, run %s: %d of %d frames differ from the GPU path (the first: frame %d)", dc_name[dc], bad,
+ gdrag_report(what, dc != DC_CORNER);
+ CHECK(!bad, "drag-exact gpu-drag, run %s: %d of %d frames differ from the GPU path (the first: frame %d)", dc_name[dc], bad,
dc_frames[dc] + 1, first);
}
done:
@@ -2271,7 +2271,7 @@ done:
}
static void test_drag_exact(int write) {
- static const char *const variant[4] = { "cpu", "gpu", "g0", "g0 pipelined" };
+ static const char *const variant[4] = { "cpu", "gpu", "gpu-drag", "gpu-drag pipelined" };
DOut o, o2; /* the display at 100 %, and at 200 % (DC_K2) */
int ok = dout_init(&o, out_view(0, 0, DW, DH, 100));
ok = dout_init(&o2, out_view(0, 0, 2 * DW, 2 * DH, 200)) && ok;
@@ -2281,11 +2281,11 @@ static void test_drag_exact(int write) {
dout_free(&o); dout_free(&o2); free(hash);
return;
}
- /* g0: the GPU path with G0 (the window composited by canvas_g0_model), against the GPU's hashes */
- /* g0 pipelined: the same, each frame presented after the next frame's changes (the frame pipeline) */
+ /* gpu-drag: the GPU path with GPU drag (the window composited by canvas_gdrag_model), against the GPU's hashes */
+ /* gpu-drag pipelined: the same, each frame presented after the next frame's changes (the frame pipeline) */
for (int g = 0; g < (write ? 2 : 4); g++) {
test_gpu = g > 0;
- test_g0 = g >= 2;
+ test_gdrag = g >= 2;
test_pipe = g == 3;
char path[64];
snprintf(path, sizeof path, "tests/drag_golden_%s.txt", variant[g >= 2 ? 1 : g]);
@@ -2298,10 +2298,10 @@ static void test_drag_exact(int write) {
BelowStats bs;
paint_below_stats(&bs);
paint_below_bad = paint_below_checked = 0;
- paint_below_verify = !test_g0; /* G0's frames leave the window to the GPU: the hashes check them */
- G0Stats g0s;
- paint_g0_stats(&g0s);
- g0_quads = 0;
+ paint_below_verify = !test_gdrag; /* GPU drag's frames leave the window to the GPU: the hashes check them */
+ GdragStats gdrags;
+ paint_gdrag_stats(&gdrags);
+ gdrag_quads = 0;
if (getenv("LORD_BELOW_SWITCH")) paint_below_switch = atoi(getenv("LORD_BELOW_SWITCH"));
for (int dc = 0; dc < DC_N; dc++) {
drag_run(dc, dc_k2(dc) ? &o2 : &o, hash + k, &fullw[dc], &worst[dc]);
@@ -2317,10 +2317,10 @@ static void test_drag_exact(int write) {
"%ld blur, %ld transform, %ld unreached, %ld cost), %ld pixels differ in %ld of them painted the old way\n",
variant[g], bs.full, bs.part, bs.switched, bs.refused[BR_ANCESTOR], bs.refused[BR_BLUR], bs.refused[BR_TRANSFORM],
bs.refused[BR_UNREACHED], bs.refused[BR_COST], paint_below_bad, paint_below_checked);
- if (!test_g0)
+ if (!test_gdrag)
CHECK(!paint_below_bad && paint_below_checked == bs.switched, "drag-exact %s: frames switched to the copy of what is below "
"differ from painting everything: %ld pixels in %ld frames", variant[g], paint_below_bad, paint_below_checked);
- else g0_report(variant[g], 1);
+ else gdrag_report(variant[g], 1);
printf("drag-exact %s: most pixels differing from a full repaint (largest difference):", variant[g]);
for (int dc = 0; dc < DC_N; dc++) printf(" %s %ld (%d)", dc_name[dc], fullw[dc], worst[dc]);
printf("\n");
@@ -2347,11 +2347,11 @@ static void test_drag_exact(int write) {
}
free(file);
}
- test_gpu = test_g0 = test_pipe = 0;
+ test_gpu = test_gdrag = test_pipe = 0;
dout_free(&o);
dout_free(&o2);
free(hash);
- if (!write) test_g0_extra();
+ if (!write) test_gdrag_extra();
}
/* ---- The corners of a dragged window ----
diff --git a/server/tests/lordbench_test.c b/server/tests/lordbench_test.c
index 210047d..d3ab3ea 100644
--- a/server/tests/lordbench_test.c
+++ b/server/tests/lordbench_test.c
@@ -205,7 +205,7 @@ int main(void) {
/* on time: woke 0.1 ms after a flip, render 0.5 ms later for 9 ms, queued at 10 ms, GPU done at 12, shown at the next vblank */
LbPhase a = { .prev_flip = F0, .wake = F0 + 100000, .from_flip = 1, .render0 = F0 + 600000, .built = F0 + 9600000,
.paint_ms = 6, .up_ms = 2, .swap_ms = 0.1, .submit_ms = 0.2, .up_px = 1000, .submit = F0 + 10000000,
- .period = (uint32_t)P, .par = 1, .g0 = 1 };
+ .period = (uint32_t)P, .par = 1, .gdrag = 1 };
lbf_phase_built(&a);
lbf_phase_shown(F0 + P, F0 + 12000000);
/* CPU-late: queued 18 ms after that flip, past the next vblank */
@@ -216,9 +216,9 @@ int main(void) {
b.built = b.wake + 17000000;
b.submit = b.wake + 18000000;
b.par = 0;
- b.g0 = 0;
- b.g0_why = 0; /* G0R_LAYER, G0L_INVALID */
- b.g0_sub = 1;
+ b.gdrag = 0;
+ b.gdrag_why = 0; /* GDRAG_R_LAYER, GDRAG_L_INVALID */
+ b.gdrag_sub = 1;
lbf_phase_built(&b);
lbf_phase_shown(F0 + 3 * P, b.submit + 2000000);
/* GPU-late: queued at 12 ms, the GPU finished at 17, past the vblank at 16.7 */
@@ -228,9 +228,9 @@ int main(void) {
c.render0 = c.wake + 500000;
c.built = c.wake + 11000000;
c.submit = c.prev_flip + 12000000;
- c.g0 = 0;
- c.g0_why = 6; /* G0R_FEED */
- c.g0_sub = -1;
+ c.gdrag = 0;
+ c.gdrag_why = 6; /* GDRAG_R_FEED */
+ c.gdrag_sub = -1;
c.unshown = 0;
c.feed_ms = 1.5;
c.feed_px = 262144;
@@ -240,7 +240,7 @@ int main(void) {
LbPhase d = a;
d.submit = 0;
d.unshown = 1;
- d.g0 = -1;
+ d.gdrag = -1;
lbf_phase_built(&d);
lbf_phase_shown(F0 + 6 * P, 0); /* a flip of something else: nothing waits for it */
lbf_drag_end(&ps);
@@ -253,16 +253,16 @@ int main(void) {
CHECK(fabs(ps.build.p50 - 10.5) < 1e-3 && fabs(ps.build.p99 - 16.5) < 1e-3, "render %f/%f", ps.build.p50, ps.build.p99);
CHECK(fabs(ps.gpu.p50 - 2) < 1e-3 && fabs(ps.gpu.p99 - 5) < 1e-3, "GPU %f/%f", ps.gpu.p50, ps.gpu.p99);
CHECK(fabs(ps.wait.p50 - 13.233333) < 1e-3 && fabs(ps.wait.p99 - 16.333333) < 1e-3, "to the vblank %f/%f", ps.wait.p50, ps.wait.p99);
- CHECK(ps.par == 3 && ps.g0_tried == 3 && ps.g0_taken == 1 && ps.g0_refused[0] == 1 && ps.g0_layer[1] == 1 &&
- ps.g0_refused[6] == 1 && ps.unshown == 1, "counts: par %d, G0 %d of %d, refused %d %d (%d), unshown %d", ps.par,
- ps.g0_taken, ps.g0_tried, ps.g0_refused[0], ps.g0_refused[6], ps.g0_layer[1], ps.unshown);
+ CHECK(ps.par == 3 && ps.gdrag_tried == 3 && ps.gdrag_taken == 1 && ps.gdrag_refused[0] == 1 && ps.gdrag_layer[1] == 1 &&
+ ps.gdrag_refused[6] == 1 && ps.unshown == 1, "counts: par %d, GPU drag %d of %d, refused %d %d (%d), unshown %d", ps.par,
+ ps.gdrag_taken, ps.gdrag_tried, ps.gdrag_refused[0], ps.gdrag_refused[6], ps.gdrag_layer[1], ps.unshown);
CHECK(fabs(ps.feed_mpx - 262144 / 4.0 / 1e6) < 1e-9 && fabs(ps.feed.p99 - 1.5) < 1e-6, "catch-up %f Mpx %f ms", ps.feed_mpx, ps.feed.p99);
char pt[1536];
lbf_phases_text(&ps, pt, sizeof pt);
CHECK(strstr(pt, "CPU-late 1") && strstr(pt, "not layer 1 [invalid 1]") && strstr(pt, "not feed 1") && strstr(pt, "unshown 1"),
"phases text: %s", pt);
- CHECK(!strcmp(lbf_g0r_name(6), "feed") && !lbf_g0r_name(7) && !lbf_g0r_name(-1) && !strcmp(lbf_g0l_name(14), "part") &&
- !lbf_g0l_name(15), "G0 names");
+ CHECK(!strcmp(lbf_gdrag_r_name(6), "feed") && !lbf_gdrag_r_name(7) && !lbf_gdrag_r_name(-1) && !strcmp(lbf_gdrag_l_name(14), "part") &&
+ !lbf_gdrag_l_name(15), "GPU drag names");
char small[16];
lbf_phases_text(&ps, small, sizeof small);
CHECK(strlen(small) == 15, "a short buffer is cut, terminated");
@@ -277,7 +277,7 @@ int main(void) {
/* a frame the pipeline prepared: painted during the flip before (12 ms), held until that flip, submitted
* at it in 2 ms and shown at the next vblank: on time, its build is both parts */
LbPhase e = { .piped = 1, .prev_flip = F0 + 7 * P, .wake = F0 + 6 * P + 100000, .from_flip = 1, .period = (uint32_t)P,
- .paint_ms = 10, .g0 = -1, .g0_why = -1, .g0_sub = -1 };
+ .paint_ms = 10, .gdrag = -1, .gdrag_why = -1, .gdrag_sub = -1 };
e.pre_end = e.wake + 300000;
e.render0 = e.pre_end + 200000;
e.built = e.render0 + 12000000;