mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 16:28:38 +00:00
On the console a texture access loads the T# and samples. Translated shaders hashed the eight T# words and probed up to eight slots of the descriptor table for every access: 62 lookups and 19,714 RADV instructions in the tiled-lighting pixel shader (3,080 in the native program). The layer now writes the index into dword 6 of every T# in the heaps shaders read, as TAG 0xA [31:28] | storage kind [27:23] | sampled kind [22:16] | index [15:0] (gfx10_descriptors.h, tsharp_index_word): the console resource heap copies (fix_console_slot, again whenever the texture at the T#'s address comes, goes or is replaced) and its own shader-visible heaps (write_image_descriptor, refreshed for bound tables by scan_title_table). The title's bytes and the T#'s table key keep the title's dword 6. The translator (tools/descriptor_sources.py, Gen.tsharp_index_sgpr) follows the SGPR dataflow and takes the index from dword 6, with no lookup, for every T# whose dword 6 it traces to a heap slot (an s_load from a 32-bit descriptor-table or heap pointer in user data); index 0 unless the word has the tag and dword 3 names an image. Other T#s are looked up and prefer a tagged word. S#s keep the lookup (sampler heaps are read in place; 40% are literals). Over the 1.0.2.1 corpus (tools/descriptor_source_census.py) 438,353 of 439,415 T# operands (99.76%) take the word and 17,432 of 17,540 modules keep no T# lookup; no scalar instruction reads dword 5-7 of a heap T#. RADV on an RX 7900 XTX, lighting shader: instructions 19,714 -> 17,568, latency 73,690 -> 32,458, inverse throughput 16,453 -> 7,468. Modules record "tsharp_index": "dword6"; the runtime writes the word when the library's modules read it, so packs translated before keep working as they did. LEONIDA_CONSOLE_HEAP_GPU's pass copies T#s as written, so such a library's console heaps are fixed on the CPU. Tests: tests/semantic/test_tsharp_index_word.py (interpreter and dataflow), gfx10_descriptors_test, shader_library_test; ps_texture_sample and ps_table_fetch now load their T# through a table pointer and vk_texture_test writes the word (integrated GPU, RADV). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.2 KiB
NASM
26 lines
1.2 KiB
NASM
; Texture sampling test: samples a 2D texture (T# at s[8:15] loaded via s[0:1], S# at s[16:19])
|
|
; using normalized UV coordinates from attr0, outputs sampled color to mrt0.
|
|
; Run: vk_texture_test (autonomously, or with vs.spv fs.spv out.raw ptr_sgpr s0 s1 s2 s3)
|
|
; -> verifies center pixel = gradient color (0.5, 0.5, 0.5, 1.0) sampled via descriptor table
|
|
; s0 = descriptor-table pointer to the T# in the GPU heap, made a 32-bit pointer (s1 = 0) as the title's shaders do:
|
|
; the shader takes the T#'s bindless index from its dword 6, with no hash-table lookup (docs/design.md, "Bindless
|
|
; index in the T#"); vk_texture_test writes the index word there.
|
|
; s[8:15] = 8-dword T# (image descriptor)
|
|
; s[16:19] = 4-dword S# (sampler descriptor)
|
|
; v[0:1] = barycentric UV coordinates
|
|
s_mov_b32 s1, 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
|
|
s_load_dwordx8 s[8:15], s[0:1], 0x0
|
|
s_waitcnt lgkmcnt(0)
|
|
s_mov_b32 s16, 0x92
|
|
s_mov_b32 s17, 0xc00000
|
|
s_mov_b32 s18, 0x14500000
|
|
s_mov_b32 s19, 0
|
|
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
|