2 * Copyright 2017 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include "tgsi/tgsi_from_mesa.h"
26 #include "pipe/p_compiler.h"
29 * Determine the semantic index that is used when the given varying is mapped
30 * to TGSI_SEMANTIC_GENERIC.
33 tgsi_get_generic_gl_varying_index(gl_varying_slot attr
,
34 bool needs_texcoord_semantic
)
36 if (attr
>= VARYING_SLOT_VAR0
) {
37 if (needs_texcoord_semantic
)
38 return attr
- VARYING_SLOT_VAR0
;
40 return 9 + (attr
- VARYING_SLOT_VAR0
);
42 if (attr
== VARYING_SLOT_PNTC
) {
43 assert(!needs_texcoord_semantic
);
46 if (attr
>= VARYING_SLOT_TEX0
&& attr
<= VARYING_SLOT_TEX7
) {
47 assert(!needs_texcoord_semantic
);
48 return attr
- VARYING_SLOT_TEX0
;
56 * Determine the semantic name and index used for the given varying.
59 tgsi_get_gl_varying_semantic(gl_varying_slot attr
,
60 bool needs_texcoord_semantic
,
61 unsigned *semantic_name
,
62 unsigned *semantic_index
)
65 case VARYING_SLOT_POS
:
66 *semantic_name
= TGSI_SEMANTIC_POSITION
;
69 case VARYING_SLOT_COL0
:
70 *semantic_name
= TGSI_SEMANTIC_COLOR
;
73 case VARYING_SLOT_COL1
:
74 *semantic_name
= TGSI_SEMANTIC_COLOR
;
77 case VARYING_SLOT_BFC0
:
78 *semantic_name
= TGSI_SEMANTIC_BCOLOR
;
81 case VARYING_SLOT_BFC1
:
82 *semantic_name
= TGSI_SEMANTIC_BCOLOR
;
85 case VARYING_SLOT_FOGC
:
86 *semantic_name
= TGSI_SEMANTIC_FOG
;
89 case VARYING_SLOT_PSIZ
:
90 *semantic_name
= TGSI_SEMANTIC_PSIZE
;
93 case VARYING_SLOT_CLIP_DIST0
:
94 *semantic_name
= TGSI_SEMANTIC_CLIPDIST
;
97 case VARYING_SLOT_CLIP_DIST1
:
98 *semantic_name
= TGSI_SEMANTIC_CLIPDIST
;
101 case VARYING_SLOT_CULL_DIST0
:
102 case VARYING_SLOT_CULL_DIST1
:
103 /* these should have been lowered by GLSL */
106 case VARYING_SLOT_EDGE
:
107 *semantic_name
= TGSI_SEMANTIC_EDGEFLAG
;
110 case VARYING_SLOT_CLIP_VERTEX
:
111 *semantic_name
= TGSI_SEMANTIC_CLIPVERTEX
;
114 case VARYING_SLOT_LAYER
:
115 *semantic_name
= TGSI_SEMANTIC_LAYER
;
118 case VARYING_SLOT_VIEWPORT
:
119 *semantic_name
= TGSI_SEMANTIC_VIEWPORT_INDEX
;
122 case VARYING_SLOT_PNTC
:
123 *semantic_name
= TGSI_SEMANTIC_PCOORD
;
127 case VARYING_SLOT_TEX0
:
128 case VARYING_SLOT_TEX1
:
129 case VARYING_SLOT_TEX2
:
130 case VARYING_SLOT_TEX3
:
131 case VARYING_SLOT_TEX4
:
132 case VARYING_SLOT_TEX5
:
133 case VARYING_SLOT_TEX6
:
134 case VARYING_SLOT_TEX7
:
135 if (needs_texcoord_semantic
) {
136 *semantic_name
= TGSI_SEMANTIC_TEXCOORD
;
137 *semantic_index
= attr
- VARYING_SLOT_TEX0
;
141 case VARYING_SLOT_VAR0
:
143 assert(attr
>= VARYING_SLOT_VAR0
||
144 (attr
>= VARYING_SLOT_TEX0
&& attr
<= VARYING_SLOT_TEX7
));
145 *semantic_name
= TGSI_SEMANTIC_GENERIC
;
147 tgsi_get_generic_gl_varying_index(attr
, needs_texcoord_semantic
);
153 * Determine the semantic name and index used for the given fragment shader
157 tgsi_get_gl_frag_result_semantic(gl_frag_result frag_result
,
158 unsigned *semantic_name
,
159 unsigned *semantic_index
)
161 if (frag_result
>= FRAG_RESULT_DATA0
) {
162 *semantic_name
= TGSI_SEMANTIC_COLOR
;
163 *semantic_index
= frag_result
- FRAG_RESULT_DATA0
;
169 switch (frag_result
) {
170 case FRAG_RESULT_DEPTH
:
171 *semantic_name
= TGSI_SEMANTIC_POSITION
;
173 case FRAG_RESULT_STENCIL
:
174 *semantic_name
= TGSI_SEMANTIC_STENCIL
;
176 case FRAG_RESULT_COLOR
:
177 *semantic_name
= TGSI_SEMANTIC_COLOR
;
179 case FRAG_RESULT_SAMPLE_MASK
:
180 *semantic_name
= TGSI_SEMANTIC_SAMPLEMASK
;