From 7641a662dced6c7678a7e797af45520c02aa9462 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Wed, 5 Jun 2024 20:13:47 +0900 Subject: [PATCH] do not require ext_image_drm_format_modifier --- src/graphics.rs | 22 +++++++++++++++------- src/overlays/screen.rs | 15 +++++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/graphics.rs b/src/graphics.rs index 439ec78..762f89d 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -109,11 +109,6 @@ pub struct Vert2Uv { pub const INDICES: [u16; 6] = [2, 1, 0, 1, 2, 3]; -#[cfg(not(feature = "no-dmabuf"))] -pub const DMA_BUF_SUPPORTED: bool = true; -#[cfg(feature = "no-dmabuf")] -pub const DMA_BUF_SUPPORTED: bool = false; - pub const BLEND_ALPHA: AttachmentBlend = AttachmentBlend { src_color_blend_factor: BlendFactor::SrcAlpha, dst_color_blend_factor: BlendFactor::OneMinusSrcAlpha, @@ -263,7 +258,14 @@ impl WlxGraphics { .position(|(_, q)| q.queue_flags.intersects(QueueFlags::GRAPHICS)) .expect("Vulkan device has no graphics queue") as u32; - let device_extensions = get_device_extensions(); + let mut device_extensions = get_device_extensions(); + if !physical_device + .supported_extensions() + .ext_image_drm_format_modifier + { + device_extensions.ext_image_drm_format_modifier = false; + } + let device_extensions_raw = device_extensions .into_iter() .filter_map(|(name, enabled)| { @@ -406,10 +408,16 @@ impl WlxGraphics { p.properties().device_name, &runtime_extensions ); - let my_extensions = runtime_extensions.union(&device_extensions); + let mut my_extensions = runtime_extensions.union(&device_extensions); if p.supported_extensions().contains(&my_extensions) { Some((p, my_extensions)) } else { + // try without DRM format modifiers + my_extensions.ext_image_drm_format_modifier = false; + if p.supported_extensions().contains(&my_extensions) { + return Some((p, my_extensions)); + } + log::debug!( "Not using {} because it does not implement the following device extensions:", p.properties().device_name, diff --git a/src/overlays/screen.rs b/src/overlays/screen.rs index d642a96..04ef3d2 100644 --- a/src/overlays/screen.rs +++ b/src/overlays/screen.rs @@ -46,8 +46,7 @@ use crate::{ }, config::{def_pw_tokens, PwTokenMap}, graphics::{ - fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, DMA_BUF_SUPPORTED, - DRM_FORMAT_MOD_INVALID, + fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, DRM_FORMAT_MOD_INVALID, }, hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT}, state::{AppSession, AppState, ScreenMeta}, @@ -365,10 +364,18 @@ impl OverlayRenderer for ScreenRenderer { } fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> { if !self.capture.is_ready() { - let supports_dmabuf = DMA_BUF_SUPPORTED && self.capture.supports_dmbuf(); + let supports_dmabuf = app + .graphics + .device + .enabled_extensions() + .ext_external_memory_dma_buf + && self.capture.supports_dmbuf(); + let allow_dmabuf = &*app.session.config.capture_method != "pw_fallback" && &*app.session.config.capture_method != "screencopy"; + let capture_method = app.session.config.capture_method.clone(); + let drm_formats = DRM_FORMATS.get_or_init({ let graphics = app.graphics.clone(); move || { @@ -377,7 +384,7 @@ impl OverlayRenderer for ScreenRenderer { return vec![]; } if !allow_dmabuf { - log::info!("Not using DMA-buf capture due to pw_fallback"); + log::info!("Not using DMA-buf capture due to {}", capture_method); return vec![]; } log::warn!("Using DMA-buf capture. If screens are blank for you, switch to SHM using:");