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

Add S3TC extensions #38

Merged
merged 3 commits into from Apr 22, 2019

Conversation

Projects
None yet
3 participants
@alexheretic
Copy link
Contributor

commented Apr 12, 2019

This update brings gl_generator up to date and adds extensions:

  • GL_EXT_texture_compression_s3tc
  • GL_EXT_texture_sRGB

Required/justified by gfx-rs/gfx#2733

alexheretic added some commits Apr 9, 2019

@kvark

This comment has been minimized.

Copy link
Member

commented Apr 22, 2019

@alexheretic Than you!. Please bump the crate version so that we can publish.
bors delegate+

@bors

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2019

✌️ alexheretic can now approve this pull request

@alexheretic

This comment has been minimized.

Copy link
Contributor Author

commented Apr 22, 2019

bors r+

bors bot added a commit that referenced this pull request Apr 22, 2019

Merge #38
38: Add S3TC extensions r=alexheretic a=alexheretic

This update brings `gl_generator` up to date and adds extensions:
* `GL_EXT_texture_compression_s3tc`
* `GL_EXT_texture_sRGB`

Required/justified by gfx-rs/gfx#2733

Co-authored-by: Alex Butler <alexheretic@gmail.com>
@bors

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2019

@bors bors bot merged commit 6e91340 into gfx-rs:master Apr 22, 2019

2 checks passed

bors Build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@alexheretic alexheretic deleted the alexheretic:s3tc branch Apr 22, 2019

@alexheretic

This comment has been minimized.

Copy link
Contributor Author

commented Apr 22, 2019

Thanks! Let me know when the release is available and I'll update gfx-rs/gfx#2733

@kvark

This comment has been minimized.

Copy link
Member

commented Apr 22, 2019

bors bot added a commit to gfx-rs/gfx that referenced this pull request Apr 22, 2019

Merge #2733
2733: [pre-ll] Add BC1 (DXT1), BC3 (DXT5) S3TC texture formats r=alexheretic a=alexheretic

Adds compressed BC1 & BC3 image formats for gfx_device_gl/opengl. Image data is expected to be already compressed.

New formats:
* `SurfaceType::BC1_R8_G8_B8` (DXT1)
* `SurfaceType::BC3_R8_G8_B8_A8` (DXT5)

Each supports rgb & srgb.

Resolves #2688

## Motive
I've been investigating texture compression to reduce VRAM usage in my game Robo Instructus. For this end I wanted more efficient 8-bit channel rgb & rgba storage with good opengl driver & hardware support.

S3TC is old and the best supported compression available (see https://opengl.gpuinfo.org/listcompressedformats.php). Patent issues are now history (see https://en.wikipedia.org/wiki/S3_Texture_Compression). For testing I used [GPUOpen-Tools/Compressonator](https://github.com/GPUOpen-Tools/Compressonator) for encoding, which is quite fast and seems to have decent quality.

* `BC1_R8_G8_B8` offers 8:1 compression over `R8_G8_B8_A8`
* `BC3_R8_G8_B8_A8` offers 4:1 compression over `R8_G8_B8_A8`

I didn't include BC2/DXT3, or BC7 as I don't plan to use it. However, support for this format can be trivially added on top of this change.

## No ETC2?
I did investigate ETC2 compression too which is newer yet features wide support. However, I found actual _hardware_ support for ETC2 on the desktop is much more limited that it may appear. It was a bit of a downer to see no VRAM usage reduction on my polaris RX480 when using ETC2 compressed textures. ETC2 formats also didn't seem to work without the `GL_ARB_texture_storage`/immutable storage code paths, whereas I've tested the BC1 & BC3 formats working either way. That can probably be addressed, but I didn't.

For the above reasons I decided against using ETC2 in the game & adding it here. Note though; similarly to BC2, this change will make it simpler to support ETC2 formats in future if desired.

## Issues
### OpenGL Extensions
~This code requires S3TC extensions added to `gfx_gl`. The changes there are ready to go if this PR is wanted. The gfx_gl dependency line needs to be changed:~
~gfx-rs/gfx_gl#38
Extensions now available in gfx_gl `0.6`.

### API support
Robo Instructus is an OpenGL 3.3 game so I'm not personally interested in other API support for these formats at the moment. Also considering pre-ll code is in support mode, and unsupported formats already seem common I thought it wasn't a big deal not supporting other APIs.

### Naming
I went with Vulkan naming style ie prefix with BC1. Maybe you guys have a better idea of what you'd like to name the formats. I'm not hugely fussed here.

### Format documentation
~It would be nice to have documentation for the new formats. Mentioning there various other pseudonyms & API support will probably help people wondering what BC1 does & means. However, the `impl_formats!` macro prevents easy documentation.~ I've added this. Other formats can now be fairly easily documented too.

Co-authored-by: Alex Butler <alexheretic@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.