10 Commits

Author SHA1 Message Date
Mathias Agopian
a943b57c86 ktxreader: Fix vulnerabilities and memory leaks in Ktx2Reader.cpp
- Implement PR #9842 to fix integer overflows in transcodeImageLevel.
- Fix potential division by zero in transcodeImageLevel if bytesPerPix is 0.
- Fix memory leaks in transcodeImageLevel by freeing allocated buffers on
  failure.
- Fix memory leak in Ktx2Reader::load by deleting PixelBufferDescriptor after
  use.
2026-04-16 09:10:08 -07:00
Powei Feng
e501a15ef2 gltfio: Release cancelled, decoded texture resources (#6620)
When we call TextureProvider::cancelDecoding, we should make sure
that textures that have been decoded, but not yet used (popped)
should be released (i.e. memory freed and the meta data marked
appropriately.)
2023-03-20 10:34:24 -07:00
Koncz Levente
c2fcaf7a6b Add RGTC + BPTC support (#6320)
* Add RGTC support
* Add BPTC support
2022-12-06 11:18:35 -08:00
Pei Jia
edb9ca71e5 included header files are now in alphabetic order 2022-05-11 15:04:53 -07:00
Pei Jia
ad9ce72f61 header files added, for compatibility of clang c++17. Don't forget to add -std=c++17. 2022-05-11 15:04:53 -07:00
Philip Rideout
b7c9a36d57 Ktx2Reader: Fix error in enum translation table.
This caused DXT5 content to be interpreted as DXT3 by the GPU,
which seemed to manifest as visual artifacts in the alpha channel.
2022-04-29 16:29:53 -07:00
Philip Rideout
d76551ab28 Add async interface to Ktx2Reader. 2022-04-29 14:20:57 -07:00
Philip Rideout
3f0dc6f7e6 Minor Ktx2Reader refactoring. 2022-04-18 15:02:08 -07:00
Philip Rideout
d52a24b6e9 Incorporate feedback from code review. 2022-04-15 10:48:48 -07:00
Philip Rideout
9aeec3a759 Add Ktx2Reader and BasisEncoder and use them in samples.
mipgen can now emit basis-encoded KTX2 files. Both the desktop and
web "suzanne" samples use this as a test for compressed textures.

This PR does not add KTX2 support to glTF, but it's on the way.

`BasisEncoder` has a builder style API that calls the basis encoder to
create KTX2 files. This hides some low-level BasisU features that we are
not using, like file I/O and mipmap generation.

`Ktx2Reader` is an easy-to-use API for creating Filament textures from
KTX2 files. Its API primarily consists of these two methods:

    bool requestFormat(Texture::InternalFormat format);
    Filament::Texture* load(const uint8_t* data, size_t size);

The first method is used to build an ordered list of formats that are
supported by your hardware. The second method consumes the contents of a
basis-encoded KTX2 file and attempts to produce a Filament texture with
a preferred format.

IMPORTANT: Our tools still let you use KTX1 for non-compressed images
because it is useful for HDR, but you can no longer use KTX1 for
block-compressed data.

Partial fix for #4771.
2022-04-15 10:48:48 -07:00