Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * XGL |
| 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 | #include "xglLayer.h" |
| 25 | // Draw State ERROR codes |
| 26 | typedef enum _DRAW_STATE_ERROR |
| 27 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 28 | DRAWSTATE_NONE, // Used for INFO & other non-error messages |
| 29 | DRAWSTATE_INTERNAL_ERROR, // Error with DrawState internal data structures |
| 30 | DRAWSTATE_DESCRIPTOR_MAX_EXCEEDED, // Descriptor Count of DS Mapping exceeds MAX_SLOTS |
| 31 | DRAWSTATE_SLOT_REMAPPING, // DS Slot being mapped to a different type than previously |
| 32 | DRAWSTATE_NO_PIPELINE_BOUND, // Unable to identify a bound pipeline |
| 33 | DRAWSTATE_NO_DS_BOUND, // Unable to identify a bound DS |
| 34 | DRAWSTATE_DS_SLOT_NUM_MISMATCH, // Number of slots in DS mapping exceeds actual DS slots |
| 35 | DRAWSTATE_UNKNOWN_DS_MAPPING, // Shader slot mapping is not recognized |
| 36 | DRAWSTATE_DS_MAPPING_MISMATCH, // DS Mapping mismatch |
| 37 | DRAWSTATE_INVALID_DS, // Invalid DS referenced |
| 38 | DRAWSTATE_DS_END_WITHOUT_BEGIN, // EndDSUpdate called w/o corresponding BeginDSUpdate |
| 39 | DRAWSTATE_UPDATE_WITHOUT_BEGIN, // Attempt to update descriptors w/o calling BeginDescriptorRegionUpdate |
| 40 | DRAWSTATE_DS_SAMPLE_ATTACH_FAILED, // Error while attempting to Attach Sampler mapping to DS Slot |
| 41 | DRAWSTATE_DS_IMAGE_ATTACH_FAILED, // Error while attempting to Attach Image mapping to DS Slot |
| 42 | DRAWSTATE_DS_MEMORY_ATTACH_FAILED, // Error while attempting to Attach Mem mapping to DS Slot |
| 43 | DRAWSTATE_DS_NESTED_DS_ATTACH_FAILED, // Error while attempting to Attach Nested DS mapping to DS Slot |
| 44 | DRAWSTATE_CLEAR_DS_FAILED, // Error while attempting ClearDS |
| 45 | DRAWSTATE_INVALID_PIPELINE, // Invalid DS referenced |
| 46 | DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in xglCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array |
| 47 | DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, // Invalid dyn state object |
| 48 | DRAWSTATE_MISSING_DOT_PROGRAM, // No "dot" program in order to generate png image |
| 49 | DRAWSTATE_BINDING_DS_NO_END_UPDATE, // DS bound to CmdBuffer w/o call to xglEndDescriptorSetUpdate()) |
| 50 | DRAWSTATE_NO_DS_REGION, // No DS Region is available |
| 51 | DRAWSTATE_OUT_OF_MEMORY // malloc failed |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 52 | } DRAW_STATE_ERROR; |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 53 | |
| 54 | typedef enum _DRAW_TYPE |
| 55 | { |
| 56 | DRAW = 0, |
| 57 | DRAW_INDEXED = 1, |
| 58 | DRAW_INDIRECT = 2, |
| 59 | DRAW_INDEXED_INDIRECT = 3, |
| 60 | DRAW_BEGIN_RANGE = DRAW, |
| 61 | DRAW_END_RANGE = DRAW_INDEXED_INDIRECT, |
| 62 | NUM_DRAW_TYPES = (DRAW_END_RANGE - DRAW_BEGIN_RANGE + 1), |
| 63 | } DRAW_TYPE; |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 64 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame] | 65 | typedef struct _SHADER_DS_MAPPING { |
| 66 | uint32_t slotCount; |
| 67 | // TODO : Need to understand this with new binding model, changed to LAYOUT_CI for now |
| 68 | XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pShaderMappingSlot; |
| 69 | } SHADER_DS_MAPPING; |
| 70 | |
| 71 | typedef struct _PIPELINE_LL_HEADER { |
| 72 | XGL_STRUCTURE_TYPE sType; |
| 73 | const void* pNext; |
| 74 | } PIPELINE_LL_HEADER; |
| 75 | |
| 76 | typedef struct _PIPELINE_NODE { |
| 77 | XGL_PIPELINE pipeline; |
| 78 | struct _PIPELINE_NODE *pNext; |
| 79 | XGL_GRAPHICS_PIPELINE_CREATE_INFO *pCreateTree; // Ptr to shadow of data in create tree |
| 80 | // 1st dimension of array is shader type |
| 81 | SHADER_DS_MAPPING dsMapping[XGL_NUM_GRAPHICS_SHADERS]; |
| 82 | // Vtx input info (if any) |
| 83 | uint32_t vtxBindingCount; // number of bindings |
| 84 | XGL_VERTEX_INPUT_BINDING_DESCRIPTION* pVertexBindingDescriptions; |
| 85 | uint32_t vtxAttributeCount; // number of attributes |
| 86 | XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions; |
| 87 | } PIPELINE_NODE; |
| 88 | |
| 89 | typedef struct _SAMPLER_NODE { |
| 90 | XGL_SAMPLER sampler; |
| 91 | XGL_SAMPLER_CREATE_INFO createInfo; |
| 92 | struct _SAMPLER_NODE *pNext; |
| 93 | } SAMPLER_NODE; |
| 94 | |
| 95 | typedef struct _DYNAMIC_STATE_NODE { |
| 96 | XGL_DYNAMIC_STATE_OBJECT stateObj; |
| 97 | PIPELINE_LL_HEADER *pCreateInfo; |
| 98 | struct _DYNAMIC_STATE_NODE *pNext; |
| 99 | } DYNAMIC_STATE_NODE; |
| 100 | |
| 101 | typedef struct _DS_SLOT { |
| 102 | uint32_t slot; |
| 103 | // TODO : Fix this for latest binding model |
| 104 | XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO shaderSlotInfo[XGL_NUM_GRAPHICS_SHADERS]; |
| 105 | // Only 1 of 4 possible slot mappings active |
| 106 | uint32_t activeMapping; |
| 107 | uint32_t mappingMask; // store record of different mappings used |
| 108 | XGL_BUFFER_VIEW_ATTACH_INFO buffView; |
| 109 | XGL_IMAGE_VIEW_ATTACH_INFO imageView; |
| 110 | XGL_SAMPLER sampler; |
| 111 | } DS_SLOT; |
| 112 | |
| 113 | // Top-level node that points to start of DS |
| 114 | typedef struct _DS_LL_HEAD { |
| 115 | XGL_DESCRIPTOR_SET dsID; |
| 116 | uint32_t numSlots; |
| 117 | struct _DS_LL_HEAD *pNextDS; |
| 118 | DS_SLOT *dsSlot; // Dynamically allocated array of DS_SLOTs |
| 119 | bool32_t updateActive; // Track if DS is in an update block |
| 120 | } DS_LL_HEAD; |
| 121 | |
| 122 | // Descriptor Data structures |
| 123 | typedef struct _LAYOUT_NODE { |
| 124 | XGL_DESCRIPTOR_SET_LAYOUT layout; |
| 125 | XGL_FLAGS stageFlags; |
| 126 | const uint32_t[XGL_NUM_SHADER_STAGE] shaderStateBindPoints; |
| 127 | const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO createInfo; |
| 128 | //XGL_DESCRIPTOR_SET_LAYOUT priorSetLayout, |
| 129 | struct _LAYOUT_NODE* pNext; // Points to node w/ priorSetLayout |
| 130 | } LAYOUT_NODE; |
| 131 | |
| 132 | typedef struct _SET_NODE { |
| 133 | XGL_DESCRIPTOR_SET set; |
| 134 | XGL_DESCRIPTOR_REGION region; |
| 135 | XGL_DESCRIPTOR_SET_USAGE setUsage; |
| 136 | //uint32_t count; |
| 137 | //const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayouts; |
| 138 | LAYOUT_NODE* pLayouts; |
| 139 | struct _SET_NODE* pNext; |
| 140 | } SET_NODE; |
| 141 | |
| 142 | typedef struct _REGION_NODE { |
| 143 | XGL_DESCRIPTOR_REGION region; |
| 144 | XGL_DESCRIPTOR_REGION_USAGE regionUsage; |
| 145 | uint32_t maxSets; |
| 146 | const XGL_DESCRIPTOR_REGION_CREATE_INFO createInfo; |
| 147 | bool32_t updateActive; // Track if Region is in an update block |
| 148 | struct _REGION_NODE* pNext; |
| 149 | SET_NODE* pSets; // Head of LL of sets for this Region |
| 150 | } REGION_NODE; |
| 151 | |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 152 | //prototypes for extension functions |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 153 | void drawStateDumpDotFile(char* outFileName); |
| 154 | void drawStateDumpPngFile(char* outFileName); |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 155 | // Func ptr typedefs |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 156 | typedef void (*DRAW_STATE_DUMP_DOT_FILE)(char*); |
| 157 | typedef void (*DRAW_STATE_DUMP_PNG_FILE)(char*); |