kms: Drop VulkanAllocator code
This commit is contained in:
parent
f7b062aa81
commit
aac287984b
1 changed files with 4 additions and 68 deletions
|
|
@ -22,7 +22,6 @@ use smithay::{
|
||||||
allocator::{
|
allocator::{
|
||||||
dmabuf::{AnyError, Dmabuf, DmabufAllocator},
|
dmabuf::{AnyError, Dmabuf, DmabufAllocator},
|
||||||
gbm::{GbmAllocator, GbmBufferFlags, GbmDevice},
|
gbm::{GbmAllocator, GbmBufferFlags, GbmDevice},
|
||||||
vulkan::{ImageUsageFlags, VulkanAllocator},
|
|
||||||
Allocator, Format, Fourcc,
|
Allocator, Format, Fourcc,
|
||||||
},
|
},
|
||||||
drm::{
|
drm::{
|
||||||
|
|
@ -44,7 +43,6 @@ use smithay::{
|
||||||
},
|
},
|
||||||
session::{libseat::LibSeatSession, Event as SessionEvent, Session},
|
session::{libseat::LibSeatSession, Event as SessionEvent, Session},
|
||||||
udev::{all_gpus, primary_gpu, UdevBackend, UdevEvent},
|
udev::{all_gpus, primary_gpu, UdevBackend, UdevEvent},
|
||||||
vulkan::{version::Version, Instance, PhysicalDevice},
|
|
||||||
},
|
},
|
||||||
desktop::utils::OutputPresentationFeedback,
|
desktop::utils::OutputPresentationFeedback,
|
||||||
input::Seat,
|
input::Seat,
|
||||||
|
|
@ -247,7 +245,7 @@ pub fn init_backend(
|
||||||
let dh = state.common.display_handle.clone();
|
let dh = state.common.display_handle.clone();
|
||||||
match match event {
|
match match event {
|
||||||
UdevEvent::Added { device_id, path } => state
|
UdevEvent::Added { device_id, path } => state
|
||||||
.device_added(device_id, path, &dh, true)
|
.device_added(device_id, path, &dh)
|
||||||
.with_context(|| format!("Failed to add drm device: {}", device_id)),
|
.with_context(|| format!("Failed to add drm device: {}", device_id)),
|
||||||
UdevEvent::Changed { device_id } => state
|
UdevEvent::Changed { device_id } => state
|
||||||
.device_changed(device_id)
|
.device_changed(device_id)
|
||||||
|
|
@ -301,7 +299,7 @@ pub fn init_backend(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let dh = state.common.display_handle.clone();
|
let dh = state.common.display_handle.clone();
|
||||||
if let Err(err) = state.device_added(dev, path.into(), &dh, true) {
|
if let Err(err) = state.device_added(dev, path.into(), &dh) {
|
||||||
error!(?err, "Failed to add drm device {}.", path.display(),);
|
error!(?err, "Failed to add drm device {}.", path.display(),);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -386,34 +384,16 @@ pub fn init_backend(
|
||||||
state.launch_xwayland(Some(primary));
|
state.launch_xwayland(Some(primary));
|
||||||
|
|
||||||
for (dev, path) in udev_dispatcher.as_source_ref().device_list() {
|
for (dev, path) in udev_dispatcher.as_source_ref().device_list() {
|
||||||
if let Err(err) = state.device_added(dev, path.into(), dh, false) {
|
if let Err(err) = state.device_added(dev, path.into(), dh) {
|
||||||
warn!("Failed to add device {}: {:?}", path.display(), err);
|
warn!("Failed to add device {}: {:?}", path.display(), err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: amdgpu doesn't like us initializing vulkan too early..
|
|
||||||
// so lets do that delayed until mesa fixes that.
|
|
||||||
let devices = state
|
|
||||||
.backend
|
|
||||||
.kms()
|
|
||||||
.devices
|
|
||||||
.iter()
|
|
||||||
.map(|(drm_node, device)| (*drm_node, device.render_node))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
for (drm_node, render_node) in devices {
|
|
||||||
state.init_vulkan(drm_node, render_node);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
fn device_added(
|
fn device_added(&mut self, dev: dev_t, path: PathBuf, dh: &DisplayHandle) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
dev: dev_t,
|
|
||||||
path: PathBuf,
|
|
||||||
dh: &DisplayHandle,
|
|
||||||
try_vulkan: bool,
|
|
||||||
) -> Result<()> {
|
|
||||||
if !self.backend.kms().session.is_active() {
|
if !self.backend.kms().session.is_active() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
@ -719,53 +699,9 @@ impl State {
|
||||||
&self.common.event_loop_handle,
|
&self.common.event_loop_handle,
|
||||||
);
|
);
|
||||||
|
|
||||||
if try_vulkan {
|
|
||||||
self.init_vulkan(drm_node, render_node);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_vulkan(&mut self, drm_node: DrmNode, render_node: DrmNode) {
|
|
||||||
if let Ok(instance) = Instance::new(Version::VERSION_1_2, None) {
|
|
||||||
if let Some(physical_device) =
|
|
||||||
PhysicalDevice::enumerate(&instance)
|
|
||||||
.ok()
|
|
||||||
.and_then(|devices| {
|
|
||||||
devices
|
|
||||||
.filter(|phd| {
|
|
||||||
phd.has_device_extension(unsafe {
|
|
||||||
CStr::from_bytes_with_nul_unchecked(
|
|
||||||
b"VK_EXT_physical_device_drm\0",
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.find(|phd| {
|
|
||||||
phd.primary_node().unwrap() == Some(render_node)
|
|
||||||
|| phd.render_node().unwrap() == Some(render_node)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
{
|
|
||||||
match VulkanAllocator::new(
|
|
||||||
&physical_device,
|
|
||||||
ImageUsageFlags::COLOR_ATTACHMENT | ImageUsageFlags::SAMPLED,
|
|
||||||
) {
|
|
||||||
Ok(allocator) => {
|
|
||||||
self.backend
|
|
||||||
.kms()
|
|
||||||
.devices
|
|
||||||
.get_mut(&drm_node)
|
|
||||||
.unwrap()
|
|
||||||
.allocator = Box::new(DmabufAllocator(allocator));
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
warn!(?err, "Failed to create vulkan allocator.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn device_changed(&mut self, dev: dev_t) -> Result<()> {
|
fn device_changed(&mut self, dev: dev_t) -> Result<()> {
|
||||||
if !self.backend.kms().session.is_active() {
|
if !self.backend.kms().session.is_active() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue