From b4af0e6caace516cf49b0d552aa0d8bb030defa2 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Sat, 10 Jan 2026 01:13:17 +0900 Subject: [PATCH] fix dma-buf export via vulkano patch --- Cargo.lock | 62 +++++++++++++++++++-------- Cargo.toml | 3 +- wayvr/Cargo.toml | 2 +- wayvr/src/backend/openxr/helpers.rs | 13 +++--- wayvr/src/graphics/dmabuf.rs | 15 ++----- wayvr/src/overlays/keyboard/layout.rs | 1 - wayvr/src/overlays/screen/capture.rs | 4 +- 7 files changed, 60 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 423e1da..8f8c429 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -293,7 +293,7 @@ version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "libloading", + "libloading 0.8.9", ] [[package]] @@ -957,7 +957,7 @@ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", - "libloading", + "libloading 0.8.9", ] [[package]] @@ -1544,7 +1544,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading", + "libloading 0.8.9", ] [[package]] @@ -2875,6 +2875,16 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "libloading" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" +dependencies = [ + "cfg-if", + "windows-link 0.2.1", +] + [[package]] name = "libm" version = "0.2.15" @@ -3730,19 +3740,21 @@ dependencies = [ [[package]] name = "openxr" -version = "0.19.0" -source = "git+https://github.com/Ralith/openxrs?rev=d0afdd3365bc1e14de28f6a3a21f457e788a702e#d0afdd3365bc1e14de28f6a3a21f457e788a702e" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a7b5f4a26a71928a11b912f94c387378b1c14caac3bde3d9cecd4bb8870262" dependencies = [ "libc", - "libloading", + "libloading 0.9.0", "ndk-context", "openxr-sys", ] [[package]] name = "openxr-sys" -version = "0.11.0" -source = "git+https://github.com/Ralith/openxrs?rev=d0afdd3365bc1e14de28f6a3a21f457e788a702e#d0afdd3365bc1e14de28f6a3a21f457e788a702e" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b69a1e728e450d419fa7e82fdfb2988d4a0eadd6bdd16fceff72f1b485c4d96b" dependencies = [ "libc", "mint", @@ -5825,7 +5837,7 @@ dependencies = [ "log", "rust-embed", "tracing-subscriber", - "vulkano", + "vulkano 0.35.0", "vulkano-shaders", "wgui", "winit", @@ -5983,6 +5995,25 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "vulkano" +version = "0.35.0" +dependencies = [ + "ash", + "bytemuck", + "crossbeam-queue", + "foldhash 0.1.5", + "half", + "libloading 0.8.9", + "parking_lot", + "raw-window-handle", + "raw-window-metal", + "slabbin", + "smallvec", + "thread_local", + "vulkano-macros", +] + [[package]] name = "vulkano" version = "0.35.2" @@ -5996,7 +6027,7 @@ dependencies = [ "half", "heck 0.4.1", "indexmap 2.12.1", - "libloading", + "libloading 0.8.9", "nom 7.1.3", "once_cell", "parking_lot", @@ -6010,14 +6041,11 @@ dependencies = [ "smallvec", "thread_local", "vk-parse", - "vulkano-macros", ] [[package]] name = "vulkano-macros" version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dc929c42c9336fd082079ac3ea30126e4a0dfe36fd2e2b3581303f7d140d20f" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6037,7 +6065,7 @@ dependencies = [ "quote", "shaderc", "syn 2.0.113", - "vulkano", + "vulkano 0.35.2", ] [[package]] @@ -6335,7 +6363,7 @@ dependencies = [ "tracing", "tracing-subscriber", "uuid", - "vulkano", + "vulkano 0.35.0", "vulkano-shaders", "wayland-client", "wayvr-ipc", @@ -6427,7 +6455,7 @@ dependencies = [ "slotmap", "smallvec", "taffy", - "vulkano", + "vulkano 0.35.0", "vulkano-shaders", ] @@ -7021,7 +7049,7 @@ dependencies = [ "as-raw-xcb-connection", "gethostname", "libc", - "libloading", + "libloading 0.8.9", "once_cell", "rustix 1.1.3", "x11rb-protocol", diff --git a/Cargo.toml b/Cargo.toml index 7654ac6..e8b3178 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,8 @@ serde = { version = "1", features = ["derive"] } serde_json = "1.0.145" slotmap = "1.1.1" strum = { version = "0.27.2", features = ["derive"] } -vulkano = { version = "0.35.2", default-features = false, features = [ +# vulkano = { version = "0.35.2", default-features = false, features = [ +vulkano = { git = "https://github.com/galister/vulkano.git", rev = "ee170056e0402e18eb352df36894aa1f1d35aaad", default-features = false, features = [ "macros", ] } vulkano-shaders = "0.35.0" diff --git a/wayvr/Cargo.toml b/wayvr/Cargo.toml index fe4ee41..96e90bd 100644 --- a/wayvr/Cargo.toml +++ b/wayvr/Cargo.toml @@ -60,7 +60,7 @@ libc = "0.2.178" libmonado = { git = "https://github.com/technobaboo/libmonado-rs.git", rev = "26292e5b14663ee2f089f66f0851438a0c00ee67", optional = true } log-panics = { version = "2.1.0", features = ["with-backtrace"] } mint = "0.5.9" -openxr = { git = "https://github.com/Ralith/openxrs", rev = "d0afdd3365bc1e14de28f6a3a21f457e788a702e", features = [ +openxr = { version = "0.21.0", features = [ "linked", "mint", ], optional = true } diff --git a/wayvr/src/backend/openxr/helpers.rs b/wayvr/src/backend/openxr/helpers.rs index f8a2798..4a0510a 100644 --- a/wayvr/src/backend/openxr/helpers.rs +++ b/wayvr/src/backend/openxr/helpers.rs @@ -1,6 +1,6 @@ use anyhow::{bail, ensure}; use glam::{Affine3A, Quat, Vec3, Vec3A}; -use openxr::{self as xr, SessionCreateFlags, Version}; +use openxr::{self as xr, SessionCreateFlags, Version, sys::Handle}; use xr::OverlaySessionCreateFlagsEXTX; pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> { @@ -47,13 +47,10 @@ pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> { } else { log::warn!("Missing EXT_composition_layer_equirect2 extension."); } - if available_extensions - .other - .contains(&"XR_MNDX_system_buttons".to_owned()) - { - enabled_extensions - .other - .push("XR_MNDX_system_buttons".to_owned()); + + let xr_mndx_system_buttons = "XR_MNDX_system_buttons".as_bytes().to_vec(); + if available_extensions.other.contains(&xr_mndx_system_buttons) { + enabled_extensions.other.push(xr_mndx_system_buttons); } //#[cfg(not(debug_assertions))] diff --git a/wayvr/src/graphics/dmabuf.rs b/wayvr/src/graphics/dmabuf.rs index 35bdcd2..615517a 100644 --- a/wayvr/src/graphics/dmabuf.rs +++ b/wayvr/src/graphics/dmabuf.rs @@ -11,8 +11,8 @@ use vulkano::{ device::Device, format::Format, image::{ - Image, ImageCreateInfo, ImageMemory, ImageTiling, ImageType, ImageUsage, SubresourceLayout, - sys::RawImage, view::ImageView, + Image, ImageAspect, ImageCreateInfo, ImageMemory, ImageTiling, ImageType, ImageUsage, + SubresourceLayout, sys::RawImage, view::ImageView, }, memory::{ DedicatedAllocation, DeviceMemory, ExternalMemoryHandleType, ExternalMemoryHandleTypes, @@ -316,14 +316,6 @@ pub fn export_dmabuf_image( format: Format, modifier: DrmModifier, ) -> anyhow::Result { - let layout = SubresourceLayout { - offset: 0, - size: 0, - row_pitch: align_to(format.block_size() * (extent[0] as u64), 64), - array_pitch: None, - depth_pitch: None, - }; - let image = Image::new( allocator.clone(), ImageCreateInfo { @@ -333,7 +325,6 @@ pub fn export_dmabuf_image( usage: ImageUsage::TRANSFER_DST | ImageUsage::TRANSFER_SRC | ImageUsage::SAMPLED, tiling: ImageTiling::DrmFormatModifier, drm_format_modifiers: vec![modifier.into()], - drm_format_modifier_plane_layouts: vec![layout], external_memory_handle_types: ExternalMemoryHandleTypes::DMA_BUF, ..Default::default() }, @@ -353,6 +344,8 @@ pub fn export_dmabuf_image( _ => anyhow::bail!("Could not export DMA-buf: invalid ImageMemory"), }; + let layout = unsafe { image.subresource_layout_unchecked(ImageAspect::MemoryPlane0, 0, 0) }; + Ok(ExportedDmabufImage { view: ImageView::new_default(image)?, fd, diff --git a/wayvr/src/overlays/keyboard/layout.rs b/wayvr/src/overlays/keyboard/layout.rs index 4e79e8b..2af0590 100644 --- a/wayvr/src/overlays/keyboard/layout.rs +++ b/wayvr/src/overlays/keyboard/layout.rs @@ -2,7 +2,6 @@ use std::{collections::HashMap, str::FromStr, sync::LazyLock}; use regex::Regex; use serde::{Deserialize, Serialize}; -use wlx_common::config::AltModifier; use crate::{ config::{ConfigType, load_known_yaml}, diff --git a/wayvr/src/overlays/screen/capture.rs b/wayvr/src/overlays/screen/capture.rs index b52c13d..7c6a726 100644 --- a/wayvr/src/overlays/screen/capture.rs +++ b/wayvr/src/overlays/screen/capture.rs @@ -429,7 +429,9 @@ impl MyFirstDmaExporter { for _ in 0..2 { let image = export_dmabuf_image(allocator.clone(), [width, height, 1], format, modifier) - .log_err("Could not export DMA-buf image") + .log_err(&format!( + "Could not export DMA-buf image {width}x{height} {fourcc} {modifier:?}" + )) .ok()?; self.images.push(image);