Repository navigation
Conversation
KHR TLAS builds hardcoded arrayOfPointers = VK_FALSE and passed the guest's console-VA pointer list straight to Vulkan. Carry DescsLayout into the recorded build, validate each pointer, stage a copy with heap_base added into a device-addressable buffer, and use it as the build input. The guest input is not modified and GPU-written pointer lists are refused. Adds ARRAY and ARRAY_OF_POINTERS RayQuery coverage plus a null-entry refusal check.
Kam471
left a comment
There was a problem hiding this comment.
Tested cc4b3744 on Windows 11, RTX 5070 Ti (621.24).
- KHR path (
LEONIDA_RT_AS=khr):d3d12_indirect_rt_test.exe-> exit 0, all cases PASS: ExecuteIndirect with suballocated argument/count buffers, BLAS + TLAS (ARRAY and ARRAY_OF_POINTERS) + RayQueryKHR (hit=1, miss=0), and ARRAY_OF_POINTERS null entry refused before submission;0 validation errors. - Default XDXR path: same three PASS, 0 validation errors.
ctest -R d3d12_indirect_rt-> 1/1 passed, 0.24 s.
The ExecuteCommandLists failed: invalid copy or resolve line is the expected negative-path log; it appears before the passing cases and does not affect the verdict. The pointer-list validation and the staged address copy are exercised on real hardware. No game files; no blocker.
|
Review note about allocation cost. An AI tool helped me to read the diff. I did not measure the cost. I found no defect in the logic. Possible cost
Many titles build the TLAS again in each frame. Then each frame makes one new device memory allocation for each such TLAS. The lifetime is correct. The queue releases the stage when it uses the slot again. Thus the number of stages has a limit. Suggestions
Test Build the same TLAS in a loop of N frames. Count the |
Flyander
left a comment
There was a problem hiding this comment.
The KHR path needs to distinguish CPU-authored descriptor data from GPU-produced inputs before staging it on the CPU.
| BufferVaIndex<ResourceId>::Hit hit{}; | ||
| if (!buffer_vas_.find(va, hit)) return false; | ||
| const ResourceBinding* b = resolve(hit.id); | ||
| if (!b || !b->host) return false; |
There was a problem hiding this comment.
[P2] Do not stage InstanceDescs by reading a CPU mirror when the list can be GPU-generated. D3D12 explicitly permits instance descriptions to be generated directly in GPU memory by compute shaders (https://learn.microsoft.com/en-us/windows/desktop/api/d3d12/ns-d3d12-d3d12_raytracing_instance_desc). This host_at mapping is also attached to arena/default-heap resources, and stage_khr_instances reads the list and pointed-to descriptors during CPU preparation, before this submission executes. If an earlier dispatch/copy in the same command list writes them, this sees stale pre-submit bytes and can reject the build or stage the wrong instances. Restrict this path to explicitly CPU-authored inputs and return unsupported for GPU-produced lists, or translate the pointer list on-GPU while preserving command ordering; add a dispatch-produced-list regression case.
There was a problem hiding this comment.
Addressed in 77f00b6. host_at now distinguishes CPU-written from GPU-writable memory; non-CPU-writable instance lists return unsupported before submission. Added a GPU-copy-produced placed-DEFAULT regression with a negative control; per-frame builds reuse completed stages. RTX 3090/621.24: KHR and default XDXR full CTest 153 passed, 0 failed each, 0 validation errors.
AI-assisted (OpenCode)
|
Code read at cc4b374 (not built: the machine is macOS). The new
Failure scenario: a title keeps its pointer list in a buffer placed in a DEFAULT heap, which is the usual console layout. It fills the list on the GPU, with
All the new tests use committed resources, so this path isn't reached. Two possible fixes:
Either way, a test with a placed-DEFAULT list would cover this path. No game files. AI-assisted (Claude Code). |
|
Tested cc4b374 on NVIDIA GeForce RTX 5070, driver 621.14, Windows 11, MSVC (VS 2022 17.14),
Small note: the null-entry refusal logs I had a second PR on D3D-425 (#4105); closing it in favour of this one, which claimed it first and doesn't depend on #3944. AI-assisted (Claude). |
Only CPU-writable heaps expose a host pointer to replay, so DEFAULT and READBACK pointer lists are refused as unsupported instead of being read from possibly stale mapped bytes. Reuse completed staging buffers and write translated addresses directly. Adds a GPU-copy-produced placed-DEFAULT regression with a negative control. AI-assisted (OpenCode)
|
Review fixes are in 77f00b6. GPU-written instance lists are now refused as RTX 3090/621.24: KHR and default XDXR full CTest 153 passed, 0 failed each, 0 validation errors. One unrelated AI-assisted (OpenCode) |
|
Re-read at 77f00b6 (code read, not built). This resolves my placed-DEFAULT note. No game files. AI-assisted (Claude Code). |
|
Ready for re-review at 77f00b6. paratustra confirmed their placed-DEFAULT concern is resolved. RTX 3090/621.24: KHR and default XDXR full CTest 153 passed, 0 failed each, 0 validation errors; the negative control fails when the gate is removed. AI-assisted (OpenCode) |
|
Tested the new head
I ran #4301 ( |
Fixes D3D-425 on the opt-in
LEONIDA_RT_AS=khrpath. TLAS builds withD3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERSwere sent to Vulkan witharrayOfPointers = VK_FALSEand the guest's console-VA list, so pointer bytes were read as instance descs. The layout is now recorded, each pointer is validated, and a translated device-address copy is staged for the build without modifying guest input. GPU-written pointer lists are refused.Tests: full CTest 153 passed, 9 skipped, 1 disabled in both KHR and default XDXR modes (Windows/MSVC, RTX 3090).
d3d12_indirect_rtpasses with Core + Sync validation, 0 validation errors. Negative controls: reverting only the emit change fails the ARRAY_OF_POINTERS RayQuery case; a null pointer entry is refused before submission. No game files.AI-assisted (OpenCode)