[GH-ISSUE #506] With LEONIDA_VK_VALIDATION=1 on main: 7 validation errors in d3d12_clear (depth clear outside [0,1]) and d3d12_mesh (pipeline statistics over a mesh draw) #12

Open
opened 2026-11-26 20:13:59 +01:00 by 4ld0 · 9 comments
Owner

Originally created by @dcastell1 on GitHub (Nov 24, 2026).
Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/506

On main@8f481cf16, the d3d12_* suite is green without validation (301 of 303 pass, the two known ones) but trips seven Vulkan validation errors when it is switched on. Both tests report the errors themselves and fail, so ctest -R '^d3d12_' goes 113/117 with LEONIDA_VK_VALIDATION=1:

ctest.exe --test-dir runtime\build -C RelWithDebInfo -j 8 -R "^d3d12_"
set LEONIDA_VK_VALIDATION=1

Windows 11 10.0.26300, NVIDIA GeForce RTX 5090, driver 621.24, MSVC 14.44.35207, RelWithDebInfo.

d3d12_clear: depth clear outside [0, 1] (4 errors)

vkCmdClearDepthStencilImage(): pDepthStencil->depth is 1.500000 (not within the [0.0, 1.0] range) but
  VK_EXT_depth_range_unrestricted extension is not enabled.   [VUID-VkClearDepthStencilValue-depth-00022]
vkCmdClearAttachments(): pAttachments[0].clearValue.depthStencil.depth is -0.500000 (... same VUID)
the same two again with depth nan

The test is deliberately exercising D3D12's ClearDepthStencilView with 1.5, -0.5 and NaN, which the host accepts. Vulkan only accepts them with VK_EXT_depth_range_unrestricted; the layer does not enable it (no use of it in runtime/), so the Vulkan call is out of spec even though the driver takes it. Enabling the extension where the device offers it, or clamping and documenting the difference, would close it. #307 covers a narrower AMD behaviour (NaN canonicalised to 1.0) and does not cover the range check itself.

d3d12_mesh: pipeline statistics incompatible with mesh draws (3 errors)

vkCmdDrawMeshTasksEXT(): query 1 in VkQueryPool ... with type VK_QUERY_TYPE_PIPELINE_STATISTICS is active,
  which is invalid because it was created with pipelineStatistics
  (CLIPPING_INVOCATIONS_BIT|CLIPPING_PRIMITIVES_BIT) which is incompatible with mesh shaders.
  [VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076]

Queries 1 and 3 of the pool. A D3D12 pipeline-statistics query that includes the clipping counters is legal across a mesh draw; the Vulkan equivalent must not have those bits in the pool when vkCmdDrawMeshTasksEXT runs, so the layer needs to end/switch the query (or drop those bits for mesh pipelines) instead of recording the draw with the query active.

Neither error needs game files; both come from the synthetic tests in runtime/test.

Originally created by @dcastell1 on GitHub (Nov 24, 2026). Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/506 On `main@8f481cf16`, the `d3d12_*` suite is **green without validation** (301 of 303 pass, the two known ones) but trips **seven Vulkan validation errors** when it is switched on. Both tests report the errors themselves and fail, so `ctest -R '^d3d12_'` goes 113/117 with `LEONIDA_VK_VALIDATION=1`: ``` ctest.exe --test-dir runtime\build -C RelWithDebInfo -j 8 -R "^d3d12_" set LEONIDA_VK_VALIDATION=1 ``` Windows 11 10.0.26300, NVIDIA GeForce RTX 5090, driver 621.24, MSVC 14.44.35207, RelWithDebInfo. ### `d3d12_clear`: depth clear outside `[0, 1]` (4 errors) ``` vkCmdClearDepthStencilImage(): pDepthStencil->depth is 1.500000 (not within the [0.0, 1.0] range) but VK_EXT_depth_range_unrestricted extension is not enabled. [VUID-VkClearDepthStencilValue-depth-00022] vkCmdClearAttachments(): pAttachments[0].clearValue.depthStencil.depth is -0.500000 (... same VUID) the same two again with depth nan ``` The test is deliberately exercising D3D12's `ClearDepthStencilView` with `1.5`, `-0.5` and NaN, which the host accepts. Vulkan only accepts them with `VK_EXT_depth_range_unrestricted`; the layer does not enable it (no use of it in `runtime/`), so the Vulkan call is out of spec even though the driver takes it. Enabling the extension where the device offers it, or clamping and documenting the difference, would close it. `#307` covers a narrower AMD behaviour (NaN canonicalised to 1.0) and does not cover the range check itself. ### `d3d12_mesh`: pipeline statistics incompatible with mesh draws (3 errors) ``` vkCmdDrawMeshTasksEXT(): query 1 in VkQueryPool ... with type VK_QUERY_TYPE_PIPELINE_STATISTICS is active, which is invalid because it was created with pipelineStatistics (CLIPPING_INVOCATIONS_BIT|CLIPPING_PRIMITIVES_BIT) which is incompatible with mesh shaders. [VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076] ``` Queries 1 and 3 of the pool. A D3D12 pipeline-statistics query that includes the clipping counters is legal across a mesh draw; the Vulkan equivalent must not have those bits in the pool when `vkCmdDrawMeshTasksEXT` runs, so the layer needs to end/switch the query (or drop those bits for mesh pipelines) instead of recording the draw with the query active. Neither error needs game files; both come from the synthetic tests in `runtime/test`.
Author
Owner

@sodove commented on GitHub (Nov 24, 2026):

I reproduced the four d3d12_clear validation errors on RTX 5070 Ti. #516 fixes the depth-clear half and passes both extension-enabled and restricted-depth tests with Vulkan validation enabled.

I also reproduced all three mesh errors and verified a separate candidate change on c023a365. With this change and #516 applied together, d3d12_clear, d3d12_clear_restricted_depth and d3d12_mesh passed with validation enabled. The mesh segment contributed pixel and compute invocations. Clipping was counted in regular draw segments. In a native comparison, WARP and hardware D3D12 each reported one clipping invocation and one primitive for one mesh triangle.

I closed my duplicate PR #527 because Mby159 had already claimed D3D-291. The measurements above are available for that work.

Follow-up on the exact #540 head c9f4a569. d3d12_mesh passed with validation enabled on RTX 5070 Ti. With #516 applied over it, all three tests covering this issue passed. Test report

<!-- gh-comment-id:7124321557 --> @sodove commented on GitHub (Nov 24, 2026): I reproduced the four d3d12_clear validation errors on RTX 5070 Ti. #516 fixes the depth-clear half and passes both extension-enabled and restricted-depth tests with Vulkan validation enabled. I also reproduced all three mesh errors and verified a separate candidate change on c023a365. With this change and #516 applied together, d3d12_clear, d3d12_clear_restricted_depth and d3d12_mesh passed with validation enabled. The mesh segment contributed pixel and compute invocations. Clipping was counted in regular draw segments. In a native comparison, WARP and hardware D3D12 each reported one clipping invocation and one primitive for one mesh triangle. I closed my duplicate PR #527 because Mby159 had already [claimed D3D-291](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7124368713). The measurements above are available for that work. Follow-up on the exact #540 head c9f4a569. d3d12_mesh passed with validation enabled on RTX 5070 Ti. With #516 applied over it, all three tests covering this issue passed. [Test report](https://github.com/ubiquitarianism/leonida/pull/540#issuecomment-7124883608)
Author
Owner

@whoalin1 commented on GitHub (Nov 25, 2026):

Status check on current main (b4b7756e8, merge of #403), ctest -C RelWithDebInfo -R "d3d12_clear|d3d12_mesh" with LEONIDA_VK_VALIDATION=1. Both halves of this issue have merged fixes: #516 (depth clear range, merge 3f203947) and #540 (mesh statistics pool drops the clipping counters, merge 3bb46d65), plus #577's mesh-primitives clipping counter (47c651174).

NVIDIA GeForce RTX 4070 SUPER (VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070): all four matched tests pass with validation on — d3d12_clear, d3d12_clear_restricted_depth, d3d12_mesh, d3d12_clear_formats. The tests fail on any reported validation error, so none of the 7 original VUIDs (VkClearDepthStencilValue-depth-00022 x4, vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 x3) reproduce.

AMD Radeon iGPU (VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon LEONIDA_PC_TAIL_UBO=1): d3d12_clear_restricted_depth and d3d12_clear_formats pass; d3d12_clear fails only on the known AMD NaN→1.0 canonicalization quirk (#787/#307 — 15 NaN texels read back 1.0) with no depth-00022 VUID; d3d12_mesh fails before any draw because the test shaders need 144 bytes of push constants and the device reports maxPushConstantsSize 128 (the known 128B pushconst limit) — the mesh-draw statistics path can't be exercised on this iGPU, but no validation errors were emitted up to that point.

Verdict: fixed on NVIDIA; the depth-clear half is fixed on AMD too (the remaining d3d12_clear failure there is the separate #787 quirk, not this issue). The mesh half is verified on NVIDIA only — the AMD iGPU cannot run d3d12_mesh due to the push-constant limit, so it stays unverifiable on that device until #1449-class work lands.

Environment note for whoever runs this next: the tests need TMP/TEMP/TMPDIR and COMSPEC set — under a stripped agent shell std::filesystem::temp_directory_path() resolves to C:\Windows, create_directories fails, and the test dies with 0xc0000409 before printing anything (looks like a crash, isn't one).

AI-assisted: yes (Devin).

<!-- gh-comment-id:7149282102 --> @whoalin1 commented on GitHub (Nov 25, 2026): Status check on current `main` (`b4b7756e8`, merge of #403), `ctest -C RelWithDebInfo -R "d3d12_clear|d3d12_mesh"` with `LEONIDA_VK_VALIDATION=1`. Both halves of this issue have merged fixes: #516 (depth clear range, merge `3f203947`) and #540 (mesh statistics pool drops the clipping counters, merge `3bb46d65`), plus #577's mesh-primitives clipping counter (`47c651174`). **NVIDIA GeForce RTX 4070 SUPER** (`VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070`): all four matched tests pass with validation on — `d3d12_clear`, `d3d12_clear_restricted_depth`, `d3d12_mesh`, `d3d12_clear_formats`. The tests fail on any reported validation error, so none of the 7 original VUIDs (`VkClearDepthStencilValue-depth-00022` x4, `vkCmdDrawMeshTasksEXT-pipelineStatistics-07076` x3) reproduce. **AMD Radeon iGPU** (`VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon LEONIDA_PC_TAIL_UBO=1`): `d3d12_clear_restricted_depth` and `d3d12_clear_formats` pass; `d3d12_clear` fails only on the known AMD NaN→1.0 canonicalization quirk (#787/#307 — 15 NaN texels read back 1.0) with **no** `depth-00022` VUID; `d3d12_mesh` fails before any draw because the test shaders need 144 bytes of push constants and the device reports `maxPushConstantsSize 128` (the known 128B pushconst limit) — the mesh-draw statistics path can't be exercised on this iGPU, but no validation errors were emitted up to that point. **Verdict: fixed on NVIDIA; the depth-clear half is fixed on AMD too (the remaining `d3d12_clear` failure there is the separate #787 quirk, not this issue). The mesh half is verified on NVIDIA only — the AMD iGPU cannot run `d3d12_mesh` due to the push-constant limit, so it stays unverifiable on that device until #1449-class work lands.** Environment note for whoever runs this next: the tests need `TMP`/`TEMP`/`TMPDIR` and `COMSPEC` set — under a stripped agent shell `std::filesystem::temp_directory_path()` resolves to `C:\Windows`, `create_directories` fails, and the test dies with `0xc0000409` before printing anything (looks like a crash, isn't one). AI-assisted: yes (Devin).
Author
Owner

@efeekrb commented on GitHub (Nov 25, 2026):

Both causes reported here have fixes merged on main since this was opened:

  • depth clear outside [0,1] in d3d12_clear: #516 (673dd15d, D3D-CLEAR-DEPTH-RANGE, "use legal Vulkan depth clear values")
  • pipeline statistics over a mesh draw in d3d12_mesh: #540 (916dbc61, D3D-291, "the mesh statistics pool enables no forbidden counter")
    Could you rerun d3d12_clear and d3d12_mesh with LEONIDA_VK_VALIDATION=1 on current main? If both come out clean, this can be closed. (I could not run them: they are Windows-only.)
<!-- gh-comment-id:7159785998 --> @efeekrb commented on GitHub (Nov 25, 2026): Both causes reported here have fixes merged on main since this was opened: - depth clear outside [0,1] in d3d12_clear: #516 (673dd15d, D3D-CLEAR-DEPTH-RANGE, "use legal Vulkan depth clear values") - pipeline statistics over a mesh draw in d3d12_mesh: #540 (916dbc61, D3D-291, "the mesh statistics pool enables no forbidden counter") Could you rerun d3d12_clear and d3d12_mesh with LEONIDA_VK_VALIDATION=1 on current main? If both come out clean, this can be closed. (I could not run them: they are Windows-only.)
Author
Owner

@sodove commented on GitHub (Nov 25, 2026):

Retested the two requested cases on native Windows 11 build 26100, MSVC 19.44 RelWithDebInfo, at main bcaa13dad. Each run selected its adapter explicitly. Both tests reported validation on and the Vulkan loader confirmed the Khronos 1.4.369 layer was active.

Adapter d3d12_clear d3d12_mesh VUIDs emitted
RTX 5070 Ti, NVIDIA 610.74 Pass Pass 0
Ryzen 5 9600X Radeon iGPU, driver 32.0.21045.29003, LEONIDA_PC_TAIL_UBO=1 Fail: 15 NaN depth texels read back as 1.0 Fail: the mixed mesh/vertex statistics assertion at d3d12_mesh_test.cpp:688 0

Neither originally reported VUID reproduced on either GPU. On this iGPU the mesh test reached the mixed-query readback. A second run failed at the same assertion, again with no VUID. The assertion checks several counters together, so this run does not identify which counter differed.

Synthetic fixtures only. AI-assisted: yes (OpenAI Codex).

<!-- gh-comment-id:7160322426 --> @sodove commented on GitHub (Nov 25, 2026): Retested the two requested cases on native Windows 11 build 26100, MSVC 19.44 RelWithDebInfo, at main `bcaa13dad`. Each run selected its adapter explicitly. Both tests reported validation on and the Vulkan loader confirmed the Khronos 1.4.369 layer was active. | Adapter | `d3d12_clear` | `d3d12_mesh` | VUIDs emitted | | --- | --- | --- | --- | | RTX 5070 Ti, NVIDIA 610.74 | Pass | Pass | 0 | | Ryzen 5 9600X Radeon iGPU, driver 32.0.21045.29003, `LEONIDA_PC_TAIL_UBO=1` | Fail: 15 NaN depth texels read back as 1.0 | Fail: the mixed mesh/vertex statistics assertion at `d3d12_mesh_test.cpp:688` | 0 | Neither originally reported VUID reproduced on either GPU. On this iGPU the mesh test reached the mixed-query readback. A second run failed at the same assertion, again with no VUID. The assertion checks several counters together, so this run does not identify which counter differed. Synthetic fixtures only. AI-assisted: yes (OpenAI Codex).
Author
Owner

@BubsMcgee commented on GitHub (Nov 25, 2026):

Verified on current main 0d80bc5df, with the Khronos validation layer actually active.

Environment:

  • Windows 11 Pro build 26300
  • NVIDIA GeForce RTX 3080 Ti, driver 616.64
  • Vulkan SDK 1.4.363.0 (VK_LAYER_KHRONOS_validation, "Khronos Validation Layer", api 1.4.363), installed via winget. d3d12_mesh_test needs glslangValidator, so it was built for this run.

Command:

LEONIDA_VK_VALIDATION=1 ctest -C RelWithDebInfo -R "d3d12_clear|d3d12_mesh" --output-on-failure

Result: 4/4 passed, 0 failed

  • d3d12_clear
  • d3d12_clear_restricted_depth
  • d3d12_mesh
  • d3d12_clear_formats

These tests fail on any reported validation error, so none of the seven original VUIDs (VkClearDepthStencilValue-depth-00022 x4, vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 x3) reproduce here. The depth-clear half (#516) and the mesh-statistics half (#540/#577) are on main.

Note this run covers the original Windows/NVIDIA validation VUIDs only; the separate AMD failures (e.g. NaN depth canonicalization) are a different problem and are not exercised here. On this evidence the issue looks closeable.

AI-assisted.

<!-- gh-comment-id:7162482207 --> @BubsMcgee commented on GitHub (Nov 25, 2026): Verified on current `main` `0d80bc5df`, with the Khronos validation layer actually active. Environment: - Windows 11 Pro build 26300 - NVIDIA GeForce RTX 3080 Ti, driver 616.64 - Vulkan SDK 1.4.363.0 (`VK_LAYER_KHRONOS_validation`, "Khronos Validation Layer", api 1.4.363), installed via winget. `d3d12_mesh_test` needs `glslangValidator`, so it was built for this run. Command: ``` LEONIDA_VK_VALIDATION=1 ctest -C RelWithDebInfo -R "d3d12_clear|d3d12_mesh" --output-on-failure ``` Result: **4/4 passed, 0 failed** - `d3d12_clear` - `d3d12_clear_restricted_depth` - `d3d12_mesh` - `d3d12_clear_formats` These tests fail on any reported validation error, so none of the seven original VUIDs (`VkClearDepthStencilValue-depth-00022` x4, `vkCmdDrawMeshTasksEXT-pipelineStatistics-07076` x3) reproduce here. The depth-clear half (#516) and the mesh-statistics half (#540/#577) are on main. Note this run covers the original Windows/NVIDIA validation VUIDs only; the separate AMD failures (e.g. NaN depth canonicalization) are a different problem and are not exercised here. On this evidence the issue looks closeable. AI-assisted.
Author
Owner

@BubsMcgee commented on GitHub (Nov 25, 2026):

The seven original VUIDs no longer reproduce on current main (verified on 0d80bc5df with the Khronos validation layer, above), and #516/#540/#577 are merged. This can be closed; the separate AMD NaN-depth failures are a different problem. (AI-assisted.)

<!-- gh-comment-id:7163235388 --> @BubsMcgee commented on GitHub (Nov 25, 2026): The seven original VUIDs no longer reproduce on current main (verified on 0d80bc5df with the Khronos validation layer, above), and #516/#540/#577 are merged. This can be closed; the separate AMD NaN-depth failures are a different problem. (AI-assisted.)
Author
Owner

@BubsMcgee commented on GitHub (Nov 25, 2026):

Both validation errors have merged fixes on main: the depth clear outside [0, 1] by 673dd15d0 (D3D-CLEAR-DEPTH-RANGE, merged in #516) and the mesh pipeline-statistics case by #540 (3bb46d658). Both are ancestors of origin/main at 9e7720c9e. A rerun with LEONIDA_VK_VALIDATION=1 should show 0 in d3d12_clear; anything left would be new.

<!-- gh-comment-id:7169514569 --> @BubsMcgee commented on GitHub (Nov 25, 2026): Both validation errors have merged fixes on main: the depth clear outside [0, 1] by `673dd15d0` (D3D-CLEAR-DEPTH-RANGE, merged in #516) and the mesh pipeline-statistics case by #540 (`3bb46d658`). Both are ancestors of `origin/main` at `9e7720c9e`. A rerun with `LEONIDA_VK_VALIDATION=1` should show 0 in `d3d12_clear`; anything left would be new.
Author
Owner

@ZroIsHere commented on GitHub (Nov 26, 2026):

The seven reported Vulkan validation errors are resolved on current main: depth clear range in #516 and the mesh statistics pool/counter handling in #540/#577. Follow-up runs with the Khronos validation layer active report all original VUIDs absent. Remaining AMD NaN-depth and push-constant-limit failures are separate issues, so closing this report.

<!-- gh-comment-id:7178859607 --> @ZroIsHere commented on GitHub (Nov 26, 2026): The seven reported Vulkan validation errors are resolved on current main: depth clear range in #516 and the mesh statistics pool/counter handling in #540/#577. Follow-up runs with the Khronos validation layer active report all original VUIDs absent. Remaining AMD NaN-depth and push-constant-limit failures are separate issues, so closing this report.
Author
Owner

@ZroIsHere commented on GitHub (Nov 26, 2026):

Checked the current source and follow-up reports: the original seven VUIDs are fixed on main by #516 (depth clear) and #540/#577 (mesh statistics). Runs with Khronos validation active report none of those VUIDs. The AMD NaN-depth and mesh push-constant-limit failures mentioned in later reports are separate. I attempted to close this resolved report, but GitHub denied the account the CloseIssue permission, so it remains open for a maintainer to close.

<!-- gh-comment-id:7178862290 --> @ZroIsHere commented on GitHub (Nov 26, 2026): Checked the current source and follow-up reports: the original seven VUIDs are fixed on main by #516 (depth clear) and #540/#577 (mesh statistics). Runs with Khronos validation active report none of those VUIDs. The AMD NaN-depth and mesh push-constant-limit failures mentioned in later reports are separate. I attempted to close this resolved report, but GitHub denied the account the `CloseIssue` permission, so it remains open for a maintainer to close.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#12
No description provided.