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