-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix KTX2 header initialization in included BasisU code #848
Conversation
Two questions:
|
I cloned this repository, built it as a static library, and linked it to my project. Since KTX already contains a copy of BasisU, I'm using it to convert a As far as I understand, the struct is not initialized to 0 because it's not a POD struct, because |
I still do not understand how you end up calling this code. libktx does not use it. When it uses one of the BasisU codecs it has it create a .basis file in memory which it converts to a ktxTexture2 object. It does not call function containing the line of code you have changed. If you are calling this API directly that is unsupported. It is not exposed in ktx.h nor is it exported when building a DLL. Since libktx doesn't use this code it may very possibly be removed in a future release. You can use |
I guess I misused the library. I didn't find a way to create a .ktx2 file from a .png using ktx (none of the create functions are taking a pointer to raw png data, at least I didn't find one). And that's why I thought I needed to convert it to KTX2 using BasisU which is inside |
What you are doing could never have worked if you are using this repo's root We would not use BasisU's I am curious why there was no compiler warning or error due to the non-POD struct issue. We have warnings as errors in our CI builds, though we disable some in clang and gcc. Are you using the MSVC or clang toolset in VS 2022? The disabled clang warnings do not seem to be any of those I would expect to see due to the non-POD struct issue. I'm going to merge this so we don't inadvertently push the broken code upstream to the BasisU repo. |
I didn't use any custom builds. I cloned the repo, generated the project files using CMake (as static library), built the project, copied KTX and BasisU include files to my project, and also linked my project to KTX Ah, I see. Sorry, I incorrectly expressed myself in the last message. I wasn't trying to feed the libraries a pointer to raw png data. Here's what I'm doing currently:
I think I need to make myself more familiar with other KTX tools such as Yes, that's a bit strange, I also didn't see any warnings. I'm using MSVC. |
I see. That makes sense. You can do something very similar via the libktx API. You first have to determine a VkFormat that matches the color type of the PNG file, as modified by whatever parameters you pass to the
Using the KTX tools will be much easier than writing your own.
All level 4 warnings are enabled in MSVC builds so it must be that MSVC does not warn in such circumstance which I would consider a bug. |
Do I understand correctly, that all I need to do is this?
Seems like it's working. But how do I generate compressed mips? Here I set the image data from Do I need to generate mips on my side and pass the data using Thanks! |
Yes. Open issue #464 has requested mipmapping capabilities be added to libktx. We haven't decided yet. It's a big chunk of code, even bigger if it mipmap generation for 3d textures is added. Currently
Be careful that you match the format, |
Ok, much thanks for the help! One last question: currently, compression of HDR textures is not supported, right? I couldn't find any information on how to do it |
Right. We plan to support compression to ASTC HDR soon and I believe Binomial is working on a universal codec for HDR. I've no idea of its ETA. |
Ok. Thanks again! |
) A change we made to the the subrepo'ed BasisU code as part of the mass warning fixes in PR KhronosGroup#687 broke initialization of the KTX2 header when BasisU is creating a .ktx2 file. This code is not used by libktx. The fix is being committed to avoid inadvertently pushing the broken code upstream. The user who encountered this was doing something unsupported by libktx.
) A change we made to the the subrepo'ed BasisU code as part of the mass warning fixes in PR KhronosGroup#687 broke initialization of the KTX2 header when BasisU is creating a .ktx2 file. This code is not used by libktx. The fix is being committed to avoid inadvertently pushing the broken code upstream. The user who encountered this was doing something unsupported by libktx.
) A change we made to the the subrepo'ed BasisU code as part of the mass warning fixes in PR KhronosGroup#687 broke initialization of the KTX2 header when BasisU is creating a .ktx2 file. This code is not used by libktx. The fix is being committed to avoid inadvertently pushing the broken code upstream. The user who encountered this was doing something unsupported by libktx.
) A change we made to the the subrepo'ed BasisU code as part of the mass warning fixes in PR KhronosGroup#687 broke initialization of the KTX2 header when BasisU is creating a .ktx2 file. This code is not used by libktx. The fix is being committed to avoid inadvertently pushing the broken code upstream. The user who encountered this was doing something unsupported by libktx.
) A change we made to the the subrepo'ed BasisU code as part of the mass warning fixes in PR KhronosGroup#687 broke initialization of the KTX2 header when BasisU is creating a .ktx2 file. This code is not used by libktx. The fix is being committed to avoid inadvertently pushing the broken code upstream. The user who encountered this was doing something unsupported by libktx.
KTX2 header wasn't initialized correctly which led to bugs. In my case, this code was succeeding, but
ktxTexture->baseDepth
was containing garbage because of it.I'm not sure why this was changed though
https://github.com/KhronosGroup/KTX-Software/pull/687/files#diff-00fb4e838b1a5a861eb92b498116262bbf956d06d6ae0bab54b1b30fb4e2acbc