Mark the texture pool slots that shaders index, for eviction by disuse (work in progress: not built; the runtime side follows).

vk_pipeline.c spirv_pool_mark gives each module that indexes the texture pool a storage buffer at set 2, binding
VK_POOL_MARK_BINDING, and a store of 1 into the slot after every access chain into a pool texture array; modules that
cannot be marked are counted in vk_pool_marks_missed. NX2NAVI_SPV_MARK_TEST=<list> runs the rewrite over files for
spirv-val under --selftest. Still to do: the marks buffer and its read-back (vk_exec_draw.c), the pool lookup context,
the holds and the eviction by disuse (vk_texture.c).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7ae86070f166d935a9949e95dae7a95e2cf3272b)
This commit is contained in:
chrg6
2026-11-09 14:13:11 -05:00
committed by tangerineturtle1
parent 87f51f94a9
commit d016a6dc86
2 changed files with 186 additions and 0 deletions

View File

@@ -476,6 +476,12 @@ int vk_sampler_slot_count_locked(void);
#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
// Texture pool marks (vk_pipeline.c spirv_pool_mark, vk_exec_draw.c "pool marks"): set 2, this binding, a uint per pool
// slot that shaders set to 1 when they index the slot.
#define VK_POOL_MARK_BINDING (VK_POOL_KINDS + 1)
int vk_pool_marks_enabled(void); // NX2NAVI_TEX_DISUSE: modules get the marks
extern volatile int32_t vk_pool_marks_missed; // modules indexing the pool that could not be marked
void vk_pool_marks_read(const uint32_t *marks, uint32_t n); // vk_texture.c: slots marked since the last read
VkDescriptorSetLayout vk_pool_set_layout(void); // the pools' layout (made on first use)
VkDescriptorSetLayout vk_empty_set_layout(void); // set 1 of layouts without one
// The upscaler stand-in (vk_tonemap.c): src (sampled) scaled to dw x dh and tonemapped into its own RGBA16F image, which