From c48b54f3fb7bbe9046915eb99eca02fa84dc55c9 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:22 +0100 Subject: feat(render): multithreaded texture loading also a bunch of supporting changes --- stockton-render/src/draw/ui/texture.rs | 49 ++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'stockton-render/src/draw/ui/texture.rs') diff --git a/stockton-render/src/draw/ui/texture.rs b/stockton-render/src/draw/ui/texture.rs index 98688de..439c3d7 100755 --- a/stockton-render/src/draw/ui/texture.rs +++ b/stockton-render/src/draw/ui/texture.rs @@ -14,10 +14,25 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ -use crate::draw::texture::{LoadableImage, TextureStore}; +use crate::draw::texture::{LoadableImage, TextureRepo}; use crate::types::*; -use crate::UIState; +use crate::UiState; use egui::Texture; +use stockton_levels::{prelude::HasTextures, traits::textures::Texture as LTexture}; + +pub struct UiTextures; + +impl HasTextures for UiTextures { + type TexturesIter<'a> = std::slice::Iter<'a, LTexture>; + + fn textures_iter(&self) -> Self::TexturesIter<'_> { + (&[]).iter() + } + + fn get_texture(&self, _idx: u32) -> Option<&stockton_levels::prelude::textures::Texture> { + None + } +} impl LoadableImage for &Texture { fn width(&self) -> u32 { @@ -38,31 +53,25 @@ impl LoadableImage for &Texture { } } } + + unsafe fn copy_into(&self, _ptr: *mut u8, _row_size: usize) { + todo!() + } } pub fn ensure_textures( - texture_store: &mut TextureStore, - ui: &mut UIState, - device: &mut Device, - adapter: &mut Adapter, - allocator: &mut DynamicAllocator, - command_queue: &mut CommandQueue, - command_pool: &mut CommandPool, + _tex_repo: &mut TextureRepo, + ui: &mut UiState, + _device: &mut Device, + _adapter: &mut Adapter, + _allocator: &mut DynamicAllocator, + _command_queue: &mut CommandQueue, + _command_pool: &mut CommandPool, ) { let tex = ui.ctx.texture(); if tex.version != ui.last_tex_ver { - texture_store - .put_texture( - 0, - &*tex, - device, - adapter, - allocator, - command_queue, - command_pool, - ) - .unwrap(); // TODO + // tex_repo.force_queue_load(0).unwrap(); // TODO ui.last_tex_ver = tex.version; } } -- cgit v1.2.3