implements PLN-0095

This commit is contained in:
bQUARKz 2026-06-05 09:52:46 +01:00
parent f01822bd53
commit 8c43d85ce8
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
6 changed files with 98 additions and 5 deletions

View File

@ -23,6 +23,7 @@ impl VirtualMachineRuntime {
current_cartridge_app_version: String::new(),
current_cartridge_app_mode: AppMode::Game,
frame_scheduler: FrameScheduler::default(),
render_capabilities: RenderRuntimeCapabilities::default(),
render_manager: RenderManager::new(AppMode::Game),
gfx2d_commands: Vec::new(),
gfxui_commands: Vec::new(),
@ -121,6 +122,7 @@ impl VirtualMachineRuntime {
self.current_cartridge_app_version.clear();
self.current_cartridge_app_mode = AppMode::Game;
self.frame_scheduler = FrameScheduler::default();
self.render_capabilities = RenderRuntimeCapabilities::default();
self.render_manager = RenderManager::new(AppMode::Game);
self.gfx2d_commands.clear();
self.gfxui_commands.clear();
@ -141,6 +143,10 @@ impl VirtualMachineRuntime {
self.clear_cartridge_state();
}
pub fn set_render_runtime_capabilities(&mut self, capabilities: RenderRuntimeCapabilities) {
self.render_capabilities = capabilities;
}
pub fn initialize_vm(
&mut self,
log_service: &mut LogService,

View File

@ -14,7 +14,7 @@ use prometeu_hal::log::LogService;
use prometeu_hal::telemetry::{AtomicTelemetry, CertificationConfig, Certifier};
use prometeu_hal::{Gfx2dCommand, GfxUiCommand};
use prometeu_vm::VirtualMachine;
pub use render_manager::RenderManager;
pub use render_manager::{RenderManager, RenderRuntimeCapabilities};
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::atomic::AtomicU32;
@ -31,6 +31,7 @@ pub struct VirtualMachineRuntime {
pub current_cartridge_app_version: String,
pub current_cartridge_app_mode: AppMode,
pub frame_scheduler: FrameScheduler,
pub render_capabilities: RenderRuntimeCapabilities,
pub render_manager: RenderManager,
pub gfx2d_commands: Vec<Gfx2dCommand>,
pub gfxui_commands: Vec<GfxUiCommand>,

View File

@ -29,6 +29,17 @@ pub enum RenderExecutionPolicy {
WorkerCapableWithLocalFallback,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct RenderRuntimeCapabilities {
pub game_render_worker: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RenderConsumerPath {
LocalSynchronous,
LocalWorkerPrototype,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RenderPolicy {
pub app_mode: AppMode,
@ -55,12 +66,37 @@ impl RenderPolicy {
pub const fn uses_frame_scheduler(self) -> bool {
matches!(self.pacing, RenderPacingPolicy::FrameScheduled)
}
pub const fn resolve_consumer_path(
self,
capabilities: RenderRuntimeCapabilities,
) -> RenderConsumerPath {
match (self.execution, capabilities.game_render_worker) {
(RenderExecutionPolicy::WorkerCapableWithLocalFallback, true) => {
RenderConsumerPath::LocalWorkerPrototype
}
_ => RenderConsumerPath::LocalSynchronous,
}
}
}
pub trait RenderSurface {
fn consume_submission(&mut self, submission: &RenderSubmission);
}
#[derive(Debug, Default)]
pub struct LocalRenderWorker;
impl LocalRenderWorker {
pub fn consume_latest<S: RenderSurface>(
&mut self,
manager: &mut RenderManager,
surface: &mut S,
) -> bool {
manager.publish_latest(surface)
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct RenderTelemetrySnapshot {
pub produced_submissions: u64,
@ -499,6 +535,30 @@ mod tests {
assert!(!policy.uses_frame_scheduler());
}
#[test]
fn render_policy_resolves_game_worker_only_when_capability_is_enabled() {
let policy = RenderPolicy::for_app_mode(AppMode::Game);
assert_eq!(
policy.resolve_consumer_path(RenderRuntimeCapabilities::default()),
RenderConsumerPath::LocalSynchronous
);
assert_eq!(
policy.resolve_consumer_path(RenderRuntimeCapabilities { game_render_worker: true }),
RenderConsumerPath::LocalWorkerPrototype
);
}
#[test]
fn render_policy_keeps_shell_local_even_when_worker_capability_is_enabled() {
let policy = RenderPolicy::for_app_mode(AppMode::Shell);
assert_eq!(
policy.resolve_consumer_path(RenderRuntimeCapabilities { game_render_worker: true }),
RenderConsumerPath::LocalSynchronous
);
}
#[test]
fn active_render_policy_follows_app_mode_transition() {
let mut manager = RenderManager::new(AppMode::Game);
@ -522,6 +582,20 @@ mod tests {
assert_eq!(surface.seen, vec![FrameId::new(0)]);
}
#[test]
fn local_render_worker_consumes_latest_game_submission() {
let mut manager = RenderManager::new(AppMode::Game);
let mut surface = RecordingSurface::default();
let mut worker = LocalRenderWorker;
manager.close_compat_frame();
assert!(worker.consume_latest(&mut manager, &mut surface));
assert_eq!(surface.seen, vec![FrameId::ZERO]);
assert_eq!(manager.render_telemetry().consumed_submissions, 1);
assert_eq!(manager.render_telemetry().presented_frames, 1);
}
#[test]
fn render_handoff_takes_owned_latest_submission() {
let mut handoff = RenderHandoff::default();

View File

@ -1,5 +1,5 @@
use super::dispatch::VmRuntimeHost;
use super::render_manager::RenderSurface;
use super::render_manager::{LocalRenderWorker, RenderConsumerPath, RenderSurface};
use super::*;
use crate::CrashReport;
use crate::fs::{FsState, VirtualFS};
@ -261,7 +261,19 @@ impl VirtualMachineRuntime {
if let Err(payload) = catch_unwind(AssertUnwindSafe(|| {
let mut surface = HardwareRenderSurface { hw };
self.render_manager.publish_latest(&mut surface);
match self
.render_manager
.active_render_policy()
.resolve_consumer_path(self.render_capabilities)
{
RenderConsumerPath::LocalSynchronous => {
self.render_manager.publish_latest(&mut surface);
}
RenderConsumerPath::LocalWorkerPrototype => {
let mut worker = LocalRenderWorker;
worker.consume_latest(&mut self.render_manager, &mut surface);
}
}
})) {
let message = Self::host_panic_payload_to_string(payload);
let report = CrashReport::VmPanic { message, pc: Some(vm.pc() as u32) };

View File

@ -1,6 +1,6 @@
{"type":"meta","next_id":{"DSC":42,"AGD":42,"DEC":32,"PLN":98,"LSN":48,"CLSN":1}}
{"type":"discussion","id":"DSC-0039","status":"abandoned","ticket":"render-pipeline-family-and-future-3d","title":"Render Pipeline Family and Future 3D","created_at":"2026-06-04","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","architecture","pipeline"],"agendas":[{"id":"AGD-0039","file":"AGD-0039-render-pipeline-family-and-future-3d.md","status":"abandoned","created_at":"2026-06-04","updated_at":"2026-06-04","_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}],"decisions":[],"plans":[],"lessons":[],"_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}
{"type":"discussion","id":"DSC-0040","status":"in_progress","ticket":"vm-render-parallel-execution-boundary","title":"VM and Render Parallel Execution Boundary","created_at":"2026-06-04","updated_at":"2026-06-05","tags":["runtime","renderer","vm","concurrency","architecture","perf"],"agendas":[{"id":"AGD-0040","file":"AGD-0040-vm-and-render-parallel-execution-boundary.md","status":"accepted","created_at":"2026-06-04","updated_at":"2026-06-05"}],"decisions":[{"id":"DEC-0031","file":"DEC-0031-vm-and-render-parallel-execution-boundary.md","status":"accepted","created_at":"2026-06-05","updated_at":"2026-06-05","ref_agenda":"AGD-0040"}],"plans":[{"id":"PLN-0087","file":"PLN-0087-fix-game2d-packet-overlay-composition.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0088","file":"PLN-0088-define-read-only-render-resource-boundary.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0089","file":"PLN-0089-introduce-render-handoff-abstraction.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0090","file":"PLN-0090-add-render-frame-pacing-contract.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0091","file":"PLN-0091-implement-appmode-render-policy-matrix.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0092","file":"PLN-0092-add-render-epoch-ownership-transitions.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0093","file":"PLN-0093-add-render-telemetry-counters-and-events.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0094","file":"PLN-0094-specify-async-render-boundary.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0095","file":"PLN-0095-prototype-local-render-worker-capability.md","status":"open","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0096","file":"PLN-0096-define-render-shutdown-and-failure-handling.md","status":"open","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0097","file":"PLN-0097-add-async-render-integration-test-matrix.md","status":"open","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]}],"lessons":[]}
{"type":"discussion","id":"DSC-0040","status":"in_progress","ticket":"vm-render-parallel-execution-boundary","title":"VM and Render Parallel Execution Boundary","created_at":"2026-06-04","updated_at":"2026-06-05","tags":["runtime","renderer","vm","concurrency","architecture","perf"],"agendas":[{"id":"AGD-0040","file":"AGD-0040-vm-and-render-parallel-execution-boundary.md","status":"accepted","created_at":"2026-06-04","updated_at":"2026-06-05"}],"decisions":[{"id":"DEC-0031","file":"DEC-0031-vm-and-render-parallel-execution-boundary.md","status":"accepted","created_at":"2026-06-05","updated_at":"2026-06-05","ref_agenda":"AGD-0040"}],"plans":[{"id":"PLN-0087","file":"PLN-0087-fix-game2d-packet-overlay-composition.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0088","file":"PLN-0088-define-read-only-render-resource-boundary.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0089","file":"PLN-0089-introduce-render-handoff-abstraction.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0090","file":"PLN-0090-add-render-frame-pacing-contract.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0091","file":"PLN-0091-implement-appmode-render-policy-matrix.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0092","file":"PLN-0092-add-render-epoch-ownership-transitions.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0093","file":"PLN-0093-add-render-telemetry-counters-and-events.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0094","file":"PLN-0094-specify-async-render-boundary.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0095","file":"PLN-0095-prototype-local-render-worker-capability.md","status":"done","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0096","file":"PLN-0096-define-render-shutdown-and-failure-handling.md","status":"open","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]},{"id":"PLN-0097","file":"PLN-0097-add-async-render-integration-test-matrix.md","status":"open","created_at":"2026-06-05","updated_at":"2026-06-05","ref_decisions":["DEC-0031"]}],"lessons":[]}
{"type":"discussion","id":"DSC-0041","status":"open","ticket":"foreground-stack-game-pause-shell-vm-backed","title":"Foreground Stack, Game Pause, and VM-Backed Shell Coexistence","created_at":"2026-06-05","updated_at":"2026-06-05","tags":["runtime","os","lifecycle","shell","game","vm","foreground","architecture"],"agendas":[{"id":"AGD-0041","file":"AGD-0041-foreground-stack-game-pause-shell-vm-backed.md","status":"open","created_at":"2026-06-05","updated_at":"2026-06-05"}],"decisions":[],"plans":[],"lessons":[]}
{"type":"discussion","id":"DSC-0038","status":"done","ticket":"render-frame-packet-boundary","title":"Logical Render Pipelines and Command Packets","created_at":"2026-05-25","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","frame-composer","architecture","ui","pipeline"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0047","file":"discussion/lessons/DSC-0038-render-frame-packet-boundary/LSN-0047-typed-render-submissions-preserve-domain-boundaries.md","status":"done","created_at":"2026-06-04","updated_at":"2026-06-04"}]}
{"type":"discussion","id":"DSC-0035","status":"done","ticket":"task-owned-shell-windows","title":"Agenda - Task-Owned Shell Windows","created_at":"2026-05-15","updated_at":"2026-05-15","tags":["runtime","os","task","window-manager","shell","lifecycle"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0044","file":"discussion/lessons/DSC-0035-task-owned-shell-windows/LSN-0044-task-window-liveness-belongs-to-the-task.md","status":"done","created_at":"2026-05-15","updated_at":"2026-05-15"}]}

View File

@ -2,7 +2,7 @@
id: PLN-0095
ticket: vm-render-parallel-execution-boundary
title: Prototype Local Render Worker Capability
status: open
status: done
created: 2026-06-05
ref_decisions: [DEC-0031]
tags: [runtime, host, renderer, worker, prototype]