1
0
Fork 0
forked from wry/wry

gfx: add GfxBlendBuffer

This commit is contained in:
Julian Orth 2025-02-20 18:29:48 +01:00
parent 446779ab83
commit a7cb2ee42a
14 changed files with 107 additions and 23 deletions

View file

@ -197,6 +197,8 @@ enum RenderError {
UnsupportedShmFormat(&'static str),
#[error("Could not access the client memory")]
AccessFailed(#[source] Box<dyn Error + Sync + Send>),
#[error("OpenGL does not support blend buffers")]
NoBlendBuffer,
}
#[derive(Default)]

View file

@ -4,8 +4,8 @@ use {
cpu_worker::CpuWorker,
format::{Format, XRGB8888},
gfx_api::{
AsyncShmGfxTexture, BufferResvUser, GfxContext, GfxError, GfxFormat, GfxFramebuffer,
GfxImage, GfxInternalFramebuffer, ResetStatus, ShmGfxTexture,
AsyncShmGfxTexture, BufferResvUser, GfxBlendBuffer, GfxContext, GfxError, GfxFormat,
GfxFramebuffer, GfxImage, GfxInternalFramebuffer, ResetStatus, ShmGfxTexture,
},
gfx_apis::gl::{
GfxGlState, RenderError, Texture,
@ -339,4 +339,12 @@ impl GfxContext for GlRenderContext {
fn sync_obj_ctx(&self) -> Option<&Rc<SyncObjCtx>> {
Some(&self.sync_ctx)
}
fn acquire_blend_buffer(
&self,
_width: i32,
_height: i32,
) -> Result<Rc<dyn GfxBlendBuffer>, GfxError> {
Err(GfxError(Box::new(RenderError::NoBlendBuffer)))
}
}

View file

@ -2,9 +2,9 @@ use {
crate::{
format::Format,
gfx_api::{
AcquireSync, AsyncShmGfxTextureCallback, GfxApiOpt, GfxError, GfxFramebuffer,
GfxInternalFramebuffer, GfxStagingBuffer, PendingShmTransfer, ReleaseSync, ShmMemory,
SyncFile,
AcquireSync, AsyncShmGfxTextureCallback, GfxApiOpt, GfxBlendBuffer, GfxError,
GfxFramebuffer, GfxInternalFramebuffer, GfxStagingBuffer, PendingShmTransfer,
ReleaseSync, ShmMemory, SyncFile,
},
gfx_apis::gl::{
RenderError,
@ -106,6 +106,7 @@ impl GfxFramebuffer for Framebuffer {
ops: &[GfxApiOpt],
clear: Option<&Color>,
_region: &Region,
_blend_buffer: Option<&Rc<dyn GfxBlendBuffer>>,
) -> Result<Option<SyncFile>, GfxError> {
(*self)
.render(acquire_sync, ops, clear)

View file

@ -24,9 +24,9 @@ use {
cpu_worker::{CpuWorker, jobs::read_write::ReadWriteJobError},
format::Format,
gfx_api::{
AsyncShmGfxTexture, GfxContext, GfxError, GfxFormat, GfxImage, GfxInternalFramebuffer,
GfxStagingBuffer, ResetStatus, STAGING_DOWNLOAD, STAGING_UPLOAD, ShmGfxTexture,
StagingBufferUsecase,
AsyncShmGfxTexture, GfxBlendBuffer, GfxContext, GfxError, GfxFormat, GfxImage,
GfxInternalFramebuffer, GfxStagingBuffer, ResetStatus, STAGING_DOWNLOAD,
STAGING_UPLOAD, ShmGfxTexture, StagingBufferUsecase,
},
gfx_apis::vulkan::{
image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer,
@ -204,6 +204,8 @@ pub enum VulkanError {
UndefinedContents,
#[error("The framebuffer is being used by the transfer queue")]
BusyInTransfer,
#[error("Vulkan does not support blend buffers")]
NoBlendBuffer,
}
impl From<VulkanError> for GfxError {
@ -350,6 +352,14 @@ impl GfxContext for Context {
.device
.create_staging_shell(size as u64, upload, download)
}
fn acquire_blend_buffer(
&self,
_width: i32,
_height: i32,
) -> Result<Rc<dyn GfxBlendBuffer>, GfxError> {
Err(GfxError(Box::new(VulkanError::NoBlendBuffer)))
}
}
impl Drop for Context {

View file

@ -3,9 +3,9 @@ use {
format::Format,
gfx_api::{
AcquireSync, AsyncShmGfxTexture, AsyncShmGfxTextureCallback,
AsyncShmGfxTextureTransferCancellable, GfxApiOpt, GfxError, GfxFramebuffer, GfxImage,
GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture, PendingShmTransfer, ReleaseSync,
ShmGfxTexture, ShmMemory, SyncFile,
AsyncShmGfxTextureTransferCancellable, GfxApiOpt, GfxBlendBuffer, GfxError,
GfxFramebuffer, GfxImage, GfxInternalFramebuffer, GfxStagingBuffer, GfxTexture,
PendingShmTransfer, ReleaseSync, ShmGfxTexture, ShmMemory, SyncFile,
},
gfx_apis::vulkan::{
VulkanError, allocator::VulkanAllocation, device::VulkanDevice,
@ -539,6 +539,7 @@ impl GfxFramebuffer for VulkanImage {
ops: &[GfxApiOpt],
clear: Option<&Color>,
region: &Region,
_blend_buffer: Option<&Rc<dyn GfxBlendBuffer>>,
) -> Result<Option<SyncFile>, GfxError> {
self.renderer
.execute(&self, acquire_sync, release_sync, ops, clear, region)