Repository navigation
borealis: report the M5 acceleration structure's buffer address - #1405
Conversation
vkGetAccelerationStructureDeviceAddressKHR returned the M5 image address,
the buffer address rounded up to 1 KiB. vkd3d-proton creates every D3D12
structure as a GENERIC view at a 256-byte aligned buffer address and uses
that address directly: TLAS instances name BLAS by it. It logs the
mismatch ("buffer_address = 0x5a57ace700, rtas_address = 0x5a57ace800"),
and the TLAS build then read each BLAS header 256 to 768 bytes before the
image. In GTA V Enhanced most structures sit at such addresses; the
traversal hit garbage instance records, which ended in a firmware compute
fault and a lost device within seconds.
Report the buffer address, like the other drivers do, and round an
address up to the image wherever one is read: instance references in the
TLAS leaf build (a VK_BVH_AS_ADDRESS hook in the common leaf code, the
identity for every other driver) and the structure a ray query starts
from. Descriptors already store the rounded address.
Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: MERGE at e70c5c45
Blockers:
- None.
Checked:
src/asahi/vulkan/hk_m5_acceleration_structure.c:hk_m5_backend_GetAccelerationStructureDeviceAddressKHR()now returns the raw buffer addressvk_acceleration_structure_get_va(as)rather than rounding up to 1 KiB, matching spec expectations and vkd3d-proton D3D12 256-byte-aligned addresses.src/vulkan/runtime/bvh/leaf.h+src/asahi/vulkan/bvh/agx3_batch_build_leaf.comp: introducesVK_BVH_AS_ADDRESS(reference)(identity default for other drivers,(((reference) + 1023ul) & ~1023ul)inagx3_batch_build_leaf.comp) and applies it consistently acrossbase_ptr,BVH_BOUNDS_OFFSET,CALCULATE_FINE_INSTANCE_NODE_BOUNDS, andROOT_FLAGS_OFFSET.- Verified all M5 leaf-build paths (both initial builds and
hk_update_as()->vk_cmd_build_as_leaves()) dispatch throughdevice->as_build_ops->build_leaves(hk_build_leaves_batched()->agx3_batch_build_leaf.comp) and disablefused_leaf_morton, and verified descriptor paths (write_accel_struct_descandvkGetDescriptorEXTinhk_descriptor_set.c) already round to 1 KiB ondev->m5_native_as. src/asahi/vulkan/hk_nir_lower_m5_ray_queries.c:lower_rq_initialize()roundsinstr->src[1].ssaup to 1 KiB ((addr + 1023) & ~1023), which preserves0 -> 0, is idempotent on already-aligned descriptor addresses, and handles raw addresses fromOpConvertUToAccelerationStructureKHR.- Exact-head hardware verification on J714s (M5 Pro, G17S): CTS 1.4.7.1
ray_query7,249pass /0fail,rqbatchraw 256-byte-aligned BLAS addresses0 -> 27,922hits (0mismatches), and GTA V Enhanced benchmark completes (21.19 FPS,0GPU faults).
Evidence
- Cross-checked against live
aurora-wipsrc/asahi/vulkan/hk_descriptor_set.c:92-107,1742-1748andsrc/vulkan/runtime/vk_acceleration_structure.c:638-774. MERGEABLEagainstaurora-wip(disjoint from#1404inhk_m5_acceleration_structure.c).
|
@DjDeveloperr, code-owner heads-up: App approval at |
|
Merge-train landing at
Revert: |
|
MacBook Neo (J700, A18 Pro, G17P B1), stock Fedora 44 kernel The compute ray-query readback passed on both builds. A four-triangle GPU-built BLAS had identical storage and scratch sizes, a 64-byte header offset, a 696-byte native image length, the expected bounds and matching relative offsets. With Zero GPU faults, kernel WARNs or AVCs. The same stock boot, four SLC planes, both CPU policies and zero failed units were verified at handback. |
|
Post-merge review of Deserialize keeps the raw handle. Rounding once, before both uses, fixes it (zero stays zero): uint64_t blas = src[AGX3_AS_SERIAL_WORDS + i];
blas = (blas + 1023ul) & ~1023ul;Row for the fix: serialize a TLAS, patch its handles with Everything else checks out:
|
What: Return the acceleration structure's buffer address from
vkGetAccelerationStructureDeviceAddressKHRon M5, and round an address up to the 1 KiB image wherever the native image is read from one. The driver returned the buffer address rounded up to 1 KiB. vkd3d-proton places D3D12 structures at 256-byte aligned addresses and writes those addresses into TLAS instances, so the TLAS build read each BLAS header 256 to 768 bytes before its image. In GTA V Enhanced most BLAS sit at such addresses.Tested: J714s (M5 Pro, G17S), stock 7.3.0-m5-pr67, built natively on the M5 from this head's tree: CTS 1.4.7.1
ray_query.acceleration_structures(traditional, GPU-built) plusray_query.{misc,builtin,watertightness,advanced}(first 630), 11667 cases: 7249 pass, 0 fail, 4418 not supported. With nine BLAS at 256-byte aligned buffer addresses and TLAS instances holding those addresses (as vkd3d-proton writes them), rays hit 27922 of 27922 expected; on aurora-wip they hit nothing.Risk: two-way · M5 family only (M5 native acceleration-structure format: G17G, G17S, G17C). The common leaf code gains a
VK_BVH_AS_ADDRESShook that is the identity unless a driver defines it.Not yet: a base M5 (G17G) row.
Details
vkGetAccelerationStructureDeviceAddressKHRreturnsvk_acceleration_structure_get_va(), as every other driver does. ForvkCreateAccelerationStructure2KHRthe spec requires exactly that, and vkd3d-proton checks it (buffer_address = 0x5a57ace700, rtas_address = 0x5a57ace800before this change).agx3_batch_build_leaf.comp, through the new hook inleaf.h) rounds each instance reference up to the image before it reads the BLAS bounds and stores the instance's BLAS pointer, so the instance encoder and the traversal see the image address.OpConvertUToAccelerationStructureKHR) is the device address.Evidence
Instance-reference test (
rqbatch, default software traversal, nine BLAS of 108 to 7151 triangles packed in one buffer at 1 KiB + 768, full rebuilds, 262144 rays per round, compared with references fromvkGetAccelerationStructureDeviceAddressKHR):a532ab05e5bbGTA V Enhanced (built-in benchmark, 2560x1440, Very High ray tracing, FSR) on a private M5 ray-tracing trial build (#337 rebased, not published): vkd3d-proton logged
buffer_address != rtas_address731 times, and 1113 of 1529 acceleration-structure builds were at 256, 512 or 768 bytes past a 1 KiB boundary. With only the refit scratch fix (#1404) the run lost the device after about 3 s of ray tracing (firmware compute fault). With both changes the benchmark completes: 21.19 FPS, 0 GPU faults, 0 s at the 338 MHz clamp.