Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * GLAVE & vulkan |
| 3 | * |
| 4 | * Copyright (C) 2015 LunarG, Inc. and Valve Corporation |
| 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 | |
Courtney Goeltzenleuchter | f53c3cb | 2015-04-14 14:55:44 -0600 | [diff] [blame] | 25 | #include "vkLayer.h" |
Peter Lohrmann | 0582ed3 | 2015-03-24 17:15:03 -0700 | [diff] [blame] | 26 | |
| 27 | // Glave Snapshot ERROR codes |
| 28 | typedef enum _GLAVE_SNAPSHOT_ERROR |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 29 | { |
Peter Lohrmann | 0582ed3 | 2015-03-24 17:15:03 -0700 | [diff] [blame] | 30 | GLVSNAPSHOT_NONE, // Used for INFO & other non-error messages |
| 31 | GLVSNAPSHOT_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list |
| 32 | GLVSNAPSHOT_INTERNAL_ERROR, // Bug with data tracking within the layer |
| 33 | GLVSNAPSHOT_DESTROY_OBJECT_FAILED, // Couldn't find object to be destroyed |
| 34 | GLVSNAPSHOT_MISSING_OBJECT, // Attempted look-up on object that isn't in global object list |
| 35 | GLVSNAPSHOT_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed |
| 36 | GLVSNAPSHOT_OBJCOUNT_MAX_EXCEEDED, // Request for Object data in excess of max obj count |
| 37 | GLVSNAPSHOT_INVALID_FENCE, // Requested status of unsubmitted fence object |
| 38 | GLVSNAPSHOT_VIEWPORT_NOT_BOUND, // Draw submitted with no viewport state object bound |
| 39 | GLVSNAPSHOT_RASTER_NOT_BOUND, // Draw submitted with no raster state object bound |
| 40 | GLVSNAPSHOT_COLOR_BLEND_NOT_BOUND, // Draw submitted with no color blend state object bound |
| 41 | GLVSNAPSHOT_DEPTH_STENCIL_NOT_BOUND, // Draw submitted with no depth-stencil state object bound |
| 42 | GLVSNAPSHOT_GPU_MEM_MAPPED, // Mem object ref'd in cmd buff is still mapped |
| 43 | GLVSNAPSHOT_GETGPUINFO_NOT_CALLED, // Gpu Information has not been requested before drawing |
| 44 | GLVSNAPSHOT_MEMREFCOUNT_MAX_EXCEEDED, // Number of QueueSubmit memory references exceeds GPU maximum |
Peter Lohrmann | 1ea1271 | 2015-03-25 10:35:03 -0700 | [diff] [blame] | 45 | GLVSNAPSHOT_SNAPSHOT_DATA, // Message being printed is actually snapshot data |
Peter Lohrmann | 0582ed3 | 2015-03-24 17:15:03 -0700 | [diff] [blame] | 46 | } GLAVE_SNAPSHOT_ERROR; |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 47 | |
| 48 | // Object Status -- used to track state of individual objects |
| 49 | typedef enum _OBJECT_STATUS |
| 50 | { |
| 51 | OBJSTATUS_NONE = 0x00000000, // No status is set |
| 52 | OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted |
| 53 | OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound |
| 54 | OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound |
| 55 | OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound |
| 56 | OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound |
| 57 | OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped |
| 58 | } OBJECT_STATUS; |
Peter Lohrmann | 0582ed3 | 2015-03-24 17:15:03 -0700 | [diff] [blame] | 59 | |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 60 | // Object type enum |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 61 | typedef enum _VK_OBJECT_TYPE |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 62 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 63 | VK_OBJECT_TYPE_UNKNOWN, |
| 64 | VK_OBJECT_TYPE_SAMPLER, |
| 65 | VK_OBJECT_TYPE_DYNAMIC_DS_STATE_OBJECT, |
| 66 | VK_OBJECT_TYPE_DESCRIPTOR_SET, |
| 67 | VK_OBJECT_TYPE_DESCRIPTOR_POOL, |
| 68 | VK_OBJECT_TYPE_DYNAMIC_CB_STATE_OBJECT, |
| 69 | VK_OBJECT_TYPE_IMAGE_VIEW, |
| 70 | VK_OBJECT_TYPE_QUEUE_SEMAPHORE, |
| 71 | VK_OBJECT_TYPE_SHADER, |
| 72 | VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, |
| 73 | VK_OBJECT_TYPE_BUFFER, |
| 74 | VK_OBJECT_TYPE_PIPELINE, |
| 75 | VK_OBJECT_TYPE_DEVICE, |
| 76 | VK_OBJECT_TYPE_QUERY_POOL, |
| 77 | VK_OBJECT_TYPE_EVENT, |
| 78 | VK_OBJECT_TYPE_QUEUE, |
| 79 | VK_OBJECT_TYPE_PHYSICAL_GPU, |
| 80 | VK_OBJECT_TYPE_RENDER_PASS, |
| 81 | VK_OBJECT_TYPE_FRAMEBUFFER, |
| 82 | VK_OBJECT_TYPE_IMAGE, |
| 83 | VK_OBJECT_TYPE_BUFFER_VIEW, |
| 84 | VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW, |
| 85 | VK_OBJECT_TYPE_INSTANCE, |
| 86 | VK_OBJECT_TYPE_PIPELINE_DELTA, |
| 87 | VK_OBJECT_TYPE_DYNAMIC_VP_STATE_OBJECT, |
| 88 | VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW, |
| 89 | VK_OBJECT_TYPE_GPU_MEMORY, |
| 90 | VK_OBJECT_TYPE_DYNAMIC_RS_STATE_OBJECT, |
| 91 | VK_OBJECT_TYPE_FENCE, |
| 92 | VK_OBJECT_TYPE_CMD_BUFFER, |
| 93 | VK_OBJECT_TYPE_PRESENTABLE_IMAGE_MEMORY, |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 94 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 95 | VK_NUM_OBJECT_TYPE, |
| 96 | VK_OBJECT_TYPE_ANY, // Allow global object list to be queried/retrieved |
| 97 | } VK_OBJECT_TYPE; |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 98 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 99 | static const char* string_VK_OBJECT_TYPE(VK_OBJECT_TYPE type) { |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 100 | switch (type) |
| 101 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 102 | case VK_OBJECT_TYPE_DEVICE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 103 | return "DEVICE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 104 | case VK_OBJECT_TYPE_PIPELINE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 105 | return "PIPELINE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 106 | case VK_OBJECT_TYPE_FENCE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 107 | return "FENCE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 108 | case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 109 | return "DESCRIPTOR_SET_LAYOUT"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 110 | case VK_OBJECT_TYPE_GPU_MEMORY: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 111 | return "GPU_MEMORY"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 112 | case VK_OBJECT_TYPE_QUEUE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 113 | return "QUEUE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 114 | case VK_OBJECT_TYPE_IMAGE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 115 | return "IMAGE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 116 | case VK_OBJECT_TYPE_CMD_BUFFER: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 117 | return "CMD_BUFFER"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 118 | case VK_OBJECT_TYPE_QUEUE_SEMAPHORE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 119 | return "QUEUE_SEMAPHORE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 120 | case VK_OBJECT_TYPE_FRAMEBUFFER: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 121 | return "FRAMEBUFFER"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 122 | case VK_OBJECT_TYPE_SAMPLER: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 123 | return "SAMPLER"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 124 | case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 125 | return "COLOR_ATTACHMENT_VIEW"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 126 | case VK_OBJECT_TYPE_BUFFER_VIEW: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 127 | return "BUFFER_VIEW"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 128 | case VK_OBJECT_TYPE_DESCRIPTOR_SET: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 129 | return "DESCRIPTOR_SET"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 130 | case VK_OBJECT_TYPE_PHYSICAL_GPU: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 131 | return "PHYSICAL_GPU"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 132 | case VK_OBJECT_TYPE_IMAGE_VIEW: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 133 | return "IMAGE_VIEW"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 134 | case VK_OBJECT_TYPE_BUFFER: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 135 | return "BUFFER"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 136 | case VK_OBJECT_TYPE_PIPELINE_DELTA: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 137 | return "PIPELINE_DELTA"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 138 | case VK_OBJECT_TYPE_DYNAMIC_RS_STATE_OBJECT: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 139 | return "DYNAMIC_RS_STATE_OBJECT"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 140 | case VK_OBJECT_TYPE_EVENT: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 141 | return "EVENT"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 142 | case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 143 | return "DEPTH_STENCIL_VIEW"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 144 | case VK_OBJECT_TYPE_SHADER: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 145 | return "SHADER"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 146 | case VK_OBJECT_TYPE_DYNAMIC_DS_STATE_OBJECT: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 147 | return "DYNAMIC_DS_STATE_OBJECT"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 148 | case VK_OBJECT_TYPE_DYNAMIC_VP_STATE_OBJECT: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 149 | return "DYNAMIC_VP_STATE_OBJECT"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 150 | case VK_OBJECT_TYPE_DYNAMIC_CB_STATE_OBJECT: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 151 | return "DYNAMIC_CB_STATE_OBJECT"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 152 | case VK_OBJECT_TYPE_INSTANCE: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 153 | return "INSTANCE"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 154 | case VK_OBJECT_TYPE_RENDER_PASS: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 155 | return "RENDER_PASS"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 156 | case VK_OBJECT_TYPE_QUERY_POOL: |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 157 | return "QUERY_POOL"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 158 | case VK_OBJECT_TYPE_DESCRIPTOR_POOL: |
Jon Ashburn | 2112d6b | 2015-04-01 13:30:06 -0600 | [diff] [blame] | 159 | return "DESCRIPTOR_POOL"; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 160 | case VK_OBJECT_TYPE_PRESENTABLE_IMAGE_MEMORY: |
Peter Lohrmann | b6b4ce2 | 2015-03-24 16:31:39 -0700 | [diff] [blame] | 161 | return "PRESENTABLE_IMAGE_MEMORY"; |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 162 | default: |
| 163 | return "UNKNOWN"; |
| 164 | } |
| 165 | } |
| 166 | |
Peter Lohrmann | 6d84923 | 2015-04-01 13:54:18 -0700 | [diff] [blame] | 167 | //============================================================================= |
| 168 | // Helper structure for a GLAVE vulkan snapshot. |
| 169 | // These can probably be auto-generated at some point. |
| 170 | //============================================================================= |
| 171 | |
| 172 | void glv_vk_malloc_and_copy(void** ppDest, size_t size, const void* pSrc); |
| 173 | |
| 174 | typedef struct _GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS |
| 175 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 176 | VkPhysicalGpu gpu; |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 177 | VkDeviceCreateInfo* pCreateInfo; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 178 | VkDevice* pDevice; |
Peter Lohrmann | 6d84923 | 2015-04-01 13:54:18 -0700 | [diff] [blame] | 179 | } GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS; |
| 180 | |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 181 | VkDeviceCreateInfo* glv_deepcopy_xgl_device_create_info(const VkDeviceCreateInfo* pSrcCreateInfo);void glv_deepfree_xgl_device_create_info(VkDeviceCreateInfo* pCreateInfo); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 182 | void glv_vk_snapshot_copy_createdevice_params(GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS* pDest, VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice); |
Peter Lohrmann | 6d84923 | 2015-04-01 13:54:18 -0700 | [diff] [blame] | 183 | void glv_vk_snapshot_destroy_createdevice_params(GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS* pSrc); |
| 184 | |
| 185 | //============================================================================= |
| 186 | // Glave Snapshot helper structs |
| 187 | //============================================================================= |
| 188 | |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 189 | // Node that stores information about an object |
| 190 | typedef struct _GLV_VK_SNAPSHOT_OBJECT_NODE { |
Peter Lohrmann | 0506950 | 2015-03-30 12:58:50 -0700 | [diff] [blame] | 191 | void* pVkObject; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 192 | VK_OBJECT_TYPE objType; |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 193 | uint64_t numUses; |
| 194 | OBJECT_STATUS status; |
Peter Lohrmann | 0506950 | 2015-03-30 12:58:50 -0700 | [diff] [blame] | 195 | void* pStruct; //< optionally points to a device-specific struct (ie, GLV_VK_SNAPSHOT_DEVICE_NODE) |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 196 | } GLV_VK_SNAPSHOT_OBJECT_NODE; |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 197 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 198 | // Node that stores information about an VkDevice |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 199 | typedef struct _GLV_VK_SNAPSHOT_DEVICE_NODE { |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 200 | // This object |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 201 | VkDevice device; |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 202 | |
| 203 | // CreateDevice parameters |
Peter Lohrmann | 6d84923 | 2015-04-01 13:54:18 -0700 | [diff] [blame] | 204 | GLV_VK_SNAPSHOT_CREATEDEVICE_PARAMS params; |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 205 | |
| 206 | // Other information a device needs to store. |
| 207 | // TODO: anything? |
| 208 | } GLV_VK_SNAPSHOT_DEVICE_NODE; |
| 209 | |
| 210 | // Linked-List node that stores information about an object |
| 211 | // We maintain a "Global" list which links every object and a |
| 212 | // per-Object list which just links objects of a given type |
| 213 | // The object node has both pointers so the actual nodes are shared between the two lists |
| 214 | typedef struct _GLV_VK_SNAPSHOT_LL_NODE { |
| 215 | struct _GLV_VK_SNAPSHOT_LL_NODE *pNextObj; |
| 216 | struct _GLV_VK_SNAPSHOT_LL_NODE *pNextGlobal; |
| 217 | GLV_VK_SNAPSHOT_OBJECT_NODE obj; |
| 218 | } GLV_VK_SNAPSHOT_LL_NODE; |
| 219 | |
Peter Lohrmann | 0506950 | 2015-03-30 12:58:50 -0700 | [diff] [blame] | 220 | // Linked-List node to identify an object that has been deleted, |
| 221 | // but the delta snapshot never saw it get created. |
| 222 | typedef struct _GLV_VK_SNAPSHOT_DELETED_OBJ_NODE { |
| 223 | struct _GLV_VK_SNAPSHOT_DELETED_OBJ_NODE* pNextObj; |
| 224 | void* pVkObject; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 225 | VK_OBJECT_TYPE objType; |
Peter Lohrmann | 0506950 | 2015-03-30 12:58:50 -0700 | [diff] [blame] | 226 | } GLV_VK_SNAPSHOT_DELETED_OBJ_NODE; |
| 227 | |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 228 | //============================================================================= |
| 229 | // Main structure for a GLAVE vulkan snapshot. |
| 230 | //============================================================================= |
| 231 | typedef struct _GLV_VK_SNAPSHOT { |
| 232 | // Stores a list of all the objects known by this snapshot. |
| 233 | // This may be used as a shortcut to more easily find objects. |
| 234 | uint64_t globalObjCount; |
| 235 | GLV_VK_SNAPSHOT_LL_NODE* pGlobalObjs; |
| 236 | |
| 237 | // TEMPORARY: Keep track of all objects of each type |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 238 | uint64_t numObjs[VK_NUM_OBJECT_TYPE]; |
| 239 | GLV_VK_SNAPSHOT_LL_NODE *pObjectHead[VK_NUM_OBJECT_TYPE]; |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 240 | |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 241 | // List of created devices and [potentially] hierarchical tree of the objects on it. |
| 242 | // This is used to represent ownership of the objects |
| 243 | uint64_t deviceCount; |
Peter Lohrmann | 0506950 | 2015-03-30 12:58:50 -0700 | [diff] [blame] | 244 | GLV_VK_SNAPSHOT_LL_NODE* pDevices; |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 245 | |
| 246 | // This is used to support snapshot deltas. |
| 247 | uint64_t deltaDeletedObjectCount; |
Peter Lohrmann | 0506950 | 2015-03-30 12:58:50 -0700 | [diff] [blame] | 248 | GLV_VK_SNAPSHOT_DELETED_OBJ_NODE* pDeltaDeletedObjects; |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 249 | } GLV_VK_SNAPSHOT; |
| 250 | |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 251 | //============================================================================= |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 252 | // prototype for extension functions |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 253 | //============================================================================= |
| 254 | // The snapshot functionality should work similar to a stopwatch. |
| 255 | // 1) 'StartTracking()' is like starting the stopwatch. This causes the snapshot |
| 256 | // to start tracking the creation of objects and state. In general, this |
| 257 | // should happen at the very beginning, to track all objects. During this |
| 258 | // tracking time, all creations and deletions are tracked on the |
| 259 | // 'deltaSnapshot'. |
| 260 | // NOTE: This entrypoint currently does nothing, as tracking is implied |
| 261 | // by enabling the layer. |
| 262 | // 2) 'GetDelta()' is analogous to looking at the stopwatch and seeing the |
| 263 | // current lap time - A copy of the 'deltaSnapshot' will be returned to the |
| 264 | // caller, but nothings changes within the snapshot layer. All creations |
| 265 | // and deletions continue to be applied to the 'deltaSnapshot'. |
| 266 | // NOTE: This will involve a deep copy of the delta, so there may be a |
| 267 | // performance hit. |
| 268 | // 3) 'GetSnapshot()' is similar to hitting the 'Lap' button on a stopwatch. |
| 269 | // The 'deltaSnapshot' is merged into the 'masterSnapshot', the 'deltaSnapshot' |
| 270 | // is cleared, and the 'masterSnapshot' is returned. All creations and |
| 271 | // deletions continue to be applied to the 'deltaSnapshot'. |
| 272 | // NOTE: This will involve a deep copy of the snapshot, so there may be a |
| 273 | // performance hit. |
| 274 | // 4) 'PrintDelta()' will cause the delta to be output by the layer's msgCallback. |
| 275 | // 5) Steps 2, 3, and 4 can happen as often as needed. |
| 276 | // 6) 'StopTracking()' is like stopping the stopwatch. |
| 277 | // NOTE: This entrypoint currently does nothing, as tracking is implied |
| 278 | // by disabling the layer. |
| 279 | // 7) 'Clear()' will clear the 'deltaSnapshot' and the 'masterSnapshot'. |
| 280 | //============================================================================= |
| 281 | |
| 282 | void glvSnapshotStartTracking(void); |
| 283 | GLV_VK_SNAPSHOT glvSnapshotGetDelta(void); |
| 284 | GLV_VK_SNAPSHOT glvSnapshotGetSnapshot(void); |
| 285 | void glvSnapshotPrintDelta(void); |
| 286 | void glvSnapshotStopTracking(void); |
| 287 | void glvSnapshotClear(void); |
| 288 | |
| 289 | // utility |
| 290 | // merge a delta into a snapshot and return the updated snapshot |
| 291 | GLV_VK_SNAPSHOT glvSnapshotMerge(const GLV_VK_SNAPSHOT * const pDelta, const GLV_VK_SNAPSHOT * const pSnapshot); |
| 292 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 293 | uint64_t glvSnapshotGetObjectCount(VK_OBJECT_TYPE type); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 294 | VkResult glvSnapshotGetObjects(VK_OBJECT_TYPE type, uint64_t objCount, GLV_VK_SNAPSHOT_OBJECT_NODE* pObjNodeArray); |
Peter Lohrmann | 0582ed3 | 2015-03-24 17:15:03 -0700 | [diff] [blame] | 295 | void glvSnapshotPrintObjects(void); |
Peter Lohrmann | d67314b | 2015-03-24 16:14:01 -0700 | [diff] [blame] | 296 | |
| 297 | // Func ptr typedefs |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 298 | typedef uint64_t (*GLVSNAPSHOT_GET_OBJECT_COUNT)(VK_OBJECT_TYPE); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 299 | typedef VkResult (*GLVSNAPSHOT_GET_OBJECTS)(VK_OBJECT_TYPE, uint64_t, GLV_VK_SNAPSHOT_OBJECT_NODE*); |
Peter Lohrmann | 0582ed3 | 2015-03-24 17:15:03 -0700 | [diff] [blame] | 300 | typedef void (*GLVSNAPSHOT_PRINT_OBJECTS)(void); |
Peter Lohrmann | 623be4e | 2015-03-26 20:38:12 -0700 | [diff] [blame] | 301 | typedef void (*GLVSNAPSHOT_START_TRACKING)(void); |
| 302 | typedef GLV_VK_SNAPSHOT (*GLVSNAPSHOT_GET_DELTA)(void); |
| 303 | typedef GLV_VK_SNAPSHOT (*GLVSNAPSHOT_GET_SNAPSHOT)(void); |
| 304 | typedef void (*GLVSNAPSHOT_PRINT_DELTA)(void); |
| 305 | typedef void (*GLVSNAPSHOT_STOP_TRACKING)(void); |
| 306 | typedef void (*GLVSNAPSHOT_CLEAR)(void); |