Probe (diagnostic) build: capture and copy problems with lifetime-0 inputs

Aberta
#78 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
cpp

Direção de pesquisa

Start in probe.cpp at the lifetime-0 tag handling (around lines 502-526) and in RrProbe::capture (around 1155-1175), then probe_gpu_d3d12.cpp where capture calls QueryInterface and GetDesc. The first fix is item A: skip lifetime-0 sources that were never copied and log "lifetime-0, not copied". Done means test_probe_dll on WARP passes with depth released before a capture evaluate, showing no crash and a skip line. Items B-D change the design of copies and need maintainer agreement first.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

area: ray-reconstruction bug

This was found by reading the code. It has not been reproduced.

Release builds are not affected. Everything below is in the probe (diagnostic) build only (WG_RR_PROBE=1): probe.cpp and probe_gpu_d3d12.cpp are built only there. Item A also needs the capture option switched on. The release plugin does not contain this code. All paths are under clean/rr_f/proxy/src/.

What happens

A. Capture reads lifetime-0 inputs that were never copied.
The probe copies a lifetime-0 tag only for colour (type 3), normals (5) and normal-roughness (14) (probe.cpp:513-516). Every other lifetime-0 tag keeps the game's own pointer (probe.cpp:502). Capture collects every tagged type of the viewport, skips only outputs, and takes the resource with no lifetime check (probe.cpp:1155-1175). It then calls QueryInterface and GetDesc and records barriers and copies on that pointer (probe_gpu_d3d12.cpp:437, 452, 511-528, 644-649). If the game freed the resource after tagging, that is a call on a dead object (crash) or a capture of the wrong content.

  • Reachable: a game that tags depth, motion, albedo and similar with lifetime 0 (some engines tag transient-pool targets this way) while a tester has capture on.
  • Effect: a crash, or silently wrong captures.

B. Barriers and copies cover all subresources with one declared state.
transition() always uses D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES (probe_gpu_d3d12.cpp:132-139). copy_input accepts any single-sample 2D texture, keeps its mip and array count and uses CopyResource (probe_gpu_d3d12.cpp:365-417). Capture copies subresource 0 only but transitions the whole resource (probe_gpu_d3d12.cpp:511-528). This is wrong only for an input with more than one mip whose mips are in different states. The interface cannot express that (one state per tagged resource). RR inputs are almost always single-mip render targets. If all mips share the declared state, the code is valid.

  • Effect: a debug-layer error, and possibly a wrong mip on real hardware.

C. Retired copy textures accumulate until a device change.
On a shape mismatch the old lifetime-0 copy goes to retired_ (probe_gpu_d3d12.cpp:382-388). retired_ is released only in reset(), called from the destructor and on device change (probe_gpu_d3d12.cpp:290, 301, 623-641). Finished capture readback buffers also go there (probe_gpu_d3d12.cpp:603-604). Growth is one texture per shape change, for at most the three copy keys. Dynamic resolution normally keeps a fixed texture with a changing extent, so it does not grow. Capture readbacks are bounded by the capture budget.

D. Lifetime-0 copies keyed only by buffer type alias across frames and viewports.
The copy key is the buffer type only (probe.cpp:526; probe_gpu_d3d12.cpp:377). probe.h:113-114 documents the copy as "valid until the next copy for key". Frame-scoped records (probe.cpp:567-572) and per-viewport records (probe.h:234) can hold the same copy pointer. This is harmful only if a second lifetime-0 copy of the same type is recorded before the evaluate of the first frame runs: for example tag frame B and then evaluate frame A on the same list, or two viewports with equal-size colour evaluated after both tags. The normal tag-then-evaluate order per frame is correct.

  • Effect: the probe upscales or captures another frame's input. Wrong diagnostics, no crash.

When it can happen

Only when a tester runs the probe build. For players on the release build, none of this applies. For the capture tool, A can give wrong captures without any sign, so it matters before the next capture run on a new game. B, C and D need an atypical input or a particular call order.

To do

  • A: in RrProbe::capture, skip any source whose stored tag has lifetime == WG_LIFE_ONLY_DURING_TAG and was not copied. Log "lifetime-0, not copied". Track a copied bool in StoredTag, or compare resource != res.native. Copying every lifetime-0 input when capture is on is the fuller fix, but costs VRAM and widens C and D. Captures of such games will lose those inputs (logged).
  • B: in copy_input and in capture, refuse and log inputs with MipLevels > 1 || DepthOrArraySize > 1. Or transition subresource 0 only and copy with CopyTextureRegion into a one-mip texture. A refused input shows as missing in the probe.
  • C: record an evaluate counter with each retired texture and free entries older than a fixed number of evaluates, above the maximum frames in flight. A fence signalled after use is exact; a counter is heuristic and can free too early if it is not tied to GPU completion.
  • D: key copies by (viewport id, buffer type, frame-scoped or viewport) and keep a small ring of copies per key, handed out round-robin and recycled once the consuming evaluate is past the frames in flight. This costs more VRAM per key. The ring size must exceed the pipelining depth.

Test

CPU-only.

  • A: test_probe_dll (WARP). Tag depth with lifetime 0, release the depth texture, run a capture evaluate. Assert no crash, a "not copied" skip line, and depth absent from frame.json.
  • B: test_probe_dll on WARP with the debug layer. Tag a 2-mip colour texture with mip 1 left in a different state. Assert no debug-layer error after the fix, or that the input is refused with a log line.
  • C: test_probe_dll on WARP. Alternate two sizes many times and assert the retired count (add a test hook) stays bounded. test_probe_core with the fake GPU is not enough, since it has no D3D12 objects.
  • D: test_probe_core with the fake GPU. Tag-for-frame colour (lifetime 0) for frames A and B, then evaluate A. Assert A's upscale source differs from B's copy.
Linguagem predominante
C++
Estrelas
12
Forks
2
Merge médio
3h 10min
PRs com merge (30d)
171

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de phantoslayer21/wronggpu

Todas as issues de phantoslayer21/wronggpu

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.