bkaradzic / bimg

Image library.
BSD 2-Clause "Simplified" License
327 stars 268 forks source link

PVRTC decoding: incorrect morton offset for non-square textures #61

Open attilaz opened 3 years ago

attilaz commented 3 years ago

Morton offset should take texture dimensions into account see reflectedMortonOffset function:

https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#_format_pvrtc1_4bpp

Current implementation https://github.com/bkaradzic/bimg/blob/master/src/image.cpp#L2973 causes crashes/incorrect textures for non-square textures.

I can send PR with the function in specs, but current implementation seems more optimized.

bkaradzic commented 3 years ago

Can you attach PVRTC texture that would crash?

attilaz commented 3 years ago

I had a crash on windows with texturev. crash

fractal.zip