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