Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <unordered_map> |
| 29 | |
| 30 | #include "loader_platform.h" |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 31 | #include "vk_dispatch_table_helper.h" |
| 32 | #include "vk_struct_string_helper_cpp.h" |
Tony Barbour | a938abb | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 33 | #if defined(__GNUC__) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 34 | #pragma GCC diagnostic ignored "-Wwrite-strings" |
Tony Barbour | a938abb | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 35 | #endif |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 36 | #include "vk_struct_graphviz_helper.h" |
Tony Barbour | a938abb | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 37 | #if defined(__GNUC__) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 38 | #pragma GCC diagnostic warning "-Wwrite-strings" |
Tony Barbour | a938abb | 2015-04-22 11:36:22 -0600 | [diff] [blame] | 39 | #endif |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 40 | #include "vk_struct_size_helper.h" |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 41 | #include "draw_state.h" |
| 42 | #include "layers_config.h" |
| 43 | // The following is #included again to catch certain OS-specific functions |
| 44 | // being used: |
| 45 | #include "loader_platform.h" |
| 46 | #include "layers_msg.h" |
| 47 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 48 | unordered_map<VkSampler, SAMPLER_NODE*> sampleMap; |
| 49 | unordered_map<VkImageView, IMAGE_NODE*> imageMap; |
| 50 | unordered_map<VkBufferView, BUFFER_NODE*> bufferMap; |
| 51 | unordered_map<VkDynamicStateObject, DYNAMIC_STATE_NODE*> dynamicStateMap; |
| 52 | unordered_map<VkPipeline, PIPELINE_NODE*> pipelineMap; |
| 53 | unordered_map<VkDescriptorPool, POOL_NODE*> poolMap; |
| 54 | unordered_map<VkDescriptorSet, SET_NODE*> setMap; |
| 55 | unordered_map<VkDescriptorSetLayout, LAYOUT_NODE*> layoutMap; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 56 | // Map for layout chains |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 57 | unordered_map<VkCmdBuffer, GLOBAL_CB_NODE*> cmdBufferMap; |
| 58 | unordered_map<VkRenderPass, VkRenderPassCreateInfo*> renderPassMap; |
| 59 | unordered_map<VkFramebuffer, VkFramebufferCreateInfo*> frameBufferMap; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 60 | |
Jon Ashburn | 301c5f0 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 61 | static VkLayerDispatchTable nextTable; |
| 62 | static VkBaseLayerObject *pCurObj; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 63 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
| 64 | // TODO : This can be much smarter, using separate locks for separate global data |
| 65 | static int globalLockInitialized = 0; |
| 66 | static loader_platform_thread_mutex globalLock; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 67 | #define MAX_TID 513 |
| 68 | static loader_platform_thread_id g_tidMapping[MAX_TID] = {0}; |
| 69 | static uint32_t g_maxTID = 0; |
| 70 | // Map actual TID to an index value and return that index |
| 71 | // This keeps TIDs in range from 0-MAX_TID and simplifies compares between runs |
| 72 | static uint32_t getTIDIndex() { |
| 73 | loader_platform_thread_id tid = loader_platform_get_thread_id(); |
| 74 | for (uint32_t i = 0; i < g_maxTID; i++) { |
| 75 | if (tid == g_tidMapping[i]) |
| 76 | return i; |
| 77 | } |
| 78 | // Don't yet have mapping, set it and return newly set index |
| 79 | uint32_t retVal = (uint32_t) g_maxTID; |
| 80 | g_tidMapping[g_maxTID++] = tid; |
| 81 | assert(g_maxTID < MAX_TID); |
| 82 | return retVal; |
| 83 | } |
| 84 | // Return a string representation of CMD_TYPE enum |
| 85 | static string cmdTypeToString(CMD_TYPE cmd) |
| 86 | { |
| 87 | switch (cmd) |
| 88 | { |
| 89 | case CMD_BINDPIPELINE: |
| 90 | return "CMD_BINDPIPELINE"; |
| 91 | case CMD_BINDPIPELINEDELTA: |
| 92 | return "CMD_BINDPIPELINEDELTA"; |
| 93 | case CMD_BINDDYNAMICSTATEOBJECT: |
| 94 | return "CMD_BINDDYNAMICSTATEOBJECT"; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 95 | case CMD_BINDDESCRIPTORSETS: |
| 96 | return "CMD_BINDDESCRIPTORSETS"; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 97 | case CMD_BINDINDEXBUFFER: |
| 98 | return "CMD_BINDINDEXBUFFER"; |
| 99 | case CMD_BINDVERTEXBUFFER: |
| 100 | return "CMD_BINDVERTEXBUFFER"; |
| 101 | case CMD_DRAW: |
| 102 | return "CMD_DRAW"; |
| 103 | case CMD_DRAWINDEXED: |
| 104 | return "CMD_DRAWINDEXED"; |
| 105 | case CMD_DRAWINDIRECT: |
| 106 | return "CMD_DRAWINDIRECT"; |
| 107 | case CMD_DRAWINDEXEDINDIRECT: |
| 108 | return "CMD_DRAWINDEXEDINDIRECT"; |
| 109 | case CMD_DISPATCH: |
| 110 | return "CMD_DISPATCH"; |
| 111 | case CMD_DISPATCHINDIRECT: |
| 112 | return "CMD_DISPATCHINDIRECT"; |
| 113 | case CMD_COPYBUFFER: |
| 114 | return "CMD_COPYBUFFER"; |
| 115 | case CMD_COPYIMAGE: |
| 116 | return "CMD_COPYIMAGE"; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 117 | case CMD_BLITIMAGE: |
| 118 | return "CMD_BLITIMAGE"; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 119 | case CMD_COPYBUFFERTOIMAGE: |
| 120 | return "CMD_COPYBUFFERTOIMAGE"; |
| 121 | case CMD_COPYIMAGETOBUFFER: |
| 122 | return "CMD_COPYIMAGETOBUFFER"; |
| 123 | case CMD_CLONEIMAGEDATA: |
| 124 | return "CMD_CLONEIMAGEDATA"; |
| 125 | case CMD_UPDATEBUFFER: |
| 126 | return "CMD_UPDATEBUFFER"; |
| 127 | case CMD_FILLBUFFER: |
| 128 | return "CMD_FILLBUFFER"; |
| 129 | case CMD_CLEARCOLORIMAGE: |
| 130 | return "CMD_CLEARCOLORIMAGE"; |
| 131 | case CMD_CLEARCOLORIMAGERAW: |
| 132 | return "CMD_CLEARCOLORIMAGERAW"; |
| 133 | case CMD_CLEARDEPTHSTENCIL: |
| 134 | return "CMD_CLEARDEPTHSTENCIL"; |
| 135 | case CMD_RESOLVEIMAGE: |
| 136 | return "CMD_RESOLVEIMAGE"; |
| 137 | case CMD_SETEVENT: |
| 138 | return "CMD_SETEVENT"; |
| 139 | case CMD_RESETEVENT: |
| 140 | return "CMD_RESETEVENT"; |
| 141 | case CMD_WAITEVENTS: |
| 142 | return "CMD_WAITEVENTS"; |
| 143 | case CMD_PIPELINEBARRIER: |
| 144 | return "CMD_PIPELINEBARRIER"; |
| 145 | case CMD_BEGINQUERY: |
| 146 | return "CMD_BEGINQUERY"; |
| 147 | case CMD_ENDQUERY: |
| 148 | return "CMD_ENDQUERY"; |
| 149 | case CMD_RESETQUERYPOOL: |
| 150 | return "CMD_RESETQUERYPOOL"; |
| 151 | case CMD_WRITETIMESTAMP: |
| 152 | return "CMD_WRITETIMESTAMP"; |
| 153 | case CMD_INITATOMICCOUNTERS: |
| 154 | return "CMD_INITATOMICCOUNTERS"; |
| 155 | case CMD_LOADATOMICCOUNTERS: |
| 156 | return "CMD_LOADATOMICCOUNTERS"; |
| 157 | case CMD_SAVEATOMICCOUNTERS: |
| 158 | return "CMD_SAVEATOMICCOUNTERS"; |
| 159 | case CMD_BEGINRENDERPASS: |
| 160 | return "CMD_BEGINRENDERPASS"; |
| 161 | case CMD_ENDRENDERPASS: |
| 162 | return "CMD_ENDRENDERPASS"; |
| 163 | case CMD_DBGMARKERBEGIN: |
| 164 | return "CMD_DBGMARKERBEGIN"; |
| 165 | case CMD_DBGMARKEREND: |
| 166 | return "CMD_DBGMARKEREND"; |
| 167 | default: |
| 168 | return "UNKNOWN"; |
| 169 | } |
| 170 | } |
| 171 | // Block of code at start here for managing/tracking Pipeline state that this layer cares about |
| 172 | // Just track 2 shaders for now |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 173 | #define VK_NUM_GRAPHICS_SHADERS VK_SHADER_STAGE_COMPUTE |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 174 | #define MAX_SLOTS 2048 |
| 175 | #define NUM_COMMAND_BUFFERS_TO_DISPLAY 10 |
| 176 | |
| 177 | static uint64_t g_drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0}; |
| 178 | |
| 179 | // TODO : Should be tracking lastBound per cmdBuffer and when draws occur, report based on that cmd buffer lastBound |
| 180 | // Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates |
| 181 | // to that same cmd buffer by separate thread are not changing state from underneath us |
| 182 | // Track the last cmd buffer touched by this thread |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 183 | static VkCmdBuffer g_lastCmdBuffer[MAX_TID] = {NULL}; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 184 | // Track the last group of CBs touched for displaying to dot file |
| 185 | static GLOBAL_CB_NODE* g_pLastTouchedCB[NUM_COMMAND_BUFFERS_TO_DISPLAY] = {NULL}; |
| 186 | static uint32_t g_lastTouchedCBIndex = 0; |
| 187 | // Track the last global DrawState of interest touched by any thread |
| 188 | static GLOBAL_CB_NODE* g_lastGlobalCB = NULL; |
| 189 | static PIPELINE_NODE* g_lastBoundPipeline = NULL; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 190 | static DYNAMIC_STATE_NODE* g_lastBoundDynamicState[VK_NUM_STATE_BIND_POINT] = {NULL}; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 191 | static VkDescriptorSet g_lastBoundDescriptorSet = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 192 | #define MAX_BINDING 0xFFFFFFFF // Default vtxBinding value in CB Node to identify if no vtxBinding set |
| 193 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 194 | //static DYNAMIC_STATE_NODE* g_pDynamicStateHead[VK_NUM_STATE_BIND_POINT] = {0}; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 195 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 196 | static void insertDynamicState(const VkDynamicStateObject state, const GENERIC_HEADER* pCreateInfo, VkStateBindPoint bindPoint) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 197 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 198 | VkDynamicVpStateCreateInfo* pVPCI = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 199 | size_t scSize = 0; |
| 200 | size_t vpSize = 0; |
| 201 | loader_platform_thread_lock_mutex(&globalLock); |
| 202 | DYNAMIC_STATE_NODE* pStateNode = new DYNAMIC_STATE_NODE; |
| 203 | pStateNode->stateObj = state; |
| 204 | switch (pCreateInfo->sType) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 205 | case VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 206 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicVpStateCreateInfo)); |
| 207 | pVPCI = (VkDynamicVpStateCreateInfo*)pCreateInfo; |
| 208 | pStateNode->create_info.vpci.pScissors = new VkRect[pStateNode->create_info.vpci.viewportAndScissorCount]; |
| 209 | pStateNode->create_info.vpci.pViewports = new VkViewport[pStateNode->create_info.vpci.viewportAndScissorCount]; |
| 210 | scSize = pVPCI->viewportAndScissorCount * sizeof(VkRect); |
| 211 | vpSize = pVPCI->viewportAndScissorCount * sizeof(VkViewport); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 212 | memcpy((void*)pStateNode->create_info.vpci.pScissors, pVPCI->pScissors, scSize); |
| 213 | memcpy((void*)pStateNode->create_info.vpci.pViewports, pVPCI->pViewports, vpSize); |
| 214 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 215 | case VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 216 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicRsStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 217 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 218 | case VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 219 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicCbStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 220 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 221 | case VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 222 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicDsStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 223 | break; |
| 224 | default: |
| 225 | assert(0); |
| 226 | break; |
| 227 | } |
| 228 | pStateNode->pCreateInfo = (GENERIC_HEADER*)&pStateNode->create_info.cbci; |
| 229 | dynamicStateMap[state] = pStateNode; |
| 230 | loader_platform_thread_unlock_mutex(&globalLock); |
| 231 | } |
| 232 | // Free all allocated nodes for Dynamic State objs |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 233 | static void deleteDynamicState() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 234 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 235 | for (unordered_map<VkDynamicStateObject, DYNAMIC_STATE_NODE*>::iterator ii=dynamicStateMap.begin(); ii!=dynamicStateMap.end(); ++ii) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 236 | if (VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO == (*ii).second->create_info.vpci.sType) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 237 | delete[] (*ii).second->create_info.vpci.pScissors; |
| 238 | delete[] (*ii).second->create_info.vpci.pViewports; |
| 239 | } |
| 240 | delete (*ii).second; |
| 241 | } |
| 242 | } |
| 243 | // Free all sampler nodes |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 244 | static void deleteSamplers() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 245 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 246 | for (unordered_map<VkSampler, SAMPLER_NODE*>::iterator ii=sampleMap.begin(); ii!=sampleMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 247 | delete (*ii).second; |
| 248 | } |
| 249 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 250 | static VkImageViewCreateInfo* getImageViewCreateInfo(VkImageView view) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 251 | { |
| 252 | loader_platform_thread_lock_mutex(&globalLock); |
| 253 | if (imageMap.find(view) == imageMap.end()) { |
| 254 | loader_platform_thread_unlock_mutex(&globalLock); |
| 255 | return NULL; |
| 256 | } |
| 257 | else { |
| 258 | loader_platform_thread_unlock_mutex(&globalLock); |
| 259 | return &imageMap[view]->createInfo; |
| 260 | } |
| 261 | } |
| 262 | // Free all image nodes |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 263 | static void deleteImages() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 264 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 265 | for (unordered_map<VkImageView, IMAGE_NODE*>::iterator ii=imageMap.begin(); ii!=imageMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 266 | delete (*ii).second; |
| 267 | } |
| 268 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 269 | static VkBufferViewCreateInfo* getBufferViewCreateInfo(VkBufferView view) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 270 | { |
| 271 | loader_platform_thread_lock_mutex(&globalLock); |
| 272 | if (bufferMap.find(view) == bufferMap.end()) { |
| 273 | loader_platform_thread_unlock_mutex(&globalLock); |
| 274 | return NULL; |
| 275 | } |
| 276 | else { |
| 277 | loader_platform_thread_unlock_mutex(&globalLock); |
| 278 | return &bufferMap[view]->createInfo; |
| 279 | } |
| 280 | } |
| 281 | // Free all buffer nodes |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 282 | static void deleteBuffers() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 283 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 284 | for (unordered_map<VkBufferView, BUFFER_NODE*>::iterator ii=bufferMap.begin(); ii!=bufferMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 285 | delete (*ii).second; |
| 286 | } |
| 287 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 288 | static GLOBAL_CB_NODE* getCBNode(VkCmdBuffer cb); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 289 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 290 | static void updateCBTracking(VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 291 | { |
| 292 | g_lastCmdBuffer[getTIDIndex()] = cb; |
| 293 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 294 | loader_platform_thread_lock_mutex(&globalLock); |
| 295 | g_lastGlobalCB = pCB; |
| 296 | // TODO : This is a dumb algorithm. Need smart LRU that drops off oldest |
| 297 | for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) { |
| 298 | if (g_pLastTouchedCB[i] == pCB) { |
| 299 | loader_platform_thread_unlock_mutex(&globalLock); |
| 300 | return; |
| 301 | } |
| 302 | } |
| 303 | g_pLastTouchedCB[g_lastTouchedCBIndex++] = pCB; |
| 304 | g_lastTouchedCBIndex = g_lastTouchedCBIndex % NUM_COMMAND_BUFFERS_TO_DISPLAY; |
| 305 | loader_platform_thread_unlock_mutex(&globalLock); |
| 306 | } |
| 307 | |
| 308 | // Print the last bound dynamic state |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 309 | static void printDynamicState(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 310 | { |
| 311 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 312 | if (pCB) { |
| 313 | loader_platform_thread_lock_mutex(&globalLock); |
| 314 | char str[4*1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 315 | for (uint32_t i = 0; i < VK_NUM_STATE_BIND_POINT; i++) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 316 | if (pCB->lastBoundDynamicState[i]) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 317 | sprintf(str, "Reporting CreateInfo for currently bound %s object %p", string_VkStateBindPoint((VkStateBindPoint)i), pCB->lastBoundDynamicState[i]->stateObj); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 318 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pCB->lastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", str); |
| 319 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pCB->lastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", dynamic_display(pCB->lastBoundDynamicState[i]->pCreateInfo, " ").c_str()); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 320 | break; |
| 321 | } |
| 322 | else { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 323 | sprintf(str, "No dynamic state of type %s bound", string_VkStateBindPoint((VkStateBindPoint)i)); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 324 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | loader_platform_thread_unlock_mutex(&globalLock); |
| 328 | } |
| 329 | else { |
| 330 | char str[1024]; |
| 331 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cb); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 332 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | // Retrieve pipeline node ptr for given pipeline object |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 336 | static PIPELINE_NODE* getPipeline(VkPipeline pipeline) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 337 | { |
| 338 | loader_platform_thread_lock_mutex(&globalLock); |
| 339 | if (pipelineMap.find(pipeline) == pipelineMap.end()) { |
| 340 | loader_platform_thread_unlock_mutex(&globalLock); |
| 341 | return NULL; |
| 342 | } |
| 343 | loader_platform_thread_unlock_mutex(&globalLock); |
| 344 | return pipelineMap[pipeline]; |
| 345 | } |
| 346 | |
| 347 | // For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 348 | static VkSamplerCreateInfo* getSamplerCreateInfo(const VkSampler sampler) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 349 | { |
| 350 | loader_platform_thread_lock_mutex(&globalLock); |
| 351 | if (sampleMap.find(sampler) == sampleMap.end()) { |
| 352 | loader_platform_thread_unlock_mutex(&globalLock); |
| 353 | return NULL; |
| 354 | } |
| 355 | loader_platform_thread_unlock_mutex(&globalLock); |
| 356 | return &sampleMap[sampler]->createInfo; |
| 357 | } |
| 358 | |
| 359 | // Init the pipeline mapping info based on pipeline create info LL tree |
| 360 | // Threading note : Calls to this function should wrapped in mutex |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 361 | static void initPipeline(PIPELINE_NODE* pPipeline, const VkGraphicsPipelineCreateInfo* pCreateInfo) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 362 | { |
| 363 | // First init create info, we'll shadow the structs as we go down the tree |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 364 | // TODO : Validate that no create info is incorrectly replicated |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 365 | memcpy(&pPipeline->graphicsPipelineCI, pCreateInfo, sizeof(VkGraphicsPipelineCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 366 | GENERIC_HEADER* pTrav = (GENERIC_HEADER*)pCreateInfo->pNext; |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 367 | GENERIC_HEADER* pPrev = (GENERIC_HEADER*)&pPipeline->graphicsPipelineCI; // Hold prev ptr to tie chain of structs together |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 368 | size_t bufferSize = 0; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 369 | VkPipelineVertexInputCreateInfo* pVICI = NULL; |
| 370 | VkPipelineCbStateCreateInfo* pCBCI = NULL; |
| 371 | VkPipelineShaderStageCreateInfo* pTmpPSSCI = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 372 | while (pTrav) { |
| 373 | switch (pTrav->sType) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 374 | case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 375 | pTmpPSSCI = (VkPipelineShaderStageCreateInfo*)pTrav; |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 376 | switch (pTmpPSSCI->shader.stage) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 377 | case VK_SHADER_STAGE_VERTEX: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 378 | pPrev->pNext = &pPipeline->vsCI; |
| 379 | pPrev = (GENERIC_HEADER*)&pPipeline->vsCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 380 | memcpy(&pPipeline->vsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 381 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 382 | case VK_SHADER_STAGE_TESS_CONTROL: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 383 | pPrev->pNext = &pPipeline->tcsCI; |
| 384 | pPrev = (GENERIC_HEADER*)&pPipeline->tcsCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 385 | memcpy(&pPipeline->tcsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 386 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 387 | case VK_SHADER_STAGE_TESS_EVALUATION: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 388 | pPrev->pNext = &pPipeline->tesCI; |
| 389 | pPrev = (GENERIC_HEADER*)&pPipeline->tesCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 390 | memcpy(&pPipeline->tesCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 391 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 392 | case VK_SHADER_STAGE_GEOMETRY: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 393 | pPrev->pNext = &pPipeline->gsCI; |
| 394 | pPrev = (GENERIC_HEADER*)&pPipeline->gsCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 395 | memcpy(&pPipeline->gsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 396 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 397 | case VK_SHADER_STAGE_FRAGMENT: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 398 | pPrev->pNext = &pPipeline->fsCI; |
| 399 | pPrev = (GENERIC_HEADER*)&pPipeline->fsCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 400 | memcpy(&pPipeline->fsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 401 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 402 | case VK_SHADER_STAGE_COMPUTE: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 403 | // TODO : Flag error, CS is specified through VkComputePipelineCreateInfo |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 404 | break; |
| 405 | default: |
| 406 | // TODO : Flag error |
| 407 | break; |
| 408 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 409 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 410 | case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 411 | pPrev->pNext = &pPipeline->vertexInputCI; |
| 412 | pPrev = (GENERIC_HEADER*)&pPipeline->vertexInputCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 413 | memcpy((void*)&pPipeline->vertexInputCI, pTrav, sizeof(VkPipelineVertexInputCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 414 | // Copy embedded ptrs |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 415 | pVICI = (VkPipelineVertexInputCreateInfo*)pTrav; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 416 | pPipeline->vtxBindingCount = pVICI->bindingCount; |
| 417 | if (pPipeline->vtxBindingCount) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 418 | pPipeline->pVertexBindingDescriptions = new VkVertexInputBindingDescription[pPipeline->vtxBindingCount]; |
| 419 | bufferSize = pPipeline->vtxBindingCount * sizeof(VkVertexInputBindingDescription); |
| 420 | memcpy((void*)pPipeline->pVertexBindingDescriptions, ((VkPipelineVertexInputCreateInfo*)pTrav)->pVertexAttributeDescriptions, bufferSize); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 421 | } |
| 422 | pPipeline->vtxAttributeCount = pVICI->attributeCount; |
| 423 | if (pPipeline->vtxAttributeCount) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 424 | pPipeline->pVertexAttributeDescriptions = new VkVertexInputAttributeDescription[pPipeline->vtxAttributeCount]; |
| 425 | bufferSize = pPipeline->vtxAttributeCount * sizeof(VkVertexInputAttributeDescription); |
| 426 | memcpy((void*)pPipeline->pVertexAttributeDescriptions, ((VkPipelineVertexInputCreateInfo*)pTrav)->pVertexAttributeDescriptions, bufferSize); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 427 | } |
| 428 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 429 | case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 430 | pPrev->pNext = &pPipeline->iaStateCI; |
| 431 | pPrev = (GENERIC_HEADER*)&pPipeline->iaStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 432 | memcpy((void*)&pPipeline->iaStateCI, pTrav, sizeof(VkPipelineIaStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 433 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 434 | case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 435 | pPrev->pNext = &pPipeline->tessStateCI; |
| 436 | pPrev = (GENERIC_HEADER*)&pPipeline->tessStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 437 | memcpy((void*)&pPipeline->tessStateCI, pTrav, sizeof(VkPipelineTessStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 438 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 439 | case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 440 | pPrev->pNext = &pPipeline->vpStateCI; |
| 441 | pPrev = (GENERIC_HEADER*)&pPipeline->vpStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 442 | memcpy((void*)&pPipeline->vpStateCI, pTrav, sizeof(VkPipelineVpStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 443 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 444 | case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 445 | pPrev->pNext = &pPipeline->rsStateCI; |
| 446 | pPrev = (GENERIC_HEADER*)&pPipeline->rsStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 447 | memcpy((void*)&pPipeline->rsStateCI, pTrav, sizeof(VkPipelineRsStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 448 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 449 | case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 450 | pPrev->pNext = &pPipeline->msStateCI; |
| 451 | pPrev = (GENERIC_HEADER*)&pPipeline->msStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 452 | memcpy((void*)&pPipeline->msStateCI, pTrav, sizeof(VkPipelineMsStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 453 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 454 | case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 455 | pPrev->pNext = &pPipeline->cbStateCI; |
| 456 | pPrev = (GENERIC_HEADER*)&pPipeline->cbStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 457 | memcpy((void*)&pPipeline->cbStateCI, pTrav, sizeof(VkPipelineCbStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 458 | // Copy embedded ptrs |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 459 | pCBCI = (VkPipelineCbStateCreateInfo*)pTrav; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 460 | pPipeline->attachmentCount = pCBCI->attachmentCount; |
| 461 | if (pPipeline->attachmentCount) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 462 | pPipeline->pAttachments = new VkPipelineCbAttachmentState[pPipeline->attachmentCount]; |
| 463 | bufferSize = pPipeline->attachmentCount * sizeof(VkPipelineCbAttachmentState); |
| 464 | memcpy((void*)pPipeline->pAttachments, ((VkPipelineCbStateCreateInfo*)pTrav)->pAttachments, bufferSize); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 465 | } |
| 466 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 467 | case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 468 | pPrev->pNext = &pPipeline->dsStateCI; |
| 469 | pPrev = (GENERIC_HEADER*)&pPipeline->dsStateCI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 470 | memcpy((void*)&pPipeline->dsStateCI, pTrav, sizeof(VkPipelineDsStateCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 471 | break; |
| 472 | default: |
| 473 | assert(0); |
| 474 | break; |
| 475 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 476 | pTrav = (GENERIC_HEADER*)pTrav->pNext; |
| 477 | } |
| 478 | pipelineMap[pPipeline->pipeline] = pPipeline; |
| 479 | } |
| 480 | // Free the Pipeline nodes |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 481 | static void deletePipelines() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 482 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 483 | for (unordered_map<VkPipeline, PIPELINE_NODE*>::iterator ii=pipelineMap.begin(); ii!=pipelineMap.end(); ++ii) { |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 484 | if ((*ii).second->pVertexBindingDescriptions) { |
| 485 | delete[] (*ii).second->pVertexBindingDescriptions; |
| 486 | } |
| 487 | if ((*ii).second->pVertexAttributeDescriptions) { |
| 488 | delete[] (*ii).second->pVertexAttributeDescriptions; |
| 489 | } |
| 490 | if ((*ii).second->pAttachments) { |
| 491 | delete[] (*ii).second->pAttachments; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 492 | } |
| 493 | delete (*ii).second; |
| 494 | } |
| 495 | } |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 496 | // For given pipeline, return number of MSAA samples, or one if MSAA disabled |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 497 | static uint32_t getNumSamples(const VkPipeline pipeline) |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 498 | { |
| 499 | PIPELINE_NODE* pPipe = pipelineMap[pipeline]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 500 | if (VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO == pPipe->msStateCI.sType) { |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 501 | if (pPipe->msStateCI.multisampleEnable) |
| 502 | return pPipe->msStateCI.samples; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 503 | } |
| 504 | return 1; |
| 505 | } |
| 506 | // Validate state related to the PSO |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 507 | static void validatePipelineState(const GLOBAL_CB_NODE* pCB, const VkPipelineBindPoint pipelineBindPoint, const VkPipeline pipeline) |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 508 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 509 | if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) { |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 510 | // Verify that any MSAA request in PSO matches sample# in bound FB |
| 511 | uint32_t psoNumSamples = getNumSamples(pipeline); |
| 512 | if (pCB->activeRenderPass) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 513 | VkRenderPassCreateInfo* pRPCI = renderPassMap[pCB->activeRenderPass]; |
| 514 | VkFramebufferCreateInfo* pFBCI = frameBufferMap[pCB->framebuffer]; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 515 | if (psoNumSamples != pFBCI->sampleCount) { |
| 516 | char str[1024]; |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 517 | sprintf(str, "Num samples mismatche! Binding PSO (%p) with %u samples while current RenderPass (%p) uses FB (%p) with %u samples!", (void*)pipeline, psoNumSamples, (void*)pCB->activeRenderPass, (void*)pCB->framebuffer, pFBCI->sampleCount); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 518 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", str); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 519 | } |
| 520 | } else { |
| 521 | // TODO : I believe it's an error if we reach this point and don't have an activeRenderPass |
| 522 | // Verify and flag error as appropriate |
| 523 | } |
| 524 | // TODO : Add more checks here |
| 525 | } else { |
| 526 | // TODO : Validate non-gfx pipeline updates |
| 527 | } |
| 528 | } |
| 529 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 530 | // Block of code at start here specifically for managing/tracking DSs |
| 531 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 532 | // Return Pool node ptr for specified pool or else NULL |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 533 | static POOL_NODE* getPoolNode(VkDescriptorPool pool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 534 | { |
| 535 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 536 | if (poolMap.find(pool) == poolMap.end()) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 537 | loader_platform_thread_unlock_mutex(&globalLock); |
| 538 | return NULL; |
| 539 | } |
| 540 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 541 | return poolMap[pool]; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 542 | } |
| 543 | // Return Set node ptr for specified set or else NULL |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 544 | static SET_NODE* getSetNode(VkDescriptorSet set) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 545 | { |
| 546 | loader_platform_thread_lock_mutex(&globalLock); |
| 547 | if (setMap.find(set) == setMap.end()) { |
| 548 | loader_platform_thread_unlock_mutex(&globalLock); |
| 549 | return NULL; |
| 550 | } |
| 551 | loader_platform_thread_unlock_mutex(&globalLock); |
| 552 | return setMap[set]; |
| 553 | } |
| 554 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 555 | // Return VK_TRUE if DS Exists and is within an vkBeginDescriptorPoolUpdate() call sequence, otherwise VK_FALSE |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 556 | static bool32_t dsUpdateActive(VkDescriptorSet ds) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 557 | { |
| 558 | // Note, both "get" functions use global mutex so this guy does not |
| 559 | SET_NODE* pTrav = getSetNode(ds); |
| 560 | if (pTrav) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 561 | POOL_NODE* pPool = getPoolNode(pTrav->pool); |
| 562 | if (pPool) { |
| 563 | return pPool->updateActive; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 564 | } |
| 565 | } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 566 | return VK_FALSE; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 567 | } |
| 568 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 569 | static LAYOUT_NODE* getLayoutNode(const VkDescriptorSetLayout layout) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 570 | loader_platform_thread_lock_mutex(&globalLock); |
| 571 | if (layoutMap.find(layout) == layoutMap.end()) { |
| 572 | loader_platform_thread_unlock_mutex(&globalLock); |
| 573 | return NULL; |
| 574 | } |
| 575 | loader_platform_thread_unlock_mutex(&globalLock); |
| 576 | return layoutMap[layout]; |
| 577 | } |
| 578 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 579 | // For given update struct, return binding |
| 580 | static uint32_t getUpdateBinding(const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 581 | { |
| 582 | switch (pUpdateStruct->sType) |
| 583 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 584 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 585 | return ((VkUpdateSamplers*)pUpdateStruct)->binding; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 586 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 587 | return ((VkUpdateSamplerTextures*)pUpdateStruct)->binding; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 588 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 589 | return ((VkUpdateImages*)pUpdateStruct)->binding; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 590 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 591 | return ((VkUpdateBuffers*)pUpdateStruct)->binding; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 592 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 593 | return ((VkUpdateAsCopy*)pUpdateStruct)->binding; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 594 | default: |
| 595 | // TODO : Flag specific error for this case |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 596 | assert(0); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 597 | return 0; |
| 598 | } |
| 599 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 600 | // Return count for given update struct |
| 601 | static uint32_t getUpdateArrayIndex(const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 602 | { |
| 603 | switch (pUpdateStruct->sType) |
| 604 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 605 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 606 | return (((VkUpdateSamplers*)pUpdateStruct)->arrayIndex); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 607 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 608 | return (((VkUpdateSamplerTextures*)pUpdateStruct)->arrayIndex); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 609 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 610 | return (((VkUpdateImages*)pUpdateStruct)->arrayIndex); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 611 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 612 | return (((VkUpdateBuffers*)pUpdateStruct)->arrayIndex); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 613 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 614 | // TODO : Need to understand this case better and make sure code is correct |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 615 | return (((VkUpdateAsCopy*)pUpdateStruct)->arrayElement); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 616 | default: |
| 617 | // TODO : Flag specific error for this case |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 618 | assert(0); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 619 | return 0; |
| 620 | } |
| 621 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 622 | // Return count for given update struct |
| 623 | static uint32_t getUpdateCount(const GENERIC_HEADER* pUpdateStruct) |
| 624 | { |
| 625 | switch (pUpdateStruct->sType) |
| 626 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 627 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 628 | return (((VkUpdateSamplers*)pUpdateStruct)->count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 629 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 630 | return (((VkUpdateSamplerTextures*)pUpdateStruct)->count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 631 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 632 | return (((VkUpdateImages*)pUpdateStruct)->count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 633 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 634 | return (((VkUpdateBuffers*)pUpdateStruct)->count); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 635 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 636 | // TODO : Need to understand this case better and make sure code is correct |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 637 | return (((VkUpdateAsCopy*)pUpdateStruct)->count); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 638 | default: |
| 639 | // TODO : Flag specific error for this case |
| 640 | assert(0); |
| 641 | return 0; |
| 642 | } |
| 643 | } |
| 644 | // For given Layout Node and binding, return index where that binding begins |
| 645 | static uint32_t getBindingStartIndex(const LAYOUT_NODE* pLayout, const uint32_t binding) |
| 646 | { |
| 647 | uint32_t offsetIndex = 0; |
| 648 | for (uint32_t i = 0; i<binding; i++) { |
| 649 | offsetIndex += pLayout->createInfo.pBinding[i].count; |
| 650 | } |
| 651 | return offsetIndex; |
| 652 | } |
| 653 | // For given layout node and binding, return last index that is updated |
| 654 | static uint32_t getBindingEndIndex(const LAYOUT_NODE* pLayout, const uint32_t binding) |
| 655 | { |
| 656 | uint32_t offsetIndex = 0; |
| 657 | for (uint32_t i = 0; i<=binding; i++) { |
| 658 | offsetIndex += pLayout->createInfo.pBinding[i].count; |
| 659 | } |
| 660 | return offsetIndex-1; |
| 661 | } |
| 662 | // For given layout and update, return the first overall index of the layout that is update |
| 663 | static uint32_t getUpdateStartIndex(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct) |
| 664 | { |
| 665 | return (getBindingStartIndex(pLayout, getUpdateBinding(pUpdateStruct))+getUpdateArrayIndex(pUpdateStruct)); |
| 666 | } |
| 667 | // For given layout and update, return the last overall index of the layout that is update |
| 668 | static uint32_t getUpdateEndIndex(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct) |
| 669 | { |
| 670 | return (getBindingStartIndex(pLayout, getUpdateBinding(pUpdateStruct))+getUpdateArrayIndex(pUpdateStruct)+getUpdateCount(pUpdateStruct)-1); |
| 671 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 672 | // Verify that the descriptor type in the update struct matches what's expected by the layout |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 673 | static bool32_t validateUpdateType(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 674 | { |
| 675 | // First get actual type of update |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 676 | VkDescriptorType actualType; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 677 | uint32_t i = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 678 | switch (pUpdateStruct->sType) |
| 679 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 680 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 681 | actualType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 682 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 683 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | ad87081 | 2015-04-15 15:29:59 -0600 | [diff] [blame] | 684 | actualType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 685 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 686 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 687 | actualType = ((VkUpdateImages*)pUpdateStruct)->descriptorType; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 688 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 689 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 690 | actualType = ((VkUpdateBuffers*)pUpdateStruct)->descriptorType; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 691 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 692 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 693 | actualType = ((VkUpdateAsCopy*)pUpdateStruct)->descriptorType; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 694 | break; |
| 695 | default: |
| 696 | // TODO : Flag specific error for this case |
| 697 | return 0; |
| 698 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 699 | for (i = getUpdateStartIndex(pLayout, pUpdateStruct); i <= getUpdateEndIndex(pLayout, pUpdateStruct); i++) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 700 | if (pLayout->pTypes[i] != actualType) |
| 701 | return 0; |
| 702 | } |
| 703 | return 1; |
| 704 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 705 | // Determine the update type, allocate a new struct of that type, shadow the given pUpdate |
| 706 | // struct into the new struct and return ptr to shadow struct cast as GENERIC_HEADER |
| 707 | // NOTE : Calls to this function should be wrapped in mutex |
| 708 | static GENERIC_HEADER* shadowUpdateNode(GENERIC_HEADER* pUpdate) |
| 709 | { |
| 710 | GENERIC_HEADER* pNewNode = NULL; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 711 | VkUpdateSamplers* pUS = NULL; |
| 712 | VkUpdateSamplerTextures* pUST = NULL; |
| 713 | VkUpdateBuffers* pUB = NULL; |
| 714 | VkUpdateImages* pUI = NULL; |
| 715 | VkUpdateAsCopy* pUAC = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 716 | size_t array_size = 0; |
| 717 | size_t base_array_size = 0; |
| 718 | size_t total_array_size = 0; |
| 719 | size_t baseBuffAddr = 0; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 720 | VkImageViewAttachInfo** ppLocalImageViews = NULL; |
| 721 | VkBufferViewAttachInfo** ppLocalBufferViews = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 722 | char str[1024]; |
| 723 | switch (pUpdate->sType) |
| 724 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 725 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 726 | pUS = new VkUpdateSamplers; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 727 | pNewNode = (GENERIC_HEADER*)pUS; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 728 | memcpy(pUS, pUpdate, sizeof(VkUpdateSamplers)); |
| 729 | pUS->pSamplers = new VkSampler[pUS->count]; |
| 730 | array_size = sizeof(VkSampler) * pUS->count; |
| 731 | memcpy((void*)pUS->pSamplers, ((VkUpdateSamplers*)pUpdate)->pSamplers, array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 732 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 733 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 734 | pUST = new VkUpdateSamplerTextures; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 735 | pNewNode = (GENERIC_HEADER*)pUST; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 736 | memcpy(pUST, pUpdate, sizeof(VkUpdateSamplerTextures)); |
| 737 | pUST->pSamplerImageViews = new VkSamplerImageViewInfo[pUST->count]; |
| 738 | array_size = sizeof(VkSamplerImageViewInfo) * pUST->count; |
| 739 | memcpy((void*)pUST->pSamplerImageViews, ((VkUpdateSamplerTextures*)pUpdate)->pSamplerImageViews, array_size); |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 740 | for (uint32_t i = 0; i < pUST->count; i++) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 741 | VkImageViewAttachInfo** ppIV = (VkImageViewAttachInfo**)&pUST->pSamplerImageViews[i].pImageView; |
| 742 | *ppIV = new VkImageViewAttachInfo; |
| 743 | memcpy((void*)*ppIV, ((VkUpdateSamplerTextures*)pUpdate)->pSamplerImageViews[i].pImageView, sizeof(VkImageViewAttachInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 744 | } |
| 745 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 746 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 747 | pUI = new VkUpdateImages; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 748 | pNewNode = (GENERIC_HEADER*)pUI; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 749 | memcpy(pUI, pUpdate, sizeof(VkUpdateImages)); |
| 750 | pUI->pImageViews = new VkImageViewAttachInfo[pUI->count]; |
| 751 | array_size = (sizeof(VkImageViewAttachInfo) * pUI->count); |
| 752 | memcpy((void*)pUI->pImageViews, ((VkUpdateImages*)pUpdate)->pImageViews, array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 753 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 754 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 755 | pUB = new VkUpdateBuffers; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 756 | pNewNode = (GENERIC_HEADER*)pUB; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 757 | memcpy(pUB, pUpdate, sizeof(VkUpdateBuffers)); |
| 758 | pUB->pBufferViews = new VkBufferViewAttachInfo[pUB->count]; |
| 759 | array_size = (sizeof(VkBufferViewAttachInfo) * pUB->count); |
| 760 | memcpy((void*)pUB->pBufferViews, ((VkUpdateBuffers*)pUpdate)->pBufferViews, array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 761 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 762 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 763 | pUAC = new VkUpdateAsCopy; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 764 | pUpdate = (GENERIC_HEADER*)pUAC; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 765 | memcpy(pUAC, pUpdate, sizeof(VkUpdateAsCopy)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 766 | break; |
| 767 | default: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 768 | sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdate->sType), pUpdate->sType); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 769 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 770 | return NULL; |
| 771 | } |
| 772 | // Make sure that pNext for the end of shadow copy is NULL |
| 773 | pNewNode->pNext = NULL; |
| 774 | return pNewNode; |
| 775 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 776 | // For given ds, update its mapping based on ppUpdateArray |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 777 | static void dsUpdate(VkDescriptorSet ds, uint32_t updateCount, const void** ppUpdateArray) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 778 | { |
| 779 | SET_NODE* pSet = getSetNode(ds); |
| 780 | loader_platform_thread_lock_mutex(&globalLock); |
| 781 | g_lastBoundDescriptorSet = pSet->set; |
| 782 | LAYOUT_NODE* pLayout = NULL; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 783 | VkDescriptorSetLayoutCreateInfo* pLayoutCI = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 784 | // TODO : If pCIList is NULL, flag error |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 785 | // Perform all updates |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 786 | for (uint32_t i = 0; i < updateCount; i++) { |
| 787 | GENERIC_HEADER* pUpdate = (GENERIC_HEADER*)ppUpdateArray[i]; |
| 788 | pLayout = pSet->pLayout; |
| 789 | // Make sure that binding is within bounds |
| 790 | if (pLayout->createInfo.count < getUpdateBinding(pUpdate)) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 791 | char str[1024]; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 792 | sprintf(str, "Descriptor Set %p does not have binding to match update binding %u for update type %s!", ds, getUpdateBinding(pUpdate), string_VkStructureType(pUpdate->sType)); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 793 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 794 | } |
| 795 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 796 | // Next verify that update falls within size of given binding |
| 797 | if (getBindingEndIndex(pLayout, getUpdateBinding(pUpdate)) < getUpdateEndIndex(pLayout, pUpdate)) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 798 | char str[48*1024]; // TODO : Keep count of layout CI structs and size this string dynamically based on that count |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 799 | pLayoutCI = &pLayout->createInfo; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 800 | string DSstr = vk_print_vkdescriptorsetlayoutcreateinfo(pLayoutCI, "{DS} "); |
| 801 | sprintf(str, "Descriptor update type of %s is out of bounds for matching binding %u in Layout w/ CI:\n%s!", string_VkStructureType(pUpdate->sType), getUpdateBinding(pUpdate), DSstr.c_str()); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 802 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 803 | } |
| 804 | else { // TODO : should we skip update on a type mismatch or force it? |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 805 | // Layout bindings match w/ update ok, now verify that update is of the right type |
| 806 | if (!validateUpdateType(pLayout, pUpdate)) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 807 | char str[1024]; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 808 | sprintf(str, "Descriptor update type of %s does not match overlapping binding type!", string_VkStructureType(pUpdate->sType)); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 809 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 810 | } |
| 811 | else { |
| 812 | // Save the update info |
| 813 | // TODO : Info message that update successful |
| 814 | // Create new update struct for this set's shadow copy |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 815 | GENERIC_HEADER* pNewNode = shadowUpdateNode(pUpdate); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 816 | if (NULL == pNewNode) { |
| 817 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 818 | sprintf(str, "Out of memory while attempting to allocate UPDATE struct in vkUpdateDescriptors()"); |
| 819 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 820 | } |
| 821 | else { |
| 822 | // Insert shadow node into LL of updates for this set |
| 823 | pNewNode->pNext = pSet->pUpdateStructs; |
| 824 | pSet->pUpdateStructs = pNewNode; |
| 825 | // Now update appropriate descriptor(s) to point to new Update node |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 826 | for (uint32_t j = getUpdateStartIndex(pLayout, pUpdate); j <= getUpdateEndIndex(pLayout, pUpdate); j++) { |
| 827 | assert(j<pSet->descriptorCount); |
| 828 | pSet->ppDescriptors[j] = pNewNode; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 829 | } |
| 830 | } |
| 831 | } |
| 832 | } |
| 833 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 834 | } |
| 835 | loader_platform_thread_unlock_mutex(&globalLock); |
| 836 | } |
| 837 | // Free the shadowed update node for this Set |
| 838 | // NOTE : Calls to this function should be wrapped in mutex |
| 839 | static void freeShadowUpdateTree(SET_NODE* pSet) |
| 840 | { |
| 841 | GENERIC_HEADER* pShadowUpdate = pSet->pUpdateStructs; |
| 842 | pSet->pUpdateStructs = NULL; |
| 843 | GENERIC_HEADER* pFreeUpdate = pShadowUpdate; |
| 844 | // Clear the descriptor mappings as they will now be invalid |
| 845 | memset(pSet->ppDescriptors, 0, pSet->descriptorCount*sizeof(GENERIC_HEADER*)); |
| 846 | while(pShadowUpdate) { |
| 847 | pFreeUpdate = pShadowUpdate; |
| 848 | pShadowUpdate = (GENERIC_HEADER*)pShadowUpdate->pNext; |
| 849 | uint32_t index = 0; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 850 | VkUpdateSamplers* pUS = NULL; |
| 851 | VkUpdateSamplerTextures* pUST = NULL; |
| 852 | VkUpdateImages* pUI = NULL; |
| 853 | VkUpdateBuffers* pUB = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 854 | void** ppToFree = NULL; |
| 855 | switch (pFreeUpdate->sType) |
| 856 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 857 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 858 | pUS = (VkUpdateSamplers*)pFreeUpdate; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 859 | if (pUS->pSamplers) |
| 860 | delete[] pUS->pSamplers; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 861 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 862 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 863 | pUST = (VkUpdateSamplerTextures*)pFreeUpdate; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 864 | if (pUST->pSamplerImageViews) { |
| 865 | for (index = 0; index < pUST->count; index++) { |
| 866 | if (pUST->pSamplerImageViews[index].pImageView) { |
| 867 | delete pUST->pSamplerImageViews[index].pImageView; |
| 868 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 869 | } |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 870 | delete[] pUST->pSamplerImageViews; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 871 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 872 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 873 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 874 | pUI = (VkUpdateImages*)pFreeUpdate; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 875 | if (pUI->pImageViews) |
| 876 | delete[] pUI->pImageViews; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 877 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 878 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 879 | pUB = (VkUpdateBuffers*)pFreeUpdate; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 880 | if (pUB->pBufferViews) |
| 881 | delete[] pUB->pBufferViews; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 882 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 883 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 884 | break; |
| 885 | default: |
| 886 | assert(0); |
| 887 | break; |
| 888 | } |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 889 | delete pFreeUpdate; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 890 | } |
| 891 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 892 | // Free all DS Pools including their Sets & related sub-structs |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 893 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 894 | static void deletePools() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 895 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 896 | for (unordered_map<VkDescriptorPool, POOL_NODE*>::iterator ii=poolMap.begin(); ii!=poolMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 897 | SET_NODE* pSet = (*ii).second->pSets; |
| 898 | SET_NODE* pFreeSet = pSet; |
| 899 | while (pSet) { |
| 900 | pFreeSet = pSet; |
| 901 | pSet = pSet->pNext; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 902 | // Freeing layouts handled in deleteLayouts() function |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 903 | // Free Update shadow struct tree |
| 904 | freeShadowUpdateTree(pFreeSet); |
| 905 | if (pFreeSet->ppDescriptors) { |
| 906 | delete pFreeSet->ppDescriptors; |
| 907 | } |
| 908 | delete pFreeSet; |
| 909 | } |
| 910 | if ((*ii).second->createInfo.pTypeCount) { |
| 911 | delete (*ii).second->createInfo.pTypeCount; |
| 912 | } |
| 913 | delete (*ii).second; |
| 914 | } |
| 915 | } |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 916 | // WARN : Once deleteLayouts() called, any layout ptrs in Pool/Set data structure will be invalid |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 917 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 918 | static void deleteLayouts() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 919 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 920 | for (unordered_map<VkDescriptorSetLayout, LAYOUT_NODE*>::iterator ii=layoutMap.begin(); ii!=layoutMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 921 | LAYOUT_NODE* pLayout = (*ii).second; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 922 | if (pLayout->createInfo.pBinding) { |
| 923 | for (uint32_t i=0; i<pLayout->createInfo.count; i++) { |
| 924 | if (pLayout->createInfo.pBinding[i].pImmutableSamplers) |
| 925 | delete[] pLayout->createInfo.pBinding[i].pImmutableSamplers; |
| 926 | } |
| 927 | delete[] pLayout->createInfo.pBinding; |
| 928 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 929 | if (pLayout->pTypes) { |
| 930 | delete pLayout->pTypes; |
| 931 | } |
| 932 | delete pLayout; |
| 933 | } |
| 934 | } |
| 935 | // Currently clearing a set is removing all previous updates to that set |
| 936 | // TODO : Validate if this is correct clearing behavior |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 937 | static void clearDescriptorSet(VkDescriptorSet set) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 938 | { |
| 939 | SET_NODE* pSet = getSetNode(set); |
| 940 | if (!pSet) { |
| 941 | // TODO : Return error |
| 942 | } |
| 943 | else { |
| 944 | loader_platform_thread_lock_mutex(&globalLock); |
| 945 | freeShadowUpdateTree(pSet); |
| 946 | loader_platform_thread_unlock_mutex(&globalLock); |
| 947 | } |
| 948 | } |
| 949 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 950 | static void clearDescriptorPool(VkDescriptorPool pool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 951 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 952 | POOL_NODE* pPool = getPoolNode(pool); |
| 953 | if (!pPool) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 954 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 955 | sprintf(str, "Unable to find pool node for pool %p specified in vkClearDescriptorPool() call", (void*)pool); |
| 956 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pool, 0, DRAWSTATE_INVALID_POOL, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 957 | } |
| 958 | else |
| 959 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 960 | // For every set off of this pool, clear it |
| 961 | SET_NODE* pSet = pPool->pSets; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 962 | while (pSet) { |
| 963 | clearDescriptorSet(pSet->set); |
| 964 | } |
| 965 | } |
| 966 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 967 | // Code here to manage the Cmd buffer LL |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 968 | static GLOBAL_CB_NODE* getCBNode(VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 969 | { |
| 970 | loader_platform_thread_lock_mutex(&globalLock); |
| 971 | if (cmdBufferMap.find(cb) == cmdBufferMap.end()) { |
| 972 | loader_platform_thread_unlock_mutex(&globalLock); |
| 973 | return NULL; |
| 974 | } |
| 975 | loader_platform_thread_unlock_mutex(&globalLock); |
| 976 | return cmdBufferMap[cb]; |
| 977 | } |
| 978 | // Free all CB Nodes |
| 979 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 980 | static void deleteCmdBuffers() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 981 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 982 | for (unordered_map<VkCmdBuffer, GLOBAL_CB_NODE*>::iterator ii=cmdBufferMap.begin(); ii!=cmdBufferMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 983 | while (!(*ii).second->pCmds.empty()) { |
| 984 | delete (*ii).second->pCmds.back(); |
| 985 | (*ii).second->pCmds.pop_back(); |
| 986 | } |
| 987 | delete (*ii).second; |
| 988 | } |
| 989 | } |
| 990 | static void addCmd(GLOBAL_CB_NODE* pCB, const CMD_TYPE cmd) |
| 991 | { |
| 992 | CMD_NODE* pCmd = new CMD_NODE; |
| 993 | if (pCmd) { |
| 994 | // init cmd node and append to end of cmd LL |
| 995 | memset(pCmd, 0, sizeof(CMD_NODE)); |
| 996 | pCmd->cmdNumber = ++pCB->numCmds; |
| 997 | pCmd->type = cmd; |
| 998 | pCB->pCmds.push_back(pCmd); |
| 999 | } |
| 1000 | else { |
| 1001 | char str[1024]; |
| 1002 | sprintf(str, "Out of memory while attempting to allocate new CMD_NODE for cmdBuffer %p", (void*)pCB->cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1003 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCB->cmdBuffer, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1004 | } |
| 1005 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1006 | static void resetCB(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1007 | { |
| 1008 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1009 | if (pCB) { |
| 1010 | while (!pCB->pCmds.empty()) { |
| 1011 | delete pCB->pCmds.back(); |
| 1012 | pCB->pCmds.pop_back(); |
| 1013 | } |
| 1014 | // Reset CB state |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1015 | VkFlags saveFlags = pCB->flags; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1016 | uint32_t saveQueueNodeIndex = pCB->queueNodeIndex; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1017 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
| 1018 | pCB->cmdBuffer = cb; |
| 1019 | pCB->flags = saveFlags; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1020 | pCB->queueNodeIndex = saveQueueNodeIndex; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1021 | pCB->lastVtxBinding = MAX_BINDING; |
| 1022 | } |
| 1023 | } |
| 1024 | // Set the last bound dynamic state of given type |
| 1025 | // TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer? |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1026 | static void setLastBoundDynamicState(const VkCmdBuffer cmdBuffer, const VkDynamicStateObject state, const VkStateBindPoint sType) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1027 | { |
| 1028 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1029 | if (pCB) { |
| 1030 | updateCBTracking(cmdBuffer); |
| 1031 | loader_platform_thread_lock_mutex(&globalLock); |
| 1032 | addCmd(pCB, CMD_BINDDYNAMICSTATEOBJECT); |
| 1033 | if (dynamicStateMap.find(state) == dynamicStateMap.end()) { |
| 1034 | char str[1024]; |
| 1035 | sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1036 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1037 | } |
| 1038 | else { |
| 1039 | pCB->lastBoundDynamicState[sType] = dynamicStateMap[state]; |
| 1040 | g_lastBoundDynamicState[sType] = dynamicStateMap[state]; |
| 1041 | } |
| 1042 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1043 | } |
| 1044 | else { |
| 1045 | char str[1024]; |
| 1046 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1047 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1048 | } |
| 1049 | } |
| 1050 | // Print the last bound Gfx Pipeline |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1051 | static void printPipeline(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1052 | { |
| 1053 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1054 | if (pCB) { |
| 1055 | PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline); |
| 1056 | if (!pPipeTrav) { |
| 1057 | // nothing to print |
| 1058 | } |
| 1059 | else { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1060 | string pipeStr = vk_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "{DS}").c_str(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1061 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr.c_str()); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1062 | } |
| 1063 | } |
| 1064 | } |
| 1065 | // Common Dot dumping code |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1066 | static void dsCoreDumpDot(const VkDescriptorSet ds, FILE* pOutFile) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1067 | { |
| 1068 | SET_NODE* pSet = getSetNode(ds); |
| 1069 | if (pSet) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1070 | POOL_NODE* pPool = getPoolNode(pSet->pool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1071 | char tmp_str[4*1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1072 | fprintf(pOutFile, "subgraph cluster_DescriptorPool\n{\nlabel=\"Descriptor Pool\"\n"); |
| 1073 | sprintf(tmp_str, "Pool (%p)", pPool->pool); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1074 | char* pGVstr = vk_gv_print_vkdescriptorpoolcreateinfo(&pPool->createInfo, tmp_str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1075 | fprintf(pOutFile, "%s", pGVstr); |
| 1076 | free(pGVstr); |
| 1077 | fprintf(pOutFile, "subgraph cluster_DescriptorSet\n{\nlabel=\"Descriptor Set (%p)\"\n", pSet->set); |
| 1078 | sprintf(tmp_str, "Descriptor Set (%p)", pSet->set); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1079 | LAYOUT_NODE* pLayout = pSet->pLayout; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1080 | uint32_t layout_index = 0; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1081 | ++layout_index; |
| 1082 | sprintf(tmp_str, "LAYOUT%u", layout_index); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1083 | pGVstr = vk_gv_print_vkdescriptorsetlayoutcreateinfo(&pLayout->createInfo, tmp_str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1084 | fprintf(pOutFile, "%s", pGVstr); |
| 1085 | free(pGVstr); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1086 | if (pSet->pUpdateStructs) { |
| 1087 | pGVstr = dynamic_gv_display(pSet->pUpdateStructs, "Descriptor Updates"); |
| 1088 | fprintf(pOutFile, "%s", pGVstr); |
| 1089 | free(pGVstr); |
| 1090 | } |
| 1091 | if (pSet->ppDescriptors) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1092 | fprintf(pOutFile, "\"DESCRIPTORS\" [\nlabel=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD COLSPAN=\"2\" PORT=\"desc\">DESCRIPTORS</TD></TR>"); |
| 1093 | uint32_t i = 0; |
| 1094 | for (i=0; i < pSet->descriptorCount; i++) { |
| 1095 | if (pSet->ppDescriptors[i]) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1096 | fprintf(pOutFile, "<TR><TD PORT=\"slot%u\">slot%u</TD><TD>%s</TD></TR>", i, i, string_VkStructureType(pSet->ppDescriptors[i]->sType)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1097 | } |
| 1098 | } |
| 1099 | #define NUM_COLORS 7 |
| 1100 | vector<string> edgeColors; |
| 1101 | edgeColors.push_back("0000ff"); |
| 1102 | edgeColors.push_back("ff00ff"); |
| 1103 | edgeColors.push_back("ffff00"); |
| 1104 | edgeColors.push_back("00ff00"); |
| 1105 | edgeColors.push_back("000000"); |
| 1106 | edgeColors.push_back("00ffff"); |
| 1107 | edgeColors.push_back("ff0000"); |
| 1108 | uint32_t colorIdx = 0; |
| 1109 | fprintf(pOutFile, "</TABLE>>\n];\n"); |
| 1110 | // Now add the views that are mapped to active descriptors |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1111 | VkUpdateSamplers* pUS = NULL; |
| 1112 | VkUpdateSamplerTextures* pUST = NULL; |
| 1113 | VkUpdateImages* pUI = NULL; |
| 1114 | VkUpdateBuffers* pUB = NULL; |
| 1115 | VkUpdateAsCopy* pUAC = NULL; |
| 1116 | VkSamplerCreateInfo* pSCI = NULL; |
| 1117 | VkImageViewCreateInfo* pIVCI = NULL; |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 1118 | VkBufferViewCreateInfo* pBVCI = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1119 | void** ppNextPtr = NULL; |
| 1120 | void* pSaveNext = NULL; |
| 1121 | for (i=0; i < pSet->descriptorCount; i++) { |
| 1122 | if (pSet->ppDescriptors[i]) { |
| 1123 | switch (pSet->ppDescriptors[i]->sType) |
| 1124 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1125 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1126 | pUS = (VkUpdateSamplers*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1127 | pSCI = getSamplerCreateInfo(pUS->pSamplers[i-pUS->arrayIndex]); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1128 | if (pSCI) { |
| 1129 | sprintf(tmp_str, "SAMPLER%u", i); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1130 | fprintf(pOutFile, "%s", vk_gv_print_vksamplercreateinfo(pSCI, tmp_str)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1131 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1132 | } |
| 1133 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1134 | case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1135 | pUST = (VkUpdateSamplerTextures*)pSet->ppDescriptors[i]; |
Courtney Goeltzenleuchter | d38dcc9 | 2015-04-09 11:43:10 -0600 | [diff] [blame] | 1136 | pSCI = getSamplerCreateInfo(pUST->pSamplerImageViews[i-pUST->arrayIndex].sampler); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1137 | if (pSCI) { |
| 1138 | sprintf(tmp_str, "SAMPLER%u", i); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1139 | fprintf(pOutFile, "%s", vk_gv_print_vksamplercreateinfo(pSCI, tmp_str)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1140 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1141 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1142 | pIVCI = getImageViewCreateInfo(pUST->pSamplerImageViews[i-pUST->arrayIndex].pImageView->view); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1143 | if (pIVCI) { |
| 1144 | sprintf(tmp_str, "IMAGE_VIEW%u", i); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1145 | fprintf(pOutFile, "%s", vk_gv_print_vkimageviewcreateinfo(pIVCI, tmp_str)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1146 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1147 | } |
| 1148 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1149 | case VK_STRUCTURE_TYPE_UPDATE_IMAGES: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1150 | pUI = (VkUpdateImages*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1151 | pIVCI = getImageViewCreateInfo(pUI->pImageViews[i-pUI->arrayIndex].view); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1152 | if (pIVCI) { |
| 1153 | sprintf(tmp_str, "IMAGE_VIEW%u", i); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1154 | fprintf(pOutFile, "%s", vk_gv_print_vkimageviewcreateinfo(pIVCI, tmp_str)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1155 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1156 | } |
| 1157 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1158 | case VK_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1159 | pUB = (VkUpdateBuffers*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1160 | pBVCI = getBufferViewCreateInfo(pUB->pBufferViews[i-pUB->arrayIndex].view); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1161 | if (pBVCI) { |
| 1162 | sprintf(tmp_str, "BUFFER_VIEW%u", i); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 1163 | fprintf(pOutFile, "%s", vk_gv_print_vkbufferviewcreateinfo(pBVCI, tmp_str)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1164 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1165 | } |
| 1166 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1167 | case VK_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1168 | pUAC = (VkUpdateAsCopy*)pSet->ppDescriptors[i]; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1169 | // TODO : Need to validate this code |
| 1170 | // Save off pNext and set to NULL while printing this struct, then restore it |
| 1171 | ppNextPtr = (void**)&pUAC->pNext; |
| 1172 | pSaveNext = *ppNextPtr; |
| 1173 | *ppNextPtr = NULL; |
| 1174 | sprintf(tmp_str, "UPDATE_AS_COPY%u", i); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1175 | fprintf(pOutFile, "%s", vk_gv_print_vkupdateascopy(pUAC, tmp_str)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1176 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1177 | // Restore next ptr |
| 1178 | *ppNextPtr = pSaveNext; |
| 1179 | break; |
| 1180 | default: |
| 1181 | break; |
| 1182 | } |
| 1183 | colorIdx = (colorIdx+1) % NUM_COLORS; |
| 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | fprintf(pOutFile, "}\n"); |
| 1188 | fprintf(pOutFile, "}\n"); |
| 1189 | } |
| 1190 | } |
| 1191 | // Dump subgraph w/ DS info |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1192 | static void dsDumpDot(const VkCmdBuffer cb, FILE* pOutFile) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1193 | { |
| 1194 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1195 | if (pCB && pCB->lastBoundDescriptorSet) { |
| 1196 | dsCoreDumpDot(pCB->lastBoundDescriptorSet, pOutFile); |
| 1197 | } |
| 1198 | } |
| 1199 | // Dump a GraphViz dot file showing the Cmd Buffers |
| 1200 | static void cbDumpDotFile(string outFileName) |
| 1201 | { |
| 1202 | // Print CB Chain for each CB |
| 1203 | FILE* pOutFile; |
| 1204 | pOutFile = fopen(outFileName.c_str(), "w"); |
| 1205 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 1206 | fprintf(pOutFile, "subgraph cluster_cmdBuffers\n{\nlabel=\"Command Buffers\"\n"); |
| 1207 | GLOBAL_CB_NODE* pCB = NULL; |
| 1208 | for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) { |
| 1209 | pCB = g_pLastTouchedCB[i]; |
| 1210 | if (pCB) { |
| 1211 | fprintf(pOutFile, "subgraph cluster_cmdBuffer%u\n{\nlabel=\"Command Buffer #%u\"\n", i, i); |
| 1212 | uint32_t instNum = 0; |
| 1213 | for (vector<CMD_NODE*>::iterator ii=pCB->pCmds.begin(); ii!=pCB->pCmds.end(); ++ii) { |
| 1214 | if (instNum) { |
| 1215 | fprintf(pOutFile, "\"CB%pCMD%u\" -> \"CB%pCMD%u\" [];\n", (void*)pCB->cmdBuffer, instNum-1, (void*)pCB->cmdBuffer, instNum); |
| 1216 | } |
| 1217 | if (pCB == g_lastGlobalCB) { |
| 1218 | fprintf(pOutFile, "\"CB%pCMD%u\" [\nlabel=<<TABLE BGCOLOR=\"#00FF00\" BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD>CMD#</TD><TD>%u</TD></TR><TR><TD>CMD Type</TD><TD>%s</TD></TR></TABLE>>\n];\n", (void*)pCB->cmdBuffer, instNum, instNum, cmdTypeToString((*ii)->type).c_str()); |
| 1219 | } |
| 1220 | else { |
| 1221 | fprintf(pOutFile, "\"CB%pCMD%u\" [\nlabel=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD>CMD#</TD><TD>%u</TD></TR><TR><TD>CMD Type</TD><TD>%s</TD></TR></TABLE>>\n];\n", (void*)pCB->cmdBuffer, instNum, instNum, cmdTypeToString((*ii)->type).c_str()); |
| 1222 | } |
| 1223 | ++instNum; |
| 1224 | } |
| 1225 | fprintf(pOutFile, "}\n"); |
| 1226 | } |
| 1227 | } |
| 1228 | fprintf(pOutFile, "}\n"); |
| 1229 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 1230 | fclose(pOutFile); |
| 1231 | } |
| 1232 | // Dump a GraphViz dot file showing the pipeline for last bound global state |
| 1233 | static void dumpGlobalDotFile(char *outFileName) |
| 1234 | { |
| 1235 | PIPELINE_NODE *pPipeTrav = g_lastBoundPipeline; |
| 1236 | if (pPipeTrav) { |
| 1237 | FILE* pOutFile; |
| 1238 | pOutFile = fopen(outFileName, "w"); |
| 1239 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 1240 | fprintf(pOutFile, "subgraph cluster_dynamicState\n{\nlabel=\"Dynamic State\"\n"); |
| 1241 | char* pGVstr = NULL; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1242 | for (uint32_t i = 0; i < VK_NUM_STATE_BIND_POINT; i++) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1243 | if (g_lastBoundDynamicState[i] && g_lastBoundDynamicState[i]->pCreateInfo) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1244 | pGVstr = dynamic_gv_display(g_lastBoundDynamicState[i]->pCreateInfo, string_VkStateBindPoint((VkStateBindPoint)i)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1245 | fprintf(pOutFile, "%s", pGVstr); |
| 1246 | free(pGVstr); |
| 1247 | } |
| 1248 | } |
| 1249 | fprintf(pOutFile, "}\n"); // close dynamicState subgraph |
| 1250 | fprintf(pOutFile, "subgraph cluster_PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1251 | pGVstr = vk_gv_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "PSO HEAD"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1252 | fprintf(pOutFile, "%s", pGVstr); |
| 1253 | free(pGVstr); |
| 1254 | fprintf(pOutFile, "}\n"); |
| 1255 | dsCoreDumpDot(g_lastBoundDescriptorSet, pOutFile); |
| 1256 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 1257 | fclose(pOutFile); |
| 1258 | } |
| 1259 | } |
| 1260 | // Dump a GraphViz dot file showing the pipeline for a given CB |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1261 | static void dumpDotFile(const VkCmdBuffer cb, string outFileName) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1262 | { |
| 1263 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1264 | if (pCB) { |
| 1265 | PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline); |
| 1266 | if (pPipeTrav) { |
| 1267 | FILE* pOutFile; |
| 1268 | pOutFile = fopen(outFileName.c_str(), "w"); |
| 1269 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 1270 | fprintf(pOutFile, "subgraph cluster_dynamicState\n{\nlabel=\"Dynamic State\"\n"); |
| 1271 | char* pGVstr = NULL; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1272 | for (uint32_t i = 0; i < VK_NUM_STATE_BIND_POINT; i++) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1273 | if (pCB->lastBoundDynamicState[i] && pCB->lastBoundDynamicState[i]->pCreateInfo) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1274 | pGVstr = dynamic_gv_display(pCB->lastBoundDynamicState[i]->pCreateInfo, string_VkStateBindPoint((VkStateBindPoint)i)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1275 | fprintf(pOutFile, "%s", pGVstr); |
| 1276 | free(pGVstr); |
| 1277 | } |
| 1278 | } |
| 1279 | fprintf(pOutFile, "}\n"); // close dynamicState subgraph |
| 1280 | fprintf(pOutFile, "subgraph cluster_PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1281 | pGVstr = vk_gv_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "PSO HEAD"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1282 | fprintf(pOutFile, "%s", pGVstr); |
| 1283 | free(pGVstr); |
| 1284 | fprintf(pOutFile, "}\n"); |
| 1285 | dsDumpDot(cb, pOutFile); |
| 1286 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 1287 | fclose(pOutFile); |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | // Verify VB Buffer binding |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1292 | static void validateVBBinding(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1293 | { |
| 1294 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1295 | if (pCB && pCB->lastBoundPipeline) { |
| 1296 | // First verify that we have a Node for bound pipeline |
| 1297 | PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline); |
| 1298 | char str[1024]; |
| 1299 | if (!pPipeTrav) { |
| 1300 | sprintf(str, "Can't find last bound Pipeline %p!", (void*)pCB->lastBoundPipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1301 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_PIPELINE_BOUND, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1302 | } |
| 1303 | else { |
| 1304 | // Verify Vtx binding |
| 1305 | if (MAX_BINDING != pCB->lastVtxBinding) { |
| 1306 | if (pCB->lastVtxBinding >= pPipeTrav->vtxBindingCount) { |
| 1307 | if (0 == pPipeTrav->vtxBindingCount) { |
| 1308 | sprintf(str, "Vtx Buffer Index %u was bound, but no vtx buffers are attached to PSO.", pCB->lastVtxBinding); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1309 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1310 | } |
| 1311 | else { |
| 1312 | sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", pCB->lastVtxBinding, (pPipeTrav->vtxBindingCount - 1)); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1313 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1314 | } |
| 1315 | } |
| 1316 | else { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1317 | string tmpStr = vk_print_vkvertexinputbindingdescription(&pPipeTrav->pVertexBindingDescriptions[pCB->lastVtxBinding], "{DS}INFO : ").c_str(); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1318 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr.c_str()); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1319 | } |
| 1320 | } |
| 1321 | } |
| 1322 | } |
| 1323 | } |
| 1324 | // Print details of DS config to stdout |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1325 | static void printDSConfig(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1326 | { |
| 1327 | char tmp_str[1024]; |
| 1328 | 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. |
| 1329 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1330 | if (pCB) { |
| 1331 | SET_NODE* pSet = getSetNode(pCB->lastBoundDescriptorSet); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1332 | POOL_NODE* pPool = getPoolNode(pSet->pool); |
| 1333 | // Print out pool details |
| 1334 | sprintf(tmp_str, "Details for pool %p.", (void*)pPool->pool); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1335 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1336 | string poolStr = vk_print_vkdescriptorpoolcreateinfo(&pPool->createInfo, " "); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1337 | sprintf(ds_config_str, "%s", poolStr.c_str()); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1338 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1339 | // Print out set details |
| 1340 | char prefix[10]; |
| 1341 | uint32_t index = 0; |
| 1342 | sprintf(tmp_str, "Details for descriptor set %p.", (void*)pSet->set); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1343 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1344 | LAYOUT_NODE* pLayout = pSet->pLayout; |
| 1345 | // Print layout details |
| 1346 | sprintf(tmp_str, "Layout #%u, (object %p) for DS %p.", index+1, (void*)pLayout->layout, (void*)pSet->set); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1347 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1348 | sprintf(prefix, " [L%u] ", index); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1349 | string DSLstr = vk_print_vkdescriptorsetlayoutcreateinfo(&pLayout->createInfo, prefix).c_str(); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1350 | sprintf(ds_config_str, "%s", DSLstr.c_str()); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1351 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1352 | index++; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1353 | GENERIC_HEADER* pUpdate = pSet->pUpdateStructs; |
| 1354 | if (pUpdate) { |
| 1355 | sprintf(tmp_str, "Update Chain [UC] for descriptor set %p:", (void*)pSet->set); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1356 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1357 | sprintf(prefix, " [UC] "); |
| 1358 | sprintf(ds_config_str, "%s", dynamic_display(pUpdate, prefix).c_str()); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1359 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1360 | // TODO : If there is a "view" associated with this update, print CI for that view |
| 1361 | } |
| 1362 | else { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1363 | sprintf(tmp_str, "No Update Chain for descriptor set %p (vkUpdateDescriptors has not been called)", (void*)pSet->set); |
| 1364 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1369 | static void printCB(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1370 | { |
| 1371 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1372 | if (pCB) { |
| 1373 | char str[1024]; |
| 1374 | sprintf(str, "Cmds in CB %p", (void*)cb); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1375 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1376 | for (vector<CMD_NODE*>::iterator ii=pCB->pCmds.begin(); ii!=pCB->pCmds.end(); ++ii) { |
| 1377 | sprintf(str, " CMD#%lu: %s", (*ii)->cmdNumber, cmdTypeToString((*ii)->type).c_str()); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1378 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cb, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1379 | } |
| 1380 | } |
| 1381 | else { |
| 1382 | // Nothing to print |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1387 | static void synchAndPrintDSConfig(const VkCmdBuffer cb) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1388 | { |
| 1389 | printDSConfig(cb); |
| 1390 | printPipeline(cb); |
| 1391 | printDynamicState(cb); |
| 1392 | static int autoDumpOnce = 0; |
| 1393 | if (autoDumpOnce) { |
| 1394 | autoDumpOnce = 0; |
| 1395 | dumpDotFile(cb, "pipeline_dump.dot"); |
| 1396 | cbDumpDotFile("cb_dump.dot"); |
| 1397 | #if defined(_WIN32) |
| 1398 | // FIXME: NEED WINDOWS EQUIVALENT |
| 1399 | #else // WIN32 |
| 1400 | // Convert dot to svg if dot available |
| 1401 | if(access( "/usr/bin/dot", X_OK) != -1) { |
Tony Barbour | 22a3086 | 2015-04-22 09:02:32 -0600 | [diff] [blame] | 1402 | int retval = system("/usr/bin/dot pipeline_dump.dot -Tsvg -o pipeline_dump.svg"); |
| 1403 | assert(retval != -1); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1404 | } |
| 1405 | #endif // WIN32 |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | static void initDrawState(void) |
| 1410 | { |
| 1411 | const char *strOpt; |
| 1412 | // initialize DrawState options |
| 1413 | getLayerOptionEnum("DrawStateReportLevel", (uint32_t *) &g_reportingLevel); |
| 1414 | g_actionIsDefault = getLayerOptionEnum("DrawStateDebugAction", (uint32_t *) &g_debugAction); |
| 1415 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1416 | if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1417 | { |
| 1418 | strOpt = getLayerOption("DrawStateLogFilename"); |
| 1419 | if (strOpt) |
| 1420 | { |
| 1421 | g_logFile = fopen(strOpt, "w"); |
| 1422 | } |
| 1423 | if (g_logFile == NULL) |
| 1424 | g_logFile = stdout; |
| 1425 | } |
| 1426 | // initialize Layer dispatch table |
| 1427 | // TODO handle multiple GPUs |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1428 | PFN_vkGetProcAddr fpNextGPA; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1429 | fpNextGPA = pCurObj->pGPA; |
| 1430 | assert(fpNextGPA); |
| 1431 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1432 | layer_initialize_dispatch_table(&nextTable, fpNextGPA, (VkPhysicalDevice) pCurObj->nextObject); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1433 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1434 | if (!globalLockInitialized) |
| 1435 | { |
| 1436 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1437 | // suggestion is to call this during vkCreateInstance(), and then we |
| 1438 | // can clean it up during vkDestroyInstance(). However, that requires |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1439 | // that the layer have per-instance locks. We need to come back and |
| 1440 | // address this soon. |
| 1441 | loader_platform_thread_create_mutex(&globalLock); |
| 1442 | globalLockInitialized = 1; |
| 1443 | } |
| 1444 | } |
| 1445 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1446 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1447 | { |
Jon Ashburn | 630e44f | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 1448 | pCurObj = (VkBaseLayerObject *) gpu; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1449 | loader_platform_thread_once(&g_initOnce, initDrawState); |
Jon Ashburn | 630e44f | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 1450 | VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1451 | return result; |
| 1452 | } |
| 1453 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1454 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1455 | { |
| 1456 | // Free all the memory |
| 1457 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 1458 | deletePipelines(); |
| 1459 | deleteSamplers(); |
| 1460 | deleteImages(); |
| 1461 | deleteBuffers(); |
| 1462 | deleteCmdBuffers(); |
| 1463 | deleteDynamicState(); |
| 1464 | deletePools(); |
| 1465 | deleteLayouts(); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1466 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1467 | VkResult result = nextTable.DestroyDevice(device); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1468 | return result; |
| 1469 | } |
| 1470 | |
Jon Ashburn | eb2728b | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1471 | struct extProps { |
| 1472 | uint32_t version; |
| 1473 | const char * const name; |
| 1474 | }; |
Jon Ashburn | bdcd756 | 2015-04-14 14:12:59 -0600 | [diff] [blame] | 1475 | #define DRAW_STATE_LAYER_EXT_ARRAY_SIZE 5 |
Jon Ashburn | eb2728b | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1476 | static const struct extProps dsExts[DRAW_STATE_LAYER_EXT_ARRAY_SIZE] = { |
| 1477 | // TODO what is the version? |
Jon Ashburn | bdcd756 | 2015-04-14 14:12:59 -0600 | [diff] [blame] | 1478 | 0x10, "DrawState", |
| 1479 | 0x10, "Validation", |
| 1480 | 0x10, "drawStateDumpDotFile", |
| 1481 | 0x10, "drawStateDumpCommandBufferDotFile", |
| 1482 | 0x10, "drawStateDumpPngFile" |
Jon Ashburn | eb2728b | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1483 | }; |
| 1484 | |
| 1485 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( |
| 1486 | VkExtensionInfoType infoType, |
| 1487 | uint32_t extensionIndex, |
| 1488 | size_t* pDataSize, |
| 1489 | void* pData) |
| 1490 | { |
Jon Ashburn | eb2728b | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 1491 | /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ |
| 1492 | VkExtensionProperties *ext_props; |
| 1493 | uint32_t *count; |
| 1494 | |
| 1495 | if (pDataSize == NULL) |
| 1496 | return VK_ERROR_INVALID_POINTER; |
| 1497 | |
| 1498 | switch (infoType) { |
| 1499 | case VK_EXTENSION_INFO_TYPE_COUNT: |
| 1500 | *pDataSize = sizeof(uint32_t); |
| 1501 | if (pData == NULL) |
| 1502 | return VK_SUCCESS; |
| 1503 | count = (uint32_t *) pData; |
| 1504 | *count = DRAW_STATE_LAYER_EXT_ARRAY_SIZE; |
| 1505 | break; |
| 1506 | case VK_EXTENSION_INFO_TYPE_PROPERTIES: |
| 1507 | *pDataSize = sizeof(VkExtensionProperties); |
| 1508 | if (pData == NULL) |
| 1509 | return VK_SUCCESS; |
| 1510 | if (extensionIndex >= DRAW_STATE_LAYER_EXT_ARRAY_SIZE) |
| 1511 | return VK_ERROR_INVALID_VALUE; |
| 1512 | ext_props = (VkExtensionProperties *) pData; |
| 1513 | ext_props->version = dsExts[extensionIndex].version; |
| 1514 | strncpy(ext_props->extName, dsExts[extensionIndex].name, |
| 1515 | VK_MAX_EXTENSION_NAME); |
| 1516 | ext_props->extName[VK_MAX_EXTENSION_NAME - 1] = '\0'; |
| 1517 | break; |
| 1518 | default: |
| 1519 | return VK_ERROR_INVALID_VALUE; |
| 1520 | }; |
| 1521 | |
| 1522 | return VK_SUCCESS; |
| 1523 | } |
| 1524 | |
Courtney Goeltzenleuchter | bb1f360 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 1525 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, size_t maxStringSize, size_t* pLayerCount, char* const* pOutLayers, void* pReserved) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1526 | { |
| 1527 | if (gpu != NULL) |
| 1528 | { |
Jon Ashburn | 630e44f | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 1529 | pCurObj = (VkBaseLayerObject *) gpu; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1530 | loader_platform_thread_once(&g_initOnce, initDrawState); |
Courtney Goeltzenleuchter | bb1f360 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 1531 | VkResult result = nextTable.EnumerateLayers(gpu, maxStringSize, pLayerCount, pOutLayers, pReserved); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1532 | return result; |
Jon Ashburn | 630e44f | 2015-04-08 21:33:34 -0600 | [diff] [blame] | 1533 | } else { |
Courtney Goeltzenleuchter | bb1f360 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 1534 | if (pLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1535 | return VK_ERROR_INVALID_POINTER; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1536 | // This layer compatible with all GPUs |
Courtney Goeltzenleuchter | bb1f360 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 1537 | *pLayerCount = 1; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1538 | strncpy((char *) pOutLayers[0], "DrawState", maxStringSize); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1539 | return VK_SUCCESS; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1540 | } |
| 1541 | } |
| 1542 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1543 | VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1544 | { |
| 1545 | for (uint32_t i=0; i < cmdBufferCount; i++) { |
| 1546 | // Validate that cmd buffers have been updated |
| 1547 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1548 | VkResult result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1549 | return result; |
| 1550 | } |
| 1551 | |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1552 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1553 | { |
| 1554 | // TODO : When wrapped objects (such as dynamic state) are destroyed, need to clean up memory |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1555 | VkResult result = nextTable.DestroyObject(device, objType, object); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1556 | return result; |
| 1557 | } |
| 1558 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1559 | VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1560 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1561 | VkResult result = nextTable.CreateBufferView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1562 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1563 | loader_platform_thread_lock_mutex(&globalLock); |
| 1564 | BUFFER_NODE* pNewNode = new BUFFER_NODE; |
| 1565 | pNewNode->buffer = *pView; |
| 1566 | pNewNode->createInfo = *pCreateInfo; |
| 1567 | bufferMap[*pView] = pNewNode; |
| 1568 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1569 | } |
| 1570 | return result; |
| 1571 | } |
| 1572 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1573 | VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1574 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1575 | VkResult result = nextTable.CreateImageView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1576 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1577 | loader_platform_thread_lock_mutex(&globalLock); |
| 1578 | IMAGE_NODE *pNewNode = new IMAGE_NODE; |
| 1579 | pNewNode->image = *pView; |
| 1580 | pNewNode->createInfo = *pCreateInfo; |
| 1581 | imageMap[*pView] = pNewNode; |
| 1582 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1583 | } |
| 1584 | return result; |
| 1585 | } |
| 1586 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1587 | static void track_pipeline(const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1588 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1589 | // Create LL HEAD for this Pipeline |
| 1590 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1591 | PIPELINE_NODE* pPipeNode = new PIPELINE_NODE; |
| 1592 | memset((void*)pPipeNode, 0, sizeof(PIPELINE_NODE)); |
| 1593 | pPipeNode->pipeline = *pPipeline; |
| 1594 | initPipeline(pPipeNode, pCreateInfo); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1595 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1596 | } |
| 1597 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1598 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1599 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1600 | VkResult result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1601 | // Create LL HEAD for this Pipeline |
| 1602 | char str[1024]; |
| 1603 | sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1604 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, *pPipeline, 0, DRAWSTATE_NONE, "DS", str); |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1605 | |
| 1606 | track_pipeline(pCreateInfo, pPipeline); |
| 1607 | |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1608 | return result; |
| 1609 | } |
| 1610 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1611 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative( |
| 1612 | VkDevice device, |
| 1613 | const VkGraphicsPipelineCreateInfo* pCreateInfo, |
| 1614 | VkPipeline basePipeline, |
| 1615 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1616 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1617 | VkResult result = nextTable.CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline); |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1618 | // Create LL HEAD for this Pipeline |
| 1619 | char str[1024]; |
| 1620 | sprintf(str, "Created Gfx Pipeline %p (derived from pipeline %p)", (void*)*pPipeline, basePipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1621 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, *pPipeline, 0, DRAWSTATE_NONE, "DS", str); |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1622 | |
| 1623 | track_pipeline(pCreateInfo, pPipeline); |
| 1624 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1625 | loader_platform_thread_unlock_mutex(&globalLock); |
Jon Ashburn | bdcd756 | 2015-04-14 14:12:59 -0600 | [diff] [blame] | 1626 | |
| 1627 | return result; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1628 | } |
| 1629 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1630 | VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1631 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1632 | VkResult result = nextTable.CreateSampler(device, pCreateInfo, pSampler); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1633 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1634 | loader_platform_thread_lock_mutex(&globalLock); |
| 1635 | SAMPLER_NODE* pNewNode = new SAMPLER_NODE; |
| 1636 | pNewNode->sampler = *pSampler; |
| 1637 | pNewNode->createInfo = *pCreateInfo; |
| 1638 | sampleMap[*pSampler] = pNewNode; |
| 1639 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1640 | } |
| 1641 | return result; |
| 1642 | } |
| 1643 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1644 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1645 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1646 | VkResult result = nextTable.CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1647 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1648 | LAYOUT_NODE* pNewNode = new LAYOUT_NODE; |
| 1649 | if (NULL == pNewNode) { |
| 1650 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1651 | sprintf(str, "Out of memory while attempting to allocate LAYOUT_NODE in vkCreateDescriptorSetLayout()"); |
| 1652 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, *pSetLayout, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1653 | } |
| 1654 | memset(pNewNode, 0, sizeof(LAYOUT_NODE)); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1655 | memcpy((void*)&pNewNode->createInfo, pCreateInfo, sizeof(VkDescriptorSetLayoutCreateInfo)); |
| 1656 | pNewNode->createInfo.pBinding = new VkDescriptorSetLayoutBinding[pCreateInfo->count]; |
| 1657 | memcpy((void*)pNewNode->createInfo.pBinding, pCreateInfo->pBinding, sizeof(VkDescriptorSetLayoutBinding)*pCreateInfo->count); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1658 | uint32_t totalCount = 0; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1659 | for (uint32_t i=0; i<pCreateInfo->count; i++) { |
| 1660 | totalCount += pCreateInfo->pBinding[i].count; |
| 1661 | if (pCreateInfo->pBinding[i].pImmutableSamplers) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1662 | VkSampler** ppIS = (VkSampler**)&pNewNode->createInfo.pBinding[i].pImmutableSamplers; |
| 1663 | *ppIS = new VkSampler[pCreateInfo->pBinding[i].count]; |
| 1664 | memcpy(*ppIS, pCreateInfo->pBinding[i].pImmutableSamplers, pCreateInfo->pBinding[i].count*sizeof(VkSampler)); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1665 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1666 | } |
| 1667 | if (totalCount > 0) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1668 | pNewNode->pTypes = new VkDescriptorType[totalCount]; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1669 | uint32_t offset = 0; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1670 | uint32_t j = 0; |
| 1671 | for (uint32_t i=0; i<pCreateInfo->count; i++) { |
| 1672 | for (j = 0; j < pCreateInfo->pBinding[i].count; j++) { |
| 1673 | pNewNode->pTypes[offset + j] = pCreateInfo->pBinding[i].descriptorType; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1674 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1675 | offset += j; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1676 | } |
| 1677 | } |
| 1678 | pNewNode->layout = *pSetLayout; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1679 | pNewNode->startIndex = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1680 | pNewNode->endIndex = pNewNode->startIndex + totalCount - 1; |
| 1681 | assert(pNewNode->endIndex >= pNewNode->startIndex); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1682 | // Put new node at Head of global Layer list |
| 1683 | loader_platform_thread_lock_mutex(&globalLock); |
| 1684 | layoutMap[*pSetLayout] = pNewNode; |
| 1685 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1686 | } |
| 1687 | return result; |
| 1688 | } |
| 1689 | |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1690 | VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1691 | { |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1692 | VkResult result = nextTable.CreatePipelineLayout(device, pCreateInfo, pPipelineLayout); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1693 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1694 | // TODO : Need to capture the pipeline layout |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1695 | } |
| 1696 | return result; |
| 1697 | } |
| 1698 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1699 | VK_LAYER_EXPORT VkResult VKAPI vkBeginDescriptorPoolUpdate(VkDevice device, VkDescriptorUpdateMode updateMode) |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1700 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1701 | VkResult result = nextTable.BeginDescriptorPoolUpdate(device, updateMode); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1702 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1703 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1704 | POOL_NODE* pPoolNode = poolMap.begin()->second; |
| 1705 | if (!pPoolNode) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1706 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1707 | sprintf(str, "Unable to find pool node"); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1708 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1709 | } |
| 1710 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1711 | pPoolNode->updateActive = 1; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1712 | } |
| 1713 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1714 | } |
| 1715 | return result; |
| 1716 | } |
| 1717 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1718 | VK_LAYER_EXPORT VkResult VKAPI vkEndDescriptorPoolUpdate(VkDevice device, VkCmdBuffer cmd) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1719 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1720 | VkResult result = nextTable.EndDescriptorPoolUpdate(device, cmd); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1721 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1722 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1723 | POOL_NODE* pPoolNode = poolMap.begin()->second; |
| 1724 | if (!pPoolNode) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1725 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1726 | sprintf(str, "Unable to find pool node"); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1727 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1728 | } |
| 1729 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1730 | if (!pPoolNode->updateActive) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1731 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1732 | sprintf(str, "You must call vkBeginDescriptorPoolUpdate() before this call to vkEndDescriptorPoolUpdate()!"); |
| 1733 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1734 | } |
| 1735 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1736 | pPoolNode->updateActive = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1737 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1738 | pPoolNode->updateActive = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1739 | } |
| 1740 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1741 | } |
| 1742 | return result; |
| 1743 | } |
| 1744 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1745 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1746 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1747 | VkResult result = nextTable.CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1748 | if (VK_SUCCESS == result) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1749 | // Insert this pool into Global Pool LL at head |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1750 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1751 | sprintf(str, "Created Descriptor Pool %p", (void*)*pDescriptorPool); |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1752 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, (VkObject)pDescriptorPool, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1753 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1754 | POOL_NODE* pNewNode = new POOL_NODE; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1755 | if (NULL == pNewNode) { |
| 1756 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1757 | sprintf(str, "Out of memory while attempting to allocate POOL_NODE in vkCreateDescriptorPool()"); |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1758 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, (VkObject)*pDescriptorPool, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1759 | } |
| 1760 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1761 | memset(pNewNode, 0, sizeof(POOL_NODE)); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1762 | VkDescriptorPoolCreateInfo* pCI = (VkDescriptorPoolCreateInfo*)&pNewNode->createInfo; |
| 1763 | memcpy((void*)pCI, pCreateInfo, sizeof(VkDescriptorPoolCreateInfo)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1764 | if (pNewNode->createInfo.count) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1765 | size_t typeCountSize = pNewNode->createInfo.count * sizeof(VkDescriptorTypeCount); |
| 1766 | pNewNode->createInfo.pTypeCount = new VkDescriptorTypeCount[typeCountSize]; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1767 | memcpy((void*)pNewNode->createInfo.pTypeCount, pCreateInfo->pTypeCount, typeCountSize); |
| 1768 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1769 | pNewNode->poolUsage = poolUsage; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1770 | pNewNode->updateActive = 0; |
| 1771 | pNewNode->maxSets = maxSets; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1772 | pNewNode->pool = *pDescriptorPool; |
| 1773 | poolMap[*pDescriptorPool] = pNewNode; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1774 | } |
| 1775 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1776 | } |
| 1777 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1778 | // Need to do anything if pool create fails? |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1779 | } |
| 1780 | return result; |
| 1781 | } |
| 1782 | |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1783 | VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1784 | { |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1785 | VkResult result = nextTable.ResetDescriptorPool(device, descriptorPool); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1786 | if (VK_SUCCESS == result) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1787 | clearDescriptorPool(descriptorPool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1788 | } |
| 1789 | return result; |
| 1790 | } |
| 1791 | |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1792 | VK_LAYER_EXPORT VkResult VKAPI vkAllocDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1793 | { |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1794 | VkResult result = nextTable.AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1795 | if ((VK_SUCCESS == result) || (*pCount > 0)) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1796 | POOL_NODE *pPoolNode = getPoolNode(descriptorPool); |
| 1797 | if (!pPoolNode) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1798 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1799 | sprintf(str, "Unable to find pool node for pool %p specified in vkAllocDescriptorSets() call", (void*)descriptorPool); |
| 1800 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, descriptorPool, 0, DRAWSTATE_INVALID_POOL, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1801 | } |
| 1802 | else { |
| 1803 | for (uint32_t i = 0; i < *pCount; i++) { |
| 1804 | char str[1024]; |
| 1805 | sprintf(str, "Created Descriptor Set %p", (void*)pDescriptorSets[i]); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1806 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1807 | // Create new set node and add to head of pool nodes |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1808 | SET_NODE* pNewNode = new SET_NODE; |
| 1809 | if (NULL == pNewNode) { |
| 1810 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1811 | sprintf(str, "Out of memory while attempting to allocate SET_NODE in vkAllocDescriptorSets()"); |
| 1812 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1813 | } |
| 1814 | else { |
| 1815 | memset(pNewNode, 0, sizeof(SET_NODE)); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1816 | // Insert set at head of Set LL for this pool |
| 1817 | pNewNode->pNext = pPoolNode->pSets; |
| 1818 | pPoolNode->pSets = pNewNode; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1819 | LAYOUT_NODE* pLayout = getLayoutNode(pSetLayouts[i]); |
| 1820 | if (NULL == pLayout) { |
| 1821 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1822 | sprintf(str, "Unable to find set layout node for layout %p specified in vkAllocDescriptorSets() call", (void*)pSetLayouts[i]); |
| 1823 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pSetLayouts[i], 0, DRAWSTATE_INVALID_LAYOUT, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1824 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1825 | pNewNode->pLayout = pLayout; |
| 1826 | pNewNode->pool = descriptorPool; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1827 | pNewNode->set = pDescriptorSets[i]; |
| 1828 | pNewNode->setUsage = setUsage; |
| 1829 | pNewNode->descriptorCount = pLayout->endIndex + 1; |
| 1830 | if (pNewNode->descriptorCount) { |
| 1831 | size_t descriptorArraySize = sizeof(GENERIC_HEADER*)*pNewNode->descriptorCount; |
| 1832 | pNewNode->ppDescriptors = new GENERIC_HEADER*[descriptorArraySize]; |
| 1833 | memset(pNewNode->ppDescriptors, 0, descriptorArraySize); |
| 1834 | } |
| 1835 | setMap[pDescriptorSets[i]] = pNewNode; |
| 1836 | } |
| 1837 | } |
| 1838 | } |
| 1839 | } |
| 1840 | return result; |
| 1841 | } |
| 1842 | |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1843 | VK_LAYER_EXPORT void VKAPI vkClearDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1844 | { |
| 1845 | for (uint32_t i = 0; i < count; i++) { |
| 1846 | clearDescriptorSet(pDescriptorSets[i]); |
| 1847 | } |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1848 | nextTable.ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1849 | } |
| 1850 | |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1851 | VK_LAYER_EXPORT void VKAPI vkUpdateDescriptors(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1852 | { |
| 1853 | SET_NODE* pSet = getSetNode(descriptorSet); |
| 1854 | if (!dsUpdateActive(descriptorSet)) { |
| 1855 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1856 | sprintf(str, "You must call vkBeginDescriptorPoolUpdate() before this call to vkUpdateDescriptors()!"); |
| 1857 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pSet->pool, 0, DRAWSTATE_UPDATE_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1858 | } |
| 1859 | else { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1860 | // pUpdateChain is a Linked-list of VK_UPDATE_* structures defining the mappings for the descriptors |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1861 | dsUpdate(descriptorSet, updateCount, ppUpdateArray); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1862 | } |
| 1863 | |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1864 | nextTable.UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1865 | } |
| 1866 | |
Courtney Goeltzenleuchter | fcf855f | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1867 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1868 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1869 | VkResult result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1870 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_VIEWPORT); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1871 | return result; |
| 1872 | } |
| 1873 | |
Courtney Goeltzenleuchter | fcf855f | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1874 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1875 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1876 | VkResult result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1877 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_RASTER); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1878 | return result; |
| 1879 | } |
| 1880 | |
Courtney Goeltzenleuchter | fcf855f | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1881 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1882 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1883 | VkResult result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1884 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_COLOR_BLEND); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1885 | return result; |
| 1886 | } |
| 1887 | |
Courtney Goeltzenleuchter | fcf855f | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1888 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, VkDynamicDsState* pState) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1889 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1890 | VkResult result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1891 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_DEPTH_STENCIL); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1892 | return result; |
| 1893 | } |
| 1894 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1895 | VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1896 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1897 | VkResult result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1898 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1899 | loader_platform_thread_lock_mutex(&globalLock); |
| 1900 | GLOBAL_CB_NODE* pCB = new GLOBAL_CB_NODE; |
| 1901 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
| 1902 | pCB->cmdBuffer = *pCmdBuffer; |
| 1903 | pCB->flags = pCreateInfo->flags; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1904 | pCB->queueNodeIndex = pCreateInfo->queueNodeIndex; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1905 | pCB->lastVtxBinding = MAX_BINDING; |
| 1906 | cmdBufferMap[*pCmdBuffer] = pCB; |
| 1907 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1908 | updateCBTracking(*pCmdBuffer); |
| 1909 | } |
| 1910 | return result; |
| 1911 | } |
| 1912 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1913 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1914 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1915 | VkResult result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1916 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1917 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1918 | if (pCB) { |
| 1919 | if (CB_NEW != pCB->state) |
| 1920 | resetCB(cmdBuffer); |
| 1921 | pCB->state = CB_UPDATE_ACTIVE; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1922 | if (pBeginInfo->pNext) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1923 | VkCmdBufferGraphicsBeginInfo* pCbGfxBI = (VkCmdBufferGraphicsBeginInfo*)pBeginInfo->pNext; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1924 | if (VK_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO == pCbGfxBI->sType) { |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 1925 | pCB->activeRenderPass = pCbGfxBI->renderPassContinue.renderPass; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1926 | } |
| 1927 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1928 | } |
| 1929 | else { |
| 1930 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1931 | sprintf(str, "In vkBeginCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer); |
| 1932 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1933 | } |
| 1934 | updateCBTracking(cmdBuffer); |
| 1935 | } |
| 1936 | return result; |
| 1937 | } |
| 1938 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1939 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1940 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1941 | VkResult result = nextTable.EndCommandBuffer(cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1942 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1943 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1944 | if (pCB) { |
| 1945 | pCB->state = CB_UPDATE_COMPLETE; |
| 1946 | printCB(cmdBuffer); |
| 1947 | } |
| 1948 | else { |
| 1949 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1950 | sprintf(str, "In vkEndCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer); |
| 1951 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1952 | } |
| 1953 | updateCBTracking(cmdBuffer); |
| 1954 | //cbDumpDotFile("cb_dump.dot"); |
| 1955 | } |
| 1956 | return result; |
| 1957 | } |
| 1958 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1959 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1960 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1961 | VkResult result = nextTable.ResetCommandBuffer(cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1962 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1963 | resetCB(cmdBuffer); |
| 1964 | updateCBTracking(cmdBuffer); |
| 1965 | } |
| 1966 | return result; |
| 1967 | } |
| 1968 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1969 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1970 | { |
| 1971 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1972 | if (pCB) { |
| 1973 | updateCBTracking(cmdBuffer); |
| 1974 | addCmd(pCB, CMD_BINDPIPELINE); |
| 1975 | PIPELINE_NODE* pPN = getPipeline(pipeline); |
| 1976 | if (pPN) { |
| 1977 | pCB->lastBoundPipeline = pipeline; |
| 1978 | loader_platform_thread_lock_mutex(&globalLock); |
| 1979 | g_lastBoundPipeline = pPN; |
| 1980 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1981 | validatePipelineState(pCB, pipelineBindPoint, pipeline); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1982 | } |
| 1983 | else { |
| 1984 | char str[1024]; |
| 1985 | sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1986 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_INVALID_PIPELINE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1987 | } |
| 1988 | } |
| 1989 | else { |
| 1990 | char str[1024]; |
| 1991 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1992 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1993 | } |
| 1994 | nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
| 1995 | } |
| 1996 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1997 | VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1998 | { |
| 1999 | setLastBoundDynamicState(cmdBuffer, state, stateBindPoint); |
| 2000 | nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); |
| 2001 | } |
| 2002 | |
Cody Northrop | 1a01b1d | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 2003 | VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2004 | { |
| 2005 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2006 | if (pCB) { |
| 2007 | updateCBTracking(cmdBuffer); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2008 | addCmd(pCB, CMD_BINDDESCRIPTORSETS); |
Cody Northrop | 1a01b1d | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 2009 | for (uint32_t i=0; i<setCount; i++) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2010 | if (getSetNode(pDescriptorSets[i])) { |
| 2011 | if (dsUpdateActive(pDescriptorSets[i])) { |
| 2012 | // TODO : This check here needs to be made at QueueSubmit time |
| 2013 | /* |
| 2014 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2015 | sprintf(str, "You must call vkEndDescriptorPoolUpdate(%p) before this call to vkCmdBindDescriptorSet()!", (void*)descriptorSet); |
| 2016 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2017 | */ |
| 2018 | } |
| 2019 | loader_platform_thread_lock_mutex(&globalLock); |
| 2020 | pCB->lastBoundDescriptorSet = pDescriptorSets[i]; |
| 2021 | g_lastBoundDescriptorSet = pDescriptorSets[i]; |
| 2022 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2023 | char str[1024]; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2024 | sprintf(str, "DS %p bound on pipeline %s", (void*)pDescriptorSets[i], string_VkPipelineBindPoint(pipelineBindPoint)); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2025 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2026 | synchAndPrintDSConfig(cmdBuffer); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2027 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2028 | else { |
| 2029 | char str[1024]; |
| 2030 | sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)pDescriptorSets[i]); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2031 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_INVALID_SET, "DS", str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2032 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2033 | } |
| 2034 | } |
| 2035 | else { |
| 2036 | char str[1024]; |
| 2037 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2038 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2039 | } |
Cody Northrop | 1a01b1d | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 2040 | nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2041 | } |
| 2042 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2043 | VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2044 | { |
| 2045 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2046 | if (pCB) { |
| 2047 | updateCBTracking(cmdBuffer); |
| 2048 | addCmd(pCB, CMD_BINDINDEXBUFFER); |
| 2049 | // TODO : Track idxBuffer binding |
| 2050 | } |
| 2051 | else { |
| 2052 | char str[1024]; |
| 2053 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2054 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2055 | } |
| 2056 | nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
| 2057 | } |
| 2058 | |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2059 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
| 2060 | VkCmdBuffer cmdBuffer, |
| 2061 | uint32_t startBinding, |
| 2062 | uint32_t bindingCount, |
| 2063 | const VkBuffer* pBuffers, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2064 | const VkDeviceSize* pOffsets) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2065 | { |
| 2066 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2067 | if (pCB) { |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2068 | /* TODO: Need to track all the vertex buffers, not just last one */ |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2069 | updateCBTracking(cmdBuffer); |
| 2070 | addCmd(pCB, CMD_BINDVERTEXBUFFER); |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2071 | pCB->lastVtxBinding = startBinding + bindingCount -1; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2072 | validateVBBinding(cmdBuffer); |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2073 | } else { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2074 | char str[1024]; |
| 2075 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2076 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2077 | } |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2078 | nextTable.CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2079 | } |
| 2080 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2081 | VK_LAYER_EXPORT void VKAPI vkCmdDraw(VkCmdBuffer cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2082 | { |
| 2083 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2084 | if (pCB) { |
| 2085 | updateCBTracking(cmdBuffer); |
| 2086 | addCmd(pCB, CMD_DRAW); |
| 2087 | pCB->drawCount[DRAW]++; |
| 2088 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2089 | sprintf(str, "vkCmdDraw() call #%lu, reporting DS state:", g_drawCount[DRAW]++); |
| 2090 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2091 | synchAndPrintDSConfig(cmdBuffer); |
| 2092 | } |
| 2093 | else { |
| 2094 | char str[1024]; |
| 2095 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2096 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2097 | } |
| 2098 | nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount); |
| 2099 | } |
| 2100 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2101 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2102 | { |
| 2103 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2104 | if (pCB) { |
| 2105 | updateCBTracking(cmdBuffer); |
| 2106 | addCmd(pCB, CMD_DRAWINDEXED); |
| 2107 | pCB->drawCount[DRAW_INDEXED]++; |
| 2108 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2109 | sprintf(str, "vkCmdDrawIndexed() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED]++); |
| 2110 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2111 | synchAndPrintDSConfig(cmdBuffer); |
| 2112 | } |
| 2113 | else { |
| 2114 | char str[1024]; |
| 2115 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2116 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2117 | } |
| 2118 | nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount); |
| 2119 | } |
| 2120 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2121 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2122 | { |
| 2123 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2124 | if (pCB) { |
| 2125 | updateCBTracking(cmdBuffer); |
| 2126 | addCmd(pCB, CMD_DRAWINDIRECT); |
| 2127 | pCB->drawCount[DRAW_INDIRECT]++; |
| 2128 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2129 | sprintf(str, "vkCmdDrawIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDIRECT]++); |
| 2130 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2131 | synchAndPrintDSConfig(cmdBuffer); |
| 2132 | } |
| 2133 | else { |
| 2134 | char str[1024]; |
| 2135 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2136 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2137 | } |
| 2138 | nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
| 2139 | } |
| 2140 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2141 | VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2142 | { |
| 2143 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2144 | if (pCB) { |
| 2145 | updateCBTracking(cmdBuffer); |
| 2146 | addCmd(pCB, CMD_DRAWINDEXEDINDIRECT); |
| 2147 | pCB->drawCount[DRAW_INDEXED_INDIRECT]++; |
| 2148 | char str[1024]; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2149 | sprintf(str, "vkCmdDrawIndexedIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED_INDIRECT]++); |
| 2150 | layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2151 | synchAndPrintDSConfig(cmdBuffer); |
| 2152 | } |
| 2153 | else { |
| 2154 | char str[1024]; |
| 2155 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2156 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2157 | } |
| 2158 | nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
| 2159 | } |
| 2160 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2161 | VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2162 | { |
| 2163 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2164 | if (pCB) { |
| 2165 | updateCBTracking(cmdBuffer); |
| 2166 | addCmd(pCB, CMD_DISPATCH); |
| 2167 | } |
| 2168 | else { |
| 2169 | char str[1024]; |
| 2170 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2171 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2172 | } |
| 2173 | nextTable.CmdDispatch(cmdBuffer, x, y, z); |
| 2174 | } |
| 2175 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2176 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2177 | { |
| 2178 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2179 | if (pCB) { |
| 2180 | updateCBTracking(cmdBuffer); |
| 2181 | addCmd(pCB, CMD_DISPATCHINDIRECT); |
| 2182 | } |
| 2183 | else { |
| 2184 | char str[1024]; |
| 2185 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2186 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2187 | } |
| 2188 | nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset); |
| 2189 | } |
| 2190 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2191 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2192 | { |
| 2193 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2194 | if (pCB) { |
| 2195 | updateCBTracking(cmdBuffer); |
| 2196 | addCmd(pCB, CMD_COPYBUFFER); |
| 2197 | } |
| 2198 | else { |
| 2199 | char str[1024]; |
| 2200 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2201 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2202 | } |
| 2203 | nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
| 2204 | } |
| 2205 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2206 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer, |
| 2207 | VkImage srcImage, |
| 2208 | VkImageLayout srcImageLayout, |
| 2209 | VkImage destImage, |
| 2210 | VkImageLayout destImageLayout, |
| 2211 | uint32_t regionCount, const VkImageCopy* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2212 | { |
| 2213 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2214 | if (pCB) { |
| 2215 | updateCBTracking(cmdBuffer); |
| 2216 | addCmd(pCB, CMD_COPYIMAGE); |
| 2217 | } |
| 2218 | else { |
| 2219 | char str[1024]; |
| 2220 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2221 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2222 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2223 | nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2224 | } |
| 2225 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2226 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer, |
| 2227 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 2228 | VkImage destImage, VkImageLayout destImageLayout, |
| 2229 | uint32_t regionCount, const VkImageBlit* pRegions) |
Courtney Goeltzenleuchter | 6ff8ebc | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2230 | { |
| 2231 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2232 | if (pCB) { |
| 2233 | updateCBTracking(cmdBuffer); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2234 | addCmd(pCB, CMD_BLITIMAGE); |
Courtney Goeltzenleuchter | 6ff8ebc | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2235 | } |
| 2236 | else { |
| 2237 | char str[1024]; |
| 2238 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2239 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Courtney Goeltzenleuchter | 6ff8ebc | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2240 | } |
| 2241 | nextTable.CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
| 2242 | } |
| 2243 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2244 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, |
| 2245 | VkBuffer srcBuffer, |
| 2246 | VkImage destImage, VkImageLayout destImageLayout, |
| 2247 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2248 | { |
| 2249 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2250 | if (pCB) { |
| 2251 | updateCBTracking(cmdBuffer); |
| 2252 | addCmd(pCB, CMD_COPYBUFFERTOIMAGE); |
| 2253 | } |
| 2254 | else { |
| 2255 | char str[1024]; |
| 2256 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2257 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2258 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2259 | nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2260 | } |
| 2261 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2262 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, |
| 2263 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 2264 | VkBuffer destBuffer, |
| 2265 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2266 | { |
| 2267 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2268 | if (pCB) { |
| 2269 | updateCBTracking(cmdBuffer); |
| 2270 | addCmd(pCB, CMD_COPYIMAGETOBUFFER); |
| 2271 | } |
| 2272 | else { |
| 2273 | char str[1024]; |
| 2274 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2275 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2276 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2277 | nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2278 | } |
| 2279 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2280 | VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2281 | { |
| 2282 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2283 | if (pCB) { |
| 2284 | updateCBTracking(cmdBuffer); |
| 2285 | addCmd(pCB, CMD_CLONEIMAGEDATA); |
| 2286 | } |
| 2287 | else { |
| 2288 | char str[1024]; |
| 2289 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2290 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2291 | } |
| 2292 | nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout); |
| 2293 | } |
| 2294 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2295 | VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2296 | { |
| 2297 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2298 | if (pCB) { |
| 2299 | updateCBTracking(cmdBuffer); |
| 2300 | addCmd(pCB, CMD_UPDATEBUFFER); |
| 2301 | } |
| 2302 | else { |
| 2303 | char str[1024]; |
| 2304 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2305 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2306 | } |
| 2307 | nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
| 2308 | } |
| 2309 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2310 | VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2311 | { |
| 2312 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2313 | if (pCB) { |
| 2314 | updateCBTracking(cmdBuffer); |
| 2315 | addCmd(pCB, CMD_FILLBUFFER); |
| 2316 | } |
| 2317 | else { |
| 2318 | char str[1024]; |
| 2319 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2320 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2321 | } |
| 2322 | nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
| 2323 | } |
| 2324 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2325 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer, |
| 2326 | VkImage image, VkImageLayout imageLayout, |
| 2327 | VkClearColor color, |
| 2328 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2329 | { |
| 2330 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2331 | if (pCB) { |
| 2332 | updateCBTracking(cmdBuffer); |
| 2333 | addCmd(pCB, CMD_CLEARCOLORIMAGE); |
| 2334 | } |
| 2335 | else { |
| 2336 | char str[1024]; |
| 2337 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2338 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2339 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2340 | nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, color, rangeCount, pRanges); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2341 | } |
| 2342 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2343 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, |
| 2344 | VkImage image, VkImageLayout imageLayout, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2345 | float depth, uint32_t stencil, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2346 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2347 | { |
| 2348 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2349 | if (pCB) { |
| 2350 | updateCBTracking(cmdBuffer); |
| 2351 | addCmd(pCB, CMD_CLEARDEPTHSTENCIL); |
| 2352 | } |
| 2353 | else { |
| 2354 | char str[1024]; |
| 2355 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2356 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2357 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2358 | nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2359 | } |
| 2360 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2361 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, |
| 2362 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 2363 | VkImage destImage, VkImageLayout destImageLayout, |
Tony Barbour | 11f7437 | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 2364 | uint32_t regionCount, const VkImageResolve* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2365 | { |
| 2366 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2367 | if (pCB) { |
| 2368 | updateCBTracking(cmdBuffer); |
| 2369 | addCmd(pCB, CMD_RESOLVEIMAGE); |
| 2370 | } |
| 2371 | else { |
| 2372 | char str[1024]; |
| 2373 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2374 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2375 | } |
Tony Barbour | 11f7437 | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 2376 | nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2377 | } |
| 2378 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2379 | VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2380 | { |
| 2381 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2382 | if (pCB) { |
| 2383 | updateCBTracking(cmdBuffer); |
| 2384 | addCmd(pCB, CMD_SETEVENT); |
| 2385 | } |
| 2386 | else { |
| 2387 | char str[1024]; |
| 2388 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2389 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2390 | } |
| 2391 | nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent); |
| 2392 | } |
| 2393 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2394 | VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2395 | { |
| 2396 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2397 | if (pCB) { |
| 2398 | updateCBTracking(cmdBuffer); |
| 2399 | addCmd(pCB, CMD_RESETEVENT); |
| 2400 | } |
| 2401 | else { |
| 2402 | char str[1024]; |
| 2403 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2404 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2405 | } |
Courtney Goeltzenleuchter | aa86e0e | 2015-03-24 18:02:34 -0600 | [diff] [blame] | 2406 | nextTable.CmdResetEvent(cmdBuffer, event, pipeEvent); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2407 | } |
| 2408 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2409 | VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t eventCount, const VkEvent* pEvents, uint32_t memBarrierCount, const void** ppMemBarriers) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2410 | { |
| 2411 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2412 | if (pCB) { |
| 2413 | updateCBTracking(cmdBuffer); |
| 2414 | addCmd(pCB, CMD_WAITEVENTS); |
| 2415 | } |
| 2416 | else { |
| 2417 | char str[1024]; |
| 2418 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2419 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2420 | } |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2421 | nextTable.CmdWaitEvents(cmdBuffer, waitEvent, eventCount, pEvents, memBarrierCount, ppMemBarriers); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2422 | } |
| 2423 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2424 | VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2425 | { |
| 2426 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2427 | if (pCB) { |
| 2428 | updateCBTracking(cmdBuffer); |
| 2429 | addCmd(pCB, CMD_PIPELINEBARRIER); |
| 2430 | } |
| 2431 | else { |
| 2432 | char str[1024]; |
| 2433 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2434 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2435 | } |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2436 | nextTable.CmdPipelineBarrier(cmdBuffer, waitEvent, pipeEventCount, pPipeEvents, memBarrierCount, ppMemBarriers); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2437 | } |
| 2438 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2439 | VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2440 | { |
| 2441 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2442 | if (pCB) { |
| 2443 | updateCBTracking(cmdBuffer); |
| 2444 | addCmd(pCB, CMD_BEGINQUERY); |
| 2445 | } |
| 2446 | else { |
| 2447 | char str[1024]; |
| 2448 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2449 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2450 | } |
| 2451 | nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
| 2452 | } |
| 2453 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2454 | VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2455 | { |
| 2456 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2457 | if (pCB) { |
| 2458 | updateCBTracking(cmdBuffer); |
| 2459 | addCmd(pCB, CMD_ENDQUERY); |
| 2460 | } |
| 2461 | else { |
| 2462 | char str[1024]; |
| 2463 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2464 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2465 | } |
| 2466 | nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); |
| 2467 | } |
| 2468 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2469 | VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2470 | { |
| 2471 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2472 | if (pCB) { |
| 2473 | updateCBTracking(cmdBuffer); |
| 2474 | addCmd(pCB, CMD_RESETQUERYPOOL); |
| 2475 | } |
| 2476 | else { |
| 2477 | char str[1024]; |
| 2478 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2479 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2480 | } |
| 2481 | nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
| 2482 | } |
| 2483 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2484 | VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2485 | { |
| 2486 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2487 | if (pCB) { |
| 2488 | updateCBTracking(cmdBuffer); |
| 2489 | addCmd(pCB, CMD_WRITETIMESTAMP); |
| 2490 | } |
| 2491 | else { |
| 2492 | char str[1024]; |
| 2493 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2494 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2495 | } |
| 2496 | nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset); |
| 2497 | } |
| 2498 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2499 | VK_LAYER_EXPORT void VKAPI vkCmdInitAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2500 | { |
| 2501 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2502 | if (pCB) { |
| 2503 | updateCBTracking(cmdBuffer); |
| 2504 | addCmd(pCB, CMD_INITATOMICCOUNTERS); |
| 2505 | } |
| 2506 | else { |
| 2507 | char str[1024]; |
| 2508 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2509 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2510 | } |
| 2511 | nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData); |
| 2512 | } |
| 2513 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2514 | VK_LAYER_EXPORT void VKAPI vkCmdLoadAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer srcBuffer, VkDeviceSize srcOffset) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2515 | { |
| 2516 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2517 | if (pCB) { |
| 2518 | updateCBTracking(cmdBuffer); |
| 2519 | addCmd(pCB, CMD_LOADATOMICCOUNTERS); |
| 2520 | } |
| 2521 | else { |
| 2522 | char str[1024]; |
| 2523 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2524 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2525 | } |
| 2526 | nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset); |
| 2527 | } |
| 2528 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2529 | VK_LAYER_EXPORT void VKAPI vkCmdSaveAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer destBuffer, VkDeviceSize destOffset) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2530 | { |
| 2531 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2532 | if (pCB) { |
| 2533 | updateCBTracking(cmdBuffer); |
| 2534 | addCmd(pCB, CMD_SAVEATOMICCOUNTERS); |
| 2535 | } |
| 2536 | else { |
| 2537 | char str[1024]; |
| 2538 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2539 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2540 | } |
| 2541 | nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset); |
| 2542 | } |
| 2543 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2544 | VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer) |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2545 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2546 | VkResult result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2547 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2548 | // Shadow create info and store in map |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2549 | VkFramebufferCreateInfo* localFBCI = new VkFramebufferCreateInfo(*pCreateInfo); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2550 | if (pCreateInfo->pColorAttachments) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2551 | localFBCI->pColorAttachments = new VkColorAttachmentBindInfo[localFBCI->colorAttachmentCount]; |
| 2552 | memcpy((void*)localFBCI->pColorAttachments, pCreateInfo->pColorAttachments, localFBCI->colorAttachmentCount*sizeof(VkColorAttachmentBindInfo)); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2553 | } |
| 2554 | if (pCreateInfo->pDepthStencilAttachment) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2555 | localFBCI->pDepthStencilAttachment = new VkDepthStencilBindInfo[localFBCI->colorAttachmentCount]; |
| 2556 | memcpy((void*)localFBCI->pDepthStencilAttachment, pCreateInfo->pDepthStencilAttachment, localFBCI->colorAttachmentCount*sizeof(VkDepthStencilBindInfo)); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2557 | } |
| 2558 | frameBufferMap[*pFramebuffer] = localFBCI; |
| 2559 | } |
| 2560 | return result; |
| 2561 | } |
| 2562 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2563 | VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass) |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2564 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2565 | VkResult result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2566 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2567 | // Shadow create info and store in map |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2568 | VkRenderPassCreateInfo* localRPCI = new VkRenderPassCreateInfo(*pCreateInfo); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2569 | if (pCreateInfo->pColorLoadOps) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2570 | localRPCI->pColorLoadOps = new VkAttachmentLoadOp[localRPCI->colorAttachmentCount]; |
| 2571 | memcpy((void*)localRPCI->pColorLoadOps, pCreateInfo->pColorLoadOps, localRPCI->colorAttachmentCount*sizeof(VkAttachmentLoadOp)); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2572 | } |
| 2573 | if (pCreateInfo->pColorStoreOps) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2574 | localRPCI->pColorStoreOps = new VkAttachmentStoreOp[localRPCI->colorAttachmentCount]; |
| 2575 | memcpy((void*)localRPCI->pColorStoreOps, pCreateInfo->pColorStoreOps, localRPCI->colorAttachmentCount*sizeof(VkAttachmentStoreOp)); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2576 | } |
| 2577 | if (pCreateInfo->pColorLoadClearValues) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2578 | localRPCI->pColorLoadClearValues = new VkClearColor[localRPCI->colorAttachmentCount]; |
| 2579 | memcpy((void*)localRPCI->pColorLoadClearValues, pCreateInfo->pColorLoadClearValues, localRPCI->colorAttachmentCount*sizeof(VkClearColor)); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2580 | } |
| 2581 | renderPassMap[*pRenderPass] = localRPCI; |
| 2582 | } |
| 2583 | return result; |
| 2584 | } |
| 2585 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2586 | VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBegin *pRenderPassBegin) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2587 | { |
| 2588 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2589 | if (pCB) { |
| 2590 | updateCBTracking(cmdBuffer); |
| 2591 | addCmd(pCB, CMD_BEGINRENDERPASS); |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2592 | pCB->activeRenderPass = pRenderPassBegin->renderPass; |
| 2593 | pCB->framebuffer = pRenderPassBegin->framebuffer; |
Tony Barbour | b9f82ba | 2015-04-06 11:09:26 -0600 | [diff] [blame] | 2594 | if (pCB->lastBoundPipeline) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2595 | validatePipelineState(pCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pCB->lastBoundPipeline); |
Tony Barbour | b9f82ba | 2015-04-06 11:09:26 -0600 | [diff] [blame] | 2596 | } |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2597 | } else { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2598 | char str[1024]; |
| 2599 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2600 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2601 | } |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2602 | nextTable.CmdBeginRenderPass(cmdBuffer, pRenderPassBegin); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2603 | } |
| 2604 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2605 | VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2606 | { |
| 2607 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2608 | if (pCB) { |
| 2609 | updateCBTracking(cmdBuffer); |
| 2610 | addCmd(pCB, CMD_ENDRENDERPASS); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2611 | pCB->activeRenderPass = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2612 | } |
| 2613 | else { |
| 2614 | char str[1024]; |
| 2615 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2616 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2617 | } |
| 2618 | nextTable.CmdEndRenderPass(cmdBuffer, renderPass); |
| 2619 | } |
| 2620 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2621 | VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2622 | { |
| 2623 | // This layer intercepts callbacks |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 2624 | VK_LAYER_DBG_FUNCTION_NODE* pNewDbgFuncNode = new VK_LAYER_DBG_FUNCTION_NODE; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2625 | if (!pNewDbgFuncNode) |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2626 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2627 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 2628 | pNewDbgFuncNode->pUserData = pUserData; |
| 2629 | pNewDbgFuncNode->pNext = g_pDbgFunctionHead; |
| 2630 | g_pDbgFunctionHead = pNewDbgFuncNode; |
| 2631 | // force callbacks if DebugAction hasn't been set already other than initial value |
| 2632 | if (g_actionIsDefault) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2633 | g_debugAction = VK_DBG_LAYER_ACTION_CALLBACK; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2634 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2635 | VkResult result = nextTable.DbgRegisterMsgCallback(instance, pfnMsgCallback, pUserData); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2636 | return result; |
| 2637 | } |
| 2638 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2639 | VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2640 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2641 | VK_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; |
| 2642 | VK_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2643 | while (pTrav) { |
| 2644 | if (pTrav->pfnMsgCallback == pfnMsgCallback) { |
| 2645 | pPrev->pNext = pTrav->pNext; |
| 2646 | if (g_pDbgFunctionHead == pTrav) |
| 2647 | g_pDbgFunctionHead = pTrav->pNext; |
Tobin Ehlis | eaf2866 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 2648 | delete pTrav; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2649 | break; |
| 2650 | } |
| 2651 | pPrev = pTrav; |
| 2652 | pTrav = pTrav->pNext; |
| 2653 | } |
| 2654 | if (g_pDbgFunctionHead == NULL) |
| 2655 | { |
| 2656 | if (g_actionIsDefault) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2657 | g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2658 | else |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2659 | g_debugAction = (VK_LAYER_DBG_ACTION)(g_debugAction & ~((uint32_t)VK_DBG_LAYER_ACTION_CALLBACK)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2660 | } |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2661 | VkResult result = nextTable.DbgUnregisterMsgCallback(instance, pfnMsgCallback); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2662 | return result; |
| 2663 | } |
| 2664 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2665 | VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2666 | { |
| 2667 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2668 | if (pCB) { |
| 2669 | updateCBTracking(cmdBuffer); |
| 2670 | addCmd(pCB, CMD_DBGMARKERBEGIN); |
| 2671 | } |
| 2672 | else { |
| 2673 | char str[1024]; |
| 2674 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2675 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2676 | } |
| 2677 | nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker); |
| 2678 | } |
| 2679 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2680 | VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2681 | { |
| 2682 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2683 | if (pCB) { |
| 2684 | updateCBTracking(cmdBuffer); |
| 2685 | addCmd(pCB, CMD_DBGMARKEREND); |
| 2686 | } |
| 2687 | else { |
| 2688 | char str[1024]; |
| 2689 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2690 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2691 | } |
| 2692 | nextTable.CmdDbgMarkerEnd(cmdBuffer); |
| 2693 | } |
| 2694 | |
| 2695 | // TODO : Want to pass in a cmdBuffer here based on which state to display |
| 2696 | void drawStateDumpDotFile(char* outFileName) |
| 2697 | { |
| 2698 | // TODO : Currently just setting cmdBuffer based on global var |
| 2699 | //dumpDotFile(g_lastDrawStateCmdBuffer, outFileName); |
| 2700 | dumpGlobalDotFile(outFileName); |
| 2701 | } |
| 2702 | |
| 2703 | void drawStateDumpCommandBufferDotFile(char* outFileName) |
| 2704 | { |
| 2705 | cbDumpDotFile(outFileName); |
| 2706 | } |
| 2707 | |
| 2708 | void drawStateDumpPngFile(char* outFileName) |
| 2709 | { |
| 2710 | #if defined(_WIN32) |
| 2711 | // FIXME: NEED WINDOWS EQUIVALENT |
| 2712 | char str[1024]; |
| 2713 | sprintf(str, "Cannot execute dot program yet on Windows."); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2714 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2715 | #else // WIN32 |
| 2716 | char dotExe[32] = "/usr/bin/dot"; |
| 2717 | if( access(dotExe, X_OK) != -1) { |
| 2718 | dumpDotFile(g_lastCmdBuffer[getTIDIndex()], "/tmp/tmp.dot"); |
| 2719 | char dotCmd[1024]; |
| 2720 | sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName); |
Tony Barbour | 22a3086 | 2015-04-22 09:02:32 -0600 | [diff] [blame] | 2721 | int retval = system(dotCmd); |
| 2722 | assert(retval != -1); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2723 | remove("/tmp/tmp.dot"); |
| 2724 | } |
| 2725 | else { |
| 2726 | char str[1024]; |
| 2727 | sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2728 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2729 | } |
| 2730 | #endif // WIN32 |
| 2731 | } |
| 2732 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2733 | VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalDevice gpu, const char* funcName) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2734 | { |
Jon Ashburn | 301c5f0 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 2735 | VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2736 | |
| 2737 | if (gpu == NULL) |
| 2738 | return NULL; |
| 2739 | pCurObj = gpuw; |
| 2740 | loader_platform_thread_once(&g_initOnce, initDrawState); |
| 2741 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2742 | if (!strcmp(funcName, "vkGetProcAddr")) |
| 2743 | return (void *) vkGetProcAddr; |
| 2744 | if (!strcmp(funcName, "vkCreateDevice")) |
| 2745 | return (void*) vkCreateDevice; |
| 2746 | if (!strcmp(funcName, "vkDestroyDevice")) |
| 2747 | return (void*) vkDestroyDevice; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2748 | if (!strcmp(funcName, "vkEnumerateLayers")) |
| 2749 | return (void*) vkEnumerateLayers; |
| 2750 | if (!strcmp(funcName, "vkQueueSubmit")) |
| 2751 | return (void*) vkQueueSubmit; |
| 2752 | if (!strcmp(funcName, "vkDestroyObject")) |
| 2753 | return (void*) vkDestroyObject; |
| 2754 | if (!strcmp(funcName, "vkCreateBufferView")) |
| 2755 | return (void*) vkCreateBufferView; |
| 2756 | if (!strcmp(funcName, "vkCreateImageView")) |
| 2757 | return (void*) vkCreateImageView; |
| 2758 | if (!strcmp(funcName, "vkCreateGraphicsPipeline")) |
| 2759 | return (void*) vkCreateGraphicsPipeline; |
| 2760 | if (!strcmp(funcName, "vkCreateGraphicsPipelineDerivative")) |
| 2761 | return (void*) vkCreateGraphicsPipelineDerivative; |
| 2762 | if (!strcmp(funcName, "vkCreateSampler")) |
| 2763 | return (void*) vkCreateSampler; |
| 2764 | if (!strcmp(funcName, "vkCreateDescriptorSetLayout")) |
| 2765 | return (void*) vkCreateDescriptorSetLayout; |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 2766 | if (!strcmp(funcName, "vkCreatePipelineLayout")) |
| 2767 | return (void*) vkCreatePipelineLayout; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2768 | if (!strcmp(funcName, "vkBeginDescriptorPoolUpdate")) |
| 2769 | return (void*) vkBeginDescriptorPoolUpdate; |
| 2770 | if (!strcmp(funcName, "vkEndDescriptorPoolUpdate")) |
| 2771 | return (void*) vkEndDescriptorPoolUpdate; |
| 2772 | if (!strcmp(funcName, "vkCreateDescriptorPool")) |
| 2773 | return (void*) vkCreateDescriptorPool; |
| 2774 | if (!strcmp(funcName, "vkResetDescriptorPool")) |
| 2775 | return (void*) vkResetDescriptorPool; |
| 2776 | if (!strcmp(funcName, "vkAllocDescriptorSets")) |
| 2777 | return (void*) vkAllocDescriptorSets; |
| 2778 | if (!strcmp(funcName, "vkClearDescriptorSets")) |
| 2779 | return (void*) vkClearDescriptorSets; |
| 2780 | if (!strcmp(funcName, "vkUpdateDescriptors")) |
| 2781 | return (void*) vkUpdateDescriptors; |
| 2782 | if (!strcmp(funcName, "vkCreateDynamicViewportState")) |
| 2783 | return (void*) vkCreateDynamicViewportState; |
| 2784 | if (!strcmp(funcName, "vkCreateDynamicRasterState")) |
| 2785 | return (void*) vkCreateDynamicRasterState; |
| 2786 | if (!strcmp(funcName, "vkCreateDynamicColorBlendState")) |
| 2787 | return (void*) vkCreateDynamicColorBlendState; |
| 2788 | if (!strcmp(funcName, "vkCreateDynamicDepthStencilState")) |
| 2789 | return (void*) vkCreateDynamicDepthStencilState; |
| 2790 | if (!strcmp(funcName, "vkCreateCommandBuffer")) |
| 2791 | return (void*) vkCreateCommandBuffer; |
| 2792 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
| 2793 | return (void*) vkBeginCommandBuffer; |
| 2794 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
| 2795 | return (void*) vkEndCommandBuffer; |
| 2796 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
| 2797 | return (void*) vkResetCommandBuffer; |
| 2798 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
| 2799 | return (void*) vkCmdBindPipeline; |
| 2800 | if (!strcmp(funcName, "vkCmdBindDynamicStateObject")) |
| 2801 | return (void*) vkCmdBindDynamicStateObject; |
| 2802 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
| 2803 | return (void*) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | 4696294 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2804 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
| 2805 | return (void*) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2806 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
| 2807 | return (void*) vkCmdBindIndexBuffer; |
| 2808 | if (!strcmp(funcName, "vkCmdDraw")) |
| 2809 | return (void*) vkCmdDraw; |
| 2810 | if (!strcmp(funcName, "vkCmdDrawIndexed")) |
| 2811 | return (void*) vkCmdDrawIndexed; |
| 2812 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
| 2813 | return (void*) vkCmdDrawIndirect; |
| 2814 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
| 2815 | return (void*) vkCmdDrawIndexedIndirect; |
| 2816 | if (!strcmp(funcName, "vkCmdDispatch")) |
| 2817 | return (void*) vkCmdDispatch; |
| 2818 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
| 2819 | return (void*) vkCmdDispatchIndirect; |
| 2820 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
| 2821 | return (void*) vkCmdCopyBuffer; |
| 2822 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 2823 | return (void*) vkCmdCopyImage; |
| 2824 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 2825 | return (void*) vkCmdCopyBufferToImage; |
| 2826 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 2827 | return (void*) vkCmdCopyImageToBuffer; |
| 2828 | if (!strcmp(funcName, "vkCmdCloneImageData")) |
| 2829 | return (void*) vkCmdCloneImageData; |
| 2830 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
| 2831 | return (void*) vkCmdUpdateBuffer; |
| 2832 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
| 2833 | return (void*) vkCmdFillBuffer; |
| 2834 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 2835 | return (void*) vkCmdClearColorImage; |
| 2836 | if (!strcmp(funcName, "vkCmdClearDepthStencil")) |
| 2837 | return (void*) vkCmdClearDepthStencil; |
| 2838 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 2839 | return (void*) vkCmdResolveImage; |
| 2840 | if (!strcmp(funcName, "vkCmdSetEvent")) |
| 2841 | return (void*) vkCmdSetEvent; |
| 2842 | if (!strcmp(funcName, "vkCmdResetEvent")) |
| 2843 | return (void*) vkCmdResetEvent; |
| 2844 | if (!strcmp(funcName, "vkCmdWaitEvents")) |
| 2845 | return (void*) vkCmdWaitEvents; |
| 2846 | if (!strcmp(funcName, "vkCmdPipelineBarrier")) |
| 2847 | return (void*) vkCmdPipelineBarrier; |
| 2848 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
| 2849 | return (void*) vkCmdBeginQuery; |
| 2850 | if (!strcmp(funcName, "vkCmdEndQuery")) |
| 2851 | return (void*) vkCmdEndQuery; |
| 2852 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
| 2853 | return (void*) vkCmdResetQueryPool; |
| 2854 | if (!strcmp(funcName, "vkCmdWriteTimestamp")) |
| 2855 | return (void*) vkCmdWriteTimestamp; |
| 2856 | if (!strcmp(funcName, "vkCmdInitAtomicCounters")) |
| 2857 | return (void*) vkCmdInitAtomicCounters; |
| 2858 | if (!strcmp(funcName, "vkCmdLoadAtomicCounters")) |
| 2859 | return (void*) vkCmdLoadAtomicCounters; |
| 2860 | if (!strcmp(funcName, "vkCmdSaveAtomicCounters")) |
| 2861 | return (void*) vkCmdSaveAtomicCounters; |
| 2862 | if (!strcmp(funcName, "vkCreateFramebuffer")) |
| 2863 | return (void*) vkCreateFramebuffer; |
| 2864 | if (!strcmp(funcName, "vkCreateRenderPass")) |
| 2865 | return (void*) vkCreateRenderPass; |
| 2866 | if (!strcmp(funcName, "vkCmdBeginRenderPass")) |
| 2867 | return (void*) vkCmdBeginRenderPass; |
| 2868 | if (!strcmp(funcName, "vkCmdEndRenderPass")) |
| 2869 | return (void*) vkCmdEndRenderPass; |
| 2870 | if (!strcmp(funcName, "vkDbgRegisterMsgCallback")) |
| 2871 | return (void*) vkDbgRegisterMsgCallback; |
| 2872 | if (!strcmp(funcName, "vkDbgUnregisterMsgCallback")) |
| 2873 | return (void*) vkDbgUnregisterMsgCallback; |
| 2874 | if (!strcmp(funcName, "vkCmdDbgMarkerBegin")) |
| 2875 | return (void*) vkCmdDbgMarkerBegin; |
| 2876 | if (!strcmp(funcName, "vkCmdDbgMarkerEnd")) |
| 2877 | return (void*) vkCmdDbgMarkerEnd; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2878 | if (!strcmp("drawStateDumpDotFile", funcName)) |
| 2879 | return (void*) drawStateDumpDotFile; |
| 2880 | if (!strcmp("drawStateDumpCommandBufferDotFile", funcName)) |
| 2881 | return (void*) drawStateDumpCommandBufferDotFile; |
| 2882 | if (!strcmp("drawStateDumpPngFile", funcName)) |
| 2883 | return (void*) drawStateDumpPngFile; |
| 2884 | else { |
| 2885 | if (gpuw->pGPA == NULL) |
| 2886 | return NULL; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2887 | return gpuw->pGPA((VkPhysicalDevice)gpuw->nextObject, funcName); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2888 | } |
| 2889 | } |