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