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 | c9fb3ae28fe491bc55243fb80d8c6be93f37ad99 (patch) | |
tree | c8d6519479d3b17f5bd657495c4d7fe2d2830a1a /stockton-render/src/draw/texture/load.rs | |
parent | c52a05e6d3977efce6bd4479aa312dc90e0452e5 (diff) |
feat(render): ui working
Diffstat (limited to 'stockton-render/src/draw/texture/load.rs')
-rw-r--r-- | stockton-render/src/draw/texture/load.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/stockton-render/src/draw/texture/load.rs b/stockton-render/src/draw/texture/load.rs index eea820a..e278fa2 100644 --- a/stockton-render/src/draw/texture/load.rs +++ b/stockton-render/src/draw/texture/load.rs @@ -1,9 +1,8 @@ use super::{ - block::LoadedImage, block::TexturesBlock, loader::TextureLoader, repo::BLOCK_SIZE, - resolver::TextureResolver, staging_buffer::StagingBuffer, LoadableImage, PIXEL_SIZE, + block::LoadedImage, block::TexturesBlock, repo::BLOCK_SIZE, resolver::TextureResolver, + staging_buffer::StagingBuffer, LoadableImage, PIXEL_SIZE, }; use crate::types::*; -use stockton_levels::prelude::*; use anyhow::{Context, Result}; use arrayvec::ArrayVec; @@ -24,9 +23,6 @@ use thiserror::Error; pub enum TextureLoadError { #[error("No available resources")] NoResources, - - #[error("Texture could not be resolved")] - ResolveFailed(usize), } pub const FORMAT: Format = Format::Rgba8Srgb; @@ -43,6 +39,12 @@ pub const LAYERS: SubresourceLayers = SubresourceLayers { layers: 0..1, }; +pub struct TextureLoadConfig<R: TextureResolver> { + pub resolver: R, + pub filter: Filter, + pub wrap_mode: WrapMode, +} + pub struct QueuedLoad<B: Block<back::Backend>> { pub fence: FenceT, pub buf: CommandBufferT, @@ -62,8 +64,6 @@ impl<B: Block<back::Backend>> QueuedLoad<B> { } } -impl<'a, T: HasTextures, R: TextureResolver<I>, I: LoadableImage> TextureLoader<T, R, I> {} - pub fn tex_size_info<T: LoadableImage>(img: &T, obcpa: hal::buffer::Offset) -> (usize, usize) { let initial_row_size = PIXEL_SIZE * img.width() as usize; let row_alignment_mask = obcpa as u32 - 1; @@ -119,13 +119,14 @@ where Ok((block, image_ref)) } -pub unsafe fn load_image<I: LoadableImage>( +pub unsafe fn load_image<I: LoadableImage, R: TextureResolver>( device: &mut DeviceT, staging_allocator: &mut DynamicAllocator, tex_allocator: &mut DynamicAllocator, staging_memory_type: MemoryTypeId, obcpa: u64, img_data: I, + config: &TextureLoadConfig<R>, ) -> Result<(StagingBuffer, LoadedImage<DynamicBlock>)> { // Calculate buffer size let (row_size, total_size) = tex_size_info(&img_data, obcpa); @@ -172,7 +173,7 @@ pub unsafe fn load_image<I: LoadableImage>( // Create sampler let sampler = device - .create_sampler(&SamplerDesc::new(Filter::Nearest, WrapMode::Tile)) + .create_sampler(&SamplerDesc::new(config.filter, config.wrap_mode)) .context("Error creating sampler")?; Ok(( |