From f273745589cdd0da79087a1f94767c403fd5ba39 Mon Sep 17 00:00:00 2001 From: bQUARKz Date: Sat, 23 May 2026 19:23:07 +0100 Subject: [PATCH] implements PLN-0070 --- crates/console/prometeu-drivers/src/asset.rs | 29 +++++++++++-------- .../prometeu-hal/src/cartridge_loader.rs | 4 +-- crates/console/prometeu-hal/src/color.rs | 19 ------------ .../src/services/vm_runtime/tests.rs | 8 ++--- crates/tools/pbxgen-stress/src/lib.rs | 6 ++-- discussion/index.ndjson | 2 +- ...888-asset-palettes-tooling-and-fixtures.md | 2 +- 7 files changed, 28 insertions(+), 42 deletions(-) diff --git a/crates/console/prometeu-drivers/src/asset.rs b/crates/console/prometeu-drivers/src/asset.rs index 8579038b..5adb1f12 100644 --- a/crates/console/prometeu-drivers/src/asset.rs +++ b/crates/console/prometeu-drivers/src/asset.rs @@ -64,7 +64,7 @@ impl GlyphAssetSlotIndex { const GLYPH_BANK_PALETTE_COUNT_V1: usize = 64; const GLYPH_BANK_COLORS_PER_PALETTE: usize = 16; const GLYPH_BANK_PALETTE_BYTES_V1: usize = - GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * size_of::(); + GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * size_of::(); /// Resident metadata for a decoded/materialized asset inside a BankPolicy. #[derive(Debug)] @@ -655,10 +655,13 @@ impl AssetManager { [[Color::BLACK; GLYPH_BANK_COLORS_PER_PALETTE]; GLYPH_BANK_PALETTE_COUNT_V1]; for (p, pal) in palettes.iter_mut().enumerate() { for (c, slot) in pal.iter_mut().enumerate() { - let offset = (p * 16 + c) * 2; - let color_raw = - u16::from_le_bytes([palette_data[offset], palette_data[offset + 1]]); - *slot = Color::from_rgb565_lossy(color_raw); + let offset = (p * 16 + c) * 4; + *slot = Color::rgba( + palette_data[offset], + palette_data[offset + 1], + palette_data[offset + 2], + palette_data[offset + 3], + ); } } @@ -687,10 +690,13 @@ impl AssetManager { [[Color::BLACK; GLYPH_BANK_COLORS_PER_PALETTE]; GLYPH_BANK_PALETTE_COUNT_V1]; for (p, pal) in palettes.iter_mut().enumerate() { for (c, slot) in pal.iter_mut().enumerate() { - let offset = (p * 16 + c) * 2; - let color_raw = - u16::from_le_bytes([palette_data[offset], palette_data[offset + 1]]); - *slot = Color::from_rgb565_lossy(color_raw); + let offset = (p * 16 + c) * 4; + *slot = Color::rgba( + palette_data[offset], + palette_data[offset + 1], + palette_data[offset + 2], + palette_data[offset + 3], + ); } } @@ -1306,14 +1312,13 @@ mod tests { let entry = test_glyph_asset_entry("glyphs", 2, 2); let mut data = vec![0x10, 0x23]; data.extend_from_slice(&[0u8; GLYPH_BANK_PALETTE_BYTES_V1]); - data[2] = 0x34; - data[3] = 0x12; + data[2..6].copy_from_slice(&[0x12, 0x34, 0x56, 0x78]); let bank = AssetManager::decode_glyph_bank_from_buffer(&entry, &data).expect("glyph decode"); assert_eq!(bank.pixel_indices, vec![1, 0, 2, 3]); - assert_eq!(bank.palettes[0][0], Color::from_rgb565_lossy(0x1234)); + assert_eq!(bank.palettes[0][0], Color::from_raw(0x12345678)); } #[test] diff --git a/crates/console/prometeu-hal/src/cartridge_loader.rs b/crates/console/prometeu-hal/src/cartridge_loader.rs index ed46a15f..2b287f96 100644 --- a/crates/console/prometeu-hal/src/cartridge_loader.rs +++ b/crates/console/prometeu-hal/src/cartridge_loader.rs @@ -366,7 +366,7 @@ mod tests { bank_type: BankType::GLYPH, offset, size, - decoded_size: 16 * 16 + (GLYPH_BANK_PALETTE_COUNT_V1 as u64 * 16 * 2), + decoded_size: 16 * 16 + (GLYPH_BANK_PALETTE_COUNT_V1 as u64 * 16 * 4), codec: AssetCodec::None, metadata: json!({ "tile_size": 16, @@ -449,7 +449,7 @@ mod tests { bank_type: BankType::GLYPH, offset: 4, size: 4, - decoded_size: 16 * 16 + (GLYPH_BANK_PALETTE_COUNT_V1 as u64 * 16 * 2), + decoded_size: 16 * 16 + (GLYPH_BANK_PALETTE_COUNT_V1 as u64 * 16 * 4), codec: AssetCodec::None, metadata: json!({ "tile_size": 16, diff --git a/crates/console/prometeu-hal/src/color.rs b/crates/console/prometeu-hal/src/color.rs index 04f16c9d..a4374859 100644 --- a/crates/console/prometeu-hal/src/color.rs +++ b/crates/console/prometeu-hal/src/color.rs @@ -65,23 +65,4 @@ impl Color { (self.0 & 0xFF) as u8 } - #[deprecated(note = "Temporary bridge until the renderer buffer migrates to RGBA8888.")] - pub const fn to_rgb565_lossy(self) -> u16 { - let (r, g, b, _) = Self::unpack_to_native(self.0); - let r5 = (r as u16 >> 3) & 0x1F; - let g6 = (g as u16 >> 2) & 0x3F; - let b5 = (b as u16 >> 3) & 0x1F; - (r5 << 11) | (g6 << 5) | b5 - } - - #[deprecated(note = "Temporary bridge until asset palettes migrate to RGBA8888.")] - pub const fn from_rgb565_lossy(raw: u16) -> Self { - let r5 = ((raw >> 11) & 0x1F) as u32; - let g6 = ((raw >> 5) & 0x3F) as u32; - let b5 = (raw & 0x1F) as u32; - let r = ((r5 << 3) | (r5 >> 2)) as u8; - let g = ((g6 << 2) | (g6 >> 4)) as u8; - let b = ((b5 << 3) | (b5 >> 2)) as u8; - Self::rgba(r, g, b, 255) - } } diff --git a/crates/console/prometeu-system/src/services/vm_runtime/tests.rs b/crates/console/prometeu-system/src/services/vm_runtime/tests.rs index 84dd8a61..457624fd 100644 --- a/crates/console/prometeu-system/src/services/vm_runtime/tests.rs +++ b/crates/console/prometeu-system/src/services/vm_runtime/tests.rs @@ -113,11 +113,11 @@ fn serialized_single_function_module_with_consts( } fn test_glyph_payload_size(width: usize, height: usize) -> usize { - (width * height).div_ceil(2) + (GLYPH_BANK_PALETTE_COUNT_V1 * 16 * std::mem::size_of::()) + (width * height).div_ceil(2) + (GLYPH_BANK_PALETTE_COUNT_V1 * 16 * std::mem::size_of::()) } fn test_glyph_decoded_size(width: usize, height: usize) -> usize { - width * height + (GLYPH_BANK_PALETTE_COUNT_V1 * 16 * std::mem::size_of::()) + width * height + (GLYPH_BANK_PALETTE_COUNT_V1 * 16 * std::mem::size_of::()) } fn test_glyph_asset_entry(asset_name: &str, data_len: usize) -> AssetEntry { @@ -141,8 +141,8 @@ fn test_glyph_asset_entry(asset_name: &str, data_len: usize) -> AssetEntry { fn test_glyph_asset_data() -> Vec { let mut data = - vec![0x11u8; test_glyph_payload_size(16, 16) - (GLYPH_BANK_PALETTE_COUNT_V1 * 16 * 2)]; - data.extend_from_slice(&[0u8; GLYPH_BANK_PALETTE_COUNT_V1 * 16 * 2]); + vec![0x11u8; test_glyph_payload_size(16, 16) - (GLYPH_BANK_PALETTE_COUNT_V1 * 16 * 4)]; + data.extend_from_slice(&[0u8; GLYPH_BANK_PALETTE_COUNT_V1 * 16 * 4]); data } diff --git a/crates/tools/pbxgen-stress/src/lib.rs b/crates/tools/pbxgen-stress/src/lib.rs index 6af0bde7..bc95c149 100644 --- a/crates/tools/pbxgen-stress/src/lib.rs +++ b/crates/tools/pbxgen-stress/src/lib.rs @@ -284,7 +284,7 @@ fn build_glyph_asset() -> (AssetEntry, Vec) { bank_type: BankType::GLYPH, offset: 0, size: payload.len() as u64, - decoded_size: (8 * 8 + GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 2) + decoded_size: (8 * 8 + GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 4) as u64, codec: AssetCodec::None, metadata: serde_json::json!({ @@ -301,11 +301,11 @@ fn build_glyph_asset() -> (AssetEntry, Vec) { fn build_palette_bytes() -> Vec { let mut bytes = - Vec::with_capacity(GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 2); + Vec::with_capacity(GLYPH_BANK_PALETTE_COUNT_V1 * GLYPH_BANK_COLORS_PER_PALETTE * 4); for palette_id in 0..GLYPH_BANK_PALETTE_COUNT_V1 { for color_index in 0..GLYPH_BANK_COLORS_PER_PALETTE { let color = if color_index == 1 { stress_color(palette_id) } else { Color::BLACK }; - bytes.extend_from_slice(&color.raw().to_le_bytes()); + bytes.extend_from_slice(&color.raw().to_be_bytes()); } } bytes diff --git a/discussion/index.ndjson b/discussion/index.ndjson index 411b9717..06cfa7cb 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":"open","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":"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":[]} diff --git a/discussion/workflow/plans/PLN-0070-rgba8888-asset-palettes-tooling-and-fixtures.md b/discussion/workflow/plans/PLN-0070-rgba8888-asset-palettes-tooling-and-fixtures.md index b494a405..e46b688b 100644 --- a/discussion/workflow/plans/PLN-0070-rgba8888-asset-palettes-tooling-and-fixtures.md +++ b/discussion/workflow/plans/PLN-0070-rgba8888-asset-palettes-tooling-and-fixtures.md @@ -2,7 +2,7 @@ id: PLN-0070 ticket: rgba8888-framebuffer-and-pixel-format-direction title: RGBA8888 Asset Palettes Tooling and Fixtures -status: open +status: done created: 2026-05-23 ref_decisions: [DEC-0029] tags: [gfx, framebuffer, rgb565, rgba8888, renderer, assets, host, backend]