1 /**************************************************************************
2  *
3  * Copyright 2007-2008 VMware, Inc.
4  * Copyright 2012 VMware, Inc.
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  **************************************************************************/
28 
29 
30 #include "pipe/p_compiler.h"
31 #include "util/u_memory.h"
32 #include "tgsi_strings.h"
33 
34 
35 const char *tgsi_processor_type_names[6] =
36 {
37    "VERT",
38    "FRAG",
39    "GEOM",
40    "TESS_CTRL",
41    "TESS_EVAL",
42    "COMP"
43 };
44 
45 static const char *tgsi_file_names[] =
46 {
47    "NULL",
48    "CONST",
49    "IN",
50    "OUT",
51    "TEMP",
52    "SAMP",
53    "ADDR",
54    "IMM",
55    "SV",
56    "IMAGE",
57    "SVIEW",
58    "BUFFER",
59    "MEMORY",
60    "CONSTBUF",
61    "HWATOMIC",
62 };
63 
64 const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
65 {
66    "POSITION",
67    "COLOR",
68    "BCOLOR",
69    "FOG",
70    "PSIZE",
71    "GENERIC",
72    "NORMAL",
73    "FACE",
74    "EDGEFLAG",
75    "PRIM_ID",
76    "INSTANCEID",
77    "VERTEXID",
78    "STENCIL",
79    "CLIPDIST",
80    "CLIPVERTEX",
81    "GRID_SIZE",
82    "BLOCK_ID",
83    "BLOCK_SIZE",
84    "THREAD_ID",
85    "TEXCOORD",
86    "PCOORD",
87    "VIEWPORT_INDEX",
88    "LAYER",
89    "SAMPLEID",
90    "SAMPLEPOS",
91    "SAMPLEMASK",
92    "INVOCATIONID",
93    "VERTEXID_NOBASE",
94    "BASEVERTEX",
95    "PATCH",
96    "TESSCOORD",
97    "TESSOUTER",
98    "TESSINNER",
99    "VERTICESIN",
100    "HELPER_INVOCATION",
101    "BASEINSTANCE",
102    "DRAWID",
103    "WORK_DIM",
104    "SUBGROUP_SIZE",
105    "SUBGROUP_INVOCATION",
106    "SUBGROUP_EQ_MASK",
107    "SUBGROUP_GE_MASK",
108    "SUBGROUP_GT_MASK",
109    "SUBGROUP_LE_MASK",
110    "SUBGROUP_LT_MASK",
111 };
112 
113 const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =
114 {
115    "BUFFER",
116    "1D",
117    "2D",
118    "3D",
119    "CUBE",
120    "RECT",
121    "SHADOW1D",
122    "SHADOW2D",
123    "SHADOWRECT",
124    "1D_ARRAY",
125    "2D_ARRAY",
126    "SHADOW1D_ARRAY",
127    "SHADOW2D_ARRAY",
128    "SHADOWCUBE",
129    "2D_MSAA",
130    "2D_ARRAY_MSAA",
131    "CUBEARRAY",
132    "SHADOWCUBEARRAY",
133    "UNKNOWN",
134 };
135 
136 const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
137 {
138    "GS_INPUT_PRIMITIVE",
139    "GS_OUTPUT_PRIMITIVE",
140    "GS_MAX_OUTPUT_VERTICES",
141    "FS_COORD_ORIGIN",
142    "FS_COORD_PIXEL_CENTER",
143    "FS_COLOR0_WRITES_ALL_CBUFS",
144    "FS_DEPTH_LAYOUT",
145    "VS_PROHIBIT_UCPS",
146    "GS_INVOCATIONS",
147    "VS_WINDOW_SPACE_POSITION",
148    "TCS_VERTICES_OUT",
149    "TES_PRIM_MODE",
150    "TES_SPACING",
151    "TES_VERTEX_ORDER_CW",
152    "TES_POINT_MODE",
153    "NUM_CLIPDIST_ENABLED",
154    "NUM_CULLDIST_ENABLED",
155    "FS_EARLY_DEPTH_STENCIL",
156    "FS_POST_DEPTH_COVERAGE",
157    "NEXT_SHADER",
158    "CS_FIXED_BLOCK_WIDTH",
159    "CS_FIXED_BLOCK_HEIGHT",
160    "CS_FIXED_BLOCK_DEPTH",
161    "MUL_ZERO_WINS",
162 };
163 
164 const char *tgsi_return_type_names[TGSI_RETURN_TYPE_COUNT] =
165 {
166    "UNORM",
167    "SNORM",
168    "SINT",
169    "UINT",
170    "FLOAT"
171 };
172 
173 const char *tgsi_interpolate_names[TGSI_INTERPOLATE_COUNT] =
174 {
175    "CONSTANT",
176    "LINEAR",
177    "PERSPECTIVE",
178    "COLOR"
179 };
180 
181 const char *tgsi_interpolate_locations[TGSI_INTERPOLATE_LOC_COUNT] =
182 {
183    "CENTER",
184    "CENTROID",
185    "SAMPLE",
186 };
187 
188 const char *tgsi_primitive_names[PIPE_PRIM_MAX] =
189 {
190    "POINTS",
191    "LINES",
192    "LINE_LOOP",
193    "LINE_STRIP",
194    "TRIANGLES",
195    "TRIANGLE_STRIP",
196    "TRIANGLE_FAN",
197    "QUADS",
198    "QUAD_STRIP",
199    "POLYGON",
200    "LINES_ADJACENCY",
201    "LINE_STRIP_ADJACENCY",
202    "TRIANGLES_ADJACENCY",
203    "TRIANGLE_STRIP_ADJACENCY",
204    "PATCHES",
205 };
206 
207 const char *tgsi_fs_coord_origin_names[2] =
208 {
209    "UPPER_LEFT",
210    "LOWER_LEFT"
211 };
212 
213 const char *tgsi_fs_coord_pixel_center_names[2] =
214 {
215    "HALF_INTEGER",
216    "INTEGER"
217 };
218 
219 const char *tgsi_immediate_type_names[6] =
220 {
221    "FLT32",
222    "UINT32",
223    "INT32",
224    "FLT64",
225    "UINT64",
226    "INT64",
227 };
228 
229 const char *tgsi_memory_names[3] =
230 {
231    "COHERENT",
232    "RESTRICT",
233    "VOLATILE",
234 };
235 
236 
237 static inline void
tgsi_strings_check(void)238 tgsi_strings_check(void)
239 {
240    STATIC_ASSERT(ARRAY_SIZE(tgsi_semantic_names) == TGSI_SEMANTIC_COUNT);
241    STATIC_ASSERT(ARRAY_SIZE(tgsi_texture_names) == TGSI_TEXTURE_COUNT);
242    STATIC_ASSERT(ARRAY_SIZE(tgsi_property_names) == TGSI_PROPERTY_COUNT);
243    STATIC_ASSERT(ARRAY_SIZE(tgsi_primitive_names) == PIPE_PRIM_MAX);
244    STATIC_ASSERT(ARRAY_SIZE(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT);
245    STATIC_ASSERT(ARRAY_SIZE(tgsi_return_type_names) == TGSI_RETURN_TYPE_COUNT);
246    (void) tgsi_processor_type_names;
247    (void) tgsi_return_type_names;
248    (void) tgsi_immediate_type_names;
249    (void) tgsi_fs_coord_origin_names;
250    (void) tgsi_fs_coord_pixel_center_names;
251 }
252 
253 
254 const char *
tgsi_file_name(unsigned file)255 tgsi_file_name(unsigned file)
256 {
257    STATIC_ASSERT(ARRAY_SIZE(tgsi_file_names) == TGSI_FILE_COUNT);
258    if (file < ARRAY_SIZE(tgsi_file_names))
259       return tgsi_file_names[file];
260    else
261       return "invalid file";
262 }
263