Commit Graph

3 Commits

Author SHA1 Message Date
59f14e13c4 device-markers: draws get marker pairs too, and the report names the draw that started and did not finish
With LEONIDA_DEVICE_MARKERS=1 every draw the replay records takes a seq from the dispatch numbering and writes the
VK_AMD_buffer_marker pair: started before its helper passes and rendering scope, finished after the scope ends (the
legacy indirect path inside the caller's scope, which the extension allows). The marker history (now 65,536 items)
keeps each draw's kind and counts, pipeline names, execute, list, command and its place among the draws to the same
targets. The loss and stall reports name the last finished item, the likely hang, the rest in flight and an idle
queue's next one not started, for draws and dispatches alike; a device-fault address is followed by the last draw
each queue started. Tests: the CPU marker test records draws and dispatches and checks the lines; the GPU marker
test writes draw markers outside and inside a dynamic-rendering scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 19:40:14 -05:00
a9fb8058aa d3d12: indexed quad lists draw from triangle indices a compute pass expands on the GPU (OLD-9940)
An indexed quad list was one triangle fan per quad over the application's index buffer.
That is wrong in two ways, both measured on #207 (RTX 4070 Ti there, RTX 4070 SUPER here):

- A fan's triangles are (v1 v2 v0) and (v2 v3 v0), and Vulkan takes a flat input from a
  triangle's first vertex. So a quad showed its second and third vertex, never its first:
  a quad with a red first vertex came out black and blue, 0 of 4096 pixels red.
- One draw per quad runs every instance of quad 0 before quad 1. D3D12 draws instance by
  instance, so where instances overlap the wrong one ended on top (2048 of 4096 pixels).

Neither can be fixed inside that scheme (VK_EXT_provoking_vertex cannot name a fan's hub
either), so the indices are rewritten: a compute pass (quad_index_expand.comp) reads the
application's index buffer on the GPU and writes (i0 i1 i2) (i0 i2 i3) for each quad as
32-bit indices into copy scratch, and the draw is one indexed triangle list over that
scratch with the application's instance count, base vertex and first instance. Both
triangles start at the quad's first vertex, like the non-indexed path.

- The host never reads the indices: a copy or a shader earlier in the list can have
  written them. The pass runs before the draw's rendering scope, between a barrier for
  those writes and one for its own, and between two segments of an active
  pipeline-statistics query, as the other helper dispatches do (D3D-162).
- 16-bit and 32-bit indices, read as whole words, so a 16-bit view at an address of
  2 modulo 4 works. Index values are copied as they are: VertexIndex - BaseVertex is still
  the application's index.
- The strip-cut values are ordinary indices, as in every list topology. An index past the
  view reads 0, as in D3D12, and the pass reads nothing past the view. A draw's last one to
  three indices are dropped.
- It needs bufferDeviceAddress. Without it, or inside a statistics query that cannot be
  split, the list is refused as unsupported.
- vulkan_topology(19) is a triangle list for both paths; nothing draws a fan any more
  (MoltenVK has no fans).

replay_quad_list_test replays indexed draws through prepare() and the real expander on a
recording device: one dispatch before the rendering scope and one draw in it, the push
constants for both index sizes, the view's end, the split of a draw larger than one
dispatch, the refusals, and the order inside a statistics query.

AI-assisted (Claude Code; Claude Opus 5.5 and Claude Fable 5.2).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
2026-11-24 05:10:18 -05:00
abe64d495b d3d12: quad lists draw as triangle-list indices (0 1 2) (0 2 3) so flat inputs use the first quad vertex, and the PSO topology type is read as raw bits
Taken from the follow-up patch of @matheuskshn (930e78a2, tested by them on an RTX 4070 Ti: replay_quad_list_test fails the two non-indexed cases on a6b31d51 and passes with it). Re-run here: replay_quad_list_test and d3d12_rect_list_test exit 0 on the pod (Wine, RTX 4090).
2026-11-24 05:10:18 -05:00