Repository navigation
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).
- Detecting 32-bit unsigned wrap on
imm + soffsetand per-dwordstart + 4 * kand selecting0cleanly prevents wrapped scalar buffer load offsets from reading back into the start of the buffer. cargo test -p victory-shader --lib emit::stride_tests::a_scalar_buffer_loads_offset_sum_does_not_wrap_in_32_bits -- --test-threads=1: passed on RTX 5090 andVICTORY_WARP=1.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
LGTM — guarding 32-bit unsigned carry on imm + soffset and per-dword start + 4 * k separately from built_offset's base/extra cleanly prevents wrapped s_buffer_load_dword* offsets from reading back into low dwords across CODE, raw_view, and CBV paths while leaving s_load_dword* untouched.
Verified
crates/victory-shader/src/emit/lower.rssize: 521,627 bytes (under the 524,288-byte limit).cargo run --locked -p xtask -- policy:191 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--all-features): clean.rustfmt --edition 2024: clean on all PR-touched hunks inlower.rsandstride_tests.rs.VICTORY_WARP=0(RTX 5090):emit::stride_tests7 passed, 2 failed (only the two pre-existing#1835a_heap_buffer_read_*failures;a_scalar_buffer_loads_offset_sum_does_not_wrap_in_32_bitspasses).VICTORY_WARP=1:emit::stride_tests9 passed, 0 failed;emit::lower33 passed, 0 failed.
Non-blocking notes
- Pre-existing host-address edge cases: if a built descriptor adds nonzero
base/extra(base = 16, imm = 0, soffset = 0xffff_fffc),imm + soffsetdoes not carry whilebase + sumstill wraps in 32 bits; onNULLsoffset,overstaysNone(lower.rs:4153) and the constant CBV path'sbase + 4 * k(lower.rs:4248) can still wrap/overflow on0xffff_fffc. - On
srv || root_uav,raw_view(lower.rs:4212) runs withactive = Nonebeforeguardselects0, so a carry-zeroed title-memory load can still record a page-miss mark if the wrapped offset hits an unmapped page. a_scalar_buffer_loads_offset_sum_does_not_wrap_in_32_bitschecks zero outputs on a zero-initialized UAV over theraw_viewpath; adding an in-range store as a positive control (and note the sharedLower::smemoverlap with #3351) is nice to keep in mind.
|
AMD check at
Synthetic shaders only, no game files. AI-assisted. |
|
I tested both scalar-load changes in one shader, with the same synthetic program on Windows D3D12 using an RTX 4090 Laptop and Microsoft WARP. The fixture pre-fills the output UAV with
Both adapters gave the same rows. Removing one zero-result store left its word at Integration diff and portable fixture. Run AI-assisted with Codex. |
Scalar
s_buffer_load*does not wrap(imm + soffset)or per-dwordstart + 4*kin 32 bits: an unsigned carry means the access passed2^32bytes (beyond any 32-bitNUM_RECORDSbound), so RDNA2 hardware (gfx1036, wave32 = wave64, measured withsOFF = 0xfffffffc, IMM = 8andsOFF = 0xfffffff0, IMM = 0x20returning0inzDiazG/Leonida) treats it as out of bounds and returns0rather than wrapping back to low dwords.This directly resolves the 32-bit wrap question raised on #1393.
Changes
crates/victory-shader/src/emit/lower.rs(Lower::smem,521,627bytes /+1,064vsmain,2,661bytes below the524,288limit):imm + soffset(pred::IULT(sum, imm)) separately from the descriptorbaseoffset and track per-dword carry onstart + 4 * k(k > 0) inside a sharedguardclosure across all threeLower::smempaths (CODE,raw_view, andCBV), selecting0when either addition overflows 32 bits.Lower::smemalongside Shaders: truncate s_buffer_load terms to dword alignment independently #1939 and Shaders: scalar code-table buffer loads keep NUM_RECORDS #3351 — happy to rebase once either lands.crates/victory-shader/src/emit/stride_tests.rs:a_scalar_buffer_loads_offset_sum_does_not_wrap_in_32_bitscoverings_buffer_load_dwordats5 = 0xffff_fffc, offset:0x8(wraps to+4without the fix) ands_buffer_load_dwordx2ats5 = 0xffff_fffc, offset:0x0(second dword wraps to+0without the fix).Verification
main): https://github.com/Moon0755/VIctory/actions/runs/45887853618 (failure— 302 passed, 1 failed solely ona_scalar_buffer_loads_offset_sum_does_not_wrap_in_32_bits, reading[8×32, 0×32, 7×32]instead of0)ae3e603): https://github.com/Moon0755/VIctory/actions/runs/45892937466 (success— 303 passed / 0 failed, Clippy + diagnostics Clippy clean,policy::tests::repository_passes_policy ... ok)WARP,AMD Radeon(TM) Graphics, andNVIDIA GeForce RTX 2060 with Max-Q Design— all fail without the fix and pass onae3e603.— Devin & Neon