implements PLN-0100

This commit is contained in:
bQUARKz 2026-06-15 05:46:28 +01:00
parent a268bd0b75
commit 18cfeedbff
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
8 changed files with 62 additions and 16 deletions

View File

@ -302,7 +302,11 @@ mod tests {
color: Color::BLUE, color: Color::BLUE,
}]; }];
hardware.publish_render_submission(&RenderSubmission::game2d(FrameId::ZERO, packet)); RenderSubmissionSink::submit_render_submission(
&mut hardware,
RenderSubmission::game2d(FrameId::ZERO, packet),
)
.expect("local sink should publish Game2D packet");
assert_eq!(hardware.gfx.front_buffer()[0], Color::BLUE.raw()); assert_eq!(hardware.gfx.front_buffer()[0], Color::BLUE.raw());
} }
@ -340,7 +344,11 @@ mod tests {
); );
hardware.begin_frame(); hardware.begin_frame();
hardware.publish_render_submission(&RenderSubmission::game2d(FrameId::ZERO, packet)); RenderSubmissionSink::submit_render_submission(
&mut hardware,
RenderSubmission::game2d(FrameId::ZERO, packet),
)
.expect("local sink should publish Game2D packet");
assert_eq!(hardware.gfx.front_buffer()[0], Color::RED.raw()); assert_eq!(hardware.gfx.front_buffer()[0], Color::RED.raw());
} }

View File

@ -2,7 +2,10 @@ use crate::firmware::firmware_state::{FirmwareState, LaunchHubStep};
use crate::firmware::prometeu_context::PrometeuContext; use crate::firmware::prometeu_context::PrometeuContext;
use prometeu_hal::color::Color; use prometeu_hal::color::Color;
use prometeu_hal::log::{LogLevel, LogSource}; use prometeu_hal::log::{LogLevel, LogSource};
use prometeu_hal::{FrameId, GfxUiCommand, RenderSubmission, ShellUiFramePacket}; use prometeu_hal::{
FrameId, GfxUiCommand, LegacyHardwareRenderSubmissionSink, RenderSubmission,
RenderSubmissionSink, ShellUiFramePacket,
};
use prometeu_system::CrashReport; use prometeu_system::CrashReport;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -24,7 +27,9 @@ impl AppCrashesStep {
ctx.hw.pad_mut().begin_frame(ctx.signals); ctx.hw.pad_mut().begin_frame(ctx.signals);
let packet = ShellUiFramePacket::new(vec![GfxUiCommand::Clear { color: Color::RED }]); let packet = ShellUiFramePacket::new(vec![GfxUiCommand::Clear { color: Color::RED }]);
ctx.hw.publish_render_submission(&RenderSubmission::shell_ui(FrameId::ZERO, packet)); LegacyHardwareRenderSubmissionSink::new(ctx.hw)
.submit_render_submission(RenderSubmission::shell_ui(FrameId::ZERO, packet))
.expect("firmware crash render submission should publish");
// If START is pressed, return to the Hub // If START is pressed, return to the Hub
if ctx.hw.pad().start().down { if ctx.hw.pad().start().down {

View File

@ -3,7 +3,10 @@ use crate::firmware::prometeu_context::PrometeuContext;
use prometeu_hal::color::Color; use prometeu_hal::color::Color;
use prometeu_hal::log::{LogLevel, LogSource}; use prometeu_hal::log::{LogLevel, LogSource};
use prometeu_hal::primitives::Rect; use prometeu_hal::primitives::Rect;
use prometeu_hal::{FrameId, GfxUiCommand, RenderSubmission, ShellUiFramePacket}; use prometeu_hal::{
FrameId, GfxUiCommand, LegacyHardwareRenderSubmissionSink, RenderSubmission,
RenderSubmissionSink, ShellUiFramePacket,
};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SplashScreenStep { pub struct SplashScreenStep {
@ -44,7 +47,9 @@ impl SplashScreenStep {
color: Color::WHITE, color: Color::WHITE,
}, },
]); ]);
ctx.hw.publish_render_submission(&RenderSubmission::shell_ui(FrameId::ZERO, packet)); LegacyHardwareRenderSubmissionSink::new(ctx.hw)
.submit_render_submission(RenderSubmission::shell_ui(FrameId::ZERO, packet))
.expect("firmware splash render submission should publish");
// Transition logic // Transition logic
// If any button is pressed at any time after the animation ends // If any button is pressed at any time after the animation ends

View File

@ -49,8 +49,8 @@ pub use native_interface::{NativeInterface, SyscallId};
pub use pad_bridge::PadBridge; pub use pad_bridge::PadBridge;
pub use platform::{ pub use platform::{
AssetStoragePlatform, AudioPlatform, ClockPacingPlatform, Game2DFrameComposer, InputPlatform, AssetStoragePlatform, AudioPlatform, ClockPacingPlatform, Game2DFrameComposer, InputPlatform,
RenderBackend, RenderSubmissionSink, RenderSubmitError, RuntimePlatform, TelemetryPlatform, LegacyHardwareRenderSubmissionSink, RenderBackend, RenderSubmissionSink, RenderSubmitError,
TestPlatform, RuntimePlatform, TelemetryPlatform, TestPlatform,
}; };
pub use render_submission::{ pub use render_submission::{
BoundScenePacket, Camera2D, ComposerFramePacket, FrameId, Game2DFramePacket, GameSpritePacket, BoundScenePacket, Camera2D, ComposerFramePacket, FrameId, Game2DFramePacket, GameSpritePacket,

View File

@ -1,6 +1,7 @@
use crate::asset_bridge::AssetBridge; use crate::asset_bridge::AssetBridge;
use crate::audio_bridge::AudioBridge; use crate::audio_bridge::AudioBridge;
use crate::composer_status::ComposerOpStatus; use crate::composer_status::ComposerOpStatus;
use crate::hardware_bridge::HardwareBridge;
use crate::pad_bridge::PadBridge; use crate::pad_bridge::PadBridge;
use crate::render_submission::{Game2DFramePacket, RenderSubmission}; use crate::render_submission::{Game2DFramePacket, RenderSubmission};
use crate::sprite::Sprite; use crate::sprite::Sprite;
@ -20,6 +21,26 @@ pub trait RenderSubmissionSink {
) -> Result<(), RenderSubmitError>; ) -> Result<(), RenderSubmitError>;
} }
pub struct LegacyHardwareRenderSubmissionSink<'a> {
hw: &'a mut dyn HardwareBridge,
}
impl<'a> LegacyHardwareRenderSubmissionSink<'a> {
pub fn new(hw: &'a mut dyn HardwareBridge) -> Self {
Self { hw }
}
}
impl RenderSubmissionSink for LegacyHardwareRenderSubmissionSink<'_> {
fn submit_render_submission(
&mut self,
submission: RenderSubmission,
) -> Result<(), RenderSubmitError> {
self.hw.publish_render_submission(&submission);
Ok(())
}
}
pub trait RenderBackend { pub trait RenderBackend {
fn render_frame(&mut self); fn render_frame(&mut self);
} }

View File

@ -2,7 +2,8 @@ use crate::{CrashReport, SystemOS};
use prometeu_hal::color::Color; use prometeu_hal::color::Color;
use prometeu_hal::primitives::Rect; use prometeu_hal::primitives::Rect;
use prometeu_hal::{ use prometeu_hal::{
FrameId, GfxUiCommand, HardwareBridge, InputSignals, RenderSubmission, ShellUiFramePacket, FrameId, GfxUiCommand, HardwareBridge, InputSignals, LegacyHardwareRenderSubmissionSink,
RenderSubmission, RenderSubmissionSink, ShellUiFramePacket,
}; };
use prometeu_vm::VirtualMachine; use prometeu_vm::VirtualMachine;
@ -142,7 +143,9 @@ impl PrometeuHub {
} }
ShellUiFramePacket::new(commands) ShellUiFramePacket::new(commands)
}; };
hw.publish_render_submission(&RenderSubmission::shell_ui(FrameId::ZERO, packet)); LegacyHardwareRenderSubmissionSink::new(hw)
.submit_render_submission(RenderSubmission::shell_ui(FrameId::ZERO, packet))
.expect("hub render submission should publish");
} }
pub fn update_shell_profile( pub fn update_shell_profile(

View File

@ -858,7 +858,8 @@ fn tick_game_submissions_are_immutable_and_latest_complete_wins() {
first_packet.gfx2d[0], first_packet.gfx2d[0],
prometeu_hal::Gfx2dCommand::Clear { color } if color == Color::from_raw(0x11223344) prometeu_hal::Gfx2dCommand::Clear { color } if color == Color::from_raw(0x11223344)
)); ));
prometeu_hal::HardwareBridge::publish_render_submission(&mut hardware, latest); prometeu_hal::RenderSubmissionSink::submit_render_submission(&mut hardware, latest.clone())
.expect("local sink should publish latest submission");
assert_eq!(hardware.gfx.front_buffer()[0], Color::from_raw(0x55667788).raw()); assert_eq!(hardware.gfx.front_buffer()[0], Color::from_raw(0x55667788).raw());
} }

View File

@ -9,8 +9,8 @@ use crate::services::memcard::MemcardService;
use prometeu_hal::asset::{BankTelemetry, BankType}; use prometeu_hal::asset::{BankTelemetry, BankType};
use prometeu_hal::log::{LogLevel, LogService, LogSource}; use prometeu_hal::log::{LogLevel, LogService, LogSource};
use prometeu_hal::{ use prometeu_hal::{
FrameId, HardwareBridge, HostContext, InputSignals, RenderSubmission, RenderSubmissionPacket, FrameId, HardwareBridge, HostContext, InputSignals, LegacyHardwareRenderSubmissionSink,
ShellUiFramePacket, RenderSubmission, RenderSubmissionPacket, RenderSubmissionSink, ShellUiFramePacket,
}; };
use prometeu_vm::LogicalFrameEndingReason; use prometeu_vm::LogicalFrameEndingReason;
use std::collections::HashMap; use std::collections::HashMap;
@ -18,12 +18,14 @@ use std::panic::{AssertUnwindSafe, catch_unwind};
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
struct HardwareRenderSurface<'a> { struct HardwareRenderSurface<'a> {
hw: &'a mut dyn HardwareBridge, sink: &'a mut dyn RenderSubmissionSink,
} }
impl RenderSurface for HardwareRenderSurface<'_> { impl RenderSurface for HardwareRenderSurface<'_> {
fn consume_submission(&mut self, submission: &RenderSubmission) { fn consume_submission(&mut self, submission: &RenderSubmission) {
self.hw.publish_render_submission(submission); self.sink
.submit_render_submission(submission.clone())
.expect("local render submission sink should publish");
} }
} }
@ -262,7 +264,8 @@ impl VirtualMachineRuntime {
} }
let render_outcome = catch_unwind(AssertUnwindSafe(|| { let render_outcome = catch_unwind(AssertUnwindSafe(|| {
let mut surface = HardwareRenderSurface { hw }; let mut sink = LegacyHardwareRenderSubmissionSink::new(hw);
let mut surface = HardwareRenderSurface { sink: &mut sink };
match self match self
.render_manager .render_manager
.active_render_policy() .active_render_policy()