Repository navigation
BUILD-858: Lower dynamic scalar-buffer bounds to word pairs - #2986
kacper-serewis wants to merge 10 commits into
Conversation
…HADER-423) Every PhysicalStorageBuffer address the generator builds is one idiom: widen a dword, shift the high word by 32, OR, add or subtract, AND, narrow or shift right by 32, compare two such values, convert to a pointer. lower_addr64 runs on the assembled module: when a shader's only 64-bit integers are that idiom, each value becomes a (low, high) pair of uints with OpIAddCarry / OpISubBorrow into the high word, compares go high word first, and the pair is a uvec2 bitcast to the pointer (as GL_EXT_buffer_reference_uvec2). The module drops OpCapability Int64, so index.json stops listing shaderInt64 for it; devices with buffer device addresses but no shaderInt64 (Intel) can run those modules. A shader with any other 64-bit integer use keeps Int64. --int64-addresses opts out. spirv_mini_interp learns the uint-pair-to-pointer bitcast. Tests: tests/semantic/test_addr64_lowering.py (both forms read the same word with a plain sum, a low-word carry and a 64-bit wrap; dropping the carry is caught; a 64-bit data op keeps Int64). run_gpu_tests.py: 190 shaders pass spirv-val; RTX 5070 Ti 139/185 native, 170/185 emulated; RDNA2 gfx1036 iGPU 170/185; 0 failures. 103 of the 117 shaders that touch memory no longer declare Int64. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eck it in the interpreter, docs wording - tests/test_translate.py test_cs_store_packed_atomic_pointers pinned the OpConvertUToPtr form of the atomics' array pointer; it is the uvec2 OpBitcast since lower_addr64 (OpConvertUToPtr with --int64-addresses), so it accepts both (reported by @zneel on ItsNotRexed#2463). - spirv_mini_interp's pointer bitcast checks the source's declared type (a 2-component 32-bit integer vector), not only the runtime tuple, so an invalid 64-bit pair cannot pass the test oracle (@richardsenra). - docs/design.md: the contract row describes the idiom the pass handles (narrowing and the logical shift by 32 included) and what keeps Int64 (@richardsenra). pytest tests/test_translate.py: 526 passed, 2 skipped. tests/semantic: 2,573 OK. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s, arithmetic shift by 32) A global_* access with a negative instruction offset sign-extends it through a 64-bit signed integer (OpSConvert %long, OpBitcast %ulong) before the add, and a few paths shift a 64-bit value right arithmetically by 32. The pass now lowers those as well: the sign-extended dword is (value, value >> 31 arithmetic), the shift by 32 is (high, high >> 31), and a bitcast between the 64-bit integer types is the same word pair. The rewrite's 32-bit constants are declared once the body is done (they are made while it is rewritten). Review point from @UNYTIX on ItsNotRexed#2463. tests/semantic/test_addr64_lowering.py: three global_load cases with negative and positive offsets read the same word in both forms, and the lowered module has no Int64 or %long. cs_global_neg_offset now runs without Int64 (RDNA2 gfx1036 iGPU: 170/185, 190/190 spirv-val); 13 of the 117 memory-touching test shaders keep Int64 (was 14). tests/semantic 2,573 OK; pytest tests/test_translate.py 526 passed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
test_buffer_store_format's emission check accepts the uvec2 OpBitcast of the store's address as well as OpConvertUToPtr (--int64-addresses), and test_loop_ballot_barrier's local interpreter turns a (low, high) uint pair bitcast to a PhysicalStorageBuffer pointer into the same "phys" address OpConvertUToPtr gives (its OpBitcast was the identity, so the pair reached OpAccessChain as a list). Both were added to main after this branch's base (reported by @davidesidoti on ItsNotRexed#2463). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Tested 81924a5 (merged on current main) on RTX 3090, driver 616.56, Windows 11 23H2: pass. With this translator change, AI-assisted test run. |
|
Tested
gfx1151 is RDNA 3.5, not RDNA2: this shows the translated SPIR-V gives the modelled words on a real driver, not that RDNA2 hardware does. AI-assisted (Claude Code). |
|
Tested 81924a5 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass. Semantic tests:
Full GPU suite (run from PR worktree against main runtime build):
Note: tested PR head as submitted (PR description lists dependency on #2463). AI-assisted (OpenCode). |
…ion: both PC_TAIL_UBO and ADDR_PAIR)
81924a5 to
72e1d7a
Compare
|
Tested 48281e6 merged onto main aa2988c on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
Depends on: #2463
BUILD-858 · current claim · claim
Head
48281e60integrates official main4c52ce27and published #24633de4f0fb. The published dependency tree matched the previously integrated dependency. The contract retains main’s updated instruction-encoding checks. All eight CPU address-lowering tests and seven printed-encoding tests passed. On NVIDIA GeForce RTX 5070, driver 616.56, all eight synthetic modules passed Vulkan 1.2 spirv-val and returned the expected value in native and lowered forms for raw and strided bounds, including a product above 4 GiB.Earlier validation
Rebased head
72e1d7a1includes mainf847748cand #2463 at6ed0f368. The eight address tests pass. Against the integrated dependency alone, the dynamic-bounds test fails because the module retains Int64. On the RTX 5070 (616.56), four raw/structured boundary cases matched in both native and lowered form, including a product above 2³². All eight synthetic modules passed Vulkan 1.2 spirv-val. Full semantic discovery ran 7,330 tests successfully with one expected failure. Translator pytest reported 562 passed and four skipped.Historical validation at 81924a5 and its predecessors
This branch adds one commit on #2463 at 65e64c2. Dynamic scalar-buffer bounds choose NUM_RECORDS when stride is zero and NUM_RECORDS × stride otherwise. The pass selects both words with the same predicate and uses OpUMulExtended for a multiply of two widened uints. Unsupported producers preserve the entire input module.
On Windows, semantic discovery passed all 2,575 tests. The focused address suite passed all eight, including both selector values, a nonzero high word on either arm and a full-width multiply control. The translator pytest suite passed 526 with two skips. On an RTX 5070, driver 616.56, eight synthetic readbacks matched across native and lowered forms, covering raw and structured bounds on both sides of the limit.
Private integration with #2904 at 5ddfabc, Vulkan SDK 1.4.363.0, five local programs per configuration:
The five soft outputs match the prior address-opt-out binaries byte for byte. Full-width normalized-format multiplication and data-dependent shifts still require Int64. Tracker finding. Retail validation was static. Only synthetic code, tests and contract documentation are included.
AI-assisted with Codex.