Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 1 | /* |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 2 | * |
Courtney Goeltzenleuchter | fcbe16f | 2015-10-29 13:50:34 -0600 | [diff] [blame] | 3 | * Copyright (C) 2015 Valve Corporation |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 4 | * Copyright (C) 2015 Google Inc. |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 24 | * Author: Ian Elliott <ian@lunarg.com> |
| 25 | * |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef SWAPCHAIN_H |
| 29 | #define SWAPCHAIN_H |
| 30 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 31 | #include "vulkan/vk_layer.h" |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 32 | #include "vulkan/vk_ext_debug_report.h" |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 33 | #include "vk_layer_config.h" |
| 34 | #include "vk_layer_logging.h" |
Courtney Goeltzenleuchter | cf60e0a | 2015-10-08 17:07:25 -0600 | [diff] [blame] | 35 | #include <vector> |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 36 | #include <unordered_map> |
Courtney Goeltzenleuchter | cf60e0a | 2015-10-08 17:07:25 -0600 | [diff] [blame] | 37 | |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 38 | static const VkLayerProperties globalLayerProps[] = { |
| 39 | { |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 40 | "VK_LAYER_LUNARG_swapchain", |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 41 | VK_API_VERSION, // specVersion |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 42 | VK_MAKE_VERSION(0, 1, 0), // implementationVersion |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 43 | "layer: swapchain", |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 44 | } |
| 45 | }; |
| 46 | |
| 47 | static const VkLayerProperties deviceLayerProps[] = { |
| 48 | { |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 49 | "VK_LAYER_LUNARG_swapchain", |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 50 | VK_API_VERSION, // specVersion |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 51 | VK_MAKE_VERSION(0, 1, 0), // implementationVersion |
Mark Lobodzinski | 0d054fe | 2015-12-30 08:16:12 -0700 | [diff] [blame] | 52 | "layer: swapchain", |
Ian Elliott | d8c5db1 | 2015-10-07 11:32:31 -0600 | [diff] [blame] | 53 | } |
| 54 | }; |
| 55 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 56 | |
| 57 | using namespace std; |
| 58 | |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 59 | |
| 60 | // Swapchain ERROR codes |
| 61 | typedef enum _SWAPCHAIN_ERROR |
| 62 | { |
| 63 | SWAPCHAIN_INVALID_HANDLE, // Handle used that isn't currently valid |
| 64 | SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, // Did not enable WSI extension, but called WSI function |
| 65 | SWAPCHAIN_DEL_DEVICE_BEFORE_SWAPCHAINS, // Called vkDestroyDevice() before vkDestroySwapchainKHR() |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 66 | SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, // Called vkCreateSwapchainKHR() without calling a query (e.g. vkGetPhysicalDeviceSurfaceCapabilitiesKHR()) |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 67 | SWAPCHAIN_CREATE_SWAP_BAD_MIN_IMG_COUNT, // Called vkCreateSwapchainKHR() with out-of-bounds minImageCount |
| 68 | SWAPCHAIN_CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS,// Called vkCreateSwapchainKHR() with out-of-bounds imageExtent |
| 69 | SWAPCHAIN_CREATE_SWAP_EXTENTS_NO_MATCH_WIN, // Called vkCreateSwapchainKHR() with imageExtent that doesn't match window's extent |
| 70 | SWAPCHAIN_CREATE_SWAP_BAD_PRE_TRANSFORM, // Called vkCreateSwapchainKHR() with a non-supported preTransform |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 71 | SWAPCHAIN_CREATE_SWAP_BAD_COMPOSITE_ALPHA, // Called vkCreateSwapchainKHR() with a non-supported compositeAlpha |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 72 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_ARRAY_SIZE, // Called vkCreateSwapchainKHR() with a non-supported imageArraySize |
| 73 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_USAGE_FLAGS, // Called vkCreateSwapchainKHR() with a non-supported imageUsageFlags |
| 74 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_COLOR_SPACE, // Called vkCreateSwapchainKHR() with a non-supported imageColorSpace |
| 75 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_FORMAT, // Called vkCreateSwapchainKHR() with a non-supported imageFormat |
| 76 | SWAPCHAIN_CREATE_SWAP_BAD_IMG_FMT_CLR_SP, // Called vkCreateSwapchainKHR() with a non-supported imageColorSpace |
| 77 | SWAPCHAIN_CREATE_SWAP_BAD_PRESENT_MODE, // Called vkCreateSwapchainKHR() with a non-supported presentMode |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 78 | SWAPCHAIN_CREATE_SWAP_BAD_SHARING_MODE, // Called vkCreateSwapchainKHR() with a non-supported imageSharingMode |
| 79 | SWAPCHAIN_CREATE_SWAP_BAD_SHARING_VALUES, // Called vkCreateSwapchainKHR() with bad values when imageSharingMode is VK_SHARING_MODE_CONCURRENT |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 80 | SWAPCHAIN_DESTROY_SWAP_DIFF_DEVICE, // Called vkDestroySwapchainKHR() with a different VkDevice than vkCreateSwapchainKHR() |
| 81 | SWAPCHAIN_APP_OWNS_TOO_MANY_IMAGES, // vkAcquireNextImageKHR() asked for more images than are available |
| 82 | SWAPCHAIN_INDEX_TOO_LARGE, // Index is too large for swapchain |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 83 | SWAPCHAIN_INDEX_NOT_IN_USE, // vkQueuePresentKHR() given index that is not owned by app |
Ian Elliott | a2a89c5 | 2015-12-28 15:23:57 -0700 | [diff] [blame] | 84 | SWAPCHAIN_BAD_BOOL, // VkBool32 that doesn't have value of VK_TRUE or VK_FALSE (e.g. is a non-zero form of true) |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 85 | } SWAPCHAIN_ERROR; |
| 86 | |
| 87 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 88 | // The following is for logging error messages: |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 89 | #define LAYER_NAME (char *) "Swapchain" |
| 90 | #define LOG_ERROR_NON_VALID_OBJ(objType, type, obj) \ |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 91 | (my_data) ? \ |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 92 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (objType), \ |
Mark Lobodzinski | 80e774f | 2016-01-04 15:54:59 -0700 | [diff] [blame] | 93 | (uint64_t) (obj), __LINE__, SWAPCHAIN_INVALID_HANDLE, LAYER_NAME, \ |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 94 | "%s() called with a non-valid %s.", __FUNCTION__, (obj)) \ |
| 95 | : VK_FALSE |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 96 | |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 97 | #define LOG_ERROR(objType, type, obj, enm, fmt, ...) \ |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 98 | (my_data) ? \ |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 99 | log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (objType), \ |
Mark Lobodzinski | 80e774f | 2016-01-04 15:54:59 -0700 | [diff] [blame] | 100 | (uint64_t) (obj), __LINE__, (enm), LAYER_NAME, (fmt), __VA_ARGS__) \ |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 101 | : VK_FALSE |
Ian Elliott | b0f474c | 2015-09-25 15:50:55 -0600 | [diff] [blame] | 102 | #define LOG_PERF_WARNING(objType, type, obj, enm, fmt, ...) \ |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 103 | (my_data) ? \ |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 104 | log_msg(my_data->report_data, VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, (objType), \ |
Mark Lobodzinski | 80e774f | 2016-01-04 15:54:59 -0700 | [diff] [blame] | 105 | (uint64_t) (obj), __LINE__, (enm), LAYER_NAME, (fmt), __VA_ARGS__) \ |
Ian Elliott | 68124ac | 2015-10-07 16:18:35 -0600 | [diff] [blame] | 106 | : VK_FALSE |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 107 | |
| 108 | |
| 109 | // NOTE: The following struct's/typedef's are for keeping track of |
| 110 | // info that is used for validating the WSI extensions. |
| 111 | |
| 112 | // Forward declarations: |
| 113 | struct _SwpInstance; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 114 | struct _SwpSurface; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 115 | struct _SwpPhysicalDevice; |
| 116 | struct _SwpDevice; |
| 117 | struct _SwpSwapchain; |
| 118 | struct _SwpImage; |
| 119 | |
| 120 | typedef _SwpInstance SwpInstance; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 121 | typedef _SwpSurface SwpSurface; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 122 | typedef _SwpPhysicalDevice SwpPhysicalDevice; |
| 123 | typedef _SwpDevice SwpDevice; |
| 124 | typedef _SwpSwapchain SwpSwapchain; |
| 125 | typedef _SwpImage SwpImage; |
| 126 | |
| 127 | // Create one of these for each VkInstance: |
| 128 | struct _SwpInstance { |
| 129 | // The actual handle for this VkInstance: |
| 130 | VkInstance instance; |
| 131 | |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 132 | // Remember the VkSurfaceKHR's that are created for this VkInstance: |
| 133 | unordered_map<const void*, SwpSurface*> surfaces; |
| 134 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 135 | // When vkEnumeratePhysicalDevices is called, the VkPhysicalDevice's are |
| 136 | // remembered: |
| 137 | unordered_map<const void*, SwpPhysicalDevice*> physicalDevices; |
| 138 | |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 139 | // Set to true if VK_KHR_SURFACE_EXTENSION_NAME was enabled for this VkInstance: |
Ian Elliott | 1cb77a6 | 2015-12-29 16:44:39 -0700 | [diff] [blame] | 140 | bool surfaceExtensionEnabled; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 141 | |
| 142 | // TODO: Add additional booleans for platform-specific extensions: |
| 143 | }; |
| 144 | |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 145 | // Create one of these for each VkSurfaceKHR: |
| 146 | struct _SwpSurface { |
| 147 | // The actual handle for this VkSurfaceKHR: |
| 148 | VkSurfaceKHR surface; |
| 149 | |
| 150 | // VkInstance that this VkSurfaceKHR is associated with: |
| 151 | SwpInstance *pInstance; |
| 152 | |
| 153 | // Which platform this VkSurfaceKHR is associated with: |
| 154 | VkIcdWsiPlatform platform; |
| 155 | |
| 156 | // TODO: Add additional platform-specific info: |
| 157 | }; |
| 158 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 159 | // Create one of these for each VkPhysicalDevice within a VkInstance: |
| 160 | struct _SwpPhysicalDevice { |
| 161 | // The actual handle for this VkPhysicalDevice: |
| 162 | VkPhysicalDevice physicalDevice; |
| 163 | |
| 164 | // Corresponding VkDevice (and info) to this VkPhysicalDevice: |
| 165 | SwpDevice *pDevice; |
| 166 | |
| 167 | // VkInstance that this VkPhysicalDevice is associated with: |
| 168 | SwpInstance *pInstance; |
| 169 | |
| 170 | // Which queueFamilyIndices support presenting with WSI swapchains: |
| 171 | unordered_map<uint32_t, VkBool32> queueFamilyIndexSupport; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 172 | |
| 173 | // TODO: Record/use this info per-surface, not per-device, once a |
| 174 | // non-dispatchable surface object is added to WSI: |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 175 | // Results of vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 176 | bool gotSurfaceCapabilities; |
| 177 | VkSurfaceCapabilitiesKHR surfaceCapabilities; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 178 | |
| 179 | // TODO: Record/use this info per-surface, not per-device, once a |
| 180 | // non-dispatchable surface object is added to WSI: |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 181 | // Count and VkSurfaceFormatKHR's returned by vkGetPhysicalDeviceSurfaceFormatsKHR(): |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 182 | uint32_t surfaceFormatCount; |
| 183 | VkSurfaceFormatKHR* pSurfaceFormats; |
| 184 | |
| 185 | // TODO: Record/use this info per-surface, not per-device, once a |
| 186 | // non-dispatchable surface object is added to WSI: |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 187 | // Count and VkPresentModeKHR's returned by vkGetPhysicalDeviceSurfacePresentModesKHR(): |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 188 | uint32_t presentModeCount; |
| 189 | VkPresentModeKHR* pPresentModes; |
Ian Elliott | 27d39c7 | 2015-11-20 16:39:34 -0700 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | // Create one of these for each VkDevice within a VkInstance: |
| 193 | struct _SwpDevice { |
| 194 | // The actual handle for this VkDevice: |
| 195 | VkDevice device; |
| 196 | |
| 197 | // Corresponding VkPhysicalDevice (and info) to this VkDevice: |
| 198 | SwpPhysicalDevice *pPhysicalDevice; |
| 199 | |
| 200 | // Set to true if VK_KHR_SWAPCHAIN_EXTENSION_NAME was enabled: |
Ian Elliott | 427058f | 2015-12-29 16:45:49 -0700 | [diff] [blame] | 201 | bool swapchainExtensionEnabled; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 202 | |
| 203 | // When vkCreateSwapchainKHR is called, the VkSwapchainKHR's are |
| 204 | // remembered: |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 205 | unordered_map<VkSwapchainKHR, SwpSwapchain*> swapchains; |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | // Create one of these for each VkImage within a VkSwapchainKHR: |
| 209 | struct _SwpImage { |
| 210 | // The actual handle for this VkImage: |
| 211 | VkImage image; |
| 212 | |
| 213 | // Corresponding VkSwapchainKHR (and info) to this VkImage: |
| 214 | SwpSwapchain *pSwapchain; |
| 215 | |
| 216 | // true if application got this image from vkAcquireNextImageKHR(), and |
| 217 | // hasn't yet called vkQueuePresentKHR() for it; otherwise false: |
| 218 | bool ownedByApp; |
| 219 | }; |
| 220 | |
| 221 | // Create one of these for each VkSwapchainKHR within a VkDevice: |
| 222 | struct _SwpSwapchain { |
| 223 | // The actual handle for this VkSwapchainKHR: |
| 224 | VkSwapchainKHR swapchain; |
| 225 | |
| 226 | // Corresponding VkDevice (and info) to this VkSwapchainKHR: |
| 227 | SwpDevice *pDevice; |
| 228 | |
| 229 | // When vkGetSwapchainImagesKHR is called, the VkImage's are |
| 230 | // remembered: |
| 231 | uint32_t imageCount; |
| 232 | unordered_map<int, SwpImage> images; |
| 233 | }; |
| 234 | |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 235 | struct layer_data { |
| 236 | debug_report_data *report_data; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 237 | std::vector<VkDebugReportCallbackEXT> logging_callback; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 238 | VkLayerDispatchTable* device_dispatch_table; |
| 239 | VkLayerInstanceDispatchTable* instance_dispatch_table; |
| 240 | // NOTE: The following are for keeping track of info that is used for |
| 241 | // validating the WSI extensions. |
| 242 | std::unordered_map<void *, SwpInstance> instanceMap; |
Ian Elliott | a983e9a | 2015-12-22 12:18:12 -0700 | [diff] [blame] | 243 | std::unordered_map<void *, SwpSurface> surfaceMap; |
Tobin Ehlis | 711ff31 | 2015-10-29 12:58:13 -0600 | [diff] [blame] | 244 | std::unordered_map<void *, SwpPhysicalDevice> physicalDeviceMap; |
| 245 | std::unordered_map<void *, SwpDevice> deviceMap; |
| 246 | std::unordered_map<VkSwapchainKHR, SwpSwapchain> swapchainMap; |
| 247 | |
| 248 | layer_data() : |
| 249 | report_data(nullptr), |
| 250 | device_dispatch_table(nullptr), |
| 251 | instance_dispatch_table(nullptr) |
| 252 | {}; |
| 253 | }; |
| 254 | |
Ian Elliott | 0b4d624 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 255 | #endif // SWAPCHAIN_H |