Skip to content

shader: refuse unsupported DATA_FORMAT on buffer_load_format in gfx2hlsl (Part of #1809) - #1973

Closed
tedin7 wants to merge 1 commit into
R0Y00:mainfrom
tedin7:x2w-frontier-1809-data-format
Closed

tedin7 wants to merge 1 commit into
R0Y00:mainfrom
tedin7:x2w-frontier-1809-data-format

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Part of #1809
Part of #870

What this unblocks: buffer_load_format_{x,xy,xyz,xyzw} is now refused by name with its real reason (descriptor DATA_FORMAT not tracked), so the census group is classified and no wrong typed load can be emitted.

Verification:

  • python3 -B tests/startup_gfx2hlsl_buffer_format_check.py -> PASS (9 checks fail against the previous gfx2hlsl.py, all pass with this change)
  • python3 -B tests/startup_gfx2hlsl_tbuffer_16f_check.py -> PASS (typed tbuffer_load_format_* unchanged)
  • git diff --check -> clean
  • Win2025: ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_buffer_format$' -V -> not run yet, to be run on Win2025 before merge

Scope: this does not lower the loads. buffer_load_format_* has no format field; the format lives in the resource descriptor, and Stage.descriptor() tracks only where descriptor words came from. Guessing a format from the destination width would give silently wrong data. Lowering needs pipeline state that supplies the descriptor words, as described in the issue. The test starts from synthetic encoded MUBUF instructions and pins each width's refusal plus the unchanged buffer_load_dword. docs/experiments.md records the finding.

AI-assisted; commands listed were executed locally.

… is known

The untyped-format MUBUF loads take their element format from the resource
descriptor, which the translator does not track. Refuse each width with that
reason instead of the generic unknown-op message. Part of R0Y00#1809, R0Y00#870.
@tedin7
tedin7 marked this pull request as ready for review November 24, 2026 22:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:31:42.622853Z e600cdd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

#1965 and this PR are green alone and red together — textually clean merge, broken test

Both change the refusal for the same four mnemonics (buffer_load_format_{x,xy,xyz,xyzw}), and both are Part of #1809. I merged
both heads onto current main (889cd3f4) locally:

git merge review-1965   ->  clean
git merge review-1973   ->  clean, no conflict markers

git is happy because the two edits are on different lines — but two refusals now exist for the same instruction:

tools/startup/gfx2hlsl.py:590   raise Unsupported('%s requires descriptor FORMAT and DST_SEL' % base)          # #1965
tools/startup/gfx2hlsl.py:1058  raise Unsupported('buffer_load_format_%s needs the descriptor DATA_FORMAT…')   # this PR

and this PR's dispatch wins, because op_buffer_load_format_x … _xyzw (lines 1052–1070) route to buffer_format_load() before the
older generic path at 590 is reached. Running #1965's own control on the merged tree:

out/pe-env/Scripts/python.exe -B tests/startup_buffer_address_check.py controls
AssertionError: buffer_load_format_x needs the descriptor DATA_FORMAT, which is not tracked
exit 1

This PR's check still passes (startup_gfx2hlsl_buffer_format_check.py → PASS), so whichever lands second decides whether main is
green.

The triage census breaks silently too

#1965 also narrows a classifier in tools/startup/triage_run.py to keep the refusal in the existing group:

re.compile(r"buffer_load_format_(?:x|xy|xyz|xyzw) requires descriptor FORMAT and DST_SEL\Z")

Checked against both texts:

matched=True   buffer_load_format_xyzw requires descriptor FORMAT and DST_SEL
matched=False  buffer_load_format_xyzw needs the descriptor DATA_FORMAT, which is not tracked
matched=False  buffer_load_format_x needs the descriptor DATA_FORMAT, which is not tracked

So after this PR's text takes effect, those four refusals fall out of the buffer_* instruction group and the census counts move
without anyone editing a test.

What I would do

  1. Pick one message — both name the missing field, and the choice is editorial; the shorter one here (needs the descriptor DATA_FORMAT, which is not tracked) also states why it is missing, which is the more useful half.
  2. Whichever survives, the other PR's guard, its control and the triage regex have to move with it in the same change, so no single
    merge leaves main red.
  3. Please run tests/startup_buffer_address_check.py controls and tests/startup_gfx2hlsl_buffer_format_check.py after a
    rebase, not just your own check — that pair is the failing combination.

I am not asking for either PR to be dropped; the point is that the two are one decision, and it is easier to take it now than after
whichever merges first.

Notes

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Update after #1965 merged: this PR now breaks a test on main, by itself

My earlier comment described the conflict when #1965 and this PR landed together. #1965 is now merged, so the conflict is no longer
hypothetical — it is main plus this PR alone.

Verified against main 889cd3f4 (git merge clean, no conflict markers):

git checkout -B only-1973 origin/main && git merge pr-1973

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_buffer_format_check.py     # exit 0  (this PR's own check)
out/pe-env/Scripts/python.exe -B tests/startup_buffer_address_check.py controls    # exit 1  (a check already on main)

AssertionError: buffer_load_format_x needs the descriptor DATA_FORMAT, which is not tracked

Control, same tree without the merge:

git checkout check-main && git reset --hard origin/main
out/pe-env/Scripts/python.exe -B tests/startup_buffer_address_check.py controls    # exit 0

So main is green today and this PR makes it red, while this PR's own check stays green.

Why

Two refusals now exist for the same four mnemonics:

tools/startup/gfx2hlsl.py:590   '%s requires descriptor FORMAT and DST_SEL'          # merged with #1965
tools/startup/gfx2hlsl.py:1058  'buffer_load_format_%s needs the descriptor DATA_FORMAT…'  # this PR

op_buffer_load_format_x … _xyzw (this PR, lines 1052–1070) dispatch to buffer_format_load() before the generic path at 590 is
reached, so this PR's text wins and #1965's assertion fails.

tools/startup/triage_run.py is the second half: the classifier merged with #1965 matches
buffer_load_format_(?:x|xy|xyz|xyzw) requires descriptor FORMAT and DST_SEL\Z, and against these two strings

matched=True   buffer_load_format_xyzw requires descriptor FORMAT and DST_SEL
matched=False  buffer_load_format_xyzw needs the descriptor DATA_FORMAT, which is not tracked

the census group would silently lose all four forms.

What fixes it, smallest first

  1. Either adopt startup: explain formatted MUBUF descriptor refusals #1965's text here (and delete the older guard at 590 in a later cleanup), or re-point startup: explain formatted MUBUF descriptor refusals #1965's assertion and the
    triage regex at this text in this PR. One message, updated in all three places.
  2. Until that happens, this PR cannot merge without turning main red — the assertion in tests/startup_buffer_address_check.py
    is already merged and is the one that fires.

I have also checked the other open gfx2hlsl.py PRs pairwise against main (#1978, #1969, #1952, #1946): all ten pairs and the
five-way merge are green, so this is the only collision in that file right now.

Notes

  • AI-assisted review.

@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks for the source-built controls. #1965 is already on main and covers the same four encoded MUBUF widths, as well as the adjacent raw MUBUF and instruction-formatted MTBUF paths. It preserves the refusal group and names both FORMAT and DST_SEL. As the combined run in this thread shows, the two changes would disagree on the exact refusal and break the fixture. Closing the duplicate implementation. #1809 stays open for real bound-descriptor format and swizzle support.

@R0Y00 R0Y00 closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants