Repository navigation
pagh-gl-demo: PDP/1 ShmSurface integration + three CPU scenes (PR5) - #173
Merged
Merged
Conversation
The demo's gears scene needs GL_LIGHTING/GL_LIGHT0 and material state to show the same geometry with lighting off/on (spec §6.1). Upstream 0.4.1 already implements this in light.c; expose it through the safe layer instead of poking C from the demo: - ffi: glLightfv/glMaterialfv plus the GL_* pnames used (AMBIENT, DIFFUSE, SPECULAR, POSITION, EMISSION, SHININESS, AMBIENT_AND_DIFFUSE); - Context: Light/LightParam/MaterialFace/MaterialParam enums and light()/material() with finite-value validation (NaN/∞ would produce a NaN-coloured frame, not a usable error); - Capability gains Lighting/Light0/Normalize. No C sources change. Tests render the same quad with lighting off and a red material on, assert the pixel is red-dominant, green material reaches the pixel without glColor3f, and NaN/∞ are rejected by our Err before C.
PR5 of the TinyGL port spec: the demo renders triangle/cube/gears straight into the window's mmap(MAP_SHARED) memfd and sends only COMMIT+DAMAGE — no frame copy over the socket. Without --connect it renders headless into Vec<u32> and prints TINYGL digest markers. - surface.rs: memfd/mmap via pagh_ui::shm, pixels exposed as &mut [u32] for ZB_open (stride is exactly width*4, width % 4 checked before C); - client.rs: minimal PDP/1 client on the public pagh_ui protocol/shm API: hello/welcome (requires welcome.flags bit 2), create, SHM_OFFER with SCM_RIGHTS, SHM_READY, COMMIT (header flags SHM), resize via a new memfd and SHM_RELEASE(old), ping/pong, configure/close/error. There is deliberately no full-frame fallback: spec §4.5 asks for an explicit failure instead; - scenes: our own code under tinygl::Context — triangle (Gouraud, fixed angle), cube (six faces, depth+culling, frame n = 25° + n*15°), gears (~1.1k triangles generated from a tooth profile, lighting off/on). Frame n is a pure function of n; Instant/rdtsc are used only for measurements; - gears trigonometry uses a local Taylor series instead of libm so the base profile is bit-identical on glibc and musl; rotations go through C glRotatef; - CLI: triangle|cube|gears, --connect, --frames, --size, --out (PPM), --hash, --lighting on|off, --help; - tests: pinned FNV-1a digests for all scenes (lighting on/off) with geometry point checks (Gouraud centre, cube face, gear through-hole/tooth), determinism, CLI parsing, and a real e2e against the host pagh-desktop compositor over AF_UNIX proving shm_offers/shm_commits and a composed window pixel, plus a PNG screenshot artifact. Host and musl runs produce identical digests; the static-pie musl binary is checked by tools/build-rust-app.sh (no INTERP). Version is not bumped: MINOR belongs to the final acceptance PR6.
ccclosed
pushed a commit
that referenced
this pull request
Nov 22, 2026
Sync with dev=e7f2bdc3 (#169 VT/session routing, #173 tinygl PR5, #174 vtfb1 respawn, docs). Conflicts, both at appended/summary text: - AGENTS.md: kept the USB S1 description for this branch (S1 is present here) and stated explicitly that it reaches dev only after this PR; #169/#173/#174 prose is kept verbatim. - src/test.rs: kept BOTH the new #174 "desktop-b::/dev/vtfb1 respawn after session exit (device path)" and the USB "usb::BOT/SCSI/uevent layouts and /usb root rule" routines. All USB S1 files (xhci/usb_msc/usb_scsi/usb_msc_proto/usb_storage/ usb_uevent*/vfs block nodes/mount syscalls) are untouched by dev; the dev-side terminal/tinygl/respawn changes are preserved. Post-merge evidence: gates 6/6 (host 872/0), QEMU usb-storage acceptance 46/46, release-kernel selftest 125 routines / 0 failed / 1 skipped (NVMe absent).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что это
PR5 спеки
docs/tinygl-port-spec.md(она пришла вdevс #168; ветка смержена сorigin/dev=02d79f14): композитор/PDP-интеграция и демо для CPU-порта TinyGL. Вариант A (upstream C 0.4.1 + тонкий FFI, MIT). Версияpagh/Cargo.tomlне меняется — MINOR только в финальном acceptance PR6.Сцены и дайджесты (640×480, FNV-1a-64 по словам пикселей)
triangle0x13e6981740ce9b4d0x00677a83)cube0xedbd26e7dcbf0507cube0x6bf2cc8b656d31a5cube0x921eaf892e9d44a5gears(lighting on)0x3d6fcc428ccbb634gears(on)0x2a04fc59b4722ea0gears(lighting off)0x900ca56f270b8033glColor3fgears(off)0xe8d5da9652a9eb7bHost и musl совпали байт-в-байт, включая QEMU-гостя: кадры 0/1 в госте — те же
0x3d6fcc428ccbb634/0x2a04fc59b4722ea0. Дляgearsбазовый профиль зуба считается собственным рядом Тейлора без libm (f64, только IEEE-арифметика), повороты кадра уходят в CglRotatef— поэтому геометрия не зависит от glibc/musl.PDP/1 + ShmSurface (без копии кадра)
memfd_create→ftruncate(w·h·4)→mmap(MAP_SHARED)(pagh_ui::shm::ShmSurface) →hello/welcome(нуженwelcome.flagsbit 2) →create→SHM_OFFERс fd черезSCM_RIGHTS→SHM_READY→ZB_open(..., mapping_ptr)+glInit→COMMIT+DAMAGE(header flags SHM). Наconfigure— новый memfd/offer/release; наSHM_RELEASE— повторный offer. Fallback на full-frame upload отсутствует намеренно (спека §4.5): без ShmSurface демо падает с внятной ошибкой.Evidence реального композитора:
pagh-desktopheadless + настоящий бинарник демо по AF_UNIX):shm_offers=1,shm_commits>=60, пиксель окна изменился, PNG рабочего стола с окном «TinyGL — gears»;--launch-target gl=... --autostart gl: окно с шестерёнками в кадре,TINYGL gears frame=0 digest=0x3d6fcc428ccbb634, скриншотqtinygl-pr5-qemu-window.png.Frame time (замеры; TCG — верхняя граница, не бенчмарк GPU)
gears:ft≈0.76/0.77/1.18 ms.gears(≈840 кадров за 45 с, ~19 fps):ft=28.000/35.000/98.000 ms (wall) cycles=71885377/87591977/249819290.Тесты
rust-apps/tinygl: 58 host-тестов (+3 lighting:GL_LIGHTINGменяет заливку, материал красит пиксель безglColor3f, NaN/∞ отвергаются до C).rust-apps/pagh-gl-demo: 14 host и 14 musl (5 CLI + 8 render goldens + 1 PDP/SHM e2e). Pinned-дайджесты, точечная геометрия (центр Gouraud, грань куба, дырка/зуб шестерёнки), детерминизм,--frames 0только с--connect, реальный композитор по AF_UNIX (shm_offers/shm_commits, композитный пиксель).tools/build-rust-app.sh rust-apps/pagh-gl-demo→ 313 552 байта,static-pie linked,readelf -l | grep -c INTERP= 0,cc=musl-gcc.Гейты 6/6 (на финальном SHA)
Честные ограничения
CPU-only fixed-function GL 1.1 subset; без GPU/DRM/NVIDIA, shaders/GLSL/GL2+/FBO/VBO/EGL/GLX/Wayland. 16-битный Z;
stride == width*4;width % 4 == 0(композиторскийconfigureс другой шириной — честная ошибка, не молчаливое ужатие). ОдинContextна процесс.gl_fatal_errorupstream =exit(1). Освещение — толькоGL_LIGHT0..7/glMaterialfv(безglColorMaterial, spot/attenuation). Автоматическая GL-фаза вtools/e2e.pyи MINOR/README acceptance — PR6, здесь их нет. Замеры TCG — верхняя граница.Остатки / заметки
_desktop_gl_phase()вtools/e2e.py, acceptance §7 целиком, MINOR bump, README-ограничения./home/oleg/.cache/pagh-agent-notes/(не коммитятся); заметки —qtinygl-pr5.md.feat/tinygl-pr5-compositor; не мержить — lead review.