fix dma-buf export via vulkano patch

This commit is contained in:
galister
2026-01-10 01:13:17 +09:00
parent ac05e95e9c
commit b4af0e6caa
7 changed files with 60 additions and 40 deletions

62
Cargo.lock generated
View File

@@ -293,7 +293,7 @@ version = "0.38.0+1.3.281"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
dependencies = [ dependencies = [
"libloading", "libloading 0.8.9",
] ]
[[package]] [[package]]
@@ -957,7 +957,7 @@ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
dependencies = [ dependencies = [
"glob", "glob",
"libc", "libc",
"libloading", "libloading 0.8.9",
] ]
[[package]] [[package]]
@@ -1544,7 +1544,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [ dependencies = [
"libloading", "libloading 0.8.9",
] ]
[[package]] [[package]]
@@ -2875,6 +2875,16 @@ dependencies = [
"windows-link 0.2.1", "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]] [[package]]
name = "libm" name = "libm"
version = "0.2.15" version = "0.2.15"
@@ -3730,19 +3740,21 @@ dependencies = [
[[package]] [[package]]
name = "openxr" name = "openxr"
version = "0.19.0" version = "0.21.0"
source = "git+https://github.com/Ralith/openxrs?rev=d0afdd3365bc1e14de28f6a3a21f457e788a702e#d0afdd3365bc1e14de28f6a3a21f457e788a702e" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a7b5f4a26a71928a11b912f94c387378b1c14caac3bde3d9cecd4bb8870262"
dependencies = [ dependencies = [
"libc", "libc",
"libloading", "libloading 0.9.0",
"ndk-context", "ndk-context",
"openxr-sys", "openxr-sys",
] ]
[[package]] [[package]]
name = "openxr-sys" name = "openxr-sys"
version = "0.11.0" version = "0.13.0"
source = "git+https://github.com/Ralith/openxrs?rev=d0afdd3365bc1e14de28f6a3a21f457e788a702e#d0afdd3365bc1e14de28f6a3a21f457e788a702e" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b69a1e728e450d419fa7e82fdfb2988d4a0eadd6bdd16fceff72f1b485c4d96b"
dependencies = [ dependencies = [
"libc", "libc",
"mint", "mint",
@@ -5825,7 +5837,7 @@ dependencies = [
"log", "log",
"rust-embed", "rust-embed",
"tracing-subscriber", "tracing-subscriber",
"vulkano", "vulkano 0.35.0",
"vulkano-shaders", "vulkano-shaders",
"wgui", "wgui",
"winit", "winit",
@@ -5983,6 +5995,25 @@ dependencies = [
"xml-rs", "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]] [[package]]
name = "vulkano" name = "vulkano"
version = "0.35.2" version = "0.35.2"
@@ -5996,7 +6027,7 @@ dependencies = [
"half", "half",
"heck 0.4.1", "heck 0.4.1",
"indexmap 2.12.1", "indexmap 2.12.1",
"libloading", "libloading 0.8.9",
"nom 7.1.3", "nom 7.1.3",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
@@ -6010,14 +6041,11 @@ dependencies = [
"smallvec", "smallvec",
"thread_local", "thread_local",
"vk-parse", "vk-parse",
"vulkano-macros",
] ]
[[package]] [[package]]
name = "vulkano-macros" name = "vulkano-macros"
version = "0.35.0" version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dc929c42c9336fd082079ac3ea30126e4a0dfe36fd2e2b3581303f7d140d20f"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@@ -6037,7 +6065,7 @@ dependencies = [
"quote", "quote",
"shaderc", "shaderc",
"syn 2.0.113", "syn 2.0.113",
"vulkano", "vulkano 0.35.2",
] ]
[[package]] [[package]]
@@ -6335,7 +6363,7 @@ dependencies = [
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"uuid", "uuid",
"vulkano", "vulkano 0.35.0",
"vulkano-shaders", "vulkano-shaders",
"wayland-client", "wayland-client",
"wayvr-ipc", "wayvr-ipc",
@@ -6427,7 +6455,7 @@ dependencies = [
"slotmap", "slotmap",
"smallvec", "smallvec",
"taffy", "taffy",
"vulkano", "vulkano 0.35.0",
"vulkano-shaders", "vulkano-shaders",
] ]
@@ -7021,7 +7049,7 @@ dependencies = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
"gethostname", "gethostname",
"libc", "libc",
"libloading", "libloading 0.8.9",
"once_cell", "once_cell",
"rustix 1.1.3", "rustix 1.1.3",
"x11rb-protocol", "x11rb-protocol",

View File

@@ -47,7 +47,8 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1.0.145" serde_json = "1.0.145"
slotmap = "1.1.1" slotmap = "1.1.1"
strum = { version = "0.27.2", features = ["derive"] } 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", "macros",
] } ] }
vulkano-shaders = "0.35.0" vulkano-shaders = "0.35.0"

View File

@@ -60,7 +60,7 @@ libc = "0.2.178"
libmonado = { git = "https://github.com/technobaboo/libmonado-rs.git", rev = "26292e5b14663ee2f089f66f0851438a0c00ee67", optional = true } libmonado = { git = "https://github.com/technobaboo/libmonado-rs.git", rev = "26292e5b14663ee2f089f66f0851438a0c00ee67", optional = true }
log-panics = { version = "2.1.0", features = ["with-backtrace"] } log-panics = { version = "2.1.0", features = ["with-backtrace"] }
mint = "0.5.9" mint = "0.5.9"
openxr = { git = "https://github.com/Ralith/openxrs", rev = "d0afdd3365bc1e14de28f6a3a21f457e788a702e", features = [ openxr = { version = "0.21.0", features = [
"linked", "linked",
"mint", "mint",
], optional = true } ], optional = true }

View File

@@ -1,6 +1,6 @@
use anyhow::{bail, ensure}; use anyhow::{bail, ensure};
use glam::{Affine3A, Quat, Vec3, Vec3A}; 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; use xr::OverlaySessionCreateFlagsEXTX;
pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> { 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 { } else {
log::warn!("Missing EXT_composition_layer_equirect2 extension."); log::warn!("Missing EXT_composition_layer_equirect2 extension.");
} }
if available_extensions
.other let xr_mndx_system_buttons = "XR_MNDX_system_buttons".as_bytes().to_vec();
.contains(&"XR_MNDX_system_buttons".to_owned()) if available_extensions.other.contains(&xr_mndx_system_buttons) {
{ enabled_extensions.other.push(xr_mndx_system_buttons);
enabled_extensions
.other
.push("XR_MNDX_system_buttons".to_owned());
} }
//#[cfg(not(debug_assertions))] //#[cfg(not(debug_assertions))]

View File

@@ -11,8 +11,8 @@ use vulkano::{
device::Device, device::Device,
format::Format, format::Format,
image::{ image::{
Image, ImageCreateInfo, ImageMemory, ImageTiling, ImageType, ImageUsage, SubresourceLayout, Image, ImageAspect, ImageCreateInfo, ImageMemory, ImageTiling, ImageType, ImageUsage,
sys::RawImage, view::ImageView, SubresourceLayout, sys::RawImage, view::ImageView,
}, },
memory::{ memory::{
DedicatedAllocation, DeviceMemory, ExternalMemoryHandleType, ExternalMemoryHandleTypes, DedicatedAllocation, DeviceMemory, ExternalMemoryHandleType, ExternalMemoryHandleTypes,
@@ -316,14 +316,6 @@ pub fn export_dmabuf_image(
format: Format, format: Format,
modifier: DrmModifier, modifier: DrmModifier,
) -> anyhow::Result<ExportedDmabufImage> { ) -> anyhow::Result<ExportedDmabufImage> {
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( let image = Image::new(
allocator.clone(), allocator.clone(),
ImageCreateInfo { ImageCreateInfo {
@@ -333,7 +325,6 @@ pub fn export_dmabuf_image(
usage: ImageUsage::TRANSFER_DST | ImageUsage::TRANSFER_SRC | ImageUsage::SAMPLED, usage: ImageUsage::TRANSFER_DST | ImageUsage::TRANSFER_SRC | ImageUsage::SAMPLED,
tiling: ImageTiling::DrmFormatModifier, tiling: ImageTiling::DrmFormatModifier,
drm_format_modifiers: vec![modifier.into()], drm_format_modifiers: vec![modifier.into()],
drm_format_modifier_plane_layouts: vec![layout],
external_memory_handle_types: ExternalMemoryHandleTypes::DMA_BUF, external_memory_handle_types: ExternalMemoryHandleTypes::DMA_BUF,
..Default::default() ..Default::default()
}, },
@@ -353,6 +344,8 @@ pub fn export_dmabuf_image(
_ => anyhow::bail!("Could not export DMA-buf: invalid ImageMemory"), _ => anyhow::bail!("Could not export DMA-buf: invalid ImageMemory"),
}; };
let layout = unsafe { image.subresource_layout_unchecked(ImageAspect::MemoryPlane0, 0, 0) };
Ok(ExportedDmabufImage { Ok(ExportedDmabufImage {
view: ImageView::new_default(image)?, view: ImageView::new_default(image)?,
fd, fd,

View File

@@ -2,7 +2,6 @@ use std::{collections::HashMap, str::FromStr, sync::LazyLock};
use regex::Regex; use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use wlx_common::config::AltModifier;
use crate::{ use crate::{
config::{ConfigType, load_known_yaml}, config::{ConfigType, load_known_yaml},

View File

@@ -429,7 +429,9 @@ impl MyFirstDmaExporter {
for _ in 0..2 { for _ in 0..2 {
let image = let image =
export_dmabuf_image(allocator.clone(), [width, height, 1], format, modifier) 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()?; .ok()?;
self.images.push(image); self.images.push(image);