blob: 5dcc8492e45f391efa4d77076f2e093a98688c0d [file] [log] [blame]
Tobin Ehlise79df942014-11-18 16:38:08 -07001/*
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
26typedef enum _DRAW_STATE_ERROR
27{
Tobin Ehlis84c521c2015-01-19 08:42:29 -070028 DRAWSTATE_NONE, // Used for INFO & other non-error messages
Tobin Ehlis41415bb2015-01-22 10:45:21 -070029 DRAWSTATE_INTERNAL_ERROR, // Error with DrawState internal data structures
Tobin Ehlis84c521c2015-01-19 08:42:29 -070030 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
Tobin Ehlis41415bb2015-01-22 10:45:21 -070035 DRAWSTATE_UNKNOWN_DS_TYPE, // Shader slot mapping is not recognized
Tobin Ehlis84c521c2015-01-19 08:42:29 -070036 DRAWSTATE_DS_MAPPING_MISMATCH, // DS Mapping mismatch
Tobin Ehlis41415bb2015-01-22 10:45:21 -070037 DRAWSTATE_INVALID_REGION, // Invalid DS region
38 DRAWSTATE_INVALID_LAYOUT, // Invalid DS layout
Tobin Ehlis84c521c2015-01-19 08:42:29 -070039 DRAWSTATE_DS_END_WITHOUT_BEGIN, // EndDSUpdate called w/o corresponding BeginDSUpdate
40 DRAWSTATE_UPDATE_WITHOUT_BEGIN, // Attempt to update descriptors w/o calling BeginDescriptorRegionUpdate
41 DRAWSTATE_DS_SAMPLE_ATTACH_FAILED, // Error while attempting to Attach Sampler mapping to DS Slot
42 DRAWSTATE_DS_IMAGE_ATTACH_FAILED, // Error while attempting to Attach Image mapping to DS Slot
43 DRAWSTATE_DS_MEMORY_ATTACH_FAILED, // Error while attempting to Attach Mem mapping to DS Slot
44 DRAWSTATE_DS_NESTED_DS_ATTACH_FAILED, // Error while attempting to Attach Nested DS mapping to DS Slot
45 DRAWSTATE_CLEAR_DS_FAILED, // Error while attempting ClearDS
46 DRAWSTATE_INVALID_PIPELINE, // Invalid DS referenced
47 DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in xglCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array
48 DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, // Invalid dyn state object
49 DRAWSTATE_MISSING_DOT_PROGRAM, // No "dot" program in order to generate png image
50 DRAWSTATE_BINDING_DS_NO_END_UPDATE, // DS bound to CmdBuffer w/o call to xglEndDescriptorSetUpdate())
51 DRAWSTATE_NO_DS_REGION, // No DS Region is available
Tobin Ehlis41415bb2015-01-22 10:45:21 -070052 DRAWSTATE_OUT_OF_MEMORY, // malloc failed
53 DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, // Type in layout vs. update are not the same
54 DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS // Descriptors set for update out of bounds for corresponding layout section
Tobin Ehlise79df942014-11-18 16:38:08 -070055} DRAW_STATE_ERROR;
Tobin Ehlis26092022014-11-20 09:49:17 -070056
57typedef enum _DRAW_TYPE
58{
59 DRAW = 0,
60 DRAW_INDEXED = 1,
61 DRAW_INDIRECT = 2,
62 DRAW_INDEXED_INDIRECT = 3,
63 DRAW_BEGIN_RANGE = DRAW,
64 DRAW_END_RANGE = DRAW_INDEXED_INDIRECT,
65 NUM_DRAW_TYPES = (DRAW_END_RANGE - DRAW_BEGIN_RANGE + 1),
66} DRAW_TYPE;
Tobin Ehlisa701ef02014-11-27 15:43:39 -070067
Tobin Ehlis84c521c2015-01-19 08:42:29 -070068typedef struct _SHADER_DS_MAPPING {
69 uint32_t slotCount;
70 // TODO : Need to understand this with new binding model, changed to LAYOUT_CI for now
71 XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pShaderMappingSlot;
72} SHADER_DS_MAPPING;
73
Tobin Ehlis41415bb2015-01-22 10:45:21 -070074typedef struct _GENERIC_HEADER {
Tobin Ehlis84c521c2015-01-19 08:42:29 -070075 XGL_STRUCTURE_TYPE sType;
76 const void* pNext;
Tobin Ehlis41415bb2015-01-22 10:45:21 -070077} GENERIC_HEADER;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070078
79typedef struct _PIPELINE_NODE {
80 XGL_PIPELINE pipeline;
81 struct _PIPELINE_NODE *pNext;
82 XGL_GRAPHICS_PIPELINE_CREATE_INFO *pCreateTree; // Ptr to shadow of data in create tree
83 // 1st dimension of array is shader type
Tobin Ehlis41415bb2015-01-22 10:45:21 -070084 //SHADER_DS_MAPPING dsMapping[XGL_NUM_GRAPHICS_SHADERS];
Tobin Ehlis84c521c2015-01-19 08:42:29 -070085 // Vtx input info (if any)
86 uint32_t vtxBindingCount; // number of bindings
87 XGL_VERTEX_INPUT_BINDING_DESCRIPTION* pVertexBindingDescriptions;
88 uint32_t vtxAttributeCount; // number of attributes
89 XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions;
90} PIPELINE_NODE;
91
92typedef struct _SAMPLER_NODE {
93 XGL_SAMPLER sampler;
94 XGL_SAMPLER_CREATE_INFO createInfo;
Tobin Ehlis41415bb2015-01-22 10:45:21 -070095 struct _SAMPLER_NODE* pNext;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070096} SAMPLER_NODE;
97
Tobin Ehlis41415bb2015-01-22 10:45:21 -070098typedef struct _IMAGE_NODE {
99 XGL_IMAGE_VIEW image;
100 XGL_IMAGE_VIEW_CREATE_INFO createInfo;
101 XGL_IMAGE_VIEW_ATTACH_INFO attachInfo;
102 struct _IMAGE_NODE* pNext;
103} IMAGE_NODE;
104
105typedef struct _BUFFER_NODE {
106 XGL_BUFFER_VIEW buffer;
107 XGL_BUFFER_VIEW_CREATE_INFO createInfo;
108 XGL_BUFFER_VIEW_ATTACH_INFO attachInfo;
109 struct _BUFFER_NODE* pNext;
110} BUFFER_NODE;
111
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700112typedef struct _DYNAMIC_STATE_NODE {
113 XGL_DYNAMIC_STATE_OBJECT stateObj;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700114 GENERIC_HEADER *pCreateInfo;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700115 struct _DYNAMIC_STATE_NODE *pNext;
116} DYNAMIC_STATE_NODE;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700117/*
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700118typedef struct _DS_SLOT {
119 uint32_t slot;
120 // TODO : Fix this for latest binding model
121 XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO shaderSlotInfo[XGL_NUM_GRAPHICS_SHADERS];
122 // Only 1 of 4 possible slot mappings active
123 uint32_t activeMapping;
124 uint32_t mappingMask; // store record of different mappings used
125 XGL_BUFFER_VIEW_ATTACH_INFO buffView;
126 XGL_IMAGE_VIEW_ATTACH_INFO imageView;
127 XGL_SAMPLER sampler;
128} DS_SLOT;
129
130// Top-level node that points to start of DS
131typedef struct _DS_LL_HEAD {
132 XGL_DESCRIPTOR_SET dsID;
133 uint32_t numSlots;
134 struct _DS_LL_HEAD *pNextDS;
135 DS_SLOT *dsSlot; // Dynamically allocated array of DS_SLOTs
136 bool32_t updateActive; // Track if DS is in an update block
137} DS_LL_HEAD;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700138*/
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700139// Descriptor Data structures
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700140// Layout Node has the core layout data
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700141typedef struct _LAYOUT_NODE {
142 XGL_DESCRIPTOR_SET_LAYOUT layout;
143 XGL_FLAGS stageFlags;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700144 const uint32_t shaderStageBindPoints[XGL_NUM_SHADER_STAGE];
145 const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pCreateInfoList;
146 struct _LAYOUT_NODE* pPriorSetLayout; // Points to node w/ priorSetLayout
147 struct _LAYOUT_NODE* pNext; // Point to next layout in global LL chain of layouts
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700148} LAYOUT_NODE;
149
150typedef struct _SET_NODE {
151 XGL_DESCRIPTOR_SET set;
152 XGL_DESCRIPTOR_REGION region;
153 XGL_DESCRIPTOR_SET_USAGE setUsage;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700154 // Head of LL of Update structs for this set
155 GENERIC_HEADER* pUpdateStructs;
156 // Total num of descriptors in this set (count of its layout plus all prior layouts)
157 uint32_t descriptorCount;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700158 LAYOUT_NODE* pLayouts;
159 struct _SET_NODE* pNext;
160} SET_NODE;
161
162typedef struct _REGION_NODE {
163 XGL_DESCRIPTOR_REGION region;
164 XGL_DESCRIPTOR_REGION_USAGE regionUsage;
165 uint32_t maxSets;
166 const XGL_DESCRIPTOR_REGION_CREATE_INFO createInfo;
167 bool32_t updateActive; // Track if Region is in an update block
168 struct _REGION_NODE* pNext;
169 SET_NODE* pSets; // Head of LL of sets for this Region
170} REGION_NODE;
171
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700172//prototypes for extension functions
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600173void drawStateDumpDotFile(char* outFileName);
174void drawStateDumpPngFile(char* outFileName);
Tobin Ehlis266473d2014-12-16 17:34:50 -0700175// Func ptr typedefs
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600176typedef void (*DRAW_STATE_DUMP_DOT_FILE)(char*);
177typedef void (*DRAW_STATE_DUMP_PNG_FILE)(char*);