cleanup features
This commit is contained in:
@@ -4,9 +4,11 @@ use std::{
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
use openxr as xr;
|
||||
|
||||
use glam::{Affine3A, Vec2, Vec3A};
|
||||
use idmap::IdMap;
|
||||
use openxr as xr;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
io::Cursor,
|
||||
os::{
|
||||
fd::{FromRawFd, IntoRawFd},
|
||||
raw::c_void,
|
||||
},
|
||||
os::fd::{FromRawFd, IntoRawFd},
|
||||
slice::Iter,
|
||||
sync::{Arc, OnceLock, RwLock},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, bail};
|
||||
use ash::vk::{self, SubmitInfo};
|
||||
use ash::vk::SubmitInfo;
|
||||
use smallvec::smallvec;
|
||||
|
||||
#[cfg(feature = "openvr")]
|
||||
use vulkano::{
|
||||
device::physical::PhysicalDeviceType, instance::InstanceCreateFlags,
|
||||
instance::InstanceExtensions,
|
||||
};
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
use {ash::vk, std::os::raw::c_void, vulkano::swapchain::Surface};
|
||||
|
||||
use vulkano::{
|
||||
buffer::{
|
||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||
@@ -30,7 +37,6 @@ use vulkano::{
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
},
|
||||
device::physical::PhysicalDeviceType,
|
||||
device::Features,
|
||||
device::{
|
||||
physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceExtensions, Queue,
|
||||
@@ -44,8 +50,6 @@ use vulkano::{
|
||||
Image, ImageCreateInfo, ImageLayout, ImageTiling, ImageType, ImageUsage, SampleCount,
|
||||
SubresourceLayout,
|
||||
},
|
||||
instance::InstanceCreateFlags,
|
||||
instance::InstanceExtensions,
|
||||
instance::{Instance, InstanceCreateInfo},
|
||||
memory::{
|
||||
allocator::{
|
||||
@@ -75,7 +79,6 @@ use vulkano::{
|
||||
SubpassDescription,
|
||||
},
|
||||
shader::ShaderModule,
|
||||
swapchain::Surface,
|
||||
sync::{
|
||||
fence::Fence, future::NowFuture, AccessFlags, DependencyInfo, GpuFuture,
|
||||
ImageMemoryBarrier, PipelineStages,
|
||||
@@ -729,6 +732,7 @@ impl WlxGraphics {
|
||||
)?))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn create_pipeline_dynamic(
|
||||
self: &Arc<Self>,
|
||||
vert: Arc<ShaderModule>,
|
||||
@@ -763,6 +767,7 @@ impl WlxGraphics {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn transition_layout(
|
||||
&self,
|
||||
image: Arc<Image>,
|
||||
@@ -827,6 +832,7 @@ pub struct WlxCommandBuffer {
|
||||
pub command_buffer: RecordingCommandBuffer,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl WlxCommandBuffer {
|
||||
pub fn begin_render_pass(
|
||||
&mut self,
|
||||
@@ -925,9 +931,7 @@ impl WlxCommandBuffer {
|
||||
reader.next_frame(&mut image_data)?;
|
||||
self.texture2d(width, height, Format::R8G8B8A8_UNORM, &image_data)
|
||||
}
|
||||
}
|
||||
|
||||
impl WlxCommandBuffer {
|
||||
pub fn end_render_pass(&mut self) -> anyhow::Result<()> {
|
||||
self.command_buffer
|
||||
.end_render_pass(SubpassEndInfo::default())?;
|
||||
@@ -971,6 +975,7 @@ pub struct WlxPipeline<D> {
|
||||
pub data: D,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl WlxPipeline<WlxPipelineDynamic> {
|
||||
fn new(
|
||||
graphics: Arc<WlxGraphics>,
|
||||
|
||||
@@ -53,7 +53,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "openxr", feature = "openvr"))]
|
||||
fn auto_run(running: Arc<AtomicBool>) {
|
||||
use backend::common::BackendError;
|
||||
|
||||
@@ -65,7 +64,7 @@ fn auto_run(running: Arc<AtomicBool>) {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
#[cfg(feature = "openvr")]
|
||||
{
|
||||
use crate::backend::openvr::openvr_run;
|
||||
let Err(BackendError::NotSupported) = openvr_run(running) else {
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
use core::slice;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
error::Error,
|
||||
f32::consts::PI,
|
||||
ops::{Add, Deref},
|
||||
path::PathBuf,
|
||||
ops::Add,
|
||||
ptr,
|
||||
sync::{mpsc::Receiver, Arc},
|
||||
time::{Duration, Instant},
|
||||
@@ -19,14 +15,26 @@ use wlx_capture::{
|
||||
DrmFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
|
||||
DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
||||
},
|
||||
pipewire::{pipewire_select_screen, PipewireCapture},
|
||||
wayland::{wayland_client::protocol::wl_output::Transform, WlxClient, WlxOutput},
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
xshm::{XshmCapture, XshmScreen},
|
||||
wayland::wayland_client::protocol::wl_output::Transform,
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
use glam::{vec2, vec3a, Affine2, Quat, Vec2, Vec3};
|
||||
#[cfg(feature = "wayland")]
|
||||
use {
|
||||
crate::config_io,
|
||||
glam::Vec3,
|
||||
std::{collections::HashMap, error::Error, f32::consts::PI, ops::Deref, path::PathBuf},
|
||||
wlx_capture::{
|
||||
pipewire::{pipewire_select_screen, PipewireCapture},
|
||||
wayland::{WlxClient, WlxOutput},
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "x11")]
|
||||
use wlx_capture::xshm::{XshmCapture, XshmScreen};
|
||||
|
||||
use glam::{vec2, vec3a, Affine2, Quat, Vec2};
|
||||
|
||||
use crate::{
|
||||
backend::{
|
||||
@@ -34,7 +42,6 @@ use crate::{
|
||||
overlay::{OverlayData, OverlayRenderer, OverlayState, SplitOverlayBackend},
|
||||
},
|
||||
config::def_pw_tokens,
|
||||
config_io,
|
||||
graphics::{fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy},
|
||||
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
||||
state::{AppSession, AppState},
|
||||
@@ -356,12 +363,15 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
log::error!("Invalid frame");
|
||||
continue;
|
||||
}
|
||||
if let Ok(new) = app.graphics.dmabuf_texture(frame) {
|
||||
match app.graphics.dmabuf_texture(frame) {
|
||||
Ok(new) => {
|
||||
let view = ImageView::new_default(new.clone())?;
|
||||
|
||||
self.last_view = Some(view);
|
||||
} else {
|
||||
log::error!("{}: Failed to create DMA-buf texture", self.name);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("{}: Failed to create DMA-buf texture: {}", self.name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
WlxFrame::MemFd(frame) => {
|
||||
@@ -596,12 +606,14 @@ pub struct TokenConf {
|
||||
pub pw_tokens: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
fn get_pw_token_path() -> PathBuf {
|
||||
let mut path = config_io::get_conf_d_path();
|
||||
path.push("pw_tokens.yaml");
|
||||
path
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
pub fn save_pw_token_config(tokens: &HashMap<String, String>) -> Result<(), Box<dyn Error>> {
|
||||
let mut conf = TokenConf::default();
|
||||
|
||||
@@ -615,6 +627,7 @@ pub fn save_pw_token_config(tokens: &HashMap<String, String>) -> Result<(), Box<
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
pub fn load_pw_token_config() -> Result<HashMap<String, String>, Box<dyn Error>> {
|
||||
let mut map: HashMap<String, String> = HashMap::new();
|
||||
|
||||
@@ -629,11 +642,11 @@ pub fn load_pw_token_config() -> Result<HashMap<String, String>, Box<dyn Error>>
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "wayland"))]
|
||||
pub fn get_screens_wayland<O>(_session: &AppSession) -> (Vec<OverlayData<O>>, Vec2)
|
||||
pub fn get_screens_wayland<O>(_session: &AppSession) -> anyhow::Result<(Vec<OverlayData<O>>, Vec2)>
|
||||
where
|
||||
O: Default,
|
||||
{
|
||||
panic!("Wayland support not enabled")
|
||||
anyhow::bail!("Wayland support not enabled")
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
@@ -671,11 +684,11 @@ where
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "x11"))]
|
||||
pub fn get_screens_x11<O>(session: &AppSession) -> (Vec<OverlayData<O>>, Vec2)
|
||||
pub fn get_screens_x11<O>(_session: &AppSession) -> anyhow::Result<(Vec<OverlayData<O>>, Vec2)>
|
||||
where
|
||||
O: Default,
|
||||
{
|
||||
panic!("X11 support not enabled")
|
||||
anyhow::bail!("X11 support not enabled")
|
||||
}
|
||||
|
||||
#[cfg(feature = "x11")]
|
||||
|
||||
Reference in New Issue
Block a user