Translation: buffer range checks without a division #66

Manually merged
github merged 1 commit from github-bot/gh-66 into main 2026-11-27 08:00:57 +00:00 AGit
Owner

@⁠guialmm on GitHub · 2026-11-26 22:48 UTC · original
guialmm:fix/buf-limit-no-division → main · +9 −3 · 1 files · 1 commits · merged 2026-11-27 08:00 UTC

Fixes the E_OUTOFMEMORY group from #9 (21 cases on an RTX 3060, driver 32.0.16.1714).

NVIDIA refuses the pipeline when a guarded store depends on 0xffffffff / stride, which buf_limit and sbuf_limit used for the 4 GiB overflow check. buf_index_overflows answers index * stride >= 2^32 without dividing: the stride has 14 bits, so splitting the index at bit 18 keeps both products under 32 bits. I checked it against the division for every stride (0..0x3fff).

Tests: WARP 550 passed, 0 failed. On the 3060 none of the 21 fail anymore; what's left there is the rootdesc variant (next PR) and what #61/#62 fix.

AI-assisted (Claude), reviewed and tested by me.

**@⁠guialmm** on GitHub · 2026-11-26 22:48 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/66) `guialmm:fix/buf-limit-no-division` → `main` · +9 −3 · 1 files · 1 commits · merged 2026-11-27 08:00 UTC Fixes the E_OUTOFMEMORY group from #9 (21 cases on an RTX 3060, driver 32.0.16.1714). NVIDIA refuses the pipeline when a guarded store depends on `0xffffffff / stride`, which `buf_limit` and `sbuf_limit` used for the 4 GiB overflow check. `buf_index_overflows` answers `index * stride >= 2^32` without dividing: the stride has 14 bits, so splitting the index at bit 18 keeps both products under 32 bits. I checked it against the division for every stride (0..0x3fff). Tests: WARP 550 passed, 0 failed. On the 3060 none of the 21 fail anymore; what's left there is the rootdesc variant (next PR) and what #61/#62 fix. AI-assisted (Claude), reviewed and tested by me.
NVIDIA refused the pipelines of 21 shader tests with E_OUTOFMEMORY
(RTX 3060, driver 32.0.16.1714): their guarded stores depend on
0xffffffff / stride in buf_limit and sbuf_limit. buf_index_overflows
answers index * stride >= 2^32 with shifts and two products that stay
under 32 bits (checked against the division for every stride).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:16:26 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-26 23:10 UTC · original

thanks, this is a nice one. went through the math: with the 14-bit stride the hi/lo split gives exactly index * stride >= 2^32 and nothing passes 32 bits, and stride 0 behaves like before, so it's equivalent to the division. ran it here together with #61, #62, #67 and our own pending translator changes: 572 passed / 0 failed on WARP, and the buffer, typed view, wave emulation and user-data tests (50) pass on a 4090 too. it changes translation output so it lands with that batch, should be soon

**@⁠ThatRecompDev** on GitHub · 2026-11-26 23:10 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/66#issuecomment-7205321025) thanks, this is a nice one. went through the math: with the 14-bit stride the hi/lo split gives exactly index * stride >= 2^32 and nothing passes 32 bits, and stride 0 behaves like before, so it's equivalent to the division. ran it here together with #61, #62, #67 and our own pending translator changes: 572 passed / 0 failed on WARP, and the buffer, typed view, wave emulation and user-data tests (50) pass on a 4090 too. it changes translation output so it lands with that batch, should be soon
github manually merged commit 417f8086c0 into main 2026-11-27 08:00:57 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-27 08:01 UTC · original

in main now with the translator batch (976cc3e3). it ran in all of last night's boots on the 4090 without trouble, thanks for this one.

**@⁠ThatRecompDev** on GitHub · 2026-11-27 08:01 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/66#issuecomment-7213055925) in main now with the translator batch (976cc3e3). it ran in all of last night's boots on the 4090 without trouble, thanks for this one.
This discussion has been locked. Commenting is limited to contributors.
No description provided.