fix openxr line colors
This commit is contained in:
@@ -11,7 +11,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use wgui::gfx::{
|
use wgui::gfx::{
|
||||||
WGfx,
|
|
||||||
cmd::WGfxClearMode,
|
cmd::WGfxClearMode,
|
||||||
pass::WGfxPass,
|
pass::WGfxPass,
|
||||||
pipeline::{WGfxPipeline, WPipelineCreateInfo},
|
pipeline::{WGfxPipeline, WPipelineCreateInfo},
|
||||||
@@ -49,8 +48,6 @@ static COLORS: [[f32; 6]; 5] = {
|
|||||||
pub(super) struct LinePool {
|
pub(super) struct LinePool {
|
||||||
lines: IdMap<usize, LineContainer>,
|
lines: IdMap<usize, LineContainer>,
|
||||||
pipeline: Arc<WGfxPipeline<Vert2Uv>>,
|
pipeline: Arc<WGfxPipeline<Vert2Uv>>,
|
||||||
pass: WGfxPass<Vert2Uv>,
|
|
||||||
buf_color: Subbuffer<[f32]>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LinePool {
|
impl LinePool {
|
||||||
@@ -61,13 +58,22 @@ impl LinePool {
|
|||||||
WPipelineCreateInfo::new(app.gfx.surface_format),
|
WPipelineCreateInfo::new(app.gfx.surface_format),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
lines: IdMap::new(),
|
||||||
|
pipeline,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn allocate(&mut self, xr: &XrState, app: &AppState) -> anyhow::Result<usize> {
|
||||||
|
let id = LINE_AUTO_INCREMENT.fetch_add(1, Ordering::Relaxed);
|
||||||
|
|
||||||
let buf_color = app
|
let buf_color = app
|
||||||
.gfx
|
.gfx
|
||||||
.empty_buffer(BufferUsage::TRANSFER_DST | BufferUsage::UNIFORM_BUFFER, 6)?;
|
.empty_buffer(BufferUsage::TRANSFER_DST | BufferUsage::UNIFORM_BUFFER, 6)?;
|
||||||
|
|
||||||
let set0 = pipeline.buffer(0, buf_color.clone())?;
|
let set0 = self.pipeline.buffer(0, buf_color.clone())?;
|
||||||
|
|
||||||
let pass = pipeline.create_pass(
|
let pass = self.pipeline.create_pass(
|
||||||
[1.0, 1.0],
|
[1.0, 1.0],
|
||||||
app.gfx_extras.quad_verts.clone(),
|
app.gfx_extras.quad_verts.clone(),
|
||||||
0..4,
|
0..4,
|
||||||
@@ -76,22 +82,13 @@ impl LinePool {
|
|||||||
&Default::default(),
|
&Default::default(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(Self {
|
let srd = create_swapchain(xr, app.gfx.clone(), [1, 1, 1], SwapchainOpts::new())?;
|
||||||
lines: IdMap::new(),
|
|
||||||
pipeline,
|
|
||||||
pass,
|
|
||||||
buf_color,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn allocate(&mut self, xr: &XrState, gfx: Arc<WGfx>) -> anyhow::Result<usize> {
|
|
||||||
let id = LINE_AUTO_INCREMENT.fetch_add(1, Ordering::Relaxed);
|
|
||||||
|
|
||||||
let srd = create_swapchain(xr, gfx, [1, 1, 1], SwapchainOpts::new())?;
|
|
||||||
self.lines.insert(
|
self.lines.insert(
|
||||||
id,
|
id,
|
||||||
LineContainer {
|
LineContainer {
|
||||||
swapchain: srd,
|
swapchain: srd,
|
||||||
|
buf_color,
|
||||||
|
pass,
|
||||||
maybe_line: None,
|
maybe_line: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -165,13 +162,13 @@ impl LinePool {
|
|||||||
.next()
|
.next()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
self.buf_color.write()?[0..6].copy_from_slice(&COLORS[inner.color]);
|
line.buf_color.write()?[0..6].copy_from_slice(&COLORS[inner.color]);
|
||||||
|
|
||||||
let mut cmd_buffer = app
|
let mut cmd_buffer = app
|
||||||
.gfx
|
.gfx
|
||||||
.create_gfx_command_buffer(CommandBufferUsage::OneTimeSubmit)?;
|
.create_gfx_command_buffer(CommandBufferUsage::OneTimeSubmit)?;
|
||||||
cmd_buffer.begin_rendering(tgt, WGfxClearMode::DontCare)?;
|
cmd_buffer.begin_rendering(tgt, WGfxClearMode::DontCare)?;
|
||||||
cmd_buffer.run_ref(&self.pass)?;
|
cmd_buffer.run_ref(&line.pass)?;
|
||||||
cmd_buffer.end_rendering()?;
|
cmd_buffer.end_rendering()?;
|
||||||
|
|
||||||
futures.execute(cmd_buffer.queue.clone(), cmd_buffer.build()?)?;
|
futures.execute(cmd_buffer.queue.clone(), cmd_buffer.build()?)?;
|
||||||
@@ -217,5 +214,7 @@ pub(super) struct Line {
|
|||||||
|
|
||||||
struct LineContainer {
|
struct LineContainer {
|
||||||
swapchain: WlxSwapchain,
|
swapchain: WlxSwapchain,
|
||||||
|
buf_color: Subbuffer<[f32]>,
|
||||||
|
pass: WGfxPass<Vert2Uv>,
|
||||||
maybe_line: Option<Line>,
|
maybe_line: Option<Line>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ pub fn openxr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pointer_lines = [
|
let pointer_lines = [
|
||||||
lines.allocate(&xr_state, app.gfx.clone())?,
|
lines.allocate(&xr_state, &mut app)?,
|
||||||
lines.allocate(&xr_state, app.gfx.clone())?,
|
lines.allocate(&xr_state, &mut app)?,
|
||||||
];
|
];
|
||||||
|
|
||||||
let watch_id = overlays.lookup(WATCH_NAME).unwrap(); // want panic
|
let watch_id = overlays.lookup(WATCH_NAME).unwrap(); // want panic
|
||||||
|
|||||||
Reference in New Issue
Block a user