gfx: add async shm api
This commit is contained in:
parent
c968024905
commit
f213372b8e
4 changed files with 108 additions and 7 deletions
|
|
@ -1,11 +1,13 @@
|
|||
use {
|
||||
crate::{
|
||||
allocator::Allocator,
|
||||
clientmem::ClientMemOffset,
|
||||
cpu_worker::CpuWorker,
|
||||
cursor::Cursor,
|
||||
damage::DamageVisualizer,
|
||||
fixed::Fixed,
|
||||
format::Format,
|
||||
rect::Rect,
|
||||
rect::{Rect, Region},
|
||||
renderer::{renderer_base::RendererBase, RenderResult, Renderer},
|
||||
scale::Scale,
|
||||
state::State,
|
||||
|
|
@ -535,6 +537,45 @@ pub trait ShmGfxTexture: GfxTexture {
|
|||
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture>;
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub trait AsyncShmGfxTextureCallback {
|
||||
fn completed(self: Rc<Self>, res: Result<(), GfxError>);
|
||||
}
|
||||
|
||||
pub trait AsyncShmGfxTextureUploadCancellable {
|
||||
fn cancel(&self, id: u64);
|
||||
}
|
||||
|
||||
pub struct PendingShmUpload {
|
||||
cancel: Rc<dyn AsyncShmGfxTextureUploadCancellable>,
|
||||
id: u64,
|
||||
}
|
||||
|
||||
pub trait AsyncShmGfxTexture: GfxTexture {
|
||||
#[expect(dead_code)]
|
||||
fn async_upload(
|
||||
self: Rc<Self>,
|
||||
callback: Rc<dyn AsyncShmGfxTextureCallback>,
|
||||
mem: &Rc<ClientMemOffset>,
|
||||
damage: Region,
|
||||
) -> Result<Option<PendingShmUpload>, GfxError>;
|
||||
|
||||
#[expect(dead_code)]
|
||||
fn sync_upload(self: Rc<Self>, shm: &[Cell<u8>], damage: Region) -> Result<(), GfxError>;
|
||||
|
||||
#[expect(dead_code)]
|
||||
fn compatible_with(
|
||||
&self,
|
||||
format: &'static Format,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
) -> bool;
|
||||
|
||||
#[expect(dead_code)]
|
||||
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture>;
|
||||
}
|
||||
|
||||
pub trait GfxContext: Debug {
|
||||
fn reset_status(&self) -> Option<ResetStatus>;
|
||||
|
||||
|
|
@ -559,6 +600,16 @@ pub trait GfxContext: Debug {
|
|||
damage: Option<&[Rect]>,
|
||||
) -> Result<Rc<dyn ShmGfxTexture>, GfxError>;
|
||||
|
||||
#[expect(dead_code)]
|
||||
fn async_shmem_texture(
|
||||
self: Rc<Self>,
|
||||
format: &'static Format,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
cpu_worker: &Rc<CpuWorker>,
|
||||
) -> Result<Rc<dyn AsyncShmGfxTexture>, GfxError>;
|
||||
|
||||
fn allocator(&self) -> Rc<dyn Allocator>;
|
||||
|
||||
fn gfx_api(&self) -> GfxApi;
|
||||
|
|
@ -637,3 +688,16 @@ pub fn cross_intersect_formats(
|
|||
}
|
||||
res
|
||||
}
|
||||
|
||||
impl PendingShmUpload {
|
||||
#[expect(dead_code)]
|
||||
pub fn new(cancel: Rc<dyn AsyncShmGfxTextureUploadCancellable>, id: u64) -> Self {
|
||||
Self { cancel, id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PendingShmUpload {
|
||||
fn drop(&mut self) {
|
||||
self.cancel.cancel(self.id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
use {
|
||||
crate::{
|
||||
allocator::Allocator,
|
||||
cpu_worker::CpuWorker,
|
||||
format::{Format, XRGB8888},
|
||||
gfx_api::{
|
||||
BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
|
||||
ResetStatus, ShmGfxTexture,
|
||||
AsyncShmGfxTexture, BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat,
|
||||
GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture,
|
||||
},
|
||||
gfx_apis::gl::{
|
||||
egl::{context::EglContext, display::EglDisplay, image::EglImage},
|
||||
|
|
@ -279,6 +280,17 @@ impl GfxContext for GlRenderContext {
|
|||
.map_err(|e| e.into())
|
||||
}
|
||||
|
||||
fn async_shmem_texture(
|
||||
self: Rc<Self>,
|
||||
_format: &'static Format,
|
||||
_width: i32,
|
||||
_height: i32,
|
||||
_stride: i32,
|
||||
_cpu_worker: &Rc<CpuWorker>,
|
||||
) -> Result<Rc<dyn AsyncShmGfxTexture>, GfxError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn allocator(&self) -> Rc<dyn Allocator> {
|
||||
self.gbm.clone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,11 @@ use {
|
|||
crate::{
|
||||
allocator::{Allocator, AllocatorError},
|
||||
async_engine::AsyncEngine,
|
||||
cpu_worker::CpuWorker,
|
||||
format::Format,
|
||||
gfx_api::{
|
||||
GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture,
|
||||
AsyncShmGfxTexture, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
|
||||
ResetStatus, ShmGfxTexture,
|
||||
},
|
||||
gfx_apis::vulkan::{
|
||||
image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer,
|
||||
|
|
@ -278,6 +280,17 @@ impl GfxContext for Context {
|
|||
Ok(tex as _)
|
||||
}
|
||||
|
||||
fn async_shmem_texture(
|
||||
self: Rc<Self>,
|
||||
_format: &'static Format,
|
||||
_width: i32,
|
||||
_height: i32,
|
||||
_stride: i32,
|
||||
_cpu_worker: &Rc<CpuWorker>,
|
||||
) -> Result<Rc<dyn AsyncShmGfxTexture>, GfxError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn allocator(&self) -> Rc<dyn Allocator> {
|
||||
self.0.device.gbm.clone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use {
|
||||
crate::{
|
||||
allocator::{Allocator, AllocatorError, BufferObject, BufferUsage},
|
||||
cpu_worker::CpuWorker,
|
||||
format::{Format, ARGB8888, XRGB8888},
|
||||
gfx_api::{
|
||||
CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext, GfxError, GfxFormat,
|
||||
GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier, ResetStatus, ShmGfxTexture,
|
||||
SyncFile,
|
||||
AsyncShmGfxTexture, CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext,
|
||||
GfxError, GfxFormat, GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier,
|
||||
ResetStatus, ShmGfxTexture, SyncFile,
|
||||
},
|
||||
rect::Rect,
|
||||
theme::Color,
|
||||
|
|
@ -133,6 +134,17 @@ impl GfxContext for TestGfxCtx {
|
|||
})))
|
||||
}
|
||||
|
||||
fn async_shmem_texture(
|
||||
self: Rc<Self>,
|
||||
_format: &'static Format,
|
||||
_width: i32,
|
||||
_height: i32,
|
||||
_stride: i32,
|
||||
_cpu_worker: &Rc<CpuWorker>,
|
||||
) -> Result<Rc<dyn AsyncShmGfxTexture>, GfxError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn allocator(&self) -> Rc<dyn Allocator> {
|
||||
self.allocator.clone()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue