Mark Lobodzinski | 6eda00a | 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 | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 16 | * |
Jon Ashburn | e922f71 | 2015-11-03 13:41:23 -0700 | [diff] [blame] | 17 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 18 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 21 | #pragma once |
| 22 | #include <stdbool.h> |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 23 | #include <vector> |
| 24 | #include "vk_layer_logging.h" |
| 25 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 26 | #ifndef WIN32 |
| 27 | #include <strings.h> /* for ffs() */ |
Courtney Goeltzenleuchter | 3698c62 | 2015-10-27 11:23:21 -0600 | [diff] [blame] | 28 | #else |
| 29 | #include <intrin.h> /* for __lzcnt() */ |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 30 | #endif |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 31 | |
| 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
Jon Ashburn | d883d81 | 2016-03-24 08:32:09 -0600 | [diff] [blame] | 36 | #define VK_LAYER_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION) |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 37 | typedef enum VkFormatCompatibilityClass { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 38 | VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT = 0, |
| 39 | VK_FORMAT_COMPATIBILITY_CLASS_8_BIT = 1, |
| 40 | VK_FORMAT_COMPATIBILITY_CLASS_16_BIT = 2, |
| 41 | VK_FORMAT_COMPATIBILITY_CLASS_24_BIT = 3, |
| 42 | VK_FORMAT_COMPATIBILITY_CLASS_32_BIT = 4, |
| 43 | VK_FORMAT_COMPATIBILITY_CLASS_48_BIT = 5, |
| 44 | VK_FORMAT_COMPATIBILITY_CLASS_64_BIT = 6, |
| 45 | VK_FORMAT_COMPATIBILITY_CLASS_96_BIT = 7, |
| 46 | VK_FORMAT_COMPATIBILITY_CLASS_128_BIT = 8, |
| 47 | VK_FORMAT_COMPATIBILITY_CLASS_192_BIT = 9, |
| 48 | VK_FORMAT_COMPATIBILITY_CLASS_256_BIT = 10, |
| 49 | VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT = 11, |
| 50 | VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT = 12, |
| 51 | VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT = 13, |
| 52 | VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT = 14, |
| 53 | VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT = 15, |
| 54 | VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT = 16, |
| 55 | VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT = 17, |
| 56 | VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT = 18, |
| 57 | VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT = 19, |
| 58 | VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT = 20, |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 59 | VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT = 21, |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 60 | VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT = 22, |
| 61 | VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT = 23, |
| 62 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT = 24, |
| 63 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT = 25, |
| 64 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT = 26, |
| 65 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT = 27, |
| 66 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT = 28, |
| 67 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT = 29, |
| 68 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT = 20, |
| 69 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT = 31, |
| 70 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT = 32, |
| 71 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT = 33, |
| 72 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT = 34, |
| 73 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT = 35, |
| 74 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT = 36, |
| 75 | VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT = 37, |
| 76 | VK_FORMAT_COMPATIBILITY_CLASS_D16_BIT = 38, |
| 77 | VK_FORMAT_COMPATIBILITY_CLASS_D24_BIT = 39, |
| 78 | VK_FORMAT_COMPATIBILITY_CLASS_D32_BIT = 30, |
| 79 | VK_FORMAT_COMPATIBILITY_CLASS_S8_BIT = 41, |
| 80 | VK_FORMAT_COMPATIBILITY_CLASS_D16S8_BIT = 42, |
| 81 | VK_FORMAT_COMPATIBILITY_CLASS_D24S8_BIT = 43, |
| 82 | VK_FORMAT_COMPATIBILITY_CLASS_D32S8_BIT = 44, |
| 83 | VK_FORMAT_COMPATIBILITY_CLASS_MAX_ENUM = 45 |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 84 | } VkFormatCompatibilityClass; |
| 85 | |
Mark Lobodzinski | a9f3349 | 2016-01-11 14:17:05 -0700 | [diff] [blame] | 86 | typedef enum VkStringErrorFlagBits { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 87 | VK_STRING_ERROR_NONE = 0x00000000, |
| 88 | VK_STRING_ERROR_LENGTH = 0x00000001, |
| 89 | VK_STRING_ERROR_BAD_DATA = 0x00000002, |
Mark Lobodzinski | a9f3349 | 2016-01-11 14:17:05 -0700 | [diff] [blame] | 90 | } VkStringErrorFlagBits; |
| 91 | typedef VkFlags VkStringErrorFlags; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 92 | |
Mark Lobodzinski | f856847 | 2016-03-17 13:59:51 -0600 | [diff] [blame] | 93 | void layer_debug_actions(debug_report_data* report_data, std::vector<VkDebugReportCallbackEXT> &logging_callback, |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 94 | const VkAllocationCallbacks *pAllocator, const char* layer_identifier); |
| 95 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 96 | static inline bool vk_format_is_undef(VkFormat format) { return (format == VK_FORMAT_UNDEFINED); } |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 97 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 98 | bool vk_format_is_depth_or_stencil(VkFormat format); |
| 99 | bool vk_format_is_depth_and_stencil(VkFormat format); |
| 100 | bool vk_format_is_depth_only(VkFormat format); |
| 101 | bool vk_format_is_stencil_only(VkFormat format); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 102 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 103 | static inline bool vk_format_is_color(VkFormat format) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 104 | return !(vk_format_is_undef(format) || vk_format_is_depth_or_stencil(format)); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 105 | } |
| 106 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 107 | bool vk_format_is_norm(VkFormat format); |
| 108 | bool vk_format_is_int(VkFormat format); |
| 109 | bool vk_format_is_sint(VkFormat format); |
| 110 | bool vk_format_is_uint(VkFormat format); |
| 111 | bool vk_format_is_float(VkFormat format); |
| 112 | bool vk_format_is_srgb(VkFormat format); |
| 113 | bool vk_format_is_compressed(VkFormat format); |
| 114 | size_t vk_format_get_size(VkFormat format); |
| 115 | unsigned int vk_format_get_channel_count(VkFormat format); |
Mark Lobodzinski | adaac9d | 2016-01-08 11:07:56 -0700 | [diff] [blame] | 116 | VkFormatCompatibilityClass vk_format_get_compatibility_class(VkFormat format); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 117 | VkDeviceSize vk_safe_modulo(VkDeviceSize dividend, VkDeviceSize divisor); |
| 118 | VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 119 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 120 | static inline int u_ffs(int val) { |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 121 | #ifdef WIN32 |
Mark Lobodzinski | 5ddf6c3 | 2015-12-16 17:47:28 -0700 | [diff] [blame] | 122 | unsigned long bit_pos = 0; |
Mike Stroyan | debb984 | 2016-01-07 10:05:21 -0700 | [diff] [blame] | 123 | if (_BitScanForward(&bit_pos, val) != 0) { |
Mark Lobodzinski | 5ddf6c3 | 2015-12-16 17:47:28 -0700 | [diff] [blame] | 124 | bit_pos += 1; |
| 125 | } |
| 126 | return bit_pos; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 127 | #else |
Mark Lobodzinski | 5ddf6c3 | 2015-12-16 17:47:28 -0700 | [diff] [blame] | 128 | return ffs(val); |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 129 | #endif |
| 130 | } |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 131 | |
| 132 | #ifdef __cplusplus |
| 133 | } |
| 134 | #endif |