fix(gpu): corrige null CBV no create_cbv para evitar DXGI_ERROR_DEVICE_HUNG (0x887A0006) no AMD RDNA2 #117

Open
github-bot wants to merge 1 commit from github-bot/gh-117 into main AGit
Owner

@⁠ItzMeGamer on GitHub · 2026-11-26 09:39 UTC · original
ItzMeGamer:fix/null-shader-view-cbv-rdna2 → main · +37 −4 · 2 files · 1 commits · open

Resumo

Porta o tratamento de null CBV do upstream (78ed12e) para crates/victory-gpu/src/descriptor.rs (create_cbv), gravando Constant(0, 0) em vez de retornar antecipadamente e deixar uma view antiga ativa no slot quando CreateConstantBufferView recebe desc = null. Também adiciona os testes unitários correspondentes (null_cbv_clears_a_stale_view e a_null_view_has_no_alias_source).

Por que isso resolve o crash no AMD RDNA2

  • Drivers AMD RDNA2 (testado na RX 6500 XT 8 GB) falhavam com DXGI_ERROR_DEVICE_HUNG (0x887A0006) na transição para a cena 3D quando um slot CBV nulo (u4/u5 null no DRED) mantinha uma view obsoleta.
  • Como alias_of (219878a) e null_for (071487f) já estavam presentes na árvore, faltava apenas o create_cbv do commit 78ed12e.

Verificação

  • cargo test -p victory-gpu -> 207 passed, 0 failed.
  • Testado no Windows 11 / AMD RX 6500 XT 8 GB: DXGI_ERROR_DEVICE_HUNG (0x887A0006) eliminado completamente durante a compilação e execução dos shaders de compute da cena 3D.

(Assistido por IA com Antigravity; fixes #18).

English:

Port of upstream VIctory commits:
219878a GPU: a null shader view has no alias source
78ed12e GPU: write a null CBV when CreateConstantBufferView gets a null desc

descriptor.rs (create_cbv): D3D12 accepts a null CBV description and initialises BufferLocation=0, SizeInBytes=0. The old early-return left a stale Constant view in the slot; map null -> Constant(0, 0) so the slot is cleared. host mirroring already emits a null buffer view for Constant views via null_buffer_view, so no host-side change is needed.

resource.rs (alias_of): alias_of already guards is_null() at its top; add the companion test (a_null_view_has_no_alias_source) that documents and exercises that guard, matching the upstream test for alias_source.

descriptor/host.rs null_for: the buffer-dimension fix (071487f) is already present in this tree (is_some_and(|d| d[1] == 1) for both View::Unordered and View::Shader); no change needed there.

Fixes DXGI_ERROR_DEVICE_HUNG (0x887A0006) on AMD RDNA2 when a null shader view or null CBV is bound during indirect/draw commands.

**@⁠ItzMeGamer** on GitHub · 2026-11-26 09:39 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/117) `ItzMeGamer:fix/null-shader-view-cbv-rdna2` → `main` · +37 −4 · 2 files · 1 commits · open ## Resumo Porta o tratamento de null CBV do upstream (`78ed12e`) para `crates/victory-gpu/src/descriptor.rs` (`create_cbv`), gravando `Constant(0, 0)` em vez de retornar antecipadamente e deixar uma view antiga ativa no slot quando `CreateConstantBufferView` recebe `desc = null`. Também adiciona os testes unitários correspondentes (`null_cbv_clears_a_stale_view` e `a_null_view_has_no_alias_source`). ### Por que isso resolve o crash no AMD RDNA2 - Drivers AMD RDNA2 (testado na **RX 6500 XT 8 GB**) falhavam com `DXGI_ERROR_DEVICE_HUNG (0x887A0006)` na transição para a cena 3D quando um slot CBV nulo (`u4/u5 null` no DRED) mantinha uma view obsoleta. - Como `alias_of` (`219878a`) e `null_for` (`071487f`) já estavam presentes na árvore, faltava apenas o `create_cbv` do commit `78ed12e`. ### Verificação - `cargo test -p victory-gpu` -> **207 passed, 0 failed**. - Testado no Windows 11 / AMD RX 6500 XT 8 GB: `DXGI_ERROR_DEVICE_HUNG (0x887A0006)` eliminado completamente durante a compilação e execução dos shaders de compute da cena 3D. *(Assistido por IA com Antigravity; fixes #18).* English: Port of upstream VIctory commits: 219878a GPU: a null shader view has no alias source 78ed12e GPU: write a null CBV when CreateConstantBufferView gets a null desc descriptor.rs (create_cbv): D3D12 accepts a null CBV description and initialises BufferLocation=0, SizeInBytes=0. The old early-return left a stale Constant view in the slot; map null -> Constant(0, 0) so the slot is cleared. host mirroring already emits a null buffer view for Constant views via null_buffer_view, so no host-side change is needed. resource.rs (alias_of): alias_of already guards is_null() at its top; add the companion test (a_null_view_has_no_alias_source) that documents and exercises that guard, matching the upstream test for alias_source. descriptor/host.rs null_for: the buffer-dimension fix (071487f) is already present in this tree (is_some_and(|d| d[1] == 1) for both View::Unordered and View::Shader); no change needed there. Fixes DXGI_ERROR_DEVICE_HUNG (0x887A0006) on AMD RDNA2 when a null shader view or null CBV is bound during indirect/draw commands.
Port of upstream VIctory commits:
  219878a GPU: a null shader view has no alias source
  78ed12e GPU: write a null CBV when CreateConstantBufferView gets a null desc

descriptor.rs (create_cbv): D3D12 accepts a null CBV description and
initialises BufferLocation=0, SizeInBytes=0.  The old early-return left a
stale Constant view in the slot; map null -> Constant(0, 0) so the slot is
cleared.  host mirroring already emits a null buffer view for Constant views
via null_buffer_view, so no host-side change is needed.

resource.rs (alias_of): alias_of already guards is_null() at its top; add
the companion test (a_null_view_has_no_alias_source) that documents and
exercises that guard, matching the upstream test for alias_source.

descriptor/host.rs null_for: the buffer-dimension fix (071487f) is already
present in this tree (is_some_and(|d| d[1] == 1) for both View::Unordered
and View::Shader); no change needed there.

Fixes DXGI_ERROR_DEVICE_HUNG (0x887A0006) on AMD RDNA2 when a null shader
view or null CBV is bound during indirect/draw commands.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:02:37 +00:00
Author
Owner

@⁠ItzMeGamer on GitHub · 2026-11-26 09:39 UTC · original

Oi @⁠uiliannn! Testei a fundo na RX 6500 XT 8 GB e consegui isolar e corrigir o crash DXGI_ERROR_DEVICE_HUNG (0x887A0006) na transição para a cena 3D!

O que encontramos no DRED e corrigimos

  • Como alias_of (219878a) e null_for (071487f) já estavam na árvore, faltava portar o tratamento de null CBV do commit 78ed12e em crates/victory-gpu/src/descriptor.rs (create_cbv), que retornava antes da hora e deixava uma view antiga ativa no slot (u4/u5 null no DRED).
  • Abri dois PRs limpos com os testes unitários passando (207 passed no victory-gpu e 5 passed no victory):
    1. PR do fix AMD RDNA2 (null CBV -> Constant(0, 0)): corrige completamente o 0x887A0006 na RX 6500 XT.
    2. PR do atalho VICTORY_PRESET=8gb: aplica automaticamente todas as 11 variáveis recomendadas para GPUs de 8 GB VRAM + HDD em um único comando.

Agora estou testando o carregamento completo da cena 3D com a paginação expandida (16 GB RAM + pagefile em SSD/HDD) e já posto os resultados de FPS/VRAM aqui!

**@⁠ItzMeGamer** on GitHub · 2026-11-26 09:39 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/117#issuecomment-7188297524) Oi @⁠uiliannn! Testei a fundo na **RX 6500 XT 8 GB** e consegui isolar e corrigir o crash `DXGI_ERROR_DEVICE_HUNG (0x887A0006)` na transição para a cena 3D! ### O que encontramos no DRED e corrigimos - Como `alias_of` (`219878a`) e `null_for` (`071487f`) já estavam na árvore, faltava portar o tratamento de **null CBV** do commit `78ed12e` em `crates/victory-gpu/src/descriptor.rs` (`create_cbv`), que retornava antes da hora e deixava uma view antiga ativa no slot (`u4/u5 null` no DRED). - Abri dois PRs limpos com os testes unitários passando (`207 passed` no `victory-gpu` e `5 passed` no `victory`): 1. **PR do fix AMD RDNA2 (`null CBV -> Constant(0, 0)`):** corrige completamente o `0x887A0006` na RX 6500 XT. 2. **PR do atalho `VICTORY_PRESET=8gb`:** aplica automaticamente todas as 11 variáveis recomendadas para GPUs de 8 GB VRAM + HDD em um único comando. Agora estou testando o carregamento completo da cena 3D com a paginação expandida (16 GB RAM + pagefile em SSD/HDD) e já posto os resultados de FPS/VRAM aqui!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/117/head:github-bot/gh-117'
git switch 'github-bot/gh-117'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-117'
git switch 'github-bot/gh-117'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-117'
git switch 'github-bot/gh-117'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-117'
git switch 'main'
git merge --squash 'github-bot/gh-117'
git switch 'main'
git merge --ff-only 'github-bot/gh-117'
git switch 'main'
git merge 'github-bot/gh-117'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.