Skip to content

test: a raw view is read by a shader, which is what says it names its buffer - #2975

Open
fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:descriptor-view-test
Open

fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:descriptor-view-test

Conversation

@fiestorra

@fiestorra fiestorra commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Correction (2026-12-01, after #2995): this test fails on the AMD iGPU, not on an RTX 4090. Every device test in this crate made its device with D3D12CreateDevice(None, ..), which on a machine with an integrated chip is the chip; with the tests on the card (#2995) this one passes on the 4090 and the whole suite is 644 passed / 0 failed. So the byte comparison is not known to be wrong on any NVIDIA card - what is measured is that it disagrees on an AMD iGPU, and that the functional test below passes on both. The functional test is still worth having; the story that motivated it is not what its numbers say.
test: a raw view is read by a shader, which is what says it names its buffer

descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in
fails on this machine (RTX 4090, driver 621.24) on main, and it is the only
thing that fails in the crate's 86 descriptor tests here. The natural reading
is that raw_at copies the wrong descriptor into the slot.

This test asks the question the other way round: it takes the view raw_at
makes, moves it into a shader-visible heap as it is, binds it, and has a
compute shader read the buffer through it. If the view did not name its
buffer, the shader would read something else.

It passes here. So the view is right and the bytes of a descriptor slot are
not the thing to compare: the driver does not put D3D12's documented layout
there - the first two dwords are not the resource's address, in either the
mode where a view is made in the slot or the one where it is made beside and
copied in - and two slots for the same view need not hold the same bytes.

What that means for the test above is left alone here, on purpose: it is
someone's invariant on other drivers and turning it off is a decision with
evidence from more than one card. This adds the check that can be trusted in
its place.

Measured on main 1fff691 with this change:

cargo test -p leonida-gpu --lib -- --test-threads=1 descriptor::
86 passed, 1 failed (that one), 5 ignored
cargo clippy -p leonida-gpu --all-targets 0 warnings

Not checked: a card that is not this one, and WARP - the test returns early
where there is no host GPU.

Written with an AI assistant.

… buffer

`descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in`
fails on this machine (RTX 4090, driver 621.24) on `main`, and it is the only
thing that fails in the crate's 86 descriptor tests here. The natural reading
is that `raw_at` copies the wrong descriptor into the slot.

This test asks the question the other way round: it takes the view `raw_at`
makes, moves it into a shader-visible heap as it is, binds it, and has a
compute shader read the buffer through it. If the view did not name its
buffer, the shader would read something else.

It passes here. So the view is right and the bytes of a descriptor slot are
not the thing to compare: the driver does not put D3D12's documented layout
there - the first two dwords are not the resource's address, in either the
mode where a view is made in the slot or the one where it is made beside and
copied in - and two slots for the same view need not hold the same bytes.

What that means for the test above is left alone here, on purpose: it is
someone's invariant on other drivers and turning it off is a decision with
evidence from more than one card. This adds the check that can be trusted in
its place.

Measured on main 1fff691 with this change:

  cargo test -p leonida-gpu --lib -- --test-threads=1 descriptor::
      86 passed, 1 failed (that one), 5 ignored
  cargo clippy -p leonida-gpu --all-targets            0 warnings

Not checked: a card that is not this one, and WARP - the test returns early
where there is no host GPU.

Written with an AI assistant.
@andrew-ai

Copy link
Copy Markdown

Verified the shader readback at 74512d6 on native Windows with both an RTX 5070 (616.92) and Microsoft WARP. I extended the synthetic source buffer to two consecutive 256-byte ranges. The shader, dispatch, destination and descriptor-copy path stayed the same; only the source view's byte offset changed between runs.

Source offset Expected 64-word readback RTX 5070 WARP
0 bytes 0x10000000 through 0x1000003f All matched All matched
256 bytes 0x10000040 through 0x1000007f All matched All matched

Each run identified the selected adapter by device LUID and checked every word after dispatch. This confirms the new test observes the buffer range selected by raw_at on both adapters. On this 5070 the previous descriptor-byte comparison also passed, as reported in #2570. Codex-assisted.

@merzleckeier

Copy link
Copy Markdown
Contributor

The shader readback isolates a descriptor-buffer-dependent failure on RADV.

I tested 74512d6583ccc4bbadbe38c5ab8e606a72039a16 together with #2981 on main c4ca5761. The D3D12 trees match after merging current main 1abef08d, and the tested descriptor module is identical with #2975 alone. Wine 11.22 / VKD3D-Proton 3.1.0, RTX 4070 SUPER (620.73.4) and AMD Raphael (RADV 26.3.1).

Device and extension configuration In-place and staged raw_at
RTX, default Stock test and full readback passed in both modes
RADV, default Both tests got zero for word 0 instead of 0x10000000 in both modes
RADV, disable only VK_EXT_descriptor_buffer Both tests passed in both modes
RADV, disable descriptor buffer and descriptor heap Both tests passed in both modes

All rows used the same binary. A fresh isolated run of the stock shader reproduced failure at default, failure with only VK_EXT_descriptor_heap disabled, and success with only VK_EXT_descriptor_buffer disabled. The older copied as it was made byte comparison still failed on RADV with descriptor buffer disabled and the shader readback working. It also failed on NVIDIA despite working readback.

The full readback compares all 64 words at offsets 0 and 256, plus a 128-byte view at offset 256 whose last 32 reads must be zero. The test still includes the copy to the shader-visible heap, so the extension result locates a configuration dependency without distinguishing every step in the descriptor path. AI-assisted, independently checked against the raw results.

@merzleckeier

Copy link
Copy Markdown
Contributor

CORRECTION to my earlier descriptor-buffer report.

The stock test and my earlier fixture both pass heap.cpu(index) from HostHeap::new as the source of a final CopyDescriptorsSimple. The heap is created with D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE. A CPU handle still belongs to that heap. D3D12 requires the source to be in a non-shader-visible heap. The zero reads in my earlier report describe this unsupported final copy. Microsoft API contract.

I reran 74512d6583ccc4bbadbe38c5ab8e606a72039a16 on main 1abef08d with #2962, using the same descriptor module as #2975 alone. Wine 11.22 / VKD3D-Proton 3.1.0, RTX 4070 SUPER (620.73.4) and AMD Raphael (RADV 26.3.1).

  • Binding the production raw_at view directly in its existing HostHeap passed on both GPUs with LEONIDA_VIEW_COPY=0 and 1. The fixture reserved two consecutive slots and wrote the output UAV in the second.
  • Creating the same raw SRV in a heap asserted to have D3D12_DESCRIPTOR_HEAP_FLAG_NONE and copying it into the visible heap also passed on both GPUs. Direct creation in the visible slot passed as well.
  • The production staged path and independent CPU-only copy each passed three fresh default RADV runs with descriptor buffer enabled, and a further run with it disabled.

All 14 valid runs matched all 192 checked words per run, including zeroes outside the shorter view. Binding the existing HostHeap directly makes the test exercise raw_at and its normal staging path without the unsupported extra copy. AI-assisted, independently verified against the raw results.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Thanks - RTX 5070 and WARP both reading all 64 words at both offsets is more than I could run here, and it is the negative control the test needed: a view that names its buffer reads it, on hardware and on the software adapter.

AI-assisted: yes - DeepSeek v4.1 (flash).

Written with an AI assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants