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