Skip to content

chore(tools): add shader-refactor bytecode verifier#86

Merged
alandtse merged 4 commits into
devfrom
chore/shader-refactor-verifier
Jun 3, 2026
Merged

chore(tools): add shader-refactor bytecode verifier#86
alandtse merged 4 commits into
devfrom
chore/shader-refactor-verifier

Conversation

@alandtse
Copy link
Copy Markdown
Owner

@alandtse alandtse commented Jun 3, 2026

Adds tools/verify-shader-refactor.ps1 (+ tools/verify-shader-refactor.sh wrapper) 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_OUTPUT permutations, then compares the compiled DXBC:

  • IDENTICAL SHA-256 of the .cso ⇒ provable no-op (fxc emits no timestamps without /Zi).
  • DIFFERS ⇒ dumps + diffs the /Fc assembly for review.

Exit 0 all identical / 2 some differ / 1 compile error. Default base = merge-base(HEAD, origin/dev); -BaseRef overrides. Auto-detects entry/profile (*CS.hlslcs_5_0, else ps_5_0). Requires fxc.exe from the Windows SDK.

Tested

Caveat

The fixed permutation sweep is strong evidence, not the full shader-validation.yaml matrix — -Permutations handles exotic define combos.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 3, 2026 05:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@alandtse, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b1167fc1-fcb6-4e35-a237-29fbb6d9dc35

📥 Commits

Reviewing files that changed from the base of the PR and between 629b1d2 and 26ef2b5.

📒 Files selected for processing (4)
  • .claude/CLAUDE.md
  • docs/development/shader-workflow.md
  • tools/verify-shader-refactor.ps1
  • tools/verify-shader-refactor.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/shader-refactor-verifier

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ps1 to compile shader permutations and compare .cso hashes, with /Fc assembly 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.

Comment thread tools/verify-shader-refactor.ps1 Outdated
Comment thread tools/verify-shader-refactor.ps1 Outdated
Comment thread tools/verify-shader-refactor.ps1
alandtse and others added 2 commits June 2, 2026 22:41
- 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>
Copilot AI review requested due to automatic review settings June 3, 2026 05:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

Comment thread tools/verify-shader-refactor.ps1
Comment thread tools/verify-shader-refactor.ps1
Comment thread tools/verify-shader-refactor.ps1
Comment thread docs/development/shader-workflow.md
Comment thread .claude/CLAUDE.md
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>
@alandtse alandtse merged commit dc88209 into dev Jun 3, 2026
11 checks passed
@alandtse alandtse deleted the chore/shader-refactor-verifier branch June 3, 2026 06:42
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.

2 participants