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