feat(cli): scan and export BC3, BC4, BC5 and BC7 textures as PNG #13

Open
github-bot wants to merge 1 commit from github-bot/gh-13 into master AGit
Owner

@⁠brainbudt on GitHub · 2026-11-26 17:27 UTC · original
brainbudt:feat/bc3-bc7-scan-png → master · +1407 −105 · 7 files · 1 commits · open

Problem

The decoder can rebuild BC3, BC4, BC5 and BC7 blocks, but store scanning (scan) and mip-0 PNG export (ttpf-export) only handle BC1.

Change

  • Decode all five supported formats (BC1, BC3, BC4, BC5, BC7) to RGBA8 for PNG export in src/pixels.rs, including signed BC4/BC5, BC3/BC7 alpha, and sRGB PNG metadata for sRGB DXGI formats.
  • Extend scan convergence, throughput and block emission to all five formats, sampling each format independently so mixed stores preserve existing BC1 samples.
  • Validate block input lengths, dimensions, and reject unsupported formats (such as BC6H) cleanly before expanding pixels, with regression tests in tests/pixels.rs.

Scope

Follow-up to #12 covering store scanning and mip-0 PNG export with zero new dependencies and synthetic fixtures only.

Verification

  • macOS ARM64: cargo test (45 passed), cargo test --release (45 passed), cargo test --no-default-features (38 passed), and cargo clippy --all-targets -- -D warnings all passed.
  • Linux x86-64: cargo test --release (45 passed) and cargo clippy --all-targets -- -D warnings passed.
  • Existing BC1 golden hashes passed; all 36,608 synthetic BC7 blocks (across all 285 valid combinations + reserved mode) matched bcdec byte-for-byte. Retail texture parity remains unverified.

Reviewed & refined by GPT-6.2 Sol in Codex (APPROVE); implemented with Mistral Large 4 in Mistral Vibe (orchestrated with Gemini 4 Neon in T3 Code).

Summary by CodeRabbit

  • New Features
    • PNG export now supports all supported BC formats, with appropriate color handling for sRGB textures.
    • Texture scanning now reports results by format and overall, with sampling and block limits applied independently to each format. BC6H is not included in the expanded scan support.
    • Added BCn-to-RGBA8 pixel conversion support for BC1, BC3, BC4, BC5, and BC7.
  • Documentation
    • Updated format, export, scanning, and test coverage descriptions.
**@⁠brainbudt** on GitHub · 2026-11-26 17:27 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/13) `brainbudt:feat/bc3-bc7-scan-png` → `master` · +1407 −105 · 7 files · 1 commits · open ## Problem The decoder can rebuild BC3, BC4, BC5 and BC7 blocks, but store scanning (`scan`) and mip-0 PNG export (`ttpf-export`) only handle BC1. ## Change - Decode all five supported formats (BC1, BC3, BC4, BC5, BC7) to RGBA8 for PNG export in `src/pixels.rs`, including signed BC4/BC5, BC3/BC7 alpha, and sRGB PNG metadata for sRGB DXGI formats. - Extend `scan` convergence, throughput and block emission to all five formats, sampling each format independently so mixed stores preserve existing BC1 samples. - Validate block input lengths, dimensions, and reject unsupported formats (such as BC6H) cleanly before expanding pixels, with regression tests in `tests/pixels.rs`. ## Scope Follow-up to #12 covering store scanning and mip-0 PNG export with zero new dependencies and synthetic fixtures only. ## Verification - macOS ARM64: `cargo test` (45 passed), `cargo test --release` (45 passed), `cargo test --no-default-features` (38 passed), and `cargo clippy --all-targets -- -D warnings` all passed. - Linux x86-64: `cargo test --release` (45 passed) and `cargo clippy --all-targets -- -D warnings` passed. - Existing BC1 golden hashes passed; all 36,608 synthetic BC7 blocks (across all 285 valid combinations + reserved mode) matched `bcdec` byte-for-byte. Retail texture parity remains unverified. --- Reviewed & refined by GPT-6.2 Sol in Codex (APPROVE); implemented with Mistral Large 4 in Mistral Vibe (orchestrated with Gemini 4 Neon in T3 Code). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * PNG export now supports all supported BC formats, with appropriate color handling for sRGB textures. * Texture scanning now reports results by format and overall, with sampling and block limits applied independently to each format. BC6H is not included in the expanded scan support. * Added BCn-to-RGBA8 pixel conversion support for BC1, BC3, BC4, BC5, and BC7. * **Documentation** * Updated format, export, scanning, and test coverage descriptions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:56:15 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-26 17:27 UTC · original · edited 2026-11-26 17:33 UTC

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The crate adds BC1, BC3, BC4, BC5, and BC7 block-to-RGBA8 conversion. PNG export and store scanning now support multiple formats, with per-format scan results and optional sRGB tagging for PNG output.

Changes

Multi-format pixel conversion and CLI workflows

Layer / File(s) Summary
BCn pixel conversion
src/lib.rs, src/pixels.rs
A public pixels module adds BC1, BC3, BC4, BC5, and BC7 block-to-RGBA8 conversion, image expansion, and DXGI format mappings. BC7 decoding handles partitions, endpoint precision, index sets, and rotations.
PNG export integration
src/ttpf.rs, src/main.rs, src/texture.rs, README.md
PNG export converts supported formats to RGBA pixels and can tag output as sRGB. ttpf delegates format lookup to pixels; DDS export remains unchanged.
Multi-format scan and reporting
src/main.rs, tests/pixels.rs, README.md
scan samples eligible chunks independently per format, decodes them with the matching mode, and reports per-format and overall tallies and throughput. Tests cover pixel conversion, synthetic exports, and scan behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant cmd_export
  participant blocks_to_rgba
  participant png_rgba_with_srgb
  cmd_export->>blocks_to_rgba: convert decoded blocks using mode and signedness
  cmd_export->>png_rgba_with_srgb: encode RGBA pixels with optional sRGB tagging

Possibly related PRs

  • Ahmet-Dedeler/bcpack-rs#12: Adds BC3, BC4, BC5, and BC7 decoding and DDS export, which this change extends to PNG export and multi-format scanning.

Suggested reviewers: ahmet-dedeler

Merge Risk: Minimal · up to 9d2ad

This PR extends PNG export and store scanning from BC1 to BC3, BC4, BC5, and BC7, and the review found no concrete defects. Tests and clippy are reported passing, so the change looks ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says the PR adds scanning and PNG export for BC3, BC4, BC5 and BC7 textures in the CLI. The changeset does this: src/main.rs extends ttpf-export PNG output to every supported BC format and m…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title says the PR adds scanning and PNG export for BC3, BC4, BC5 and BC7 textures in the CLI. The changeset does this: src/main.rs extends ttpf-export PNG output to every supported BC format and makes scan sample multiple formats. It also adds src/pixels.rs for RGBA8 decoding of those formats. The title omits BC1, which was already supported, and the new pixel decoder, but it names the main change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f16fb1eb-ebef-4717-add7-7032e305ca4d
Commits

Reviewing files that changed from the base of the PR and between 7b2b42122c and 9d2ad00cc8.

Files selected for processing: 7

  • README.md
  • src/lib.rs
  • src/main.rs
  • src/pixels.rs
  • src/texture.rs
  • src/ttpf.rs
  • tests/pixels.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-26 17:27 UTC · [original](https://github.com/Ahmet-Dedeler/bcpack-rs/pull/13#issuecomment-7199046488) · edited 2026-11-26 17:33 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/Ahmet-Dedeler/bcpack-rs/pull/13?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> ### Walkthrough The crate adds BC1, BC3, BC4, BC5, and BC7 block-to-RGBA8 conversion. PNG export and store scanning now support multiple formats, with per-format scan results and optional sRGB tagging for PNG output. ### Changes **Multi-format pixel conversion and CLI workflows** |Layer / File(s)|Summary| |:---|:---| |**BCn pixel conversion** <br> `src/lib.rs`, `src/pixels.rs`|A public `pixels` module adds BC1, BC3, BC4, BC5, and BC7 block-to-RGBA8 conversion, image expansion, and DXGI format mappings. BC7 decoding handles partitions, endpoint precision, index sets, and rotations.| |**PNG export integration** <br> `src/ttpf.rs`, `src/main.rs`, `src/texture.rs`, `README.md`|PNG export converts supported formats to RGBA pixels and can tag output as sRGB. `ttpf` delegates format lookup to `pixels`; DDS export remains unchanged.| |**Multi-format scan and reporting** <br> `src/main.rs`, `tests/pixels.rs`, `README.md`|`scan` samples eligible chunks independently per format, decodes them with the matching mode, and reports per-format and overall tallies and throughput. Tests cover pixel conversion, synthetic exports, and scan behavior.| <!-- change_assessment_start --> **Estimated code review effort:** 4 (Complex) | ~45 minutes <!-- change_assessment_commit:"9d2ad00cc82697501e13be379229abe2fdddbcf8" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> Change: Feature <!-- change_assessment_end --> ### Sequence Diagram(s) ```mermaid sequenceDiagram participant cmd_export participant blocks_to_rgba participant png_rgba_with_srgb cmd_export->>blocks_to_rgba: convert decoded blocks using mode and signedness cmd_export->>png_rgba_with_srgb: encode RGBA pixels with optional sRGB tagging ``` **Possibly related PRs** - [Ahmet-Dedeler/bcpack-rs#12](https://git.gtahub.st/github/Ahmet-Dedeler--bcpack-rs/pulls/12): Adds BC3, BC4, BC5, and BC7 decoding and DDS export, which this change extends to PNG export and multi-format scanning. Suggested reviewers: `ahmet-dedeler` <!-- walkthrough_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>9d2ad</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `9d2ad` --> <!-- final_review_risk_coverage:{"sourceCommitId":"9d2ad00cc82697501e13be379229abe2fdddbcf8","coveredCommitId":"9d2ad00cc82697501e13be379229abe2fdddbcf8","kind":"reviewed"} --> This PR extends PNG export and store scanning from BC1 to BC3, BC4, BC5, and BC7, and the review found no concrete defects. Tests and clippy are reported passing, so the change looks ready to merge. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description Check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title says the PR adds scanning and PNG export for BC3, BC4, BC5 and BC7 textures in the CLI. The changeset does this: src/main.rs extends ttpf-export PNG output to every supported BC format and m… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title says the PR adds scanning and PNG export for BC3, BC4, BC5 and BC7 textures in the CLI. The changeset does this: src/main.rs extends ttpf-export PNG output to every supported BC format and makes scan sample multiple formats. It also adds src/pixels.rs for RGBA8 decoding of those formats. The title omits BC1, which was already supported, and the new pixel decoder, but it names the main change. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- finishing_touch_checkbox_start --> <details> <summary><strong>Finishing Touches</strong></summary> <dl> <dd> <br> <details open> <summary><strong>Generate unit tests (beta)</strong></summary> <dl> <dd> <br> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create a new PR </dd> </dl> </details> </dd> </dl> </details> <!-- finishing_touch_checkbox_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=Ahmet-Dedeler/bcpack-rs&utm_content=13)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: Unavailable - **Branch**: Unavailable - **File**: No configuration file from this repository applied - **Commit**: Unavailable - **Layers**: Organization UI - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `f16fb1eb-ebef-4717-add7-7032e305ca4d` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 7b2b42122c6b05787506f212e9a2570999d3f143 and 9d2ad00cc82697501e13be379229abe2fdddbcf8. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 7</strong></summary> <dl> <dd> <br> * `README.md` * `src/lib.rs` * `src/main.rs` * `src/pixels.rs` * `src/texture.rs` * `src/ttpf.rs` * `tests/pixels.rs` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/13/head:github-bot/gh-13'
git switch 'github-bot/gh-13'

Merge

Merge the changes and update on Forgejo.
git switch 'master'
git merge --no-ff 'github-bot/gh-13'
git switch 'github-bot/gh-13'
git rebase 'master'
git switch 'master'
git merge --ff-only 'github-bot/gh-13'
git switch 'github-bot/gh-13'
git rebase 'master'
git switch 'master'
git merge --no-ff 'github-bot/gh-13'
git switch 'master'
git merge --squash 'github-bot/gh-13'
git switch 'master'
git merge --ff-only 'github-bot/gh-13'
git switch 'master'
git merge 'github-bot/gh-13'
git push origin 'master'
This discussion has been locked. Commenting is limited to contributors.
No description provided.