Repository navigation
Ray tracing: the first real core_bvh4 BLAS on a GPU (the descriptor base is the 256-byte-unit field) - #3794
Ray tracing: the first real core_bvh4 BLAS on a GPU (the descriptor base is the 256-byte-unit field)#3794SuarezPM wants to merge 9 commits into
Conversation
The harness could only read the 0x280-byte synthetic bvh scene it builds itself. VKC_HEAP_FILE=<path>[@<offset>] copies a file into the heap, so a translated corpus shader can read a BVH, its descriptor blocks and the records from the user's work folder. Used to dispatch one of the game's RT compute shaders over a real GPU-built BLAS; the file is read at run time and never committed, so no game data enters the repository.
The game's RT shaders build the BVH descriptor base as (ptr & ~0xFF) | 0x30: a byte address with flags in the low bits, not the 256-byte-unit field the emulation assumed (base40 << 8). Masking the low byte fixes the address; a non-zero base moved every node by 256x the flags. The semantic test now runs the masked-base case (dword0 0x1030 -> base 0x1000, node at 0x1040) and fails under the old shift. Measured with the first real core_bvh4 BLAS (docs/bvh.md 7b): header at VA 0, root 0x4CABC; the game RT shadow CS returns the CPU walker's children in the same order on the RTX 2060.
strtoull(..., 0) accepted a leading zero as octal (@0256 loaded at 0xae), and a sign or spaces. Parse decimal or 0x hex explicitly, cap the offset at 4 GiB, and document the two overlaps: bvh mode writes its synthetic scene after the copy, so 0x100..0x264 is overwritten there, and the output V# starts at heap offset 0. Reported by @wildheathen.
|
Code read of
Ran on Windows 11 with pytest 9.2: the file above. The AI-assisted code read (Claude). |
|
Good catch, and you are right: the GPU run is at base 0, so the nonzero case currently rests on the shader's |
|
RTX 5070, driver 616.56, head 2c51fb2 versus parent 0c1cb46 with the #3533 harness: a hand-written traversal of one geometry-matched 1.0.2.1 BLAS root matched the CPU walk on 4/4 output words both at byte address zero and relocated to 0x1000. The parent matched 3/4 at each address. Both revisions passed spirv-val and all seven triangle semantic tests passed on head. The relocated control exercises preservation of the nonzero address above the low flags. Coverage is one root and a synthetic instruction; full retail shader execution remains open. AI-assisted. |
The nonzero-base measurement falsifies the earlier mask. The game passes ptr >> 8 in the descriptor's dword0 (0x10 for a structure at VA 0x1000), and the |0x30 its shader ORs is only the temporary root-load address. The original << 8 is correct at base 0 and at 0x1000; the GPU returns the CPU walker's children at both. This commit restores the translator and the test fixture to main and keeps the measured result in docs/bvh.md 7b and the Ray tracing row.
Resolve the VKC_HEAP_INIT/VKC_HEAP_FILE overlap by keeping both: INIT seeds VA 0 (main), FILE loads at an offset and grows the buffer (this branch).
git add -A picked up .xwin-cache (643 local SDK files). They are a build artifact, never part of the PR; the tree returns to the four intended files. The path is now in .git/info/exclude.
git add -A also staged .ignore, .slim/ and the codemap.md files; they are local agent artifacts, not part of the PR.
|
Measured, and it changes the conclusion: the nonzero base falsifies the mask. The same real BLAS at VA 0x1000 (dword0
So the game's dword0 is |
|
Tested As it stands (
Re-applied on current
What this does not cover: both cards report ray-tracing support, but our skip list is the wave64 one, and the Machine: Linux Mint 22 (Ubuntu 24.04 base), NVIDIA driver 615.71.09, Vulkan 1.4.351, |
|
Thanks. One distinction decides this: which value does your traversal put in descriptor dword0?
So both results are consistent: they are different descriptors. The game shader is the deciding evidence for the game's convention, and it says the 256-byte-unit field. Can you confirm the exact dword0 your test writes? If it is 0x1030, I will cite it in the PR as the synthetic control (and note that the game does not build that value). Also, which of the 4 words differs with the shift at the parent? If it is the tie order, it may be the same float32 tie we see elsewhere. AI-assisted. |
|
Thanks for the two-card run and the merge-on-main numbers; 0 failures at 184/199 is exactly the assurance this needed. The AI-assisted. |
|
Tested
AI-assisted (Claude). No game files. |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Thanks, this is a useful independent pass: the semantic file, the Your note is correct and expected: #3794 is stacked on #3533 (the AI-assisted. |
|
Tested on Windows 11 with two GPUs on one machine (head merged with main aa2988c, MSVC 14.51, Python 3.13.1):
The other vk_* programs came from a runtime built from main f847748. |
|
Tested dbfbb38 on RTX 5090, 621.24, Windows 11: pass.
|
|
Built the rest of it and ran the whole xdxr set on the RTX 5090 (621.24, Windows 11, MSVC 19.44, Ninja), 7bf1db9: So the BLAS half runs here too: the 256-byte-u descriptor base and the BVH4 records are read back as the check expects. With the earlier shader run (195/210, 0 failed), both halves of this PR are now verified on this GPU. |
|
Thanks — both results are useful, and your negative-control note is exactly right. There is no translator delta in this branch: the masked-byte variant ( On The Intel UHD 770 pass is worth having: it shows the AI-assisted. |
|
Thanks — that is the most complete pass this PR has had: both halves, same machine.
To keep the scope exact: those AI-assisted. |
|
The descriptor-base semantics this PR documents, measured on the native instruction rather than through the emulation. The GPU runs in the thread all execute the translator's Setup. Hand-built nodes, no game data. P is the oracle's 256-aligned output buffer.
So on hardware, node address = base × 256 + (node & ~7) × 8, in both forms. That is the
The same layout translated at Limits:
One wording point for the Ray tracing row. Its existing sentence "A GPU can't confirm the rule either, because every GPU runs this emulation and none runs the native instruction" is about the triangle rule, and it isn't quite right anymore. Windows 11, Vulkan SDK 1.4.363. The probe scripts are local. AI-assisted (Claude Code). |
@TheMrBeez ran image_bvh_intersect_ray and image_bvh64_intersect_ray through tools/hw_oracle on gfx1036 over hand-built box32 nodes: dword0 (P >> 8) + 0x10 with node 0|5 and (P >> 8) + 0x08 with node 0x800>>3|5 both traverse the node at P + 0x1000, so address = base * 256 + (node & ~7) * 8 and the base and the node offset add; the control reads the decoy. Recorded in bvh.md 7b. The Ray tracing row drops the "a GPU can't confirm the rule" sentence: it was about the triangle rule, and hw_oracle can run the native instruction, so that measurement is a follow-up rather than an impossibility. Docs only; test_docs_links, test_docs_repo_paths, test_docs_design_rows, test_docs_table_rows and test_docs_list_items pass.
|
@TheMrBeez — this is the measurement the row was missing, and the wording correction is right. Thanks for running the native instruction instead of the emulation. What I take from the run: on hardware, address = base × 256 + (node & ~7) × 8, in both I changed the Ray tracing row: the sentence now says the triangle rule has not been measured on the native instruction yet, that The translated-layout runs at Push |
|
Tested 7bf1db9 on an RX 9070 (RDNA4), AMD 26.11.1, Windows 11 (26300), VS 2022 Build Tools, RelWithDebInfo with SDL3: pass for this PR's changes
The full The new head dbfbb38 only adds to AI-assisted |
|
Request changes - the diff does not match the title, and it duplicates another PR.
What does check out: 7/7 semantic tests, 6/6 docs links, AI-assisted review, no game files, no GPU. |
|
@tupacfan04 — thanks for the review, including the parts that check out. One correction first, then the two points that are fair. Title. The title you quote is the pre-measurement one. It was renamed at 22:00Z, before this review, after the base-0x1000 run falsified the masking: the current title is "Ray tracing: the first real core_bvh4 BLAS on a GPU (the descriptor base is the 256-byte-unit field)". The PR intentionally has no translator change — Duplication. You are right that Coverage. Correct, and not claimed. The three added lines are a docstring, not a new fixture: the The game-derived counts cannot be checked from outside, as you note; that is why the body separates them from the reproducible parts. Thanks for the masked-base control (17 errors) — that is the control that settled the question. AI-assisted. |
|
@lunisahdidouch — thanks for the RDNA4 pass; it is the first one this PR has, and it matters because the descriptor decoding is the thing under test. Your read of the semantic failures matches ours: none of them touch this PR's files, and the branch only changes docs,
Thanks for running the whole suite instead of only the fixture. AI-assisted. |
…ks on inner back edges The summary now says, per category, how many sites have a some-paths read before the next call in program order and how many have them all after a later call. strip() also drops the saved-mask SGPRs, so a mask saved in one pass of an inner loop cannot place a read in the next. The docs quote the split instead of guessing causes, name the integer mnemonics, and no longer mention word 0 (the base field belongs to ItsNotRexed#3794). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claimed in the coordination issue as: RT-212.
Depends on: #3533(theVKC_HEAP_FILEharness this was measured with).What and why
The first controller-free traversal of a real GTA VI acceleration structure on a PC GPU, and the measurement that pins its descriptor-base semantics:
core_bvh4.rpfindexes to 271,637 BVH4 streams / 1,896,784,254 nodes (121.4 GB inflated) in 1,034 s (bvh_index.py).0x12060, 39,257 nodes) matches one drawable among the 258,037 models exported fromlevels.rpf: 12 geometries, 21,814 leaves.bvh_match.py's four checks pass: 0 leaves outside, 335/0 overrides, area ratio 1.000.bvh_rehydrate.pywrites the 2,512,512-byte structure; its runtime root is the first node of the last level-table entry (the header keeps the dehydrated root), and its leaves are in the leaf frame (headersceneBounds±2.5, leaf vertices ≈19,040).ptr >> 8in the descriptor's dword0 — the base in 256-byte units. The| 0x30its shader ORs is only the temporary address it uses for therootNodePtrload, not the descriptor base. At base 0 and at base 0x1000 (structure copied to VA 0x1000, dword00x10) the emulation's existing<< 8reads the right nodes. A masked-byte variant (base40 & ~0xFF) reads base 0 in the second case and misses; it was falsified and reverted. No translator change is needed.The GPU evidence
The game's RT shadow CS (
deferred_tiledfamily, 32-bitimage_bvh_intersect_ray, the smallest buffer-only one) over the rehydrated real BLAS, RTX 2060 SUPER, driver 620.73.04, Vulkan 1.4.357. First dynamic call, lane 0:intersect_node)00x3000x4CABC[0x4CAA4, 0x4CA9C, FFFFFFFF, FFFFFFFF]0x10000x100x10000x4CABC[0x4CAA4, 0x4CA9C, FFFFFFFF, FFFFFFFF]Origin/direction/tmax are the leaf-0 ray (centroid + normal·0.5,
tmax 2.0); the CPU walker reachest=0.5, leaf 8240, geometry 0, primitive 0. The shader's second traversal site remains engine-gated (the executable's call sites), so the full output staysFLT_MAX; that limit is documented in the RT-212 findings.Tested
python3 -I -m unittest discover -s tests/semantic -p 'test_image_bvh_tri.py'— 7 tests OK. The fixture's dword0 is0x10(base0x1000in 256-byte units); the masked variant makes it fail, the<< 8passes, and the docstring now records the GPU measurement.python3 -I tests/test_docs_links.py— OK.maingainedVKC_HEAP_INIT(fixed VA 0) while this was in review; #3533 keeps both loaders. The two runs above usedVKC_HEAP_FILEat VA 0 and VA 0x1000.@kacper-serewis (RTX 5070, driver 616.56): a hand-written traversal with a synthetic dword0
0x1030(byte base + flags, the shader's temp) matches the CPU 4/4 with the mask and 3/4 with the shift; that descriptor is not the game's. The game shader passesptr >> 8(0x10), where the shift matches. The two results are consistent; the game's construction is the deciding evidence.@chpeu (RTX 3080 and RTX 5080, Linux, driver 615.71.09): re-applied on
mainf847748c, GPU suite 184/199, 15 skipped, 0 failed on both cards; the branch's 174/189 is the older fixture set. Thecore_bvh4probe is a separate manual run, not inrun_gpu_tests.py.@requiemsnkrp (RTX 3060, Windows 11, MSVC 19.51): semantic 7/7;
cs_bvh/cs_bvh32throughVKC_HEAP_FILEat0x1000and at@4096, 0 mismatches;@-5and a missing file exit 2 with the message; full ctest 148/148.@crastinator (RX 6700 XT, RADV Mesa 26.3.1): GPU suite 185/199, ctest 41/41, semantic 7 passed (13 subtests).
@kapitche (RTX 4080 SUPER and Intel UHD 770, Windows 11): semantic passes;
--filter bvh2/2 on both GPUs; full suite 164/210 and 146/210, no failures attributable to this PR. No negative control is possible because the translator has no delta: the mask was falsified and reverted.@dcastell1 (RTX 5090, driver 621.24, Windows 11): shader suite 195/210, 0 failed;
xdxr_build,xdxr_build_check,d3d12_xdxr_rt,d3d12_xdxr_rt_check5/5 passed.@TheMrBeez (gfx1036, Ryzen 9 9950X3D iGPU, driver 32.0.21030.2001): ran the native
image_bvh_intersect_rayandimage_bvh64_intersect_raythroughtools/hw_oracleover hand-built box32 nodes, wave32 and wave64. dword0(P >> 8) + 0x10with node0|5, and(P >> 8) + 0x08with node0x800>>3|5, both traverse the node atP + 0x1000; the control reads the decoy. So address = base x 256 + (node & ~7) x 8, and the base and the node offset add. The same layout translated at7bf1db92gives the same 32 words on the RTX 5080 and on gfx1036 through Vulkan,spirv-valclean. Limits: descriptor bits 39:32, non-box32 nodes and a0x1030-style dword0 were not exercised.@lunisahdidouch (RX 9070, RDNA4, driver 26.11.1, Windows 11): semantic 7/7; GPU suite 196/210, 14 skipped, 0 failed, with
cs_bvh/cs_bvh32passing; full ctest 153/154, the one failure beingvk_pipeline_check_cli's first-launch timeout (3/3 on rerun, seen on main). The 7 failures/2 errors in the full semantic suite reproduce on the main this branch merged, not here.Limits
The rehydrated structure is the offline form; the pipeline patches its runtime root and builds rays in the leaf frame. The shader's second site needs the executable. AI-assisted.
Checklist
docs/design.mdnow carries the measured base semantics (base 0 and 0x1000) and how it was confirmed.