mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 14:58:37 +00:00
Set 0 as the translator declares it (docs/design.md, docs/d3d12_vulkan.md section 5), in runtime/src/vulkan_bindless.h: the twenty bindings with the array sizes vk_pipeline_check uses, and DescriptorTable (descriptor_table.h) behind binding 2. - An image has one index in its dimension (2D, 2D array, 3D, 1D), the same in every binding of that dimension. The storage arrays hold 256, so an image with a storage view gets an index below 256 and a read-only one goes above while there is room. - Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss in the table is index 0. - Changes are queued and written by flush(), one write a slot: a view removed before the next flush is never written, so it may be destroyed at once. - insert_key / erase_key change the table; flush() copies it to the buffer, into a new and larger one when it has grown. Erasing compacts a probe cluster, which moves other keys' entries, and a new buffer rewrites binding 2: flush_needs_idle() says when a flush would do either, so the owner can make sure no command buffer that uses the set is still running. - With update after bind the set may be flushed between submissions; with partially bound only index 0 is written at creation. Test: vk_bindless_test, run by runtime/test/shaders/check.py and scripts/run_gpu_tests.py. ps_tex.asm, a hand-written RDNA2 pixel shader built by build.py, loads a T# and an S# from a descriptor table and samples: the translator's own lookup against the table and the set. It draws the gradient with the T# at the fourth slot probed, the fallback after the key is erased, the gradient after the table has grown into a new buffer, another view at the same index and the fallback after removal, with and without the descriptor-indexing flags; and it adds, removes and destroys a view before its first flush, which the validation layer reports if the write is still made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
19 lines
1.0 KiB
NASM
19 lines
1.0 KiB
NASM
; A texture found through a descriptor table. User data s2:s3 is the console VA of the table: a T# (8 dwords) at
|
|
; +0 and an S# (4 dwords) at +32, read at heap base + VA. The translator hashes each and looks it up in the
|
|
; descriptor hash table (set 0, binding 2); the indices pick the image (binding 0) and the sampler (binding 1).
|
|
; The texture is sampled at attr0.xy, which vs_ids runs 0..1 over the image.
|
|
; Run: vk_bindless_test vs_ids.spv ps_tex.spv
|
|
; -> mrt0 = the texel under each pixel: an 8x8 gradient (x / 8, y / 8, 0.5, 1) through a nearest sampler, also
|
|
; after the table has grown; the fallback image at index 0 (zeros) when the table does not hold the T#.
|
|
s_load_dwordx8 s[8:15], s[2:3], 0x0
|
|
s_load_dwordx4 s[16:19], s[2:3], 0x20
|
|
s_waitcnt lgkmcnt(0)
|
|
v_interp_p1_f32_e32 v2, v0, attr0.x
|
|
v_interp_p2_f32_e32 v2, v1, attr0.x
|
|
v_interp_p1_f32_e32 v3, v0, attr0.y
|
|
v_interp_p2_f32_e32 v3, v1, attr0.y
|
|
image_sample v[4:7], v[2:3], s[8:15], s[16:19] dmask:0xf dim:SQ_RSRC_IMG_2D
|
|
s_waitcnt vmcnt(0)
|
|
exp mrt0 v4, v5, v6, v7 done vm
|
|
s_endpgm
|