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 | 7c3ec60 | 2015-05-21 09:06:56 -0600 | [diff] [blame] | 525 | if ((psoNumSamples != pFBCI->sampleCount) || (psoNumSamples != pRPCI->sampleCount)) { |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 526 | char str[1024]; |
Tobin Ehlis | 7c3ec60 | 2015-05-21 09:06:56 -0600 | [diff] [blame] | 527 | sprintf(str, "Num samples mismatche! Binding PSO (%p) with %u samples while current RenderPass (%p) w/ %u samples uses FB (%p) with %u samples!", (void*)pipeline, psoNumSamples, (void*)pCB->activeRenderPass, pRPCI->sampleCount, (void*)pCB->framebuffer, pFBCI->sampleCount); |
Courtney Goeltzenleuchter | 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]; |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 969 | sprintf(str, "Unable to find pool node for pool %p specified in vkResetDescriptorPool() call", (void*)pool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 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 | { |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1567 | GLOBAL_CB_NODE* pCB = NULL; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1568 | for (uint32_t i=0; i < cmdBufferCount; i++) { |
| 1569 | // Validate that cmd buffers have been updated |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1570 | pCB = getCBNode(pCmdBuffers[i]); |
| 1571 | loader_platform_thread_lock_mutex(&globalLock); |
| 1572 | if (CB_UPDATE_COMPLETE != pCB->state) { |
| 1573 | // Flag error for using CB w/o vkEndCommandBuffer() called |
| 1574 | char str[1024]; |
| 1575 | sprintf(str, "You must call vkEndCommandBuffer() on CB %p before this call to vkQueueSubmit()!", pCB->cmdBuffer); |
| 1576 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCB->cmdBuffer, 0, DRAWSTATE_NO_END_CMD_BUFFER, "DS", str); |
| 1577 | } |
Tobin Ehlis | dea6ddf | 2015-05-26 16:06:50 -0600 | [diff] [blame^] | 1578 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1579 | for (auto ii=pCB->boundDescriptorSets.begin(); ii != pCB->boundDescriptorSets.end(); ++ii) { |
| 1580 | if (dsUpdateActive(*ii)) { |
| 1581 | char str[1024]; |
| 1582 | sprintf(str, "You must call vkEndDescriptorPoolUpdate() before this call to vkQueueSubmit()!"); |
| 1583 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, *ii, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str); |
| 1584 | } |
| 1585 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1586 | } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1587 | VkResult result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1588 | return result; |
| 1589 | } |
| 1590 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1591 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1592 | { |
| 1593 | // 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] | 1594 | VkResult result = nextTable.DestroyObject(device, objType, object); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1595 | return result; |
| 1596 | } |
| 1597 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1598 | 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] | 1599 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1600 | VkResult result = nextTable.CreateBufferView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1601 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1602 | loader_platform_thread_lock_mutex(&globalLock); |
| 1603 | BUFFER_NODE* pNewNode = new BUFFER_NODE; |
| 1604 | pNewNode->buffer = *pView; |
| 1605 | pNewNode->createInfo = *pCreateInfo; |
| 1606 | bufferMap[*pView] = pNewNode; |
| 1607 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1608 | } |
| 1609 | return result; |
| 1610 | } |
| 1611 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1612 | 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] | 1613 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1614 | VkResult result = nextTable.CreateImageView(device, pCreateInfo, pView); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1615 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1616 | loader_platform_thread_lock_mutex(&globalLock); |
| 1617 | IMAGE_NODE *pNewNode = new IMAGE_NODE; |
| 1618 | pNewNode->image = *pView; |
| 1619 | pNewNode->createInfo = *pCreateInfo; |
| 1620 | imageMap[*pView] = pNewNode; |
| 1621 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1622 | } |
| 1623 | return result; |
| 1624 | } |
| 1625 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1626 | static void track_pipeline(const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1627 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1628 | // Create LL HEAD for this Pipeline |
| 1629 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1630 | PIPELINE_NODE* pPipeNode = new PIPELINE_NODE; |
| 1631 | memset((void*)pPipeNode, 0, sizeof(PIPELINE_NODE)); |
| 1632 | pPipeNode->pipeline = *pPipeline; |
| 1633 | initPipeline(pPipeNode, pCreateInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1634 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1635 | } |
| 1636 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1637 | 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] | 1638 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1639 | VkResult result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1640 | // Create LL HEAD for this Pipeline |
| 1641 | char str[1024]; |
| 1642 | sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline); |
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 | |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1647 | return result; |
| 1648 | } |
| 1649 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1650 | VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative( |
| 1651 | VkDevice device, |
| 1652 | const VkGraphicsPipelineCreateInfo* pCreateInfo, |
| 1653 | VkPipeline basePipeline, |
| 1654 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1655 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1656 | VkResult result = nextTable.CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline); |
Courtney Goeltzenleuchter | e2aaad0 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1657 | // Create LL HEAD for this Pipeline |
| 1658 | char str[1024]; |
| 1659 | 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] | 1660 | 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] | 1661 | |
| 1662 | track_pipeline(pCreateInfo, pPipeline); |
| 1663 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1664 | loader_platform_thread_unlock_mutex(&globalLock); |
Jon Ashburn | 120cfbe | 2015-04-14 14:12:59 -0600 | [diff] [blame] | 1665 | |
| 1666 | return result; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1667 | } |
| 1668 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1669 | 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] | 1670 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1671 | VkResult result = nextTable.CreateSampler(device, pCreateInfo, pSampler); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1672 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1673 | loader_platform_thread_lock_mutex(&globalLock); |
| 1674 | SAMPLER_NODE* pNewNode = new SAMPLER_NODE; |
| 1675 | pNewNode->sampler = *pSampler; |
| 1676 | pNewNode->createInfo = *pCreateInfo; |
| 1677 | sampleMap[*pSampler] = pNewNode; |
| 1678 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1679 | } |
| 1680 | return result; |
| 1681 | } |
| 1682 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1683 | 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] | 1684 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1685 | VkResult result = nextTable.CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1686 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1687 | LAYOUT_NODE* pNewNode = new LAYOUT_NODE; |
| 1688 | if (NULL == pNewNode) { |
| 1689 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1690 | sprintf(str, "Out of memory while attempting to allocate LAYOUT_NODE in vkCreateDescriptorSetLayout()"); |
| 1691 | 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] | 1692 | } |
| 1693 | memset(pNewNode, 0, sizeof(LAYOUT_NODE)); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1694 | memcpy((void*)&pNewNode->createInfo, pCreateInfo, sizeof(VkDescriptorSetLayoutCreateInfo)); |
| 1695 | pNewNode->createInfo.pBinding = new VkDescriptorSetLayoutBinding[pCreateInfo->count]; |
| 1696 | memcpy((void*)pNewNode->createInfo.pBinding, pCreateInfo->pBinding, sizeof(VkDescriptorSetLayoutBinding)*pCreateInfo->count); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1697 | uint32_t totalCount = 0; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1698 | for (uint32_t i=0; i<pCreateInfo->count; i++) { |
| 1699 | totalCount += pCreateInfo->pBinding[i].count; |
| 1700 | if (pCreateInfo->pBinding[i].pImmutableSamplers) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1701 | VkSampler** ppIS = (VkSampler**)&pNewNode->createInfo.pBinding[i].pImmutableSamplers; |
| 1702 | *ppIS = new VkSampler[pCreateInfo->pBinding[i].count]; |
| 1703 | memcpy(*ppIS, pCreateInfo->pBinding[i].pImmutableSamplers, pCreateInfo->pBinding[i].count*sizeof(VkSampler)); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1704 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1705 | } |
| 1706 | if (totalCount > 0) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1707 | pNewNode->pTypes = new VkDescriptorType[totalCount]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1708 | uint32_t offset = 0; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1709 | uint32_t j = 0; |
| 1710 | for (uint32_t i=0; i<pCreateInfo->count; i++) { |
| 1711 | for (j = 0; j < pCreateInfo->pBinding[i].count; j++) { |
| 1712 | pNewNode->pTypes[offset + j] = pCreateInfo->pBinding[i].descriptorType; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1713 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1714 | offset += j; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1715 | } |
| 1716 | } |
| 1717 | pNewNode->layout = *pSetLayout; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1718 | pNewNode->startIndex = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1719 | pNewNode->endIndex = pNewNode->startIndex + totalCount - 1; |
| 1720 | assert(pNewNode->endIndex >= pNewNode->startIndex); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1721 | // Put new node at Head of global Layer list |
| 1722 | loader_platform_thread_lock_mutex(&globalLock); |
| 1723 | layoutMap[*pSetLayout] = pNewNode; |
| 1724 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1725 | } |
| 1726 | return result; |
| 1727 | } |
| 1728 | |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1729 | VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1730 | { |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1731 | VkResult result = nextTable.CreatePipelineLayout(device, pCreateInfo, pPipelineLayout); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1732 | if (VK_SUCCESS == result) { |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1733 | // TODO : Need to capture the pipeline layout |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1734 | } |
| 1735 | return result; |
| 1736 | } |
| 1737 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1738 | VK_LAYER_EXPORT VkResult VKAPI vkBeginDescriptorPoolUpdate(VkDevice device, VkDescriptorUpdateMode updateMode) |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1739 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1740 | VkResult result = nextTable.BeginDescriptorPoolUpdate(device, updateMode); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1741 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1742 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1743 | POOL_NODE* pPoolNode = poolMap.begin()->second; |
| 1744 | if (!pPoolNode) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1745 | char str[1024]; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1746 | sprintf(str, "Unable to find pool node"); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1747 | 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] | 1748 | } |
| 1749 | else { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1750 | pPoolNode->updateActive = 1; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1751 | } |
| 1752 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1753 | } |
| 1754 | return result; |
| 1755 | } |
| 1756 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1757 | VK_LAYER_EXPORT VkResult VKAPI vkEndDescriptorPoolUpdate(VkDevice device, VkCmdBuffer cmd) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1758 | { |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1759 | // Perform some initial validation checks |
| 1760 | POOL_NODE* pPoolNode = NULL; |
| 1761 | loader_platform_thread_lock_mutex(&globalLock); |
| 1762 | auto poolEntry = poolMap.begin(); |
| 1763 | if (poolEntry == poolMap.end()) { |
| 1764 | char str[1024]; |
| 1765 | sprintf(str, "Unable to find pool node"); |
| 1766 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
| 1767 | } |
| 1768 | else { |
| 1769 | pPoolNode = poolEntry->second; |
| 1770 | if (!pPoolNode->updateActive) { |
| 1771 | char str[1024]; |
| 1772 | sprintf(str, "You must call vkBeginDescriptorPoolUpdate() before this call to vkEndDescriptorPoolUpdate()!"); |
| 1773 | layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str); |
| 1774 | } |
| 1775 | } |
| 1776 | loader_platform_thread_unlock_mutex(&globalLock); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1777 | VkResult result = nextTable.EndDescriptorPoolUpdate(device, cmd); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1778 | if (VK_SUCCESS == result) { |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 1779 | pPoolNode->updateActive = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1780 | } |
| 1781 | return result; |
| 1782 | } |
| 1783 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1784 | 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] | 1785 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1786 | VkResult result = nextTable.CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1787 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1788 | // Insert this pool into Global Pool LL at head |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1789 | char str[1024]; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1790 | sprintf(str, "Created Descriptor Pool %p", (void*)*pDescriptorPool); |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1791 | 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] | 1792 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1793 | POOL_NODE* pNewNode = new POOL_NODE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1794 | if (NULL == pNewNode) { |
| 1795 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1796 | 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] | 1797 | 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] | 1798 | } |
| 1799 | else { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1800 | memset(pNewNode, 0, sizeof(POOL_NODE)); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1801 | VkDescriptorPoolCreateInfo* pCI = (VkDescriptorPoolCreateInfo*)&pNewNode->createInfo; |
| 1802 | memcpy((void*)pCI, pCreateInfo, sizeof(VkDescriptorPoolCreateInfo)); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1803 | if (pNewNode->createInfo.count) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1804 | size_t typeCountSize = pNewNode->createInfo.count * sizeof(VkDescriptorTypeCount); |
| 1805 | pNewNode->createInfo.pTypeCount = new VkDescriptorTypeCount[typeCountSize]; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1806 | memcpy((void*)pNewNode->createInfo.pTypeCount, pCreateInfo->pTypeCount, typeCountSize); |
| 1807 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1808 | pNewNode->poolUsage = poolUsage; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1809 | pNewNode->updateActive = 0; |
| 1810 | pNewNode->maxSets = maxSets; |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1811 | pNewNode->pool = *pDescriptorPool; |
| 1812 | poolMap[*pDescriptorPool] = pNewNode; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1813 | } |
| 1814 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1815 | } |
| 1816 | else { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1817 | // Need to do anything if pool create fails? |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1818 | } |
| 1819 | return result; |
| 1820 | } |
| 1821 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1822 | VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1823 | { |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1824 | VkResult result = nextTable.ResetDescriptorPool(device, descriptorPool); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1825 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1826 | clearDescriptorPool(descriptorPool); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1827 | } |
| 1828 | return result; |
| 1829 | } |
| 1830 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1831 | 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] | 1832 | { |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1833 | VkResult result = nextTable.AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1834 | if ((VK_SUCCESS == result) || (*pCount > 0)) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1835 | POOL_NODE *pPoolNode = getPoolNode(descriptorPool); |
| 1836 | if (!pPoolNode) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1837 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1838 | sprintf(str, "Unable to find pool node for pool %p specified in vkAllocDescriptorSets() call", (void*)descriptorPool); |
| 1839 | 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] | 1840 | } |
| 1841 | else { |
| 1842 | for (uint32_t i = 0; i < *pCount; i++) { |
| 1843 | char str[1024]; |
| 1844 | sprintf(str, "Created Descriptor Set %p", (void*)pDescriptorSets[i]); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1845 | 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] | 1846 | // Create new set node and add to head of pool nodes |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1847 | SET_NODE* pNewNode = new SET_NODE; |
| 1848 | if (NULL == pNewNode) { |
| 1849 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1850 | sprintf(str, "Out of memory while attempting to allocate SET_NODE in vkAllocDescriptorSets()"); |
| 1851 | 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] | 1852 | } |
| 1853 | else { |
| 1854 | memset(pNewNode, 0, sizeof(SET_NODE)); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1855 | // Insert set at head of Set LL for this pool |
| 1856 | pNewNode->pNext = pPoolNode->pSets; |
| 1857 | pPoolNode->pSets = pNewNode; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1858 | LAYOUT_NODE* pLayout = getLayoutNode(pSetLayouts[i]); |
| 1859 | if (NULL == pLayout) { |
| 1860 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1861 | sprintf(str, "Unable to find set layout node for layout %p specified in vkAllocDescriptorSets() call", (void*)pSetLayouts[i]); |
| 1862 | 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] | 1863 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1864 | pNewNode->pLayout = pLayout; |
| 1865 | pNewNode->pool = descriptorPool; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1866 | pNewNode->set = pDescriptorSets[i]; |
| 1867 | pNewNode->setUsage = setUsage; |
| 1868 | pNewNode->descriptorCount = pLayout->endIndex + 1; |
| 1869 | if (pNewNode->descriptorCount) { |
| 1870 | size_t descriptorArraySize = sizeof(GENERIC_HEADER*)*pNewNode->descriptorCount; |
| 1871 | pNewNode->ppDescriptors = new GENERIC_HEADER*[descriptorArraySize]; |
| 1872 | memset(pNewNode->ppDescriptors, 0, descriptorArraySize); |
| 1873 | } |
| 1874 | setMap[pDescriptorSets[i]] = pNewNode; |
| 1875 | } |
| 1876 | } |
| 1877 | } |
| 1878 | } |
| 1879 | return result; |
| 1880 | } |
| 1881 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1882 | 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] | 1883 | { |
| 1884 | for (uint32_t i = 0; i < count; i++) { |
| 1885 | clearDescriptorSet(pDescriptorSets[i]); |
| 1886 | } |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1887 | nextTable.ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1888 | } |
| 1889 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1890 | 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] | 1891 | { |
| 1892 | SET_NODE* pSet = getSetNode(descriptorSet); |
| 1893 | if (!dsUpdateActive(descriptorSet)) { |
| 1894 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1895 | sprintf(str, "You must call vkBeginDescriptorPoolUpdate() before this call to vkUpdateDescriptors()!"); |
| 1896 | 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] | 1897 | } |
| 1898 | else { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1899 | // 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] | 1900 | dsUpdate(descriptorSet, updateCount, ppUpdateArray); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1901 | } |
| 1902 | |
Mike Stroyan | b050c68 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1903 | nextTable.UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1904 | } |
| 1905 | |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1906 | 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] | 1907 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1908 | VkResult result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1909 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_VIEWPORT); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1910 | return result; |
| 1911 | } |
| 1912 | |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1913 | 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] | 1914 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1915 | VkResult result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1916 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_RASTER); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1917 | return result; |
| 1918 | } |
| 1919 | |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1920 | 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] | 1921 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1922 | VkResult result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1923 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_COLOR_BLEND); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1924 | return result; |
| 1925 | } |
| 1926 | |
Courtney Goeltzenleuchter | 502744a | 2015-04-10 16:24:50 -0600 | [diff] [blame] | 1927 | 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] | 1928 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1929 | VkResult result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1930 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_DEPTH_STENCIL); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1931 | return result; |
| 1932 | } |
| 1933 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1934 | 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] | 1935 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1936 | VkResult result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1937 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1938 | loader_platform_thread_lock_mutex(&globalLock); |
| 1939 | GLOBAL_CB_NODE* pCB = new GLOBAL_CB_NODE; |
| 1940 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
| 1941 | pCB->cmdBuffer = *pCmdBuffer; |
| 1942 | pCB->flags = pCreateInfo->flags; |
Courtney Goeltzenleuchter | 18248e6 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1943 | pCB->queueNodeIndex = pCreateInfo->queueNodeIndex; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1944 | pCB->lastVtxBinding = MAX_BINDING; |
| 1945 | cmdBufferMap[*pCmdBuffer] = pCB; |
| 1946 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1947 | updateCBTracking(*pCmdBuffer); |
| 1948 | } |
| 1949 | return result; |
| 1950 | } |
| 1951 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1952 | VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1953 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1954 | VkResult result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1955 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1956 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1957 | if (pCB) { |
| 1958 | if (CB_NEW != pCB->state) |
| 1959 | resetCB(cmdBuffer); |
| 1960 | pCB->state = CB_UPDATE_ACTIVE; |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1961 | if (pBeginInfo->pNext) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1962 | VkCmdBufferGraphicsBeginInfo* pCbGfxBI = (VkCmdBufferGraphicsBeginInfo*)pBeginInfo->pNext; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1963 | if (VK_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO == pCbGfxBI->sType) { |
Courtney Goeltzenleuchter | 69894b7 | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 1964 | pCB->activeRenderPass = pCbGfxBI->renderPassContinue.renderPass; |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1965 | } |
| 1966 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1967 | } |
| 1968 | else { |
| 1969 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1970 | sprintf(str, "In vkBeginCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer); |
| 1971 | 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] | 1972 | } |
| 1973 | updateCBTracking(cmdBuffer); |
| 1974 | } |
| 1975 | return result; |
| 1976 | } |
| 1977 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1978 | VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1979 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1980 | VkResult result = nextTable.EndCommandBuffer(cmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1981 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1982 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1983 | if (pCB) { |
| 1984 | pCB->state = CB_UPDATE_COMPLETE; |
| 1985 | printCB(cmdBuffer); |
| 1986 | } |
| 1987 | else { |
| 1988 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1989 | sprintf(str, "In vkEndCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer); |
| 1990 | 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] | 1991 | } |
| 1992 | updateCBTracking(cmdBuffer); |
| 1993 | //cbDumpDotFile("cb_dump.dot"); |
| 1994 | } |
| 1995 | return result; |
| 1996 | } |
| 1997 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1998 | VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1999 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2000 | VkResult result = nextTable.ResetCommandBuffer(cmdBuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2001 | if (VK_SUCCESS == result) { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2002 | resetCB(cmdBuffer); |
| 2003 | updateCBTracking(cmdBuffer); |
| 2004 | } |
| 2005 | return result; |
| 2006 | } |
| 2007 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2008 | VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2009 | { |
| 2010 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2011 | if (pCB) { |
| 2012 | updateCBTracking(cmdBuffer); |
| 2013 | addCmd(pCB, CMD_BINDPIPELINE); |
| 2014 | PIPELINE_NODE* pPN = getPipeline(pipeline); |
| 2015 | if (pPN) { |
| 2016 | pCB->lastBoundPipeline = pipeline; |
| 2017 | loader_platform_thread_lock_mutex(&globalLock); |
| 2018 | g_lastBoundPipeline = pPN; |
| 2019 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2020 | validatePipelineState(pCB, pipelineBindPoint, pipeline); |
Tobin Ehlis | dea6ddf | 2015-05-26 16:06:50 -0600 | [diff] [blame^] | 2021 | nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2022 | } |
| 2023 | else { |
| 2024 | char str[1024]; |
| 2025 | 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] | 2026 | 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] | 2027 | } |
| 2028 | } |
| 2029 | else { |
| 2030 | char str[1024]; |
| 2031 | 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] | 2032 | 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] | 2033 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2034 | } |
| 2035 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2036 | VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2037 | { |
| 2038 | setLastBoundDynamicState(cmdBuffer, state, stateBindPoint); |
| 2039 | nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); |
| 2040 | } |
| 2041 | |
Cody Northrop | d4c1a50 | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 2042 | 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] | 2043 | { |
| 2044 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2045 | if (pCB) { |
| 2046 | updateCBTracking(cmdBuffer); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2047 | addCmd(pCB, CMD_BINDDESCRIPTORSETS); |
Cody Northrop | d4c1a50 | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 2048 | for (uint32_t i=0; i<setCount; i++) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2049 | if (getSetNode(pDescriptorSets[i])) { |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2050 | loader_platform_thread_lock_mutex(&globalLock); |
| 2051 | pCB->lastBoundDescriptorSet = pDescriptorSets[i]; |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 2052 | pCB->boundDescriptorSets.push_back(pDescriptorSets[i]); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2053 | g_lastBoundDescriptorSet = pDescriptorSets[i]; |
| 2054 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2055 | char str[1024]; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2056 | 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] | 2057 | 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] | 2058 | synchAndPrintDSConfig(cmdBuffer); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2059 | } |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2060 | else { |
| 2061 | char str[1024]; |
| 2062 | 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] | 2063 | 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] | 2064 | } |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2065 | } |
| 2066 | } |
| 2067 | else { |
| 2068 | char str[1024]; |
| 2069 | 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] | 2070 | 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] | 2071 | } |
Cody Northrop | d4c1a50 | 2015-04-16 13:41:56 -0600 | [diff] [blame] | 2072 | nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2073 | } |
| 2074 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2075 | 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] | 2076 | { |
| 2077 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2078 | if (pCB) { |
| 2079 | updateCBTracking(cmdBuffer); |
| 2080 | addCmd(pCB, CMD_BINDINDEXBUFFER); |
| 2081 | // TODO : Track idxBuffer binding |
| 2082 | } |
| 2083 | else { |
| 2084 | char str[1024]; |
| 2085 | 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] | 2086 | 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] | 2087 | } |
| 2088 | nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
| 2089 | } |
| 2090 | |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2091 | VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers( |
| 2092 | VkCmdBuffer cmdBuffer, |
| 2093 | uint32_t startBinding, |
| 2094 | uint32_t bindingCount, |
| 2095 | const VkBuffer* pBuffers, |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2096 | const VkDeviceSize* pOffsets) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2097 | { |
| 2098 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2099 | if (pCB) { |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2100 | /* TODO: Need to track all the vertex buffers, not just last one */ |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2101 | updateCBTracking(cmdBuffer); |
| 2102 | addCmd(pCB, CMD_BINDVERTEXBUFFER); |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2103 | pCB->lastVtxBinding = startBinding + bindingCount -1; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2104 | validateVBBinding(cmdBuffer); |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2105 | } else { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2106 | char str[1024]; |
| 2107 | 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] | 2108 | 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] | 2109 | } |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2110 | nextTable.CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2111 | } |
| 2112 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2113 | 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] | 2114 | { |
| 2115 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2116 | if (pCB) { |
| 2117 | updateCBTracking(cmdBuffer); |
| 2118 | addCmd(pCB, CMD_DRAW); |
| 2119 | pCB->drawCount[DRAW]++; |
| 2120 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2121 | sprintf(str, "vkCmdDraw() call #%lu, reporting DS state:", g_drawCount[DRAW]++); |
| 2122 | 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] | 2123 | synchAndPrintDSConfig(cmdBuffer); |
| 2124 | } |
| 2125 | else { |
| 2126 | char str[1024]; |
| 2127 | 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] | 2128 | 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] | 2129 | } |
| 2130 | nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount); |
| 2131 | } |
| 2132 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2133 | 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] | 2134 | { |
| 2135 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2136 | if (pCB) { |
| 2137 | updateCBTracking(cmdBuffer); |
| 2138 | addCmd(pCB, CMD_DRAWINDEXED); |
| 2139 | pCB->drawCount[DRAW_INDEXED]++; |
| 2140 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2141 | sprintf(str, "vkCmdDrawIndexed() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED]++); |
| 2142 | 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] | 2143 | synchAndPrintDSConfig(cmdBuffer); |
| 2144 | } |
| 2145 | else { |
| 2146 | char str[1024]; |
| 2147 | 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] | 2148 | 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] | 2149 | } |
| 2150 | nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount); |
| 2151 | } |
| 2152 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2153 | 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] | 2154 | { |
| 2155 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2156 | if (pCB) { |
| 2157 | updateCBTracking(cmdBuffer); |
| 2158 | addCmd(pCB, CMD_DRAWINDIRECT); |
| 2159 | pCB->drawCount[DRAW_INDIRECT]++; |
| 2160 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2161 | sprintf(str, "vkCmdDrawIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDIRECT]++); |
| 2162 | 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] | 2163 | synchAndPrintDSConfig(cmdBuffer); |
| 2164 | } |
| 2165 | else { |
| 2166 | char str[1024]; |
| 2167 | 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] | 2168 | 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] | 2169 | } |
| 2170 | nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
| 2171 | } |
| 2172 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2173 | 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] | 2174 | { |
| 2175 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2176 | if (pCB) { |
| 2177 | updateCBTracking(cmdBuffer); |
| 2178 | addCmd(pCB, CMD_DRAWINDEXEDINDIRECT); |
| 2179 | pCB->drawCount[DRAW_INDEXED_INDIRECT]++; |
| 2180 | char str[1024]; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2181 | sprintf(str, "vkCmdDrawIndexedIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED_INDIRECT]++); |
| 2182 | 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] | 2183 | synchAndPrintDSConfig(cmdBuffer); |
| 2184 | } |
| 2185 | else { |
| 2186 | char str[1024]; |
| 2187 | 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] | 2188 | 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] | 2189 | } |
| 2190 | nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
| 2191 | } |
| 2192 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2193 | 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] | 2194 | { |
| 2195 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2196 | if (pCB) { |
| 2197 | updateCBTracking(cmdBuffer); |
| 2198 | addCmd(pCB, CMD_DISPATCH); |
| 2199 | } |
| 2200 | else { |
| 2201 | char str[1024]; |
| 2202 | 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] | 2203 | 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] | 2204 | } |
| 2205 | nextTable.CmdDispatch(cmdBuffer, x, y, z); |
| 2206 | } |
| 2207 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2208 | VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2209 | { |
| 2210 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2211 | if (pCB) { |
| 2212 | updateCBTracking(cmdBuffer); |
| 2213 | addCmd(pCB, CMD_DISPATCHINDIRECT); |
| 2214 | } |
| 2215 | else { |
| 2216 | char str[1024]; |
| 2217 | 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] | 2218 | 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] | 2219 | } |
| 2220 | nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset); |
| 2221 | } |
| 2222 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2223 | 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] | 2224 | { |
| 2225 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2226 | if (pCB) { |
| 2227 | updateCBTracking(cmdBuffer); |
| 2228 | addCmd(pCB, CMD_COPYBUFFER); |
| 2229 | } |
| 2230 | else { |
| 2231 | char str[1024]; |
| 2232 | 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] | 2233 | 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] | 2234 | } |
| 2235 | nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
| 2236 | } |
| 2237 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2238 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer, |
| 2239 | VkImage srcImage, |
| 2240 | VkImageLayout srcImageLayout, |
| 2241 | VkImage destImage, |
| 2242 | VkImageLayout destImageLayout, |
| 2243 | uint32_t regionCount, const VkImageCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2244 | { |
| 2245 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2246 | if (pCB) { |
| 2247 | updateCBTracking(cmdBuffer); |
| 2248 | addCmd(pCB, CMD_COPYIMAGE); |
| 2249 | } |
| 2250 | else { |
| 2251 | char str[1024]; |
| 2252 | 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] | 2253 | 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] | 2254 | } |
Courtney Goeltzenleuchter | a1c9f7a | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2255 | nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2256 | } |
| 2257 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2258 | VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer, |
| 2259 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 2260 | VkImage destImage, VkImageLayout destImageLayout, |
Mark Lobodzinski | ee5eef1 | 2015-05-22 14:43:25 -0500 | [diff] [blame] | 2261 | uint32_t regionCount, const VkImageBlit* pRegions, |
| 2262 | VkTexFilter filter) |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2263 | { |
| 2264 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2265 | if (pCB) { |
| 2266 | updateCBTracking(cmdBuffer); |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2267 | addCmd(pCB, CMD_BLITIMAGE); |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2268 | } |
| 2269 | else { |
| 2270 | char str[1024]; |
| 2271 | 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] | 2272 | 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] | 2273 | } |
Mark Lobodzinski | ee5eef1 | 2015-05-22 14:43:25 -0500 | [diff] [blame] | 2274 | nextTable.CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter); |
Courtney Goeltzenleuchter | 91f9cee | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2275 | } |
| 2276 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2277 | VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer, |
| 2278 | VkBuffer srcBuffer, |
| 2279 | VkImage destImage, VkImageLayout destImageLayout, |
| 2280 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2281 | { |
| 2282 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2283 | if (pCB) { |
| 2284 | updateCBTracking(cmdBuffer); |
| 2285 | addCmd(pCB, CMD_COPYBUFFERTOIMAGE); |
| 2286 | } |
| 2287 | else { |
| 2288 | char str[1024]; |
| 2289 | 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] | 2290 | 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] | 2291 | } |
Courtney Goeltzenleuchter | a1c9f7a | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2292 | nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2293 | } |
| 2294 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2295 | VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer, |
| 2296 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 2297 | VkBuffer destBuffer, |
| 2298 | uint32_t regionCount, const VkBufferImageCopy* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2299 | { |
| 2300 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2301 | if (pCB) { |
| 2302 | updateCBTracking(cmdBuffer); |
| 2303 | addCmd(pCB, CMD_COPYIMAGETOBUFFER); |
| 2304 | } |
| 2305 | else { |
| 2306 | char str[1024]; |
| 2307 | 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] | 2308 | 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] | 2309 | } |
Courtney Goeltzenleuchter | a1c9f7a | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2310 | nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2311 | } |
| 2312 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2313 | 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] | 2314 | { |
| 2315 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2316 | if (pCB) { |
| 2317 | updateCBTracking(cmdBuffer); |
| 2318 | addCmd(pCB, CMD_UPDATEBUFFER); |
| 2319 | } |
| 2320 | else { |
| 2321 | char str[1024]; |
| 2322 | 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] | 2323 | 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] | 2324 | } |
| 2325 | nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
| 2326 | } |
| 2327 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2328 | 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] | 2329 | { |
| 2330 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2331 | if (pCB) { |
| 2332 | updateCBTracking(cmdBuffer); |
| 2333 | addCmd(pCB, CMD_FILLBUFFER); |
| 2334 | } |
| 2335 | else { |
| 2336 | char str[1024]; |
| 2337 | 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] | 2338 | 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] | 2339 | } |
| 2340 | nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
| 2341 | } |
| 2342 | |
Courtney Goeltzenleuchter | d7a5cff | 2015-04-23 17:49:22 -0600 | [diff] [blame] | 2343 | VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage( |
| 2344 | VkCmdBuffer cmdBuffer, |
| 2345 | VkImage image, VkImageLayout imageLayout, |
| 2346 | const VkClearColor *pColor, |
| 2347 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2348 | { |
| 2349 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2350 | if (pCB) { |
| 2351 | updateCBTracking(cmdBuffer); |
| 2352 | addCmd(pCB, CMD_CLEARCOLORIMAGE); |
| 2353 | } |
| 2354 | else { |
| 2355 | char str[1024]; |
| 2356 | 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] | 2357 | 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] | 2358 | } |
Courtney Goeltzenleuchter | d7a5cff | 2015-04-23 17:49:22 -0600 | [diff] [blame] | 2359 | nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2360 | } |
| 2361 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2362 | VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer, |
| 2363 | VkImage image, VkImageLayout imageLayout, |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2364 | float depth, uint32_t stencil, |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2365 | uint32_t rangeCount, const VkImageSubresourceRange* pRanges) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2366 | { |
| 2367 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2368 | if (pCB) { |
| 2369 | updateCBTracking(cmdBuffer); |
| 2370 | addCmd(pCB, CMD_CLEARDEPTHSTENCIL); |
| 2371 | } |
| 2372 | else { |
| 2373 | char str[1024]; |
| 2374 | 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] | 2375 | 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] | 2376 | } |
Courtney Goeltzenleuchter | a1c9f7a | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2377 | nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2378 | } |
| 2379 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2380 | VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer, |
| 2381 | VkImage srcImage, VkImageLayout srcImageLayout, |
| 2382 | VkImage destImage, VkImageLayout destImageLayout, |
Tony Barbour | 6865d4a | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 2383 | uint32_t regionCount, const VkImageResolve* pRegions) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2384 | { |
| 2385 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2386 | if (pCB) { |
| 2387 | updateCBTracking(cmdBuffer); |
| 2388 | addCmd(pCB, CMD_RESOLVEIMAGE); |
| 2389 | } |
| 2390 | else { |
| 2391 | char str[1024]; |
| 2392 | 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] | 2393 | 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] | 2394 | } |
Tony Barbour | 6865d4a | 2015-04-13 15:02:52 -0600 | [diff] [blame] | 2395 | nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2396 | } |
| 2397 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2398 | VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2399 | { |
| 2400 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2401 | if (pCB) { |
| 2402 | updateCBTracking(cmdBuffer); |
| 2403 | addCmd(pCB, CMD_SETEVENT); |
| 2404 | } |
| 2405 | else { |
| 2406 | char str[1024]; |
| 2407 | 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] | 2408 | 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] | 2409 | } |
| 2410 | nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent); |
| 2411 | } |
| 2412 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2413 | VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2414 | { |
| 2415 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2416 | if (pCB) { |
| 2417 | updateCBTracking(cmdBuffer); |
| 2418 | addCmd(pCB, CMD_RESETEVENT); |
| 2419 | } |
| 2420 | else { |
| 2421 | char str[1024]; |
| 2422 | 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] | 2423 | 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] | 2424 | } |
Courtney Goeltzenleuchter | 1e8f3be | 2015-03-24 18:02:34 -0600 | [diff] [blame] | 2425 | nextTable.CmdResetEvent(cmdBuffer, event, pipeEvent); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2426 | } |
| 2427 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2428 | 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] | 2429 | { |
| 2430 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2431 | if (pCB) { |
| 2432 | updateCBTracking(cmdBuffer); |
| 2433 | addCmd(pCB, CMD_WAITEVENTS); |
| 2434 | } |
| 2435 | else { |
| 2436 | char str[1024]; |
| 2437 | 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] | 2438 | 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] | 2439 | } |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2440 | nextTable.CmdWaitEvents(cmdBuffer, waitEvent, eventCount, pEvents, memBarrierCount, ppMemBarriers); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2441 | } |
| 2442 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2443 | 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] | 2444 | { |
| 2445 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2446 | if (pCB) { |
| 2447 | updateCBTracking(cmdBuffer); |
| 2448 | addCmd(pCB, CMD_PIPELINEBARRIER); |
| 2449 | } |
| 2450 | else { |
| 2451 | char str[1024]; |
| 2452 | 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] | 2453 | 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] | 2454 | } |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2455 | nextTable.CmdPipelineBarrier(cmdBuffer, waitEvent, pipeEventCount, pPipeEvents, memBarrierCount, ppMemBarriers); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2456 | } |
| 2457 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2458 | 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] | 2459 | { |
| 2460 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2461 | if (pCB) { |
| 2462 | updateCBTracking(cmdBuffer); |
| 2463 | addCmd(pCB, CMD_BEGINQUERY); |
| 2464 | } |
| 2465 | else { |
| 2466 | char str[1024]; |
| 2467 | 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] | 2468 | 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] | 2469 | } |
| 2470 | nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
| 2471 | } |
| 2472 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2473 | 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] | 2474 | { |
| 2475 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2476 | if (pCB) { |
| 2477 | updateCBTracking(cmdBuffer); |
| 2478 | addCmd(pCB, CMD_ENDQUERY); |
| 2479 | } |
| 2480 | else { |
| 2481 | char str[1024]; |
| 2482 | 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] | 2483 | 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] | 2484 | } |
| 2485 | nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); |
| 2486 | } |
| 2487 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2488 | 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] | 2489 | { |
| 2490 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2491 | if (pCB) { |
| 2492 | updateCBTracking(cmdBuffer); |
| 2493 | addCmd(pCB, CMD_RESETQUERYPOOL); |
| 2494 | } |
| 2495 | else { |
| 2496 | char str[1024]; |
| 2497 | 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] | 2498 | 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] | 2499 | } |
| 2500 | nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
| 2501 | } |
| 2502 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2503 | 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] | 2504 | { |
| 2505 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2506 | if (pCB) { |
| 2507 | updateCBTracking(cmdBuffer); |
| 2508 | addCmd(pCB, CMD_WRITETIMESTAMP); |
| 2509 | } |
| 2510 | else { |
| 2511 | char str[1024]; |
| 2512 | 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] | 2513 | 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] | 2514 | } |
| 2515 | nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset); |
| 2516 | } |
| 2517 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2518 | 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] | 2519 | { |
| 2520 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2521 | if (pCB) { |
| 2522 | updateCBTracking(cmdBuffer); |
| 2523 | addCmd(pCB, CMD_INITATOMICCOUNTERS); |
| 2524 | } |
| 2525 | else { |
| 2526 | char str[1024]; |
| 2527 | 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] | 2528 | 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] | 2529 | } |
| 2530 | nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData); |
| 2531 | } |
| 2532 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2533 | 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] | 2534 | { |
| 2535 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2536 | if (pCB) { |
| 2537 | updateCBTracking(cmdBuffer); |
| 2538 | addCmd(pCB, CMD_LOADATOMICCOUNTERS); |
| 2539 | } |
| 2540 | else { |
| 2541 | char str[1024]; |
| 2542 | 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] | 2543 | 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] | 2544 | } |
| 2545 | nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset); |
| 2546 | } |
| 2547 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2548 | 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] | 2549 | { |
| 2550 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2551 | if (pCB) { |
| 2552 | updateCBTracking(cmdBuffer); |
| 2553 | addCmd(pCB, CMD_SAVEATOMICCOUNTERS); |
| 2554 | } |
| 2555 | else { |
| 2556 | char str[1024]; |
| 2557 | 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] | 2558 | 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] | 2559 | } |
| 2560 | nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset); |
| 2561 | } |
| 2562 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2563 | 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] | 2564 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2565 | VkResult result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2566 | if (VK_SUCCESS == result) { |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2567 | // Shadow create info and store in map |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2568 | VkFramebufferCreateInfo* localFBCI = new VkFramebufferCreateInfo(*pCreateInfo); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2569 | if (pCreateInfo->pColorAttachments) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2570 | localFBCI->pColorAttachments = new VkColorAttachmentBindInfo[localFBCI->colorAttachmentCount]; |
| 2571 | memcpy((void*)localFBCI->pColorAttachments, pCreateInfo->pColorAttachments, localFBCI->colorAttachmentCount*sizeof(VkColorAttachmentBindInfo)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2572 | } |
| 2573 | if (pCreateInfo->pDepthStencilAttachment) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2574 | localFBCI->pDepthStencilAttachment = new VkDepthStencilBindInfo[localFBCI->colorAttachmentCount]; |
| 2575 | memcpy((void*)localFBCI->pDepthStencilAttachment, pCreateInfo->pDepthStencilAttachment, localFBCI->colorAttachmentCount*sizeof(VkDepthStencilBindInfo)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2576 | } |
| 2577 | frameBufferMap[*pFramebuffer] = localFBCI; |
| 2578 | } |
| 2579 | return result; |
| 2580 | } |
| 2581 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2582 | 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] | 2583 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2584 | VkResult result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2585 | if (VK_SUCCESS == result) { |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2586 | // Shadow create info and store in map |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2587 | VkRenderPassCreateInfo* localRPCI = new VkRenderPassCreateInfo(*pCreateInfo); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2588 | if (pCreateInfo->pColorLoadOps) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2589 | localRPCI->pColorLoadOps = new VkAttachmentLoadOp[localRPCI->colorAttachmentCount]; |
| 2590 | memcpy((void*)localRPCI->pColorLoadOps, pCreateInfo->pColorLoadOps, localRPCI->colorAttachmentCount*sizeof(VkAttachmentLoadOp)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2591 | } |
| 2592 | if (pCreateInfo->pColorStoreOps) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2593 | localRPCI->pColorStoreOps = new VkAttachmentStoreOp[localRPCI->colorAttachmentCount]; |
| 2594 | memcpy((void*)localRPCI->pColorStoreOps, pCreateInfo->pColorStoreOps, localRPCI->colorAttachmentCount*sizeof(VkAttachmentStoreOp)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2595 | } |
| 2596 | if (pCreateInfo->pColorLoadClearValues) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2597 | localRPCI->pColorLoadClearValues = new VkClearColor[localRPCI->colorAttachmentCount]; |
| 2598 | memcpy((void*)localRPCI->pColorLoadClearValues, pCreateInfo->pColorLoadClearValues, localRPCI->colorAttachmentCount*sizeof(VkClearColor)); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2599 | } |
| 2600 | renderPassMap[*pRenderPass] = localRPCI; |
| 2601 | } |
| 2602 | return result; |
| 2603 | } |
| 2604 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2605 | VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBegin *pRenderPassBegin) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2606 | { |
| 2607 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2608 | if (pCB) { |
| 2609 | updateCBTracking(cmdBuffer); |
| 2610 | addCmd(pCB, CMD_BEGINRENDERPASS); |
Courtney Goeltzenleuchter | 69894b7 | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2611 | pCB->activeRenderPass = pRenderPassBegin->renderPass; |
| 2612 | pCB->framebuffer = pRenderPassBegin->framebuffer; |
Tony Barbour | badda99 | 2015-04-06 11:09:26 -0600 | [diff] [blame] | 2613 | if (pCB->lastBoundPipeline) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2614 | validatePipelineState(pCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pCB->lastBoundPipeline); |
Tony Barbour | badda99 | 2015-04-06 11:09:26 -0600 | [diff] [blame] | 2615 | } |
Courtney Goeltzenleuchter | 69894b7 | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2616 | } else { |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2617 | char str[1024]; |
| 2618 | 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] | 2619 | 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] | 2620 | } |
Courtney Goeltzenleuchter | 69894b7 | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2621 | nextTable.CmdBeginRenderPass(cmdBuffer, pRenderPassBegin); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2622 | } |
| 2623 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2624 | VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2625 | { |
| 2626 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2627 | if (pCB) { |
| 2628 | updateCBTracking(cmdBuffer); |
| 2629 | addCmd(pCB, CMD_ENDRENDERPASS); |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2630 | pCB->activeRenderPass = 0; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2631 | } |
| 2632 | else { |
| 2633 | char str[1024]; |
| 2634 | 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] | 2635 | 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] | 2636 | } |
| 2637 | nextTable.CmdEndRenderPass(cmdBuffer, renderPass); |
| 2638 | } |
| 2639 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2640 | 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] | 2641 | { |
| 2642 | // This layer intercepts callbacks |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 2643 | VK_LAYER_DBG_FUNCTION_NODE* pNewDbgFuncNode = new VK_LAYER_DBG_FUNCTION_NODE; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2644 | if (!pNewDbgFuncNode) |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2645 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2646 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 2647 | pNewDbgFuncNode->pUserData = pUserData; |
| 2648 | pNewDbgFuncNode->pNext = g_pDbgFunctionHead; |
| 2649 | g_pDbgFunctionHead = pNewDbgFuncNode; |
| 2650 | // force callbacks if DebugAction hasn't been set already other than initial value |
| 2651 | if (g_actionIsDefault) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2652 | g_debugAction = VK_DBG_LAYER_ACTION_CALLBACK; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2653 | } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2654 | VkResult result = nextTable.DbgRegisterMsgCallback(instance, pfnMsgCallback, pUserData); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2655 | return result; |
| 2656 | } |
| 2657 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2658 | 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] | 2659 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2660 | VK_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; |
| 2661 | VK_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2662 | while (pTrav) { |
| 2663 | if (pTrav->pfnMsgCallback == pfnMsgCallback) { |
| 2664 | pPrev->pNext = pTrav->pNext; |
| 2665 | if (g_pDbgFunctionHead == pTrav) |
| 2666 | g_pDbgFunctionHead = pTrav->pNext; |
Tobin Ehlis | ecc6bd0 | 2015-04-08 10:58:37 -0600 | [diff] [blame] | 2667 | delete pTrav; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2668 | break; |
| 2669 | } |
| 2670 | pPrev = pTrav; |
| 2671 | pTrav = pTrav->pNext; |
| 2672 | } |
| 2673 | if (g_pDbgFunctionHead == NULL) |
| 2674 | { |
| 2675 | if (g_actionIsDefault) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2676 | g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2677 | else |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2678 | 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] | 2679 | } |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2680 | VkResult result = nextTable.DbgUnregisterMsgCallback(instance, pfnMsgCallback); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2681 | return result; |
| 2682 | } |
| 2683 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2684 | VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2685 | { |
| 2686 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2687 | if (pCB) { |
| 2688 | updateCBTracking(cmdBuffer); |
| 2689 | addCmd(pCB, CMD_DBGMARKERBEGIN); |
| 2690 | } |
| 2691 | else { |
| 2692 | char str[1024]; |
| 2693 | 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] | 2694 | 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] | 2695 | } |
| 2696 | nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker); |
| 2697 | } |
| 2698 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2699 | VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2700 | { |
| 2701 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2702 | if (pCB) { |
| 2703 | updateCBTracking(cmdBuffer); |
| 2704 | addCmd(pCB, CMD_DBGMARKEREND); |
| 2705 | } |
| 2706 | else { |
| 2707 | char str[1024]; |
| 2708 | 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] | 2709 | 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] | 2710 | } |
| 2711 | nextTable.CmdDbgMarkerEnd(cmdBuffer); |
| 2712 | } |
| 2713 | |
| 2714 | // TODO : Want to pass in a cmdBuffer here based on which state to display |
| 2715 | void drawStateDumpDotFile(char* outFileName) |
| 2716 | { |
| 2717 | // TODO : Currently just setting cmdBuffer based on global var |
| 2718 | //dumpDotFile(g_lastDrawStateCmdBuffer, outFileName); |
| 2719 | dumpGlobalDotFile(outFileName); |
| 2720 | } |
| 2721 | |
| 2722 | void drawStateDumpCommandBufferDotFile(char* outFileName) |
| 2723 | { |
| 2724 | cbDumpDotFile(outFileName); |
| 2725 | } |
| 2726 | |
| 2727 | void drawStateDumpPngFile(char* outFileName) |
| 2728 | { |
| 2729 | #if defined(_WIN32) |
| 2730 | // FIXME: NEED WINDOWS EQUIVALENT |
| 2731 | char str[1024]; |
| 2732 | sprintf(str, "Cannot execute dot program yet on Windows."); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2733 | 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] | 2734 | #else // WIN32 |
| 2735 | char dotExe[32] = "/usr/bin/dot"; |
| 2736 | if( access(dotExe, X_OK) != -1) { |
| 2737 | dumpDotFile(g_lastCmdBuffer[getTIDIndex()], "/tmp/tmp.dot"); |
| 2738 | char dotCmd[1024]; |
| 2739 | sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName); |
Tony Barbour | f20f87b | 2015-04-22 09:02:32 -0600 | [diff] [blame] | 2740 | int retval = system(dotCmd); |
| 2741 | assert(retval != -1); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2742 | remove("/tmp/tmp.dot"); |
| 2743 | } |
| 2744 | else { |
| 2745 | char str[1024]; |
| 2746 | 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] | 2747 | 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] | 2748 | } |
| 2749 | #endif // WIN32 |
| 2750 | } |
| 2751 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2752 | VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalDevice gpu, const char* funcName) |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2753 | { |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 2754 | VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2755 | |
| 2756 | if (gpu == NULL) |
| 2757 | return NULL; |
| 2758 | pCurObj = gpuw; |
| 2759 | loader_platform_thread_once(&g_initOnce, initDrawState); |
| 2760 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2761 | if (!strcmp(funcName, "vkGetProcAddr")) |
| 2762 | return (void *) vkGetProcAddr; |
| 2763 | if (!strcmp(funcName, "vkCreateDevice")) |
| 2764 | return (void*) vkCreateDevice; |
| 2765 | if (!strcmp(funcName, "vkDestroyDevice")) |
| 2766 | return (void*) vkDestroyDevice; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2767 | if (!strcmp(funcName, "vkEnumerateLayers")) |
| 2768 | return (void*) vkEnumerateLayers; |
| 2769 | if (!strcmp(funcName, "vkQueueSubmit")) |
| 2770 | return (void*) vkQueueSubmit; |
| 2771 | if (!strcmp(funcName, "vkDestroyObject")) |
| 2772 | return (void*) vkDestroyObject; |
| 2773 | if (!strcmp(funcName, "vkCreateBufferView")) |
| 2774 | return (void*) vkCreateBufferView; |
| 2775 | if (!strcmp(funcName, "vkCreateImageView")) |
| 2776 | return (void*) vkCreateImageView; |
| 2777 | if (!strcmp(funcName, "vkCreateGraphicsPipeline")) |
| 2778 | return (void*) vkCreateGraphicsPipeline; |
| 2779 | if (!strcmp(funcName, "vkCreateGraphicsPipelineDerivative")) |
| 2780 | return (void*) vkCreateGraphicsPipelineDerivative; |
| 2781 | if (!strcmp(funcName, "vkCreateSampler")) |
| 2782 | return (void*) vkCreateSampler; |
| 2783 | if (!strcmp(funcName, "vkCreateDescriptorSetLayout")) |
| 2784 | return (void*) vkCreateDescriptorSetLayout; |
Mark Lobodzinski | 0fadf5f | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 2785 | if (!strcmp(funcName, "vkCreatePipelineLayout")) |
| 2786 | return (void*) vkCreatePipelineLayout; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2787 | if (!strcmp(funcName, "vkBeginDescriptorPoolUpdate")) |
| 2788 | return (void*) vkBeginDescriptorPoolUpdate; |
| 2789 | if (!strcmp(funcName, "vkEndDescriptorPoolUpdate")) |
| 2790 | return (void*) vkEndDescriptorPoolUpdate; |
| 2791 | if (!strcmp(funcName, "vkCreateDescriptorPool")) |
| 2792 | return (void*) vkCreateDescriptorPool; |
| 2793 | if (!strcmp(funcName, "vkResetDescriptorPool")) |
| 2794 | return (void*) vkResetDescriptorPool; |
| 2795 | if (!strcmp(funcName, "vkAllocDescriptorSets")) |
| 2796 | return (void*) vkAllocDescriptorSets; |
| 2797 | if (!strcmp(funcName, "vkClearDescriptorSets")) |
| 2798 | return (void*) vkClearDescriptorSets; |
| 2799 | if (!strcmp(funcName, "vkUpdateDescriptors")) |
| 2800 | return (void*) vkUpdateDescriptors; |
| 2801 | if (!strcmp(funcName, "vkCreateDynamicViewportState")) |
| 2802 | return (void*) vkCreateDynamicViewportState; |
| 2803 | if (!strcmp(funcName, "vkCreateDynamicRasterState")) |
| 2804 | return (void*) vkCreateDynamicRasterState; |
| 2805 | if (!strcmp(funcName, "vkCreateDynamicColorBlendState")) |
| 2806 | return (void*) vkCreateDynamicColorBlendState; |
| 2807 | if (!strcmp(funcName, "vkCreateDynamicDepthStencilState")) |
| 2808 | return (void*) vkCreateDynamicDepthStencilState; |
| 2809 | if (!strcmp(funcName, "vkCreateCommandBuffer")) |
| 2810 | return (void*) vkCreateCommandBuffer; |
| 2811 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
| 2812 | return (void*) vkBeginCommandBuffer; |
| 2813 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
| 2814 | return (void*) vkEndCommandBuffer; |
| 2815 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
| 2816 | return (void*) vkResetCommandBuffer; |
| 2817 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
| 2818 | return (void*) vkCmdBindPipeline; |
| 2819 | if (!strcmp(funcName, "vkCmdBindDynamicStateObject")) |
| 2820 | return (void*) vkCmdBindDynamicStateObject; |
| 2821 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
| 2822 | return (void*) vkCmdBindDescriptorSets; |
Courtney Goeltzenleuchter | f68ad72 | 2015-04-16 13:38:46 -0600 | [diff] [blame] | 2823 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
| 2824 | return (void*) vkCmdBindVertexBuffers; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2825 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
| 2826 | return (void*) vkCmdBindIndexBuffer; |
| 2827 | if (!strcmp(funcName, "vkCmdDraw")) |
| 2828 | return (void*) vkCmdDraw; |
| 2829 | if (!strcmp(funcName, "vkCmdDrawIndexed")) |
| 2830 | return (void*) vkCmdDrawIndexed; |
| 2831 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
| 2832 | return (void*) vkCmdDrawIndirect; |
| 2833 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
| 2834 | return (void*) vkCmdDrawIndexedIndirect; |
| 2835 | if (!strcmp(funcName, "vkCmdDispatch")) |
| 2836 | return (void*) vkCmdDispatch; |
| 2837 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
| 2838 | return (void*) vkCmdDispatchIndirect; |
| 2839 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
| 2840 | return (void*) vkCmdCopyBuffer; |
| 2841 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 2842 | return (void*) vkCmdCopyImage; |
| 2843 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 2844 | return (void*) vkCmdCopyBufferToImage; |
| 2845 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 2846 | return (void*) vkCmdCopyImageToBuffer; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2847 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
| 2848 | return (void*) vkCmdUpdateBuffer; |
| 2849 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
| 2850 | return (void*) vkCmdFillBuffer; |
| 2851 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 2852 | return (void*) vkCmdClearColorImage; |
| 2853 | if (!strcmp(funcName, "vkCmdClearDepthStencil")) |
| 2854 | return (void*) vkCmdClearDepthStencil; |
| 2855 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 2856 | return (void*) vkCmdResolveImage; |
| 2857 | if (!strcmp(funcName, "vkCmdSetEvent")) |
| 2858 | return (void*) vkCmdSetEvent; |
| 2859 | if (!strcmp(funcName, "vkCmdResetEvent")) |
| 2860 | return (void*) vkCmdResetEvent; |
| 2861 | if (!strcmp(funcName, "vkCmdWaitEvents")) |
| 2862 | return (void*) vkCmdWaitEvents; |
| 2863 | if (!strcmp(funcName, "vkCmdPipelineBarrier")) |
| 2864 | return (void*) vkCmdPipelineBarrier; |
| 2865 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
| 2866 | return (void*) vkCmdBeginQuery; |
| 2867 | if (!strcmp(funcName, "vkCmdEndQuery")) |
| 2868 | return (void*) vkCmdEndQuery; |
| 2869 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
| 2870 | return (void*) vkCmdResetQueryPool; |
| 2871 | if (!strcmp(funcName, "vkCmdWriteTimestamp")) |
| 2872 | return (void*) vkCmdWriteTimestamp; |
| 2873 | if (!strcmp(funcName, "vkCmdInitAtomicCounters")) |
| 2874 | return (void*) vkCmdInitAtomicCounters; |
| 2875 | if (!strcmp(funcName, "vkCmdLoadAtomicCounters")) |
| 2876 | return (void*) vkCmdLoadAtomicCounters; |
| 2877 | if (!strcmp(funcName, "vkCmdSaveAtomicCounters")) |
| 2878 | return (void*) vkCmdSaveAtomicCounters; |
| 2879 | if (!strcmp(funcName, "vkCreateFramebuffer")) |
| 2880 | return (void*) vkCreateFramebuffer; |
| 2881 | if (!strcmp(funcName, "vkCreateRenderPass")) |
| 2882 | return (void*) vkCreateRenderPass; |
| 2883 | if (!strcmp(funcName, "vkCmdBeginRenderPass")) |
| 2884 | return (void*) vkCmdBeginRenderPass; |
| 2885 | if (!strcmp(funcName, "vkCmdEndRenderPass")) |
| 2886 | return (void*) vkCmdEndRenderPass; |
| 2887 | if (!strcmp(funcName, "vkDbgRegisterMsgCallback")) |
| 2888 | return (void*) vkDbgRegisterMsgCallback; |
| 2889 | if (!strcmp(funcName, "vkDbgUnregisterMsgCallback")) |
| 2890 | return (void*) vkDbgUnregisterMsgCallback; |
| 2891 | if (!strcmp(funcName, "vkCmdDbgMarkerBegin")) |
| 2892 | return (void*) vkCmdDbgMarkerBegin; |
| 2893 | if (!strcmp(funcName, "vkCmdDbgMarkerEnd")) |
| 2894 | return (void*) vkCmdDbgMarkerEnd; |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2895 | if (!strcmp("drawStateDumpDotFile", funcName)) |
| 2896 | return (void*) drawStateDumpDotFile; |
| 2897 | if (!strcmp("drawStateDumpCommandBufferDotFile", funcName)) |
| 2898 | return (void*) drawStateDumpCommandBufferDotFile; |
| 2899 | if (!strcmp("drawStateDumpPngFile", funcName)) |
| 2900 | return (void*) drawStateDumpPngFile; |
| 2901 | else { |
| 2902 | if (gpuw->pGPA == NULL) |
| 2903 | return NULL; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 2904 | return gpuw->pGPA((VkPhysicalDevice)gpuw->nextObject, funcName); |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2905 | } |
| 2906 | } |