xash3d-fwgs/engine/common/imagelib
Ivan Avdeev a251600c8a
engine: common: imagelib: add KTX2 support (#1455)
* engine: common: imagelib: add KTX2 support

Adds basic KTX2 support for a few compressed formats. KTX2 essentially
is a Vulkan-centric texture format that supports literally hundreds of
pixel formats.
For now only support for these is added:
- `VK_FORMAT_BC4_UNORM_BLOCK`
- `VK_FORMAT_BC4_SNORM_BLOCK`
- `VK_FORMAT_BC5_UNORM_BLOCK`
- `VK_FORMAT_BC5_SNORM_BLOCK`
- `VK_FORMAT_BC6H_UFLOAT_BLOCK`
- `VK_FORMAT_BC6H_SFLOAT_BLOCK`
- `VK_FORMAT_BC7_UNORM_BLOCK`
- `VK_FORMAT_BC7_SRGB_BLOCK`

Adding more formats is relatively straightforward:
- Copy format definition from `VkFormat` enum in `vulkan_core.h`
- Add a new definition into `pixformat_t` enum.
- Add format size calculation into `Image_ComputeSize()`

While we're at it, also adds a few new formats to DDS:
- BC4_UNORM -- PF_BC4_UNSIGNED
- BC4_SNORM -- PF_BC4_SIGNED
- BC5_UNORM -- PF_BC5_UNSIGNED
- BC5_SNORM -- PF_BC5_SIGNED
- BC7 is expanded into BC7_UNORM and BC7_SRGB

ref_gl and ref_soft code is updated where it made sense. But not tested
really. Support for these formats has been tested with ref_vk.

* address spaces-vs-parentheses formatting where noticed

* parenthesize sizeofs

* move ktx2.h to imagelib as img_ktx2.h; massage it a bit

* use SetBits() instead of |=

* remove stale TODO comments
2023-10-18 10:31:40 +03:00
..
imagelib.h engine: common: imagelib: add KTX2 support (#1455) 2023-10-18 10:31:40 +03:00
img_bmp.c engine: imagelib: img_bmp: fully initialize local palette array 2023-01-31 00:50:04 +03:00
img_bmp.h engine: common: imagelib: added missed BMP compression type macros 2022-11-25 22:30:49 +03:00
img_dds.c engine: common: imagelib: add KTX2 support (#1455) 2023-10-18 10:31:40 +03:00
img_dds.h engine: common: imagelib: add KTX2 support (#1455) 2023-10-18 10:31:40 +03:00
img_ktx2.c engine: common: imagelib: add KTX2 support (#1455) 2023-10-18 10:31:40 +03:00
img_ktx2.h engine: common: imagelib: add KTX2 support (#1455) 2023-10-18 10:31:40 +03:00
img_main.c public: remove Q_sprintf, and patch all code that used it to use Q_snprintf instead 2023-04-26 05:20:45 +03:00
img_png.c Nintendo Switch support (again) 2023-02-05 02:09:32 +01:00
img_png.h engine: common: imagelib: img_png.c: add support for indexed and grayscale PNG images. 2022-09-08 12:11:02 +03:00
img_quant.c engine: imagelib: img_quant: fix a bug in quantizer (thanks, @SNMetamorph for fix) 2023-01-05 07:24:24 +03:00
img_tga.c Revert "engine: common: imagelib: img_tga.c: fix broken tga flip." 2022-06-25 17:03:13 +03:00
img_tga.h engine: imagelib: refactor to use stdint.h definitions, use spaces for alignment instead of tabs 2020-05-11 02:28:04 +03:00
img_utils.c engine: common: imagelib: add KTX2 support (#1455) 2023-10-18 10:31:40 +03:00
img_wad.c engine: imagelib: img_wad: dirty hack to fix black holes in console background images 2022-12-08 05:40:11 +03:00