summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-01 13:07:11 +1100
committerquou <quou@disroot.org>2025-01-01 13:07:11 +1100
commit221d157d069ab248c9f11653fa37a670d5a7a212 (patch)
treee05a61f1c452a3be3ace2318221c615959cf786f
parent87393ae98fa459715b0c9616b986a23650e373b6 (diff)
improve efficiency of texture uploading
-rw-r--r--video.cpp30
1 files changed, 10 insertions, 20 deletions
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
+}