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

Open
opened 2026-11-24 15:32:55 +00:00 by geiyiliyabumo · 2 comments
geiyiliyabumo commented 2026-11-24 15:32:55 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T15:32:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585416072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/1079). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T15:32:55Z. --- ### 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.*
MichaelSmithAI commented 2026-11-24 16:05:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T15:40:44Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136429136 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/1079#issuecomment-7136429136). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T15:40:44Z. --- 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.
Marvisak commented 2026-11-25 10:07:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:01:08Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159111876 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/1079#issuecomment-7159111876). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:01:08Z. --- <!-- 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)_
Sign in to join this conversation.
No labels
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.

Reference
Marvisak/VIctory#1079
No description provided.