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