mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:05:53 +01:00
[PR #811] [CLOSED] rdna2spirv: demand-driven %fmt_dec_dyn for 1/2/3-component buffer_load_format #849
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#849
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/811
Author: @SweatierKey
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:feat/fmt-dec-demand-channels📝 Commits (2)
7bddb1brdna2spirv: demand-driven %fmt_dec_dyn for 1/2/3-component buffer_load_format5c7a8bbtests: set odd DST_SEL_Y in _x selector matrix to kill 3->4 bitfield width mutant📊 Changes
4 files changed (+207 additions, -28 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
tests/semantic/test_format_decode_table.py(+90 -0)📝
tests/test_rdna2spirv_decode.py(+13 -0)📝
tools/rdna2spirv.py(+103 -27)📄 Description
Claimed in the coordination issue as: SHADER-FMT-DEC-DEMAND (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133732630)
What and why
Previously, every dynamic-format
buffer_load_format_{x,xy,xyz,xyzw}(and_d16_{x,xy,xyz,xyzw}) calledformat_decode_call, which invoked all four per-component functions%fmt_dec_c0..c3even for 1-componentbuffer_load_format_xloads, then swizzled byDST_SELand discarded 1–3 decoded components (75% dead work for_x, 50% for_xy, 25% for_xyz). Large compute shaders with thousands ofbuffer_load_format_xinstructions emitted up to13,124%fmt_dec_c*calls per shader.This change introduces a single shared branch-free dynamic-channel helper
%fmt_dec_dyn(fmt, words, chan)(reusingGen.fmt_dec_component(None, params)with branch-freechan % ncompselection) used on demand by 1/2/3-component dynamic-format loads:buffer_load_format_x/_d16_xemits 1%fmt_dec_dyncall instead of 4 (-75%).buffer_load_format_xy/_d16_xyemits 2 calls instead of 4 (-50%).buffer_load_format_xyz/_d16_xyzemits 3 calls instead of 4 (-25%).buffer_load_format_xyzw/_d16_xyzwcontinues using%fmt_dec_c0..c3unchanged.<4-component loads omit%fmt_dec_c0..c3entirely; shaders mixing_xyzwand<4-component loads share a single%fmt_norm_bitsdefinition.DST_SELhandling (0 -> 0,1 -> dst1even when OOB per SHADER-429, reserved2/3 -> 0,4..7 -> in_b ? dec : 0withchan = sel & 3) is bit-exact with the 4-component path.Aggregate impact across 15 cached large compute shaders (counts only):
35,200 -> 8,849(-74.9%); SPIR-V lines drop from7,017,898 -> 6,915,894(-102,004lines). All modules passspirv-val --target-env vulkan1.2.Tested
python3 -I tests/test_rdna2spirv_decode.py: 26/26 passed (including newtest_format_decode_dyn_call_builds_and_caches_function).LEONIDA_REQUIRE_SPIRV_TOOLS=1 PYTHONPATH=tests/semantic:tools python3 tests/semantic/test_format_decode_table.py: 7/7 passed (exhaustive check across all 128 format codes with rotatedDST_SELon_xyz, all 8DST_SELvalues in-bounds & OOB on_x, mixed_xyzw+_xdeduplication of%fmt_norm_bits, branch-free verification, and exact call-count assertions).LEONIDA_REQUIRE_SPIRV_TOOLS=1 python3 -I scripts/run_semantic_tests.py tests/semantic: 465 files, 6111 tests, 0 failures.python3 -I tests/test_docs_links.py(16/16),python3 -I tests/test_text_write_line_endings.py(3/3),python3 -I scripts/check_no_game_data.py,python3 -m compileall -q make_game.py tools tests: all passed.vk_compute_test.exe+spirv-val --target-env vulkan1.2): all 7 format compute fixtures passed with 816/816 exact readback words (cs_buf_swizzle8/8,cs_fmt_101010264/64,cs_fmt_int_narrow136/136,cs_fmt_sint3264/64 exercising mixed%fmt_dec_dyn+%fmt_dec_c*,cs_fmt_all336/336,cs_fmt_xy_xyz128/128 exercising 22%fmt_dec_dyncalls,cs_fmt_d16_xyz80/80 exercising 6%fmt_dec_dyncalls).GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.