[GH-ISSUE #504] d3d12_execute_indirect_validation: 5 rows where the layer rejects and live WARP and hardware accept (over-strict, not permissive) #10

Closed
opened 2026-11-26 20:13:58 +01:00 by 4ld0 · 3 comments
Owner

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

On main@8f481cf16, ctest -j 8 on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), MSVC 14.44.35207 / RelWithDebInfo: 301 of 303 pass. One of the two that fail is real and repeatable here:

d3d12_execute_indirect_validation: 49 parity cases, 44 agree, 5 disagree with both live WARP and live hardware D3D12 on the same machine — the layer's Close() accepts a call the host rejects:

FAIL arg_offset=260 >width (max=0 no-op):                    layer=0 warp=1 hw=1 expected=0
FAIL arg_offset=U64MAX-3 aligned (max=0 no-op):              layer=0 warp=1 hw=1 expected=0
FAIL draw stride=20 off=240 max=1 (240+20>256):              layer=0 warp=1 hw=1 expected=0
FAIL draw stride=20 off=220 max=2 (220+40>256):              layer=0 warp=1 hw=1 expected=0
FAIL dispatch stride=20 off=244 max=1 (244+20>256):          layer=0 warp=1 hw=1 expected=0

layer=0 is S_OK; warp=1 and hw=1 are E_INVALIDARG measured on this GPU, which is the same model the table's expected_ok column was calibrated on. The rest of the table (alignment, count-buffer width, arg_offset=U64MAX unaligned, the OOB max=2 count-buffer rows) matches exactly, and the positive GPU dispatch runs with 0 validation errors.

Two shapes, both argument-buffer bounds:

  1. MaxCommandCount == 0: runtime/src/command_list.h:876 returns !closed_ before any range check ("the PC runtime takes MaxCommandCount 0 as a no-op"), so argument_offset 260 in a 256-byte buffer and U64MAX-3 are accepted. The host still validates the offset when no command will run.
  2. A span that starts inside the buffer and ends past it: 240 + 20, 220 + 2*20, 244 + 20 in 256 bytes. The check in runtime/shims/d3d12_com.cpp:847-848 looks right on paper (offset > width || max > (width - offset) / stride), so either this path is not the one the test drives or the width it reads is not the resource's.

Repro, no game files:

cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build runtime/build --target d3d12_execute_indirect_validation_test
runtime\build\d3d12_execute_indirect_validation_test.exe

The other failure in the same run, d3d12_present, is not a layer defect here: this box has no active monitor right now, so the test's GetPixel on the screen DC reads 0,0,0 at the window centre while its four captured presented images hold the right colours (255,0,0 and 51,153,229, one colour per frame). That check should probably be skipped when no display is attached, but the presented images prove the swapchain path.

Originally created by @dcastell1 on GitHub (Nov 24, 2026). Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/504 On `main@8f481cf16`, `ctest -j 8` on **Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24)**, MSVC 14.44.35207 / RelWithDebInfo: **301 of 303 pass**. One of the two that fail is real and repeatable here: `d3d12_execute_indirect_validation`: 49 parity cases, 44 agree, **5 disagree with both live WARP and live hardware D3D12 on the same machine** — the layer's `Close()` accepts a call the host rejects: ``` FAIL arg_offset=260 >width (max=0 no-op): layer=0 warp=1 hw=1 expected=0 FAIL arg_offset=U64MAX-3 aligned (max=0 no-op): layer=0 warp=1 hw=1 expected=0 FAIL draw stride=20 off=240 max=1 (240+20>256): layer=0 warp=1 hw=1 expected=0 FAIL draw stride=20 off=220 max=2 (220+40>256): layer=0 warp=1 hw=1 expected=0 FAIL dispatch stride=20 off=244 max=1 (244+20>256): layer=0 warp=1 hw=1 expected=0 ``` `layer=0` is `S_OK`; `warp=1` and `hw=1` are `E_INVALIDARG` measured on this GPU, which is the same model the table's `expected_ok` column was calibrated on. The rest of the table (alignment, count-buffer width, `arg_offset=U64MAX` unaligned, the OOB `max=2` count-buffer rows) matches exactly, and the positive GPU dispatch runs with 0 validation errors. Two shapes, both argument-buffer bounds: 1. **`MaxCommandCount == 0`**: `runtime/src/command_list.h:876` returns `!closed_` before any range check ("the PC runtime takes MaxCommandCount 0 as a no-op"), so `argument_offset` 260 in a 256-byte buffer and `U64MAX-3` are accepted. The host still validates the offset when no command will run. 2. **A span that starts inside the buffer and ends past it**: `240 + 20`, `220 + 2*20`, `244 + 20` in 256 bytes. The check in `runtime/shims/d3d12_com.cpp:847-848` looks right on paper (`offset > width || max > (width - offset) / stride`), so either this path is not the one the test drives or the width it reads is not the resource's. Repro, no game files: ``` cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build runtime/build --target d3d12_execute_indirect_validation_test runtime\build\d3d12_execute_indirect_validation_test.exe ``` The other failure in the same run, `d3d12_present`, is **not** a layer defect here: this box has no active monitor right now, so the test's `GetPixel` on the screen DC reads `0,0,0` at the window centre while its four captured presented images hold the right colours (`255,0,0` and `51,153,229`, one colour per frame). That check should probably be skipped when no display is attached, but the presented images prove the swapchain path.
4ld0 closed this issue 2026-11-26 20:13:58 +01:00
Author
Owner

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

I reproduced the same five rows on current main c023a365 with live WARP and RTX 5070 Ti. The numeric columns come from SUCCEEDED(hr), so layer=0 means the layer rejected the call, while warp=1 and hw=1 mean the host accepted it. The full table on this machine showed 0x80070057 in the layer column and S_OK in both host columns for all five. The layer and both hosts agreed on all 51 cases with #337 applied, including the two new cases that overrun the argument buffer. Windows test results

<!-- gh-comment-id:7124171135 --> @sodove commented on GitHub (Nov 24, 2026): I reproduced the same five rows on current main c023a365 with live WARP and RTX 5070 Ti. The numeric columns come from SUCCEEDED(hr), so layer=0 means the layer rejected the call, while warp=1 and hw=1 mean the host accepted it. The full table on this machine showed 0x80070057 in the layer column and S_OK in both host columns for all five. The layer and both hosts agreed on all 51 cases with #337 applied, including the two new cases that overrun the argument buffer. [Windows test results](https://github.com/ubiquitarianism/leonida/pull/337#issuecomment-7124165037)
Author
Owner

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

Correction, and thanks @sodove — I read the two numeric columns backwards in the first post.

The layer column is the layer's own Close() HRESULT, so in these five rows it is the 0x80070057, and it is WARP and the hardware that return S_OK. The layer is stricter than the host here, not more permissive:

arg_offset=260 >width (max=0 no-op)      | 0x80070057 | S_OK | S_OK
draw stride=20 off=240 max=1 (240+20>256)| 0x80070057 | S_OK | S_OK

Why the host accepts in each shape, as the other rows of the same table show:

  • MaxCommandCount == 0: nothing runs, so the host never looks at the argument buffer (with max=1 the same offset is refused by both hosts). The layer still applies its offset > width rule, which is where the two rows come from.
  • A span that ends past the buffer: the host needs (max-1)*stride + record_size, not max*stride — a 16-byte DRAW_ARGUMENTS at offset 240 in a 256-byte buffer fits (240+16 = 256), and the 20-byte stride only matters for a second command. The layer's max > (width - offset) / stride rejects the three stride rows for that reason.

So the actionable part is a false rejection, and it matches what you report with #337 making all 51 rows agree. Everything else in the original post (the other 44 rows agreeing, the positive GPU dispatch, d3d12_present being the headless environment rather than the layer) stands.

<!-- gh-comment-id:7125178549 --> @dcastell1 commented on GitHub (Nov 24, 2026): Correction, and thanks @sodove — I read the two numeric columns backwards in the first post. The `layer` column is the layer's own `Close()` HRESULT, so in these five rows it is the **0x80070057**, and it is WARP and the hardware that return `S_OK`. The layer is **stricter than the host** here, not more permissive: ``` arg_offset=260 >width (max=0 no-op) | 0x80070057 | S_OK | S_OK draw stride=20 off=240 max=1 (240+20>256)| 0x80070057 | S_OK | S_OK ``` Why the host accepts in each shape, as the other rows of the same table show: - **`MaxCommandCount == 0`**: nothing runs, so the host never looks at the argument buffer (with `max=1` the same offset is refused by both hosts). The layer still applies its `offset > width` rule, which is where the two rows come from. - **A span that ends past the buffer**: the host needs `(max-1)*stride + record_size`, not `max*stride` — a 16-byte `DRAW_ARGUMENTS` at offset 240 in a 256-byte buffer fits (240+16 = 256), and the 20-byte stride only matters for a second command. The layer's `max > (width - offset) / stride` rejects the three stride rows for that reason. So the actionable part is a false rejection, and it matches what you report with **#337** making all 51 rows agree. Everything else in the original post (the other 44 rows agreeing, the positive GPU dispatch, `d3d12_present` being the headless environment rather than the layer) stands.
Author
Owner

@quartz-heron-58 commented on GitHub (Nov 24, 2026):

Same five rows on main d42773d0 with live WARP and an NVIDIA GeForce RTX 4080 (driver 621.24), Windows 11 Home build 26300, MSVC 14.44 / RelWithDebInfo. ctest -j 4: 302 of 303 pass, and d3d12_execute_indirect_validation is the one that fails (49 parity cases, 5 failures, positive GPU dispatch ok, 0 validation errors).

The table agrees with the corrected reading above: the layer returns 0x80070057 and both hosts return S_OK for arg_offset=260 >width (max=0 no-op), arg_offset=U64MAX-3 aligned (max=0 no-op), draw stride=20 off=240 max=1, draw stride=20 off=220 max=2 and dispatch stride=20 off=244 max=1. The max=1 variants of the first two are refused by the layer and by both hosts here as well.

Not tested with #337 applied. AI-assisted (Claude Code ran the tests and wrote this comment).

<!-- gh-comment-id:7125311705 --> @quartz-heron-58 commented on GitHub (Nov 24, 2026): Same five rows on main d42773d0 with live WARP and an NVIDIA GeForce RTX 4080 (driver 621.24), Windows 11 Home build 26300, MSVC 14.44 / RelWithDebInfo. `ctest -j 4`: 302 of 303 pass, and `d3d12_execute_indirect_validation` is the one that fails (49 parity cases, 5 failures, positive GPU dispatch ok, 0 validation errors). The table agrees with the corrected reading above: the layer returns 0x80070057 and both hosts return S_OK for `arg_offset=260 >width (max=0 no-op)`, `arg_offset=U64MAX-3 aligned (max=0 no-op)`, `draw stride=20 off=240 max=1`, `draw stride=20 off=220 max=2` and `dispatch stride=20 off=244 max=1`. The `max=1` variants of the first two are refused by the layer and by both hosts here as well. Not tested with #337 applied. AI-assisted (Claude Code ran the tests and wrote this comment).
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#10
No description provided.