From c9fb3ae28fe491bc55243fb80d8c6be93f37ad99 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:23 +0100 Subject: feat(render): ui working --- stockton-render/src/draw/texture/load.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'stockton-render/src/draw/texture/load.rs') 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 { + pub resolver: R, + pub filter: Filter, + pub wrap_mode: WrapMode, +} + pub struct QueuedLoad> { pub fence: FenceT, pub buf: CommandBufferT, @@ -62,8 +64,6 @@ impl> QueuedLoad { } } -impl<'a, T: HasTextures, R: TextureResolver, I: LoadableImage> TextureLoader {} - pub fn tex_size_info(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( +pub unsafe fn load_image( device: &mut DeviceT, staging_allocator: &mut DynamicAllocator, tex_allocator: &mut DynamicAllocator, staging_memory_type: MemoryTypeId, obcpa: u64, img_data: I, + config: &TextureLoadConfig, ) -> Result<(StagingBuffer, LoadedImage)> { // Calculate buffer size let (row_size, total_size) = tex_size_info(&img_data, obcpa); @@ -172,7 +173,7 @@ pub unsafe fn load_image( // 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(( -- cgit v1.2.3