blob: 18fa7fe2f32f8ad4d23f6df2410d28e0715c760d [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
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070038 DRAWSTATE_INVALID_SET, // Invalid DS
Tobin Ehlis41415bb2015-01-22 10:45:21 -070039 DRAWSTATE_INVALID_LAYOUT, // Invalid DS layout
Tobin Ehlis84c521c2015-01-19 08:42:29 -070040 DRAWSTATE_DS_END_WITHOUT_BEGIN, // EndDSUpdate called w/o corresponding BeginDSUpdate
41 DRAWSTATE_UPDATE_WITHOUT_BEGIN, // Attempt to update descriptors w/o calling BeginDescriptorRegionUpdate
42 DRAWSTATE_DS_SAMPLE_ATTACH_FAILED, // Error while attempting to Attach Sampler mapping to DS Slot
43 DRAWSTATE_DS_IMAGE_ATTACH_FAILED, // Error while attempting to Attach Image mapping to DS Slot
44 DRAWSTATE_DS_MEMORY_ATTACH_FAILED, // Error while attempting to Attach Mem mapping to DS Slot
45 DRAWSTATE_DS_NESTED_DS_ATTACH_FAILED, // Error while attempting to Attach Nested DS mapping to DS Slot
46 DRAWSTATE_CLEAR_DS_FAILED, // Error while attempting ClearDS
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070047 DRAWSTATE_INVALID_PIPELINE, // Invalid Pipeline referenced
Tobin Ehlis84c521c2015-01-19 08:42:29 -070048 DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in xglCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array
49 DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, // Invalid dyn state object
50 DRAWSTATE_MISSING_DOT_PROGRAM, // No "dot" program in order to generate png image
51 DRAWSTATE_BINDING_DS_NO_END_UPDATE, // DS bound to CmdBuffer w/o call to xglEndDescriptorSetUpdate())
52 DRAWSTATE_NO_DS_REGION, // No DS Region is available
Tobin Ehlis41415bb2015-01-22 10:45:21 -070053 DRAWSTATE_OUT_OF_MEMORY, // malloc failed
54 DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, // Type in layout vs. update are not the same
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070055 DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, // Descriptors set for update out of bounds for corresponding layout section
56 DRAWSTATE_INVALID_UPDATE_INDEX // Index of requested update is invalid for specified descriptors set
Tobin Ehlise79df942014-11-18 16:38:08 -070057} DRAW_STATE_ERROR;
Tobin Ehlis26092022014-11-20 09:49:17 -070058
59typedef enum _DRAW_TYPE
60{
61 DRAW = 0,
62 DRAW_INDEXED = 1,
63 DRAW_INDIRECT = 2,
64 DRAW_INDEXED_INDIRECT = 3,
65 DRAW_BEGIN_RANGE = DRAW,
66 DRAW_END_RANGE = DRAW_INDEXED_INDIRECT,
67 NUM_DRAW_TYPES = (DRAW_END_RANGE - DRAW_BEGIN_RANGE + 1),
68} DRAW_TYPE;
Tobin Ehlisa701ef02014-11-27 15:43:39 -070069
Tobin Ehlis84c521c2015-01-19 08:42:29 -070070typedef struct _SHADER_DS_MAPPING {
71 uint32_t slotCount;
72 // TODO : Need to understand this with new binding model, changed to LAYOUT_CI for now
73 XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pShaderMappingSlot;
74} SHADER_DS_MAPPING;
75
Tobin Ehlis41415bb2015-01-22 10:45:21 -070076typedef struct _GENERIC_HEADER {
Tobin Ehlis84c521c2015-01-19 08:42:29 -070077 XGL_STRUCTURE_TYPE sType;
78 const void* pNext;
Tobin Ehlis41415bb2015-01-22 10:45:21 -070079} GENERIC_HEADER;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070080
81typedef struct _PIPELINE_NODE {
82 XGL_PIPELINE pipeline;
83 struct _PIPELINE_NODE *pNext;
84 XGL_GRAPHICS_PIPELINE_CREATE_INFO *pCreateTree; // Ptr to shadow of data in create tree
85 // 1st dimension of array is shader type
Tobin Ehlis41415bb2015-01-22 10:45:21 -070086 //SHADER_DS_MAPPING dsMapping[XGL_NUM_GRAPHICS_SHADERS];
Tobin Ehlis84c521c2015-01-19 08:42:29 -070087 // Vtx input info (if any)
88 uint32_t vtxBindingCount; // number of bindings
89 XGL_VERTEX_INPUT_BINDING_DESCRIPTION* pVertexBindingDescriptions;
90 uint32_t vtxAttributeCount; // number of attributes
91 XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070092 uint32_t attachmentCount; // number of CB attachments
93 XGL_PIPELINE_CB_ATTACHMENT_STATE* pAttachments;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070094} PIPELINE_NODE;
95
96typedef struct _SAMPLER_NODE {
97 XGL_SAMPLER sampler;
98 XGL_SAMPLER_CREATE_INFO createInfo;
Tobin Ehlis41415bb2015-01-22 10:45:21 -070099 struct _SAMPLER_NODE* pNext;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700100} SAMPLER_NODE;
101
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700102typedef struct _IMAGE_NODE {
103 XGL_IMAGE_VIEW image;
104 XGL_IMAGE_VIEW_CREATE_INFO createInfo;
105 XGL_IMAGE_VIEW_ATTACH_INFO attachInfo;
106 struct _IMAGE_NODE* pNext;
107} IMAGE_NODE;
108
109typedef struct _BUFFER_NODE {
110 XGL_BUFFER_VIEW buffer;
111 XGL_BUFFER_VIEW_CREATE_INFO createInfo;
112 XGL_BUFFER_VIEW_ATTACH_INFO attachInfo;
113 struct _BUFFER_NODE* pNext;
114} BUFFER_NODE;
115
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700116typedef struct _DYNAMIC_STATE_NODE {
117 XGL_DYNAMIC_STATE_OBJECT stateObj;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700118 GENERIC_HEADER *pCreateInfo;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700119 struct _DYNAMIC_STATE_NODE *pNext;
120} DYNAMIC_STATE_NODE;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700121/*
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700122typedef struct _DS_SLOT {
123 uint32_t slot;
124 // TODO : Fix this for latest binding model
125 XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO shaderSlotInfo[XGL_NUM_GRAPHICS_SHADERS];
126 // Only 1 of 4 possible slot mappings active
127 uint32_t activeMapping;
128 uint32_t mappingMask; // store record of different mappings used
129 XGL_BUFFER_VIEW_ATTACH_INFO buffView;
130 XGL_IMAGE_VIEW_ATTACH_INFO imageView;
131 XGL_SAMPLER sampler;
132} DS_SLOT;
133
134// Top-level node that points to start of DS
135typedef struct _DS_LL_HEAD {
136 XGL_DESCRIPTOR_SET dsID;
137 uint32_t numSlots;
138 struct _DS_LL_HEAD *pNextDS;
139 DS_SLOT *dsSlot; // Dynamically allocated array of DS_SLOTs
140 bool32_t updateActive; // Track if DS is in an update block
141} DS_LL_HEAD;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700142*/
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700143// Descriptor Data structures
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700144// Layout Node has the core layout data
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700145typedef struct _LAYOUT_NODE {
146 XGL_DESCRIPTOR_SET_LAYOUT layout;
147 XGL_FLAGS stageFlags;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700148 const uint32_t shaderStageBindPoints[XGL_NUM_SHADER_STAGE];
149 const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pCreateInfoList;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700150 uint32_t startIndex; // 1st index of this layout
151 uint32_t endIndex; // last index of this layout
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700152 struct _LAYOUT_NODE* pPriorSetLayout; // Points to node w/ priorSetLayout
153 struct _LAYOUT_NODE* pNext; // Point to next layout in global LL chain of layouts
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700154} LAYOUT_NODE;
155
156typedef struct _SET_NODE {
157 XGL_DESCRIPTOR_SET set;
158 XGL_DESCRIPTOR_REGION region;
159 XGL_DESCRIPTOR_SET_USAGE setUsage;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700160 // Head of LL of Update structs for this set
161 GENERIC_HEADER* pUpdateStructs;
162 // Total num of descriptors in this set (count of its layout plus all prior layouts)
163 uint32_t descriptorCount;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700164 LAYOUT_NODE* pLayouts;
165 struct _SET_NODE* pNext;
166} SET_NODE;
167
168typedef struct _REGION_NODE {
169 XGL_DESCRIPTOR_REGION region;
170 XGL_DESCRIPTOR_REGION_USAGE regionUsage;
171 uint32_t maxSets;
172 const XGL_DESCRIPTOR_REGION_CREATE_INFO createInfo;
173 bool32_t updateActive; // Track if Region is in an update block
174 struct _REGION_NODE* pNext;
175 SET_NODE* pSets; // Head of LL of sets for this Region
176} REGION_NODE;
177
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700178//prototypes for extension functions
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600179void drawStateDumpDotFile(char* outFileName);
180void drawStateDumpPngFile(char* outFileName);
Tobin Ehlis266473d2014-12-16 17:34:50 -0700181// Func ptr typedefs
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600182typedef void (*DRAW_STATE_DUMP_DOT_FILE)(char*);
183typedef void (*DRAW_STATE_DUMP_PNG_FILE)(char*);