Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basis plugins: support UASTC HDR #145

Closed
wants to merge 10 commits into from
Closed

Conversation

pezcode
Copy link
Contributor

@pezcode pezcode commented Sep 11, 2024

Adds support for HDR format encoding and transcoding to BasisImageConverter and BasisImporter. UASTC HDR support got added to Basis in version 1.50.

The limitations for HDR currently are:

  • can't transcode LDR -> HDR or HDR -> LDR
  • HDR alpha is always 1

Depends on #119.

Todos:

  • tests
  • tests
  • did I mention tests
  • update example code for supported format detection code requires _ldr and _hdr pseudo extensions for profiles of WEBGL_compressed_texture_astc

@mosra mosra added this to the 2023.0a milestone Sep 11, 2024
Copy link
Owner

@mosra mosra left a comment

Choose a reason for hiding this comment

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

First of all, thanks a lot!

Doing a really tired review, so apologies if something doesn't make sense or the ramblings are too long. ... or if I'm pointing out something you mentioned in the description, such as tests. Or tests.

for(std::size_t x = 0; x != src.size()[1]; ++x)
dst[y][x] = Math::Vector3<T>::pad(src[y][x]); /* Alpha implicitly opaque */

} else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
Copy link
Owner

Choose a reason for hiding this comment

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

Ah, this reminds me you requested the batch swizzle. On my list :)

@pezcode
Copy link
Contributor Author

pezcode commented Sep 27, 2024

Oops, I committed the basisu binary 🙈 Have to undo that

Copy link

codecov bot commented Sep 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.00%. Comparing base (a18f9d8) to head (801e501).
Report is 9 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #145   +/-   ##
=======================================
  Coverage   96.99%   97.00%           
=======================================
  Files         147      147           
  Lines       16552    16600   +48     
=======================================
+ Hits        16054    16102   +48     
  Misses        498      498           
Flag Coverage Δ
97.00% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@mosra mosra left a comment

Choose a reason for hiding this comment

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

I'll try to do a more thorough review later today, but so far seems like I won't have much to complain about. 👌

src/MagnumPlugins/BasisImporter/BasisImporter.cpp Outdated Show resolved Hide resolved
Instead of an unavoidable copy. If users want 4-byte alignment, they can
choose to perform the copy themselves. Most other importers do the same
thing.
Copy link
Owner

@mosra mosra left a comment

Choose a reason for hiding this comment

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

One last bit, other than that looks good to me (plus the 1-byte alignment from above, and arrayCast() instead of mutablePixels()).

I'm still rushing deadlines, so I won't be able to add that fake ldr/hdr extension for WebGL until later next week. So either the PR will wait, or I'll merge and the loading code will get (partially) updated later.

@pezcode
Copy link
Contributor Author

pezcode commented Sep 29, 2024

So either the PR will wait, or I'll merge and the loading code will get (partially) updated later.

I think it's okay to do that later, otherwise this PR might get stalled out needlessly. Sometimes things come up etc. and this is just a convenient doc detail.

I reverted back to arrayCast() for the slicing, but my code for getting a view on the alpha channel looks terrible. Feel free to codegolf that a bit (or revert the commit) if it's worse than before 😸

@mosra
Copy link
Owner

mosra commented Sep 29, 2024

Damn, I thought it is possible to slice a const view to single channels at least, sorry.

I'll fix that, those getters should return a const&, like Pair etc does. Various documentation mentions slice(&Color4::a) etc as one of the main slicing use cases, it'd be silly if that only worked on mutable views.

@mosra
Copy link
Owner

mosra commented Oct 1, 2024

Squashed a bit and merged as a18f9d8...e327796. I reverted back to .slice(&Color4h::a), as of mosra/magnum@d5b5158 that works properly on const views as well. (Oh and it seems some trailing whitespace sneaked into your commits, I cleaned those up in the process but you might want to check your editor settings, or whether it could use the .editorconfig that's in the repository.)

In any case, thanks a lot for this!

@mosra mosra closed this Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants