Treat pool arrays of the old 32768 length as pool arrays, for translations carried over from the translator before.

After an update the game keeps the previous translator's translations until a background pass translates them again. Those still declare texture pool arrays of 32768, which spirv_pool_rebind no longer took for pool arrays once VK_POOL_TEX grew, so their textures were never bound and areas loaded with empty images. They now bind to the first 32768 entries of the larger binding.
This commit is contained in:
Leyukaka
2026-11-11 22:52:10 +01:00
committed by chrg6
parent 2388f1f581
commit e0271c0298
2 changed files with 7 additions and 1 deletions

View File

@@ -660,6 +660,7 @@ int vk_sampler_slot_count_locked(void);
// see-through ground until the area was loaded again (#569). 16 kinds x 40960 = 655,360 sampled images in set 2, under
// NVIDIA's 1,048,576 update-after-bind limit with room for the bound slots. vk_texture_register logs a slot past it.
#define VK_POOL_TEX 40960 // as the translator's Accessor.TexturePoolLength
#define VK_POOL_TEX_CARRIED 32768 // the length before: carried translations still declare it
#define VK_POOL_SAMP 4096 // Accessor.SamplerPoolLength
#define VK_POOL_KINDS 16 // kind = depth * 8 + dim * 2 + arrayed, dim 1D 2D 3D CUBE
extern volatile uint32_t vk_pool_kinds_used; // bit k: a pipeline was made with a kind-k pool array

View File

@@ -2209,7 +2209,12 @@ static uint32_t *spirv_pool_rebind(const uint32_t *w, uint64_t n) {
} else if (op == OP_TYPE_ARRAY_ && len >= 4 && w[i + 1] < bound && w[i + 2] < bound && w[i + 3] < bound) {
int32_t k = kind[w[i + 2]];
uint32_t want = k == 100 ? VK_POOL_SAMP : VK_POOL_TEX;
kind[w[i + 1]] = k >= 0 && cval[w[i + 3]] == want ? k + 1000 : -1; // + 1000: a pool array
// A translation carried over from a translator whose pool was VK_POOL_TEX_CARRIED long (gfx_shader.c,
// carry) is a pool array too: left in its own set, its textures were never bound and the scene drew
// with empty images until the background pass translated it again. It indexes the first
// VK_POOL_TEX_CARRIED entries of the larger binding, which Vulkan allows.
int pool = k >= 0 && (cval[w[i + 3]] == want || (k != 100 && cval[w[i + 3]] == VK_POOL_TEX_CARRIED));
kind[w[i + 1]] = pool ? k + 1000 : -1; // + 1000: a pool array
} else if (op == SPV_OP_TYPE_POINTER && len >= 4 && w[i + 1] < bound && w[i + 3] < bound) {
kind[w[i + 1]] = kind[w[i + 3]] >= 1000 ? kind[w[i + 3]] : -1;
} else if (op == SPV_OP_VARIABLE && len >= 4 && w[i + 1] < bound && w[i + 2] < bound) {