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

Closed
tedin7 wants to merge 1 commit from upstream-pr/1973 into main
tedin7 commented 2026-11-24 22:21:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:21:12Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592572680 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1973). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T22:21:12Z. --- 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.
upstream-sync closed this pull request 2026-11-24 23:03:21 +00:00
ChazY11 commented 2026-11-24 23:03:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:31:20Z.


#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

  • AI-assisted review, posted on both #1965 and #1973 so the two authors see the same evidence.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146329240 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1973#issuecomment-7146329240). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:31:20Z. --- ## #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: ```text 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: ```text 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: ```powershell 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: ```python re.compile(r"buffer_load_format_(?:x|xy|xyz|xyzw) requires descriptor FORMAT and DST_SEL\Z") ``` Checked against both texts: ```text 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 - AI-assisted review, posted on both #1965 and #1973 so the two authors see the same evidence.
chatgpt-codex-connector[bot commented 2026-11-24 23:03:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:29:42Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146297259 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1973#issuecomment-7146297259). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:29:42Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"e600cdd5c23c971763337e043dadda0b3347f9d7","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T22:31:42.622853Z">2026-11-24T22:31:42.622853Z</relative-time> | `e600cdd` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). 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. </details> </details>
ChazY11 commented 2026-11-24 23:03:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:34:12Z.


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 #1965's text here (and delete the older guard at 590 in a later cleanup), or re-point #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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146387727 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1973#issuecomment-7146387727). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:34:12Z. --- ## 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): ```powershell 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: ```powershell 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: ```text 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 ```text 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 #1965's text here (and delete the older guard at 590 in a later cleanup), or re-point #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 commented 2026-11-24 23:03:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T22:44:24Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146587871 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1973#issuecomment-7146587871). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T22:44:24Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1966
No description provided.