Add dds to ktx2 lossless converter - #1223
Conversation
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
…t/KTX-Software into add-dds-to-ktx2-lossless-converter
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
…ings Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
MarkCallow
left a comment
There was a problem hiding this comment.
This is exciting. A DDS converter has been on our To Do list for a long time.
This together with your BCn codec and the format queries I mention in one of my comments will make a very nice addition to KTX-Software.
Looks good to me.
It doesn't. I just left the comment there so that I verify if there is anything I have to worry about in terms of alignment. Good to know that KTX v2 is always tightly packed (less things to worry about).
I will try to figure this out. Ruby should be fairly simple to pick up, I'll open a PR in KTX-Specification if I manage to generate the enum.
I left them commented out. Examples: // case TDDS_AYUV: return VK_FORMAT_UNDEFINED;
// case TDDS_Y410: return VK_FORMAT_UNDEFINED;
// case TDDS_Y416: return VK_FORMAT_UNDEFINED;
// case TDDS_NV12: return VK_FORMAT_UNDEFINED;
// case TDDS_P010: return VK_FORMAT_UNDEFINED;
// case TDDS_P016: return VK_FORMAT_UNDEFINED;
// case TDDS_420_OPAQUE: return VK_FORMAT_UNDEFINED;
// case TDDS_YUY2: return VK_FORMAT_UNDEFINED;
// case TDDS_Y210: return VK_FORMAT_UNDEFINED;
// case TDDS_Y216: return VK_FORMAT_UNDEFINED;
// case TDDS_NV11: return VK_FORMAT_UNDEFINED;
// case TDDS_AI44: return VK_FORMAT_UNDEFINED;
// case TDDS_IA44: return VK_FORMAT_UNDEFINED;
// case TDDS_P8: return VK_FORMAT_UNDEFINED;
// case TDDS_A8P8: return VK_FORMAT_UNDEFINED;
// ...
// case TDDS_R16_UNORM_X8_TYPELESS: return VK_FORMAT_UNDEFINED;
// case TDDS_X16_TYPELESS_G8_UINT: return VK_FORMAT_UNDEFINED;
// case TDDS_P208: return VK_FORMAT_UNDEFINED;
// case TDDS_V208: return VK_FORMAT_UNDEFINED;
// case TDDS_V408: return VK_FORMAT_UNDEFINED;
// case TDDS_R10G10B10_SNORM_A2_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_R4G4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_G4R4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_A4B4G4R4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_X4B4G4R4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_A4R4G4B4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_X4R4G4B4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_B4G4R4X4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_R4G4B4A4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_R4G4B4X4_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_B5G5R5X1_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_R5G5B5A1_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_R5G5B5X1_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_A1R5G5B5_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_X1R5G5B5_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_A1B5G5R5_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_X1B5G5R5_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_R5G6B5_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_B2G3R3_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_B2G3R3A8_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_G8R8_UNORM: return VK_FORMAT_UNDEFINED;
// case TDDS_G8R8_SNORM: return VK_FORMAT_UNDEFINED;I don't know what the |
In Vulkan formats X means unused a.k.a. padding bits. AYUV is almost certainly a YUV format with alpha. That database I mentioned is to DXGI formats. I do not know if those and DDS formats are equivalent or use the same enumeration values. |
I couldn't get my head around Ruby so I re-wrote the Ruby scripts in Python. I will open a PR feel free to accept it or close it (at least some Python equivalents can be referred to in PR search). I'm finalizing the testsuite (there are quite a lot of combinations to test). There are also some issues with |
We want to keep everything in the spec. repo. Ruby, which we need for Asciidoctor, in order to minimize dependencies so I won't accept the PR. Could the Python version of the DXGI to VkFormat generator you created be useful for working on a Ruby version? What is the answer to my TDDS vs DXGI question? |
I will try to translate it and open it as a PR in Ruby but I have never programmed in it before.
Ah, I forgot to answer. They are the same (as far as I see they map one-to-one). So once we generate TinyDDS_Format tinydds_format = TinyDDS_GetFormat(handle); // returns format in this TinyDDS-specific struct `TinyDDS_Format`
if (tinydds_format < TDDS_SYNTHESISED_DXGIFORMATS) {
DXGI_FORMAT dxgi_format = static_cast<DXGI_FORMAT>(tinydds_format); // they map 1-to-1
} else {
// unsupported format (see comment below)
}The formats that cannot be translated from TinyDDS to DXGI_FORMAT are these: KTX-Software/external/basis_universal/encoder/3rdparty/tinydds.h Lines 333 to 387 in 7b08882 |
There is this comment already that addresses it, no? |
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
|
30a7e76 has an incorrect commit id for tests/cts. The id does not exist. Hence the build failures. |
|
Yes, I always keep forgetting to push local CTS changes. Apologies for the mess/many CI runs. On a side note, I'm trying to clean-up all my currently open PRs so that they are finally finalized. |
|
There is an edge case where |
Ouch! That definitely needs fixing. Sounds like a bug in the GIMP exporter to me. |
It's probably not. Even for older versions of NVTT sRGB is being exported as Also // Not all tools support DXGI_FORMAT_BC7_UNORM_SRGB (like NVTT), but ddsview in DirectXTex pays attention to it. So not sure what to do here.
// For best compatibility just write DXGI_FORMAT_BC7_UNORM.
//hdr10.dxgiFormat = srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM;
hdr10.dxgiFormat = dxgi_format; // DXGI_FORMAT_BC7_UNORM;
hdr10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE2D;
hdr10.arraySize = 1;A great argument on why KTX is superior to DDS is that we have the At worst, we might just add a flag to force to-sRGB vkFormat conversion even if input is UNORM. I will address this once I finalize the BCn PR. |
KTX has rules that allow "mismatched" VkFormat and KHR_DF_TRANSFER only in limited circumstances. Using a UNORM format with
This would not be conversion. It would be assignment,
Please. There is no rush as I will not be merging the converter until v5.0.0 is released. Unfortunately I do not know how much longer it will be until the item blocking its release is resolved. It has nothing to do with the software. |
What a shit show. In my view broken viewers are no excuse for a texture creation tool to be outputting incorrect data. |
Fixes #92.
Still in draft because testing isn't yet done (a bit difficult since I have to use my other BCn PR to test extracts)=> is now ready for review (still a couple of missing edge-case test files and invalid dds test files).Feel free to give an early review but this is still far from done.