test: compare mesh geometry invocations against the vertex control #3219

Open
Maticcm wants to merge 1 commit from upstream-pr/3219 into main
Maticcm commented 2026-12-02 20:21:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Maticcm on 2026-12-02T20:21:20Z.


Claimed in the coordination issue as RT-AMD-MIXED-QUERY-UNUSED-STAGE-COUNTS.

What and why

The mixed mesh/vertex statistics test expected zero GSInvocations from the mixed query. Direct3D's counter contract allows an adapter to increment that counter with no geometry shader bound. The vertex-only control and mixed query both report 2 on Radeon. The mesh-only query reports 0.

Compare the mixed query with the existing vertex-only control, which runs the same two vertex draws. The comparison still fails if adding mesh draws changes this counter. The mesh-only zero check and the other stage-counter checks remain in place.

Tested

  • On exact main a8465211fb882e8c38cc0a39760bb8014d927289, d3d12_mesh failed the mixed-counter assertion on Radeon and passed on RTX 3080.

  • Captured the raw D3D12 readback fields with a temporary diagnostic: mixed / mesh-only / vertex-only GSInvocations were 2 / 0 / 2 on Radeon, and 0 / 0 / 0 on RTX 3080.

  • With this change, d3d12_mesh and d3d12_mesh_heavy_cache passed on both adapters with Vulkan validation enabled. No validation errors or VUIDs appeared. Changed-file game-data and whitespace checks passed.

  • On the original verification checkout, the full semantic suite ran 522 files and 6,484 tests. One file failed, the existing f16 conversion expectation.

GPUs tested: AMD Radeon(TM) Graphics (Ryzen 9 9950X3D, driver 32.0.21045.29003), NVIDIA GeForce RTX 3080 (630.20); Windows 11. Synthetic fixtures only.

AI-assisted with OpenAI Codex (GPT-6.2 Sol), with a separate reviewer.

Checklist

  • Merge check reconfirmed during queue preparation.
  • One topic.
  • No game data, keys or protection workarounds.
  • No translator rule changed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5614035726 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3219). Originally posted by [Maticcm](https://github.com/Maticcm) on 2026-12-02T20:21:20Z. --- Claimed in the coordination issue as [RT-AMD-MIXED-QUERY-UNUSED-STAGE-COUNTS](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7246339457). ### What and why The mixed mesh/vertex statistics test expected zero `GSInvocations` from the mixed query. [Direct3D's counter contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_query_data_pipeline_statistics) allows an adapter to increment that counter with no geometry shader bound. The vertex-only control and mixed query both report 2 on Radeon. The mesh-only query reports 0. Compare the mixed query with the existing vertex-only control, which runs the same two vertex draws. The comparison still fails if adding mesh draws changes this counter. The mesh-only zero check and the other stage-counter checks remain in place. ### Tested - On exact main `a8465211fb882e8c38cc0a39760bb8014d927289`, `d3d12_mesh` failed the mixed-counter assertion on Radeon and passed on RTX 3080. - Captured the raw D3D12 readback fields with a temporary diagnostic: mixed / mesh-only / vertex-only `GSInvocations` were 2 / 0 / 2 on Radeon, and 0 / 0 / 0 on RTX 3080. - With this change, `d3d12_mesh` and `d3d12_mesh_heavy_cache` passed on both adapters with Vulkan validation enabled. No validation errors or VUIDs appeared. Changed-file game-data and whitespace checks passed. - On the original verification checkout, the full semantic suite ran 522 files and 6,484 tests. One file failed, the existing [f16 conversion expectation](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7238985184). GPUs tested: AMD Radeon(TM) Graphics (Ryzen 9 9950X3D, driver 32.0.21045.29003), NVIDIA GeForce RTX 3080 (630.20); Windows 11. Synthetic fixtures only. AI-assisted with OpenAI Codex (GPT-6.2 Sol), with a separate reviewer. ### Checklist - [x] Merge check reconfirmed during queue preparation. - [x] One topic. - [x] No game data, keys or protection workarounds. - [x] No translator rule changed.
merzleckeier commented 2026-12-02 20:23:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T20:23:16Z.

Review: COMMENTED


Source review on 38c56ae9, clean merge with current main b41763227. Both queries invoke the same vertex_draw helper twice with the same PSO, viewport and draw arguments. The separate mesh-only zero assertion and the other stage assertions still run. The D3D12 counter contract permits a nonzero GS invocation count with no geometry shader bound, so the control is a better check than an absolute mixed count. One non-blocking request: include GSInvocations for all three queries in the existing printf. EXPECT currently prints only the expression, so the next driver discrepancy would otherwise need the temporary diagnostic again. This is a source review; I did not repeat the GPU runs. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6158307164 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3219#pullrequestreview-6158307164). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T20:23:16Z. **Review:** COMMENTED --- Source review on `38c56ae9`, clean merge with current `main` `b41763227`. Both queries invoke the same `vertex_draw` helper twice with the same PSO, viewport and draw arguments. The separate mesh-only zero assertion and the other stage assertions still run. The [D3D12 counter contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_query_data_pipeline_statistics) permits a nonzero GS invocation count with no geometry shader bound, so the control is a better check than an absolute mixed count. One non-blocking request: include `GSInvocations` for all three queries in the existing `printf`. `EXPECT` currently prints only the expression, so the next driver discrepancy would otherwise need the temporary diagnostic again. This is a source review; I did not repeat the GPU runs. AI-assisted.
copilot-pull-request-reviewer[bot] commented 2026-12-02 20:23:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-12-02T20:23:56Z.

Review: COMMENTED


No active review issues are reported for the adapter-specific geometry invocation baseline update.

No open issues 🎉

What changed in this PR

Updates the D3D12 mesh statistics test to accommodate adapter-specific geometry invocation counts without weakening mesh-stage isolation checks.

Changes:

  • Compares mixed-query GSInvocations against the equivalent vertex-only control instead of zero.
  • Documents the rationale and preserves mesh-only and other stage-counter checks.
File Description
runtime/​test/​d3d12_mesh_test.cpp Uses the vertex-only geometry invocation count as the mixed-query baseline.

Review effort: Balanced

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6158318713 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3219#pullrequestreview-6158318713). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-12-02T20:23:56Z. **Review:** COMMENTED --- <!-- ccr-overview-v2 --> ### 🟢 Approval recommended No active review issues are reported for the adapter-specific geometry invocation baseline update. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> Updates the D3D12 mesh statistics test to accommodate adapter-specific geometry invocation counts without weakening mesh-stage isolation checks. **Changes:** - Compares mixed-query `GSInvocations` against the equivalent vertex-only control instead of zero. - Documents the rationale and preserves mesh-only and other stage-counter checks. | File | Description | | ---- | ----------- | | `runtime/​test/​d3d12_mesh_test.cpp` | Uses the vertex-only geometry invocation count as the mixed-query baseline. | </details> <sub>Review effort: Balanced</sub>
fiestorra commented 2026-12-02 20:52:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T20:52:14Z.


VERIFY-3219 — compilado y ejecutado aquí: el cambio no rompe nada, pero el rojo no se puede reproducir en esta tarjeta

Head (this PR)
Merge base a8465211f (behind main b41763227; main moved the same file by 75 lines since)
Merged onto main — git merge-tree --write-tree clean, so GitHub merges it despite the drift

Ran (native Windows, VS 2022 Build Tools, RelWithDebInfo, RTX 4090)

cmake --build runtime/build --config RelWithDebInfo --target d3d12_mesh_test   ok (1.2 min, then 0.2 min)
runtime/build/d3d12_mesh_test.exe                                              exit 0

With the old assertion, as main has it, the test passes here (exit 0). Because of the drift I applied the PR's three assertions to the current file by hand, rebuilt (only the test target) and ran it again: exit 0 as well, and the statistics line is unchanged (mixed: IA 6/2 VS 6 C 12/2 PS 3328 CS 0; mesh only: C 8/0 PS 1024; vertex only: C 2 PS 2048).

So on this adapter the change is behaviour-preserving, and the red side is not reproducible: an RTX 4090 reports GSInvocations == 0 without a geometry shader, which is exactly what the old assertion expected. The PR is for adapters that report the geometry invocations anyway — the comment in the diff names that, and I cannot exercise it. I am saying that instead of calling this a red/green.

What the change does hold: it still pins mixed.GSPrimitives == 0, HSInvocations == 0, DSInvocations == 0 and CSInvocations == 0, and it adds the comparison that matters for a mesh draw — mixed.GSInvocations == vertex_only.GSInvocations, i.e. the mesh draws add nothing to the counter the two queries share. That is stronger than "== 0" where the counter is non-zero for both.

What I could not test

  • The adapter the change is for: I have one card, and it reports 0.
  • The full runtime suite: only this target, and only through main + the three assertion lines, not the PR's tree (the drift is 75 lines of unrelated test additions).

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358448072 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3219#issuecomment-7358448072). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T20:52:14Z. --- ## VERIFY-3219 — compilado y ejecutado aquí: el cambio **no rompe nada**, pero el rojo no se puede reproducir en esta tarjeta | | | |---|---| | Head | `(this PR)` | | Merge base | `a8465211f` (behind `main` `b41763227`; `main` moved the same file by 75 lines since) | | Merged onto | `main` — `git merge-tree --write-tree` clean, so GitHub merges it despite the drift | **Ran (native Windows, VS 2022 Build Tools, `RelWithDebInfo`, RTX 4090)** ``` cmake --build runtime/build --config RelWithDebInfo --target d3d12_mesh_test ok (1.2 min, then 0.2 min) runtime/build/d3d12_mesh_test.exe exit 0 ``` **With the old assertion, as `main` has it, the test passes here** (exit 0). Because of the drift I applied the PR's three assertions to the current file by hand, rebuilt (only the test target) and ran it again: **exit 0 as well**, and the statistics line is unchanged (`mixed: IA 6/2 VS 6 C 12/2 PS 3328 CS 0; mesh only: C 8/0 PS 1024; vertex only: C 2 PS 2048`). **So on this adapter the change is behaviour-preserving, and the red side is not reproducible**: an RTX 4090 reports `GSInvocations == 0` without a geometry shader, which is exactly what the old assertion expected. The PR is for adapters that report the geometry invocations anyway — the comment in the diff names that, and I cannot exercise it. I am saying that instead of calling this a red/green. **What the change does hold**: it still pins `mixed.GSPrimitives == 0`, `HSInvocations == 0`, `DSInvocations == 0` and `CSInvocations == 0`, and it adds the comparison that matters for a mesh draw — `mixed.GSInvocations == vertex_only.GSInvocations`, i.e. the mesh draws add nothing to the counter the two queries share. That is stronger than "== 0" where the counter is non-zero for both. ## What I could not test - **The adapter the change is for**: I have one card, and it reports 0. - **The full `runtime` suite**: only this target, and only through `main` + the three assertion lines, not the PR's tree (the drift is 75 lines of unrelated test additions). Written with an AI assistant.
fiestorra commented 2026-12-03 06:50:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T06:50:55Z.


VERIFY-3219 — compilado y ejecutado el test de C++ que toca: exit 0 con el cambio y exit 0 en main, y el cambio es de una aserción que era demasiado estricta

Es la primera PR de C++ que verifico esta noche ejecutando, y el camino para llegar costó tres intentos que vale la pena contar.

runtime/test/d3d12_mesh_test.cpp   +5/−2

cmake --build runtime/build --config RelWithDebInfo --target d3d12_mesh_test
  con el cambio de #3219:  exit 0, Linking d3d12_mesh_test.exe
main (sin el cambio):      exit 0

d3d12_mesh_test.exe
  con #3219:  exit 0
  main:       exit 0

Los tres intentos:

  1. copiar runtime/build a un worktree → CMake Error: The current CMakeCache.txt directory…: el cache lleva rutas absolutas y no se puede mover;
  2. compilar en el checkout principal → C1083: cannot open 'windows.h': faltaba el entorno de MSVC, que no está en este shell;
  3. con vcvars64.bat delante (C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools) → compila.

Y el cambio, que es de los que no se pueden juzgar por el diff sin saber qué mide: la aserción exigía GSInvocations == 0 en un caso mixto, y ahora exige que sea igual a las invocaciones del caso sólo-vértices. El comentario nuevo lo dice: "D3D12 permits geometry invocations with no geometry shader bound on some…" — o sea que el 0 no era una garantía del API, era una suposición del test.

Por qué el exit 0 en los dos lados no invalida nada: este ejecutable no imprime resumen de gtest (no lo usa): hace sus comprobaciones y devuelve un código. Y en main también sale 0 — lo que significa que el caso mixto que la PR relaja no se da en esta tarjeta. O sea: la PR no cambia el resultado aquí, cambia lo que el test exige, y esta máquina ya lo cumplía.

Lo que no puedo decir: que la relajación sea correcta en la tarjeta del autor (donde el caso sí se daba) — lo que sí puedo es que no rompe nada en esta, y que el exit 0 de antes y el de ahora vienen del mismo binario recompilado, no de un test que no se ejecutó.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370303936 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3219#issuecomment-7370303936). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T06:50:55Z. --- ## VERIFY-3219 — compilado y ejecutado el test de C++ que toca: **`exit 0` con el cambio y `exit 0` en `main`**, y el cambio es de una aserción que era demasiado estricta **Es la primera PR de C++ que verifico esta noche ejecutando, y el camino para llegar costó tres intentos que vale la pena contar.** ``` runtime/test/d3d12_mesh_test.cpp +5/−2 cmake --build runtime/build --config RelWithDebInfo --target d3d12_mesh_test con el cambio de #3219: exit 0, Linking d3d12_mesh_test.exe main (sin el cambio): exit 0 d3d12_mesh_test.exe con #3219: exit 0 main: exit 0 ``` **Los tres intentos**: 1. **copiar `runtime/build` a un worktree** → **`CMake Error: The current CMakeCache.txt directory…`**: **el cache lleva rutas absolutas y no se puede mover**; 2. **compilar en el checkout principal** → **`C1083: cannot open 'windows.h'`**: **faltaba el entorno de MSVC**, **que no está en este shell**; 3. **con `vcvars64.bat` delante** (**`C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools`**) → **compila**. **Y el cambio, que es de los que no se pueden juzgar por el diff sin saber qué mide**: **la aserción exigía `GSInvocations == 0` en un caso mixto**, **y ahora exige que sea *igual a las invocaciones del caso sólo-vértices*.** **El comentario nuevo lo dice**: ***"D3D12 permits geometry invocations with no geometry shader bound on some…"*** — **o sea que el 0 no era una garantía del API, era una suposición del test.** **Por qué el `exit 0` en los dos lados no invalida nada**: **este ejecutable no imprime resumen de `gtest`** (**no lo usa**): **hace sus comprobaciones y devuelve un código.** **Y en `main` también sale 0** — **lo que significa que el caso mixto que la PR relaja no se da en esta tarjeta.** **O sea: la PR no cambia el resultado aquí, cambia lo que el test *exige*, y esta máquina ya lo cumplía.** **Lo que no puedo decir**: **que la relajación sea correcta en la tarjeta del autor** (**donde el caso sí se daba**) — **lo que sí puedo es que no rompe nada en esta, y que el `exit 0` de antes y el de ahora vienen del mismo binario recompilado, no de un test que no se ejecutó.**
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3219:upstream-pr/3219'
git switch 'upstream-pr/3219'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3219'
git switch 'upstream-pr/3219'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3219'
git switch 'upstream-pr/3219'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3219'
git switch 'main'
git merge --squash 'upstream-pr/3219'
git switch 'main'
git merge --ff-only 'upstream-pr/3219'
git switch 'main'
git merge 'upstream-pr/3219'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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
ProjectLeonida/mandy!3219
No description provided.