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]
name = "wlx-capture"
version = "0.5.3"
edition = "2021"
edition = "2024"
authors = ["galister"]
description = "Screen capture library for Wayland and X11"
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
[dependencies]
ashpd = { version = "0.11.0", default_features = false, features = [
ashpd = { version = "0.11.0", default-features = false, features = [
"async-std",
], optional = true }
drm-fourcc = "2.2.0"

View File

@@ -5,12 +5,20 @@ debug = true
[package]
name = "wlx-overlay-s"
version = "25.4.2"
edition = "2021"
edition = "2024"
license = "GPL-3.0-only"
authors = ["galister"]
description = "Access your Wayland/X11 desktop from Monado/WiVRn/SteamVR. Now with Vulkan!"
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"]
# 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,
};
let mut out = xr::sys::Session::NULL;
let x = (instance.fp().create_session)(instance.as_raw(), &info, &mut out);
if x.into_raw() >= 0 {
Ok(out)
} else {
Err(x)
}
let x = unsafe { (instance.fp().create_session)(instance.as_raw(), &info, &mut out) };
if x.into_raw() >= 0 { Ok(out) } else { Err(x) }
}
type Vec3M = mint::Vector3<f32>;

View File

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

View File

@@ -6,7 +6,7 @@ use std::{
sync::{Arc, OnceLock},
};
use glam::{vec2, Vec2};
use glam::{Vec2, vec2};
use vulkano::{
buffer::{BufferCreateInfo, BufferUsage},
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 vulkano::{
self,
self, VulkanObject,
buffer::{Buffer, BufferContents, IndexBuffer, Subbuffer},
device::{
physical::{PhysicalDevice, PhysicalDeviceType},
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, Queue, QueueCreateInfo,
QueueFlags,
physical::{PhysicalDevice, PhysicalDeviceType},
},
format::Format,
instance::{Instance, InstanceCreateInfo, InstanceExtensions},
@@ -40,7 +40,6 @@ use vulkano::{
vertex_input::Vertex,
},
shader::ShaderModule,
VulkanObject,
};
use dmabuf::get_drm_formats;
@@ -159,7 +158,7 @@ unsafe extern "system" fn get_instance_proc_addr(
use vulkano::Handle;
let instance = ash::vk::Instance::from_raw(instance as _);
let library = get_vulkan_library();
library.get_instance_proc_addr(instance, name)
unsafe { library.get_instance_proc_addr(instance, name) }
}
#[cfg(feature = "openxr")]

View File

@@ -1,10 +1,10 @@
#[derive(rust_embed::Embed)]
#[folder = "src/gui/assets/"]
#[folder = "src/assets/"]
pub struct GuiAsset;
impl wgui::assets::AssetProvider for GuiAsset {
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()),
None => anyhow::bail!("embedded file {} not found", path),
}

View File

@@ -136,7 +136,7 @@ impl OverlayRenderer for GuiPanel {
_alpha: f32,
) -> anyhow::Result<bool> {
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
.gfx

View File

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