Skip to content

feat: add DXGI-to-VkFormat switch generation script - #235

Open
walcht wants to merge 6 commits into
KhronosGroup:mainfrom
walcht:add-dxgi-to-vkformat-script
Open

feat: add DXGI-to-VkFormat switch generation script#235
walcht wants to merge 6 commits into
KhronosGroup:mainfrom
walcht:add-dxgi-to-vkformat-script

Conversation

@walcht

@walcht walcht commented Jul 24, 2026

Copy link
Copy Markdown

Some consumers may need a specification-compliant (and much easier to integrate) auto-generated DXGI-to-VkFormat switch. E.g., DDS to KTX2 converters have to figure out the corresponding VkFormat of the input DDS DXGI format.

Related: KhronosGroup/KTX-Software#1223

* Some consumers may need a specification-compliant (and much easier to
  integrate) auto-generated DXGI-to-VkFormat switch. E.g., DDS to KTX2
  converters have to figure out the corresponding VkFormat of the input
  DDS DXGI format.

Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
@CLAassistant

CLAassistant commented Jul 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

walcht added 3 commits July 24, 2026 13:37
* Some librarise map same DXGI enum value to custom enums with same
  names but only prefixed by some value (see tinydds.h for an example).
  This is disabled by default and is only a placeholder for convenience.

Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
* We assume that the first encountered DXGI-to-VkFormat conversion is the most
  suitable DXGI-to-VkFormat conversion. Without this check we will end up with
  multiple similar case statements on same DXGI enum values because
  'formats.json' is used to map VkFormat to other formats and can, therefore,
  map to same DXGI value multiple times (e.g., DXGI_FORMAT_R8G8B8A8_UNORM)

Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
@MarkCallow

Copy link
Copy Markdown
Contributor

Looks good. Would be great to extend switch_test to cover this. I know at present it only covers the VkFormal to GL switches. I am planning to add vk2dxgi and vk2metal tests when I add those queries I mentioned to KTX-Software. For those queries I have created header files with the DXGI and Metal formats which can be used for those tests.

walcht added 2 commits July 25, 2026 04:11
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
Signed-off-by: Walid Chtioui <walid.chtioui.main@gmail.com>
@walcht

walcht commented Jul 25, 2026

Copy link
Copy Markdown
Author

Would be great to extend switch_test to cover this.

Done. By the way, generating DXGI->VkFormat mappings from reverse VkFormat->DXGI might not be ideal because multiple DXGI formats can (need to verify) map to the same VkFormat.

E.g., see DXGI_\w+_TYPELESS formats. These are currently not supported but can (as far as I understand) map to some VkFormats. Same with DXGI formats with the X\d+ placeholder.

At the very least, we can be confident that the generated switches, even though they cover only a subset, are 100% correct and with no ambiguity.

@MarkCallow

Copy link
Copy Markdown
Contributor

By the way, generating DXGI->VkFormat mappings from reverse VkFormat->DXGI might not be ideal because multiple DXGI formats can (need to verify) map to the same VkFormat.

E.g., see DXGI_\w+_TYPELESS formats. These are currently not supported but can (as far as I understand) map to some VkFormats. Same with DXGI formats with the X\d+ placeholder.

We must look into this but keep in mind that

  • some VkFormats are not allowed in KTX, mostly multi-plane YUV formats and formats used for vertices rather than images
  • and some VkFormats with the X placeholder do not exist outside a Vulkan implementation. That is they cannot be uploaded to the GPU. That is why KTX defines specific mappings for depth and stencil formats which have X placeholders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants