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 {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
allocator::Allocator,
|
allocator::Allocator,
|
||||||
|
clientmem::ClientMemOffset,
|
||||||
|
cpu_worker::CpuWorker,
|
||||||
cursor::Cursor,
|
cursor::Cursor,
|
||||||
damage::DamageVisualizer,
|
damage::DamageVisualizer,
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
format::Format,
|
format::Format,
|
||||||
rect::Rect,
|
rect::{Rect, Region},
|
||||||
renderer::{renderer_base::RendererBase, RenderResult, Renderer},
|
renderer::{renderer_base::RendererBase, RenderResult, Renderer},
|
||||||
scale::Scale,
|
scale::Scale,
|
||||||
state::State,
|
state::State,
|
||||||
|
|
@ -535,6 +537,45 @@ pub trait ShmGfxTexture: GfxTexture {
|
||||||
fn into_texture(self: Rc<Self>) -> Rc<dyn 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 {
|
pub trait GfxContext: Debug {
|
||||||
fn reset_status(&self) -> Option<ResetStatus>;
|
fn reset_status(&self) -> Option<ResetStatus>;
|
||||||
|
|
||||||
|
|
@ -559,6 +600,16 @@ pub trait GfxContext: Debug {
|
||||||
damage: Option<&[Rect]>,
|
damage: Option<&[Rect]>,
|
||||||
) -> Result<Rc<dyn ShmGfxTexture>, GfxError>;
|
) -> 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 allocator(&self) -> Rc<dyn Allocator>;
|
||||||
|
|
||||||
fn gfx_api(&self) -> GfxApi;
|
fn gfx_api(&self) -> GfxApi;
|
||||||
|
|
@ -637,3 +688,16 @@ pub fn cross_intersect_formats(
|
||||||
}
|
}
|
||||||
res
|
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 {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
allocator::Allocator,
|
allocator::Allocator,
|
||||||
|
cpu_worker::CpuWorker,
|
||||||
format::{Format, XRGB8888},
|
format::{Format, XRGB8888},
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
|
AsyncShmGfxTexture, BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat,
|
||||||
ResetStatus, ShmGfxTexture,
|
GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture,
|
||||||
},
|
},
|
||||||
gfx_apis::gl::{
|
gfx_apis::gl::{
|
||||||
egl::{context::EglContext, display::EglDisplay, image::EglImage},
|
egl::{context::EglContext, display::EglDisplay, image::EglImage},
|
||||||
|
|
@ -279,6 +280,17 @@ impl GfxContext for GlRenderContext {
|
||||||
.map_err(|e| e.into())
|
.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> {
|
fn allocator(&self) -> Rc<dyn Allocator> {
|
||||||
self.gbm.clone()
|
self.gbm.clone()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,11 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
allocator::{Allocator, AllocatorError},
|
allocator::{Allocator, AllocatorError},
|
||||||
async_engine::AsyncEngine,
|
async_engine::AsyncEngine,
|
||||||
|
cpu_worker::CpuWorker,
|
||||||
format::Format,
|
format::Format,
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture,
|
AsyncShmGfxTexture, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
|
||||||
|
ResetStatus, ShmGfxTexture,
|
||||||
},
|
},
|
||||||
gfx_apis::vulkan::{
|
gfx_apis::vulkan::{
|
||||||
image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer,
|
image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer,
|
||||||
|
|
@ -278,6 +280,17 @@ impl GfxContext for Context {
|
||||||
Ok(tex as _)
|
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> {
|
fn allocator(&self) -> Rc<dyn Allocator> {
|
||||||
self.0.device.gbm.clone()
|
self.0.device.gbm.clone()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
allocator::{Allocator, AllocatorError, BufferObject, BufferUsage},
|
allocator::{Allocator, AllocatorError, BufferObject, BufferUsage},
|
||||||
|
cpu_worker::CpuWorker,
|
||||||
format::{Format, ARGB8888, XRGB8888},
|
format::{Format, ARGB8888, XRGB8888},
|
||||||
gfx_api::{
|
gfx_api::{
|
||||||
CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext, GfxError, GfxFormat,
|
AsyncShmGfxTexture, CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext,
|
||||||
GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier, ResetStatus, ShmGfxTexture,
|
GfxError, GfxFormat, GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier,
|
||||||
SyncFile,
|
ResetStatus, ShmGfxTexture, SyncFile,
|
||||||
},
|
},
|
||||||
rect::Rect,
|
rect::Rect,
|
||||||
theme::Color,
|
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> {
|
fn allocator(&self) -> Rc<dyn Allocator> {
|
||||||
self.allocator.clone()
|
self.allocator.clone()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue