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-skeleton/src/texture/block.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-skeleton/src/texture/block.rs')
-rw-r--r-- | stockton-skeleton/src/texture/block.rs | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/stockton-skeleton/src/texture/block.rs b/stockton-skeleton/src/texture/block.rs index 5ac3a94..1b195c2 100644 --- a/stockton-skeleton/src/texture/block.rs +++ b/stockton-skeleton/src/texture/block.rs @@ -1,21 +1,22 @@ use super::{loader::BlockRef, repo::BLOCK_SIZE}; -use crate::types::*; +use crate::{buffers::image::SampledImage, mem::MemoryPool, types::*}; use arrayvec::ArrayVec; -use rendy_memory::{Allocator, Block}; use std::{iter::once, mem::ManuallyDrop}; -pub struct TexturesBlock<B: Block<back::Backend>> { +/// A block of loaded textures +pub struct TexturesBlock<TP: MemoryPool> { pub id: BlockRef, pub descriptor_set: ManuallyDrop<RDescriptorSet>, - pub imgs: ArrayVec<[LoadedImage<B>; BLOCK_SIZE]>, + pub imgs: ArrayVec<[SampledImage<TP>; BLOCK_SIZE]>, } -impl<B: Block<back::Backend>> TexturesBlock<B> { - pub fn deactivate<T: Allocator<back::Backend, Block = B>>( +impl<TP: MemoryPool> TexturesBlock<TP> { + /// Destroy all Vulkan objects. Must be called before dropping. + pub fn deactivate( mut self, device: &mut DeviceT, - tex_alloc: &mut T, + tex_alloc: &mut TP, desc_alloc: &mut DescriptorAllocator, ) { unsafe { @@ -27,36 +28,8 @@ impl<B: Block<back::Backend>> TexturesBlock<B> { // Images self.imgs .drain(..) - .map(|x| x.deactivate(device, tex_alloc)) + .map(|x| x.deactivate_with_device_pool(device, tex_alloc)) .for_each(|_| {}); } } } - -pub struct LoadedImage<B: Block<back::Backend>> { - pub mem: ManuallyDrop<B>, - pub img: ManuallyDrop<ImageT>, - pub img_view: ManuallyDrop<ImageViewT>, - pub sampler: ManuallyDrop<SamplerT>, - pub row_size: usize, - pub height: u32, - pub width: u32, -} - -impl<B: Block<back::Backend>> LoadedImage<B> { - pub fn deactivate<T: Allocator<back::Backend, Block = B>>( - self, - device: &mut DeviceT, - alloc: &mut T, - ) { - unsafe { - use std::ptr::read; - - device.destroy_image_view(read(&*self.img_view)); - device.destroy_image(read(&*self.img)); - device.destroy_sampler(read(&*self.sampler)); - - alloc.free(device, read(&*self.mem)); - } - } -} |