do not require ext_image_drm_format_modifier

This commit is contained in:
galister
2024-06-05 20:13:47 +09:00
parent 3a3cda7a45
commit 7641a662dc
2 changed files with 26 additions and 11 deletions

View File

@@ -109,11 +109,6 @@ pub struct Vert2Uv {
pub const INDICES: [u16; 6] = [2, 1, 0, 1, 2, 3]; 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 { pub const BLEND_ALPHA: AttachmentBlend = AttachmentBlend {
src_color_blend_factor: BlendFactor::SrcAlpha, src_color_blend_factor: BlendFactor::SrcAlpha,
dst_color_blend_factor: BlendFactor::OneMinusSrcAlpha, dst_color_blend_factor: BlendFactor::OneMinusSrcAlpha,
@@ -263,7 +258,14 @@ impl WlxGraphics {
.position(|(_, q)| q.queue_flags.intersects(QueueFlags::GRAPHICS)) .position(|(_, q)| q.queue_flags.intersects(QueueFlags::GRAPHICS))
.expect("Vulkan device has no graphics queue") as u32; .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 let device_extensions_raw = device_extensions
.into_iter() .into_iter()
.filter_map(|(name, enabled)| { .filter_map(|(name, enabled)| {
@@ -406,10 +408,16 @@ impl WlxGraphics {
p.properties().device_name, p.properties().device_name,
&runtime_extensions &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) { if p.supported_extensions().contains(&my_extensions) {
Some((p, my_extensions)) Some((p, my_extensions))
} else { } 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!( log::debug!(
"Not using {} because it does not implement the following device extensions:", "Not using {} because it does not implement the following device extensions:",
p.properties().device_name, p.properties().device_name,

View File

@@ -46,8 +46,7 @@ use crate::{
}, },
config::{def_pw_tokens, PwTokenMap}, config::{def_pw_tokens, PwTokenMap},
graphics::{ graphics::{
fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, DMA_BUF_SUPPORTED, fourcc_to_vk, WlxCommandBuffer, WlxPipeline, WlxPipelineLegacy, DRM_FORMAT_MOD_INVALID,
DRM_FORMAT_MOD_INVALID,
}, },
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT}, hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
state::{AppSession, AppState, ScreenMeta}, state::{AppSession, AppState, ScreenMeta},
@@ -365,10 +364,18 @@ impl OverlayRenderer for ScreenRenderer {
} }
fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> { fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> {
if !self.capture.is_ready() { 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" let allow_dmabuf = &*app.session.config.capture_method != "pw_fallback"
&& &*app.session.config.capture_method != "screencopy"; && &*app.session.config.capture_method != "screencopy";
let capture_method = app.session.config.capture_method.clone();
let drm_formats = DRM_FORMATS.get_or_init({ let drm_formats = DRM_FORMATS.get_or_init({
let graphics = app.graphics.clone(); let graphics = app.graphics.clone();
move || { move || {
@@ -377,7 +384,7 @@ impl OverlayRenderer for ScreenRenderer {
return vec![]; return vec![];
} }
if !allow_dmabuf { 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![]; return vec![];
} }
log::warn!("Using DMA-buf capture. If screens are blank for you, switch to SHM using:"); log::warn!("Using DMA-buf capture. If screens are blank for you, switch to SHM using:");