From 819778f292ee4e1294603b98662e083e49e23463 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 19:52:05 +0200 Subject: rsnix v0.5.0: graphics layer + cursor compositor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first visible GUI surface: real rect primitives, a single shadow→display push path, and an on-screen mouse cursor that can never race the text surface. gop: - fill_rect + push_rect(x,y,w,h): every raster op rasterises into the RAM shadow, then push_rect copies the rect to the display (write-only, still never read) and composites the cursor on top. blit_glyph and scroll shifts now route through it. - cursor overlay: 12x16 pointer (const-fn built from column lists) drawn white with a black offset outline; position in one AtomicU64 (x:high 32, y:low 32) — unpack masks the low word (a bare 'as usize' cast is a no-op on 64-bit). The cursor never enters the shadow, so erasing is just a shadow push of the old rect. - cursor_redraw after scroll shifts and once at spawn (the vt diff never re-blits idle cells). cursor task (task 2, spawned at boot when a mouse is present): - owns the PS/2 ring; polls every 10 ms, moves the cursor (clamped), tracks buttons, and forwards every event to a task's queue when 'mouse ' armed it (the window-manager input path). - /dev/mouse is now a position device (x/y/buttons snapshot); 'mouse' watches the cursor live (prints on change); 'cursor' prints one-shot state; 'gfx' draws a status-bar demo; 'gfx check' is an in-kernel pixel self-test (shadow readback, display readback, cursor overlay purity) — PASS/FAIL per stage. Tests (headless QEMU + monitor injection): - make test-gfx (new): all four compositor checks PASS. - make test-mouse (rewritten): cursor tracks mouse_move deltas, buttons ride along, /dev/mouse snapshot, live watch, real-event queue routing. - make test-msg: task numbering shifted (cursor is task 2; msgrecv is task 3) — updated, still PASS. - make test-disk regression re-passes. 0 build warnings. --- scripts/test-gfx.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100755 scripts/test-gfx.sh (limited to 'scripts/test-gfx.sh') diff --git a/scripts/test-gfx.sh b/scripts/test-gfx.sh new file mode 100755 index 0000000..a6e4016 --- /dev/null +++ b/scripts/test-gfx.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# +# scripts/test-gfx.sh — automated graphics-layer verification. +# +# The cursor overlay compositor is the core of the GUI path: the shadow +# holds true content, the display gets shadow pushes with the cursor +# painted on top at every push, and the cursor never enters the shadow. +# This test boots QEMU headless and runs `gfx check` — an in-kernel +# pixel self-test that reads back shadow *and* display pixels — plus the +# `gfx` demo scene. Cursor *movement* against injected mouse input is +# covered by test-mouse.sh; here we prove the compositor math. +# +# Usage: ./scripts/test-gfx.sh +# Env: OVMF, QEMU (same defaults as other test scripts) +# +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +cd "$PROJECT_DIR" + +OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" +QEMU="${QEMU:-qemu-system-x86_64}" +ESP_DIR="$PROJECT_DIR/esp" +QPID=/tmp/rsdos-gfx-qpid +SOCK=/tmp/rsdos-gfx-qmon.sock +LOG=/tmp/rsdos-gfx-serial.log +QLOG=/tmp/rsdos-gfx-qemu.log + +trap 'kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true' EXIT + +fail() { + echo "FAIL: $1" + [ -f "$LOG" ] && tail -40 "$LOG" + exit 1 +} + +wait_log() { + local i=0 + while [ "$i" -lt $((${3:-60} * 10)) ]; do + grep -q "$2" "$1" 2>/dev/null && return 0 + sleep 0.1 + i=$((i + 1)) + done + return 1 +} + +wait_qemu_exit() { + local i=0 + while [ "$i" -lt $((${1:-30} * 10)) ]; do + kill -0 "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || return 0 + sleep 0.1 + i=$((i + 1)) + done + return 1 +} + +qemu_hmp() { + python3 - "$SOCK" "$1" <<'EOF' +import socket, sys, time +s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +s.connect(sys.argv[1]) +s.sendall((sys.argv[2] + "\n").encode()) +time.sleep(0.4) +EOF +} + +echo "==> 1/5 build kernel (debug)" +cargo build --package rsdos --target x86_64-unknown-uefi + +echo "==> 2/5 deploy to ESP" +mkdir -p "$ESP_DIR/EFI/BOOT" +cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" + +echo "==> 3/5 boot QEMU (headless)" +kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true +sleep 1 +rm -f "$SOCK" "$LOG" +"$QEMU" -bios "$OVMF" \ + -drive file=fat:rw:"$ESP_DIR",format=raw \ + -serial file:"$LOG" \ + -monitor unix:"$SOCK",server,nowait \ + -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ + >"$QLOG" 2>&1 & +echo $! >"$QPID" + +wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" +grep -aq "cursor: task " "$LOG" || fail "cursor task did not spawn" + +echo "==> 4/5 in-kernel pixel self-test (gfx check)" +python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ + "clear" \ + "gfx check" +sleep 1.5 + +# Every sub-check must have printed OK. +grep -aq "fill_rect/shadow: OK" "$LOG" || fail "shadow writeback failed" +grep -aq "display push: OK" "$LOG" || fail "shadow→display push failed" +grep -aq "cursor overlay: OK" "$LOG" || fail "cursor not composited on display" +grep -aq "cursor not in shadow: OK" "$LOG" || fail "cursor leaked into the shadow" +grep -aq "gfx check: PASS" "$LOG" || fail "gfx check did not PASS" +grep -aq "gfx check: FAIL" "$LOG" && fail "gfx check reported FAIL" + +echo "==> 5/5 demo scene + poweroff" +python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ + "gfx" \ + "poweroff" +wait_qemu_exit 30 || fail "QEMU did not exit after poweroff" + +grep -aq "gfx: drew status bar" "$LOG" || fail "gfx demo did not draw" + +echo "" +echo "PASS — graphics layer OK (shadow, display push, cursor overlay)" +echo " compositor: shadow=content, display=push+cursor, cursor never in shadow" -- cgit v1.2.3