Refactor of mipmapping support and vsgXchange::ktx and dds loaders #1605
robertosfield
started this conversation in
General
Replies: 2 comments 8 replies
-
|
Without external KTX library, building vsgXchange from master fails: "undefined reference to vsgXchange::ktx::~ktx()" |
Beta Was this translation helpful? Give feedback.
5 replies
-
|
Test on MacOS 26.1 / M4 Max / Vulkan 1.4.238.1 / VSG latest commits: is running very well. Doing this leads to a problem: See attachments. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
For the past 3 weeks I've went down a KTX image loader rabbit hole, now finally I've got it all working and have updated the dds and the VSG's mipping mapping support and created a vsgsampler example as part of this work. Changes are now checked into respective masters:
The big change is refactoring vsgXchange::ktx support so that rather than including an old version of KTX-Software source directly in vsgXchange/src/ktx I have instead moved to linking to libktx as a 3rd party library. The main motivation behind this was to enable full use of ktx2 along with basisu support, which means we'll be able to read imagery that is highly compressed on disk that is directly trans-coded into compressed GPU block textures. This makes it perfect for streaming such as when using paged databases.
Over the past 4 months I've also done a lot of work using .dds image format and came across rendering problems when combining .dds files that used GPU block textures and mipmaps, this issue would show itself on screen as corrupted mipmaps. The refactor of vsgXchange::ktx also tripped up on this same rendering problem once I started loading GPU block textures with mipmaps. I tracked down the the cause of the rendering issues to .dds and .ktx2 files that used GPU block compression and started off with image sizes that weren't a multiple of the block size, such as a 511x511 texture that used 4x4 block compression and mipmaps, the actual data is always round up to the nearest 4 so you get some very odd mipmap sizes on the way down. This curious edge case broke the VSG's assumption of mipmaps halving in size on each successive mipmap.
To resolve this issue I had to rewrite how the VSG handled mipmap layout, providing the option to explicitly specify the layout using a new vsg::MipmapLayout class that provides the pixel size { width, height, depth} along with the offset into the memory used for the texture image. For backwards compatibility the VSG's image related classes also retain the ability to compute the mipmap sizes implicitly when an explicit MipmapLayout isn't provided.
The help test the changes to vsgXchange::dds, vsgXchange::ktx and the mipmapping support I wrote a [vsgsample] example. Here's in it action rendering the testimages that can be found in the KTX-Software repo.
Not all the target VkFormats specified in all test KTX images are supported by all graphics hardware/drivers so I've added a runtime query into the vsgsampler example to check for support and report to the console about lack of support. So expect console output like the following:
I have bumped the versions to VulkanSceneGraph-1.1.12, vsgXchange-1.1.8 and vsgExamples-1.1.13 and once we've done more testing across a wider range of OS and build combinations and resolved any issues I'll push ahead and make developer releases for these version numbers. I'd appreciate testing and feedback so we can get these tagged quickly, potentially this week.
Beta Was this translation helpful? Give feedback.
All reactions