From 3ab7bb46f6a3ad35f2ba2a85f2b515ccfc6d92dd Mon Sep 17 00:00:00 2001 From: ouczbs Date: Sat, 21 Sep 2024 17:19:22 +0800 Subject: [PATCH] update --- .../core/{include => }/3rdparty/singleton.h | 0 .../{include => }/3rdparty/source_location.h | 0 .../core/{include => }/3rdparty/yyjson.h | 0 .../engine/core/{include => }/3rdparty/zlog.h | 0 engine/modules/engine/core/xmake.lua | 2 +- .../tinyimageformat/tinyimageformat_apis.h | 2445 ++++++++++ .../tinyimageformat/tinyimageformat_base.h | 523 ++ .../tinyimageformat/tinyimageformat_bits.h | 281 ++ .../tinyimageformat/tinyimageformat_decode.h | 2139 +++++++++ .../tinyimageformat/tinyimageformat_encode.h | 1906 ++++++++ .../tinyimageformat/tinyimageformat_query.h | 4217 +++++++++++++++++ .../render/include/render/graph/frame_graph.h | 2 + .../engine/render/include/render/graph/type.h | 65 +- .../engine/render/include/render/renderapi.h | 4 + .../engine/render/include/render/type.h | 21 + .../engine/render/src/graph/frame_graph.cpp | 75 +- .../render/src/graph/frame_graph_builder.cpp | 23 +- engine/modules/engine/render/xmake.lua | 1 + .../render/vulkan/include/vkn/vulkan_api.h | 8 +- .../vulkan/include/vkn/vulkan_api_help.h | 4 + .../modules/render/vulkan/src/vulkan_api.cpp | 32 +- .../render/vulkan/src/vulkan_api_help.cpp | 103 + game/zworld/src/zworld.cpp | 4 +- 23 files changed, 11777 insertions(+), 78 deletions(-) rename engine/modules/engine/core/{include => }/3rdparty/singleton.h (100%) rename engine/modules/engine/core/{include => }/3rdparty/source_location.h (100%) rename engine/modules/engine/core/{include => }/3rdparty/yyjson.h (100%) rename engine/modules/engine/core/{include => }/3rdparty/zlog.h (100%) create mode 100644 engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_apis.h create mode 100644 engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_base.h create mode 100644 engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_bits.h create mode 100644 engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_decode.h create mode 100644 engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_encode.h create mode 100644 engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_query.h create mode 100644 engine/modules/render/vulkan/include/vkn/vulkan_api_help.h create mode 100644 engine/modules/render/vulkan/src/vulkan_api_help.cpp diff --git a/engine/modules/engine/core/include/3rdparty/singleton.h b/engine/modules/engine/core/3rdparty/singleton.h similarity index 100% rename from engine/modules/engine/core/include/3rdparty/singleton.h rename to engine/modules/engine/core/3rdparty/singleton.h diff --git a/engine/modules/engine/core/include/3rdparty/source_location.h b/engine/modules/engine/core/3rdparty/source_location.h similarity index 100% rename from engine/modules/engine/core/include/3rdparty/source_location.h rename to engine/modules/engine/core/3rdparty/source_location.h diff --git a/engine/modules/engine/core/include/3rdparty/yyjson.h b/engine/modules/engine/core/3rdparty/yyjson.h similarity index 100% rename from engine/modules/engine/core/include/3rdparty/yyjson.h rename to engine/modules/engine/core/3rdparty/yyjson.h diff --git a/engine/modules/engine/core/include/3rdparty/zlog.h b/engine/modules/engine/core/3rdparty/zlog.h similarity index 100% rename from engine/modules/engine/core/include/3rdparty/zlog.h rename to engine/modules/engine/core/3rdparty/zlog.h diff --git a/engine/modules/engine/core/xmake.lua b/engine/modules/engine/core/xmake.lua index 5cd8a61..0f67862 100644 --- a/engine/modules/engine/core/xmake.lua +++ b/engine/modules/engine/core/xmake.lua @@ -2,7 +2,7 @@ static_component("core","engine") add_rules("c++.codegen",{ files = {"include/module/module.h"} }) - add_includedirs("include/3rdparty", {public = true}) + add_includedirs("3rdparty", {public = true}) add_headerfiles("include/**.h","include/**.inl", "impl/*.inl") add_files("src/**.cpp") add_deps("zlib") diff --git a/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_apis.h b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_apis.h new file mode 100644 index 0000000..28051ee --- /dev/null +++ b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_apis.h @@ -0,0 +1,2445 @@ +// Auto generated by formatgen on Sep 21 2019 +#pragma once +#if !defined(TINYIMAGEFORMAT_APIS_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) +#define TINYIMAGEFORMAT_APIS_H_ 1 + +#include "tinyimageformat_base.h" + +#ifndef TINYIMAGEFORMAT_VKFORMAT +#define TINYIMAGEFORMAT_VKFORMAT +typedef enum TinyImageFormat_VkFormat { + TIF_VK_FORMAT_UNDEFINED = 0, + TIF_VK_FORMAT_R4G4_UNORM_PACK8 = 1, + TIF_VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2, + TIF_VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3, + TIF_VK_FORMAT_R5G6B5_UNORM_PACK16 = 4, + TIF_VK_FORMAT_B5G6R5_UNORM_PACK16 = 5, + TIF_VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6, + TIF_VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7, + TIF_VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8, + TIF_VK_FORMAT_R8_UNORM = 9, + TIF_VK_FORMAT_R8_SNORM = 10, + TIF_VK_FORMAT_R8_USCALED = 11, + TIF_VK_FORMAT_R8_SSCALED = 12, + TIF_VK_FORMAT_R8_UINT = 13, + TIF_VK_FORMAT_R8_SINT = 14, + TIF_VK_FORMAT_R8_SRGB = 15, + TIF_VK_FORMAT_R8G8_UNORM = 16, + TIF_VK_FORMAT_R8G8_SNORM = 17, + TIF_VK_FORMAT_R8G8_USCALED = 18, + TIF_VK_FORMAT_R8G8_SSCALED = 19, + TIF_VK_FORMAT_R8G8_UINT = 20, + TIF_VK_FORMAT_R8G8_SINT = 21, + TIF_VK_FORMAT_R8G8_SRGB = 22, + TIF_VK_FORMAT_R8G8B8_UNORM = 23, + TIF_VK_FORMAT_R8G8B8_SNORM = 24, + TIF_VK_FORMAT_R8G8B8_USCALED = 25, + TIF_VK_FORMAT_R8G8B8_SSCALED = 26, + TIF_VK_FORMAT_R8G8B8_UINT = 27, + TIF_VK_FORMAT_R8G8B8_SINT = 28, + TIF_VK_FORMAT_R8G8B8_SRGB = 29, + TIF_VK_FORMAT_B8G8R8_UNORM = 30, + TIF_VK_FORMAT_B8G8R8_SNORM = 31, + TIF_VK_FORMAT_B8G8R8_USCALED = 32, + TIF_VK_FORMAT_B8G8R8_SSCALED = 33, + TIF_VK_FORMAT_B8G8R8_UINT = 34, + TIF_VK_FORMAT_B8G8R8_SINT = 35, + TIF_VK_FORMAT_B8G8R8_SRGB = 36, + TIF_VK_FORMAT_R8G8B8A8_UNORM = 37, + TIF_VK_FORMAT_R8G8B8A8_SNORM = 38, + TIF_VK_FORMAT_R8G8B8A8_USCALED = 39, + TIF_VK_FORMAT_R8G8B8A8_SSCALED = 40, + TIF_VK_FORMAT_R8G8B8A8_UINT = 41, + TIF_VK_FORMAT_R8G8B8A8_SINT = 42, + TIF_VK_FORMAT_R8G8B8A8_SRGB = 43, + TIF_VK_FORMAT_B8G8R8A8_UNORM = 44, + TIF_VK_FORMAT_B8G8R8A8_SNORM = 45, + TIF_VK_FORMAT_B8G8R8A8_USCALED = 46, + TIF_VK_FORMAT_B8G8R8A8_SSCALED = 47, + TIF_VK_FORMAT_B8G8R8A8_UINT = 48, + TIF_VK_FORMAT_B8G8R8A8_SINT = 49, + TIF_VK_FORMAT_B8G8R8A8_SRGB = 50, + TIF_VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51, + TIF_VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52, + TIF_VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53, + TIF_VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54, + TIF_VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55, + TIF_VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56, + TIF_VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57, + TIF_VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58, + TIF_VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59, + TIF_VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60, + TIF_VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61, + TIF_VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62, + TIF_VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63, + TIF_VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64, + TIF_VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65, + TIF_VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66, + TIF_VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67, + TIF_VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68, + TIF_VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69, + TIF_VK_FORMAT_R16_UNORM = 70, + TIF_VK_FORMAT_R16_SNORM = 71, + TIF_VK_FORMAT_R16_USCALED = 72, + TIF_VK_FORMAT_R16_SSCALED = 73, + TIF_VK_FORMAT_R16_UINT = 74, + TIF_VK_FORMAT_R16_SINT = 75, + TIF_VK_FORMAT_R16_SFLOAT = 76, + TIF_VK_FORMAT_R16G16_UNORM = 77, + TIF_VK_FORMAT_R16G16_SNORM = 78, + TIF_VK_FORMAT_R16G16_USCALED = 79, + TIF_VK_FORMAT_R16G16_SSCALED = 80, + TIF_VK_FORMAT_R16G16_UINT = 81, + TIF_VK_FORMAT_R16G16_SINT = 82, + TIF_VK_FORMAT_R16G16_SFLOAT = 83, + TIF_VK_FORMAT_R16G16B16_UNORM = 84, + TIF_VK_FORMAT_R16G16B16_SNORM = 85, + TIF_VK_FORMAT_R16G16B16_USCALED = 86, + TIF_VK_FORMAT_R16G16B16_SSCALED = 87, + TIF_VK_FORMAT_R16G16B16_UINT = 88, + TIF_VK_FORMAT_R16G16B16_SINT = 89, + TIF_VK_FORMAT_R16G16B16_SFLOAT = 90, + TIF_VK_FORMAT_R16G16B16A16_UNORM = 91, + TIF_VK_FORMAT_R16G16B16A16_SNORM = 92, + TIF_VK_FORMAT_R16G16B16A16_USCALED = 93, + TIF_VK_FORMAT_R16G16B16A16_SSCALED = 94, + TIF_VK_FORMAT_R16G16B16A16_UINT = 95, + TIF_VK_FORMAT_R16G16B16A16_SINT = 96, + TIF_VK_FORMAT_R16G16B16A16_SFLOAT = 97, + TIF_VK_FORMAT_R32_UINT = 98, + TIF_VK_FORMAT_R32_SINT = 99, + TIF_VK_FORMAT_R32_SFLOAT = 100, + TIF_VK_FORMAT_R32G32_UINT = 101, + TIF_VK_FORMAT_R32G32_SINT = 102, + TIF_VK_FORMAT_R32G32_SFLOAT = 103, + TIF_VK_FORMAT_R32G32B32_UINT = 104, + TIF_VK_FORMAT_R32G32B32_SINT = 105, + TIF_VK_FORMAT_R32G32B32_SFLOAT = 106, + TIF_VK_FORMAT_R32G32B32A32_UINT = 107, + TIF_VK_FORMAT_R32G32B32A32_SINT = 108, + TIF_VK_FORMAT_R32G32B32A32_SFLOAT = 109, + TIF_VK_FORMAT_R64_UINT = 110, + TIF_VK_FORMAT_R64_SINT = 111, + TIF_VK_FORMAT_R64_SFLOAT = 112, + TIF_VK_FORMAT_R64G64_UINT = 113, + TIF_VK_FORMAT_R64G64_SINT = 114, + TIF_VK_FORMAT_R64G64_SFLOAT = 115, + TIF_VK_FORMAT_R64G64B64_UINT = 116, + TIF_VK_FORMAT_R64G64B64_SINT = 117, + TIF_VK_FORMAT_R64G64B64_SFLOAT = 118, + TIF_VK_FORMAT_R64G64B64A64_UINT = 119, + TIF_VK_FORMAT_R64G64B64A64_SINT = 120, + TIF_VK_FORMAT_R64G64B64A64_SFLOAT = 121, + TIF_VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122, + TIF_VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123, + TIF_VK_FORMAT_D16_UNORM = 124, + TIF_VK_FORMAT_X8_D24_UNORM_PACK32 = 125, + TIF_VK_FORMAT_D32_SFLOAT = 126, + TIF_VK_FORMAT_S8_UINT = 127, + TIF_VK_FORMAT_D16_UNORM_S8_UINT = 128, + TIF_VK_FORMAT_D24_UNORM_S8_UINT = 129, + TIF_VK_FORMAT_D32_SFLOAT_S8_UINT = 130, + TIF_VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131, + TIF_VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132, + TIF_VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133, + TIF_VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134, + TIF_VK_FORMAT_BC2_UNORM_BLOCK = 135, + TIF_VK_FORMAT_BC2_SRGB_BLOCK = 136, + TIF_VK_FORMAT_BC3_UNORM_BLOCK = 137, + TIF_VK_FORMAT_BC3_SRGB_BLOCK = 138, + TIF_VK_FORMAT_BC4_UNORM_BLOCK = 139, + TIF_VK_FORMAT_BC4_SNORM_BLOCK = 140, + TIF_VK_FORMAT_BC5_UNORM_BLOCK = 141, + TIF_VK_FORMAT_BC5_SNORM_BLOCK = 142, + TIF_VK_FORMAT_BC6H_UFLOAT_BLOCK = 143, + TIF_VK_FORMAT_BC6H_SFLOAT_BLOCK = 144, + TIF_VK_FORMAT_BC7_UNORM_BLOCK = 145, + TIF_VK_FORMAT_BC7_SRGB_BLOCK = 146, + TIF_VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147, + TIF_VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148, + TIF_VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149, + TIF_VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150, + TIF_VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151, + TIF_VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152, + TIF_VK_FORMAT_EAC_R11_UNORM_BLOCK = 153, + TIF_VK_FORMAT_EAC_R11_SNORM_BLOCK = 154, + TIF_VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155, + TIF_VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156, + TIF_VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157, + TIF_VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158, + TIF_VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159, + TIF_VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160, + TIF_VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161, + TIF_VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162, + TIF_VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163, + TIF_VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164, + TIF_VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165, + TIF_VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166, + TIF_VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167, + TIF_VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168, + TIF_VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169, + TIF_VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170, + TIF_VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171, + TIF_VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172, + TIF_VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173, + TIF_VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174, + TIF_VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175, + TIF_VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176, + TIF_VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177, + TIF_VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178, + TIF_VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179, + TIF_VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180, + TIF_VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181, + TIF_VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182, + TIF_VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183, + TIF_VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184, + + TIF_VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000, + TIF_VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001, + TIF_VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002, + TIF_VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003, + TIF_VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004, + TIF_VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005, + TIF_VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006, + TIF_VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007, + TIF_VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008, + TIF_VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009, + TIF_VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010, + TIF_VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011, + TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012, + TIF_VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013, + TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014, + TIF_VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015, + TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016, + TIF_VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017, + TIF_VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018, + TIF_VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019, + TIF_VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020, + TIF_VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021, + TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022, + TIF_VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023, + TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024, + TIF_VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025, + TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026, + TIF_VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027, + TIF_VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028, + TIF_VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029, + TIF_VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030, + TIF_VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031, + TIF_VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032, + TIF_VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033, + TIF_VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, + TIF_VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, + TIF_VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, + TIF_VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, + TIF_VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, + TIF_VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, + TIF_VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, + TIF_VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, +} TinyImageFormat_VkFormat; +#endif + +inline TinyImageFormat TinyImageFormat_FromVkFormat(TinyImageFormat_VkFormat fmt) { + switch (fmt) { + + case TIF_VK_FORMAT_UNDEFINED: return TinyImageFormat_UNDEFINED; + case TIF_VK_FORMAT_R4G4_UNORM_PACK8: return TinyImageFormat_G4R4_UNORM; + case TIF_VK_FORMAT_R4G4B4A4_UNORM_PACK16: return TinyImageFormat_A4B4G4R4_UNORM; + case TIF_VK_FORMAT_B4G4R4A4_UNORM_PACK16: return TinyImageFormat_A4R4G4B4_UNORM; + case TIF_VK_FORMAT_R5G6B5_UNORM_PACK16: return TinyImageFormat_B5G6R5_UNORM; + case TIF_VK_FORMAT_B5G6R5_UNORM_PACK16: return TinyImageFormat_R5G6B5_UNORM; + case TIF_VK_FORMAT_R5G5B5A1_UNORM_PACK16: return TinyImageFormat_A1B5G5R5_UNORM; + case TIF_VK_FORMAT_B5G5R5A1_UNORM_PACK16: return TinyImageFormat_A1R5G5B5_UNORM; + case TIF_VK_FORMAT_A1R5G5B5_UNORM_PACK16: return TinyImageFormat_B5G5R5A1_UNORM; + case TIF_VK_FORMAT_R8_UNORM: return TinyImageFormat_R8_UNORM; + case TIF_VK_FORMAT_R8_SNORM: return TinyImageFormat_R8_SNORM; + case TIF_VK_FORMAT_R8_UINT: return TinyImageFormat_R8_UINT; + case TIF_VK_FORMAT_R8_SINT: return TinyImageFormat_R8_SINT; + case TIF_VK_FORMAT_R8_SRGB: return TinyImageFormat_R8_SRGB; + case TIF_VK_FORMAT_R8G8_UNORM: return TinyImageFormat_R8G8_UNORM; + case TIF_VK_FORMAT_R8G8_SNORM: return TinyImageFormat_R8G8_SNORM; + case TIF_VK_FORMAT_R8G8_UINT: return TinyImageFormat_R8G8_UINT; + case TIF_VK_FORMAT_R8G8_SINT: return TinyImageFormat_R8G8_SINT; + case TIF_VK_FORMAT_R8G8_SRGB: return TinyImageFormat_R8G8_SRGB; + case TIF_VK_FORMAT_R8G8B8_UNORM: return TinyImageFormat_R8G8B8_UNORM; + case TIF_VK_FORMAT_R8G8B8_SNORM: return TinyImageFormat_R8G8B8_SNORM; + case TIF_VK_FORMAT_R8G8B8_UINT: return TinyImageFormat_R8G8B8_UINT; + case TIF_VK_FORMAT_R8G8B8_SINT: return TinyImageFormat_R8G8B8_SINT; + case TIF_VK_FORMAT_R8G8B8_SRGB: return TinyImageFormat_R8G8B8_SRGB; + case TIF_VK_FORMAT_B8G8R8_UNORM: return TinyImageFormat_B8G8R8_UNORM; + case TIF_VK_FORMAT_B8G8R8_SNORM: return TinyImageFormat_B8G8R8_SNORM; + case TIF_VK_FORMAT_B8G8R8_UINT: return TinyImageFormat_B8G8R8_UINT; + case TIF_VK_FORMAT_B8G8R8_SINT: return TinyImageFormat_B8G8R8_SINT; + case TIF_VK_FORMAT_B8G8R8_SRGB: return TinyImageFormat_B8G8R8_SRGB; + case TIF_VK_FORMAT_R8G8B8A8_UNORM: return TinyImageFormat_R8G8B8A8_UNORM; + case TIF_VK_FORMAT_R8G8B8A8_SNORM: return TinyImageFormat_R8G8B8A8_SNORM; + case TIF_VK_FORMAT_R8G8B8A8_UINT: return TinyImageFormat_R8G8B8A8_UINT; + case TIF_VK_FORMAT_R8G8B8A8_SINT: return TinyImageFormat_R8G8B8A8_SINT; + case TIF_VK_FORMAT_R8G8B8A8_SRGB: return TinyImageFormat_R8G8B8A8_SRGB; + case TIF_VK_FORMAT_B8G8R8A8_UNORM: return TinyImageFormat_B8G8R8A8_UNORM; + case TIF_VK_FORMAT_B8G8R8A8_SNORM: return TinyImageFormat_B8G8R8A8_SNORM; + case TIF_VK_FORMAT_B8G8R8A8_UINT: return TinyImageFormat_B8G8R8A8_UINT; + case TIF_VK_FORMAT_B8G8R8A8_SINT: return TinyImageFormat_B8G8R8A8_SINT; + case TIF_VK_FORMAT_B8G8R8A8_SRGB: return TinyImageFormat_B8G8R8A8_SRGB; + case TIF_VK_FORMAT_A2R10G10B10_UNORM_PACK32: return TinyImageFormat_B10G10R10A2_UNORM; + case TIF_VK_FORMAT_A2R10G10B10_UINT_PACK32: return TinyImageFormat_B10G10R10A2_UINT; + case TIF_VK_FORMAT_A2B10G10R10_UNORM_PACK32: return TinyImageFormat_R10G10B10A2_UNORM; + case TIF_VK_FORMAT_A2B10G10R10_UINT_PACK32: return TinyImageFormat_R10G10B10A2_UINT; + case TIF_VK_FORMAT_R16_UNORM: return TinyImageFormat_R16_UNORM; + case TIF_VK_FORMAT_R16_SNORM: return TinyImageFormat_R16_SNORM; + case TIF_VK_FORMAT_R16_UINT: return TinyImageFormat_R16_UINT; + case TIF_VK_FORMAT_R16_SINT: return TinyImageFormat_R16_SINT; + case TIF_VK_FORMAT_R16_SFLOAT: return TinyImageFormat_R16_SFLOAT; + case TIF_VK_FORMAT_R16G16_UNORM: return TinyImageFormat_R16G16_UNORM; + case TIF_VK_FORMAT_R16G16_SNORM: return TinyImageFormat_R16G16_SNORM; + case TIF_VK_FORMAT_R16G16_UINT: return TinyImageFormat_R16G16_UINT; + case TIF_VK_FORMAT_R16G16_SINT: return TinyImageFormat_R16G16_SINT; + case TIF_VK_FORMAT_R16G16_SFLOAT: return TinyImageFormat_R16G16_SFLOAT; + case TIF_VK_FORMAT_R16G16B16_UNORM: return TinyImageFormat_R16G16B16_UNORM; + case TIF_VK_FORMAT_R16G16B16_SNORM: return TinyImageFormat_R16G16B16_SNORM; + case TIF_VK_FORMAT_R16G16B16_UINT: return TinyImageFormat_R16G16B16_UINT; + case TIF_VK_FORMAT_R16G16B16_SINT: return TinyImageFormat_R16G16B16_SINT; + case TIF_VK_FORMAT_R16G16B16_SFLOAT: return TinyImageFormat_R16G16B16_SFLOAT; + case TIF_VK_FORMAT_R16G16B16A16_UNORM: return TinyImageFormat_R16G16B16A16_UNORM; + case TIF_VK_FORMAT_R16G16B16A16_SNORM: return TinyImageFormat_R16G16B16A16_SNORM; + case TIF_VK_FORMAT_R16G16B16A16_UINT: return TinyImageFormat_R16G16B16A16_UINT; + case TIF_VK_FORMAT_R16G16B16A16_SINT: return TinyImageFormat_R16G16B16A16_SINT; + case TIF_VK_FORMAT_R16G16B16A16_SFLOAT: return TinyImageFormat_R16G16B16A16_SFLOAT; + case TIF_VK_FORMAT_R32_UINT: return TinyImageFormat_R32_UINT; + case TIF_VK_FORMAT_R32_SINT: return TinyImageFormat_R32_SINT; + case TIF_VK_FORMAT_R32_SFLOAT: return TinyImageFormat_R32_SFLOAT; + case TIF_VK_FORMAT_R32G32_UINT: return TinyImageFormat_R32G32_UINT; + case TIF_VK_FORMAT_R32G32_SINT: return TinyImageFormat_R32G32_SINT; + case TIF_VK_FORMAT_R32G32_SFLOAT: return TinyImageFormat_R32G32_SFLOAT; + case TIF_VK_FORMAT_R32G32B32_UINT: return TinyImageFormat_R32G32B32_UINT; + case TIF_VK_FORMAT_R32G32B32_SINT: return TinyImageFormat_R32G32B32_SINT; + case TIF_VK_FORMAT_R32G32B32_SFLOAT: return TinyImageFormat_R32G32B32_SFLOAT; + case TIF_VK_FORMAT_R32G32B32A32_UINT: return TinyImageFormat_R32G32B32A32_UINT; + case TIF_VK_FORMAT_R32G32B32A32_SINT: return TinyImageFormat_R32G32B32A32_SINT; + case TIF_VK_FORMAT_R32G32B32A32_SFLOAT: return TinyImageFormat_R32G32B32A32_SFLOAT; + case TIF_VK_FORMAT_R64_UINT: return TinyImageFormat_R64_UINT; + case TIF_VK_FORMAT_R64_SINT: return TinyImageFormat_R64_SINT; + case TIF_VK_FORMAT_R64_SFLOAT: return TinyImageFormat_R64_SFLOAT; + case TIF_VK_FORMAT_R64G64_UINT: return TinyImageFormat_R64G64_UINT; + case TIF_VK_FORMAT_R64G64_SINT: return TinyImageFormat_R64G64_SINT; + case TIF_VK_FORMAT_R64G64_SFLOAT: return TinyImageFormat_R64G64_SFLOAT; + case TIF_VK_FORMAT_R64G64B64_UINT: return TinyImageFormat_R64G64B64_UINT; + case TIF_VK_FORMAT_R64G64B64_SINT: return TinyImageFormat_R64G64B64_SINT; + case TIF_VK_FORMAT_R64G64B64_SFLOAT: return TinyImageFormat_R64G64B64_SFLOAT; + case TIF_VK_FORMAT_R64G64B64A64_UINT: return TinyImageFormat_R64G64B64A64_UINT; + case TIF_VK_FORMAT_R64G64B64A64_SINT: return TinyImageFormat_R64G64B64A64_SINT; + case TIF_VK_FORMAT_R64G64B64A64_SFLOAT: return TinyImageFormat_R64G64B64A64_SFLOAT; + case TIF_VK_FORMAT_B10G11R11_UFLOAT_PACK32: return TinyImageFormat_B10G11R11_UFLOAT; + case TIF_VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: return TinyImageFormat_E5B9G9R9_UFLOAT; + case TIF_VK_FORMAT_D16_UNORM: return TinyImageFormat_D16_UNORM; + case TIF_VK_FORMAT_X8_D24_UNORM_PACK32: return TinyImageFormat_X8_D24_UNORM; + case TIF_VK_FORMAT_D32_SFLOAT: return TinyImageFormat_D32_SFLOAT; + case TIF_VK_FORMAT_S8_UINT: return TinyImageFormat_S8_UINT; + case TIF_VK_FORMAT_D16_UNORM_S8_UINT: return TinyImageFormat_D16_UNORM_S8_UINT; + case TIF_VK_FORMAT_D24_UNORM_S8_UINT: return TinyImageFormat_D24_UNORM_S8_UINT; + case TIF_VK_FORMAT_D32_SFLOAT_S8_UINT: return TinyImageFormat_D32_SFLOAT_S8_UINT; + case TIF_VK_FORMAT_BC1_RGB_UNORM_BLOCK: return TinyImageFormat_DXBC1_RGB_UNORM; + case TIF_VK_FORMAT_BC1_RGB_SRGB_BLOCK: return TinyImageFormat_DXBC1_RGB_SRGB; + case TIF_VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return TinyImageFormat_DXBC1_RGBA_UNORM; + case TIF_VK_FORMAT_BC1_RGBA_SRGB_BLOCK: return TinyImageFormat_DXBC1_RGBA_SRGB; + case TIF_VK_FORMAT_BC2_UNORM_BLOCK: return TinyImageFormat_DXBC2_UNORM; + case TIF_VK_FORMAT_BC2_SRGB_BLOCK: return TinyImageFormat_DXBC2_SRGB; + case TIF_VK_FORMAT_BC3_UNORM_BLOCK: return TinyImageFormat_DXBC3_UNORM; + case TIF_VK_FORMAT_BC3_SRGB_BLOCK: return TinyImageFormat_DXBC3_SRGB; + case TIF_VK_FORMAT_BC4_UNORM_BLOCK: return TinyImageFormat_DXBC4_UNORM; + case TIF_VK_FORMAT_BC4_SNORM_BLOCK: return TinyImageFormat_DXBC4_SNORM; + case TIF_VK_FORMAT_BC5_UNORM_BLOCK: return TinyImageFormat_DXBC5_UNORM; + case TIF_VK_FORMAT_BC5_SNORM_BLOCK: return TinyImageFormat_DXBC5_SNORM; + case TIF_VK_FORMAT_BC6H_UFLOAT_BLOCK: return TinyImageFormat_DXBC6H_UFLOAT; + case TIF_VK_FORMAT_BC6H_SFLOAT_BLOCK: return TinyImageFormat_DXBC6H_SFLOAT; + case TIF_VK_FORMAT_BC7_UNORM_BLOCK: return TinyImageFormat_DXBC7_UNORM; + case TIF_VK_FORMAT_BC7_SRGB_BLOCK: return TinyImageFormat_DXBC7_SRGB; + case TIF_VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return TinyImageFormat_ETC2_R8G8B8_UNORM; + case TIF_VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: return TinyImageFormat_ETC2_R8G8B8_SRGB; + case TIF_VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: return TinyImageFormat_ETC2_R8G8B8A1_UNORM; + case TIF_VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: return TinyImageFormat_ETC2_R8G8B8A1_SRGB; + case TIF_VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: return TinyImageFormat_ETC2_R8G8B8A8_UNORM; + case TIF_VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: return TinyImageFormat_ETC2_R8G8B8A8_SRGB; + case TIF_VK_FORMAT_EAC_R11_UNORM_BLOCK: return TinyImageFormat_ETC2_EAC_R11_UNORM; + case TIF_VK_FORMAT_EAC_R11_SNORM_BLOCK: return TinyImageFormat_ETC2_EAC_R11_SNORM; + case TIF_VK_FORMAT_EAC_R11G11_UNORM_BLOCK: return TinyImageFormat_ETC2_EAC_R11G11_UNORM; + case TIF_VK_FORMAT_EAC_R11G11_SNORM_BLOCK: return TinyImageFormat_ETC2_EAC_R11G11_SNORM; + case TIF_VK_FORMAT_ASTC_4x4_UNORM_BLOCK: return TinyImageFormat_ASTC_4x4_UNORM; + case TIF_VK_FORMAT_ASTC_4x4_SRGB_BLOCK: return TinyImageFormat_ASTC_4x4_SRGB; + case TIF_VK_FORMAT_ASTC_5x4_UNORM_BLOCK: return TinyImageFormat_ASTC_5x4_UNORM; + case TIF_VK_FORMAT_ASTC_5x4_SRGB_BLOCK: return TinyImageFormat_ASTC_5x4_SRGB; + case TIF_VK_FORMAT_ASTC_5x5_UNORM_BLOCK: return TinyImageFormat_ASTC_5x5_UNORM; + case TIF_VK_FORMAT_ASTC_5x5_SRGB_BLOCK: return TinyImageFormat_ASTC_5x5_SRGB; + case TIF_VK_FORMAT_ASTC_6x5_UNORM_BLOCK: return TinyImageFormat_ASTC_6x5_UNORM; + case TIF_VK_FORMAT_ASTC_6x5_SRGB_BLOCK: return TinyImageFormat_ASTC_6x5_SRGB; + case TIF_VK_FORMAT_ASTC_6x6_UNORM_BLOCK: return TinyImageFormat_ASTC_6x6_UNORM; + case TIF_VK_FORMAT_ASTC_6x6_SRGB_BLOCK: return TinyImageFormat_ASTC_6x6_SRGB; + case TIF_VK_FORMAT_ASTC_8x5_UNORM_BLOCK: return TinyImageFormat_ASTC_8x5_UNORM; + case TIF_VK_FORMAT_ASTC_8x5_SRGB_BLOCK: return TinyImageFormat_ASTC_8x5_SRGB; + case TIF_VK_FORMAT_ASTC_8x6_UNORM_BLOCK: return TinyImageFormat_ASTC_8x6_UNORM; + case TIF_VK_FORMAT_ASTC_8x6_SRGB_BLOCK: return TinyImageFormat_ASTC_8x6_SRGB; + case TIF_VK_FORMAT_ASTC_8x8_UNORM_BLOCK: return TinyImageFormat_ASTC_8x8_UNORM; + case TIF_VK_FORMAT_ASTC_8x8_SRGB_BLOCK: return TinyImageFormat_ASTC_8x8_SRGB; + case TIF_VK_FORMAT_ASTC_10x5_UNORM_BLOCK: return TinyImageFormat_ASTC_10x5_UNORM; + case TIF_VK_FORMAT_ASTC_10x5_SRGB_BLOCK: return TinyImageFormat_ASTC_10x5_SRGB; + case TIF_VK_FORMAT_ASTC_10x6_UNORM_BLOCK: return TinyImageFormat_ASTC_10x6_UNORM; + case TIF_VK_FORMAT_ASTC_10x6_SRGB_BLOCK: return TinyImageFormat_ASTC_10x6_SRGB; + case TIF_VK_FORMAT_ASTC_10x8_UNORM_BLOCK: return TinyImageFormat_ASTC_10x8_UNORM; + case TIF_VK_FORMAT_ASTC_10x8_SRGB_BLOCK: return TinyImageFormat_ASTC_10x8_SRGB; + case TIF_VK_FORMAT_ASTC_10x10_UNORM_BLOCK: return TinyImageFormat_ASTC_10x10_UNORM; + case TIF_VK_FORMAT_ASTC_10x10_SRGB_BLOCK: return TinyImageFormat_ASTC_10x10_SRGB; + case TIF_VK_FORMAT_ASTC_12x10_UNORM_BLOCK: return TinyImageFormat_ASTC_12x10_UNORM; + case TIF_VK_FORMAT_ASTC_12x10_SRGB_BLOCK: return TinyImageFormat_ASTC_12x10_SRGB; + case TIF_VK_FORMAT_ASTC_12x12_UNORM_BLOCK: return TinyImageFormat_ASTC_12x12_UNORM; + case TIF_VK_FORMAT_ASTC_12x12_SRGB_BLOCK: return TinyImageFormat_ASTC_12x12_SRGB; + + case TIF_VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: return TinyImageFormat_PVRTC1_2BPP_UNORM; + case TIF_VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: return TinyImageFormat_PVRTC1_4BPP_UNORM; + case TIF_VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: return TinyImageFormat_PVRTC1_2BPP_SRGB; + case TIF_VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: return TinyImageFormat_PVRTC1_4BPP_SRGB; + + case TIF_VK_FORMAT_G16B16G16R16_422_UNORM: return TinyImageFormat_G16B16G16R16_422_UNORM; + case TIF_VK_FORMAT_B16G16R16G16_422_UNORM: return TinyImageFormat_B16G16R16G16_422_UNORM; + case TIF_VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: return TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16; + case TIF_VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: return TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16; + case TIF_VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: return TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16; + case TIF_VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: return TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16; + case TIF_VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: return TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16; + case TIF_VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: return TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16; + case TIF_VK_FORMAT_G8B8G8R8_422_UNORM: return TinyImageFormat_G8B8G8R8_422_UNORM; + case TIF_VK_FORMAT_B8G8R8G8_422_UNORM: return TinyImageFormat_B8G8R8G8_422_UNORM; + case TIF_VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: return TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM; + case TIF_VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: return TinyImageFormat_G8_B8R8_2PLANE_420_UNORM; + case TIF_VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: return TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM; + case TIF_VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: return TinyImageFormat_G8_B8R8_2PLANE_422_UNORM; + case TIF_VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: return TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM; + case TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: return TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16; + case TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: return TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16; + case TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: return TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16; + case TIF_VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: return TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16; + case TIF_VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: return TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16; + case TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: return TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16; + case TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: return TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16; + case TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: return TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16; + case TIF_VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: return TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16; + case TIF_VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: return TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16; + case TIF_VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: return TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM; + case TIF_VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: return TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM; + case TIF_VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: return TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM; + case TIF_VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: return TinyImageFormat_G16_B16R16_2PLANE_420_UNORM; + case TIF_VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: return TinyImageFormat_G16_B16R16_2PLANE_422_UNORM; + + case TIF_VK_FORMAT_A8B8G8R8_UNORM_PACK32: + case TIF_VK_FORMAT_R8_USCALED: + case TIF_VK_FORMAT_R8_SSCALED: + case TIF_VK_FORMAT_R8G8_USCALED: + case TIF_VK_FORMAT_R8G8_SSCALED: + case TIF_VK_FORMAT_R8G8B8_USCALED: + case TIF_VK_FORMAT_R8G8B8_SSCALED: + case TIF_VK_FORMAT_B8G8R8_USCALED: + case TIF_VK_FORMAT_B8G8R8_SSCALED: + case TIF_VK_FORMAT_R8G8B8A8_USCALED: + case TIF_VK_FORMAT_R8G8B8A8_SSCALED: + case TIF_VK_FORMAT_B8G8R8A8_USCALED: + case TIF_VK_FORMAT_B8G8R8A8_SSCALED: + case TIF_VK_FORMAT_A8B8G8R8_SNORM_PACK32: + case TIF_VK_FORMAT_A8B8G8R8_USCALED_PACK32: + case TIF_VK_FORMAT_A8B8G8R8_SSCALED_PACK32: + case TIF_VK_FORMAT_A8B8G8R8_UINT_PACK32: + case TIF_VK_FORMAT_A8B8G8R8_SINT_PACK32: + case TIF_VK_FORMAT_A8B8G8R8_SRGB_PACK32: + case TIF_VK_FORMAT_A2R10G10B10_SNORM_PACK32: + case TIF_VK_FORMAT_A2R10G10B10_USCALED_PACK32: + case TIF_VK_FORMAT_A2R10G10B10_SSCALED_PACK32: + case TIF_VK_FORMAT_A2R10G10B10_SINT_PACK32: + case TIF_VK_FORMAT_A2B10G10R10_SNORM_PACK32: + case TIF_VK_FORMAT_A2B10G10R10_USCALED_PACK32: + case TIF_VK_FORMAT_A2B10G10R10_SSCALED_PACK32: + case TIF_VK_FORMAT_A2B10G10R10_SINT_PACK32: + case TIF_VK_FORMAT_R16_USCALED: + case TIF_VK_FORMAT_R16_SSCALED: + case TIF_VK_FORMAT_R16G16_USCALED: + case TIF_VK_FORMAT_R16G16_SSCALED: + case TIF_VK_FORMAT_R16G16B16_USCALED: + case TIF_VK_FORMAT_R16G16B16_SSCALED: + case TIF_VK_FORMAT_R16G16B16A16_USCALED: + case TIF_VK_FORMAT_R16G16B16A16_SSCALED: + case TIF_VK_FORMAT_R10X6_UNORM_PACK16: + case TIF_VK_FORMAT_R10X6G10X6_UNORM_2PACK16: + case TIF_VK_FORMAT_R12X4_UNORM_PACK16: + case TIF_VK_FORMAT_R12X4G12X4_UNORM_2PACK16: + case TIF_VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: + case TIF_VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: + case TIF_VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: + case TIF_VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: + return TinyImageFormat_UNDEFINED; + } + return TinyImageFormat_UNDEFINED; +} + +inline TinyImageFormat_VkFormat TinyImageFormat_ToVkFormat(TinyImageFormat fmt) { + switch (fmt) { + + case TinyImageFormat_UNDEFINED: return TIF_VK_FORMAT_UNDEFINED; + case TinyImageFormat_G4R4_UNORM: return TIF_VK_FORMAT_R4G4_UNORM_PACK8; + case TinyImageFormat_A4B4G4R4_UNORM: return TIF_VK_FORMAT_R4G4B4A4_UNORM_PACK16; + case TinyImageFormat_A4R4G4B4_UNORM: return TIF_VK_FORMAT_B4G4R4A4_UNORM_PACK16; + case TinyImageFormat_R5G6B5_UNORM: return TIF_VK_FORMAT_B5G6R5_UNORM_PACK16; + case TinyImageFormat_B5G6R5_UNORM: return TIF_VK_FORMAT_R5G6B5_UNORM_PACK16; + case TinyImageFormat_A1B5G5R5_UNORM: return TIF_VK_FORMAT_R5G5B5A1_UNORM_PACK16; + case TinyImageFormat_A1R5G5B5_UNORM: return TIF_VK_FORMAT_B5G5R5A1_UNORM_PACK16; + case TinyImageFormat_B5G5R5A1_UNORM: return TIF_VK_FORMAT_A1R5G5B5_UNORM_PACK16; + case TinyImageFormat_A2B10G10R10_UNORM: return TIF_VK_FORMAT_A2B10G10R10_UNORM_PACK32; + + case TinyImageFormat_R8_UNORM: return TIF_VK_FORMAT_R8_UNORM; + case TinyImageFormat_R8_SNORM: return TIF_VK_FORMAT_R8_SNORM; + case TinyImageFormat_R8_UINT: return TIF_VK_FORMAT_R8_UINT; + case TinyImageFormat_R8_SINT: return TIF_VK_FORMAT_R8_SINT; + case TinyImageFormat_R8_SRGB: return TIF_VK_FORMAT_R8_SRGB; + case TinyImageFormat_R8G8_UNORM: return TIF_VK_FORMAT_R8G8_UNORM; + case TinyImageFormat_R8G8_SNORM: return TIF_VK_FORMAT_R8G8_SNORM; + case TinyImageFormat_R8G8_UINT: return TIF_VK_FORMAT_R8G8_UINT; + case TinyImageFormat_R8G8_SINT: return TIF_VK_FORMAT_R8G8_SINT; + case TinyImageFormat_R8G8_SRGB: return TIF_VK_FORMAT_R8G8_SRGB; + case TinyImageFormat_R8G8B8_UNORM: return TIF_VK_FORMAT_R8G8B8_UNORM; + case TinyImageFormat_R8G8B8_SNORM: return TIF_VK_FORMAT_R8G8B8_SNORM; + case TinyImageFormat_R8G8B8_UINT: return TIF_VK_FORMAT_R8G8B8_UINT; + case TinyImageFormat_R8G8B8_SINT: return TIF_VK_FORMAT_R8G8B8_SINT; + case TinyImageFormat_R8G8B8_SRGB: return TIF_VK_FORMAT_R8G8B8_SRGB; + case TinyImageFormat_B8G8R8_UNORM: return TIF_VK_FORMAT_B8G8R8_UNORM; + case TinyImageFormat_B8G8R8_SNORM: return TIF_VK_FORMAT_B8G8R8_SNORM; + case TinyImageFormat_B8G8R8_UINT: return TIF_VK_FORMAT_B8G8R8_UINT; + case TinyImageFormat_B8G8R8_SINT: return TIF_VK_FORMAT_B8G8R8_SINT; + case TinyImageFormat_B8G8R8_SRGB: return TIF_VK_FORMAT_B8G8R8_SRGB; + case TinyImageFormat_R8G8B8A8_UNORM: return TIF_VK_FORMAT_R8G8B8A8_UNORM; + case TinyImageFormat_R8G8B8A8_SNORM: return TIF_VK_FORMAT_R8G8B8A8_SNORM; + case TinyImageFormat_R8G8B8A8_UINT: return TIF_VK_FORMAT_R8G8B8A8_UINT; + case TinyImageFormat_R8G8B8A8_SINT: return TIF_VK_FORMAT_R8G8B8A8_SINT; + case TinyImageFormat_R8G8B8A8_SRGB: return TIF_VK_FORMAT_R8G8B8A8_SRGB; + case TinyImageFormat_B8G8R8A8_UNORM: return TIF_VK_FORMAT_B8G8R8A8_UNORM; + case TinyImageFormat_B8G8R8A8_SNORM: return TIF_VK_FORMAT_B8G8R8A8_SNORM; + case TinyImageFormat_B8G8R8A8_UINT: return TIF_VK_FORMAT_B8G8R8A8_UINT; + case TinyImageFormat_B8G8R8A8_SINT: return TIF_VK_FORMAT_B8G8R8A8_SINT; + case TinyImageFormat_B8G8R8A8_SRGB: return TIF_VK_FORMAT_B8G8R8A8_SRGB; + case TinyImageFormat_R16_UNORM: return TIF_VK_FORMAT_R16_UNORM; + case TinyImageFormat_R16_SNORM: return TIF_VK_FORMAT_R16_SNORM; + case TinyImageFormat_R16_UINT: return TIF_VK_FORMAT_R16_UINT; + case TinyImageFormat_R16_SINT: return TIF_VK_FORMAT_R16_SINT; + case TinyImageFormat_R16_SFLOAT: return TIF_VK_FORMAT_R16_SFLOAT; + case TinyImageFormat_R16G16_UNORM: return TIF_VK_FORMAT_R16G16_UNORM; + case TinyImageFormat_R16G16_SNORM: return TIF_VK_FORMAT_R16G16_SNORM; + case TinyImageFormat_R16G16_UINT: return TIF_VK_FORMAT_R16G16_UINT; + case TinyImageFormat_R16G16_SINT: return TIF_VK_FORMAT_R16G16_SINT; + case TinyImageFormat_R16G16_SFLOAT: return TIF_VK_FORMAT_R16G16_SFLOAT; + case TinyImageFormat_R16G16B16_UNORM: return TIF_VK_FORMAT_R16G16B16_UNORM; + case TinyImageFormat_R16G16B16_SNORM: return TIF_VK_FORMAT_R16G16B16_SNORM; + case TinyImageFormat_R16G16B16_UINT: return TIF_VK_FORMAT_R16G16B16_UINT; + case TinyImageFormat_R16G16B16_SINT: return TIF_VK_FORMAT_R16G16B16_SINT; + case TinyImageFormat_R16G16B16_SFLOAT: return TIF_VK_FORMAT_R16G16B16_SFLOAT; + case TinyImageFormat_R16G16B16A16_UNORM: return TIF_VK_FORMAT_R16G16B16A16_UNORM; + case TinyImageFormat_R16G16B16A16_SNORM: return TIF_VK_FORMAT_R16G16B16A16_SNORM; + case TinyImageFormat_R16G16B16A16_UINT: return TIF_VK_FORMAT_R16G16B16A16_UINT; + case TinyImageFormat_R16G16B16A16_SINT: return TIF_VK_FORMAT_R16G16B16A16_SINT; + case TinyImageFormat_R16G16B16A16_SFLOAT: return TIF_VK_FORMAT_R16G16B16A16_SFLOAT; + case TinyImageFormat_R32_UINT: return TIF_VK_FORMAT_R32_UINT; + case TinyImageFormat_R32_SINT: return TIF_VK_FORMAT_R32_SINT; + case TinyImageFormat_R32_SFLOAT: return TIF_VK_FORMAT_R32_SFLOAT; + case TinyImageFormat_R32G32_UINT: return TIF_VK_FORMAT_R32G32_UINT; + case TinyImageFormat_R32G32_SINT: return TIF_VK_FORMAT_R32G32_SINT; + case TinyImageFormat_R32G32_SFLOAT: return TIF_VK_FORMAT_R32G32_SFLOAT; + case TinyImageFormat_R32G32B32_UINT: return TIF_VK_FORMAT_R32G32B32_UINT; + case TinyImageFormat_R32G32B32_SINT: return TIF_VK_FORMAT_R32G32B32_SINT; + case TinyImageFormat_R32G32B32_SFLOAT: return TIF_VK_FORMAT_R32G32B32_SFLOAT; + case TinyImageFormat_R32G32B32A32_UINT: return TIF_VK_FORMAT_R32G32B32A32_UINT; + case TinyImageFormat_R32G32B32A32_SINT: return TIF_VK_FORMAT_R32G32B32A32_SINT; + case TinyImageFormat_R32G32B32A32_SFLOAT: return TIF_VK_FORMAT_R32G32B32A32_SFLOAT; + case TinyImageFormat_R64_UINT: return TIF_VK_FORMAT_R64_UINT; + case TinyImageFormat_R64_SINT: return TIF_VK_FORMAT_R64_SINT; + case TinyImageFormat_R64_SFLOAT: return TIF_VK_FORMAT_R64_SFLOAT; + case TinyImageFormat_R64G64_UINT: return TIF_VK_FORMAT_R64G64_UINT; + case TinyImageFormat_R64G64_SINT: return TIF_VK_FORMAT_R64G64_SINT; + case TinyImageFormat_R64G64_SFLOAT: return TIF_VK_FORMAT_R64G64_SFLOAT; + case TinyImageFormat_R64G64B64_UINT: return TIF_VK_FORMAT_R64G64B64_UINT; + case TinyImageFormat_R64G64B64_SINT: return TIF_VK_FORMAT_R64G64B64_SINT; + case TinyImageFormat_R64G64B64_SFLOAT: return TIF_VK_FORMAT_R64G64B64_SFLOAT; + case TinyImageFormat_R64G64B64A64_UINT: return TIF_VK_FORMAT_R64G64B64A64_UINT; + case TinyImageFormat_R64G64B64A64_SINT: return TIF_VK_FORMAT_R64G64B64A64_SINT; + case TinyImageFormat_R64G64B64A64_SFLOAT: return TIF_VK_FORMAT_R64G64B64A64_SFLOAT; + + case TinyImageFormat_B10G10R10A2_UNORM: return TIF_VK_FORMAT_A2R10G10B10_UNORM_PACK32; + case TinyImageFormat_B10G10R10A2_UINT: return TIF_VK_FORMAT_A2R10G10B10_UINT_PACK32; + case TinyImageFormat_R10G10B10A2_UNORM: return TIF_VK_FORMAT_A2B10G10R10_UNORM_PACK32; + case TinyImageFormat_R10G10B10A2_UINT: return TIF_VK_FORMAT_A2B10G10R10_UINT_PACK32; + + case TinyImageFormat_B10G11R11_UFLOAT: return TIF_VK_FORMAT_B10G11R11_UFLOAT_PACK32; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TIF_VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; + + case TinyImageFormat_G16B16G16R16_422_UNORM: return TIF_VK_FORMAT_G16B16G16R16_422_UNORM; + case TinyImageFormat_B16G16R16G16_422_UNORM: return TIF_VK_FORMAT_B16G16R16G16_422_UNORM; + case TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16: return TIF_VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16; + case TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: return TIF_VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16; + case TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: return TIF_VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16; + case TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16: return TIF_VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16; + case TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: return TIF_VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16; + case TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: return TIF_VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16; + case TinyImageFormat_G8B8G8R8_422_UNORM: return TIF_VK_FORMAT_G8B8G8R8_422_UNORM; + case TinyImageFormat_B8G8R8G8_422_UNORM: return TIF_VK_FORMAT_B8G8R8G8_422_UNORM; + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: return TIF_VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM; + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: return TIF_VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: return TIF_VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM; + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: return TIF_VK_FORMAT_G8_B8R8_2PLANE_422_UNORM; + case TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM: return TIF_VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM; + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: return TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16; + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: return TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16; + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: return TIF_VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16; + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: return TIF_VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16; + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: return TIF_VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16; + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: return TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16; + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: return TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16; + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: return TIF_VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16; + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: return TIF_VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16; + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: return TIF_VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16; + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: return TIF_VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM; + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: return TIF_VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM; + case TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM: return TIF_VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM; + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: return TIF_VK_FORMAT_G16_B16R16_2PLANE_420_UNORM; + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: return TIF_VK_FORMAT_G16_B16R16_2PLANE_422_UNORM; + + case TinyImageFormat_D16_UNORM: return TIF_VK_FORMAT_D16_UNORM; + case TinyImageFormat_X8_D24_UNORM: return TIF_VK_FORMAT_X8_D24_UNORM_PACK32; + case TinyImageFormat_D32_SFLOAT: return TIF_VK_FORMAT_D32_SFLOAT; + case TinyImageFormat_S8_UINT: return TIF_VK_FORMAT_S8_UINT; + case TinyImageFormat_D16_UNORM_S8_UINT: return TIF_VK_FORMAT_D16_UNORM_S8_UINT; + case TinyImageFormat_D24_UNORM_S8_UINT: return TIF_VK_FORMAT_D24_UNORM_S8_UINT; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TIF_VK_FORMAT_D32_SFLOAT_S8_UINT; + case TinyImageFormat_DXBC1_RGB_UNORM: return TIF_VK_FORMAT_BC1_RGB_UNORM_BLOCK; + case TinyImageFormat_DXBC1_RGB_SRGB: return TIF_VK_FORMAT_BC1_RGB_SRGB_BLOCK; + case TinyImageFormat_DXBC1_RGBA_UNORM: return TIF_VK_FORMAT_BC1_RGBA_UNORM_BLOCK; + case TinyImageFormat_DXBC1_RGBA_SRGB: return TIF_VK_FORMAT_BC1_RGBA_SRGB_BLOCK; + case TinyImageFormat_DXBC2_UNORM: return TIF_VK_FORMAT_BC2_UNORM_BLOCK; + case TinyImageFormat_DXBC2_SRGB: return TIF_VK_FORMAT_BC2_SRGB_BLOCK; + case TinyImageFormat_DXBC3_UNORM: return TIF_VK_FORMAT_BC3_UNORM_BLOCK; + case TinyImageFormat_DXBC3_SRGB: return TIF_VK_FORMAT_BC3_SRGB_BLOCK; + case TinyImageFormat_DXBC4_UNORM: return TIF_VK_FORMAT_BC4_UNORM_BLOCK; + case TinyImageFormat_DXBC4_SNORM: return TIF_VK_FORMAT_BC4_SNORM_BLOCK; + case TinyImageFormat_DXBC5_UNORM: return TIF_VK_FORMAT_BC5_UNORM_BLOCK; + case TinyImageFormat_DXBC5_SNORM: return TIF_VK_FORMAT_BC5_SNORM_BLOCK; + case TinyImageFormat_DXBC6H_UFLOAT: return TIF_VK_FORMAT_BC6H_UFLOAT_BLOCK; + case TinyImageFormat_DXBC6H_SFLOAT: return TIF_VK_FORMAT_BC6H_SFLOAT_BLOCK; + case TinyImageFormat_DXBC7_UNORM: return TIF_VK_FORMAT_BC7_UNORM_BLOCK; + case TinyImageFormat_DXBC7_SRGB: return TIF_VK_FORMAT_BC7_SRGB_BLOCK; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return TIF_VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return TIF_VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return TIF_VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return TIF_VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return TIF_VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return TIF_VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return TIF_VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return TIF_VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return TIF_VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return TIF_VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TIF_VK_FORMAT_EAC_R11_UNORM_BLOCK; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return TIF_VK_FORMAT_EAC_R11G11_UNORM_BLOCK; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TIF_VK_FORMAT_EAC_R11_SNORM_BLOCK; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return TIF_VK_FORMAT_EAC_R11G11_SNORM_BLOCK; + case TinyImageFormat_ASTC_4x4_UNORM: return TIF_VK_FORMAT_ASTC_4x4_UNORM_BLOCK; + case TinyImageFormat_ASTC_4x4_SRGB: return TIF_VK_FORMAT_ASTC_4x4_SRGB_BLOCK; + case TinyImageFormat_ASTC_5x4_UNORM: return TIF_VK_FORMAT_ASTC_5x4_UNORM_BLOCK; + case TinyImageFormat_ASTC_5x4_SRGB: return TIF_VK_FORMAT_ASTC_5x4_SRGB_BLOCK; + case TinyImageFormat_ASTC_5x5_UNORM: return TIF_VK_FORMAT_ASTC_5x5_UNORM_BLOCK; + case TinyImageFormat_ASTC_5x5_SRGB: return TIF_VK_FORMAT_ASTC_5x5_SRGB_BLOCK; + case TinyImageFormat_ASTC_6x5_UNORM: return TIF_VK_FORMAT_ASTC_6x5_UNORM_BLOCK; + case TinyImageFormat_ASTC_6x5_SRGB: return TIF_VK_FORMAT_ASTC_6x5_SRGB_BLOCK; + case TinyImageFormat_ASTC_6x6_UNORM: return TIF_VK_FORMAT_ASTC_6x6_UNORM_BLOCK; + case TinyImageFormat_ASTC_6x6_SRGB: return TIF_VK_FORMAT_ASTC_6x6_SRGB_BLOCK; + case TinyImageFormat_ASTC_8x5_UNORM: return TIF_VK_FORMAT_ASTC_8x5_UNORM_BLOCK; + case TinyImageFormat_ASTC_8x5_SRGB: return TIF_VK_FORMAT_ASTC_8x5_SRGB_BLOCK; + case TinyImageFormat_ASTC_8x6_UNORM: return TIF_VK_FORMAT_ASTC_8x6_UNORM_BLOCK; + case TinyImageFormat_ASTC_8x6_SRGB: return TIF_VK_FORMAT_ASTC_8x6_SRGB_BLOCK; + case TinyImageFormat_ASTC_8x8_UNORM: return TIF_VK_FORMAT_ASTC_8x8_UNORM_BLOCK; + case TinyImageFormat_ASTC_8x8_SRGB: return TIF_VK_FORMAT_ASTC_8x8_SRGB_BLOCK; + case TinyImageFormat_ASTC_10x5_UNORM: return TIF_VK_FORMAT_ASTC_10x5_UNORM_BLOCK; + case TinyImageFormat_ASTC_10x5_SRGB: return TIF_VK_FORMAT_ASTC_10x5_SRGB_BLOCK; + case TinyImageFormat_ASTC_10x6_UNORM: return TIF_VK_FORMAT_ASTC_10x6_UNORM_BLOCK; + case TinyImageFormat_ASTC_10x6_SRGB: return TIF_VK_FORMAT_ASTC_10x6_SRGB_BLOCK; + case TinyImageFormat_ASTC_10x8_UNORM: return TIF_VK_FORMAT_ASTC_10x8_UNORM_BLOCK; + case TinyImageFormat_ASTC_10x8_SRGB: return TIF_VK_FORMAT_ASTC_10x8_SRGB_BLOCK; + case TinyImageFormat_ASTC_10x10_UNORM: return TIF_VK_FORMAT_ASTC_10x10_UNORM_BLOCK; + case TinyImageFormat_ASTC_10x10_SRGB: return TIF_VK_FORMAT_ASTC_10x10_SRGB_BLOCK; + case TinyImageFormat_ASTC_12x10_UNORM: return TIF_VK_FORMAT_ASTC_12x10_UNORM_BLOCK; + case TinyImageFormat_ASTC_12x10_SRGB: return TIF_VK_FORMAT_ASTC_12x10_SRGB_BLOCK; + case TinyImageFormat_ASTC_12x12_UNORM: return TIF_VK_FORMAT_ASTC_12x12_UNORM_BLOCK; + case TinyImageFormat_ASTC_12x12_SRGB: return TIF_VK_FORMAT_ASTC_12x12_SRGB_BLOCK; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return TIF_VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return TIF_VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return TIF_VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return TIF_VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG; + + default: return TIF_VK_FORMAT_UNDEFINED; + } +} + +#ifndef TINYIMAGEFORMAT_DXGIFORMAT +#define TINYIMAGEFORMAT_DXGIFORMAT + +typedef enum TinyImageFormat_DXGI_FORMAT { + + TIF_DXGI_FORMAT_UNKNOWN = 0, + TIF_DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, + TIF_DXGI_FORMAT_R32G32B32A32_FLOAT = 2, + TIF_DXGI_FORMAT_R32G32B32A32_UINT = 3, + TIF_DXGI_FORMAT_R32G32B32A32_SINT = 4, + TIF_DXGI_FORMAT_R32G32B32_TYPELESS = 5, + TIF_DXGI_FORMAT_R32G32B32_FLOAT = 6, + TIF_DXGI_FORMAT_R32G32B32_UINT = 7, + TIF_DXGI_FORMAT_R32G32B32_SINT = 8, + TIF_DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, + TIF_DXGI_FORMAT_R16G16B16A16_FLOAT = 10, + TIF_DXGI_FORMAT_R16G16B16A16_UNORM = 11, + TIF_DXGI_FORMAT_R16G16B16A16_UINT = 12, + TIF_DXGI_FORMAT_R16G16B16A16_SNORM = 13, + TIF_DXGI_FORMAT_R16G16B16A16_SINT = 14, + TIF_DXGI_FORMAT_R32G32_TYPELESS = 15, + TIF_DXGI_FORMAT_R32G32_FLOAT = 16, + TIF_DXGI_FORMAT_R32G32_UINT = 17, + TIF_DXGI_FORMAT_R32G32_SINT = 18, + TIF_DXGI_FORMAT_R32G8X24_TYPELESS = 19, + TIF_DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, + TIF_DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, + TIF_DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, + TIF_DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, + TIF_DXGI_FORMAT_R10G10B10A2_UNORM = 24, + TIF_DXGI_FORMAT_R10G10B10A2_UINT = 25, + TIF_DXGI_FORMAT_R11G11B10_FLOAT = 26, + TIF_DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, + TIF_DXGI_FORMAT_R8G8B8A8_UNORM = 28, + TIF_DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, + TIF_DXGI_FORMAT_R8G8B8A8_UINT = 30, + TIF_DXGI_FORMAT_R8G8B8A8_SNORM = 31, + TIF_DXGI_FORMAT_R8G8B8A8_SINT = 32, + TIF_DXGI_FORMAT_R16G16_TYPELESS = 33, + TIF_DXGI_FORMAT_R16G16_FLOAT = 34, + TIF_DXGI_FORMAT_R16G16_UNORM = 35, + TIF_DXGI_FORMAT_R16G16_UINT = 36, + TIF_DXGI_FORMAT_R16G16_SNORM = 37, + TIF_DXGI_FORMAT_R16G16_SINT = 38, + TIF_DXGI_FORMAT_R32_TYPELESS = 39, + TIF_DXGI_FORMAT_D32_FLOAT = 40, + TIF_DXGI_FORMAT_R32_FLOAT = 41, + TIF_DXGI_FORMAT_R32_UINT = 42, + TIF_DXGI_FORMAT_R32_SINT = 43, + TIF_DXGI_FORMAT_R24G8_TYPELESS = 44, + TIF_DXGI_FORMAT_D24_UNORM_S8_UINT = 45, + TIF_DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, + TIF_DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, + TIF_DXGI_FORMAT_R8G8_TYPELESS = 48, + TIF_DXGI_FORMAT_R8G8_UNORM = 49, + TIF_DXGI_FORMAT_R8G8_UINT = 50, + TIF_DXGI_FORMAT_R8G8_SNORM = 51, + TIF_DXGI_FORMAT_R8G8_SINT = 52, + TIF_DXGI_FORMAT_R16_TYPELESS = 53, + TIF_DXGI_FORMAT_R16_FLOAT = 54, + TIF_DXGI_FORMAT_D16_UNORM = 55, + TIF_DXGI_FORMAT_R16_UNORM = 56, + TIF_DXGI_FORMAT_R16_UINT = 57, + TIF_DXGI_FORMAT_R16_SNORM = 58, + TIF_DXGI_FORMAT_R16_SINT = 59, + TIF_DXGI_FORMAT_R8_TYPELESS = 60, + TIF_DXGI_FORMAT_R8_UNORM = 61, + TIF_DXGI_FORMAT_R8_UINT = 62, + TIF_DXGI_FORMAT_R8_SNORM = 63, + TIF_DXGI_FORMAT_R8_SINT = 64, + TIF_DXGI_FORMAT_A8_UNORM = 65, + TIF_DXGI_FORMAT_R1_UNORM = 66, + TIF_DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, + TIF_DXGI_FORMAT_R8G8_B8G8_UNORM = 68, + TIF_DXGI_FORMAT_G8R8_G8B8_UNORM = 69, + TIF_DXGI_FORMAT_BC1_TYPELESS = 70, + TIF_DXGI_FORMAT_BC1_UNORM = 71, + TIF_DXGI_FORMAT_BC1_UNORM_SRGB = 72, + TIF_DXGI_FORMAT_BC2_TYPELESS = 73, + TIF_DXGI_FORMAT_BC2_UNORM = 74, + TIF_DXGI_FORMAT_BC2_UNORM_SRGB = 75, + TIF_DXGI_FORMAT_BC3_TYPELESS = 76, + TIF_DXGI_FORMAT_BC3_UNORM = 77, + TIF_DXGI_FORMAT_BC3_UNORM_SRGB = 78, + TIF_DXGI_FORMAT_BC4_TYPELESS = 79, + TIF_DXGI_FORMAT_BC4_UNORM = 80, + TIF_DXGI_FORMAT_BC4_SNORM = 81, + TIF_DXGI_FORMAT_BC5_TYPELESS = 82, + TIF_DXGI_FORMAT_BC5_UNORM = 83, + TIF_DXGI_FORMAT_BC5_SNORM = 84, + TIF_DXGI_FORMAT_B5G6R5_UNORM = 85, + TIF_DXGI_FORMAT_B5G5R5A1_UNORM = 86, + TIF_DXGI_FORMAT_B8G8R8A8_UNORM = 87, + TIF_DXGI_FORMAT_B8G8R8X8_UNORM = 88, + TIF_DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, + TIF_DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, + TIF_DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, + TIF_DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, + TIF_DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, + TIF_DXGI_FORMAT_BC6H_TYPELESS = 94, + TIF_DXGI_FORMAT_BC6H_UF16 = 95, + TIF_DXGI_FORMAT_BC6H_SF16 = 96, + TIF_DXGI_FORMAT_BC7_TYPELESS = 97, + TIF_DXGI_FORMAT_BC7_UNORM = 98, + TIF_DXGI_FORMAT_BC7_UNORM_SRGB = 99, + TIF_DXGI_FORMAT_AYUV = 100, + TIF_DXGI_FORMAT_Y410 = 101, + TIF_DXGI_FORMAT_Y416 = 102, + TIF_DXGI_FORMAT_NV12 = 103, + TIF_DXGI_FORMAT_P010 = 104, + TIF_DXGI_FORMAT_P016 = 105, + TIF_DXGI_FORMAT_420_OPAQUE = 106, + TIF_DXGI_FORMAT_YUY2 = 107, + TIF_DXGI_FORMAT_Y210 = 108, + TIF_DXGI_FORMAT_Y216 = 109, + TIF_DXGI_FORMAT_NV11 = 110, + TIF_DXGI_FORMAT_AI44 = 111, + TIF_DXGI_FORMAT_IA44 = 112, + TIF_DXGI_FORMAT_P8 = 113, + TIF_DXGI_FORMAT_A8P8 = 114, + TIF_DXGI_FORMAT_B4G4R4A4_UNORM = 115, + + // ASTC Format + TIF_DXGI_FORMAT_ASTC_4X4_TYPELESS = 133, + TIF_DXGI_FORMAT_ASTC_4X4_UNORM = 134, + TIF_DXGI_FORMAT_ASTC_4X4_UNORM_SRGB = 135, + TIF_DXGI_FORMAT_ASTC_5X4_TYPELESS = 137, + TIF_DXGI_FORMAT_ASTC_5X4_UNORM = 138, + TIF_DXGI_FORMAT_ASTC_5X4_UNORM_SRGB = 139, + TIF_DXGI_FORMAT_ASTC_5X5_TYPELESS = 141, + TIF_DXGI_FORMAT_ASTC_5X5_UNORM = 142, + TIF_DXGI_FORMAT_ASTC_5X5_UNORM_SRGB = 143, + TIF_DXGI_FORMAT_ASTC_6X5_TYPELESS = 145, + TIF_DXGI_FORMAT_ASTC_6X5_UNORM = 146, + TIF_DXGI_FORMAT_ASTC_6X5_UNORM_SRGB = 147, + TIF_DXGI_FORMAT_ASTC_6X6_TYPELESS = 149, + TIF_DXGI_FORMAT_ASTC_6X6_UNORM = 150, + TIF_DXGI_FORMAT_ASTC_6X6_UNORM_SRGB = 151, + TIF_DXGI_FORMAT_ASTC_8X5_TYPELESS = 153, + TIF_DXGI_FORMAT_ASTC_8X5_UNORM = 154, + TIF_DXGI_FORMAT_ASTC_8X5_UNORM_SRGB = 155, + TIF_DXGI_FORMAT_ASTC_8X6_TYPELESS = 157, + TIF_DXGI_FORMAT_ASTC_8X6_UNORM = 158, + TIF_DXGI_FORMAT_ASTC_8X6_UNORM_SRGB = 159, + TIF_DXGI_FORMAT_ASTC_8X8_TYPELESS = 161, + TIF_DXGI_FORMAT_ASTC_8X8_UNORM = 162, + TIF_DXGI_FORMAT_ASTC_8X8_UNORM_SRGB = 163, + TIF_DXGI_FORMAT_ASTC_10X5_TYPELESS = 165, + TIF_DXGI_FORMAT_ASTC_10X5_UNORM = 166, + TIF_DXGI_FORMAT_ASTC_10X5_UNORM_SRGB = 167, + TIF_DXGI_FORMAT_ASTC_10X6_TYPELESS = 169, + TIF_DXGI_FORMAT_ASTC_10X6_UNORM = 170, + TIF_DXGI_FORMAT_ASTC_10X6_UNORM_SRGB = 171, + TIF_DXGI_FORMAT_ASTC_10X8_TYPELESS = 173, + TIF_DXGI_FORMAT_ASTC_10X8_UNORM = 174, + TIF_DXGI_FORMAT_ASTC_10X8_UNORM_SRGB = 175, + TIF_DXGI_FORMAT_ASTC_10X10_TYPELESS = 177, + TIF_DXGI_FORMAT_ASTC_10X10_UNORM = 178, + TIF_DXGI_FORMAT_ASTC_10X10_UNORM_SRGB = 179, + TIF_DXGI_FORMAT_ASTC_12X10_TYPELESS = 181, + TIF_DXGI_FORMAT_ASTC_12X10_UNORM = 182, + TIF_DXGI_FORMAT_ASTC_12X10_UNORM_SRGB = 183, + TIF_DXGI_FORMAT_ASTC_12X12_TYPELESS = 185, + TIF_DXGI_FORMAT_ASTC_12X12_UNORM = 186, + TIF_DXGI_FORMAT_ASTC_12X12_UNORM_SRGB = 187, + + // xbox 360 formats + TIF_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT = 116, + TIF_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT = 117, + TIF_DXGI_FORMAT_D16_UNORM_S8_UINT = 118, + TIF_DXGI_FORMAT_R16_UNORM_X8_TYPELESS = 119, + TIF_DXGI_FORMAT_X16_TYPELESS_G8_UINT = 120, + + TIF_DXGI_FORMAT_P208 = 130, + TIF_DXGI_FORMAT_V208 = 131, + TIF_DXGI_FORMAT_V408 = 132, + + // XBox One formats + TIF_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM = 189, + TIF_DXGI_FORMAT_R4G4_UNORM = 190, + +} TinyImageFormat_DXGI_FORMAT; +#endif + + +inline TinyImageFormat TinyImageFormat_FromDXGI_FORMAT(TinyImageFormat_DXGI_FORMAT fmt) { + switch (fmt) { + case TIF_DXGI_FORMAT_UNKNOWN: return TinyImageFormat_UNDEFINED; + case TIF_DXGI_FORMAT_R32G32B32A32_FLOAT: return TinyImageFormat_R32G32B32A32_SFLOAT; + case TIF_DXGI_FORMAT_R32G32B32A32_UINT: return TinyImageFormat_R32G32B32A32_UINT; + case TIF_DXGI_FORMAT_R32G32B32A32_SINT: return TinyImageFormat_R32G32B32A32_SINT; + case TIF_DXGI_FORMAT_R32G32B32_FLOAT: return TinyImageFormat_R32G32B32_SFLOAT; + case TIF_DXGI_FORMAT_R32G32B32_UINT: return TinyImageFormat_R32G32B32_UINT; + case TIF_DXGI_FORMAT_R32G32B32_SINT: return TinyImageFormat_R32G32B32_SINT; + case TIF_DXGI_FORMAT_R16G16B16A16_FLOAT: return TinyImageFormat_R16G16B16A16_SFLOAT; + case TIF_DXGI_FORMAT_R16G16B16A16_UNORM: return TinyImageFormat_R16G16B16A16_UNORM; + case TIF_DXGI_FORMAT_R16G16B16A16_UINT: return TinyImageFormat_R16G16B16A16_UINT; + case TIF_DXGI_FORMAT_R16G16B16A16_SNORM: return TinyImageFormat_R16G16B16A16_SNORM; + case TIF_DXGI_FORMAT_R16G16B16A16_SINT: return TinyImageFormat_R16G16B16A16_SINT; + case TIF_DXGI_FORMAT_R32G32_FLOAT: return TinyImageFormat_R32G32_SFLOAT; + case TIF_DXGI_FORMAT_R32G32_UINT: return TinyImageFormat_R32G32_UINT; + case TIF_DXGI_FORMAT_R32G32_SINT: return TinyImageFormat_R32G32_SINT; + case TIF_DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return TinyImageFormat_D32_SFLOAT_S8_UINT; + case TIF_DXGI_FORMAT_R10G10B10A2_UNORM: return TinyImageFormat_R10G10B10A2_UNORM; + case TIF_DXGI_FORMAT_R10G10B10A2_UINT: return TinyImageFormat_R10G10B10A2_UINT; + case TIF_DXGI_FORMAT_R11G11B10_FLOAT: return TinyImageFormat_B10G11R11_UFLOAT; // WRONG! + case TIF_DXGI_FORMAT_R8G8B8A8_UNORM: return TinyImageFormat_R8G8B8A8_UNORM; + case TIF_DXGI_FORMAT_R16G16_FLOAT: return TinyImageFormat_R16G16_SFLOAT; + case TIF_DXGI_FORMAT_R16G16_UNORM: return TinyImageFormat_R16G16_UNORM; + case TIF_DXGI_FORMAT_R16G16_UINT: return TinyImageFormat_R16G16_UINT; + case TIF_DXGI_FORMAT_R16G16_SNORM: return TinyImageFormat_R16G16_SNORM; + case TIF_DXGI_FORMAT_R16G16_SINT: return TinyImageFormat_R16G16_SINT; + case TIF_DXGI_FORMAT_D32_FLOAT: return TinyImageFormat_D32_SFLOAT; + case TIF_DXGI_FORMAT_R32_FLOAT: return TinyImageFormat_R32_SFLOAT; + case TIF_DXGI_FORMAT_R32_UINT: return TinyImageFormat_R32_UINT; + case TIF_DXGI_FORMAT_R32_SINT: return TinyImageFormat_R32_SINT; + case TIF_DXGI_FORMAT_D24_UNORM_S8_UINT: return TinyImageFormat_D24_UNORM_S8_UINT; + case TIF_DXGI_FORMAT_X24_TYPELESS_G8_UINT: return TinyImageFormat_D24_UNORM_S8_UINT; + case TIF_DXGI_FORMAT_R8G8_UNORM: return TinyImageFormat_R8G8_UNORM; + case TIF_DXGI_FORMAT_R8G8_UINT: return TinyImageFormat_R8G8_UINT; + case TIF_DXGI_FORMAT_R8G8_SNORM: return TinyImageFormat_R8G8_SNORM; + case TIF_DXGI_FORMAT_R8G8_SINT: return TinyImageFormat_R8G8_SINT; + case TIF_DXGI_FORMAT_R16_FLOAT: return TinyImageFormat_R16_SFLOAT; + case TIF_DXGI_FORMAT_D16_UNORM: return TinyImageFormat_D16_UNORM; + case TIF_DXGI_FORMAT_R16_UNORM: return TinyImageFormat_R16_UNORM; + case TIF_DXGI_FORMAT_R16_UINT: return TinyImageFormat_R16_UINT; + case TIF_DXGI_FORMAT_R16_SNORM: return TinyImageFormat_R16_SNORM; + case TIF_DXGI_FORMAT_R16_SINT: return TinyImageFormat_R16_SINT; + case TIF_DXGI_FORMAT_R8_UNORM: return TinyImageFormat_R8_UNORM; + case TIF_DXGI_FORMAT_R8_UINT: return TinyImageFormat_R8_UINT; + case TIF_DXGI_FORMAT_R8_SNORM: return TinyImageFormat_R8_SNORM; + case TIF_DXGI_FORMAT_R8_SINT: return TinyImageFormat_R8_SINT; + case TIF_DXGI_FORMAT_A8_UNORM: return TinyImageFormat_A8_UNORM; + case TIF_DXGI_FORMAT_R9G9B9E5_SHAREDEXP: return TinyImageFormat_E5B9G9R9_UFLOAT; + case TIF_DXGI_FORMAT_BC1_UNORM: return TinyImageFormat_DXBC1_RGBA_UNORM; + case TIF_DXGI_FORMAT_BC1_UNORM_SRGB: return TinyImageFormat_DXBC1_RGBA_SRGB; + case TIF_DXGI_FORMAT_BC2_UNORM: return TinyImageFormat_DXBC2_UNORM; + case TIF_DXGI_FORMAT_BC2_UNORM_SRGB: return TinyImageFormat_DXBC2_SRGB; + case TIF_DXGI_FORMAT_BC3_UNORM: return TinyImageFormat_DXBC3_UNORM; + case TIF_DXGI_FORMAT_BC3_UNORM_SRGB: return TinyImageFormat_DXBC3_SRGB; + case TIF_DXGI_FORMAT_BC4_UNORM: return TinyImageFormat_DXBC4_UNORM; + case TIF_DXGI_FORMAT_BC4_SNORM: return TinyImageFormat_DXBC4_SNORM; + case TIF_DXGI_FORMAT_BC5_UNORM: return TinyImageFormat_DXBC5_UNORM; + case TIF_DXGI_FORMAT_BC5_SNORM: return TinyImageFormat_DXBC5_SNORM; + case TIF_DXGI_FORMAT_B5G6R5_UNORM: return TinyImageFormat_R5G6B5_UNORM; + case TIF_DXGI_FORMAT_B5G5R5A1_UNORM: return TinyImageFormat_R5G5B5A1_UNORM; + case TIF_DXGI_FORMAT_B8G8R8A8_UNORM: return TinyImageFormat_B8G8R8A8_UNORM; + case TIF_DXGI_FORMAT_B8G8R8X8_UNORM: return TinyImageFormat_B8G8R8X8_UNORM; + case TIF_DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: return TinyImageFormat_B8G8R8A8_SRGB; + case TIF_DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: return TinyImageFormat_B8G8R8A8_SRGB; // WRONG should be X8 + case TIF_DXGI_FORMAT_BC6H_UF16: return TinyImageFormat_DXBC6H_UFLOAT; + case TIF_DXGI_FORMAT_BC6H_SF16: return TinyImageFormat_DXBC6H_SFLOAT; + case TIF_DXGI_FORMAT_BC7_UNORM: return TinyImageFormat_DXBC7_UNORM; + case TIF_DXGI_FORMAT_BC7_UNORM_SRGB: return TinyImageFormat_DXBC7_SRGB; + case TIF_DXGI_FORMAT_B4G4R4A4_UNORM: return TinyImageFormat_B4G4R4A4_UNORM; + case TIF_DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return TinyImageFormat_R8G8B8A8_SRGB; + case TIF_DXGI_FORMAT_R8G8B8A8_UINT: return TinyImageFormat_R8G8B8A8_UINT; + case TIF_DXGI_FORMAT_R8G8B8A8_SNORM: return TinyImageFormat_R8G8B8A8_SNORM; + case TIF_DXGI_FORMAT_R8G8B8A8_SINT: return TinyImageFormat_R8G8B8A8_SINT; + case TIF_DXGI_FORMAT_R4G4_UNORM: return TinyImageFormat_R4G4_UNORM; + case TIF_DXGI_FORMAT_R1_UNORM: return TinyImageFormat_R1_UNORM; + + case TIF_DXGI_FORMAT_420_OPAQUE: return TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM; + case TIF_DXGI_FORMAT_AYUV: return TinyImageFormat_B8G8R8A8_UNORM; + case TIF_DXGI_FORMAT_Y410: return TinyImageFormat_A2B10G10R10_UNORM; + case TIF_DXGI_FORMAT_Y416: return TinyImageFormat_R16G16B16A16_UNORM; + case TIF_DXGI_FORMAT_NV12: return TinyImageFormat_G8_B8R8_2PLANE_420_UNORM; + case TIF_DXGI_FORMAT_P010: return TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16; + case TIF_DXGI_FORMAT_P016: return TinyImageFormat_G16_B16R16_2PLANE_420_UNORM; + case TIF_DXGI_FORMAT_YUY2: return TinyImageFormat_G8B8G8R8_422_UNORM; + case TIF_DXGI_FORMAT_Y210: return TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16; + case TIF_DXGI_FORMAT_Y216: return TinyImageFormat_G16B16G16R16_422_UNORM; + case TIF_DXGI_FORMAT_P208: return TinyImageFormat_G8_B8R8_2PLANE_422_UNORM; + + // ASTC + case TIF_DXGI_FORMAT_ASTC_4X4_UNORM : return TinyImageFormat_ASTC_4x4_UNORM; + case TIF_DXGI_FORMAT_ASTC_4X4_UNORM_SRGB : return TinyImageFormat_ASTC_4x4_SRGB; + case TIF_DXGI_FORMAT_ASTC_5X4_UNORM : return TinyImageFormat_ASTC_5x4_UNORM; + case TIF_DXGI_FORMAT_ASTC_5X4_UNORM_SRGB : return TinyImageFormat_ASTC_5x4_SRGB; + case TIF_DXGI_FORMAT_ASTC_5X5_UNORM : return TinyImageFormat_ASTC_5x5_UNORM; + case TIF_DXGI_FORMAT_ASTC_5X5_UNORM_SRGB : return TinyImageFormat_ASTC_5x5_SRGB; + case TIF_DXGI_FORMAT_ASTC_6X5_UNORM : return TinyImageFormat_ASTC_6x5_UNORM; + case TIF_DXGI_FORMAT_ASTC_6X5_UNORM_SRGB : return TinyImageFormat_ASTC_6x5_SRGB; + case TIF_DXGI_FORMAT_ASTC_6X6_UNORM : return TinyImageFormat_ASTC_6x6_UNORM; + case TIF_DXGI_FORMAT_ASTC_6X6_UNORM_SRGB : return TinyImageFormat_ASTC_6x6_SRGB; + case TIF_DXGI_FORMAT_ASTC_8X5_UNORM : return TinyImageFormat_ASTC_8x5_UNORM; + case TIF_DXGI_FORMAT_ASTC_8X5_UNORM_SRGB : return TinyImageFormat_ASTC_8x5_SRGB; + case TIF_DXGI_FORMAT_ASTC_8X6_UNORM : return TinyImageFormat_ASTC_8x6_UNORM; + case TIF_DXGI_FORMAT_ASTC_8X6_UNORM_SRGB : return TinyImageFormat_ASTC_8x6_SRGB; + case TIF_DXGI_FORMAT_ASTC_8X8_UNORM : return TinyImageFormat_ASTC_8x8_UNORM; + case TIF_DXGI_FORMAT_ASTC_8X8_UNORM_SRGB : return TinyImageFormat_ASTC_8x8_SRGB; + case TIF_DXGI_FORMAT_ASTC_10X5_UNORM : return TinyImageFormat_ASTC_10x5_UNORM; + case TIF_DXGI_FORMAT_ASTC_10X5_UNORM_SRGB : return TinyImageFormat_ASTC_10x5_SRGB; + case TIF_DXGI_FORMAT_ASTC_10X6_UNORM : return TinyImageFormat_ASTC_10x6_UNORM; + case TIF_DXGI_FORMAT_ASTC_10X6_UNORM_SRGB : return TinyImageFormat_ASTC_10x6_SRGB; + case TIF_DXGI_FORMAT_ASTC_10X8_UNORM : return TinyImageFormat_ASTC_10x8_UNORM; + case TIF_DXGI_FORMAT_ASTC_10X8_UNORM_SRGB : return TinyImageFormat_ASTC_10x8_SRGB; + case TIF_DXGI_FORMAT_ASTC_10X10_UNORM : return TinyImageFormat_ASTC_10x10_UNORM; + case TIF_DXGI_FORMAT_ASTC_10X10_UNORM_SRGB : return TinyImageFormat_ASTC_10x10_SRGB; + case TIF_DXGI_FORMAT_ASTC_12X10_UNORM : return TinyImageFormat_ASTC_12x10_UNORM; + case TIF_DXGI_FORMAT_ASTC_12X10_UNORM_SRGB : return TinyImageFormat_ASTC_12x10_SRGB; + case TIF_DXGI_FORMAT_ASTC_12X12_UNORM : return TinyImageFormat_ASTC_12x12_UNORM; + case TIF_DXGI_FORMAT_ASTC_12X12_UNORM_SRGB : return TinyImageFormat_ASTC_12x12_SRGB; + + case TIF_DXGI_FORMAT_ASTC_4X4_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_5X4_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_5X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_6X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_6X6_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_8X6_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_8X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_8X8_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X6_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X8_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X10_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_12X10_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_12X12_TYPELESS: + + case TIF_DXGI_FORMAT_R32G32B32A32_TYPELESS: + case TIF_DXGI_FORMAT_R32G32B32_TYPELESS: + case TIF_DXGI_FORMAT_R16G16B16A16_TYPELESS: + case TIF_DXGI_FORMAT_R32G32_TYPELESS: + case TIF_DXGI_FORMAT_R32G8X24_TYPELESS: + case TIF_DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case TIF_DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + case TIF_DXGI_FORMAT_R10G10B10A2_TYPELESS: + case TIF_DXGI_FORMAT_R8G8B8A8_TYPELESS: + case TIF_DXGI_FORMAT_R16G16_TYPELESS: + case TIF_DXGI_FORMAT_R32_TYPELESS: + case TIF_DXGI_FORMAT_R24G8_TYPELESS: + case TIF_DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case TIF_DXGI_FORMAT_R8G8_TYPELESS: + case TIF_DXGI_FORMAT_R16_TYPELESS: + case TIF_DXGI_FORMAT_R8_TYPELESS: + case TIF_DXGI_FORMAT_BC1_TYPELESS: + case TIF_DXGI_FORMAT_BC2_TYPELESS: + case TIF_DXGI_FORMAT_BC3_TYPELESS: + case TIF_DXGI_FORMAT_BC4_TYPELESS: + case TIF_DXGI_FORMAT_BC5_TYPELESS: + case TIF_DXGI_FORMAT_B8G8R8A8_TYPELESS: + case TIF_DXGI_FORMAT_B8G8R8X8_TYPELESS: + case TIF_DXGI_FORMAT_BC6H_TYPELESS: + case TIF_DXGI_FORMAT_BC7_TYPELESS: + case TIF_DXGI_FORMAT_NV11: + case TIF_DXGI_FORMAT_AI44: + case TIF_DXGI_FORMAT_IA44: + case TIF_DXGI_FORMAT_P8: + case TIF_DXGI_FORMAT_A8P8: + case TIF_DXGI_FORMAT_V208: + case TIF_DXGI_FORMAT_V408: + case TIF_DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: + case TIF_DXGI_FORMAT_R8G8_B8G8_UNORM: + case TIF_DXGI_FORMAT_G8R8_G8B8_UNORM: + case TIF_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: + case TIF_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: + case TIF_DXGI_FORMAT_D16_UNORM_S8_UINT: + case TIF_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: + case TIF_DXGI_FORMAT_X16_TYPELESS_G8_UINT: + case TIF_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: + return TinyImageFormat_UNDEFINED; + } + return TinyImageFormat_UNDEFINED; +} + +inline TinyImageFormat_DXGI_FORMAT TinyImageFormat_ToDXGI_FORMAT(TinyImageFormat fmt) { + switch (fmt) { + case TinyImageFormat_R1_UNORM: return TIF_DXGI_FORMAT_R1_UNORM; + case TinyImageFormat_R4G4_UNORM: return TIF_DXGI_FORMAT_R4G4_UNORM; + case TinyImageFormat_R5G6B5_UNORM: return TIF_DXGI_FORMAT_B5G6R5_UNORM; + case TinyImageFormat_B5G6R5_UNORM: return TIF_DXGI_FORMAT_B5G6R5_UNORM; + case TinyImageFormat_B5G5R5A1_UNORM: return TIF_DXGI_FORMAT_B5G5R5A1_UNORM; + case TinyImageFormat_R8_UNORM: return TIF_DXGI_FORMAT_R8_UNORM; + case TinyImageFormat_R8_SNORM: return TIF_DXGI_FORMAT_R8_SNORM; + case TinyImageFormat_R8_UINT: return TIF_DXGI_FORMAT_R8_UINT; + case TinyImageFormat_R8_SINT: return TIF_DXGI_FORMAT_R8_SINT; + case TinyImageFormat_R8G8_UNORM: return TIF_DXGI_FORMAT_R8G8_UNORM; + case TinyImageFormat_R8G8_SNORM: return TIF_DXGI_FORMAT_R8G8_SNORM; + case TinyImageFormat_R8G8_UINT: return TIF_DXGI_FORMAT_R8G8_UINT; + case TinyImageFormat_R8G8_SINT: return TIF_DXGI_FORMAT_R8G8_SINT; + case TinyImageFormat_B4G4R4A4_UNORM: return TIF_DXGI_FORMAT_B4G4R4A4_UNORM; + + case TinyImageFormat_R8G8B8A8_UNORM: return TIF_DXGI_FORMAT_R8G8B8A8_UNORM; + case TinyImageFormat_R8G8B8A8_SNORM: return TIF_DXGI_FORMAT_R8G8B8A8_SNORM; + case TinyImageFormat_R8G8B8A8_UINT: return TIF_DXGI_FORMAT_R8G8B8A8_UINT; + case TinyImageFormat_R8G8B8A8_SINT: return TIF_DXGI_FORMAT_R8G8B8A8_SINT; + case TinyImageFormat_R8G8B8A8_SRGB: return TIF_DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; + + case TinyImageFormat_B8G8R8A8_UNORM: return TIF_DXGI_FORMAT_B8G8R8A8_UNORM; + case TinyImageFormat_B8G8R8X8_UNORM: return TIF_DXGI_FORMAT_B8G8R8X8_UNORM; + case TinyImageFormat_B8G8R8A8_SRGB: return TIF_DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; + + case TinyImageFormat_R10G10B10A2_UNORM: return TIF_DXGI_FORMAT_R10G10B10A2_UNORM; + case TinyImageFormat_B10G10R10A2_UNORM: return TIF_DXGI_FORMAT_R10G10B10A2_UNORM; + case TinyImageFormat_R10G10B10A2_UINT: return TIF_DXGI_FORMAT_R10G10B10A2_UINT; + case TinyImageFormat_B10G10R10A2_UINT: return TIF_DXGI_FORMAT_R10G10B10A2_UINT; + + case TinyImageFormat_R16_UNORM: return TIF_DXGI_FORMAT_R16_UNORM; + case TinyImageFormat_R16_SNORM: return TIF_DXGI_FORMAT_R16_SNORM; + case TinyImageFormat_R16_UINT: return TIF_DXGI_FORMAT_R16_UINT; + case TinyImageFormat_R16_SINT: return TIF_DXGI_FORMAT_R16_SINT; + case TinyImageFormat_R16_SFLOAT: return TIF_DXGI_FORMAT_R16_FLOAT; + case TinyImageFormat_R16G16_UNORM: return TIF_DXGI_FORMAT_R16G16_UNORM; + case TinyImageFormat_R16G16_SNORM: return TIF_DXGI_FORMAT_R16G16_SNORM; + case TinyImageFormat_R16G16_UINT: return TIF_DXGI_FORMAT_R16G16_UINT; + case TinyImageFormat_R16G16_SINT: return TIF_DXGI_FORMAT_R16G16_SINT; + case TinyImageFormat_R16G16_SFLOAT: return TIF_DXGI_FORMAT_R16G16_FLOAT; + case TinyImageFormat_R16G16B16A16_UNORM: return TIF_DXGI_FORMAT_R16G16B16A16_UNORM; + case TinyImageFormat_R16G16B16A16_SNORM: return TIF_DXGI_FORMAT_R16G16B16A16_SNORM; + case TinyImageFormat_R16G16B16A16_UINT: return TIF_DXGI_FORMAT_R16G16B16A16_UINT; + case TinyImageFormat_R16G16B16A16_SINT: return TIF_DXGI_FORMAT_R16G16B16A16_SINT; + case TinyImageFormat_R16G16B16A16_SFLOAT: return TIF_DXGI_FORMAT_R16G16B16A16_FLOAT; + case TinyImageFormat_R32_UINT: return TIF_DXGI_FORMAT_R32_UINT; + case TinyImageFormat_R32_SINT: return TIF_DXGI_FORMAT_R32_SINT; + case TinyImageFormat_R32_SFLOAT: return TIF_DXGI_FORMAT_R32_FLOAT; + case TinyImageFormat_R32G32_UINT: return TIF_DXGI_FORMAT_R32G32_UINT; + case TinyImageFormat_R32G32_SINT: return TIF_DXGI_FORMAT_R32G32_SINT; + case TinyImageFormat_R32G32_SFLOAT: return TIF_DXGI_FORMAT_R32G32_FLOAT; + case TinyImageFormat_R32G32B32_UINT: return TIF_DXGI_FORMAT_R32G32B32_UINT; + case TinyImageFormat_R32G32B32_SINT: return TIF_DXGI_FORMAT_R32G32B32_SINT; + case TinyImageFormat_R32G32B32_SFLOAT: return TIF_DXGI_FORMAT_R32G32B32_FLOAT; + case TinyImageFormat_R32G32B32A32_UINT: return TIF_DXGI_FORMAT_R32G32B32A32_UINT; + case TinyImageFormat_R32G32B32A32_SINT: return TIF_DXGI_FORMAT_R32G32B32A32_SINT; + case TinyImageFormat_R32G32B32A32_SFLOAT: return TIF_DXGI_FORMAT_R32G32B32A32_FLOAT; + case TinyImageFormat_B10G11R11_UFLOAT: return TIF_DXGI_FORMAT_R11G11B10_FLOAT; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TIF_DXGI_FORMAT_R9G9B9E5_SHAREDEXP; + case TinyImageFormat_D16_UNORM: return TIF_DXGI_FORMAT_D16_UNORM; + case TinyImageFormat_X8_D24_UNORM: return TIF_DXGI_FORMAT_D24_UNORM_S8_UINT; + case TinyImageFormat_D32_SFLOAT: return TIF_DXGI_FORMAT_D32_FLOAT; + case TinyImageFormat_D24_UNORM_S8_UINT: return TIF_DXGI_FORMAT_D24_UNORM_S8_UINT; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TIF_DXGI_FORMAT_D32_FLOAT_S8X24_UINT; + case TinyImageFormat_DXBC1_RGB_UNORM: return TIF_DXGI_FORMAT_BC1_UNORM; + case TinyImageFormat_DXBC1_RGB_SRGB: return TIF_DXGI_FORMAT_BC1_UNORM_SRGB; + case TinyImageFormat_DXBC1_RGBA_UNORM: return TIF_DXGI_FORMAT_BC1_UNORM; + case TinyImageFormat_DXBC1_RGBA_SRGB: return TIF_DXGI_FORMAT_BC1_UNORM_SRGB; + case TinyImageFormat_DXBC2_UNORM: return TIF_DXGI_FORMAT_BC2_UNORM; + case TinyImageFormat_DXBC2_SRGB: return TIF_DXGI_FORMAT_BC2_UNORM_SRGB; + case TinyImageFormat_DXBC3_UNORM: return TIF_DXGI_FORMAT_BC3_UNORM; + case TinyImageFormat_DXBC3_SRGB: return TIF_DXGI_FORMAT_BC3_UNORM_SRGB; + case TinyImageFormat_DXBC4_UNORM: return TIF_DXGI_FORMAT_BC4_UNORM; + case TinyImageFormat_DXBC4_SNORM: return TIF_DXGI_FORMAT_BC4_SNORM; + case TinyImageFormat_DXBC5_UNORM: return TIF_DXGI_FORMAT_BC5_UNORM; + case TinyImageFormat_DXBC5_SNORM: return TIF_DXGI_FORMAT_BC5_SNORM; + case TinyImageFormat_DXBC6H_UFLOAT: return TIF_DXGI_FORMAT_BC6H_UF16; + case TinyImageFormat_DXBC6H_SFLOAT: return TIF_DXGI_FORMAT_BC6H_SF16; + case TinyImageFormat_DXBC7_UNORM: return TIF_DXGI_FORMAT_BC7_UNORM; + case TinyImageFormat_DXBC7_SRGB: return TIF_DXGI_FORMAT_BC7_UNORM_SRGB; + case TinyImageFormat_D16_UNORM_S8_UINT: return TIF_DXGI_FORMAT_D16_UNORM_S8_UINT; + //ASTC + case TinyImageFormat_ASTC_4x4_UNORM: return TIF_DXGI_FORMAT_ASTC_4X4_UNORM; + case TinyImageFormat_ASTC_4x4_SRGB: return TIF_DXGI_FORMAT_ASTC_4X4_UNORM_SRGB; + case TinyImageFormat_ASTC_5x4_UNORM: return TIF_DXGI_FORMAT_ASTC_5X4_UNORM; + case TinyImageFormat_ASTC_5x4_SRGB: return TIF_DXGI_FORMAT_ASTC_5X4_UNORM_SRGB; + case TinyImageFormat_ASTC_5x5_UNORM: return TIF_DXGI_FORMAT_ASTC_5X5_UNORM; + case TinyImageFormat_ASTC_5x5_SRGB: return TIF_DXGI_FORMAT_ASTC_5X5_UNORM_SRGB; + case TinyImageFormat_ASTC_6x5_UNORM: return TIF_DXGI_FORMAT_ASTC_6X5_UNORM; + case TinyImageFormat_ASTC_6x5_SRGB: return TIF_DXGI_FORMAT_ASTC_6X5_UNORM_SRGB; + case TinyImageFormat_ASTC_6x6_UNORM: return TIF_DXGI_FORMAT_ASTC_6X6_UNORM; + case TinyImageFormat_ASTC_6x6_SRGB: return TIF_DXGI_FORMAT_ASTC_6X6_UNORM_SRGB; + case TinyImageFormat_ASTC_8x5_UNORM: return TIF_DXGI_FORMAT_ASTC_8X5_UNORM; + case TinyImageFormat_ASTC_8x5_SRGB: return TIF_DXGI_FORMAT_ASTC_8X5_UNORM_SRGB; + case TinyImageFormat_ASTC_8x6_UNORM: return TIF_DXGI_FORMAT_ASTC_8X6_UNORM; + case TinyImageFormat_ASTC_8x6_SRGB: return TIF_DXGI_FORMAT_ASTC_8X6_UNORM_SRGB; + case TinyImageFormat_ASTC_8x8_UNORM: return TIF_DXGI_FORMAT_ASTC_8X8_UNORM; + case TinyImageFormat_ASTC_8x8_SRGB: return TIF_DXGI_FORMAT_ASTC_8X8_UNORM_SRGB; + case TinyImageFormat_ASTC_10x5_UNORM: return TIF_DXGI_FORMAT_ASTC_10X5_UNORM; + case TinyImageFormat_ASTC_10x5_SRGB: return TIF_DXGI_FORMAT_ASTC_10X5_UNORM_SRGB; + case TinyImageFormat_ASTC_10x6_UNORM: return TIF_DXGI_FORMAT_ASTC_10X6_UNORM; + case TinyImageFormat_ASTC_10x6_SRGB: return TIF_DXGI_FORMAT_ASTC_10X6_UNORM_SRGB; + case TinyImageFormat_ASTC_10x8_UNORM: return TIF_DXGI_FORMAT_ASTC_10X8_UNORM; + case TinyImageFormat_ASTC_10x8_SRGB: return TIF_DXGI_FORMAT_ASTC_10X8_UNORM_SRGB; + case TinyImageFormat_ASTC_10x10_UNORM: return TIF_DXGI_FORMAT_ASTC_10X10_UNORM; + case TinyImageFormat_ASTC_10x10_SRGB: return TIF_DXGI_FORMAT_ASTC_10X10_UNORM_SRGB; + case TinyImageFormat_ASTC_12x10_UNORM: return TIF_DXGI_FORMAT_ASTC_12X10_UNORM; + case TinyImageFormat_ASTC_12x10_SRGB: return TIF_DXGI_FORMAT_ASTC_12X10_UNORM_SRGB; + case TinyImageFormat_ASTC_12x12_UNORM: return TIF_DXGI_FORMAT_ASTC_12X12_UNORM; + case TinyImageFormat_ASTC_12x12_SRGB: return TIF_DXGI_FORMAT_ASTC_12X12_UNORM_SRGB; + default: return TIF_DXGI_FORMAT_UNKNOWN; + } +} + +inline TinyImageFormat_DXGI_FORMAT TinyImageFormat_DXGI_FORMATToTypeless(TinyImageFormat_DXGI_FORMAT fmt) { + switch (fmt) { + case TIF_DXGI_FORMAT_R32G32B32A32_FLOAT: + case TIF_DXGI_FORMAT_R32G32B32A32_UINT: + case TIF_DXGI_FORMAT_R32G32B32A32_SINT: return TIF_DXGI_FORMAT_R32G32B32A32_TYPELESS; + case TIF_DXGI_FORMAT_R32G32B32_FLOAT: + case TIF_DXGI_FORMAT_R32G32B32_UINT: + case TIF_DXGI_FORMAT_R32G32B32_SINT: return TIF_DXGI_FORMAT_R32G32B32_TYPELESS; + + case TIF_DXGI_FORMAT_R16G16B16A16_FLOAT: + case TIF_DXGI_FORMAT_R16G16B16A16_UNORM: + case TIF_DXGI_FORMAT_R16G16B16A16_UINT: + case TIF_DXGI_FORMAT_R16G16B16A16_SNORM: + case TIF_DXGI_FORMAT_R16G16B16A16_SINT: return TIF_DXGI_FORMAT_R16G16B16A16_TYPELESS; + + case TIF_DXGI_FORMAT_R32G32_FLOAT: + case TIF_DXGI_FORMAT_R32G32_UINT: + case TIF_DXGI_FORMAT_R32G32_SINT: return TIF_DXGI_FORMAT_R32G32_TYPELESS; + + case TIF_DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: + case TIF_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: + case TIF_DXGI_FORMAT_R10G10B10A2_UNORM: + case TIF_DXGI_FORMAT_R10G10B10A2_UINT: return TIF_DXGI_FORMAT_R10G10B10A2_TYPELESS; + + case TIF_DXGI_FORMAT_R8G8B8A8_UNORM: + case TIF_DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case TIF_DXGI_FORMAT_R8G8B8A8_UINT: + case TIF_DXGI_FORMAT_R8G8B8A8_SNORM: + case TIF_DXGI_FORMAT_R8G8B8A8_SINT: return TIF_DXGI_FORMAT_R8G8B8A8_TYPELESS; + case TIF_DXGI_FORMAT_R16G16_FLOAT: + case TIF_DXGI_FORMAT_R16G16_UNORM: + case TIF_DXGI_FORMAT_R16G16_UINT: + case TIF_DXGI_FORMAT_R16G16_SNORM: + case TIF_DXGI_FORMAT_R16G16_SINT: return TIF_DXGI_FORMAT_R16G16_TYPELESS; + + case TIF_DXGI_FORMAT_R9G9B9E5_SHAREDEXP: + case TIF_DXGI_FORMAT_D32_FLOAT: + case TIF_DXGI_FORMAT_R32_FLOAT: + case TIF_DXGI_FORMAT_R32_UINT: + case TIF_DXGI_FORMAT_R32_SINT: return TIF_DXGI_FORMAT_R32_TYPELESS; + case TIF_DXGI_FORMAT_R8G8_UNORM: + case TIF_DXGI_FORMAT_R8G8_UINT: + case TIF_DXGI_FORMAT_R8G8_SNORM: + case TIF_DXGI_FORMAT_R8G8_SINT: return TIF_DXGI_FORMAT_R8G8_TYPELESS; + case TIF_DXGI_FORMAT_B4G4R4A4_UNORM: // just treats a 16 raw bits + case TIF_DXGI_FORMAT_D16_UNORM: + case TIF_DXGI_FORMAT_R16_FLOAT: + case TIF_DXGI_FORMAT_R16_UNORM: + case TIF_DXGI_FORMAT_R16_UINT: + case TIF_DXGI_FORMAT_R16_SNORM: + case TIF_DXGI_FORMAT_R16_SINT: return TIF_DXGI_FORMAT_R16_TYPELESS; + case TIF_DXGI_FORMAT_A8_UNORM: + case TIF_DXGI_FORMAT_R8_UNORM: + case TIF_DXGI_FORMAT_R8_UINT: + case TIF_DXGI_FORMAT_R8_SNORM: + case TIF_DXGI_FORMAT_R4G4_UNORM: + case TIF_DXGI_FORMAT_R8_SINT: return TIF_DXGI_FORMAT_R8_TYPELESS; + case TIF_DXGI_FORMAT_BC1_UNORM: + case TIF_DXGI_FORMAT_BC1_UNORM_SRGB: return TIF_DXGI_FORMAT_BC1_TYPELESS; + case TIF_DXGI_FORMAT_BC2_UNORM: + case TIF_DXGI_FORMAT_BC2_UNORM_SRGB: return TIF_DXGI_FORMAT_BC2_TYPELESS; + case TIF_DXGI_FORMAT_BC3_UNORM: + case TIF_DXGI_FORMAT_BC3_UNORM_SRGB: return TIF_DXGI_FORMAT_BC3_TYPELESS; + case TIF_DXGI_FORMAT_BC4_UNORM: + case TIF_DXGI_FORMAT_BC4_SNORM: return TIF_DXGI_FORMAT_BC4_TYPELESS; + case TIF_DXGI_FORMAT_BC5_UNORM: + case TIF_DXGI_FORMAT_BC5_SNORM: return TIF_DXGI_FORMAT_BC5_TYPELESS; + case TIF_DXGI_FORMAT_B5G6R5_UNORM: + case TIF_DXGI_FORMAT_B5G5R5A1_UNORM: return TIF_DXGI_FORMAT_R16_TYPELESS; + + case TIF_DXGI_FORMAT_R11G11B10_FLOAT: return TIF_DXGI_FORMAT_R11G11B10_FLOAT; + + case TIF_DXGI_FORMAT_B8G8R8X8_UNORM: + case TIF_DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: return TIF_DXGI_FORMAT_B8G8R8X8_TYPELESS; + + case TIF_DXGI_FORMAT_B8G8R8A8_UNORM: + case TIF_DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: return TIF_DXGI_FORMAT_B8G8R8A8_TYPELESS; + + case TIF_DXGI_FORMAT_BC6H_UF16: + case TIF_DXGI_FORMAT_BC6H_SF16: return TIF_DXGI_FORMAT_BC6H_TYPELESS; + + case TIF_DXGI_FORMAT_BC7_UNORM: + case TIF_DXGI_FORMAT_BC7_UNORM_SRGB: return TIF_DXGI_FORMAT_BC7_TYPELESS; + + case TIF_DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + case TIF_DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return TIF_DXGI_FORMAT_R32G8X24_TYPELESS; + case TIF_DXGI_FORMAT_X24_TYPELESS_G8_UINT: return TIF_DXGI_FORMAT_R24G8_TYPELESS; + case TIF_DXGI_FORMAT_D24_UNORM_S8_UINT: return TIF_DXGI_FORMAT_R24G8_TYPELESS; + + // ASTC + case TIF_DXGI_FORMAT_ASTC_4X4_UNORM: + case TIF_DXGI_FORMAT_ASTC_4X4_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_4X4_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_5X4_UNORM: + case TIF_DXGI_FORMAT_ASTC_5X4_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_5X4_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_5X5_UNORM: + case TIF_DXGI_FORMAT_ASTC_5X5_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_5X5_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_6X5_UNORM: + case TIF_DXGI_FORMAT_ASTC_6X5_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_6X5_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_6X6_UNORM: + case TIF_DXGI_FORMAT_ASTC_6X6_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_6X6_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_8X5_UNORM: + case TIF_DXGI_FORMAT_ASTC_8X5_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_8X5_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_8X6_UNORM: + case TIF_DXGI_FORMAT_ASTC_8X6_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_8X6_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_8X8_UNORM: + case TIF_DXGI_FORMAT_ASTC_8X8_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_8X8_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_10X5_UNORM: + case TIF_DXGI_FORMAT_ASTC_10X5_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_10X5_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_10X6_UNORM: + case TIF_DXGI_FORMAT_ASTC_10X6_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_10X6_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_10X8_UNORM: + case TIF_DXGI_FORMAT_ASTC_10X8_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_10X8_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_10X10_UNORM: + case TIF_DXGI_FORMAT_ASTC_10X10_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_10X10_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_12X10_UNORM: + case TIF_DXGI_FORMAT_ASTC_12X10_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_12X10_TYPELESS; + + case TIF_DXGI_FORMAT_ASTC_12X12_UNORM: + case TIF_DXGI_FORMAT_ASTC_12X12_UNORM_SRGB: + return TIF_DXGI_FORMAT_ASTC_12X12_TYPELESS; + + + // typeless just return the input format + case TIF_DXGI_FORMAT_ASTC_4X4_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_5X4_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_5X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_6X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_6X6_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_8X6_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_8X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_8X8_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X5_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X6_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X8_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_10X10_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_12X10_TYPELESS: + case TIF_DXGI_FORMAT_ASTC_12X12_TYPELESS: + case TIF_DXGI_FORMAT_R32G32B32A32_TYPELESS: + case TIF_DXGI_FORMAT_R32G32B32_TYPELESS: + case TIF_DXGI_FORMAT_R16G16B16A16_TYPELESS: + case TIF_DXGI_FORMAT_R32G32_TYPELESS: + case TIF_DXGI_FORMAT_R32G8X24_TYPELESS: + case TIF_DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case TIF_DXGI_FORMAT_R10G10B10A2_TYPELESS: + case TIF_DXGI_FORMAT_R8G8B8A8_TYPELESS: + case TIF_DXGI_FORMAT_R16G16_TYPELESS: + case TIF_DXGI_FORMAT_R32_TYPELESS: + case TIF_DXGI_FORMAT_R24G8_TYPELESS: + case TIF_DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case TIF_DXGI_FORMAT_R8G8_TYPELESS: + case TIF_DXGI_FORMAT_R16_TYPELESS: + case TIF_DXGI_FORMAT_R8_TYPELESS: + case TIF_DXGI_FORMAT_BC1_TYPELESS: + case TIF_DXGI_FORMAT_BC2_TYPELESS: + case TIF_DXGI_FORMAT_BC3_TYPELESS: + case TIF_DXGI_FORMAT_BC4_TYPELESS: + case TIF_DXGI_FORMAT_BC5_TYPELESS: + case TIF_DXGI_FORMAT_B8G8R8A8_TYPELESS: + case TIF_DXGI_FORMAT_B8G8R8X8_TYPELESS: + case TIF_DXGI_FORMAT_BC6H_TYPELESS: + case TIF_DXGI_FORMAT_BC7_TYPELESS: return fmt; + + case TIF_DXGI_FORMAT_R1_UNORM: + case TIF_DXGI_FORMAT_R8G8_B8G8_UNORM: + case TIF_DXGI_FORMAT_G8R8_G8B8_UNORM: + case TIF_DXGI_FORMAT_AYUV: + case TIF_DXGI_FORMAT_Y410: + case TIF_DXGI_FORMAT_Y416: + case TIF_DXGI_FORMAT_NV12: + case TIF_DXGI_FORMAT_P010: + case TIF_DXGI_FORMAT_P016: + case TIF_DXGI_FORMAT_420_OPAQUE: + case TIF_DXGI_FORMAT_YUY2: + case TIF_DXGI_FORMAT_Y210: + case TIF_DXGI_FORMAT_Y216: + case TIF_DXGI_FORMAT_NV11: + case TIF_DXGI_FORMAT_AI44: + case TIF_DXGI_FORMAT_IA44: + case TIF_DXGI_FORMAT_P8: + case TIF_DXGI_FORMAT_A8P8: + case TIF_DXGI_FORMAT_P208: + case TIF_DXGI_FORMAT_V208: + case TIF_DXGI_FORMAT_V408: + case TIF_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: + case TIF_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: + case TIF_DXGI_FORMAT_D16_UNORM_S8_UINT: + case TIF_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: + case TIF_DXGI_FORMAT_X16_TYPELESS_G8_UINT: + case TIF_DXGI_FORMAT_UNKNOWN: return TIF_DXGI_FORMAT_UNKNOWN; + } + return TIF_DXGI_FORMAT_UNKNOWN; +} +#ifndef TINYIMAGEFORMAT_MTLPIXEL_FORMAT +#define TINYIMAGEFORMAT_MTLPIXEL_FORMAT + +typedef enum TinyImageFormat_MTLPixelFormat { + TIF_MTLPixelFormatInvalid = 0, + TIF_MTLPixelFormatA8Unorm = 1, + TIF_MTLPixelFormatR8Unorm = 10, + TIF_MTLPixelFormatR8Unorm_sRGB = 11, + TIF_MTLPixelFormatR8Snorm = 12, + TIF_MTLPixelFormatR8Uint = 13, + TIF_MTLPixelFormatR8Sint = 14, + TIF_MTLPixelFormatR16Unorm = 20, + TIF_MTLPixelFormatR16Snorm = 22, + TIF_MTLPixelFormatR16Uint = 23, + TIF_MTLPixelFormatR16Sint = 24, + TIF_MTLPixelFormatR16Float = 25, + TIF_MTLPixelFormatRG8Unorm = 30, + TIF_MTLPixelFormatRG8Unorm_sRGB = 31, + TIF_MTLPixelFormatRG8Snorm = 32, + TIF_MTLPixelFormatRG8Uint = 33, + TIF_MTLPixelFormatRG8Sint = 34, + TIF_MTLPixelFormatB5G6R5Unorm = 40, + TIF_MTLPixelFormatA1BGR5Unorm = 41, + TIF_MTLPixelFormatABGR4Unorm = 42, + TIF_MTLPixelFormatBGR5A1Unorm = 43, + TIF_MTLPixelFormatR32Uint = 53, + TIF_MTLPixelFormatR32Sint = 54, + TIF_MTLPixelFormatR32Float = 55, + TIF_MTLPixelFormatRG16Unorm = 60, + TIF_MTLPixelFormatRG16Snorm = 62, + TIF_MTLPixelFormatRG16Uint = 63, + TIF_MTLPixelFormatRG16Sint = 64, + TIF_MTLPixelFormatRG16Float = 65, + TIF_MTLPixelFormatRGBA8Unorm = 70, + TIF_MTLPixelFormatRGBA8Unorm_sRGB = 71, + TIF_MTLPixelFormatRGBA8Snorm = 72, + TIF_MTLPixelFormatRGBA8Uint = 73, + TIF_MTLPixelFormatRGBA8Sint = 74, + TIF_MTLPixelFormatBGRA8Unorm = 80, + TIF_MTLPixelFormatBGRA8Unorm_sRGB = 81, + TIF_MTLPixelFormatRGB10A2Unorm = 90, + TIF_MTLPixelFormatRGB10A2Uint = 91, + TIF_MTLPixelFormatRG11B10Float = 92, + TIF_MTLPixelFormatRGB9E5Float = 93, + TIF_MTLPixelFormatBGR10A2Unorm = 94, + TIF_MTLPixelFormatBGR10_XR = 554, + TIF_MTLPixelFormatBGR10_XR_sRGB = 555, + TIF_MTLPixelFormatRG32Uint = 103, + TIF_MTLPixelFormatRG32Sint = 104, + TIF_MTLPixelFormatRG32Float = 105, + TIF_MTLPixelFormatRGBA16Unorm = 110, + TIF_MTLPixelFormatRGBA16Snorm = 112, + TIF_MTLPixelFormatRGBA16Uint = 113, + TIF_MTLPixelFormatRGBA16Sint = 114, + TIF_MTLPixelFormatRGBA16Float = 115, + TIF_MTLPixelFormatBGRA10_XR = 552, + TIF_MTLPixelFormatBGRA10_XR_sRGB = 553, + TIF_MTLPixelFormatRGBA32Uint = 123, + TIF_MTLPixelFormatRGBA32Sint = 124, + TIF_MTLPixelFormatRGBA32Float = 125, + TIF_MTLPixelFormatBC1_RGBA = 130, + TIF_MTLPixelFormatBC1_RGBA_sRGB = 131, + TIF_MTLPixelFormatBC2_RGBA = 132, + TIF_MTLPixelFormatBC2_RGBA_sRGB = 133, + TIF_MTLPixelFormatBC3_RGBA = 134, + TIF_MTLPixelFormatBC3_RGBA_sRGB = 135, + TIF_MTLPixelFormatBC4_RUnorm = 140, + TIF_MTLPixelFormatBC4_RSnorm = 141, + TIF_MTLPixelFormatBC5_RGUnorm = 142, + TIF_MTLPixelFormatBC5_RGSnorm = 143, + TIF_MTLPixelFormatBC6H_RGBFloat = 150, + TIF_MTLPixelFormatBC6H_RGBUfloat = 151, + TIF_MTLPixelFormatBC7_RGBAUnorm = 152, + TIF_MTLPixelFormatBC7_RGBAUnorm_sRGB = 153, + TIF_MTLPixelFormatPVRTC_RGB_2BPP = 160, + TIF_MTLPixelFormatPVRTC_RGB_2BPP_sRGB = 161, + TIF_MTLPixelFormatPVRTC_RGB_4BPP = 162, + TIF_MTLPixelFormatPVRTC_RGB_4BPP_sRGB = 163, + TIF_MTLPixelFormatPVRTC_RGBA_2BPP = 164, + TIF_MTLPixelFormatPVRTC_RGBA_2BPP_sRGB = 165, + TIF_MTLPixelFormatPVRTC_RGBA_4BPP = 166, + TIF_MTLPixelFormatPVRTC_RGBA_4BPP_sRGB = 167, + TIF_MTLPixelFormatEAC_R11Unorm = 170, + TIF_MTLPixelFormatEAC_R11Snorm = 172, + TIF_MTLPixelFormatEAC_RG11Unorm = 174, + TIF_MTLPixelFormatEAC_RG11Snorm = 176, + TIF_MTLPixelFormatEAC_RGBA8 = 178, + TIF_MTLPixelFormatEAC_RGBA8_sRGB = 179, + TIF_MTLPixelFormatETC2_RGB8 = 180, + TIF_MTLPixelFormatETC2_RGB8_sRGB = 181, + TIF_MTLPixelFormatETC2_RGB8A1 = 182, + TIF_MTLPixelFormatETC2_RGB8A1_sRGB = 183, + TIF_MTLPixelFormatASTC_4x4_sRGB = 186, + TIF_MTLPixelFormatASTC_5x4_sRGB = 187, + TIF_MTLPixelFormatASTC_5x5_sRGB = 188, + TIF_MTLPixelFormatASTC_6x5_sRGB = 189, + TIF_MTLPixelFormatASTC_6x6_sRGB = 190, + TIF_MTLPixelFormatASTC_8x5_sRGB = 192, + TIF_MTLPixelFormatASTC_8x6_sRGB = 193, + TIF_MTLPixelFormatASTC_8x8_sRGB = 194, + TIF_MTLPixelFormatASTC_10x5_sRGB = 195, + TIF_MTLPixelFormatASTC_10x6_sRGB = 196, + TIF_MTLPixelFormatASTC_10x8_sRGB = 197, + TIF_MTLPixelFormatASTC_10x10_sRGB = 198, + TIF_MTLPixelFormatASTC_12x10_sRGB = 199, + TIF_MTLPixelFormatASTC_12x12_sRGB = 200, + TIF_MTLPixelFormatASTC_4x4_LDR = 204, + TIF_MTLPixelFormatASTC_5x4_LDR = 205, + TIF_MTLPixelFormatASTC_5x5_LDR = 206, + TIF_MTLPixelFormatASTC_6x5_LDR = 207, + TIF_MTLPixelFormatASTC_6x6_LDR = 208, + TIF_MTLPixelFormatASTC_8x5_LDR = 210, + TIF_MTLPixelFormatASTC_8x6_LDR = 211, + TIF_MTLPixelFormatASTC_8x8_LDR = 212, + TIF_MTLPixelFormatASTC_10x5_LDR = 213, + TIF_MTLPixelFormatASTC_10x6_LDR = 214, + TIF_MTLPixelFormatASTC_10x8_LDR = 215, + TIF_MTLPixelFormatASTC_10x10_LDR = 216, + TIF_MTLPixelFormatASTC_12x10_LDR = 217, + TIF_MTLPixelFormatASTC_12x12_LDR = 218, + TIF_MTLPixelFormatGBGR422 = 240, + TIF_MTLPixelFormatBGRG422 = 241, + TIF_MTLPixelFormatDepth16Unorm = 250, + TIF_MTLPixelFormatDepth32Float = 252, + TIF_MTLPixelFormatStencil8 = 253, + TIF_MTLPixelFormatDepth24Unorm_Stencil8 = 255, + TIF_MTLPixelFormatDepth32Float_Stencil8 = 260, + TIF_MTLPixelFormatX32_Stencil8 = 261, + TIF_MTLPixelFormatX24_Stencil8 = 262, +} TinyImageFormat_MTLPixelFormat; +#endif + +inline TinyImageFormat_MTLPixelFormat TinyImageFormat_ToMTLPixelFormat(TinyImageFormat fmt) { + switch (fmt) { + case TinyImageFormat_A8_UNORM: return TIF_MTLPixelFormatA8Unorm; + case TinyImageFormat_R8_UNORM: return TIF_MTLPixelFormatR8Unorm; + case TinyImageFormat_R8_SNORM: return TIF_MTLPixelFormatR8Snorm; + case TinyImageFormat_R8_UINT: return TIF_MTLPixelFormatR8Uint; + case TinyImageFormat_R8_SINT: return TIF_MTLPixelFormatR8Sint; + case TinyImageFormat_R8_SRGB: return TIF_MTLPixelFormatR8Unorm_sRGB; + case TinyImageFormat_UNDEFINED: return TIF_MTLPixelFormatInvalid; + case TinyImageFormat_R4G4B4A4_UNORM: return TIF_MTLPixelFormatABGR4Unorm; + case TinyImageFormat_R5G6B5_UNORM: return TIF_MTLPixelFormatB5G6R5Unorm;; + case TinyImageFormat_R5G5B5A1_UNORM: return TIF_MTLPixelFormatA1BGR5Unorm; + case TinyImageFormat_R8G8_UNORM: return TIF_MTLPixelFormatRG8Unorm; + case TinyImageFormat_R8G8_SNORM: return TIF_MTLPixelFormatRG8Snorm; + case TinyImageFormat_R8G8_UINT: return TIF_MTLPixelFormatRG8Uint; + case TinyImageFormat_R8G8_SINT: return TIF_MTLPixelFormatRG8Sint; + case TinyImageFormat_R8G8_SRGB: return TIF_MTLPixelFormatRG8Unorm_sRGB; + case TinyImageFormat_R8G8B8A8_UNORM: return TIF_MTLPixelFormatRGBA8Unorm; + case TinyImageFormat_R8G8B8A8_SNORM: return TIF_MTLPixelFormatRGBA8Snorm; + case TinyImageFormat_R8G8B8A8_UINT: return TIF_MTLPixelFormatRGBA8Uint; + case TinyImageFormat_R8G8B8A8_SINT: return TIF_MTLPixelFormatRGBA8Sint; + case TinyImageFormat_R8G8B8A8_SRGB: return TIF_MTLPixelFormatRGBA8Unorm_sRGB; + case TinyImageFormat_B8G8R8A8_UNORM: return TIF_MTLPixelFormatBGRA8Unorm; + case TinyImageFormat_B8G8R8A8_SRGB: return TIF_MTLPixelFormatBGRA8Unorm_sRGB; + case TinyImageFormat_B10G10R10A2_UNORM: return TIF_MTLPixelFormatBGR10A2Unorm; + case TinyImageFormat_R10G10B10A2_UNORM: return TIF_MTLPixelFormatRGB10A2Unorm; + case TinyImageFormat_R10G10B10A2_UINT: return TIF_MTLPixelFormatRGB10A2Uint; + case TinyImageFormat_R16_UNORM: return TIF_MTLPixelFormatR16Unorm; + case TinyImageFormat_R16_SNORM: return TIF_MTLPixelFormatR16Snorm; + case TinyImageFormat_R16_UINT: return TIF_MTLPixelFormatR16Uint; + case TinyImageFormat_R16_SINT: return TIF_MTLPixelFormatR16Sint; + case TinyImageFormat_R16_SFLOAT: return TIF_MTLPixelFormatR16Float; + case TinyImageFormat_R16G16_UNORM: return TIF_MTLPixelFormatRG16Unorm; + case TinyImageFormat_R16G16_SNORM: return TIF_MTLPixelFormatRG16Snorm; + case TinyImageFormat_R16G16_UINT: return TIF_MTLPixelFormatRG16Uint; + case TinyImageFormat_R16G16_SINT: return TIF_MTLPixelFormatRG16Sint; + case TinyImageFormat_R16G16_SFLOAT: return TIF_MTLPixelFormatRG16Float; + case TinyImageFormat_R16G16B16A16_UNORM: return TIF_MTLPixelFormatRGBA16Unorm; + case TinyImageFormat_R16G16B16A16_SNORM: return TIF_MTLPixelFormatRGBA16Snorm; + case TinyImageFormat_R16G16B16A16_UINT: return TIF_MTLPixelFormatRGBA16Uint; + case TinyImageFormat_R16G16B16A16_SINT: return TIF_MTLPixelFormatRGBA16Sint; + case TinyImageFormat_R16G16B16A16_SFLOAT: return TIF_MTLPixelFormatRGBA16Float; + case TinyImageFormat_R32_UINT: return TIF_MTLPixelFormatR32Uint; + case TinyImageFormat_R32_SINT: return TIF_MTLPixelFormatR32Sint; + case TinyImageFormat_R32_SFLOAT: return TIF_MTLPixelFormatR32Float; + case TinyImageFormat_R32G32_UINT: return TIF_MTLPixelFormatRG32Uint; + case TinyImageFormat_R32G32_SINT: return TIF_MTLPixelFormatRG32Sint; + case TinyImageFormat_R32G32_SFLOAT: return TIF_MTLPixelFormatRG32Float; + case TinyImageFormat_R32G32B32A32_UINT: return TIF_MTLPixelFormatRGBA32Uint; + case TinyImageFormat_R32G32B32A32_SINT: return TIF_MTLPixelFormatRGBA32Sint; + case TinyImageFormat_R32G32B32A32_SFLOAT: return TIF_MTLPixelFormatRGBA32Float; + case TinyImageFormat_B10G11R11_UFLOAT: return TIF_MTLPixelFormatRG11B10Float; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TIF_MTLPixelFormatRGB9E5Float; + case TinyImageFormat_D16_UNORM: return TIF_MTLPixelFormatDepth16Unorm; + case TinyImageFormat_X8_D24_UNORM: return TIF_MTLPixelFormatDepth24Unorm_Stencil8; + case TinyImageFormat_D32_SFLOAT: return TIF_MTLPixelFormatDepth32Float; + case TinyImageFormat_S8_UINT: return TIF_MTLPixelFormatStencil8; + case TinyImageFormat_D24_UNORM_S8_UINT: return TIF_MTLPixelFormatDepth24Unorm_Stencil8; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TIF_MTLPixelFormatDepth32Float_Stencil8; + case TinyImageFormat_DXBC1_RGB_UNORM: return TIF_MTLPixelFormatBC1_RGBA; + case TinyImageFormat_DXBC1_RGB_SRGB: return TIF_MTLPixelFormatBC1_RGBA_sRGB; + case TinyImageFormat_DXBC1_RGBA_UNORM: return TIF_MTLPixelFormatBC1_RGBA; + case TinyImageFormat_DXBC1_RGBA_SRGB: return TIF_MTLPixelFormatBC1_RGBA_sRGB; + case TinyImageFormat_DXBC2_UNORM: return TIF_MTLPixelFormatBC2_RGBA; + case TinyImageFormat_DXBC2_SRGB: return TIF_MTLPixelFormatBC2_RGBA_sRGB; + case TinyImageFormat_DXBC3_UNORM: return TIF_MTLPixelFormatBC3_RGBA; + case TinyImageFormat_DXBC3_SRGB: return TIF_MTLPixelFormatBC3_RGBA_sRGB; + case TinyImageFormat_DXBC4_UNORM: return TIF_MTLPixelFormatBC4_RUnorm; + case TinyImageFormat_DXBC4_SNORM: return TIF_MTLPixelFormatBC4_RSnorm; + case TinyImageFormat_DXBC5_UNORM: return TIF_MTLPixelFormatBC5_RGUnorm; + case TinyImageFormat_DXBC5_SNORM: return TIF_MTLPixelFormatBC5_RGSnorm; + case TinyImageFormat_DXBC6H_UFLOAT: return TIF_MTLPixelFormatBC6H_RGBUfloat; + case TinyImageFormat_DXBC6H_SFLOAT: return TIF_MTLPixelFormatBC6H_RGBFloat; + case TinyImageFormat_DXBC7_UNORM: return TIF_MTLPixelFormatBC7_RGBAUnorm; + case TinyImageFormat_DXBC7_SRGB: return TIF_MTLPixelFormatBC7_RGBAUnorm_sRGB; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return TIF_MTLPixelFormatPVRTC_RGBA_2BPP; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return TIF_MTLPixelFormatPVRTC_RGBA_4BPP; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return TIF_MTLPixelFormatPVRTC_RGBA_2BPP_sRGB; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return TIF_MTLPixelFormatPVRTC_RGBA_4BPP_sRGB; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return TIF_MTLPixelFormatETC2_RGB8; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM:return TIF_MTLPixelFormatETC2_RGB8A1; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return TIF_MTLPixelFormatEAC_RGBA8; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return TIF_MTLPixelFormatETC2_RGB8_sRGB; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return TIF_MTLPixelFormatETC2_RGB8A1_sRGB; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return TIF_MTLPixelFormatEAC_RGBA8_sRGB; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TIF_MTLPixelFormatEAC_R11Unorm; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return TIF_MTLPixelFormatEAC_RG11Unorm; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TIF_MTLPixelFormatEAC_R11Snorm; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return TIF_MTLPixelFormatEAC_RG11Snorm; + case TinyImageFormat_ASTC_4x4_UNORM: return TIF_MTLPixelFormatASTC_4x4_LDR; + case TinyImageFormat_ASTC_4x4_SRGB: return TIF_MTLPixelFormatASTC_4x4_sRGB; + case TinyImageFormat_ASTC_5x4_UNORM: return TIF_MTLPixelFormatASTC_5x4_LDR; + case TinyImageFormat_ASTC_5x4_SRGB: return TIF_MTLPixelFormatASTC_5x4_sRGB; + case TinyImageFormat_ASTC_5x5_UNORM: return TIF_MTLPixelFormatASTC_5x5_LDR; + case TinyImageFormat_ASTC_5x5_SRGB: return TIF_MTLPixelFormatASTC_5x5_sRGB; + case TinyImageFormat_ASTC_6x5_UNORM: return TIF_MTLPixelFormatASTC_6x5_LDR; + case TinyImageFormat_ASTC_6x5_SRGB: return TIF_MTLPixelFormatASTC_6x5_sRGB; + case TinyImageFormat_ASTC_6x6_UNORM: return TIF_MTLPixelFormatASTC_6x6_LDR; + case TinyImageFormat_ASTC_6x6_SRGB: return TIF_MTLPixelFormatASTC_6x6_sRGB; + case TinyImageFormat_ASTC_8x5_UNORM: return TIF_MTLPixelFormatASTC_8x5_LDR; + case TinyImageFormat_ASTC_8x5_SRGB: return TIF_MTLPixelFormatASTC_8x5_sRGB; + case TinyImageFormat_ASTC_8x6_UNORM: return TIF_MTLPixelFormatASTC_8x6_LDR; + case TinyImageFormat_ASTC_8x6_SRGB: return TIF_MTLPixelFormatASTC_8x6_sRGB; + case TinyImageFormat_ASTC_8x8_UNORM: return TIF_MTLPixelFormatASTC_8x8_LDR; + case TinyImageFormat_ASTC_8x8_SRGB: return TIF_MTLPixelFormatASTC_8x8_sRGB; + case TinyImageFormat_ASTC_10x5_UNORM: return TIF_MTLPixelFormatASTC_10x5_LDR; + case TinyImageFormat_ASTC_10x5_SRGB: return TIF_MTLPixelFormatASTC_10x5_sRGB; + case TinyImageFormat_ASTC_10x6_UNORM: return TIF_MTLPixelFormatASTC_10x6_LDR; + case TinyImageFormat_ASTC_10x6_SRGB: return TIF_MTLPixelFormatASTC_10x6_sRGB; + case TinyImageFormat_ASTC_10x8_UNORM: return TIF_MTLPixelFormatASTC_10x8_LDR; + case TinyImageFormat_ASTC_10x8_SRGB: return TIF_MTLPixelFormatASTC_10x8_sRGB; + case TinyImageFormat_ASTC_10x10_UNORM: return TIF_MTLPixelFormatASTC_10x10_LDR; + case TinyImageFormat_ASTC_10x10_SRGB: return TIF_MTLPixelFormatASTC_10x10_sRGB; + case TinyImageFormat_ASTC_12x10_UNORM: return TIF_MTLPixelFormatASTC_12x10_LDR; + case TinyImageFormat_ASTC_12x10_SRGB: return TIF_MTLPixelFormatASTC_12x10_sRGB; + case TinyImageFormat_ASTC_12x12_UNORM: return TIF_MTLPixelFormatASTC_12x12_LDR; + case TinyImageFormat_ASTC_12x12_SRGB: return TIF_MTLPixelFormatASTC_12x12_sRGB; + + default: return TIF_MTLPixelFormatInvalid; + } + + return TIF_MTLPixelFormatInvalid; +} + +inline TinyImageFormat TinyImageFormat_FromMTLPixelFormat(TinyImageFormat_MTLPixelFormat fmt) { + switch (fmt) { + case TIF_MTLPixelFormatInvalid: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatA8Unorm: return TinyImageFormat_A8_UNORM; + case TIF_MTLPixelFormatR8Unorm: return TinyImageFormat_R8_UNORM; + case TIF_MTLPixelFormatR8Unorm_sRGB: return TinyImageFormat_R8_SRGB; + case TIF_MTLPixelFormatR8Snorm: return TinyImageFormat_R8_SNORM; + case TIF_MTLPixelFormatR8Uint: return TinyImageFormat_R8_UINT; + case TIF_MTLPixelFormatR8Sint: return TinyImageFormat_R8_SINT; + case TIF_MTLPixelFormatR16Unorm: return TinyImageFormat_R16_UNORM; + case TIF_MTLPixelFormatR16Snorm: return TinyImageFormat_R16_SNORM; + case TIF_MTLPixelFormatR16Uint: return TinyImageFormat_R16_UINT; + case TIF_MTLPixelFormatR16Sint: return TinyImageFormat_R16_SINT; + case TIF_MTLPixelFormatR16Float: return TinyImageFormat_R16_SFLOAT; + case TIF_MTLPixelFormatRG8Unorm: return TinyImageFormat_R8G8B8_UNORM; + case TIF_MTLPixelFormatRG8Unorm_sRGB: return TinyImageFormat_R8G8_SRGB; + case TIF_MTLPixelFormatRG8Snorm: return TinyImageFormat_R8G8_SNORM; + case TIF_MTLPixelFormatRG8Uint: return TinyImageFormat_R8G8_UINT; + case TIF_MTLPixelFormatRG8Sint: return TinyImageFormat_R8G8_SINT; + case TIF_MTLPixelFormatB5G6R5Unorm: return TinyImageFormat_R5G6B5_UNORM; + case TIF_MTLPixelFormatA1BGR5Unorm: return TinyImageFormat_R5G5B5A1_UNORM; + case TIF_MTLPixelFormatABGR4Unorm: return TinyImageFormat_R4G4B4A4_UNORM; + case TIF_MTLPixelFormatBGR5A1Unorm: return TinyImageFormat_A1R5G5B5_UNORM; + case TIF_MTLPixelFormatR32Uint: return TinyImageFormat_R32_UINT; + case TIF_MTLPixelFormatR32Sint: return TinyImageFormat_R32_SINT; + case TIF_MTLPixelFormatR32Float: return TinyImageFormat_R32_SFLOAT; + case TIF_MTLPixelFormatRG16Unorm: return TinyImageFormat_R16G16_UNORM; + case TIF_MTLPixelFormatRG16Snorm: return TinyImageFormat_R16G16_SNORM; + case TIF_MTLPixelFormatRG16Uint: return TinyImageFormat_R16G16B16_UINT; + case TIF_MTLPixelFormatRG16Sint: return TinyImageFormat_R16G16_SINT; + case TIF_MTLPixelFormatRG16Float: return TinyImageFormat_R16G16_SFLOAT; + case TIF_MTLPixelFormatRGBA8Unorm: return TinyImageFormat_R8G8B8A8_UNORM; + case TIF_MTLPixelFormatRGBA8Unorm_sRGB: return TinyImageFormat_R8G8B8A8_SRGB; + case TIF_MTLPixelFormatRGBA8Snorm: return TinyImageFormat_R8G8B8A8_SNORM; + case TIF_MTLPixelFormatRGBA8Uint: return TinyImageFormat_R8G8B8A8_UINT; + case TIF_MTLPixelFormatRGBA8Sint: return TinyImageFormat_R8G8B8A8_SINT; + case TIF_MTLPixelFormatBGRA8Unorm: return TinyImageFormat_B8G8R8A8_UNORM; + case TIF_MTLPixelFormatRGB10A2Unorm: return TinyImageFormat_R10G10B10A2_UNORM; + case TIF_MTLPixelFormatRGB10A2Uint: return TinyImageFormat_R10G10B10A2_UNORM; + case TIF_MTLPixelFormatRG11B10Float: return TinyImageFormat_B10G11R11_UFLOAT; + case TIF_MTLPixelFormatRGB9E5Float: return TinyImageFormat_E5B9G9R9_UFLOAT; + case TIF_MTLPixelFormatBGR10A2Unorm: return TinyImageFormat_B10G10R10A2_UNORM; + case TIF_MTLPixelFormatRG32Uint: return TinyImageFormat_R32G32_UINT; + case TIF_MTLPixelFormatRG32Sint: return TinyImageFormat_R32G32_SINT; + case TIF_MTLPixelFormatRG32Float: return TinyImageFormat_R32G32_SFLOAT; + case TIF_MTLPixelFormatRGBA16Unorm: return TinyImageFormat_R16G16B16A16_UNORM; + case TIF_MTLPixelFormatRGBA16Snorm: return TinyImageFormat_R16G16B16A16_SNORM; + case TIF_MTLPixelFormatRGBA16Uint: return TinyImageFormat_R16G16B16A16_UINT; + case TIF_MTLPixelFormatRGBA16Sint: return TinyImageFormat_R16G16B16A16_SINT; + case TIF_MTLPixelFormatRGBA16Float: return TinyImageFormat_R16G16B16A16_SFLOAT; + case TIF_MTLPixelFormatRGBA32Uint: return TinyImageFormat_R32G32B32A32_UINT; + case TIF_MTLPixelFormatRGBA32Sint: return TinyImageFormat_R32G32B32A32_SINT; + case TIF_MTLPixelFormatRGBA32Float: return TinyImageFormat_R32G32B32A32_SFLOAT; + case TIF_MTLPixelFormatBC1_RGBA: return TinyImageFormat_DXBC1_RGBA_SRGB; + case TIF_MTLPixelFormatBC1_RGBA_sRGB: return TinyImageFormat_DXBC1_RGBA_SRGB; + case TIF_MTLPixelFormatBC2_RGBA: return TinyImageFormat_DXBC2_UNORM; + case TIF_MTLPixelFormatBC2_RGBA_sRGB: return TinyImageFormat_DXBC2_SRGB; + case TIF_MTLPixelFormatBC3_RGBA: return TinyImageFormat_DXBC3_UNORM; + case TIF_MTLPixelFormatBC3_RGBA_sRGB: return TinyImageFormat_DXBC2_SRGB; + case TIF_MTLPixelFormatBC4_RUnorm: return TinyImageFormat_DXBC4_UNORM; + case TIF_MTLPixelFormatBC4_RSnorm: return TinyImageFormat_DXBC4_SNORM; + case TIF_MTLPixelFormatBC5_RGUnorm: return TinyImageFormat_DXBC5_UNORM; + case TIF_MTLPixelFormatBC5_RGSnorm: return TinyImageFormat_DXBC5_SNORM; + case TIF_MTLPixelFormatBC6H_RGBFloat: return TinyImageFormat_DXBC6H_SFLOAT; + case TIF_MTLPixelFormatBC6H_RGBUfloat: return TinyImageFormat_DXBC6H_UFLOAT; + case TIF_MTLPixelFormatBC7_RGBAUnorm: return TinyImageFormat_DXBC7_UNORM; + case TIF_MTLPixelFormatBC7_RGBAUnorm_sRGB: return TinyImageFormat_DXBC7_SRGB; + case TIF_MTLPixelFormatPVRTC_RGB_2BPP: return TinyImageFormat_PVRTC1_2BPP_UNORM; + case TIF_MTLPixelFormatPVRTC_RGB_2BPP_sRGB: return TinyImageFormat_PVRTC1_2BPP_SRGB; + case TIF_MTLPixelFormatPVRTC_RGB_4BPP: return TinyImageFormat_PVRTC1_4BPP_UNORM; + case TIF_MTLPixelFormatPVRTC_RGB_4BPP_sRGB: return TinyImageFormat_PVRTC1_4BPP_SRGB; + case TIF_MTLPixelFormatPVRTC_RGBA_2BPP: return TinyImageFormat_PVRTC1_2BPP_UNORM; + case TIF_MTLPixelFormatPVRTC_RGBA_2BPP_sRGB: return TinyImageFormat_PVRTC1_2BPP_SRGB; + case TIF_MTLPixelFormatPVRTC_RGBA_4BPP: return TinyImageFormat_PVRTC1_4BPP_UNORM; + case TIF_MTLPixelFormatPVRTC_RGBA_4BPP_sRGB: return TinyImageFormat_PVRTC1_4BPP_SRGB; + case TIF_MTLPixelFormatEAC_R11Unorm: return TinyImageFormat_ETC2_EAC_R11_UNORM; + case TIF_MTLPixelFormatEAC_R11Snorm: return TinyImageFormat_ETC2_EAC_R11_SNORM; + case TIF_MTLPixelFormatEAC_RG11Unorm: return TinyImageFormat_ETC2_EAC_R11G11_UNORM; + case TIF_MTLPixelFormatEAC_RG11Snorm: return TinyImageFormat_ETC2_EAC_R11G11_SNORM; + case TIF_MTLPixelFormatEAC_RGBA8: return TinyImageFormat_ETC2_R8G8B8A8_UNORM; + case TIF_MTLPixelFormatEAC_RGBA8_sRGB: return TinyImageFormat_ETC2_R8G8B8A8_SRGB; + case TIF_MTLPixelFormatETC2_RGB8: return TinyImageFormat_ETC2_R8G8B8_UNORM; + case TIF_MTLPixelFormatETC2_RGB8_sRGB: return TinyImageFormat_ETC2_R8G8B8_SRGB; + case TIF_MTLPixelFormatETC2_RGB8A1: return TinyImageFormat_ETC2_R8G8B8A1_UNORM; + case TIF_MTLPixelFormatETC2_RGB8A1_sRGB: return TinyImageFormat_ETC2_R8G8B8A1_SRGB; + case TIF_MTLPixelFormatASTC_4x4_sRGB: return TinyImageFormat_ASTC_4x4_SRGB; + case TIF_MTLPixelFormatASTC_5x4_sRGB: return TinyImageFormat_ASTC_5x4_SRGB; + case TIF_MTLPixelFormatASTC_5x5_sRGB: return TinyImageFormat_ASTC_5x4_SRGB; + case TIF_MTLPixelFormatASTC_6x5_sRGB: return TinyImageFormat_ASTC_6x5_SRGB; + case TIF_MTLPixelFormatASTC_6x6_sRGB: return TinyImageFormat_ASTC_6x6_SRGB; + case TIF_MTLPixelFormatASTC_8x5_sRGB: return TinyImageFormat_ASTC_8x5_SRGB; + case TIF_MTLPixelFormatASTC_8x6_sRGB: return TinyImageFormat_ASTC_8x6_SRGB; + case TIF_MTLPixelFormatASTC_8x8_sRGB: return TinyImageFormat_ASTC_8x8_SRGB; + case TIF_MTLPixelFormatASTC_10x5_sRGB: return TinyImageFormat_ASTC_10x5_SRGB; + case TIF_MTLPixelFormatASTC_10x6_sRGB: return TinyImageFormat_ASTC_10x6_SRGB; + case TIF_MTLPixelFormatASTC_10x8_sRGB: return TinyImageFormat_ASTC_10x8_SRGB; + case TIF_MTLPixelFormatASTC_10x10_sRGB: return TinyImageFormat_ASTC_10x10_SRGB; + case TIF_MTLPixelFormatASTC_12x10_sRGB: return TinyImageFormat_ASTC_12x10_SRGB; + case TIF_MTLPixelFormatASTC_12x12_sRGB: return TinyImageFormat_ASTC_12x12_SRGB; + case TIF_MTLPixelFormatASTC_4x4_LDR: return TinyImageFormat_ASTC_4x4_UNORM; + case TIF_MTLPixelFormatASTC_5x4_LDR: return TinyImageFormat_ASTC_5x4_UNORM; + case TIF_MTLPixelFormatASTC_5x5_LDR: return TinyImageFormat_ASTC_5x4_UNORM; + case TIF_MTLPixelFormatASTC_6x5_LDR: return TinyImageFormat_ASTC_6x5_UNORM; + case TIF_MTLPixelFormatASTC_6x6_LDR: return TinyImageFormat_ASTC_6x6_UNORM; + case TIF_MTLPixelFormatASTC_8x5_LDR: return TinyImageFormat_ASTC_8x5_UNORM; + case TIF_MTLPixelFormatASTC_8x6_LDR: return TinyImageFormat_ASTC_8x6_UNORM; + case TIF_MTLPixelFormatASTC_8x8_LDR: return TinyImageFormat_ASTC_8x8_UNORM; + case TIF_MTLPixelFormatASTC_10x5_LDR: return TinyImageFormat_ASTC_10x5_UNORM; + case TIF_MTLPixelFormatASTC_10x6_LDR: return TinyImageFormat_ASTC_10x6_UNORM; + case TIF_MTLPixelFormatASTC_10x8_LDR: return TinyImageFormat_ASTC_10x8_UNORM; + case TIF_MTLPixelFormatASTC_10x10_LDR: return TinyImageFormat_ASTC_10x10_UNORM; + case TIF_MTLPixelFormatASTC_12x10_LDR: return TinyImageFormat_ASTC_12x10_UNORM; + case TIF_MTLPixelFormatASTC_12x12_LDR: return TinyImageFormat_ASTC_12x12_UNORM; + case TIF_MTLPixelFormatDepth16Unorm: return TinyImageFormat_D16_UNORM; + case TIF_MTLPixelFormatDepth32Float: return TinyImageFormat_D32_SFLOAT; + case TIF_MTLPixelFormatStencil8: return TinyImageFormat_S8_UINT; + case TIF_MTLPixelFormatDepth24Unorm_Stencil8: return TinyImageFormat_D24_UNORM_S8_UINT; + case TIF_MTLPixelFormatDepth32Float_Stencil8: return TinyImageFormat_D32_SFLOAT_S8_UINT; + case TIF_MTLPixelFormatX32_Stencil8: return TinyImageFormat_D32_SFLOAT_S8_UINT; + case TIF_MTLPixelFormatX24_Stencil8: return TinyImageFormat_D24_UNORM_S8_UINT; + + case TIF_MTLPixelFormatBGRA8Unorm_sRGB: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatBGR10_XR: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatBGR10_XR_sRGB: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatBGRA10_XR: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatBGRA10_XR_sRGB: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatGBGR422: return TinyImageFormat_UNDEFINED; + case TIF_MTLPixelFormatBGRG422: return TinyImageFormat_UNDEFINED; + } + return TinyImageFormat_UNDEFINED; +} + + +inline bool TinyImageFormat_MTLPixelFormatOnMac(TinyImageFormat_MTLPixelFormat fmt) { + switch(fmt) { + case TIF_MTLPixelFormatA8Unorm: + case TIF_MTLPixelFormatR8Unorm: + case TIF_MTLPixelFormatR8Snorm: + case TIF_MTLPixelFormatR8Uint: + case TIF_MTLPixelFormatR8Sint: + case TIF_MTLPixelFormatR16Unorm: + case TIF_MTLPixelFormatR16Snorm: + case TIF_MTLPixelFormatR16Uint: + case TIF_MTLPixelFormatR16Sint: + case TIF_MTLPixelFormatR16Float: + case TIF_MTLPixelFormatRG8Unorm: + case TIF_MTLPixelFormatRG8Snorm: + case TIF_MTLPixelFormatRG8Uint: + case TIF_MTLPixelFormatRG8Sint: + case TIF_MTLPixelFormatR32Uint: + case TIF_MTLPixelFormatR32Sint: + case TIF_MTLPixelFormatR32Float: + case TIF_MTLPixelFormatRG16Unorm: + case TIF_MTLPixelFormatRG16Snorm: + case TIF_MTLPixelFormatRG16Uint: + case TIF_MTLPixelFormatRG16Sint: + case TIF_MTLPixelFormatRG16Float: + case TIF_MTLPixelFormatRGBA8Unorm: + case TIF_MTLPixelFormatRGBA8Unorm_sRGB: + case TIF_MTLPixelFormatRGBA8Snorm: + case TIF_MTLPixelFormatRGBA8Uint: + case TIF_MTLPixelFormatRGBA8Sint: + case TIF_MTLPixelFormatBGRA8Unorm: + case TIF_MTLPixelFormatBGRA8Unorm_sRGB: + case TIF_MTLPixelFormatRGB10A2Unorm: + case TIF_MTLPixelFormatRGB10A2Uint: + case TIF_MTLPixelFormatRG11B10Float: + case TIF_MTLPixelFormatRGB9E5Float: + case TIF_MTLPixelFormatBGR10A2Unorm: + case TIF_MTLPixelFormatRG32Uint: + case TIF_MTLPixelFormatRG32Sint: + case TIF_MTLPixelFormatRG32Float: + case TIF_MTLPixelFormatRGBA16Unorm: + case TIF_MTLPixelFormatRGBA16Snorm: + case TIF_MTLPixelFormatRGBA16Uint: + case TIF_MTLPixelFormatRGBA16Sint: + case TIF_MTLPixelFormatRGBA16Float: + case TIF_MTLPixelFormatRGBA32Uint: + case TIF_MTLPixelFormatRGBA32Sint: + case TIF_MTLPixelFormatRGBA32Float: + case TIF_MTLPixelFormatBC1_RGBA: + case TIF_MTLPixelFormatBC1_RGBA_sRGB: + case TIF_MTLPixelFormatBC2_RGBA: + case TIF_MTLPixelFormatBC2_RGBA_sRGB: + case TIF_MTLPixelFormatBC3_RGBA: + case TIF_MTLPixelFormatBC3_RGBA_sRGB: + case TIF_MTLPixelFormatBC4_RUnorm: + case TIF_MTLPixelFormatBC4_RSnorm: + case TIF_MTLPixelFormatBC5_RGUnorm: + case TIF_MTLPixelFormatBC5_RGSnorm: + case TIF_MTLPixelFormatBC6H_RGBFloat: + case TIF_MTLPixelFormatBC6H_RGBUfloat: + case TIF_MTLPixelFormatBC7_RGBAUnorm: + case TIF_MTLPixelFormatBC7_RGBAUnorm_sRGB: + case TIF_MTLPixelFormatGBGR422: + case TIF_MTLPixelFormatBGRG422: + case TIF_MTLPixelFormatDepth16Unorm: + case TIF_MTLPixelFormatDepth32Float: + case TIF_MTLPixelFormatStencil8: + case TIF_MTLPixelFormatDepth24Unorm_Stencil8: + case TIF_MTLPixelFormatDepth32Float_Stencil8: + case TIF_MTLPixelFormatX32_Stencil8: + case TIF_MTLPixelFormatX24_Stencil8: + return true; + + case TIF_MTLPixelFormatBGRA10_XR: + case TIF_MTLPixelFormatBGRA10_XR_sRGB: + case TIF_MTLPixelFormatBGR10_XR: + case TIF_MTLPixelFormatBGR10_XR_sRGB: + case TIF_MTLPixelFormatB5G6R5Unorm: + case TIF_MTLPixelFormatA1BGR5Unorm: + case TIF_MTLPixelFormatABGR4Unorm: + case TIF_MTLPixelFormatBGR5A1Unorm: + case TIF_MTLPixelFormatR8Unorm_sRGB: + case TIF_MTLPixelFormatRG8Unorm_sRGB: + case TIF_MTLPixelFormatPVRTC_RGB_2BPP: + case TIF_MTLPixelFormatPVRTC_RGB_2BPP_sRGB: + case TIF_MTLPixelFormatPVRTC_RGB_4BPP: + case TIF_MTLPixelFormatPVRTC_RGB_4BPP_sRGB: + case TIF_MTLPixelFormatPVRTC_RGBA_2BPP: + case TIF_MTLPixelFormatPVRTC_RGBA_2BPP_sRGB: + case TIF_MTLPixelFormatPVRTC_RGBA_4BPP: + case TIF_MTLPixelFormatPVRTC_RGBA_4BPP_sRGB: + case TIF_MTLPixelFormatEAC_R11Unorm: + case TIF_MTLPixelFormatEAC_R11Snorm: + case TIF_MTLPixelFormatEAC_RG11Unorm: + case TIF_MTLPixelFormatEAC_RG11Snorm: + case TIF_MTLPixelFormatEAC_RGBA8: + case TIF_MTLPixelFormatEAC_RGBA8_sRGB: + case TIF_MTLPixelFormatETC2_RGB8: + case TIF_MTLPixelFormatETC2_RGB8_sRGB: + case TIF_MTLPixelFormatETC2_RGB8A1: + case TIF_MTLPixelFormatETC2_RGB8A1_sRGB: + case TIF_MTLPixelFormatASTC_4x4_sRGB: + case TIF_MTLPixelFormatASTC_5x4_sRGB: + case TIF_MTLPixelFormatASTC_5x5_sRGB: + case TIF_MTLPixelFormatASTC_6x5_sRGB: + case TIF_MTLPixelFormatASTC_6x6_sRGB: + case TIF_MTLPixelFormatASTC_8x5_sRGB: + case TIF_MTLPixelFormatASTC_8x6_sRGB: + case TIF_MTLPixelFormatASTC_8x8_sRGB: + case TIF_MTLPixelFormatASTC_10x5_sRGB: + case TIF_MTLPixelFormatASTC_10x6_sRGB: + case TIF_MTLPixelFormatASTC_10x8_sRGB: + case TIF_MTLPixelFormatASTC_10x10_sRGB: + case TIF_MTLPixelFormatASTC_12x10_sRGB: + case TIF_MTLPixelFormatASTC_12x12_sRGB: + case TIF_MTLPixelFormatASTC_4x4_LDR: + case TIF_MTLPixelFormatASTC_5x4_LDR: + case TIF_MTLPixelFormatASTC_5x5_LDR: + case TIF_MTLPixelFormatASTC_6x5_LDR: + case TIF_MTLPixelFormatASTC_6x6_LDR: + case TIF_MTLPixelFormatASTC_8x5_LDR: + case TIF_MTLPixelFormatASTC_8x6_LDR: + case TIF_MTLPixelFormatASTC_8x8_LDR: + case TIF_MTLPixelFormatASTC_10x5_LDR: + case TIF_MTLPixelFormatASTC_10x6_LDR: + case TIF_MTLPixelFormatASTC_10x8_LDR: + case TIF_MTLPixelFormatASTC_10x10_LDR: + case TIF_MTLPixelFormatASTC_12x10_LDR: + case TIF_MTLPixelFormatASTC_12x12_LDR: + case TIF_MTLPixelFormatInvalid: return false; + } +} + + +inline bool TinyImageFormat_MTLPixelFormatOnIOS(TinyImageFormat_MTLPixelFormat fmt) { + switch(fmt) { + case TIF_MTLPixelFormatA8Unorm: + case TIF_MTLPixelFormatR8Unorm: + case TIF_MTLPixelFormatR8Snorm: + case TIF_MTLPixelFormatR8Uint: + case TIF_MTLPixelFormatR8Sint: + case TIF_MTLPixelFormatR16Unorm: + case TIF_MTLPixelFormatR16Snorm: + case TIF_MTLPixelFormatR16Uint: + case TIF_MTLPixelFormatR16Sint: + case TIF_MTLPixelFormatR16Float: + case TIF_MTLPixelFormatRG8Unorm: + case TIF_MTLPixelFormatRG8Snorm: + case TIF_MTLPixelFormatRG8Uint: + case TIF_MTLPixelFormatRG8Sint: + case TIF_MTLPixelFormatR32Uint: + case TIF_MTLPixelFormatR32Sint: + case TIF_MTLPixelFormatR32Float: + case TIF_MTLPixelFormatRG16Unorm: + case TIF_MTLPixelFormatRG16Snorm: + case TIF_MTLPixelFormatRG16Uint: + case TIF_MTLPixelFormatRG16Sint: + case TIF_MTLPixelFormatRG16Float: + case TIF_MTLPixelFormatRGBA8Unorm: + case TIF_MTLPixelFormatRGBA8Unorm_sRGB: + case TIF_MTLPixelFormatRGBA8Snorm: + case TIF_MTLPixelFormatRGBA8Uint: + case TIF_MTLPixelFormatRGBA8Sint: + case TIF_MTLPixelFormatBGRA8Unorm: + case TIF_MTLPixelFormatBGRA8Unorm_sRGB: + case TIF_MTLPixelFormatRGB10A2Unorm: + case TIF_MTLPixelFormatRGB10A2Uint: + case TIF_MTLPixelFormatRG11B10Float: + case TIF_MTLPixelFormatRGB9E5Float: + case TIF_MTLPixelFormatBGR10A2Unorm: + case TIF_MTLPixelFormatRG32Uint: + case TIF_MTLPixelFormatRG32Sint: + case TIF_MTLPixelFormatRG32Float: + case TIF_MTLPixelFormatRGBA16Unorm: + case TIF_MTLPixelFormatRGBA16Snorm: + case TIF_MTLPixelFormatRGBA16Uint: + case TIF_MTLPixelFormatRGBA16Sint: + case TIF_MTLPixelFormatRGBA16Float: + case TIF_MTLPixelFormatRGBA32Uint: + case TIF_MTLPixelFormatRGBA32Sint: + case TIF_MTLPixelFormatRGBA32Float: + case TIF_MTLPixelFormatGBGR422: + case TIF_MTLPixelFormatBGRG422: + case TIF_MTLPixelFormatDepth32Float: + case TIF_MTLPixelFormatStencil8: + case TIF_MTLPixelFormatDepth32Float_Stencil8: + case TIF_MTLPixelFormatX32_Stencil8: + case TIF_MTLPixelFormatBGRA10_XR: + case TIF_MTLPixelFormatBGRA10_XR_sRGB: + case TIF_MTLPixelFormatBGR10_XR: + case TIF_MTLPixelFormatBGR10_XR_sRGB: + case TIF_MTLPixelFormatPVRTC_RGB_2BPP: + case TIF_MTLPixelFormatPVRTC_RGB_2BPP_sRGB: + case TIF_MTLPixelFormatPVRTC_RGB_4BPP: + case TIF_MTLPixelFormatPVRTC_RGB_4BPP_sRGB: + case TIF_MTLPixelFormatPVRTC_RGBA_2BPP: + case TIF_MTLPixelFormatPVRTC_RGBA_2BPP_sRGB: + case TIF_MTLPixelFormatPVRTC_RGBA_4BPP: + case TIF_MTLPixelFormatPVRTC_RGBA_4BPP_sRGB: + case TIF_MTLPixelFormatEAC_R11Unorm: + case TIF_MTLPixelFormatEAC_R11Snorm: + case TIF_MTLPixelFormatEAC_RG11Unorm: + case TIF_MTLPixelFormatEAC_RG11Snorm: + case TIF_MTLPixelFormatEAC_RGBA8: + case TIF_MTLPixelFormatEAC_RGBA8_sRGB: + case TIF_MTLPixelFormatETC2_RGB8: + case TIF_MTLPixelFormatETC2_RGB8_sRGB: + case TIF_MTLPixelFormatETC2_RGB8A1: + case TIF_MTLPixelFormatETC2_RGB8A1_sRGB: + case TIF_MTLPixelFormatASTC_4x4_sRGB: + case TIF_MTLPixelFormatASTC_5x4_sRGB: + case TIF_MTLPixelFormatASTC_5x5_sRGB: + case TIF_MTLPixelFormatASTC_6x5_sRGB: + case TIF_MTLPixelFormatASTC_6x6_sRGB: + case TIF_MTLPixelFormatASTC_8x5_sRGB: + case TIF_MTLPixelFormatASTC_8x6_sRGB: + case TIF_MTLPixelFormatASTC_8x8_sRGB: + case TIF_MTLPixelFormatASTC_10x5_sRGB: + case TIF_MTLPixelFormatASTC_10x6_sRGB: + case TIF_MTLPixelFormatASTC_10x8_sRGB: + case TIF_MTLPixelFormatASTC_10x10_sRGB: + case TIF_MTLPixelFormatASTC_12x10_sRGB: + case TIF_MTLPixelFormatASTC_12x12_sRGB: + case TIF_MTLPixelFormatASTC_4x4_LDR: + case TIF_MTLPixelFormatASTC_5x4_LDR: + case TIF_MTLPixelFormatASTC_5x5_LDR: + case TIF_MTLPixelFormatASTC_6x5_LDR: + case TIF_MTLPixelFormatASTC_6x6_LDR: + case TIF_MTLPixelFormatASTC_8x5_LDR: + case TIF_MTLPixelFormatASTC_8x6_LDR: + case TIF_MTLPixelFormatASTC_8x8_LDR: + case TIF_MTLPixelFormatASTC_10x5_LDR: + case TIF_MTLPixelFormatASTC_10x6_LDR: + case TIF_MTLPixelFormatASTC_10x8_LDR: + case TIF_MTLPixelFormatASTC_10x10_LDR: + case TIF_MTLPixelFormatASTC_12x10_LDR: + case TIF_MTLPixelFormatASTC_12x12_LDR: + case TIF_MTLPixelFormatB5G6R5Unorm: + case TIF_MTLPixelFormatA1BGR5Unorm: + case TIF_MTLPixelFormatABGR4Unorm: + case TIF_MTLPixelFormatBGR5A1Unorm: + case TIF_MTLPixelFormatR8Unorm_sRGB: + case TIF_MTLPixelFormatRG8Unorm_sRGB: + return true; + + case TIF_MTLPixelFormatDepth16Unorm: + case TIF_MTLPixelFormatDepth24Unorm_Stencil8: + case TIF_MTLPixelFormatX24_Stencil8: + case TIF_MTLPixelFormatBC1_RGBA: + case TIF_MTLPixelFormatBC1_RGBA_sRGB: + case TIF_MTLPixelFormatBC2_RGBA: + case TIF_MTLPixelFormatBC2_RGBA_sRGB: + case TIF_MTLPixelFormatBC3_RGBA: + case TIF_MTLPixelFormatBC3_RGBA_sRGB: + case TIF_MTLPixelFormatBC4_RUnorm: + case TIF_MTLPixelFormatBC4_RSnorm: + case TIF_MTLPixelFormatBC5_RGUnorm: + case TIF_MTLPixelFormatBC5_RGSnorm: + case TIF_MTLPixelFormatBC6H_RGBFloat: + case TIF_MTLPixelFormatBC6H_RGBUfloat: + case TIF_MTLPixelFormatBC7_RGBAUnorm: + case TIF_MTLPixelFormatBC7_RGBAUnorm_sRGB: + case TIF_MTLPixelFormatInvalid: return false; + } +} + #undef TIF_CONSTEXPR + +//CONFFX +#ifndef TINYIMAGEFORMAT_GLFORMAT +#define TINYIMAGEFORMAT_GLFORMAT + +typedef enum TinyImageFormat_GL_FORMAT { + TIF_GL_FORMAT_UNKNOWN = 0, + // Types + TIF_GL_TYPE_COMPRESSED = 0x0, + TIF_GL_TYPE_BYTE = 0x1400, + TIF_GL_TYPE_UNSIGNED_BYTE = 0x1401, + TIF_GL_TYPE_SHORT = 0x1402, + TIF_GL_TYPE_UNSIGNED_SHORT = 0x1403, + TIF_GL_TYPE_INT = 0x1404, + TIF_GL_TYPE_UNSIGNED_INT = 0x1405, + TIF_GL_TYPE_FLOAT = 0x1406, + TIF_GL_TYPE_DOUBLE = 0x140A, + TIF_GL_TYPE_HALF_FLOAT = 0x8D61,//OES half float, was 0x140B, + TIF_GL_TYPE_UNSIGNED_BYTE_3_3_2 = 0x8032, + TIF_GL_TYPE_UNSIGNED_SHORT_4_4_4_4 = 0x8033, + TIF_GL_TYPE_UNSIGNED_SHORT_5_5_5_1 = 0x8034, + TIF_GL_TYPE_UNSIGNED_INT_8_8_8_8 = 0x8035, + TIF_GL_TYPE_UNSIGNED_INT_10_10_10_2 = 0x8036, + TIF_GL_TYPE_UNSIGNED_BYTE_2_3_3_REV = 0x8362, + TIF_GL_TYPE_UNSIGNED_SHORT_5_6_5 = 0x8363, + TIF_GL_TYPE_UNSIGNED_SHORT_5_6_5_REV = 0x8364, + TIF_GL_TYPE_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365, + TIF_GL_TYPE_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366, + TIF_GL_TYPE_UNSIGNED_INT_8_8_8_8_REV = 0x8367, + TIF_GL_TYPE_UNSIGNED_INT_2_10_10_10_REV = 0x8368, + TIF_GL_TYPE_UNSIGNED_INT_24_8 = 0x84FA, + TIF_GL_TYPE_UNSIGNED_INT_5_9_9_9_REV = 0x8C3E, + TIF_GL_TYPE_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B, + TIF_GL_TYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD, + // Formats + TIF_GL_FORMAT_RED = 0x1903, + TIF_GL_FORMAT_GREEN = 0x1904, + TIF_GL_FORMAT_BLUE = 0x1905, + TIF_GL_FORMAT_ALPHA = 0x1906, + TIF_GL_FORMAT_RGB = 0x1907, + TIF_GL_FORMAT_RGBA = 0x1908, + TIF_GL_FORMAT_LUMINANCE = 0x1909, + TIF_GL_FORMAT_LUMINANCE_ALPHA = 0x190A, + TIF_GL_FORMAT_ABGR = 0x8000, + TIF_GL_FORMAT_INTENSITY = 0x8049, + TIF_GL_FORMAT_BGR = 0x80E0, + TIF_GL_FORMAT_BGRA = 0x80E1, + TIF_GL_FORMAT_RG = 0x8227, + TIF_GL_FORMAT_RG_INTEGER = 0x8228, + TIF_GL_FORMAT_SRGB = 0x8C40, + TIF_GL_FORMAT_SRGB_ALPHA = 0x8C42, + TIF_GL_FORMAT_SLUMINANCE_ALPHA = 0x8C44, + TIF_GL_FORMAT_SLUMINANCE = 0x8C46, + TIF_GL_FORMAT_RED_INTEGER = 0x8D94, + TIF_GL_FORMAT_GREEN_INTEGER = 0x8D95, + TIF_GL_FORMAT_BLUE_INTEGER = 0x8D96, + TIF_GL_FORMAT_ALPHA_INTEGER = 0x8D97, + TIF_GL_FORMAT_RGB_INTEGER = 0x8D98, + TIF_GL_FORMAT_RGBA_INTEGER = 0x8D99, + TIF_GL_FORMAT_BGR_INTEGER = 0x8D9A, + TIF_GL_FORMAT_BGRA_INTEGER = 0x8D9B, + TIF_GL_FORMAT_RED_SNORM = 0x8F90, + TIF_GL_FORMAT_RG_SNORM = 0x8F91, + TIF_GL_FORMAT_RGB_SNORM = 0x8F92, + TIF_GL_FORMAT_RGBA_SNORM = 0x8F93, + // Internal Formats + TIF_GL_FORMAT_ALPHA4 = 0x803B, + TIF_GL_FORMAT_ALPHA8 = 0x803C, + TIF_GL_FORMAT_ALPHA12 = 0x803D, + TIF_GL_FORMAT_ALPHA16 = 0x803E, + TIF_GL_FORMAT_LUMINANCE4 = 0x803F, + TIF_GL_FORMAT_LUMINANCE8 = 0x8040, + TIF_GL_FORMAT_LUMINANCE12 = 0x8041, + TIF_GL_FORMAT_LUMINANCE16 = 0x8042, + TIF_GL_FORMAT_LUMINANCE4_ALPHA4 = 0x8043, + TIF_GL_FORMAT_LUMINANCE6_ALPHA2 = 0x8044, + TIF_GL_FORMAT_LUMINANCE8_ALPHA8 = 0x8045, + TIF_GL_FORMAT_LUMINANCE12_ALPHA4 = 0x8046, + TIF_GL_FORMAT_LUMINANCE12_ALPHA12 = 0x8047, + TIF_GL_FORMAT_LUMINANCE16_ALPHA16 = 0x8048, + TIF_GL_FORMAT_INTENSITY4 = 0x804A, + TIF_GL_FORMAT_INTENSITY8 = 0x804B, + TIF_GL_FORMAT_INTENSITY12 = 0x804C, + TIF_GL_FORMAT_INTENSITY16 = 0x804D, + TIF_GL_FORMAT_RGB2 = 0x804E, + TIF_GL_FORMAT_RGB4 = 0x804F, + TIF_GL_FORMAT_RGB5 = 0x8050, + TIF_GL_FORMAT_RGB8 = 0x8051, + TIF_GL_FORMAT_RGB10 = 0x8052, + TIF_GL_FORMAT_RGB12 = 0x8053, + TIF_GL_FORMAT_RGB16 = 0x8054, + TIF_GL_FORMAT_RGBA2 = 0x8055, + TIF_GL_FORMAT_RGBA4 = 0x8056, + TIF_GL_FORMAT_RGB5_A1 = 0x8057, + TIF_GL_FORMAT_RGBA8 = 0x8058, + TIF_GL_FORMAT_RGB10_A2 = 0x8059, + TIF_GL_FORMAT_RGBA12 = 0x805A, + TIF_GL_FORMAT_RGBA16 = 0x805B, + TIF_GL_FORMAT_R8 = 0x8229, + TIF_GL_FORMAT_R16 = 0x822A, + TIF_GL_FORMAT_RG8 = 0x822B, + TIF_GL_FORMAT_RG16 = 0x822C, + TIF_GL_FORMAT_R16F = 0x822D, + TIF_GL_FORMAT_R32F = 0x822E, + TIF_GL_FORMAT_RG16F = 0x822F, + TIF_GL_FORMAT_RG32F = 0x8230, + TIF_GL_FORMAT_R8I = 0x8231, + TIF_GL_FORMAT_R8UI = 0x8232, + TIF_GL_FORMAT_R16I = 0x8233, + TIF_GL_FORMAT_R16UI = 0x8234, + TIF_GL_FORMAT_R32I = 0x8235, + TIF_GL_FORMAT_R32UI = 0x8236, + TIF_GL_FORMAT_RG8I = 0x8237, + TIF_GL_FORMAT_RG8UI = 0x8238, + TIF_GL_FORMAT_RG16I = 0x8239, + TIF_GL_FORMAT_RG16UI = 0x823A, + TIF_GL_FORMAT_RG32I = 0x823B, + TIF_GL_FORMAT_RG32UI = 0x823C, + TIF_GL_FORMAT_RGBA32F = 0x8814, + TIF_GL_FORMAT_RGB32F = 0x8815, + TIF_GL_FORMAT_RGBA16F = 0x881A, + TIF_GL_FORMAT_RGB16F = 0x881B, + TIF_GL_FORMAT_R11F_G11F_B10F = 0x8C3A, + TIF_GL_FORMAT_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B, + TIF_GL_FORMAT_RGB9_E5 = 0x8C3D, + TIF_GL_FORMAT_SRGB8 = 0x8C41, + TIF_GL_FORMAT_SRGB8_ALPHA8 = 0x8C43, + TIF_GL_FORMAT_SLUMINANCE8_ALPHA8 = 0x8C45, + TIF_GL_FORMAT_SLUMINANCE8 = 0x8C47, + TIF_GL_FORMAT_RGB565 = 0x8D62, + TIF_GL_FORMAT_RGBA32UI = 0x8D70, + TIF_GL_FORMAT_RGB32UI = 0x8D71, + TIF_GL_FORMAT_RGBA16UI = 0x8D76, + TIF_GL_FORMAT_RGB16UI = 0x8D77, + TIF_GL_FORMAT_RGBA8UI = 0x8D7C, + TIF_GL_FORMAT_RGB8UI = 0x8D7D, + TIF_GL_FORMAT_RGBA32I = 0x8D82, + TIF_GL_FORMAT_RGB32I = 0x8D83, + TIF_GL_FORMAT_RGBA16I = 0x8D88, + TIF_GL_FORMAT_RGB16I = 0x8D89, + TIF_GL_FORMAT_RGBA8I = 0x8D8E, + TIF_GL_FORMAT_RGB8I = 0x8D8F, + TIF_GL_FORMAT_FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD, + TIF_GL_FORMAT_R8_SNORM = 0x8F94, + TIF_GL_FORMAT_RG8_SNORM = 0x8F95, + TIF_GL_FORMAT_RGB8_SNORM = 0x8F96, + TIF_GL_FORMAT_RGBA8_SNORM = 0x8F97, + TIF_GL_FORMAT_R16_SNORM = 0x8F98, + TIF_GL_FORMAT_RG16_SNORM = 0x8F99, + TIF_GL_FORMAT_RGB16_SNORM = 0x8F9A, + TIF_GL_FORMAT_RGBA16_SNORM = 0x8F9B, + TIF_GL_FORMAT_ALPHA8_SNORM = 0x9014, + TIF_GL_FORMAT_LUMINANCE8_SNORM = 0x9015, + TIF_GL_FORMAT_LUMINANCE8_ALPHA8_SNORM = 0x9016, + TIF_GL_FORMAT_INTENSITY8_SNORM = 0x9017, + TIF_GL_FORMAT_ALPHA16_SNORM = 0x9018, + TIF_GL_FORMAT_LUMINANCE16_SNORM = 0x9019, + TIF_GL_FORMAT_LUMINANCE16_ALPHA16_SNORM = 0x901A, + TIF_GL_FORMAT_INTENSITY16_SNORM = 0x901B, + // Compressed Formats + TIF_GL_FORMAT_RGBA_ASTC_4x4 = 0x93B0, + TIF_GL_FORMAT_RGBA_ASTC_5x4 = 0x93B1, + TIF_GL_FORMAT_RGBA_ASTC_5x5 = 0x93B2, + TIF_GL_FORMAT_RGBA_ASTC_6x5 = 0x93B3, + TIF_GL_FORMAT_RGBA_ASTC_6x6 = 0x93B4, + TIF_GL_FORMAT_RGBA_ASTC_8x5 = 0x93B5, + TIF_GL_FORMAT_RGBA_ASTC_8x6 = 0x93B6, + TIF_GL_FORMAT_RGBA_ASTC_8x8 = 0x93B7, + TIF_GL_FORMAT_RGBA_ASTC_10x5 = 0x93B8, + TIF_GL_FORMAT_RGBA_ASTC_10x6 = 0x93B9, + TIF_GL_FORMAT_RGBA_ASTC_10x8 = 0x93BA, + TIF_GL_FORMAT_RGBA_ASTC_10x10 = 0x93BB, + TIF_GL_FORMAT_RGBA_ASTC_12x10 = 0x93BC, + TIF_GL_FORMAT_RGBA_ASTC_12x12 = 0x93BD, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_4x4 = 0x93D0, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_5x4 = 0x93D1, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_5x5 = 0x93D2, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_6x5 = 0x93D3, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_6x6 = 0x93D4, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_8x5 = 0x93D5, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_8x6 = 0x93D6, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_8x8 = 0x93D7, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_10x5 = 0x93D8, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_10x6 = 0x93D9, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_10x8 = 0x93DA, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_10x10 = 0x93DB, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_12x10 = 0x93DC, + TIF_GL_FORMAT_SRGB8_ALPHA8_ASTC_12x12 = 0x93DD, + TIF_GL_FORMAT_RGB_S3TC_DXT1 = 0x83F0, + TIF_GL_FORMAT_RGBA_S3TC_DXT1 = 0x83F1, + TIF_GL_FORMAT_RGBA_S3TC_DXT3 = 0x83F2, + TIF_GL_FORMAT_RGBA_S3TC_DXT5 = 0x83F3, + TIF_GL_FORMAT_3DC_X_AMD = 0x87F9, + TIF_GL_FORMAT_3DC_XY_AMD = 0x87FA, + TIF_GL_FORMAT_ATC_RGBA_INTERPOLATED_ALPHA = 0x87EE, + TIF_GL_FORMAT_SRGB_PVRTC_2BPPV1 = 0x8A54, + TIF_GL_FORMAT_SRGB_PVRTC_4BPPV1 = 0x8A55, + TIF_GL_FORMAT_SRGB_ALPHA_PVRTC_2BPPV1 = 0x8A56, + TIF_GL_FORMAT_SRGB_ALPHA_PVRTC_4BPPV1 = 0x8A57, + TIF_GL_FORMAT_RGB_PVRTC_4BPPV1 = 0x8C00, + TIF_GL_FORMAT_RGB_PVRTC_2BPPV1 = 0x8C01, + TIF_GL_FORMAT_RGBA_PVRTC_4BPPV1 = 0x8C02, + TIF_GL_FORMAT_RGBA_PVRTC_2BPPV1 = 0x8C03, + TIF_GL_FORMAT_SRGB_S3TC_DXT1 = 0x8C4C, + TIF_GL_FORMAT_SRGB_ALPHA_S3TC_DXT1 = 0x8C4D, + TIF_GL_FORMAT_SRGB_ALPHA_S3TC_DXT3 = 0x8C4E, + TIF_GL_FORMAT_SRGB_ALPHA_S3TC_DXT5 = 0x8C4F, + TIF_GL_FORMAT_LUMINANCE_LATC1 = 0x8C70, + TIF_GL_FORMAT_SIGNED_LUMINANCE_LATC1 = 0x8C71, + TIF_GL_FORMAT_LUMINANCE_ALPHA_LATC2 = 0x8C72, + TIF_GL_FORMAT_SIGNED_LUMINANCE_ALPHA_LATC2 = 0x8C73, + TIF_GL_FORMAT_ATC_RGB = 0x8C92, + TIF_GL_FORMAT_ATC_RGBA_EXPLICIT_ALPHA = 0x8C93, + TIF_GL_FORMAT_RED_RGTC1 = 0x8DBB, + TIF_GL_FORMAT_SIGNED_RED_RGTC1 = 0x8DBC, + TIF_GL_FORMAT_RED_GREEN_RGTC2 = 0x8DBD, + TIF_GL_FORMAT_SIGNED_RED_GREEN_RGTC2 = 0x8DBE, + TIF_GL_FORMAT_ETC1_RGB8_OES = 0x8D64, + TIF_GL_FORMAT_RGBA_BPTC_UNORM = 0x8E8C, + TIF_GL_FORMAT_SRGB_ALPHA_BPTC_UNORM = 0x8E8D, + TIF_GL_FORMAT_RGB_BPTC_SIGNED_FLOAT = 0x8E8E, + TIF_GL_FORMAT_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F, + TIF_GL_FORMAT_R11_EAC = 0x9270, + TIF_GL_FORMAT_SIGNED_R11_EAC = 0x9271, + TIF_GL_FORMAT_RG11_EAC = 0x9272, + TIF_GL_FORMAT_SIGNED_RG11_EAC = 0x9273, + TIF_GL_FORMAT_RGB8_ETC2 = 0x9274, + TIF_GL_FORMAT_SRGB8_ETC2 = 0x9275, + TIF_GL_FORMAT_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276, + TIF_GL_FORMAT_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277, + TIF_GL_FORMAT_RGBA8_ETC2_EAC = 0x9278, + TIF_GL_FORMAT_SRGB8_ALPHA8_ETC2_EAC = 0x9279, + TIF_GL_FORMAT_SRGB_ALPHA_PVRTC_2BPPV2 = 0x93F0, + TIF_GL_FORMAT_SRGB_ALPHA_PVRTC_4BPPV2 = 0x93F1, + // Depth Formats + TIF_GL_FORMAT_DEPTH_COMPONENT = 0x1902, + TIF_GL_FORMAT_DEPTH_STENCIL = 0x84F9, + // Depth Internal Formats + TIF_GL_FORMAT_STENCIL_INDEX8 = 0x8D48, + TIF_GL_FORMAT_DEPTH_COMPONENT16 = 0x81A5, + TIF_GL_FORMAT_DEPTH24_STENCIL8 = 0x88F0, + TIF_GL_FORMAT_DEPTH_COMPONENT32F = 0x8CAC, + +} TinyImageFormat_GL_FORMAT; +#endif + +#define FT(fmt, type, intfmt, size) *glformat = TIF_GL_FORMAT_##fmt; \ + *gltype = TIF_GL_TYPE_##type; \ + *glinternalformat = TIF_GL_FORMAT_##intfmt; \ + *typesize = size; \ + return; +#define FTC(fmt, intfmt) *glformat = TIF_GL_FORMAT_##fmt; \ + *gltype = TIF_GL_TYPE_COMPRESSED; \ + *glinternalformat = TIF_GL_FORMAT_##intfmt; \ + *typesize = 1; \ + return; + +inline void TinyImageFormat_ToGL_FORMAT(TinyImageFormat fmt, uint32_t *glformat, uint32_t* gltype, uint32_t* glinternalformat, uint32_t* typesize) { + switch (fmt) + { + case TinyImageFormat_UNDEFINED: FT(UNKNOWN, UNSIGNED_SHORT_4_4_4_4, UNKNOWN, 0) + + case TinyImageFormat_R4G4_UNORM: FT(RG, UNSIGNED_SHORT_4_4_4_4, RGB4, 1) + case TinyImageFormat_R4G4B4A4_UNORM: FT(RGBA, UNSIGNED_SHORT_4_4_4_4, RGBA4, 2) + case TinyImageFormat_B4G4R4A4_UNORM: FT(BGRA, UNSIGNED_SHORT_4_4_4_4_REV, RGBA4, 2) + case TinyImageFormat_R5G6B5_UNORM: FT(RGB, UNSIGNED_SHORT_5_6_5_REV, RGB565, 2) + case TinyImageFormat_B5G6R5_UNORM: FT(BGR, UNSIGNED_SHORT_5_6_5, RGB565, 2) + case TinyImageFormat_R5G5B5A1_UNORM: FT(RGBA, UNSIGNED_SHORT_5_5_5_1, RGB5_A1, 2) + case TinyImageFormat_B5G5R5A1_UNORM: FT(BGRA, UNSIGNED_SHORT_5_5_5_1, RGB5_A1, 2) + case TinyImageFormat_A1R5G5B5_UNORM: FT(RGBA, UNSIGNED_SHORT_1_5_5_5_REV, RGB5_A1, 2) + case TinyImageFormat_R8_UNORM: FT(LUMINANCE, UNSIGNED_BYTE, R8, 1) // RED -> LUMINANCE For older api's + case TinyImageFormat_R8_SNORM: FT(RED, BYTE, R8_SNORM, 1) + case TinyImageFormat_R8_UINT: FT(RED_INTEGER, UNSIGNED_BYTE, R8UI, 1) + case TinyImageFormat_R8_SINT: FT(RED_INTEGER, BYTE, R8I, 1) + case TinyImageFormat_R8_SRGB: FT(SLUMINANCE, UNSIGNED_BYTE, SRGB8, 1) + case TinyImageFormat_R8G8_UNORM: FT(RG, UNSIGNED_BYTE, RG8, 1) + case TinyImageFormat_R8G8_SNORM: FT(RG, BYTE, RG8_SNORM, 1) + case TinyImageFormat_R8G8_UINT: FT(RG_INTEGER, UNSIGNED_BYTE, RG8UI, 1) + case TinyImageFormat_R8G8_SINT: FT(RG_INTEGER, BYTE, RG8I, 1) + case TinyImageFormat_R8G8_SRGB: FT(SLUMINANCE_ALPHA, UNSIGNED_BYTE, SRGB8, 1) + case TinyImageFormat_R8G8B8_UNORM: FT(RGB, UNSIGNED_BYTE, RGB8, 1) + case TinyImageFormat_R8G8B8_SNORM: FT(RGB, BYTE, RGB8_SNORM, 1) + case TinyImageFormat_R8G8B8_UINT: FT(RGB_INTEGER, UNSIGNED_BYTE, RGB8UI, 1) + case TinyImageFormat_R8G8B8_SINT: FT(RGB_INTEGER, BYTE, RGB8I, 1) + case TinyImageFormat_R8G8B8_SRGB: FT(SRGB, UNSIGNED_BYTE, SRGB8, 1) + case TinyImageFormat_B8G8R8_UNORM: FT(BGR, UNSIGNED_BYTE, RGB8, 1) + case TinyImageFormat_B8G8R8_SNORM: FT(BGR, BYTE, RGB8_SNORM, 1) + case TinyImageFormat_B8G8R8_UINT: FT(BGR_INTEGER, UNSIGNED_BYTE, RGB8UI, 1) + case TinyImageFormat_B8G8R8_SINT: FT(BGR_INTEGER, BYTE, RGB8I, 1) + case TinyImageFormat_B8G8R8_SRGB: FT(BGR, UNSIGNED_BYTE, SRGB8, 1) + case TinyImageFormat_R8G8B8A8_UNORM: FT(RGBA, UNSIGNED_BYTE, RGBA8, 1) + case TinyImageFormat_R8G8B8A8_SNORM: FT(RGBA, BYTE, RGBA8_SNORM, 1) + case TinyImageFormat_R8G8B8A8_UINT: FT(RGBA_INTEGER, UNSIGNED_BYTE, RGBA8UI, 1) + case TinyImageFormat_R8G8B8A8_SINT: FT(RGBA_INTEGER, BYTE, RGBA8I, 1) + case TinyImageFormat_R8G8B8A8_SRGB: FT(SRGB_ALPHA, UNSIGNED_BYTE, SRGB8, 1) + case TinyImageFormat_B8G8R8A8_UNORM: FT(BGRA, UNSIGNED_BYTE, RGBA8, 1) + case TinyImageFormat_B8G8R8A8_SNORM: FT(BGRA, BYTE, RGBA8_SNORM, 1) + case TinyImageFormat_B8G8R8A8_UINT: FT(BGRA_INTEGER, UNSIGNED_BYTE, RGBA8UI, 1) + case TinyImageFormat_B8G8R8A8_SINT: FT(BGRA_INTEGER, BYTE, RGBA8I, 1) + case TinyImageFormat_B8G8R8A8_SRGB: FT(BGRA, UNSIGNED_BYTE, SRGB8, 1) + case TinyImageFormat_R10G10B10A2_UNORM: FT(RGBA, UNSIGNED_INT_2_10_10_10_REV, RGB10_A2, 4) + case TinyImageFormat_R10G10B10A2_UINT: FT(RGBA_INTEGER, UNSIGNED_INT_2_10_10_10_REV, RGB10_A2, 4) + case TinyImageFormat_B10G10R10A2_UNORM: FT(BGRA, UNSIGNED_INT_2_10_10_10_REV, RGB10_A2, 4) + case TinyImageFormat_B10G10R10A2_UINT: FT(BGRA_INTEGER, UNSIGNED_INT_2_10_10_10_REV, RGB10_A2, 4) + case TinyImageFormat_R16_UNORM: FT(RED, UNSIGNED_SHORT, R16, 2) + case TinyImageFormat_R16_SNORM: FT(RED, SHORT, R16_SNORM, 2) + case TinyImageFormat_R16_UINT: FT(RED_INTEGER, UNSIGNED_SHORT, R16UI, 2) + case TinyImageFormat_R16_SINT: FT(RED_INTEGER, SHORT, R16I, 2) + case TinyImageFormat_R16_SFLOAT: FT(RED, HALF_FLOAT, R16F, 2) + case TinyImageFormat_R16G16_UNORM: FT(RG, UNSIGNED_SHORT, RG16, 2) + case TinyImageFormat_R16G16_SNORM: FT(RG, SHORT, RG16_SNORM, 2) + case TinyImageFormat_R16G16_UINT: FT(RG_INTEGER, UNSIGNED_SHORT, RG16UI, 2) + case TinyImageFormat_R16G16_SINT: FT(RG_INTEGER, SHORT, RG16I, 2) + case TinyImageFormat_R16G16_SFLOAT: FT(RG, HALF_FLOAT, RG16F, 2) + case TinyImageFormat_R16G16B16_UNORM: FT(RGB, UNSIGNED_SHORT, RGB16, 2) + case TinyImageFormat_R16G16B16_SNORM: FT(RGB, SHORT, RGB16_SNORM, 2) + case TinyImageFormat_R16G16B16_UINT: FT(RGB_INTEGER, UNSIGNED_SHORT, RGB16UI, 2) + case TinyImageFormat_R16G16B16_SINT: FT(RGB_INTEGER, SHORT, RGB16I, 2) + case TinyImageFormat_R16G16B16_SFLOAT: FT(RGB, HALF_FLOAT, RGB16F, 2) + case TinyImageFormat_R16G16B16A16_UNORM: FT(RGBA, UNSIGNED_SHORT, RGBA16, 2) + case TinyImageFormat_R16G16B16A16_SNORM: FT(RGBA, SHORT, RGBA16_SNORM, 2) + case TinyImageFormat_R16G16B16A16_UINT: FT(RGBA_INTEGER, UNSIGNED_SHORT, RGBA16UI, 2) + case TinyImageFormat_R16G16B16A16_SINT: FT(RGBA_INTEGER, SHORT, RGBA16I, 2) + case TinyImageFormat_R16G16B16A16_SFLOAT: FT(RGBA, HALF_FLOAT, RGBA16F, 2) + case TinyImageFormat_R32_UINT: FT(RED_INTEGER, UNSIGNED_INT, R32UI, 4) + case TinyImageFormat_R32_SINT: FT(RED_INTEGER, INT, R32I, 4) + case TinyImageFormat_R32_SFLOAT: FT(RED, FLOAT, R32F, 4) + case TinyImageFormat_R32G32_UINT: FT(RG_INTEGER, UNSIGNED_INT, RG32UI, 4) + case TinyImageFormat_R32G32_SINT: FT(RG_INTEGER, INT, RG32I, 4) + case TinyImageFormat_R32G32_SFLOAT: FT(RG, FLOAT, RG32F, 4) + case TinyImageFormat_R32G32B32_UINT: FT(RGB_INTEGER, UNSIGNED_INT, RGB32UI, 4) + case TinyImageFormat_R32G32B32_SINT: FT(RGB_INTEGER, INT, RGB32I, 4) + case TinyImageFormat_R32G32B32_SFLOAT: FT(RGB_INTEGER, FLOAT, RGB32F, 4) + case TinyImageFormat_R32G32B32A32_UINT: FT(RGBA_INTEGER, UNSIGNED_INT, RGBA32UI, 4) + case TinyImageFormat_R32G32B32A32_SINT: FT(RGBA_INTEGER, INT, RGBA32I, 4) + case TinyImageFormat_R32G32B32A32_SFLOAT: FT(RGBA, FLOAT, RGBA32F, 4) + case TinyImageFormat_B10G11R11_UFLOAT: FT(BGR, UNSIGNED_INT_10F_11F_11F_REV, R11F_G11F_B10F, 4) + case TinyImageFormat_E5B9G9R9_UFLOAT: FT(BGR, UNSIGNED_INT_5_9_9_9_REV, RGB9_E5, 4); + + // Compressed Formats + case TinyImageFormat_DXBC1_RGB_UNORM: FTC(RGB, RGB_S3TC_DXT1) + case TinyImageFormat_DXBC1_RGB_SRGB: FTC(RGB, SRGB_S3TC_DXT1) + case TinyImageFormat_DXBC1_RGBA_UNORM: FTC(RGBA, RGBA_S3TC_DXT1) + case TinyImageFormat_DXBC1_RGBA_SRGB: FTC(RGBA, SRGB_ALPHA_S3TC_DXT1) + case TinyImageFormat_DXBC2_UNORM: FTC(RGBA, RGBA_S3TC_DXT3) + case TinyImageFormat_DXBC2_SRGB: FTC(RGBA, SRGB_ALPHA_S3TC_DXT3) + case TinyImageFormat_DXBC3_UNORM: FTC(RGBA, RGBA_S3TC_DXT5) + case TinyImageFormat_DXBC3_SRGB: FTC(RGBA, SRGB_ALPHA_S3TC_DXT5) + case TinyImageFormat_DXBC4_UNORM: FTC(RED, RED_RGTC1) + case TinyImageFormat_DXBC4_SNORM: FTC(RED, SIGNED_RED_RGTC1) + case TinyImageFormat_DXBC5_UNORM: FTC(RG, RED_GREEN_RGTC2) + case TinyImageFormat_DXBC5_SNORM: FTC(RG, SIGNED_RED_GREEN_RGTC2) + case TinyImageFormat_DXBC6H_UFLOAT: FTC(RGB, RGB_BPTC_UNSIGNED_FLOAT) + case TinyImageFormat_DXBC6H_SFLOAT: FTC(RGB, RGB_BPTC_SIGNED_FLOAT) + case TinyImageFormat_DXBC7_UNORM: FTC(RGBA, RGBA_BPTC_UNORM) + case TinyImageFormat_DXBC7_SRGB: FTC(RGBA, SRGB_ALPHA_BPTC_UNORM) + case TinyImageFormat_PVRTC1_2BPP_UNORM: FTC(RGB, RGB_PVRTC_2BPPV1) + case TinyImageFormat_PVRTC1_4BPP_UNORM: FTC(RGB, RGB_PVRTC_4BPPV1) + case TinyImageFormat_PVRTC1_2BPP_SRGB: FTC(SRGB, SRGB_PVRTC_2BPPV1) + case TinyImageFormat_PVRTC1_4BPP_SRGB: FTC(SRGB, SRGB_PVRTC_4BPPV1) + + case TinyImageFormat_ETC2_R8G8B8_UNORM: FTC(RGB, RGB8_ETC2) + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: FTC(RGBA, RGB8_PUNCHTHROUGH_ALPHA1_ETC2) + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: FTC(RGBA, RGBA8_ETC2_EAC) + case TinyImageFormat_ETC2_R8G8B8_SRGB: FTC(SRGB, SRGB8_ETC2) + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: FTC(SRGB_ALPHA, SRGB8_PUNCHTHROUGH_ALPHA1_ETC2) + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ETC2_EAC) + case TinyImageFormat_ETC2_EAC_R11_UNORM: FTC(RED, R11_EAC) + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: FTC(RG, RG11_EAC) + case TinyImageFormat_ETC2_EAC_R11_SNORM: FTC(RED, SIGNED_R11_EAC) + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: FTC(RG, SIGNED_RG11_EAC) + case TinyImageFormat_ASTC_4x4_UNORM: FTC(RGBA, RGBA_ASTC_4x4) + case TinyImageFormat_ASTC_4x4_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_4x4) + case TinyImageFormat_ASTC_5x4_UNORM: FTC(RGBA, RGBA_ASTC_5x4) + case TinyImageFormat_ASTC_5x4_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_5x4) + case TinyImageFormat_ASTC_5x5_UNORM: FTC(RGBA, RGBA_ASTC_5x5) + case TinyImageFormat_ASTC_5x5_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_5x5) + case TinyImageFormat_ASTC_6x5_UNORM: FTC(RGBA, RGBA_ASTC_6x5) + case TinyImageFormat_ASTC_6x5_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_6x5) + case TinyImageFormat_ASTC_6x6_UNORM: FTC(RGBA, RGBA_ASTC_6x6) + case TinyImageFormat_ASTC_6x6_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_6x6) + case TinyImageFormat_ASTC_8x5_UNORM: FTC(RGBA, RGBA_ASTC_8x5) + case TinyImageFormat_ASTC_8x5_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_8x5) + case TinyImageFormat_ASTC_8x6_UNORM: FTC(RGBA, RGBA_ASTC_8x6) + case TinyImageFormat_ASTC_8x6_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_8x6) + case TinyImageFormat_ASTC_8x8_UNORM: FTC(RGBA, RGBA_ASTC_8x8) + case TinyImageFormat_ASTC_8x8_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_8x8) + case TinyImageFormat_ASTC_10x5_UNORM: FTC(RGBA, RGBA_ASTC_10x5) + case TinyImageFormat_ASTC_10x5_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_10x5) + case TinyImageFormat_ASTC_10x6_UNORM: FTC(RGBA, RGBA_ASTC_10x6) + case TinyImageFormat_ASTC_10x6_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_10x6) + case TinyImageFormat_ASTC_10x8_UNORM: FTC(RGBA, RGBA_ASTC_10x8); + case TinyImageFormat_ASTC_10x8_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_10x8) + case TinyImageFormat_ASTC_10x10_UNORM: FTC(RGBA, RGBA_ASTC_10x10) + case TinyImageFormat_ASTC_10x10_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_10x10) + case TinyImageFormat_ASTC_12x10_UNORM: FTC(RGBA, RGBA_ASTC_12x10) + case TinyImageFormat_ASTC_12x10_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_12x10) + case TinyImageFormat_ASTC_12x12_UNORM: FTC(RGBA, RGBA_ASTC_12x12) + case TinyImageFormat_ASTC_12x12_SRGB: FTC(SRGB_ALPHA, SRGB8_ALPHA8_ASTC_12x12) + + // Depth + case TinyImageFormat_D32_SFLOAT: FT(DEPTH_COMPONENT, UNSIGNED_INT, DEPTH_COMPONENT32F, 4) + case TinyImageFormat_D16_UNORM: FT(DEPTH_COMPONENT, UNSIGNED_SHORT, DEPTH_COMPONENT16, 2) + case TinyImageFormat_S8_UINT: FT(DEPTH_COMPONENT, UNSIGNED_BYTE, STENCIL_INDEX8, 1) + case TinyImageFormat_D24_UNORM_S8_UINT: FT(DEPTH_STENCIL, UNSIGNED_INT_24_8, DEPTH24_STENCIL8, 4) + default: FT(UNKNOWN, UNSIGNED_SHORT_4_4_4_4, UNKNOWN, 0) + } +} +#undef FT +#undef FTC +//CONFFX +#endif // TINYIMAGEFORMAT_APIS_H_ \ No newline at end of file diff --git a/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_base.h b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_base.h new file mode 100644 index 0000000..ba86991 --- /dev/null +++ b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_base.h @@ -0,0 +1,523 @@ +// Auto generated by formatgen on Sep 21 2019 +#pragma once +#if !defined(TINYIMAGEFORMAT_BASE_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) +#define TINYIMAGEFORMAT_BASE_H_ 1 + +/* TinyImageFormat is a library about the encodings of pixels typically + * encountered in real time graphics. + * + * Like modern graphics API it is enumeration based but it also provides an API + * for reasoning about that enumeration programmatically. + * + * Additionally it provide ways of accessing pixels encoded in the specified + * format for most pixel formats. The hope is eventually to get decode to 100% + * but not there yet (119 out of 193 currently). + * This allows you to effectively read/write a large amount of image data. + * + * To assist with working with graphics APIs converters to and from Vulkan, + * D3D12 and Metal. These are self contained and do not require the actual APIs. + * + * Available as either a single header or a version made of 6 headers split into + * functional groups. Use one style or the other but they don't mix. + * + * These files are large due to unrolling and large switches. Functions are + * inlined, allowing the compiler to eliminate and collapse when possible, + * however particularly the Encode/Decode functions aren't near as fast as they + * could be if heavily optimised for specific formats/layouts. + * + * Whilst not optimal due to number of formats it supports, it intends to be + * fast enough that in many cases it will be fine. + * + * Internally every format has a descriptor packed into a 64 bit code word. + * This code word is used to generate the header and it isn't used by the API + * itself, as its been 'burnt' out by the code generator but it can be used at + * runtime if desired and in future its intended to be used for exotic packed + * formats that don't get there own enumeration value but can be expressed + * via a descriptor. + * + * Where possible for C++ users functions are constexpr. + * + * It is MIT licensed and borrows/builds on code/specs including but not + * limited to + * Microsoft's Chris Walbourn DXTextureTool + * Rygerous public domain Half to float (and vice versa) code + * Khronos DFD specifications + * Khronos Vulkan Specification + * Microsoft D3D11/D3D12 Specifications + * Apple Metal documentation + * DDS Loaders from various sources (Humus, Confetti FX, DXTextureTool) + * + * TODO + * ---- + * Test CLUT formats and add encode clause + * Add shared component i.e. G8R8G8B8 4:2:x formats + * Add Multi plane formats + * Add compressed format decoders + * Add Block copy (for updating compressed formats) + * Add functions that work on descriptor codes directly + * Add UFLOAT 6 and 7 bit support + * Optional SIMD decode/encode functions + * More tests + * + * Definitions + * ----------- + * + * Pixel + * We define a pixel as upto 4 channels representing a single 'colour' + * Its may not be addressable directly but as blocks of related pixels. + * When decode/encoding pixels are presented to the API as 4 floats or doubles. + * + * Logical Channels (TinyImageFormat_LogicalChannel) + * Logical channel are the usual way you would ask for a particular channel, + * so asking about LC_Red while get you data for the red channel, however its + * actually physically encoded in the data. + * + * Physical Channels (TinyImageFormat_PhysicalChannel) + * Physical channels are the inverse of logical channels, that have no meaning + * beyond the position in the data itself. + * + * Both Logical and Physical channels support returning constant 0 or 1 + * + * Blocks + * A block is the smallest addressable element this format refers to. Blocks + * have up to 3 dimensions (though no format currently uses the 3rd). + * Blocks are always at least byte aligned. + * For single pixel formats this will be 1x1x1. For something like R1 it would + * be 8x1x1 (8 single bits for 8 pixels). + * For block compressed format a common value is 4x4x1. + * A block for shared channels or very tightly packed this is how many pixels + * are combined into one addressable unit. + * + * API + * --- + * The primary enumeration is simply TinyImageFormat, everything else supports + * this enum. + * All functions, enums etc. are prefixed with TinyImageFormat_, All functions + * also take the format as first parameter. These are often removed in the api + * docs to save space. + * + * Defines + * ------- + * TinyImageFormat_Count - how many formats in total + * TinyImageFormat_MaxPixelCountOfBlock - maximum number of pixels in a block + * - for any format (for static decode buffer allocation) + * + * Enums + * ----- + * TinyImageFormat - Count entries, one for each format supported + * LogicalChannel - values for logical channel or constants + * - LC_Red - Red channel is specified + * - LC_Green - Green channel is specified + * - LC_Blue - Blue channel is specified + * - LC_Alpha - Alpha channel is specified + * - LC_Depth - Depth channel is specified + * - LC_Stencil - Stencil channel is specified + * - LC_1 - constant 1 will be returned + * - LC_0 - constant 0 will be return + * PhysicalChannel - values for physical channel or constants + * - PC_0 - Leftmost channel + * - PC_1 - 2nd channel + * - PC_2 - 3rd channel + * - PC_3 - 4th channel + * - PC_CONST_1 - constant 1 will be returned + * - PC_CONST_0 - constant 0 will be return + * + * Structs + * ------- + * TinyImageFormat_DecodeInput + * - pixel or pixelPlane0 - pixel data ptr or pixel data ptr for plane 0 + * - lut or pixelPlane1 - Look Up Table ptr for CLUT formats or pixel plane 1 + * - pixelPlane2 to pixelPlane 9 - 7 more planes ptrs + * TinyImageFormat_EncodeOutput + * - pixel or pixelPlane0 - pixel data ptr or pixel data ptr for plane 0 + * - pixelPlane2 to pixelPlane 9 - 8 more planes ptrs + + * Query Functions + * ----------- + * Code - uint64_t with the internal descriptor code + * Name - Human C string with the name of this fmt + * FromName - lookup the format given the name as a C String (fast) + * IsDepthOnly - true if just a depth channel + * IsStencilOnly - true if just a stencil channel + * IsDepthAndStencil - if has both depth and stencil channel + * IsCompressed - true if its a compressed format (aka block) + * IsCLUT - true if data is index into a CLUT (Colour Look Up Table) + * IsFloat - is the data in floating point + * IsNormalised - return true if data will be within 0 to 1 or -1 to 1 + * IsSigned - does the data include negatives + * IsSRGB - is the data encoded using sRGB non linear encoding + * IsHomogenous - is the encoding the same for every channel + * WidthOfBlock - How many pixels in the x dimension for a block + * HeightOfBlock - How many pixels in the y dimension for a block + * DepthOfBlock - How many pixels in the z dimension for a block + * PixelCountOfBlock - How many pixels in total for a block + * BitSizeOfBlock - How big in bits is a single block. + * ChannelCount - How many channels are actually encoded + * + * Logical Channel Functions + * ------------------------- + * ChannelBitWidth( logical channel ) - how wide in bits is the channel + * Min( logical channel ) - minimum possible value for the channel + * Max( logical channel ) - maximum possible value for the channel + * LogicalChannelToPhysical( logical channel ) + * - what physical channel is the logical channel stored in + * - or constant 0 or 1 if its not physically stored + * + * Pixel Decoder Functions (X = F or D version, use F if possible as its faster) + * ----------------------- + * CanDecodeLogicalPixelsX - Can DecodeLogicalPixelsX work with this format? + * DecodeLogicalPixelsX( width in blocks, FetchInput, out pixels) + * - pixels should be a pointer to 4 * PixelCounfOfBlack float/doubles + * - does full decode and remapping into logical channels include constants. + * - Returned result can be used directly as RGBA floating point data + * - Input pointers are updated are used, so can be passed back in for + * - next set of pixel decoding if desired. + * - For CLUT formats in.pixel should be the packed pixel data and in.lut is + * - the lookuptable in R8G8B8A8 format of 2^Pbits entries + * - For all others in.pixel should be the packed pixel data + * Pixel Decoder Helper Functions + * ----------------------- + * UFloat6AsUintToFloat - returns the value stored as a 6 bit UFloat + * UFloat7AsUintToFloat - returns the value stored as a 7 bit UFloat + * UFloat10AsUintToFloat - returns the value stored as a 10 bit UFloat + * UFloat11AsUintToFloat - returns the value stored as a 11 bit UFloat + * SharedE5B9G9R9UFloatToFloats - return the pixel stored in shared + * - shared 5 bit exponent, 9 bit mantissa for RGB + * HalfAsUintToFloat - returns the value stored as a 16 bit SFloat + * BFloatAsUintToFloat - returns the value stored as a 16 bit BFloat + * LookupSRGB - returns the value for an 8 bit sRGB encoded value + * + * Pixel Encoder Functions (X = F or D version, use F if possible as its faster) + * ----------------------- + * CanEncodeLogicalPixelsX - Can EncodeLogicalPixelsX work with this format? + * EncodeLogicalPixelsX( width in blocks, in pixels, PutOutput) + * - pixels should be a pointer to 4 * PixelCounfOfBlack float/doubles + * - does full encode and remapping into logical channels + * - Output pointers are updated are used, so can be passed back in for + * - next set of pixel encoding if desired. + * - out.pixel is where colour information should be stored + * + * Pixel Encoder Helper Functions + * ----------------------- + * FloatToUFloat6AsUint - Encodes float into a 6 bit UFloat + * FloatToUFloat7AsUint - Encodes float into a 7 bit UFloat + * FloatToUFloat10AsUint - Encodes float into a 10 bit UFloat + * FloatToUFloat11AsUint - Encodes float into 11 bit UFloat + * FloatRGBToRGB9E5AsUint32 - Encodes a float RGB into RGB9E5 + * FloatToHalfAsUint - Encodes a float into a 16 bit SFloat + * FloatToBFloatAsUint - Encodes a float into a 16 bit BFloat + * FloatToSRGB - encodes a float to sRGB assuming input is 0-1 + * + * Physical Channel Functions (in general use the Logical Channels) + * ------------------ + * ChannelBitWidthAtPhysical( phys channel ) - how wide in bits for this channel + * MinAtPhysical( phys channel ) - min possible value for this channel + * MaxAtPhysical( phys channel ) - max possible value for this channel + * PhysicalChannelToLogical(phys channel) + * - what logical channel does a physical channel map to. + * - Or a constant 0 or 1 + * + * Graphics API Functions + * ------------------ + * FromVkFormat( VkFormat ) - converts from or UNDEFINED if not possible + * ToVkFormat - converts to or VK_FORMAT_UNDEFINED if not possible + * FromDXGI_FORMAT( DXGI_FORMAT) converts from or UNDEFINED if not possible + * ToDXGI_FORMAT - converts to or DXGI_FORMAT_UNKNOWN if not possible + * DXGI_FORMATToTypeless - returns the DXGI typeless format if possible + * FromMetal( MTLPixelFormat ) - converts from or UNDEFINED if not possible + * ToMetal - converts to or MTLPixelFormatInvalid if not possible + * + * + */ +typedef enum TinyImageFormat { + TinyImageFormat_UNDEFINED = 0, + TinyImageFormat_R1_UNORM = 1, + TinyImageFormat_R2_UNORM = 2, + TinyImageFormat_R4_UNORM = 3, + TinyImageFormat_R4G4_UNORM = 4, + TinyImageFormat_G4R4_UNORM = 5, + TinyImageFormat_A8_UNORM = 6, + TinyImageFormat_R8_UNORM = 7, + TinyImageFormat_R8_SNORM = 8, + TinyImageFormat_R8_UINT = 9, + TinyImageFormat_R8_SINT = 10, + TinyImageFormat_R8_SRGB = 11, + TinyImageFormat_B2G3R3_UNORM = 12, + TinyImageFormat_R4G4B4A4_UNORM = 13, + TinyImageFormat_R4G4B4X4_UNORM = 14, + TinyImageFormat_B4G4R4A4_UNORM = 15, + TinyImageFormat_B4G4R4X4_UNORM = 16, + TinyImageFormat_A4R4G4B4_UNORM = 17, + TinyImageFormat_X4R4G4B4_UNORM = 18, + TinyImageFormat_A4B4G4R4_UNORM = 19, + TinyImageFormat_X4B4G4R4_UNORM = 20, + TinyImageFormat_R5G6B5_UNORM = 21, + TinyImageFormat_B5G6R5_UNORM = 22, + TinyImageFormat_R5G5B5A1_UNORM = 23, + TinyImageFormat_B5G5R5A1_UNORM = 24, + TinyImageFormat_A1B5G5R5_UNORM = 25, + TinyImageFormat_A1R5G5B5_UNORM = 26, + TinyImageFormat_R5G5B5X1_UNORM = 27, + TinyImageFormat_B5G5R5X1_UNORM = 28, + TinyImageFormat_X1R5G5B5_UNORM = 29, + TinyImageFormat_X1B5G5R5_UNORM = 30, + TinyImageFormat_B2G3R3A8_UNORM = 31, + TinyImageFormat_R8G8_UNORM = 32, + TinyImageFormat_R8G8_SNORM = 33, + TinyImageFormat_G8R8_UNORM = 34, + TinyImageFormat_G8R8_SNORM = 35, + TinyImageFormat_R8G8_UINT = 36, + TinyImageFormat_R8G8_SINT = 37, + TinyImageFormat_R8G8_SRGB = 38, + TinyImageFormat_R16_UNORM = 39, + TinyImageFormat_R16_SNORM = 40, + TinyImageFormat_R16_UINT = 41, + TinyImageFormat_R16_SINT = 42, + TinyImageFormat_R16_SFLOAT = 43, + TinyImageFormat_R16_SBFLOAT = 44, + TinyImageFormat_R8G8B8_UNORM = 45, + TinyImageFormat_R8G8B8_SNORM = 46, + TinyImageFormat_R8G8B8_UINT = 47, + TinyImageFormat_R8G8B8_SINT = 48, + TinyImageFormat_R8G8B8_SRGB = 49, + TinyImageFormat_B8G8R8_UNORM = 50, + TinyImageFormat_B8G8R8_SNORM = 51, + TinyImageFormat_B8G8R8_UINT = 52, + TinyImageFormat_B8G8R8_SINT = 53, + TinyImageFormat_B8G8R8_SRGB = 54, + TinyImageFormat_R8G8B8A8_UNORM = 55, + TinyImageFormat_R8G8B8A8_SNORM = 56, + TinyImageFormat_R8G8B8A8_UINT = 57, + TinyImageFormat_R8G8B8A8_SINT = 58, + TinyImageFormat_R8G8B8A8_SRGB = 59, + TinyImageFormat_B8G8R8A8_UNORM = 60, + TinyImageFormat_B8G8R8A8_SNORM = 61, + TinyImageFormat_B8G8R8A8_UINT = 62, + TinyImageFormat_B8G8R8A8_SINT = 63, + TinyImageFormat_B8G8R8A8_SRGB = 64, + TinyImageFormat_R8G8B8X8_UNORM = 65, + TinyImageFormat_B8G8R8X8_UNORM = 66, + TinyImageFormat_R16G16_UNORM = 67, + TinyImageFormat_G16R16_UNORM = 68, + TinyImageFormat_R16G16_SNORM = 69, + TinyImageFormat_G16R16_SNORM = 70, + TinyImageFormat_R16G16_UINT = 71, + TinyImageFormat_R16G16_SINT = 72, + TinyImageFormat_R16G16_SFLOAT = 73, + TinyImageFormat_R16G16_SBFLOAT = 74, + TinyImageFormat_R32_UINT = 75, + TinyImageFormat_R32_SINT = 76, + TinyImageFormat_R32_SFLOAT = 77, + TinyImageFormat_A2R10G10B10_UNORM = 78, + TinyImageFormat_A2R10G10B10_UINT = 79, + TinyImageFormat_A2R10G10B10_SNORM = 80, + TinyImageFormat_A2R10G10B10_SINT = 81, + TinyImageFormat_A2B10G10R10_UNORM = 82, + TinyImageFormat_A2B10G10R10_UINT = 83, + TinyImageFormat_A2B10G10R10_SNORM = 84, + TinyImageFormat_A2B10G10R10_SINT = 85, + TinyImageFormat_R10G10B10A2_UNORM = 86, + TinyImageFormat_R10G10B10A2_UINT = 87, + TinyImageFormat_R10G10B10A2_SNORM = 88, + TinyImageFormat_R10G10B10A2_SINT = 89, + TinyImageFormat_B10G10R10A2_UNORM = 90, + TinyImageFormat_B10G10R10A2_UINT = 91, + TinyImageFormat_B10G10R10A2_SNORM = 92, + TinyImageFormat_B10G10R10A2_SINT = 93, + TinyImageFormat_B10G11R11_UFLOAT = 94, + TinyImageFormat_E5B9G9R9_UFLOAT = 95, + TinyImageFormat_R16G16B16_UNORM = 96, + TinyImageFormat_R16G16B16_SNORM = 97, + TinyImageFormat_R16G16B16_UINT = 98, + TinyImageFormat_R16G16B16_SINT = 99, + TinyImageFormat_R16G16B16_SFLOAT = 100, + TinyImageFormat_R16G16B16_SBFLOAT = 101, + TinyImageFormat_R16G16B16A16_UNORM = 102, + TinyImageFormat_R16G16B16A16_SNORM = 103, + TinyImageFormat_R16G16B16A16_UINT = 104, + TinyImageFormat_R16G16B16A16_SINT = 105, + TinyImageFormat_R16G16B16A16_SFLOAT = 106, + TinyImageFormat_R16G16B16A16_SBFLOAT = 107, + TinyImageFormat_R32G32_UINT = 108, + TinyImageFormat_R32G32_SINT = 109, + TinyImageFormat_R32G32_SFLOAT = 110, + TinyImageFormat_R32G32B32_UINT = 111, + TinyImageFormat_R32G32B32_SINT = 112, + TinyImageFormat_R32G32B32_SFLOAT = 113, + TinyImageFormat_R32G32B32A32_UINT = 114, + TinyImageFormat_R32G32B32A32_SINT = 115, + TinyImageFormat_R32G32B32A32_SFLOAT = 116, + TinyImageFormat_R64_UINT = 117, + TinyImageFormat_R64_SINT = 118, + TinyImageFormat_R64_SFLOAT = 119, + TinyImageFormat_R64G64_UINT = 120, + TinyImageFormat_R64G64_SINT = 121, + TinyImageFormat_R64G64_SFLOAT = 122, + TinyImageFormat_R64G64B64_UINT = 123, + TinyImageFormat_R64G64B64_SINT = 124, + TinyImageFormat_R64G64B64_SFLOAT = 125, + TinyImageFormat_R64G64B64A64_UINT = 126, + TinyImageFormat_R64G64B64A64_SINT = 127, + TinyImageFormat_R64G64B64A64_SFLOAT = 128, + TinyImageFormat_D16_UNORM = 129, + TinyImageFormat_X8_D24_UNORM = 130, + TinyImageFormat_D32_SFLOAT = 131, + TinyImageFormat_S8_UINT = 132, + TinyImageFormat_D16_UNORM_S8_UINT = 133, + TinyImageFormat_D24_UNORM_S8_UINT = 134, + TinyImageFormat_D32_SFLOAT_S8_UINT = 135, + TinyImageFormat_DXBC1_RGB_UNORM = 136, + TinyImageFormat_DXBC1_RGB_SRGB = 137, + TinyImageFormat_DXBC1_RGBA_UNORM = 138, + TinyImageFormat_DXBC1_RGBA_SRGB = 139, + TinyImageFormat_DXBC2_UNORM = 140, + TinyImageFormat_DXBC2_SRGB = 141, + TinyImageFormat_DXBC3_UNORM = 142, + TinyImageFormat_DXBC3_SRGB = 143, + TinyImageFormat_DXBC4_UNORM = 144, + TinyImageFormat_DXBC4_SNORM = 145, + TinyImageFormat_DXBC5_UNORM = 146, + TinyImageFormat_DXBC5_SNORM = 147, + TinyImageFormat_DXBC6H_UFLOAT = 148, + TinyImageFormat_DXBC6H_SFLOAT = 149, + TinyImageFormat_DXBC7_UNORM = 150, + TinyImageFormat_DXBC7_SRGB = 151, + TinyImageFormat_PVRTC1_2BPP_UNORM = 152, + TinyImageFormat_PVRTC1_4BPP_UNORM = 153, + TinyImageFormat_PVRTC2_2BPP_UNORM = 154, + TinyImageFormat_PVRTC2_4BPP_UNORM = 155, + TinyImageFormat_PVRTC1_2BPP_SRGB = 156, + TinyImageFormat_PVRTC1_4BPP_SRGB = 157, + TinyImageFormat_PVRTC2_2BPP_SRGB = 158, + TinyImageFormat_PVRTC2_4BPP_SRGB = 159, + TinyImageFormat_ETC2_R8G8B8_UNORM = 160, + TinyImageFormat_ETC2_R8G8B8_SRGB = 161, + TinyImageFormat_ETC2_R8G8B8A1_UNORM = 162, + TinyImageFormat_ETC2_R8G8B8A1_SRGB = 163, + TinyImageFormat_ETC2_R8G8B8A8_UNORM = 164, + TinyImageFormat_ETC2_R8G8B8A8_SRGB = 165, + TinyImageFormat_ETC2_EAC_R11_UNORM = 166, + TinyImageFormat_ETC2_EAC_R11_SNORM = 167, + TinyImageFormat_ETC2_EAC_R11G11_UNORM = 168, + TinyImageFormat_ETC2_EAC_R11G11_SNORM = 169, + TinyImageFormat_ASTC_4x4_UNORM = 170, + TinyImageFormat_ASTC_4x4_SRGB = 171, + TinyImageFormat_ASTC_5x4_UNORM = 172, + TinyImageFormat_ASTC_5x4_SRGB = 173, + TinyImageFormat_ASTC_5x5_UNORM = 174, + TinyImageFormat_ASTC_5x5_SRGB = 175, + TinyImageFormat_ASTC_6x5_UNORM = 176, + TinyImageFormat_ASTC_6x5_SRGB = 177, + TinyImageFormat_ASTC_6x6_UNORM = 178, + TinyImageFormat_ASTC_6x6_SRGB = 179, + TinyImageFormat_ASTC_8x5_UNORM = 180, + TinyImageFormat_ASTC_8x5_SRGB = 181, + TinyImageFormat_ASTC_8x6_UNORM = 182, + TinyImageFormat_ASTC_8x6_SRGB = 183, + TinyImageFormat_ASTC_8x8_UNORM = 184, + TinyImageFormat_ASTC_8x8_SRGB = 185, + TinyImageFormat_ASTC_10x5_UNORM = 186, + TinyImageFormat_ASTC_10x5_SRGB = 187, + TinyImageFormat_ASTC_10x6_UNORM = 188, + TinyImageFormat_ASTC_10x6_SRGB = 189, + TinyImageFormat_ASTC_10x8_UNORM = 190, + TinyImageFormat_ASTC_10x8_SRGB = 191, + TinyImageFormat_ASTC_10x10_UNORM = 192, + TinyImageFormat_ASTC_10x10_SRGB = 193, + TinyImageFormat_ASTC_12x10_UNORM = 194, + TinyImageFormat_ASTC_12x10_SRGB = 195, + TinyImageFormat_ASTC_12x12_UNORM = 196, + TinyImageFormat_ASTC_12x12_SRGB = 197, + TinyImageFormat_CLUT_P4 = 198, + TinyImageFormat_CLUT_P4A4 = 199, + TinyImageFormat_CLUT_P8 = 200, + TinyImageFormat_CLUT_P8A8 = 201, + TinyImageFormat_R4G4B4A4_UNORM_PACK16 = 202, + TinyImageFormat_B4G4R4A4_UNORM_PACK16 = 203, + TinyImageFormat_R5G6B5_UNORM_PACK16 = 204, + TinyImageFormat_B5G6R5_UNORM_PACK16 = 205, + TinyImageFormat_R5G5B5A1_UNORM_PACK16 = 206, + TinyImageFormat_B5G5R5A1_UNORM_PACK16 = 207, + TinyImageFormat_A1R5G5B5_UNORM_PACK16 = 208, + TinyImageFormat_G16B16G16R16_422_UNORM = 209, + TinyImageFormat_B16G16R16G16_422_UNORM = 210, + TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 211, + TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 212, + TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 213, + TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 214, + TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 215, + TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 216, + TinyImageFormat_G8B8G8R8_422_UNORM = 217, + TinyImageFormat_B8G8R8G8_422_UNORM = 218, + TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM = 219, + TinyImageFormat_G8_B8R8_2PLANE_420_UNORM = 220, + TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM = 221, + TinyImageFormat_G8_B8R8_2PLANE_422_UNORM = 222, + TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM = 223, + TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 224, + TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 225, + TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 226, + TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 227, + TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 228, + TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 229, + TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 230, + TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 231, + TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 232, + TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 233, + TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM = 234, + TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM = 235, + TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM = 236, + TinyImageFormat_G16_B16R16_2PLANE_420_UNORM = 237, + TinyImageFormat_G16_B16R16_2PLANE_422_UNORM = 238, +} TinyImageFormat; + +typedef enum TinyImageFormat_LogicalChannel { + TinyImageFormat_LC_Red = 0, + TinyImageFormat_LC_Green = 1, + TinyImageFormat_LC_Blue = 2, + TinyImageFormat_LC_Alpha = 3, + TinyImageFormat_LC_Depth = 0, + TinyImageFormat_LC_Stencil = 1, + TinyImageFormat_LC_0 = -1, + TinyImageFormat_LC_1 = -2, +} TinyImageFormat_LogicalChannel; + +typedef enum TinyImageFormat_PhysicalChannel { + TinyImageFormat_PC_0 = 0, + TinyImageFormat_PC_1 = 1, + TinyImageFormat_PC_2 = 2, + TinyImageFormat_PC_3 = 3, + TinyImageFormat_PC_CONST_0 = -1, + TinyImageFormat_PC_CONST_1 = -2, +} TinyImageFormat_PhysicalChannel; + +#define TinyImageFormat_Count 239U + +typedef struct TinyImageFormat_DecodeInput { + union { void const* pixel; void const* pixelPlane0; }; + union { void const* lut; void const* pixelPlane1; }; + void const* pixelPlane2; + void const* pixelPlane3; + void const* pixelPlane4; + void const* pixelPlane5; + void const* pixelPlane6; + void const* pixelPlane7; + void const* pixelPlane8; + void const* pixelPlane9; +} TinyImageFormat_FetchInput; + +typedef struct TinyImageFormat_EncodeOutput { + union { void const* pixel; void const* pixelPlane0; }; + void const* pixelPlane1; + void const* pixelPlane2; + void const* pixelPlane3; + void const* pixelPlane4; + void const* pixelPlane5; + void const* pixelPlane6; + void const* pixelPlane7; + void const* pixelPlane8; + void const* pixelPlane9; +} TinyImageFormat_PutOutput; + +#endif // TINYIMAGEFORMAT_BASE_H_ + diff --git a/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_bits.h b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_bits.h new file mode 100644 index 0000000..853871d --- /dev/null +++ b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_bits.h @@ -0,0 +1,281 @@ +#pragma once + +typedef enum TinyImageFormat_Namespace { + TinyImageFormat_NAMESPACE_PACK = 0ULL, + TinyImageFormat_NAMESPACE_DEPTH_STENCIL = 1ULL, + TinyImageFormat_NAMESPACE_DXTC = 2ULL, + TinyImageFormat_NAMESPACE_PVRTC = 3ULL, + TinyImageFormat_NAMESPACE_ETC = 4ULL, + TinyImageFormat_NAMESPACE_ASTC = 5ULL, + TinyImageFormat_NAMESPACE_CLUT = 6ULL, +} TinyImageFormat_Namespace; + +typedef enum TinyImageFormat_Pack_Special { + TinyImageFormat_PACK_SPECIAL_NONE = 0ULL, + TinyImageFormat_PACK_SPECIAL_PACK = 1ULL, + TinyImageFormat_PACK_SPECIAL_MULTI2 = 2ULL, + TinyImageFormat_PACK_SPECIAL_MULTI4 = 3ULL, + TinyImageFormat_PACK_SPECIAL_MULTI8 = 4ULL, +} TinyImageFormat_Pack_Special; + +typedef enum TinyImageFormat_Pack_Bits { + TinyImageFormat_PACK_BITS_0 = 0ULL, + TinyImageFormat_PACK_BITS_1 = 1ULL, + TinyImageFormat_PACK_BITS_2 = 2ULL, + TinyImageFormat_PACK_BITS_3 = 3ULL, + TinyImageFormat_PACK_BITS_4 = 4ULL, + TinyImageFormat_PACK_BITS_5 = 5ULL, + TinyImageFormat_PACK_BITS_6 = 6ULL, + TinyImageFormat_PACK_BITS_7 = 7ULL, + TinyImageFormat_PACK_BITS_8 = 8ULL, + TinyImageFormat_PACK_BITS_9 = 9ULL, + TinyImageFormat_PACK_BITS_10 = 10ULL, + TinyImageFormat_PACK_BITS_11 = 11ULL, + TinyImageFormat_PACK_BITS_12 = 12ULL, + TinyImageFormat_PACK_BITS_16 = 13ULL, + TinyImageFormat_PACK_BITS_24 = 14ULL, + TinyImageFormat_PACK_BITS_32 = 15ULL, + TinyImageFormat_PACK_BITS_64 = 16ULL, +} TinyImageFormat_Pack_Bits; + +typedef enum TinyImageFormat_Pack_Swizzle { + TinyImageFormat_PACK_SWIZZLE_R = 0ULL, + TinyImageFormat_PACK_SWIZZLE_G = 1ULL, + TinyImageFormat_PACK_SWIZZLE_B = 2ULL, + TinyImageFormat_PACK_SWIZZLE_A = 3ULL, + TinyImageFormat_PACK_SWIZZLE_0 = 4ULL, + TinyImageFormat_PACK_SWIZZLE_1 = 5ULL, +} TinyImageFormat_Pack_Swizzle; + +typedef enum TinyImageFormat_Pack_Type { + TinyImageFormat_PACK_TYPE_NONE = 0ULL, + TinyImageFormat_PACK_TYPE_UNORM = 1ULL, + TinyImageFormat_PACK_TYPE_SNORM = 2ULL, + TinyImageFormat_PACK_TYPE_UINT = 3ULL, + TinyImageFormat_PACK_TYPE_SINT = 4ULL, + TinyImageFormat_PACK_TYPE_UFLOAT = 5ULL, + TinyImageFormat_PACK_TYPE_SFLOAT = 6ULL, + TinyImageFormat_PACK_TYPE_SRGB = 7ULL, + TinyImageFormat_PACK_TYPE_SBFLOAT = 8ULL, +} TinyImageFormat_Pack_Type; + +typedef enum TinyImageFormat_DepthStencil_Total_Size { + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_8 = 0ULL, + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_16 = 1ULL, + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_32 = 2ULL, + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_64 = 3ULL, +} TinyImageFormat_DepthStencil_Total_Size; + +typedef enum TinyImageFormat_DepthStencil_Bits { + TinyImageFormat_DEPTH_STENCIL_BITS_0 = 0ULL, + TinyImageFormat_DEPTH_STENCIL_BITS_8 = 1ULL, + TinyImageFormat_DEPTH_STENCIL_BITS_16 = 2ULL, + TinyImageFormat_DEPTH_STENCIL_BITS_24 = 3ULL, + TinyImageFormat_DEPTH_STENCIL_BITS_32 = 4ULL, +} TinyImageFormat_DepthStencil_Bits; + +typedef enum TinyImageFormat_DepthStencil_Swizzle { + TinyImageFormat_DEPTH_STENCIL_SWIZZLE_D = 0ULL, + TinyImageFormat_DEPTH_STENCIL_SWIZZLE_S = 1ULL, + TinyImageFormat_DEPTH_STENCIL_SWIZZLE_0 = 2ULL, +} TinyImageFormat_DepthStencil_Swizzle; + +typedef enum TinyImageFormat_DepthStencil_Type { + TinyImageFormat_DEPTH_STENCIL_TYPE_NONE = 0ULL, + TinyImageFormat_DEPTH_STENCIL_TYPE_UNORM = 1ULL, + TinyImageFormat_DEPTH_STENCIL_TYPE_UINT = 2ULL, + TinyImageFormat_DEPTH_STENCIL_TYPE_SFLOAT = 3ULL, +} TinyImageFormat_DepthStencil_Type; + +typedef enum TinyImageFormat_DXTC_Alpha { + TinyImageFormat_DXTC_ALPHA_NONE = 0ULL, + TinyImageFormat_DXTC_ALPHA_PUNCHTHROUGH = 1ULL, + TinyImageFormat_DXTC_ALPHA_BLOCK = 2ULL, + TinyImageFormat_DXTC_ALPHA_FULL = 3ULL, +} TinyImageFormat_DXTC_Alpha; + +typedef enum TinyImageFormat_DXTC_Type { + TinyImageFormat_DXTC_TYPE_UNORM = 0ULL, + TinyImageFormat_DXTC_TYPE_SNORM = 1ULL, + TinyImageFormat_DXTC_TYPE_SRGB = 2ULL, + TinyImageFormat_DXTC_TYPE_SFLOAT = 3ULL, + TinyImageFormat_DXTC_TYPE_UFLOAT = 4ULL, +} TinyImageFormat_DXTC_Type; + +typedef enum TinyImageFormat_DXTC_BlockBytes { + TinyImageFormat_DXTC_BLOCKBYTES_8 = 0ULL, + TinyImageFormat_DXTC_BLOCKBYTES_16 = 1ULL, +} TinyImageFormat_DXTC_BlockBytes; + +typedef enum TinyImageFormat_DXTC_ChannelCount { + TinyImageFormat_DXTC_CHANNELCOUNT_1 = 0ULL, + TinyImageFormat_DXTC_CHANNELCOUNT_2 = 1ULL, + TinyImageFormat_DXTC_CHANNELCOUNT_3 = 2ULL, + TinyImageFormat_DXTC_CHANNELCOUNT_4 = 3ULL, +} TinyImageFormat_DXTC_ChannelCount; + +typedef enum TinyImageFormat_DXTC_ModeCount { + TinyImageFormat_DXTC_MODECOUNT_1 = 0ULL, + TinyImageFormat_DXTC_MODECOUNT_8 = 1ULL, + TinyImageFormat_DXTC_MODECOUNT_14 = 2ULL, +} TinyImageFormat_DXTC_ModeCount; + +typedef enum TinyImageFormat_PVRTC_Version { + TinyImageFormat_PVRTC_VERSION_V1 = 0ULL, + TinyImageFormat_PVRTC_VERSION_V2 = 1ULL, +} TinyImageFormat_PVRTC_Version; + +typedef enum TinyImageFormat_PVRTC_Bits { + TinyImageFormat_PVRTC_BITS_2 = 0ULL, + TinyImageFormat_PVRTC_BITS_4 = 1ULL, +} TinyImageFormat_PVRTC_Bits; + +typedef enum TinyImageFormat_PVRTC_Type { + TinyImageFormat_PVRTC_TYPE_UNORM = 0ULL, + TinyImageFormat_PVRTC_TYPE_SRGB = 1ULL, +} TinyImageFormat_PVRTC_Type; + +typedef enum TinyImageFormat_ETC_Bits { + TinyImageFormat_ETC_BITS_8 = 0ULL, + TinyImageFormat_ETC_BITS_11 = 1ULL, +} TinyImageFormat_ETC_Bits; + +typedef enum TinyImageFormat_ETC_Alpha { + TinyImageFormat_ETC_ALPHA_NONE = 0ULL, + TinyImageFormat_ETC_ALPHA_PUNCHTHROUGH = 1ULL, + TinyImageFormat_ETC_ALPHA_BLOCK = 2ULL, +} TinyImageFormat_ETC_Alpha; + +typedef enum TinyImageFormat_ETC_Type { + TinyImageFormat_ETC_TYPE_UNORM = 0ULL, + TinyImageFormat_ETC_TYPE_SNORM = 1ULL, + TinyImageFormat_ETC_TYPE_SRGB = 2ULL, +} TinyImageFormat_ETC_Type; + +typedef enum TinyImageFormat_ETC_ChannelCount { + TinyImageFormat_ETC_CHANNELCOUNT_1 = 0ULL, + TinyImageFormat_ETC_CHANNELCOUNT_2 = 1ULL, + TinyImageFormat_ETC_CHANNELCOUNT_3 = 2ULL, + TinyImageFormat_ETC_CHANNELCOUNT_4 = 3ULL, +} TinyImageFormat_ETC_ChannelCount; + +typedef enum TinyImageFormat_ASTC_Size { + TinyImageFormat_ASTC_SIZE_1 = 0ULL, + TinyImageFormat_ASTC_SIZE_4 = 2ULL, + TinyImageFormat_ASTC_SIZE_5 = 3ULL, + TinyImageFormat_ASTC_SIZE_6 = 4ULL, + TinyImageFormat_ASTC_SIZE_8 = 5ULL, + TinyImageFormat_ASTC_SIZE_10 = 6ULL, + TinyImageFormat_ASTC_SIZE_12 = 7ULL, +} TinyImageFormat_ASTC_Size; + +typedef enum TinyImageFormat_ASTC_Type { + TinyImageFormat_ASTC_TYPE_UNORM = 0ULL, + TinyImageFormat_ASTC_TYPE_SRGB = 1ULL, +} TinyImageFormat_ASTC_Type; + +typedef enum TinyImageFormat_CLUT_BlockSize { + TinyImageFormat_CLUT_BLOCKSIZE_1 = 0ULL, + TinyImageFormat_CLUT_BLOCKSIZE_2 = 1ULL, + TinyImageFormat_CLUT_BLOCKSIZE_4 = 2ULL, + TinyImageFormat_CLUT_BLOCKSIZE_8 = 3ULL, +} TinyImageFormat_CLUT_BlockSize; + +typedef enum TinyImageFormat_CLUT_Bits { + TinyImageFormat_CLUT_BITS_0 = 0ULL, + TinyImageFormat_CLUT_BITS_1 = 1ULL, + TinyImageFormat_CLUT_BITS_2 = 2ULL, + TinyImageFormat_CLUT_BITS_4 = 3ULL, + TinyImageFormat_CLUT_BITS_8 = 4ULL, +} TinyImageFormat_CLUT_Bits; + +typedef enum TinyImageFormat_CLUT_Type { + TinyImageFormat_CLUT_TYPE_NONE = 0ULL, + TinyImageFormat_CLUT_TYPE_RGB = 1ULL, + TinyImageFormat_CLUT_TYPE_SINGLE = 2ULL, + TinyImageFormat_CLUT_TYPE_EXPLICIT_ALPHA = 3ULL, +} TinyImageFormat_CLUT_Type; + +typedef enum TinyImageFormat_Bits { + TinyImageFormat_NAMESPACE_REQUIRED_BITS = 12ULL, + TinyImageFormat_NAMESPACE_MASK = (1 << TinyImageFormat_NAMESPACE_REQUIRED_BITS) - 1, + + TinyImageFormat_PACK_SPECIAL_REQUIRED_BITS = 3ULL, + TinyImageFormat_PACK_BITS_REQUIRED_BITS = 5ULL, + TinyImageFormat_PACK_SWIZZLE_REQUIRED_BITS = 3ULL, + + TinyImageFormat_PACK_TYPE_REQUIRED_BITS = 4ULL, + TinyImageFormat_PACK_NUM_CHANNELS = 4ULL, + + TinyImageFormat_PACK_SPECIAL_SHIFT = (TinyImageFormat_NAMESPACE_REQUIRED_BITS), + TinyImageFormat_PACK_BITS_SHIFT = (TinyImageFormat_PACK_SPECIAL_REQUIRED_BITS + TinyImageFormat_PACK_SPECIAL_SHIFT), + TinyImageFormat_PACK_SWIZZLE_SHIFT = + ((TinyImageFormat_PACK_BITS_REQUIRED_BITS * TinyImageFormat_PACK_NUM_CHANNELS) + TinyImageFormat_PACK_BITS_SHIFT), + TinyImageFormat_PACK_TYPE_SHIFT = ((TinyImageFormat_PACK_SWIZZLE_REQUIRED_BITS * TinyImageFormat_PACK_NUM_CHANNELS) + + TinyImageFormat_PACK_SWIZZLE_SHIFT), + + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_REQUIRED_BITS = 2ULL, + TinyImageFormat_DEPTH_STENCIL_BITS_REQUIRED_BITS = 3ULL, + TinyImageFormat_DEPTH_STENCIL_SWIZZLE_REQUIRED_BITS = 2ULL, + TinyImageFormat_DEPTH_STENCIL_TYPE_REQUIRED_BITS = 2ULL, + TinyImageFormat_DEPTH_STENCIL_NUM_CHANNELS = 2ULL, + + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_SHIFT = (TinyImageFormat_NAMESPACE_REQUIRED_BITS), + TinyImageFormat_DEPTH_STENCIL_BITS_SHIFT = + ((TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_REQUIRED_BITS) + TinyImageFormat_DEPTH_STENCIL_TOTAL_SIZE_SHIFT), + TinyImageFormat_DEPTH_STENCIL_SWIZZLE_SHIFT = + ((TinyImageFormat_DEPTH_STENCIL_BITS_REQUIRED_BITS * TinyImageFormat_DEPTH_STENCIL_NUM_CHANNELS) + + TinyImageFormat_DEPTH_STENCIL_BITS_SHIFT), + TinyImageFormat_DEPTH_STENCIL_TYPE_SHIFT = + ((TinyImageFormat_DEPTH_STENCIL_SWIZZLE_REQUIRED_BITS * TinyImageFormat_DEPTH_STENCIL_NUM_CHANNELS) + + TinyImageFormat_DEPTH_STENCIL_SWIZZLE_SHIFT), + + TinyImageFormat_DXTC_ALPHA_REQUIRED_BITS = 2ULL, + TinyImageFormat_DXTC_TYPE_REQUIRED_BITS = 3ULL, + TinyImageFormat_DXTC_BLOCKBYTES_REQUIRED_BITS = 2ULL, + TinyImageFormat_DXTC_CHANNELCOUNT_REQUIRED_BITS = 2ULL, + TinyImageFormat_DXTC_MODECOUNT_REQUIRED_BITS = 3ULL, + + TinyImageFormat_DXTC_ALPHA_SHIFT = (TinyImageFormat_NAMESPACE_REQUIRED_BITS), + TinyImageFormat_DXTC_TYPE_SHIFT = (TinyImageFormat_DXTC_ALPHA_REQUIRED_BITS + TinyImageFormat_DXTC_ALPHA_SHIFT), + TinyImageFormat_DXTC_BLOCKBYTES_SHIFT = (TinyImageFormat_DXTC_TYPE_REQUIRED_BITS + TinyImageFormat_DXTC_TYPE_SHIFT), + TinyImageFormat_DXTC_CHANNELCOUNT_SHIFT = + (TinyImageFormat_DXTC_BLOCKBYTES_REQUIRED_BITS + TinyImageFormat_DXTC_BLOCKBYTES_SHIFT), + TinyImageFormat_DXTC_MODECOUNT_SHIFT = + (TinyImageFormat_DXTC_CHANNELCOUNT_REQUIRED_BITS + TinyImageFormat_DXTC_CHANNELCOUNT_SHIFT), + + TinyImageFormat_PVRTC_VERSION_REQUIRED_BITS = 2ULL, + TinyImageFormat_PVRTC_BITS_REQUIRED_BITS = 2ULL, + TinyImageFormat_PVRTC_TYPE_REQUIRED_BITS = 2ULL, + TinyImageFormat_PVRTC_VERSION_SHIFT = (TinyImageFormat_NAMESPACE_REQUIRED_BITS), + TinyImageFormat_PVRTC_BITS_SHIFT = + (TinyImageFormat_PVRTC_VERSION_REQUIRED_BITS + TinyImageFormat_PVRTC_VERSION_SHIFT), + TinyImageFormat_PVRTC_TYPE_SHIFT = (TinyImageFormat_PVRTC_BITS_REQUIRED_BITS + TinyImageFormat_PVRTC_BITS_SHIFT), + + TinyImageFormat_ETC_BITS_REQUIRED_BITS = 2ULL, + TinyImageFormat_ETC_ALPHA_REQUIRED_BITS = 2ULL, + TinyImageFormat_ETC_TYPE_REQUIRED_BITS = 2ULL, + TinyImageFormat_ETC_CHANNELCOUNT_REQUIRED_BITS = 2ULL, + TinyImageFormat_ETC_BITS_SHIFT = (TinyImageFormat_NAMESPACE_REQUIRED_BITS), + TinyImageFormat_ETC_ALPHA_SHIFT = (TinyImageFormat_ETC_BITS_REQUIRED_BITS + TinyImageFormat_ETC_BITS_SHIFT), + TinyImageFormat_ETC_TYPE_SHIFT = (TinyImageFormat_ETC_ALPHA_REQUIRED_BITS + TinyImageFormat_ETC_ALPHA_SHIFT), + TinyImageFormat_ETC_CHANNELCOUNT_SHIFT = (TinyImageFormat_ETC_TYPE_REQUIRED_BITS + TinyImageFormat_ETC_TYPE_SHIFT), + + TinyImageFormat_ASTC_SIZE_REQUIRED_BITS = 3, + TinyImageFormat_ASTC_TYPE_REQUIRED_BITS = 2ULL, + TinyImageFormat_ASTC_NUM_DIMS = 3, + TinyImageFormat_ASTC_SIZE_SHIFT = (TinyImageFormat_NAMESPACE_REQUIRED_BITS), + TinyImageFormat_ASTC_TYPE_SHIFT = + ((TinyImageFormat_ASTC_SIZE_REQUIRED_BITS * TinyImageFormat_ASTC_NUM_DIMS) + TinyImageFormat_ASTC_SIZE_SHIFT), + + TinyImageFormat_CLUT_BLOCKSIZE_REQUIRED_BITS = 2, + TinyImageFormat_CLUT_BITS_REQUIRED_BITS = 3, + TinyImageFormat_CLUT_TYPE_REQUIRED_BITS = 2, + TinyImageFormat_CLUT_NUM_CHANNELS = 2, + + TinyImageFormat_CLUT_BLOCKSIZE_SHIFT = TinyImageFormat_NAMESPACE_REQUIRED_BITS, + TinyImageFormat_CLUT_BITS_SHIFT = TinyImageFormat_CLUT_BLOCKSIZE_REQUIRED_BITS + TinyImageFormat_CLUT_BLOCKSIZE_SHIFT, + TinyImageFormat_CLUT_TYPE_SHIFT = + ((TinyImageFormat_CLUT_BITS_REQUIRED_BITS * TinyImageFormat_CLUT_NUM_CHANNELS) + TinyImageFormat_CLUT_BITS_SHIFT), + +} TinyImageFormat_Bits; diff --git a/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_decode.h b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_decode.h new file mode 100644 index 0000000..3602d90 --- /dev/null +++ b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_decode.h @@ -0,0 +1,2139 @@ +// Auto generated by formatgen on Sep 21 2019 +#pragma once +#if !defined(TINYIMAGEFORMAT_DECODE_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) +#define TINYIMAGEFORMAT_DECODE_H_ 1 + +#include "tinyimageformat_base.h" + +#if __cplusplus > 201402L +#define TIF_CONSTEXPR constexpr +#else +#define TIF_CONSTEXPR +#endif +#ifndef TinyImageFormat_HAVE_UINTXX_T +#include // for uint32_t and int64_t +#endif +#ifndef TinyImageFormat_HAVE_BOOL +#include // for bool +#endif +#ifndef TinyImageFormat_HAVE_POWF +#include // for powf +#endif +//TinyImageFormat_ASSERT needs to be constexpr on some platforms +#ifndef TinyImageFormat_ASSERT +#define TinyImageFormat_ASSERT(x) +#endif + + + + +inline void TinyImageFormat_SharedE5B9G9R9UFloatToFloats(uint32_t v, float out[4]) { + // https://github.com/microsoft/DirectXMath/blob/ecfb4754400dac581c2eeb6e849617cf5d210426/Inc/DirectXPackedVector.h + union + { + struct + { + uint32_t rm : 9; + uint32_t gm : 9; + uint32_t bm : 9; + uint32_t e : 5; + }; + uint32_t v; + } ei; + + union { + uint32_t u; + float f; + } t; + + ei.v = v; + t.u = 0x33800000 + (ei.e << 23); + + out[0] = t.f * (float)(ei.rm); + out[1] = t.f * (float)(ei.gm); + out[2] = t.f * (float)(ei.bm); + out[3] = 1.0f; +} + +//HalfToFloat from Rygorous public domain code +inline float TinyImageFormat_HalfAsUintToFloat(uint16_t h_) { + + const uint32_t shifted_exp = 0x7c00 << 13; // exponent mask after shift + union { + uint16_t u; + struct { + uint32_t Mantissa : 10; + uint32_t Exponent : 5; + uint32_t Sign : 1; + }; + } h; + + union { + uint32_t u; + float f; + struct { + uint32_t Mantissa : 23; + uint32_t Exponent : 8; + uint32_t Sign : 1; + }; + } o; + + h.u = h_; + + o.u = (h.u & 0x7fff) << 13; // exponent/mantissa bits + uint32_t exp = shifted_exp & o.u; // just the exponent + o.u += (127 - 15) << 23; // exponent adjust + + // handle exponent special cases + if (exp == shifted_exp) { // Inf/NaN? + o.u += (128 - 16) << 23; // extra exp adjust + } else if (exp == 0) // Zero/Denormal? + { + union { + uint32_t u; + float f; + } magic; + magic.u = 113 << 23; + + o.u += 1 << 23; // extra exp adjust + o.f -= magic.f; // renormalize + } + + o.u |= (h.u & 0x8000) << 16; // sign bit + return o.f; +} + +inline float TinyImageFormat_BFloatAsUintToFloat(uint16_t h_) { + union { + struct { + uint16_t x; + uint16_t u; + }; + float f; + } o; + + o.u = h_; + o.x = 0; + + return o.f; +} + +inline float TinyImageFormat_UFloat6AsUintToFloat(uint16_t Value) +{ + // https://github.com/microsoft/DirectXMath/blob/ecfb4754400dac581c2eeb6e849617cf5d210426/Inc/DirectXPackedVector.h + + union { + uint32_t u; + float f; + struct { + uint32_t Mantissa : 23; + uint32_t Exponent : 8; + uint32_t Sign : 1; + }; + } o; + + o.Mantissa = Value & 0x3F; + o.Exponent = Value & 0x3C0; + o.Sign = 0; + + if (o.Exponent != 0) // The value is normalized + { + o.Exponent = (uint32_t)((Value >> 6) & 0xF); + } + else if (o.Mantissa != 0) // The value is denormalized + { + // Normalize the value in the resulting float + o.Exponent = 1; + do + { + o.Exponent--; + o.Mantissa <<= 1; + } while ((o.Mantissa & 0x40) == 0); + o.Mantissa &= 0x3F; + } + else + { + // The value is zero + o.u = 0; + } + + return o.f; +} + +inline float TinyImageFormat_UFloat7AsUintToFloat(uint16_t Value) +{ + // https://github.com/microsoft/DirectXMath/blob/ecfb4754400dac581c2eeb6e849617cf5d210426/Inc/DirectXPackedVector.h + + union { + uint32_t u; + float f; + struct { + uint32_t Mantissa : 23; + uint32_t Exponent : 8; + uint32_t Sign : 1; + }; + } o; + + o.Mantissa = Value & 0x7F; + o.Exponent = Value & 0x380; + o.Sign = 0; + + if (o.Exponent != 0) // The value is normalized + { + o.Exponent = (uint32_t)((Value >> 7) & 0x7); + } + else if (o.Mantissa != 0) // The value is denormalized + { + // Normalize the value in the resulting float + o.Exponent = 1; + do + { + o.Exponent--; + o.Mantissa <<= 1; + } while ((o.Mantissa & 0x80) == 0); + o.Mantissa &= 0x7F; + } + else + { + // The value is zero + o.u = 0; + } + + return o.f; +} + +inline float TinyImageFormat_UFloat10AsUintToFloat(uint16_t v) { + // https://github.com/microsoft/DirectXMath/blob/ecfb4754400dac581c2eeb6e849617cf5d210426/Inc/DirectXPackedVector.h + union { + struct { + uint16_t e : 5; + uint16_t m : 5; + uint16_t x : 6; // not used + }; + uint16_t v; + } ei; + + union { + uint32_t u; + float f; + } t; + + ei.v = v; + + if (ei.e == 31) { + if (ei.m == 0) { + t.u = 0xFF100000; // + infinity + } else { + t.u = 0xFF100002; // float qNAN with payload = 1 + } + } else if (ei.e == 0) { + if(ei.m == 0) { + t.f = 0.0f; + } else { + // Normalized float + uint32_t exp = 1; + uint32_t man = ei.m; + do + { + exp--; + man <<= 1; + } while ((man & 0x20) == 0); + man &= 0x1F; + t.u = ((exp + 112) << 23) | (man << 18); + } + } else { + t.u = ((ei.e + 112) << 23) | (ei.m << 18); + } + return t.f; +} + +inline float TinyImageFormat_UFloat11AsUintToFloat(uint16_t v) { + // https://github.com/microsoft/DirectXMath/blob/ecfb4754400dac581c2eeb6e849617cf5d210426/Inc/DirectXPackedVector.h + union { + struct { + uint16_t e : 5; + uint16_t m : 6; + uint16_t x : 5; // not used + }; + uint16_t v; + } ei; + + union { + uint32_t u; + float f; + } t; + + ei.v = v; + + if (ei.e == 31) { + if (ei.m == 0) { + t.u = 0xFF100000; // + infinity + } else { + t.u = 0xFF100002; // float qNAN with payload = 1 + } + } else if (ei.e == 0) { + if(ei.m == 0) { + t.f = 0.0f; + } else { + // Normalized float + uint32_t exp = 1; + uint32_t man = ei.m; + do + { + exp--; + man <<= 1; + } while ((man & 0x40) == 0); + man &= 0x3F; + t.u = ((exp + 112) << 23) | (man << 17); + } + } else { + t.u = ((ei.e + 112) << 23) | (ei.m << 17); + } + return t.f; +} + +TIF_CONSTEXPR inline float TinyImageFormat_LookupSRGB(uint8_t lookup) { + switch(lookup) { + case 0: return 0.00000000f; + case 1: return 0.00030353f; + case 2: return 0.00060705f; + case 3: return 0.00091058f; + case 4: return 0.00121411f; + case 5: return 0.00151763f; + case 6: return 0.00182116f; + case 7: return 0.00212469f; + case 8: return 0.00242822f; + case 9: return 0.00273174f; + case 10: return 0.00303527f; + case 11: return 0.00334654f; + case 12: return 0.00367651f; + case 13: return 0.00402472f; + case 14: return 0.00439144f; + case 15: return 0.00477695f; + case 16: return 0.00518152f; + case 17: return 0.00560539f; + case 18: return 0.00604883f; + case 19: return 0.00651209f; + case 20: return 0.00699541f; + case 21: return 0.00749903f; + case 22: return 0.00802319f; + case 23: return 0.00856812f; + case 24: return 0.00913406f; + case 25: return 0.00972122f; + case 26: return 0.01032982f; + case 27: return 0.01096009f; + case 28: return 0.01161224f; + case 29: return 0.01228649f; + case 30: return 0.01298303f; + case 31: return 0.01370208f; + case 32: return 0.01444384f; + case 33: return 0.01520851f; + case 34: return 0.01599629f; + case 35: return 0.01680738f; + case 36: return 0.01764195f; + case 37: return 0.01850022f; + case 38: return 0.01938236f; + case 39: return 0.02028856f; + case 40: return 0.02121901f; + case 41: return 0.02217388f; + case 42: return 0.02315336f; + case 43: return 0.02415763f; + case 44: return 0.02518686f; + case 45: return 0.02624122f; + case 46: return 0.02732089f; + case 47: return 0.02842604f; + case 48: return 0.02955683f; + case 49: return 0.03071344f; + case 50: return 0.03189603f; + case 51: return 0.03310476f; + case 52: return 0.03433981f; + case 53: return 0.03560131f; + case 54: return 0.03688945f; + case 55: return 0.03820436f; + case 56: return 0.03954624f; + case 57: return 0.04091520f; + case 58: return 0.04231141f; + case 59: return 0.04373503f; + case 60: return 0.04518620f; + case 61: return 0.04666508f; + case 62: return 0.04817182f; + case 63: return 0.04970656f; + case 64: return 0.05126947f; + case 65: return 0.05286065f; + case 66: return 0.05448028f; + case 67: return 0.05612849f; + case 68: return 0.05780543f; + case 69: return 0.05951124f; + case 70: return 0.06124607f; + case 71: return 0.06301003f; + case 72: return 0.06480328f; + case 73: return 0.06662595f; + case 74: return 0.06847818f; + case 75: return 0.07036011f; + case 76: return 0.07227186f; + case 77: return 0.07421358f; + case 78: return 0.07618539f; + case 79: return 0.07818743f; + case 80: return 0.08021983f; + case 81: return 0.08228271f; + case 82: return 0.08437622f; + case 83: return 0.08650047f; + case 84: return 0.08865561f; + case 85: return 0.09084173f; + case 86: return 0.09305898f; + case 87: return 0.09530748f; + case 88: return 0.09758736f; + case 89: return 0.09989874f; + case 90: return 0.10224175f; + case 91: return 0.10461649f; + case 92: return 0.10702311f; + case 93: return 0.10946172f; + case 94: return 0.11193243f; + case 95: return 0.11443538f; + case 96: return 0.11697067f; + case 97: return 0.11953843f; + case 98: return 0.12213880f; + case 99: return 0.12477184f; + case 100: return 0.12743770f; + case 101: return 0.13013649f; + case 102: return 0.13286833f; + case 103: return 0.13563335f; + case 104: return 0.13843162f; + case 105: return 0.14126331f; + case 106: return 0.14412849f; + case 107: return 0.14702728f; + case 108: return 0.14995980f; + case 109: return 0.15292616f; + case 110: return 0.15592647f; + case 111: return 0.15896086f; + case 112: return 0.16202940f; + case 113: return 0.16513222f; + case 114: return 0.16826940f; + case 115: return 0.17144109f; + case 116: return 0.17464739f; + case 117: return 0.17788841f; + case 118: return 0.18116423f; + case 119: return 0.18447499f; + case 120: return 0.18782076f; + case 121: return 0.19120167f; + case 122: return 0.19461781f; + case 123: return 0.19806930f; + case 124: return 0.20155624f; + case 125: return 0.20507871f; + case 126: return 0.20863685f; + case 127: return 0.21223073f; + case 128: return 0.21586053f; + case 129: return 0.21952623f; + case 130: return 0.22322798f; + case 131: return 0.22696589f; + case 132: return 0.23074007f; + case 133: return 0.23455065f; + case 134: return 0.23839766f; + case 135: return 0.24228120f; + case 136: return 0.24620140f; + case 137: return 0.25015837f; + case 138: return 0.25415218f; + case 139: return 0.25818291f; + case 140: return 0.26225072f; + case 141: return 0.26635566f; + case 142: return 0.27049786f; + case 143: return 0.27467737f; + case 144: return 0.27889434f; + case 145: return 0.28314880f; + case 146: return 0.28744090f; + case 147: return 0.29177070f; + case 148: return 0.29613832f; + case 149: return 0.30054384f; + case 150: return 0.30498737f; + case 151: return 0.30946895f; + case 152: return 0.31398875f; + case 153: return 0.31854683f; + case 154: return 0.32314324f; + case 155: return 0.32777813f; + case 156: return 0.33245158f; + case 157: return 0.33716366f; + case 158: return 0.34191445f; + case 159: return 0.34670410f; + case 160: return 0.35153270f; + case 161: return 0.35640025f; + case 162: return 0.36130688f; + case 163: return 0.36625269f; + case 164: return 0.37123778f; + case 165: return 0.37626222f; + case 166: return 0.38132611f; + case 167: return 0.38642952f; + case 168: return 0.39157256f; + case 169: return 0.39675531f; + case 170: return 0.40197787f; + case 171: return 0.40724030f; + case 172: return 0.41254270f; + case 173: return 0.41788515f; + case 174: return 0.42326775f; + case 175: return 0.42869055f; + case 176: return 0.43415371f; + case 177: return 0.43965724f; + case 178: return 0.44520125f; + case 179: return 0.45078585f; + case 180: return 0.45641106f; + case 181: return 0.46207705f; + case 182: return 0.46778384f; + case 183: return 0.47353154f; + case 184: return 0.47932023f; + case 185: return 0.48514998f; + case 186: return 0.49102089f; + case 187: return 0.49693304f; + case 188: return 0.50288659f; + case 189: return 0.50888145f; + case 190: return 0.51491779f; + case 191: return 0.52099568f; + case 192: return 0.52711523f; + case 193: return 0.53327650f; + case 194: return 0.53947961f; + case 195: return 0.54572457f; + case 196: return 0.55201149f; + case 197: return 0.55834049f; + case 198: return 0.56471163f; + case 199: return 0.57112491f; + case 200: return 0.57758051f; + case 201: return 0.58407849f; + case 202: return 0.59061891f; + case 203: return 0.59720188f; + case 204: return 0.60382742f; + case 205: return 0.61049563f; + case 206: return 0.61720663f; + case 207: return 0.62396044f; + case 208: return 0.63075721f; + case 209: return 0.63759696f; + case 210: return 0.64447975f; + case 211: return 0.65140569f; + case 212: return 0.65837485f; + case 213: return 0.66538733f; + case 214: return 0.67244321f; + case 215: return 0.67954254f; + case 216: return 0.68668544f; + case 217: return 0.69387192f; + case 218: return 0.70110202f; + case 219: return 0.70837593f; + case 220: return 0.71569365f; + case 221: return 0.72305524f; + case 222: return 0.73046088f; + case 223: return 0.73791057f; + case 224: return 0.74540436f; + case 225: return 0.75294232f; + case 226: return 0.76052463f; + case 227: return 0.76815128f; + case 228: return 0.77582234f; + case 229: return 0.78353792f; + case 230: return 0.79129803f; + case 231: return 0.79910284f; + case 232: return 0.80695236f; + case 233: return 0.81484669f; + case 234: return 0.82278585f; + case 235: return 0.83076996f; + case 236: return 0.83879912f; + case 237: return 0.84687328f; + case 238: return 0.85499269f; + case 239: return 0.86315727f; + case 240: return 0.87136722f; + case 241: return 0.87962234f; + case 242: return 0.88792318f; + case 243: return 0.89626938f; + case 244: return 0.90466136f; + case 245: return 0.91309869f; + case 246: return 0.92158204f; + case 247: return 0.93011087f; + case 248: return 0.93868589f; + case 249: return 0.94730657f; + case 250: return 0.95597351f; + case 251: return 0.96468627f; + case 252: return 0.97344548f; + case 253: return 0.98225057f; + case 254: return 0.99110222f; + case 255: return 1.00000000f; + default: return 1.0; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_CanDecodeLogicalPixelsF(TinyImageFormat const fmt) { + switch(fmt) { + case TinyImageFormat_R1_UNORM: return true; + case TinyImageFormat_R2_UNORM: return true; + case TinyImageFormat_R4_UNORM: return true; + case TinyImageFormat_R4G4_UNORM: return true; + case TinyImageFormat_G4R4_UNORM: return true; + case TinyImageFormat_A8_UNORM: return true; + case TinyImageFormat_R8_UNORM: return true; + case TinyImageFormat_R8_SNORM: return true; + case TinyImageFormat_R8_UINT: return true; + case TinyImageFormat_R8_SINT: return true; + case TinyImageFormat_R8_SRGB: return true; + case TinyImageFormat_B2G3R3_UNORM: return true; + case TinyImageFormat_R4G4B4A4_UNORM: return true; + case TinyImageFormat_R4G4B4X4_UNORM: return true; + case TinyImageFormat_B4G4R4A4_UNORM: return true; + case TinyImageFormat_B4G4R4X4_UNORM: return true; + case TinyImageFormat_A4R4G4B4_UNORM: return true; + case TinyImageFormat_X4R4G4B4_UNORM: return true; + case TinyImageFormat_A4B4G4R4_UNORM: return true; + case TinyImageFormat_X4B4G4R4_UNORM: return true; + case TinyImageFormat_R5G6B5_UNORM: return true; + case TinyImageFormat_B5G6R5_UNORM: return true; + case TinyImageFormat_R5G5B5A1_UNORM: return true; + case TinyImageFormat_B5G5R5A1_UNORM: return true; + case TinyImageFormat_A1B5G5R5_UNORM: return true; + case TinyImageFormat_A1R5G5B5_UNORM: return true; + case TinyImageFormat_R5G5B5X1_UNORM: return true; + case TinyImageFormat_B5G5R5X1_UNORM: return true; + case TinyImageFormat_X1R5G5B5_UNORM: return true; + case TinyImageFormat_X1B5G5R5_UNORM: return true; + case TinyImageFormat_B2G3R3A8_UNORM: return true; + case TinyImageFormat_R8G8_UNORM: return true; + case TinyImageFormat_R8G8_SNORM: return true; + case TinyImageFormat_G8R8_UNORM: return true; + case TinyImageFormat_G8R8_SNORM: return true; + case TinyImageFormat_R8G8_UINT: return true; + case TinyImageFormat_R8G8_SINT: return true; + case TinyImageFormat_R8G8_SRGB: return true; + case TinyImageFormat_R16_UNORM: return true; + case TinyImageFormat_R16_SNORM: return true; + case TinyImageFormat_R16_UINT: return true; + case TinyImageFormat_R16_SINT: return true; + case TinyImageFormat_R16_SFLOAT: return true; + case TinyImageFormat_R16_SBFLOAT: return true; + case TinyImageFormat_R8G8B8_UNORM: return true; + case TinyImageFormat_R8G8B8_SNORM: return true; + case TinyImageFormat_R8G8B8_UINT: return true; + case TinyImageFormat_R8G8B8_SINT: return true; + case TinyImageFormat_R8G8B8_SRGB: return true; + case TinyImageFormat_B8G8R8_UNORM: return true; + case TinyImageFormat_B8G8R8_SNORM: return true; + case TinyImageFormat_B8G8R8_UINT: return true; + case TinyImageFormat_B8G8R8_SINT: return true; + case TinyImageFormat_B8G8R8_SRGB: return true; + case TinyImageFormat_R8G8B8A8_UNORM: return true; + case TinyImageFormat_R8G8B8A8_SNORM: return true; + case TinyImageFormat_R8G8B8A8_UINT: return true; + case TinyImageFormat_R8G8B8A8_SINT: return true; + case TinyImageFormat_R8G8B8A8_SRGB: return true; + case TinyImageFormat_B8G8R8A8_UNORM: return true; + case TinyImageFormat_B8G8R8A8_SNORM: return true; + case TinyImageFormat_B8G8R8A8_UINT: return true; + case TinyImageFormat_B8G8R8A8_SINT: return true; + case TinyImageFormat_B8G8R8A8_SRGB: return true; + case TinyImageFormat_R8G8B8X8_UNORM: return true; + case TinyImageFormat_B8G8R8X8_UNORM: return true; + case TinyImageFormat_R16G16_UNORM: return true; + case TinyImageFormat_G16R16_UNORM: return true; + case TinyImageFormat_R16G16_SNORM: return true; + case TinyImageFormat_G16R16_SNORM: return true; + case TinyImageFormat_R16G16_UINT: return true; + case TinyImageFormat_R16G16_SINT: return true; + case TinyImageFormat_R16G16_SFLOAT: return true; + case TinyImageFormat_R16G16_SBFLOAT: return true; + case TinyImageFormat_R32_UINT: return true; + case TinyImageFormat_R32_SINT: return true; + case TinyImageFormat_R32_SFLOAT: return true; + case TinyImageFormat_A2R10G10B10_UNORM: return true; + case TinyImageFormat_A2R10G10B10_UINT: return true; + case TinyImageFormat_A2R10G10B10_SNORM: return true; + case TinyImageFormat_A2R10G10B10_SINT: return true; + case TinyImageFormat_A2B10G10R10_UNORM: return true; + case TinyImageFormat_A2B10G10R10_UINT: return true; + case TinyImageFormat_A2B10G10R10_SNORM: return true; + case TinyImageFormat_A2B10G10R10_SINT: return true; + case TinyImageFormat_R10G10B10A2_UNORM: return true; + case TinyImageFormat_R10G10B10A2_UINT: return true; + case TinyImageFormat_R10G10B10A2_SNORM: return true; + case TinyImageFormat_R10G10B10A2_SINT: return true; + case TinyImageFormat_B10G10R10A2_UNORM: return true; + case TinyImageFormat_B10G10R10A2_UINT: return true; + case TinyImageFormat_B10G10R10A2_SNORM: return true; + case TinyImageFormat_B10G10R10A2_SINT: return true; + case TinyImageFormat_B10G11R11_UFLOAT: return true; + case TinyImageFormat_E5B9G9R9_UFLOAT: return true; + case TinyImageFormat_R16G16B16_UNORM: return true; + case TinyImageFormat_R16G16B16_SNORM: return true; + case TinyImageFormat_R16G16B16_UINT: return true; + case TinyImageFormat_R16G16B16_SINT: return true; + case TinyImageFormat_R16G16B16_SFLOAT: return true; + case TinyImageFormat_R16G16B16_SBFLOAT: return true; + case TinyImageFormat_R16G16B16A16_UNORM: return true; + case TinyImageFormat_R16G16B16A16_SNORM: return true; + case TinyImageFormat_R16G16B16A16_UINT: return true; + case TinyImageFormat_R16G16B16A16_SINT: return true; + case TinyImageFormat_R16G16B16A16_SFLOAT: return true; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return true; + case TinyImageFormat_R32G32_UINT: return true; + case TinyImageFormat_R32G32_SINT: return true; + case TinyImageFormat_R32G32_SFLOAT: return true; + case TinyImageFormat_R32G32B32_UINT: return true; + case TinyImageFormat_R32G32B32_SINT: return true; + case TinyImageFormat_R32G32B32_SFLOAT: return true; + case TinyImageFormat_R32G32B32A32_UINT: return true; + case TinyImageFormat_R32G32B32A32_SINT: return true; + case TinyImageFormat_R32G32B32A32_SFLOAT: return true; + case TinyImageFormat_CLUT_P4: return true; + case TinyImageFormat_CLUT_P4A4: return true; + case TinyImageFormat_CLUT_P8: return true; + case TinyImageFormat_CLUT_P8A8: return true; + default: return false; + } + } + +TIF_CONSTEXPR inline bool TinyImageFormat_DecodeLogicalPixelsF(TinyImageFormat const fmt, TinyImageFormat_DecodeInput * in, uint32_t const width, float* out) { + switch(fmt) { + case TinyImageFormat_R1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + out[0] = (float)((val >> 0) & 0x1); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out[4] = (float)((val >> 1) & 0x1); + out[5] = (float)0.00000000; + out[6] = (float)0.00000000; + out[7] = (float)1.00000000; + out[8] = (float)((val >> 2) & 0x1); + out[9] = (float)0.00000000; + out[10] = (float)0.00000000; + out[11] = (float)1.00000000; + out[12] = (float)((val >> 3) & 0x1); + out[13] = (float)0.00000000; + out[14] = (float)0.00000000; + out[15] = (float)1.00000000; + out[16] = (float)((val >> 4) & 0x1); + out[17] = (float)0.00000000; + out[18] = (float)0.00000000; + out[19] = (float)1.00000000; + out[20] = (float)((val >> 5) & 0x1); + out[21] = (float)0.00000000; + out[22] = (float)0.00000000; + out[23] = (float)1.00000000; + out[24] = (float)((val >> 6) & 0x1); + out[25] = (float)0.00000000; + out[26] = (float)0.00000000; + out[27] = (float)1.00000000; + out[28] = (float)((val >> 7) & 0x1); + out[29] = (float)0.00000000; + out[30] = (float)0.00000000; + out[31] = (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + out+=32; + } + return true; + case TinyImageFormat_R2_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0x3)) * ((float)0.33333333); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out[4] = ((float)((val >> 2) & 0x3)) * ((float)0.33333333); + out[5] = (float)0.00000000; + out[6] = (float)0.00000000; + out[7] = (float)1.00000000; + out[8] = ((float)((val >> 4) & 0x3)) * ((float)0.33333333); + out[9] = (float)0.00000000; + out[10] = (float)0.00000000; + out[11] = (float)1.00000000; + out[12] = ((float)((val >> 6) & 0x3)) * ((float)0.33333333); + out[13] = (float)0.00000000; + out[14] = (float)0.00000000; + out[15] = (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + out+=16; + } + return true; + case TinyImageFormat_R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out[4] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[5] = (float)0.00000000; + out[6] = (float)0.00000000; + out[7] = (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + out+=8; + } + return true; + case TinyImageFormat_R4G4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_G4R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + out[1] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[0] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[3] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[0] = (float)0.00000000; + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R8_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint8_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R8_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int8_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_B2G3R3_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x3)) * ((float)0.33333333); + out[1] = ((float)((val >> 2) & 0x7)) * ((float)0.14285714); + out[0] = ((float)((val >> 5) & 0x7)) * ((float)0.14285714); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R4G4B4A4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[2] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[3] = ((float)((val >> 12) & 0xf)) * ((float)0.06666667); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R4G4B4X4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[2] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B4G4R4A4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[0] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[3] = ((float)((val >> 12) & 0xf)) * ((float)0.06666667); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B4G4R4X4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[0] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A4R4G4B4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[3] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[0] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[2] = ((float)((val >> 12) & 0xf)) * ((float)0.06666667); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_X4R4G4B4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[2] = ((float)((val >> 12) & 0xf)) * ((float)0.06666667); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A4B4G4R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[3] = ((float)((val >> 0) & 0xf)) * ((float)0.06666667); + out[2] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[0] = ((float)((val >> 12) & 0xf)) * ((float)0.06666667); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_X4B4G4R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 4) & 0xf)) * ((float)0.06666667); + out[1] = ((float)((val >> 8) & 0xf)) * ((float)0.06666667); + out[0] = ((float)((val >> 12) & 0xf)) * ((float)0.06666667); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R5G6B5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 5) & 0x3f)) * ((float)0.01587302); + out[2] = ((float)((val >> 11) & 0x1f)) * ((float)0.03225806); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B5G6R5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 5) & 0x3f)) * ((float)0.01587302); + out[0] = ((float)((val >> 11) & 0x1f)) * ((float)0.03225806); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R5G5B5A1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 5) & 0x1f)) * ((float)0.03225806); + out[2] = ((float)((val >> 10) & 0x1f)) * ((float)0.03225806); + out[3] = (float)((val >> 15) & 0x1); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B5G5R5A1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 5) & 0x1f)) * ((float)0.03225806); + out[0] = ((float)((val >> 10) & 0x1f)) * ((float)0.03225806); + out[3] = (float)((val >> 15) & 0x1); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A1B5G5R5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[3] = (float)((val >> 0) & 0x1); + out[2] = ((float)((val >> 1) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 6) & 0x1f)) * ((float)0.03225806); + out[0] = ((float)((val >> 11) & 0x1f)) * ((float)0.03225806); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A1R5G5B5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[3] = (float)((val >> 0) & 0x1); + out[0] = ((float)((val >> 1) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 6) & 0x1f)) * ((float)0.03225806); + out[2] = ((float)((val >> 11) & 0x1f)) * ((float)0.03225806); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R5G5B5X1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 5) & 0x1f)) * ((float)0.03225806); + out[2] = ((float)((val >> 10) & 0x1f)) * ((float)0.03225806); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B5G5R5X1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 5) & 0x1f)) * ((float)0.03225806); + out[0] = ((float)((val >> 10) & 0x1f)) * ((float)0.03225806); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_X1R5G5B5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[0] = ((float)((val >> 1) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 6) & 0x1f)) * ((float)0.03225806); + out[2] = ((float)((val >> 11) & 0x1f)) * ((float)0.03225806); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_X1B5G5R5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 1) & 0x1f)) * ((float)0.03225806); + out[1] = ((float)((val >> 6) & 0x1f)) * ((float)0.03225806); + out[0] = ((float)((val >> 11) & 0x1f)) * ((float)0.03225806); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B2G3R3A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x3)) * ((float)0.33333333); + out[1] = ((float)((val >> 2) & 0x7)) * ((float)0.14285714); + out[0] = ((float)((val >> 5) & 0x7)) * ((float)0.14285714); + out[3] = ((float)((val >> 8) & 0xff)) * ((float)0.00392157); + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R8G8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R8G8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[1] = ((float)((int8_t const *)in->pixel)[1]) * (float)0.00787402; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_G8R8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[1] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[0] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_G8R8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[1] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[0] = ((float)((int8_t const *)in->pixel)[1]) * (float)0.00787402; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R8G8_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint8_t const *)in->pixel)[0]); + out[1] = (float)(((uint8_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R8G8_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int8_t const *)in->pixel)[0]); + out[1] = (float)(((int8_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R8G8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[0]); + out[1] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint16_t const *)in->pixel)[0]) * (float)0.00001526; + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int16_t const *)in->pixel)[0]) * (float)0.00003052; + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R16_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint16_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R16_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int16_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R8G8B8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[2] = ((float)((uint8_t const *)in->pixel)[2]) * (float)0.00392157; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R8G8B8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[1] = ((float)((int8_t const *)in->pixel)[1]) * (float)0.00787402; + out[2] = ((float)((int8_t const *)in->pixel)[2]) * (float)0.00787402; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R8G8B8_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint8_t const *)in->pixel)[0]); + out[1] = (float)(((uint8_t const *)in->pixel)[1]); + out[2] = (float)(((uint8_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R8G8B8_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int8_t const *)in->pixel)[0]); + out[1] = (float)(((int8_t const *)in->pixel)[1]); + out[2] = (float)(((int8_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R8G8B8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[0]); + out[1] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[1]); + out[2] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_B8G8R8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[2] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[0] = ((float)((uint8_t const *)in->pixel)[2]) * (float)0.00392157; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_B8G8R8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[2] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[1] = ((float)((int8_t const *)in->pixel)[1]) * (float)0.00787402; + out[0] = ((float)((int8_t const *)in->pixel)[2]) * (float)0.00787402; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_B8G8R8_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[2] = (float)(((uint8_t const *)in->pixel)[0]); + out[1] = (float)(((uint8_t const *)in->pixel)[1]); + out[0] = (float)(((uint8_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_B8G8R8_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[2] = (float)(((int8_t const *)in->pixel)[0]); + out[1] = (float)(((int8_t const *)in->pixel)[1]); + out[0] = (float)(((int8_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_B8G8R8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + out[2] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[0]); + out[1] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[1]); + out[0] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R8G8B8A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[2] = ((float)((uint8_t const *)in->pixel)[2]) * (float)0.00392157; + out[3] = ((float)((uint8_t const *)in->pixel)[3]) * (float)0.00392157; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R8G8B8A8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[1] = ((float)((int8_t const *)in->pixel)[1]) * (float)0.00787402; + out[2] = ((float)((int8_t const *)in->pixel)[2]) * (float)0.00787402; + out[3] = ((float)((int8_t const *)in->pixel)[3]) * (float)0.00787402; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R8G8B8A8_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint8_t const *)in->pixel)[0]); + out[1] = (float)(((uint8_t const *)in->pixel)[1]); + out[2] = (float)(((uint8_t const *)in->pixel)[2]); + out[3] = (float)(((uint8_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R8G8B8A8_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int8_t const *)in->pixel)[0]); + out[1] = (float)(((int8_t const *)in->pixel)[1]); + out[2] = (float)(((int8_t const *)in->pixel)[2]); + out[3] = (float)(((int8_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R8G8B8A8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[0]); + out[1] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[1]); + out[2] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[2]); + out[3] = ((float)((uint8_t const *)in->pixel)[3]) * (float)0.00392157; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_B8G8R8A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[2] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[0] = ((float)((uint8_t const *)in->pixel)[2]) * (float)0.00392157; + out[3] = ((float)((uint8_t const *)in->pixel)[3]) * (float)0.00392157; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_B8G8R8A8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[2] = ((float)((int8_t const *)in->pixel)[0]) * (float)0.00787402; + out[1] = ((float)((int8_t const *)in->pixel)[1]) * (float)0.00787402; + out[0] = ((float)((int8_t const *)in->pixel)[2]) * (float)0.00787402; + out[3] = ((float)((int8_t const *)in->pixel)[3]) * (float)0.00787402; + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_B8G8R8A8_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[2] = (float)(((uint8_t const *)in->pixel)[0]); + out[1] = (float)(((uint8_t const *)in->pixel)[1]); + out[0] = (float)(((uint8_t const *)in->pixel)[2]); + out[3] = (float)(((uint8_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_B8G8R8A8_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[2] = (float)(((int8_t const *)in->pixel)[0]); + out[1] = (float)(((int8_t const *)in->pixel)[1]); + out[0] = (float)(((int8_t const *)in->pixel)[2]); + out[3] = (float)(((int8_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((int8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_B8G8R8A8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + out[2] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[0]); + out[1] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[1]); + out[0] = (float)TinyImageFormat_LookupSRGB(((uint8_t const *)in->pixel)[2]); + out[3] = ((float)((uint8_t const *)in->pixel)[3]) * (float)0.00392157; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R8G8B8X8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[2] = ((float)((uint8_t const *)in->pixel)[2]) * (float)0.00392157; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_B8G8R8X8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[2] = ((float)((uint8_t const *)in->pixel)[0]) * (float)0.00392157; + out[1] = ((float)((uint8_t const *)in->pixel)[1]) * (float)0.00392157; + out[0] = ((float)((uint8_t const *)in->pixel)[2]) * (float)0.00392157; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R16G16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint16_t const *)in->pixel)[0]) * (float)0.00001526; + out[1] = ((float)((uint16_t const *)in->pixel)[1]) * (float)0.00001526; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_G16R16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[1] = ((float)((uint16_t const *)in->pixel)[0]) * (float)0.00001526; + out[0] = ((float)((uint16_t const *)in->pixel)[1]) * (float)0.00001526; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R16G16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int16_t const *)in->pixel)[0]) * (float)0.00003052; + out[1] = ((float)((int16_t const *)in->pixel)[1]) * (float)0.00003052; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_G16R16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[1] = ((float)((int16_t const *)in->pixel)[0]) * (float)0.00003052; + out[0] = ((float)((int16_t const *)in->pixel)[1]) * (float)0.00003052; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R16G16_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint16_t const *)in->pixel)[0]); + out[1] = (float)(((uint16_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R16G16_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int16_t const *)in->pixel)[0]); + out[1] = (float)(((int16_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R16G16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R16G16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R32_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint32_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R32_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int32_t const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int32_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float) (((float const *)in->pixel)[0]); + out[1] = (float)0.00000000; + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((float const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_A2R10G10B10_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = ((float)((val >> 0) & 0x3)) * ((float)0.33333333); + out[0] = ((float)((val >> 2) & 0x3ff)) * ((float)0.00097752); + out[1] = ((float)((val >> 12) & 0x3ff)) * ((float)0.00097752); + out[2] = ((float)((val >> 22) & 0x3ff)) * ((float)0.00097752); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = (float)((val >> 0) & 0x3); + out[0] = (float)((val >> 2) & 0x3ff); + out[1] = (float)((val >> 12) & 0x3ff); + out[2] = (float)((val >> 22) & 0x3ff); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = ((float)((val >> 0) & 0x3)) * ((float)1.00000000); + out[0] = ((float)((val >> 2) & 0x3ff)) * ((float)0.00195695); + out[1] = ((float)((val >> 12) & 0x3ff)) * ((float)0.00195695); + out[2] = ((float)((val >> 22) & 0x3ff)) * ((float)0.00195695); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = (float)((val >> 0) & 0x3); + out[0] = (float)((val >> 2) & 0x3ff); + out[1] = (float)((val >> 12) & 0x3ff); + out[2] = (float)((val >> 22) & 0x3ff); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = ((float)((val >> 0) & 0x3)) * ((float)0.33333333); + out[2] = ((float)((val >> 2) & 0x3ff)) * ((float)0.00097752); + out[1] = ((float)((val >> 12) & 0x3ff)) * ((float)0.00097752); + out[0] = ((float)((val >> 22) & 0x3ff)) * ((float)0.00097752); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = (float)((val >> 0) & 0x3); + out[2] = (float)((val >> 2) & 0x3ff); + out[1] = (float)((val >> 12) & 0x3ff); + out[0] = (float)((val >> 22) & 0x3ff); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = ((float)((val >> 0) & 0x3)) * ((float)1.00000000); + out[2] = ((float)((val >> 2) & 0x3ff)) * ((float)0.00195695); + out[1] = ((float)((val >> 12) & 0x3ff)) * ((float)0.00195695); + out[0] = ((float)((val >> 22) & 0x3ff)) * ((float)0.00195695); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[3] = (float)((val >> 0) & 0x3); + out[2] = (float)((val >> 2) & 0x3ff); + out[1] = (float)((val >> 12) & 0x3ff); + out[0] = (float)((val >> 22) & 0x3ff); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0x3ff)) * ((float)0.00097752); + out[1] = ((float)((val >> 10) & 0x3ff)) * ((float)0.00097752); + out[2] = ((float)((val >> 20) & 0x3ff)) * ((float)0.00097752); + out[3] = ((float)((val >> 30) & 0x3)) * ((float)0.33333333); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[0] = (float)((val >> 0) & 0x3ff); + out[1] = (float)((val >> 10) & 0x3ff); + out[2] = (float)((val >> 20) & 0x3ff); + out[3] = (float)((val >> 30) & 0x3); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[0] = ((float)((val >> 0) & 0x3ff)) * ((float)0.00195695); + out[1] = ((float)((val >> 10) & 0x3ff)) * ((float)0.00195695); + out[2] = ((float)((val >> 20) & 0x3ff)) * ((float)0.00195695); + out[3] = ((float)((val >> 30) & 0x3)) * ((float)1.00000000); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[0] = (float)((val >> 0) & 0x3ff); + out[1] = (float)((val >> 10) & 0x3ff); + out[2] = (float)((val >> 20) & 0x3ff); + out[3] = (float)((val >> 30) & 0x3); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x3ff)) * ((float)0.00097752); + out[1] = ((float)((val >> 10) & 0x3ff)) * ((float)0.00097752); + out[0] = ((float)((val >> 20) & 0x3ff)) * ((float)0.00097752); + out[3] = ((float)((val >> 30) & 0x3)) * ((float)0.33333333); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[2] = (float)((val >> 0) & 0x3ff); + out[1] = (float)((val >> 10) & 0x3ff); + out[0] = (float)((val >> 20) & 0x3ff); + out[3] = (float)((val >> 30) & 0x3); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[2] = ((float)((val >> 0) & 0x3ff)) * ((float)0.00195695); + out[1] = ((float)((val >> 10) & 0x3ff)) * ((float)0.00195695); + out[0] = ((float)((val >> 20) & 0x3ff)) * ((float)0.00195695); + out[3] = ((float)((val >> 30) & 0x3)) * ((float)1.00000000); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[2] = (float)((val >> 0) & 0x3ff); + out[1] = (float)((val >> 10) & 0x3ff); + out[0] = (float)((val >> 20) & 0x3ff); + out[3] = (float)((val >> 30) & 0x3); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_B10G11R11_UFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t val = *((uint32_t const*)in->pixel); + out[2] = (float)TinyImageFormat_UFloat10AsUintToFloat((val >> 0) & 0x3ff); + out[1] = (float)TinyImageFormat_UFloat11AsUintToFloat((val >> 10) & 0x7ff); + out[0] = (float)TinyImageFormat_UFloat11AsUintToFloat((val >> 21) & 0x7ff); + out[3] = (float)1.00000000; + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out+=4; + } + return true; + case TinyImageFormat_E5B9G9R9_UFLOAT: + for(uint32_t w = 0; w < width; ++w) { + TinyImageFormat_SharedE5B9G9R9UFloatToFloats(*(uint32_t*)in->pixel, out); + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 1); + out += 4; + } + return true; + case TinyImageFormat_R16G16B16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint16_t const *)in->pixel)[0]) * (float)0.00001526; + out[1] = ((float)((uint16_t const *)in->pixel)[1]) * (float)0.00001526; + out[2] = ((float)((uint16_t const *)in->pixel)[2]) * (float)0.00001526; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R16G16B16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int16_t const *)in->pixel)[0]) * (float)0.00003052; + out[1] = ((float)((int16_t const *)in->pixel)[1]) * (float)0.00003052; + out[2] = ((float)((int16_t const *)in->pixel)[2]) * (float)0.00003052; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R16G16B16_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint16_t const *)in->pixel)[0]); + out[1] = (float)(((uint16_t const *)in->pixel)[1]); + out[2] = (float)(((uint16_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R16G16B16_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int16_t const *)in->pixel)[0]); + out[1] = (float)(((int16_t const *)in->pixel)[1]); + out[2] = (float)(((int16_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R16G16B16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[1]); + out[2] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R16G16B16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[1]); + out[2] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R16G16B16A16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((uint16_t const *)in->pixel)[0]) * (float)0.00001526; + out[1] = ((float)((uint16_t const *)in->pixel)[1]) * (float)0.00001526; + out[2] = ((float)((uint16_t const *)in->pixel)[2]) * (float)0.00001526; + out[3] = ((float)((uint16_t const *)in->pixel)[3]) * (float)0.00001526; + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R16G16B16A16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + out[0] = ((float)((int16_t const *)in->pixel)[0]) * (float)0.00003052; + out[1] = ((float)((int16_t const *)in->pixel)[1]) * (float)0.00003052; + out[2] = ((float)((int16_t const *)in->pixel)[2]) * (float)0.00003052; + out[3] = ((float)((int16_t const *)in->pixel)[3]) * (float)0.00003052; + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R16G16B16A16_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint16_t const *)in->pixel)[0]); + out[1] = (float)(((uint16_t const *)in->pixel)[1]); + out[2] = (float)(((uint16_t const *)in->pixel)[2]); + out[3] = (float)(((uint16_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R16G16B16A16_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int16_t const *)in->pixel)[0]); + out[1] = (float)(((int16_t const *)in->pixel)[1]); + out[2] = (float)(((int16_t const *)in->pixel)[2]); + out[3] = (float)(((int16_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((int16_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R16G16B16A16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[1]); + out[2] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[2]); + out[3] = (float)TinyImageFormat_HalfAsUintToFloat((((uint16_t const *)in->pixel))[3]); + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R16G16B16A16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[0]); + out[1] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[1]); + out[2] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[2]); + out[3] = (float)TinyImageFormat_BFloatAsUintToFloat((((uint16_t const *)in->pixel))[3]); + out += 4; + in->pixel = (void const*)(((uint16_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R32G32_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint32_t const *)in->pixel)[0]); + out[1] = (float)(((uint32_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R32G32_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int32_t const *)in->pixel)[0]); + out[1] = (float)(((int32_t const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int32_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R32G32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float) (((float const *)in->pixel)[0]); + out[1] = (float) (((float const *)in->pixel)[1]); + out[2] = (float)0.00000000; + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((float const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R32G32B32_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint32_t const *)in->pixel)[0]); + out[1] = (float)(((uint32_t const *)in->pixel)[1]); + out[2] = (float)(((uint32_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R32G32B32_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int32_t const *)in->pixel)[0]); + out[1] = (float)(((int32_t const *)in->pixel)[1]); + out[2] = (float)(((int32_t const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((int32_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R32G32B32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float) (((float const *)in->pixel)[0]); + out[1] = (float) (((float const *)in->pixel)[1]); + out[2] = (float) (((float const *)in->pixel)[2]); + out[3] = (float)1.00000000; + out += 4; + in->pixel = (void const*)(((float const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R32G32B32A32_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((uint32_t const *)in->pixel)[0]); + out[1] = (float)(((uint32_t const *)in->pixel)[1]); + out[2] = (float)(((uint32_t const *)in->pixel)[2]); + out[3] = (float)(((uint32_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((uint32_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R32G32B32A32_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float)(((int32_t const *)in->pixel)[0]); + out[1] = (float)(((int32_t const *)in->pixel)[1]); + out[2] = (float)(((int32_t const *)in->pixel)[2]); + out[3] = (float)(((int32_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((int32_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R32G32B32A32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (float) (((float const *)in->pixel)[0]); + out[1] = (float) (((float const *)in->pixel)[1]); + out[2] = (float) (((float const *)in->pixel)[2]); + out[3] = (float) (((float const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((float const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_CLUT_P4: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + uint32_t const* lut = (uint32_t const*)in->lut; + uint32_t v0 = lut[((val >> 0) & 0xf)]; + out[0] = (float)((lut[v0] >> 0) & 0xFF) * (float)1.00000000; + out[1] = (float)((lut[v0] >> 8) & 0xFF) * (float)1.00000000; + out[2] = (float)((lut[v0] >> 16) & 0xFF) * (float)1.00000000; + out[3] = (float)((lut[v0] >> 24) & 0xFF) * (float)1.00000000; + uint32_t v1 = lut[((val >> 4) & 0xf)]; + out[4] = (float)((lut[v1] >> 0) & 0xFF) * (float)1.00000000; + out[5] = (float)((lut[v1] >> 8) & 0xFF) * (float)1.00000000; + out[6] = (float)((lut[v1] >> 16) & 0xFF) * (float)1.00000000; + out[7] = (float)((lut[v1] >> 24) & 0xFF) * (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_CLUT_P4A4: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + uint32_t const* lut = (uint32_t const*)in->lut; + uint32_t v0 = lut[((val >> 0) & 0xf)]; + out[0] = (float)((lut[v0] >> 0) & 0xFF) * (float)1.00000000; + out[1] = (float)((lut[v0] >> 8) & 0xFF) * (float)1.00000000; + out[2] = (float)((lut[v0] >> 16) & 0xFF) * (float)1.00000000; + out[3] = ((float)((val >> 4) & 0xf)) * ((float)1.00000000); + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_CLUT_P8: + for(uint32_t w = 0; w < width; ++w) { + uint8_t val = *((uint8_t const*)in->pixel); + uint32_t const* lut = (uint32_t const*)in->lut; + uint32_t v0 = lut[((val >> 0) & 0xff)]; + out[0] = (float)((lut[v0] >> 0) & 0xFF) * (float)1.00000000; + out[1] = (float)((lut[v0] >> 8) & 0xFF) * (float)1.00000000; + out[2] = (float)((lut[v0] >> 16) & 0xFF) * (float)1.00000000; + out[3] = (float)((lut[v0] >> 24) & 0xFF) * (float)1.00000000; + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_CLUT_P8A8: + for(uint32_t w = 0; w < width; ++w) { + uint16_t val = *((uint16_t const*)in->pixel); + uint32_t const* lut = (uint32_t const*)in->lut; + uint32_t v0 = lut[((val >> 0) & 0xff)]; + out[0] = (float)((lut[v0] >> 0) & 0xFF) * (float)1.00000000; + out[1] = (float)((lut[v0] >> 8) & 0xFF) * (float)1.00000000; + out[2] = (float)((lut[v0] >> 16) & 0xFF) * (float)1.00000000; + out[3] = ((float)((val >> 8) & 0xff)) * ((float)1.00000000); + in->pixel = (void const*)(((uint8_t const*)in->pixel) + 1); + } + return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_CanDecodeLogicalPixelsD(TinyImageFormat const fmt) { + switch(fmt) { + case TinyImageFormat_R64_UINT: return true; + case TinyImageFormat_R64_SINT: return true; + case TinyImageFormat_R64_SFLOAT: return true; + case TinyImageFormat_R64G64_UINT: return true; + case TinyImageFormat_R64G64_SINT: return true; + case TinyImageFormat_R64G64_SFLOAT: return true; + case TinyImageFormat_R64G64B64_UINT: return true; + case TinyImageFormat_R64G64B64_SINT: return true; + case TinyImageFormat_R64G64B64_SFLOAT: return true; + case TinyImageFormat_R64G64B64A64_UINT: return true; + case TinyImageFormat_R64G64B64A64_SINT: return true; + case TinyImageFormat_R64G64B64A64_SFLOAT: return true; + default: return TinyImageFormat_CanDecodeLogicalPixelsF(fmt); + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_DecodeLogicalPixelsD(TinyImageFormat const fmt, TinyImageFormat_DecodeInput * in, uint32_t const width, double* out) { + switch(fmt) { + case TinyImageFormat_R64_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((uint64_t const *)in->pixel)[0]); + out[1] = (double)0.00000000; + out[2] = (double)0.00000000; + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((uint64_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R64_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((int64_t const *)in->pixel)[0]); + out[1] = (double)0.00000000; + out[2] = (double)0.00000000; + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((int64_t const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double) (((double const *)in->pixel)[0]); + out[1] = (double)0.00000000; + out[2] = (double)0.00000000; + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((double const*)in->pixel) + 1); + } + return true; + case TinyImageFormat_R64G64_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((uint64_t const *)in->pixel)[0]); + out[1] = (double)(((uint64_t const *)in->pixel)[1]); + out[2] = (double)0.00000000; + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((uint64_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R64G64_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((int64_t const *)in->pixel)[0]); + out[1] = (double)(((int64_t const *)in->pixel)[1]); + out[2] = (double)0.00000000; + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((int64_t const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R64G64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double) (((double const *)in->pixel)[0]); + out[1] = (double) (((double const *)in->pixel)[1]); + out[2] = (double)0.00000000; + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((double const*)in->pixel) + 2); + } + return true; + case TinyImageFormat_R64G64B64_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((uint64_t const *)in->pixel)[0]); + out[1] = (double)(((uint64_t const *)in->pixel)[1]); + out[2] = (double)(((uint64_t const *)in->pixel)[2]); + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((uint64_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R64G64B64_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((int64_t const *)in->pixel)[0]); + out[1] = (double)(((int64_t const *)in->pixel)[1]); + out[2] = (double)(((int64_t const *)in->pixel)[2]); + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((int64_t const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R64G64B64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double) (((double const *)in->pixel)[0]); + out[1] = (double) (((double const *)in->pixel)[1]); + out[2] = (double) (((double const *)in->pixel)[2]); + out[3] = (double)1.00000000; + out += 4; + in->pixel = (void const*)(((double const*)in->pixel) + 3); + } + return true; + case TinyImageFormat_R64G64B64A64_UINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((uint64_t const *)in->pixel)[0]); + out[1] = (double)(((uint64_t const *)in->pixel)[1]); + out[2] = (double)(((uint64_t const *)in->pixel)[2]); + out[3] = (double)(((uint64_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((uint64_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R64G64B64A64_SINT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double)(((int64_t const *)in->pixel)[0]); + out[1] = (double)(((int64_t const *)in->pixel)[1]); + out[2] = (double)(((int64_t const *)in->pixel)[2]); + out[3] = (double)(((int64_t const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((int64_t const*)in->pixel) + 4); + } + return true; + case TinyImageFormat_R64G64B64A64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + out[0] = (double) (((double const *)in->pixel)[0]); + out[1] = (double) (((double const *)in->pixel)[1]); + out[2] = (double) (((double const *)in->pixel)[2]); + out[3] = (double) (((double const *)in->pixel)[3]); + out += 4; + in->pixel = (void const*)(((double const*)in->pixel) + 4); + } + return true; + default: + { + float outF[4] = {0, 0, 0, 0}; bool ret = true; + for(uint32_t w = 0; w < width && ret; ++w) { + ret = TinyImageFormat_DecodeLogicalPixelsF(fmt, in, 1, outF); + out[0] = outF[0]; out[1] = outF[1]; out[2] = outF[2]; out[3] = outF[3]; out += 4; + } + return ret; + } + } +} + +#undef TIF_CONSTEXPR +#endif // TINYIMAGEFORMAT_DECODE_H_ + diff --git a/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_encode.h b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_encode.h new file mode 100644 index 0000000..18d0a54 --- /dev/null +++ b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_encode.h @@ -0,0 +1,1906 @@ +// Auto generated by formatgen on Sep 21 2019 +#pragma once +#if !defined(TINYIMAGEFORMAT_ENCODE_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) +#define TINYIMAGEFORMAT_ENCODE_H_ 1 + +#include "tinyimageformat_base.h" + +#if __cplusplus > 201402L +#define TIF_CONSTEXPR constexpr +#else +#define TIF_CONSTEXPR +#endif +#ifndef TinyImageFormat_HAVE_UINTXX_T +#include // for uint32_t and int64_t +#endif +#ifndef TinyImageFormat_HAVE_BOOL +#include // for bool +#endif +#ifndef TinyImageFormat_HAVE_POWF +#include // for powf +#endif +//TinyImageFormat_ASSERT needs to be constexpr on some platforms +#ifndef TinyImageFormat_ASSERT +#define TinyImageFormat_ASSERT(x) +#endif + + + +// from D3DX_DXGIFormatConvert.inl +inline uint8_t TinyImageFormat_FloatToSRGB(float v) { + if (v < 0.0031308f) { + v *= 12.92f; + } else { + v = 1.055f * powf(v, 1.0f / 2.4f) - 0.055f; + } + return (uint8_t)v; +} + +//Float2Half from Rygorous public domain code +inline uint16_t TinyImageFormat_FloatToHalfAsUint(float f_) { + union { + uint16_t u; + struct { + uint16_t Mantissa : 10; + uint16_t Exponent : 5; + uint16_t Sign : 1; + }; + } o; + + union { + uint32_t u; + float f; + struct { + uint32_t Mantissa : 23; + uint32_t Exponent : 8; + uint32_t Sign : 1; + }; + } f; + + static uint32_t const f32infty = {255 << 23}; + static uint32_t const f16max = {(127 + 16) << 23}; + static uint32_t const denorm_magicU = {((127 - 15) + (23 - 10) + 1) << 23}; + static uint32_t const sign_mask = 0x80000000u; + + float const denorm_magic = *(float const*)(&denorm_magicU); + + o.u = 0; + f.f = f_; + + uint32_t const sign = f.u & sign_mask; + f.u ^= sign; + + // NOTE all the integer compares in this function can be safely + // compiled into signed compares since all operands are below + // 0x80000000. Important if you want fast straight SSE2 code + // (since there's no unsigned PCMPGTD). + + if (f.u >= f16max) { // result is Inf or NaN (all exponent bits set) + o.u = (f.u > f32infty) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf + } else // (De)normalized number or zero + { + if (f.u < (113 << 23)) // resulting FP16 is subnormal or zero + { + // use a magic value to align our 10 mantissa bits at the bottom of + // the float. as long as FP addition is round-to-nearest-even this + // just works. + f.f += denorm_magic; + + // and one integer subtract of the bias later, we have our final float! + o.u = f.u - denorm_magicU; + } else { + uint32_t mant_odd = (f.u >> 13) & 1; // resulting mantissa is odd + + // update exponent, rounding bias part 1 + f.u += 0xc8000fff; + // rounding bias part 2 + f.u += mant_odd; + // take the bits! + o.u = f.u >> 13; + } + } + + o.u |= sign >> 16; + return o.u; +} + +inline uint16_t TinyImageFormat_FloatToBFloatAsUint(float v) { + union { + struct { + uint16_t x; + uint16_t u; + }; + float f; + } o; + + o.f = v; + o.x = 0; + + return o.u; +} + +inline void TinyImageFormat_FloatRGBToRGB9E5AsUint32(float const* in, uint32_t* out) { + float const r = in[0]; + float const g = in[1]; + float const b = in[2]; + float const v = r > g ? r > b ? r : b : g > b ? g : b; + + + union + { + struct + { + uint32_t rm : 9; + uint32_t gm : 9; + uint32_t bm : 9; + uint32_t e : 5; + }; + uint32_t v; + } ei; + + if (v < 1.52587890625e-5f) { + *out = 0; + } else if (v < 65536) { + int ex; + float m = frexpf(v, &ex) * 512.0f / v; + + ei.rm = (uint32_t)(m * r); + ei.gm = (uint32_t)(m * g); + ei.bm = (uint32_t)(m * b); + ei.e = (unsigned int) (ex + 15); + *out = ei.v; + } else { + ei.rm = (r < 65536) ? (uint32_t)(r * (1.0f / 128.0f)) : 0x1FF; + ei.gm = (g < 65536) ? (uint32_t)(g * (1.0f / 128.0f)) : 0x1FF; + ei.bm = (b < 65536) ? (uint32_t)(b * (1.0f / 128.0f)) : 0x1FF; + ei.e = 31; + *out = ei.v; + } +} + +inline uint16_t TinyImageFormat_FloatToUFloat6AsUint(float Value) +{ + uint32_t IValue = *((uint32_t *)&Value); + + if (IValue & 0x80000000U) + { + // Positive only + return 0; + } + else if (IValue > 0x43FEFFFFU) + { + // The number is too large to be represented as a 6e4. Saturate. + return 0x3FFU; + } + else + { + if (IValue < 0x3C800000U) + { + // The number is too small to be represented as a normalized 6e4. + // Convert it to a denormalized value. + uint32_t Shift = 121U - (IValue >> 23U); + if(Shift < 24U) Shift = 24U; + + IValue = (0x800000U | (IValue & 0x7FFFFFU)) >> Shift; + } + else + { + // Rebias the exponent to represent the value as a normalized 6e4. + IValue += 0xC4000000U; + } + + return (uint16_t)(((IValue + 0xFFFFU + ((IValue >> 17U) & 1U)) >> 17U) & 0x3FFU); + } +} + +inline uint16_t TinyImageFormat_FloatToUFloat7AsUint(float Value) +{ + uint32_t IValue = *((uint32_t *)&Value); + + if (IValue & 0x80000000U) + { + // Positive only + return 0; + } + else if (IValue > 0x41FF73FFU) + { + // The number is too large to be represented as a 7e3. Saturate. + return 0x3FFU; + } + else + { + if (IValue < 0x3E800000U) + { + // The number is too small to be represented as a normalized 7e3. + // Convert it to a denormalized value. + uint32_t Shift = 125U - (IValue >> 23U); + if(Shift < 24U) Shift = 24U; + + IValue = (0x800000U | (IValue & 0x7FFFFFU)) >> Shift; + } + else + { + // Rebias the exponent to represent the value as a normalized 7e3. + IValue += 0xC2000000U; + } + + return (uint16_t)(((IValue + 0x7FFFU + ((IValue >> 16U) & 1U)) >> 16U) & 0x3FFU); + } +} + +inline uint16_t TinyImageFormat_FloatToUFloat10AsUint(float v) { + union { + uint32_t u; + float f; + struct { + uint32_t Mantissa : 23; + uint32_t Exponent : 8; + uint32_t Sign : 1; + }; + } o; + union { + struct { + uint16_t e : 5; + uint16_t m : 5; + uint16_t x : 6; // not used + }; + uint16_t v; + } ei; + + o.f = v; + ei.v = 0; + + // positive only, so clamp to zero + if(o.Sign) return 0; + + // 5-bit exponent, 5-bit mantissa + + // INF or NAN + if (o.Exponent == 0xFF) { + if ( o.Mantissa != 0) { + return 0x3e0 | (((o.u>>18)|(o.u>>11)|(o.u>>6)|(o.u))&0x3f); + } else { + return 0x3e0; + } + } else if (o.u > 0x477C0000U) { + // The number is too large to be represented as a float10, set to max + return 0x3df; + } + else if (o.u < 0x38800000U) { + // The number is too small to be represented as a normalized float11 + // Convert it to a denormalized value. + ei.e = 0; + ei.m = o.Mantissa >> (113U - o.Exponent); + } else { + // Rebias the exponent to represent the value as a normalized float11 + ei.e = o.Exponent + 16; + ei.m = o.Mantissa >> 18; + } + + return ei.v; +} + +inline uint16_t TinyImageFormat_FloatToUFloat11AsUint(float v) { + union { + uint32_t u; + float f; + struct { + uint32_t Mantissa : 23; + uint32_t Exponent : 8; + uint32_t Sign : 1; + }; + } o; + union { + struct { + uint16_t e : 5; + uint16_t m : 6; + uint16_t x : 5; // not used + }; + uint16_t v; + } ei; + + o.f = v; + ei.v = 0; + + // positive only, so clamp to zero + if(o.Sign) return 0; + + // 5-bit exponent, 6-bit mantissa) + + // INF or NAN + if (o.Exponent == 0xFF) { + if ( o.Mantissa != 0) { + return 0x7c0 | (((o.u>>17)|(o.u>>11)|(o.u>>6)|(o.u))&0x3f); + } else { + return 0x7c0; + } + } else if (o.u > 0x477C0000U) { + // The number is too large to be represented as a float11, set to max + return 0x7BF; + } + else if (o.u < 0x38800000U) { + // The number is too small to be represented as a normalized float11 + // Convert it to a denormalized value. + ei.e = 0; + ei.m = o.Mantissa >> (113U - o.Exponent); + } else { + // Rebias the exponent to represent the value as a normalized float11 + ei.e = o.Exponent + 16; + ei.m = o.Mantissa >> 17; + } + + return ei.v; +} + +TIF_CONSTEXPR inline bool TinyImageFormat_CanEncodeLogicalPixelsF(TinyImageFormat const fmt) { + switch(fmt) { + case TinyImageFormat_R1_UNORM: return true; + case TinyImageFormat_R2_UNORM: return true; + case TinyImageFormat_R4_UNORM: return true; + case TinyImageFormat_R4G4_UNORM: return true; + case TinyImageFormat_G4R4_UNORM: return true; + case TinyImageFormat_A8_UNORM: return true; + case TinyImageFormat_R8_UNORM: return true; + case TinyImageFormat_R8_SNORM: return true; + case TinyImageFormat_R8_UINT: return true; + case TinyImageFormat_R8_SINT: return true; + case TinyImageFormat_R8_SRGB: return true; + case TinyImageFormat_B2G3R3_UNORM: return true; + case TinyImageFormat_R4G4B4A4_UNORM: return true; + case TinyImageFormat_R4G4B4X4_UNORM: return true; + case TinyImageFormat_B4G4R4A4_UNORM: return true; + case TinyImageFormat_B4G4R4X4_UNORM: return true; + case TinyImageFormat_A4R4G4B4_UNORM: return true; + case TinyImageFormat_X4R4G4B4_UNORM: return true; + case TinyImageFormat_A4B4G4R4_UNORM: return true; + case TinyImageFormat_X4B4G4R4_UNORM: return true; + case TinyImageFormat_R5G6B5_UNORM: return true; + case TinyImageFormat_B5G6R5_UNORM: return true; + case TinyImageFormat_R5G5B5A1_UNORM: return true; + case TinyImageFormat_B5G5R5A1_UNORM: return true; + case TinyImageFormat_A1B5G5R5_UNORM: return true; + case TinyImageFormat_A1R5G5B5_UNORM: return true; + case TinyImageFormat_R5G5B5X1_UNORM: return true; + case TinyImageFormat_B5G5R5X1_UNORM: return true; + case TinyImageFormat_X1R5G5B5_UNORM: return true; + case TinyImageFormat_X1B5G5R5_UNORM: return true; + case TinyImageFormat_B2G3R3A8_UNORM: return true; + case TinyImageFormat_R8G8_UNORM: return true; + case TinyImageFormat_R8G8_SNORM: return true; + case TinyImageFormat_G8R8_UNORM: return true; + case TinyImageFormat_G8R8_SNORM: return true; + case TinyImageFormat_R8G8_UINT: return true; + case TinyImageFormat_R8G8_SINT: return true; + case TinyImageFormat_R8G8_SRGB: return true; + case TinyImageFormat_R16_UNORM: return true; + case TinyImageFormat_R16_SNORM: return true; + case TinyImageFormat_R16_UINT: return true; + case TinyImageFormat_R16_SINT: return true; + case TinyImageFormat_R16_SFLOAT: return true; + case TinyImageFormat_R16_SBFLOAT: return true; + case TinyImageFormat_R8G8B8_UNORM: return true; + case TinyImageFormat_R8G8B8_SNORM: return true; + case TinyImageFormat_R8G8B8_UINT: return true; + case TinyImageFormat_R8G8B8_SINT: return true; + case TinyImageFormat_R8G8B8_SRGB: return true; + case TinyImageFormat_B8G8R8_UNORM: return true; + case TinyImageFormat_B8G8R8_SNORM: return true; + case TinyImageFormat_B8G8R8_UINT: return true; + case TinyImageFormat_B8G8R8_SINT: return true; + case TinyImageFormat_B8G8R8_SRGB: return true; + case TinyImageFormat_R8G8B8A8_UNORM: return true; + case TinyImageFormat_R8G8B8A8_SNORM: return true; + case TinyImageFormat_R8G8B8A8_UINT: return true; + case TinyImageFormat_R8G8B8A8_SINT: return true; + case TinyImageFormat_R8G8B8A8_SRGB: return true; + case TinyImageFormat_B8G8R8A8_UNORM: return true; + case TinyImageFormat_B8G8R8A8_SNORM: return true; + case TinyImageFormat_B8G8R8A8_UINT: return true; + case TinyImageFormat_B8G8R8A8_SINT: return true; + case TinyImageFormat_B8G8R8A8_SRGB: return true; + case TinyImageFormat_R8G8B8X8_UNORM: return true; + case TinyImageFormat_B8G8R8X8_UNORM: return true; + case TinyImageFormat_R16G16_UNORM: return true; + case TinyImageFormat_G16R16_UNORM: return true; + case TinyImageFormat_R16G16_SNORM: return true; + case TinyImageFormat_G16R16_SNORM: return true; + case TinyImageFormat_R16G16_UINT: return true; + case TinyImageFormat_R16G16_SINT: return true; + case TinyImageFormat_R16G16_SFLOAT: return true; + case TinyImageFormat_R16G16_SBFLOAT: return true; + case TinyImageFormat_R32_UINT: return true; + case TinyImageFormat_R32_SINT: return true; + case TinyImageFormat_R32_SFLOAT: return true; + case TinyImageFormat_A2R10G10B10_UNORM: return true; + case TinyImageFormat_A2R10G10B10_UINT: return true; + case TinyImageFormat_A2R10G10B10_SNORM: return true; + case TinyImageFormat_A2R10G10B10_SINT: return true; + case TinyImageFormat_A2B10G10R10_UNORM: return true; + case TinyImageFormat_A2B10G10R10_UINT: return true; + case TinyImageFormat_A2B10G10R10_SNORM: return true; + case TinyImageFormat_A2B10G10R10_SINT: return true; + case TinyImageFormat_R10G10B10A2_UNORM: return true; + case TinyImageFormat_R10G10B10A2_UINT: return true; + case TinyImageFormat_R10G10B10A2_SNORM: return true; + case TinyImageFormat_R10G10B10A2_SINT: return true; + case TinyImageFormat_B10G10R10A2_UNORM: return true; + case TinyImageFormat_B10G10R10A2_UINT: return true; + case TinyImageFormat_B10G10R10A2_SNORM: return true; + case TinyImageFormat_B10G10R10A2_SINT: return true; + case TinyImageFormat_B10G11R11_UFLOAT: return true; + case TinyImageFormat_E5B9G9R9_UFLOAT: return true; + case TinyImageFormat_R16G16B16_UNORM: return true; + case TinyImageFormat_R16G16B16_SNORM: return true; + case TinyImageFormat_R16G16B16_UINT: return true; + case TinyImageFormat_R16G16B16_SINT: return true; + case TinyImageFormat_R16G16B16_SFLOAT: return true; + case TinyImageFormat_R16G16B16_SBFLOAT: return true; + case TinyImageFormat_R16G16B16A16_UNORM: return true; + case TinyImageFormat_R16G16B16A16_SNORM: return true; + case TinyImageFormat_R16G16B16A16_UINT: return true; + case TinyImageFormat_R16G16B16A16_SINT: return true; + case TinyImageFormat_R16G16B16A16_SFLOAT: return true; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return true; + case TinyImageFormat_R32G32_UINT: return true; + case TinyImageFormat_R32G32_SINT: return true; + case TinyImageFormat_R32G32_SFLOAT: return true; + case TinyImageFormat_R32G32B32_UINT: return true; + case TinyImageFormat_R32G32B32_SINT: return true; + case TinyImageFormat_R32G32B32_SFLOAT: return true; + case TinyImageFormat_R32G32B32A32_UINT: return true; + case TinyImageFormat_R32G32B32A32_SINT: return true; + case TinyImageFormat_R32G32B32A32_SFLOAT: return true; + default: return false; + } + } + +TIF_CONSTEXPR inline bool TinyImageFormat_EncodeLogicalPixelsF(TinyImageFormat const fmt, float const *in, uint32_t const width, TinyImageFormat_EncodeOutput * out) { + switch(fmt) { + case TinyImageFormat_R1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[0] * 1.00f) & 0x1) << 0; + *op0 |= ((uint8_t)(in[4] * 1.00f) & 0x1) << 1; + *op0 |= ((uint8_t)(in[8] * 1.00f) & 0x1) << 2; + *op0 |= ((uint8_t)(in[12] * 1.00f) & 0x1) << 3; + *op0 |= ((uint8_t)(in[16] * 1.00f) & 0x1) << 4; + *op0 |= ((uint8_t)(in[20] * 1.00f) & 0x1) << 5; + *op0 |= ((uint8_t)(in[24] * 1.00f) & 0x1) << 6; + *op0 |= ((uint8_t)(in[28] * 1.00f) & 0x1) << 7; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=32; + } + return true; + case TinyImageFormat_R2_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[0] * 3.00f) & 0x3) << 0; + *op0 |= ((uint8_t)(in[4] * 3.00f) & 0x3) << 2; + *op0 |= ((uint8_t)(in[8] * 3.00f) & 0x3) << 4; + *op0 |= ((uint8_t)(in[12] * 3.00f) & 0x3) << 6; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=16; + } + return true; + case TinyImageFormat_R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[0] * 15.00f) & 0xf) << 0; + *op0 |= ((uint8_t)(in[4] * 15.00f) & 0xf) << 4; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=8; + } + return true; + case TinyImageFormat_R4G4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[0] * 15.00f) & 0xf) << 0; + *op0 |= ((uint8_t)(in[1] * 15.00f) & 0xf) << 4; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_G4R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[1] * 15.00f) & 0xf) << 0; + *op0 |= ((uint8_t)(in[0] * 15.00f) & 0xf) << 4; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[3] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[0] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((int8_t)(in[0] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= (((uint8_t)in[0]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= (((int8_t)in[0]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[0])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B2G3R3_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[2] * 3.00f) & 0x3) << 0; + *op0 |= ((uint8_t)(in[1] * 7.00f) & 0x7) << 2; + *op0 |= ((uint8_t)(in[0] * 7.00f) & 0x7) << 5; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R4G4B4A4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 0; + *op0 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 4; + *op0 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 8; + *op0 |= ((uint16_t)(in[3] * 15.00f) & 0xf) << 12; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R4G4B4X4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 0; + *op0 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 4; + *op0 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B4G4R4A4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 0; + *op0 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 4; + *op0 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 8; + *op0 |= ((uint16_t)(in[3] * 15.00f) & 0xf) << 12; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B4G4R4X4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 0; + *op0 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 4; + *op0 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A4R4G4B4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[3] * 15.00f) & 0xf) << 0; + *op0 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 4; + *op0 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 8; + *op0 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 12; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_X4R4G4B4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 4; + *op1 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 8; + *op1 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 12; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A4B4G4R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[3] * 15.00f) & 0xf) << 0; + *op0 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 4; + *op0 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 8; + *op0 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 12; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_X4B4G4R4_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)(in[2] * 15.00f) & 0xf) << 4; + *op1 |= ((uint16_t)(in[1] * 15.00f) & 0xf) << 8; + *op1 |= ((uint16_t)(in[0] * 15.00f) & 0xf) << 12; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R5G6B5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 0; + *op0 |= ((uint16_t)(in[1] * 63.00f) & 0x3f) << 5; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 11; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B5G6R5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 0; + *op0 |= ((uint16_t)(in[1] * 63.00f) & 0x3f) << 5; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 11; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R5G5B5A1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 0; + *op0 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 5; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 10; + *op0 |= ((uint16_t)(in[3] * 1.00f) & 0x1) << 15; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B5G5R5A1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 0; + *op0 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 5; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 10; + *op0 |= ((uint16_t)(in[3] * 1.00f) & 0x1) << 15; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A1B5G5R5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[3] * 1.00f) & 0x1) << 0; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 1; + *op0 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 6; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 11; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A1R5G5B5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[3] * 1.00f) & 0x1) << 0; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 1; + *op0 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 6; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 11; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R5G5B5X1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 0; + *op0 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 5; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 10; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B5G5R5X1_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 0; + *op0 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 5; + *op0 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 10; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_X1R5G5B5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 1; + *op1 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 6; + *op1 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 11; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_X1B5G5R5_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)(in[2] * 31.00f) & 0x1f) << 1; + *op1 |= ((uint16_t)(in[1] * 31.00f) & 0x1f) << 6; + *op1 |= ((uint16_t)(in[0] * 31.00f) & 0x1f) << 11; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B2G3R3A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[2] * 3.00f) & 0x3) << 0; + *op0 |= ((uint16_t)(in[1] * 7.00f) & 0x7) << 2; + *op0 |= ((uint16_t)(in[0] * 7.00f) & 0x7) << 5; + *op0 |= ((uint16_t)(in[3] * 255.00f) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 255.00f) & 0xff) << 0; + *op0 |= ((uint16_t)(in[1] * 255.00f) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((int16_t)(in[0] * 127.00f) & 0xff) << 0; + *op0 |= ((int16_t)(in[1] * 127.00f) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_G8R8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[1] * 255.00f) & 0xff) << 0; + *op0 |= ((uint16_t)(in[0] * 255.00f) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_G8R8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((int16_t)(in[1] * 127.00f) & 0xff) << 0; + *op0 |= ((int16_t)(in[0] * 127.00f) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= (((uint16_t)in[0]) & 0xff) << 0; + *op0 |= (((uint16_t)in[1]) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= (((int16_t)in[0]) & 0xff) << 0; + *op0 |= (((int16_t)in[1]) & 0xff) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)TinyImageFormat_FloatToSRGB((float)in[0])) << 0; + *op0 |= ((uint16_t)TinyImageFormat_FloatToSRGB((float)in[1])) << 8; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 65535.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((int16_t)(in[0] * 32767.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= (((uint16_t)in[0]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= (((int16_t)in[0]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)TinyImageFormat_FloatToHalfAsUint((float)in[0])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)TinyImageFormat_FloatToBFloatAsUint((float)in[0])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[0] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= ((uint8_t)(in[1] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= ((uint8_t)(in[2] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((int8_t)(in[0] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= ((int8_t)(in[1] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= ((int8_t)(in[2] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= (((uint8_t)in[0]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= (((uint8_t)in[1]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= (((uint8_t)in[2]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= (((int8_t)in[0]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= (((int8_t)in[1]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= (((int8_t)in[2]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[0])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[1])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[2])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)(in[2] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= ((uint8_t)(in[1] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= ((uint8_t)(in[0] * 255.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((int8_t)(in[2] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= ((int8_t)(in[1] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= ((int8_t)(in[0] * 127.00f) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= (((uint8_t)in[2]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= (((uint8_t)in[1]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= (((uint8_t)in[0]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= (((int8_t)in[2]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= (((int8_t)in[1]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= (((int8_t)in[0]) & 0xff) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + uint8_t* op0 = (uint8_t*)out->pixel; *op0 = 0; + *op0 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[2])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op1 = (uint8_t*)out->pixel; *op1 = 0; + *op1 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[1])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + uint8_t* op2 = (uint8_t*)out->pixel; *op2 = 0; + *op2 |= ((uint8_t)TinyImageFormat_FloatToSRGB((float)in[0])) << 0; + out->pixel = (void*)(((uint8_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[0] * 255.00f) & 0xff) << 0; + *op0 |= ((uint32_t)(in[1] * 255.00f) & 0xff) << 8; + *op0 |= ((uint32_t)(in[2] * 255.00f) & 0xff) << 16; + *op0 |= ((uint32_t)(in[3] * 255.00f) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8A8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[0] * 127.00f) & 0xff) << 0; + *op0 |= ((int32_t)(in[1] * 127.00f) & 0xff) << 8; + *op0 |= ((int32_t)(in[2] * 127.00f) & 0xff) << 16; + *op0 |= ((int32_t)(in[3] * 127.00f) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8A8_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[0]) & 0xff) << 0; + *op0 |= (((uint32_t)in[1]) & 0xff) << 8; + *op0 |= (((uint32_t)in[2]) & 0xff) << 16; + *op0 |= (((uint32_t)in[3]) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8A8_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[0]) & 0xff) << 0; + *op0 |= (((int32_t)in[1]) & 0xff) << 8; + *op0 |= (((int32_t)in[2]) & 0xff) << 16; + *op0 |= (((int32_t)in[3]) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8A8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToSRGB((float)in[0])) << 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToSRGB((float)in[1])) << 8; + *op0 |= ((uint32_t)TinyImageFormat_FloatToSRGB((float)in[2])) << 16; + *op0 |= ((uint32_t)(in[3] * 255.00f) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8A8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[2] * 255.00f) & 0xff) << 0; + *op0 |= ((uint32_t)(in[1] * 255.00f) & 0xff) << 8; + *op0 |= ((uint32_t)(in[0] * 255.00f) & 0xff) << 16; + *op0 |= ((uint32_t)(in[3] * 255.00f) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8A8_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[2] * 127.00f) & 0xff) << 0; + *op0 |= ((int32_t)(in[1] * 127.00f) & 0xff) << 8; + *op0 |= ((int32_t)(in[0] * 127.00f) & 0xff) << 16; + *op0 |= ((int32_t)(in[3] * 127.00f) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8A8_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[2]) & 0xff) << 0; + *op0 |= (((uint32_t)in[1]) & 0xff) << 8; + *op0 |= (((uint32_t)in[0]) & 0xff) << 16; + *op0 |= (((uint32_t)in[3]) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8A8_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[2]) & 0xff) << 0; + *op0 |= (((int32_t)in[1]) & 0xff) << 8; + *op0 |= (((int32_t)in[0]) & 0xff) << 16; + *op0 |= (((int32_t)in[3]) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8A8_SRGB: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToSRGB((float)in[2])) << 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToSRGB((float)in[1])) << 8; + *op0 |= ((uint32_t)TinyImageFormat_FloatToSRGB((float)in[0])) << 16; + *op0 |= ((uint32_t)(in[3] * 255.00f) & 0xff) << 24; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R8G8B8X8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[0] * 255.00f) & 0xff) << 0; + *op0 |= ((uint32_t)(in[1] * 255.00f) & 0xff) << 8; + *op0 |= ((uint32_t)(in[2] * 255.00f) & 0xff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B8G8R8X8_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[2] * 255.00f) & 0xff) << 0; + *op0 |= ((uint32_t)(in[1] * 255.00f) & 0xff) << 8; + *op0 |= ((uint32_t)(in[0] * 255.00f) & 0xff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[0] * 65535.00f) & 0xffff) << 0; + *op0 |= ((uint32_t)(in[1] * 65535.00f) & 0xffff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_G16R16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[1] * 65535.00f) & 0xffff) << 0; + *op0 |= ((uint32_t)(in[0] * 65535.00f) & 0xffff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[0] * 32767.00f) & 0xffff) << 0; + *op0 |= ((int32_t)(in[1] * 32767.00f) & 0xffff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_G16R16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[1] * 32767.00f) & 0xffff) << 0; + *op0 |= ((int32_t)(in[0] * 32767.00f) & 0xffff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[0]) & 0xffff) << 0; + *op0 |= (((uint32_t)in[1]) & 0xffff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[0]) & 0xffff) << 0; + *op0 |= (((int32_t)in[1]) & 0xffff) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToHalfAsUint((float)in[0])) << 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToHalfAsUint((float)in[1])) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToBFloatAsUint((float)in[0])) << 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToBFloatAsUint((float)in[1])) << 16; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[0]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[0]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + float in0 = (float)in[0]; + *op0 |= ((uint32_t)*((uint32_t*)&in0)) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[3] * 3.00f) & 0x3) << 0; + *op0 |= ((uint32_t)(in[0] * 1023.00f) & 0x3ff) << 2; + *op0 |= ((uint32_t)(in[1] * 1023.00f) & 0x3ff) << 12; + *op0 |= ((uint32_t)(in[2] * 1023.00f) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[3]) & 0x3) << 0; + *op0 |= (((uint32_t)in[0]) & 0x3ff) << 2; + *op0 |= (((uint32_t)in[1]) & 0x3ff) << 12; + *op0 |= (((uint32_t)in[2]) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[3] * 1.00f) & 0x3) << 0; + *op0 |= ((int32_t)(in[0] * 511.00f) & 0x3ff) << 2; + *op0 |= ((int32_t)(in[1] * 511.00f) & 0x3ff) << 12; + *op0 |= ((int32_t)(in[2] * 511.00f) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2R10G10B10_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[3]) & 0x3) << 0; + *op0 |= (((int32_t)in[0]) & 0x3ff) << 2; + *op0 |= (((int32_t)in[1]) & 0x3ff) << 12; + *op0 |= (((int32_t)in[2]) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[3] * 3.00f) & 0x3) << 0; + *op0 |= ((uint32_t)(in[2] * 1023.00f) & 0x3ff) << 2; + *op0 |= ((uint32_t)(in[1] * 1023.00f) & 0x3ff) << 12; + *op0 |= ((uint32_t)(in[0] * 1023.00f) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[3]) & 0x3) << 0; + *op0 |= (((uint32_t)in[2]) & 0x3ff) << 2; + *op0 |= (((uint32_t)in[1]) & 0x3ff) << 12; + *op0 |= (((uint32_t)in[0]) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[3] * 1.00f) & 0x3) << 0; + *op0 |= ((int32_t)(in[2] * 511.00f) & 0x3ff) << 2; + *op0 |= ((int32_t)(in[1] * 511.00f) & 0x3ff) << 12; + *op0 |= ((int32_t)(in[0] * 511.00f) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_A2B10G10R10_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[3]) & 0x3) << 0; + *op0 |= (((int32_t)in[2]) & 0x3ff) << 2; + *op0 |= (((int32_t)in[1]) & 0x3ff) << 12; + *op0 |= (((int32_t)in[0]) & 0x3ff) << 22; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[0] * 1023.00f) & 0x3ff) << 0; + *op0 |= ((uint32_t)(in[1] * 1023.00f) & 0x3ff) << 10; + *op0 |= ((uint32_t)(in[2] * 1023.00f) & 0x3ff) << 20; + *op0 |= ((uint32_t)(in[3] * 3.00f) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[0]) & 0x3ff) << 0; + *op0 |= (((uint32_t)in[1]) & 0x3ff) << 10; + *op0 |= (((uint32_t)in[2]) & 0x3ff) << 20; + *op0 |= (((uint32_t)in[3]) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[0] * 511.00f) & 0x3ff) << 0; + *op0 |= ((int32_t)(in[1] * 511.00f) & 0x3ff) << 10; + *op0 |= ((int32_t)(in[2] * 511.00f) & 0x3ff) << 20; + *op0 |= ((int32_t)(in[3] * 1.00f) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R10G10B10A2_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[0]) & 0x3ff) << 0; + *op0 |= (((int32_t)in[1]) & 0x3ff) << 10; + *op0 |= (((int32_t)in[2]) & 0x3ff) << 20; + *op0 |= (((int32_t)in[3]) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)(in[2] * 1023.00f) & 0x3ff) << 0; + *op0 |= ((uint32_t)(in[1] * 1023.00f) & 0x3ff) << 10; + *op0 |= ((uint32_t)(in[0] * 1023.00f) & 0x3ff) << 20; + *op0 |= ((uint32_t)(in[3] * 3.00f) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[2]) & 0x3ff) << 0; + *op0 |= (((uint32_t)in[1]) & 0x3ff) << 10; + *op0 |= (((uint32_t)in[0]) & 0x3ff) << 20; + *op0 |= (((uint32_t)in[3]) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((int32_t)(in[2] * 511.00f) & 0x3ff) << 0; + *op0 |= ((int32_t)(in[1] * 511.00f) & 0x3ff) << 10; + *op0 |= ((int32_t)(in[0] * 511.00f) & 0x3ff) << 20; + *op0 |= ((int32_t)(in[3] * 1.00f) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B10G10R10A2_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[2]) & 0x3ff) << 0; + *op0 |= (((int32_t)in[1]) & 0x3ff) << 10; + *op0 |= (((int32_t)in[0]) & 0x3ff) << 20; + *op0 |= (((int32_t)in[3]) & 0x3) << 30; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_B10G11R11_UFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToUFloat10AsUint((float)in[2])) << 0; + *op0 |= ((uint32_t)TinyImageFormat_FloatToUFloat11AsUint((float)in[1])) << 10; + *op0 |= ((uint32_t)TinyImageFormat_FloatToUFloat11AsUint((float)in[0])) << 21; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_E5B9G9R9_UFLOAT: + for(uint32_t w = 0; w < width; ++w) { + TinyImageFormat_FloatRGBToRGB9E5AsUint32( (float const*)in, (uint32_t*)out->pixel); + out->pixel = (void const*)(((uint32_t const*)out->pixel) + 1); + in += 4; + } + return true; + case TinyImageFormat_R16G16B16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)(in[0] * 65535.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)(in[1] * 65535.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op2 = (uint16_t*)out->pixel; *op2 = 0; + *op2 |= ((uint16_t)(in[2] * 65535.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((int16_t)(in[0] * 32767.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((int16_t)(in[1] * 32767.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op2 = (uint16_t*)out->pixel; *op2 = 0; + *op2 |= ((int16_t)(in[2] * 32767.00f) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= (((uint16_t)in[0]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= (((uint16_t)in[1]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op2 = (uint16_t*)out->pixel; *op2 = 0; + *op2 |= (((uint16_t)in[2]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= (((int16_t)in[0]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= (((int16_t)in[1]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op2 = (uint16_t*)out->pixel; *op2 = 0; + *op2 |= (((int16_t)in[2]) & 0xffff) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)TinyImageFormat_FloatToHalfAsUint((float)in[0])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)TinyImageFormat_FloatToHalfAsUint((float)in[1])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op2 = (uint16_t*)out->pixel; *op2 = 0; + *op2 |= ((uint16_t)TinyImageFormat_FloatToHalfAsUint((float)in[2])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint16_t* op0 = (uint16_t*)out->pixel; *op0 = 0; + *op0 |= ((uint16_t)TinyImageFormat_FloatToBFloatAsUint((float)in[0])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op1 = (uint16_t*)out->pixel; *op1 = 0; + *op1 |= ((uint16_t)TinyImageFormat_FloatToBFloatAsUint((float)in[1])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + uint16_t* op2 = (uint16_t*)out->pixel; *op2 = 0; + *op2 |= ((uint16_t)TinyImageFormat_FloatToBFloatAsUint((float)in[2])) << 0; + out->pixel = (void*)(((uint16_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16A16_UNORM: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= ((uint64_t)(in[0] * 65535.00f) & 0xffff) << 0; + *op0 |= ((uint64_t)(in[1] * 65535.00f) & 0xffff) << 16; + *op0 |= ((uint64_t)(in[2] * 65535.00f) & 0xffff) << 32; + *op0 |= ((uint64_t)(in[3] * 65535.00f) & 0xffff) << 48; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16A16_SNORM: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= ((int64_t)(in[0] * 32767.00f) & 0xffff) << 0; + *op0 |= ((int64_t)(in[1] * 32767.00f) & 0xffff) << 16; + *op0 |= ((int64_t)(in[2] * 32767.00f) & 0xffff) << 32; + *op0 |= ((int64_t)(in[3] * 32767.00f) & 0xffff) << 48; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16A16_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0xffff) << 0; + *op0 |= (((uint64_t)in[1]) & 0xffff) << 16; + *op0 |= (((uint64_t)in[2]) & 0xffff) << 32; + *op0 |= (((uint64_t)in[3]) & 0xffff) << 48; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16A16_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0xffff) << 0; + *op0 |= (((int64_t)in[1]) & 0xffff) << 16; + *op0 |= (((int64_t)in[2]) & 0xffff) << 32; + *op0 |= (((int64_t)in[3]) & 0xffff) << 48; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16A16_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= ((uint64_t)TinyImageFormat_FloatToHalfAsUint((float)in[0])) << 0; + *op0 |= ((uint64_t)TinyImageFormat_FloatToHalfAsUint((float)in[1])) << 16; + *op0 |= ((uint64_t)TinyImageFormat_FloatToHalfAsUint((float)in[2])) << 32; + *op0 |= ((uint64_t)TinyImageFormat_FloatToHalfAsUint((float)in[3])) << 48; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R16G16B16A16_SBFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= ((uint64_t)TinyImageFormat_FloatToBFloatAsUint((float)in[0])) << 0; + *op0 |= ((uint64_t)TinyImageFormat_FloatToBFloatAsUint((float)in[1])) << 16; + *op0 |= ((uint64_t)TinyImageFormat_FloatToBFloatAsUint((float)in[2])) << 32; + *op0 |= ((uint64_t)TinyImageFormat_FloatToBFloatAsUint((float)in[3])) << 48; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0xffffffff) << 0; + *op0 |= (((uint64_t)in[1]) & 0xffffffff) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0xffffffff) << 0; + *op0 |= (((int64_t)in[1]) & 0xffffffff) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + float in0 = (float)in[0]; + *op0 |= ((uint64_t)*((uint32_t*)&in0)) << 0; + float in1 = (float)in[1]; + *op0 |= ((uint64_t)*((uint32_t*)&in1)) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32B32_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((uint32_t)in[0]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + uint32_t* op1 = (uint32_t*)out->pixel; *op1 = 0; + *op1 |= (((uint32_t)in[1]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + uint32_t* op2 = (uint32_t*)out->pixel; *op2 = 0; + *op2 |= (((uint32_t)in[2]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32B32_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + *op0 |= (((int32_t)in[0]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + uint32_t* op1 = (uint32_t*)out->pixel; *op1 = 0; + *op1 |= (((int32_t)in[1]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + uint32_t* op2 = (uint32_t*)out->pixel; *op2 = 0; + *op2 |= (((int32_t)in[2]) & 0xffffffff) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32B32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint32_t* op0 = (uint32_t*)out->pixel; *op0 = 0; + float in0 = (float)in[0]; + *op0 |= ((uint32_t)*((uint32_t*)&in0)) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + uint32_t* op1 = (uint32_t*)out->pixel; *op1 = 0; + float in1 = (float)in[1]; + *op1 |= ((uint32_t)*((uint32_t*)&in1)) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + uint32_t* op2 = (uint32_t*)out->pixel; *op2 = 0; + float in2 = (float)in[2]; + *op2 |= ((uint32_t)*((uint32_t*)&in2)) << 0; + out->pixel = (void*)(((uint32_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32B32A32_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0xffffffff) << 0; + *op0 |= (((uint64_t)in[1]) & 0xffffffff) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + *op2 |= (((uint64_t)in[2]) & 0xffffffff) << 0; + *op2 |= (((uint64_t)in[3]) & 0xffffffff) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32B32A32_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0xffffffff) << 0; + *op0 |= (((int64_t)in[1]) & 0xffffffff) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + *op2 |= (((int64_t)in[2]) & 0xffffffff) << 0; + *op2 |= (((int64_t)in[3]) & 0xffffffff) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R32G32B32A32_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + float in0 = (float)in[0]; + *op0 |= ((uint64_t)*((uint32_t*)&in0)) << 0; + float in1 = (float)in[1]; + *op0 |= ((uint64_t)*((uint32_t*)&in1)) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + float in2 = (float)in[2]; + *op2 |= ((uint64_t)*((uint32_t*)&in2)) << 0; + float in3 = (float)in[3]; + *op2 |= ((uint64_t)*((uint32_t*)&in3)) << 32; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_CanEncodeLogicalPixelsD(TinyImageFormat const fmt) { + switch(fmt) { + case TinyImageFormat_R64_UINT: return true; + case TinyImageFormat_R64_SINT: return true; + case TinyImageFormat_R64_SFLOAT: return true; + case TinyImageFormat_R64G64_UINT: return true; + case TinyImageFormat_R64G64_SINT: return true; + case TinyImageFormat_R64G64_SFLOAT: return true; + case TinyImageFormat_R64G64B64_UINT: return true; + case TinyImageFormat_R64G64B64_SINT: return true; + case TinyImageFormat_R64G64B64_SFLOAT: return true; + case TinyImageFormat_R64G64B64A64_UINT: return true; + case TinyImageFormat_R64G64B64A64_SINT: return true; + case TinyImageFormat_R64G64B64A64_SFLOAT: return true; + default: return TinyImageFormat_CanEncodeLogicalPixelsF(fmt); + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_EncodeLogicalPixelsD(TinyImageFormat const fmt, double const *in, uint32_t const width, TinyImageFormat_EncodeOutput * out) { + switch(fmt) { + case TinyImageFormat_R64_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + double in0 = (double)in[0]; + *op0 |= ((uint64_t)*((uint64_t*)&in0)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + *op1 |= (((uint64_t)in[1]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + *op1 |= (((int64_t)in[1]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + double in0 = (double)in[0]; + *op0 |= ((uint64_t)*((uint64_t*)&in0)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + double in1 = (double)in[1]; + *op1 |= ((uint64_t)*((uint64_t*)&in1)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64B64_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + *op1 |= (((uint64_t)in[1]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + *op2 |= (((uint64_t)in[2]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64B64_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + *op1 |= (((int64_t)in[1]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + *op2 |= (((int64_t)in[2]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64B64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + double in0 = (double)in[0]; + *op0 |= ((uint64_t)*((uint64_t*)&in0)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + double in1 = (double)in[1]; + *op1 |= ((uint64_t)*((uint64_t*)&in1)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + double in2 = (double)in[2]; + *op2 |= ((uint64_t)*((uint64_t*)&in2)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64B64A64_UINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((uint64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + *op1 |= (((uint64_t)in[1]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + *op2 |= (((uint64_t)in[2]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op3 = (uint64_t*)out->pixel; *op3 = 0; + *op3 |= (((uint64_t)in[3]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64B64A64_SINT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + *op0 |= (((int64_t)in[0]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + *op1 |= (((int64_t)in[1]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + *op2 |= (((int64_t)in[2]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op3 = (uint64_t*)out->pixel; *op3 = 0; + *op3 |= (((int64_t)in[3]) & 0x0) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + case TinyImageFormat_R64G64B64A64_SFLOAT: + for(uint32_t w = 0; w < width; ++w) { + uint64_t* op0 = (uint64_t*)out->pixel; *op0 = 0; + double in0 = (double)in[0]; + *op0 |= ((uint64_t)*((uint64_t*)&in0)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op1 = (uint64_t*)out->pixel; *op1 = 0; + double in1 = (double)in[1]; + *op1 |= ((uint64_t)*((uint64_t*)&in1)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op2 = (uint64_t*)out->pixel; *op2 = 0; + double in2 = (double)in[2]; + *op2 |= ((uint64_t)*((uint64_t*)&in2)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + uint64_t* op3 = (uint64_t*)out->pixel; *op3 = 0; + double in3 = (double)in[3]; + *op3 |= ((uint64_t)*((uint64_t*)&in3)) << 0; + out->pixel = (void*)(((uint64_t*)out->pixel) + 1); + in+=4; + } + return true; + default: + { + bool ret = true; + for(uint32_t w = 0; w < width && ret; ++w) { + float inF[4] = {(float)in[0], (float)in[1], (float)in[2], (float)in[3]}; + ret = TinyImageFormat_EncodeLogicalPixelsF(fmt, inF, 1, out); + in += 4; + } + return ret; + } + } +} + +#undef TIF_CONSTEXPR +#endif // TINYIMAGEFORMAT_ENCODE_H_ + diff --git a/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_query.h b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_query.h new file mode 100644 index 0000000..5c678ba --- /dev/null +++ b/engine/modules/engine/render/3rdparty/tinyimageformat/tinyimageformat_query.h @@ -0,0 +1,4217 @@ +// Auto generated by formatgen on Sep 21 2019 +#pragma once +#if !defined(TINYIMAGEFORMAT_QUERY_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) +#define TINYIMAGEFORMAT_QUERY_H_ 1 + +#include "tinyimageformat_base.h" + +#if __cplusplus > 201402L +#define TIF_CONSTEXPR constexpr +#else +#define TIF_CONSTEXPR +#endif +#ifndef TinyImageFormat_HAVE_UINTXX_T +#include // for uint32_t and int64_t +#endif +#ifndef TinyImageFormat_HAVE_BOOL +#include // for bool +#endif +#ifndef TinyImageFormat_HAVE_POWF +#include // for powf +#endif +//TinyImageFormat_ASSERT needs to be constexpr on some platforms +#ifndef TinyImageFormat_ASSERT +#define TinyImageFormat_ASSERT(x) +#endif + +TIF_CONSTEXPR inline uint64_t TinyImageFormat_Code(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0x0000000000000000; + case TinyImageFormat_R1_UNORM: return 0x0000D9000000C000; + case TinyImageFormat_R2_UNORM: return 0x0000D90000013000; + case TinyImageFormat_R4_UNORM: return 0x0000D90000022000; + case TinyImageFormat_R4G4_UNORM: return 0x0008D84000421000; + case TinyImageFormat_G4R4_UNORM: return 0x0008D80800421000; + case TinyImageFormat_A8_UNORM: return 0x0000C91800040000; + case TinyImageFormat_R8_UNORM: return 0x0000D90000040000; + case TinyImageFormat_R8_SNORM: return 0x0001590000040000; + case TinyImageFormat_R8_UINT: return 0x0001D90000040000; + case TinyImageFormat_R8_SINT: return 0x0002590000040000; + case TinyImageFormat_R8_SRGB: return 0x0003D90000040000; + case TinyImageFormat_B2G3R3_UNORM: return 0x0088D05006311000; + case TinyImageFormat_R4G4B4A4_UNORM: return 0x0888B44108421000; + case TinyImageFormat_R4G4B4X4_UNORM: return 0x0888D44108421000; + case TinyImageFormat_B4G4R4A4_UNORM: return 0x0888B05108421000; + case TinyImageFormat_B4G4R4X4_UNORM: return 0x0888D05108421000; + case TinyImageFormat_A4R4G4B4_UNORM: return 0x0888A21908421000; + case TinyImageFormat_X4R4G4B4_UNORM: return 0x0889A22908421000; + case TinyImageFormat_A4B4G4R4_UNORM: return 0x0888829908421000; + case TinyImageFormat_X4B4G4R4_UNORM: return 0x088982A908421000; + case TinyImageFormat_R5G6B5_UNORM: return 0x0088D4400A629000; + case TinyImageFormat_B5G6R5_UNORM: return 0x0088D0500A629000; + case TinyImageFormat_R5G5B5A1_UNORM: return 0x0888B4404A529000; + case TinyImageFormat_B5G5R5A1_UNORM: return 0x0888B0504A529000; + case TinyImageFormat_A1B5G5R5_UNORM: return 0x088882994A509000; + case TinyImageFormat_A1R5G5B5_UNORM: return 0x0888A2194A509000; + case TinyImageFormat_R5G5B5X1_UNORM: return 0x1888D4404A529000; + case TinyImageFormat_B5G5R5X1_UNORM: return 0x1888D0504A529000; + case TinyImageFormat_X1R5G5B5_UNORM: return 0x0889A2294A509000; + case TinyImageFormat_X1B5G5R5_UNORM: return 0x088982A94A509000; + case TinyImageFormat_B2G3R3A8_UNORM: return 0x0888B05206311000; + case TinyImageFormat_R8G8_UNORM: return 0x0008D84000840000; + case TinyImageFormat_R8G8_SNORM: return 0x0011584000840000; + case TinyImageFormat_G8R8_UNORM: return 0x0008D80800840000; + case TinyImageFormat_G8R8_SNORM: return 0x0011580800840000; + case TinyImageFormat_R8G8_UINT: return 0x0019D84000840000; + case TinyImageFormat_R8G8_SINT: return 0x0022584000840000; + case TinyImageFormat_R8G8_SRGB: return 0x003BD84000840000; + case TinyImageFormat_R16_UNORM: return 0x0000D90000068000; + case TinyImageFormat_R16_SNORM: return 0x0001590000068000; + case TinyImageFormat_R16_UINT: return 0x0001D90000068000; + case TinyImageFormat_R16_SINT: return 0x0002590000068000; + case TinyImageFormat_R16_SFLOAT: return 0x0003590000068000; + case TinyImageFormat_R16_SBFLOAT: return 0x0004590000068000; + case TinyImageFormat_R8G8B8_UNORM: return 0x0088D44010840000; + case TinyImageFormat_R8G8B8_SNORM: return 0x0111544010840000; + case TinyImageFormat_R8G8B8_UINT: return 0x0199D44010840000; + case TinyImageFormat_R8G8B8_SINT: return 0x0222544010840000; + case TinyImageFormat_R8G8B8_SRGB: return 0x03BBD44010840000; + case TinyImageFormat_B8G8R8_UNORM: return 0x0088D05010840000; + case TinyImageFormat_B8G8R8_SNORM: return 0x0111505010840000; + case TinyImageFormat_B8G8R8_UINT: return 0x0199D05010840000; + case TinyImageFormat_B8G8R8_SINT: return 0x0222505010840000; + case TinyImageFormat_B8G8R8_SRGB: return 0x03BBD05010840000; + case TinyImageFormat_R8G8B8A8_UNORM: return 0x0888B44210840000; + case TinyImageFormat_R8G8B8A8_SNORM: return 0x1111344210840000; + case TinyImageFormat_R8G8B8A8_UINT: return 0x1999B44210840000; + case TinyImageFormat_R8G8B8A8_SINT: return 0x2222344210840000; + case TinyImageFormat_R8G8B8A8_SRGB: return 0x0BBBB44210840000; + case TinyImageFormat_B8G8R8A8_UNORM: return 0x0888B05210840000; + case TinyImageFormat_B8G8R8A8_SNORM: return 0x1111305210840000; + case TinyImageFormat_B8G8R8A8_UINT: return 0x1999B05210840000; + case TinyImageFormat_B8G8R8A8_SINT: return 0x2222305210840000; + case TinyImageFormat_B8G8R8A8_SRGB: return 0x0BBBB05210840000; + case TinyImageFormat_R8G8B8X8_UNORM: return 0x0888D44210840000; + case TinyImageFormat_B8G8R8X8_UNORM: return 0x0888D05210840000; + case TinyImageFormat_R16G16_UNORM: return 0x0008D84000D68000; + case TinyImageFormat_G16R16_UNORM: return 0x0008D80800D68000; + case TinyImageFormat_R16G16_SNORM: return 0x0011584000D68000; + case TinyImageFormat_G16R16_SNORM: return 0x0011580800D68000; + case TinyImageFormat_R16G16_UINT: return 0x0019D84000D68000; + case TinyImageFormat_R16G16_SINT: return 0x0022584000D68000; + case TinyImageFormat_R16G16_SFLOAT: return 0x0033584000D68000; + case TinyImageFormat_R16G16_SBFLOAT: return 0x0044584000D68000; + case TinyImageFormat_R32_UINT: return 0x0001D90000078000; + case TinyImageFormat_R32_SINT: return 0x0002590000078000; + case TinyImageFormat_R32_SFLOAT: return 0x0003590000078000; + case TinyImageFormat_A2R10G10B10_UNORM: return 0x0888A21A94A11000; + case TinyImageFormat_A2R10G10B10_UINT: return 0x1999A21A94A11000; + case TinyImageFormat_A2R10G10B10_SNORM: return 0x1111221A94A11000; + case TinyImageFormat_A2R10G10B10_SINT: return 0x2222221A94A11000; + case TinyImageFormat_A2B10G10R10_UNORM: return 0x0888829A94A11000; + case TinyImageFormat_A2B10G10R10_UINT: return 0x1999829A94A11000; + case TinyImageFormat_A2B10G10R10_SNORM: return 0x1111029A94A11000; + case TinyImageFormat_A2B10G10R10_SINT: return 0x2222029A94A11000; + case TinyImageFormat_R10G10B10A2_UNORM: return 0x0888B44094A51000; + case TinyImageFormat_R10G10B10A2_UINT: return 0x1999B44094A51000; + case TinyImageFormat_R10G10B10A2_SNORM: return 0x1111344094A51000; + case TinyImageFormat_R10G10B10A2_SINT: return 0x2222344094A51000; + case TinyImageFormat_B10G10R10A2_UNORM: return 0x0888B05094A51000; + case TinyImageFormat_B10G10R10A2_UINT: return 0x1999B05094A51000; + case TinyImageFormat_B10G10R10A2_SNORM: return 0x1111305094A51000; + case TinyImageFormat_B10G10R10A2_SINT: return 0x2222305094A51000; + case TinyImageFormat_B10G11R11_UFLOAT: return 0x02AAD05016B51000; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 0x2AA9829A52929000; + case TinyImageFormat_R16G16B16_UNORM: return 0x0088D4401AD68000; + case TinyImageFormat_R16G16B16_SNORM: return 0x011154401AD68000; + case TinyImageFormat_R16G16B16_UINT: return 0x0199D4401AD68000; + case TinyImageFormat_R16G16B16_SINT: return 0x022254401AD68000; + case TinyImageFormat_R16G16B16_SFLOAT: return 0x033354401AD68000; + case TinyImageFormat_R16G16B16_SBFLOAT: return 0x044454401AD68000; + case TinyImageFormat_R16G16B16A16_UNORM: return 0x0888B4435AD68000; + case TinyImageFormat_R16G16B16A16_SNORM: return 0x111134435AD68000; + case TinyImageFormat_R16G16B16A16_UINT: return 0x1999B4435AD68000; + case TinyImageFormat_R16G16B16A16_SINT: return 0x222234435AD68000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 0x333334435AD68000; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 0x444434435AD68000; + case TinyImageFormat_R32G32_UINT: return 0x0019D84000F78000; + case TinyImageFormat_R32G32_SINT: return 0x0022584000F78000; + case TinyImageFormat_R32G32_SFLOAT: return 0x0033584000F78000; + case TinyImageFormat_R32G32B32_UINT: return 0x0199D4401EF78000; + case TinyImageFormat_R32G32B32_SINT: return 0x022254401EF78000; + case TinyImageFormat_R32G32B32_SFLOAT: return 0x033354401EF78000; + case TinyImageFormat_R32G32B32A32_UINT: return 0x1999B443DEF78000; + case TinyImageFormat_R32G32B32A32_SINT: return 0x22223443DEF78000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 0x33333443DEF78000; + case TinyImageFormat_R64_UINT: return 0x0001D90000080000; + case TinyImageFormat_R64_SINT: return 0x0002590000080000; + case TinyImageFormat_R64_SFLOAT: return 0x0003590000080000; + case TinyImageFormat_R64G64_UINT: return 0x0019D84001080000; + case TinyImageFormat_R64G64_SINT: return 0x0022584001080000; + case TinyImageFormat_R64G64_SFLOAT: return 0x0033584001080000; + case TinyImageFormat_R64G64B64_UINT: return 0x0199D44021080000; + case TinyImageFormat_R64G64B64_SINT: return 0x0222544021080000; + case TinyImageFormat_R64G64B64_SFLOAT: return 0x0333544021080000; + case TinyImageFormat_R64G64B64A64_UINT: return 0x1999B44421080000; + case TinyImageFormat_R64G64B64A64_SINT: return 0x2222344421080000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 0x3333344421080000; + case TinyImageFormat_D16_UNORM: return 0x0000000001809001; + case TinyImageFormat_X8_D24_UNORM: return 0x0000000006266001; + case TinyImageFormat_D32_SFLOAT: return 0x0000000003812001; + case TinyImageFormat_S8_UINT: return 0x0000000002904001; + case TinyImageFormat_D16_UNORM_S8_UINT: return 0x000000000942A001; + case TinyImageFormat_D24_UNORM_S8_UINT: return 0x000000000942E001; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 0x000000000B433001; + case TinyImageFormat_DXBC1_RGB_UNORM: return 0x0000000000100002; + case TinyImageFormat_DXBC1_RGB_SRGB: return 0x0000000000108002; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 0x0000000000181002; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 0x0000000000189002; + case TinyImageFormat_DXBC2_UNORM: return 0x00000000001A3002; + case TinyImageFormat_DXBC2_SRGB: return 0x00000000001AB002; + case TinyImageFormat_DXBC3_UNORM: return 0x00000000001A2002; + case TinyImageFormat_DXBC3_SRGB: return 0x00000000001AA002; + case TinyImageFormat_DXBC4_UNORM: return 0x0000000000000002; + case TinyImageFormat_DXBC4_SNORM: return 0x0000000000004002; + case TinyImageFormat_DXBC5_UNORM: return 0x00000000000A0002; + case TinyImageFormat_DXBC5_SNORM: return 0x00000000000A4002; + case TinyImageFormat_DXBC6H_UFLOAT: return 0x0000000000530002; + case TinyImageFormat_DXBC6H_SFLOAT: return 0x000000000052C002; + case TinyImageFormat_DXBC7_UNORM: return 0x00000000003A3002; + case TinyImageFormat_DXBC7_SRGB: return 0x00000000003AB002; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return 0x0000000000000003; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return 0x0000000000004003; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return 0x0000000000001003; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return 0x0000000000005003; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return 0x0000000000010003; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return 0x0000000000014003; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return 0x0000000000011003; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return 0x0000000000015003; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return 0x0000000000080004; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return 0x00000000000A0004; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return 0x00000000000C4004; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return 0x00000000000E4004; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return 0x00000000000C8004; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return 0x00000000000E8004; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 0x0000000000001004; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 0x0000000000011004; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 0x0000000000041004; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 0x0000000000051004; + case TinyImageFormat_ASTC_4x4_UNORM: return 0x0000000000012005; + case TinyImageFormat_ASTC_4x4_SRGB: return 0x0000000000212005; + case TinyImageFormat_ASTC_5x4_UNORM: return 0x0000000000013005; + case TinyImageFormat_ASTC_5x4_SRGB: return 0x0000000000213005; + case TinyImageFormat_ASTC_5x5_UNORM: return 0x000000000001B005; + case TinyImageFormat_ASTC_5x5_SRGB: return 0x000000000021B005; + case TinyImageFormat_ASTC_6x5_UNORM: return 0x000000000001C005; + case TinyImageFormat_ASTC_6x5_SRGB: return 0x000000000021C005; + case TinyImageFormat_ASTC_6x6_UNORM: return 0x0000000000024005; + case TinyImageFormat_ASTC_6x6_SRGB: return 0x0000000000224005; + case TinyImageFormat_ASTC_8x5_UNORM: return 0x000000000001D005; + case TinyImageFormat_ASTC_8x5_SRGB: return 0x000000000021D005; + case TinyImageFormat_ASTC_8x6_UNORM: return 0x0000000000025005; + case TinyImageFormat_ASTC_8x6_SRGB: return 0x0000000000225005; + case TinyImageFormat_ASTC_8x8_UNORM: return 0x000000000002D005; + case TinyImageFormat_ASTC_8x8_SRGB: return 0x000000000022D005; + case TinyImageFormat_ASTC_10x5_UNORM: return 0x000000000001E005; + case TinyImageFormat_ASTC_10x5_SRGB: return 0x000000000021E005; + case TinyImageFormat_ASTC_10x6_UNORM: return 0x0000000000026005; + case TinyImageFormat_ASTC_10x6_SRGB: return 0x0000000000226005; + case TinyImageFormat_ASTC_10x8_UNORM: return 0x000000000002E005; + case TinyImageFormat_ASTC_10x8_SRGB: return 0x000000000022E005; + case TinyImageFormat_ASTC_10x10_UNORM: return 0x0000000000036005; + case TinyImageFormat_ASTC_10x10_SRGB: return 0x0000000000236005; + case TinyImageFormat_ASTC_12x10_UNORM: return 0x0000000000037005; + case TinyImageFormat_ASTC_12x10_SRGB: return 0x0000000000237005; + case TinyImageFormat_ASTC_12x12_UNORM: return 0x000000000003F005; + case TinyImageFormat_ASTC_12x12_SRGB: return 0x000000000023F005; + case TinyImageFormat_CLUT_P4: return 0x000000000010D006; + case TinyImageFormat_CLUT_P4A4: return 0x0000000000D6C006; + case TinyImageFormat_CLUT_P8: return 0x0000000000110006; + case TinyImageFormat_CLUT_P8A8: return 0x0000000000D90006; + default: return 0ULL; + } +} + +#define TinyImageFormat_MaxPixelCountOfBlock 144U + +TIF_CONSTEXPR inline bool TinyImageFormat_IsDepthOnly(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_D16_UNORM: return true; + case TinyImageFormat_X8_D24_UNORM: return true; + case TinyImageFormat_D32_SFLOAT: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsStencilOnly(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_S8_UINT: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsDepthAndStencil(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_D16_UNORM_S8_UINT: return true; + case TinyImageFormat_D24_UNORM_S8_UINT: return true; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_HasDepth(TinyImageFormat const fmt) +{ + return TinyImageFormat_IsDepthOnly(fmt) || TinyImageFormat_IsDepthAndStencil(fmt); +} + +TIF_CONSTEXPR inline bool TinyImageFormat_HasStencil(TinyImageFormat const fmt) +{ + return TinyImageFormat_IsStencilOnly(fmt) || TinyImageFormat_IsDepthAndStencil(fmt); +} + +TIF_CONSTEXPR inline bool TinyImageFormat_HasDepthOrStencil(TinyImageFormat const fmt) +{ + return TinyImageFormat_IsDepthOnly(fmt) || TinyImageFormat_IsStencilOnly(fmt) || TinyImageFormat_IsDepthAndStencil(fmt); +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCLUT(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_CLUT_P4: return true; + case TinyImageFormat_CLUT_P4A4: return true; + case TinyImageFormat_CLUT_P8: return true; + case TinyImageFormat_CLUT_P8A8: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsFloat(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_R16_SFLOAT: return true; + case TinyImageFormat_R16_SBFLOAT: return true; + case TinyImageFormat_R16G16_SFLOAT: return true; + case TinyImageFormat_R16G16_SBFLOAT: return true; + case TinyImageFormat_R32_SFLOAT: return true; + case TinyImageFormat_B10G11R11_UFLOAT: return true; + case TinyImageFormat_E5B9G9R9_UFLOAT: return true; + case TinyImageFormat_R16G16B16_SFLOAT: return true; + case TinyImageFormat_R16G16B16_SBFLOAT: return true; + case TinyImageFormat_R16G16B16A16_SFLOAT: return true; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return true; + case TinyImageFormat_R32G32_SFLOAT: return true; + case TinyImageFormat_R32G32B32_SFLOAT: return true; + case TinyImageFormat_R32G32B32A32_SFLOAT: return true; + case TinyImageFormat_R64_SFLOAT: return true; + case TinyImageFormat_R64G64_SFLOAT: return true; + case TinyImageFormat_R64G64B64_SFLOAT: return true; + case TinyImageFormat_R64G64B64A64_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return true; + case TinyImageFormat_DXBC6H_UFLOAT: return true; + case TinyImageFormat_DXBC6H_SFLOAT: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsNormalised(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_R1_UNORM: return true; + case TinyImageFormat_R2_UNORM: return true; + case TinyImageFormat_R4_UNORM: return true; + case TinyImageFormat_R4G4_UNORM: return true; + case TinyImageFormat_G4R4_UNORM: return true; + case TinyImageFormat_A8_UNORM: return true; + case TinyImageFormat_R8_UNORM: return true; + case TinyImageFormat_R8_SNORM: return true; + case TinyImageFormat_R8_SRGB: return true; + case TinyImageFormat_B2G3R3_UNORM: return true; + case TinyImageFormat_R4G4B4A4_UNORM: return true; + case TinyImageFormat_R4G4B4X4_UNORM: return true; + case TinyImageFormat_B4G4R4A4_UNORM: return true; + case TinyImageFormat_B4G4R4X4_UNORM: return true; + case TinyImageFormat_A4R4G4B4_UNORM: return true; + case TinyImageFormat_X4R4G4B4_UNORM: return true; + case TinyImageFormat_A4B4G4R4_UNORM: return true; + case TinyImageFormat_X4B4G4R4_UNORM: return true; + case TinyImageFormat_R5G6B5_UNORM: return true; + case TinyImageFormat_B5G6R5_UNORM: return true; + case TinyImageFormat_R5G5B5A1_UNORM: return true; + case TinyImageFormat_B5G5R5A1_UNORM: return true; + case TinyImageFormat_A1B5G5R5_UNORM: return true; + case TinyImageFormat_A1R5G5B5_UNORM: return true; + case TinyImageFormat_R5G5B5X1_UNORM: return true; + case TinyImageFormat_B5G5R5X1_UNORM: return true; + case TinyImageFormat_X1R5G5B5_UNORM: return true; + case TinyImageFormat_X1B5G5R5_UNORM: return true; + case TinyImageFormat_B2G3R3A8_UNORM: return true; + case TinyImageFormat_R8G8_UNORM: return true; + case TinyImageFormat_R8G8_SNORM: return true; + case TinyImageFormat_G8R8_UNORM: return true; + case TinyImageFormat_G8R8_SNORM: return true; + case TinyImageFormat_R8G8_SRGB: return true; + case TinyImageFormat_R16_UNORM: return true; + case TinyImageFormat_R16_SNORM: return true; + case TinyImageFormat_R8G8B8_UNORM: return true; + case TinyImageFormat_R8G8B8_SNORM: return true; + case TinyImageFormat_R8G8B8_SRGB: return true; + case TinyImageFormat_B8G8R8_UNORM: return true; + case TinyImageFormat_B8G8R8_SNORM: return true; + case TinyImageFormat_B8G8R8_SRGB: return true; + case TinyImageFormat_R8G8B8A8_UNORM: return true; + case TinyImageFormat_R8G8B8A8_SNORM: return true; + case TinyImageFormat_R8G8B8A8_SRGB: return true; + case TinyImageFormat_B8G8R8A8_UNORM: return true; + case TinyImageFormat_B8G8R8A8_SNORM: return true; + case TinyImageFormat_B8G8R8A8_SRGB: return true; + case TinyImageFormat_R8G8B8X8_UNORM: return true; + case TinyImageFormat_B8G8R8X8_UNORM: return true; + case TinyImageFormat_R16G16_UNORM: return true; + case TinyImageFormat_G16R16_UNORM: return true; + case TinyImageFormat_R16G16_SNORM: return true; + case TinyImageFormat_G16R16_SNORM: return true; + case TinyImageFormat_A2R10G10B10_UNORM: return true; + case TinyImageFormat_A2R10G10B10_SNORM: return true; + case TinyImageFormat_A2B10G10R10_UNORM: return true; + case TinyImageFormat_A2B10G10R10_SNORM: return true; + case TinyImageFormat_R10G10B10A2_UNORM: return true; + case TinyImageFormat_R10G10B10A2_SNORM: return true; + case TinyImageFormat_B10G10R10A2_UNORM: return true; + case TinyImageFormat_B10G10R10A2_SNORM: return true; + case TinyImageFormat_R16G16B16_UNORM: return true; + case TinyImageFormat_R16G16B16_SNORM: return true; + case TinyImageFormat_R16G16B16A16_UNORM: return true; + case TinyImageFormat_R16G16B16A16_SNORM: return true; + case TinyImageFormat_D16_UNORM: return true; + case TinyImageFormat_X8_D24_UNORM: return true; + case TinyImageFormat_D16_UNORM_S8_UINT: return true; + case TinyImageFormat_D24_UNORM_S8_UINT: return true; + case TinyImageFormat_DXBC1_RGB_UNORM: return true; + case TinyImageFormat_DXBC1_RGB_SRGB: return true; + case TinyImageFormat_DXBC1_RGBA_UNORM: return true; + case TinyImageFormat_DXBC1_RGBA_SRGB: return true; + case TinyImageFormat_DXBC2_UNORM: return true; + case TinyImageFormat_DXBC2_SRGB: return true; + case TinyImageFormat_DXBC3_UNORM: return true; + case TinyImageFormat_DXBC3_SRGB: return true; + case TinyImageFormat_DXBC4_UNORM: return true; + case TinyImageFormat_DXBC4_SNORM: return true; + case TinyImageFormat_DXBC5_UNORM: return true; + case TinyImageFormat_DXBC5_SNORM: return true; + case TinyImageFormat_DXBC7_UNORM: return true; + case TinyImageFormat_DXBC7_SRGB: return true; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return true; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return true; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return true; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return true; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return true; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return true; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return true; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return true; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return true; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return true; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return true; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return true; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return true; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return true; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return true; + case TinyImageFormat_ASTC_4x4_UNORM: return true; + case TinyImageFormat_ASTC_4x4_SRGB: return true; + case TinyImageFormat_ASTC_5x4_UNORM: return true; + case TinyImageFormat_ASTC_5x4_SRGB: return true; + case TinyImageFormat_ASTC_5x5_UNORM: return true; + case TinyImageFormat_ASTC_5x5_SRGB: return true; + case TinyImageFormat_ASTC_6x5_UNORM: return true; + case TinyImageFormat_ASTC_6x5_SRGB: return true; + case TinyImageFormat_ASTC_6x6_UNORM: return true; + case TinyImageFormat_ASTC_6x6_SRGB: return true; + case TinyImageFormat_ASTC_8x5_UNORM: return true; + case TinyImageFormat_ASTC_8x5_SRGB: return true; + case TinyImageFormat_ASTC_8x6_UNORM: return true; + case TinyImageFormat_ASTC_8x6_SRGB: return true; + case TinyImageFormat_ASTC_8x8_UNORM: return true; + case TinyImageFormat_ASTC_8x8_SRGB: return true; + case TinyImageFormat_ASTC_10x5_UNORM: return true; + case TinyImageFormat_ASTC_10x5_SRGB: return true; + case TinyImageFormat_ASTC_10x6_UNORM: return true; + case TinyImageFormat_ASTC_10x6_SRGB: return true; + case TinyImageFormat_ASTC_10x8_UNORM: return true; + case TinyImageFormat_ASTC_10x8_SRGB: return true; + case TinyImageFormat_ASTC_10x10_UNORM: return true; + case TinyImageFormat_ASTC_10x10_SRGB: return true; + case TinyImageFormat_ASTC_12x10_UNORM: return true; + case TinyImageFormat_ASTC_12x10_SRGB: return true; + case TinyImageFormat_ASTC_12x12_UNORM: return true; + case TinyImageFormat_ASTC_12x12_SRGB: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsSigned(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_R8_SNORM: return true; + case TinyImageFormat_R8_SINT: return true; + case TinyImageFormat_R8G8_SNORM: return true; + case TinyImageFormat_G8R8_SNORM: return true; + case TinyImageFormat_R8G8_SINT: return true; + case TinyImageFormat_R16_SNORM: return true; + case TinyImageFormat_R16_SINT: return true; + case TinyImageFormat_R16_SFLOAT: return true; + case TinyImageFormat_R16_SBFLOAT: return true; + case TinyImageFormat_R8G8B8_SNORM: return true; + case TinyImageFormat_R8G8B8_SINT: return true; + case TinyImageFormat_B8G8R8_SNORM: return true; + case TinyImageFormat_B8G8R8_SINT: return true; + case TinyImageFormat_R8G8B8A8_SNORM: return true; + case TinyImageFormat_R8G8B8A8_SINT: return true; + case TinyImageFormat_B8G8R8A8_SNORM: return true; + case TinyImageFormat_B8G8R8A8_SINT: return true; + case TinyImageFormat_R16G16_SNORM: return true; + case TinyImageFormat_G16R16_SNORM: return true; + case TinyImageFormat_R16G16_SINT: return true; + case TinyImageFormat_R16G16_SFLOAT: return true; + case TinyImageFormat_R16G16_SBFLOAT: return true; + case TinyImageFormat_R32_SINT: return true; + case TinyImageFormat_R32_SFLOAT: return true; + case TinyImageFormat_A2R10G10B10_SNORM: return true; + case TinyImageFormat_A2R10G10B10_SINT: return true; + case TinyImageFormat_A2B10G10R10_SNORM: return true; + case TinyImageFormat_A2B10G10R10_SINT: return true; + case TinyImageFormat_R10G10B10A2_SNORM: return true; + case TinyImageFormat_R10G10B10A2_SINT: return true; + case TinyImageFormat_B10G10R10A2_SNORM: return true; + case TinyImageFormat_B10G10R10A2_SINT: return true; + case TinyImageFormat_R16G16B16_SNORM: return true; + case TinyImageFormat_R16G16B16_SINT: return true; + case TinyImageFormat_R16G16B16_SFLOAT: return true; + case TinyImageFormat_R16G16B16_SBFLOAT: return true; + case TinyImageFormat_R16G16B16A16_SNORM: return true; + case TinyImageFormat_R16G16B16A16_SINT: return true; + case TinyImageFormat_R16G16B16A16_SFLOAT: return true; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return true; + case TinyImageFormat_R32G32_SINT: return true; + case TinyImageFormat_R32G32_SFLOAT: return true; + case TinyImageFormat_R32G32B32_SINT: return true; + case TinyImageFormat_R32G32B32_SFLOAT: return true; + case TinyImageFormat_R32G32B32A32_SINT: return true; + case TinyImageFormat_R32G32B32A32_SFLOAT: return true; + case TinyImageFormat_R64_SINT: return true; + case TinyImageFormat_R64_SFLOAT: return true; + case TinyImageFormat_R64G64_SINT: return true; + case TinyImageFormat_R64G64_SFLOAT: return true; + case TinyImageFormat_R64G64B64_SINT: return true; + case TinyImageFormat_R64G64B64_SFLOAT: return true; + case TinyImageFormat_R64G64B64A64_SINT: return true; + case TinyImageFormat_R64G64B64A64_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return true; + case TinyImageFormat_DXBC4_SNORM: return true; + case TinyImageFormat_DXBC5_SNORM: return true; + case TinyImageFormat_DXBC6H_SFLOAT: return true; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return true; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsSRGB(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_R8_SRGB: return true; + case TinyImageFormat_R8G8_SRGB: return true; + case TinyImageFormat_R8G8B8_SRGB: return true; + case TinyImageFormat_B8G8R8_SRGB: return true; + case TinyImageFormat_R8G8B8A8_SRGB: return true; + case TinyImageFormat_B8G8R8A8_SRGB: return true; + case TinyImageFormat_DXBC1_RGB_SRGB: return true; + case TinyImageFormat_DXBC1_RGBA_SRGB: return true; + case TinyImageFormat_DXBC2_SRGB: return true; + case TinyImageFormat_DXBC3_SRGB: return true; + case TinyImageFormat_DXBC7_SRGB: return true; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return true; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return true; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return true; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return true; + case TinyImageFormat_ASTC_4x4_SRGB: return true; + case TinyImageFormat_ASTC_5x4_SRGB: return true; + case TinyImageFormat_ASTC_5x5_SRGB: return true; + case TinyImageFormat_ASTC_6x5_SRGB: return true; + case TinyImageFormat_ASTC_6x6_SRGB: return true; + case TinyImageFormat_ASTC_8x5_SRGB: return true; + case TinyImageFormat_ASTC_8x6_SRGB: return true; + case TinyImageFormat_ASTC_8x8_SRGB: return true; + case TinyImageFormat_ASTC_10x5_SRGB: return true; + case TinyImageFormat_ASTC_10x6_SRGB: return true; + case TinyImageFormat_ASTC_10x8_SRGB: return true; + case TinyImageFormat_ASTC_10x10_SRGB: return true; + case TinyImageFormat_ASTC_12x10_SRGB: return true; + case TinyImageFormat_ASTC_12x12_SRGB: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsYCbCr(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_G8B8G8R8_422_UNORM: + case TinyImageFormat_B8G8R8G8_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM : + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM: + case TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16: + case TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: + case TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16: + case TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: + case TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_G16B16G16R16_422_UNORM: + case TinyImageFormat_B16G16R16G16_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM: + return true; + + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCompressedDXBC(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_DXBC1_RGB_UNORM: return true; + case TinyImageFormat_DXBC1_RGB_SRGB: return true; + case TinyImageFormat_DXBC1_RGBA_UNORM: return true; + case TinyImageFormat_DXBC1_RGBA_SRGB: return true; + case TinyImageFormat_DXBC2_UNORM: return true; + case TinyImageFormat_DXBC2_SRGB: return true; + case TinyImageFormat_DXBC3_UNORM: return true; + case TinyImageFormat_DXBC3_SRGB: return true; + case TinyImageFormat_DXBC4_UNORM: return true; + case TinyImageFormat_DXBC4_SNORM: return true; + case TinyImageFormat_DXBC5_UNORM: return true; + case TinyImageFormat_DXBC5_SNORM: return true; + case TinyImageFormat_DXBC6H_UFLOAT: return true; + case TinyImageFormat_DXBC6H_SFLOAT: return true; + case TinyImageFormat_DXBC7_UNORM: return true; + case TinyImageFormat_DXBC7_SRGB: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCompressedASTC(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_ASTC_4x4_UNORM: return true; + case TinyImageFormat_ASTC_4x4_SRGB: return true; + case TinyImageFormat_ASTC_5x4_UNORM: return true; + case TinyImageFormat_ASTC_5x4_SRGB: return true; + case TinyImageFormat_ASTC_5x5_UNORM: return true; + case TinyImageFormat_ASTC_5x5_SRGB: return true; + case TinyImageFormat_ASTC_6x5_UNORM: return true; + case TinyImageFormat_ASTC_6x5_SRGB: return true; + case TinyImageFormat_ASTC_6x6_UNORM: return true; + case TinyImageFormat_ASTC_6x6_SRGB: return true; + case TinyImageFormat_ASTC_8x5_UNORM: return true; + case TinyImageFormat_ASTC_8x5_SRGB: return true; + case TinyImageFormat_ASTC_8x6_UNORM: return true; + case TinyImageFormat_ASTC_8x6_SRGB: return true; + case TinyImageFormat_ASTC_8x8_UNORM: return true; + case TinyImageFormat_ASTC_8x8_SRGB: return true; + case TinyImageFormat_ASTC_10x5_UNORM: return true; + case TinyImageFormat_ASTC_10x5_SRGB: return true; + case TinyImageFormat_ASTC_10x6_UNORM: return true; + case TinyImageFormat_ASTC_10x6_SRGB: return true; + case TinyImageFormat_ASTC_10x8_UNORM: return true; + case TinyImageFormat_ASTC_10x8_SRGB: return true; + case TinyImageFormat_ASTC_10x10_UNORM: return true; + case TinyImageFormat_ASTC_10x10_SRGB: return true; + case TinyImageFormat_ASTC_12x10_UNORM: return true; + case TinyImageFormat_ASTC_12x10_SRGB: return true; + case TinyImageFormat_ASTC_12x12_UNORM: return true; + case TinyImageFormat_ASTC_12x12_SRGB: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCompressedPVRTC1(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_PVRTC1_2BPP_UNORM: return true; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return true; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return true; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCompressedPVRTC2(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_PVRTC2_2BPP_UNORM: return true; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return true; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return true; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCompressedETC2(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_ETC2_R8G8B8_UNORM: return true; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return true; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return true; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return true; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return true; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return true; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return true; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return true; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return true; + default: return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsCompressed(TinyImageFormat const fmt) +{ + return TinyImageFormat_IsCompressedDXBC(fmt) || + TinyImageFormat_IsCompressedASTC(fmt) || + TinyImageFormat_IsCompressedPVRTC1(fmt) || + TinyImageFormat_IsCompressedPVRTC2(fmt) || + TinyImageFormat_IsCompressedETC2(fmt); +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsPlanar(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + return true; + + default: + return false; + } +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsPacked(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_G8B8G8R8_422_UNORM: + case TinyImageFormat_B8G8R8G8_422_UNORM: + case TinyImageFormat_G16B16G16R16_422_UNORM: + case TinyImageFormat_B16G16R16G16_422_UNORM: + case TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16: + case TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16: + case TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: + case TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: + case TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: + case TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: + return true; + + default: + return false; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_NumOfPlanes(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + return 3; + + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + return 2; + + default: + return 1; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_PlaneWidth(TinyImageFormat const fmt, uint32_t const plane, uint32_t const width) +{ + if (0 == plane) + return width; + + switch(fmt) + { + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: + return width >> 1; + + default: + return width; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_PlaneHeight(TinyImageFormat const fmt, uint32_t const plane, uint32_t const height) +{ + if (0 == plane) + return height; + + switch(fmt) + { + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + return height >> 1; + + default: + return height; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_PlaneSizeOfBlock(TinyImageFormat const fmt, uint32_t plane) +{ + switch(fmt) + { + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM: + return 1; + + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + return 2; + + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: + return 0 == plane ? 1 : 2; + + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + return 0 == plane ? 2 : 4; + + default: + return 1; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_IsSinglePlane(TinyImageFormat const fmt) +{ + return !TinyImageFormat_IsPlanar(fmt) || TinyImageFormat_NumOfPlanes(fmt) < 2; +} + +TIF_CONSTEXPR inline bool TinyImageFormat_IsHomogenous(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return false; + case TinyImageFormat_B2G3R3_UNORM: return false; + case TinyImageFormat_X4R4G4B4_UNORM: return false; + case TinyImageFormat_X4B4G4R4_UNORM: return false; + case TinyImageFormat_R5G6B5_UNORM: return false; + case TinyImageFormat_B5G6R5_UNORM: return false; + case TinyImageFormat_R5G5B5A1_UNORM: return false; + case TinyImageFormat_B5G5R5A1_UNORM: return false; + case TinyImageFormat_A1B5G5R5_UNORM: return false; + case TinyImageFormat_A1R5G5B5_UNORM: return false; + case TinyImageFormat_R5G5B5X1_UNORM: return false; + case TinyImageFormat_B5G5R5X1_UNORM: return false; + case TinyImageFormat_X1R5G5B5_UNORM: return false; + case TinyImageFormat_X1B5G5R5_UNORM: return false; + case TinyImageFormat_B2G3R3A8_UNORM: return false; + case TinyImageFormat_R8G8B8A8_SRGB: return false; + case TinyImageFormat_B8G8R8A8_SRGB: return false; + case TinyImageFormat_A2R10G10B10_UNORM: return false; + case TinyImageFormat_A2R10G10B10_UINT: return false; + case TinyImageFormat_A2R10G10B10_SNORM: return false; + case TinyImageFormat_A2R10G10B10_SINT: return false; + case TinyImageFormat_A2B10G10R10_UNORM: return false; + case TinyImageFormat_A2B10G10R10_UINT: return false; + case TinyImageFormat_A2B10G10R10_SNORM: return false; + case TinyImageFormat_A2B10G10R10_SINT: return false; + case TinyImageFormat_R10G10B10A2_UNORM: return false; + case TinyImageFormat_R10G10B10A2_UINT: return false; + case TinyImageFormat_R10G10B10A2_SNORM: return false; + case TinyImageFormat_R10G10B10A2_SINT: return false; + case TinyImageFormat_B10G10R10A2_UNORM: return false; + case TinyImageFormat_B10G10R10A2_UINT: return false; + case TinyImageFormat_B10G10R10A2_SNORM: return false; + case TinyImageFormat_B10G10R10A2_SINT: return false; + case TinyImageFormat_B10G11R11_UFLOAT: return false; + case TinyImageFormat_E5B9G9R9_UFLOAT: return false; + case TinyImageFormat_X8_D24_UNORM: return false; + case TinyImageFormat_D16_UNORM_S8_UINT: return false; + case TinyImageFormat_D24_UNORM_S8_UINT: return false; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return false; + case TinyImageFormat_DXBC1_RGB_UNORM: return false; + case TinyImageFormat_DXBC1_RGB_SRGB: return false; + case TinyImageFormat_DXBC1_RGBA_UNORM: return false; + case TinyImageFormat_DXBC1_RGBA_SRGB: return false; + case TinyImageFormat_DXBC2_UNORM: return false; + case TinyImageFormat_DXBC2_SRGB: return false; + case TinyImageFormat_DXBC3_UNORM: return false; + case TinyImageFormat_DXBC3_SRGB: return false; + case TinyImageFormat_DXBC4_UNORM: return false; + case TinyImageFormat_DXBC4_SNORM: return false; + case TinyImageFormat_DXBC5_UNORM: return false; + case TinyImageFormat_DXBC5_SNORM: return false; + case TinyImageFormat_DXBC6H_UFLOAT: return false; + case TinyImageFormat_DXBC6H_SFLOAT: return false; + case TinyImageFormat_DXBC7_UNORM: return false; + case TinyImageFormat_DXBC7_SRGB: return false; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return false; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return false; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return false; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return false; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return false; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return false; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return false; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return false; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return false; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return false; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return false; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return false; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return false; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return false; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return false; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return false; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return false; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return false; + case TinyImageFormat_ASTC_4x4_UNORM: return false; + case TinyImageFormat_ASTC_4x4_SRGB: return false; + case TinyImageFormat_ASTC_5x4_UNORM: return false; + case TinyImageFormat_ASTC_5x4_SRGB: return false; + case TinyImageFormat_ASTC_5x5_UNORM: return false; + case TinyImageFormat_ASTC_5x5_SRGB: return false; + case TinyImageFormat_ASTC_6x5_UNORM: return false; + case TinyImageFormat_ASTC_6x5_SRGB: return false; + case TinyImageFormat_ASTC_6x6_UNORM: return false; + case TinyImageFormat_ASTC_6x6_SRGB: return false; + case TinyImageFormat_ASTC_8x5_UNORM: return false; + case TinyImageFormat_ASTC_8x5_SRGB: return false; + case TinyImageFormat_ASTC_8x6_UNORM: return false; + case TinyImageFormat_ASTC_8x6_SRGB: return false; + case TinyImageFormat_ASTC_8x8_UNORM: return false; + case TinyImageFormat_ASTC_8x8_SRGB: return false; + case TinyImageFormat_ASTC_10x5_UNORM: return false; + case TinyImageFormat_ASTC_10x5_SRGB: return false; + case TinyImageFormat_ASTC_10x6_UNORM: return false; + case TinyImageFormat_ASTC_10x6_SRGB: return false; + case TinyImageFormat_ASTC_10x8_UNORM: return false; + case TinyImageFormat_ASTC_10x8_SRGB: return false; + case TinyImageFormat_ASTC_10x10_UNORM: return false; + case TinyImageFormat_ASTC_10x10_SRGB: return false; + case TinyImageFormat_ASTC_12x10_UNORM: return false; + case TinyImageFormat_ASTC_12x10_SRGB: return false; + case TinyImageFormat_ASTC_12x12_UNORM: return false; + case TinyImageFormat_ASTC_12x12_SRGB: return false; + case TinyImageFormat_CLUT_P4: return false; + case TinyImageFormat_CLUT_P4A4: return false; + case TinyImageFormat_CLUT_P8: return false; + case TinyImageFormat_CLUT_P8A8: return false; + default: return true; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_WidthOfBlock(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 1; + case TinyImageFormat_R1_UNORM: return 8; + case TinyImageFormat_R2_UNORM: return 4; + case TinyImageFormat_R4_UNORM: return 2; + case TinyImageFormat_DXBC1_RGB_UNORM: return 4; + case TinyImageFormat_DXBC1_RGB_SRGB: return 4; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 4; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 4; + case TinyImageFormat_DXBC2_UNORM: return 4; + case TinyImageFormat_DXBC2_SRGB: return 4; + case TinyImageFormat_DXBC3_UNORM: return 4; + case TinyImageFormat_DXBC3_SRGB: return 4; + case TinyImageFormat_DXBC4_UNORM: return 4; + case TinyImageFormat_DXBC4_SNORM: return 4; + case TinyImageFormat_DXBC5_UNORM: return 4; + case TinyImageFormat_DXBC5_SNORM: return 4; + case TinyImageFormat_DXBC6H_UFLOAT: return 4; + case TinyImageFormat_DXBC6H_SFLOAT: return 4; + case TinyImageFormat_DXBC7_UNORM: return 4; + case TinyImageFormat_DXBC7_SRGB: return 4; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return 8; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return 4; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return 8; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return 4; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return 8; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return 4; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return 8; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return 4; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return 4; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return 4; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return 4; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return 4; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return 4; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return 4; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 4; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 4; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 4; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 4; + case TinyImageFormat_ASTC_4x4_UNORM: return 4; + case TinyImageFormat_ASTC_4x4_SRGB: return 4; + case TinyImageFormat_ASTC_5x4_UNORM: return 5; + case TinyImageFormat_ASTC_5x4_SRGB: return 5; + case TinyImageFormat_ASTC_5x5_UNORM: return 5; + case TinyImageFormat_ASTC_5x5_SRGB: return 5; + case TinyImageFormat_ASTC_6x5_UNORM: return 6; + case TinyImageFormat_ASTC_6x5_SRGB: return 6; + case TinyImageFormat_ASTC_6x6_UNORM: return 6; + case TinyImageFormat_ASTC_6x6_SRGB: return 6; + case TinyImageFormat_ASTC_8x5_UNORM: return 8; + case TinyImageFormat_ASTC_8x5_SRGB: return 8; + case TinyImageFormat_ASTC_8x6_UNORM: return 8; + case TinyImageFormat_ASTC_8x6_SRGB: return 8; + case TinyImageFormat_ASTC_8x8_UNORM: return 8; + case TinyImageFormat_ASTC_8x8_SRGB: return 8; + case TinyImageFormat_ASTC_10x5_UNORM: return 10; + case TinyImageFormat_ASTC_10x5_SRGB: return 10; + case TinyImageFormat_ASTC_10x6_UNORM: return 10; + case TinyImageFormat_ASTC_10x6_SRGB: return 10; + case TinyImageFormat_ASTC_10x8_UNORM: return 10; + case TinyImageFormat_ASTC_10x8_SRGB: return 10; + case TinyImageFormat_ASTC_10x10_UNORM: return 10; + case TinyImageFormat_ASTC_10x10_SRGB: return 10; + case TinyImageFormat_ASTC_12x10_UNORM: return 12; + case TinyImageFormat_ASTC_12x10_SRGB: return 12; + case TinyImageFormat_ASTC_12x12_UNORM: return 12; + case TinyImageFormat_ASTC_12x12_SRGB: return 12; + case TinyImageFormat_CLUT_P4: return 2; + default: return 1; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_HeightOfBlock(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 1; + case TinyImageFormat_DXBC1_RGB_UNORM: return 4; + case TinyImageFormat_DXBC1_RGB_SRGB: return 4; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 4; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 4; + case TinyImageFormat_DXBC2_UNORM: return 4; + case TinyImageFormat_DXBC2_SRGB: return 4; + case TinyImageFormat_DXBC3_UNORM: return 4; + case TinyImageFormat_DXBC3_SRGB: return 4; + case TinyImageFormat_DXBC4_UNORM: return 4; + case TinyImageFormat_DXBC4_SNORM: return 4; + case TinyImageFormat_DXBC5_UNORM: return 4; + case TinyImageFormat_DXBC5_SNORM: return 4; + case TinyImageFormat_DXBC6H_UFLOAT: return 4; + case TinyImageFormat_DXBC6H_SFLOAT: return 4; + case TinyImageFormat_DXBC7_UNORM: return 4; + case TinyImageFormat_DXBC7_SRGB: return 4; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return 4; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return 4; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return 4; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return 4; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return 4; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return 4; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return 4; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return 4; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return 4; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return 4; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return 4; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return 4; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return 4; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return 4; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 4; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 4; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 4; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 4; + case TinyImageFormat_ASTC_4x4_UNORM: return 4; + case TinyImageFormat_ASTC_4x4_SRGB: return 4; + case TinyImageFormat_ASTC_5x4_UNORM: return 4; + case TinyImageFormat_ASTC_5x4_SRGB: return 4; + case TinyImageFormat_ASTC_5x5_UNORM: return 5; + case TinyImageFormat_ASTC_5x5_SRGB: return 5; + case TinyImageFormat_ASTC_6x5_UNORM: return 5; + case TinyImageFormat_ASTC_6x5_SRGB: return 5; + case TinyImageFormat_ASTC_6x6_UNORM: return 6; + case TinyImageFormat_ASTC_6x6_SRGB: return 6; + case TinyImageFormat_ASTC_8x5_UNORM: return 5; + case TinyImageFormat_ASTC_8x5_SRGB: return 5; + case TinyImageFormat_ASTC_8x6_UNORM: return 6; + case TinyImageFormat_ASTC_8x6_SRGB: return 6; + case TinyImageFormat_ASTC_8x8_UNORM: return 8; + case TinyImageFormat_ASTC_8x8_SRGB: return 8; + case TinyImageFormat_ASTC_10x5_UNORM: return 5; + case TinyImageFormat_ASTC_10x5_SRGB: return 5; + case TinyImageFormat_ASTC_10x6_UNORM: return 6; + case TinyImageFormat_ASTC_10x6_SRGB: return 6; + case TinyImageFormat_ASTC_10x8_UNORM: return 8; + case TinyImageFormat_ASTC_10x8_SRGB: return 8; + case TinyImageFormat_ASTC_10x10_UNORM: return 10; + case TinyImageFormat_ASTC_10x10_SRGB: return 10; + case TinyImageFormat_ASTC_12x10_UNORM: return 10; + case TinyImageFormat_ASTC_12x10_SRGB: return 10; + case TinyImageFormat_ASTC_12x12_UNORM: return 12; + case TinyImageFormat_ASTC_12x12_SRGB: return 12; + default: return 1; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_DepthOfBlock(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 1; + default: return 1; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_BitSizeOfBlock(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0; + case TinyImageFormat_R1_UNORM: return 8; + case TinyImageFormat_R2_UNORM: return 8; + case TinyImageFormat_R4_UNORM: return 8; + case TinyImageFormat_R4G4_UNORM: return 8; + case TinyImageFormat_G4R4_UNORM: return 8; + case TinyImageFormat_A8_UNORM: return 8; + case TinyImageFormat_R8_UNORM: return 8; + case TinyImageFormat_R8_SNORM: return 8; + case TinyImageFormat_R8_UINT: return 8; + case TinyImageFormat_R8_SINT: return 8; + case TinyImageFormat_R8_SRGB: return 8; + case TinyImageFormat_B2G3R3_UNORM: return 8; + case TinyImageFormat_R4G4B4A4_UNORM: return 16; + case TinyImageFormat_R4G4B4X4_UNORM: return 16; + case TinyImageFormat_B4G4R4A4_UNORM: return 16; + case TinyImageFormat_B4G4R4X4_UNORM: return 16; + case TinyImageFormat_A4R4G4B4_UNORM: return 16; + case TinyImageFormat_X4R4G4B4_UNORM: return 16; + case TinyImageFormat_A4B4G4R4_UNORM: return 16; + case TinyImageFormat_X4B4G4R4_UNORM: return 16; + case TinyImageFormat_R5G6B5_UNORM: return 16; + case TinyImageFormat_B5G6R5_UNORM: return 16; + case TinyImageFormat_R5G5B5A1_UNORM: return 16; + case TinyImageFormat_B5G5R5A1_UNORM: return 16; + case TinyImageFormat_A1B5G5R5_UNORM: return 16; + case TinyImageFormat_A1R5G5B5_UNORM: return 16; + case TinyImageFormat_R5G5B5X1_UNORM: return 16; + case TinyImageFormat_B5G5R5X1_UNORM: return 16; + case TinyImageFormat_X1R5G5B5_UNORM: return 16; + case TinyImageFormat_X1B5G5R5_UNORM: return 16; + case TinyImageFormat_B2G3R3A8_UNORM: return 16; + case TinyImageFormat_R8G8_UNORM: return 16; + case TinyImageFormat_R8G8_SNORM: return 16; + case TinyImageFormat_G8R8_UNORM: return 16; + case TinyImageFormat_G8R8_SNORM: return 16; + case TinyImageFormat_R8G8_UINT: return 16; + case TinyImageFormat_R8G8_SINT: return 16; + case TinyImageFormat_R8G8_SRGB: return 16; + case TinyImageFormat_R16_UNORM: return 16; + case TinyImageFormat_R16_SNORM: return 16; + case TinyImageFormat_R16_UINT: return 16; + case TinyImageFormat_R16_SINT: return 16; + case TinyImageFormat_R16_SFLOAT: return 16; + case TinyImageFormat_R16_SBFLOAT: return 16; + case TinyImageFormat_R8G8B8_UNORM: return 24; + case TinyImageFormat_R8G8B8_SNORM: return 24; + case TinyImageFormat_R8G8B8_UINT: return 24; + case TinyImageFormat_R8G8B8_SINT: return 24; + case TinyImageFormat_R8G8B8_SRGB: return 24; + case TinyImageFormat_B8G8R8_UNORM: return 24; + case TinyImageFormat_B8G8R8_SNORM: return 24; + case TinyImageFormat_B8G8R8_UINT: return 24; + case TinyImageFormat_B8G8R8_SINT: return 24; + case TinyImageFormat_B8G8R8_SRGB: return 24; + case TinyImageFormat_R16G16B16_UNORM: return 48; + case TinyImageFormat_R16G16B16_SNORM: return 48; + case TinyImageFormat_R16G16B16_UINT: return 48; + case TinyImageFormat_R16G16B16_SINT: return 48; + case TinyImageFormat_R16G16B16_SFLOAT: return 48; + case TinyImageFormat_R16G16B16_SBFLOAT: return 48; + case TinyImageFormat_R16G16B16A16_UNORM: return 64; + case TinyImageFormat_R16G16B16A16_SNORM: return 64; + case TinyImageFormat_R16G16B16A16_UINT: return 64; + case TinyImageFormat_R16G16B16A16_SINT: return 64; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 64; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 64; + case TinyImageFormat_R32G32_UINT: return 64; + case TinyImageFormat_R32G32_SINT: return 64; + case TinyImageFormat_R32G32_SFLOAT: return 64; + case TinyImageFormat_R32G32B32_UINT: return 96; + case TinyImageFormat_R32G32B32_SINT: return 96; + case TinyImageFormat_R32G32B32_SFLOAT: return 96; + case TinyImageFormat_R32G32B32A32_UINT: return 128; + case TinyImageFormat_R32G32B32A32_SINT: return 128; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 128; + case TinyImageFormat_R64_UINT: return 64; + case TinyImageFormat_R64_SINT: return 64; + case TinyImageFormat_R64_SFLOAT: return 64; + case TinyImageFormat_R64G64_UINT: return 128; + case TinyImageFormat_R64G64_SINT: return 128; + case TinyImageFormat_R64G64_SFLOAT: return 128; + case TinyImageFormat_R64G64B64_UINT: return 192; + case TinyImageFormat_R64G64B64_SINT: return 192; + case TinyImageFormat_R64G64B64_SFLOAT: return 192; + case TinyImageFormat_R64G64B64A64_UINT: return 256; + case TinyImageFormat_R64G64B64A64_SINT: return 256; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 256; + case TinyImageFormat_D16_UNORM: return 16; + case TinyImageFormat_S8_UINT: return 8; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 64; + case TinyImageFormat_DXBC1_RGB_UNORM: return 64; + case TinyImageFormat_DXBC1_RGB_SRGB: return 64; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 64; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 64; + case TinyImageFormat_DXBC2_UNORM: return 128; + case TinyImageFormat_DXBC2_SRGB: return 128; + case TinyImageFormat_DXBC3_UNORM: return 128; + case TinyImageFormat_DXBC3_SRGB: return 128; + case TinyImageFormat_DXBC4_UNORM: return 64; + case TinyImageFormat_DXBC4_SNORM: return 64; + case TinyImageFormat_DXBC5_UNORM: return 128; + case TinyImageFormat_DXBC5_SNORM: return 128; + case TinyImageFormat_DXBC6H_UFLOAT: return 128; + case TinyImageFormat_DXBC6H_SFLOAT: return 128; + case TinyImageFormat_DXBC7_UNORM: return 128; + case TinyImageFormat_DXBC7_SRGB: return 128; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return 64; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return 64; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return 64; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return 64; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return 64; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return 64; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return 64; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return 64; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return 64; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return 64; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return 64; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return 64; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return 128; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return 128; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 64; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 64; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 128; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 128; + case TinyImageFormat_ASTC_4x4_UNORM: return 128; + case TinyImageFormat_ASTC_4x4_SRGB: return 128; + case TinyImageFormat_ASTC_5x4_UNORM: return 128; + case TinyImageFormat_ASTC_5x4_SRGB: return 128; + case TinyImageFormat_ASTC_5x5_UNORM: return 128; + case TinyImageFormat_ASTC_5x5_SRGB: return 128; + case TinyImageFormat_ASTC_6x5_UNORM: return 128; + case TinyImageFormat_ASTC_6x5_SRGB: return 128; + case TinyImageFormat_ASTC_6x6_UNORM: return 128; + case TinyImageFormat_ASTC_6x6_SRGB: return 128; + case TinyImageFormat_ASTC_8x5_UNORM: return 128; + case TinyImageFormat_ASTC_8x5_SRGB: return 128; + case TinyImageFormat_ASTC_8x6_UNORM: return 128; + case TinyImageFormat_ASTC_8x6_SRGB: return 128; + case TinyImageFormat_ASTC_8x8_UNORM: return 128; + case TinyImageFormat_ASTC_8x8_SRGB: return 128; + case TinyImageFormat_ASTC_10x5_UNORM: return 128; + case TinyImageFormat_ASTC_10x5_SRGB: return 128; + case TinyImageFormat_ASTC_10x6_UNORM: return 128; + case TinyImageFormat_ASTC_10x6_SRGB: return 128; + case TinyImageFormat_ASTC_10x8_UNORM: return 128; + case TinyImageFormat_ASTC_10x8_SRGB: return 128; + case TinyImageFormat_ASTC_10x10_UNORM: return 128; + case TinyImageFormat_ASTC_10x10_SRGB: return 128; + case TinyImageFormat_ASTC_12x10_UNORM: return 128; + case TinyImageFormat_ASTC_12x10_SRGB: return 128; + case TinyImageFormat_ASTC_12x12_UNORM: return 128; + case TinyImageFormat_ASTC_12x12_SRGB: return 128; + case TinyImageFormat_CLUT_P4: return 8; + case TinyImageFormat_CLUT_P4A4: return 8; + case TinyImageFormat_CLUT_P8: return 8; + case TinyImageFormat_CLUT_P8A8: return 16; + case TinyImageFormat_G16B16G16R16_422_UNORM: return 8; + case TinyImageFormat_B16G16R16G16_422_UNORM: return 8; + case TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16: return 8; + case TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: return 8; + case TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: return 8; + case TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16: return 8; + case TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: return 8; + case TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: return 8; + case TinyImageFormat_G8B8G8R8_422_UNORM: return 4; + case TinyImageFormat_B8G8R8G8_422_UNORM: return 4; + default: return 32; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_ChannelCount(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0; + case TinyImageFormat_R1_UNORM: return 1; + case TinyImageFormat_R2_UNORM: return 1; + case TinyImageFormat_R4_UNORM: return 1; + case TinyImageFormat_R4G4_UNORM: return 2; + case TinyImageFormat_G4R4_UNORM: return 2; + case TinyImageFormat_A8_UNORM: return 1; + case TinyImageFormat_R8_UNORM: return 1; + case TinyImageFormat_R8_SNORM: return 1; + case TinyImageFormat_R8_UINT: return 1; + case TinyImageFormat_R8_SINT: return 1; + case TinyImageFormat_R8_SRGB: return 1; + case TinyImageFormat_B2G3R3_UNORM: return 3; + case TinyImageFormat_R5G6B5_UNORM: return 3; + case TinyImageFormat_B5G6R5_UNORM: return 3; + case TinyImageFormat_R8G8_UNORM: return 2; + case TinyImageFormat_R8G8_SNORM: return 2; + case TinyImageFormat_G8R8_UNORM: return 2; + case TinyImageFormat_G8R8_SNORM: return 2; + case TinyImageFormat_R8G8_UINT: return 2; + case TinyImageFormat_R8G8_SINT: return 2; + case TinyImageFormat_R8G8_SRGB: return 2; + case TinyImageFormat_R16_UNORM: return 1; + case TinyImageFormat_R16_SNORM: return 1; + case TinyImageFormat_R16_UINT: return 1; + case TinyImageFormat_R16_SINT: return 1; + case TinyImageFormat_R16_SFLOAT: return 1; + case TinyImageFormat_R16_SBFLOAT: return 1; + case TinyImageFormat_R8G8B8_UNORM: return 3; + case TinyImageFormat_R8G8B8_SNORM: return 3; + case TinyImageFormat_R8G8B8_UINT: return 3; + case TinyImageFormat_R8G8B8_SINT: return 3; + case TinyImageFormat_R8G8B8_SRGB: return 3; + case TinyImageFormat_B8G8R8_UNORM: return 3; + case TinyImageFormat_B8G8R8_SNORM: return 3; + case TinyImageFormat_B8G8R8_UINT: return 3; + case TinyImageFormat_B8G8R8_SINT: return 3; + case TinyImageFormat_B8G8R8_SRGB: return 3; + case TinyImageFormat_R16G16_UNORM: return 2; + case TinyImageFormat_G16R16_UNORM: return 2; + case TinyImageFormat_R16G16_SNORM: return 2; + case TinyImageFormat_G16R16_SNORM: return 2; + case TinyImageFormat_R16G16_UINT: return 2; + case TinyImageFormat_R16G16_SINT: return 2; + case TinyImageFormat_R16G16_SFLOAT: return 2; + case TinyImageFormat_R16G16_SBFLOAT: return 2; + case TinyImageFormat_R32_UINT: return 1; + case TinyImageFormat_R32_SINT: return 1; + case TinyImageFormat_R32_SFLOAT: return 1; + case TinyImageFormat_B10G11R11_UFLOAT: return 3; + case TinyImageFormat_R16G16B16_UNORM: return 3; + case TinyImageFormat_R16G16B16_SNORM: return 3; + case TinyImageFormat_R16G16B16_UINT: return 3; + case TinyImageFormat_R16G16B16_SINT: return 3; + case TinyImageFormat_R16G16B16_SFLOAT: return 3; + case TinyImageFormat_R16G16B16_SBFLOAT: return 3; + case TinyImageFormat_R32G32_UINT: return 2; + case TinyImageFormat_R32G32_SINT: return 2; + case TinyImageFormat_R32G32_SFLOAT: return 2; + case TinyImageFormat_R32G32B32_UINT: return 3; + case TinyImageFormat_R32G32B32_SINT: return 3; + case TinyImageFormat_R32G32B32_SFLOAT: return 3; + case TinyImageFormat_R64_UINT: return 1; + case TinyImageFormat_R64_SINT: return 1; + case TinyImageFormat_R64_SFLOAT: return 1; + case TinyImageFormat_R64G64_UINT: return 2; + case TinyImageFormat_R64G64_SINT: return 2; + case TinyImageFormat_R64G64_SFLOAT: return 2; + case TinyImageFormat_R64G64B64_UINT: return 3; + case TinyImageFormat_R64G64B64_SINT: return 3; + case TinyImageFormat_R64G64B64_SFLOAT: return 3; + case TinyImageFormat_D16_UNORM: return 1; + case TinyImageFormat_X8_D24_UNORM: return 2; + case TinyImageFormat_D32_SFLOAT: return 1; + case TinyImageFormat_S8_UINT: return 1; + case TinyImageFormat_D16_UNORM_S8_UINT: return 2; + case TinyImageFormat_D24_UNORM_S8_UINT: return 2; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 2; + case TinyImageFormat_DXBC1_RGB_UNORM: return 3; + case TinyImageFormat_DXBC1_RGB_SRGB: return 3; + case TinyImageFormat_DXBC4_UNORM: return 1; + case TinyImageFormat_DXBC4_SNORM: return 1; + case TinyImageFormat_DXBC5_UNORM: return 2; + case TinyImageFormat_DXBC5_SNORM: return 2; + case TinyImageFormat_DXBC6H_UFLOAT: return 3; + case TinyImageFormat_DXBC6H_SFLOAT: return 3; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return 3; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return 3; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 1; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 1; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 2; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 2; + case TinyImageFormat_CLUT_P4: return 1; + case TinyImageFormat_CLUT_P4A4: return 2; + case TinyImageFormat_CLUT_P8: return 1; + case TinyImageFormat_CLUT_P8A8: return 2; + default: return 4; + } +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_ChannelBitWidthAtPhysical(TinyImageFormat const fmt, uint32_t const channel) +{ + if(TinyImageFormat_IsHomogenous(fmt) || channel == 0) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0; + case TinyImageFormat_R1_UNORM: return 1; + case TinyImageFormat_R2_UNORM: return 2; + case TinyImageFormat_R4_UNORM: return 4; + case TinyImageFormat_R4G4_UNORM: return 4; + case TinyImageFormat_G4R4_UNORM: return 4; + case TinyImageFormat_B2G3R3_UNORM: return 2; + case TinyImageFormat_R4G4B4A4_UNORM: return 4; + case TinyImageFormat_R4G4B4X4_UNORM: return 4; + case TinyImageFormat_B4G4R4A4_UNORM: return 4; + case TinyImageFormat_B4G4R4X4_UNORM: return 4; + case TinyImageFormat_A4R4G4B4_UNORM: return 4; + case TinyImageFormat_X4R4G4B4_UNORM: return 4; + case TinyImageFormat_A4B4G4R4_UNORM: return 4; + case TinyImageFormat_X4B4G4R4_UNORM: return 4; + case TinyImageFormat_R5G6B5_UNORM: return 5; + case TinyImageFormat_B5G6R5_UNORM: return 5; + case TinyImageFormat_R5G5B5A1_UNORM: return 5; + case TinyImageFormat_B5G5R5A1_UNORM: return 5; + case TinyImageFormat_A1B5G5R5_UNORM: return 1; + case TinyImageFormat_A1R5G5B5_UNORM: return 1; + case TinyImageFormat_R5G5B5X1_UNORM: return 5; + case TinyImageFormat_B5G5R5X1_UNORM: return 5; + case TinyImageFormat_X1R5G5B5_UNORM: return 1; + case TinyImageFormat_X1B5G5R5_UNORM: return 1; + case TinyImageFormat_B2G3R3A8_UNORM: return 2; + case TinyImageFormat_R16_UNORM: return 16; + case TinyImageFormat_R16_SNORM: return 16; + case TinyImageFormat_R16_UINT: return 16; + case TinyImageFormat_R16_SINT: return 16; + case TinyImageFormat_R16_SFLOAT: return 16; + case TinyImageFormat_R16_SBFLOAT: return 16; + case TinyImageFormat_R16G16_UNORM: return 16; + case TinyImageFormat_G16R16_UNORM: return 16; + case TinyImageFormat_R16G16_SNORM: return 16; + case TinyImageFormat_G16R16_SNORM: return 16; + case TinyImageFormat_R16G16_UINT: return 16; + case TinyImageFormat_R16G16_SINT: return 16; + case TinyImageFormat_R16G16_SFLOAT: return 16; + case TinyImageFormat_R16G16_SBFLOAT: return 16; + case TinyImageFormat_R32_UINT: return 32; + case TinyImageFormat_R32_SINT: return 32; + case TinyImageFormat_R32_SFLOAT: return 32; + case TinyImageFormat_A2R10G10B10_UNORM: return 2; + case TinyImageFormat_A2R10G10B10_UINT: return 2; + case TinyImageFormat_A2R10G10B10_SNORM: return 2; + case TinyImageFormat_A2R10G10B10_SINT: return 2; + case TinyImageFormat_A2B10G10R10_UNORM: return 2; + case TinyImageFormat_A2B10G10R10_UINT: return 2; + case TinyImageFormat_A2B10G10R10_SNORM: return 2; + case TinyImageFormat_A2B10G10R10_SINT: return 2; + case TinyImageFormat_R10G10B10A2_UNORM: return 10; + case TinyImageFormat_R10G10B10A2_UINT: return 10; + case TinyImageFormat_R10G10B10A2_SNORM: return 10; + case TinyImageFormat_R10G10B10A2_SINT: return 10; + case TinyImageFormat_B10G10R10A2_UNORM: return 10; + case TinyImageFormat_B10G10R10A2_UINT: return 10; + case TinyImageFormat_B10G10R10A2_SNORM: return 10; + case TinyImageFormat_B10G10R10A2_SINT: return 10; + case TinyImageFormat_B10G11R11_UFLOAT: return 10; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 5; + case TinyImageFormat_R16G16B16_UNORM: return 16; + case TinyImageFormat_R16G16B16_SNORM: return 16; + case TinyImageFormat_R16G16B16_UINT: return 16; + case TinyImageFormat_R16G16B16_SINT: return 16; + case TinyImageFormat_R16G16B16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16_SBFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_UNORM: return 16; + case TinyImageFormat_R16G16B16A16_SNORM: return 16; + case TinyImageFormat_R16G16B16A16_UINT: return 16; + case TinyImageFormat_R16G16B16A16_SINT: return 16; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 16; + case TinyImageFormat_R32G32_UINT: return 32; + case TinyImageFormat_R32G32_SINT: return 32; + case TinyImageFormat_R32G32_SFLOAT: return 32; + case TinyImageFormat_R32G32B32_UINT: return 32; + case TinyImageFormat_R32G32B32_SINT: return 32; + case TinyImageFormat_R32G32B32_SFLOAT: return 32; + case TinyImageFormat_R32G32B32A32_UINT: return 32; + case TinyImageFormat_R32G32B32A32_SINT: return 32; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 32; + case TinyImageFormat_R64_UINT: return 64; + case TinyImageFormat_R64_SINT: return 64; + case TinyImageFormat_R64_SFLOAT: return 64; + case TinyImageFormat_R64G64_UINT: return 64; + case TinyImageFormat_R64G64_SINT: return 64; + case TinyImageFormat_R64G64_SFLOAT: return 64; + case TinyImageFormat_R64G64B64_UINT: return 64; + case TinyImageFormat_R64G64B64_SINT: return 64; + case TinyImageFormat_R64G64B64_SFLOAT: return 64; + case TinyImageFormat_R64G64B64A64_UINT: return 64; + case TinyImageFormat_R64G64B64A64_SINT: return 64; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 64; + case TinyImageFormat_D16_UNORM: return 16; + case TinyImageFormat_D32_SFLOAT: return 32; + case TinyImageFormat_D16_UNORM_S8_UINT: return 16; + case TinyImageFormat_D24_UNORM_S8_UINT: return 24; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 32; + case TinyImageFormat_DXBC1_RGB_UNORM: return 5; + case TinyImageFormat_DXBC1_RGB_SRGB: return 5; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 5; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 5; + case TinyImageFormat_DXBC2_UNORM: return 5; + case TinyImageFormat_DXBC2_SRGB: return 5; + case TinyImageFormat_DXBC3_UNORM: return 5; + case TinyImageFormat_DXBC3_SRGB: return 5; + case TinyImageFormat_DXBC6H_UFLOAT: return 16; + case TinyImageFormat_DXBC6H_SFLOAT: return 16; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 11; + case TinyImageFormat_CLUT_P4: return 4; + case TinyImageFormat_CLUT_P4A4: return 4; + default: return 8; + } + } + else if(channel == 1) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0; + case TinyImageFormat_R1_UNORM: return 0; + case TinyImageFormat_R2_UNORM: return 0; + case TinyImageFormat_R4_UNORM: return 0; + case TinyImageFormat_R4G4_UNORM: return 4; + case TinyImageFormat_G4R4_UNORM: return 4; + case TinyImageFormat_A8_UNORM: return 0; + case TinyImageFormat_R8_UNORM: return 0; + case TinyImageFormat_R8_SNORM: return 0; + case TinyImageFormat_R8_UINT: return 0; + case TinyImageFormat_R8_SINT: return 0; + case TinyImageFormat_R8_SRGB: return 0; + case TinyImageFormat_B2G3R3_UNORM: return 3; + case TinyImageFormat_R4G4B4A4_UNORM: return 4; + case TinyImageFormat_R4G4B4X4_UNORM: return 4; + case TinyImageFormat_B4G4R4A4_UNORM: return 4; + case TinyImageFormat_B4G4R4X4_UNORM: return 4; + case TinyImageFormat_A4R4G4B4_UNORM: return 4; + case TinyImageFormat_X4R4G4B4_UNORM: return 4; + case TinyImageFormat_A4B4G4R4_UNORM: return 4; + case TinyImageFormat_X4B4G4R4_UNORM: return 4; + case TinyImageFormat_R5G6B5_UNORM: return 6; + case TinyImageFormat_B5G6R5_UNORM: return 6; + case TinyImageFormat_R5G5B5A1_UNORM: return 5; + case TinyImageFormat_B5G5R5A1_UNORM: return 5; + case TinyImageFormat_A1B5G5R5_UNORM: return 5; + case TinyImageFormat_A1R5G5B5_UNORM: return 5; + case TinyImageFormat_R5G5B5X1_UNORM: return 5; + case TinyImageFormat_B5G5R5X1_UNORM: return 5; + case TinyImageFormat_X1R5G5B5_UNORM: return 5; + case TinyImageFormat_X1B5G5R5_UNORM: return 5; + case TinyImageFormat_B2G3R3A8_UNORM: return 3; + case TinyImageFormat_R16_UNORM: return 0; + case TinyImageFormat_R16_SNORM: return 0; + case TinyImageFormat_R16_UINT: return 0; + case TinyImageFormat_R16_SINT: return 0; + case TinyImageFormat_R16_SFLOAT: return 0; + case TinyImageFormat_R16_SBFLOAT: return 0; + case TinyImageFormat_R16G16_UNORM: return 16; + case TinyImageFormat_G16R16_UNORM: return 16; + case TinyImageFormat_R16G16_SNORM: return 16; + case TinyImageFormat_G16R16_SNORM: return 16; + case TinyImageFormat_R16G16_UINT: return 16; + case TinyImageFormat_R16G16_SINT: return 16; + case TinyImageFormat_R16G16_SFLOAT: return 16; + case TinyImageFormat_R16G16_SBFLOAT: return 16; + case TinyImageFormat_R32_UINT: return 0; + case TinyImageFormat_R32_SINT: return 0; + case TinyImageFormat_R32_SFLOAT: return 0; + case TinyImageFormat_A2R10G10B10_UNORM: return 10; + case TinyImageFormat_A2R10G10B10_UINT: return 10; + case TinyImageFormat_A2R10G10B10_SNORM: return 10; + case TinyImageFormat_A2R10G10B10_SINT: return 10; + case TinyImageFormat_A2B10G10R10_UNORM: return 10; + case TinyImageFormat_A2B10G10R10_UINT: return 10; + case TinyImageFormat_A2B10G10R10_SNORM: return 10; + case TinyImageFormat_A2B10G10R10_SINT: return 10; + case TinyImageFormat_R10G10B10A2_UNORM: return 10; + case TinyImageFormat_R10G10B10A2_UINT: return 10; + case TinyImageFormat_R10G10B10A2_SNORM: return 10; + case TinyImageFormat_R10G10B10A2_SINT: return 10; + case TinyImageFormat_B10G10R10A2_UNORM: return 10; + case TinyImageFormat_B10G10R10A2_UINT: return 10; + case TinyImageFormat_B10G10R10A2_SNORM: return 10; + case TinyImageFormat_B10G10R10A2_SINT: return 10; + case TinyImageFormat_B10G11R11_UFLOAT: return 11; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 9; + case TinyImageFormat_R16G16B16_UNORM: return 16; + case TinyImageFormat_R16G16B16_SNORM: return 16; + case TinyImageFormat_R16G16B16_UINT: return 16; + case TinyImageFormat_R16G16B16_SINT: return 16; + case TinyImageFormat_R16G16B16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16_SBFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_UNORM: return 16; + case TinyImageFormat_R16G16B16A16_SNORM: return 16; + case TinyImageFormat_R16G16B16A16_UINT: return 16; + case TinyImageFormat_R16G16B16A16_SINT: return 16; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 16; + case TinyImageFormat_R32G32_UINT: return 32; + case TinyImageFormat_R32G32_SINT: return 32; + case TinyImageFormat_R32G32_SFLOAT: return 32; + case TinyImageFormat_R32G32B32_UINT: return 32; + case TinyImageFormat_R32G32B32_SINT: return 32; + case TinyImageFormat_R32G32B32_SFLOAT: return 32; + case TinyImageFormat_R32G32B32A32_UINT: return 32; + case TinyImageFormat_R32G32B32A32_SINT: return 32; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 32; + case TinyImageFormat_R64_UINT: return 0; + case TinyImageFormat_R64_SINT: return 0; + case TinyImageFormat_R64_SFLOAT: return 0; + case TinyImageFormat_R64G64_UINT: return 64; + case TinyImageFormat_R64G64_SINT: return 64; + case TinyImageFormat_R64G64_SFLOAT: return 64; + case TinyImageFormat_R64G64B64_UINT: return 64; + case TinyImageFormat_R64G64B64_SINT: return 64; + case TinyImageFormat_R64G64B64_SFLOAT: return 64; + case TinyImageFormat_R64G64B64A64_UINT: return 64; + case TinyImageFormat_R64G64B64A64_SINT: return 64; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 64; + case TinyImageFormat_D16_UNORM: return 0; + case TinyImageFormat_X8_D24_UNORM: return 24; + case TinyImageFormat_D32_SFLOAT: return 0; + case TinyImageFormat_S8_UINT: return 0; + case TinyImageFormat_DXBC1_RGB_UNORM: return 6; + case TinyImageFormat_DXBC1_RGB_SRGB: return 6; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 6; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 6; + case TinyImageFormat_DXBC2_UNORM: return 6; + case TinyImageFormat_DXBC2_SRGB: return 6; + case TinyImageFormat_DXBC3_UNORM: return 6; + case TinyImageFormat_DXBC3_SRGB: return 6; + case TinyImageFormat_DXBC6H_UFLOAT: return 16; + case TinyImageFormat_DXBC6H_SFLOAT: return 16; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 11; + case TinyImageFormat_CLUT_P4: return 0; + case TinyImageFormat_CLUT_P4A4: return 4; + case TinyImageFormat_CLUT_P8: return 0; + default: return 8; + } + } + else if(channel == 2) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0; + case TinyImageFormat_R1_UNORM: return 0; + case TinyImageFormat_R2_UNORM: return 0; + case TinyImageFormat_R4_UNORM: return 0; + case TinyImageFormat_R4G4_UNORM: return 0; + case TinyImageFormat_G4R4_UNORM: return 0; + case TinyImageFormat_A8_UNORM: return 0; + case TinyImageFormat_R8_UNORM: return 0; + case TinyImageFormat_R8_SNORM: return 0; + case TinyImageFormat_R8_UINT: return 0; + case TinyImageFormat_R8_SINT: return 0; + case TinyImageFormat_R8_SRGB: return 0; + case TinyImageFormat_B2G3R3_UNORM: return 3; + case TinyImageFormat_R4G4B4A4_UNORM: return 4; + case TinyImageFormat_R4G4B4X4_UNORM: return 4; + case TinyImageFormat_B4G4R4A4_UNORM: return 4; + case TinyImageFormat_B4G4R4X4_UNORM: return 4; + case TinyImageFormat_A4R4G4B4_UNORM: return 4; + case TinyImageFormat_X4R4G4B4_UNORM: return 4; + case TinyImageFormat_A4B4G4R4_UNORM: return 4; + case TinyImageFormat_X4B4G4R4_UNORM: return 4; + case TinyImageFormat_R5G6B5_UNORM: return 5; + case TinyImageFormat_B5G6R5_UNORM: return 5; + case TinyImageFormat_R5G5B5A1_UNORM: return 5; + case TinyImageFormat_B5G5R5A1_UNORM: return 5; + case TinyImageFormat_A1B5G5R5_UNORM: return 5; + case TinyImageFormat_A1R5G5B5_UNORM: return 5; + case TinyImageFormat_R5G5B5X1_UNORM: return 5; + case TinyImageFormat_B5G5R5X1_UNORM: return 5; + case TinyImageFormat_X1R5G5B5_UNORM: return 5; + case TinyImageFormat_X1B5G5R5_UNORM: return 5; + case TinyImageFormat_B2G3R3A8_UNORM: return 3; + case TinyImageFormat_R8G8_UNORM: return 0; + case TinyImageFormat_R8G8_SNORM: return 0; + case TinyImageFormat_G8R8_UNORM: return 0; + case TinyImageFormat_G8R8_SNORM: return 0; + case TinyImageFormat_R8G8_UINT: return 0; + case TinyImageFormat_R8G8_SINT: return 0; + case TinyImageFormat_R8G8_SRGB: return 0; + case TinyImageFormat_R16_UNORM: return 0; + case TinyImageFormat_R16_SNORM: return 0; + case TinyImageFormat_R16_UINT: return 0; + case TinyImageFormat_R16_SINT: return 0; + case TinyImageFormat_R16_SFLOAT: return 0; + case TinyImageFormat_R16_SBFLOAT: return 0; + case TinyImageFormat_R16G16_UNORM: return 0; + case TinyImageFormat_G16R16_UNORM: return 0; + case TinyImageFormat_R16G16_SNORM: return 0; + case TinyImageFormat_G16R16_SNORM: return 0; + case TinyImageFormat_R16G16_UINT: return 0; + case TinyImageFormat_R16G16_SINT: return 0; + case TinyImageFormat_R16G16_SFLOAT: return 0; + case TinyImageFormat_R16G16_SBFLOAT: return 0; + case TinyImageFormat_R32_UINT: return 0; + case TinyImageFormat_R32_SINT: return 0; + case TinyImageFormat_R32_SFLOAT: return 0; + case TinyImageFormat_A2R10G10B10_UNORM: return 10; + case TinyImageFormat_A2R10G10B10_UINT: return 10; + case TinyImageFormat_A2R10G10B10_SNORM: return 10; + case TinyImageFormat_A2R10G10B10_SINT: return 10; + case TinyImageFormat_A2B10G10R10_UNORM: return 10; + case TinyImageFormat_A2B10G10R10_UINT: return 10; + case TinyImageFormat_A2B10G10R10_SNORM: return 10; + case TinyImageFormat_A2B10G10R10_SINT: return 10; + case TinyImageFormat_R10G10B10A2_UNORM: return 10; + case TinyImageFormat_R10G10B10A2_UINT: return 10; + case TinyImageFormat_R10G10B10A2_SNORM: return 10; + case TinyImageFormat_R10G10B10A2_SINT: return 10; + case TinyImageFormat_B10G10R10A2_UNORM: return 10; + case TinyImageFormat_B10G10R10A2_UINT: return 10; + case TinyImageFormat_B10G10R10A2_SNORM: return 10; + case TinyImageFormat_B10G10R10A2_SINT: return 10; + case TinyImageFormat_B10G11R11_UFLOAT: return 11; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 9; + case TinyImageFormat_R16G16B16_UNORM: return 16; + case TinyImageFormat_R16G16B16_SNORM: return 16; + case TinyImageFormat_R16G16B16_UINT: return 16; + case TinyImageFormat_R16G16B16_SINT: return 16; + case TinyImageFormat_R16G16B16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16_SBFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_UNORM: return 16; + case TinyImageFormat_R16G16B16A16_SNORM: return 16; + case TinyImageFormat_R16G16B16A16_UINT: return 16; + case TinyImageFormat_R16G16B16A16_SINT: return 16; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 16; + case TinyImageFormat_R32G32_UINT: return 0; + case TinyImageFormat_R32G32_SINT: return 0; + case TinyImageFormat_R32G32_SFLOAT: return 0; + case TinyImageFormat_R32G32B32_UINT: return 32; + case TinyImageFormat_R32G32B32_SINT: return 32; + case TinyImageFormat_R32G32B32_SFLOAT: return 32; + case TinyImageFormat_R32G32B32A32_UINT: return 32; + case TinyImageFormat_R32G32B32A32_SINT: return 32; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 32; + case TinyImageFormat_R64_UINT: return 0; + case TinyImageFormat_R64_SINT: return 0; + case TinyImageFormat_R64_SFLOAT: return 0; + case TinyImageFormat_R64G64_UINT: return 0; + case TinyImageFormat_R64G64_SINT: return 0; + case TinyImageFormat_R64G64_SFLOAT: return 0; + case TinyImageFormat_R64G64B64_UINT: return 64; + case TinyImageFormat_R64G64B64_SINT: return 64; + case TinyImageFormat_R64G64B64_SFLOAT: return 64; + case TinyImageFormat_R64G64B64A64_UINT: return 64; + case TinyImageFormat_R64G64B64A64_SINT: return 64; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 64; + case TinyImageFormat_D16_UNORM: return 0; + case TinyImageFormat_X8_D24_UNORM: return 0; + case TinyImageFormat_D32_SFLOAT: return 0; + case TinyImageFormat_S8_UINT: return 0; + case TinyImageFormat_D16_UNORM_S8_UINT: return 0; + case TinyImageFormat_D24_UNORM_S8_UINT: return 0; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 0; + case TinyImageFormat_DXBC1_RGB_UNORM: return 5; + case TinyImageFormat_DXBC1_RGB_SRGB: return 5; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 5; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 5; + case TinyImageFormat_DXBC2_UNORM: return 5; + case TinyImageFormat_DXBC2_SRGB: return 5; + case TinyImageFormat_DXBC3_UNORM: return 5; + case TinyImageFormat_DXBC3_SRGB: return 5; + case TinyImageFormat_DXBC6H_UFLOAT: return 16; + case TinyImageFormat_DXBC6H_SFLOAT: return 16; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 11; + case TinyImageFormat_CLUT_P4: return 0; + case TinyImageFormat_CLUT_P4A4: return 0; + case TinyImageFormat_CLUT_P8: return 0; + case TinyImageFormat_CLUT_P8A8: return 0; + default: return 8; + } + } + else if(channel == 3) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0; + case TinyImageFormat_R1_UNORM: return 0; + case TinyImageFormat_R2_UNORM: return 0; + case TinyImageFormat_R4_UNORM: return 0; + case TinyImageFormat_R4G4_UNORM: return 0; + case TinyImageFormat_G4R4_UNORM: return 0; + case TinyImageFormat_A8_UNORM: return 0; + case TinyImageFormat_R8_UNORM: return 0; + case TinyImageFormat_R8_SNORM: return 0; + case TinyImageFormat_R8_UINT: return 0; + case TinyImageFormat_R8_SINT: return 0; + case TinyImageFormat_R8_SRGB: return 0; + case TinyImageFormat_B2G3R3_UNORM: return 0; + case TinyImageFormat_R4G4B4A4_UNORM: return 4; + case TinyImageFormat_R4G4B4X4_UNORM: return 4; + case TinyImageFormat_B4G4R4A4_UNORM: return 4; + case TinyImageFormat_B4G4R4X4_UNORM: return 4; + case TinyImageFormat_A4R4G4B4_UNORM: return 4; + case TinyImageFormat_X4R4G4B4_UNORM: return 4; + case TinyImageFormat_A4B4G4R4_UNORM: return 4; + case TinyImageFormat_X4B4G4R4_UNORM: return 4; + case TinyImageFormat_R5G6B5_UNORM: return 0; + case TinyImageFormat_B5G6R5_UNORM: return 0; + case TinyImageFormat_R5G5B5A1_UNORM: return 1; + case TinyImageFormat_B5G5R5A1_UNORM: return 1; + case TinyImageFormat_A1B5G5R5_UNORM: return 5; + case TinyImageFormat_A1R5G5B5_UNORM: return 5; + case TinyImageFormat_R5G5B5X1_UNORM: return 1; + case TinyImageFormat_B5G5R5X1_UNORM: return 1; + case TinyImageFormat_X1R5G5B5_UNORM: return 5; + case TinyImageFormat_X1B5G5R5_UNORM: return 5; + case TinyImageFormat_R8G8_UNORM: return 0; + case TinyImageFormat_R8G8_SNORM: return 0; + case TinyImageFormat_G8R8_UNORM: return 0; + case TinyImageFormat_G8R8_SNORM: return 0; + case TinyImageFormat_R8G8_UINT: return 0; + case TinyImageFormat_R8G8_SINT: return 0; + case TinyImageFormat_R8G8_SRGB: return 0; + case TinyImageFormat_R16_UNORM: return 0; + case TinyImageFormat_R16_SNORM: return 0; + case TinyImageFormat_R16_UINT: return 0; + case TinyImageFormat_R16_SINT: return 0; + case TinyImageFormat_R16_SFLOAT: return 0; + case TinyImageFormat_R16_SBFLOAT: return 0; + case TinyImageFormat_R8G8B8_UNORM: return 0; + case TinyImageFormat_R8G8B8_SNORM: return 0; + case TinyImageFormat_R8G8B8_UINT: return 0; + case TinyImageFormat_R8G8B8_SINT: return 0; + case TinyImageFormat_R8G8B8_SRGB: return 0; + case TinyImageFormat_B8G8R8_UNORM: return 0; + case TinyImageFormat_B8G8R8_SNORM: return 0; + case TinyImageFormat_B8G8R8_UINT: return 0; + case TinyImageFormat_B8G8R8_SINT: return 0; + case TinyImageFormat_B8G8R8_SRGB: return 0; + case TinyImageFormat_R16G16_UNORM: return 0; + case TinyImageFormat_G16R16_UNORM: return 0; + case TinyImageFormat_R16G16_SNORM: return 0; + case TinyImageFormat_G16R16_SNORM: return 0; + case TinyImageFormat_R16G16_UINT: return 0; + case TinyImageFormat_R16G16_SINT: return 0; + case TinyImageFormat_R16G16_SFLOAT: return 0; + case TinyImageFormat_R16G16_SBFLOAT: return 0; + case TinyImageFormat_R32_UINT: return 0; + case TinyImageFormat_R32_SINT: return 0; + case TinyImageFormat_R32_SFLOAT: return 0; + case TinyImageFormat_A2R10G10B10_UNORM: return 10; + case TinyImageFormat_A2R10G10B10_UINT: return 10; + case TinyImageFormat_A2R10G10B10_SNORM: return 10; + case TinyImageFormat_A2R10G10B10_SINT: return 10; + case TinyImageFormat_A2B10G10R10_UNORM: return 10; + case TinyImageFormat_A2B10G10R10_UINT: return 10; + case TinyImageFormat_A2B10G10R10_SNORM: return 10; + case TinyImageFormat_A2B10G10R10_SINT: return 10; + case TinyImageFormat_R10G10B10A2_UNORM: return 2; + case TinyImageFormat_R10G10B10A2_UINT: return 2; + case TinyImageFormat_R10G10B10A2_SNORM: return 2; + case TinyImageFormat_R10G10B10A2_SINT: return 2; + case TinyImageFormat_B10G10R10A2_UNORM: return 2; + case TinyImageFormat_B10G10R10A2_UINT: return 2; + case TinyImageFormat_B10G10R10A2_SNORM: return 2; + case TinyImageFormat_B10G10R10A2_SINT: return 2; + case TinyImageFormat_B10G11R11_UFLOAT: return 0; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 9; + case TinyImageFormat_R16G16B16_UNORM: return 0; + case TinyImageFormat_R16G16B16_SNORM: return 0; + case TinyImageFormat_R16G16B16_UINT: return 0; + case TinyImageFormat_R16G16B16_SINT: return 0; + case TinyImageFormat_R16G16B16_SFLOAT: return 0; + case TinyImageFormat_R16G16B16_SBFLOAT: return 0; + case TinyImageFormat_R16G16B16A16_UNORM: return 16; + case TinyImageFormat_R16G16B16A16_SNORM: return 16; + case TinyImageFormat_R16G16B16A16_UINT: return 16; + case TinyImageFormat_R16G16B16A16_SINT: return 16; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 16; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 16; + case TinyImageFormat_R32G32_UINT: return 0; + case TinyImageFormat_R32G32_SINT: return 0; + case TinyImageFormat_R32G32_SFLOAT: return 0; + case TinyImageFormat_R32G32B32_UINT: return 0; + case TinyImageFormat_R32G32B32_SINT: return 0; + case TinyImageFormat_R32G32B32_SFLOAT: return 0; + case TinyImageFormat_R32G32B32A32_UINT: return 32; + case TinyImageFormat_R32G32B32A32_SINT: return 32; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 32; + case TinyImageFormat_R64_UINT: return 0; + case TinyImageFormat_R64_SINT: return 0; + case TinyImageFormat_R64_SFLOAT: return 0; + case TinyImageFormat_R64G64_UINT: return 0; + case TinyImageFormat_R64G64_SINT: return 0; + case TinyImageFormat_R64G64_SFLOAT: return 0; + case TinyImageFormat_R64G64B64_UINT: return 0; + case TinyImageFormat_R64G64B64_SINT: return 0; + case TinyImageFormat_R64G64B64_SFLOAT: return 0; + case TinyImageFormat_R64G64B64A64_UINT: return 64; + case TinyImageFormat_R64G64B64A64_SINT: return 64; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 64; + case TinyImageFormat_D16_UNORM: return 0; + case TinyImageFormat_X8_D24_UNORM: return 0; + case TinyImageFormat_D32_SFLOAT: return 0; + case TinyImageFormat_S8_UINT: return 0; + case TinyImageFormat_D16_UNORM_S8_UINT: return 0; + case TinyImageFormat_D24_UNORM_S8_UINT: return 0; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 0; + case TinyImageFormat_DXBC1_RGB_UNORM: return 0; + case TinyImageFormat_DXBC1_RGB_SRGB: return 0; + case TinyImageFormat_DXBC1_RGBA_UNORM: return 0; + case TinyImageFormat_DXBC1_RGBA_SRGB: return 0; + case TinyImageFormat_DXBC2_UNORM: return 4; + case TinyImageFormat_DXBC2_SRGB: return 4; + case TinyImageFormat_DXBC3_UNORM: return 4; + case TinyImageFormat_DXBC3_SRGB: return 4; + case TinyImageFormat_DXBC6H_UFLOAT: return 16; + case TinyImageFormat_DXBC6H_SFLOAT: return 16; + case TinyImageFormat_DXBC7_UNORM: return 4; + case TinyImageFormat_DXBC7_SRGB: return 4; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 11; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 11; + case TinyImageFormat_CLUT_P4: return 0; + case TinyImageFormat_CLUT_P4A4: return 0; + case TinyImageFormat_CLUT_P8: return 0; + case TinyImageFormat_CLUT_P8A8: return 0; + default: return 8; + } + } + TinyImageFormat_ASSERT(false); + return 0; +} + +TIF_CONSTEXPR inline double TinyImageFormat_MinAtPhysical(TinyImageFormat const fmt, uint32_t const channel) +{ + if(TinyImageFormat_IsHomogenous(fmt) || channel == 0) + { + switch(fmt) + { + case TinyImageFormat_R8_SNORM: return -1.000000; + case TinyImageFormat_R8_SINT: return -128.000000; + case TinyImageFormat_R8G8_SNORM: return -1.000000; + case TinyImageFormat_G8R8_SNORM: return -1.000000; + case TinyImageFormat_R8G8_SINT: return -128.000000; + case TinyImageFormat_R16_SNORM: return -1.000000; + case TinyImageFormat_R16_SINT: return -32768.000000; + case TinyImageFormat_R16_SFLOAT: return -65504.000000; + case TinyImageFormat_R8G8B8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8_SINT: return -128.000000; + case TinyImageFormat_R8G8B8A8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8A8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8A8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8A8_SINT: return -128.000000; + case TinyImageFormat_R16G16_SNORM: return -1.000000; + case TinyImageFormat_G16R16_SNORM: return -1.000000; + case TinyImageFormat_R16G16_SINT: return -32768.000000; + case TinyImageFormat_R16G16_SFLOAT: return -65504.000000; + case TinyImageFormat_R32_SINT: return -2147483648.000000; + case TinyImageFormat_R32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_A2R10G10B10_SNORM: return -1.000000; + case TinyImageFormat_A2R10G10B10_SINT: return -2.000000; + case TinyImageFormat_A2B10G10R10_SNORM: return -1.000000; + case TinyImageFormat_A2B10G10R10_SINT: return -2.000000; + case TinyImageFormat_R10G10B10A2_SNORM: return -1.000000; + case TinyImageFormat_R10G10B10A2_SINT: return -512.000000; + case TinyImageFormat_B10G10R10A2_SNORM: return -1.000000; + case TinyImageFormat_B10G10R10A2_SINT: return -512.000000; + case TinyImageFormat_R16G16B16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return -65504.000000; + case TinyImageFormat_R16G16B16A16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16A16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return -65504.000000; + case TinyImageFormat_R32G32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32A32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64A64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_D32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_DXBC4_SNORM: return -1.000000; + case TinyImageFormat_DXBC5_SNORM: return -1.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return -1.000000; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return -1.000000; + default: return 0.000000; + } + } + else if(channel == 1) + { + switch(fmt) + { + case TinyImageFormat_R8G8_SNORM: return -1.000000; + case TinyImageFormat_G8R8_SNORM: return -1.000000; + case TinyImageFormat_R8G8_SINT: return -128.000000; + case TinyImageFormat_R8G8B8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8_SINT: return -128.000000; + case TinyImageFormat_R8G8B8A8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8A8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8A8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8A8_SINT: return -128.000000; + case TinyImageFormat_R16G16_SNORM: return -1.000000; + case TinyImageFormat_G16R16_SNORM: return -1.000000; + case TinyImageFormat_R16G16_SINT: return -32768.000000; + case TinyImageFormat_R16G16_SFLOAT: return -65504.000000; + case TinyImageFormat_A2R10G10B10_SNORM: return -1.000000; + case TinyImageFormat_A2R10G10B10_SINT: return -512.000000; + case TinyImageFormat_A2B10G10R10_SNORM: return -1.000000; + case TinyImageFormat_A2B10G10R10_SINT: return -512.000000; + case TinyImageFormat_R10G10B10A2_SNORM: return -1.000000; + case TinyImageFormat_R10G10B10A2_SINT: return -512.000000; + case TinyImageFormat_B10G10R10A2_SNORM: return -1.000000; + case TinyImageFormat_B10G10R10A2_SINT: return -512.000000; + case TinyImageFormat_R16G16B16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return -65504.000000; + case TinyImageFormat_R16G16B16A16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16A16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return -65504.000000; + case TinyImageFormat_R32G32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32A32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64G64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64A64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_DXBC4_SNORM: return -1.000000; + case TinyImageFormat_DXBC5_SNORM: return -1.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return -1.000000; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return -1.000000; + default: return 0.000000; + } + } + else if(channel == 2) + { + switch(fmt) + { + case TinyImageFormat_R8G8B8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8_SINT: return -128.000000; + case TinyImageFormat_R8G8B8A8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8A8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8A8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8A8_SINT: return -128.000000; + case TinyImageFormat_A2R10G10B10_SNORM: return -1.000000; + case TinyImageFormat_A2R10G10B10_SINT: return -512.000000; + case TinyImageFormat_A2B10G10R10_SNORM: return -1.000000; + case TinyImageFormat_A2B10G10R10_SINT: return -512.000000; + case TinyImageFormat_R10G10B10A2_SNORM: return -1.000000; + case TinyImageFormat_R10G10B10A2_SINT: return -512.000000; + case TinyImageFormat_B10G10R10A2_SNORM: return -1.000000; + case TinyImageFormat_B10G10R10A2_SINT: return -512.000000; + case TinyImageFormat_R16G16B16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return -65504.000000; + case TinyImageFormat_R16G16B16A16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16A16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return -65504.000000; + case TinyImageFormat_R32G32B32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32A32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64G64B64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64A64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_DXBC4_SNORM: return -1.000000; + case TinyImageFormat_DXBC5_SNORM: return -1.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return -1.000000; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return -1.000000; + default: return 0.000000; + } + } + else if(channel == 3) + { + switch(fmt) + { + case TinyImageFormat_R8G8B8A8_SNORM: return -1.000000; + case TinyImageFormat_R8G8B8A8_SINT: return -128.000000; + case TinyImageFormat_B8G8R8A8_SNORM: return -1.000000; + case TinyImageFormat_B8G8R8A8_SINT: return -128.000000; + case TinyImageFormat_A2R10G10B10_SNORM: return -1.000000; + case TinyImageFormat_A2R10G10B10_SINT: return -512.000000; + case TinyImageFormat_A2B10G10R10_SNORM: return -1.000000; + case TinyImageFormat_A2B10G10R10_SINT: return -512.000000; + case TinyImageFormat_R10G10B10A2_SNORM: return -1.000000; + case TinyImageFormat_R10G10B10A2_SINT: return -2.000000; + case TinyImageFormat_B10G10R10A2_SNORM: return -1.000000; + case TinyImageFormat_B10G10R10A2_SINT: return -2.000000; + case TinyImageFormat_R16G16B16A16_SNORM: return -1.000000; + case TinyImageFormat_R16G16B16A16_SINT: return -32768.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return -65504.000000; + case TinyImageFormat_R32G32B32A32_SINT: return -2147483648.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64G64B64A64_SINT: return -9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_DXBC4_SNORM: return -1.000000; + case TinyImageFormat_DXBC5_SNORM: return -1.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return -340282346638528859811704183484516925440.000000; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return -1.000000; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return -1.000000; + default: return 0.000000; + } + } + TinyImageFormat_ASSERT(false); + return 0.0; +} + +TIF_CONSTEXPR inline double TinyImageFormat_MaxAtPhysical(TinyImageFormat const fmt, uint32_t const channel) +{ + if(TinyImageFormat_IsHomogenous(fmt) || channel == 0) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0.000000; + case TinyImageFormat_R8_UINT: return 255.000000; + case TinyImageFormat_R8_SINT: return 127.000000; + case TinyImageFormat_X4R4G4B4_UNORM: return 15.000000; + case TinyImageFormat_X4B4G4R4_UNORM: return 15.000000; + case TinyImageFormat_R8G8_UINT: return 255.000000; + case TinyImageFormat_R8G8_SINT: return 127.000000; + case TinyImageFormat_R16_UINT: return 65535.000000; + case TinyImageFormat_R16_SINT: return 32767.000000; + case TinyImageFormat_R16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16_SBFLOAT: return 0.000000; + case TinyImageFormat_R8G8B8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8_SINT: return 127.000000; + case TinyImageFormat_R8G8B8A8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8A8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8A8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8A8_SINT: return 127.000000; + case TinyImageFormat_R16G16_UINT: return 65535.000000; + case TinyImageFormat_R16G16_SINT: return 32767.000000; + case TinyImageFormat_R16G16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32_UINT: return 4294967295.000000; + case TinyImageFormat_R32_SINT: return 2147483647.000000; + case TinyImageFormat_R32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_A2R10G10B10_UINT: return 3.000000; + case TinyImageFormat_A2B10G10R10_UINT: return 3.000000; + case TinyImageFormat_R10G10B10A2_UINT: return 1023.000000; + case TinyImageFormat_R10G10B10A2_SINT: return 511.000000; + case TinyImageFormat_B10G10R10A2_UINT: return 1023.000000; + case TinyImageFormat_B10G10R10A2_SINT: return 511.000000; + case TinyImageFormat_B10G11R11_UFLOAT: return 65000.000000; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 31.000000; + case TinyImageFormat_R16G16B16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16_SBFLOAT: return 0.000000; + case TinyImageFormat_R16G16B16A16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16A16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32G32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32A32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32A32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64A64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64A64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_X8_D24_UNORM: return 255.000000; + case TinyImageFormat_D32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_S8_UINT: return 255.000000; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_DXBC6H_UFLOAT: return 131008.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return 65504.000000; + default: return 1.000000; + } + } + else if(channel == 1) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0.000000; + case TinyImageFormat_R1_UNORM: return 0.000000; + case TinyImageFormat_R2_UNORM: return 0.000000; + case TinyImageFormat_R4_UNORM: return 0.000000; + case TinyImageFormat_A8_UNORM: return 0.000000; + case TinyImageFormat_R8_UNORM: return 0.000000; + case TinyImageFormat_R8_SNORM: return 0.000000; + case TinyImageFormat_R8_UINT: return 0.000000; + case TinyImageFormat_R8_SINT: return 0.000000; + case TinyImageFormat_R8_SRGB: return 0.000000; + case TinyImageFormat_R8G8_UINT: return 255.000000; + case TinyImageFormat_R8G8_SINT: return 127.000000; + case TinyImageFormat_R16_UNORM: return 0.000000; + case TinyImageFormat_R16_SNORM: return 0.000000; + case TinyImageFormat_R16_UINT: return 0.000000; + case TinyImageFormat_R16_SINT: return 0.000000; + case TinyImageFormat_R16_SFLOAT: return 0.000000; + case TinyImageFormat_R16_SBFLOAT: return 0.000000; + case TinyImageFormat_R8G8B8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8_SINT: return 127.000000; + case TinyImageFormat_R8G8B8A8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8A8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8A8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8A8_SINT: return 127.000000; + case TinyImageFormat_R16G16_UINT: return 65535.000000; + case TinyImageFormat_R16G16_SINT: return 32767.000000; + case TinyImageFormat_R16G16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32_UINT: return 0.000000; + case TinyImageFormat_R32_SINT: return 0.000000; + case TinyImageFormat_R32_SFLOAT: return 0.000000; + case TinyImageFormat_A2R10G10B10_UINT: return 1023.000000; + case TinyImageFormat_A2R10G10B10_SINT: return 511.000000; + case TinyImageFormat_A2B10G10R10_UINT: return 1023.000000; + case TinyImageFormat_A2B10G10R10_SINT: return 511.000000; + case TinyImageFormat_R10G10B10A2_UINT: return 1023.000000; + case TinyImageFormat_R10G10B10A2_SINT: return 511.000000; + case TinyImageFormat_B10G10R10A2_UINT: return 1023.000000; + case TinyImageFormat_B10G10R10A2_SINT: return 511.000000; + case TinyImageFormat_B10G11R11_UFLOAT: return 65500.000000; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 65408.000000; + case TinyImageFormat_R16G16B16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16_SBFLOAT: return 0.000000; + case TinyImageFormat_R16G16B16A16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16A16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32G32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32A32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32A32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64_UINT: return 0.000000; + case TinyImageFormat_R64_SINT: return 0.000000; + case TinyImageFormat_R64_SFLOAT: return 0.000000; + case TinyImageFormat_R64G64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64A64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64A64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_D16_UNORM: return 0.000000; + case TinyImageFormat_D32_SFLOAT: return 0.000000; + case TinyImageFormat_S8_UINT: return 0.000000; + case TinyImageFormat_D16_UNORM_S8_UINT: return 255.000000; + case TinyImageFormat_D24_UNORM_S8_UINT: return 255.000000; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 255.000000; + case TinyImageFormat_DXBC6H_UFLOAT: return 131008.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return 65504.000000; + default: return 1.000000; + } + } + else if(channel == 2) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0.000000; + case TinyImageFormat_R1_UNORM: return 0.000000; + case TinyImageFormat_R2_UNORM: return 0.000000; + case TinyImageFormat_R4_UNORM: return 0.000000; + case TinyImageFormat_R4G4_UNORM: return 0.000000; + case TinyImageFormat_G4R4_UNORM: return 0.000000; + case TinyImageFormat_A8_UNORM: return 0.000000; + case TinyImageFormat_R8_UNORM: return 0.000000; + case TinyImageFormat_R8_SNORM: return 0.000000; + case TinyImageFormat_R8_UINT: return 0.000000; + case TinyImageFormat_R8_SINT: return 0.000000; + case TinyImageFormat_R8_SRGB: return 0.000000; + case TinyImageFormat_R8G8_UNORM: return 0.000000; + case TinyImageFormat_R8G8_SNORM: return 0.000000; + case TinyImageFormat_G8R8_UNORM: return 0.000000; + case TinyImageFormat_G8R8_SNORM: return 0.000000; + case TinyImageFormat_R8G8_UINT: return 0.000000; + case TinyImageFormat_R8G8_SINT: return 0.000000; + case TinyImageFormat_R8G8_SRGB: return 0.000000; + case TinyImageFormat_R16_UNORM: return 0.000000; + case TinyImageFormat_R16_SNORM: return 0.000000; + case TinyImageFormat_R16_UINT: return 0.000000; + case TinyImageFormat_R16_SINT: return 0.000000; + case TinyImageFormat_R16_SFLOAT: return 0.000000; + case TinyImageFormat_R16_SBFLOAT: return 0.000000; + case TinyImageFormat_R8G8B8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8_SINT: return 127.000000; + case TinyImageFormat_R8G8B8A8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8A8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8A8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8A8_SINT: return 127.000000; + case TinyImageFormat_R16G16_UNORM: return 0.000000; + case TinyImageFormat_G16R16_UNORM: return 0.000000; + case TinyImageFormat_R16G16_SNORM: return 0.000000; + case TinyImageFormat_G16R16_SNORM: return 0.000000; + case TinyImageFormat_R16G16_UINT: return 0.000000; + case TinyImageFormat_R16G16_SINT: return 0.000000; + case TinyImageFormat_R16G16_SFLOAT: return 0.000000; + case TinyImageFormat_R16G16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32_UINT: return 0.000000; + case TinyImageFormat_R32_SINT: return 0.000000; + case TinyImageFormat_R32_SFLOAT: return 0.000000; + case TinyImageFormat_A2R10G10B10_UINT: return 1023.000000; + case TinyImageFormat_A2R10G10B10_SINT: return 511.000000; + case TinyImageFormat_A2B10G10R10_UINT: return 1023.000000; + case TinyImageFormat_A2B10G10R10_SINT: return 511.000000; + case TinyImageFormat_R10G10B10A2_UINT: return 1023.000000; + case TinyImageFormat_R10G10B10A2_SINT: return 511.000000; + case TinyImageFormat_B10G10R10A2_UINT: return 1023.000000; + case TinyImageFormat_B10G10R10A2_SINT: return 511.000000; + case TinyImageFormat_B10G11R11_UFLOAT: return 65500.000000; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 65408.000000; + case TinyImageFormat_R16G16B16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16_SBFLOAT: return 0.000000; + case TinyImageFormat_R16G16B16A16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16A16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32G32_UINT: return 0.000000; + case TinyImageFormat_R32G32_SINT: return 0.000000; + case TinyImageFormat_R32G32_SFLOAT: return 0.000000; + case TinyImageFormat_R32G32B32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R32G32B32A32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32A32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64_UINT: return 0.000000; + case TinyImageFormat_R64_SINT: return 0.000000; + case TinyImageFormat_R64_SFLOAT: return 0.000000; + case TinyImageFormat_R64G64_UINT: return 0.000000; + case TinyImageFormat_R64G64_SINT: return 0.000000; + case TinyImageFormat_R64G64_SFLOAT: return 0.000000; + case TinyImageFormat_R64G64B64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_R64G64B64A64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64A64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_D16_UNORM: return 0.000000; + case TinyImageFormat_X8_D24_UNORM: return 0.000000; + case TinyImageFormat_D32_SFLOAT: return 0.000000; + case TinyImageFormat_S8_UINT: return 0.000000; + case TinyImageFormat_D16_UNORM_S8_UINT: return 0.000000; + case TinyImageFormat_D24_UNORM_S8_UINT: return 0.000000; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 0.000000; + case TinyImageFormat_DXBC6H_UFLOAT: return 131008.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return 65504.000000; + default: return 1.000000; + } + } + else if(channel == 3) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return 0.000000; + case TinyImageFormat_R1_UNORM: return 0.000000; + case TinyImageFormat_R2_UNORM: return 0.000000; + case TinyImageFormat_R4_UNORM: return 0.000000; + case TinyImageFormat_R4G4_UNORM: return 0.000000; + case TinyImageFormat_G4R4_UNORM: return 0.000000; + case TinyImageFormat_A8_UNORM: return 0.000000; + case TinyImageFormat_R8_UNORM: return 0.000000; + case TinyImageFormat_R8_SNORM: return 0.000000; + case TinyImageFormat_R8_UINT: return 0.000000; + case TinyImageFormat_R8_SINT: return 0.000000; + case TinyImageFormat_R8_SRGB: return 0.000000; + case TinyImageFormat_B2G3R3_UNORM: return 0.000000; + case TinyImageFormat_R5G6B5_UNORM: return 0.000000; + case TinyImageFormat_B5G6R5_UNORM: return 0.000000; + case TinyImageFormat_R8G8_UNORM: return 0.000000; + case TinyImageFormat_R8G8_SNORM: return 0.000000; + case TinyImageFormat_G8R8_UNORM: return 0.000000; + case TinyImageFormat_G8R8_SNORM: return 0.000000; + case TinyImageFormat_R8G8_UINT: return 0.000000; + case TinyImageFormat_R8G8_SINT: return 0.000000; + case TinyImageFormat_R8G8_SRGB: return 0.000000; + case TinyImageFormat_R16_UNORM: return 0.000000; + case TinyImageFormat_R16_SNORM: return 0.000000; + case TinyImageFormat_R16_UINT: return 0.000000; + case TinyImageFormat_R16_SINT: return 0.000000; + case TinyImageFormat_R16_SFLOAT: return 0.000000; + case TinyImageFormat_R16_SBFLOAT: return 0.000000; + case TinyImageFormat_R8G8B8_UNORM: return 0.000000; + case TinyImageFormat_R8G8B8_SNORM: return 0.000000; + case TinyImageFormat_R8G8B8_UINT: return 0.000000; + case TinyImageFormat_R8G8B8_SINT: return 0.000000; + case TinyImageFormat_R8G8B8_SRGB: return 0.000000; + case TinyImageFormat_B8G8R8_UNORM: return 0.000000; + case TinyImageFormat_B8G8R8_SNORM: return 0.000000; + case TinyImageFormat_B8G8R8_UINT: return 0.000000; + case TinyImageFormat_B8G8R8_SINT: return 0.000000; + case TinyImageFormat_B8G8R8_SRGB: return 0.000000; + case TinyImageFormat_R8G8B8A8_UINT: return 255.000000; + case TinyImageFormat_R8G8B8A8_SINT: return 127.000000; + case TinyImageFormat_B8G8R8A8_UINT: return 255.000000; + case TinyImageFormat_B8G8R8A8_SINT: return 127.000000; + case TinyImageFormat_R16G16_UNORM: return 0.000000; + case TinyImageFormat_G16R16_UNORM: return 0.000000; + case TinyImageFormat_R16G16_SNORM: return 0.000000; + case TinyImageFormat_G16R16_SNORM: return 0.000000; + case TinyImageFormat_R16G16_UINT: return 0.000000; + case TinyImageFormat_R16G16_SINT: return 0.000000; + case TinyImageFormat_R16G16_SFLOAT: return 0.000000; + case TinyImageFormat_R16G16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32_UINT: return 0.000000; + case TinyImageFormat_R32_SINT: return 0.000000; + case TinyImageFormat_R32_SFLOAT: return 0.000000; + case TinyImageFormat_A2R10G10B10_UINT: return 1023.000000; + case TinyImageFormat_A2R10G10B10_SINT: return 511.000000; + case TinyImageFormat_A2B10G10R10_UINT: return 1023.000000; + case TinyImageFormat_A2B10G10R10_SINT: return 511.000000; + case TinyImageFormat_R10G10B10A2_UINT: return 3.000000; + case TinyImageFormat_B10G10R10A2_UINT: return 3.000000; + case TinyImageFormat_B10G11R11_UFLOAT: return 0.000000; + case TinyImageFormat_E5B9G9R9_UFLOAT: return 65408.000000; + case TinyImageFormat_R16G16B16_UNORM: return 0.000000; + case TinyImageFormat_R16G16B16_SNORM: return 0.000000; + case TinyImageFormat_R16G16B16_UINT: return 0.000000; + case TinyImageFormat_R16G16B16_SINT: return 0.000000; + case TinyImageFormat_R16G16B16_SFLOAT: return 0.000000; + case TinyImageFormat_R16G16B16_SBFLOAT: return 0.000000; + case TinyImageFormat_R16G16B16A16_UINT: return 65535.000000; + case TinyImageFormat_R16G16B16A16_SINT: return 32767.000000; + case TinyImageFormat_R16G16B16A16_SFLOAT: return 65504.000000; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return 0.000000; + case TinyImageFormat_R32G32_UINT: return 0.000000; + case TinyImageFormat_R32G32_SINT: return 0.000000; + case TinyImageFormat_R32G32_SFLOAT: return 0.000000; + case TinyImageFormat_R32G32B32_UINT: return 0.000000; + case TinyImageFormat_R32G32B32_SINT: return 0.000000; + case TinyImageFormat_R32G32B32_SFLOAT: return 0.000000; + case TinyImageFormat_R32G32B32A32_UINT: return 4294967295.000000; + case TinyImageFormat_R32G32B32A32_SINT: return 2147483647.000000; + case TinyImageFormat_R32G32B32A32_SFLOAT: return 340282346638528859811704183484516925440.000000; + case TinyImageFormat_R64_UINT: return 0.000000; + case TinyImageFormat_R64_SINT: return 0.000000; + case TinyImageFormat_R64_SFLOAT: return 0.000000; + case TinyImageFormat_R64G64_UINT: return 0.000000; + case TinyImageFormat_R64G64_SINT: return 0.000000; + case TinyImageFormat_R64G64_SFLOAT: return 0.000000; + case TinyImageFormat_R64G64B64_UINT: return 0.000000; + case TinyImageFormat_R64G64B64_SINT: return 0.000000; + case TinyImageFormat_R64G64B64_SFLOAT: return 0.000000; + case TinyImageFormat_R64G64B64A64_UINT: return 18446744073709551616.000000; + case TinyImageFormat_R64G64B64A64_SINT: return 9223372036854775808.000000; + case TinyImageFormat_R64G64B64A64_SFLOAT: return 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000; + case TinyImageFormat_D16_UNORM: return 0.000000; + case TinyImageFormat_X8_D24_UNORM: return 0.000000; + case TinyImageFormat_D32_SFLOAT: return 0.000000; + case TinyImageFormat_S8_UINT: return 0.000000; + case TinyImageFormat_D16_UNORM_S8_UINT: return 0.000000; + case TinyImageFormat_D24_UNORM_S8_UINT: return 0.000000; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return 0.000000; + case TinyImageFormat_DXBC6H_UFLOAT: return 131008.000000; + case TinyImageFormat_DXBC6H_SFLOAT: return 65504.000000; + default: return 1.000000; + } + } + TinyImageFormat_ASSERT(false); + return 0.0; +} + +TIF_CONSTEXPR inline TinyImageFormat_LogicalChannel TinyImageFormat_PhysicalChannelToLogical(TinyImageFormat const fmt, int8_t const channel) +{ + TinyImageFormat_ASSERT(channel != TinyImageFormat_PC_CONST_0); + TinyImageFormat_ASSERT(channel != TinyImageFormat_PC_CONST_1); + if(channel == TinyImageFormat_PC_0) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_LC_0; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_B2G3R3_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B4G4R4A4_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B4G4R4X4_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B5G6R5_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B5G5R5A1_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_B5G5R5X1_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B2G3R3A8_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_B8G8R8_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8_SNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8_UINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8_SINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8_SRGB: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8A8_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8A8_SNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8A8_UINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8A8_SINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8A8_SRGB: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B8G8R8X8_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_B10G10R10A2_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B10G10R10A2_UINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B10G10R10A2_SNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B10G10R10A2_SINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_B10G11R11_UFLOAT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_LC_Green; + default: return TinyImageFormat_LC_Red; + } + } + else if(channel == TinyImageFormat_PC_1) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_LC_0; + case TinyImageFormat_R1_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R2_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R4_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_SRGB: return TinyImageFormat_LC_0; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_R16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SBFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_R32_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_R64_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_D16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_D32_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC4_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC4_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P4: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P4A4: return TinyImageFormat_LC_Alpha; + case TinyImageFormat_CLUT_P8: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P8A8: return TinyImageFormat_LC_Alpha; + default: return TinyImageFormat_LC_Green; + } + } + else if(channel == TinyImageFormat_PC_2) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_LC_0; + case TinyImageFormat_R1_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R2_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R4_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R4G4_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_SRGB: return TinyImageFormat_LC_0; + case TinyImageFormat_B2G3R3_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B4G4R4A4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B4G4R4X4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_B5G6R5_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B5G5R5A1_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_B5G5R5X1_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_B2G3R3A8_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_R8G8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8G8_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8G8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R8G8_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R8G8_SRGB: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16_SBFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_B8G8R8_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8_UINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8_SINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8_SRGB: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8A8_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8A8_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8A8_UINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8A8_SINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8A8_SRGB: return TinyImageFormat_LC_Red; + case TinyImageFormat_B8G8R8X8_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_R16G16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R16G16_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R16G16_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16G16_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16G16_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_R16G16_SBFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_LC_Green; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_LC_Green; + case TinyImageFormat_B10G10R10A2_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B10G10R10A2_UINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B10G10R10A2_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_B10G10R10A2_SINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B10G11R11_UFLOAT: return TinyImageFormat_LC_Red; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_LC_Green; + case TinyImageFormat_R32G32_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32G32_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R32G32_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64G64_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64G64_SINT: return TinyImageFormat_LC_0; + case TinyImageFormat_R64G64_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_D16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_D32_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_D16_UNORM_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_D24_UNORM_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC4_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC4_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC5_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC5_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P4: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P4A4: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P8: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P8A8: return TinyImageFormat_LC_0; + default: return TinyImageFormat_LC_Blue; + } + } + else if(channel == TinyImageFormat_PC_3) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_LC_0; + case TinyImageFormat_R1_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R2_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R4G4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_R8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R8_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R8_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8_SRGB: return TinyImageFormat_LC_1; + case TinyImageFormat_B2G3R3_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R4G4B4X4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B4G4R4X4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_R5G6B5_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B5G6R5_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_R5G5B5X1_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B5G5R5X1_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_R8G8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8_SRGB: return TinyImageFormat_LC_1; + case TinyImageFormat_R16_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16_SBFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8B8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8B8_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8B8_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8B8_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8B8_SRGB: return TinyImageFormat_LC_1; + case TinyImageFormat_B8G8R8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B8G8R8_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B8G8R8_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_B8G8R8_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_B8G8R8_SRGB: return TinyImageFormat_LC_1; + case TinyImageFormat_R8G8B8X8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_B8G8R8X8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16_SBFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_LC_Blue; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_LC_Red; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_LC_Red; + case TinyImageFormat_B10G11R11_UFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_LC_Red; + case TinyImageFormat_R16G16B16_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16B16_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16B16_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16B16_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16B16_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R16G16B16_SBFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32G32_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32G32_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32G32_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32G32B32_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32G32B32_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R32G32B32_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64G64_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64G64_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64G64_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64G64B64_UINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64G64B64_SINT: return TinyImageFormat_LC_1; + case TinyImageFormat_R64G64B64_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_D16_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_LC_0; + case TinyImageFormat_D32_SFLOAT: return TinyImageFormat_LC_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_D16_UNORM_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_D24_UNORM_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TinyImageFormat_LC_0; + case TinyImageFormat_DXBC1_RGB_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC1_RGB_SRGB: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC4_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC4_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC5_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC5_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC6H_UFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_DXBC6H_SFLOAT: return TinyImageFormat_LC_1; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return TinyImageFormat_LC_1; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return TinyImageFormat_LC_1; + case TinyImageFormat_CLUT_P4: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P4A4: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P8: return TinyImageFormat_LC_0; + case TinyImageFormat_CLUT_P8A8: return TinyImageFormat_LC_0; + default: return TinyImageFormat_LC_Alpha; + } + } + TinyImageFormat_ASSERT(false); + return TinyImageFormat_LC_0; +} + +TIF_CONSTEXPR inline int8_t TinyImageFormat_LogicalChannelToPhysical(TinyImageFormat const fmt, TinyImageFormat_LogicalChannel const channel) +{ + TinyImageFormat_ASSERT(channel != TinyImageFormat_LC_0); + TinyImageFormat_ASSERT(channel != TinyImageFormat_LC_1); + if(channel == TinyImageFormat_LC_Red) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_B2G3R3_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B4G4R4A4_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B4G4R4X4_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_B5G6R5_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B5G5R5A1_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_B5G5R5X1_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_B2G3R3A8_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_B8G8R8_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8_SNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8_UINT: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8_SINT: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8_SRGB: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8A8_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8A8_SNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8A8_UINT: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8A8_SINT: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8A8_SRGB: return TinyImageFormat_PC_2; + case TinyImageFormat_B8G8R8X8_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_PC_1; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_PC_1; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_PC_3; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_PC_3; + case TinyImageFormat_B10G10R10A2_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B10G10R10A2_UINT: return TinyImageFormat_PC_2; + case TinyImageFormat_B10G10R10A2_SNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_B10G10R10A2_SINT: return TinyImageFormat_PC_2; + case TinyImageFormat_B10G11R11_UFLOAT: return TinyImageFormat_PC_2; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_PC_3; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_S8_UINT: return TinyImageFormat_PC_CONST_0; + default: return TinyImageFormat_PC_0; + } + } + else if(channel == TinyImageFormat_LC_Green) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R1_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R2_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R4_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_SRGB: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_R16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SBFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_R32_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_PC_2; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_PC_2; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_PC_2; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_PC_2; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_PC_2; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_PC_2; + case TinyImageFormat_R64_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D32_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_PC_0; + case TinyImageFormat_DXBC4_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_DXBC4_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P4: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P4A4: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P8: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P8A8: return TinyImageFormat_PC_CONST_0; + default: return TinyImageFormat_PC_1; + } + } + else if(channel == TinyImageFormat_LC_Blue) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R1_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R2_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R4_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R4G4_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8_SRGB: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_B2G3R3_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B4G4R4A4_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B4G4R4X4_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_B5G6R5_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B5G5R5A1_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_B5G5R5X1_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_B2G3R3A8_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_R8G8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8G8_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8G8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8G8_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R8G8_SRGB: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16_SBFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_B8G8R8_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8_UINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8_SINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8_SRGB: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8A8_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8A8_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8A8_UINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8A8_SINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8A8_SRGB: return TinyImageFormat_PC_0; + case TinyImageFormat_B8G8R8X8_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_R16G16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16G16_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16G16_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16G16_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16G16_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R16G16_SBFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_PC_3; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_PC_3; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_PC_3; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_PC_1; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_PC_1; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_PC_1; + case TinyImageFormat_B10G10R10A2_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B10G10R10A2_UINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B10G10R10A2_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_B10G10R10A2_SINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B10G11R11_UFLOAT: return TinyImageFormat_PC_0; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_PC_1; + case TinyImageFormat_R32G32_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32G32_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R32G32_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64G64_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64G64_SINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R64G64_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D32_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D16_UNORM_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D24_UNORM_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_DXBC4_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_DXBC4_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_DXBC5_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_DXBC5_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P4: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P4A4: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P8: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P8A8: return TinyImageFormat_PC_CONST_0; + default: return TinyImageFormat_PC_2; + } + } + else if(channel == TinyImageFormat_LC_Alpha) + { + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_R1_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R2_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R4G4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_G4R4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_A8_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_R8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8_SRGB: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B2G3R3_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R4G4B4X4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B4G4R4X4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_A4R4G4B4_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_X4R4G4B4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_A4B4G4R4_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_X4B4G4R4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R5G6B5_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B5G6R5_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_A1B5G5R5_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A1R5G5B5_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_R5G5B5X1_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B5G5R5X1_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_X1R5G5B5_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_X1B5G5R5_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_G8R8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_G8R8_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8_SRGB: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16_SBFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8B8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8B8_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8B8_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8B8_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8B8_SRGB: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B8G8R8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B8G8R8_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B8G8R8_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B8G8R8_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B8G8R8_SRGB: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R8G8B8X8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_B8G8R8X8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_G16R16_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_G16R16_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16_SBFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_A2R10G10B10_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A2R10G10B10_UINT: return TinyImageFormat_PC_0; + case TinyImageFormat_A2R10G10B10_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A2R10G10B10_SINT: return TinyImageFormat_PC_0; + case TinyImageFormat_A2B10G10R10_UNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A2B10G10R10_UINT: return TinyImageFormat_PC_0; + case TinyImageFormat_A2B10G10R10_SNORM: return TinyImageFormat_PC_0; + case TinyImageFormat_A2B10G10R10_SINT: return TinyImageFormat_PC_0; + case TinyImageFormat_B10G11R11_UFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_E5B9G9R9_UFLOAT: return TinyImageFormat_PC_0; + case TinyImageFormat_R16G16B16_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16B16_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16B16_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16B16_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16B16_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R16G16B16_SBFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32G32_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32G32_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32G32_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32G32B32_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32G32B32_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R32G32B32_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64G64_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64G64_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64G64_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64G64B64_UINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64G64B64_SINT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_R64G64B64_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_D16_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_X8_D24_UNORM: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D32_SFLOAT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D16_UNORM_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D24_UNORM_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_DXBC1_RGB_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC1_RGB_SRGB: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC4_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC4_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC5_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC5_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC6H_UFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_DXBC6H_SFLOAT: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return TinyImageFormat_PC_CONST_1; + case TinyImageFormat_CLUT_P4: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P4A4: return TinyImageFormat_PC_1; + case TinyImageFormat_CLUT_P8: return TinyImageFormat_PC_CONST_0; + case TinyImageFormat_CLUT_P8A8: return TinyImageFormat_PC_1; + default: return TinyImageFormat_PC_3; + } + } + TinyImageFormat_ASSERT(false); + return TinyImageFormat_PC_CONST_0; +} + +TIF_CONSTEXPR inline TinyImageFormat TinyImageFormat_ToSRGB(TinyImageFormat const fmt) +{ + switch (fmt) + { + case TinyImageFormat_R8_UNORM: + return TinyImageFormat_R8_SRGB; + case TinyImageFormat_R8_SNORM: + return TinyImageFormat_R8_SRGB; + case TinyImageFormat_R8_UINT: + return TinyImageFormat_R8_SRGB; + case TinyImageFormat_R8_SINT: + return TinyImageFormat_R8_SRGB; + case TinyImageFormat_R8_SRGB: + return TinyImageFormat_R8_SRGB; + case TinyImageFormat_R8G8_UNORM: + return TinyImageFormat_R8G8_SRGB; + case TinyImageFormat_R8G8_SNORM: + return TinyImageFormat_R8G8_SRGB; + case TinyImageFormat_R8G8_UINT: + return TinyImageFormat_R8G8_SRGB; + case TinyImageFormat_R8G8_SINT: + return TinyImageFormat_R8G8_SRGB; + case TinyImageFormat_R8G8_SRGB: + return TinyImageFormat_R8G8_SRGB; + case TinyImageFormat_R8G8B8_UNORM: + return TinyImageFormat_R8G8B8_SRGB; + case TinyImageFormat_R8G8B8_SNORM: + return TinyImageFormat_R8G8B8_SRGB; + case TinyImageFormat_R8G8B8_UINT: + return TinyImageFormat_R8G8B8_SRGB; + case TinyImageFormat_R8G8B8_SINT: + return TinyImageFormat_R8G8B8_SRGB; + case TinyImageFormat_R8G8B8_SRGB: + return TinyImageFormat_R8G8B8_SRGB; + case TinyImageFormat_B8G8R8_UNORM: + return TinyImageFormat_B8G8R8_SRGB; + case TinyImageFormat_B8G8R8_SNORM: + return TinyImageFormat_B8G8R8_SRGB; + case TinyImageFormat_B8G8R8_UINT: + return TinyImageFormat_B8G8R8_SRGB; + case TinyImageFormat_B8G8R8_SINT: + return TinyImageFormat_B8G8R8_SRGB; + case TinyImageFormat_B8G8R8_SRGB: + return TinyImageFormat_B8G8R8_SRGB; + case TinyImageFormat_R8G8B8A8_UNORM: + return TinyImageFormat_R8G8B8A8_SRGB; + case TinyImageFormat_R8G8B8A8_SNORM: + return TinyImageFormat_R8G8B8A8_SRGB; + case TinyImageFormat_R8G8B8A8_UINT: + return TinyImageFormat_R8G8B8A8_SRGB; + case TinyImageFormat_R8G8B8A8_SINT: + return TinyImageFormat_R8G8B8A8_SRGB; + case TinyImageFormat_R8G8B8A8_SRGB: + return TinyImageFormat_R8G8B8A8_SRGB; + case TinyImageFormat_B8G8R8A8_UNORM: + return TinyImageFormat_B8G8R8A8_SRGB; + case TinyImageFormat_B8G8R8A8_SNORM: + return TinyImageFormat_B8G8R8A8_SRGB; + case TinyImageFormat_B8G8R8A8_UINT: + return TinyImageFormat_B8G8R8A8_SRGB; + case TinyImageFormat_B8G8R8A8_SINT: + return TinyImageFormat_B8G8R8A8_SRGB; + case TinyImageFormat_B8G8R8A8_SRGB: + return TinyImageFormat_B8G8R8A8_SRGB; + case TinyImageFormat_DXBC1_RGB_UNORM: + return TinyImageFormat_DXBC1_RGB_SRGB; + case TinyImageFormat_DXBC1_RGB_SRGB: + return TinyImageFormat_DXBC1_RGB_SRGB; + case TinyImageFormat_DXBC1_RGBA_UNORM: + return TinyImageFormat_DXBC1_RGBA_SRGB; + case TinyImageFormat_DXBC1_RGBA_SRGB: + return TinyImageFormat_DXBC1_RGBA_SRGB; + case TinyImageFormat_DXBC2_UNORM: + return TinyImageFormat_DXBC2_SRGB; + case TinyImageFormat_DXBC2_SRGB: + return TinyImageFormat_DXBC2_SRGB; + case TinyImageFormat_DXBC3_UNORM: + return TinyImageFormat_DXBC3_SRGB; + case TinyImageFormat_DXBC3_SRGB: + return TinyImageFormat_DXBC3_SRGB; + case TinyImageFormat_DXBC7_UNORM: + return TinyImageFormat_DXBC7_SRGB; + case TinyImageFormat_DXBC7_SRGB: + return TinyImageFormat_DXBC7_SRGB; + case TinyImageFormat_PVRTC1_2BPP_UNORM: + return TinyImageFormat_PVRTC1_2BPP_SRGB; + case TinyImageFormat_PVRTC1_4BPP_UNORM: + return TinyImageFormat_PVRTC1_4BPP_SRGB; + case TinyImageFormat_PVRTC2_2BPP_UNORM: + return TinyImageFormat_PVRTC2_2BPP_SRGB; + case TinyImageFormat_PVRTC2_4BPP_UNORM: + return TinyImageFormat_PVRTC2_4BPP_SRGB; + case TinyImageFormat_PVRTC1_2BPP_SRGB: + return TinyImageFormat_PVRTC1_2BPP_SRGB; + case TinyImageFormat_PVRTC1_4BPP_SRGB: + return TinyImageFormat_PVRTC1_4BPP_SRGB; + case TinyImageFormat_PVRTC2_2BPP_SRGB: + return TinyImageFormat_PVRTC2_2BPP_SRGB; + case TinyImageFormat_PVRTC2_4BPP_SRGB: + return TinyImageFormat_PVRTC2_4BPP_SRGB; + case TinyImageFormat_ETC2_R8G8B8_UNORM: + return TinyImageFormat_ETC2_R8G8B8_SRGB; + case TinyImageFormat_ETC2_R8G8B8_SRGB: + return TinyImageFormat_ETC2_R8G8B8_SRGB; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: + return TinyImageFormat_ETC2_R8G8B8A1_SRGB; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: + return TinyImageFormat_ETC2_R8G8B8A1_SRGB; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: + return TinyImageFormat_ETC2_R8G8B8A8_SRGB; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: + return TinyImageFormat_ETC2_R8G8B8A8_SRGB; + case TinyImageFormat_ASTC_4x4_UNORM: + return TinyImageFormat_ASTC_4x4_SRGB; + case TinyImageFormat_ASTC_4x4_SRGB: + return TinyImageFormat_ASTC_4x4_SRGB; + case TinyImageFormat_ASTC_5x4_UNORM: + return TinyImageFormat_ASTC_5x4_SRGB; + case TinyImageFormat_ASTC_5x4_SRGB: + return TinyImageFormat_ASTC_5x4_SRGB; + case TinyImageFormat_ASTC_5x5_UNORM: + return TinyImageFormat_ASTC_5x5_SRGB; + case TinyImageFormat_ASTC_5x5_SRGB: + return TinyImageFormat_ASTC_5x5_SRGB; + case TinyImageFormat_ASTC_6x5_UNORM: + return TinyImageFormat_ASTC_6x5_SRGB; + case TinyImageFormat_ASTC_6x5_SRGB: + return TinyImageFormat_ASTC_6x5_SRGB; + case TinyImageFormat_ASTC_6x6_UNORM: + return TinyImageFormat_ASTC_6x6_SRGB; + case TinyImageFormat_ASTC_6x6_SRGB: + return TinyImageFormat_ASTC_6x6_SRGB; + case TinyImageFormat_ASTC_8x5_UNORM: + return TinyImageFormat_ASTC_8x5_SRGB; + case TinyImageFormat_ASTC_8x5_SRGB: + return TinyImageFormat_ASTC_8x5_SRGB; + case TinyImageFormat_ASTC_8x6_UNORM: + return TinyImageFormat_ASTC_8x6_SRGB; + case TinyImageFormat_ASTC_8x6_SRGB: + return TinyImageFormat_ASTC_8x6_SRGB; + case TinyImageFormat_ASTC_8x8_UNORM: + return TinyImageFormat_ASTC_8x8_SRGB; + case TinyImageFormat_ASTC_8x8_SRGB: + return TinyImageFormat_ASTC_8x8_SRGB; + case TinyImageFormat_ASTC_10x5_UNORM: + return TinyImageFormat_ASTC_10x5_SRGB; + case TinyImageFormat_ASTC_10x5_SRGB: + return TinyImageFormat_ASTC_10x5_SRGB; + case TinyImageFormat_ASTC_10x6_UNORM: + return TinyImageFormat_ASTC_10x6_SRGB; + case TinyImageFormat_ASTC_10x6_SRGB: + return TinyImageFormat_ASTC_10x6_SRGB; + case TinyImageFormat_ASTC_10x8_UNORM: + return TinyImageFormat_ASTC_10x8_SRGB; + case TinyImageFormat_ASTC_10x8_SRGB: + return TinyImageFormat_ASTC_10x8_SRGB; + case TinyImageFormat_ASTC_10x10_UNORM: + return TinyImageFormat_ASTC_10x10_SRGB; + case TinyImageFormat_ASTC_10x10_SRGB: + return TinyImageFormat_ASTC_10x10_SRGB; + case TinyImageFormat_ASTC_12x10_UNORM: + return TinyImageFormat_ASTC_12x10_SRGB; + case TinyImageFormat_ASTC_12x10_SRGB: + return TinyImageFormat_ASTC_12x10_SRGB; + case TinyImageFormat_ASTC_12x12_UNORM: + return TinyImageFormat_ASTC_12x12_SRGB; + case TinyImageFormat_ASTC_12x12_SRGB: + return TinyImageFormat_ASTC_12x12_SRGB; + default: + return TinyImageFormat_UNDEFINED; + } +} + +TIF_CONSTEXPR inline TinyImageFormat TinyImageFormat_ToUNORM(TinyImageFormat fmt) +{ + switch (fmt) + { + case TinyImageFormat_R8_SNORM: + return TinyImageFormat_R8_UNORM; + case TinyImageFormat_R8_UINT: + return TinyImageFormat_R8_UNORM; + case TinyImageFormat_R8_SINT: + return TinyImageFormat_R8_UNORM; + case TinyImageFormat_R8_SRGB: + return TinyImageFormat_R8_UNORM; + case TinyImageFormat_R8G8_SNORM: + return TinyImageFormat_R8G8_UNORM; + case TinyImageFormat_G8R8_SNORM: + return TinyImageFormat_G8R8_UNORM; + case TinyImageFormat_R8G8_UINT: + return TinyImageFormat_R8G8_UNORM; + case TinyImageFormat_R8G8_SINT: + return TinyImageFormat_R8G8_UNORM; + case TinyImageFormat_R8G8_SRGB: + return TinyImageFormat_R8G8_UNORM; + case TinyImageFormat_R16_SNORM: + return TinyImageFormat_R16_UNORM; + case TinyImageFormat_R16_UINT: + return TinyImageFormat_R16_UNORM; + case TinyImageFormat_R16_SINT: + return TinyImageFormat_R16_UNORM; + case TinyImageFormat_R16_SFLOAT: + return TinyImageFormat_R16_UNORM; + case TinyImageFormat_R16_SBFLOAT: + return TinyImageFormat_R16_UNORM; + case TinyImageFormat_R8G8B8_SNORM: + return TinyImageFormat_R8G8B8_UNORM; + case TinyImageFormat_R8G8B8_UINT: + return TinyImageFormat_R8G8B8_UNORM; + case TinyImageFormat_R8G8B8_SINT: + return TinyImageFormat_R8G8B8_UNORM; + case TinyImageFormat_R8G8B8_SRGB: + return TinyImageFormat_R8G8B8_UNORM; + case TinyImageFormat_B8G8R8_SNORM: + return TinyImageFormat_B8G8R8_UNORM; + case TinyImageFormat_B8G8R8_UINT: + return TinyImageFormat_B8G8R8_UNORM; + case TinyImageFormat_B8G8R8_SINT: + return TinyImageFormat_B8G8R8_UNORM; + case TinyImageFormat_B8G8R8_SRGB: + return TinyImageFormat_B8G8R8_UNORM; + case TinyImageFormat_R8G8B8A8_SNORM: + return TinyImageFormat_R8G8B8A8_UNORM; + case TinyImageFormat_R8G8B8A8_UINT: + return TinyImageFormat_R8G8B8A8_UNORM; + case TinyImageFormat_R8G8B8A8_SINT: + return TinyImageFormat_R8G8B8A8_UNORM; + case TinyImageFormat_R8G8B8A8_SRGB: + return TinyImageFormat_R8G8B8A8_UNORM; + case TinyImageFormat_B8G8R8A8_SNORM: + return TinyImageFormat_B8G8R8A8_UNORM; + case TinyImageFormat_B8G8R8A8_UINT: + return TinyImageFormat_B8G8R8A8_UNORM; + case TinyImageFormat_B8G8R8A8_SINT: + return TinyImageFormat_B8G8R8A8_UNORM; + case TinyImageFormat_B8G8R8A8_SRGB: + return TinyImageFormat_B8G8R8A8_UNORM; + case TinyImageFormat_R16G16_SNORM: + return TinyImageFormat_R16G16_UNORM; + case TinyImageFormat_G16R16_SNORM: + return TinyImageFormat_G16R16_UNORM; + case TinyImageFormat_R16G16_UINT: + return TinyImageFormat_R16G16_UNORM; + case TinyImageFormat_R16G16_SINT: + return TinyImageFormat_R16G16_UNORM; + case TinyImageFormat_R16G16_SFLOAT: + return TinyImageFormat_R16G16_UNORM; + case TinyImageFormat_R16G16_SBFLOAT: + return TinyImageFormat_R16G16_UNORM; + case TinyImageFormat_A2R10G10B10_UINT: + return TinyImageFormat_A2R10G10B10_UNORM; + case TinyImageFormat_A2R10G10B10_SNORM: + return TinyImageFormat_A2R10G10B10_UNORM; + case TinyImageFormat_A2R10G10B10_SINT: + return TinyImageFormat_A2R10G10B10_UNORM; + case TinyImageFormat_A2B10G10R10_UINT: + return TinyImageFormat_A2B10G10R10_UNORM; + case TinyImageFormat_A2B10G10R10_SNORM: + return TinyImageFormat_A2B10G10R10_UNORM; + case TinyImageFormat_A2B10G10R10_SINT: + return TinyImageFormat_A2B10G10R10_UNORM; + case TinyImageFormat_R10G10B10A2_UINT: + return TinyImageFormat_R10G10B10A2_UNORM; + case TinyImageFormat_R10G10B10A2_SNORM: + return TinyImageFormat_R10G10B10A2_UNORM; + case TinyImageFormat_R10G10B10A2_SINT: + return TinyImageFormat_R10G10B10A2_UNORM; + case TinyImageFormat_B10G10R10A2_UINT: + return TinyImageFormat_B10G10R10A2_UNORM; + case TinyImageFormat_B10G10R10A2_SNORM: + return TinyImageFormat_B10G10R10A2_UNORM; + case TinyImageFormat_B10G10R10A2_SINT: + return TinyImageFormat_B10G10R10A2_UNORM; + case TinyImageFormat_R16G16B16_SNORM: + return TinyImageFormat_R16G16B16_UNORM; + case TinyImageFormat_R16G16B16_UINT: + return TinyImageFormat_R16G16B16_UNORM; + case TinyImageFormat_R16G16B16_SINT: + return TinyImageFormat_R16G16B16_UNORM; + case TinyImageFormat_R16G16B16_SFLOAT: + return TinyImageFormat_R16G16B16_UNORM; + case TinyImageFormat_R16G16B16_SBFLOAT: + return TinyImageFormat_R16G16B16_UNORM; + case TinyImageFormat_R16G16B16A16_SNORM: + return TinyImageFormat_R16G16B16A16_UNORM; + case TinyImageFormat_R16G16B16A16_UINT: + return TinyImageFormat_R16G16B16A16_UNORM; + case TinyImageFormat_R16G16B16A16_SINT: + return TinyImageFormat_R16G16B16A16_UNORM; + case TinyImageFormat_R16G16B16A16_SFLOAT: + return TinyImageFormat_R16G16B16A16_UNORM; + case TinyImageFormat_R16G16B16A16_SBFLOAT: + return TinyImageFormat_R16G16B16A16_UNORM; + case TinyImageFormat_DXBC1_RGB_SRGB: + return TinyImageFormat_DXBC1_RGB_UNORM; + case TinyImageFormat_DXBC1_RGBA_SRGB: + return TinyImageFormat_DXBC1_RGBA_UNORM; + case TinyImageFormat_DXBC2_SRGB: + return TinyImageFormat_DXBC2_UNORM; + case TinyImageFormat_DXBC3_SRGB: + return TinyImageFormat_DXBC3_UNORM; + case TinyImageFormat_DXBC4_SNORM: + return TinyImageFormat_DXBC4_UNORM; + case TinyImageFormat_DXBC5_SNORM: + return TinyImageFormat_DXBC5_UNORM; + case TinyImageFormat_DXBC7_SRGB: + return TinyImageFormat_DXBC7_UNORM; + case TinyImageFormat_PVRTC1_2BPP_SRGB: + return TinyImageFormat_PVRTC1_2BPP_UNORM; + case TinyImageFormat_PVRTC1_4BPP_SRGB: + return TinyImageFormat_PVRTC1_4BPP_UNORM; + case TinyImageFormat_PVRTC2_2BPP_SRGB: + return TinyImageFormat_PVRTC2_2BPP_UNORM; + case TinyImageFormat_PVRTC2_4BPP_SRGB: + return TinyImageFormat_PVRTC2_4BPP_UNORM; + case TinyImageFormat_ETC2_R8G8B8_SRGB: + return TinyImageFormat_ETC2_R8G8B8_UNORM; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: + return TinyImageFormat_ETC2_R8G8B8A1_UNORM; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: + return TinyImageFormat_ETC2_R8G8B8A8_UNORM; + case TinyImageFormat_ETC2_EAC_R11_SNORM: + return TinyImageFormat_ETC2_EAC_R11_UNORM; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: + return TinyImageFormat_ETC2_EAC_R11G11_UNORM; + case TinyImageFormat_ASTC_4x4_SRGB: + return TinyImageFormat_ASTC_4x4_UNORM; + case TinyImageFormat_ASTC_5x4_SRGB: + return TinyImageFormat_ASTC_5x4_UNORM; + case TinyImageFormat_ASTC_5x5_SRGB: + return TinyImageFormat_ASTC_5x5_UNORM; + case TinyImageFormat_ASTC_6x5_SRGB: + return TinyImageFormat_ASTC_6x5_UNORM; + case TinyImageFormat_ASTC_6x6_SRGB: + return TinyImageFormat_ASTC_6x6_UNORM; + case TinyImageFormat_ASTC_8x5_SRGB: + return TinyImageFormat_ASTC_8x5_UNORM; + case TinyImageFormat_ASTC_8x6_SRGB: + return TinyImageFormat_ASTC_8x6_UNORM; + case TinyImageFormat_ASTC_8x8_SRGB: + return TinyImageFormat_ASTC_8x8_UNORM; + case TinyImageFormat_ASTC_10x5_SRGB: + return TinyImageFormat_ASTC_10x5_UNORM; + case TinyImageFormat_ASTC_10x6_SRGB: + return TinyImageFormat_ASTC_10x6_UNORM; + case TinyImageFormat_ASTC_10x8_SRGB: + return TinyImageFormat_ASTC_10x8_UNORM; + case TinyImageFormat_ASTC_10x10_SRGB: + return TinyImageFormat_ASTC_10x10_UNORM; + case TinyImageFormat_ASTC_12x10_SRGB: + return TinyImageFormat_ASTC_12x10_UNORM; + case TinyImageFormat_ASTC_12x12_SRGB: + return TinyImageFormat_ASTC_12x12_UNORM; + case TinyImageFormat_R1_UNORM: + case TinyImageFormat_R2_UNORM: + case TinyImageFormat_R4_UNORM: + case TinyImageFormat_R4G4_UNORM: + case TinyImageFormat_G4R4_UNORM: + case TinyImageFormat_A8_UNORM: + case TinyImageFormat_R8_UNORM: + case TinyImageFormat_B2G3R3_UNORM: + case TinyImageFormat_R4G4B4A4_UNORM: + case TinyImageFormat_R4G4B4X4_UNORM: + case TinyImageFormat_B4G4R4A4_UNORM: + case TinyImageFormat_B4G4R4X4_UNORM: + case TinyImageFormat_A4R4G4B4_UNORM: + case TinyImageFormat_X4R4G4B4_UNORM: + case TinyImageFormat_A4B4G4R4_UNORM: + case TinyImageFormat_X4B4G4R4_UNORM: + case TinyImageFormat_R5G6B5_UNORM: + case TinyImageFormat_B5G6R5_UNORM: + case TinyImageFormat_R5G5B5A1_UNORM: + case TinyImageFormat_B5G5R5A1_UNORM: + case TinyImageFormat_A1B5G5R5_UNORM: + case TinyImageFormat_A1R5G5B5_UNORM: + case TinyImageFormat_R5G5B5X1_UNORM: + case TinyImageFormat_B5G5R5X1_UNORM: + case TinyImageFormat_X1R5G5B5_UNORM: + case TinyImageFormat_X1B5G5R5_UNORM: + case TinyImageFormat_B2G3R3A8_UNORM: + case TinyImageFormat_R8G8_UNORM: + case TinyImageFormat_G8R8_UNORM: + case TinyImageFormat_R16_UNORM: + case TinyImageFormat_R8G8B8_UNORM: + case TinyImageFormat_B8G8R8_UNORM: + case TinyImageFormat_R8G8B8A8_UNORM: + case TinyImageFormat_B8G8R8A8_UNORM: + case TinyImageFormat_R8G8B8X8_UNORM: + case TinyImageFormat_B8G8R8X8_UNORM: + case TinyImageFormat_R16G16_UNORM: + case TinyImageFormat_G16R16_UNORM: + case TinyImageFormat_A2R10G10B10_UNORM: + case TinyImageFormat_A2B10G10R10_UNORM: + case TinyImageFormat_R10G10B10A2_UNORM: + case TinyImageFormat_B10G10R10A2_UNORM: + case TinyImageFormat_R16G16B16_UNORM: + case TinyImageFormat_R16G16B16A16_UNORM: + case TinyImageFormat_D16_UNORM: + case TinyImageFormat_X8_D24_UNORM: + case TinyImageFormat_D16_UNORM_S8_UINT: + case TinyImageFormat_D24_UNORM_S8_UINT: + case TinyImageFormat_DXBC1_RGB_UNORM: + case TinyImageFormat_DXBC1_RGBA_UNORM: + case TinyImageFormat_DXBC2_UNORM: + case TinyImageFormat_DXBC3_UNORM: + case TinyImageFormat_DXBC4_UNORM: + case TinyImageFormat_DXBC5_UNORM: + case TinyImageFormat_DXBC7_UNORM: + case TinyImageFormat_PVRTC1_2BPP_UNORM: + case TinyImageFormat_PVRTC1_4BPP_UNORM: + case TinyImageFormat_PVRTC2_2BPP_UNORM: + case TinyImageFormat_PVRTC2_4BPP_UNORM: + case TinyImageFormat_ETC2_R8G8B8_UNORM: + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: + case TinyImageFormat_ETC2_EAC_R11_UNORM: + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: + case TinyImageFormat_ASTC_4x4_UNORM: + case TinyImageFormat_ASTC_5x4_UNORM: + case TinyImageFormat_ASTC_5x5_UNORM: + case TinyImageFormat_ASTC_6x5_UNORM: + case TinyImageFormat_ASTC_6x6_UNORM: + case TinyImageFormat_ASTC_8x5_UNORM: + case TinyImageFormat_ASTC_8x6_UNORM: + case TinyImageFormat_ASTC_8x8_UNORM: + case TinyImageFormat_ASTC_10x5_UNORM: + case TinyImageFormat_ASTC_10x6_UNORM: + case TinyImageFormat_ASTC_10x8_UNORM: + case TinyImageFormat_ASTC_10x10_UNORM: + case TinyImageFormat_ASTC_12x10_UNORM: + case TinyImageFormat_ASTC_12x12_UNORM: + case TinyImageFormat_R4G4B4A4_UNORM_PACK16: + case TinyImageFormat_B4G4R4A4_UNORM_PACK16: + case TinyImageFormat_R5G6B5_UNORM_PACK16: + case TinyImageFormat_B5G6R5_UNORM_PACK16: + case TinyImageFormat_R5G5B5A1_UNORM_PACK16: + case TinyImageFormat_B5G5R5A1_UNORM_PACK16: + case TinyImageFormat_A1R5G5B5_UNORM_PACK16: + case TinyImageFormat_G16B16G16R16_422_UNORM: + case TinyImageFormat_B16G16R16G16_422_UNORM: + case TinyImageFormat_R12X4G12X4B12X4A12X4_UNORM_4PACK16: + case TinyImageFormat_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: + case TinyImageFormat_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: + case TinyImageFormat_R10X6G10X6B10X6A10X6_UNORM_4PACK16: + case TinyImageFormat_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: + case TinyImageFormat_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: + case TinyImageFormat_G8B8G8R8_422_UNORM: + case TinyImageFormat_B8G8R8G8_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_420_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_420_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_422_UNORM: + case TinyImageFormat_G8_B8R8_2PLANE_422_UNORM: + case TinyImageFormat_G8_B8_R8_3PLANE_444_UNORM: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case TinyImageFormat_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case TinyImageFormat_G16_B16_R16_3PLANE_420_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_422_UNORM: + case TinyImageFormat_G16_B16_R16_3PLANE_444_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_420_UNORM: + case TinyImageFormat_G16_B16R16_2PLANE_422_UNORM: + return fmt; + default: + return TinyImageFormat_UNDEFINED; + } +} + +TIF_CONSTEXPR inline char const * const TinyImageFormat_Name(TinyImageFormat const fmt) +{ + switch(fmt) + { + case TinyImageFormat_UNDEFINED: return "UNDEFINED"; + case TinyImageFormat_R1_UNORM: return "R1_UNORM"; + case TinyImageFormat_R2_UNORM: return "R2_UNORM"; + case TinyImageFormat_R4_UNORM: return "R4_UNORM"; + case TinyImageFormat_R4G4_UNORM: return "R4G4_UNORM"; + case TinyImageFormat_G4R4_UNORM: return "G4R4_UNORM"; + case TinyImageFormat_A8_UNORM: return "A8_UNORM"; + case TinyImageFormat_R8_UNORM: return "R8_UNORM"; + case TinyImageFormat_R8_SNORM: return "R8_SNORM"; + case TinyImageFormat_R8_UINT: return "R8_UINT"; + case TinyImageFormat_R8_SINT: return "R8_SINT"; + case TinyImageFormat_R8_SRGB: return "R8_SRGB"; + case TinyImageFormat_B2G3R3_UNORM: return "B2G3R3_UNORM"; + case TinyImageFormat_R4G4B4A4_UNORM: return "R4G4B4A4_UNORM"; + case TinyImageFormat_R4G4B4X4_UNORM: return "R4G4B4X4_UNORM"; + case TinyImageFormat_B4G4R4A4_UNORM: return "B4G4R4A4_UNORM"; + case TinyImageFormat_B4G4R4X4_UNORM: return "B4G4R4X4_UNORM"; + case TinyImageFormat_A4R4G4B4_UNORM: return "A4R4G4B4_UNORM"; + case TinyImageFormat_X4R4G4B4_UNORM: return "X4R4G4B4_UNORM"; + case TinyImageFormat_A4B4G4R4_UNORM: return "A4B4G4R4_UNORM"; + case TinyImageFormat_X4B4G4R4_UNORM: return "X4B4G4R4_UNORM"; + case TinyImageFormat_R5G6B5_UNORM: return "R5G6B5_UNORM"; + case TinyImageFormat_B5G6R5_UNORM: return "B5G6R5_UNORM"; + case TinyImageFormat_R5G5B5A1_UNORM: return "R5G5B5A1_UNORM"; + case TinyImageFormat_B5G5R5A1_UNORM: return "B5G5R5A1_UNORM"; + case TinyImageFormat_A1B5G5R5_UNORM: return "A1B5G5R5_UNORM"; + case TinyImageFormat_A1R5G5B5_UNORM: return "A1R5G5B5_UNORM"; + case TinyImageFormat_R5G5B5X1_UNORM: return "R5G5B5X1_UNORM"; + case TinyImageFormat_B5G5R5X1_UNORM: return "B5G5R5X1_UNORM"; + case TinyImageFormat_X1R5G5B5_UNORM: return "X1R5G5B5_UNORM"; + case TinyImageFormat_X1B5G5R5_UNORM: return "X1B5G5R5_UNORM"; + case TinyImageFormat_B2G3R3A8_UNORM: return "B2G3R3A8_UNORM"; + case TinyImageFormat_R8G8_UNORM: return "R8G8_UNORM"; + case TinyImageFormat_R8G8_SNORM: return "R8G8_SNORM"; + case TinyImageFormat_G8R8_UNORM: return "G8R8_UNORM"; + case TinyImageFormat_G8R8_SNORM: return "G8R8_SNORM"; + case TinyImageFormat_R8G8_UINT: return "R8G8_UINT"; + case TinyImageFormat_R8G8_SINT: return "R8G8_SINT"; + case TinyImageFormat_R8G8_SRGB: return "R8G8_SRGB"; + case TinyImageFormat_R16_UNORM: return "R16_UNORM"; + case TinyImageFormat_R16_SNORM: return "R16_SNORM"; + case TinyImageFormat_R16_UINT: return "R16_UINT"; + case TinyImageFormat_R16_SINT: return "R16_SINT"; + case TinyImageFormat_R16_SFLOAT: return "R16_SFLOAT"; + case TinyImageFormat_R16_SBFLOAT: return "R16_SBFLOAT"; + case TinyImageFormat_R8G8B8_UNORM: return "R8G8B8_UNORM"; + case TinyImageFormat_R8G8B8_SNORM: return "R8G8B8_SNORM"; + case TinyImageFormat_R8G8B8_UINT: return "R8G8B8_UINT"; + case TinyImageFormat_R8G8B8_SINT: return "R8G8B8_SINT"; + case TinyImageFormat_R8G8B8_SRGB: return "R8G8B8_SRGB"; + case TinyImageFormat_B8G8R8_UNORM: return "B8G8R8_UNORM"; + case TinyImageFormat_B8G8R8_SNORM: return "B8G8R8_SNORM"; + case TinyImageFormat_B8G8R8_UINT: return "B8G8R8_UINT"; + case TinyImageFormat_B8G8R8_SINT: return "B8G8R8_SINT"; + case TinyImageFormat_B8G8R8_SRGB: return "B8G8R8_SRGB"; + case TinyImageFormat_R8G8B8A8_UNORM: return "R8G8B8A8_UNORM"; + case TinyImageFormat_R8G8B8A8_SNORM: return "R8G8B8A8_SNORM"; + case TinyImageFormat_R8G8B8A8_UINT: return "R8G8B8A8_UINT"; + case TinyImageFormat_R8G8B8A8_SINT: return "R8G8B8A8_SINT"; + case TinyImageFormat_R8G8B8A8_SRGB: return "R8G8B8A8_SRGB"; + case TinyImageFormat_B8G8R8A8_UNORM: return "B8G8R8A8_UNORM"; + case TinyImageFormat_B8G8R8A8_SNORM: return "B8G8R8A8_SNORM"; + case TinyImageFormat_B8G8R8A8_UINT: return "B8G8R8A8_UINT"; + case TinyImageFormat_B8G8R8A8_SINT: return "B8G8R8A8_SINT"; + case TinyImageFormat_B8G8R8A8_SRGB: return "B8G8R8A8_SRGB"; + case TinyImageFormat_R8G8B8X8_UNORM: return "R8G8B8X8_UNORM"; + case TinyImageFormat_B8G8R8X8_UNORM: return "B8G8R8X8_UNORM"; + case TinyImageFormat_R16G16_UNORM: return "R16G16_UNORM"; + case TinyImageFormat_G16R16_UNORM: return "G16R16_UNORM"; + case TinyImageFormat_R16G16_SNORM: return "R16G16_SNORM"; + case TinyImageFormat_G16R16_SNORM: return "G16R16_SNORM"; + case TinyImageFormat_R16G16_UINT: return "R16G16_UINT"; + case TinyImageFormat_R16G16_SINT: return "R16G16_SINT"; + case TinyImageFormat_R16G16_SFLOAT: return "R16G16_SFLOAT"; + case TinyImageFormat_R16G16_SBFLOAT: return "R16G16_SBFLOAT"; + case TinyImageFormat_R32_UINT: return "R32_UINT"; + case TinyImageFormat_R32_SINT: return "R32_SINT"; + case TinyImageFormat_R32_SFLOAT: return "R32_SFLOAT"; + case TinyImageFormat_A2R10G10B10_UNORM: return "A2R10G10B10_UNORM"; + case TinyImageFormat_A2R10G10B10_UINT: return "A2R10G10B10_UINT"; + case TinyImageFormat_A2R10G10B10_SNORM: return "A2R10G10B10_SNORM"; + case TinyImageFormat_A2R10G10B10_SINT: return "A2R10G10B10_SINT"; + case TinyImageFormat_A2B10G10R10_UNORM: return "A2B10G10R10_UNORM"; + case TinyImageFormat_A2B10G10R10_UINT: return "A2B10G10R10_UINT"; + case TinyImageFormat_A2B10G10R10_SNORM: return "A2B10G10R10_SNORM"; + case TinyImageFormat_A2B10G10R10_SINT: return "A2B10G10R10_SINT"; + case TinyImageFormat_R10G10B10A2_UNORM: return "R10G10B10A2_UNORM"; + case TinyImageFormat_R10G10B10A2_UINT: return "R10G10B10A2_UINT"; + case TinyImageFormat_R10G10B10A2_SNORM: return "R10G10B10A2_SNORM"; + case TinyImageFormat_R10G10B10A2_SINT: return "R10G10B10A2_SINT"; + case TinyImageFormat_B10G10R10A2_UNORM: return "B10G10R10A2_UNORM"; + case TinyImageFormat_B10G10R10A2_UINT: return "B10G10R10A2_UINT"; + case TinyImageFormat_B10G10R10A2_SNORM: return "B10G10R10A2_SNORM"; + case TinyImageFormat_B10G10R10A2_SINT: return "B10G10R10A2_SINT"; + case TinyImageFormat_B10G11R11_UFLOAT: return "B10G11R11_UFLOAT"; + case TinyImageFormat_E5B9G9R9_UFLOAT: return "E5B9G9R9_UFLOAT"; + case TinyImageFormat_R16G16B16_UNORM: return "R16G16B16_UNORM"; + case TinyImageFormat_R16G16B16_SNORM: return "R16G16B16_SNORM"; + case TinyImageFormat_R16G16B16_UINT: return "R16G16B16_UINT"; + case TinyImageFormat_R16G16B16_SINT: return "R16G16B16_SINT"; + case TinyImageFormat_R16G16B16_SFLOAT: return "R16G16B16_SFLOAT"; + case TinyImageFormat_R16G16B16_SBFLOAT: return "R16G16B16_SBFLOAT"; + case TinyImageFormat_R16G16B16A16_UNORM: return "R16G16B16A16_UNORM"; + case TinyImageFormat_R16G16B16A16_SNORM: return "R16G16B16A16_SNORM"; + case TinyImageFormat_R16G16B16A16_UINT: return "R16G16B16A16_UINT"; + case TinyImageFormat_R16G16B16A16_SINT: return "R16G16B16A16_SINT"; + case TinyImageFormat_R16G16B16A16_SFLOAT: return "R16G16B16A16_SFLOAT"; + case TinyImageFormat_R16G16B16A16_SBFLOAT: return "R16G16B16A16_SBFLOAT"; + case TinyImageFormat_R32G32_UINT: return "R32G32_UINT"; + case TinyImageFormat_R32G32_SINT: return "R32G32_SINT"; + case TinyImageFormat_R32G32_SFLOAT: return "R32G32_SFLOAT"; + case TinyImageFormat_R32G32B32_UINT: return "R32G32B32_UINT"; + case TinyImageFormat_R32G32B32_SINT: return "R32G32B32_SINT"; + case TinyImageFormat_R32G32B32_SFLOAT: return "R32G32B32_SFLOAT"; + case TinyImageFormat_R32G32B32A32_UINT: return "R32G32B32A32_UINT"; + case TinyImageFormat_R32G32B32A32_SINT: return "R32G32B32A32_SINT"; + case TinyImageFormat_R32G32B32A32_SFLOAT: return "R32G32B32A32_SFLOAT"; + case TinyImageFormat_R64_UINT: return "R64_UINT"; + case TinyImageFormat_R64_SINT: return "R64_SINT"; + case TinyImageFormat_R64_SFLOAT: return "R64_SFLOAT"; + case TinyImageFormat_R64G64_UINT: return "R64G64_UINT"; + case TinyImageFormat_R64G64_SINT: return "R64G64_SINT"; + case TinyImageFormat_R64G64_SFLOAT: return "R64G64_SFLOAT"; + case TinyImageFormat_R64G64B64_UINT: return "R64G64B64_UINT"; + case TinyImageFormat_R64G64B64_SINT: return "R64G64B64_SINT"; + case TinyImageFormat_R64G64B64_SFLOAT: return "R64G64B64_SFLOAT"; + case TinyImageFormat_R64G64B64A64_UINT: return "R64G64B64A64_UINT"; + case TinyImageFormat_R64G64B64A64_SINT: return "R64G64B64A64_SINT"; + case TinyImageFormat_R64G64B64A64_SFLOAT: return "R64G64B64A64_SFLOAT"; + case TinyImageFormat_D16_UNORM: return "D16_UNORM"; + case TinyImageFormat_X8_D24_UNORM: return "X8_D24_UNORM"; + case TinyImageFormat_D32_SFLOAT: return "D32_SFLOAT"; + case TinyImageFormat_S8_UINT: return "S8_UINT"; + case TinyImageFormat_D16_UNORM_S8_UINT: return "D16_UNORM_S8_UINT"; + case TinyImageFormat_D24_UNORM_S8_UINT: return "D24_UNORM_S8_UINT"; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return "D32_SFLOAT_S8_UINT"; + case TinyImageFormat_DXBC1_RGB_UNORM: return "DXBC1_RGB_UNORM"; + case TinyImageFormat_DXBC1_RGB_SRGB: return "DXBC1_RGB_SRGB"; + case TinyImageFormat_DXBC1_RGBA_UNORM: return "DXBC1_RGBA_UNORM"; + case TinyImageFormat_DXBC1_RGBA_SRGB: return "DXBC1_RGBA_SRGB"; + case TinyImageFormat_DXBC2_UNORM: return "DXBC2_UNORM"; + case TinyImageFormat_DXBC2_SRGB: return "DXBC2_SRGB"; + case TinyImageFormat_DXBC3_UNORM: return "DXBC3_UNORM"; + case TinyImageFormat_DXBC3_SRGB: return "DXBC3_SRGB"; + case TinyImageFormat_DXBC4_UNORM: return "DXBC4_UNORM"; + case TinyImageFormat_DXBC4_SNORM: return "DXBC4_SNORM"; + case TinyImageFormat_DXBC5_UNORM: return "DXBC5_UNORM"; + case TinyImageFormat_DXBC5_SNORM: return "DXBC5_SNORM"; + case TinyImageFormat_DXBC6H_UFLOAT: return "DXBC6H_UFLOAT"; + case TinyImageFormat_DXBC6H_SFLOAT: return "DXBC6H_SFLOAT"; + case TinyImageFormat_DXBC7_UNORM: return "DXBC7_UNORM"; + case TinyImageFormat_DXBC7_SRGB: return "DXBC7_SRGB"; + case TinyImageFormat_PVRTC1_2BPP_UNORM: return "PVRTC1_2BPP_UNORM"; + case TinyImageFormat_PVRTC1_4BPP_UNORM: return "PVRTC1_4BPP_UNORM"; + case TinyImageFormat_PVRTC2_2BPP_UNORM: return "PVRTC2_2BPP_UNORM"; + case TinyImageFormat_PVRTC2_4BPP_UNORM: return "PVRTC2_4BPP_UNORM"; + case TinyImageFormat_PVRTC1_2BPP_SRGB: return "PVRTC1_2BPP_SRGB"; + case TinyImageFormat_PVRTC1_4BPP_SRGB: return "PVRTC1_4BPP_SRGB"; + case TinyImageFormat_PVRTC2_2BPP_SRGB: return "PVRTC2_2BPP_SRGB"; + case TinyImageFormat_PVRTC2_4BPP_SRGB: return "PVRTC2_4BPP_SRGB"; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return "ETC2_R8G8B8_UNORM"; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return "ETC2_R8G8B8_SRGB"; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return "ETC2_R8G8B8A1_UNORM"; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return "ETC2_R8G8B8A1_SRGB"; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return "ETC2_R8G8B8A8_UNORM"; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return "ETC2_R8G8B8A8_SRGB"; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return "ETC2_EAC_R11_UNORM"; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return "ETC2_EAC_R11_SNORM"; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return "ETC2_EAC_R11G11_UNORM"; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return "ETC2_EAC_R11G11_SNORM"; + case TinyImageFormat_ASTC_4x4_UNORM: return "ASTC_4x4_UNORM"; + case TinyImageFormat_ASTC_4x4_SRGB: return "ASTC_4x4_SRGB"; + case TinyImageFormat_ASTC_5x4_UNORM: return "ASTC_5x4_UNORM"; + case TinyImageFormat_ASTC_5x4_SRGB: return "ASTC_5x4_SRGB"; + case TinyImageFormat_ASTC_5x5_UNORM: return "ASTC_5x5_UNORM"; + case TinyImageFormat_ASTC_5x5_SRGB: return "ASTC_5x5_SRGB"; + case TinyImageFormat_ASTC_6x5_UNORM: return "ASTC_6x5_UNORM"; + case TinyImageFormat_ASTC_6x5_SRGB: return "ASTC_6x5_SRGB"; + case TinyImageFormat_ASTC_6x6_UNORM: return "ASTC_6x6_UNORM"; + case TinyImageFormat_ASTC_6x6_SRGB: return "ASTC_6x6_SRGB"; + case TinyImageFormat_ASTC_8x5_UNORM: return "ASTC_8x5_UNORM"; + case TinyImageFormat_ASTC_8x5_SRGB: return "ASTC_8x5_SRGB"; + case TinyImageFormat_ASTC_8x6_UNORM: return "ASTC_8x6_UNORM"; + case TinyImageFormat_ASTC_8x6_SRGB: return "ASTC_8x6_SRGB"; + case TinyImageFormat_ASTC_8x8_UNORM: return "ASTC_8x8_UNORM"; + case TinyImageFormat_ASTC_8x8_SRGB: return "ASTC_8x8_SRGB"; + case TinyImageFormat_ASTC_10x5_UNORM: return "ASTC_10x5_UNORM"; + case TinyImageFormat_ASTC_10x5_SRGB: return "ASTC_10x5_SRGB"; + case TinyImageFormat_ASTC_10x6_UNORM: return "ASTC_10x6_UNORM"; + case TinyImageFormat_ASTC_10x6_SRGB: return "ASTC_10x6_SRGB"; + case TinyImageFormat_ASTC_10x8_UNORM: return "ASTC_10x8_UNORM"; + case TinyImageFormat_ASTC_10x8_SRGB: return "ASTC_10x8_SRGB"; + case TinyImageFormat_ASTC_10x10_UNORM: return "ASTC_10x10_UNORM"; + case TinyImageFormat_ASTC_10x10_SRGB: return "ASTC_10x10_SRGB"; + case TinyImageFormat_ASTC_12x10_UNORM: return "ASTC_12x10_UNORM"; + case TinyImageFormat_ASTC_12x10_SRGB: return "ASTC_12x10_SRGB"; + case TinyImageFormat_ASTC_12x12_UNORM: return "ASTC_12x12_UNORM"; + case TinyImageFormat_ASTC_12x12_SRGB: return "ASTC_12x12_SRGB"; + case TinyImageFormat_CLUT_P4: return "CLUT_P4"; + case TinyImageFormat_CLUT_P4A4: return "CLUT_P4A4"; + case TinyImageFormat_CLUT_P8: return "CLUT_P8"; + case TinyImageFormat_CLUT_P8A8: return "CLUT_P8A8"; + default: return "The_Format_With_No_Name"; + } +} + +inline TinyImageFormat TinyImageFormat_FromName(char const* p) +{ + // FNV-1a hashing algorithm. + uint64_t hash = 0xcbf29ce484222325ULL; + while ((*p) != 0) { hash = (((uint64_t) *p) ^ hash) * 1099511628211ULL; p++; } + switch(hash) + { + case 0x2BF653266B186C03: return TinyImageFormat_UNDEFINED; + case 0x9C45001516D833DA: return TinyImageFormat_R1_UNORM; + case 0x6C00F001F570B433: return TinyImageFormat_R2_UNORM; + case 0xDF531A87DF5CFA59: return TinyImageFormat_R4_UNORM; + case 0xCBA3F653C82E1E9E: return TinyImageFormat_R4G4_UNORM; + case 0x9B897AC5679B790E: return TinyImageFormat_G4R4_UNORM; + case 0x63DBCDF5F194196A: return TinyImageFormat_A8_UNORM; + case 0x6ECBF1EF06BCE325: return TinyImageFormat_R8_UNORM; + case 0x5C766FFB8DE1F1E3: return TinyImageFormat_R8_SNORM; + case 0x2B467E1FD60E7DD8: return TinyImageFormat_R8_UINT; + case 0xE9ABC60F283D0A72: return TinyImageFormat_R8_SINT; + case 0x358F830EC2BB0208: return TinyImageFormat_R8_SRGB; + case 0x7706DB5BF249BD5A: return TinyImageFormat_B2G3R3_UNORM; + case 0xE2805E85156D9F31: return TinyImageFormat_R4G4B4A4_UNORM; + case 0xB8C356FBFD0E908: return TinyImageFormat_R4G4B4X4_UNORM; + case 0xC5A6BE73259B0031: return TinyImageFormat_B4G4R4A4_UNORM; + case 0xEEB2955DCFFE4A08: return TinyImageFormat_B4G4R4X4_UNORM; + case 0x220561C5779CB911: return TinyImageFormat_A4R4G4B4_UNORM; + case 0xD30FAF6090EC7818: return TinyImageFormat_X4R4G4B4_UNORM; + case 0x3CFC9293744E0831: return TinyImageFormat_A4B4G4R4_UNORM; + case 0xE725A84DF23BFD38: return TinyImageFormat_X4B4G4R4_UNORM; + case 0xE1AFBA335D26A8DA: return TinyImageFormat_R5G6B5_UNORM; + case 0x7A0E74B498D4FAFA: return TinyImageFormat_B5G6R5_UNORM; + case 0xA15971F29DD0621: return TinyImageFormat_R5G5B5A1_UNORM; + case 0x8EFDC73AA126BFA1: return TinyImageFormat_B5G5R5A1_UNORM; + case 0xC742A70EF53AC9F5: return TinyImageFormat_A1B5G5R5_UNORM; + case 0xD5B003D5851331F5: return TinyImageFormat_A1R5G5B5_UNORM; + case 0x7269A347036A9034: return TinyImageFormat_R5G5B5X1_UNORM; + case 0xF751D3627AB449B4: return TinyImageFormat_B5G5R5X1_UNORM; + case 0x42335ADEA4EFC0AC: return TinyImageFormat_X1R5G5B5_UNORM; + case 0xF4330B957F4D6A4C: return TinyImageFormat_X1B5G5R5_UNORM; + case 0x9A6812074759CB0B: return TinyImageFormat_B2G3R3A8_UNORM; + case 0xA8082655C8EFA87E: return TinyImageFormat_R8G8_UNORM; + case 0x8B68D9060D1834FC: return TinyImageFormat_R8G8_SNORM; + case 0x3304A6DE2E40A66: return TinyImageFormat_G8R8_UNORM; + case 0x76ED014D8BD59584: return TinyImageFormat_G8R8_SNORM; + case 0x15A01776FAC06AE1: return TinyImageFormat_R8G8_UINT; + case 0x810697A68C3D3FFB: return TinyImageFormat_R8G8_SINT; + case 0xAC3EAAA6A4B1CBB5: return TinyImageFormat_R8G8_SRGB; + case 0x2E5F1FF55A762DFC: return TinyImageFormat_R16_UNORM; + case 0x4AFE6D45164DA17E: return TinyImageFormat_R16_SNORM; + case 0x733B292CB050E2FB: return TinyImageFormat_R16_UINT; + case 0x7D4A8FD1ED40DE1: return TinyImageFormat_R16_SINT; + case 0x5181789E57BBA72A: return TinyImageFormat_R16_SFLOAT; + case 0xC56CFEC3560B6C7C: return TinyImageFormat_R16_SBFLOAT; + case 0x9B3BE5AE0416CB88: return TinyImageFormat_R8G8B8_UNORM; + case 0x5705279F0768C4D2: return TinyImageFormat_R8G8B8_SNORM; + case 0x8E06FA3EEA5892D7: return TinyImageFormat_R8G8B8_UINT; + case 0x43570A4F483894A5: return TinyImageFormat_R8G8B8_SINT; + case 0x8A0FD4F27827FAF: return TinyImageFormat_R8G8B8_SRGB; + case 0xE97F84F8095F6908: return TinyImageFormat_B8G8R8_UNORM; + case 0xA548C6E90CB16252: return TinyImageFormat_B8G8R8_SNORM; + case 0xF4DDD5D490E7BF57: return TinyImageFormat_B8G8R8_UINT; + case 0xAA2DE5E4EEC7C125: return TinyImageFormat_B8G8R8_SINT; + case 0x6F77D8E4CE11AC2F: return TinyImageFormat_B8G8R8_SRGB; + case 0x5DE537C5CEE18C99: return TinyImageFormat_R8G8B8A8_UNORM; + case 0xE25912D12E286C9F: return TinyImageFormat_R8G8B8A8_SNORM; + case 0x8725F84C50561C6C: return TinyImageFormat_R8G8B8A8_UINT; + case 0x9C079080C9D1C54E: return TinyImageFormat_R8G8B8A8_SINT; + case 0xE7B4D5806421618C: return TinyImageFormat_R8G8B8A8_SRGB; + case 0xE2CD67E1462B4619: return TinyImageFormat_B8G8R8A8_UNORM; + case 0x674142ECA572261F: return TinyImageFormat_B8G8R8A8_SNORM; + case 0xCCAB23134AB9BCEC: return TinyImageFormat_B8G8R8A8_UINT; + case 0xE18CBB47C43565CE: return TinyImageFormat_B8G8R8A8_SINT; + case 0x2D3A00475E85020C: return TinyImageFormat_B8G8R8A8_SRGB; + case 0x98E2B1CDECAE73E8: return TinyImageFormat_R8G8B8X8_UNORM; + case 0x1DCAE1E963F82D68: return TinyImageFormat_B8G8R8X8_UNORM; + case 0xA3FD1100F830F62E: return TinyImageFormat_R16G16_UNORM; + case 0xEF345ACC71CAFA68: return TinyImageFormat_G16R16_UNORM; + case 0x7F7DCC076FEC8E6C: return TinyImageFormat_R16G16_SNORM; + case 0x5736988FE4CCE7B2: return TinyImageFormat_G16R16_SNORM; + case 0xD347EDE3A8782E71: return TinyImageFormat_R16G16_UINT; + case 0xE8296E1821F3AE8B: return TinyImageFormat_R16G16_SINT; + case 0x2DA5B5DBEAB009F0: return TinyImageFormat_R16G16_SFLOAT; + case 0x1EBDD86AD61EECA: return TinyImageFormat_R16G16_SBFLOAT; + case 0xC89CD2CBE8076CC9: return TinyImageFormat_R32_UINT; + case 0x339692FB7927DCC3: return TinyImageFormat_R32_SINT; + case 0x79FC5AE23681AB28: return TinyImageFormat_R32_SFLOAT; + case 0xFB3BEE0BC19BCDC0: return TinyImageFormat_A2R10G10B10_UNORM; + case 0x258D79F3CBE9042F: return TinyImageFormat_A2R10G10B10_UINT; + case 0x4CDA31047B01F04A: return TinyImageFormat_A2R10G10B10_SNORM; + case 0xF00CCA04C6C8A4FD: return TinyImageFormat_A2R10G10B10_SINT; + case 0x477903BFE709CD40: return TinyImageFormat_A2B10G10R10_UNORM; + case 0x2274BF26D27846AF: return TinyImageFormat_A2B10G10R10_UINT; + case 0x991746B8A06FEFCA: return TinyImageFormat_A2B10G10R10_SNORM; + case 0xECF40F37CD57E77D: return TinyImageFormat_A2B10G10R10_SINT; + case 0xC370B0AC1F93F676: return TinyImageFormat_R10G10B10A2_UNORM; + case 0x171461D7B1633919: return TinyImageFormat_R10G10B10A2_UINT; + case 0xE6CC635E3B189E94: return TinyImageFormat_R10G10B10A2_SNORM; + case 0x805B220741121493: return TinyImageFormat_R10G10B10A2_SINT; + case 0xBB10FC1669F59756: return TinyImageFormat_B10G10R10A2_UNORM; + case 0xCAAD5E1DF82DE439: return TinyImageFormat_B10G10R10A2_UINT; + case 0x87FBAEC610087BF4: return TinyImageFormat_B10G10R10A2_SNORM; + case 0x35A69E4D894D7AB3: return TinyImageFormat_B10G10R10A2_SINT; + case 0x5E8DCDA0219DCB1: return TinyImageFormat_B10G11R11_UFLOAT; + case 0x1DBB77A7372DFC97: return TinyImageFormat_E5B9G9R9_UFLOAT; + case 0xEA85D5CCC5E081E7: return TinyImageFormat_R16G16B16_UNORM; + case 0xB57B831A10558861: return TinyImageFormat_R16G16B16_SNORM; + case 0x734C0B9981BA0FD6: return TinyImageFormat_R16G16B16_UINT; + case 0x851D369F098D3F4: return TinyImageFormat_R16G16B16_SINT; + case 0xD1D0593BFAADABEF: return TinyImageFormat_R16G16B16_SFLOAT; + case 0x6FDE47BBA7BEA90F: return TinyImageFormat_R16G16B16_SBFLOAT; + case 0xA20A282E75CABD2D: return TinyImageFormat_R16G16B16A16_UNORM; + case 0x8F48663AFC94404B: return TinyImageFormat_R16G16B16A16_SNORM; + case 0xC02442503D4CE820: return TinyImageFormat_R16G16B16A16_UINT; + case 0x7E89AA3F8F7BAB1A: return TinyImageFormat_R16G16B16A16_SINT; + case 0xBBE9BB01E53ECD91: return TinyImageFormat_R16G16B16A16_SFLOAT; + case 0xF170487E732A86C9: return TinyImageFormat_R16G16B16A16_SBFLOAT; + case 0x300B9BAFAA9826B9: return TinyImageFormat_R32G32_UINT; + case 0x9B04DBDF3BB7BD33: return TinyImageFormat_R32G32_SINT; + case 0x1FDED9A9A6421118: return TinyImageFormat_R32G32_SFLOAT; + case 0xFFFC8DBFFAC96F58: return TinyImageFormat_R32G32B32_UINT; + case 0xBE61D5AF4CF7FBF2: return TinyImageFormat_R32G32B32_SINT; + case 0x886FF275EC1787A9: return TinyImageFormat_R32G32B32_SFLOAT; + case 0x7648F8DE0F31709C: return TinyImageFormat_R32G32B32A32_UINT; + case 0x8B2A511288ACACBE: return TinyImageFormat_R32G32B32A32_SINT; + case 0xC1C2788592D0E665: return TinyImageFormat_R32G32B32A32_SFLOAT; + case 0x8FAC507F3E91D2F8: return TinyImageFormat_R64_UINT; + case 0xA635187107A2DE12: return TinyImageFormat_R64_SINT; + case 0x43149901E509F949: return TinyImageFormat_R64_SFLOAT; + case 0xA1ECCC57631904C7: return TinyImageFormat_R64G64_UINT; + case 0x573CDC67C0F90695: return TinyImageFormat_R64G64_SINT; + case 0xE09F2F9190B7A44E: return TinyImageFormat_R64G64_SFLOAT; + case 0x1E505D1E0F7F67: return TinyImageFormat_R64G64B64_UINT; + case 0xBDEE06FF1606B35: return TinyImageFormat_R64G64B64_SINT; + case 0x8B6FB89954C14C6E: return TinyImageFormat_R64G64B64_SFLOAT; + case 0x6E24CB511E0FC194: return TinyImageFormat_R64G64B64A64_UINT; + case 0xD91E8380AF3023F6: return TinyImageFormat_R64G64B64A64_SINT; + case 0x2B3FE15FC07EF07D: return TinyImageFormat_R64G64B64A64_SFLOAT; + case 0x54D2FD13F48C6DF6: return TinyImageFormat_D16_UNORM; + case 0xC01BE1F2E68AD96E: return TinyImageFormat_X8_D24_UNORM; + case 0xD032BE522E700032: return TinyImageFormat_D32_SFLOAT; + case 0xCF3FC9D0CC3D3B3B: return TinyImageFormat_S8_UINT; + case 0xE48C6BDE0E1BDCB9: return TinyImageFormat_D16_UNORM_S8_UINT; + case 0x882CBC689033B818: return TinyImageFormat_D24_UNORM_S8_UINT; + case 0x8F4B0A1BC125EADD: return TinyImageFormat_D32_SFLOAT_S8_UINT; + case 0x1AA6B819AB24AB4F: return TinyImageFormat_DXBC1_RGB_UNORM; + case 0xA0508EF228A561DA: return TinyImageFormat_DXBC1_RGB_SRGB; + case 0x71A3B9E5FE557FAE: return TinyImageFormat_DXBC1_RGBA_UNORM; + case 0xB9884F4F748AE445: return TinyImageFormat_DXBC1_RGBA_SRGB; + case 0x32F4805474A831D2: return TinyImageFormat_DXBC2_UNORM; + case 0xB38A3E758BE52A09: return TinyImageFormat_DXBC2_SRGB; + case 0x3D1459BB143AA545: return TinyImageFormat_DXBC3_UNORM; + case 0xBE7A8D5D66E49268: return TinyImageFormat_DXBC3_SRGB; + case 0x8F2AE8FFFA7C726C: return TinyImageFormat_DXBC4_UNORM; + case 0xB3AA2DF982C0DA2E: return TinyImageFormat_DXBC4_SNORM; + case 0x9FF9DF3FAAA96027: return TinyImageFormat_DXBC5_UNORM; + case 0x6CDE8436BC805FA1: return TinyImageFormat_DXBC5_SNORM; + case 0xC44BF30D194202E2: return TinyImageFormat_DXBC6H_UFLOAT; + case 0xAB754D40F2829738: return TinyImageFormat_DXBC6H_SFLOAT; + case 0x3694D3DE28B7BD51: return TinyImageFormat_DXBC7_UNORM; + case 0x25F07F23AA734B04: return TinyImageFormat_DXBC7_SRGB; + case 0x8DB1509C891B79CC: return TinyImageFormat_PVRTC1_2BPP_UNORM; + case 0xA909A9CC15D983BE: return TinyImageFormat_PVRTC1_4BPP_UNORM; + case 0x92E357BAD5FE499B: return TinyImageFormat_PVRTC2_2BPP_UNORM; + case 0xD1A7C043408183C1: return TinyImageFormat_PVRTC2_4BPP_UNORM; + case 0xFB26F7CE7F6C7153: return TinyImageFormat_PVRTC1_2BPP_SRGB; + case 0x14B5F7A00D275AF5: return TinyImageFormat_PVRTC1_4BPP_SRGB; + case 0x56D223B86BC012D6: return TinyImageFormat_PVRTC2_2BPP_SRGB; + case 0x3B616527F2F78AD4: return TinyImageFormat_PVRTC2_4BPP_SRGB; + case 0xA222B6AEF8F6342F: return TinyImageFormat_ETC2_R8G8B8_UNORM; + case 0xF7F74F04283C85FA: return TinyImageFormat_ETC2_R8G8B8_SRGB; + case 0xBDF6B48E8BA852A1: return TinyImageFormat_ETC2_R8G8B8A1_UNORM; + case 0xBA6524ED755FF874: return TinyImageFormat_ETC2_R8G8B8A1_SRGB; + case 0x1462C4700CE54CF6: return TinyImageFormat_ETC2_R8G8B8A8_UNORM; + case 0xB011F915A61397ED: return TinyImageFormat_ETC2_R8G8B8A8_SRGB; + case 0xB7BD64A57C276EFC: return TinyImageFormat_ETC2_EAC_R11_UNORM; + case 0xD45CB1F537FEE27E: return TinyImageFormat_ETC2_EAC_R11_SNORM; + case 0x4AAA81E45F616ADB: return TinyImageFormat_ETC2_EAC_R11G11_UNORM; + case 0x60548007F77B43D: return TinyImageFormat_ETC2_EAC_R11G11_SNORM; + case 0x42BDD8AC55AFC9ED: return TinyImageFormat_ASTC_4x4_UNORM; + case 0x8016161C7AB56E10: return TinyImageFormat_ASTC_4x4_SRGB; + case 0x2B5386538D919E02: return TinyImageFormat_ASTC_5x4_UNORM; + case 0xA8D99F174DB11719: return TinyImageFormat_ASTC_5x4_SRGB; + case 0x915C196DFECCFF75: return TinyImageFormat_ASTC_5x5_UNORM; + case 0xDB79A577D6446078: return TinyImageFormat_ASTC_5x5_SRGB; + case 0x1160A2285ABAED98: return TinyImageFormat_ASTC_6x5_UNORM; + case 0x920DC8F697217E9F: return TinyImageFormat_ASTC_6x5_SRGB; + case 0xB16AD1AF5DE6EBCD: return TinyImageFormat_ASTC_6x6_UNORM; + case 0x2745169EA3B7D5B0: return TinyImageFormat_ASTC_6x6_SRGB; + case 0x8E0E209D6C1311DE: return TinyImageFormat_ASTC_8x5_UNORM; + case 0x4ED6E5BA6D481E55: return TinyImageFormat_ASTC_8x5_SRGB; + case 0x2E56A25E2CED3A27: return TinyImageFormat_ASTC_8x6_UNORM; + case 0x991F492892D765F2: return TinyImageFormat_ASTC_8x6_SRGB; + case 0x4C114CE1A220870D: return TinyImageFormat_ASTC_8x8_UNORM; + case 0x18043CB1FA4302F0: return TinyImageFormat_ASTC_8x8_SRGB; + case 0xDAD7C1D8F81107E9: return TinyImageFormat_ASTC_10x5_UNORM; + case 0x6C33C4CA9B25A7BC: return TinyImageFormat_ASTC_10x5_SRGB; + case 0xC9992EE75BB14BC4: return TinyImageFormat_ASTC_10x6_UNORM; + case 0xFE70841B7B9AEF2B: return TinyImageFormat_ASTC_10x6_SRGB; + case 0x9ABA2EE82583DC42: return TinyImageFormat_ASTC_10x8_UNORM; + case 0x7F1CDE06C9B3C759: return TinyImageFormat_ASTC_10x8_SRGB; + case 0xDE0FA47A2B73AF7B: return TinyImageFormat_ASTC_10x10_UNORM; + case 0xCB795EFA4A237676: return TinyImageFormat_ASTC_10x10_SRGB; + case 0x5C03E046D11AEA6D: return TinyImageFormat_ASTC_12x10_UNORM; + case 0xC68986D3DC188B90: return TinyImageFormat_ASTC_12x10_SRGB; + case 0xCE0C328A06CC3333: return TinyImageFormat_ASTC_12x12_UNORM; + case 0x6C2617E4D8F0DC0E: return TinyImageFormat_ASTC_12x12_SRGB; + case 0xAFF9FCAB198F3D50: return TinyImageFormat_CLUT_P4; + case 0x9CF31C2F9538C655: return TinyImageFormat_CLUT_P4A4; + case 0xAFFA08AB198F51B4: return TinyImageFormat_CLUT_P8; + case 0x698142FD18AA335: return TinyImageFormat_CLUT_P8A8; + default: return TinyImageFormat_UNDEFINED; + } +} + + + +// Helpers +TIF_CONSTEXPR inline uint32_t TinyImageFormat_PixelCountOfBlock(TinyImageFormat const fmt) +{ + return TinyImageFormat_WidthOfBlock(fmt) * TinyImageFormat_HeightOfBlock(fmt) * TinyImageFormat_DepthOfBlock(fmt); +} + +TIF_CONSTEXPR inline double TinyImageFormat_Min(TinyImageFormat const fmt, TinyImageFormat_LogicalChannel const channel) +{ + return TinyImageFormat_MinAtPhysical(fmt, TinyImageFormat_LogicalChannelToPhysical(fmt, channel)); +} + +TIF_CONSTEXPR inline double TinyImageFormat_Max(TinyImageFormat const fmt, TinyImageFormat_LogicalChannel const channel) +{ + return TinyImageFormat_MaxAtPhysical(fmt, TinyImageFormat_LogicalChannelToPhysical(fmt, channel)); +} + +TIF_CONSTEXPR inline uint32_t TinyImageFormat_ChannelBitWidth(TinyImageFormat const fmt, TinyImageFormat_LogicalChannel const channel) +{ + return TinyImageFormat_ChannelBitWidthAtPhysical(fmt, TinyImageFormat_LogicalChannelToPhysical(fmt, channel)); +} + +#undef TIF_CONSTEXPR +#endif // TINYIMAGEFORMAT_QUERY_H_ + diff --git a/engine/modules/engine/render/include/render/graph/frame_graph.h b/engine/modules/engine/render/include/render/graph/frame_graph.h index 999882c..be7ec69 100644 --- a/engine/modules/engine/render/include/render/graph/frame_graph.h +++ b/engine/modules/engine/render/include/render/graph/frame_graph.h @@ -35,5 +35,7 @@ namespace api { void ExecutePresentPass(RenderPassNode* node, FRenderView& view); void ExecuteComputePass(RenderPassNode* node, FRenderView& view); void ExecuteCopyPass(RenderPassNode* node, FRenderView& view); + + void ExecuteResourceBarriers(RenderPassNode* node, RenderPassEdgeIterFn fn); }; } \ No newline at end of file diff --git a/engine/modules/engine/render/include/render/graph/type.h b/engine/modules/engine/render/include/render/graph/type.h index 9947fa0..8902cf3 100644 --- a/engine/modules/engine/render/include/render/graph/type.h +++ b/engine/modules/engine/render/include/render/graph/type.h @@ -35,36 +35,36 @@ namespace api { return node; } }; - struct FrameTextureResource { - TextureDesc texture; - AttachmentDesc attach; - }; struct FrameResource { - using Resource = std::variant; + using Resource = std::variant; Name name; + ResourceState sourceState; Resource resource; FrameGraphNodePtr source; pmr::vector targets{ FramePool() }; template - T CastTo() { + T& CastTo() { return std::get(resource); } + bool IsAttachment() { + return std::holds_alternative(resource); + } + bool IsTexture() { + return std::holds_alternative(resource); + } + bool IsBuffer() { + return std::holds_alternative(resource); + } }; struct FrameGraphEdgePtr { - enum EdgeType : uint8_t { - Import, - Input, - Output - }; - EdgeType type{ EdgeType::Import }; + uint8_t isImport : 1; + ResourceState targetState; FrameResource* resource; - FrameGraphEdgePtr() : resource(nullptr) {}; - FrameGraphEdgePtr(FrameResource* resource, EdgeType type = EdgeType::Import) - : resource(resource), type(type) {} - FrameGraphEdgePtr(EdgeType type) : type(type){ + FrameGraphEdgePtr() = default; + FrameResource* Make() { resource = new (FramePool()) FrameResource(); + return resource; } - bool IsImport() const { return type == EdgeType::Import; } operator bool() const{ return resource; } @@ -72,15 +72,34 @@ namespace api { return resource; } }; + using RenderPassEdgeIterFn = std::function; struct RenderPassNode { Name name; - RenderPass* pass; + const void* pass; RenderPassNodeExecuteFn executor; - pmr::vector edges{ FramePool() };//read -> write, 顺序固定 - FrameGraphEdgePtr GetInput(int i); - FrameGraphEdgePtr GetOutput(int i); - FrameGraphEdgePtr FindInput(Name name); - FrameGraphEdgePtr FindOutput(Name name); + pmr::vector inEdges{ FramePool() }; + pmr::vector outEdges{ FramePool() }; + void ForeachEdge(RenderPassEdgeIterFn fn); + FrameGraphEdgePtr GetInput(int i) { return inEdges[i]; }; + FrameGraphEdgePtr GetOutput(int i) { return outEdges[i]; }; + FrameGraphEdgePtr FindInput(Name name) + { + for (auto edge : inEdges) { + if (edge.resource->name == name) { + return edge; + } + } + return {}; + } + FrameGraphEdgePtr FindOutput(Name name) + { + for (auto edge : outEdges) { + if (edge.resource->name == name) { + return edge; + } + } + return {}; + } }; inline FrameGraphNodePtr::FrameGraphNodePtr(GraphNodeRef ref, const RenderPassNodeExecuteFn& executor, NodeType type) : ref(ref), type(type) diff --git a/engine/modules/engine/render/include/render/renderapi.h b/engine/modules/engine/render/include/render/renderapi.h index 4f006b8..77197d1 100644 --- a/engine/modules/engine/render/include/render/renderapi.h +++ b/engine/modules/engine/render/include/render/renderapi.h @@ -6,6 +6,7 @@ namespace api { class Mesh; class Shader; + class RenderPassNode; class RENDER_API RenderAPI : public Singleton { public: @@ -30,6 +31,9 @@ namespace api { virtual void BeginFrame() = 0; virtual void EndFrame() = 0; virtual void RenderView(FRenderView& view); + virtual void BeginRenderPass(RenderPassNode* node) = 0; + virtual void EndRenderPass(RenderPassNode* node) = 0; + virtual void ExecuteResourceBarriers(const ResourceBarrierDesc& desc) = 0; void Render(); }; } \ No newline at end of file diff --git a/engine/modules/engine/render/include/render/type.h b/engine/modules/engine/render/include/render/type.h index 443f64d..0af0775 100644 --- a/engine/modules/engine/render/include/render/type.h +++ b/engine/modules/engine/render/include/render/type.h @@ -1,4 +1,5 @@ #pragma once +#include "tinyimageformat/tinyimageformat_base.h" #include namespace api { enum class GraphicsAPI @@ -7,12 +8,18 @@ namespace api { Vulkan, D3D12 }; + struct BufferDesc { + static BufferDesc Make() { + return {}; + } + }; struct TextureDesc { static TextureDesc Make() { return {}; } }; struct AttachmentDesc { + TinyImageFormat colorFormat; static AttachmentDesc Make() { return {}; } @@ -76,4 +83,18 @@ namespace api { uint8_t mMipLevel : 7; uint16_t mArrayLayer; }; + typedef struct BufferBarrier + { + //Buffer* pBuffer; + ResourceState mSrcState; + ResourceState mDstState; + uint8_t mBeginOnly : 1; + uint8_t mEndOnly : 1; + } BufferBarrier; + struct ResourceBarrierDesc { + const BufferBarrier* pBufferBarriers; + uint32_t bufferBarriersCount; + const TextureBarrier* pTextureBarriers; + uint32_t textureBarriersCount; + }; } \ No newline at end of file diff --git a/engine/modules/engine/render/src/graph/frame_graph.cpp b/engine/modules/engine/render/src/graph/frame_graph.cpp index 0ceb06e..b2ae9b2 100644 --- a/engine/modules/engine/render/src/graph/frame_graph.cpp +++ b/engine/modules/engine/render/src/graph/frame_graph.cpp @@ -12,7 +12,8 @@ namespace api { } FrameGraphEdgePtr FrameGraph::CreateTexture(const TextureSetupFunction& setup) { - FrameGraphEdgePtr edge{ FrameGraphEdgePtr::Import }; + FrameGraphEdgePtr edge{}; + edge.Make(); TextureBuilder builder(this, edge); setup(*this, builder); return edge; @@ -36,7 +37,7 @@ namespace api { ExecuteRenderPass(node.node, view); break; case FrameGraphNodePtr::Present: - ExecuteRenderPass(node.node, view); + ExecutePresentPass(node.node, view); break; case FrameGraphNodePtr::Compute: ExecuteComputePass(node.node, view); @@ -51,16 +52,13 @@ namespace api { { mGraph.clear(); mNodes.clear(); - } - void BeginRenderPass() { - } void FrameGraph::ExecuteRenderPass(RenderPassNode* node, FRenderView& view) { - BeginRenderPass(); - //RenderAPI::Ptr()->BeginRenderPass(); + RenderAPI::Ptr()->BeginRenderPass(node); RenderPassContext context{}; std::get(node->executor)(*this, context); + RenderAPI::Ptr()->EndRenderPass(node); } void FrameGraph::ExecutePresentPass(RenderPassNode* node, FRenderView& view) { @@ -77,42 +75,43 @@ namespace api { CopyPassContext context{}; std::get(node->executor)(*this, context); } - FrameGraphEdgePtr RenderPassNode::GetInput(int i) + void FrameGraph::ExecuteResourceBarriers(RenderPassNode* node, RenderPassEdgeIterFn fn) { - int count = 0; - for (auto edge : edges) { - if (edge.type != FrameGraphEdgePtr::Output && count++ == i) { - return edge; + pmr::vector bufferBarrier{FramePool()}; + pmr::vector textureBarrier{ FramePool() }; + node->ForeachEdge([&](FrameResource* resource, FrameGraphEdgePtr edge) { + if (!edge || edge.targetState == resource->sourceState) { + return; } + if (resource->IsBuffer()) { + BufferBarrier barrier{}; + barrier.mSrcState = resource->sourceState; + barrier.mDstState = edge.targetState; + bufferBarrier.push_back(barrier); + } + else { + TextureBarrier barrier{}; + barrier.mSrcState = resource->sourceState; + barrier.mDstState = edge.targetState; + textureBarrier.push_back(barrier); + } + }); + if (bufferBarrier.empty() && textureBarrier.empty()) { + return; } - return nullptr; + ResourceBarrierDesc desc{}; + desc.bufferBarriersCount = bufferBarrier.size(); + desc.pBufferBarriers = bufferBarrier.data(); + desc.textureBarriersCount = textureBarrier.size(); + desc.pTextureBarriers = textureBarrier.data(); + } - FrameGraphEdgePtr RenderPassNode::GetOutput(int i) - { - int count = 0; - for (auto edge : edges) { - if (edge.type == FrameGraphEdgePtr::Output && count++ == i) { - return edge; - } + void RenderPassNode::ForeachEdge(RenderPassEdgeIterFn fn) { + for (auto& edge : inEdges) { + fn(edge.resource, edge); } - return nullptr; - } - FrameGraphEdgePtr RenderPassNode::FindInput(Name name) - { - for (auto edge : edges) { - if (edge.resource->name == name && edge.type != FrameGraphEdgePtr::Output) { - return edge; - } + for (auto& edge : outEdges) { + fn(edge.resource, edge); } - return nullptr; - } - FrameGraphEdgePtr RenderPassNode::FindOutput(Name name) - { - for (auto edge : edges) { - if (edge.resource->name == name && edge.type == FrameGraphEdgePtr::Output) { - return edge; - } - } - return nullptr; } } diff --git a/engine/modules/engine/render/src/graph/frame_graph_builder.cpp b/engine/modules/engine/render/src/graph/frame_graph_builder.cpp index 85707f8..48e0490 100644 --- a/engine/modules/engine/render/src/graph/frame_graph_builder.cpp +++ b/engine/modules/engine/render/src/graph/frame_graph_builder.cpp @@ -14,29 +14,28 @@ namespace api { FrameGraph::RenderPassBuilder& FrameGraph::RenderPassBuilder::Read(TextureDesc desc) { - FrameGraphEdgePtr edge{ FrameGraphEdgePtr::Input }; - resource = edge.resource; + FrameGraphEdgePtr edge{}; + resource = edge.Make(); resource->source = node; - resource->resource = FrameTextureResource{desc}; - node->edges.push_back(edge); + resource->resource = desc; + node->inEdges.push_back(edge); return *this; } FrameGraph::RenderPassBuilder& FrameGraph::RenderPassBuilder::Write(TextureDesc desc) { - FrameGraphEdgePtr edge{ FrameGraphEdgePtr::Output }; - resource = edge.resource; + FrameGraphEdgePtr edge{}; + resource = edge.Make(); resource->source = node; - resource->resource = FrameTextureResource{ desc }; - node->edges.push_back(edge); + resource->resource = desc; + node->outEdges.push_back(edge); return *this; } FrameGraph::RenderPassBuilder& FrameGraph::RenderPassBuilder::Attach(AttachmentDesc desc) { if (resource) { - auto& text_resource = std::get(resource->resource); - text_resource.attach = desc; + resource->resource = desc; } return *this; } @@ -44,7 +43,7 @@ namespace api { FrameGraph::RenderPassBuilder& FrameGraph::RenderPassBuilder::Read(const FrameGraphEdgePtr& edge) { if (!edge) { return *this; } - node->edges.emplace_back(edge.resource, edge.IsImport() ? FrameGraphEdgePtr::Import : FrameGraphEdgePtr::Input); + node->inEdges.emplace_back(edge); edge->targets.emplace_back(node); if(edge->source) graph.mGraph.addEdge(edge->source.ref, node.ref); @@ -57,7 +56,7 @@ namespace api { } FrameGraph::TextureBuilder& FrameGraph::TextureBuilder::Import(RscHandle handle) { - edge.type = FrameGraphEdgePtr::Import; + edge.isImport = true; return *this; } } \ No newline at end of file diff --git a/engine/modules/engine/render/xmake.lua b/engine/modules/engine/render/xmake.lua index f4bb53f..a83b5e7 100644 --- a/engine/modules/engine/render/xmake.lua +++ b/engine/modules/engine/render/xmake.lua @@ -1,4 +1,5 @@ static_component("render","engine") + add_includedirs("3rdparty", {public = true}) add_headerfiles("include/**.h", "impl/*.inl") add_files("src/**.cpp") add_deps("asset", "zlib", "core") diff --git a/engine/modules/render/vulkan/include/vkn/vulkan_api.h b/engine/modules/render/vulkan/include/vkn/vulkan_api.h index c35ae88..b1771bc 100644 --- a/engine/modules/render/vulkan/include/vkn/vulkan_api.h +++ b/engine/modules/render/vulkan/include/vkn/vulkan_api.h @@ -11,6 +11,8 @@ namespace vkn { using api::Guid; using api::Mesh; using api::Shader; + using api::RenderPassNode; + using api::ResourceBarrierDesc; struct VulkanContext : public api::RenderContext { VkSemaphore surfaceSemaphore; VkSemaphore presentSemaphore; @@ -34,8 +36,12 @@ namespace vkn { void BeginFrame()override; void EndFrame()override; + void BeginRenderPass(RenderPassNode* node) override; + void EndRenderPass(RenderPassNode* node) override; + void ExecuteResourceBarriers(const ResourceBarrierDesc& desc) override; + VkPipeline GetPipeline(); - VkRenderPass GetRenderPass(RenderPassKey config); + VkRenderPass GetRenderPass(RenderPassKey& config); Backend& GetBackend() { return backend; diff --git a/engine/modules/render/vulkan/include/vkn/vulkan_api_help.h b/engine/modules/render/vulkan/include/vkn/vulkan_api_help.h new file mode 100644 index 0000000..c0f07a3 --- /dev/null +++ b/engine/modules/render/vulkan/include/vkn/vulkan_api_help.h @@ -0,0 +1,4 @@ +#include "type.h" +namespace vkn { + +} \ No newline at end of file diff --git a/engine/modules/render/vulkan/src/vulkan_api.cpp b/engine/modules/render/vulkan/src/vulkan_api.cpp index a577d9e..f927073 100644 --- a/engine/modules/render/vulkan/src/vulkan_api.cpp +++ b/engine/modules/render/vulkan/src/vulkan_api.cpp @@ -6,6 +6,7 @@ #include "vkn/thread/command_worker.h" #include "render/asset/mesh.h" #include "meta/enum.h" +#include "tinyimageformat/tinyimageformat_apis.h" namespace vkn { inline bool operator==(const RenderPassKey& k1, const RenderPassKey& k2) { if (k1.initialColorLayoutMask != k2.initialColorLayoutMask) return false; @@ -72,7 +73,36 @@ namespace vkn { { window.Present(*(VulkanContext*)&context); } - VkRenderPass VulkanAPI::GetRenderPass(RenderPassKey config) { + void VulkanAPI::ExecuteResourceBarriers(const ResourceBarrierDesc& desc) { + VkCommandBuffer cmd; + pmr::vector bufferBarriers{ FramePool() }; + bufferBarriers.reserve(desc.bufferBarriersCount); + pmr::vector imageBarriers{ FramePool() }; + imageBarriers.reserve(desc.textureBarriersCount); + using api::ResourceState; + for (uint32_t i = 0; i < desc.textureBarriersCount; i++) + { + auto& barrier = desc.pTextureBarriers[i]; + } + } + void VulkanAPI::BeginRenderPass(RenderPassNode* node) + { + RenderPassKey config{}; + int i = 0; + for (auto& it : node->outEdges) { + if (it->IsAttachment()) { + auto& desc = it->CastTo(); + config.colorFormat[i] = (VkFormat)TinyImageFormat_ToVkFormat(desc.colorFormat); + i++; + } + } + node->pass = GetRenderPass(config); + } + void VulkanAPI::EndRenderPass(RenderPassNode* node) + { + + } + VkRenderPass VulkanAPI::GetRenderPass(RenderPassKey& config) { auto it = RenderPassCache.find(config); if (it != RenderPassCache.end()) { return it->second; diff --git a/engine/modules/render/vulkan/src/vulkan_api_help.cpp b/engine/modules/render/vulkan/src/vulkan_api_help.cpp new file mode 100644 index 0000000..a51f88b --- /dev/null +++ b/engine/modules/render/vulkan/src/vulkan_api_help.cpp @@ -0,0 +1,103 @@ +#include +#include "vkn/vulkan_api_help.h" +namespace vkn { + using api::ResourceState; + inline std::tuple + getVkTransition(const api::TextureBarrier& barrier) { + VkAccessFlags srcAccessMask, dstAccessMask; + VkPipelineStageFlags srcStage, dstStage; + + switch (barrier.mSrcState) { + case ResourceState::UNDEFINED: + srcAccessMask = VK_ACCESS_MEMORY_READ_BIT; + srcStage = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT; + break; + case ResourceState::COLOR_ATTACHMENT: + srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | + VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + srcStage = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | + VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + break; + case ResourceState::READ_WRITE: + srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + srcStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + break; + case ResourceState::READ_ONLY: + srcAccessMask = VK_ACCESS_SHADER_READ_BIT; + srcStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + break; + case ResourceState::TRANSFER_SRC: + srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + case ResourceState::TRANSFER_DST: + srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + case ResourceState::DEPTH_ATTACHMENT: + srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + srcStage = VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; + break; + case ResourceState::DEPTH_SAMPLER: + srcAccessMask = VK_ACCESS_MEMORY_READ_BIT; + srcStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + break; + case ResourceState::COLOR_ATTACHMENT_RESOLVE: + srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + case ResourceState::PRESENT: + srcAccessMask = VK_ACCESS_NONE; + srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + } + + switch (barrier.mDstState) { + case ResourceState::COLOR_ATTACHMENT: + dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT + | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT + | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dstStage = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT + | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + break; + case ResourceState::READ_WRITE: + dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + dstStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + break; + case ResourceState::READ_ONLY: + dstAccessMask = VK_ACCESS_SHADER_READ_BIT; + dstStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT; + break; + case ResourceState::TRANSFER_SRC: + dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + case ResourceState::TRANSFER_DST: + dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + case ResourceState::DEPTH_ATTACHMENT: + dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT + | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + dstStage = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT; + break; + case ResourceState::DEPTH_SAMPLER: + dstAccessMask = + VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + dstStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | + VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT; + break; + case ResourceState::PRESENT: + case ResourceState::COLOR_ATTACHMENT_RESOLVE: + case ResourceState::UNDEFINED: + dstAccessMask = 0; + dstStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + break; + } + + return std::make_tuple(srcAccessMask, dstAccessMask, srcStage, dstStage, + getVkLayout(transition.oldLayout), getVkLayout(transition.newLayout)); + } +} \ No newline at end of file diff --git a/game/zworld/src/zworld.cpp b/game/zworld/src/zworld.cpp index 6ce2b06..9cd2725 100644 --- a/game/zworld/src/zworld.cpp +++ b/game/zworld/src/zworld.cpp @@ -5,11 +5,12 @@ #include "render/pass/demo_pass.h" #include using namespace api; +RenderAPI* API; void ZWorldModule::OnLoad(int argc, char** argv) { // 创建窗口 auto window = new vkn::VulkanWindow(&SDL_CreateWindow, { "zengine" , SDL_WINDOW_VULKAN }, 1080, 720); - RenderAPI* API = new vkn::VulkanAPI(); + API = new vkn::VulkanAPI(); auto args = vkn::VulkanWindowArgs::Default(); args.frames = 3; if (!window->CreateRender(&SDL_Vulkan_CreateSurface, args)) { @@ -24,7 +25,6 @@ void ZWorldModule::OnUnload() void ZWorldModule::MainLoop() { - RenderAPI* API = RenderAPI::Ptr(); bool running = true; SDL_Event event_; while (running) {