Tobin Ehlis | 246ba4d | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Tobin Ehlis | 246ba4d | 2014-11-18 16:38:08 -0700 | [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 | */ |
Tobin Ehlis | 0c6f9ee | 2015-07-03 09:42:57 -0600 | [diff] [blame] | 24 | #include "vk_layer.h" |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 25 | #include <vector> |
Tobin Ehlis | 257d974 | 2015-07-08 17:08:02 -0600 | [diff] [blame] | 26 | #include "layer_common.h" |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 27 | |
| 28 | using namespace std; |
| 29 | |
Tobin Ehlis | 246ba4d | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 30 | // Draw State ERROR codes |
| 31 | typedef enum _DRAW_STATE_ERROR |
| 32 | { |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 33 | DRAWSTATE_NONE, // Used for INFO & other non-error messages |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 34 | DRAWSTATE_INTERNAL_ERROR, // Error with DrawState internal data structures |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 35 | DRAWSTATE_NO_PIPELINE_BOUND, // Unable to identify a bound pipeline |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 36 | DRAWSTATE_INVALID_POOL, // Invalid DS pool |
Tobin Ehlis | a3a693e | 2015-02-10 15:35:23 -0700 | [diff] [blame] | 37 | DRAWSTATE_INVALID_SET, // Invalid DS |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 38 | DRAWSTATE_INVALID_LAYOUT, // Invalid DS layout |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 39 | DRAWSTATE_INVALID_PIPELINE, // Invalid Pipeline handle referenced |
| 40 | DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, // Attempt to create a pipeline with invalid state |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 41 | DRAWSTATE_INVALID_CMD_BUFFER, // Invalid CmdBuffer referenced |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 42 | DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in vkCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 43 | DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, // Invalid dyn state object |
| 44 | DRAWSTATE_MISSING_DOT_PROGRAM, // No "dot" program in order to generate png image |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 45 | DRAWSTATE_OUT_OF_MEMORY, // malloc failed |
| 46 | DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, // Type in layout vs. update are not the same |
Tobin Ehlis | a3a693e | 2015-02-10 15:35:23 -0700 | [diff] [blame] | 47 | DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, // Descriptors set for update out of bounds for corresponding layout section |
Tobin Ehlis | 297b985 | 2015-02-23 16:09:58 -0700 | [diff] [blame] | 48 | DRAWSTATE_INVALID_UPDATE_INDEX, // Index of requested update is invalid for specified descriptors set |
Tobin Ehlis | eba312c | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 49 | DRAWSTATE_INVALID_UPDATE_STRUCT, // Struct in DS Update tree is of invalid type |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 50 | DRAWSTATE_NUM_SAMPLES_MISMATCH, // Number of samples in bound PSO does not match number in FB of current RenderPass |
| 51 | DRAWSTATE_NO_END_CMD_BUFFER, // Must call vkEndCommandBuffer() before QueueSubmit on that cmdBuffer |
Tobin Ehlis | 9c53644 | 2015-06-19 13:00:59 -0600 | [diff] [blame] | 52 | DRAWSTATE_NO_BEGIN_CMD_BUFFER, // Binding cmds or calling End on CB that never had vkBeginCommandBuffer() called on it |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 53 | DRAWSTATE_CMD_BUFFER_SINGLE_SUBMIT_VIOLATION, // Cmd Buffer created with VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT flag is submitted multiple times |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 54 | DRAWSTATE_VIEWPORT_NOT_BOUND, // Draw submitted with no viewport state object bound |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame^] | 55 | DRAWSTATE_RASTER_LINE_NOT_BOUND, // Draw submitted with no raster line state object bound |
| 56 | DRAWSTATE_RASTER_DEPTH_BIAS_NOT_BOUND, // Draw submitted with no raster depth bias state object bound |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 57 | DRAWSTATE_COLOR_BLEND_NOT_BOUND, // Draw submitted with no color blend state object bound when color write enabled |
| 58 | DRAWSTATE_DEPTH_STENCIL_NOT_BOUND, // Draw submitted with no depth-stencil state object bound when depth write enabled |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 59 | DRAWSTATE_INDEX_BUFFER_NOT_BOUND, // Draw submitted with no depth-stencil state object bound when depth write enabled |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 60 | DRAWSTATE_PIPELINE_LAYOUT_MISMATCH, // Draw submitted PSO Pipeline layout that doesn't match layout from BindDescriptorSets |
Tobin Ehlis | 259730a | 2015-06-23 16:13:03 -0600 | [diff] [blame] | 61 | DRAWSTATE_INVALID_RENDERPASS, // Use of a NULL or otherwise invalid RenderPass object |
Tobin Ehlis | d1fe4ec | 2015-06-23 11:22:55 -0600 | [diff] [blame] | 62 | DRAWSTATE_INVALID_RENDERPASS_CMD, // Invalid cmd submitted while a RenderPass is active |
| 63 | DRAWSTATE_NO_ACTIVE_RENDERPASS, // Rendering cmd submitted without an active RenderPass |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 64 | DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, // DescriptorSet bound but it was never updated. This is a warning code. |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 65 | DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, // Clear cmd issued before any Draw in CmdBuffer, should use RenderPass Ops instead |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 66 | DRAWSTATE_BEGIN_CB_INVALID_STATE, // Primary/Secondary CB created with mismatched FB/RP information |
Tobin Ehlis | 75283bf | 2015-06-18 15:59:33 -0600 | [diff] [blame] | 67 | DRAWSTATE_INVALID_EXTENSION, |
Tobin Ehlis | 246ba4d | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 68 | } DRAW_STATE_ERROR; |
Tobin Ehlis | 5742e77 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 69 | |
| 70 | typedef enum _DRAW_TYPE |
| 71 | { |
| 72 | DRAW = 0, |
| 73 | DRAW_INDEXED = 1, |
| 74 | DRAW_INDIRECT = 2, |
| 75 | DRAW_INDEXED_INDIRECT = 3, |
| 76 | DRAW_BEGIN_RANGE = DRAW, |
| 77 | DRAW_END_RANGE = DRAW_INDEXED_INDIRECT, |
| 78 | NUM_DRAW_TYPES = (DRAW_END_RANGE - DRAW_BEGIN_RANGE + 1), |
| 79 | } DRAW_TYPE; |
Tobin Ehlis | 8356288 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 80 | |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 81 | typedef struct _SHADER_DS_MAPPING { |
| 82 | uint32_t slotCount; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 83 | VkDescriptorSetLayoutCreateInfo* pShaderMappingSlot; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 84 | } SHADER_DS_MAPPING; |
| 85 | |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 86 | typedef struct _GENERIC_HEADER { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 87 | VkStructureType sType; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 88 | const void* pNext; |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 89 | } GENERIC_HEADER; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 90 | |
| 91 | typedef struct _PIPELINE_NODE { |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 92 | VkPipeline pipeline; |
| 93 | VkGraphicsPipelineCreateInfo graphicsPipelineCI; |
| 94 | VkPipelineVertexInputStateCreateInfo vertexInputCI; |
| 95 | VkPipelineInputAssemblyStateCreateInfo iaStateCI; |
| 96 | VkPipelineTessellationStateCreateInfo tessStateCI; |
| 97 | VkPipelineViewportStateCreateInfo vpStateCI; |
| 98 | VkPipelineRasterStateCreateInfo rsStateCI; |
| 99 | VkPipelineMultisampleStateCreateInfo msStateCI; |
| 100 | VkPipelineColorBlendStateCreateInfo cbStateCI; |
| 101 | VkPipelineDepthStencilStateCreateInfo dsStateCI; |
| 102 | VkPipelineShaderStageCreateInfo vsCI; |
| 103 | VkPipelineShaderStageCreateInfo tcsCI; |
| 104 | VkPipelineShaderStageCreateInfo tesCI; |
| 105 | VkPipelineShaderStageCreateInfo gsCI; |
| 106 | VkPipelineShaderStageCreateInfo fsCI; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 107 | // Compute shader is include in VkComputePipelineCreateInfo |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 108 | VkComputePipelineCreateInfo computePipelineCI; |
Tobin Ehlis | a85167d | 2015-06-18 11:02:59 -0600 | [diff] [blame] | 109 | // Flag of which shader stages are active for this pipeline |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 110 | uint32_t active_shaders; |
| 111 | VkGraphicsPipelineCreateInfo* pCreateTree; // Ptr to shadow of data in create tree |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 112 | // Vtx input info (if any) |
Mark Lobodzinski | d5732f3 | 2015-06-23 15:11:57 -0600 | [diff] [blame] | 113 | uint32_t vtxBindingCount; // number of bindings |
| 114 | VkVertexInputBindingDescription* pVertexBindingDescriptions; |
| 115 | uint32_t vtxAttributeCount; // number of attributes |
| 116 | VkVertexInputAttributeDescription* pVertexAttributeDescriptions; |
| 117 | uint32_t attachmentCount; // number of CB attachments |
Tony Barbour | dd6e32e | 2015-07-10 15:29:03 -0600 | [diff] [blame] | 118 | VkPipelineColorBlendAttachmentState* pAttachments; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 119 | } PIPELINE_NODE; |
| 120 | |
| 121 | typedef struct _SAMPLER_NODE { |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 122 | VkSampler sampler; |
| 123 | VkSamplerCreateInfo createInfo; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 124 | } SAMPLER_NODE; |
| 125 | |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 126 | typedef struct _BUFFER_NODE { |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 127 | VkBufferView buffer; |
Courtney Goeltzenleuchter | 95487bc | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 128 | VkBufferViewCreateInfo createInfo; |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 129 | VkDescriptorInfo descriptorInfo; |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 130 | } BUFFER_NODE; |
| 131 | |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 132 | // Descriptor Data structures |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 133 | // Layout Node has the core layout data |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 134 | typedef struct _LAYOUT_NODE { |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 135 | VkDescriptorSetLayout layout; |
| 136 | VkDescriptorType* pTypes; // Dynamic array that will be created to verify descriptor types |
| 137 | VkDescriptorSetLayoutCreateInfo createInfo; |
| 138 | uint32_t startIndex; // 1st index of this layout |
| 139 | uint32_t endIndex; // last index of this layout |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 140 | } LAYOUT_NODE; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 141 | typedef struct _SET_NODE { |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 142 | VkDescriptorSet set; |
| 143 | VkDescriptorPool pool; |
| 144 | VkDescriptorSetUsage setUsage; |
Tobin Ehlis | 481ec71 | 2015-02-19 09:55:18 -0700 | [diff] [blame] | 145 | // Head of LL of all Update structs for this set |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 146 | GENERIC_HEADER* pUpdateStructs; |
Tobin Ehlis | 04178d7 | 2015-01-22 10:45:21 -0700 | [diff] [blame] | 147 | // Total num of descriptors in this set (count of its layout plus all prior layouts) |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 148 | uint32_t descriptorCount; |
| 149 | GENERIC_HEADER** ppDescriptors; // Array where each index points to update node for its slot |
| 150 | LAYOUT_NODE* pLayout; // Layout for this set |
| 151 | struct _SET_NODE* pNext; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 152 | } SET_NODE; |
| 153 | |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 154 | typedef struct _POOL_NODE { |
Tobin Ehlis | ce132d8 | 2015-06-19 15:07:05 -0600 | [diff] [blame] | 155 | VkDescriptorPool pool; |
| 156 | VkDescriptorPoolUsage poolUsage; |
| 157 | uint32_t maxSets; |
| 158 | VkDescriptorPoolCreateInfo createInfo; |
| 159 | SET_NODE* pSets; // Head of LL of sets for this Pool |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 160 | } POOL_NODE; |
Tobin Ehlis | 7265e83 | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 161 | |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 162 | // Cmd Buffer Tracking |
| 163 | typedef enum _CMD_TYPE |
| 164 | { |
| 165 | CMD_BINDPIPELINE, |
| 166 | CMD_BINDPIPELINEDELTA, |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 167 | CMD_BINDDYNAMICVIEWPORTSTATE, |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame^] | 168 | CMD_BINDDYNAMICRASTERLINESTATE, |
| 169 | CMD_BINDDYNAMICRASTERDEPTHBIASSTATE, |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 170 | CMD_BINDDYNAMICCOLORBLENDSTATE, |
| 171 | CMD_BINDDYNAMICDEPTHSTENCILSTATE, |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 172 | CMD_BINDDESCRIPTORSETS, |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 173 | CMD_BINDINDEXBUFFER, |
| 174 | CMD_BINDVERTEXBUFFER, |
| 175 | CMD_DRAW, |
| 176 | CMD_DRAWINDEXED, |
| 177 | CMD_DRAWINDIRECT, |
| 178 | CMD_DRAWINDEXEDINDIRECT, |
| 179 | CMD_DISPATCH, |
| 180 | CMD_DISPATCHINDIRECT, |
| 181 | CMD_COPYBUFFER, |
| 182 | CMD_COPYIMAGE, |
Tobin Ehlis | 793ad30 | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 183 | CMD_BLITIMAGE, |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 184 | CMD_COPYBUFFERTOIMAGE, |
| 185 | CMD_COPYIMAGETOBUFFER, |
| 186 | CMD_CLONEIMAGEDATA, |
| 187 | CMD_UPDATEBUFFER, |
| 188 | CMD_FILLBUFFER, |
| 189 | CMD_CLEARCOLORIMAGE, |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 190 | CMD_CLEARCOLORATTACHMENT, |
| 191 | CMD_CLEARDEPTHSTENCILIMAGE, |
| 192 | CMD_CLEARDEPTHSTENCILATTACHMENT, |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 193 | CMD_RESOLVEIMAGE, |
| 194 | CMD_SETEVENT, |
| 195 | CMD_RESETEVENT, |
| 196 | CMD_WAITEVENTS, |
| 197 | CMD_PIPELINEBARRIER, |
| 198 | CMD_BEGINQUERY, |
| 199 | CMD_ENDQUERY, |
| 200 | CMD_RESETQUERYPOOL, |
| 201 | CMD_WRITETIMESTAMP, |
| 202 | CMD_INITATOMICCOUNTERS, |
| 203 | CMD_LOADATOMICCOUNTERS, |
| 204 | CMD_SAVEATOMICCOUNTERS, |
| 205 | CMD_BEGINRENDERPASS, |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 206 | CMD_NEXTSUBPASS, |
Tobin Ehlis | 6744942 | 2015-03-02 10:16:40 -0700 | [diff] [blame] | 207 | CMD_ENDRENDERPASS, |
Chia-I Wu | 0b50a1c | 2015-06-26 15:34:39 +0800 | [diff] [blame] | 208 | CMD_EXECUTECOMMANDS, |
Tobin Ehlis | 6744942 | 2015-03-02 10:16:40 -0700 | [diff] [blame] | 209 | CMD_DBGMARKERBEGIN, |
| 210 | CMD_DBGMARKEREND, |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 211 | } CMD_TYPE; |
| 212 | // Data structure for holding sequence of cmds in cmd buffer |
| 213 | typedef struct _CMD_NODE { |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 214 | CMD_TYPE type; |
| 215 | uint64_t cmdNumber; |
| 216 | } CMD_NODE; |
| 217 | |
| 218 | typedef enum _CB_STATE |
| 219 | { |
| 220 | CB_NEW, // Newly created CB w/o any cmds |
| 221 | CB_UPDATE_ACTIVE, // BeginCB has been called on this CB |
| 222 | CB_UPDATE_COMPLETE // EndCB has been called on this CB |
| 223 | } CB_STATE; |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 224 | // CB Status -- used to track status of various bindings on cmd buffer objects |
| 225 | typedef VkFlags CBStatusFlags; |
| 226 | typedef enum _CBStatusFlagBits |
| 227 | { |
| 228 | CBSTATUS_NONE = 0x00000000, // No status is set |
| 229 | CBSTATUS_VIEWPORT_BOUND = 0x00000001, // Viewport state object has been bound |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame^] | 230 | CBSTATUS_RASTER_LINE_BOUND = 0x00000002, // Raster state object has been bound |
| 231 | CBSTATUS_RASTER_DEPTH_BIAS_BOUND = 0x00000004, // Raster state object has been bound |
| 232 | CBSTATUS_COLOR_BLEND_WRITE_ENABLE = 0x00000008, // PSO w/ CB Enable set has been bound |
| 233 | CBSTATUS_COLOR_BLEND_BOUND = 0x00000010, // CB state object has been bound |
| 234 | CBSTATUS_DEPTH_STENCIL_WRITE_ENABLE = 0x00000020, // PSO w/ DS Enable set has been bound |
| 235 | CBSTATUS_DEPTH_STENCIL_BOUND = 0x00000040, // DS state object has been bound |
| 236 | CBSTATUS_INDEX_BUFFER_BOUND = 0x00000080, // Index buffer has been bound |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 237 | } CBStatusFlagBits; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 238 | |
Tobin Ehlis | 10ae8c1 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 239 | // Cmd Buffer Wrapper Struct |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 240 | typedef struct _GLOBAL_CB_NODE { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 241 | VkCmdBuffer cmdBuffer; |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 242 | VkCmdBufferCreateInfo createInfo; |
| 243 | VkCmdBufferBeginInfo beginInfo; |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 244 | VkFence fence; // fence tracking this cmd buffer |
| 245 | uint64_t numCmds; // number of cmds in this CB |
| 246 | uint64_t drawCount[NUM_DRAW_TYPES]; // Count of each type of draw in this CB |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 247 | CB_STATE state; // Track cmd buffer update state |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 248 | uint64_t submitCount; // Number of times CB has been submitted |
Tobin Ehlis | e382c5a | 2015-06-10 12:57:07 -0600 | [diff] [blame] | 249 | CBStatusFlags status; // Track status of various bindings on cmd buffer |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 250 | vector<CMD_NODE*> pCmds; |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 251 | // Currently storing "lastBound" objects on per-CB basis |
| 252 | // long-term may want to create caches of "lastBound" states and could have |
| 253 | // each individual CMD_NODE referencing its own "lastBound" state |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 254 | VkPipeline lastBoundPipeline; |
| 255 | uint32_t lastVtxBinding; |
Tobin Ehlis | 60a9b4f | 2015-07-07 10:42:20 -0600 | [diff] [blame] | 256 | uint64_t lastBoundDynamicState[VK_NUM_STATE_BIND_POINT]; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 257 | VkDescriptorSet lastBoundDescriptorSet; |
Tobin Ehlis | 429b91d | 2015-06-22 17:20:50 -0600 | [diff] [blame] | 258 | VkPipelineLayout lastBoundPipelineLayout; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 259 | VkRenderPass activeRenderPass; |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 260 | uint32_t activeSubpass; |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 261 | VkFramebuffer framebuffer; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 262 | VkCmdBufferLevel level; |
Tobin Ehlis | a9f3d76 | 2015-05-22 12:38:16 -0600 | [diff] [blame] | 263 | vector<VkDescriptorSet> boundDescriptorSets; |
Tobin Ehlis | d01f7d6 | 2015-02-13 10:26:14 -0700 | [diff] [blame] | 264 | } GLOBAL_CB_NODE; |