Repository navigation
feat(bc7): always-on mode 6 / mode 4 selection — −33% MSE at speed parity - #16
Merged
Merged
Conversation
…rity Every block now chooses between mode 6 (one RGBA line, 16 levels) and mode 4 (one channel split into its own scalar plane, 2-bit + 3-bit index sets, idxMode per block). The choice comes from the block covariance: the variance each mode explains net of its quantisation, with a closed-form estimate of each candidate plane's principal eigenvalue. Both modes run the same per-pixel code (stored extents projections reused as indices, one endpoint quantiser, anchor rule applied before indexing), so mixed warps no longer pay for two paths. /eval (M3, hardware decode) vs the mode-6-only kernel: - MSE −33% geomean over 41 images, −25% over the 32 real textures - normal maps +2.4..4.5 dB, rock colour +1.1..2.2, packed +0.3..4.4; gray maps and smooth wood colour unchanged (±0.03 dB) - f16 GPU time ×0.99 geomean (1K mode-4-heavy textures +2–3%, 2K/4K par); f32 fallback ×0.75 - WebGL GLSL byte-identical to the f32 WGSL module BREAKING: removes the BC7Encoder `adaptiveMode4` option, the BC7EncoderOptions type and the Encoder pipelineConstants() hook. /test BC7 floors re-pinned; /eval reports a per-mode block histogram. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CvMZvPkPRPM8oZMVs44qB7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every BC7 block now chooses between mode 6 (one RGBA line, 16 levels) and mode 4 (one channel split into its own scalar plane, 2-bit + 3-bit index sets, idxMode chosen per block). The opt-in
adaptiveMode4option is removed: this is the default and only path.Results
/eval, Apple M3, hardware decode, RGBA PSNR, vs the mode-6-only kernel:A reference shader that exhaustively tries every single-subset candidate (modes 6, 4 and 5) sits only 0.1–0.9 dB above this encoder. The old gated mode 4 sat 2–8 dB below it.
Breaking changes
BC7EncoderadaptiveMode4option and the exportedBC7EncoderOptionstype.Encoder.pipelineConstants()hook.Also in this PR
/testBC7 quality floors re-pinned to the new baselines (gray rows unchanged). 0 failures./evalreports a per-mode BC7 block histogram.Test plan
bun run all(format, lint, typecheck, warden, 225 tests)/testGPU suite: 0 failures, both f16 and f32 variants/evalA/B vs HEAD, f16 and f32🤖 Generated with Claude Code
https://claude.ai/code/session_01CvMZvPkPRPM8oZMVs44qB7