GPU: validate input layouts and aligned vertex offsets in pipeline/host.rs with unit tests #1079

Open
opened 2026-11-26 04:19:11 +00:00 by github-bot · 2 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 15:32 UTC · original

Summary

Fixes input-layout validation and appended vertex-offset calculation bugs in crates/victory-gpu/src/pipeline/host.rs (previously 0 unit tests) and adds 14 deterministic synthetic unit tests.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-pipeline-host
  • Commit: geiyiliyabumo/VIctory@649c6e5 (based on main ffe310e)

Changes (crates/victory-gpu/src/pipeline/host.rs)

  • Fixes (5 synthetic regressions proved red before fix):
    • Empty layouts now properly reset state.
    • Rejects element counts > 32, input slots outside 0..=31, null SemanticName, and null/misaligned element arrays with nonzero counts.
    • Appended (D3D12_APPEND_ALIGNED_ELEMENT) vertex offsets now account for per-slot format alignment and reject arithmetic overflow.
  • Tests (+14 synthetic): covers layout ownership, malformed descriptors, offset arithmetic, defaults, format conversion, blend, rasterizer, depth/stencil, and bytecode copying.

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-gpu/src/pipeline/host.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- pipeline::host::: 14 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 15:32 UTC · [original](https://github.com/Marvisak/VIctory/issues/1079) ### Summary Fixes input-layout validation and appended vertex-offset calculation bugs in `crates/victory-gpu/src/pipeline/host.rs` (previously 0 unit tests) and adds 14 deterministic synthetic unit tests. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-pipeline-host` - **Commit**: `geiyiliyabumo/VIctory@649c6e5` (based on `main` `ffe310e`) ### Changes (`crates/victory-gpu/src/pipeline/host.rs`) - **Fixes (5 synthetic regressions proved red before fix)**: - Empty layouts now properly reset state. - Rejects element counts `> 32`, input slots outside `0..=31`, null `SemanticName`, and null/misaligned element arrays with nonzero counts. - Appended (`D3D12_APPEND_ALIGNED_ELEMENT`) vertex offsets now account for per-slot format alignment and reject arithmetic overflow. - **Tests (+14 synthetic)**: covers layout ownership, malformed descriptors, offset arithmetic, defaults, format conversion, blend, rasterizer, depth/stencil, and bytecode copying. ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-gpu/src/pipeline/host.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- pipeline::host::`: **14 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:11 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 15:40 UTC · original

The alignment change fixes an observable attribute value in VIctory’s CPU rectangle expansion, even with a single input slot. We tested an 8-byte vertex with R8_UINT at offset 0 and an appended R32_FLOAT at offset 4. With input floats 1.0, 3.0 and 7.0, the generated fourth vertex contained the expected 5.0. Restoring just the previous offset calculation produced 1.0 with the same input.

All 14 authored tests passed on the gstack integration. The full GPU crate run under Wine had 99 passes, one ignored test and the existing empty-pipeline-library failure. The rectangle control inspected the expanded vertex bytes. Native triangle input assembly resolves append offsets independently, and title use of this CPU expansion layout is still open.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 15:40 UTC · [original](https://github.com/Marvisak/VIctory/issues/1079#issuecomment-7136429136) The alignment change fixes an observable attribute value in VIctory’s CPU rectangle expansion, even with a single input slot. We tested an 8-byte vertex with R8_UINT at offset 0 and an appended R32_FLOAT at offset 4. With input floats 1.0, 3.0 and 7.0, the generated fourth vertex contained the expected 5.0. Restoring just the previous offset calculation produced 1.0 with the same input. All 14 authored tests passed on the gstack integration. The full GPU crate run under Wine had 99 passes, one ignored test and the existing empty-pipeline-library failure. The rectangle control inspected the expanded vertex bytes. Native triangle input assembly resolves append offsets independently, and title use of this CPU expansion layout is still open.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:01 UTC · original

Automated triage for the maintainers.

The appended-offset part is already in main. GraphicsState::elements in crates/victory-gpu/src/pipeline/host.rs now places a D3D12_APPEND_ALIGNED_ELEMENT at the next multiple of min(4, its size) on its input slot. That came from PR #618, merged 2026-11-25, and covers the R8_UINT then R32_FLOAT case tested in the comment.

These parts are not in main:

  • Checks on the title's input layout: more than 32 elements, a slot past 31 (clamped today, not refused), a null semantic name.
  • The 14 tests.

These checks guard against malformed descriptions from the title, not against a failure seen in a run. Open PR #1207, from the same author, adds tests for this file. Please carry the remaining validation there, or in a new pull request (now open to everyone), rebased on #618 so the maintainers can review it.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:01 UTC · [original](https://github.com/Marvisak/VIctory/issues/1079#issuecomment-7159111876) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T15:40:44Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. The appended-offset part is already in `main`. `GraphicsState::elements` in `crates/victory-gpu/src/pipeline/host.rs` now places a `D3D12_APPEND_ALIGNED_ELEMENT` at the next multiple of min(4, its size) on its input slot. That came from PR #618, merged 2026-11-25, and covers the R8_UINT then R32_FLOAT case tested in the comment. These parts are not in `main`: - Checks on the title's input layout: more than 32 elements, a slot past 31 (clamped today, not refused), a null semantic name. - The 14 tests. These checks guard against malformed descriptions from the title, not against a failure seen in a run. Open PR #1207, from the same author, adds tests for this file. Please carry the remaining validation there, or in a new pull request (now open to everyone), rebased on #618 so the maintainers can review it. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#1079
No description provided.