rust 2024

This commit is contained in:
Aleksander
2025-06-17 18:29:57 +02:00
parent f05d3a8251
commit cc26831e35
8 changed files with 47 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "wlx-capture" name = "wlx-capture"
version = "0.5.3" version = "0.5.3"
edition = "2021" edition = "2024"
authors = ["galister"] authors = ["galister"]
description = "Screen capture library for Wayland and X11" description = "Screen capture library for Wayland and X11"
repository = "https://github.com/galister/wlx-capture" repository = "https://github.com/galister/wlx-capture"
@@ -25,7 +25,7 @@ xshm = ["dep:rxscreen"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
ashpd = { version = "0.11.0", default_features = false, features = [ ashpd = { version = "0.11.0", default-features = false, features = [
"async-std", "async-std",
], optional = true } ], optional = true }
drm-fourcc = "2.2.0" drm-fourcc = "2.2.0"

View File

@@ -5,12 +5,20 @@ debug = true
[package] [package]
name = "wlx-overlay-s" name = "wlx-overlay-s"
version = "25.4.2" version = "25.4.2"
edition = "2021" edition = "2024"
license = "GPL-3.0-only" license = "GPL-3.0-only"
authors = ["galister"] authors = ["galister"]
description = "Access your Wayland/X11 desktop from Monado/WiVRn/SteamVR. Now with Vulkan!" description = "Access your Wayland/X11 desktop from Monado/WiVRn/SteamVR. Now with Vulkan!"
repository = "https://github.com/galister/wlx-overlay-s" repository = "https://github.com/galister/wlx-overlay-s"
keywords = ["linux", "openvr", "openxr", "x11", "wayland", "openvr-overlay", "openxr-overlay"] keywords = [
"linux",
"openvr",
"openxr",
"x11",
"wayland",
"openvr-overlay",
"openxr-overlay",
]
categories = ["games"] categories = ["games"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -132,12 +132,8 @@ pub(super) unsafe fn create_overlay_session(
system_id: system, system_id: system,
}; };
let mut out = xr::sys::Session::NULL; let mut out = xr::sys::Session::NULL;
let x = (instance.fp().create_session)(instance.as_raw(), &info, &mut out); let x = unsafe { (instance.fp().create_session)(instance.as_raw(), &info, &mut out) };
if x.into_raw() >= 0 { if x.into_raw() >= 0 { Ok(out) } else { Err(x) }
Ok(out)
} else {
Err(x)
}
} }
type Vec3M = mint::Vector3<f32>; type Vec3M = mint::Vector3<f32>;

View File

@@ -6,21 +6,21 @@ use std::{
use smallvec::SmallVec; use smallvec::SmallVec;
use vulkano::{ use vulkano::{
VulkanError, VulkanObject,
device::Device, device::Device,
format::Format, format::Format,
image::{sys::RawImage, Image, ImageCreateInfo, ImageTiling, ImageUsage, SubresourceLayout}, image::{Image, ImageCreateInfo, ImageTiling, ImageUsage, SubresourceLayout, sys::RawImage},
memory::{ memory::{
allocator::{MemoryAllocator, MemoryTypeFilter},
DedicatedAllocation, DeviceMemory, ExternalMemoryHandleType, ExternalMemoryHandleTypes, DedicatedAllocation, DeviceMemory, ExternalMemoryHandleType, ExternalMemoryHandleTypes,
MemoryAllocateInfo, MemoryImportInfo, MemoryPropertyFlags, ResourceMemory, MemoryAllocateInfo, MemoryImportInfo, MemoryPropertyFlags, ResourceMemory,
allocator::{MemoryAllocator, MemoryTypeFilter},
}, },
sync::Sharing, sync::Sharing,
VulkanError, VulkanObject,
}; };
use wgui::gfx::WGfx; use wgui::gfx::WGfx;
use wlx_capture::frame::{ use wlx_capture::frame::{
DmabufFrame, DrmFormat, FourCC, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR8888, DRM_FORMAT_ABGR8888, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR8888,
DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XBGR2101010, DRM_FORMAT_XRGB8888, DmabufFrame, DrmFormat, FourCC,
}; };
pub const DRM_FORMAT_MOD_INVALID: u64 = 0xff_ffff_ffff_ffff; pub const DRM_FORMAT_MOD_INVALID: u64 = 0xff_ffff_ffff_ffff;
@@ -284,6 +284,7 @@ pub(super) unsafe fn create_dmabuf_image(
create_info_vk.p_next = next as *const _ as *const _; create_info_vk.p_next = next as *const _ as *const _;
} }
unsafe {
let handle = { let handle = {
let fns = device.fns(); let fns = device.fns();
let mut output = MaybeUninit::uninit(); let mut output = MaybeUninit::uninit();
@@ -299,6 +300,7 @@ pub(super) unsafe fn create_dmabuf_image(
}; };
RawImage::from_handle(device, handle, create_info) RawImage::from_handle(device, handle, create_info)
}
} }
pub fn get_drm_formats(device: Arc<Device>) -> Vec<DrmFormat> { pub fn get_drm_formats(device: Arc<Device>) -> Vec<DrmFormat> {

View File

@@ -6,7 +6,7 @@ use std::{
sync::{Arc, OnceLock}, sync::{Arc, OnceLock},
}; };
use glam::{vec2, Vec2}; use glam::{Vec2, vec2};
use vulkano::{ use vulkano::{
buffer::{BufferCreateInfo, BufferUsage}, buffer::{BufferCreateInfo, BufferUsage},
command_buffer::{PrimaryAutoCommandBuffer, PrimaryCommandBufferAbstract}, command_buffer::{PrimaryAutoCommandBuffer, PrimaryCommandBufferAbstract},
@@ -26,12 +26,12 @@ use crate::shaders::{frag_color, frag_grid, frag_screen, frag_srgb, vert_quad};
use {ash::vk, std::os::raw::c_void}; use {ash::vk, std::os::raw::c_void};
use vulkano::{ use vulkano::{
self, self, VulkanObject,
buffer::{Buffer, BufferContents, IndexBuffer, Subbuffer}, buffer::{Buffer, BufferContents, IndexBuffer, Subbuffer},
device::{ device::{
physical::{PhysicalDevice, PhysicalDeviceType},
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, Queue, QueueCreateInfo, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, Queue, QueueCreateInfo,
QueueFlags, QueueFlags,
physical::{PhysicalDevice, PhysicalDeviceType},
}, },
format::Format, format::Format,
instance::{Instance, InstanceCreateInfo, InstanceExtensions}, instance::{Instance, InstanceCreateInfo, InstanceExtensions},
@@ -40,7 +40,6 @@ use vulkano::{
vertex_input::Vertex, vertex_input::Vertex,
}, },
shader::ShaderModule, shader::ShaderModule,
VulkanObject,
}; };
use dmabuf::get_drm_formats; use dmabuf::get_drm_formats;
@@ -159,7 +158,7 @@ unsafe extern "system" fn get_instance_proc_addr(
use vulkano::Handle; use vulkano::Handle;
let instance = ash::vk::Instance::from_raw(instance as _); let instance = ash::vk::Instance::from_raw(instance as _);
let library = get_vulkan_library(); let library = get_vulkan_library();
library.get_instance_proc_addr(instance, name) unsafe { library.get_instance_proc_addr(instance, name) }
} }
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]

View File

@@ -1,10 +1,10 @@
#[derive(rust_embed::Embed)] #[derive(rust_embed::Embed)]
#[folder = "src/gui/assets/"] #[folder = "src/assets/"]
pub struct GuiAsset; pub struct GuiAsset;
impl wgui::assets::AssetProvider for GuiAsset { impl wgui::assets::AssetProvider for GuiAsset {
fn load_from_path(&mut self, path: &str) -> anyhow::Result<Vec<u8>> { fn load_from_path(&mut self, path: &str) -> anyhow::Result<Vec<u8>> {
match GuiAsset::get(path) { match Self::get(path) {
Some(data) => Ok(data.data.to_vec()), Some(data) => Ok(data.data.to_vec()),
None => anyhow::bail!("embedded file {} not found", path), None => anyhow::bail!("embedded file {} not found", path),
} }

View File

@@ -136,7 +136,7 @@ impl OverlayRenderer for GuiPanel {
_alpha: f32, _alpha: f32,
) -> anyhow::Result<bool> { ) -> anyhow::Result<bool> {
self.context.update_viewport(tgt.extent_u32arr(), 1.0)?; self.context.update_viewport(tgt.extent_u32arr(), 1.0)?;
self.layout.update(tgt.extent_vec2(), self.timestep.alpha); self.layout.update(tgt.extent_vec2(), self.timestep.alpha)?;
let mut cmd_buf = app let mut cmd_buf = app
.gfx .gfx

View File

@@ -1,13 +1,13 @@
use std::{ use std::{
collections::HashMap, collections::HashMap,
process::{Child, Command}, process::Child,
str::FromStr, str::FromStr,
sync::{Arc, LazyLock}, sync::{Arc, LazyLock},
}; };
use crate::{ use crate::{
backend::{ backend::{
input::{InteractionHandler, PointerMode}, input::InteractionHandler,
overlay::{ overlay::{
FrameMeta, OverlayBackend, OverlayData, OverlayRenderer, OverlayState, Positioning, FrameMeta, OverlayBackend, OverlayData, OverlayRenderer, OverlayState, Positioning,
ShouldRender, ShouldRender,
@@ -17,12 +17,12 @@ use crate::{
graphics::CommandBuffers, graphics::CommandBuffers,
gui::panel::GuiPanel, gui::panel::GuiPanel,
hid::{ hid::{
get_key_type, KeyModifier, KeyType, VirtualKey, XkbKeymap, ALT, CTRL, KEYS_TO_MODS, META, ALT, CTRL, KEYS_TO_MODS, KeyModifier, KeyType, META, NUM_LOCK, SHIFT, SUPER, VirtualKey,
NUM_LOCK, SHIFT, SUPER, XkbKeymap, get_key_type,
}, },
state::{AppState, KeyboardFocus}, state::{AppState, KeyboardFocus},
}; };
use glam::{vec2, vec3a, Affine2, Vec2Swizzles, Vec4}; use glam::{Affine2, vec2, vec3a};
use regex::Regex; use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use vulkano::image::view::ImageView; use vulkano::image::view::ImageView;