diff --git a/crates/host/prometeu-host-desktop-winit/src/runner.rs b/crates/host/prometeu-host-desktop-winit/src/runner.rs index 2e6a2f2b..a5044674 100644 --- a/crates/host/prometeu-host-desktop-winit/src/runner.rs +++ b/crates/host/prometeu-host-desktop-winit/src/runner.rs @@ -5,7 +5,7 @@ use crate::input::HostInputHandler; use crate::log_sink::HostConsoleSink; use crate::overlay::{capture_snapshot, draw_overlay}; use crate::stats::HostStats; -use crate::utilities::draw_rgb565_to_rgba8; +use crate::utilities::draw_rgba8888_to_rgba8; use pixels::wgpu::PresentMode; use pixels::{Pixels, PixelsBuilder, SurfaceTexture}; use prometeu_drivers::AudioCommand; @@ -285,7 +285,7 @@ impl ApplicationHandler for HostRunner { // Immutable borrow of prometeu-core (different field, ok) let src = self.hardware.gfx.front_buffer(); - draw_rgb565_to_rgba8(src, frame); + draw_rgba8888_to_rgba8(src, frame); if let Some(snapshot) = overlay_snapshot.as_ref() { draw_overlay(frame, Hardware::W, Hardware::H, snapshot); diff --git a/crates/host/prometeu-host-desktop-winit/src/utilities.rs b/crates/host/prometeu-host-desktop-winit/src/utilities.rs index 1967f089..30eb7933 100644 --- a/crates/host/prometeu-host-desktop-winit/src/utilities.rs +++ b/crates/host/prometeu-host-desktop-winit/src/utilities.rs @@ -1,26 +1,25 @@ -/// Copies RGB565 (u16) -> RGBA8888 (u8[4]) to the pixels frame. -/// Pixels format: RGBA8. -pub fn draw_rgb565_to_rgba8(src: &[u16], dst_rgba: &mut [u8]) { +/// Copies RGBA8888 pixels in canonical RGBA raw order into the `pixels` RGBA8 frame. +pub fn draw_rgba8888_to_rgba8(src: &[u32], dst_rgba: &mut [u8]) { for (i, &px) in src.iter().enumerate() { - let (r8, g8, b8) = rgb565_to_rgb888(px); let o = i * 4; - dst_rgba[o] = r8; - dst_rgba[o + 1] = g8; - dst_rgba[o + 2] = b8; - dst_rgba[o + 3] = 0xFF; + dst_rgba[o] = ((px >> 24) & 0xFF) as u8; + dst_rgba[o + 1] = ((px >> 16) & 0xFF) as u8; + dst_rgba[o + 2] = ((px >> 8) & 0xFF) as u8; + dst_rgba[o + 3] = (px & 0xFF) as u8; } } -/// Expands RGB565 to RGB888 (high bit replication). -#[inline(always)] -pub fn rgb565_to_rgb888(px: u16) -> (u8, u8, u8) { - let r5 = ((px >> 11) & 0x1F) as u8; - let g6 = ((px >> 5) & 0x3F) as u8; - let b5 = (px & 0x1F) as u8; +#[cfg(test)] +mod tests { + use super::draw_rgba8888_to_rgba8; - let r8 = (r5 << 3) | (r5 >> 2); - let g8 = (g6 << 2) | (g6 >> 4); - let b8 = (b5 << 3) | (b5 >> 2); + #[test] + fn draw_rgba8888_to_rgba8_preserves_channel_order_and_alpha() { + let src = [0x12345678, 0xABCDEF01]; + let mut dst = [0; 8]; - (r8, g8, b8) + draw_rgba8888_to_rgba8(&src, &mut dst); + + assert_eq!(dst, [0x12, 0x34, 0x56, 0x78, 0xAB, 0xCD, 0xEF, 0x01]); + } } diff --git a/discussion/index.ndjson b/discussion/index.ndjson index 06cfa7cb..5079ba1e 100644 --- a/discussion/index.ndjson +++ b/discussion/index.ndjson @@ -35,4 +35,4 @@ {"type":"discussion","id":"DSC-0032","status":"done","ticket":"system-os-lifecycle-process-task-contract","title":"Agenda - SystemOS Lifecycle, Process and Task Contract","created_at":"2026-05-14","updated_at":"2026-05-15","tags":["runtime","os","lifecycle","process","task","shell","firmware"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0041","file":"discussion/lessons/DSC-0032-system-os-lifecycle-process-task-contract/LSN-0041-systemos-lifecycle-authority.md","status":"done","created_at":"2026-05-15","updated_at":"2026-05-15"}]} {"type":"discussion","id":"DSC-0033","status":"done","ticket":"system-os-service-ownership-and-module-layout","title":"Agenda - SystemOS Service Ownership and Module Layout","created_at":"2026-05-14","updated_at":"2026-05-15","tags":["runtime","os","services","module-layout","vm","window-manager","logging"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0042","file":"discussion/lessons/DSC-0033-system-os-service-ownership-and-module-layout/LSN-0042-systemos-service-ownership-boundary.md","status":"done","created_at":"2026-05-15","updated_at":"2026-05-15"}]} {"type":"discussion","id":"DSC-0036","status":"done","ticket":"prometeu-hub-ui-direction","title":"Agenda - Prometeu Hub UI Direction","created_at":"2026-05-15","updated_at":"2026-05-22","tags":["hub","ui","shell","system-apps","lifecycle","design-system"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0045","file":"discussion/lessons/DSC-0036-prometeu-hub-ui-direction/LSN-0045-hub-ui-slices-should-prove-os-boundaries.md","status":"done","created_at":"2026-05-22","updated_at":"2026-05-22"}]} -{"type":"discussion","id":"DSC-0037","status":"in_progress","ticket":"rgba8888-framebuffer-and-pixel-format-direction","title":"Agenda - RGBA8888 Framebuffer and Pixel Format Direction","created_at":"2026-05-22","updated_at":"2026-05-23","tags":["gfx","framebuffer","rgb565","rgba8888","renderer","assets","host","backend"],"agendas":[{"id":"AGD-0037","file":"AGD-0037-rgba8888-framebuffer-and-pixel-format-direction.md","status":"accepted","created_at":"2026-05-22","updated_at":"2026-05-23"}],"decisions":[{"id":"DEC-0029","file":"DEC-0029-rgba8888-runtime-pixel-format-contract.md","status":"accepted","created_at":"2026-05-23","updated_at":"2026-05-23","ref_agenda":"AGD-0037"}],"plans":[{"id":"PLN-0067","file":"PLN-0067-rgba8888-published-contracts-and-specs.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0068","file":"PLN-0068-rgba8888-color-type-hal-and-abi-surface.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0069","file":"PLN-0069-rgba8888-cpu-renderer-and-composition.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0070","file":"PLN-0070-rgba8888-asset-palettes-tooling-and-fixtures.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0071","file":"PLN-0071-rgba8888-host-presentation-path.md","status":"open","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0072","file":"PLN-0072-rgba8888-residue-removal-and-end-to-end-validation.md","status":"open","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]}],"lessons":[]} +{"type":"discussion","id":"DSC-0037","status":"in_progress","ticket":"rgba8888-framebuffer-and-pixel-format-direction","title":"Agenda - RGBA8888 Framebuffer and Pixel Format Direction","created_at":"2026-05-22","updated_at":"2026-05-23","tags":["gfx","framebuffer","rgb565","rgba8888","renderer","assets","host","backend"],"agendas":[{"id":"AGD-0037","file":"AGD-0037-rgba8888-framebuffer-and-pixel-format-direction.md","status":"accepted","created_at":"2026-05-22","updated_at":"2026-05-23"}],"decisions":[{"id":"DEC-0029","file":"DEC-0029-rgba8888-runtime-pixel-format-contract.md","status":"accepted","created_at":"2026-05-23","updated_at":"2026-05-23","ref_agenda":"AGD-0037"}],"plans":[{"id":"PLN-0067","file":"PLN-0067-rgba8888-published-contracts-and-specs.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0068","file":"PLN-0068-rgba8888-color-type-hal-and-abi-surface.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0069","file":"PLN-0069-rgba8888-cpu-renderer-and-composition.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0070","file":"PLN-0070-rgba8888-asset-palettes-tooling-and-fixtures.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0071","file":"PLN-0071-rgba8888-host-presentation-path.md","status":"done","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]},{"id":"PLN-0072","file":"PLN-0072-rgba8888-residue-removal-and-end-to-end-validation.md","status":"open","created_at":"2026-05-23","updated_at":"2026-05-23","ref_decisions":["DEC-0029"]}],"lessons":[]} diff --git a/discussion/workflow/plans/PLN-0071-rgba8888-host-presentation-path.md b/discussion/workflow/plans/PLN-0071-rgba8888-host-presentation-path.md index 226d732b..2270112e 100644 --- a/discussion/workflow/plans/PLN-0071-rgba8888-host-presentation-path.md +++ b/discussion/workflow/plans/PLN-0071-rgba8888-host-presentation-path.md @@ -2,7 +2,7 @@ id: PLN-0071 ticket: rgba8888-framebuffer-and-pixel-format-direction title: RGBA8888 Host Presentation Path -status: open +status: done created: 2026-05-23 ref_decisions: [DEC-0029] tags: [gfx, framebuffer, rgb565, rgba8888, renderer, assets, host, backend]