1
0
Fork 0
forked from wry/wry

gfx: add GfxStagingBuffer

This commit is contained in:
Julian Orth 2024-10-05 16:49:22 +02:00
parent 1462933ef4
commit 3619a51fbd
11 changed files with 215 additions and 43 deletions

View file

@ -23,7 +23,8 @@ use {
format::Format,
gfx_api::{
AsyncShmGfxTexture, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
ResetStatus, ShmGfxTexture,
GfxStagingBuffer, ResetStatus, ShmGfxTexture, StagingBufferUsecase, STAGING_DOWNLOAD,
STAGING_UPLOAD,
},
gfx_apis::vulkan::{
image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer,
@ -203,6 +204,10 @@ pub enum VulkanError {
AsyncCopyToStaging(#[source] ReadWriteJobError),
#[error("The async shm texture is busy")]
AsyncCopyBusy,
#[error("The staging buffer is busy")]
StagingBufferBusy,
#[error("The staging buffer does not support uploads")]
StagingBufferNoUpload,
}
impl From<VulkanError> for GfxError {
@ -330,6 +335,18 @@ impl GfxContext for Context {
fn sync_obj_ctx(&self) -> Option<&Rc<SyncObjCtx>> {
Some(&self.0.device.sync_ctx)
}
fn create_staging_buffer(
&self,
size: usize,
usecase: StagingBufferUsecase,
) -> Rc<dyn GfxStagingBuffer> {
let upload = usecase.contains(STAGING_UPLOAD);
let download = usecase.contains(STAGING_DOWNLOAD);
self.0
.device
.create_staging_shell(size as u64, upload, download)
}
}
impl Drop for Context {