blob: f464567ae41b33d09e10f5b42169000de3aeee11 [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_NO_PIPELINE_BOUND, // Unable to identify a bound pipeline
Tobin Ehlis41415bb2015-01-22 10:45:21 -070031 DRAWSTATE_INVALID_REGION, // Invalid DS region
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070032 DRAWSTATE_INVALID_SET, // Invalid DS
Tobin Ehlis41415bb2015-01-22 10:45:21 -070033 DRAWSTATE_INVALID_LAYOUT, // Invalid DS layout
Tobin Ehlis84c521c2015-01-19 08:42:29 -070034 DRAWSTATE_DS_END_WITHOUT_BEGIN, // EndDSUpdate called w/o corresponding BeginDSUpdate
35 DRAWSTATE_UPDATE_WITHOUT_BEGIN, // Attempt to update descriptors w/o calling BeginDescriptorRegionUpdate
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070036 DRAWSTATE_INVALID_PIPELINE, // Invalid Pipeline referenced
Tobin Ehlis84c521c2015-01-19 08:42:29 -070037 DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in xglCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array
38 DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, // Invalid dyn state object
39 DRAWSTATE_MISSING_DOT_PROGRAM, // No "dot" program in order to generate png image
40 DRAWSTATE_BINDING_DS_NO_END_UPDATE, // DS bound to CmdBuffer w/o call to xglEndDescriptorSetUpdate())
41 DRAWSTATE_NO_DS_REGION, // No DS Region is available
Tobin Ehlis41415bb2015-01-22 10:45:21 -070042 DRAWSTATE_OUT_OF_MEMORY, // malloc failed
43 DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, // Type in layout vs. update are not the same
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070044 DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, // Descriptors set for update out of bounds for corresponding layout section
45 DRAWSTATE_INVALID_UPDATE_INDEX // Index of requested update is invalid for specified descriptors set
Tobin Ehlise79df942014-11-18 16:38:08 -070046} DRAW_STATE_ERROR;
Tobin Ehlis26092022014-11-20 09:49:17 -070047
48typedef enum _DRAW_TYPE
49{
50 DRAW = 0,
51 DRAW_INDEXED = 1,
52 DRAW_INDIRECT = 2,
53 DRAW_INDEXED_INDIRECT = 3,
54 DRAW_BEGIN_RANGE = DRAW,
55 DRAW_END_RANGE = DRAW_INDEXED_INDIRECT,
56 NUM_DRAW_TYPES = (DRAW_END_RANGE - DRAW_BEGIN_RANGE + 1),
57} DRAW_TYPE;
Tobin Ehlisa701ef02014-11-27 15:43:39 -070058
Tobin Ehlis84c521c2015-01-19 08:42:29 -070059typedef struct _SHADER_DS_MAPPING {
60 uint32_t slotCount;
61 // TODO : Need to understand this with new binding model, changed to LAYOUT_CI for now
62 XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pShaderMappingSlot;
63} SHADER_DS_MAPPING;
64
Tobin Ehlis41415bb2015-01-22 10:45:21 -070065typedef struct _GENERIC_HEADER {
Tobin Ehlis84c521c2015-01-19 08:42:29 -070066 XGL_STRUCTURE_TYPE sType;
67 const void* pNext;
Tobin Ehlis41415bb2015-01-22 10:45:21 -070068} GENERIC_HEADER;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070069
70typedef struct _PIPELINE_NODE {
71 XGL_PIPELINE pipeline;
72 struct _PIPELINE_NODE *pNext;
73 XGL_GRAPHICS_PIPELINE_CREATE_INFO *pCreateTree; // Ptr to shadow of data in create tree
Tobin Ehlis84c521c2015-01-19 08:42:29 -070074 // Vtx input info (if any)
75 uint32_t vtxBindingCount; // number of bindings
76 XGL_VERTEX_INPUT_BINDING_DESCRIPTION* pVertexBindingDescriptions;
77 uint32_t vtxAttributeCount; // number of attributes
78 XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -070079 uint32_t attachmentCount; // number of CB attachments
80 XGL_PIPELINE_CB_ATTACHMENT_STATE* pAttachments;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070081} PIPELINE_NODE;
82
83typedef struct _SAMPLER_NODE {
84 XGL_SAMPLER sampler;
85 XGL_SAMPLER_CREATE_INFO createInfo;
Tobin Ehlis41415bb2015-01-22 10:45:21 -070086 struct _SAMPLER_NODE* pNext;
Tobin Ehlis84c521c2015-01-19 08:42:29 -070087} SAMPLER_NODE;
88
Tobin Ehlis41415bb2015-01-22 10:45:21 -070089typedef struct _IMAGE_NODE {
90 XGL_IMAGE_VIEW image;
91 XGL_IMAGE_VIEW_CREATE_INFO createInfo;
92 XGL_IMAGE_VIEW_ATTACH_INFO attachInfo;
93 struct _IMAGE_NODE* pNext;
94} IMAGE_NODE;
95
96typedef struct _BUFFER_NODE {
97 XGL_BUFFER_VIEW buffer;
98 XGL_BUFFER_VIEW_CREATE_INFO createInfo;
99 XGL_BUFFER_VIEW_ATTACH_INFO attachInfo;
100 struct _BUFFER_NODE* pNext;
101} BUFFER_NODE;
102
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700103typedef struct _DYNAMIC_STATE_NODE {
104 XGL_DYNAMIC_STATE_OBJECT stateObj;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700105 GENERIC_HEADER *pCreateInfo;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700106 struct _DYNAMIC_STATE_NODE *pNext;
107} DYNAMIC_STATE_NODE;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700108// Descriptor Data structures
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700109// Layout Node has the core layout data
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700110typedef struct _LAYOUT_NODE {
111 XGL_DESCRIPTOR_SET_LAYOUT layout;
112 XGL_FLAGS stageFlags;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700113 const uint32_t shaderStageBindPoints[XGL_NUM_SHADER_STAGE];
114 const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pCreateInfoList;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700115 uint32_t startIndex; // 1st index of this layout
116 uint32_t endIndex; // last index of this layout
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700117 struct _LAYOUT_NODE* pPriorSetLayout; // Points to node w/ priorSetLayout
118 struct _LAYOUT_NODE* pNext; // Point to next layout in global LL chain of layouts
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700119} LAYOUT_NODE;
120
121typedef struct _SET_NODE {
122 XGL_DESCRIPTOR_SET set;
123 XGL_DESCRIPTOR_REGION region;
124 XGL_DESCRIPTOR_SET_USAGE setUsage;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700125 // Head of LL of Update structs for this set
126 GENERIC_HEADER* pUpdateStructs;
127 // Total num of descriptors in this set (count of its layout plus all prior layouts)
128 uint32_t descriptorCount;
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700129 LAYOUT_NODE* pLayouts;
130 struct _SET_NODE* pNext;
131} SET_NODE;
132
133typedef struct _REGION_NODE {
134 XGL_DESCRIPTOR_REGION region;
135 XGL_DESCRIPTOR_REGION_USAGE regionUsage;
136 uint32_t maxSets;
137 const XGL_DESCRIPTOR_REGION_CREATE_INFO createInfo;
138 bool32_t updateActive; // Track if Region is in an update block
139 struct _REGION_NODE* pNext;
140 SET_NODE* pSets; // Head of LL of sets for this Region
141} REGION_NODE;
142
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700143//prototypes for extension functions
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600144void drawStateDumpDotFile(char* outFileName);
145void drawStateDumpPngFile(char* outFileName);
Tobin Ehlis266473d2014-12-16 17:34:50 -0700146// Func ptr typedefs
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600147typedef void (*DRAW_STATE_DUMP_DOT_FILE)(char*);
148typedef void (*DRAW_STATE_DUMP_PNG_FILE)(char*);