Skip to content

Count distinct FSSM payloads in G-buffer census cohorts - #6726

Merged
shayderrr merged 2 commits into
ItsNotRexed:mainfrom
kacper-serewis:feat/gbuffer-payload-multiplicity
Nov 23, 2026
Merged

shayderrr merged 2 commits into
ItsNotRexed:mainfrom
kacper-serewis:feat/gbuffer-payload-multiplicity

Conversation

@kacper-serewis

@kacper-serewis kacper-serewis commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Coordinator item BUILD-2347.

SHADER-GBUFFER-PAYLOAD-COVERAGE claim

Depends on: #5657

Review ba0f817 above #5657. Pass --payload-coverage to the G-buffer census to add a per-cohort histogram of indexed entries per distinct whole FSSM. The census hashes every unpacked tag-0x0D payload. Multiple distinct payloads in one container count as ambiguous. Missing or unreadable identities count as unavailable. Static export observations and signatures retain their indexed-entry denominators.

Cohort Indexed entries Distinct payloads
All PS 12,101 12,037
Entry contains deferred (casefold) 3,014 3,012
Stem contains Deferred 3,004 3,002
Stem contains PS_DeferredTextured 807 805

The full cached CPU run found 11,978 singleton identities, 55 pairs, three triples and one group of four. Each indexed PS contained one payload. An independent pass compared the unpacked bytes with each cached FSSM sidecar and reproduced the per-cohort distinct counts. All 12,101 signatures were readable. Listing coverage was 12,000 complete and 101 partial.

Synthetic controls exercise identical payloads in different containers, a different payload, equal and conflicting repeated tags, invalid, absent and missing payloads, cohort-specific multiplicity, and equivalence of the other report fields with the default. Census, unpacker, feature scan and text line-ending tests passed, as did Python compilation and git diff --check. Windows, AMD Ryzen 5 9600X, CPU only. GPU and driver untested. AI-assisted with Codex.

@kapitche

Copy link
Copy Markdown
Contributor

Tested ba0f817 merged with main 8f208d0 on Linux/Python 3.12.16: pass

Note: the branch carries two commits (b0e4e660b G-buffer census, ba0f8170c the payload coverage), because it is stacked on #5657 ("Depends on: #5657" in the body). tools/gbuffer_census.py, tests/test_gbuffer_census.py and the feature_scan.signature_offsets refactor are new relative to main, so this result covers both commits together; the merge itself was clean.

Commands (git merge --no-edit of the PR head onto upstream/main), each as ~/src/Leonida/.venv/bin/python -I tests/<file>:

  • test_gbuffer_census.py: Ran 2 tests, OK (the payload-coverage test and the cohort/coverage test).
  • test_feature_scan.py, test_feature_scan_bad_index.py, test_feature_scan_order.py, test_fssm_unpack.py, test_inner_coverage_metadata.py, test_runner_calls_all_tests.py: all OK.
  • Negative controls by mutation (the census tool does not exist on main, so there is nothing to revert to):
    • tools/gbuffer_census.py: if len(identities) > 1: -> > 99: (multi-payload containers no longer ambiguous). test_gbuffer_census.py FAILED (failures=1), {'identified': 4, 'ambiguous': 0, ...} != {'identified': 3, ..., 'ambiguous': 1, ...}.
    • tools/feature_scan.py: dropped the end > len(sig) truncation check in signature_offsets. test_feature_scan.py then dies with struct.error: unpack_from requires a buffer of at least 44 bytes ..., so the truncated-signature case is covered there (the two census tests alone still pass under this mutation, they do not cover it).
      Both mutations reverted; the tree was clean afterwards.

Not run: the real shader carve (game data); the table of counts in the PR body is unverified by me.

Diff read: no concern. Unpacking all payloads via unpack_all and hashing each, with ValueError/struct.error/zlib.error mapped to "unavailable", matches the denominators the test asserts.

@duudiis

duudiis commented Nov 23, 2026

Copy link
Copy Markdown

Tested ba0f817 merged onto main 48ff424 on Windows 11 Pro, Intel i7-14700KF, CPython 3.11.0 (venv: pytest 9.2.0, numpy 2.4.6, Pillow 13.0.0; numpy is below the 2.5.5 pin because 2.5 needs Python 3.12), CPU only: pass.

  • The merge is clean. The PR stacks on Add a reproducible G-buffer cohort census CLI #5657 (b0e4e66, still open), so the diff also carries that commit: tools/gbuffer_census.py (new), tools/feature_scan.py, tests/test_gbuffer_census.py (new).
  • pytest -q tests/test_gbuffer_census.py tests/test_feature_scan.py tests/test_feature_scan_bad_index.py tests/test_feature_scan_order.py tests/test_fssm_unpack.py: 67 passed, 20 subtests passed.
  • python -I tests/test_gbuffer_census.py: 2 tests OK (stdlib only).
  • python -I -m compileall on the 3 changed files and git diff --check: clean.
  • Regression check: with tools/gbuffer_census.py from b0e4e66 (Add a reproducible G-buffer cohort census CLI #5657 alone), tests/test_gbuffer_census.py fails with TypeError: census() got an unexpected keyword argument 'payload_coverage'. With this PR's version it passes.
  • tests/test_text_write_line_endings.py fails on this merge, as it did on main in an earlier run. It flags files this PR doesn't touch, and the new text writes here all set newline="\n" and encoding="utf-8".

Review note (minor): tools/gbuffer_census.py:130 builds payloads_by_indexed_entry_count as a Counter with int keys, and json.dumps at line 141 turns them into strings ({"3": 1}). That's fine for reading, but anyone consuming the JSON should know about it.

AI-assisted (Claude Code).

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

Adds tools/gbuffer_census.py, which counts declared OSG1 signatures and static exp mrt instructions across indexed PS shaders, tracking coverage for missing/unreadable containers and incomplete listings. --payload-coverage hashes each whole FSSM from fssm_unpack.unpack_all() with SHA256, reporting identified/ambiguous/unavailable counts and a histogram of distinct payloads per indexed entry. feature_scan.streams() is refactored to use the new signature_offsets() helper that raises ValueError on bad tables. tests/test_gbuffer_census.py builds synthetic DXBC/DXIL and listings to verify payload multiplicity stays independent of declared-count cohorts.

Why merge

Distinct FSSM payload coverage was invisible in the census; quantifying it prevents duplicate shader entries from being mistaken for independent G-buffer variants.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

Adds tools/gbuffer_census.py, which counts declared OSG1 signatures and static exp mrt instructions across indexed PS shaders, tracking coverage for missing/unreadable containers and incomplete listings. --payload-coverage hashes each whole FSSM from fssm_unpack.unpack_all() with SHA256, reporting identified/ambiguous/unavailable counts and a histogram of distinct payloads per indexed entry. feature_scan.streams() is refactored to use the new signature_offsets() helper that raises ValueError on bad tables. tests/test_gbuffer_census.py builds synthetic DXBC/DXIL and listings to verify payload multiplicity stays independent of declared-count cohorts.

Why merge

Distinct FSSM payload coverage was invisible in the census; quantifying it prevents duplicate shader entries from being mistaken for independent G-buffer variants.

Verdict: Approve

@shayderrr
shayderrr merged commit 775287b into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
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.

4 participants