implements PLN-0119
This commit is contained in:
@@ -33,6 +33,8 @@ use std::sync::Arc;
|
||||
/// - **Audio**: Stereo, Command-based mixing.
|
||||
/// - **Input**: 12-button Digital Gamepad + Absolute Touch/Mouse.
|
||||
pub struct Hardware {
|
||||
/// Shared physical memory bank ownership used by peripherals and worker backends.
|
||||
pub memory_banks: Arc<MemoryBanks>,
|
||||
/// The Graphics Processing Unit (GPU). Handles drawing primitives, sprites, and tilemaps.
|
||||
pub gfx: Gfx,
|
||||
/// Canonical frame orchestration owner for scene/camera/cache/resolver/sprites.
|
||||
@@ -216,6 +218,7 @@ impl Hardware {
|
||||
);
|
||||
let glyph_slot_index = assets.glyph_asset_slot_index();
|
||||
Self {
|
||||
memory_banks: Arc::clone(&memory_banks),
|
||||
gfx: Gfx::new(
|
||||
Self::W,
|
||||
Self::H,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use crate::asset::GlyphAssetSlotIndex;
|
||||
use crate::frame_composer::FrameComposer;
|
||||
use crate::gfx::Gfx;
|
||||
use crate::memory_banks::GlyphBankPoolAccess;
|
||||
use crate::memory_banks::{GlyphBankPoolAccess, MemoryBanks, SceneBankPoolAccess};
|
||||
use prometeu_hal::app_mode::AppMode;
|
||||
use prometeu_hal::{
|
||||
OwnedRgba8888Frame, RenderSubmission, RenderSubmissionPacket, RenderWorkerBackend,
|
||||
@@ -9,11 +11,51 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
pub struct LocalFramebufferRenderBackend {
|
||||
gfx: Mutex<Gfx>,
|
||||
frame_composer: Mutex<FrameComposer>,
|
||||
}
|
||||
|
||||
impl LocalFramebufferRenderBackend {
|
||||
pub fn new(width: usize, height: usize, glyph_banks: Arc<dyn GlyphBankPoolAccess>) -> Self {
|
||||
Self { gfx: Mutex::new(Gfx::new(width, height, glyph_banks)) }
|
||||
Self::new_with_parts(
|
||||
width,
|
||||
height,
|
||||
glyph_banks,
|
||||
Arc::new(MemoryBanks::new()),
|
||||
GlyphAssetSlotIndex::new(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_with_memory_banks(
|
||||
width: usize,
|
||||
height: usize,
|
||||
memory_banks: Arc<MemoryBanks>,
|
||||
glyph_slot_index: GlyphAssetSlotIndex,
|
||||
) -> Self {
|
||||
Self::new_with_parts(
|
||||
width,
|
||||
height,
|
||||
Arc::clone(&memory_banks) as Arc<dyn GlyphBankPoolAccess>,
|
||||
memory_banks,
|
||||
glyph_slot_index,
|
||||
)
|
||||
}
|
||||
|
||||
fn new_with_parts(
|
||||
width: usize,
|
||||
height: usize,
|
||||
glyph_banks: Arc<dyn GlyphBankPoolAccess>,
|
||||
scene_banks: Arc<dyn SceneBankPoolAccess>,
|
||||
glyph_slot_index: GlyphAssetSlotIndex,
|
||||
) -> Self {
|
||||
Self {
|
||||
gfx: Mutex::new(Gfx::new(width, height, glyph_banks)),
|
||||
frame_composer: Mutex::new(FrameComposer::new(
|
||||
width,
|
||||
height,
|
||||
scene_banks,
|
||||
glyph_slot_index,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_submission(
|
||||
@@ -23,7 +65,16 @@ impl LocalFramebufferRenderBackend {
|
||||
let mut gfx = self.gfx.lock().map_err(|_| RenderWorkerError::InternalFailure)?;
|
||||
match &submission.packet {
|
||||
RenderSubmissionPacket::Game2D(packet) if submission.app_mode == AppMode::Game => {
|
||||
gfx.render_game2d_frame_packet(packet);
|
||||
if packet.composer.bound_scene.is_none() {
|
||||
gfx.render_game2d_frame_packet(packet);
|
||||
} else {
|
||||
let mut frame_composer = self
|
||||
.frame_composer
|
||||
.lock()
|
||||
.map_err(|_| RenderWorkerError::InternalFailure)?;
|
||||
frame_composer.render_game2d_frame_packet(packet, &mut *gfx);
|
||||
gfx.apply_gfx2d_commands(&packet.gfx2d);
|
||||
}
|
||||
}
|
||||
RenderSubmissionPacket::ShellUi(packet) if submission.app_mode == AppMode::Shell => {
|
||||
gfx.render_shell_ui_frame_packet(packet);
|
||||
|
||||
Reference in New Issue
Block a user