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