Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 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: |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 11 | * |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 12 | * The above copyright notice(s) and this permission notice shall be included |
| 13 | * in all copies or substantial portions of the Materials. |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14 | * |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 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 |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 23 | * |
Jon Ashburn | c5a5d63 | 2015-11-03 13:41:23 -0700 | [diff] [blame] | 24 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 25 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 26 | */ |
| 27 | |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 28 | #pragma once |
| 29 | #include <stdbool.h> |
Mark Lobodzinski | d11c4ee | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 30 | #include <vector> |
| 31 | #include "vk_layer_logging.h" |
| 32 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 33 | #ifndef WIN32 |
| 34 | #include <strings.h> /* for ffs() */ |
Courtney Goeltzenleuchter | 55a1a36 | 2015-10-27 11:23:21 -0600 | [diff] [blame] | 35 | #else |
| 36 | #include <intrin.h> /* for __lzcnt() */ |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 37 | #endif |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 38 | |
| 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | |
Jon Ashburn | 2f42d49 | 2016-03-24 08:32:09 -0600 | [diff] [blame] | 43 | #define VK_LAYER_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION) |
Mark Lobodzinski | fdd29d9 | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 44 | typedef enum VkFormatCompatibilityClass { |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 45 | VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT = 0, |
| 46 | VK_FORMAT_COMPATIBILITY_CLASS_8_BIT = 1, |
| 47 | VK_FORMAT_COMPATIBILITY_CLASS_16_BIT = 2, |
| 48 | VK_FORMAT_COMPATIBILITY_CLASS_24_BIT = 3, |
| 49 | VK_FORMAT_COMPATIBILITY_CLASS_32_BIT = 4, |
| 50 | VK_FORMAT_COMPATIBILITY_CLASS_48_BIT = 5, |
| 51 | VK_FORMAT_COMPATIBILITY_CLASS_64_BIT = 6, |
| 52 | VK_FORMAT_COMPATIBILITY_CLASS_96_BIT = 7, |
| 53 | VK_FORMAT_COMPATIBILITY_CLASS_128_BIT = 8, |
| 54 | VK_FORMAT_COMPATIBILITY_CLASS_192_BIT = 9, |
| 55 | VK_FORMAT_COMPATIBILITY_CLASS_256_BIT = 10, |
| 56 | VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT = 11, |
| 57 | VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT = 12, |
| 58 | VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT = 13, |
| 59 | VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT = 14, |
| 60 | VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT = 15, |
| 61 | VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT = 16, |
| 62 | VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT = 17, |
| 63 | VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT = 18, |
| 64 | VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT = 19, |
| 65 | VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT = 20, |
Mark Lobodzinski | fdd29d9 | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 66 | VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT = 21, |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 67 | VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT = 22, |
| 68 | VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT = 23, |
| 69 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT = 24, |
| 70 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT = 25, |
| 71 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT = 26, |
| 72 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT = 27, |
| 73 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT = 28, |
| 74 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT = 29, |
| 75 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT = 20, |
| 76 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT = 31, |
| 77 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT = 32, |
| 78 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT = 33, |
| 79 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT = 34, |
| 80 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT = 35, |
| 81 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT = 36, |
| 82 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT = 37, |
| 83 | VK_FORMAT_COMPATIBILITY_CLASS_D16_BIT = 38, |
| 84 | VK_FORMAT_COMPATIBILITY_CLASS_D24_BIT = 39, |
| 85 | VK_FORMAT_COMPATIBILITY_CLASS_D32_BIT = 30, |
| 86 | VK_FORMAT_COMPATIBILITY_CLASS_S8_BIT = 41, |
| 87 | VK_FORMAT_COMPATIBILITY_CLASS_D16S8_BIT = 42, |
| 88 | VK_FORMAT_COMPATIBILITY_CLASS_D24S8_BIT = 43, |
| 89 | VK_FORMAT_COMPATIBILITY_CLASS_D32S8_BIT = 44, |
| 90 | VK_FORMAT_COMPATIBILITY_CLASS_MAX_ENUM = 45 |
Mark Lobodzinski | fdd29d9 | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 91 | } VkFormatCompatibilityClass; |
| 92 | |
Mark Lobodzinski | bc9a9d8 | 2016-01-11 14:17:05 -0700 | [diff] [blame] | 93 | typedef enum VkStringErrorFlagBits { |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 94 | VK_STRING_ERROR_NONE = 0x00000000, |
| 95 | VK_STRING_ERROR_LENGTH = 0x00000001, |
| 96 | VK_STRING_ERROR_BAD_DATA = 0x00000002, |
Mark Lobodzinski | bc9a9d8 | 2016-01-11 14:17:05 -0700 | [diff] [blame] | 97 | } VkStringErrorFlagBits; |
| 98 | typedef VkFlags VkStringErrorFlags; |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 99 | |
Mark Lobodzinski | 24e7586 | 2016-03-17 13:59:51 -0600 | [diff] [blame] | 100 | void layer_debug_actions(debug_report_data* report_data, std::vector<VkDebugReportCallbackEXT> &logging_callback, |
Mark Lobodzinski | d11c4ee | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 101 | const VkAllocationCallbacks *pAllocator, const char* layer_identifier); |
| 102 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 103 | static inline bool vk_format_is_undef(VkFormat format) { return (format == VK_FORMAT_UNDEFINED); } |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 104 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 105 | bool vk_format_is_depth_or_stencil(VkFormat format); |
| 106 | bool vk_format_is_depth_and_stencil(VkFormat format); |
| 107 | bool vk_format_is_depth_only(VkFormat format); |
| 108 | bool vk_format_is_stencil_only(VkFormat format); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 109 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 110 | static inline bool vk_format_is_color(VkFormat format) { |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 111 | return !(vk_format_is_undef(format) || vk_format_is_depth_or_stencil(format)); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 112 | } |
| 113 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 114 | bool vk_format_is_norm(VkFormat format); |
| 115 | bool vk_format_is_int(VkFormat format); |
| 116 | bool vk_format_is_sint(VkFormat format); |
| 117 | bool vk_format_is_uint(VkFormat format); |
| 118 | bool vk_format_is_float(VkFormat format); |
| 119 | bool vk_format_is_srgb(VkFormat format); |
| 120 | bool vk_format_is_compressed(VkFormat format); |
| 121 | size_t vk_format_get_size(VkFormat format); |
| 122 | unsigned int vk_format_get_channel_count(VkFormat format); |
Mark Lobodzinski | fdd29d9 | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 123 | VkFormatCompatibilityClass vk_format_get_compatibility_class(VkFormat format); |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 124 | VkDeviceSize vk_safe_modulo(VkDeviceSize dividend, VkDeviceSize divisor); |
| 125 | VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 126 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 127 | static inline int u_ffs(int val) { |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 128 | #ifdef WIN32 |
Mark Lobodzinski | d672944 | 2015-12-16 17:47:28 -0700 | [diff] [blame] | 129 | unsigned long bit_pos = 0; |
Mike Stroyan | 2febb86 | 2016-01-07 10:05:21 -0700 | [diff] [blame] | 130 | if (_BitScanForward(&bit_pos, val) != 0) { |
Mark Lobodzinski | d672944 | 2015-12-16 17:47:28 -0700 | [diff] [blame] | 131 | bit_pos += 1; |
| 132 | } |
| 133 | return bit_pos; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 134 | #else |
Mark Lobodzinski | d672944 | 2015-12-16 17:47:28 -0700 | [diff] [blame] | 135 | return ffs(val); |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 136 | #endif |
| 137 | } |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 138 | |
| 139 | #ifdef __cplusplus |
| 140 | } |
| 141 | #endif |