Skip to content

feat(rhi): a pipeline that generates its own vertices can cast a shadow - #273

Open
CagdasErturk wants to merge 2 commits into
mainfrom
depth-only-generative
Open

feat(rhi): a pipeline that generates its own vertices can cast a shadow#273
CagdasErturk wants to merge 2 commits into
mainfrom
depth-only-generative

Conversation

@CagdasErturk

Copy link
Copy Markdown
Member

PipelineDesc::depth_only(vertex_spirv, vertex_count) — no per-vertex stream, no fragment stage, no colour attachment.

Until now that shape could not be spelled. The only depth-only constructor hard-sets vertex_input: Some(layout), and the frame contract asserts that an item names geometry exactly when its pipeline declares per-vertex input:

an item names geometry exactly when its pipeline declares per-vertex input — a mesh
pipeline with no mesh reads an unbound binding, and a mesh on a pipeline that generates
its own vertices is ignored

So a pipeline that writes its own vertex list and draws an instance stream could reach a colour target and no depth-only one. A renderer of that shape could be seen and could not cast, which is not a limitation anybody chose.

Two tests, at two distances from the hardware

The unit test pins that the two depth-only shapes differ in exactly one field, and that it is the one Item's rule reads. vertex_input is not a detail of these constructors — it is the whole difference between them, one demanding geometry and one demanding its absence.

The device test builds the pipeline and submits a depth pass whose item names no geometry, with no validation error. It deliberately does not read the depth back, and says so in its doc: the only stage available here writes z = 0.0, which under reversed-Z is the clear value, so a readback cannot separate a draw that happened from one that did not. Claiming otherwise would be a test that looks like it checked something.

Probes

Both watched red and restored. Swapping depth_only for depth_mesh makes the frame contract refuse the item, in the words that made this constructor necessary. Giving depth_only a vertex input makes the unit test name the refusal it would cause.

cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace all green on a real adapter with validation active, exit codes read directly.

`PipelineDesc::depth_only(vertex_spirv, vertex_count)`: no per-vertex
stream, no fragment stage, no colour attachment.

Until now that shape could not be spelled. The only depth-only
constructor hard-sets `vertex_input: Some(layout)`, and the frame
contract asserts that an item names geometry exactly when its pipeline
declares per-vertex input - so a pipeline that writes its own vertex list
and draws an instance stream could reach a colour target and no
depth-only one. A renderer of that shape could be seen and could not
cast, which is not a limitation anybody chose.

`vertex_count` is what the stage generates for one instance, kept for the
same reason `Shaders` bundles it: too low renders part of the geometry
and too high indexes past the end of the stage's own constant array.

Two tests, at two distances from the hardware.

The unit test pins that the two depth-only shapes differ in exactly one
field, and that it is the one `Item`'s rule reads. `vertex_input` is not a
detail of these constructors - it is the whole difference between them,
one demanding geometry and one demanding its absence - so an edit that
made them differ anywhere else is a compile-time-invisible change to what
a caller may pass.

The device test builds the pipeline and submits a depth pass whose item
names no geometry, with no validation error. It deliberately does not
read the depth back, and says so: the only stage available writes z = 0.0,
which under reversed-Z is the clear value, so a readback cannot separate a
draw that happened from one that did not. Claiming otherwise would be a
test that looks like it checked something.

Probed twice, both watched red and restored. Swapping `depth_only` for
`depth_mesh` makes the frame contract refuse the item, in the words that
made this constructor necessary. Giving `depth_only` a vertex input makes
the unit test name the refusal it would cause.

cargo fmt --all --check, cargo clippy --workspace --all-targets
-- -D warnings and cargo test --workspace all green on a real adapter with
validation active, exit codes read directly.
Adding `depth_only` and its doc pushed crates/rhi/src/vk/pipeline.rs down
forty-six lines, so the exemption for the DepthUnsupported
pipeline-creation arm pointed at covered code while the arm itself
pointed at nothing.

Content compared rather than the offset trusted, because the checker
warns that a block which moved and a block which changed look identical
from where it stands: lines 1318-1324 on main and 1364-1370 here are
byte-identical, the same `Some(format) => Some(format), None => return
Err(DepthUnsupported)` match. Re-pinned; the reason is unchanged, since
the arm is still unreachable on every measuring lane's adapter.
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.

1 participant