wl_shm: use udmabuf directly as texture on integrated GPUs
This commit is contained in:
parent
da33f26918
commit
9abfe88b05
8 changed files with 213 additions and 70 deletions
|
|
@ -68,6 +68,7 @@ pub struct EglDisplay {
|
|||
pub gbm: Rc<GbmDevice>,
|
||||
pub dpy: EGLDisplay,
|
||||
pub explicit_sync: bool,
|
||||
pub fast_ram_access: bool,
|
||||
}
|
||||
|
||||
impl EglDisplay {
|
||||
|
|
@ -106,16 +107,20 @@ impl EglDisplay {
|
|||
gbm: Rc::new(gbm),
|
||||
dpy,
|
||||
explicit_sync: false,
|
||||
fast_ram_access: false,
|
||||
};
|
||||
let mut major = 0;
|
||||
let mut minor = 0;
|
||||
if (egl.eglInitialize)(dpy.dpy, &mut major, &mut minor) != EGL_TRUE {
|
||||
return Err(RenderError::Initialize);
|
||||
}
|
||||
if !software && EXTS.contains(EXT_DEVICE_QUERY) {
|
||||
if get_device_ext(procs, dpy.dpy)?.contains(MESA_DEVICE_SOFTWARE) {
|
||||
if EXTS.contains(EXT_DEVICE_QUERY)
|
||||
&& get_device_ext(procs, dpy.dpy)?.contains(MESA_DEVICE_SOFTWARE)
|
||||
{
|
||||
if !software {
|
||||
return Err(RenderError::NoHardwareRenderer);
|
||||
}
|
||||
dpy.fast_ram_access = true;
|
||||
}
|
||||
dpy.exts = get_display_ext(dpy.dpy);
|
||||
if !dpy.exts.intersects(KHR_IMAGE_BASE) {
|
||||
|
|
|
|||
|
|
@ -257,6 +257,10 @@ impl GfxContext for GlRenderContext {
|
|||
self.formats()
|
||||
}
|
||||
|
||||
fn fast_ram_access(&self) -> bool {
|
||||
self.ctx.dpy.fast_ram_access
|
||||
}
|
||||
|
||||
fn dmabuf_fb(self: Rc<Self>, buf: &DmaBuf) -> Result<Rc<dyn GfxFramebuffer>, GfxError> {
|
||||
(&self)
|
||||
.dmabuf_fb(buf)
|
||||
|
|
|
|||
|
|
@ -280,6 +280,10 @@ impl GfxContext for Context {
|
|||
self.0.formats.clone()
|
||||
}
|
||||
|
||||
fn fast_ram_access(&self) -> bool {
|
||||
self.0.device.fast_ram_access
|
||||
}
|
||||
|
||||
fn dmabuf_img(self: Rc<Self>, buf: &DmaBuf) -> Result<Rc<dyn GfxImage>, GfxError> {
|
||||
self.0
|
||||
.import_dmabuf(buf)
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ pub struct VulkanDevice {
|
|||
pub(super) uniform_buffer_offset_mask: DeviceSize,
|
||||
pub(super) uniform_buffer_descriptor_size: usize,
|
||||
pub(super) lost: Cell<bool>,
|
||||
pub(super) fast_ram_access: bool,
|
||||
}
|
||||
|
||||
impl Drop for VulkanDevice {
|
||||
|
|
@ -129,7 +130,7 @@ impl VulkanInstance {
|
|||
}
|
||||
}
|
||||
|
||||
fn find_dev(&self, drm: &Drm) -> Result<PhysicalDevice, VulkanError> {
|
||||
fn find_dev(&self, drm: &Drm) -> Result<(PhysicalDevice, PhysicalDeviceType), VulkanError> {
|
||||
let dev = drm.dev();
|
||||
log::log!(
|
||||
self.log_level,
|
||||
|
|
@ -188,7 +189,7 @@ impl VulkanInstance {
|
|||
Some(&extensions),
|
||||
Some(&driver_props),
|
||||
);
|
||||
return Ok(phy_dev);
|
||||
return Ok((phy_dev, props.device_type));
|
||||
}
|
||||
devices.push((props, Some(extensions), Some(driver_props)));
|
||||
}
|
||||
|
|
@ -210,7 +211,7 @@ impl VulkanInstance {
|
|||
Err(VulkanError::NoDeviceFound(dev))
|
||||
}
|
||||
|
||||
fn find_software_renderer(&self) -> Result<PhysicalDevice, VulkanError> {
|
||||
fn find_software_renderer(&self) -> Result<(PhysicalDevice, PhysicalDeviceType), VulkanError> {
|
||||
let phy_devs = unsafe { self.instance.enumerate_physical_devices() };
|
||||
let phy_devs = match phy_devs {
|
||||
Ok(d) => d,
|
||||
|
|
@ -222,7 +223,7 @@ impl VulkanInstance {
|
|||
continue;
|
||||
}
|
||||
if props.device_type == PhysicalDeviceType::CPU {
|
||||
return Ok(phy_dev);
|
||||
return Ok((phy_dev, props.device_type));
|
||||
}
|
||||
}
|
||||
Err(VulkanError::NoSoftwareRenderer)
|
||||
|
|
@ -344,7 +345,7 @@ impl VulkanInstance {
|
|||
.ok_or(VulkanError::NoRenderNode)
|
||||
.map(Rc::new)?;
|
||||
let gbm = GbmDevice::new(drm).map_err(VulkanError::Gbm)?;
|
||||
let phy_dev = match software {
|
||||
let (phy_dev, dev_ty) = match software {
|
||||
true => self.find_software_renderer()?,
|
||||
false => self.find_dev(drm)?,
|
||||
};
|
||||
|
|
@ -543,6 +544,11 @@ impl VulkanInstance {
|
|||
"Created queues with priorities {max_graphics_priority:?}/{max_transfer_priority:?}",
|
||||
);
|
||||
}
|
||||
let fast_ram_access = match dev_ty {
|
||||
PhysicalDeviceType::CPU => true,
|
||||
PhysicalDeviceType::INTEGRATED_GPU => true,
|
||||
_ => false,
|
||||
};
|
||||
Ok(Rc::new(VulkanDevice {
|
||||
physical_device: phy_dev,
|
||||
render_node,
|
||||
|
|
@ -572,6 +578,7 @@ impl VulkanInstance {
|
|||
uniform_buffer_offset_mask,
|
||||
uniform_buffer_descriptor_size,
|
||||
lost: Cell::new(false),
|
||||
fast_ram_access,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue