mirror of
https://github.com/doukutsu-rs/gfx.git
synced 2026-08-24 13:03:25 -07:00
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:~ ~https://github.com/gfx-rs/gfx_gl/pull/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>
133 lines
2.8 KiB
TOML
133 lines
2.8 KiB
TOML
[package]
|
|
name = "gfx_app"
|
|
version = "0.9.0"
|
|
description = "Cross platform GFX example application framework"
|
|
homepage = "https://github.com/gfx-rs/gfx"
|
|
keywords = ["graphics", "gamedev"]
|
|
license = "Apache-2.0"
|
|
authors = ["The Gfx-rs Developers"]
|
|
documentation = "https://docs.rs/gfx_app"
|
|
|
|
[features]
|
|
default = []
|
|
mint = ["gfx/mint", "gfx_core/mint"]
|
|
metal = ["gfx_device_metal", "gfx_window_metal"]
|
|
vulkan = ["gfx_device_vulkan", "gfx_window_vulkan"]
|
|
glfw = ["gfx_window_glfw"]
|
|
sdl = ["gfx_window_sdl"]
|
|
serialize = ["gfx/serialize", "gfx_core/serialize"]
|
|
headless = ["gfx_window_glutin/headless"]
|
|
unstable = []
|
|
|
|
[lib]
|
|
name = "gfx_app"
|
|
|
|
[dependencies]
|
|
log = "0.4"
|
|
env_logger = "0.6"
|
|
glutin = "0.21"
|
|
winit = "0.19"
|
|
gfx_core = { path = "src/core", version = "0.9" }
|
|
gfx = { path = "src/render", version = "0.18" }
|
|
gfx_macros = { path = "src/macros", version = "0.2" }
|
|
gfx_device_gl = { path = "src/backend/gl", version = "0.16" }
|
|
gfx_window_glutin = { path = "src/window/glutin", version = "0.30" }
|
|
gfx_window_glfw = { path = "src/window/glfw", version = "0.17", optional = true }
|
|
gfx_window_sdl = { path = "src/window/sdl", version = "0.9", optional = true }
|
|
|
|
[dependencies.gfx_device_vulkan]
|
|
path = "src/backend/vulkan"
|
|
version = "0.2"
|
|
optional = true
|
|
|
|
[dependencies.gfx_window_vulkan]
|
|
path = "src/window/vulkan"
|
|
version = "0.9"
|
|
optional = true
|
|
|
|
[dependencies.gfx_device_metal]
|
|
path = "src/backend/metal"
|
|
version = "0.3"
|
|
optional = true
|
|
|
|
[dependencies.gfx_window_metal]
|
|
path = "src/window/metal"
|
|
version = "0.9"
|
|
optional = true
|
|
|
|
[target.'cfg(windows)'.dependencies]
|
|
gfx_device_dx11 = { path = "src/backend/dx11", version = "0.8" }
|
|
gfx_window_dxgi = { path = "src/window/dxgi", version = "0.19" }
|
|
|
|
[[example]]
|
|
name = "blend"
|
|
path = "examples/blend/main.rs"
|
|
|
|
[[example]]
|
|
name = "cube"
|
|
path = "examples/cube/main.rs"
|
|
|
|
[[example]]
|
|
name = "deferred"
|
|
path = "examples/deferred/main.rs"
|
|
|
|
[[example]]
|
|
name = "flowmap"
|
|
path = "examples/flowmap/main.rs"
|
|
|
|
[[example]]
|
|
name = "gamma"
|
|
path = "examples/gamma/main.rs"
|
|
|
|
[[example]]
|
|
name = "performance"
|
|
path = "examples/performance/main.rs"
|
|
|
|
[[example]]
|
|
name = "shadow"
|
|
path = "examples/shadow/main.rs"
|
|
|
|
[[example]]
|
|
name = "skybox"
|
|
path = "examples/skybox/main.rs"
|
|
|
|
[[example]]
|
|
name = "terrain"
|
|
path = "examples/terrain/main.rs"
|
|
|
|
[[example]]
|
|
name = "terrain_tessellated"
|
|
path = "examples/terrain_tessellated/main.rs"
|
|
|
|
[[example]]
|
|
name = "triangle"
|
|
path = "examples/triangle/main.rs"
|
|
|
|
[[example]]
|
|
name = "instancing"
|
|
path = "examples/instancing/main.rs"
|
|
|
|
[[example]]
|
|
name = "ubo_tilemap"
|
|
path = "examples/ubo_tilemap/main.rs"
|
|
|
|
[[example]]
|
|
name = "mipmap"
|
|
path = "examples/mipmap/main.rs"
|
|
|
|
[[example]]
|
|
name = "particle"
|
|
path = "examples/particle/main.rs"
|
|
|
|
[[example]]
|
|
name = "render_target"
|
|
path = "examples/render_target/main.rs"
|
|
|
|
[dev-dependencies]
|
|
cgmath = "0.17"
|
|
gfx_gl = "0.6"
|
|
rand = "0.5"
|
|
genmesh = "0.5"
|
|
noise = "0.2" #TODO: update
|
|
image = "0.21"
|