Copy large textures out of the game's memory on several threads at once: a level of 1 MiB or more goes to a small worker pool as bands of rows (par_jobs.c, tex_deswizzle.c tex_bl_copy_mt), and so does a large block copy for the GPU's ASTC decoder, so the upload's storage copy no longer runs on the drawing thread alone. The bytes are those of the one-thread copy; par_jobs = 0 turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 08:35:42 -05:00
parent e7c2fc6a6b
commit fadd4a6d5e
9 changed files with 347 additions and 25 deletions

View File

@@ -23,6 +23,7 @@
#include "nvn_api.h"
#include "nvn_hmap.h"
#include "nvn_tex.h"
#include "par_jobs.h"
#include "tex.h"
#include "vk.h"
#include "vk_dlaa.h"
@@ -3754,14 +3755,14 @@ static void upload(Tex *e) {
}
if (gdsw && !sk) {
if (held && check) opq = astc_copy_opaque(e, stg, t->mem, size, &bc1_dec);
else if (held) memcpy(stg, t->mem, size);
else if (held) par_memcpy(stg, t->mem, size); // large blocks over the par_jobs pool
else memset(stg, 0, size);
} else if (gdsw) {
VkDeviceSize at = 0;
for (k = 0; k < n; k++) { // astc_bl_regions checked that each lies inside the storage
VkDeviceSize nb = vk_astc_region_bytes(&ar[k], (uint32_t)bw, (uint32_t)bh);
if (held && check) opq &= astc_copy_opaque(e, stg + at, t->mem + ar[k].src, nb, &bc1_dec);
else if (held) memcpy(stg + at, t->mem + ar[k].src, nb);
else if (held) par_memcpy(stg + at, t->mem + ar[k].src, nb);
else memset(stg + at, 0, nb);
ar[k].src = at, at += nb;
}
@@ -3776,7 +3777,7 @@ static void upload(Tex *e) {
tmps[k - k0] = tmp;
if (!held) {
memset(tmp ? tmp : dst, 0, raw);
} else if (nvn_deswizzle(d, lv + sk, ly, t->mem, tmp ? tmp : dst, rb)) {
} else if (nvn_deswizzle_mt(d, lv + sk, ly, t->mem, tmp ? tmp : dst, rb)) { // large levels: par_jobs.c
log_limited(&n_bad, "texture %#llx fmt %#x target %d: level %u layer %u has no CPU layout; uploaded as zeros",
(unsigned long long)e->pub.addr, d->format, d->target, lv + sk, ly);
memset(tmp ? tmp : dst, 0, raw);