prometeu-runtime/discussion/workflow/plans/PLN-0119-integrate-desktop-host-worker-presentation.md

82 lines
2.9 KiB
Markdown

---
id: PLN-0119
ticket: real-render-worker-establishment
title: Integrate Desktop Host Worker Presentation
status: open
created: 2026-06-15
completed:
ref_decisions: [DEC-0033]
tags: [runtime, renderer, worker, host, desktop]
---
## Briefing
`DEC-0033` is not complete until the real host path uses the worker. This plan integrates desktop presentation with the latest published `OwnedRgba8888Frame` while keeping native upload/present in the host event loop.
## Decisions de Origem
- `DEC-0033`: Real Render Worker Contract.
## Alvo
Make `prometeu-host-desktop-winit` present frames produced by the worker path.
## Escopo
- Wire the host to enable/use the worker path.
- Read the latest published `OwnedRgba8888Frame`.
- Upload/copy RGBA8888 pixels to the existing pixels/winit presentation surface in the event loop.
- Preserve host invalidation and redraw behavior.
- Keep worker free of native window dependencies.
## Fora de Escopo
- No SDL migration.
- No change to logical pixel format.
- No change to input/audio/filesystem host behavior.
## Plano de Execucao
### Step 1 - Add host access to published frame
**What:** Expose latest worker-published frame to desktop host.
**How:** Add an API through runtime/platform integration that returns or copies the latest `OwnedRgba8888Frame` for host upload.
**File(s):** system worker modules, host runner integration.
### Step 2 - Upload RGBA8888 in event loop
**What:** Present worker output through existing host surface.
**How:** Convert/copy `Vec<u32>` RGBA8888 into the existing pixels frame buffer using existing RGBA8888 utility conventions.
**File(s):** `crates/host/prometeu-host-desktop-winit/src/runner.rs`, `utilities.rs` if needed.
### Step 3 - Preserve invalidation model
**What:** Keep host redraw policy coherent.
**How:** Trigger redraw when a new frame is published or host invalidation occurs; repeat uses the last published frame.
**File(s):** host runner/presentation state.
### Step 4 - Add host tests
**What:** Prove host consumes worker-published frame.
**How:** Add unit tests for RGBA8888 copy/upload helper and presentation state transitions without opening a native window.
**File(s):** host tests.
## Criterios de Aceite
- [ ] Desktop host presents the latest worker-published `OwnedRgba8888Frame`.
- [ ] Worker code does not import winit, pixels, SDL, swapchain, native texture, or window APIs.
- [ ] Host event loop remains responsible for native present.
- [ ] Existing host invalidation tests still pass.
- [ ] Real host path can run with worker enabled.
## Tests / Validacao
- `cargo test -p prometeu-host-desktop-winit`
- `cargo test -p prometeu-system -p prometeu-firmware`
- Manual run of a simple cartridge through desktop host with worker path enabled.
## Riscos
- Upload/copy can accidentally reinterpret RGBA8888 as native endian bytes.
- Host redraw policy can regress into perpetual polling if publication/invalidation are not kept separate.