shader: bind further constant buffers by table register and offset in pixel_aot #721
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/727"
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 R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-22T23:21:16Z.
Change
pixel_aot.lower()resolves one constant descriptor, on the texture table, tob0. A pixel program that loads a second 16-byte descriptor stops there: atUnresolved constant buffer bindingwhen the table address comes from another entry register, or atConstant descriptor differs from binding contractwhen it is another offset of the same table. In the fixed-profile rescan this is the largest first rejection of the first general profile (4,411 PS records in my local input at4c3b573, counts below).This PR adds an explicit contract for further constant buffers:
lower(..., extra_constants=[(sgpr, offset), ...]), and--extra-constant SGPR OFFSET(repeatable) on the command line.b1,b2and onward, eachcbuffer ConstantsN : register(bN) { float4 paramsN[16]; }, read under the existings_buffer_load_dword,dwordx2anddwordx4rules (dword-aligned immediate offsets inside 256 bytes).constant_descriptorkeeps its meaning and itsb0mapping, and may be omitted.Still rejected, each with a diagnostic:
Constant descriptor differs from binding contract);Unresolved constant buffer binding);Expected a numeric scalar register);Not done on purpose: no audit profile uses the new contract, and nothing is inferred. Which descriptors a title uses as constant buffers, their sizes and their original HLSL registers are not known from the shader bytes, so the caller supplies the contract and the translator only verifies each load against it. Descriptors that feed vector
buffer_load_*are the subject of #319 and ofdocs/pixel_mubuf_contract.md, and stay rejected here.Nine existing checks tested for the prefix
"params["to recognise a constant-buffer value. They now test"params", so thatparams1[...]and later arrays are recognised the same way. No other tracked value starts with that prefix.Test harness: the
offscreen_checkpixel root signature gains root CBVsb1andb2, set only for a case that supplies them. The pixel-case trailer carries their contents under bit 3 of the flags byte (512 bytes after the flags byte and any viewport). I used bit 3 because #694 uses bit 2 for its title memory.Verification
Update before opening: rebased onto
mainat121fdc3as837fd52. On that commit I reran the LLVM 15 round trip,tests/form_coverage_check.pyand the fullpixel_aot_check.py drawrun on WARP (all pass); the hardware and ctest results below are from the commit named there.Environment: Windows 10 Pro build 19045, Python 3.13, LLVM 15.0.7, DXC from Windows SDK 10.0.26100.0, D3D12 debug layer enabled. Commit
9b2b8c1on45559f9. Adapters: WARP (Microsoft Basic Render Driver) 10.0.19041.5794 and NVIDIA GeForce RTX 3060, driver 32.0.15.9636.python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>python -B tests/pixel_aot_check.py draw <dxc> <offscreen_check> warppython -B tests/pixel_aot_check.py draw <dxc> <offscreen_check> hardwarescalarfixture, see belowcheck_three_buffer_drawrun on its own,warpandhardwarepython -B tests/form_coverage_check.pyAGENTS.mdctest --preset dev -R 'pixel|bc7|coverage|offscreen|mesh_pixel|mesh_textured|mesh_attribute|mesh_depth|compute_to_pixel|compute_mesh' -j 4(run one rebase earlier, on787ace7; the later commits onmaindo not touch the renderer)Hardware run: the full
draw ... hardwarerun stops at apixel_mismatchin the existingscalarfixture (channel 0,expected_bits=3fa0c000 actual_bits=3fa04000). Unmodifiedmainstops at the same fixture with the same bits on this adapter, so I am not counting the hardware run as a pass and it is not caused by this PR. The same mismatch is the one ctest failure,pixel_aot_blend_scalar_hardware, which also fails on unmodifiedb03f754here. The new draw passes on this adapter when run on its own.pixel_aot_hardwareand the other ninepixel_aot_*_hardwaretests passed.Capability skips (not passes):
mesh_pixel_pipeline_warp,mesh_attribute_draw_warp,mesh_textured_draw_warp,compute_mesh_texture_warp,mesh_depth_pair_warp.Because the root signature changed for every pixel draw, the ctest row above covers the other users of the renderer (
bc7_draw, attribute, coverage,pixel_cb_read, compute to pixel) on both adapters.Evidence and follow-up
Fixture:
with_three_constant_buffers()intests/pixel_aot_check.py, written for this PR (MIT), built from the existing source fixture. It loads theb0descriptor and a second descriptor from the texture table and a third from the table at entry s9, reads word 2 of each buffer and exports one buffer per channel. Every other word of the three buffers holds a sentinel. It is in the LLVM 15 round trip list.Draw and negative controls: two constant sets match all four channels of 4,096 pixels per draw. A reference with
b1andb2exchanged, a reference that readsb0in place ofb1, and a translation with the two contract entries exchanged each report a mismatch on both adapters. A case file with a truncated pair of extra buffers is refused as a case-format error.check_three_constant_buffers()holds 31 rejection controls, 30 of them tied to their diagnostic text, beside the accepted variants.Aggregate observation from one local input (counts only, 12,101 PS records; a local script outside the repository traced scalar moves and loads in linear order and then asked
lower()to verify):4c3b573s_buffer_load_*With every traced entry-table descriptor bound through
extra_constants:s_buffer_load_*reads (candidate vector buffer, #319)The 3,461 that get further without completing next stop at: a read of an unbound entry SGPR (1,553), a
v_mov_b32whose source is not a tracked numeric value (692), an unbound pixel input atv_cvt_u32_f32_e32(624),v_interp_p1_f32_e32outside the accepted contexts (162), a register-offsets_buffer_load_dword(97), an unbound texture descriptor offset (96), and smaller groups.What this does and does not show: the fixture verifies the lowering of the contract. The counts say how far lowering proceeds under explicit bindings; they do not establish what a title binds to any slot. The trace is linear and 4,250 of these programs branch, so the trace only proposes bindings and
lower()rejects anything it cannot verify.tools/shader_profile_audit.pyis unchanged, and its output on this input is byte-identical before and after this PR (853 PS accepted: 339 general, 354 depth, 124 coverage, 36 attribute). The two records that complete do so with a single descriptor at an offset the fixed profiles do not try; adding that profile is a separate audit change.Follow-up another contributor can pick up: the unbound entry SGPR reads (1,553 here) are the next largest stop and need entry-layout evidence, not a translator change. Reads beyond byte 256 need a decision on the bound buffer size.
Overlap with open PRs (same lines, textual conflicts only): #694 changes the
lower()signature line, thewrite_casesignature, and the trailer flag mask intests/pixel_aot_render.cpp, and takes flag bit 2. #429 and #398 changewrite_caseand the flag mask. #718 adds one more"params["prefix test, which would need the same one-word edit after this lands. #651 touches other regions oflower(). No open PR or issue claims constant-buffer binding inpixel_aot; #319 covers vector loads.docs/experiments.mddocuments the contract, the fixture, the trailer bit and the counts. No README row changes: the pixel shader row and its command are the same.AI-assisted (Claude). I ran every command above locally and read the results.
🤖 Generated with Claude Code