diff options
| author | QemmHD <290605352+QemmHD@users.noreply.github.com> | 2026-11-24 05:09:17 -0500 |
|---|---|---|
| committer | QemmHD <290605352+QemmHD@users.noreply.github.com> | 2026-11-24 05:10:18 -0500 |
| commit | a9fb8058aa14d7686c6af11d1b14064924fe50d2 (patch) | |
| tree | 2e6e5e2804af14371f8c802c2d76787dde92ec93 /runtime/src/pe_loader.cpp | |
| parent | 7739895421f52326ab9523690848ec105e99e2e5 (diff) | |
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
Diffstat (limited to 'runtime/src/pe_loader.cpp')
0 files changed, 0 insertions, 0 deletions