From 221d157d069ab248c9f11653fa37a670d5a7a212 Mon Sep 17 00:00:00 2001 From: quou Date: Wed, 1 Jan 2025 13:07:11 +1100 Subject: improve efficiency of texture uploading --- video.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'video.cpp') diff --git a/video.cpp b/video.cpp index 372b851..1dc8f68 100644 --- a/video.cpp +++ b/video.cpp @@ -938,8 +938,6 @@ struct Texture_Loader : public Asset_Loader { Pack_File* f ) override; void unload(Asset* a) override; - - Buffer_Id upload(void* buf, size_t size); }; struct Terminator { @@ -3645,20 +3643,6 @@ size_t Texture_Loader::calc_size( } } -Buffer_Id Texture_Loader::upload(void* buf, size_t size) { - void* mem; - Buffer_Id id = dev->create_buffer( - "texture stage", - size, - Buffer_Flags::copy_src | - Buffer_Flags::cpu_readwrite - ); - mem = dev->map_buffer(id, 0, size); - memcpy(mem, buf, size); - dev->unmap_buffer(id); - return id; -} - Asset* Texture_Loader::load( Arena* a, Arena* s, @@ -3676,10 +3660,16 @@ Asset* Texture_Loader::load( pack_read(f, &h, 4); pack_read(f, &fmt, 4); size = calc_size(fmt, w, h); - data = arena_alloc(s, size); - pack_read(f, data, size); { - Buffer_Id buf = upload(data, size); + Buffer_Id buf = dev->create_buffer( + "texture stage", + size, + Buffer_Flags::copy_src | + Buffer_Flags::cpu_readwrite + ); + void* mem = dev->map_buffer(buf, 0, size); + pack_read(f, mem, size); + dev->unmap_buffer(buf); Texture_Id tex = dev->create_texture( filename, fmt, @@ -4059,4 +4049,4 @@ void Device_Debug_Hooks::on_page_alloc(size_t size) { void Device_Debug_Hooks::on_vram_alloc(size_t size, size_t align) { (void)size; (void)align; -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf