diff options
author | quou <quou@disroot.org> | 2025-01-01 13:07:11 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-01-01 13:07:11 +1100 |
commit | 221d157d069ab248c9f11653fa37a670d5a7a212 (patch) | |
tree | e05a61f1c452a3be3ace2318221c615959cf786f | |
parent | 87393ae98fa459715b0c9616b986a23650e373b6 (diff) |
improve efficiency of texture uploading
-rw-r--r-- | video.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
@@ -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 +} |