diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:24 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:24 +0100 |
commit | b86e97f67a07368877bd18501aebcbe80cf93118 (patch) | |
tree | 97b72b4339da6400b481170eab11fd89ab5dfa80 /stockton-render/src/ui.rs | |
parent | e1cc0e9a9d191bcd3a634be46fd3555d430b07a8 (diff) |
feat(skeleton): add memory pools
added stock memory pools behind a feature gate
refactored buffers to use them and to have better APIs.
moved some util code out of builders::pipeline
updated stockton-render for the changes
deactivation is a WIP
breaks UI drawing, fix WIP
Diffstat (limited to 'stockton-render/src/ui.rs')
-rw-r--r-- | stockton-render/src/ui.rs | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/stockton-render/src/ui.rs b/stockton-render/src/ui.rs index 77ff805..2c8818c 100644 --- a/stockton-render/src/ui.rs +++ b/stockton-render/src/ui.rs @@ -2,7 +2,7 @@ use crate::window::UiState; use stockton_skeleton::{ - buffers::{DrawBuffers, ModifiableBuffer}, + buffers::draw::DrawBuffers, builders::{ CompletePipeline, PipelineSpecBuilder, RenderpassSpec, ShaderDesc, VertexBufferSpec, VertexPrimitiveAssemblerSpec, @@ -10,6 +10,7 @@ use stockton_skeleton::{ context::RenderingContext, draw_passes::{util::TargetSpecificResources, DrawPass, IntoDrawPass, PassPosition}, error::{EnvironmentError, LockPoisoned}, + mem::{DataPool, StagingPool, TexturesPool}, queue_negotiator::QueueNegotiator, texture::{ resolver::TextureResolver, LoadableImage, TexLoadQueue, TextureLoadConfig, TextureRepo, @@ -47,8 +48,8 @@ pub struct UiPoint(pub Vector2, pub Vector2, pub [f32; 4]); /// Draw a Ui object pub struct UiDrawPass<'a> { pipeline: CompletePipeline, - repo: TextureRepo, - draw_buffers: DrawBuffers<'a, UiPoint>, + repo: TextureRepo<TexturesPool, StagingPool>, + draw_buffers: DrawBuffers<'a, UiPoint, DataPool, StagingPool>, framebuffers: TargetSpecificResources<FramebufferT>, } @@ -185,15 +186,16 @@ impl<'a, P: PassPosition> DrawPass<P> for UiDrawPass<'a> { } fn deactivate(self, context: &mut RenderingContext) -> Result<()> { + self.draw_buffers.deactivate(context); + unsafe { let mut device = context.device().write().map_err(|_| LockPoisoned::Device)?; self.pipeline.deactivate(&mut device); - self.draw_buffers.deactivate(&mut device); for fb in self.framebuffers.dissolve() { device.destroy_framebuffer(fb); } } - self.repo.deactivate(context.device()); + self.repo.deactivate(context); Ok(()) } @@ -276,19 +278,8 @@ impl<'a, P: PassPosition> IntoDrawPass<UiDrawPass<'a>, P> for () { .context("Error building pipeline")?; let ui: &mut UiState = &mut session.resources.get_mut::<UiState>().unwrap(); - let repo = TextureRepo::new( - context.device().clone(), - context - .queue_negotiator_mut() - .family::<TexLoadQueue>() - .ok_or(EnvironmentError::NoSuitableFamilies) - .context("Error finding texture queue")?, - context - .queue_negotiator_mut() - .get_queue::<TexLoadQueue>() - .ok_or(EnvironmentError::NoQueues) - .context("Error finding texture queue")?, - context.adapter(), + let repo = TextureRepo::new::<_, TexLoadQueue>( + context, TextureLoadConfig { resolver: UiTextures::new(ui.ctx().clone()), filter: hal::image::Filter::Linear, @@ -297,10 +288,12 @@ impl<'a, P: PassPosition> IntoDrawPass<UiDrawPass<'a>, P> for () { ) .context("Error creating texture repo")?; - let (draw_buffers, pipeline, framebuffers) = { + let draw_buffers = + DrawBuffers::from_context(context).context("Error creating draw buffers")?; + + let (pipeline, framebuffers) = { let mut device = context.device().write().map_err(|_| LockPoisoned::Device)?; - let draw_buffers = DrawBuffers::new(&mut device, context.adapter()) - .context("Error creating draw buffers")?; + let pipeline = spec .build( &mut device, @@ -321,7 +314,7 @@ impl<'a, P: PassPosition> IntoDrawPass<UiDrawPass<'a>, P> for () { }, context.target_chain().properties().image_count as usize, )?; - (draw_buffers, pipeline, framebuffers) + (pipeline, framebuffers) }; Ok(UiDrawPass { |