Game: guarantee 8-byte alignment for pipeline stream subobjects and input elements #2531
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2533"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:23:44Z.
Problem
victory_game::pipelines::Streambacked its D3D12 pipeline state subobject stream withVec<u8>and itsD3D12_INPUT_ELEMENT_DESCarray withVec<[u8; 32]>. Both types have alignment 1, whereas D3D12 requires 8-byte alignment for subobject streams and input element descriptors, andvictory-gpu/src/pipeline.rscasts stream offsets directly to&Bytecode(alignment 8).Fix
#[repr(C, align(8))] struct AlignedBytes<const N: usize>([u8; N])and storebytes: Box<AlignedBytes<0x2b0>>and_elements: Vec<AlignedBytes<32>>inStream.Testing
a_record_becomes_the_engines_creation_stream(crates/victory-game/src/pipelines.rs).cargo test -p victory-game --lockedand Windows cross-clippy (-D warnings).Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:53:56Z.
Automated triage for the maintainers.
Recommended for a look.
pipelines::stream(crates/victory-game/src/pipelines.rs) now stores the 0x2b0-byte creation stream and the input element array in an 8-byte-aligned wrapper instead ofVec<u8>/Vec<[u8; 32]>. I checked the consumer: apps/victory/src/prebuild.rs handsstream.bytes()to victory-gpu, whose pipeline.rs takes&*ptr.cast::<Bytecode>()at stream offsets, so the alignment was only guaranteed by the allocator in practice, not by the types; the change is mechanical otherwise. CI (clippy + tests on Windows): passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:37:34Z.
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
41ab323(on its base940d32f).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 696 passed, 0 failed, 10 ignored.#[test]functions in the diff.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:26:53Z.
Review: COMMENTED
Reviewed and verified against
main(63bcca43) on Windows 11 — real alignment-UB fix and ready to merge:crates/victory-gpu/src/pipeline/host.rs:191-194callsslice::from_raw_parts::<D3D12_INPUT_ELEMENT_DESC>(...)(requires 8-byte alignment) on pointers backed byStream._elements(Vec<[u8; 32]>, align 1) andStream.bytes(Vec<u8>, align 1).#[repr(C, align(8))] struct AlignedBytes<const N: usize>guarantees 8-byte alignment for both without changingStream::bytes().Local verification:
cargo test --locked -p victory-game: 15/15 passedcargo clippy --locked -p victory-game --tests -- -D warnings(default &--all-features) +cargo xtask policy(191 files ok): 0 warningsView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.