Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 5 | * Copyright (C) 2015 Google, Inc. |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 | * DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | |
| 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 29 | #include <algorithm> |
| 30 | #include <memory> |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 31 | #include <unordered_map> |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 32 | #include <unordered_set> |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 33 | |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame] | 34 | #include "vk_loader_platform.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 35 | #include "vk_dispatch_table_helper.h" |
| 36 | #include "vk_struct_string_helper_cpp.h" |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 37 | #if defined(__GNUC__) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 38 | #pragma GCC diagnostic ignored "-Wwrite-strings" |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 39 | #endif |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 40 | #if defined(__GNUC__) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 41 | #pragma GCC diagnostic warning "-Wwrite-strings" |
Tony Barbour | 18f7155 | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 42 | #endif |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 43 | #include "vk_struct_size_helper.h" |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 44 | #include "draw_state.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 45 | #include "vk_layer_config.h" |
Jon Ashburn | e68a9ff | 2015-05-25 14:11:37 -0600 | [diff] [blame] | 46 | #include "vk_debug_marker_layer.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 47 | #include "vk_layer_table.h" |
| 48 | #include "vk_layer_debug_marker_table.h" |
| 49 | #include "vk_layer_data.h" |
| 50 | #include "vk_layer_logging.h" |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 51 | #include "vk_layer_extension_utils.h" |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 52 | #include "vk_layer_utils.h" |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 53 | |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 54 | struct devExts { |
| 55 | bool debug_marker_enabled; |
| 56 | }; |
| 57 | |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 58 | struct layer_data { |
Tobin Ehlis | c16c3e9 | 2015-06-16 09:04:30 -0600 | [diff] [blame] | 59 | debug_report_data *report_data; |
| 60 | // TODO: put instance data here |
Courtney Goeltzenleuchter | 62d945a | 2015-10-05 15:58:38 -0600 | [diff] [blame] | 61 | std::vector<VkDbgMsgCallback> logging_callback; |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 62 | VkLayerDispatchTable* device_dispatch_table; |
| 63 | VkLayerInstanceDispatchTable* instance_dispatch_table; |
| 64 | devExts device_extensions; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 65 | // Layer specific data |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 66 | unordered_map<VkSampler, unique_ptr<SAMPLER_NODE>> sampleMap; |
| 67 | unordered_map<VkImageView, unique_ptr<VkImageViewCreateInfo>> imageViewMap; |
| 68 | unordered_map<VkImage, unique_ptr<VkImageCreateInfo>> imageMap; |
| 69 | unordered_map<VkBufferView, unique_ptr<VkBufferViewCreateInfo>> bufferViewMap; |
| 70 | unordered_map<VkBuffer, unique_ptr<VkBufferCreateInfo>> bufferMap; |
| 71 | unordered_map<VkPipeline, PIPELINE_NODE*> pipelineMap; |
| 72 | unordered_map<VkDescriptorPool, POOL_NODE*> poolMap; |
| 73 | unordered_map<VkDescriptorSet, SET_NODE*> setMap; |
| 74 | unordered_map<VkDescriptorSetLayout, LAYOUT_NODE*> layoutMap; |
| 75 | unordered_map<VkPipelineLayout, PIPELINE_LAYOUT_NODE> pipelineLayoutMap; |
| 76 | unordered_map<VkShader, VkShaderStageFlagBits> shaderStageMap; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 77 | // Map for layout chains |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 78 | unordered_map<void*, GLOBAL_CB_NODE*> commandBufferMap; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 79 | unordered_map<VkRenderPass, VkRenderPassCreateInfo*> renderPassMap; |
| 80 | unordered_map<VkFramebuffer, VkFramebufferCreateInfo*> frameBufferMap; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 81 | |
| 82 | layer_data() : |
| 83 | report_data(nullptr), |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 84 | device_dispatch_table(nullptr), |
| 85 | instance_dispatch_table(nullptr), |
| 86 | device_extensions() |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 87 | {}; |
| 88 | }; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 89 | // TODO : Do we need to guard access to layer_data_map w/ lock? |
Tobin Ehlis | c16c3e9 | 2015-06-16 09:04:30 -0600 | [diff] [blame] | 90 | static std::unordered_map<void *, layer_data *> layer_data_map; |
Courtney Goeltzenleuchter | 3d0dfad | 2015-06-13 21:23:09 -0600 | [diff] [blame] | 91 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 92 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 93 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 94 | // TODO : This can be much smarter, using separate locks for separate global data |
| 95 | static int globalLockInitialized = 0; |
| 96 | static loader_platform_thread_mutex globalLock; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 97 | #define MAX_TID 513 |
| 98 | static loader_platform_thread_id g_tidMapping[MAX_TID] = {0}; |
| 99 | static uint32_t g_maxTID = 0; |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 100 | |
| 101 | template layer_data *get_my_data_ptr<layer_data>( |
| 102 | void *data_key, |
| 103 | std::unordered_map<void *, layer_data *> &data_map); |
| 104 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 105 | // Map actual TID to an index value and return that index |
| 106 | // This keeps TIDs in range from 0-MAX_TID and simplifies compares between runs |
| 107 | static uint32_t getTIDIndex() { |
| 108 | loader_platform_thread_id tid = loader_platform_get_thread_id(); |
| 109 | for (uint32_t i = 0; i < g_maxTID; i++) { |
| 110 | if (tid == g_tidMapping[i]) |
| 111 | return i; |
| 112 | } |
| 113 | // Don't yet have mapping, set it and return newly set index |
| 114 | uint32_t retVal = (uint32_t) g_maxTID; |
| 115 | g_tidMapping[g_maxTID++] = tid; |
| 116 | assert(g_maxTID < MAX_TID); |
| 117 | return retVal; |
| 118 | } |
| 119 | // Return a string representation of CMD_TYPE enum |
| 120 | static string cmdTypeToString(CMD_TYPE cmd) |
| 121 | { |
| 122 | switch (cmd) |
| 123 | { |
| 124 | case CMD_BINDPIPELINE: |
| 125 | return "CMD_BINDPIPELINE"; |
| 126 | case CMD_BINDPIPELINEDELTA: |
| 127 | return "CMD_BINDPIPELINEDELTA"; |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 128 | case CMD_SETVIEWPORTSTATE: |
| 129 | return "CMD_SETVIEWPORTSTATE"; |
| 130 | case CMD_SETLINEWIDTHSTATE: |
| 131 | return "CMD_SETLINEWIDTHSTATE"; |
| 132 | case CMD_SETDEPTHBIASSTATE: |
| 133 | return "CMD_SETDEPTHBIASSTATE"; |
| 134 | case CMD_SETBLENDSTATE: |
| 135 | return "CMD_SETBLENDSTATE"; |
| 136 | case CMD_SETDEPTHBOUNDSSTATE: |
| 137 | return "CMD_SETDEPTHBOUNDSSTATE"; |
| 138 | case CMD_SETSTENCILREADMASKSTATE: |
| 139 | return "CMD_SETSTENCILREADMASKSTATE"; |
| 140 | case CMD_SETSTENCILWRITEMASKSTATE: |
| 141 | return "CMD_SETSTENCILWRITEMASKSTATE"; |
| 142 | case CMD_SETSTENCILREFERENCESTATE: |
| 143 | return "CMD_SETSTENCILREFERENCESTATE"; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 144 | case CMD_BINDDESCRIPTORSETS: |
| 145 | return "CMD_BINDDESCRIPTORSETS"; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 146 | case CMD_BINDINDEXBUFFER: |
| 147 | return "CMD_BINDINDEXBUFFER"; |
| 148 | case CMD_BINDVERTEXBUFFER: |
| 149 | return "CMD_BINDVERTEXBUFFER"; |
| 150 | case CMD_DRAW: |
| 151 | return "CMD_DRAW"; |
| 152 | case CMD_DRAWINDEXED: |
| 153 | return "CMD_DRAWINDEXED"; |
| 154 | case CMD_DRAWINDIRECT: |
| 155 | return "CMD_DRAWINDIRECT"; |
| 156 | case CMD_DRAWINDEXEDINDIRECT: |
| 157 | return "CMD_DRAWINDEXEDINDIRECT"; |
| 158 | case CMD_DISPATCH: |
| 159 | return "CMD_DISPATCH"; |
| 160 | case CMD_DISPATCHINDIRECT: |
| 161 | return "CMD_DISPATCHINDIRECT"; |
| 162 | case CMD_COPYBUFFER: |
| 163 | return "CMD_COPYBUFFER"; |
| 164 | case CMD_COPYIMAGE: |
| 165 | return "CMD_COPYIMAGE"; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 166 | case CMD_BLITIMAGE: |
| 167 | return "CMD_BLITIMAGE"; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 168 | case CMD_COPYBUFFERTOIMAGE: |
| 169 | return "CMD_COPYBUFFERTOIMAGE"; |
| 170 | case CMD_COPYIMAGETOBUFFER: |
| 171 | return "CMD_COPYIMAGETOBUFFER"; |
| 172 | case CMD_CLONEIMAGEDATA: |
| 173 | return "CMD_CLONEIMAGEDATA"; |
| 174 | case CMD_UPDATEBUFFER: |
| 175 | return "CMD_UPDATEBUFFER"; |
| 176 | case CMD_FILLBUFFER: |
| 177 | return "CMD_FILLBUFFER"; |
| 178 | case CMD_CLEARCOLORIMAGE: |
| 179 | return "CMD_CLEARCOLORIMAGE"; |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 180 | case CMD_CLEARATTACHMENTS: |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 181 | return "CMD_CLEARCOLORATTACHMENT"; |
| 182 | case CMD_CLEARDEPTHSTENCILIMAGE: |
| 183 | return "CMD_CLEARDEPTHSTENCILIMAGE"; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 184 | case CMD_RESOLVEIMAGE: |
| 185 | return "CMD_RESOLVEIMAGE"; |
| 186 | case CMD_SETEVENT: |
| 187 | return "CMD_SETEVENT"; |
| 188 | case CMD_RESETEVENT: |
| 189 | return "CMD_RESETEVENT"; |
| 190 | case CMD_WAITEVENTS: |
| 191 | return "CMD_WAITEVENTS"; |
| 192 | case CMD_PIPELINEBARRIER: |
| 193 | return "CMD_PIPELINEBARRIER"; |
| 194 | case CMD_BEGINQUERY: |
| 195 | return "CMD_BEGINQUERY"; |
| 196 | case CMD_ENDQUERY: |
| 197 | return "CMD_ENDQUERY"; |
| 198 | case CMD_RESETQUERYPOOL: |
| 199 | return "CMD_RESETQUERYPOOL"; |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 200 | case CMD_COPYQUERYPOOLRESULTS: |
| 201 | return "CMD_COPYQUERYPOOLRESULTS"; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 202 | case CMD_WRITETIMESTAMP: |
| 203 | return "CMD_WRITETIMESTAMP"; |
| 204 | case CMD_INITATOMICCOUNTERS: |
| 205 | return "CMD_INITATOMICCOUNTERS"; |
| 206 | case CMD_LOADATOMICCOUNTERS: |
| 207 | return "CMD_LOADATOMICCOUNTERS"; |
| 208 | case CMD_SAVEATOMICCOUNTERS: |
| 209 | return "CMD_SAVEATOMICCOUNTERS"; |
| 210 | case CMD_BEGINRENDERPASS: |
| 211 | return "CMD_BEGINRENDERPASS"; |
| 212 | case CMD_ENDRENDERPASS: |
| 213 | return "CMD_ENDRENDERPASS"; |
| 214 | case CMD_DBGMARKERBEGIN: |
| 215 | return "CMD_DBGMARKERBEGIN"; |
| 216 | case CMD_DBGMARKEREND: |
| 217 | return "CMD_DBGMARKEREND"; |
| 218 | default: |
| 219 | return "UNKNOWN"; |
| 220 | } |
| 221 | } |
| 222 | // Block of code at start here for managing/tracking Pipeline state that this layer cares about |
| 223 | // Just track 2 shaders for now |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 224 | #define MAX_SLOTS 2048 |
| 225 | #define NUM_COMMAND_BUFFERS_TO_DISPLAY 10 |
| 226 | |
| 227 | static uint64_t g_drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0}; |
| 228 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 229 | // TODO : Should be tracking lastBound per commandBuffer and when draws occur, report based on that cmd buffer lastBound |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 230 | // Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates |
| 231 | // to that same cmd buffer by separate thread are not changing state from underneath us |
| 232 | // Track the last cmd buffer touched by this thread |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 233 | static VkCommandBuffer g_lastCommandBuffer[MAX_TID] = {NULL}; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 234 | // Track the last group of CBs touched for displaying to dot file |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 235 | static GLOBAL_CB_NODE* g_pLastTouchedCB[NUM_COMMAND_BUFFERS_TO_DISPLAY] = {NULL}; |
| 236 | static uint32_t g_lastTouchedCBIndex = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 237 | // Track the last global DrawState of interest touched by any thread |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 238 | static GLOBAL_CB_NODE* g_lastGlobalCB = NULL; |
| 239 | static PIPELINE_NODE* g_lastBoundPipeline = NULL; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 240 | #define MAX_BINDING 0xFFFFFFFF // Default vtxBinding value in CB Node to identify if no vtxBinding set |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 241 | // prototype |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | static GLOBAL_CB_NODE* getCBNode(layer_data*, const VkCommandBuffer); |
| 243 | // Update global ptrs to reflect that specified commandBuffer has been used |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 244 | static void updateCBTracking(GLOBAL_CB_NODE* pCB) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 245 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 246 | g_lastCommandBuffer[getTIDIndex()] = pCB->commandBuffer; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 247 | loader_platform_thread_lock_mutex(&globalLock); |
| 248 | g_lastGlobalCB = pCB; |
| 249 | // TODO : This is a dumb algorithm. Need smart LRU that drops off oldest |
| 250 | for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) { |
| 251 | if (g_pLastTouchedCB[i] == pCB) { |
| 252 | loader_platform_thread_unlock_mutex(&globalLock); |
| 253 | return; |
| 254 | } |
| 255 | } |
| 256 | g_pLastTouchedCB[g_lastTouchedCBIndex++] = pCB; |
| 257 | g_lastTouchedCBIndex = g_lastTouchedCBIndex % NUM_COMMAND_BUFFERS_TO_DISPLAY; |
| 258 | loader_platform_thread_unlock_mutex(&globalLock); |
| 259 | } |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 260 | static VkBool32 hasDrawCmd(GLOBAL_CB_NODE* pCB) |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 261 | { |
| 262 | for (uint32_t i=0; i<NUM_DRAW_TYPES; i++) { |
| 263 | if (pCB->drawCount[i]) |
| 264 | return VK_TRUE; |
| 265 | } |
| 266 | return VK_FALSE; |
| 267 | } |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 268 | // Check object status for selected flag state |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 269 | static VkBool32 validate_status(layer_data* my_data, GLOBAL_CB_NODE* pNode, CBStatusFlags enable_mask, CBStatusFlags status_mask, CBStatusFlags status_flag, VkFlags msg_flags, DRAW_STATE_ERROR error_code, const char* fail_msg) |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 270 | { |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 271 | // If non-zero enable mask is present, check it against status but if enable_mask |
| 272 | // is 0 then no enable required so we should always just check status |
| 273 | if ((!enable_mask) || (enable_mask & pNode->status)) { |
| 274 | if ((pNode->status & status_mask) != status_flag) { |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 275 | // TODO : How to pass dispatchable objects as srcObject? Here src obj should be cmd buffer |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 276 | return log_msg(my_data->report_data, msg_flags, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, error_code, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 277 | "CB object %#" PRIxLEAST64 ": %s", reinterpret_cast<uint64_t>(pNode->commandBuffer), fail_msg); |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 278 | } |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 279 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 280 | return VK_FALSE; |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 281 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 282 | // Retrieve pipeline node ptr for given pipeline object |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 283 | static PIPELINE_NODE* getPipeline(layer_data* my_data, const VkPipeline pipeline) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 284 | { |
| 285 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 286 | if (my_data->pipelineMap.find(pipeline) == my_data->pipelineMap.end()) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 287 | loader_platform_thread_unlock_mutex(&globalLock); |
| 288 | return NULL; |
| 289 | } |
| 290 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 291 | return my_data->pipelineMap[pipeline]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 292 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 293 | // Return VK_TRUE if for a given PSO, the given state enum is dynamic, else return VK_FALSE |
| 294 | static VkBool32 isDynamic(const PIPELINE_NODE* pPipeline, const VkDynamicState state) |
| 295 | { |
| 296 | if (pPipeline && pPipeline->graphicsPipelineCI.pDynamicState) { |
| 297 | for (uint32_t i=0; i<pPipeline->graphicsPipelineCI.pDynamicState->dynamicStateCount; i++) { |
| 298 | if (state == pPipeline->graphicsPipelineCI.pDynamicState->pDynamicStates[i]) |
| 299 | return VK_TRUE; |
| 300 | } |
| 301 | } |
| 302 | return VK_FALSE; |
| 303 | } |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 304 | // Validate state stored as flags at time of draw call |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 305 | static VkBool32 validate_draw_state_flags(layer_data* my_data, GLOBAL_CB_NODE* pCB, VkBool32 indexedDraw) { |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 306 | VkBool32 result; |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 307 | result = validate_status(my_data, pCB, CBSTATUS_NONE, CBSTATUS_VIEWPORT_SET, CBSTATUS_VIEWPORT_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_VIEWPORT_NOT_BOUND, "Dynamic viewport state not set for this command buffer"); |
Cody Northrop | b161279 | 2015-10-27 13:15:41 -0600 | [diff] [blame] | 308 | result |= validate_status(my_data, pCB, CBSTATUS_NONE, CBSTATUS_SCISSOR_SET, CBSTATUS_SCISSOR_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_SCISSOR_NOT_BOUND, "Dynamic scissor state not set for this command buffer"); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 309 | result |= validate_status(my_data, pCB, CBSTATUS_NONE, CBSTATUS_LINE_WIDTH_SET, CBSTATUS_LINE_WIDTH_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_LINE_WIDTH_NOT_BOUND, "Dynamic line width state not set for this command buffer"); |
| 310 | result |= validate_status(my_data, pCB, CBSTATUS_NONE, CBSTATUS_DEPTH_BIAS_SET, CBSTATUS_DEPTH_BIAS_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_DEPTH_BIAS_NOT_BOUND, "Dynamic depth bias state not set for this command buffer"); |
| 311 | result |= validate_status(my_data, pCB, CBSTATUS_COLOR_BLEND_WRITE_ENABLE, CBSTATUS_BLEND_SET, CBSTATUS_BLEND_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_BLEND_NOT_BOUND, "Dynamic blend object state not set for this command buffer"); |
| 312 | result |= validate_status(my_data, pCB, CBSTATUS_DEPTH_WRITE_ENABLE, CBSTATUS_DEPTH_BOUNDS_SET, CBSTATUS_DEPTH_BOUNDS_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_DEPTH_BOUNDS_NOT_BOUND, "Dynamic depth bounds state not set for this command buffer"); |
| 313 | result |= validate_status(my_data, pCB, CBSTATUS_STENCIL_TEST_ENABLE, CBSTATUS_STENCIL_READ_MASK_SET, CBSTATUS_STENCIL_READ_MASK_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_STENCIL_NOT_BOUND, "Dynamic stencil read mask state not set for this command buffer"); |
| 314 | result |= validate_status(my_data, pCB, CBSTATUS_STENCIL_TEST_ENABLE, CBSTATUS_STENCIL_WRITE_MASK_SET, CBSTATUS_STENCIL_WRITE_MASK_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_STENCIL_NOT_BOUND, "Dynamic stencil write mask state not set for this command buffer"); |
| 315 | result |= validate_status(my_data, pCB, CBSTATUS_STENCIL_TEST_ENABLE, CBSTATUS_STENCIL_REFERENCE_SET, CBSTATUS_STENCIL_REFERENCE_SET, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_STENCIL_NOT_BOUND, "Dynamic stencil reference state not set for this command buffer"); |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 316 | if (indexedDraw) |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 317 | result |= validate_status(my_data, pCB, CBSTATUS_NONE, CBSTATUS_INDEX_BUFFER_BOUND, CBSTATUS_INDEX_BUFFER_BOUND, VK_DBG_REPORT_ERROR_BIT, DRAWSTATE_INDEX_BUFFER_NOT_BOUND, "Index buffer object not bound to this command buffer when Indexed Draw attempted"); |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 318 | return result; |
| 319 | } |
| 320 | // Validate overall state at the time of a draw call |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 321 | static VkBool32 validate_draw_state(layer_data* my_data, GLOBAL_CB_NODE* pCB, VkBool32 indexedDraw) { |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 322 | // First check flag states |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 323 | VkBool32 result = validate_draw_state_flags(my_data, pCB, indexedDraw); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 324 | PIPELINE_NODE* pPipe = getPipeline(my_data, pCB->lastBoundPipeline); |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 325 | // Now complete other state checks |
Tobin Ehlis | e90e66d | 2015-09-09 13:31:01 -0600 | [diff] [blame] | 326 | // TODO : Currently only performing next check if *something* was bound (non-zero last bound) |
| 327 | // There is probably a better way to gate when this check happens, and to know if something *should* have been bound |
| 328 | // We should have that check separately and then gate this check based on that check |
| 329 | if (pPipe && (pCB->lastBoundPipelineLayout) && (pCB->lastBoundPipelineLayout != pPipe->graphicsPipelineCI.layout)) { |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 330 | result = VK_FALSE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 331 | result |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PIPELINE_LAYOUT, (uint64_t) pCB->lastBoundPipelineLayout, 0, DRAWSTATE_PIPELINE_LAYOUT_MISMATCH, "DS", |
| 332 | "Pipeline layout from last vkCmdBindDescriptorSets() (%#" PRIxLEAST64 ") does not match PSO Pipeline layout (%#" PRIxLEAST64 ") ", (uint64_t) pCB->lastBoundPipelineLayout, (uint64_t) pPipe->graphicsPipelineCI.layout); |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 333 | } |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 334 | // Verify Vtx binding |
| 335 | if (MAX_BINDING != pCB->lastVtxBinding) { |
| 336 | if (pCB->lastVtxBinding >= pPipe->vtxBindingCount) { |
| 337 | if (0 == pPipe->vtxBindingCount) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 338 | result |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 339 | "Vtx Buffer Index %u was bound, but no vtx buffers are attached to PSO.", pCB->lastVtxBinding); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 340 | } |
| 341 | else { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 342 | result |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 343 | "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", pCB->lastVtxBinding, (pPipe->vtxBindingCount - 1)); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 347 | // If Viewport or scissors are dynamic, verify that dynamic count matches PSO count |
| 348 | VkBool32 dynViewport = isDynamic(pPipe, VK_DYNAMIC_STATE_VIEWPORT); |
| 349 | VkBool32 dynScissor = isDynamic(pPipe, VK_DYNAMIC_STATE_SCISSOR); |
| 350 | if (dynViewport) { |
| 351 | if (pCB->viewports.size() != pPipe->graphicsPipelineCI.pViewportState->viewportCount) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 352 | result |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, "DS", |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 353 | "Dynamic viewportCount from vkCmdSetViewport() is %u, but PSO viewportCount is %u. These counts must match.", pCB->viewports.size(), pPipe->graphicsPipelineCI.pViewportState->viewportCount); |
| 354 | } |
| 355 | } |
| 356 | if (dynScissor) { |
| 357 | if (pCB->scissors.size() != pPipe->graphicsPipelineCI.pViewportState->scissorCount) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 358 | result |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, "DS", |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 359 | "Dynamic scissorCount from vkCmdSetScissor() is %u, but PSO scissorCount is %u. These counts must match.", pCB->scissors.size(), pPipe->graphicsPipelineCI.pViewportState->scissorCount); |
| 360 | } |
| 361 | } |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 362 | return result; |
| 363 | } |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 364 | // Verify that create state for a pipeline is valid |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 365 | static VkBool32 verifyPipelineCreateState(layer_data* my_data, const VkDevice device, const PIPELINE_NODE* pPipeline) |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 366 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 367 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 368 | // VS is required |
| 369 | if (!(pPipeline->active_shaders & VK_SHADER_STAGE_VERTEX_BIT)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 370 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 371 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 372 | } |
| 373 | // Either both or neither TC/TE shaders should be defined |
Courtney Goeltzenleuchter | 9683589 | 2015-10-15 17:35:38 -0600 | [diff] [blame] | 374 | if (((pPipeline->active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) == 0) != |
| 375 | ((pPipeline->active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) == 0) ) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 376 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 377 | "Invalid Pipeline CreateInfo State: TE and TC shaders must be included or excluded as a pair"); |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 378 | } |
| 379 | // Compute shaders should be specified independent of Gfx shaders |
| 380 | if ((pPipeline->active_shaders & VK_SHADER_STAGE_COMPUTE_BIT) && |
Courtney Goeltzenleuchter | 9683589 | 2015-10-15 17:35:38 -0600 | [diff] [blame] | 381 | (pPipeline->active_shaders & (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT | |
| 382 | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT | VK_SHADER_STAGE_GEOMETRY_BIT | |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 383 | VK_SHADER_STAGE_FRAGMENT_BIT))) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 384 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 385 | "Invalid Pipeline CreateInfo State: Do not specify Compute Shader for Gfx Pipeline"); |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 386 | } |
| 387 | // VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology is only valid for tessellation pipelines. |
| 388 | // Mismatching primitive topology and tessellation fails graphics pipeline creation. |
Courtney Goeltzenleuchter | 9683589 | 2015-10-15 17:35:38 -0600 | [diff] [blame] | 389 | if (pPipeline->active_shaders & (VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 390 | (pPipeline->iaStateCI.topology != VK_PRIMITIVE_TOPOLOGY_PATCH)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 391 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 392 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH must be set as IA topology for tessellation pipelines"); |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 393 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 394 | if (pPipeline->iaStateCI.topology == VK_PRIMITIVE_TOPOLOGY_PATCH) { |
Courtney Goeltzenleuchter | 9683589 | 2015-10-15 17:35:38 -0600 | [diff] [blame] | 395 | if (~pPipeline->active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 396 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 397 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology is only valid for tessellation pipelines"); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 398 | } |
| 399 | if (!pPipeline->tessStateCI.patchControlPoints || (pPipeline->tessStateCI.patchControlPoints > 32)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 400 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, "DS", |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 401 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology used with patchControlPoints value %u." |
| 402 | " patchControlPoints should be >0 and <=32.", pPipeline->tessStateCI.patchControlPoints); |
| 403 | } |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 404 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 405 | // Viewport state must be included and viewport and scissor counts should always match |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 406 | // NOTE : Even if these are flagged as dynamic, counts need to be set correctly for shader compiler |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 407 | if (!pPipeline->graphicsPipelineCI.pViewportState) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 408 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, "DS", |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 409 | "Gfx Pipeline pViewportState is null. Even if viewport and scissors are dynamic PSO must include viewportCount and scissorCount in pViewportState."); |
| 410 | } else if (pPipeline->graphicsPipelineCI.pViewportState->scissorCount != pPipeline->graphicsPipelineCI.pViewportState->viewportCount) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 411 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, "DS", |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 412 | "Gfx Pipeline viewport count (%u) must match scissor count (%u).", pPipeline->vpStateCI.viewportCount, pPipeline->vpStateCI.scissorCount); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 413 | } else { |
| 414 | // If viewport or scissor are not dynamic, then verify that data is appropriate for count |
| 415 | VkBool32 dynViewport = isDynamic(pPipeline, VK_DYNAMIC_STATE_VIEWPORT); |
| 416 | VkBool32 dynScissor = isDynamic(pPipeline, VK_DYNAMIC_STATE_SCISSOR); |
| 417 | if (!dynViewport) { |
| 418 | if (pPipeline->graphicsPipelineCI.pViewportState->viewportCount && !pPipeline->graphicsPipelineCI.pViewportState->pViewports) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 419 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, "DS", |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 420 | "Gfx Pipeline viewportCount is %u, but pViewports is NULL. For non-zero viewportCount, you must either include pViewports data, or include viewport in pDynamicState and set it with vkCmdSetViewport().", pPipeline->graphicsPipelineCI.pViewportState->viewportCount); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 421 | } |
| 422 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 423 | if (!dynScissor) { |
| 424 | if (pPipeline->graphicsPipelineCI.pViewportState->scissorCount && !pPipeline->graphicsPipelineCI.pViewportState->pScissors) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 425 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, "DS", |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 426 | "Gfx Pipeline scissorCount is %u, but pScissors is NULL. For non-zero scissorCount, you must either include pScissors data, or include scissor in pDynamicState and set it with vkCmdSetScissor().", pPipeline->graphicsPipelineCI.pViewportState->scissorCount); |
| 427 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 428 | } |
| 429 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 430 | return skipCall; |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 431 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 432 | // Init the pipeline mapping info based on pipeline create info LL tree |
| 433 | // Threading note : Calls to this function should wrapped in mutex |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 434 | static PIPELINE_NODE* initPipeline(layer_data* dev_data, const VkGraphicsPipelineCreateInfo* pCreateInfo, PIPELINE_NODE* pBasePipeline) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 435 | { |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 436 | PIPELINE_NODE* pPipeline = new PIPELINE_NODE; |
| 437 | if (pBasePipeline) { |
| 438 | memcpy((void*)pPipeline, (void*)pBasePipeline, sizeof(PIPELINE_NODE)); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 439 | } else { |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 440 | memset((void*)pPipeline, 0, sizeof(PIPELINE_NODE)); |
| 441 | } |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 442 | // First init create info |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 443 | memcpy(&pPipeline->graphicsPipelineCI, pCreateInfo, sizeof(VkGraphicsPipelineCreateInfo)); |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 444 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 445 | size_t bufferSize = 0; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 446 | const VkPipelineVertexInputStateCreateInfo* pVICI = NULL; |
Tobin Ehlis | 5a65cca | 2015-07-13 13:14:24 -0600 | [diff] [blame] | 447 | const VkPipelineColorBlendStateCreateInfo* pCBCI = NULL; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 448 | |
| 449 | for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { |
| 450 | const VkPipelineShaderStageCreateInfo *pPSSCI = &pCreateInfo->pStages[i]; |
| 451 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 452 | if (dev_data->shaderStageMap.find(pPSSCI->shader) == dev_data->shaderStageMap.end()) |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 453 | continue; |
| 454 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 455 | switch (dev_data->shaderStageMap[pPSSCI->shader]) { |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 456 | case VK_SHADER_STAGE_VERTEX_BIT: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 457 | memcpy(&pPipeline->vsCI, pPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
| 458 | pPipeline->active_shaders |= VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 459 | break; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 460 | case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 461 | memcpy(&pPipeline->tcsCI, pPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Courtney Goeltzenleuchter | 9683589 | 2015-10-15 17:35:38 -0600 | [diff] [blame] | 462 | pPipeline->active_shaders |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 463 | break; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 464 | case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 465 | memcpy(&pPipeline->tesCI, pPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Courtney Goeltzenleuchter | 9683589 | 2015-10-15 17:35:38 -0600 | [diff] [blame] | 466 | pPipeline->active_shaders |= VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 467 | break; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 468 | case VK_SHADER_STAGE_GEOMETRY_BIT: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 469 | memcpy(&pPipeline->gsCI, pPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
| 470 | pPipeline->active_shaders |= VK_SHADER_STAGE_GEOMETRY_BIT; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 471 | break; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 472 | case VK_SHADER_STAGE_FRAGMENT_BIT: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 473 | memcpy(&pPipeline->fsCI, pPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
| 474 | pPipeline->active_shaders |= VK_SHADER_STAGE_FRAGMENT_BIT; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 475 | break; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 476 | case VK_SHADER_STAGE_COMPUTE_BIT: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 477 | // TODO : Flag error, CS is specified through VkComputePipelineCreateInfo |
| 478 | pPipeline->active_shaders |= VK_SHADER_STAGE_COMPUTE_BIT; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 479 | break; |
| 480 | default: |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 481 | // TODO : Flag error |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 482 | break; |
| 483 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 484 | } |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 485 | // Copy over GraphicsPipelineCreateInfo structure embedded pointers |
| 486 | if (pCreateInfo->stageCount != 0) { |
| 487 | pPipeline->graphicsPipelineCI.pStages = new VkPipelineShaderStageCreateInfo[pCreateInfo->stageCount]; |
| 488 | bufferSize = pCreateInfo->stageCount * sizeof(VkPipelineShaderStageCreateInfo); |
| 489 | memcpy((void*)pPipeline->graphicsPipelineCI.pStages, pCreateInfo->pStages, bufferSize); |
| 490 | } |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 491 | if (pCreateInfo->pVertexInputState != NULL) { |
| 492 | memcpy((void*)&pPipeline->vertexInputCI, pCreateInfo->pVertexInputState , sizeof(VkPipelineVertexInputStateCreateInfo)); |
| 493 | // Copy embedded ptrs |
| 494 | pVICI = pCreateInfo->pVertexInputState; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 495 | pPipeline->vtxBindingCount = pVICI->vertexBindingDescriptionCount; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 496 | if (pPipeline->vtxBindingCount) { |
| 497 | pPipeline->pVertexBindingDescriptions = new VkVertexInputBindingDescription[pPipeline->vtxBindingCount]; |
| 498 | bufferSize = pPipeline->vtxBindingCount * sizeof(VkVertexInputBindingDescription); |
| 499 | memcpy((void*)pPipeline->pVertexBindingDescriptions, pVICI->pVertexBindingDescriptions, bufferSize); |
| 500 | } |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 501 | pPipeline->vtxAttributeCount = pVICI->vertexAttributeDescriptionCount; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 502 | if (pPipeline->vtxAttributeCount) { |
| 503 | pPipeline->pVertexAttributeDescriptions = new VkVertexInputAttributeDescription[pPipeline->vtxAttributeCount]; |
| 504 | bufferSize = pPipeline->vtxAttributeCount * sizeof(VkVertexInputAttributeDescription); |
| 505 | memcpy((void*)pPipeline->pVertexAttributeDescriptions, pVICI->pVertexAttributeDescriptions, bufferSize); |
| 506 | } |
| 507 | pPipeline->graphicsPipelineCI.pVertexInputState = &pPipeline->vertexInputCI; |
| 508 | } |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 509 | if (pCreateInfo->pInputAssemblyState != NULL) { |
| 510 | memcpy((void*)&pPipeline->iaStateCI, pCreateInfo->pInputAssemblyState, sizeof(VkPipelineInputAssemblyStateCreateInfo)); |
| 511 | pPipeline->graphicsPipelineCI.pInputAssemblyState = &pPipeline->iaStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 512 | } |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 513 | if (pCreateInfo->pTessellationState != NULL) { |
| 514 | memcpy((void*)&pPipeline->tessStateCI, pCreateInfo->pTessellationState, sizeof(VkPipelineTessellationStateCreateInfo)); |
| 515 | pPipeline->graphicsPipelineCI.pTessellationState = &pPipeline->tessStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 516 | } |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 517 | if (pCreateInfo->pViewportState != NULL) { |
| 518 | memcpy((void*)&pPipeline->vpStateCI, pCreateInfo->pViewportState, sizeof(VkPipelineViewportStateCreateInfo)); |
| 519 | pPipeline->graphicsPipelineCI.pViewportState = &pPipeline->vpStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 520 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 521 | if (pCreateInfo->pRasterizationState != NULL) { |
| 522 | memcpy((void*)&pPipeline->rsStateCI, pCreateInfo->pRasterizationState, sizeof(VkPipelineRasterizationStateCreateInfo)); |
| 523 | pPipeline->graphicsPipelineCI.pRasterizationState = &pPipeline->rsStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 524 | } |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 525 | if (pCreateInfo->pMultisampleState != NULL) { |
| 526 | memcpy((void*)&pPipeline->msStateCI, pCreateInfo->pMultisampleState, sizeof(VkPipelineMultisampleStateCreateInfo)); |
| 527 | pPipeline->graphicsPipelineCI.pMultisampleState = &pPipeline->msStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 528 | } |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 529 | if (pCreateInfo->pDepthStencilState != NULL) { |
| 530 | memcpy((void*)&pPipeline->dsStateCI, pCreateInfo->pDepthStencilState, sizeof(VkPipelineDepthStencilStateCreateInfo)); |
| 531 | pPipeline->graphicsPipelineCI.pDepthStencilState = &pPipeline->dsStateCI; |
| 532 | } |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 533 | if (pCreateInfo->pColorBlendState != NULL) { |
| 534 | memcpy((void*)&pPipeline->cbStateCI, pCreateInfo->pColorBlendState, sizeof(VkPipelineColorBlendStateCreateInfo)); |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 535 | // Copy embedded ptrs |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 536 | pCBCI = pCreateInfo->pColorBlendState; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 537 | pPipeline->attachmentCount = pCBCI->attachmentCount; |
| 538 | if (pPipeline->attachmentCount) { |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 539 | pPipeline->pAttachments = new VkPipelineColorBlendAttachmentState[pPipeline->attachmentCount]; |
| 540 | bufferSize = pPipeline->attachmentCount * sizeof(VkPipelineColorBlendAttachmentState); |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 541 | memcpy((void*)pPipeline->pAttachments, pCBCI->pAttachments, bufferSize); |
| 542 | } |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 543 | pPipeline->graphicsPipelineCI.pColorBlendState = &pPipeline->cbStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 544 | } |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 545 | if (pCreateInfo->pDynamicState != NULL) { |
| 546 | memcpy((void*)&pPipeline->dynStateCI, pCreateInfo->pDynamicState, sizeof(VkPipelineDynamicStateCreateInfo)); |
| 547 | if (pPipeline->dynStateCI.dynamicStateCount) { |
| 548 | pPipeline->dynStateCI.pDynamicStates = new VkDynamicState[pPipeline->dynStateCI.dynamicStateCount]; |
| 549 | bufferSize = pPipeline->dynStateCI.dynamicStateCount * sizeof(VkDynamicState); |
| 550 | memcpy((void*)pPipeline->dynStateCI.pDynamicStates, pCreateInfo->pDynamicState->pDynamicStates, bufferSize); |
| 551 | } |
| 552 | pPipeline->graphicsPipelineCI.pDynamicState = &pPipeline->dynStateCI; |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 553 | } |
| 554 | |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 555 | return pPipeline; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 556 | } |
| 557 | // Free the Pipeline nodes |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 558 | static void deletePipelines(layer_data* my_data) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 559 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 560 | if (my_data->pipelineMap.size() <= 0) |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 561 | return; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 562 | for (auto ii=my_data->pipelineMap.begin(); ii!=my_data->pipelineMap.end(); ++ii) { |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 563 | if ((*ii).second->graphicsPipelineCI.stageCount != 0) { |
| 564 | delete[] (*ii).second->graphicsPipelineCI.pStages; |
| 565 | } |
Tobin Ehlis | f313c8b | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 566 | if ((*ii).second->pVertexBindingDescriptions) { |
| 567 | delete[] (*ii).second->pVertexBindingDescriptions; |
| 568 | } |
| 569 | if ((*ii).second->pVertexAttributeDescriptions) { |
| 570 | delete[] (*ii).second->pVertexAttributeDescriptions; |
| 571 | } |
| 572 | if ((*ii).second->pAttachments) { |
| 573 | delete[] (*ii).second->pAttachments; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 574 | } |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 575 | if ((*ii).second->dynStateCI.dynamicStateCount != 0) { |
| 576 | delete[] (*ii).second->dynStateCI.pDynamicStates; |
| 577 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 578 | delete (*ii).second; |
| 579 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 580 | my_data->pipelineMap.clear(); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 581 | } |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 582 | // For given pipeline, return number of MSAA samples, or one if MSAA disabled |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 583 | static uint32_t getNumSamples(layer_data* my_data, const VkPipeline pipeline) |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 584 | { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 585 | PIPELINE_NODE* pPipe = my_data->pipelineMap[pipeline]; |
Tobin Ehlis | 577188e | 2015-07-13 14:51:15 -0600 | [diff] [blame] | 586 | if (VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO == pPipe->msStateCI.sType) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 587 | return pPipe->msStateCI.rasterizationSamples; |
Tobin Ehlis | 577188e | 2015-07-13 14:51:15 -0600 | [diff] [blame] | 588 | } |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 589 | return 1; |
| 590 | } |
| 591 | // Validate state related to the PSO |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 592 | static VkBool32 validatePipelineState(layer_data* my_data, const GLOBAL_CB_NODE* pCB, const VkPipelineBindPoint pipelineBindPoint, const VkPipeline pipeline) |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 593 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 594 | if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) { |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 595 | // Verify that any MSAA request in PSO matches sample# in bound FB |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 596 | uint32_t psoNumSamples = getNumSamples(my_data, pipeline); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 597 | if (pCB->activeRenderPass) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 598 | const VkRenderPassCreateInfo* pRPCI = my_data->renderPassMap[pCB->activeRenderPass]; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 599 | const VkSubpassDescription* pSD = &pRPCI->pSubpasses[pCB->activeSubpass]; |
| 600 | int subpassNumSamples = 0; |
| 601 | uint32_t i; |
| 602 | |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 603 | for (i = 0; i < pSD->colorAttachmentCount; i++) { |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 604 | uint32_t samples; |
| 605 | |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 606 | if (pSD->pColorAttachments[i].attachment == VK_ATTACHMENT_UNUSED) |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 607 | continue; |
| 608 | |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 609 | samples = pRPCI->pAttachments[pSD->pColorAttachments[i].attachment].samples; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 610 | if (subpassNumSamples == 0) { |
| 611 | subpassNumSamples = samples; |
| 612 | } else if (subpassNumSamples != samples) { |
| 613 | subpassNumSamples = -1; |
| 614 | break; |
| 615 | } |
| 616 | } |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 617 | if (pSD->pDepthStencilAttachment && pSD->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
| 618 | const uint32_t samples = pRPCI->pAttachments[pSD->pDepthStencilAttachment->attachment].samples; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 619 | if (subpassNumSamples == 0) |
| 620 | subpassNumSamples = samples; |
| 621 | else if (subpassNumSamples != samples) |
| 622 | subpassNumSamples = -1; |
| 623 | } |
| 624 | |
| 625 | if (psoNumSamples != subpassNumSamples) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 626 | return log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PIPELINE, (uint64_t) pipeline, 0, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 627 | "Num samples mismatch! Binding PSO (%#" PRIxLEAST64 ") with %u samples while current RenderPass (%#" PRIxLEAST64 ") w/ %u samples!", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 628 | (uint64_t) pipeline, psoNumSamples, (uint64_t) pCB->activeRenderPass, subpassNumSamples); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 629 | } |
| 630 | } else { |
| 631 | // TODO : I believe it's an error if we reach this point and don't have an activeRenderPass |
| 632 | // Verify and flag error as appropriate |
| 633 | } |
| 634 | // TODO : Add more checks here |
| 635 | } else { |
| 636 | // TODO : Validate non-gfx pipeline updates |
| 637 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 638 | return VK_FALSE; |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 639 | } |
| 640 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 641 | // Block of code at start here specifically for managing/tracking DSs |
| 642 | |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 643 | // Return Pool node ptr for specified pool or else NULL |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 644 | static POOL_NODE* getPoolNode(layer_data* my_data, const VkDescriptorPool pool) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 645 | { |
| 646 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 647 | if (my_data->poolMap.find(pool) == my_data->poolMap.end()) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 648 | loader_platform_thread_unlock_mutex(&globalLock); |
| 649 | return NULL; |
| 650 | } |
| 651 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 652 | return my_data->poolMap[pool]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 653 | } |
| 654 | // Return Set node ptr for specified set or else NULL |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 655 | static SET_NODE* getSetNode(layer_data* my_data, const VkDescriptorSet set) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 656 | { |
| 657 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 658 | if (my_data->setMap.find(set) == my_data->setMap.end()) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 659 | loader_platform_thread_unlock_mutex(&globalLock); |
| 660 | return NULL; |
| 661 | } |
| 662 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 663 | return my_data->setMap[set]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 664 | } |
| 665 | |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 666 | static LAYOUT_NODE* getLayoutNode(layer_data* my_data, const VkDescriptorSetLayout layout) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 667 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 668 | if (my_data->layoutMap.find(layout) == my_data->layoutMap.end()) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 669 | loader_platform_thread_unlock_mutex(&globalLock); |
| 670 | return NULL; |
| 671 | } |
| 672 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 673 | return my_data->layoutMap[layout]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 674 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 675 | // Return VK_FALSE if update struct is of valid type, otherwise flag error and return code from callback |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 676 | static VkBool32 validUpdateStruct(layer_data* my_data, const VkDevice device, const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 677 | { |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 678 | switch (pUpdateStruct->sType) |
| 679 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 680 | case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: |
| 681 | case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 682 | return VK_FALSE; |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 683 | default: |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 684 | return log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 685 | "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType); |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 686 | } |
| 687 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 688 | // Set count for given update struct in the last parameter |
| 689 | // Return value of skipCall, which is only VK_TRUE is error occurs and callback signals execution to cease |
Tobin Ehlis | baca3ab | 2015-10-27 12:54:50 -0600 | [diff] [blame] | 690 | static uint32_t getUpdateCount(layer_data* my_data, const VkDevice device, const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 691 | { |
| 692 | switch (pUpdateStruct->sType) |
| 693 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 694 | case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 695 | return ((VkWriteDescriptorSet*)pUpdateStruct)->descriptorCount; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 696 | case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 697 | // TODO : Need to understand this case better and make sure code is correct |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 698 | return ((VkCopyDescriptorSet*)pUpdateStruct)->descriptorCount; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | // For given Layout Node and binding, return index where that binding begins |
| 702 | static uint32_t getBindingStartIndex(const LAYOUT_NODE* pLayout, const uint32_t binding) |
| 703 | { |
| 704 | uint32_t offsetIndex = 0; |
| 705 | for (uint32_t i = 0; i<binding; i++) { |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 706 | offsetIndex += pLayout->createInfo.pBindings[i].arraySize; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 707 | } |
| 708 | return offsetIndex; |
| 709 | } |
| 710 | // For given layout node and binding, return last index that is updated |
| 711 | static uint32_t getBindingEndIndex(const LAYOUT_NODE* pLayout, const uint32_t binding) |
| 712 | { |
| 713 | uint32_t offsetIndex = 0; |
| 714 | for (uint32_t i = 0; i<=binding; i++) { |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 715 | offsetIndex += pLayout->createInfo.pBindings[i].arraySize; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 716 | } |
| 717 | return offsetIndex-1; |
| 718 | } |
Tobin Ehlis | baca3ab | 2015-10-27 12:54:50 -0600 | [diff] [blame] | 719 | // For given layout and update, return the first overall index of the layout that is updated |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 720 | static uint32_t getUpdateStartIndex(layer_data* my_data, const VkDevice device, const LAYOUT_NODE* pLayout, const uint32_t binding, const uint32_t arrayIndex, const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 721 | { |
Tobin Ehlis | baca3ab | 2015-10-27 12:54:50 -0600 | [diff] [blame] | 722 | return getBindingStartIndex(pLayout, binding)+arrayIndex; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 723 | } |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 724 | // For given layout and update, return the last overall index of the layout that is updated |
| 725 | static uint32_t getUpdateEndIndex(layer_data* my_data, const VkDevice device, const LAYOUT_NODE* pLayout, const uint32_t binding, const uint32_t arrayIndex, const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 726 | { |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 727 | uint32_t count = getUpdateCount(my_data, device, pUpdateStruct); |
Tobin Ehlis | baca3ab | 2015-10-27 12:54:50 -0600 | [diff] [blame] | 728 | return getBindingStartIndex(pLayout, binding)+arrayIndex+count-1; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 729 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 730 | // Verify that the descriptor type in the update struct matches what's expected by the layout |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 731 | static VkBool32 validateUpdateConsistency(layer_data* my_data, const VkDevice device, const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct, uint32_t startIndex, uint32_t endIndex) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 732 | { |
| 733 | // First get actual type of update |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 734 | VkBool32 skipCall = VK_FALSE; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 735 | VkDescriptorType actualType; |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 736 | uint32_t i = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 737 | switch (pUpdateStruct->sType) |
| 738 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 739 | case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: |
| 740 | actualType = ((VkWriteDescriptorSet*)pUpdateStruct)->descriptorType; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 741 | break; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 742 | case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: |
| 743 | /* no need to validate */ |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 744 | return VK_FALSE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 745 | break; |
| 746 | default: |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 747 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 748 | "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 749 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 750 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 751 | // Set first stageFlags as reference and verify that all other updates match it |
| 752 | VkShaderStageFlags refStageFlags = pLayout->stageFlags[startIndex]; |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 753 | for (i = startIndex; i <= endIndex; i++) { |
Tobin Ehlis | 644ff04 | 2015-10-20 10:11:55 -0600 | [diff] [blame] | 754 | if (pLayout->descriptorTypes[i] != actualType) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 755 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, "DS", |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 756 | "Write descriptor update has descriptor type %s that does not match overlapping binding descriptor type of %s!", |
| 757 | string_VkDescriptorType(actualType), string_VkDescriptorType(pLayout->descriptorTypes[i])); |
| 758 | } |
| 759 | if (pLayout->stageFlags[i] != refStageFlags) { |
| 760 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_DESCRIPTOR_STAGEFLAGS_MISMATCH, "DS", |
| 761 | "Write descriptor update has stageFlags %x that do not match overlapping binding descriptor stageFlags of %x!", |
| 762 | refStageFlags, pLayout->stageFlags[i]); |
Tobin Ehlis | 483cc35 | 2015-09-30 08:30:20 -0600 | [diff] [blame] | 763 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 764 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 765 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 766 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 767 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 768 | // Determine the update type, allocate a new struct of that type, shadow the given pUpdate |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 769 | // struct into the pNewNode param. Return VK_TRUE if error condition encountered and callback signals early exit. |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 770 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 771 | static VkBool32 shadowUpdateNode(layer_data* my_data, const VkDevice device, GENERIC_HEADER* pUpdate, GENERIC_HEADER** pNewNode) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 772 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 773 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 774 | VkWriteDescriptorSet* pWDS = NULL; |
| 775 | VkCopyDescriptorSet* pCDS = NULL; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 776 | size_t array_size = 0; |
| 777 | size_t base_array_size = 0; |
| 778 | size_t total_array_size = 0; |
| 779 | size_t baseBuffAddr = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 780 | switch (pUpdate->sType) |
| 781 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 782 | case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: |
| 783 | pWDS = new VkWriteDescriptorSet; |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 784 | *pNewNode = (GENERIC_HEADER*)pWDS; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 785 | memcpy(pWDS, pUpdate, sizeof(VkWriteDescriptorSet)); |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 786 | |
| 787 | switch (pWDS->descriptorType) { |
| 788 | case VK_DESCRIPTOR_TYPE_SAMPLER: |
| 789 | case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| 790 | case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: |
| 791 | case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: |
| 792 | { |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 793 | VkDescriptorImageInfo *info = new VkDescriptorImageInfo[pWDS->descriptorCount]; |
| 794 | memcpy(info, pWDS->pImageInfo, pWDS->descriptorCount * sizeof(VkDescriptorImageInfo)); |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 795 | pWDS->pImageInfo = info; |
| 796 | } |
| 797 | break; |
| 798 | case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: |
| 799 | case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: |
| 800 | { |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 801 | VkBufferView *info = new VkBufferView[pWDS->descriptorCount]; |
| 802 | memcpy(info, pWDS->pTexelBufferView, pWDS->descriptorCount * sizeof(VkBufferView)); |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 803 | pWDS->pTexelBufferView = info; |
| 804 | } |
| 805 | break; |
| 806 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: |
| 807 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: |
| 808 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 809 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 810 | { |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 811 | VkDescriptorBufferInfo *info = new VkDescriptorBufferInfo[pWDS->descriptorCount]; |
| 812 | memcpy(info, pWDS->pBufferInfo, pWDS->descriptorCount * sizeof(VkDescriptorBufferInfo)); |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 813 | pWDS->pBufferInfo = info; |
| 814 | } |
| 815 | break; |
| 816 | default: |
| 817 | return VK_ERROR_VALIDATION_FAILED; |
| 818 | break; |
| 819 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 820 | break; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 821 | case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: |
| 822 | pCDS = new VkCopyDescriptorSet; |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 823 | *pNewNode = (GENERIC_HEADER*)pCDS; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 824 | memcpy(pCDS, pUpdate, sizeof(VkCopyDescriptorSet)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 825 | break; |
| 826 | default: |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 827 | if (log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 828 | "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdate->sType), pUpdate->sType)) |
| 829 | return VK_TRUE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 830 | } |
| 831 | // Make sure that pNext for the end of shadow copy is NULL |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 832 | (*pNewNode)->pNext = NULL; |
| 833 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 834 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 835 | // Verify that given sampler is valid |
| 836 | static VkBool32 validateSampler(const layer_data* my_data, const VkSampler* pSampler, const VkBool32 immutable) |
| 837 | { |
| 838 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 839 | auto sampIt = my_data->sampleMap.find(*pSampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 840 | if (sampIt == my_data->sampleMap.end()) { |
| 841 | if (!immutable) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 842 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SAMPLER, (uint64_t) *pSampler, 0, DRAWSTATE_SAMPLER_DESCRIPTOR_ERROR, "DS", |
| 843 | "vkUpdateDescriptorSets: Attempt to update descriptor with invalid sampler %#" PRIxLEAST64, (uint64_t) *pSampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 844 | } else { // immutable |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 845 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SAMPLER, (uint64_t) *pSampler, 0, DRAWSTATE_SAMPLER_DESCRIPTOR_ERROR, "DS", |
| 846 | "vkUpdateDescriptorSets: Attempt to update descriptor whose binding has an invalid immutable sampler %#" PRIxLEAST64, (uint64_t) *pSampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 847 | } |
| 848 | } else { |
| 849 | // TODO : Any further checks we want to do on the sampler? |
| 850 | } |
| 851 | return skipCall; |
| 852 | } |
| 853 | // Verify that given imageView is valid |
| 854 | static VkBool32 validateImageView(const layer_data* my_data, const VkImageView* pImageView, const VkImageLayout imageLayout) |
| 855 | { |
| 856 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 857 | auto ivIt = my_data->imageViewMap.find(*pImageView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 858 | if (ivIt == my_data->imageViewMap.end()) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 859 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t) *pImageView, 0, DRAWSTATE_IMAGEVIEW_DESCRIPTOR_ERROR, "DS", |
| 860 | "vkUpdateDescriptorSets: Attempt to update descriptor with invalid imageView %#" PRIxLEAST64, (uint64_t) *pImageView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 861 | } else { |
| 862 | // Validate that imageLayout is compatible with aspectMask and image format |
| 863 | VkImageAspectFlags aspectMask = ivIt->second->subresourceRange.aspectMask; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 864 | VkImage image = ivIt->second->image; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 865 | // TODO : Check here in case we have a bad image handle |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 866 | auto imgIt = my_data->imageMap.find(image); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 867 | if (imgIt == my_data->imageMap.end()) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 868 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE, (uint64_t) image, 0, DRAWSTATE_IMAGEVIEW_DESCRIPTOR_ERROR, "DS", |
| 869 | "vkUpdateDescriptorSets: Attempt to update descriptor with invalid image handle %#" PRIxLEAST64 " in imageView %#" PRIxLEAST64, (uint64_t) image, (uint64_t) *pImageView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 870 | } else { |
| 871 | VkFormat format = (*imgIt).second->format; |
| 872 | bool ds = vk_format_is_depth_or_stencil(format); |
| 873 | switch (imageLayout) { |
| 874 | case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: |
| 875 | // Only Color bit must be set |
| 876 | if ((aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != VK_IMAGE_ASPECT_COLOR_BIT) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 877 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t) *pImageView, 0, |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 878 | DRAWSTATE_INVALID_IMAGE_ASPECT, "DS", "vkUpdateDescriptorSets: Updating descriptor with layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL and imageView %#" PRIxLEAST64 "" |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 879 | " that does not have VK_IMAGE_ASPECT_COLOR_BIT set.", (uint64_t) *pImageView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 880 | } |
| 881 | // format must NOT be DS |
| 882 | if (ds) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 883 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t) *pImageView, 0, |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 884 | DRAWSTATE_IMAGEVIEW_DESCRIPTOR_ERROR, "DS", "vkUpdateDescriptorSets: Updating descriptor with layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL and imageView %#" PRIxLEAST64 "" |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 885 | " but the image format is %s which is not a color format.", (uint64_t) *pImageView, string_VkFormat(format)); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 886 | } |
| 887 | break; |
| 888 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: |
| 889 | case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: |
| 890 | // Depth or stencil bit must be set, but both must NOT be set |
| 891 | if (aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) { |
| 892 | if (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) { |
| 893 | // both must NOT be set |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 894 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t) *pImageView, 0, |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 895 | DRAWSTATE_INVALID_IMAGE_ASPECT, "DS", "vkUpdateDescriptorSets: Updating descriptor with imageView %#" PRIxLEAST64 "" |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 896 | " that has both STENCIL and DEPTH aspects set", (uint64_t) *pImageView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 897 | } |
| 898 | } else if (!(aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 899 | // Neither were set |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 900 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t) *pImageView, 0, |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 901 | DRAWSTATE_INVALID_IMAGE_ASPECT, "DS", "vkUpdateDescriptorSets: Updating descriptor with layout %s and imageView %#" PRIxLEAST64 "" |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 902 | " that does not have STENCIL or DEPTH aspect set.", string_VkImageLayout(imageLayout), (uint64_t) *pImageView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 903 | } |
| 904 | // format must be DS |
| 905 | if (!ds) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 906 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t) *pImageView, 0, |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 907 | DRAWSTATE_IMAGEVIEW_DESCRIPTOR_ERROR, "DS", "vkUpdateDescriptorSets: Updating descriptor with layout %s and imageView %#" PRIxLEAST64 "" |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 908 | " but the image format is %s which is not a depth/stencil format.", string_VkImageLayout(imageLayout), (uint64_t) *pImageView, string_VkFormat(format)); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 909 | } |
| 910 | break; |
| 911 | default: |
| 912 | // anything to check for other layouts? |
| 913 | break; |
| 914 | } |
| 915 | } |
| 916 | } |
| 917 | return skipCall; |
| 918 | } |
| 919 | // Verify that given bufferView is valid |
| 920 | static VkBool32 validateBufferView(const layer_data* my_data, const VkBufferView* pBufferView) |
| 921 | { |
| 922 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 923 | auto sampIt = my_data->bufferViewMap.find(*pBufferView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 924 | if (sampIt == my_data->bufferViewMap.end()) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 925 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_BUFFER_VIEW, (uint64_t) *pBufferView, 0, DRAWSTATE_BUFFERVIEW_DESCRIPTOR_ERROR, "DS", |
| 926 | "vkUpdateDescriptorSets: Attempt to update descriptor with invalid bufferView %#" PRIxLEAST64, (uint64_t) *pBufferView); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 927 | } else { |
| 928 | // TODO : Any further checks we want to do on the bufferView? |
| 929 | } |
| 930 | return skipCall; |
| 931 | } |
| 932 | // Verify that given bufferInfo is valid |
| 933 | static VkBool32 validateBufferInfo(const layer_data* my_data, const VkDescriptorBufferInfo* pBufferInfo) |
| 934 | { |
| 935 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 936 | auto sampIt = my_data->bufferMap.find(pBufferInfo->buffer); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 937 | if (sampIt == my_data->bufferMap.end()) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 938 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_BUFFER, (uint64_t) pBufferInfo->buffer, 0, DRAWSTATE_BUFFERINFO_DESCRIPTOR_ERROR, "DS", |
| 939 | "vkUpdateDescriptorSets: Attempt to update descriptor where bufferInfo has invalid buffer %#" PRIxLEAST64, (uint64_t) pBufferInfo->buffer); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 940 | } else { |
| 941 | // TODO : Any further checks we want to do on the bufferView? |
| 942 | } |
| 943 | return skipCall; |
| 944 | } |
| 945 | static VkBool32 validateUpdateContents(const layer_data* my_data, const VkWriteDescriptorSet *pWDS, const VkDescriptorSetLayoutBinding* pLayoutBinding) |
| 946 | { |
| 947 | VkBool32 skipCall = VK_FALSE; |
| 948 | // First verify that for the given Descriptor type, the correct DescriptorInfo data is supplied |
| 949 | VkBufferView* pBufferView = NULL; |
| 950 | const VkSampler* pSampler = NULL; |
| 951 | VkImageView* pImageView = NULL; |
| 952 | VkImageLayout* pImageLayout = NULL; |
| 953 | VkDescriptorBufferInfo* pBufferInfo = NULL; |
| 954 | VkBool32 immutable = VK_FALSE; |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 955 | uint32_t i = 0; |
| 956 | // For given update type, verify that update contents are correct |
| 957 | switch (pWDS->descriptorType) { |
| 958 | case VK_DESCRIPTOR_TYPE_SAMPLER: |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 959 | for (i=0; i<pWDS->descriptorCount; ++i) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 960 | skipCall |= validateSampler(my_data, &(pWDS->pImageInfo[i].sampler), immutable); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 961 | } |
| 962 | break; |
| 963 | case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 964 | for (i=0; i<pWDS->descriptorCount; ++i) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 965 | if (NULL == pLayoutBinding->pImmutableSamplers) { |
| 966 | pSampler = &(pWDS->pImageInfo[i].sampler); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 967 | if (immutable) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 968 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SAMPLER, (uint64_t) *pSampler, 0, DRAWSTATE_INCONSISTENT_IMMUTABLE_SAMPLER_UPDATE, "DS", |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 969 | "vkUpdateDescriptorSets: Update #%u is not an immutable sampler %#" PRIxLEAST64 ", but previous update(s) from this " |
| 970 | "VkWriteDescriptorSet struct used an immutable sampler. All updates from a single struct must either " |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 971 | "use immutable or non-immutable samplers.", i, (uint64_t) *pSampler); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 972 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 973 | } else { |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 974 | if (i>0 && !immutable) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 975 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_SAMPLER, (uint64_t) *pSampler, 0, DRAWSTATE_INCONSISTENT_IMMUTABLE_SAMPLER_UPDATE, "DS", |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 976 | "vkUpdateDescriptorSets: Update #%u is an immutable sampler, but previous update(s) from this " |
| 977 | "VkWriteDescriptorSet struct used a non-immutable sampler. All updates from a single struct must either " |
| 978 | "use immutable or non-immutable samplers.", i); |
| 979 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 980 | immutable = VK_TRUE; |
| 981 | pSampler = &(pLayoutBinding->pImmutableSamplers[i]); |
| 982 | } |
| 983 | skipCall |= validateSampler(my_data, pSampler, immutable); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 984 | } |
| 985 | // Intentionally fall through here to also validate image stuff |
| 986 | case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: |
| 987 | case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: |
| 988 | case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 989 | for (i=0; i<pWDS->descriptorCount; ++i) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 990 | skipCall |= validateImageView(my_data, &(pWDS->pImageInfo[i].imageView), pWDS->pImageInfo[i].imageLayout); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 991 | } |
| 992 | break; |
| 993 | case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: |
| 994 | case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 995 | for (i=0; i<pWDS->descriptorCount; ++i) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 996 | skipCall |= validateBufferView(my_data, &(pWDS->pTexelBufferView[i])); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 997 | } |
| 998 | break; |
| 999 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: |
| 1000 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: |
| 1001 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 1002 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1003 | for (i=0; i<pWDS->descriptorCount; ++i) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1004 | skipCall |= validateBufferInfo(my_data, &(pWDS->pBufferInfo[i])); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 1005 | } |
| 1006 | break; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1007 | } |
| 1008 | return skipCall; |
| 1009 | } |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 1010 | // update DS mappings based on write and copy update arrays |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1011 | static VkBool32 dsUpdate(layer_data* my_data, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pWDS, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pCDS) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1012 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1013 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 1014 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1015 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1016 | LAYOUT_NODE* pLayout = NULL; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1017 | VkDescriptorSetLayoutCreateInfo* pLayoutCI = NULL; |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 1018 | // Validate Write updates |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1019 | uint32_t i = 0; |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1020 | for (i=0; i < descriptorWriteCount; i++) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1021 | VkDescriptorSet ds = pWDS[i].dstSet; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1022 | SET_NODE* pSet = my_data->setMap[ds]; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1023 | GENERIC_HEADER* pUpdate = (GENERIC_HEADER*) &pWDS[i]; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1024 | pLayout = pSet->pLayout; |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 1025 | // First verify valid update struct |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1026 | if ((skipCall = validUpdateStruct(my_data, device, pUpdate)) == VK_TRUE) { |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 1027 | break; |
| 1028 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1029 | uint32_t binding = 0, endIndex = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1030 | binding = pWDS[i].dstBinding; |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 1031 | // Make sure that layout being updated has the binding being updated |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1032 | if (pLayout->createInfo.bindingCount < binding) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1033 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) ds, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1034 | "Descriptor Set %p does not have binding to match update binding %u for update type %s!", ds, binding, string_VkStructureType(pUpdate->sType)); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 1035 | } else { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1036 | // Next verify that update falls within size of given binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1037 | endIndex = getUpdateEndIndex(my_data, device, pLayout, binding, pWDS[i].dstArrayElement, pUpdate); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1038 | if (getBindingEndIndex(pLayout, binding) < endIndex) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1039 | pLayoutCI = &pLayout->createInfo; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1040 | string DSstr = vk_print_vkdescriptorsetlayoutcreateinfo(pLayoutCI, "{DS} "); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1041 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) ds, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1042 | "Descriptor update type of %s is out of bounds for matching binding %u in Layout w/ CI:\n%s!", string_VkStructureType(pUpdate->sType), binding, DSstr.c_str()); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 1043 | } else { // TODO : should we skip update on a type mismatch or force it? |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 1044 | uint32_t startIndex; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1045 | startIndex = getUpdateStartIndex(my_data, device, pLayout, binding, pWDS[i].dstArrayElement, pUpdate); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 1046 | // Layout bindings match w/ update, now verify that update type & stageFlags are the same for entire update |
| 1047 | if ((skipCall = validateUpdateConsistency(my_data, device, pLayout, pUpdate, startIndex, endIndex)) == VK_FALSE) { |
| 1048 | // The update is within bounds and consistent, but need to make sure contents make sense as well |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1049 | if ((skipCall = validateUpdateContents(my_data, &pWDS[i], &pLayout->createInfo.pBindings[binding])) == VK_FALSE) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1050 | // Update is good. Save the update info |
| 1051 | // Create new update struct for this set's shadow copy |
| 1052 | GENERIC_HEADER* pNewNode = NULL; |
| 1053 | skipCall |= shadowUpdateNode(my_data, device, pUpdate, &pNewNode); |
| 1054 | if (NULL == pNewNode) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1055 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) ds, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1056 | "Out of memory while attempting to allocate UPDATE struct in vkUpdateDescriptors()"); |
| 1057 | } else { |
| 1058 | // Insert shadow node into LL of updates for this set |
| 1059 | pNewNode->pNext = pSet->pUpdateStructs; |
| 1060 | pSet->pUpdateStructs = pNewNode; |
| 1061 | // Now update appropriate descriptor(s) to point to new Update node |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1062 | for (uint32_t j = startIndex; j <= endIndex; j++) { |
| 1063 | assert(j<pSet->descriptorCount); |
| 1064 | pSet->ppDescriptors[j] = pNewNode; |
| 1065 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1071 | } |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1072 | // Now validate copy updates |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1073 | for (i=0; i < descriptorCopyCount; ++i) { |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1074 | SET_NODE *pSrcSet = NULL, *pDstSet = NULL; |
| 1075 | LAYOUT_NODE *pSrcLayout = NULL, *pDstLayout = NULL; |
| 1076 | uint32_t srcStartIndex = 0, srcEndIndex = 0, dstStartIndex = 0, dstEndIndex = 0; |
| 1077 | // For each copy make sure that update falls within given layout and that types match |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1078 | pSrcSet = my_data->setMap[pCDS[i].srcSet]; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1079 | pDstSet = my_data->setMap[pCDS[i].dstSet]; |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1080 | pSrcLayout = pSrcSet->pLayout; |
| 1081 | pDstLayout = pDstSet->pLayout; |
| 1082 | // Validate that src binding is valid for src set layout |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1083 | if (pSrcLayout->createInfo.bindingCount < pCDS[i].srcBinding) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1084 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pSrcSet->set, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1085 | "Copy descriptor update %u has srcBinding %u which is out of bounds for underlying SetLayout %#" PRIxLEAST64 " which only has bindings 0-%u.", |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1086 | i, pCDS[i].srcBinding, (uint64_t) pSrcLayout->layout, pSrcLayout->createInfo.bindingCount-1); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1087 | } else if (pDstLayout->createInfo.bindingCount < pCDS[i].dstBinding) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1088 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDstSet->set, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1089 | "Copy descriptor update %u has dstBinding %u which is out of bounds for underlying SetLayout %#" PRIxLEAST64 " which only has bindings 0-%u.", |
| 1090 | i, pCDS[i].dstBinding, (uint64_t) pDstLayout->layout, pDstLayout->createInfo.bindingCount-1); |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1091 | } else { |
| 1092 | // Proceed with validation. Bindings are ok, but make sure update is within bounds of given layout |
| 1093 | srcEndIndex = getUpdateEndIndex(my_data, device, pSrcLayout, pCDS[i].srcBinding, pCDS[i].srcArrayElement, (const GENERIC_HEADER*)&(pCDS[i])); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1094 | dstEndIndex = getUpdateEndIndex(my_data, device, pDstLayout, pCDS[i].dstBinding, pCDS[i].dstArrayElement, (const GENERIC_HEADER*)&(pCDS[i])); |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1095 | if (getBindingEndIndex(pSrcLayout, pCDS[i].srcBinding) < srcEndIndex) { |
| 1096 | pLayoutCI = &pSrcLayout->createInfo; |
| 1097 | string DSstr = vk_print_vkdescriptorsetlayoutcreateinfo(pLayoutCI, "{DS} "); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1098 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pSrcSet->set, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1099 | "Copy descriptor src update is out of bounds for matching binding %u in Layout w/ CI:\n%s!", pCDS[i].srcBinding, DSstr.c_str()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1100 | } else if (getBindingEndIndex(pDstLayout, pCDS[i].dstBinding) < dstEndIndex) { |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1101 | pLayoutCI = &pDstLayout->createInfo; |
| 1102 | string DSstr = vk_print_vkdescriptorsetlayoutcreateinfo(pLayoutCI, "{DS} "); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1103 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDstSet->set, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1104 | "Copy descriptor dest update is out of bounds for matching binding %u in Layout w/ CI:\n%s!", pCDS[i].dstBinding, DSstr.c_str()); |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1105 | } else { |
| 1106 | srcStartIndex = getUpdateStartIndex(my_data, device, pSrcLayout, pCDS[i].srcBinding, pCDS[i].srcArrayElement, (const GENERIC_HEADER*)&(pCDS[i])); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1107 | dstStartIndex = getUpdateStartIndex(my_data, device, pDstLayout, pCDS[i].dstBinding, pCDS[i].dstArrayElement, (const GENERIC_HEADER*)&(pCDS[i])); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1108 | for (uint32_t j=0; j<pCDS[i].descriptorCount; ++j) { |
Tobin Ehlis | 8a62e63 | 2015-10-27 15:43:38 -0600 | [diff] [blame] | 1109 | // For copy just make sure that the types match and then perform the update |
| 1110 | if (pSrcLayout->descriptorTypes[srcStartIndex+j] != pDstLayout->descriptorTypes[dstStartIndex+j]) { |
| 1111 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, "DS", |
| 1112 | "Copy descriptor update index %u, update count #%u, has src update descriptor type %s that does not match overlapping dest descriptor type of %s!", |
| 1113 | i, j+1, string_VkDescriptorType(pSrcLayout->descriptorTypes[srcStartIndex+j]), string_VkDescriptorType(pDstLayout->descriptorTypes[dstStartIndex+j])); |
| 1114 | } else { |
| 1115 | // point dst descriptor at corresponding src descriptor |
| 1116 | pDstSet->ppDescriptors[j+dstStartIndex] = pSrcSet->ppDescriptors[j+srcStartIndex]; |
| 1117 | } |
| 1118 | } |
| 1119 | } |
| 1120 | } |
| 1121 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1122 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1123 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1124 | } |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1125 | // Verify that given pool has descriptors that are being requested for allocation |
| 1126 | static VkBool32 validate_descriptor_availability_in_pool(layer_data* dev_data, POOL_NODE* pPoolNode, uint32_t count, const VkDescriptorSetLayout* pSetLayouts) |
| 1127 | { |
| 1128 | VkBool32 skipCall = VK_FALSE; |
| 1129 | uint32_t i = 0, j = 0; |
| 1130 | for (i=0; i<count; ++i) { |
| 1131 | LAYOUT_NODE* pLayout = getLayoutNode(dev_data, pSetLayouts[i]); |
| 1132 | if (NULL == pLayout) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1133 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t) pSetLayouts[i], 0, DRAWSTATE_INVALID_LAYOUT, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1134 | "Unable to find set layout node for layout %#" PRIxLEAST64 " specified in vkAllocateDescriptorSets() call", (uint64_t) pSetLayouts[i]); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1135 | } else { |
| 1136 | uint32_t typeIndex = 0, typeCount = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1137 | for (j=0; j<pLayout->createInfo.bindingCount; ++j) { |
| 1138 | typeIndex = static_cast<uint32_t>(pLayout->createInfo.pBindings[j].descriptorType); |
| 1139 | typeCount = pLayout->createInfo.pBindings[j].arraySize; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1140 | if (typeCount > pPoolNode->availableDescriptorTypeCount[typeIndex]) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1141 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t) pLayout->layout, 0, DRAWSTATE_DESCRIPTOR_POOL_EMPTY, "DS", |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1142 | "Unable to allocate %u descriptors of type %s from pool %#" PRIxLEAST64 ". This pool only has %u descriptors of this type remaining.", |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1143 | typeCount, string_VkDescriptorType(pLayout->createInfo.pBindings[j].descriptorType), (uint64_t) pPoolNode->pool, pPoolNode->availableDescriptorTypeCount[typeIndex]); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1144 | } else { // Decrement available descriptors of this type |
| 1145 | pPoolNode->availableDescriptorTypeCount[typeIndex] -= typeCount; |
| 1146 | } |
| 1147 | } |
| 1148 | } |
| 1149 | } |
| 1150 | return skipCall; |
| 1151 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1152 | // Free the shadowed update node for this Set |
| 1153 | // NOTE : Calls to this function should be wrapped in mutex |
| 1154 | static void freeShadowUpdateTree(SET_NODE* pSet) |
| 1155 | { |
| 1156 | GENERIC_HEADER* pShadowUpdate = pSet->pUpdateStructs; |
| 1157 | pSet->pUpdateStructs = NULL; |
| 1158 | GENERIC_HEADER* pFreeUpdate = pShadowUpdate; |
| 1159 | // Clear the descriptor mappings as they will now be invalid |
| 1160 | memset(pSet->ppDescriptors, 0, pSet->descriptorCount*sizeof(GENERIC_HEADER*)); |
| 1161 | while(pShadowUpdate) { |
| 1162 | pFreeUpdate = pShadowUpdate; |
| 1163 | pShadowUpdate = (GENERIC_HEADER*)pShadowUpdate->pNext; |
| 1164 | uint32_t index = 0; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 1165 | VkWriteDescriptorSet * pWDS = NULL; |
| 1166 | VkCopyDescriptorSet * pCDS = NULL; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1167 | void** ppToFree = NULL; |
| 1168 | switch (pFreeUpdate->sType) |
| 1169 | { |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 1170 | case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET: |
| 1171 | pWDS = (VkWriteDescriptorSet*)pFreeUpdate; |
Tony Barbour | b194794 | 2015-11-02 11:46:29 -0700 | [diff] [blame] | 1172 | switch (pWDS->descriptorType) { |
| 1173 | case VK_DESCRIPTOR_TYPE_SAMPLER: |
| 1174 | case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: |
| 1175 | case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: |
| 1176 | case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: |
| 1177 | { |
| 1178 | delete[] pWDS->pImageInfo; |
| 1179 | } |
| 1180 | break; |
| 1181 | case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: |
| 1182 | case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: |
| 1183 | { |
| 1184 | delete[] pWDS->pTexelBufferView; |
| 1185 | } |
| 1186 | break; |
| 1187 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: |
| 1188 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: |
| 1189 | case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: |
| 1190 | case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: |
| 1191 | { |
| 1192 | delete[] pWDS->pBufferInfo; |
| 1193 | } |
| 1194 | break; |
| 1195 | default: |
| 1196 | break; |
Courtney Goeltzenleuchter | aa132e7 | 2015-10-22 15:31:56 -0600 | [diff] [blame] | 1197 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1198 | break; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 1199 | case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET: |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1200 | break; |
| 1201 | default: |
| 1202 | assert(0); |
| 1203 | break; |
| 1204 | } |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 1205 | delete pFreeUpdate; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1206 | } |
| 1207 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1208 | // Free all DS Pools including their Sets & related sub-structs |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1209 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1210 | static void deletePools(layer_data* my_data) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1211 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1212 | if (my_data->poolMap.size() <= 0) |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1213 | return; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1214 | for (auto ii=my_data->poolMap.begin(); ii!=my_data->poolMap.end(); ++ii) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1215 | SET_NODE* pSet = (*ii).second->pSets; |
| 1216 | SET_NODE* pFreeSet = pSet; |
| 1217 | while (pSet) { |
| 1218 | pFreeSet = pSet; |
| 1219 | pSet = pSet->pNext; |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 1220 | // Freeing layouts handled in deleteLayouts() function |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1221 | // Free Update shadow struct tree |
| 1222 | freeShadowUpdateTree(pFreeSet); |
| 1223 | if (pFreeSet->ppDescriptors) { |
Chris Forbes | 0203879 | 2015-06-04 10:49:27 +1200 | [diff] [blame] | 1224 | delete[] pFreeSet->ppDescriptors; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1225 | } |
| 1226 | delete pFreeSet; |
| 1227 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1228 | delete (*ii).second; |
| 1229 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1230 | my_data->poolMap.clear(); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1231 | } |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 1232 | // WARN : Once deleteLayouts() called, any layout ptrs in Pool/Set data structure will be invalid |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1233 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1234 | static void deleteLayouts(layer_data* my_data) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1235 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1236 | if (my_data->layoutMap.size() <= 0) |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1237 | return; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1238 | for (auto ii=my_data->layoutMap.begin(); ii!=my_data->layoutMap.end(); ++ii) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1239 | LAYOUT_NODE* pLayout = (*ii).second; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1240 | if (pLayout->createInfo.pBindings) { |
| 1241 | for (uint32_t i=0; i<pLayout->createInfo.bindingCount; i++) { |
| 1242 | if (pLayout->createInfo.pBindings[i].pImmutableSamplers) |
| 1243 | delete[] pLayout->createInfo.pBindings[i].pImmutableSamplers; |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 1244 | } |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1245 | delete[] pLayout->createInfo.pBindings; |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 1246 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1247 | delete pLayout; |
| 1248 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1249 | my_data->layoutMap.clear(); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1250 | } |
| 1251 | // Currently clearing a set is removing all previous updates to that set |
| 1252 | // TODO : Validate if this is correct clearing behavior |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1253 | static void clearDescriptorSet(layer_data* my_data, VkDescriptorSet set) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1254 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1255 | SET_NODE* pSet = getSetNode(my_data, set); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1256 | if (!pSet) { |
| 1257 | // TODO : Return error |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1258 | } else { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1259 | loader_platform_thread_lock_mutex(&globalLock); |
| 1260 | freeShadowUpdateTree(pSet); |
| 1261 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1262 | } |
| 1263 | } |
| 1264 | |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1265 | static void clearDescriptorPool(layer_data* my_data, const VkDevice device, const VkDescriptorPool pool, VkDescriptorPoolResetFlags flags) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1266 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1267 | POOL_NODE* pPool = getPoolNode(my_data, pool); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1268 | if (!pPool) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1269 | log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_POOL, (uint64_t) pool, 0, DRAWSTATE_INVALID_POOL, "DS", |
| 1270 | "Unable to find pool node for pool %#" PRIxLEAST64 " specified in vkResetDescriptorPool() call", (uint64_t) pool); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1271 | } else { |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1272 | // TODO: validate flags |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1273 | // For every set off of this pool, clear it |
| 1274 | SET_NODE* pSet = pPool->pSets; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1275 | while (pSet) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1276 | clearDescriptorSet(my_data, pSet->set); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1277 | } |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1278 | // Reset available count to max count for this pool |
| 1279 | for (uint32_t i=0; i<pPool->availableDescriptorTypeCount.size(); ++i) { |
| 1280 | pPool->availableDescriptorTypeCount[i] = pPool->maxDescriptorTypeCount[i]; |
| 1281 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1282 | } |
| 1283 | } |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1284 | // For given CB object, fetch associated CB Node from map |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1285 | static GLOBAL_CB_NODE* getCBNode(layer_data* my_data, const VkCommandBuffer cb) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1286 | { |
| 1287 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1288 | if (my_data->commandBufferMap.find(cb) == my_data->commandBufferMap.end()) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1289 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1290 | // TODO : How to pass cb as srcObj here? |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1291 | log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", |
| 1292 | "Attempt to use CommandBuffer %#" PRIxLEAST64 " that doesn't exist!", reinterpret_cast<uint64_t>(cb)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1293 | return NULL; |
| 1294 | } |
| 1295 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1296 | return my_data->commandBufferMap[cb]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1297 | } |
| 1298 | // Free all CB Nodes |
| 1299 | // NOTE : Calls to this function should be wrapped in mutex |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1300 | static void deleteCommandBuffers(layer_data* my_data) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1301 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1302 | if (my_data->commandBufferMap.size() <= 0) |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1303 | return; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1304 | for (auto ii=my_data->commandBufferMap.begin(); ii!=my_data->commandBufferMap.end(); ++ii) { |
Courtney Goeltzenleuchter | ea3117c | 2015-04-27 15:04:43 -0600 | [diff] [blame] | 1305 | vector<CMD_NODE*> cmd_node_list = (*ii).second->pCmds; |
| 1306 | while (!cmd_node_list.empty()) { |
| 1307 | CMD_NODE* cmd_node = cmd_node_list.back(); |
| 1308 | delete cmd_node; |
| 1309 | cmd_node_list.pop_back(); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1310 | } |
| 1311 | delete (*ii).second; |
| 1312 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1313 | my_data->commandBufferMap.clear(); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1314 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1315 | static VkBool32 report_error_no_cb_begin(const layer_data* dev_data, const VkCommandBuffer cb, const char* caller_name) |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 1316 | { |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1317 | // TODO : How to pass cb as srcObj here? |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1318 | return log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NO_BEGIN_COMMAND_BUFFER, "DS", |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 1319 | "You must call vkBeginCommandBuffer() before this call to %s", (void*)caller_name); |
| 1320 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1321 | static VkBool32 addCmd(const layer_data* my_data, GLOBAL_CB_NODE* pCB, const CMD_TYPE cmd) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1322 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1323 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1324 | CMD_NODE* pCmd = new CMD_NODE; |
| 1325 | if (pCmd) { |
| 1326 | // init cmd node and append to end of cmd LL |
| 1327 | memset(pCmd, 0, sizeof(CMD_NODE)); |
| 1328 | pCmd->cmdNumber = ++pCB->numCmds; |
| 1329 | pCmd->type = cmd; |
| 1330 | pCB->pCmds.push_back(pCmd); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1331 | } else { |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1332 | // TODO : How to pass cb as srcObj here? |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1333 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1334 | "Out of memory while attempting to allocate new CMD_NODE for commandBuffer %#" PRIxLEAST64, reinterpret_cast<uint64_t>(pCB->commandBuffer)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1335 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1336 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1337 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1338 | static void resetCB(layer_data* my_data, const VkCommandBuffer cb) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1339 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1340 | GLOBAL_CB_NODE* pCB = getCBNode(my_data, cb); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1341 | if (pCB) { |
Courtney Goeltzenleuchter | 3597a20 | 2015-04-27 17:16:56 -0600 | [diff] [blame] | 1342 | vector<CMD_NODE*> cmd_list = pCB->pCmds; |
| 1343 | while (!cmd_list.empty()) { |
| 1344 | delete cmd_list.back(); |
| 1345 | cmd_list.pop_back(); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1346 | } |
Courtney Goeltzenleuchter | 3597a20 | 2015-04-27 17:16:56 -0600 | [diff] [blame] | 1347 | pCB->pCmds.clear(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1348 | // Reset CB state (need to save createInfo) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1349 | VkCommandBufferAllocateInfo saveCBCI = pCB->createInfo; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1350 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1351 | pCB->commandBuffer = cb; |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1352 | pCB->createInfo = saveCBCI; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1353 | pCB->lastVtxBinding = MAX_BINDING; |
| 1354 | } |
| 1355 | } |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1356 | // Set PSO-related status bits for CB, including dynamic state set via PSO |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 1357 | static void set_cb_pso_status(GLOBAL_CB_NODE* pCB, const PIPELINE_NODE* pPipe) |
| 1358 | { |
| 1359 | for (uint32_t i = 0; i < pPipe->cbStateCI.attachmentCount; i++) { |
| 1360 | if (0 != pPipe->pAttachments[i].channelWriteMask) { |
| 1361 | pCB->status |= CBSTATUS_COLOR_BLEND_WRITE_ENABLE; |
| 1362 | } |
| 1363 | } |
| 1364 | if (pPipe->dsStateCI.depthWriteEnable) { |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1365 | pCB->status |= CBSTATUS_DEPTH_WRITE_ENABLE; |
| 1366 | } |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 1367 | if (pPipe->dsStateCI.stencilTestEnable) { |
| 1368 | pCB->status |= CBSTATUS_STENCIL_TEST_ENABLE; |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 1369 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 1370 | // Account for any dynamic state not set via this PSO |
| 1371 | if (!pPipe->dynStateCI.dynamicStateCount) { // All state is static |
| 1372 | pCB->status = CBSTATUS_ALL; |
| 1373 | } else { |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1374 | // First consider all state on |
| 1375 | // Then unset any state that's noted as dynamic in PSO |
| 1376 | // Finally OR that into CB statemask |
| 1377 | CBStatusFlags psoDynStateMask = CBSTATUS_ALL; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1378 | for (uint32_t i=0; i < pPipe->dynStateCI.dynamicStateCount; i++) { |
| 1379 | switch (pPipe->dynStateCI.pDynamicStates[i]) { |
| 1380 | case VK_DYNAMIC_STATE_VIEWPORT: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1381 | psoDynStateMask &= ~CBSTATUS_VIEWPORT_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1382 | break; |
| 1383 | case VK_DYNAMIC_STATE_SCISSOR: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1384 | psoDynStateMask &= ~CBSTATUS_SCISSOR_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1385 | break; |
| 1386 | case VK_DYNAMIC_STATE_LINE_WIDTH: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1387 | psoDynStateMask &= ~CBSTATUS_LINE_WIDTH_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1388 | break; |
| 1389 | case VK_DYNAMIC_STATE_DEPTH_BIAS: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1390 | psoDynStateMask &= ~CBSTATUS_DEPTH_BIAS_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1391 | break; |
| 1392 | case VK_DYNAMIC_STATE_BLEND_CONSTANTS: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1393 | psoDynStateMask &= ~CBSTATUS_BLEND_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1394 | break; |
| 1395 | case VK_DYNAMIC_STATE_DEPTH_BOUNDS: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1396 | psoDynStateMask &= ~CBSTATUS_DEPTH_BOUNDS_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1397 | break; |
| 1398 | case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1399 | psoDynStateMask &= ~CBSTATUS_STENCIL_READ_MASK_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1400 | break; |
| 1401 | case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1402 | psoDynStateMask &= ~CBSTATUS_STENCIL_WRITE_MASK_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1403 | break; |
| 1404 | case VK_DYNAMIC_STATE_STENCIL_REFERENCE: |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1405 | psoDynStateMask &= ~CBSTATUS_STENCIL_REFERENCE_SET; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1406 | break; |
| 1407 | default: |
| 1408 | // TODO : Flag error here |
| 1409 | break; |
| 1410 | } |
| 1411 | } |
Tobin Ehlis | 5e5a1e9 | 2015-10-01 09:24:40 -0600 | [diff] [blame] | 1412 | pCB->status |= psoDynStateMask; |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1413 | } |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 1414 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1415 | // Print the last bound Gfx Pipeline |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1416 | static VkBool32 printPipeline(layer_data* my_data, const VkCommandBuffer cb) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1417 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1418 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1419 | GLOBAL_CB_NODE* pCB = getCBNode(my_data, cb); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1420 | if (pCB) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1421 | PIPELINE_NODE *pPipeTrav = getPipeline(my_data, pCB->lastBoundPipeline); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1422 | if (!pPipeTrav) { |
| 1423 | // nothing to print |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1424 | } else { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1425 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1426 | vk_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "{DS}").c_str()); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1427 | } |
| 1428 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1429 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1430 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1431 | // Print details of DS config to stdout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1432 | static VkBool32 printDSConfig(layer_data* my_data, const VkCommandBuffer cb) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1433 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1434 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1435 | char ds_config_str[1024*256] = {0}; // TODO : Currently making this buffer HUGE w/o overrun protection. Need to be smarter, start smaller, and grow as needed. |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1436 | GLOBAL_CB_NODE* pCB = getCBNode(my_data, cb); |
Tobin Ehlis | 93f89e8 | 2015-06-09 08:39:32 -0600 | [diff] [blame] | 1437 | if (pCB && pCB->lastBoundDescriptorSet) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1438 | SET_NODE* pSet = getSetNode(my_data, pCB->lastBoundDescriptorSet); |
| 1439 | POOL_NODE* pPool = getPoolNode(my_data, pSet->pool); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1440 | // Print out pool details |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1441 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1442 | "Details for pool %#" PRIxLEAST64 ".", (uint64_t) pPool->pool); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1443 | string poolStr = vk_print_vkdescriptorpoolcreateinfo(&pPool->createInfo, " "); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1444 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1445 | "%s", poolStr.c_str()); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1446 | // Print out set details |
| 1447 | char prefix[10]; |
| 1448 | uint32_t index = 0; |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1449 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1450 | "Details for descriptor set %#" PRIxLEAST64 ".", (uint64_t) pSet->set); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1451 | LAYOUT_NODE* pLayout = pSet->pLayout; |
| 1452 | // Print layout details |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1453 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1454 | "Layout #%u, (object %#" PRIxLEAST64 ") for DS %#" PRIxLEAST64 ".", index+1, (void*)pLayout->layout, (void*)pSet->set); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1455 | sprintf(prefix, " [L%u] ", index); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1456 | string DSLstr = vk_print_vkdescriptorsetlayoutcreateinfo(&pLayout->createInfo, prefix).c_str(); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1457 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1458 | "%s", DSLstr.c_str()); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1459 | index++; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1460 | GENERIC_HEADER* pUpdate = pSet->pUpdateStructs; |
| 1461 | if (pUpdate) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1462 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1463 | "Update Chain [UC] for descriptor set %#" PRIxLEAST64 ":", (uint64_t) pSet->set); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1464 | sprintf(prefix, " [UC] "); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1465 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1466 | dynamic_display(pUpdate, prefix).c_str()); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1467 | // TODO : If there is a "view" associated with this update, print CI for that view |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1468 | } else { |
Tobin Ehlis | bf081f3 | 2015-06-15 08:41:17 -0600 | [diff] [blame] | 1469 | if (0 != pSet->descriptorCount) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1470 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1471 | "No Update Chain for descriptor set %#" PRIxLEAST64 " which has %u descriptors (vkUpdateDescriptors has not been called)", (uint64_t) pSet->set, pSet->descriptorCount); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1472 | } else { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1473 | skipCall |= log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1474 | "FYI: No descriptors in descriptor set %#" PRIxLEAST64 ".", (uint64_t) pSet->set); |
Tobin Ehlis | bf081f3 | 2015-06-15 08:41:17 -0600 | [diff] [blame] | 1475 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1476 | } |
| 1477 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1478 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1479 | } |
| 1480 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1481 | static void printCB(layer_data* my_data, const VkCommandBuffer cb) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1482 | { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1483 | GLOBAL_CB_NODE* pCB = getCBNode(my_data, cb); |
David Pinedo | d8f83d8 | 2015-04-27 16:36:17 -0600 | [diff] [blame] | 1484 | if (pCB && pCB->pCmds.size() > 0) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1485 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1486 | "Cmds in CB %p", (void*)cb); |
Courtney Goeltzenleuchter | ba348a9 | 2015-04-27 11:16:35 -0600 | [diff] [blame] | 1487 | vector<CMD_NODE*> pCmds = pCB->pCmds; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1488 | for (auto ii=pCmds.begin(); ii!=pCmds.end(); ++ii) { |
| 1489 | // TODO : Need to pass cb as srcObj here |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1490 | log_msg(my_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1491 | " CMD#%lu: %s", (*ii)->cmdNumber, cmdTypeToString((*ii)->type).c_str()); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1492 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 1493 | } else { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1494 | // Nothing to print |
| 1495 | } |
| 1496 | } |
| 1497 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1498 | static VkBool32 synchAndPrintDSConfig(layer_data* my_data, const VkCommandBuffer cb) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1499 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1500 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1501 | if (!(my_data->report_data->active_flags & VK_DBG_REPORT_INFO_BIT)) { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1502 | return skipCall; |
Mike Stroyan | ba35e35 | 2015-08-12 17:11:28 -0600 | [diff] [blame] | 1503 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1504 | skipCall |= printDSConfig(my_data, cb); |
| 1505 | skipCall |= printPipeline(my_data, cb); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1506 | return skipCall; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1507 | } |
| 1508 | |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 1509 | // Flags validation error if the associated call is made inside a render pass. The apiName |
| 1510 | // routine should ONLY be called outside a render pass. |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1511 | static VkBool32 insideRenderPass(const layer_data* my_data, GLOBAL_CB_NODE *pCB, const char *apiName) |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 1512 | { |
| 1513 | VkBool32 inside = VK_FALSE; |
| 1514 | if (pCB->activeRenderPass) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1515 | inside = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1516 | (uint64_t)pCB->commandBuffer, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS", |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 1517 | "%s: It is invalid to issue this call inside an active render pass (%#" PRIxLEAST64 ")", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1518 | apiName, (uint64_t) pCB->activeRenderPass); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 1519 | } |
| 1520 | return inside; |
| 1521 | } |
| 1522 | |
| 1523 | // Flags validation error if the associated call is made outside a render pass. The apiName |
| 1524 | // routine should ONLY be called inside a render pass. |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1525 | static VkBool32 outsideRenderPass(const layer_data* my_data, GLOBAL_CB_NODE *pCB, const char *apiName) |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 1526 | { |
| 1527 | VkBool32 outside = VK_FALSE; |
| 1528 | if (!pCB->activeRenderPass) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1529 | outside = log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1530 | (uint64_t)pCB->commandBuffer, 0, DRAWSTATE_NO_ACTIVE_RENDERPASS, "DS", |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 1531 | "%s: This call must be issued inside an active render pass.", apiName); |
| 1532 | } |
| 1533 | return outside; |
| 1534 | } |
| 1535 | |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1536 | static void init_draw_state(layer_data *my_data) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1537 | { |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1538 | uint32_t report_flags = 0; |
| 1539 | uint32_t debug_action = 0; |
| 1540 | FILE *log_output = NULL; |
| 1541 | const char *option_str; |
Courtney Goeltzenleuchter | 62d945a | 2015-10-05 15:58:38 -0600 | [diff] [blame] | 1542 | VkDbgMsgCallback callback; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1543 | // initialize DrawState options |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1544 | report_flags = getLayerOptionFlags("DrawStateReportFlags", 0); |
| 1545 | getLayerOptionEnum("DrawStateDebugAction", (uint32_t *) &debug_action); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1546 | |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1547 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1548 | { |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1549 | option_str = getLayerOption("DrawStateLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 1550 | log_output = getLayerLogOutput(option_str, "DrawState"); |
Courtney Goeltzenleuchter | 62d945a | 2015-10-05 15:58:38 -0600 | [diff] [blame] | 1551 | layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &callback); |
| 1552 | my_data->logging_callback.push_back(callback); |
| 1553 | } |
| 1554 | |
| 1555 | if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) { |
| 1556 | layer_create_msg_callback(my_data->report_data, report_flags, win32_debug_output_msg, NULL, &callback); |
| 1557 | my_data->logging_callback.push_back(callback); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1558 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1559 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1560 | if (!globalLockInitialized) |
| 1561 | { |
Mike Stroyan | fcb4ba6 | 2015-08-18 15:56:18 -0600 | [diff] [blame] | 1562 | // This mutex may be deleted by vkDestroyInstance of last instance. |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1563 | loader_platform_thread_create_mutex(&globalLock); |
| 1564 | globalLockInitialized = 1; |
| 1565 | } |
| 1566 | } |
| 1567 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1568 | VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) |
Courtney Goeltzenleuchter | abc035e | 2015-06-01 14:29:58 -0600 | [diff] [blame] | 1569 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1570 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 1571 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1572 | VkResult result = pTable->CreateInstance(pCreateInfo, pAllocator, pInstance); |
Courtney Goeltzenleuchter | abc035e | 2015-06-01 14:29:58 -0600 | [diff] [blame] | 1573 | |
| 1574 | if (result == VK_SUCCESS) { |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1575 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 1576 | my_data->report_data = debug_report_create_instance( |
| 1577 | pTable, |
| 1578 | *pInstance, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1579 | pCreateInfo->enabledExtensionNameCount, |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1580 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | d02a964 | 2015-06-08 14:58:39 -0600 | [diff] [blame] | 1581 | |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1582 | init_draw_state(my_data); |
Courtney Goeltzenleuchter | abc035e | 2015-06-01 14:29:58 -0600 | [diff] [blame] | 1583 | } |
| 1584 | return result; |
| 1585 | } |
| 1586 | |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 1587 | /* hook DestroyInstance to remove tableInstanceMap entry */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1588 | VK_LAYER_EXPORT void VKAPI vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator) |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 1589 | { |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1590 | dispatch_key key = get_dispatch_key(instance); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1591 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 1592 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1593 | pTable->DestroyInstance(instance, pAllocator); |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1594 | |
| 1595 | // Clean up logging callback, if any |
Courtney Goeltzenleuchter | 62d945a | 2015-10-05 15:58:38 -0600 | [diff] [blame] | 1596 | while (my_data->logging_callback.size() > 0) { |
| 1597 | VkDbgMsgCallback callback = my_data->logging_callback.back(); |
| 1598 | layer_destroy_msg_callback(my_data->report_data, callback); |
| 1599 | my_data->logging_callback.pop_back(); |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1600 | } |
| 1601 | |
Courtney Goeltzenleuchter | ee4027d | 2015-06-28 13:01:17 -0600 | [diff] [blame] | 1602 | layer_debug_report_destroy_instance(my_data->report_data); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1603 | delete my_data->instance_dispatch_table; |
| 1604 | layer_data_map.erase(key); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1605 | // TODO : Potential race here with separate threads creating/destroying instance |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1606 | if (layer_data_map.empty()) { |
Mike Stroyan | fcb4ba6 | 2015-08-18 15:56:18 -0600 | [diff] [blame] | 1607 | // Release mutex when destroying last instance. |
| 1608 | loader_platform_thread_delete_mutex(&globalLock); |
| 1609 | globalLockInitialized = 0; |
| 1610 | } |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 1611 | } |
| 1612 | |
Jon Ashburn | e68a9ff | 2015-05-25 14:11:37 -0600 | [diff] [blame] | 1613 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 1614 | { |
Tony Barbour | 3b4732f | 2015-07-13 13:37:24 -0600 | [diff] [blame] | 1615 | uint32_t i; |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1616 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 1617 | dev_data->device_extensions.debug_marker_enabled = false; |
Jon Ashburn | e68a9ff | 2015-05-25 14:11:37 -0600 | [diff] [blame] | 1618 | |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1619 | for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1620 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], DEBUG_MARKER_EXTENSION_NAME) == 0) { |
Jon Ashburn | eab3449 | 2015-06-01 09:37:38 -0600 | [diff] [blame] | 1621 | /* Found a matching extension name, mark it enabled and init dispatch table*/ |
| 1622 | initDebugMarkerTable(device); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1623 | dev_data->device_extensions.debug_marker_enabled = true; |
Jon Ashburn | e68a9ff | 2015-05-25 14:11:37 -0600 | [diff] [blame] | 1624 | } |
Jon Ashburn | e68a9ff | 2015-05-25 14:11:37 -0600 | [diff] [blame] | 1625 | } |
| 1626 | } |
| 1627 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1628 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1629 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1630 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1631 | VkResult result = dev_data->device_dispatch_table->CreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1632 | if (result == VK_SUCCESS) { |
| 1633 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1634 | dev_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 1635 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 1636 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1637 | return result; |
| 1638 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1639 | // prototype |
| 1640 | static void deleteRenderPasses(layer_data*); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1641 | VK_LAYER_EXPORT void VKAPI vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1642 | { |
Jeremy Hayes | 5d29ce3 | 2015-06-19 11:37:38 -0600 | [diff] [blame] | 1643 | dispatch_key key = get_dispatch_key(device); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1644 | layer_data* dev_data = get_my_data_ptr(key, layer_data_map); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1645 | // Free all the memory |
| 1646 | loader_platform_thread_lock_mutex(&globalLock); |
| 1647 | deletePipelines(dev_data); |
| 1648 | deleteRenderPasses(dev_data); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1649 | deleteCommandBuffers(dev_data); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1650 | deletePools(dev_data); |
| 1651 | deleteLayouts(dev_data); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1652 | dev_data->imageViewMap.clear(); |
| 1653 | dev_data->imageMap.clear(); |
| 1654 | dev_data->bufferViewMap.clear(); |
| 1655 | dev_data->bufferMap.clear(); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1656 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1657 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1658 | dev_data->device_dispatch_table->DestroyDevice(device, pAllocator); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 1659 | tableDebugMarkerMap.erase(key); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1660 | delete dev_data->device_dispatch_table; |
| 1661 | layer_data_map.erase(key); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1662 | } |
| 1663 | |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1664 | static const VkLayerProperties ds_global_layers[] = { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1665 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1666 | "DrawState", |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1667 | VK_API_VERSION, |
| 1668 | VK_MAKE_VERSION(0, 1, 0), |
| 1669 | "Validation layer: DrawState", |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1670 | } |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1671 | }; |
| 1672 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1673 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties( |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1674 | const char *pLayerName, |
| 1675 | uint32_t *pCount, |
| 1676 | VkExtensionProperties* pProperties) |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1677 | { |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1678 | /* DrawState does not have any global extensions */ |
| 1679 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
| 1680 | } |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1681 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1682 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateInstanceLayerProperties( |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1683 | uint32_t *pCount, |
| 1684 | VkLayerProperties* pProperties) |
| 1685 | { |
| 1686 | return util_GetLayerProperties(ARRAY_SIZE(ds_global_layers), |
| 1687 | ds_global_layers, |
| 1688 | pCount, pProperties); |
| 1689 | } |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1690 | |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1691 | static const VkExtensionProperties ds_device_extensions[] = { |
| 1692 | { |
| 1693 | DEBUG_MARKER_EXTENSION_NAME, |
| 1694 | VK_MAKE_VERSION(0, 1, 0), |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1695 | } |
| 1696 | }; |
| 1697 | |
| 1698 | static const VkLayerProperties ds_device_layers[] = { |
| 1699 | { |
| 1700 | "DrawState", |
| 1701 | VK_API_VERSION, |
| 1702 | VK_MAKE_VERSION(0, 1, 0), |
| 1703 | "Validation layer: DrawState", |
| 1704 | } |
| 1705 | }; |
| 1706 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1707 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateDeviceExtensionProperties( |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1708 | VkPhysicalDevice physicalDevice, |
| 1709 | const char* pLayerName, |
| 1710 | uint32_t* pCount, |
| 1711 | VkExtensionProperties* pProperties) |
| 1712 | { |
| 1713 | /* Mem tracker does not have any physical device extensions */ |
| 1714 | return util_GetExtensionProperties(ARRAY_SIZE(ds_device_extensions), ds_device_extensions, |
| 1715 | pCount, pProperties); |
| 1716 | } |
| 1717 | |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 1718 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateDeviceLayerProperties( |
Courtney Goeltzenleuchter | 7ad58c0 | 2015-07-06 22:31:52 -0600 | [diff] [blame] | 1719 | VkPhysicalDevice physicalDevice, |
| 1720 | uint32_t* pCount, |
| 1721 | VkLayerProperties* pProperties) |
| 1722 | { |
| 1723 | /* Mem tracker's physical device layers are the same as global */ |
| 1724 | return util_GetLayerProperties(ARRAY_SIZE(ds_device_layers), ds_device_layers, |
| 1725 | pCount, pProperties); |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1726 | } |
| 1727 | |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1728 | VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1729 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1730 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1731 | GLOBAL_CB_NODE* pCB = NULL; |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1732 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map); |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1733 | for (uint32_t submit_idx = 0; submit_idx < submitCount; submit_idx++) { |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1734 | const VkSubmitInfo *submit = &pSubmits[submit_idx]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1735 | for (uint32_t i=0; i < submit->commandBufferCount; i++) { |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1736 | // Validate that cmd buffers have been updated |
| 1737 | pCB = getCBNode(dev_data, submit->pCommandBuffers[i]); |
| 1738 | loader_platform_thread_lock_mutex(&globalLock); |
| 1739 | pCB->submitCount++; // increment submit count |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1740 | if ((pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) && (pCB->submitCount > 1)) { |
| 1741 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_COMMAND_BUFFER_SINGLE_SUBMIT_VIOLATION, "DS", |
| 1742 | "CB %#" PRIxLEAST64 " was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted %#" PRIxLEAST64 " times.", reinterpret_cast<uint64_t>(pCB->commandBuffer), pCB->submitCount); |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1743 | } |
| 1744 | if (CB_UPDATE_COMPLETE != pCB->state) { |
| 1745 | // Flag error for using CB w/o vkEndCommandBuffer() called |
| 1746 | // TODO : How to pass cb as srcObj? |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1747 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NO_END_COMMAND_BUFFER, "DS", |
| 1748 | "You must call vkEndCommandBuffer() on CB %#" PRIxLEAST64 " before this call to vkQueueSubmit()!", reinterpret_cast<uint64_t>(pCB->commandBuffer)); |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1749 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1750 | return VK_ERROR_VALIDATION_FAILED; |
| 1751 | } |
Tobin Ehlis | c4bdde1 | 2015-05-27 14:30:06 -0600 | [diff] [blame] | 1752 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1753 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1754 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1755 | if (VK_FALSE == skipCall) |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 1756 | return dev_data->device_dispatch_table->QueueSubmit(queue, submitCount, pSubmits, fence); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 1757 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1758 | } |
| 1759 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1760 | VK_LAYER_EXPORT void VKAPI vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1761 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1762 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyFence(device, fence, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1763 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1764 | } |
| 1765 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1766 | VK_LAYER_EXPORT void VKAPI vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1767 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1768 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroySemaphore(device, semaphore, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1769 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1770 | } |
| 1771 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1772 | VK_LAYER_EXPORT void VKAPI vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1773 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1774 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyEvent(device, event, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1775 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1776 | } |
| 1777 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1778 | VK_LAYER_EXPORT void VKAPI vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1779 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1780 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyQueryPool(device, queryPool, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1781 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1782 | } |
| 1783 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1784 | VK_LAYER_EXPORT void VKAPI vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1785 | { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1786 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1787 | dev_data->device_dispatch_table->DestroyBuffer(device, buffer, pAllocator); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1788 | dev_data->bufferMap.erase(buffer); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1789 | } |
| 1790 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1791 | VK_LAYER_EXPORT void VKAPI vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1792 | { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1793 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1794 | dev_data->device_dispatch_table->DestroyBufferView(device, bufferView, pAllocator); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1795 | dev_data->bufferViewMap.erase(bufferView); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1796 | } |
| 1797 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1798 | VK_LAYER_EXPORT void VKAPI vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1799 | { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1800 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1801 | dev_data->device_dispatch_table->DestroyImage(device, image, pAllocator); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1802 | dev_data->imageMap.erase(image); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1803 | } |
| 1804 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1805 | VK_LAYER_EXPORT void VKAPI vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1806 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1807 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyImageView(device, imageView, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1808 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1809 | } |
| 1810 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1811 | VK_LAYER_EXPORT void VKAPI vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1812 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1813 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyShaderModule(device, shaderModule, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1814 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1815 | } |
| 1816 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1817 | VK_LAYER_EXPORT void VKAPI vkDestroyShader(VkDevice device, VkShader shader, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1818 | { |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 1819 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1820 | dev_data->device_dispatch_table->DestroyShader(device, shader, pAllocator); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1821 | dev_data->shaderStageMap.erase(shader); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1822 | } |
| 1823 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1824 | VK_LAYER_EXPORT void VKAPI vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1825 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1826 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyPipeline(device, pipeline, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1827 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1828 | } |
| 1829 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1830 | VK_LAYER_EXPORT void VKAPI vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1831 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1832 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyPipelineLayout(device, pipelineLayout, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1833 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1834 | } |
| 1835 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1836 | VK_LAYER_EXPORT void VKAPI vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1837 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1838 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroySampler(device, sampler, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1839 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1840 | } |
| 1841 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1842 | VK_LAYER_EXPORT void VKAPI vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1843 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1844 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1845 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1846 | } |
| 1847 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1848 | VK_LAYER_EXPORT void VKAPI vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1849 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1850 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyDescriptorPool(device, descriptorPool, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1851 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1852 | } |
| 1853 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1854 | VK_LAYER_EXPORT void VKAPI vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t count, const VkCommandBuffer *pCommandBuffers) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1855 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1856 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->FreeCommandBuffers(device, commandPool, count, pCommandBuffers); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1857 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1858 | } |
| 1859 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1860 | VK_LAYER_EXPORT void VKAPI vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1861 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1862 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyFramebuffer(device, framebuffer, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1863 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1864 | } |
| 1865 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1866 | VK_LAYER_EXPORT void VKAPI vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1867 | { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1868 | get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyRenderPass(device, renderPass, pAllocator); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 1869 | // TODO : Clean up any internal data structures using this obj. |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1870 | } |
| 1871 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1872 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer) |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1873 | { |
| 1874 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1875 | VkResult result = dev_data->device_dispatch_table->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1876 | if (VK_SUCCESS == result) { |
| 1877 | loader_platform_thread_lock_mutex(&globalLock); |
| 1878 | // TODO : This doesn't create deep copy of pQueueFamilyIndices so need to fix that if/when we want that data to be valid |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1879 | dev_data->bufferMap[*pBuffer] = unique_ptr<VkBufferCreateInfo>(new VkBufferCreateInfo(*pCreateInfo)); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1880 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1881 | } |
| 1882 | return result; |
| 1883 | } |
| 1884 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1885 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1886 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1887 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1888 | VkResult result = dev_data->device_dispatch_table->CreateBufferView(device, pCreateInfo, pAllocator, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1889 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1890 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1891 | dev_data->bufferViewMap[*pView] = unique_ptr<VkBufferViewCreateInfo>(new VkBufferViewCreateInfo(*pCreateInfo)); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1892 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1893 | } |
| 1894 | return result; |
| 1895 | } |
| 1896 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1897 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage) |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1898 | { |
| 1899 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1900 | VkResult result = dev_data->device_dispatch_table->CreateImage(device, pCreateInfo, pAllocator, pImage); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1901 | if (VK_SUCCESS == result) { |
| 1902 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1903 | dev_data->imageMap[*pImage] = unique_ptr<VkImageCreateInfo>(new VkImageCreateInfo(*pCreateInfo)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1904 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1905 | } |
| 1906 | return result; |
| 1907 | } |
| 1908 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1909 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1910 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1911 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1912 | VkResult result = dev_data->device_dispatch_table->CreateImageView(device, pCreateInfo, pAllocator, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1913 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1914 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1915 | dev_data->imageViewMap[*pView] = unique_ptr<VkImageViewCreateInfo>(new VkImageViewCreateInfo(*pCreateInfo)); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 1916 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1917 | } |
| 1918 | return result; |
| 1919 | } |
| 1920 | |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 1921 | VK_LAYER_EXPORT VkResult VKAPI vkCreateShader( |
| 1922 | VkDevice device, |
| 1923 | const VkShaderCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1924 | const VkAllocationCallbacks* pAllocator, |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 1925 | VkShader *pShader) |
| 1926 | { |
| 1927 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1928 | VkResult result = dev_data->device_dispatch_table->CreateShader(device, pCreateInfo, pAllocator, pShader); |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 1929 | |
| 1930 | if (VK_SUCCESS == result) { |
| 1931 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1932 | dev_data->shaderStageMap[*pShader] = pCreateInfo->stage; |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 1933 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1934 | } |
| 1935 | |
| 1936 | return result; |
| 1937 | } |
| 1938 | |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1939 | //TODO handle pipeline caches |
| 1940 | VkResult VKAPI vkCreatePipelineCache( |
| 1941 | VkDevice device, |
| 1942 | const VkPipelineCacheCreateInfo* pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1943 | const VkAllocationCallbacks* pAllocator, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1944 | VkPipelineCache* pPipelineCache) |
| 1945 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1946 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1947 | VkResult result = dev_data->device_dispatch_table->CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1948 | return result; |
| 1949 | } |
| 1950 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 1951 | void VKAPI vkDestroyPipelineCache( |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1952 | VkDevice device, |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1953 | VkPipelineCache pipelineCache, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1954 | const VkAllocationCallbacks* pAllocator) |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1955 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1956 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1957 | dev_data->device_dispatch_table->DestroyPipelineCache(device, pipelineCache, pAllocator); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1958 | } |
| 1959 | |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1960 | VkResult VKAPI vkGetPipelineCacheData( |
| 1961 | VkDevice device, |
| 1962 | VkPipelineCache pipelineCache, |
Chia-I Wu | b16facd | 2015-10-26 19:17:06 +0800 | [diff] [blame] | 1963 | size_t* pDataSize, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1964 | void* pData) |
| 1965 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1966 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | b16facd | 2015-10-26 19:17:06 +0800 | [diff] [blame] | 1967 | VkResult result = dev_data->device_dispatch_table->GetPipelineCacheData(device, pipelineCache, pDataSize, pData); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1968 | return result; |
| 1969 | } |
| 1970 | |
| 1971 | VkResult VKAPI vkMergePipelineCaches( |
| 1972 | VkDevice device, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1973 | VkPipelineCache dstCache, |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1974 | uint32_t srcCacheCount, |
| 1975 | const VkPipelineCache* pSrcCaches) |
| 1976 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1977 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1978 | VkResult result = dev_data->device_dispatch_table->MergePipelineCaches(device, dstCache, srcCacheCount, pSrcCaches); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1979 | return result; |
| 1980 | } |
| 1981 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1982 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1983 | { |
Courtney Goeltzenleuchter | ed89407 | 2015-09-04 13:39:59 -0600 | [diff] [blame] | 1984 | VkResult result = VK_SUCCESS; |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 1985 | //TODO What to do with pipelineCache? |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 1986 | // The order of operations here is a little convoluted but gets the job done |
| 1987 | // 1. Pipeline create state is first shadowed into PIPELINE_NODE struct |
| 1988 | // 2. Create state is then validated (which uses flags setup during shadowing) |
| 1989 | // 3. If everything looks good, we'll then create the pipeline and add NODE to pipelineMap |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 1990 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 6539977 | 2015-09-17 16:33:58 -0600 | [diff] [blame] | 1991 | // TODO : Improve this data struct w/ unique_ptrs so cleanup below is automatic |
| 1992 | vector<PIPELINE_NODE*> pPipeNode(count); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 1993 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 1994 | uint32_t i=0; |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 1995 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 1996 | for (i=0; i<count; i++) { |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 1997 | pPipeNode[i] = initPipeline(dev_data, &pCreateInfos[i], NULL); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 1998 | skipCall |= verifyPipelineCreateState(dev_data, device, pPipeNode[i]); |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 1999 | } |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 2000 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2001 | if (VK_FALSE == skipCall) { |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2002 | result = dev_data->device_dispatch_table->CreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines); |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 2003 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 2004 | for (i=0; i<count; i++) { |
| 2005 | pPipeNode[i]->pipeline = pPipelines[i]; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2006 | dev_data->pipelineMap[pPipeNode[i]->pipeline] = pPipeNode[i]; |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 2007 | } |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 2008 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2009 | } else { |
Tobin Ehlis | 11efc30 | 2015-09-16 10:33:53 -0600 | [diff] [blame] | 2010 | for (i=0; i<count; i++) { |
| 2011 | if (pPipeNode[i]) { |
| 2012 | // If we allocated a pipeNode, need to clean it up here |
| 2013 | delete[] pPipeNode[i]->pVertexBindingDescriptions; |
| 2014 | delete[] pPipeNode[i]->pVertexAttributeDescriptions; |
| 2015 | delete[] pPipeNode[i]->pAttachments; |
| 2016 | delete pPipeNode[i]; |
| 2017 | } |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 2018 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2019 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 2020 | } |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 2021 | return result; |
| 2022 | } |
| 2023 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2024 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2025 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2026 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2027 | VkResult result = dev_data->device_dispatch_table->CreateSampler(device, pCreateInfo, pAllocator, pSampler); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2028 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2029 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2030 | dev_data->sampleMap[*pSampler] = unique_ptr<SAMPLER_NODE>(new SAMPLER_NODE(pSampler, pCreateInfo)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2031 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2032 | } |
| 2033 | return result; |
| 2034 | } |
| 2035 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2036 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2037 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2038 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2039 | VkResult result = dev_data->device_dispatch_table->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2040 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2041 | LAYOUT_NODE* pNewNode = new LAYOUT_NODE; |
| 2042 | if (NULL == pNewNode) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2043 | if (log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t) *pSetLayout, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2044 | "Out of memory while attempting to allocate LAYOUT_NODE in vkCreateDescriptorSetLayout()")) |
| 2045 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2046 | } |
| 2047 | memset(pNewNode, 0, sizeof(LAYOUT_NODE)); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2048 | memcpy((void*)&pNewNode->createInfo, pCreateInfo, sizeof(VkDescriptorSetLayoutCreateInfo)); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2049 | pNewNode->createInfo.pBindings = new VkDescriptorSetLayoutBinding[pCreateInfo->bindingCount]; |
| 2050 | memcpy((void*)pNewNode->createInfo.pBindings, pCreateInfo->pBindings, sizeof(VkDescriptorSetLayoutBinding)*pCreateInfo->bindingCount); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2051 | uint32_t totalCount = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2052 | for (uint32_t i=0; i<pCreateInfo->bindingCount; i++) { |
| 2053 | totalCount += pCreateInfo->pBindings[i].arraySize; |
| 2054 | if (pCreateInfo->pBindings[i].pImmutableSamplers) { |
| 2055 | VkSampler** ppIS = (VkSampler**)&pNewNode->createInfo.pBindings[i].pImmutableSamplers; |
| 2056 | *ppIS = new VkSampler[pCreateInfo->pBindings[i].arraySize]; |
| 2057 | memcpy(*ppIS, pCreateInfo->pBindings[i].pImmutableSamplers, pCreateInfo->pBindings[i].arraySize*sizeof(VkSampler)); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2058 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2059 | } |
| 2060 | if (totalCount > 0) { |
Cody Northrop | 43751cc | 2015-10-26 14:07:35 -0600 | [diff] [blame] | 2061 | pNewNode->descriptorTypes.resize(totalCount); |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 2062 | pNewNode->stageFlags.resize(totalCount); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2063 | uint32_t offset = 0; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2064 | uint32_t j = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2065 | for (uint32_t i=0; i<pCreateInfo->bindingCount; i++) { |
| 2066 | for (j = 0; j < pCreateInfo->pBindings[i].arraySize; j++) { |
| 2067 | pNewNode->descriptorTypes[offset + j] = pCreateInfo->pBindings[i].descriptorType; |
| 2068 | pNewNode->stageFlags[offset + j] = pCreateInfo->pBindings[i].stageFlags; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2069 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2070 | offset += j; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2071 | } |
| 2072 | } |
| 2073 | pNewNode->layout = *pSetLayout; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2074 | pNewNode->startIndex = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2075 | pNewNode->endIndex = pNewNode->startIndex + totalCount - 1; |
| 2076 | assert(pNewNode->endIndex >= pNewNode->startIndex); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2077 | // Put new node at Head of global Layer list |
| 2078 | loader_platform_thread_lock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2079 | dev_data->layoutMap[*pSetLayout] = pNewNode; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2080 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2081 | } |
| 2082 | return result; |
| 2083 | } |
| 2084 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2085 | VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2086 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2087 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2088 | VkResult result = dev_data->device_dispatch_table->CreatePipelineLayout(device, pCreateInfo, pAllocator, pPipelineLayout); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2089 | if (VK_SUCCESS == result) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2090 | PIPELINE_LAYOUT_NODE plNode = dev_data->pipelineLayoutMap[*pPipelineLayout]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2091 | plNode.descriptorSetLayouts.resize(pCreateInfo->setLayoutCount); |
Tobin Ehlis | 644ff04 | 2015-10-20 10:11:55 -0600 | [diff] [blame] | 2092 | uint32_t i = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2093 | for (i=0; i<pCreateInfo->setLayoutCount; ++i) { |
Tobin Ehlis | 644ff04 | 2015-10-20 10:11:55 -0600 | [diff] [blame] | 2094 | plNode.descriptorSetLayouts[i] = pCreateInfo->pSetLayouts[i]; |
| 2095 | } |
Cody Northrop | 43751cc | 2015-10-26 14:07:35 -0600 | [diff] [blame] | 2096 | plNode.pushConstantRanges.resize(pCreateInfo->pushConstantRangeCount); |
Tobin Ehlis | 644ff04 | 2015-10-20 10:11:55 -0600 | [diff] [blame] | 2097 | for (i=0; i<pCreateInfo->pushConstantRangeCount; ++i) { |
| 2098 | plNode.pushConstantRanges[i] = pCreateInfo->pPushConstantRanges[i]; |
| 2099 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2100 | } |
| 2101 | return result; |
| 2102 | } |
| 2103 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2104 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2105 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2106 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2107 | VkResult result = dev_data->device_dispatch_table->CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2108 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2109 | // Insert this pool into Global Pool LL at head |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2110 | if (log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DESCRIPTOR_POOL, (uint64_t) *pDescriptorPool, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", |
| 2111 | "Created Descriptor Pool %#" PRIxLEAST64, (uint64_t) *pDescriptorPool)) |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2112 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2113 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2114 | POOL_NODE* pNewNode = new POOL_NODE(*pDescriptorPool, pCreateInfo); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2115 | if (NULL == pNewNode) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2116 | if (log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_POOL, (uint64_t) *pDescriptorPool, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2117 | "Out of memory while attempting to allocate POOL_NODE in vkCreateDescriptorPool()")) |
| 2118 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2119 | } else { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2120 | dev_data->poolMap[*pDescriptorPool] = pNewNode; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2121 | } |
| 2122 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2123 | } else { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2124 | // Need to do anything if pool create fails? |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2125 | } |
| 2126 | return result; |
| 2127 | } |
| 2128 | |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2129 | VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2130 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2131 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2132 | VkResult result = dev_data->device_dispatch_table->ResetDescriptorPool(device, descriptorPool, flags); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2133 | if (VK_SUCCESS == result) { |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2134 | clearDescriptorPool(dev_data, device, descriptorPool, flags); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2135 | } |
| 2136 | return result; |
| 2137 | } |
| 2138 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2139 | VK_LAYER_EXPORT VkResult VKAPI vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2140 | { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2141 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2142 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2143 | // Verify that requested descriptorSets are available in pool |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2144 | POOL_NODE *pPoolNode = getPoolNode(dev_data, pAllocateInfo->descriptorPool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2145 | if (!pPoolNode) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2146 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_POOL, (uint64_t) pAllocateInfo->descriptorPool, 0, DRAWSTATE_INVALID_POOL, "DS", |
| 2147 | "Unable to find pool node for pool %#" PRIxLEAST64 " specified in vkAllocateDescriptorSets() call", (uint64_t) pAllocateInfo->descriptorPool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2148 | } else { // Make sure pool has all the available descriptors before calling down chain |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2149 | skipCall |= validate_descriptor_availability_in_pool(dev_data, pPoolNode, pAllocateInfo->setLayoutCount, pAllocateInfo->pSetLayouts); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2150 | } |
| 2151 | if (skipCall) |
| 2152 | return VK_ERROR_VALIDATION_FAILED; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2153 | VkResult result = dev_data->device_dispatch_table->AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); |
Cody Northrop | 1e4f802 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2154 | if (VK_SUCCESS == result) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2155 | POOL_NODE *pPoolNode = getPoolNode(dev_data, pAllocateInfo->descriptorPool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2156 | if (pPoolNode) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2157 | if (pAllocateInfo->setLayoutCount == 0) { |
| 2158 | log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, pAllocateInfo->setLayoutCount, 0, DRAWSTATE_NONE, "DS", |
| 2159 | "AllocateDescriptorSets called with 0 count"); |
Cody Northrop | 1e4f802 | 2015-08-03 12:47:29 -0600 | [diff] [blame] | 2160 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2161 | for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2162 | log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", |
| 2163 | "Created Descriptor Set %#" PRIxLEAST64, (uint64_t) pDescriptorSets[i]); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2164 | // Create new set node and add to head of pool nodes |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2165 | SET_NODE* pNewNode = new SET_NODE; |
| 2166 | if (NULL == pNewNode) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2167 | if (log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDescriptorSets[i], 0, DRAWSTATE_OUT_OF_MEMORY, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2168 | "Out of memory while attempting to allocate SET_NODE in vkAllocateDescriptorSets()")) |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2169 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2170 | } else { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2171 | memset(pNewNode, 0, sizeof(SET_NODE)); |
Tobin Ehlis | 8b5b28c | 2015-10-19 12:09:13 -0600 | [diff] [blame] | 2172 | // TODO : Pool should store a total count of each type of Descriptor available |
| 2173 | // When descriptors are allocated, decrement the count and validate here |
| 2174 | // that the count doesn't go below 0. One reset/free need to bump count back up. |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2175 | // Insert set at head of Set LL for this pool |
| 2176 | pNewNode->pNext = pPoolNode->pSets; |
| 2177 | pPoolNode->pSets = pNewNode; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2178 | LAYOUT_NODE* pLayout = getLayoutNode(dev_data, pAllocateInfo->pSetLayouts[i]); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2179 | if (NULL == pLayout) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2180 | if (log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t) pAllocateInfo->pSetLayouts[i], 0, DRAWSTATE_INVALID_LAYOUT, "DS", |
| 2181 | "Unable to find set layout node for layout %#" PRIxLEAST64 " specified in vkAllocateDescriptorSets() call", (uint64_t) pAllocateInfo->pSetLayouts[i])) |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2182 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2183 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2184 | pNewNode->pLayout = pLayout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2185 | pNewNode->pool = pAllocateInfo->descriptorPool; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2186 | pNewNode->set = pDescriptorSets[i]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2187 | pNewNode->descriptorCount = pLayout->endIndex + 1; |
| 2188 | if (pNewNode->descriptorCount) { |
| 2189 | size_t descriptorArraySize = sizeof(GENERIC_HEADER*)*pNewNode->descriptorCount; |
| 2190 | pNewNode->ppDescriptors = new GENERIC_HEADER*[descriptorArraySize]; |
| 2191 | memset(pNewNode->ppDescriptors, 0, descriptorArraySize); |
| 2192 | } |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2193 | dev_data->setMap[pDescriptorSets[i]] = pNewNode; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2194 | } |
| 2195 | } |
| 2196 | } |
| 2197 | } |
| 2198 | return result; |
| 2199 | } |
| 2200 | |
Tony Barbour | 34ec692 | 2015-07-10 10:50:45 -0600 | [diff] [blame] | 2201 | VK_LAYER_EXPORT VkResult VKAPI vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) |
| 2202 | { |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2203 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2204 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2205 | POOL_NODE *pPoolNode = getPoolNode(dev_data, descriptorPool); |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2206 | if (pPoolNode && !(VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT & pPoolNode->createInfo.flags)) { |
| 2207 | // Can't Free from a NON_FREE pool |
| 2208 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DEVICE, (uint64_t)device, 0, DRAWSTATE_CANT_FREE_FROM_NON_FREE_POOL, "DS", |
| 2209 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2210 | } |
| 2211 | if (skipCall) |
| 2212 | return VK_ERROR_VALIDATION_FAILED; |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2213 | VkResult result = dev_data->device_dispatch_table->FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2214 | if (VK_SUCCESS == result) { |
| 2215 | // For each freed descriptor add it back into the pool as available |
| 2216 | for (uint32_t i=0; i<count; ++i) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2217 | SET_NODE* pSet = dev_data->setMap[pDescriptorSets[i]]; // getSetNode() without locking |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2218 | LAYOUT_NODE* pLayout = pSet->pLayout; |
| 2219 | uint32_t typeIndex = 0, typeCount = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2220 | for (uint32_t j=0; j<pLayout->createInfo.bindingCount; ++j) { |
| 2221 | typeIndex = static_cast<uint32_t>(pLayout->createInfo.pBindings[j].descriptorType); |
| 2222 | typeCount = pLayout->createInfo.pBindings[j].arraySize; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2223 | pPoolNode->availableDescriptorTypeCount[typeIndex] += typeCount; |
| 2224 | } |
| 2225 | } |
| 2226 | } |
| 2227 | // TODO : Any other clean-up or book-keeping to do here? |
Tony Barbour | 34ec692 | 2015-07-10 10:50:45 -0600 | [diff] [blame] | 2228 | return result; |
| 2229 | } |
| 2230 | |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 2231 | VK_LAYER_EXPORT void VKAPI vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2232 | { |
Tobin Ehlis | a1f9b64 | 2015-10-27 12:25:35 -0600 | [diff] [blame] | 2233 | // dsUpdate will return VK_TRUE only if a bailout error occurs, so we want to call down tree when update returns VK_FALSE |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2234 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | 40cf0ae | 2015-10-26 17:20:32 +0800 | [diff] [blame] | 2235 | if (!dsUpdate(dev_data, device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies)) { |
| 2236 | dev_data->device_dispatch_table->UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies); |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 2237 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2238 | } |
| 2239 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2240 | VK_LAYER_EXPORT VkResult VKAPI vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pCreateInfo, VkCommandBuffer* pCommandBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2241 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 2242 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2243 | VkResult result = dev_data->device_dispatch_table->AllocateCommandBuffers(device, pCreateInfo, pCommandBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2244 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2245 | loader_platform_thread_lock_mutex(&globalLock); |
| 2246 | GLOBAL_CB_NODE* pCB = new GLOBAL_CB_NODE; |
| 2247 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2248 | pCB->commandBuffer = *pCommandBuffer; |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2249 | pCB->createInfo = *pCreateInfo; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2250 | pCB->lastVtxBinding = MAX_BINDING; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2251 | pCB->level = pCreateInfo->level; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2252 | dev_data->commandBufferMap[*pCommandBuffer] = pCB; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2253 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2254 | updateCBTracking(pCB); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2255 | } |
| 2256 | return result; |
| 2257 | } |
| 2258 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2259 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2260 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2261 | VkBool32 skipCall = false; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2262 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2263 | // Validate command buffer level |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2264 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2265 | if (pCB) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2266 | if (pCB->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2267 | if (pBeginInfo->renderPass || pBeginInfo->framebuffer) { |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2268 | // These should be NULL for a Primary CB |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2269 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_BEGIN_CB_INVALID_STATE, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2270 | "vkAllocateCommandBuffers(): Primary Command Buffer (%p) may not specify framebuffer or renderpass parameters", (void*)commandBuffer); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2271 | } |
| 2272 | } else { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2273 | if (!pBeginInfo->renderPass || !pBeginInfo->framebuffer) { |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2274 | // These should NOT be null for an Secondary CB |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2275 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_BEGIN_CB_INVALID_STATE, "DS", |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2276 | "vkAllocateCommandBuffers(): Secondary Command Buffers (%p) must specify framebuffer and renderpass parameters", (void*)commandBuffer); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2277 | } |
| 2278 | } |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2279 | pCB->beginInfo = *pBeginInfo; |
| 2280 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2281 | // TODO : Need to pass commandBuffer as objType here |
| 2282 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS", |
| 2283 | "In vkBeginCommandBuffer() and unable to find CommandBuffer Node for CB %p!", (void*)commandBuffer); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2284 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2285 | if (skipCall) { |
| 2286 | return VK_ERROR_VALIDATION_FAILED; |
Courtney Goeltzenleuchter | 5fe086f | 2015-09-04 15:03:52 -0600 | [diff] [blame] | 2287 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2288 | VkResult result = dev_data->device_dispatch_table->BeginCommandBuffer(commandBuffer, pBeginInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2289 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2290 | if (CB_NEW != pCB->state) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2291 | resetCB(dev_data, commandBuffer); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2292 | pCB->state = CB_UPDATE_ACTIVE; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2293 | updateCBTracking(pCB); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2294 | } |
| 2295 | return result; |
| 2296 | } |
| 2297 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2298 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCommandBuffer commandBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2299 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2300 | VkBool32 skipCall = VK_FALSE; |
Courtney Goeltzenleuchter | ed89407 | 2015-09-04 13:39:59 -0600 | [diff] [blame] | 2301 | VkResult result = VK_SUCCESS; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2302 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2303 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Courtney Goeltzenleuchter | ed89407 | 2015-09-04 13:39:59 -0600 | [diff] [blame] | 2304 | /* TODO: preference is to always call API function after reporting any validation errors */ |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2305 | if (pCB) { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2306 | if (pCB->state != CB_UPDATE_ACTIVE) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2307 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkEndCommandBuffer()"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2308 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2309 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2310 | if (VK_FALSE == skipCall) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2311 | result = dev_data->device_dispatch_table->EndCommandBuffer(commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2312 | if (VK_SUCCESS == result) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2313 | updateCBTracking(pCB); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2314 | pCB->state = CB_UPDATE_COMPLETE; |
| 2315 | // Reset CB status flags |
| 2316 | pCB->status = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2317 | printCB(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2318 | } |
| 2319 | } else { |
| 2320 | result = VK_ERROR_VALIDATION_FAILED; |
| 2321 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2322 | return result; |
| 2323 | } |
| 2324 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2325 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2326 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2327 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2328 | VkResult result = dev_data->device_dispatch_table->ResetCommandBuffer(commandBuffer, flags); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2329 | if (VK_SUCCESS == result) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2330 | resetCB(dev_data, commandBuffer); |
| 2331 | updateCBTracking(getCBNode(dev_data, commandBuffer)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2332 | } |
| 2333 | return result; |
| 2334 | } |
| 2335 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2336 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2337 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2338 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2339 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2340 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2341 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2342 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2343 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2344 | skipCall |= addCmd(dev_data, pCB, CMD_BINDPIPELINE); |
Tobin Ehlis | 6d58e6d | 2015-06-23 08:46:18 -0600 | [diff] [blame] | 2345 | if ((VK_PIPELINE_BIND_POINT_COMPUTE == pipelineBindPoint) && (pCB->activeRenderPass)) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2346 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PIPELINE, (uint64_t) pipeline, |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2347 | 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS", |
| 2348 | "Incorrectly binding compute pipeline (%#" PRIxLEAST64 ") during active RenderPass (%#" PRIxLEAST64 ")", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2349 | (uint64_t) pipeline, (uint64_t) pCB->activeRenderPass); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2350 | } else if ((VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) && (!pCB->activeRenderPass)) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2351 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PIPELINE, (uint64_t) pipeline, |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2352 | 0, DRAWSTATE_NO_ACTIVE_RENDERPASS, "DS", "Incorrectly binding graphics pipeline " |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2353 | " (%#" PRIxLEAST64 ") without an active RenderPass", (uint64_t) pipeline); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2354 | } else { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2355 | PIPELINE_NODE* pPN = getPipeline(dev_data, pipeline); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2356 | if (pPN) { |
| 2357 | pCB->lastBoundPipeline = pipeline; |
| 2358 | loader_platform_thread_lock_mutex(&globalLock); |
| 2359 | set_cb_pso_status(pCB, pPN); |
| 2360 | g_lastBoundPipeline = pPN; |
| 2361 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2362 | skipCall |= validatePipelineState(dev_data, pCB, pipelineBindPoint, pipeline); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2363 | } else { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2364 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PIPELINE, (uint64_t) pipeline, |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2365 | 0, DRAWSTATE_INVALID_PIPELINE, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2366 | "Attempt to bind Pipeline %#" PRIxLEAST64 " that doesn't exist!", (void*)pipeline); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2367 | } |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2368 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2369 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2370 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindPipeline()"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2371 | } |
| 2372 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2373 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2374 | dev_data->device_dispatch_table->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2375 | } |
| 2376 | |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2377 | VK_LAYER_EXPORT void VKAPI vkCmdSetViewport( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2378 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2379 | uint32_t viewportCount, |
| 2380 | const VkViewport* pViewports) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2381 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2382 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2383 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2384 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2385 | if (pCB) { |
| 2386 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2387 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2388 | skipCall |= addCmd(dev_data, pCB, CMD_SETVIEWPORTSTATE); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2389 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2390 | pCB->status |= CBSTATUS_VIEWPORT_SET; |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2391 | pCB->viewports.resize(viewportCount); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2392 | memcpy(pCB->viewports.data(), pViewports, viewportCount * sizeof(VkViewport)); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2393 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2394 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2395 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetViewport()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2396 | } |
| 2397 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2398 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2399 | dev_data->device_dispatch_table->CmdSetViewport(commandBuffer, viewportCount, pViewports); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2400 | } |
| 2401 | |
| 2402 | VK_LAYER_EXPORT void VKAPI vkCmdSetScissor( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2403 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2404 | uint32_t scissorCount, |
| 2405 | const VkRect2D* pScissors) |
| 2406 | { |
| 2407 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2408 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2409 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2410 | if (pCB) { |
| 2411 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2412 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2413 | skipCall |= addCmd(dev_data, pCB, CMD_SETSCISSORSTATE); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2414 | loader_platform_thread_lock_mutex(&globalLock); |
| 2415 | pCB->status |= CBSTATUS_SCISSOR_SET; |
| 2416 | pCB->scissors.resize(scissorCount); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2417 | memcpy(pCB->scissors.data(), pScissors, scissorCount * sizeof(VkRect2D)); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2418 | loader_platform_thread_unlock_mutex(&globalLock); |
| 2419 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2420 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetScissor()"); |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 2421 | } |
| 2422 | } |
| 2423 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2424 | dev_data->device_dispatch_table->CmdSetScissor(commandBuffer, scissorCount, pScissors); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2425 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2426 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2427 | VK_LAYER_EXPORT void VKAPI vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2428 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2429 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2430 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2431 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2432 | if (pCB) { |
| 2433 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2434 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2435 | skipCall |= addCmd(dev_data, pCB, CMD_SETLINEWIDTHSTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2436 | /* TODO: Do we still need this lock? */ |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2437 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2438 | pCB->status |= CBSTATUS_LINE_WIDTH_SET; |
| 2439 | pCB->lineWidth = lineWidth; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2440 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2441 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2442 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindDynamicLineWidthState()"); |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 2443 | } |
| 2444 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2445 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2446 | dev_data->device_dispatch_table->CmdSetLineWidth(commandBuffer, lineWidth); |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 2447 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2448 | |
| 2449 | VK_LAYER_EXPORT void VKAPI vkCmdSetDepthBias( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2450 | VkCommandBuffer commandBuffer, |
Chia-I Wu | d8c946a | 2015-10-26 19:08:09 +0800 | [diff] [blame] | 2451 | float depthBiasConstantFactor, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2452 | float depthBiasClamp, |
Chia-I Wu | d8c946a | 2015-10-26 19:08:09 +0800 | [diff] [blame] | 2453 | float depthBiasSlopeFactor) |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 2454 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2455 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2456 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2457 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 2458 | if (pCB) { |
| 2459 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2460 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2461 | skipCall |= addCmd(dev_data, pCB, CMD_SETDEPTHBIASSTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2462 | pCB->status |= CBSTATUS_DEPTH_BIAS_SET; |
Chia-I Wu | d8c946a | 2015-10-26 19:08:09 +0800 | [diff] [blame] | 2463 | pCB->depthBiasConstantFactor = depthBiasConstantFactor; |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2464 | pCB->depthBiasClamp = depthBiasClamp; |
Chia-I Wu | d8c946a | 2015-10-26 19:08:09 +0800 | [diff] [blame] | 2465 | pCB->depthBiasSlopeFactor = depthBiasSlopeFactor; |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 2466 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2467 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetDepthBias()"); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2468 | } |
| 2469 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2470 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2471 | dev_data->device_dispatch_table->CmdSetDepthBias(commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2472 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2473 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2474 | VK_LAYER_EXPORT void VKAPI vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4]) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2475 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2476 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2477 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2478 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2479 | if (pCB) { |
| 2480 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2481 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2482 | skipCall |= addCmd(dev_data, pCB, CMD_SETBLENDSTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2483 | pCB->status |= CBSTATUS_BLEND_SET; |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 2484 | memcpy(pCB->blendConstants, blendConstants, 4 * sizeof(float)); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2485 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2486 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetBlendConstants()"); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2487 | } |
| 2488 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2489 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2490 | dev_data->device_dispatch_table->CmdSetBlendConstants(commandBuffer, blendConstants); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2491 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2492 | |
| 2493 | VK_LAYER_EXPORT void VKAPI vkCmdSetDepthBounds( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2494 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2495 | float minDepthBounds, |
| 2496 | float maxDepthBounds) |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2497 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2498 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2499 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2500 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2501 | if (pCB) { |
| 2502 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2503 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2504 | skipCall |= addCmd(dev_data, pCB, CMD_SETDEPTHBOUNDSSTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2505 | pCB->status |= CBSTATUS_DEPTH_BOUNDS_SET; |
| 2506 | pCB->minDepthBounds = minDepthBounds; |
| 2507 | pCB->maxDepthBounds = maxDepthBounds; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2508 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2509 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetDepthBounds()"); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 2510 | } |
| 2511 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2512 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2513 | dev_data->device_dispatch_table->CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 2514 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2515 | |
| 2516 | VK_LAYER_EXPORT void VKAPI vkCmdSetStencilCompareMask( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2517 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2518 | VkStencilFaceFlags faceMask, |
| 2519 | uint32_t stencilCompareMask) |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 2520 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2521 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2522 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2523 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 2524 | if (pCB) { |
| 2525 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2526 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2527 | skipCall |= addCmd(dev_data, pCB, CMD_SETSTENCILREADMASKSTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2528 | if (faceMask & VK_STENCIL_FACE_FRONT_BIT) { |
| 2529 | pCB->front.stencilCompareMask = stencilCompareMask; |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 2530 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2531 | if (faceMask & VK_STENCIL_FACE_BACK_BIT) { |
| 2532 | pCB->back.stencilCompareMask = stencilCompareMask; |
| 2533 | } |
| 2534 | /* TODO: Do we need to track front and back separately? */ |
| 2535 | /* TODO: We aren't capturing the faceMask, do we need to? */ |
| 2536 | pCB->status |= CBSTATUS_STENCIL_READ_MASK_SET; |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 2537 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2538 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetStencilCompareMask()"); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2539 | } |
| 2540 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2541 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2542 | dev_data->device_dispatch_table->CmdSetStencilCompareMask(commandBuffer, faceMask, stencilCompareMask); |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 2543 | } |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2544 | |
| 2545 | VK_LAYER_EXPORT void VKAPI vkCmdSetStencilWriteMask( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2546 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2547 | VkStencilFaceFlags faceMask, |
| 2548 | uint32_t stencilWriteMask) |
| 2549 | { |
| 2550 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2551 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2552 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2553 | if (pCB) { |
| 2554 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2555 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2556 | skipCall |= addCmd(dev_data, pCB, CMD_SETSTENCILWRITEMASKSTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2557 | if (faceMask & VK_STENCIL_FACE_FRONT_BIT) { |
| 2558 | pCB->front.stencilWriteMask = stencilWriteMask; |
| 2559 | } |
| 2560 | if (faceMask & VK_STENCIL_FACE_BACK_BIT) { |
| 2561 | pCB->back.stencilWriteMask = stencilWriteMask; |
| 2562 | } |
| 2563 | pCB->status |= CBSTATUS_STENCIL_WRITE_MASK_SET; |
| 2564 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2565 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetStencilWriteMask()"); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2566 | } |
| 2567 | } |
| 2568 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2569 | dev_data->device_dispatch_table->CmdSetStencilWriteMask(commandBuffer, faceMask, stencilWriteMask); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2570 | } |
| 2571 | |
| 2572 | VK_LAYER_EXPORT void VKAPI vkCmdSetStencilReference( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2573 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2574 | VkStencilFaceFlags faceMask, |
| 2575 | uint32_t stencilReference) |
| 2576 | { |
| 2577 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2578 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2579 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2580 | if (pCB) { |
| 2581 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2582 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2583 | skipCall |= addCmd(dev_data, pCB, CMD_SETSTENCILREFERENCESTATE); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2584 | if (faceMask & VK_STENCIL_FACE_FRONT_BIT) { |
| 2585 | pCB->front.stencilReference = stencilReference; |
| 2586 | } |
| 2587 | if (faceMask & VK_STENCIL_FACE_BACK_BIT) { |
| 2588 | pCB->back.stencilReference = stencilReference; |
| 2589 | } |
| 2590 | pCB->status |= CBSTATUS_STENCIL_REFERENCE_SET; |
| 2591 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2592 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetStencilReference()"); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2593 | } |
| 2594 | } |
| 2595 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2596 | dev_data->device_dispatch_table->CmdSetStencilReference(commandBuffer, faceMask, stencilReference); |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 2597 | } |
| 2598 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2599 | VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2600 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2601 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2602 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2603 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 1a4b9e7 | 2015-10-20 09:13:54 -0600 | [diff] [blame] | 2604 | // TODO : Validate dynamic offsets |
| 2605 | // If any of the sets being bound include dynamic uniform or storage buffers, |
| 2606 | // then pDynamicOffsets must include one element for each array element |
| 2607 | // in each dynamic descriptor type binding in each set. |
| 2608 | // dynamicOffsetCount is the total number of dynamic offsets provided, and |
| 2609 | // must equal the total number of dynamic descriptors in the sets being bound |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2610 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2611 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2612 | if ((VK_PIPELINE_BIND_POINT_COMPUTE == pipelineBindPoint) && (pCB->activeRenderPass)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2613 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS", |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2614 | "Incorrectly binding compute DescriptorSets during active RenderPass (%#" PRIxLEAST64 ")", (uint64_t) pCB->activeRenderPass); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2615 | } else if ((VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) && (!pCB->activeRenderPass)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2616 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NO_ACTIVE_RENDERPASS, "DS", |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2617 | "Incorrectly binding graphics DescriptorSets without an active RenderPass"); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 2618 | } else { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2619 | for (uint32_t i=0; i<setCount; i++) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2620 | SET_NODE* pSet = getSetNode(dev_data, pDescriptorSets[i]); |
Tobin Ehlis | 3e75b2a | 2015-06-24 17:27:33 -0600 | [diff] [blame] | 2621 | if (pSet) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2622 | loader_platform_thread_lock_mutex(&globalLock); |
| 2623 | pCB->lastBoundDescriptorSet = pDescriptorSets[i]; |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 2624 | pCB->lastBoundPipelineLayout = layout; |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2625 | pCB->boundDescriptorSets.push_back(pDescriptorSets[i]); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2626 | loader_platform_thread_unlock_mutex(&globalLock); |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2627 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", |
| 2628 | "DS %#" PRIxLEAST64 " bound on pipeline %s", (uint64_t) pDescriptorSets[i], string_VkPipelineBindPoint(pipelineBindPoint)); |
Tobin Ehlis | 3e75b2a | 2015-06-24 17:27:33 -0600 | [diff] [blame] | 2629 | if (!pSet->pUpdateStructs) |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2630 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDescriptorSets[i], 0, DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", |
| 2631 | "DS %#" PRIxLEAST64 " bound but it was never updated. You may want to either update it or not bind it.", (uint64_t) pDescriptorSets[i]); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2632 | } else { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 2633 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t) pDescriptorSets[i], 0, DRAWSTATE_INVALID_SET, "DS", |
| 2634 | "Attempt to bind DS %#" PRIxLEAST64 " that doesn't exist!", (uint64_t) pDescriptorSets[i]); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2635 | } |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 2636 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2637 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2638 | skipCall |= addCmd(dev_data, pCB, CMD_BINDDESCRIPTORSETS); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2639 | } |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2640 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2641 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindDescriptorSets()"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2642 | } |
| 2643 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2644 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2645 | dev_data->device_dispatch_table->CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2646 | } |
| 2647 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2648 | VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2649 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2650 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2651 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2652 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2653 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2654 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2655 | VkDeviceSize offset_align = 0; |
| 2656 | switch (indexType) { |
| 2657 | case VK_INDEX_TYPE_UINT16: |
| 2658 | offset_align = 2; |
| 2659 | break; |
| 2660 | case VK_INDEX_TYPE_UINT32: |
| 2661 | offset_align = 4; |
| 2662 | break; |
| 2663 | default: |
| 2664 | // ParamChecker should catch bad enum, we'll also throw alignment error below if offset_align stays 0 |
| 2665 | break; |
| 2666 | } |
| 2667 | if (!offset_align || (offset % offset_align)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2668 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_VTX_INDEX_ALIGNMENT_ERROR, "DS", |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2669 | "vkCmdBindIndexBuffer() offset (%#" PRIxLEAST64 ") does not fall on alignment (%s) boundary.", offset, string_VkIndexType(indexType)); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 2670 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2671 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2672 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindIndexBuffer()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2673 | } |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2674 | pCB->status |= CBSTATUS_INDEX_BUFFER_BOUND; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2675 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2676 | skipCall |= addCmd(dev_data, pCB, CMD_BINDINDEXBUFFER); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2677 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2678 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2679 | dev_data->device_dispatch_table->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2680 | } |
| 2681 | |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2682 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2683 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2684 | uint32_t startBinding, |
| 2685 | uint32_t bindingCount, |
| 2686 | const VkBuffer* pBuffers, |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2687 | const VkDeviceSize* pOffsets) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2688 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2689 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2690 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2691 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2692 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2693 | if (pCB->state == CB_UPDATE_ACTIVE) { |
| 2694 | /* TODO: Need to track all the vertex buffers, not just last one */ |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 2695 | pCB->lastVtxBinding = startBinding + bindingCount -1; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2696 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2697 | addCmd(dev_data, pCB, CMD_BINDVERTEXBUFFER); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2698 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2699 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindVertexBuffer()"); |
Tobin Ehlis | 0174fed | 2015-05-28 12:10:17 -0600 | [diff] [blame] | 2700 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2701 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2702 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2703 | dev_data->device_dispatch_table->CmdBindVertexBuffers(commandBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2704 | } |
| 2705 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2706 | VK_LAYER_EXPORT void VKAPI vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2707 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2708 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2709 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2710 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2711 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2712 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2713 | pCB->drawCount[DRAW]++; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2714 | skipCall |= validate_draw_state(dev_data, pCB, VK_FALSE); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2715 | // TODO : Need to pass commandBuffer as srcObj here |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2716 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2717 | "vkCmdDraw() call #%lu, reporting DS state:", g_drawCount[DRAW]++); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2718 | skipCall |= synchAndPrintDSConfig(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2719 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2720 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2721 | skipCall |= addCmd(dev_data, pCB, CMD_DRAW); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2722 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2723 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2724 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdDraw()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2725 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2726 | skipCall |= outsideRenderPass(dev_data, pCB, "vkCmdDraw"); |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 2727 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2728 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2729 | dev_data->device_dispatch_table->CmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2730 | } |
| 2731 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2732 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2733 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2734 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2735 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2736 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2737 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2738 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2739 | pCB->drawCount[DRAW_INDEXED]++; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2740 | skipCall |= validate_draw_state(dev_data, pCB, VK_TRUE); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2741 | // TODO : Need to pass commandBuffer as srcObj here |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2742 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2743 | "vkCmdDrawIndexed() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED]++); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2744 | skipCall |= synchAndPrintDSConfig(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2745 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2746 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2747 | skipCall |= addCmd(dev_data, pCB, CMD_DRAWINDEXED); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2748 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2749 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2750 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdDrawIndexed()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2751 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2752 | skipCall |= outsideRenderPass(dev_data, pCB, "vkCmdDrawIndexed"); |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 2753 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2754 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2755 | dev_data->device_dispatch_table->CmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2756 | } |
| 2757 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2758 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2759 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2760 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2761 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2762 | VkBool32 skipCall = VK_FALSE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2763 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2764 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2765 | pCB->drawCount[DRAW_INDIRECT]++; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2766 | skipCall |= validate_draw_state(dev_data, pCB, VK_FALSE); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2767 | // TODO : Need to pass commandBuffer as srcObj here |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2768 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2769 | "vkCmdDrawIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDIRECT]++); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2770 | skipCall |= synchAndPrintDSConfig(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2771 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2772 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2773 | skipCall |= addCmd(dev_data, pCB, CMD_DRAWINDIRECT); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2774 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2775 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2776 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdDrawIndirect()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2777 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2778 | skipCall |= outsideRenderPass(dev_data, pCB, "vkCmdDrawIndirect"); |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 2779 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2780 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2781 | dev_data->device_dispatch_table->CmdDrawIndirect(commandBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2782 | } |
| 2783 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2784 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2785 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2786 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2787 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2788 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2789 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2790 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2791 | pCB->drawCount[DRAW_INDEXED_INDIRECT]++; |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2792 | skipCall |= validate_draw_state(dev_data, pCB, VK_TRUE); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2793 | // TODO : Need to pass commandBuffer as srcObj here |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2794 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_INFO_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_NONE, "DS", |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2795 | "vkCmdDrawIndexedIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED_INDIRECT]++); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2796 | skipCall |= synchAndPrintDSConfig(dev_data, commandBuffer); |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2797 | if (VK_FALSE == skipCall) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2798 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2799 | skipCall |= addCmd(dev_data, pCB, CMD_DRAWINDEXEDINDIRECT); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2800 | } |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2801 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2802 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdDrawIndexedIndirect()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2803 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2804 | skipCall |= outsideRenderPass(dev_data, pCB, "vkCmdDrawIndexedIndirect"); |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 2805 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2806 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2807 | dev_data->device_dispatch_table->CmdDrawIndexedIndirect(commandBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2808 | } |
| 2809 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2810 | VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2811 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2812 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2813 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2814 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2815 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2816 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2817 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2818 | skipCall |= addCmd(dev_data, pCB, CMD_DISPATCH); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2819 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2820 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdDispatch()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2821 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2822 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdDispatch"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2823 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2824 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2825 | dev_data->device_dispatch_table->CmdDispatch(commandBuffer, x, y, z); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2826 | } |
| 2827 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2828 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2829 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2830 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2831 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2832 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2833 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2834 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2835 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2836 | skipCall |= addCmd(dev_data, pCB, CMD_DISPATCHINDIRECT); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2837 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2838 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdDispatchIndirect()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2839 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2840 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdDispatchIndirect"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2841 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2842 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2843 | dev_data->device_dispatch_table->CmdDispatchIndirect(commandBuffer, buffer, offset); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2844 | } |
| 2845 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2846 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2847 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2848 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2849 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2850 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2851 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2852 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2853 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2854 | skipCall |= addCmd(dev_data, pCB, CMD_COPYBUFFER); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2855 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2856 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdCopyBuffer()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2857 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2858 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyBuffer"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2859 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2860 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2861 | dev_data->device_dispatch_table->CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2862 | } |
| 2863 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2864 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2865 | VkImage srcImage, |
| 2866 | VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2867 | VkImage dstImage, |
| 2868 | VkImageLayout dstImageLayout, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2869 | uint32_t regionCount, const VkImageCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2870 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2871 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2872 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2873 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2874 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2875 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2876 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2877 | skipCall |= addCmd(dev_data, pCB, CMD_COPYIMAGE); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2878 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2879 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdCopyImage()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2880 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2881 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyImage"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2882 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2883 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2884 | dev_data->device_dispatch_table->CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2885 | } |
| 2886 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2887 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2888 | VkImage srcImage, VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2889 | VkImage dstImage, VkImageLayout dstImageLayout, |
Mark Lobodzinski | ee5eef1 | 2015-05-22 14:43:25 -0500 | [diff] [blame] | 2890 | uint32_t regionCount, const VkImageBlit* pRegions, |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2891 | VkFilter filter) |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2892 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2893 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2894 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2895 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2896 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2897 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2898 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2899 | skipCall |= addCmd(dev_data, pCB, CMD_BLITIMAGE); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2900 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2901 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBlitImage()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2902 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2903 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdBlitImage"); |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2904 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2905 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2906 | dev_data->device_dispatch_table->CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter); |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2907 | } |
| 2908 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2909 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2910 | VkBuffer srcBuffer, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2911 | VkImage dstImage, VkImageLayout dstImageLayout, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2912 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2913 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2914 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2915 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2916 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2917 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2918 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2919 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2920 | skipCall |= addCmd(dev_data, pCB, CMD_COPYBUFFERTOIMAGE); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2921 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2922 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdCopyBufferToImage()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2923 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2924 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyBufferToImage"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2925 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2926 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2927 | dev_data->device_dispatch_table->CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2928 | } |
| 2929 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2930 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2931 | VkImage srcImage, VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2932 | VkBuffer dstBuffer, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2933 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2934 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2935 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2936 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2937 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2938 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2939 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2940 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2941 | skipCall |= addCmd(dev_data, pCB, CMD_COPYIMAGETOBUFFER); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2942 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2943 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdCopyImageToBuffer()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2944 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2945 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyImageToBuffer"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2946 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2947 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2948 | dev_data->device_dispatch_table->CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2949 | } |
| 2950 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2951 | VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const uint32_t* pData) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2952 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2953 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2954 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2955 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2956 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2957 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2958 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2959 | skipCall |= addCmd(dev_data, pCB, CMD_UPDATEBUFFER); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2960 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2961 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdUpdateBuffer()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2962 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2963 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyUpdateBuffer"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2964 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2965 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2966 | dev_data->device_dispatch_table->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2967 | } |
| 2968 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2969 | VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2970 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2971 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2972 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2973 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2974 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2975 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 2976 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2977 | skipCall |= addCmd(dev_data, pCB, CMD_FILLBUFFER); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 2978 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2979 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdFillBuffer()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 2980 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 2981 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyFillBuffer"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2982 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2983 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2984 | dev_data->device_dispatch_table->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2985 | } |
| 2986 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2987 | VK_LAYER_EXPORT void VKAPI vkCmdClearAttachments( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2988 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2989 | uint32_t attachmentCount, |
| 2990 | const VkClearAttachment* pAttachments, |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2991 | uint32_t rectCount, |
Courtney Goeltzenleuchter | 4ca43f6 | 2015-10-15 18:22:08 -0600 | [diff] [blame] | 2992 | const VkClearRect* pRects) |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2993 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 2994 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2995 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 2996 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 2997 | if (pCB) { |
| 2998 | if (pCB->state == CB_UPDATE_ACTIVE) { |
| 2999 | // Warn if this is issued prior to Draw Cmd |
| 3000 | if (!hasDrawCmd(pCB)) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3001 | // TODO : commandBuffer should be srcObj |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3002 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, "DS", |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3003 | "vkCmdClearAttachments() issued on CB object 0x%" PRIxLEAST64 " prior to any Draw Cmds." |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3004 | " It is recommended you use RenderPass LOAD_OP_CLEAR on Attachments prior to any Draw.", reinterpret_cast<uint64_t>(commandBuffer)); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3005 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3006 | updateCBTracking(pCB); |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3007 | skipCall |= addCmd(dev_data, pCB, CMD_CLEARATTACHMENTS); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3008 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3009 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdClearAttachments()"); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3010 | } |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3011 | skipCall |= outsideRenderPass(dev_data, pCB, "vkCmdClearAttachments"); |
| 3012 | } |
| 3013 | |
| 3014 | // Validate that attachment is in reference list of active subpass |
| 3015 | if (pCB->activeRenderPass) { |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3016 | const VkRenderPassCreateInfo *pRPCI = dev_data->renderPassMap[pCB->activeRenderPass]; |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3017 | const VkSubpassDescription *pSD = &pRPCI->pSubpasses[pCB->activeSubpass]; |
| 3018 | |
| 3019 | for (uint32_t attachment_idx = 0; attachment_idx < attachmentCount; attachment_idx++) { |
| 3020 | const VkClearAttachment *attachment = &pAttachments[attachment_idx]; |
| 3021 | if (attachment->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { |
| 3022 | VkBool32 found = VK_FALSE; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3023 | for (uint32_t i = 0; i < pSD->colorAttachmentCount; i++) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3024 | if (attachment->colorAttachment == pSD->pColorAttachments[i].attachment) { |
| 3025 | found = VK_TRUE; |
| 3026 | break; |
| 3027 | } |
| 3028 | } |
| 3029 | if (VK_FALSE == found) { |
| 3030 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3031 | (uint64_t)commandBuffer, 0, DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS", |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3032 | "vkCmdClearAttachments() attachment index %d not found in attachment reference array of active subpass %d", |
| 3033 | attachment->colorAttachment, pCB->activeSubpass); |
| 3034 | } |
| 3035 | } else if (attachment->aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { |
| 3036 | /* TODO: Is this a good test for depth/stencil? */ |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3037 | if (!pSD->pDepthStencilAttachment || pSD->pDepthStencilAttachment->attachment != attachment->colorAttachment) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3038 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3039 | (uint64_t)commandBuffer, 0, DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS", |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3040 | "vkCmdClearAttachments() attachment index %d does not match depthStencilAttachment.attachment (%d) found in active subpass %d", |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3041 | attachment->colorAttachment, |
| 3042 | (pSD->pDepthStencilAttachment) ? pSD->pDepthStencilAttachment->attachment : VK_ATTACHMENT_UNUSED, |
| 3043 | pCB->activeSubpass); |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3044 | } |
| 3045 | } |
| 3046 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3047 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3048 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3049 | dev_data->device_dispatch_table->CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount, pRects); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3050 | } |
| 3051 | |
Courtney Goeltzenleuchter | d7a5cff | 2015-04-23 17:49:22 -0600 | [diff] [blame] | 3052 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3053 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | d7a5cff | 2015-04-23 17:49:22 -0600 | [diff] [blame] | 3054 | VkImage image, VkImageLayout imageLayout, |
Chris Forbes | f0796e1 | 2015-06-24 14:34:53 +1200 | [diff] [blame] | 3055 | const VkClearColorValue *pColor, |
Courtney Goeltzenleuchter | d7a5cff | 2015-04-23 17:49:22 -0600 | [diff] [blame] | 3056 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3057 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3058 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3059 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3060 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3061 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3062 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3063 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3064 | skipCall |= addCmd(dev_data, pCB, CMD_CLEARCOLORIMAGE); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3065 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3066 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdClearColorImage()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3067 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3068 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdClearColorImage"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3069 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3070 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3071 | dev_data->device_dispatch_table->CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3072 | } |
| 3073 | |
Courtney Goeltzenleuchter | 45df9e1 | 2015-09-15 18:03:22 -0600 | [diff] [blame] | 3074 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencilImage( |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3075 | VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | 45df9e1 | 2015-09-15 18:03:22 -0600 | [diff] [blame] | 3076 | VkImage image, VkImageLayout imageLayout, |
| 3077 | const VkClearDepthStencilValue *pDepthStencil, |
| 3078 | uint32_t rangeCount, |
| 3079 | const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3080 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3081 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3082 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3083 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3084 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3085 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3086 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3087 | skipCall |= addCmd(dev_data, pCB, CMD_CLEARDEPTHSTENCILIMAGE); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3088 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3089 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdClearDepthStencilImage()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3090 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3091 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdClearDepthStencilImage"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3092 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3093 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3094 | dev_data->device_dispatch_table->CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3095 | } |
| 3096 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3097 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCommandBuffer commandBuffer, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 3098 | VkImage srcImage, VkImageLayout srcImageLayout, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3099 | VkImage dstImage, VkImageLayout dstImageLayout, |
Tony Barbour | 6865d4a | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 3100 | uint32_t regionCount, const VkImageResolve* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3101 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3102 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3103 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3104 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3105 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3106 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3107 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3108 | skipCall |= addCmd(dev_data, pCB, CMD_RESOLVEIMAGE); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3109 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3110 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdResolveImage()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3111 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3112 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdResolveImage"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3113 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3114 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3115 | dev_data->device_dispatch_table->CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3116 | } |
| 3117 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3118 | VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3119 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3120 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3121 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3122 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3123 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3124 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3125 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3126 | skipCall |= addCmd(dev_data, pCB, CMD_SETEVENT); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3127 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3128 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdSetEvent()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3129 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3130 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdSetEvent"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3131 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3132 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3133 | dev_data->device_dispatch_table->CmdSetEvent(commandBuffer, event, stageMask); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3134 | } |
| 3135 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3136 | VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3137 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3138 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3139 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3140 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3141 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3142 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3143 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3144 | skipCall |= addCmd(dev_data, pCB, CMD_RESETEVENT); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3145 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3146 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdResetEvent()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3147 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3148 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdResetEvent"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3149 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3150 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3151 | dev_data->device_dispatch_table->CmdResetEvent(commandBuffer, event, stageMask); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3152 | } |
| 3153 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3154 | VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const void* const* ppMemoryBarriers) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3155 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3156 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3157 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3158 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3159 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3160 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3161 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3162 | skipCall |= addCmd(dev_data, pCB, CMD_WAITEVENTS); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3163 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3164 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdWaitEvents()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3165 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3166 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3167 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3168 | dev_data->device_dispatch_table->CmdWaitEvents(commandBuffer, eventCount, pEvents, sourceStageMask, dstStageMask, memoryBarrierCount, ppMemoryBarriers); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3169 | } |
| 3170 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3171 | VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const void* const* ppMemoryBarriers) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3172 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3173 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3174 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3175 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3176 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3177 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3178 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3179 | skipCall |= addCmd(dev_data, pCB, CMD_PIPELINEBARRIER); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3180 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3181 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdPipelineBarrier()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3182 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3183 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3184 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3185 | dev_data->device_dispatch_table->CmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, ppMemoryBarriers); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3186 | } |
| 3187 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3188 | VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3189 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3190 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3191 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3192 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3193 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3194 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3195 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3196 | skipCall |= addCmd(dev_data, pCB, CMD_BEGINQUERY); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3197 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3198 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBeginQuery()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3199 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3200 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3201 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3202 | dev_data->device_dispatch_table->CmdBeginQuery(commandBuffer, queryPool, slot, flags); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3203 | } |
| 3204 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3205 | VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t slot) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3206 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3207 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3208 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3209 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3210 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3211 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3212 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3213 | skipCall |= addCmd(dev_data, pCB, CMD_ENDQUERY); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3214 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3215 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdEndQuery()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3216 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3217 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3218 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3219 | dev_data->device_dispatch_table->CmdEndQuery(commandBuffer, queryPool, slot); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3220 | } |
| 3221 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3222 | VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3223 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3224 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3225 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3226 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3227 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3228 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3229 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3230 | skipCall |= addCmd(dev_data, pCB, CMD_RESETQUERYPOOL); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3231 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3232 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdResetQueryPool()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3233 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3234 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdQueryPool"); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3235 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3236 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3237 | dev_data->device_dispatch_table->CmdResetQueryPool(commandBuffer, queryPool, startQuery, queryCount); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3238 | } |
| 3239 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3240 | VK_LAYER_EXPORT void VKAPI vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t startQuery, |
| 3241 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Chia-I Wu | ccc93a7 | 2015-10-26 18:36:20 +0800 | [diff] [blame] | 3242 | VkDeviceSize stride, VkQueryResultFlags flags) |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3243 | { |
| 3244 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3245 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3246 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3247 | if (pCB) { |
| 3248 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3249 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3250 | skipCall |= addCmd(dev_data, pCB, CMD_COPYQUERYPOOLRESULTS); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3251 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3252 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdCopyQueryPoolResults()"); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3253 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3254 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdCopyQueryPoolResults"); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3255 | } |
| 3256 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3257 | dev_data->device_dispatch_table->CmdCopyQueryPoolResults(commandBuffer, queryPool, |
| 3258 | startQuery, queryCount, dstBuffer, dstOffset, stride, flags); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3259 | } |
| 3260 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3261 | VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t slot) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3262 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3263 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3264 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3265 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3266 | if (pCB) { |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3267 | if (pCB->state == CB_UPDATE_ACTIVE) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3268 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3269 | skipCall |= addCmd(dev_data, pCB, CMD_WRITETIMESTAMP); |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3270 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3271 | skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdWriteTimestamp()"); |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 3272 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3273 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3274 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3275 | dev_data->device_dispatch_table->CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, slot); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3276 | } |
| 3277 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3278 | VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer) |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3279 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3280 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3281 | VkResult result = dev_data->device_dispatch_table->CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3282 | if (VK_SUCCESS == result) { |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3283 | // Shadow create info and store in map |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 3284 | VkFramebufferCreateInfo* localFBCI = new VkFramebufferCreateInfo(*pCreateInfo); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3285 | if (pCreateInfo->pAttachments) { |
Courtney Goeltzenleuchter | 5861a1b | 2015-09-01 17:30:39 -0600 | [diff] [blame] | 3286 | localFBCI->pAttachments = new VkImageView[localFBCI->attachmentCount]; |
| 3287 | memcpy((void*)localFBCI->pAttachments, pCreateInfo->pAttachments, localFBCI->attachmentCount*sizeof(VkImageView)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3288 | } |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3289 | dev_data->frameBufferMap[*pFramebuffer] = localFBCI; |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3290 | } |
| 3291 | return result; |
| 3292 | } |
| 3293 | |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3294 | // Store the DAG. |
| 3295 | struct DAGNode { |
| 3296 | uint32_t pass; |
| 3297 | std::vector<uint32_t> prev; |
| 3298 | std::vector<uint32_t> next; |
| 3299 | }; |
| 3300 | |
| 3301 | bool FindDependency(const int index, const int dependent, const std::vector<DAGNode>& subpass_to_node, std::unordered_set<uint32_t>& processed_nodes) { |
| 3302 | // If we have already checked this node we have not found a dependency path so return false. |
| 3303 | if (processed_nodes.count(index)) |
| 3304 | return false; |
| 3305 | processed_nodes.insert(index); |
| 3306 | const DAGNode& node = subpass_to_node[index]; |
| 3307 | // Look for a dependency path. If one exists return true else recurse on the previous nodes. |
| 3308 | if (std::find(node.prev.begin(), node.prev.end(), dependent) == node.prev.end()) { |
| 3309 | for (auto elem : node.prev) { |
| 3310 | if (FindDependency(elem, dependent, subpass_to_node, processed_nodes)) |
| 3311 | return true; |
| 3312 | } |
| 3313 | } else { |
| 3314 | return true; |
| 3315 | } |
| 3316 | return false; |
| 3317 | } |
| 3318 | |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3319 | bool CheckDependencyExists(const layer_data* my_data, VkDevice device, const int subpass, const std::vector<uint32_t>& dependent_subpasses, const std::vector<DAGNode>& subpass_to_node, bool& skip_call) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3320 | bool result = true; |
| 3321 | // Loop through all subpasses that share the same attachment and make sure a dependency exists |
| 3322 | for (uint32_t k = 0; k < dependent_subpasses.size(); ++k) { |
| 3323 | if (subpass == dependent_subpasses[k]) |
| 3324 | continue; |
| 3325 | const DAGNode& node = subpass_to_node[subpass]; |
| 3326 | // Check for a specified dependency between the two nodes. If one exists we are done. |
| 3327 | auto prev_elem = std::find(node.prev.begin(), node.prev.end(), dependent_subpasses[k]); |
| 3328 | auto next_elem = std::find(node.next.begin(), node.next.end(), dependent_subpasses[k]); |
| 3329 | if (prev_elem == node.prev.end() && next_elem == node.next.end()) { |
| 3330 | // If no dependency exits an implicit dependency still might. If so, warn and if not throw an error. |
| 3331 | std::unordered_set<uint32_t> processed_nodes; |
| 3332 | if (FindDependency(subpass, dependent_subpasses[k], subpass_to_node, processed_nodes) || |
| 3333 | FindDependency(dependent_subpasses[k], subpass, subpass_to_node, processed_nodes)) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3334 | skip_call |= log_msg(my_data->report_data, VK_DBG_REPORT_WARN_BIT, (VkDbgObjectType)0, 0, 0, DRAWSTATE_INVALID_RENDERPASS, "DS", |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3335 | "A dependency between subpasses %d and %d must exist but only an implicit one is specified.", |
| 3336 | subpass, dependent_subpasses[k]); |
| 3337 | } else { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3338 | skip_call |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, DRAWSTATE_INVALID_RENDERPASS, "DS", |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3339 | "A dependency between subpasses %d and %d must exist but one is not specified.", |
| 3340 | subpass, dependent_subpasses[k]); |
| 3341 | result = false; |
| 3342 | } |
| 3343 | } |
| 3344 | } |
| 3345 | return result; |
| 3346 | } |
| 3347 | |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3348 | bool CheckPreserved(const layer_data* my_data, VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const int index, const int attachment, const std::vector<DAGNode>& subpass_to_node, int depth, bool& skip_call) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3349 | const DAGNode& node = subpass_to_node[index]; |
| 3350 | // If this node writes to the attachment return true as next nodes need to preserve the attachment. |
| 3351 | const VkSubpassDescription& subpass = pCreateInfo->pSubpasses[index]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3352 | for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3353 | if (attachment == subpass.pColorAttachments[j].attachment) |
| 3354 | return true; |
| 3355 | } |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3356 | if (subpass.pDepthStencilAttachment && |
| 3357 | subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
| 3358 | if (attachment == subpass.pDepthStencilAttachment->attachment) |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3359 | return true; |
| 3360 | } |
| 3361 | bool result = false; |
| 3362 | // Loop through previous nodes and see if any of them write to the attachment. |
| 3363 | for (auto elem : node.prev) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3364 | result |= CheckPreserved(my_data, device, pCreateInfo, elem, attachment, subpass_to_node, depth + 1, skip_call); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3365 | } |
| 3366 | // If the attachment was written to by a previous node than this node needs to preserve it. |
| 3367 | if (result && depth > 0) { |
| 3368 | const VkSubpassDescription& subpass = pCreateInfo->pSubpasses[index]; |
| 3369 | bool has_preserved = false; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3370 | for (uint32_t j = 0; j < subpass.preserveAttachmentCount; ++j) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3371 | if (subpass.pPreserveAttachments[j].attachment == attachment) { |
| 3372 | has_preserved = true; |
| 3373 | break; |
| 3374 | } |
| 3375 | } |
| 3376 | if (!has_preserved) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3377 | skip_call |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, DRAWSTATE_INVALID_RENDERPASS, "DS", |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3378 | "Attachment %d is used by a later subpass and must be preserved in subpass %d.", attachment, index); |
| 3379 | } |
| 3380 | } |
| 3381 | return result; |
| 3382 | } |
| 3383 | |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3384 | bool validateDependencies(const layer_data* my_data, VkDevice device, const VkRenderPassCreateInfo* pCreateInfo) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3385 | bool skip_call = false; |
| 3386 | std::vector<DAGNode> subpass_to_node(pCreateInfo->subpassCount); |
| 3387 | std::vector<std::vector<uint32_t>> output_attachment_to_subpass(pCreateInfo->attachmentCount); |
| 3388 | std::vector<std::vector<uint32_t>> input_attachment_to_subpass(pCreateInfo->attachmentCount); |
| 3389 | // Create DAG |
| 3390 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 3391 | DAGNode& subpass_node = subpass_to_node[i]; |
| 3392 | subpass_node.pass = i; |
| 3393 | } |
| 3394 | for (uint32_t i = 0; i < pCreateInfo->dependencyCount; ++i) { |
| 3395 | const VkSubpassDependency& dependency = pCreateInfo->pDependencies[i]; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3396 | if (dependency.srcSubpass > dependency.dstSubpass) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3397 | skip_call |= log_msg(my_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType)0, 0, 0, DRAWSTATE_INVALID_RENDERPASS, "DS", |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3398 | "Dependency graph must be specified such that an earlier pass cannot depend on a later pass."); |
| 3399 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3400 | subpass_to_node[dependency.dstSubpass].prev.push_back(dependency.srcSubpass); |
| 3401 | subpass_to_node[dependency.srcSubpass].next.push_back(dependency.dstSubpass); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3402 | } |
| 3403 | // Find for each attachment the subpasses that use them. |
| 3404 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 3405 | const VkSubpassDescription& subpass = pCreateInfo->pSubpasses[i]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3406 | for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3407 | input_attachment_to_subpass[subpass.pInputAttachments[j].attachment].push_back(i); |
| 3408 | } |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3409 | for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3410 | output_attachment_to_subpass[subpass.pColorAttachments[j].attachment].push_back(i); |
| 3411 | } |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3412 | if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
| 3413 | output_attachment_to_subpass[subpass.pDepthStencilAttachment->attachment].push_back(i); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3414 | } |
| 3415 | } |
| 3416 | // If there is a dependency needed make sure one exists |
| 3417 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 3418 | const VkSubpassDescription& subpass = pCreateInfo->pSubpasses[i]; |
| 3419 | // If the attachment is an input then all subpasses that output must have a dependency relationship |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3420 | for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3421 | const uint32_t& attachment = subpass.pInputAttachments[j].attachment; |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3422 | CheckDependencyExists(my_data, device, i, output_attachment_to_subpass[attachment], subpass_to_node, skip_call); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3423 | } |
| 3424 | // If the attachment is an output then all subpasses that use the attachment must have a dependency relationship |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3425 | for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3426 | const uint32_t& attachment = subpass.pColorAttachments[j].attachment; |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3427 | CheckDependencyExists(my_data, device, i, output_attachment_to_subpass[attachment], subpass_to_node, skip_call); |
| 3428 | CheckDependencyExists(my_data, device, i, input_attachment_to_subpass[attachment], subpass_to_node, skip_call); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3429 | } |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3430 | if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
| 3431 | const uint32_t& attachment = subpass.pDepthStencilAttachment->attachment; |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3432 | CheckDependencyExists(my_data, device, i, output_attachment_to_subpass[attachment], subpass_to_node, skip_call); |
| 3433 | CheckDependencyExists(my_data, device, i, input_attachment_to_subpass[attachment], subpass_to_node, skip_call); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3434 | } |
| 3435 | } |
| 3436 | // Loop through implicit dependencies, if this pass reads make sure the attachment is preserved for all passes after it was written. |
| 3437 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 3438 | const VkSubpassDescription& subpass = pCreateInfo->pSubpasses[i]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3439 | for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3440 | CheckPreserved(my_data, device, pCreateInfo, i, subpass.pInputAttachments[j].attachment, subpass_to_node, 0, skip_call); |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3441 | } |
| 3442 | } |
| 3443 | return skip_call; |
| 3444 | } |
| 3445 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3446 | VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3447 | { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3448 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 3449 | if (validateDependencies(dev_data, device, pCreateInfo)) { |
Michael Lentine | b698675 | 2015-10-06 14:56:18 -0700 | [diff] [blame] | 3450 | return VK_ERROR_VALIDATION_FAILED; |
| 3451 | } |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3452 | VkResult result = dev_data->device_dispatch_table->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3453 | if (VK_SUCCESS == result) { |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3454 | // Shadow create info and store in map |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 3455 | VkRenderPassCreateInfo* localRPCI = new VkRenderPassCreateInfo(*pCreateInfo); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3456 | if (pCreateInfo->pAttachments) { |
| 3457 | localRPCI->pAttachments = new VkAttachmentDescription[localRPCI->attachmentCount]; |
| 3458 | memcpy((void*)localRPCI->pAttachments, pCreateInfo->pAttachments, localRPCI->attachmentCount*sizeof(VkAttachmentDescription)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3459 | } |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3460 | if (pCreateInfo->pSubpasses) { |
| 3461 | localRPCI->pSubpasses = new VkSubpassDescription[localRPCI->subpassCount]; |
| 3462 | memcpy((void*)localRPCI->pSubpasses, pCreateInfo->pSubpasses, localRPCI->subpassCount*sizeof(VkSubpassDescription)); |
| 3463 | |
| 3464 | for (uint32_t i = 0; i < localRPCI->subpassCount; i++) { |
| 3465 | VkSubpassDescription *subpass = (VkSubpassDescription *) &localRPCI->pSubpasses[i]; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3466 | const uint32_t attachmentCount = subpass->inputAttachmentCount + |
| 3467 | subpass->colorAttachmentCount * (1 + (subpass->pResolveAttachments?1:0)) + |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3468 | ((subpass->pDepthStencilAttachment) ? 1 : 0) + subpass->preserveAttachmentCount; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3469 | VkAttachmentReference *attachments = new VkAttachmentReference[attachmentCount]; |
| 3470 | |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3471 | memcpy(attachments, subpass->pInputAttachments, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3472 | sizeof(attachments[0]) * subpass->inputAttachmentCount); |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3473 | subpass->pInputAttachments = attachments; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3474 | attachments += subpass->inputAttachmentCount; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3475 | |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3476 | memcpy(attachments, subpass->pColorAttachments, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3477 | sizeof(attachments[0]) * subpass->colorAttachmentCount); |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3478 | subpass->pColorAttachments = attachments; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3479 | attachments += subpass->colorAttachmentCount; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3480 | |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3481 | if (subpass->pResolveAttachments) { |
| 3482 | memcpy(attachments, subpass->pResolveAttachments, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3483 | sizeof(attachments[0]) * subpass->colorAttachmentCount); |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3484 | subpass->pResolveAttachments = attachments; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3485 | attachments += subpass->colorAttachmentCount; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3486 | } |
| 3487 | |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3488 | if (subpass->pDepthStencilAttachment) { |
| 3489 | memcpy(attachments, subpass->pDepthStencilAttachment, |
| 3490 | sizeof(attachments[0]) * 1); |
| 3491 | subpass->pDepthStencilAttachment = attachments; |
| 3492 | attachments += 1; |
| 3493 | } |
| 3494 | |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3495 | memcpy(attachments, subpass->pPreserveAttachments, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3496 | sizeof(attachments[0]) * subpass->preserveAttachmentCount); |
Cody Northrop | a505dda | 2015-08-04 11:16:41 -0600 | [diff] [blame] | 3497 | subpass->pPreserveAttachments = attachments; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3498 | } |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3499 | } |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3500 | if (pCreateInfo->pDependencies) { |
| 3501 | localRPCI->pDependencies = new VkSubpassDependency[localRPCI->dependencyCount]; |
| 3502 | memcpy((void*)localRPCI->pDependencies, pCreateInfo->pDependencies, localRPCI->dependencyCount*sizeof(VkSubpassDependency)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3503 | } |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3504 | dev_data->renderPassMap[*pRenderPass] = localRPCI; |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 3505 | } |
| 3506 | return result; |
| 3507 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3508 | // Free the renderpass shadow |
| 3509 | static void deleteRenderPasses(layer_data* my_data) |
| 3510 | { |
| 3511 | if (my_data->renderPassMap.size() <= 0) |
| 3512 | return; |
| 3513 | for (auto ii=my_data->renderPassMap.begin(); ii!=my_data->renderPassMap.end(); ++ii) { |
| 3514 | if ((*ii).second->pAttachments) { |
| 3515 | delete[] (*ii).second->pAttachments; |
| 3516 | } |
| 3517 | if ((*ii).second->pSubpasses) { |
| 3518 | for (uint32_t i=0; i<(*ii).second->subpassCount; ++i) { |
| 3519 | // Attachements are all allocated in a block, so just need to |
| 3520 | // find the first non-null one to delete |
| 3521 | if ((*ii).second->pSubpasses[i].pInputAttachments) { |
| 3522 | delete[] (*ii).second->pSubpasses[i].pInputAttachments; |
| 3523 | } else if ((*ii).second->pSubpasses[i].pColorAttachments) { |
| 3524 | delete[] (*ii).second->pSubpasses[i].pColorAttachments; |
| 3525 | } else if ((*ii).second->pSubpasses[i].pResolveAttachments) { |
| 3526 | delete[] (*ii).second->pSubpasses[i].pResolveAttachments; |
| 3527 | } else if ((*ii).second->pSubpasses[i].pPreserveAttachments) { |
| 3528 | delete[] (*ii).second->pSubpasses[i].pPreserveAttachments; |
| 3529 | } |
| 3530 | } |
| 3531 | delete[] (*ii).second->pSubpasses; |
| 3532 | } |
| 3533 | if ((*ii).second->pDependencies) { |
| 3534 | delete[] (*ii).second->pDependencies; |
| 3535 | } |
| 3536 | } |
| 3537 | my_data->renderPassMap.clear(); |
| 3538 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3539 | VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkRenderPassContents contents) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3540 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3541 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3542 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3543 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3544 | if (pCB) { |
Tobin Ehlis | 259730a | 2015-06-23 16:13:03 -0600 | [diff] [blame] | 3545 | if (pRenderPassBegin && pRenderPassBegin->renderPass) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3546 | skipCall |= insideRenderPass(dev_data, pCB, "vkCmdBeginRenderPass"); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3547 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3548 | skipCall |= addCmd(dev_data, pCB, CMD_BEGINRENDERPASS); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3549 | pCB->activeRenderPass = pRenderPassBegin->renderPass; |
| 3550 | pCB->activeSubpass = 0; |
| 3551 | pCB->framebuffer = pRenderPassBegin->framebuffer; |
| 3552 | if (pCB->lastBoundPipeline) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3553 | skipCall |= validatePipelineState(dev_data, pCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pCB->lastBoundPipeline); |
Tobin Ehlis | 259730a | 2015-06-23 16:13:03 -0600 | [diff] [blame] | 3554 | } |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3555 | } else { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3556 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_RENDERPASS, "DS", |
Tobin Ehlis | 259730a | 2015-06-23 16:13:03 -0600 | [diff] [blame] | 3557 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tony Barbour | badda99 | 2015-04-06 11:09:26 -0600 | [diff] [blame] | 3558 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3559 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3560 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3561 | dev_data->device_dispatch_table->CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3562 | } |
| 3563 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3564 | VK_LAYER_EXPORT void VKAPI vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkRenderPassContents contents) |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3565 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3566 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3567 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3568 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3569 | if (pCB) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3570 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3571 | skipCall |= addCmd(dev_data, pCB, CMD_NEXTSUBPASS); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3572 | pCB->activeSubpass++; |
| 3573 | if (pCB->lastBoundPipeline) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3574 | skipCall |= validatePipelineState(dev_data, pCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pCB->lastBoundPipeline); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3575 | } |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3576 | skipCall |= outsideRenderPass(dev_data, pCB, "vkCmdNextSubpass"); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3577 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3578 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3579 | dev_data->device_dispatch_table->CmdNextSubpass(commandBuffer, contents); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3580 | } |
| 3581 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3582 | VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCommandBuffer commandBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3583 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3584 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3585 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3586 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3587 | if (pCB) { |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3588 | skipCall |= outsideRenderPass(dev_data, pCB, "vkEndRenderpass"); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3589 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3590 | skipCall |= addCmd(dev_data, pCB, CMD_ENDRENDERPASS); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3591 | pCB->activeRenderPass = 0; |
| 3592 | pCB->activeSubpass = 0; |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 3593 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3594 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3595 | dev_data->device_dispatch_table->CmdEndRenderPass(commandBuffer); |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 3596 | } |
| 3597 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3598 | VK_LAYER_EXPORT void VKAPI vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBuffersCount, const VkCommandBuffer* pCommandBuffers) |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 3599 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3600 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3601 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3602 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 3603 | if (pCB) { |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3604 | GLOBAL_CB_NODE* pSubCB = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3605 | for (uint32_t i=0; i<commandBuffersCount; i++) { |
| 3606 | pSubCB = getCBNode(dev_data, pCommandBuffers[i]); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3607 | if (!pSubCB) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3608 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", |
| 3609 | "vkCmdExecuteCommands() called w/ invalid Cmd Buffer %p in element %u of pCommandBuffers array.", (void*)pCommandBuffers[i], i); |
| 3610 | } else if (VK_COMMAND_BUFFER_LEVEL_PRIMARY == pSubCB->createInfo.level) { |
| 3611 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_SECONDARY_COMMAND_BUFFER, "DS", |
| 3612 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer %p in element %u of pCommandBuffers array. All cmd buffers in pCommandBuffers array must be secondary.", (void*)pCommandBuffers[i], i); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3613 | } |
| 3614 | } |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3615 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3616 | skipCall |= addCmd(dev_data, pCB, CMD_EXECUTECOMMANDS); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3617 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3618 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3619 | dev_data->device_dispatch_table->CmdExecuteCommands(commandBuffer, commandBuffersCount, pCommandBuffers); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3620 | } |
| 3621 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3622 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 3623 | VkInstance instance, |
| 3624 | VkFlags msgFlags, |
| 3625 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 3626 | void* pUserData, |
| 3627 | VkDbgMsgCallback* pMsgCallback) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3628 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3629 | layer_data* my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 3630 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Tobin Ehlis | c16c3e9 | 2015-06-16 09:04:30 -0600 | [diff] [blame] | 3631 | VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 3632 | if (VK_SUCCESS == res) { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3633 | //layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Tobin Ehlis | c16c3e9 | 2015-06-16 09:04:30 -0600 | [diff] [blame] | 3634 | res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 3635 | } |
| 3636 | return res; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3637 | } |
| 3638 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 3639 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 3640 | VkInstance instance, |
| 3641 | VkDbgMsgCallback msgCallback) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3642 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3643 | layer_data* my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 3644 | VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; |
Tobin Ehlis | c16c3e9 | 2015-06-16 09:04:30 -0600 | [diff] [blame] | 3645 | VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); |
Tobin Ehlis | c16c3e9 | 2015-06-16 09:04:30 -0600 | [diff] [blame] | 3646 | layer_destroy_msg_callback(my_data->report_data, msgCallback); |
| 3647 | return res; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3648 | } |
| 3649 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3650 | VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCommandBuffer commandBuffer, const char* pMarker) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3651 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3652 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3653 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3654 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3655 | if (!dev_data->device_extensions.debug_marker_enabled) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3656 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, DRAWSTATE_INVALID_EXTENSION, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 3657 | "Attempt to use CmdDbgMarkerBegin but extension disabled!"); |
Jon Ashburn | eab3449 | 2015-06-01 09:37:38 -0600 | [diff] [blame] | 3658 | return; |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3659 | } else if (pCB) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3660 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3661 | skipCall |= addCmd(dev_data, pCB, CMD_DBGMARKERBEGIN); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3662 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3663 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3664 | debug_marker_dispatch_table(commandBuffer)->CmdDbgMarkerBegin(commandBuffer, pMarker); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3665 | } |
| 3666 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3667 | VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCommandBuffer commandBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3668 | { |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3669 | VkBool32 skipCall = VK_FALSE; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3670 | layer_data* dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); |
| 3671 | GLOBAL_CB_NODE* pCB = getCBNode(dev_data, commandBuffer); |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3672 | if (!dev_data->device_extensions.debug_marker_enabled) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3673 | skipCall |= log_msg(dev_data->report_data, VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)commandBuffer, 0, DRAWSTATE_INVALID_EXTENSION, "DS", |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 3674 | "Attempt to use CmdDbgMarkerEnd but extension disabled!"); |
Jon Ashburn | eab3449 | 2015-06-01 09:37:38 -0600 | [diff] [blame] | 3675 | return; |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 3676 | } else if (pCB) { |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3677 | updateCBTracking(pCB); |
Tobin Ehlis | 432ef5c | 2015-10-20 17:06:16 -0600 | [diff] [blame] | 3678 | skipCall |= addCmd(dev_data, pCB, CMD_DBGMARKEREND); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3679 | } |
Tobin Ehlis | 1cfb30a | 2015-09-09 11:31:10 -0600 | [diff] [blame] | 3680 | if (VK_FALSE == skipCall) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3681 | debug_marker_dispatch_table(commandBuffer)->CmdDbgMarkerEnd(commandBuffer); |
Jon Ashburn | eab3449 | 2015-06-01 09:37:38 -0600 | [diff] [blame] | 3682 | } |
| 3683 | |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3684 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice dev, const char* funcName) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3685 | { |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 3686 | if (dev == NULL) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3687 | return NULL; |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 3688 | |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3689 | layer_data *dev_data; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3690 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 3691 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3692 | VkBaseLayerObject* wrapped_dev = (VkBaseLayerObject*) dev; |
| 3693 | dev_data = get_my_data_ptr(get_dispatch_key(wrapped_dev->baseObject), layer_data_map); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3694 | dev_data->device_dispatch_table = new VkLayerDispatchTable; |
| 3695 | layer_initialize_dispatch_table(dev_data->device_dispatch_table, wrapped_dev); |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3696 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3697 | } |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3698 | dev_data = get_my_data_ptr(get_dispatch_key(dev), layer_data_map); |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 3699 | if (!strcmp(funcName, "vkCreateDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3700 | return (PFN_vkVoidFunction) vkCreateDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3701 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3702 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3703 | if (!strcmp(funcName, "vkQueueSubmit")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3704 | return (PFN_vkVoidFunction) vkQueueSubmit; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3705 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3706 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3707 | if (!strcmp(funcName, "vkDestroyDevice")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3708 | return (PFN_vkVoidFunction) vkDestroyDevice; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3709 | if (!strcmp(funcName, "vkDestroyFence")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3710 | return (PFN_vkVoidFunction) vkDestroyFence; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3711 | if (!strcmp(funcName, "vkDestroySemaphore")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3712 | return (PFN_vkVoidFunction) vkDestroySemaphore; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3713 | if (!strcmp(funcName, "vkDestroyEvent")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3714 | return (PFN_vkVoidFunction) vkDestroyEvent; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3715 | if (!strcmp(funcName, "vkDestroyQueryPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3716 | return (PFN_vkVoidFunction) vkDestroyQueryPool; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3717 | if (!strcmp(funcName, "vkDestroyBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3718 | return (PFN_vkVoidFunction) vkDestroyBuffer; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3719 | if (!strcmp(funcName, "vkDestroyBufferView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3720 | return (PFN_vkVoidFunction) vkDestroyBufferView; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3721 | if (!strcmp(funcName, "vkDestroyImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3722 | return (PFN_vkVoidFunction) vkDestroyImage; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3723 | if (!strcmp(funcName, "vkDestroyImageView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3724 | return (PFN_vkVoidFunction) vkDestroyImageView; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3725 | if (!strcmp(funcName, "vkDestroyShaderModule")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3726 | return (PFN_vkVoidFunction) vkDestroyShaderModule; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3727 | if (!strcmp(funcName, "vkDestroyShader")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3728 | return (PFN_vkVoidFunction) vkDestroyShader; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3729 | if (!strcmp(funcName, "vkDestroyPipeline")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3730 | return (PFN_vkVoidFunction) vkDestroyPipeline; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3731 | if (!strcmp(funcName, "vkDestroyPipelineLayout")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3732 | return (PFN_vkVoidFunction) vkDestroyPipelineLayout; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3733 | if (!strcmp(funcName, "vkDestroySampler")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3734 | return (PFN_vkVoidFunction) vkDestroySampler; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3735 | if (!strcmp(funcName, "vkDestroyDescriptorSetLayout")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3736 | return (PFN_vkVoidFunction) vkDestroyDescriptorSetLayout; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3737 | if (!strcmp(funcName, "vkDestroyDescriptorPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3738 | return (PFN_vkVoidFunction) vkDestroyDescriptorPool; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3739 | if (!strcmp(funcName, "vkFreeCommandBuffers")) |
| 3740 | return (PFN_vkVoidFunction) vkFreeCommandBuffers; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3741 | if (!strcmp(funcName, "vkDestroyFramebuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3742 | return (PFN_vkVoidFunction) vkDestroyFramebuffer; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 3743 | if (!strcmp(funcName, "vkDestroyRenderPass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3744 | return (PFN_vkVoidFunction) vkDestroyRenderPass; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3745 | if (!strcmp(funcName, "vkCreateBuffer")) |
| 3746 | return (PFN_vkVoidFunction) vkCreateBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3747 | if (!strcmp(funcName, "vkCreateBufferView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3748 | return (PFN_vkVoidFunction) vkCreateBufferView; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3749 | if (!strcmp(funcName, "vkCreateImage")) |
| 3750 | return (PFN_vkVoidFunction) vkCreateImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3751 | if (!strcmp(funcName, "vkCreateImageView")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3752 | return (PFN_vkVoidFunction) vkCreateImageView; |
Chia-I Wu | ff3780f | 2015-10-26 19:52:46 +0800 | [diff] [blame] | 3753 | if (!strcmp(funcName, "vkCreateShader")) |
| 3754 | return (PFN_vkVoidFunction) vkCreateShader; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3755 | if (!strcmp(funcName, "CreatePipelineCache")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3756 | return (PFN_vkVoidFunction) vkCreatePipelineCache; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3757 | if (!strcmp(funcName, "DestroyPipelineCache")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3758 | return (PFN_vkVoidFunction) vkDestroyPipelineCache; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3759 | if (!strcmp(funcName, "GetPipelineCacheData")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3760 | return (PFN_vkVoidFunction) vkGetPipelineCacheData; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3761 | if (!strcmp(funcName, "MergePipelineCaches")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3762 | return (PFN_vkVoidFunction) vkMergePipelineCaches; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3763 | if (!strcmp(funcName, "vkCreateGraphicsPipelines")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3764 | return (PFN_vkVoidFunction) vkCreateGraphicsPipelines; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3765 | if (!strcmp(funcName, "vkCreateSampler")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3766 | return (PFN_vkVoidFunction) vkCreateSampler; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3767 | if (!strcmp(funcName, "vkCreateDescriptorSetLayout")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3768 | return (PFN_vkVoidFunction) vkCreateDescriptorSetLayout; |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 3769 | if (!strcmp(funcName, "vkCreatePipelineLayout")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3770 | return (PFN_vkVoidFunction) vkCreatePipelineLayout; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3771 | if (!strcmp(funcName, "vkCreateDescriptorPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3772 | return (PFN_vkVoidFunction) vkCreateDescriptorPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3773 | if (!strcmp(funcName, "vkResetDescriptorPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3774 | return (PFN_vkVoidFunction) vkResetDescriptorPool; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3775 | if (!strcmp(funcName, "vkAllocateDescriptorSets")) |
| 3776 | return (PFN_vkVoidFunction) vkAllocateDescriptorSets; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3777 | if (!strcmp(funcName, "vkFreeDescriptorSets")) |
| 3778 | return (PFN_vkVoidFunction) vkFreeDescriptorSets; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3779 | if (!strcmp(funcName, "vkUpdateDescriptorSets")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3780 | return (PFN_vkVoidFunction) vkUpdateDescriptorSets; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3781 | if (!strcmp(funcName, "vkAllocateCommandBuffers")) |
| 3782 | return (PFN_vkVoidFunction) vkAllocateCommandBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3783 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3784 | return (PFN_vkVoidFunction) vkBeginCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3785 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3786 | return (PFN_vkVoidFunction) vkEndCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3787 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3788 | return (PFN_vkVoidFunction) vkResetCommandBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3789 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3790 | return (PFN_vkVoidFunction) vkCmdBindPipeline; |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 3791 | if (!strcmp(funcName, "vkCmdSetViewport")) |
| 3792 | return (PFN_vkVoidFunction) vkCmdSetViewport; |
Courtney Goeltzenleuchter | 078f817 | 2015-09-21 11:44:06 -0600 | [diff] [blame] | 3793 | if (!strcmp(funcName, "vkCmdSetScissor")) |
| 3794 | return (PFN_vkVoidFunction) vkCmdSetScissor; |
Courtney Goeltzenleuchter | 49c7308 | 2015-09-17 15:06:17 -0600 | [diff] [blame] | 3795 | if (!strcmp(funcName, "vkCmdSetLineWidth")) |
| 3796 | return (PFN_vkVoidFunction) vkCmdSetLineWidth; |
| 3797 | if (!strcmp(funcName, "vkCmdSetDepthBias")) |
| 3798 | return (PFN_vkVoidFunction) vkCmdSetDepthBias; |
| 3799 | if (!strcmp(funcName, "vkCmdSetBlendConstants")) |
| 3800 | return (PFN_vkVoidFunction) vkCmdSetBlendConstants; |
| 3801 | if (!strcmp(funcName, "vkCmdSetDepthBounds")) |
| 3802 | return (PFN_vkVoidFunction) vkCmdSetDepthBounds; |
| 3803 | if (!strcmp(funcName, "vkCmdSetStencilCompareMask")) |
| 3804 | return (PFN_vkVoidFunction) vkCmdSetStencilCompareMask; |
| 3805 | if (!strcmp(funcName, "vkCmdSetStencilWriteMask")) |
| 3806 | return (PFN_vkVoidFunction) vkCmdSetStencilWriteMask; |
| 3807 | if (!strcmp(funcName, "vkCmdSetStencilReference")) |
| 3808 | return (PFN_vkVoidFunction) vkCmdSetStencilReference; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3809 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3810 | return (PFN_vkVoidFunction) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 3811 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3812 | return (PFN_vkVoidFunction) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3813 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3814 | return (PFN_vkVoidFunction) vkCmdBindIndexBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3815 | if (!strcmp(funcName, "vkCmdDraw")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3816 | return (PFN_vkVoidFunction) vkCmdDraw; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3817 | if (!strcmp(funcName, "vkCmdDrawIndexed")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3818 | return (PFN_vkVoidFunction) vkCmdDrawIndexed; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3819 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3820 | return (PFN_vkVoidFunction) vkCmdDrawIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3821 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3822 | return (PFN_vkVoidFunction) vkCmdDrawIndexedIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3823 | if (!strcmp(funcName, "vkCmdDispatch")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3824 | return (PFN_vkVoidFunction) vkCmdDispatch; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3825 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3826 | return (PFN_vkVoidFunction) vkCmdDispatchIndirect; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3827 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3828 | return (PFN_vkVoidFunction) vkCmdCopyBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3829 | if (!strcmp(funcName, "vkCmdCopyImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3830 | return (PFN_vkVoidFunction) vkCmdCopyImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3831 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3832 | return (PFN_vkVoidFunction) vkCmdCopyBufferToImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3833 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3834 | return (PFN_vkVoidFunction) vkCmdCopyImageToBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3835 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3836 | return (PFN_vkVoidFunction) vkCmdUpdateBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3837 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3838 | return (PFN_vkVoidFunction) vkCmdFillBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3839 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3840 | return (PFN_vkVoidFunction) vkCmdClearColorImage; |
Chris Forbes | d9be82b | 2015-06-22 17:21:59 +1200 | [diff] [blame] | 3841 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3842 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilImage; |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3843 | if (!strcmp(funcName, "vkCmdClearAttachments")) |
| 3844 | return (PFN_vkVoidFunction) vkCmdClearAttachments; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3845 | if (!strcmp(funcName, "vkCmdResolveImage")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3846 | return (PFN_vkVoidFunction) vkCmdResolveImage; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3847 | if (!strcmp(funcName, "vkCmdSetEvent")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3848 | return (PFN_vkVoidFunction) vkCmdSetEvent; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3849 | if (!strcmp(funcName, "vkCmdResetEvent")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3850 | return (PFN_vkVoidFunction) vkCmdResetEvent; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3851 | if (!strcmp(funcName, "vkCmdWaitEvents")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3852 | return (PFN_vkVoidFunction) vkCmdWaitEvents; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3853 | if (!strcmp(funcName, "vkCmdPipelineBarrier")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3854 | return (PFN_vkVoidFunction) vkCmdPipelineBarrier; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3855 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3856 | return (PFN_vkVoidFunction) vkCmdBeginQuery; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3857 | if (!strcmp(funcName, "vkCmdEndQuery")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3858 | return (PFN_vkVoidFunction) vkCmdEndQuery; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3859 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3860 | return (PFN_vkVoidFunction) vkCmdResetQueryPool; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3861 | if (!strcmp(funcName, "vkCmdWriteTimestamp")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3862 | return (PFN_vkVoidFunction) vkCmdWriteTimestamp; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3863 | if (!strcmp(funcName, "vkCreateFramebuffer")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3864 | return (PFN_vkVoidFunction) vkCreateFramebuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3865 | if (!strcmp(funcName, "vkCreateRenderPass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3866 | return (PFN_vkVoidFunction) vkCreateRenderPass; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3867 | if (!strcmp(funcName, "vkCmdBeginRenderPass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3868 | return (PFN_vkVoidFunction) vkCmdBeginRenderPass; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 3869 | if (!strcmp(funcName, "vkCmdNextSubpass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3870 | return (PFN_vkVoidFunction) vkCmdNextSubpass; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 3871 | if (!strcmp(funcName, "vkCmdEndRenderPass")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3872 | return (PFN_vkVoidFunction) vkCmdEndRenderPass; |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3873 | if (!strcmp(funcName, "vkCmdExecuteCommands")) |
| 3874 | return (PFN_vkVoidFunction) vkCmdExecuteCommands; |
Jon Ashburn | eab3449 | 2015-06-01 09:37:38 -0600 | [diff] [blame] | 3875 | |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3876 | VkLayerDispatchTable* pTable = dev_data->device_dispatch_table; |
| 3877 | if (dev_data->device_extensions.debug_marker_enabled) |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3878 | { |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3879 | if (!strcmp(funcName, "vkCmdDbgMarkerBegin")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3880 | return (PFN_vkVoidFunction) vkCmdDbgMarkerBegin; |
Jon Ashburn | 747f2b6 | 2015-06-18 15:02:58 -0600 | [diff] [blame] | 3881 | if (!strcmp(funcName, "vkCmdDbgMarkerEnd")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3882 | return (PFN_vkVoidFunction) vkCmdDbgMarkerEnd; |
Jon Ashburn | eab3449 | 2015-06-01 09:37:38 -0600 | [diff] [blame] | 3883 | } |
| 3884 | { |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3885 | if (pTable->GetDeviceProcAddr == NULL) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3886 | return NULL; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3887 | return pTable->GetDeviceProcAddr(dev, funcName); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3888 | } |
| 3889 | } |
| 3890 | |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3891 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3892 | { |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3893 | PFN_vkVoidFunction fptr; |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3894 | if (instance == NULL) |
| 3895 | return NULL; |
| 3896 | |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3897 | layer_data* my_data; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3898 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 3899 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3900 | VkBaseLayerObject* wrapped_inst = (VkBaseLayerObject*) instance; |
| 3901 | my_data = get_my_data_ptr(get_dispatch_key(wrapped_inst->baseObject), layer_data_map); |
Tobin Ehlis | b212dfc | 2015-10-07 15:40:22 -0600 | [diff] [blame] | 3902 | my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; |
| 3903 | layer_init_instance_dispatch_table(my_data->instance_dispatch_table, wrapped_inst); |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3904 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3905 | } |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3906 | my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
Courtney Goeltzenleuchter | abc035e | 2015-06-01 14:29:58 -0600 | [diff] [blame] | 3907 | if (!strcmp(funcName, "vkCreateInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3908 | return (PFN_vkVoidFunction) vkCreateInstance; |
Jon Ashburn | 3950e1b | 2015-05-20 09:00:28 -0600 | [diff] [blame] | 3909 | if (!strcmp(funcName, "vkDestroyInstance")) |
Courtney Goeltzenleuchter | 2d3ba63 | 2015-07-12 14:35:22 -0600 | [diff] [blame] | 3910 | return (PFN_vkVoidFunction) vkDestroyInstance; |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 3911 | if (!strcmp(funcName, "vkEnumerateInstanceLayerProperties")) |
| 3912 | return (PFN_vkVoidFunction) vkEnumerateInstanceLayerProperties; |
| 3913 | if (!strcmp(funcName, "vkEnumerateInstanceExtensionProperties")) |
| 3914 | return (PFN_vkVoidFunction) vkEnumerateInstanceExtensionProperties; |
| 3915 | if (!strcmp(funcName, "vkEnumerateDeviceLayerProperties")) |
| 3916 | return (PFN_vkVoidFunction) vkEnumerateDeviceLayerProperties; |
| 3917 | if (!strcmp(funcName, "vkEnumerateDeviceExtensionProperties")) |
| 3918 | return (PFN_vkVoidFunction) vkEnumerateDeviceExtensionProperties; |
Courtney Goeltzenleuchter | ee56287 | 2015-06-01 14:33:14 -0600 | [diff] [blame] | 3919 | |
Tobin Ehlis | a16e892 | 2015-06-16 15:50:44 -0600 | [diff] [blame] | 3920 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
Courtney Goeltzenleuchter | ee56287 | 2015-06-01 14:33:14 -0600 | [diff] [blame] | 3921 | if (fptr) |
| 3922 | return fptr; |
| 3923 | |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3924 | { |
Tobin Ehlis | 0b63233 | 2015-10-07 09:38:40 -0600 | [diff] [blame] | 3925 | VkLayerInstanceDispatchTable* pTable = my_data->instance_dispatch_table; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3926 | if (pTable->GetInstanceProcAddr == NULL) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 3927 | return NULL; |
Jon Ashburn | 8fd0825 | 2015-05-28 16:25:02 -0600 | [diff] [blame] | 3928 | return pTable->GetInstanceProcAddr(instance, funcName); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3929 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3930 | } |