diff --git a/runtime/vk.h b/runtime/vk.h index c8b11fd9..f8cab23f 100644 --- a/runtime/vk.h +++ b/runtime/vk.h @@ -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 diff --git a/runtime/vk_pipeline.c b/runtime/vk_pipeline.c index ee4f51dd..44341bd4 100644 --- a/runtime/vk_pipeline.c +++ b/runtime/vk_pipeline.c @@ -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) {