chore(tools): add shader-refactor bytecode verifier#86
Conversation
verify-shader-refactor.ps1 (with a bash wrapper) compiles a shader from a base git ref and from the working tree across the VR x HDR_OUTPUT permutations, then compares the compiled DXBC. Identical SHA-256 proves a refactor is behavior-preserving; on mismatch it diffs the /Fc assembly. Exit 0 = all identical, 2 = differs, 1 = compile error. Tested both ways: detects the TAA VR fix as DIFFERS (VR perms only) and the TAA constants/alpha-loop refactor as IDENTICAL across all permutations. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 55 minutes and 23 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a small verification toolchain to help shader authors confirm that “refactor-only” HLSL edits are behavior-preserving by comparing compiled DXBC output between a base git ref and the working tree.
Changes:
- Introduces
tools/verify-shader-refactor.ps1to compile shader permutations and compare.csohashes, with/Fcassembly diff output on mismatches. - Adds a bash wrapper (
tools/verify-shader-refactor.sh) for bash/WSL/git-bash entry points that forwards args into the PowerShell script. - Documents the workflow in
docs/development/shader-workflow.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tools/verify-shader-refactor.ps1 | Core implementation: compile base/worktree permutations, hash-compare DXBC, print assembly diffs on mismatch. |
| tools/verify-shader-refactor.sh | Bash wrapper to invoke the PowerShell verifier from bash-like shells. |
| docs/development/shader-workflow.md | Adds usage/docs for verifying shader refactors via the new tool. |
- Preserve explicit-valued -Permutations defines (e.g. SHADOWFILTER=0); the builder no longer appends =1 to them (was producing FOO=0=1). - Move temp-dir cleanup into finally so it never leaks on a thrown error. - Correct help text: Tier-2 lists differing asm lines, not a unified diff. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses review: the verifier only materialized the target .hlsl from the base ref while reading included .hlsli from the working tree for BOTH the base and work compiles, so a refactor that also edited a shared header was masked (both sides saw the new header) and the run could still claim "behavior- preserving". Now `git archive` materializes the base ref's whole -IncludeDir tree; base compiles against base-ref headers, work against working headers. Also guard against a shader path resolving outside the repo root. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds
tools/verify-shader-refactor.ps1(+tools/verify-shader-refactor.shwrapper) to programmatically prove an HLSL refactor changed no behavior.What it does
Compiles a shader from a base git ref and from the working tree across the
VR×HDR_OUTPUTpermutations, then compares the compiled DXBC:.cso⇒ provable no-op (fxc emits no timestamps without/Zi)./Fcassembly for review.Exit
0all identical /2some differ /1compile error. Default base =merge-base(HEAD, origin/dev);-BaseRefoverrides. Auto-detects entry/profile (*CS.hlsl→cs_5_0, elseps_5_0). Requiresfxc.exefrom the Windows SDK.Tested
PSHADER/PSHADER HDR_OUTPUTIDENTICAL, VR perms DIFFERS, exit 2 (with asm diff).pwsh/.NET-Core-only APIs).Caveat
The fixed permutation sweep is strong evidence, not the full
shader-validation.yamlmatrix —-Permutationshandles exotic define combos.🤖 Generated with Claude Code