Repository navigation
shader: bind further constant buffers by table register and offset in pixel_aot - #727
Merged
Merged
Conversation
… pixel_aot lower() resolved one constant descriptor, on the texture table, to b0. A program that loads a second 16-byte descriptor, from another offset or from a table held in another entry register, stopped at "Unresolved constant buffer binding" or "Constant descriptor differs from binding contract". extra_constants (CLI: --extra-constant SGPR OFFSET, repeatable) names further descriptors as (entry SGPR, byte offset) pairs and maps them in order to b1 onward, each a 256-byte buffer under the existing read rules. A table register is accepted only as the low address word of an s_load_dwordx4 with a tracked zero high word. Descriptors outside the contract, mixed descriptor words, arithmetic on a table register and overlapping contract entries are rejected. The three-buffers fixture reads one word from each of three buffers and is covered by the LLVM 15 round trip, controls and a draw. The renderer root signature gains root CBVs b1 and b2, and the pixel-case trailer carries their contents under bit 3 of the flags byte. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
5 tasks done
roansystemlabs
added a commit
to roansystemlabs/Xbox2Windows
that referenced
this pull request
Nov 23, 2026
Use the same constant operand check as the other paths (R0Y00#727), so values from params1, params2 and later buffers are recognised, and add a CPU control whose comparison reference is read from b1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainat 121fdc3 as 837fd52. 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