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