Skip to content

First Light: count transparent textured fragments in coverage - #4037

Open
jeremygold02 wants to merge 2 commits into
ItsNotRexed:mainfrom
jeremygold02:fix/first-light-textured-coverage
Open

jeremygold02 wants to merge 2 commits into
ItsNotRexed:mainfrom
jeremygold02:fix/first-light-textured-coverage

Conversation

@jeremygold02

@jeremygold02 jeremygold02 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds two regression tests for First Light textured coverage. One checks that fully transparent black and half-alpha fragments both count as covered. The other checks that an image containing only the clear color fails the minimum coverage requirement. Upstream main already handles low-alpha texels by comparing all four channels to the harness clear value (−1). At merge commit cb15409813b21d9ffca43b931c7d97de3ced5019, the diff against main 98fa503f consists of 12 added lines in tests/test_first_light.py. Coordination claim

Verification on the merged head

  • The first_light.py --check CLI and the package-gated draw test each rendered a fresh 128×128 frame. Both readbacks matched the complete original 262,144-byte frame byte for byte. The checker counted 12,804 of 16,384 pixels and accepted the center and four RGBA probes. Every covered pixel had alpha between 0.062744 and 0.372314.
  • Six focused suites covered First Light, invalid JSON, harness paths, mesh draws, stale meshes and text line endings. With the local GPU fixture enabled, 50 tests and eight subtests passed. Four symlink subtests skipped because the Windows test process could not create symlinks.

Original reproduction

  • On base aa2988cc, the documented mesh and a synthetic two-texel RGBA8 DDS (alpha bytes 16 and 95) rendered the same 12,804 pixels. The checker counted only fragments with alpha above 0.5, reported coverage 0.0000 and exited 1. The complete coverage mask matched the untextured draw, and the center and four RGBA probes matched their expected values.
  • On the original topic head a8c75817, the same CLI exited 0 and reported 12,804 covered pixels. Both runs used the same Vulkan harness, shaders and draw inputs. The transparent/half-alpha regression failed on the original base and passed on the topic head. The First Light, invalid-JSON, harness-path and line-ending suites passed 37 tests and four subtests with the local GPU fixture enabled.
  • A separate local integration of that topic head with 6d398841 from BUILD-1151: sample explicit sRGB DDS textures correctly in First Light #4055 rendered all 12,804 expected fragments from a low-alpha, two-texel sRGB DDS. Every covered RGB value matched the independently sampled sRGB reference exactly. Alpha matched its linear reference within 0.001. The four suites passed 39 tests and nine subtests. sRGB sampling PR

Hardware and software for the GPU replay were an Intel Core Ultra 7 265K, NVIDIA GeForce RTX 5070 (driver 621.01, subgroup 32), Windows 11 Home 25H2 build 26200.9974 and CPython 3.12.10.

AI-assisted by Codex.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Independent Windows Python check of a8c7581 against aa2988c. In a 2x2 RGBA32F readback with one clear pixel, one transparent black pixel, one half-alpha pixel, and one opaque pixel, textured coverage changed from one to three. The same bytes in untextured mode still counted one, and a clear-only textured frame still counted zero. Both focused coverage tests passed. This check used synthetic readback bytes and did not render a frame.

AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran this at a8c75817 on Windows 11: python -I tests/test_first_light.py -> 21 tests, OK (4 skipped); compileall and git diff --check clean.

For textured manifests the coverage now counts any pixel different from the four-channel clear (-1.0), so a transparent-black or half-alpha texel counts as rendered; the new cases cover both and an untouched image reports the expected coverage 0.0000 outside failure. The non-textured path keeps the alpha > 0.5 rule, and clear_pixel/centre_rgba/rgba_probes still validate the actual values, so the looser coverage rule does not let a wrong texture pass. No blocking issue.

Keep the upstream textured coverage and clear-sentinel handling. Retain the transparent-black, half-alpha and clear-only regression cases.

Refs: ItsNotRexed#4037
@SweatierKey

Copy link
Copy Markdown
Contributor

Tested cb154098 on Linux (x86_64, Python 3.13.5): pass (code read + unit tests).

What I ran:

  • git diff --check main...HEAD: clean.
  • python3 -m unittest tests/test_first_light.py: 30 tests, OK (4 skipped; both new tests test_coverage_includes_transparent_and_half_alpha_fragments and test_untouched_textured_image_has_zero_coverage pass).

Code review:

  • Clean, focused regression coverage verifying that textured fragments with alpha 0.0 / 0.5 count toward coverage while an untouched clear buffer still fails with zero coverage.

@kapitche

Copy link
Copy Markdown
Contributor

Tested cb15409 merged with main 3faac55 on Linux (WSL2), Python 3.12.16: pass.
After the merge the PR is tests-only: the tools/first_light.py coverage fix is already on main (06f9151), so the two new tests (transparent/half-alpha fragments counted; untouched image gives zero coverage) pass against main's code. tests/test_first_light.py: 30 run, OK (4 skipped).
Negative control not applicable: there is no non-test change left to revert.

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.

5 participants