mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-19 04:58:08 +02:00
Thanks to Konstantin for pointing out that we really don't need atomics here. We can use the IR offset to get the slot and keep stuffing the instance address in it. Header already writes the instance count for us. Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40734> |
||
|---|---|---|
| .. | ||
| anv_build_helpers.h | ||
| anv_build_interface.h | ||
| anv_bvh.h | ||
| copy.comp | ||
| encode.comp | ||
| header.comp | ||
| interpret.py | ||
| meson.build | ||
| README.md | ||
| visualize_json.html | ||
BVH Debug
INTEL_DEBUG=bvh_tlas,bvh_blaswill generatetlas_{id}.txtorblas_{id}.txtinbvh_dump/BVH_ANVdirectory.INTEL_DEBUG=bvh_tlas_ir_hdr,bvh_blas_ir_hdrwill generatetlas_{id}.txtorblas_{id}.txtinbvh_dump/BVH_IR_HDRdirectory.INTEL_DEBUG=bvh_tlas_ir_as,bvh_blas_ir_aswill generatetlas_{id}.txtorblas_{id}.txtinbvh_dump/BVH_IR_ASdirectory.INTEL_DEBUG=bvh_no_buildwill skip the intel-specific-encoding part. This will make the bvh NULL and the HW traversal will see this as a miss.
The dumped text file contains memory dump, byte-by-byte in hex. The contents are contiguous memory of a certain region.
- The dump in
BVH_ANVstarts from the beginning ofanv_accel_struct_headerto the end of the bvh. - The dump in
BVH_IR_HDRrecordsvk_ir_header, which sits at the beginning of ir bvh. - The dump in
BVH_IR_ASrecords allvk_ir_{leaf_type}_nodeandvk_ir_box_nodein ir bvh. The region starts from where leaves are encoded to the end of ir bvh.
Decode the dump
We have a way to decode the dump in BVH_ANV.
- To decode this memory dump, use a python script to parse the file and generate a human-readable json.
- To further visualize the tree, there is a html that parses the json and draws the tree topology and 3D views of bounding boxes.
# Using blas_0 as an example
xxd -r -p bvh_dump/BVH_ANV/blas_0.txt > input.bin
# Use a python script to generate a human-readable json file
cd mesa/src/intel/vulkan/bvh/
python3 interpret.py <path/to/input.bin>
# To further visualize the tree, the html parses the json and draws it in 3D.
cd mesa/src/intel/vulkan/bvh/
python3 -m http.server 8000
# go to localhost:8000/visualize_json.html
Note and Limitations:
- The python script use
ctypesto interpret the memory dump, so the structure defined in the script should match the structure defined in the driver. - The memory dump is a snapshot of a VkBuffer captured at the end of
CmdBuildAccelerationStructurecall. It won't capture any bvh obtained fromCmdCopy. - CPU will wait for the the command buffer to be completed, and saves the recorded bvh into files on disk.