openxr: configurable screen downscale

This commit is contained in:
galister
2024-07-29 22:14:25 +09:00
parent 57ff3ec3bc
commit dcc2cd0575
7 changed files with 58 additions and 17 deletions

View File

@@ -189,4 +189,7 @@ impl OverlayRenderer for StaticRenderer {
fn view(&mut self) -> Option<Arc<ImageView>> {
Some(self.view.clone())
}
fn extent(&mut self) -> Option<[u32; 3]> {
Some(self.view.image().extent())
}
}

View File

@@ -38,7 +38,8 @@ impl OverlayData<OpenXrOverlayData> {
log::warn!("{}: Will not show - image not ready", self.state.name);
return Ok(CompositionLayer::None);
};
let extent = my_view.image().extent();
let extent = self.extent().unwrap(); // want panic
let data = match self.data.swapchain {
Some(ref mut data) => data,

View File

@@ -224,6 +224,9 @@ where
pub fn view(&mut self) -> Option<Arc<ImageView>> {
self.backend.view()
}
pub fn extent(&mut self) -> Option<[u32; 3]> {
self.backend.extent()
}
pub fn set_visible(&mut self, app: &mut AppState, visible: bool) -> anyhow::Result<()> {
let old_visible = self.state.want_visible;
self.state.want_visible = visible;
@@ -239,11 +242,19 @@ where
}
pub trait OverlayRenderer {
/// Called once, before the first frame is rendered
fn init(&mut self, app: &mut AppState) -> anyhow::Result<()>;
fn pause(&mut self, app: &mut AppState) -> anyhow::Result<()>;
fn resume(&mut self, app: &mut AppState) -> anyhow::Result<()>;
/// Called when the presentation layer is ready to present a new frame
fn render(&mut self, app: &mut AppState) -> anyhow::Result<()>;
/// Called to retrieve the current image to be displayed
fn view(&mut self) -> Option<Arc<ImageView>>;
/// Called to retrieve the effective extent of the image
/// Used for creating swapchains.
///
/// Muse not be None if view() is also not None
fn extent(&mut self) -> Option<[u32; 3]>;
}
pub struct FallbackRenderer;
@@ -264,6 +275,9 @@ impl OverlayRenderer for FallbackRenderer {
fn view(&mut self) -> Option<Arc<ImageView>> {
None
}
fn extent(&mut self) -> Option<[u32; 3]> {
None
}
}
// Boilerplate and dummies
@@ -318,6 +332,9 @@ impl OverlayRenderer for SplitOverlayBackend {
fn view(&mut self) -> Option<Arc<ImageView>> {
self.renderer.view()
}
fn extent(&mut self) -> Option<[u32; 3]> {
self.renderer.extent()
}
}
impl InteractionHandler for SplitOverlayBackend {
fn on_left(&mut self, app: &mut AppState, pointer: usize) {