copy_device: add new utility
This commit is contained in:
parent
f2a0221c9e
commit
fa897f0f76
9 changed files with 2068 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ use {
|
||||||
clientmem::{self, ClientMemError},
|
clientmem::{self, ClientMemError},
|
||||||
cmm::{cmm_manager::ColorManager, cmm_primaries::Primaries},
|
cmm::{cmm_manager::ColorManager, cmm_primaries::Primaries},
|
||||||
config::ConfigProxy,
|
config::ConfigProxy,
|
||||||
|
copy_device::CopyDeviceRegistry,
|
||||||
cpu_worker::{CpuWorker, CpuWorkerError},
|
cpu_worker::{CpuWorker, CpuWorkerError},
|
||||||
criteria::{
|
criteria::{
|
||||||
CritMatcherIds,
|
CritMatcherIds,
|
||||||
|
|
@ -363,6 +364,7 @@ fn start_compositor2(
|
||||||
outputs_without_hc: Default::default(),
|
outputs_without_hc: Default::default(),
|
||||||
udmabuf: Default::default(),
|
udmabuf: Default::default(),
|
||||||
gfx_ctx_changed: Default::default(),
|
gfx_ctx_changed: Default::default(),
|
||||||
|
copy_device_registry: Rc::new(CopyDeviceRegistry::new(&ring, &engine)),
|
||||||
});
|
});
|
||||||
state.tracker.register(ClientId::from_raw(0));
|
state.tracker.register(ClientId::from_raw(0));
|
||||||
create_dummy_output(&state);
|
create_dummy_output(&state);
|
||||||
|
|
|
||||||
2048
src/copy_device.rs
Normal file
2048
src/copy_device.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -221,7 +221,7 @@ pub struct CopyTexture {
|
||||||
pub cd: Rc<ColorDescription>,
|
pub cd: Rc<ColorDescription>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct SyncFile(pub Rc<OwnedFd>);
|
pub struct SyncFile(pub Rc<OwnedFd>);
|
||||||
|
|
||||||
impl Deref for SyncFile {
|
impl Deref for SyncFile {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ use {
|
||||||
drm::{Drm, sync_obj::SyncObjCtx},
|
drm::{Drm, sync_obj::SyncObjCtx},
|
||||||
gbm::{GBM_BO_USE_RENDERING, GbmDevice},
|
gbm::{GBM_BO_USE_RENDERING, GbmDevice},
|
||||||
},
|
},
|
||||||
vulkan_core::{API_VERSION, ApiVersionDisplay, Extensions, map_extension_properties},
|
vulkan_core::{
|
||||||
|
ApiVersionDisplay, Extensions, VULKAN_API_VERSION, map_extension_properties,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
arrayvec::ArrayVec,
|
arrayvec::ArrayVec,
|
||||||
|
|
@ -145,7 +147,7 @@ impl VulkanInstance {
|
||||||
let mut devices = vec![];
|
let mut devices = vec![];
|
||||||
for phy_dev in phy_devs {
|
for phy_dev in phy_devs {
|
||||||
let props = unsafe { self.instance.get_physical_device_properties(phy_dev) };
|
let props = unsafe { self.instance.get_physical_device_properties(phy_dev) };
|
||||||
if props.api_version < API_VERSION {
|
if props.api_version < VULKAN_API_VERSION {
|
||||||
devices.push((props, None, None));
|
devices.push((props, None, None));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +220,7 @@ impl VulkanInstance {
|
||||||
};
|
};
|
||||||
for phy_dev in phy_devs {
|
for phy_dev in phy_devs {
|
||||||
let props = unsafe { self.instance.get_physical_device_properties(phy_dev) };
|
let props = unsafe { self.instance.get_physical_device_properties(phy_dev) };
|
||||||
if props.api_version < API_VERSION {
|
if props.api_version < VULKAN_API_VERSION {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if props.device_type == PhysicalDeviceType::CPU {
|
if props.device_type == PhysicalDeviceType::CPU {
|
||||||
|
|
@ -618,7 +620,7 @@ fn log_device(
|
||||||
Ustr::from_ptr(props.device_name.as_ptr()).display()
|
Ustr::from_ptr(props.device_name.as_ptr()).display()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if props.api_version < API_VERSION {
|
if props.api_version < VULKAN_API_VERSION {
|
||||||
log::warn!(" device does not support vulkan 1.3");
|
log::warn!(" device does not support vulkan 1.3");
|
||||||
}
|
}
|
||||||
if let Some(extensions) = extensions {
|
if let Some(extensions) = extensions {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ mod clientmem;
|
||||||
mod cmm;
|
mod cmm;
|
||||||
mod compositor;
|
mod compositor;
|
||||||
mod config;
|
mod config;
|
||||||
|
mod copy_device;
|
||||||
mod cpu_worker;
|
mod cpu_worker;
|
||||||
mod criteria;
|
mod criteria;
|
||||||
mod cursor;
|
mod cursor;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use {
|
||||||
cmm::{cmm_description::ColorDescription, cmm_manager::ColorManager},
|
cmm::{cmm_description::ColorDescription, cmm_manager::ColorManager},
|
||||||
compositor::LIBEI_SOCKET,
|
compositor::LIBEI_SOCKET,
|
||||||
config::ConfigProxy,
|
config::ConfigProxy,
|
||||||
|
copy_device::CopyDeviceRegistry,
|
||||||
cpu_worker::CpuWorker,
|
cpu_worker::CpuWorker,
|
||||||
criteria::{clm::ClMatcherManager, tlm::TlMatcherManager},
|
criteria::{clm::ClMatcherManager, tlm::TlMatcherManager},
|
||||||
cursor::{Cursor, ServerCursors},
|
cursor::{Cursor, ServerCursors},
|
||||||
|
|
@ -292,6 +293,8 @@ pub struct State {
|
||||||
pub outputs_without_hc: NumCell<usize>,
|
pub outputs_without_hc: NumCell<usize>,
|
||||||
pub udmabuf: Rc<UdmabufHolder>,
|
pub udmabuf: Rc<UdmabufHolder>,
|
||||||
pub gfx_ctx_changed: EventSource<WlBuffer>,
|
pub gfx_ctx_changed: EventSource<WlBuffer>,
|
||||||
|
#[expect(dead_code)]
|
||||||
|
pub copy_device_registry: Rc<CopyDeviceRegistry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl Drop for State {
|
// impl Drop for State {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use {
|
||||||
oserror::OsError, page_size::page_size,
|
oserror::OsError, page_size::page_size,
|
||||||
},
|
},
|
||||||
video::{
|
video::{
|
||||||
LINEAR_MODIFIER, Modifier,
|
LINEAR_MODIFIER, LINEAR_STRIDE_ALIGN, Modifier,
|
||||||
dmabuf::{DmaBuf, DmaBufIds, DmaBufPlane, PlaneVec},
|
dmabuf::{DmaBuf, DmaBufIds, DmaBufPlane, PlaneVec},
|
||||||
drm::Drm,
|
drm::Drm,
|
||||||
},
|
},
|
||||||
|
|
@ -139,8 +139,7 @@ impl Allocator for Udmabuf {
|
||||||
if height > 1 << 16 || width > 1 << 16 {
|
if height > 1 << 16 || width > 1 << 16 {
|
||||||
return Err(UdmabufError::Overflow.into());
|
return Err(UdmabufError::Overflow.into());
|
||||||
}
|
}
|
||||||
let stride_mask = 255;
|
let stride = (width * format.bpp as u64).next_multiple_of(LINEAR_STRIDE_ALIGN);
|
||||||
let stride = (width * format.bpp as u64 + stride_mask) & !stride_mask;
|
|
||||||
let size_mask = page_size() as u64 - 1;
|
let size_mask = page_size() as u64 - 1;
|
||||||
let size = (height * stride + size_mask) & !size_mask;
|
let size = (height * stride + size_mask) & !size_mask;
|
||||||
let memfd = match uapi::memfd_create("udmabuf", MFD_ALLOW_SEALING) {
|
let memfd = match uapi::memfd_create("udmabuf", MFD_ALLOW_SEALING) {
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,6 @@ pub type Modifier = u64;
|
||||||
|
|
||||||
pub const INVALID_MODIFIER: Modifier = 0x00ff_ffff_ffff_ffff;
|
pub const INVALID_MODIFIER: Modifier = 0x00ff_ffff_ffff_ffff;
|
||||||
pub const LINEAR_MODIFIER: Modifier = 0;
|
pub const LINEAR_MODIFIER: Modifier = 0;
|
||||||
|
|
||||||
|
// This is required by AMD and therefore everyone else uses this too.
|
||||||
|
pub const LINEAR_STRIDE_ALIGN: u64 = 256;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ impl VulkanCoreInstance {
|
||||||
.map(|c| c.as_ptr())
|
.map(|c| c.as_ptr())
|
||||||
.collect();
|
.collect();
|
||||||
let app_info = ApplicationInfo::default()
|
let app_info = ApplicationInfo::default()
|
||||||
.api_version(API_VERSION)
|
.api_version(VULKAN_API_VERSION)
|
||||||
.application_name(c"jay")
|
.application_name(c"jay")
|
||||||
.application_version(1);
|
.application_version(1);
|
||||||
let mut severity = DebugUtilsMessageSeverityFlagsEXT::empty()
|
let mut severity = DebugUtilsMessageSeverityFlagsEXT::empty()
|
||||||
|
|
@ -240,4 +240,4 @@ impl Display for ApiVersionDisplay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const API_VERSION: u32 = API_VERSION_1_3;
|
pub const VULKAN_API_VERSION: u32 = API_VERSION_1_3;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue