tooling: assess mesh lowering in PSO readiness #1097

Merged
tedin7 merged 2 commits from upstream-pr/1104 into main 2026-11-24 01:52:31 +00:00
tedin7 commented 2026-11-24 01:04:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:04:05Z.


Change

Refs #259. Extend pso_readiness.py --llvm to disassemble matched mesh shaders with wave64 byte offsets and run mesh_entry_aot.lower. Report lowering rejection and disassembly failure with stage-specific diagnostics. A passing mesh probe with a present root signature leaves the pipeline in needs_pso_validation. This uses the mesh translator already on main and has no dependency on #1080.

Verification

Linux x64, Python 3.14.8, LLVM 19, commit 065d7662, baseline b9beb159.

Command Result
python3 -B tests/pso_readiness_check.py Passed. One mesh lowering pass, two lowering rejections, two disassembly failures. Also checks no-LLVM evidence, signature status and stage/hash reuse.
build-a-turno python3 -B tests/mesh_entry_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1 Passed.
python3 -B tests/docs_links_check.py Passed, 15 Markdown files and 243 links.
python3 -B tests/bidi_controls_check.py Passed, 922 tracked files.
git diff --check Passed.

Negative control with the new test and the baseline implementation, expected exit 1 and observed exit 1. The triangle reported stage_not_assessed and needs_evidence instead of passing the mesh probe.

git show b9beb159:tools/pso_readiness.py | python3 -B -c 'import runpy, sys, types
sys.path[:0] = ["tools", "tests"]
baseline = types.ModuleType("pso_readiness")
exec(sys.stdin.read(), baseline.__dict__)
sys.modules[baseline.__name__] = baseline
runpy.run_path("tests/pso_readiness_check.py", run_name="__main__")'

The CLI also passed a run with assembled gfx1013 bytes and the real LLVM library. The only pipeline reported mesh_lowering_passed, needs_pso_validation and a null blocker.

build-a-turno python3 -B -c 'import hashlib, json, subprocess, sys
from pathlib import Path
from tempfile import TemporaryDirectory
sys.path.insert(0, "tests")
from mesh_entry_check import binary
with TemporaryDirectory() as tmp:
    root = Path(tmp)
    llvm = "libLLVM.so.19.1"
    binary(root, "llvm-mc-19", "llvm-objcopy-19", llvm)
    digest = hashlib.sha256((root / "fixture.bin").read_bytes()).hexdigest()
    ref = dict(stage="mesh", sha256=digest)
    (root / "manifest.json").write_text(json.dumps(dict(shaders=[dict(ref, native_file="fixture.bin")])))
    (root / "pipelines.json").write_text(json.dumps(dict(pipelines=[dict(id="triangle", effective_root_signature="present", shaders=[ref])])))
    output = subprocess.check_output([sys.executable, "-B", "tools/pso_readiness.py", str(root / "manifest.json"), str(root / "pipelines.json"), "--llvm", llvm])
    row = json.loads(output)["pipelines"][0]
    assert (row["status"], row["shaders"]["mesh"]["status"], row["first_blocker"]) == ("needs_pso_validation", "mesh_lowering_passed", None), row
    print(output.decode(), end="")'

The wider LLVM 19 checks reproduced the same failures on the unchanged baseline:

  • build-a-turno python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1 exited 1 on the v_cvt_f16_i16_e32 immediate encoding.
  • build-a-turno env LLVM_LIB=libLLVM.so.19.1 LLVM_MC=llvm-mc-19 LLVM_OBJCOPY=llvm-objcopy-19 python3 -B tests/rdna2_tools_check.py ran 101 tests with two failures and one error. The same three tests failed on the baseline.
  • The initial local command used libLLVM-19.so.1; the installed library is libLLVM.so.19.1. CI uses LLVM 15.

Evidence and follow-up

The MIT-licensed triangle fixture comes from tests/mesh_entry_check.py. The report test replaces only the LLVM boundary and exercises the real lowerer. Its allocation negative control replaces the value written to m0 with zero. The probe uses synthetic geometry and a 128-thread triangle declaration, as described in the updated experiment. Actual bindings and PSO creation require separate validation. No GPU commands or readback were added. Local Windows tests require an x64 Windows host.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact commands and results for the checks.
  • I included a negative control for the new fixture.
  • I updated README and experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572215487 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1104). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:04:05Z. --- ## Change Refs #259. Extend `pso_readiness.py --llvm` to disassemble matched mesh shaders with wave64 byte offsets and run `mesh_entry_aot.lower`. Report lowering rejection and disassembly failure with stage-specific diagnostics. A passing mesh probe with a present root signature leaves the pipeline in `needs_pso_validation`. This uses the mesh translator already on main and has no dependency on #1080. ## Verification Linux x64, Python 3.14.8, LLVM 19, commit `065d7662`, baseline `b9beb159`. | Command | Result | | --- | --- | | `python3 -B tests/pso_readiness_check.py` | Passed. One mesh lowering pass, two lowering rejections, two disassembly failures. Also checks no-LLVM evidence, signature status and stage/hash reuse. | | `build-a-turno python3 -B tests/mesh_entry_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1` | Passed. | | `python3 -B tests/docs_links_check.py` | Passed, 15 Markdown files and 243 links. | | `python3 -B tests/bidi_controls_check.py` | Passed, 922 tracked files. | | `git diff --check` | Passed. | Negative control with the new test and the baseline implementation, expected exit 1 and observed exit 1. The triangle reported `stage_not_assessed` and `needs_evidence` instead of passing the mesh probe. ```sh git show b9beb159:tools/pso_readiness.py | python3 -B -c 'import runpy, sys, types sys.path[:0] = ["tools", "tests"] baseline = types.ModuleType("pso_readiness") exec(sys.stdin.read(), baseline.__dict__) sys.modules[baseline.__name__] = baseline runpy.run_path("tests/pso_readiness_check.py", run_name="__main__")' ``` The CLI also passed a run with assembled gfx1013 bytes and the real LLVM library. The only pipeline reported `mesh_lowering_passed`, `needs_pso_validation` and a null blocker. ```sh build-a-turno python3 -B -c 'import hashlib, json, subprocess, sys from pathlib import Path from tempfile import TemporaryDirectory sys.path.insert(0, "tests") from mesh_entry_check import binary with TemporaryDirectory() as tmp: root = Path(tmp) llvm = "libLLVM.so.19.1" binary(root, "llvm-mc-19", "llvm-objcopy-19", llvm) digest = hashlib.sha256((root / "fixture.bin").read_bytes()).hexdigest() ref = dict(stage="mesh", sha256=digest) (root / "manifest.json").write_text(json.dumps(dict(shaders=[dict(ref, native_file="fixture.bin")]))) (root / "pipelines.json").write_text(json.dumps(dict(pipelines=[dict(id="triangle", effective_root_signature="present", shaders=[ref])]))) output = subprocess.check_output([sys.executable, "-B", "tools/pso_readiness.py", str(root / "manifest.json"), str(root / "pipelines.json"), "--llvm", llvm]) row = json.loads(output)["pipelines"][0] assert (row["status"], row["shaders"]["mesh"]["status"], row["first_blocker"]) == ("needs_pso_validation", "mesh_lowering_passed", None), row print(output.decode(), end="")' ``` The wider LLVM 19 checks reproduced the same failures on the unchanged baseline: - `build-a-turno python3 -B tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1` exited 1 on the `v_cvt_f16_i16_e32` immediate encoding. - `build-a-turno env LLVM_LIB=libLLVM.so.19.1 LLVM_MC=llvm-mc-19 LLVM_OBJCOPY=llvm-objcopy-19 python3 -B tests/rdna2_tools_check.py` ran 101 tests with two failures and one error. The same three tests failed on the baseline. - The initial local command used `libLLVM-19.so.1`; the installed library is `libLLVM.so.19.1`. CI uses LLVM 15. ## Evidence and follow-up The MIT-licensed triangle fixture comes from `tests/mesh_entry_check.py`. The report test replaces only the LLVM boundary and exercises the real lowerer. Its allocation negative control replaces the value written to `m0` with zero. The probe uses synthetic geometry and a 128-thread triangle declaration, as described in the updated [experiment](docs/experiments.md#pipeline-readiness-from-shader-manifests). Actual bindings and PSO creation require separate validation. No GPU commands or readback were added. Local Windows tests require an x64 Windows host. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact commands and results for the checks. - [x] I included a negative control for the new fixture. - [x] I updated README and experiment documentation. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:46:20 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:46:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T01:08:40Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 065d766258

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032082150 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1104#pullrequestreview-6032082150). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T01:08:40Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `065d766258` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:50:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T01:04:15Z.


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-24T01:08:48.196317Z 065d766 PR opened
ℹ️ 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:7118722505 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1104#issuecomment-7118722505). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T01:04:15Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"065d766258273319ff91b3c27afe0fe5cdfbf185","has_any_findings":true,"has_unresolved_findings":true,"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-24T01:08:48.196317Z">2026-11-24T01:08:48.196317Z</relative-time> | `065d766` | PR opened | <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>
tedin7 commented 2026-11-24 06:50:00 +00:00 (Migrated from github.com)

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


AI-assisted. Addressed the P2 finding in 01c992ae: unexpected exceptions from the mesh lowering probe (for example an IndexError from a scalar op with an unsupported operand shape) are now contained. The shader is reported as mesh_lowering_rejected with a short reason, the pipeline is blocked, and the report continues without a traceback.

Verification: python3 -B tests/pso_readiness_check.py passes with the new synthetic s_getpc_b64 s[0:1] case; with the previous tools/pso_readiness.py the same test fails with an IndexError. python3 -B tests/rdna2_tools_check.py OK.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118874223 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1104#issuecomment-7118874223). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:12:49Z. --- AI-assisted. Addressed the P2 finding in 01c992ae: unexpected exceptions from the mesh lowering probe (for example an IndexError from a scalar op with an unsupported operand shape) are now contained. The shader is reported as `mesh_lowering_rejected` with a short reason, the pipeline is `blocked`, and the report continues without a traceback. Verification: `python3 -B tests/pso_readiness_check.py` passes with the new synthetic `s_getpc_b64 s[0:1]` case; with the previous `tools/pso_readiness.py` the same test fails with an IndexError. `python3 -B tests/rdna2_tools_check.py` OK.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T01:08:40Z.

Code review location: tools/pso_readiness.py; line 45

@@ -16,23 +16,40 @@ def shader_key(record):
     return stage, digest.lower()
 
 
-def scan_pixel(root, records, digest, llvm):
+def scan_shader(root, record, stage, digest, llvm):
     from pixel_aot import disassemble
-    from scan_unsupported_shaders import analyze_shader_instructions
 
-    record = records[0]
     path = (root / record["native_file"]).resolve()
     if not path.is_relative_to(root):
         raise ValueError(f"native file outside the manifest directory for {digest}")
     code = path.read_bytes()
     if hashlib.sha256(code).hexdigest() != digest:
         raise ValueError(f"native file does not match SHA-256 {digest}")
+    decode_options = {}
+    if stage == "mesh":
+        decode_options = {"offsets": True, "features": b"+wavefrontsize64,-wavefrontsize32"}
     try:
-        instructions = disassemble(code, llvm)
+        instructions = disassemble(code, llvm, **decode_options)
     except ValueError as exc:
         return "disassembly_failed", str(exc)
     if not instructions:
         return "disassembly_failed", "empty instruction stream"
+    if stage == "mesh":
+        from mesh_entry_aot import lower
+
+        # Native bytes carry neither the dispatch declaration nor the bound geometry.
+        # Probe the source-built triangle profile used by the mesh entry experiment.
+        try:
+            lower(instructions, [0x1003], (3, 1))
+        except (ValueError, KeyError) as exc:
+            return "mesh_lowering_rejected", str(exc)

P2 Badge Contain mesh lowerer exceptions within the shader assessment

When a referenced mesh shader contains the legal but unsupported instruction s_getpc_b64 s[0:1], the lowerer's scalar_op() raises IndexError at vals[0], which this handler does not catch. Prepending that instruction to the source-built triangle fixture and assembling/disassembling it with LLVM 20 on Linux reproduces an exit-1 traceback with no JSON output. Consequently, one out-of-profile mesh shader aborts the entire readiness report instead of receiving mesh_lowering_rejected, discarding results for unrelated pipelines. Contain these lowerer exceptions at the per-shader boundary, as the pixel scanner already does.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4674186892 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1104#discussion_r4674186892). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T01:08:40Z. **Code review location:** `tools/pso_readiness.py`; line 45 ~~~~diff @@ -16,23 +16,40 @@ def shader_key(record): return stage, digest.lower() -def scan_pixel(root, records, digest, llvm): +def scan_shader(root, record, stage, digest, llvm): from pixel_aot import disassemble - from scan_unsupported_shaders import analyze_shader_instructions - record = records[0] path = (root / record["native_file"]).resolve() if not path.is_relative_to(root): raise ValueError(f"native file outside the manifest directory for {digest}") code = path.read_bytes() if hashlib.sha256(code).hexdigest() != digest: raise ValueError(f"native file does not match SHA-256 {digest}") + decode_options = {} + if stage == "mesh": + decode_options = {"offsets": True, "features": b"+wavefrontsize64,-wavefrontsize32"} try: - instructions = disassemble(code, llvm) + instructions = disassemble(code, llvm, **decode_options) except ValueError as exc: return "disassembly_failed", str(exc) if not instructions: return "disassembly_failed", "empty instruction stream" + if stage == "mesh": + from mesh_entry_aot import lower + + # Native bytes carry neither the dispatch declaration nor the bound geometry. + # Probe the source-built triangle profile used by the mesh entry experiment. + try: + lower(instructions, [0x1003], (3, 1)) + except (ValueError, KeyError) as exc: + return "mesh_lowering_rejected", str(exc) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Contain mesh lowerer exceptions within the shader assessment** When a referenced mesh shader contains the legal but unsupported instruction `s_getpc_b64 s[0:1]`, the lowerer's `scalar_op()` raises `IndexError` at `vals[0]`, which this handler does not catch. Prepending that instruction to the source-built triangle fixture and assembling/disassembling it with LLVM 20 on Linux reproduces an exit-1 traceback with no JSON output. Consequently, one out-of-profile mesh shader aborts the entire readiness report instead of receiving `mesh_lowering_rejected`, discarding results for unrelated pipelines. Contain these lowerer exceptions at the per-shader boundary, as the pixel scanner already does. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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!1097
No description provided.