startup: descriptor copies from a shader-visible heap crash the NVIDIA driver #3558

Closed
opened 2026-11-30 06:08:25 +00:00 by Jess-Doit · 3 comments
Jess-Doit commented 2026-11-30 06:08:25 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-30T06:08:25Z.


Summary

On an NVIDIA GTX 1060, all four startup_resource_retire_views_*_hardware tests crash with an access violation inside the driver's CopyDescriptorsSimple. The same tests pass on WARP.

The crash happens on the first descriptor copy in case 2 of tests/startup_resource_retire_views.cpp, a guest copy from the shader-visible heap into a CPU-only staging heap. copy_descriptor_run in src/startup_stubs/d3d12_xs_device.cpp forwards it unchanged to the desktop device, so the source handle is in a shader-visible desktop heap.

Desktop D3D12 requires the source descriptors of CopyDescriptors/CopyDescriptorsSimple to be in a non-shader-visible heap, because shader-visible heaps may live in memory the CPU cannot read reliably. WARP tolerates the copy, but this driver faults on it. A console title can legally copy out of a visible heap, so this is a runtime gap and not only a test issue.

Evidence

  • Windows 10 19045, NVIDIA GTX 1060 6GB driver 32.0.15.6094, in-box WARP 10.0.19041. Clean dev build of main at 2ff74a6a.
  • Retire families on this card: 24 tests, 17 passed, 7 failed. Four are the views crashes, with the debug layer both off and on, including the keep and no-retire variants. All four pass on WARP.
  • A local instrumented build showed the last call before the fault is the desktop CopyDescriptorsSimple for one descriptor, with the source in the shader-visible heap and the destination in the CPU-only heap. The shim's own bookkeeping after it never ran.
  • The other three failures, retire_reasons_hardware and retire_title_hardware_debug0/1, are separate. They fail an expectation instead of crashing. The title cases are the heap2 retention result reported on #2468.
$env:XBOX2WINDOWS_ADAPTER = '1060'
ctest --preset dev --no-tests=error -j 1 -R '^startup_resource_retire_views_'

Possible fix

Keep a CPU-only desktop mirror for each shader-visible heap. Write every view, sampler and copy destination to both the mirror and the visible heap, and use the mirror as the source whenever a copy reads from a visible range. This also gives the capture and retire code a readable copy. I'm happy to prepare a PR if this direction is acceptable.

Ready for more review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6690077858 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3558). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-30T06:08:25Z. --- ## Summary On an NVIDIA GTX 1060, all four `startup_resource_retire_views_*_hardware` tests crash with an access violation inside the driver's `CopyDescriptorsSimple`. The same tests pass on WARP. The crash happens on the first descriptor copy in case 2 of `tests/startup_resource_retire_views.cpp`, a guest copy from the shader-visible heap into a CPU-only staging heap. `copy_descriptor_run` in `src/startup_stubs/d3d12_xs_device.cpp` forwards it unchanged to the desktop device, so the source handle is in a shader-visible desktop heap. Desktop D3D12 requires the source descriptors of `CopyDescriptors`/`CopyDescriptorsSimple` to be in a non-shader-visible heap, because shader-visible heaps may live in memory the CPU cannot read reliably. WARP tolerates the copy, but this driver faults on it. A console title can legally copy out of a visible heap, so this is a runtime gap and not only a test issue. ## Evidence - Windows 10 19045, NVIDIA GTX 1060 6GB driver 32.0.15.6094, in-box WARP 10.0.19041. Clean dev build of `main` at `2ff74a6a`. - Retire families on this card: 24 tests, 17 passed, 7 failed. Four are the views crashes, with the debug layer both off and on, including the keep and no-retire variants. All four pass on WARP. - A local instrumented build showed the last call before the fault is the desktop `CopyDescriptorsSimple` for one descriptor, with the source in the shader-visible heap and the destination in the CPU-only heap. The shim's own bookkeeping after it never ran. - The other three failures, `retire_reasons_hardware` and `retire_title_hardware_debug0/1`, are separate. They fail an expectation instead of crashing. The title cases are the heap2 retention result reported on #2468. ```powershell $env:XBOX2WINDOWS_ADAPTER = '1060' ctest --preset dev --no-tests=error -j 1 -R '^startup_resource_retire_views_' ``` ## Possible fix Keep a CPU-only desktop mirror for each shader-visible heap. Write every view, sampler and copy destination to both the mirror and the visible heap, and use the mirror as the source whenever a copy reads from a visible range. This also gives the capture and retire code a readable copy. I'm happy to prepare a PR if this direction is acceptable. Ready for more review
Jess-Doit commented 2026-11-30 06:28:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-30T06:28:39Z.


A note on fix options, after reading view_slot, copy_descriptor_run, note_copy and the heap creation path on main 44a3ad5a. Each option changes a different amount, so I'd like a direction before opening a PR.

  1. Redirect only the copy. In copy_descriptor_run, when a source run lies in a shader-visible desktop range, rebuild each source descriptor at the destination from its view record (slot, resource, description), the same way view_slot would. Visible-heap writes stay as they are, so this is the smallest change. It depends on the record's resource still being alive when the copy happens, which holds with retire on but needs a check with it off. It also cannot rebuild a descriptor that has no record.
  2. Dual write. Give each shader-visible view heap a CPU-only mirror, retained like the existing CPU tail. Write every title view and copy destination in a visible range to both heaps, and read copies from the mirror. The result is exact, but every create path in view_slot needs a second write, including refused and default views and the console sampler, and the heap uses twice the descriptor memory.
  3. CPU-only primary with a sync before execute. Point the title ranges at a CPU-only heap and copy dirty spans into the visible heap before ExecuteCommandLists. Copies become trivially valid. It is the largest change: shadow_slot, note_heap and the internal heap users assume the desktop CPU handle is the visible heap.

My preference is 2, because it matches desktop semantics exactly and keeps the shadow tracking keyed as it is today. Option 1 is the quickest if you'd rather start small. The fixture already exists: the four retire-views cases crash on the GTX 1060 and should pass with any of these options.

Ready for more review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7270689242 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3558#issuecomment-7270689242). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-30T06:28:39Z. --- A note on fix options, after reading `view_slot`, `copy_descriptor_run`, `note_copy` and the heap creation path on `main` `44a3ad5a`. Each option changes a different amount, so I'd like a direction before opening a PR. 1. **Redirect only the copy.** In `copy_descriptor_run`, when a source run lies in a shader-visible desktop range, rebuild each source descriptor at the destination from its view record (slot, resource, description), the same way `view_slot` would. Visible-heap writes stay as they are, so this is the smallest change. It depends on the record's resource still being alive when the copy happens, which holds with retire on but needs a check with it off. It also cannot rebuild a descriptor that has no record. 2. **Dual write.** Give each shader-visible view heap a CPU-only mirror, retained like the existing CPU tail. Write every title view and copy destination in a visible range to both heaps, and read copies from the mirror. The result is exact, but every create path in `view_slot` needs a second write, including refused and default views and the console sampler, and the heap uses twice the descriptor memory. 3. **CPU-only primary with a sync before execute.** Point the title ranges at a CPU-only heap and copy dirty spans into the visible heap before `ExecuteCommandLists`. Copies become trivially valid. It is the largest change: `shadow_slot`, `note_heap` and the internal heap users assume the desktop CPU handle is the visible heap. My preference is 2, because it matches desktop semantics exactly and keeps the shadow tracking keyed as it is today. Option 1 is the quickest if you'd rather start small. The fixture already exists: the four retire-views cases crash on the GTX 1060 and should pass with any of these options. Ready for more review
mumba17 commented 2026-11-30 13:58:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-30T13:58:42Z.


Independent NVIDIA data point. On main 077bff3a, Release, Windows 11 build 26300, RTX 3090 (Ampere, driver 32.0.16.1664):

ctest --preset release --no-tests=error -j 1 -R ^startup_resource_retire_views_ --output-on-failure

All 8 passed: hardware_debug0, hardware_debug1, keep_hardware and noretire_hardware, plus the four WARP variants. None of them crashed in CopyDescriptorsSimple.

So the fault does not reproduce on every NVIDIA driver. It appears on the GTX 1060 (Pascal, 32.0.15.6094, Windows 10) and not on Ampere with a current driver. The copy is still outside the D3D12 rules, so a passing NVIDIA run cannot serve as the regression check here.

The debug layer does catch it deterministically. In startup_resource_retire_views_hardware_debug1, the RTX 3090 logs message ID 654 for the first copy:

ID3D12Device::CopyDescriptorsSimple: SrcDescriptorRangeStart points to a descriptor heap type that is CPU write only, so reading it … is invalid

The test still passes, because nothing fails on that message. Whichever fix option is chosen, the fixture could assert that message 654 no longer appears, which checks the contract on any adapter. A copy-source assertion in the shim would work too.

(Edited: the first version of this comment said the debug layer did not flag the copy. It does, as shown above.)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7280648459 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3558#issuecomment-7280648459). Originally posted by [mumba17](https://github.com/mumba17) on 2026-11-30T13:58:42Z. --- Independent NVIDIA data point. On main `077bff3a`, Release, Windows 11 build 26300, RTX 3090 (Ampere, driver 32.0.16.1664): ```powershell ctest --preset release --no-tests=error -j 1 -R ^startup_resource_retire_views_ --output-on-failure ``` All 8 passed: `hardware_debug0`, `hardware_debug1`, `keep_hardware` and `noretire_hardware`, plus the four WARP variants. None of them crashed in `CopyDescriptorsSimple`. So the fault does not reproduce on every NVIDIA driver. It appears on the GTX 1060 (Pascal, 32.0.15.6094, Windows 10) and not on Ampere with a current driver. The copy is still outside the D3D12 rules, so a passing NVIDIA run cannot serve as the regression check here. The debug layer does catch it deterministically. In `startup_resource_retire_views_hardware_debug1`, the RTX 3090 logs message ID 654 for the first copy: > `ID3D12Device::CopyDescriptorsSimple: SrcDescriptorRangeStart points to a descriptor heap type that is CPU write only, so reading it … is invalid` The test still passes, because nothing fails on that message. Whichever fix option is chosen, the fixture could assert that message 654 no longer appears, which checks the contract on any adapter. A copy-source assertion in the shim would work too. *(Edited: the first version of this comment said the debug layer did not flag the copy. It does, as shown above.)*
Jess-Doit commented 2026-11-30 16:40:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-30T16:40:13Z.


Thanks @mumba17. Message 654 turned out to be the check this needed. #3627 implements option 2, a CPU-only mirror of each shader-visible title heap, and uses your suggestion as its regression check:

  • The retire_views_{warp,hardware}_debug1 tests now fail if message 654 appears. That runs on WARP in CI, so it no longer depends on a driver that faults.
  • It also explains why your RTX 3090 run passed with the message in the log. The shim drains the info queue into its own log in check_device, so the test's own GetNumStoredMessages count is always 0. The new check reads the shim's log instead.
  • A control with the mirror turned off (X2W_D3D12_NO_VISIBLE_HEAP_MIRROR=1) passes only if message 654 appears.

Results on the GTX 1060:

  • The four views tests that crashed now pass.
  • The budget and retire families pass 39/39 on the GTX 1060 and WARP.
  • The debug-layer runs log no messages.

If option 1 or 3 is preferred instead, the message check and the new case 6 carry over unchanged.

Ready for more review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7285043537 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3558#issuecomment-7285043537). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-30T16:40:13Z. --- Thanks @mumba17. Message 654 turned out to be the check this needed. #3627 implements option 2, a CPU-only mirror of each shader-visible title heap, and uses your suggestion as its regression check: - The `retire_views_{warp,hardware}_debug1` tests now fail if message 654 appears. That runs on WARP in CI, so it no longer depends on a driver that faults. - It also explains why your RTX 3090 run passed with the message in the log. The shim drains the info queue into its own log in `check_device`, so the test's own `GetNumStoredMessages` count is always 0. The new check reads the shim's log instead. - A control with the mirror turned off (`X2W_D3D12_NO_VISIBLE_HEAP_MIRROR=1`) passes only if message 654 appears. Results on the GTX 1060: - The four views tests that crashed now pass. - The budget and retire families pass 39/39 on the GTX 1060 and WARP. - The debug-layer runs log no messages. If option 1 or 3 is preferred instead, the message check and the new case 6 carry over unchanged. Ready for more review
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#3558
No description provided.