Merge pull request #195 from olekolek1000/main
WayVR: Automatically fallback to software blitting in case if dmabuf initialization has failed
This commit is contained in:
@@ -211,7 +211,8 @@ impl WayVRCompositor {
|
|||||||
const STARTING_WAYLAND_ADDR_IDX: u32 = 20;
|
const STARTING_WAYLAND_ADDR_IDX: u32 = 20;
|
||||||
|
|
||||||
fn export_display_number(display_num: u32) -> anyhow::Result<()> {
|
fn export_display_number(display_num: u32) -> anyhow::Result<()> {
|
||||||
let mut path = std::env::var("XDG_RUNTIME_DIR").map_or_else(|_| PathBuf::from("/tmp"), PathBuf::from);
|
let mut path =
|
||||||
|
std::env::var("XDG_RUNTIME_DIR").map_or_else(|_| PathBuf::from("/tmp"), PathBuf::from);
|
||||||
path.push("wayvr.disp");
|
path.push("wayvr.disp");
|
||||||
std::fs::write(path, format!("{display_num}\n"))?;
|
std::fs::write(path, format!("{display_num}\n"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -127,9 +127,7 @@ impl ClientData for ClientState {
|
|||||||
|
|
||||||
fn disconnected(&self, client_id: ClientId, reason: DisconnectReason) {
|
fn disconnected(&self, client_id: ClientId, reason: DisconnectReason) {
|
||||||
*self.disconnected.lock().unwrap() = true;
|
*self.disconnected.lock().unwrap() = true;
|
||||||
log::debug!(
|
log::debug!("Client ID {client_id:?} disconnected. Reason: {reason:?}");
|
||||||
"Client ID {client_id:?} disconnected. Reason: {reason:?}"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,9 +132,13 @@ impl Display {
|
|||||||
let egl_image = params.egl_data.create_egl_image(tex_id)?;
|
let egl_image = params.egl_data.create_egl_image(tex_id)?;
|
||||||
|
|
||||||
let render_data = match params.config.blit_method {
|
let render_data = match params.config.blit_method {
|
||||||
BlitMethod::Dmabuf => {
|
BlitMethod::Dmabuf => match params.egl_data.create_dmabuf_data(&egl_image) {
|
||||||
egl_data::RenderData::Dmabuf(params.egl_data.create_dmabuf_data(&egl_image)?)
|
Ok(dmabuf_data) => egl_data::RenderData::Dmabuf(dmabuf_data),
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("create_dmabuf_data failed: {e:?}. Using software blitting (This will be slow!)");
|
||||||
|
egl_data::RenderData::Software(None)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
BlitMethod::Software => egl_data::RenderData::Software(None),
|
BlitMethod::Software => egl_data::RenderData::Software(None),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -235,21 +235,34 @@ impl EGLData {
|
|||||||
let mut strides: [i32; 3] = [0; 3];
|
let mut strides: [i32; 3] = [0; 3];
|
||||||
let mut offsets: [i32; 3] = [0; 3];
|
let mut offsets: [i32; 3] = [0; 3];
|
||||||
|
|
||||||
if egl_export_dmabuf_image_mesa(
|
let ret = egl_export_dmabuf_image_mesa(
|
||||||
self.display.as_ptr(),
|
self.display.as_ptr(),
|
||||||
egl_image.as_ptr(),
|
egl_image.as_ptr(),
|
||||||
fds.as_mut_ptr(),
|
fds.as_mut_ptr(),
|
||||||
strides.as_mut_ptr(),
|
strides.as_mut_ptr(),
|
||||||
offsets.as_mut_ptr(),
|
offsets.as_mut_ptr(),
|
||||||
) != khronos_egl::TRUE
|
);
|
||||||
{
|
|
||||||
anyhow::bail!("eglExportDMABUFImageMESA failed");
|
if ret != khronos_egl::TRUE {
|
||||||
|
anyhow::bail!("eglExportDMABUFImageMESA failed with return code {ret}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if fds[0] <= 0 {
|
||||||
|
anyhow::bail!("fd is <=0 (got {})", fds[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// many planes in RGB data?
|
// many planes in RGB data?
|
||||||
debug_assert!(fds[1] == 0);
|
if fds[1] != 0 || strides[1] != 0 || offsets[1] != 0 {
|
||||||
debug_assert!(strides[1] == 0);
|
anyhow::bail!("multi-planar data received, packed RGB expected");
|
||||||
debug_assert!(offsets[1] == 0);
|
}
|
||||||
|
|
||||||
|
if strides[0] < 0 {
|
||||||
|
anyhow::bail!("strides is < 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if offsets[0] < 0 {
|
||||||
|
anyhow::bail!("offsets is < 0");
|
||||||
|
}
|
||||||
|
|
||||||
let mod_info = self.query_dmabuf_mod_info()?;
|
let mod_info = self.query_dmabuf_mod_info()?;
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ use vulkano::{
|
|||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
},
|
},
|
||||||
device::{
|
device::{
|
||||||
physical::{PhysicalDevice, PhysicalDeviceType}, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures,
|
physical::{PhysicalDevice, PhysicalDeviceType},
|
||||||
Queue, QueueCreateInfo, QueueFlags,
|
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, Queue, QueueCreateInfo,
|
||||||
|
QueueFlags,
|
||||||
},
|
},
|
||||||
format::Format,
|
format::Format,
|
||||||
image::{
|
image::{
|
||||||
|
|||||||
Reference in New Issue
Block a user