Skip to content

perf(shader): validate BDA anchors on current main and RADV - #67

Draft
JJenkx wants to merge 5 commits into
mainfrom
validation/bda-anchors-ab9
Draft

JJenkx wants to merge 5 commits into
mainfrom
validation/bda-anchors-ab9

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

What

Fork validation of upstream #5859, retaining Gjon Gojcevic's two original commits, on current main 760ffa6838d08c13782a0dcc7e9f17319c27b049. This branch looks up a shared guest-memory base at shader entry and retains the original per-read fallback. It includes the follow-up that bounds anchors at overlapping range starts and checks address/span overflow.

Three local follow-ups:

  • Add the requested APS5_NO_BDA_ANCHORS opt-out, documented in USAGE. Generated shader-cache keys include it, so each mode requires its own warm-up. Separate codegen and GPU-readback cases require the old path when disabled, while the original default-mode assertions remain enabled.
  • Avoid creating a 64-bit SPIR-V type when there are no anchors. The initial integration failed 11 selected checks with “Using a 64-bit integer type requires the Int64 capability.” Anchor emission now creates its type only inside the anchor loop; a memory-free shader regression also checks that no 64-bit type appears.
  • Keep the two byte loads of an anchored halfword volatile on the observed RADV path. The existing exactness test failed on RX 6650 XT; a smaller uniform-lane probe read 0x80a0 instead of 0xa1a0 from bytes 0xa0, 0xa1, with no fault in either implementation. Both synthetic modules pass spirv-val. Adding the volatile operand made the full exactness fixture pass; single-byte reads retain their original mask. The regression covers uniform lanes and mixed direct/fallback lanes, and the full original boundary/fault comparisons remain. The underlying driver transformation has not been isolated; the restriction is recorded as technical debt.

Current-main rebase validation

Rebased as five linear commits on 760ffa6838d08c13782a0dcc7e9f17319c27b049, published head f25fd4aa1bff111bccb9bcfda06dc70cd4ad9125. The only conflict was in ShaderMemory's command-line test selection: retain both main's --quad-mask-no-demote case and this branch's --bda-anchors-disabled case, with their separate returns. Range-diff retains all five patches; only that insertion context changed.

Full guest libraries and selected executables rebuilt on native integration 6a2ab46ab5527461570c679ed2d5c573eb93a021, whose only tree difference from the published head is the same private SPIRV-Tools validator-table teardown repair. Sixteen selected CTests pass with zero CTest skips on RX 6650 XT / RADV (9.60 s) and lavapipe (9.64 s). They cover both conflicted CLI cases, BDA exactness/readback enabled and disabled, shader memory/disk cache, graphics, draw reuse, and prepared shader/graphics policies. The CPU-device limitation for BdaDevice's hardware-only section still applies. Conventions and whitespace checks pass. The independent public vendor build, Windows and full suite remain unverified.

All native scene checks and ABBA performance results below belong to the earlier ab9 integration. They have not been rerun on this new head and establish no repeatable FPS gain.

Earlier ab9 validation

Before the current-main rebase, published source head 9e4e9bad981186ce53d508ebb57c997eeb4a27b6 has five linear commits on the stated main. Linux Release validation uses native integration 6d8762ce7ce477c0d21a6bb30df5e679e588e95a, whose only tree difference is the separately documented local SPIRV-Tools constant-validator-table shutdown repair; that private gitlink is not published here. Full guest libraries and all selected test executables rebuilt with renderer SPIRV-Tools enabled.

Selected CTests Passed CTest skips Time
RX 6650 XT / RADV Mesa 26.2.4 19 0 10.98 s
lavapipe / Mesa 26.2.4 19 0 18.50 s

Coverage includes BDA device exactness and contracts; real wave32/wave64 anchored and disabled readback; enabled/disabled codegen; shader-memory and disk-cache checks; prepared graphics/shaders; draw-cache reuse with off/verification modes; and the four audio-shutdown cases. On CPU Vulkan, BdaDevice explicitly omits its hardware-only read/multi-dword execution section; the Radeon run executes it. These are selected tests, not a full-suite result.

Negative controls: running each disabled-mode codegen/readback test without APS5_NO_BDA_ANCHORS fails at its expected path-selection assertion. Initial uncorrected integration failures and the nonvolatile halfword mismatch are retained in the local validation evidence. Conventions, whitespace and test-executable registration pass (880 executable targets, none unregistered).

The synthetic halfword probe's raw modules are 2994 words without anchors and 3975 with anchors; these are test modules before optimization, not title module-size or compile-time measurements. Full gameplay correctness, cold pipeline-compile cost, repeatable title performance, Windows and hosted full CI remain pending; the initial native scene check is recorded below. No title FPS or loading improvement is established. The baseline for the Astro comparison is main ab9a476840 plus the same validator-table repair, measured with only APS5_TRACE_SECONDS=300:60 and common runtime settings; baseline and candidate used separate valid caches.

Checklist

Draft while matched performance and remaining validation are pending.

Initial native scene check

Astro PPSA21564, -lvl hub_crashsite, on the recorded native integration reached rendered Astro in Crash Site. A target-window capture after the window was restored confirms the scene; it does not establish complete gameplay compatibility. Normal window close was requested at 660.69 s; the process finished with exit 0 at 669.56 s and restored the temporary kernel setting.

This warm-up is excluded from loading and FPS comparisons: the game was minimized during startup and its window size changed before capture. The helper did not request activation or restoration. The warmed cache is retained for a separate 300:60 capture using the baseline's 3072x1728 native window and the same source/settings, with no profiling flags. No title performance gain is claimed.

Completed exploratory ABBA comparison

Astro PPSA21564, idle Crash Site, main ab9a476840 plus the common validator-table repair versus the same tree plus this PR. Ryzen 7950X, RX 6650 XT / RADV Mesa 26.2.4, Linux 7.2.9; native window 3072x1728 (trace resolution metadata 3840x2160), pipeline 1, draw cache 4096, host import 16384 MiB, warmed separate source-compatible caches. Only APS5_TRACE_SECONDS=300:60; no profiling, verification or frame-dump switches and no output redirection.

Run order FPS p50 ms p90 ms GPU ms/present
Main A1 3.386 286.295 343.713 178.965
Candidate B1 3.520 280.001 303.229 171.550
Candidate B2 3.308 291.445 346.177 178.585
Main A2 3.116 304.343 371.966 183.397

No repeatable code-only FPS gain is established. The first pair's approximately 4% difference is insufficient evidence: both configurations varied between runs, desktop activity and focus were uncontrolled, and idle-animation phases differed. No helper activation or game input was sent. All four processes closed normally with exit 0 and restored the temporary kernel setting. Keep this PR draft; cold pipeline cost and representative title performance remain open.

Before/after captures show the expected idle position/camera. Candidate B2's captures were pixel-identical, so their freshness is uncertain. A separate diagnostic showed changing direct GPU frames and changing target-window captures; a persistent capture failure was not reproduced, and the diagnostic was excluded from timing results. Detailed root CPU events overflowed after roughly six seconds; frame/GPU aggregate counters cover the measured minute, but detailed traces are incomplete.

Exact summary lines, in run order:

{"commit": "2c2acf664c82", "dirty": false, "env": {"APS5_DRAW_CACHE_ENTRIES": "4096", "APS5_HOST_IMPORT_MIB": "16384", "APS5_PAD_INPUT_FILE": "<path>", "APS5_PIPELINED_DRAWS": "1", "APS5_TRACE_SECONDS": "300:60"}, "gpu": "AMD Radeon RX 6650 XT (RADV NAVI23)", "driver": "radv Mesa 26.2.4-arch1.1", "os": "Linux 7.2.9-arch1-1", "resolution": "3840x2160", "window": {"spec": "seconds 300:60", "first_present": 1754, "ms": 60252.762}, "presents": 204, "frame_ms": {"p50": 286.295, "p90": 343.713, "p99": 394.708, "max": 474.303}, "gpu_busy_ms_per_present": 178.965, "worker_busy_pct": {"queue worker 0x0": 99.47, "queue worker 0x40": 99.638, "queue worker 0x48": 98.042, "queue worker 0x46": 8.87}, "top_phases_ms_per_frame": {"Driver.Packet": 902.559, "Driver.Packet.memory_wait": 547.244, "Driver.Packet.draw": 205.818, "Driver.Draw": 205.058, "Driver.Draw.draw_and_resource_release": 110.075, "Graphics.Draw": 108.932, "Graphics.Draw.draw_and_resource_release": 92.608, "Driver.Packet.prepare_memory": 85.623}, "trace_dropped": true, "trace_dropped_threads": {"queue worker 0x0": {"events_full_after_s": 6.242, "events_lost": 2310842, "totals_full": false}}, "trace": "aps5-trace-2c2acf664c82-2725134.json.gz"}
{"commit": "6d8762ce7ce4", "dirty": false, "env": {"APS5_DRAW_CACHE_ENTRIES": "4096", "APS5_HOST_IMPORT_MIB": "16384", "APS5_PAD_INPUT_FILE": "<path>", "APS5_PIPELINED_DRAWS": "1", "APS5_TRACE_SECONDS": "300:60"}, "gpu": "AMD Radeon RX 6650 XT (RADV NAVI23)", "driver": "radv Mesa 26.2.4-arch1.1", "os": "Linux 7.2.9-arch1-1", "resolution": "3840x2160", "window": {"spec": "seconds 300:60", "first_present": 1711, "ms": 60224.427}, "presents": 212, "frame_ms": {"p50": 280.001, "p90": 303.229, "p99": 340.962, "max": 556.391}, "gpu_busy_ms_per_present": 171.55, "worker_busy_pct": {"queue worker 0x0": 99.457, "queue worker 0x40": 99.669, "queue worker 0x48": 98.209, "queue worker 0x46": 10.414}, "top_phases_ms_per_frame": {"Driver.Packet": 873.141, "Driver.Packet.memory_wait": 526.682, "Driver.Packet.draw": 197.832, "Driver.Draw": 197.111, "Driver.Draw.draw_and_resource_release": 100.259, "Graphics.Draw": 99.069, "Driver.Packet.prepare_memory": 83.949, "Graphics.Draw.draw_and_resource_release": 82.361}, "trace_dropped": true, "trace_dropped_threads": {"queue worker 0x0": {"events_full_after_s": 5.727, "events_lost": 2450144, "totals_full": false}}, "trace": "aps5-trace-6d8762ce7ce4-3758098.json.gz"}
{"commit": "6d8762ce7ce4", "dirty": false, "env": {"APS5_DRAW_CACHE_ENTRIES": "4096", "APS5_HOST_IMPORT_MIB": "16384", "APS5_PAD_INPUT_FILE": "<path>", "APS5_PIPELINED_DRAWS": "1", "APS5_TRACE_SECONDS": "300:60"}, "gpu": "AMD Radeon RX 6650 XT (RADV NAVI23)", "driver": "radv Mesa 26.2.4-arch1.1", "os": "Linux 7.2.9-arch1-1", "resolution": "3840x2160", "window": {"spec": "seconds 300:60", "first_present": 1759, "ms": 60156.048}, "presents": 199, "frame_ms": {"p50": 291.445, "p90": 346.177, "p99": 419.591, "max": 476.35}, "gpu_busy_ms_per_present": 178.585, "worker_busy_pct": {"queue worker 0x0": 99.473, "queue worker 0x48": 98.388, "queue worker 0x40": 99.578, "queue worker 0x46": 9.848}, "top_phases_ms_per_frame": {"Driver.Packet": 927.648, "Driver.Packet.memory_wait": 566.318, "Driver.Packet.draw": 213.909, "Driver.Draw": 213.125, "Driver.Draw.draw_and_resource_release": 115.357, "Graphics.Draw": 114.105, "Graphics.Draw.draw_and_resource_release": 96.8, "Driver.Packet.prepare_memory": 81.17}, "trace_dropped": true, "trace_dropped_threads": {"queue worker 0x0": {"events_full_after_s": 6.135, "events_lost": 2333863, "totals_full": false}}, "trace": "aps5-trace-6d8762ce7ce4-3956258.json.gz"}
{"commit": "2c2acf664c82", "dirty": false, "env": {"APS5_DRAW_CACHE_ENTRIES": "4096", "APS5_HOST_IMPORT_MIB": "16384", "APS5_PAD_INPUT_FILE": "<path>", "APS5_PIPELINED_DRAWS": "1", "APS5_TRACE_SECONDS": "300:60"}, "gpu": "AMD Radeon RX 6650 XT (RADV NAVI23)", "driver": "radv Mesa 26.2.4-arch1.1", "os": "Linux 7.2.9-arch1-1", "resolution": "3840x2160", "window": {"spec": "seconds 300:60", "first_present": 1718, "ms": 60013.998}, "presents": 187, "frame_ms": {"p50": 304.343, "p90": 371.966, "p99": 518.746, "max": 1452.741}, "gpu_busy_ms_per_present": 183.397, "worker_busy_pct": {"queue worker 0x0": 99.175, "queue worker 0x40": 99.154, "queue worker 0x48": 97.293, "queue worker 0x46": 8.433}, "top_phases_ms_per_frame": {"Driver.Packet": 974.584, "Driver.Packet.memory_wait": 598.937, "Driver.Packet.draw": 232.289, "Driver.Draw": 231.479, "Driver.Draw.draw_and_resource_release": 122.709, "Graphics.Draw": 121.481, "Graphics.Draw.draw_and_resource_release": 103.227, "Driver.Draw.shader_compile_and_link": 90.875}, "trace_dropped": true, "trace_dropped_threads": {"queue worker 0x0": {"events_full_after_s": 5.953, "events_lost": 2269083, "totals_full": false}}, "trace": "aps5-trace-2c2acf664c82-175935.json.gz"}

gjonn and others added 5 commits October 14, 2026 22:36
…ogram entry

Address-based reads whose 64-bit base is a pair of user-data registers
search the BDA table at every read, although the base is one value for
the whole draw. Where a program has two or more such reads of one base
(at most four bases, those with the most reads), the range holding the
base is now searched once at the program's entry, by the subgroup's
elected lane when the program already uses subgroup ballots. Each read
then takes one branch: when that range holds all of its bytes, and for
dword reads the device address is 4-aligned, it loads them directly;
otherwise it runs the lookup path as before, so data, faults, invocation
stops and wraparound are unchanged. Ranges ending above
0xffffffff00000000, whose base plus a 32-bit offset could wrap, and
ranges whose device addresses wrap are not used.

The direct path relies on the table being ascending and disjoint, which
the driver builds and now requires (BdaAbi::RangesOrdered).

AI-assisted: yes
The driver builds tables whose ranges ascend by begin but can overlap
(a per-build region read over the address space's ranges). A lookup
selects the last range beginning at or below an address, so the anchor's
range now ends at the next range's begin when that comes first, and the
driver requires only ascending begins (BdaAbi::RangesOrdered).

An anchor is also not used for a range longer than 2^62 bytes, whose
offset arithmetic could wrap with a positive immediate. Anchors are
counted per read site after adjacent loads are grouped and reads with
no used dwords are dropped, so a program does not search for one
effective read; read eligibility shares RoutesApertures.

Tests: the anchored test programs can replace the lookup path by a
sentinel, which shows which reads load directly; the anchor table has an
overlapping range; a recompiled compute program reads through an anchor
on the GPU.

AI-assisted: yes

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants