Commit Graph

10 Commits

Author SHA1 Message Date
26e0830184 descriptors: T# index word follows SGPR spills and VCC, deferred views and replaced entries; unknown-source T#s probe only without the word
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 06:17:16 -05:00
872a8cf417 descriptors: a heap T# carries its bindless index in dword 6; shaders read it there instead of probing the hash table
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>
2026-11-27 05:20:52 -05:00
9f98dcc617 Improve post-load GPU memory and pipeline handling (RT-POST-LOAD-GPU-MEMORY)
Fall back to a dedicated buffer allocation when the shared arena fills.
Update console descriptors and resource backing, preserve pipeline cache
entries, and replay mesh records using bounded indirect arguments. Keep
scripted input available until read and cover the runtime and translator
paths with synthetic tests.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 14:30:51 -06:00
ee0954fd6d rdna2spirv: break directly out of desc_probe loop with DontUnroll (Mesa ANV 26.1.6)
In Gen.desc_probe (%desc_lookup_fn), replace the counter-clobbering exit
(OpStore %dl_k 8; OpBranch %dl_next) with a structured early break
(OpBranch %dl_end) and mark OpLoopMerge %dl_end %dl_cont DontUnroll.

On Intel UHD Graphics 630 (CFL GT2) with Mesa ANV 26.1.6, keeping %dl_idx
on a single-exit loop-header phi caused the backend to hoist the post-loop
binding-table-index add (add bti, idx, 2) into B0 before the probe loop
ran (confirmed in INTEL_DEBUG=wm across SIMD8, SIMD16 and SIMD32), making
ps_table_fetch read slot 0 (magenta 0x3f800000) for both fetch-sint and
fetch-uint. Breaking straight to %dl_end gives %dl_end a distinct exit phi
so the add stays after the loop, while DontUnroll preserves one compact
rolled loop.

Tested (synthetic fixtures only, no game files):
- Intel UHD 630 (Mesa ANV 26.1.6, uncached): ps_table_fetch PASS (4096/4096),
  run_gpu_tests.py default 185/241 passed (0 failed, up from 184/241 with 1 fail),
  3-fallback run 220/241 (only known ms_wave_info_s3 fails).
- NVIDIA GTX 1050 Ti (555.58.02, VK_LOADER_LAYERS_DISABLE=~implicit~):
  run_gpu_tests.py default 180/241 passed, 61 skipped, 0 failed.
- Mesa llvmpipe (26.1.6): ps_table_fetch PASS (4096/4096).
- CPU: tests/test_desc_cache.py (spirv-as, spirv_asm.py, spirv-val) OK;
  scripts/run_semantic_tests.py tests/semantic: 444/447 files pass (5,956 tests,
  same 3 pre-existing failures as main dde82f27).

AI-assisted.
2026-11-23 22:34:41 +01:00
166fd116a8 Round 44 test clashes: CI registration sees inherited tests, runner skips, v_cmpx's EXEC def, wave32-half shuffles, OpFOrdLessThanEqual in spirv_interp, fixed f64 div_fixup divergence, 10_11_11 stores; the macOS runtime configure requires Vulkan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:23:34 -05:00
0ea717560a Declare only descriptor broadcast subgroup capability 2026-11-23 00:45:21 +05:30
0e5e539c42 Work around Mesa ANV descriptor index compiler crash 2026-11-22 23:52:48 +05:30
2782aa7a6a perf(translator): defer descriptor index load to hit block in desc_probe
In `desc_probe` (`%desc_lookup_fn`), the bindless index word at `base + 9`
was loaded from the `%desc_map` storage buffer before the conditional branch
`OpBranchConditional %match %dl_hit %dl_next`.

On every non-matching slot probed as well as on 8-probe misses, this issued
an unnecessary global storage buffer load that was immediately discarded.
Moving the index load into `%dl_hit` eliminates up to 8 storage buffer reads
per miss and 1 read per non-matching collision slot, reducing memory traffic
and register pressure.

Mirrored the same deferred load structure in `runtime/test/vk_descriptor_bench.cpp`.
Added `test_desc_probe_defers_index_load_to_hit_block` to `tests/test_desc_cache.py`.
2026-11-22 18:00:09 +06:00
14daa27523 Tests: cover desc_cache_ok (no caching inside an instruction's own construct) 2026-11-21 18:46:15 +00:00
74e188c8a0 Translator: cache descriptor lookups per basic block
Each image instruction called %desc_lookup_fn for its T# and S#, so a shader sampling the same texture
many times in a block called it many times. The call count is what the driver's compile time follows
(ShadowRenderTiledCascades: 1550 static calls on main). desc_lookup_sgpr remembers the result per
(first SGPR, dwords) for the rest of the basic block.

- store_reg drops the entries overlapping the SGPR it writes; every write to %sgpr goes through it
  (64-bit writes are two calls), apart from the function prologue, which runs before any block.
- translate() clears the cache when a basic block starts.
- Only lookups at the top level of the block are remembered (desc_cache_ok): an id made inside an op's
  selection construct would not dominate the code after its merge.
- image_load passes its image index to image_load_typed instead of looking the T# up a second time.
- tests/test_desc_cache.py counts the calls.
2026-11-21 15:19:09 -03:00