diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | c52a05e6d3977efce6bd4479aa312dc90e0452e5 (patch) | |
tree | c383c910c1467b406e332651906e081c599d6951 /stockton-render/src/draw/texture | |
parent | d5b9ccd3d4a6e5b35a0411688bfb7113f5c7d631 (diff) |
feat(render): proper error handling
Diffstat (limited to 'stockton-render/src/draw/texture')
-rw-r--r-- | stockton-render/src/draw/texture/loader.rs | 16 | ||||
-rw-r--r-- | stockton-render/src/draw/texture/repo.rs | 7 |
2 files changed, 15 insertions, 8 deletions
diff --git a/stockton-render/src/draw/texture/loader.rs b/stockton-render/src/draw/texture/loader.rs index 2198fe4..3d7d32e 100644 --- a/stockton-render/src/draw/texture/loader.rs +++ b/stockton-render/src/draw/texture/loader.rs @@ -147,13 +147,14 @@ impl<T: HasTextures, R: TextureResolver<I>, I: LoadableImage> TextureLoader<T, R debug!("Load finished for texture block {:?}", block.id); // Destroy staging buffers - while staging_bufs.len() > 0 { - let buf = staging_bufs.pop().unwrap(); + for buf in staging_bufs.drain(..) { buf.deactivate(&mut device, &mut self.staging_allocator); } self.buffers.push_back(assets); - self.return_channel.send(block).unwrap(); + self.return_channel + .send(block) + .context("Error returning texture block")?; } else { i += 1; } @@ -365,7 +366,11 @@ impl<T: HasTextures, R: TextureResolver<I>, I: LoadableImage> TextureLoader<T, R self.descriptor_allocator .allocate( &device, - &*self.ds_layout.read().unwrap(), + &*self + .ds_layout + .read() + .map_err(|_| LockPoisoned::Other) + .context("Error reading descriptor set layout")?, DescriptorRanges::from_bindings(&[ DescriptorSetLayoutBinding { binding: 0, @@ -668,8 +673,7 @@ impl<T: HasTextures, R: TextureResolver<I>, I: LoadableImage> TextureLoader<T, R device.destroy_fence(assets.0); // Command buffer will be freed when we reset the command pool // Destroy staging buffers - while staging_bufs.len() > 0 { - let buf = staging_bufs.pop().unwrap(); + for buf in staging_bufs.drain(..) { buf.deactivate(&mut device, &mut self.staging_allocator); } diff --git a/stockton-render/src/draw/texture/repo.rs b/stockton-render/src/draw/texture/repo.rs index d5200be..8191f7b 100644 --- a/stockton-render/src/draw/texture/repo.rs +++ b/stockton-render/src/draw/texture/repo.rs @@ -129,8 +129,11 @@ impl<'a> TextureRepo<'a> { }) } - pub fn get_ds_layout(&self) -> RwLockReadGuard<DescriptorSetLayoutT> { - self.ds_layout.read().unwrap() + pub fn get_ds_layout(&self) -> Result<RwLockReadGuard<DescriptorSetLayoutT>> { + self.ds_layout + .read() + .map_err(|_| LockPoisoned::Other) + .context("Error locking descriptor set layout") } pub fn queue_load(&mut self, block_id: BlockRef) -> Result<()> { |