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

DXT encoding support #700

Merged
merged 4 commits into from Mar 18, 2018

Conversation

Projects
None yet
3 participants
@CensoredUsername
Contributor

CensoredUsername commented Nov 30, 2017

This pull requests adds an Encoder and Decoder for the DXT1/3/5 lossy compression formats. It however does not implement any file format that uses DXT compression, like DDS at the moment. Due to this there is currently not a nice way of integrating testing of the decoding/encoding with the current testing infrastructure. I plan to add support for at least one container format to solve this, but since I'm not really familiar with the way the project works I've made the pull request now already to ask for advice on how to proceed with this.

Notes on the encoder/decoder

The encoder is probably not the most performant possible implementation as it brute-forces the best fitting color table per block, but it does result in reasonably high-quality encoding. It's still reasonably fast, taking <0.3 sec to single-threaded encode a noisy 1024x1024 pixel RGBA image, which is the worst case for the algorithm. Images with large flats, small gradients, or limited colorspaces encode much faster.

Since the compression operates purely on a block basis, it would be trivial to speed it up using more threads.

Due to the way DXT blocks work the decoder's scanlines are actually 4 pixels tall.

@CensoredUsername

This comment has been minimized.

Contributor

CensoredUsername commented Dec 1, 2017

Previous discussion on DXT support can also be found in #127 and #621, although the patent discussion has become outdated since the patents in question expired last October.

@bvssvni

This comment has been minimized.

Member

bvssvni commented Dec 2, 2017

Can you rebase?

CensoredUsername added some commits Nov 30, 2017

Optimize DXT color encoding by moving index generation out of the mai…
…n loop, which seemed to be inhibiting optimizations. This made encoding in release about 40% faster
@CensoredUsername

This comment has been minimized.

Contributor

CensoredUsername commented Dec 2, 2017

It's rebased.

@jeditobe

This comment has been minimized.

jeditobe commented Dec 12, 2017

@CensoredUsername Wikipedia says
Some (e.g. US 5956431 A) of the multiple USPTO patents on S3 Texture Compression expired on October 2, 2017.[6] At least one continuation patent, US6,775,417, however has a 165-day extension.

@CensoredUsername

This comment has been minimized.

Contributor

CensoredUsername commented Dec 17, 2017

@jeditobe As far as I'm aware Mesa has already merged in DXT support. Fedora is already shipping S3TC enabled code. There seems to be some confusion as only a part of US6775417 is still protected.

@bvssvni

This comment has been minimized.

Member

bvssvni commented Feb 22, 2018

It has passed 143 days since October 2, 2017, so in just 22 days we can ship it.

@CensoredUsername

This comment has been minimized.

Contributor

CensoredUsername commented Mar 17, 2018

Looks like the last patent has also passed now.

@bvssvni

This comment has been minimized.

Member

bvssvni commented Mar 18, 2018

OK, merging.

@bvssvni bvssvni merged commit 399400d into PistonDevelopers:master Mar 18, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment