openxr: submit dummy layer if nothing is visible
This commit is contained in:
@@ -7,6 +7,7 @@ use std::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
},
|
||||
usize,
|
||||
};
|
||||
|
||||
use vulkano::{command_buffer::CommandBufferUsage, format::Format, image::view::ImageView};
|
||||
@@ -152,6 +153,14 @@ impl LinePool {
|
||||
|
||||
quads
|
||||
}
|
||||
|
||||
/// the number of lines that are waiting to be drawn
|
||||
pub(super) fn num_pending(&self) -> usize {
|
||||
self.lines
|
||||
.values()
|
||||
.filter(|l| l.maybe_line.is_some())
|
||||
.count()
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Line {
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use glam::Affine3A;
|
||||
use openxr as xr;
|
||||
use vulkano::{command_buffer::CommandBufferUsage, Handle, VulkanObject};
|
||||
|
||||
@@ -280,6 +281,17 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
};
|
||||
}
|
||||
|
||||
if layers.is_empty() && lines.num_pending() == 0 {
|
||||
// HACK: we need to submit at least 1 layer, else the session hangs
|
||||
lines.draw_from(
|
||||
pointer_lines[0],
|
||||
Affine3A::IDENTITY,
|
||||
0.002,
|
||||
0,
|
||||
&app_state.input_state.hmd,
|
||||
);
|
||||
}
|
||||
|
||||
for quad in lines.present_xr(&xr_state, &mut command_buffer) {
|
||||
layers.push((0.0, quad));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user