Home | History | Annotate | Download | only in layers
      1 /* Copyright (c) 2015-2016 The Khronos Group Inc.
      2  * Copyright (c) 2015-2016 Valve Corporation
      3  * Copyright (c) 2015-2016 LunarG, Inc.
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and/or associated documentation files (the "Materials"), to
      7  * deal in the Materials without restriction, including without limitation the
      8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
      9  * sell copies of the Materials, and to permit persons to whom the Materials
     10  * are furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice(s) and this permission notice shall be included
     13  * in all copies or substantial portions of the Materials.
     14  *
     15  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     18  *
     19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
     20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
     22  * USE OR OTHER DEALINGS IN THE MATERIALS
     23  *
     24  * Author: Mark Lobodzinski <mark (at) lunarg.com>
     25  *
     26  */
     27 
     28 #include <string.h>
     29 #include <string>
     30 #include <vector>
     31 #include "vulkan/vulkan.h"
     32 #include "vk_layer_config.h"
     33 #include "vk_layer_utils.h"
     34 
     35 typedef struct _VULKAN_FORMAT_INFO {
     36     size_t size;
     37     uint32_t channel_count;
     38     VkFormatCompatibilityClass format_class;
     39 } VULKAN_FORMAT_INFO;
     40 
     41 // Set up data structure with number of bytes and number of channels
     42 // for each Vulkan format.
     43 static const VULKAN_FORMAT_INFO vk_format_table[VK_FORMAT_RANGE_SIZE] = {
     44     {0, 0, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_UNDEFINED]
     45     {1, 2, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R4G4_UNORM_PACK8]
     46     {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R4G4B4A4_UNORM_PACK16]
     47     {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_B4G4R4A4_UNORM_PACK16]
     48     {2, 3, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R5G6B5_UNORM_PACK16]
     49     {2, 3, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_B5G6R5_UNORM_PACK16]
     50     {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R5G5B5A1_UNORM_PACK16]
     51     {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_B5G5R5A1_UNORM_PACK16]
     52     {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_A1R5G5B5_UNORM_PACK16]
     53     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_UNORM]
     54     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SNORM]
     55     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_USCALED]
     56     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SSCALED]
     57     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_UINT]
     58     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SINT]
     59     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SRGB]
     60     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_UNORM]
     61     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SNORM]
     62     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_USCALED]
     63     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SSCALED]
     64     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_UINT]
     65     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SINT]
     66     {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SRGB]
     67     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_UNORM]
     68     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SNORM]
     69     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_USCALED]
     70     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SSCALED]
     71     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_UINT]
     72     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SINT]
     73     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SRGB]
     74     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_UNORM]
     75     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SNORM]
     76     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_USCALED]
     77     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SSCALED]
     78     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_UINT]
     79     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SINT]
     80     {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SRGB]
     81     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_UNORM]
     82     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SNORM]
     83     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_USCALED]
     84     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SSCALED]
     85     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_UINT]
     86     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SINT]
     87     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SRGB]
     88     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_UNORM]
     89     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SNORM]
     90     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_USCALED]
     91     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SSCALED]
     92     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_UINT]
     93     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SINT]
     94     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SRGB]
     95     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_UNORM_PACK32]
     96     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_SNORM_PACK32]
     97     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_USCALED_PACK32]
     98     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_SSCALED_PACK32]
     99     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_UINT_PACK32]
    100     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_SINT_PACK32]
    101     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SRGB_PACK32]
    102     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_UNORM_PACK32]
    103     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_SNORM_PACK32]
    104     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_USCALED_PACK32]
    105     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_SSCALED_PACK32]
    106     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_UINT_PACK32]
    107     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_SINT_PACK32]
    108     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_UNORM_PACK32]
    109     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_SNORM_PACK32]
    110     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_USCALED_PACK32]
    111     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_SSCALED_PACK32]
    112     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_UINT_PACK32]
    113     {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_SINT_PACK32]
    114     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_UNORM]
    115     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SNORM]
    116     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_USCALED]
    117     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SSCALED]
    118     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_UINT]
    119     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SINT]
    120     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SFLOAT]
    121     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_UNORM]
    122     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SNORM]
    123     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_USCALED]
    124     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SSCALED]
    125     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_UINT]
    126     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SINT]
    127     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SFLOAT]
    128     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_UNORM]
    129     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SNORM]
    130     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_USCALED]
    131     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SSCALED]
    132     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_UINT]
    133     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SINT]
    134     {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SFLOAT]
    135     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_UNORM]
    136     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SNORM]
    137     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_USCALED]
    138     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SSCALED]
    139     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_UINT]
    140     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SINT]
    141     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SFLOAT]
    142     {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R32_UINT]
    143     {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R32_SINT]
    144     {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R32_SFLOAT]
    145     {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R32G32_UINT]
    146     {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R32G32_SINT]
    147     {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R32G32_SFLOAT]
    148     {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_BIT},           //    [VK_FORMAT_R32G32B32_UINT]
    149     {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_BIT},           //    [VK_FORMAT_R32G32B32_SINT]
    150     {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_BIT},           //    [VK_FORMAT_R32G32B32_SFLOAT]
    151     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R32G32B32A32_UINT]
    152     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R32G32B32A32_SINT]
    153     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R32G32B32A32_SFLOAT]
    154     {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R64_UINT]
    155     {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R64_SINT]
    156     {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R64_SFLOAT]
    157     {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R64G64_UINT]
    158     {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R64G64_SINT]
    159     {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R64G64_SFLOAT]
    160     {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_BIT},          //    [VK_FORMAT_R64G64B64_UINT]
    161     {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_BIT},          //    [VK_FORMAT_R64G64B64_SINT]
    162     {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_BIT},          //    [VK_FORMAT_R64G64B64_SFLOAT]
    163     {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT},          //    [VK_FORMAT_R64G64B64A64_UINT]
    164     {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT},          //    [VK_FORMAT_R64G64B64A64_SINT]
    165     {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT},          //    [VK_FORMAT_R64G64B64A64_SFLOAT]
    166     {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B10G11R11_UFLOAT_PACK32]
    167     {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_E5B9G9R9_UFLOAT_PACK32]
    168     {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D16_UNORM]
    169     {3, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_X8_D24_UNORM_PACK32]
    170     {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D32_SFLOAT]
    171     {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_S8_UINT]
    172     {3, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D16_UNORM_S8_UINT]
    173     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D24_UNORM_S8_UINT]
    174     {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D32_SFLOAT_S8_UINT]
    175     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT},       //    [VK_FORMAT_BC1_RGB_UNORM_BLOCK]
    176     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT},       //    [VK_FORMAT_BC1_RGB_SRGB_BLOCK]
    177     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT},      //    [VK_FORMAT_BC1_RGBA_UNORM_BLOCK]
    178     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT},      //    [VK_FORMAT_BC1_RGBA_SRGB_BLOCK]
    179     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT},          //    [VK_FORMAT_BC2_UNORM_BLOCK]
    180     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT},          //    [VK_FORMAT_BC2_SRGB_BLOCK]
    181     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT},          //    [VK_FORMAT_BC3_UNORM_BLOCK]
    182     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT},          //    [VK_FORMAT_BC3_SRGB_BLOCK]
    183     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT},           //    [VK_FORMAT_BC4_UNORM_BLOCK]
    184     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT},           //    [VK_FORMAT_BC4_SNORM_BLOCK]
    185     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT},          //    [VK_FORMAT_BC5_UNORM_BLOCK]
    186     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT},          //    [VK_FORMAT_BC5_SNORM_BLOCK]
    187     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT},         //    [VK_FORMAT_BC6H_UFLOAT_BLOCK]
    188     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT},         //    [VK_FORMAT_BC6H_SFLOAT_BLOCK]
    189     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT},          //    [VK_FORMAT_BC7_UNORM_BLOCK]
    190     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT},          //    [VK_FORMAT_BC7_SRGB_BLOCK]
    191     {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT},      //    [VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK]
    192     {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT},      //    [VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK]
    193     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT},     //    [VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK]
    194     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT},     //    [VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK]
    195     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}, //    [VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK]
    196     {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}, // [VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK]
    197     {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT},         //    [VK_FORMAT_EAC_R11_UNORM_BLOCK]
    198     {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT},         //    [VK_FORMAT_EAC_R11_SNORM_BLOCK]
    199     {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT},       //    [VK_FORMAT_EAC_R11G11_UNORM_BLOCK]
    200     {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT},       //    [VK_FORMAT_EAC_R11G11_SNORM_BLOCK]
    201     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT},     //    [VK_FORMAT_ASTC_4x4_UNORM_BLOCK]
    202     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT},     //    [VK_FORMAT_ASTC_4x4_SRGB_BLOCK]
    203     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT},     //    [VK_FORMAT_ASTC_5x4_UNORM_BLOCK]
    204     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT},     //    [VK_FORMAT_ASTC_5x4_SRGB_BLOCK]
    205     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT},     //    [VK_FORMAT_ASTC_5x5_UNORM_BLOCK]
    206     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT},     //    [VK_FORMAT_ASTC_5x5_SRGB_BLOCK]
    207     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT},     //    [VK_FORMAT_ASTC_6x5_UNORM_BLOCK]
    208     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT},     //    [VK_FORMAT_ASTC_6x5_SRGB_BLOCK]
    209     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT},     //    [VK_FORMAT_ASTC_6x6_UNORM_BLOCK]
    210     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT},     //    [VK_FORMAT_ASTC_6x6_SRGB_BLOCK]
    211     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT},     //    [VK_FORMAT_ASTC_8x5_UNORM_BLOCK]
    212     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT},     //    [VK_FORMAT_ASTC_8x5_SRGB_BLOCK]
    213     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT},     //    [VK_FORMAT_ASTC_8x6_UNORM_BLOCK]
    214     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT},     //    [VK_FORMAT_ASTC_8x6_SRGB_BLOCK]
    215     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT},     //    [VK_FORMAT_ASTC_8x8_UNORM_BLOCK]
    216     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT},     //    [VK_FORMAT_ASTC_8x8_SRGB_BLOCK]
    217     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT},    //    [VK_FORMAT_ASTC_10x5_UNORM_BLOCK]
    218     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT},    //    [VK_FORMAT_ASTC_10x5_SRGB_BLOCK]
    219     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT},    //    [VK_FORMAT_ASTC_10x6_UNORM_BLOCK]
    220     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT},    //    [VK_FORMAT_ASTC_10x6_SRGB_BLOCK]
    221     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT},    //    [VK_FORMAT_ASTC_10x8_UNORM_BLOCK]
    222     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT},    //    [VK_FORMAT_ASTC_10x8_SRGB_BLOCK]
    223     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT},   //    [VK_FORMAT_ASTC_10x10_UNORM_BLOCK]
    224     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT},   //    [VK_FORMAT_ASTC_10x10_SRGB_BLOCK]
    225     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT},   //    [VK_FORMAT_ASTC_12x10_UNORM_BLOCK]
    226     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT},   //    [VK_FORMAT_ASTC_12x10_SRGB_BLOCK]
    227     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT},   //    [VK_FORMAT_ASTC_12x12_UNORM_BLOCK]
    228     {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT},   //    [VK_FORMAT_ASTC_12x12_SRGB_BLOCK]
    229 };
    230 
    231 // Return true if format is a depth or stencil format
    232 bool vk_format_is_depth_or_stencil(VkFormat format) {
    233     return (vk_format_is_depth_and_stencil(format) || vk_format_is_depth_only(format) || vk_format_is_stencil_only(format));
    234 }
    235 
    236 // Return true if format contains depth and stencil information
    237 bool vk_format_is_depth_and_stencil(VkFormat format) {
    238     bool is_ds = false;
    239 
    240     switch (format) {
    241     case VK_FORMAT_D16_UNORM_S8_UINT:
    242     case VK_FORMAT_D24_UNORM_S8_UINT:
    243     case VK_FORMAT_D32_SFLOAT_S8_UINT:
    244         is_ds = true;
    245         break;
    246     default:
    247         break;
    248     }
    249     return is_ds;
    250 }
    251 
    252 // Return true if format is a stencil-only format
    253 bool vk_format_is_stencil_only(VkFormat format) { return (format == VK_FORMAT_S8_UINT); }
    254 
    255 // Return true if format is a depth-only format
    256 bool vk_format_is_depth_only(VkFormat format) {
    257     bool is_depth = false;
    258 
    259     switch (format) {
    260     case VK_FORMAT_D16_UNORM:
    261     case VK_FORMAT_X8_D24_UNORM_PACK32:
    262     case VK_FORMAT_D32_SFLOAT:
    263         is_depth = true;
    264         break;
    265     default:
    266         break;
    267     }
    268 
    269     return is_depth;
    270 }
    271 
    272 // Return true if format is of time UNORM
    273 bool vk_format_is_norm(VkFormat format) {
    274     bool is_norm = false;
    275 
    276     switch (format) {
    277     case VK_FORMAT_R4G4_UNORM_PACK8:
    278     case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
    279     case VK_FORMAT_R5G6B5_UNORM_PACK16:
    280     case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
    281     case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
    282     case VK_FORMAT_R8_UNORM:
    283     case VK_FORMAT_R8_SNORM:
    284     case VK_FORMAT_R8G8_UNORM:
    285     case VK_FORMAT_R8G8_SNORM:
    286     case VK_FORMAT_R8G8B8_UNORM:
    287     case VK_FORMAT_R8G8B8_SNORM:
    288     case VK_FORMAT_R8G8B8A8_UNORM:
    289     case VK_FORMAT_R8G8B8A8_SNORM:
    290     case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
    291     case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
    292     case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
    293     case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
    294     case VK_FORMAT_R16_UNORM:
    295     case VK_FORMAT_R16_SNORM:
    296     case VK_FORMAT_R16G16_UNORM:
    297     case VK_FORMAT_R16G16_SNORM:
    298     case VK_FORMAT_R16G16B16_UNORM:
    299     case VK_FORMAT_R16G16B16_SNORM:
    300     case VK_FORMAT_R16G16B16A16_UNORM:
    301     case VK_FORMAT_R16G16B16A16_SNORM:
    302     case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
    303     case VK_FORMAT_BC2_UNORM_BLOCK:
    304     case VK_FORMAT_BC3_UNORM_BLOCK:
    305     case VK_FORMAT_BC4_UNORM_BLOCK:
    306     case VK_FORMAT_BC4_SNORM_BLOCK:
    307     case VK_FORMAT_BC5_UNORM_BLOCK:
    308     case VK_FORMAT_BC5_SNORM_BLOCK:
    309     case VK_FORMAT_BC7_UNORM_BLOCK:
    310     case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
    311     case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
    312     case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
    313     case VK_FORMAT_EAC_R11_UNORM_BLOCK:
    314     case VK_FORMAT_EAC_R11_SNORM_BLOCK:
    315     case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
    316     case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
    317     case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
    318     case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
    319     case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
    320     case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
    321     case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
    322     case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
    323     case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
    324     case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
    325     case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
    326     case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
    327     case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
    328     case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
    329     case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
    330     case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
    331     case VK_FORMAT_B5G6R5_UNORM_PACK16:
    332     case VK_FORMAT_B8G8R8_UNORM:
    333     case VK_FORMAT_B8G8R8_SNORM:
    334     case VK_FORMAT_B8G8R8A8_UNORM:
    335     case VK_FORMAT_B8G8R8A8_SNORM:
    336     case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
    337     case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
    338         is_norm = true;
    339         break;
    340     default:
    341         break;
    342     }
    343 
    344     return is_norm;
    345 };
    346 
    347 // Return true if format is an integer format
    348 bool vk_format_is_int(VkFormat format) { return (vk_format_is_sint(format) || vk_format_is_uint(format)); }
    349 
    350 // Return true if format is an unsigned integer format
    351 bool vk_format_is_uint(VkFormat format) {
    352     bool is_uint = false;
    353 
    354     switch (format) {
    355     case VK_FORMAT_R8_UINT:
    356     case VK_FORMAT_R8G8_UINT:
    357     case VK_FORMAT_R8G8B8_UINT:
    358     case VK_FORMAT_R8G8B8A8_UINT:
    359     case VK_FORMAT_A8B8G8R8_UINT_PACK32:
    360     case VK_FORMAT_A2B10G10R10_UINT_PACK32:
    361     case VK_FORMAT_R16_UINT:
    362     case VK_FORMAT_R16G16_UINT:
    363     case VK_FORMAT_R16G16B16_UINT:
    364     case VK_FORMAT_R16G16B16A16_UINT:
    365     case VK_FORMAT_R32_UINT:
    366     case VK_FORMAT_R32G32_UINT:
    367     case VK_FORMAT_R32G32B32_UINT:
    368     case VK_FORMAT_R32G32B32A32_UINT:
    369     case VK_FORMAT_R64_UINT:
    370     case VK_FORMAT_R64G64_UINT:
    371     case VK_FORMAT_R64G64B64_UINT:
    372     case VK_FORMAT_R64G64B64A64_UINT:
    373     case VK_FORMAT_B8G8R8_UINT:
    374     case VK_FORMAT_B8G8R8A8_UINT:
    375     case VK_FORMAT_A2R10G10B10_UINT_PACK32:
    376         is_uint = true;
    377         break;
    378     default:
    379         break;
    380     }
    381 
    382     return is_uint;
    383 }
    384 
    385 // Return true if format is a signed integer format
    386 bool vk_format_is_sint(VkFormat format) {
    387     bool is_sint = false;
    388 
    389     switch (format) {
    390     case VK_FORMAT_R8_SINT:
    391     case VK_FORMAT_R8G8_SINT:
    392     case VK_FORMAT_R8G8B8_SINT:
    393     case VK_FORMAT_R8G8B8A8_SINT:
    394     case VK_FORMAT_A8B8G8R8_SINT_PACK32:
    395     case VK_FORMAT_A2B10G10R10_SINT_PACK32:
    396     case VK_FORMAT_R16_SINT:
    397     case VK_FORMAT_R16G16_SINT:
    398     case VK_FORMAT_R16G16B16_SINT:
    399     case VK_FORMAT_R16G16B16A16_SINT:
    400     case VK_FORMAT_R32_SINT:
    401     case VK_FORMAT_R32G32_SINT:
    402     case VK_FORMAT_R32G32B32_SINT:
    403     case VK_FORMAT_R32G32B32A32_SINT:
    404     case VK_FORMAT_R64_SINT:
    405     case VK_FORMAT_R64G64_SINT:
    406     case VK_FORMAT_R64G64B64_SINT:
    407     case VK_FORMAT_R64G64B64A64_SINT:
    408     case VK_FORMAT_B8G8R8_SINT:
    409     case VK_FORMAT_B8G8R8A8_SINT:
    410     case VK_FORMAT_A2R10G10B10_SINT_PACK32:
    411         is_sint = true;
    412         break;
    413     default:
    414         break;
    415     }
    416 
    417     return is_sint;
    418 }
    419 
    420 // Return true if format is a floating-point format
    421 bool vk_format_is_float(VkFormat format) {
    422     bool is_float = false;
    423 
    424     switch (format) {
    425     case VK_FORMAT_R16_SFLOAT:
    426     case VK_FORMAT_R16G16_SFLOAT:
    427     case VK_FORMAT_R16G16B16_SFLOAT:
    428     case VK_FORMAT_R16G16B16A16_SFLOAT:
    429     case VK_FORMAT_R32_SFLOAT:
    430     case VK_FORMAT_R32G32_SFLOAT:
    431     case VK_FORMAT_R32G32B32_SFLOAT:
    432     case VK_FORMAT_R32G32B32A32_SFLOAT:
    433     case VK_FORMAT_R64_SFLOAT:
    434     case VK_FORMAT_R64G64_SFLOAT:
    435     case VK_FORMAT_R64G64B64_SFLOAT:
    436     case VK_FORMAT_R64G64B64A64_SFLOAT:
    437     case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
    438     case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
    439     case VK_FORMAT_BC6H_UFLOAT_BLOCK:
    440     case VK_FORMAT_BC6H_SFLOAT_BLOCK:
    441         is_float = true;
    442         break;
    443     default:
    444         break;
    445     }
    446 
    447     return is_float;
    448 }
    449 
    450 // Return true if format is in the SRGB colorspace
    451 bool vk_format_is_srgb(VkFormat format) {
    452     bool is_srgb = false;
    453 
    454     switch (format) {
    455     case VK_FORMAT_R8_SRGB:
    456     case VK_FORMAT_R8G8_SRGB:
    457     case VK_FORMAT_R8G8B8_SRGB:
    458     case VK_FORMAT_R8G8B8A8_SRGB:
    459     case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
    460     case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
    461     case VK_FORMAT_BC2_SRGB_BLOCK:
    462     case VK_FORMAT_BC3_SRGB_BLOCK:
    463     case VK_FORMAT_BC7_SRGB_BLOCK:
    464     case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
    465     case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
    466     case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
    467     case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
    468     case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
    469     case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
    470     case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
    471     case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
    472     case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
    473     case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
    474     case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
    475     case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
    476     case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
    477     case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
    478     case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
    479     case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
    480     case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
    481     case VK_FORMAT_B8G8R8_SRGB:
    482     case VK_FORMAT_B8G8R8A8_SRGB:
    483         is_srgb = true;
    484         break;
    485     default:
    486         break;
    487     }
    488 
    489     return is_srgb;
    490 }
    491 
    492 // Return true if format is compressed
    493 bool vk_format_is_compressed(VkFormat format) {
    494     switch (format) {
    495     case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
    496     case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
    497     case VK_FORMAT_BC2_UNORM_BLOCK:
    498     case VK_FORMAT_BC2_SRGB_BLOCK:
    499     case VK_FORMAT_BC3_UNORM_BLOCK:
    500     case VK_FORMAT_BC3_SRGB_BLOCK:
    501     case VK_FORMAT_BC4_UNORM_BLOCK:
    502     case VK_FORMAT_BC4_SNORM_BLOCK:
    503     case VK_FORMAT_BC5_UNORM_BLOCK:
    504     case VK_FORMAT_BC5_SNORM_BLOCK:
    505     case VK_FORMAT_BC6H_UFLOAT_BLOCK:
    506     case VK_FORMAT_BC6H_SFLOAT_BLOCK:
    507     case VK_FORMAT_BC7_UNORM_BLOCK:
    508     case VK_FORMAT_BC7_SRGB_BLOCK:
    509     case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
    510     case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
    511     case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
    512     case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
    513     case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
    514     case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
    515     case VK_FORMAT_EAC_R11_UNORM_BLOCK:
    516     case VK_FORMAT_EAC_R11_SNORM_BLOCK:
    517     case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
    518     case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
    519     case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
    520     case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
    521     case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
    522     case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
    523     case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
    524     case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
    525     case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
    526     case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
    527     case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
    528     case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
    529     case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
    530     case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
    531     case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
    532     case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
    533     case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
    534     case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
    535     case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
    536     case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
    537     case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
    538     case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
    539     case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
    540     case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
    541     case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
    542     case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
    543     case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
    544     case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
    545     case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
    546     case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
    547         return true;
    548     default:
    549         return false;
    550     }
    551 }
    552 
    553 // Return format class of the specified format
    554 VkFormatCompatibilityClass vk_format_get_compatibility_class(VkFormat format) { return vk_format_table[format].format_class; }
    555 
    556 // Return size, in bytes, of a pixel of the specified format
    557 size_t vk_format_get_size(VkFormat format) { return vk_format_table[format].size; }
    558 
    559 // Return the number of channels for a given format
    560 unsigned int vk_format_get_channel_count(VkFormat format) { return vk_format_table[format].channel_count; }
    561 
    562 // Perform a zero-tolerant modulo operation
    563 VkDeviceSize vk_safe_modulo(VkDeviceSize dividend, VkDeviceSize divisor) {
    564     VkDeviceSize result = 0;
    565     if (divisor != 0) {
    566         result = dividend % divisor;
    567     }
    568     return result;
    569 }
    570 
    571 static const char UTF8_ONE_BYTE_CODE = 0xC0;
    572 static const char UTF8_ONE_BYTE_MASK = 0xE0;
    573 static const char UTF8_TWO_BYTE_CODE = 0xE0;
    574 static const char UTF8_TWO_BYTE_MASK = 0xF0;
    575 static const char UTF8_THREE_BYTE_CODE = 0xF0;
    576 static const char UTF8_THREE_BYTE_MASK = 0xF8;
    577 static const char UTF8_DATA_BYTE_CODE = 0x80;
    578 static const char UTF8_DATA_BYTE_MASK = 0xC0;
    579 
    580 VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) {
    581     VkStringErrorFlags result = VK_STRING_ERROR_NONE;
    582     int num_char_bytes = 0;
    583     int i, j;
    584 
    585     for (i = 0; i < max_length; i++) {
    586         if (utf8[i] == 0) {
    587             break;
    588         } else if ((utf8[i] >= 0x20) && (utf8[i] < 0x7f)) {
    589             num_char_bytes = 0;
    590         } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) {
    591             num_char_bytes = 1;
    592         } else if ((utf8[i] & UTF8_TWO_BYTE_MASK) == UTF8_TWO_BYTE_CODE) {
    593             num_char_bytes = 2;
    594         } else if ((utf8[i] & UTF8_THREE_BYTE_MASK) == UTF8_THREE_BYTE_CODE) {
    595             num_char_bytes = 3;
    596         } else {
    597             result = VK_STRING_ERROR_BAD_DATA;
    598         }
    599 
    600         // Validate the following num_char_bytes of data
    601         for (j = 0; (j < num_char_bytes) && (i < max_length); j++) {
    602             if (++i == max_length) {
    603                 result |= VK_STRING_ERROR_LENGTH;
    604                 break;
    605             }
    606             if ((utf8[i] & UTF8_DATA_BYTE_MASK) != UTF8_DATA_BYTE_CODE) {
    607                 result |= VK_STRING_ERROR_BAD_DATA;
    608             }
    609         }
    610     }
    611     return result;
    612 }
    613 
    614 void layer_debug_actions(debug_report_data *report_data, std::vector<VkDebugReportCallbackEXT> &logging_callback,
    615                       const VkAllocationCallbacks *pAllocator, const char *layer_identifier) {
    616 
    617     uint32_t report_flags = 0;
    618     uint32_t debug_action = 0;
    619     VkDebugReportCallbackEXT callback = VK_NULL_HANDLE;
    620 
    621     std::string report_flags_key = layer_identifier;
    622     std::string debug_action_key = layer_identifier;
    623     std::string log_filename_key = layer_identifier;
    624     report_flags_key.append(".report_flags");
    625     debug_action_key.append(".debug_action");
    626     log_filename_key.append(".log_filename");
    627 
    628     // initialize layer options
    629     report_flags = getLayerOptionFlags(report_flags_key.c_str(), 0);
    630     getLayerOptionEnum(debug_action_key.c_str(), (uint32_t *)&debug_action);
    631 
    632     if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) {
    633         const char *log_filename = getLayerOption(log_filename_key.c_str());
    634         FILE *log_output = getLayerLogOutput(log_filename, layer_identifier);
    635         VkDebugReportCallbackCreateInfoEXT dbgCreateInfo;
    636         memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
    637         dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
    638         dbgCreateInfo.flags = report_flags;
    639         dbgCreateInfo.pfnCallback = log_callback;
    640         dbgCreateInfo.pUserData = (void *)log_output;
    641         layer_create_msg_callback(report_data, &dbgCreateInfo, pAllocator, &callback);
    642         logging_callback.push_back(callback);
    643     }
    644 
    645     if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) {
    646         VkDebugReportCallbackCreateInfoEXT dbgCreateInfo;
    647         memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
    648         dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
    649         dbgCreateInfo.flags = report_flags;
    650         dbgCreateInfo.pfnCallback = win32_debug_output_msg;
    651         dbgCreateInfo.pUserData = NULL;
    652         layer_create_msg_callback(report_data, &dbgCreateInfo, pAllocator, &callback);
    653         logging_callback.push_back(callback);
    654     }
    655 }
    656