nv50: fix build-predicate function
[mesa.git] / src / mesa / slang / library / slang_vertex_builtin.gc
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 2006 Brian Paul 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 "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 //
26 // From Shader Spec, ver. 1.10, rev. 59
27 //
28
29 __fixed_output vec4 gl_Position;
30 __fixed_output float gl_PointSize;
31 __fixed_output vec4 gl_ClipVertex;
32
33 attribute vec4 gl_Color;
34 attribute vec4 gl_SecondaryColor;
35 attribute vec3 gl_Normal;
36 attribute vec4 gl_Vertex;
37 attribute vec4 gl_MultiTexCoord0;
38 attribute vec4 gl_MultiTexCoord1;
39 attribute vec4 gl_MultiTexCoord2;
40 attribute vec4 gl_MultiTexCoord3;
41 attribute vec4 gl_MultiTexCoord4;
42 attribute vec4 gl_MultiTexCoord5;
43 attribute vec4 gl_MultiTexCoord6;
44 attribute vec4 gl_MultiTexCoord7;
45 attribute float gl_FogCoord;
46
47 varying vec4 gl_FrontColor;
48 varying vec4 gl_BackColor;
49 varying vec4 gl_FrontSecondaryColor;
50 varying vec4 gl_BackSecondaryColor;
51 varying vec4 gl_TexCoord[gl_MaxTextureCoords];
52 varying float gl_FogFragCoord;
53
54 //
55 // Geometric Functions
56 //
57
58 vec4 ftransform()
59 {
60 __retVal = gl_ModelViewProjectionMatrix[0] * gl_Vertex.xxxx
61 + gl_ModelViewProjectionMatrix[1] * gl_Vertex.yyyy
62 + gl_ModelViewProjectionMatrix[2] * gl_Vertex.zzzz
63 + gl_ModelViewProjectionMatrix[3] * gl_Vertex.wwww;
64 }
65
66
67
68 //
69 // 8.7 Texture Lookup Functions
70 // These are pretty much identical to the ones in slang_fragment_builtin.gc
71 // When used in a vertex program, the texture sample instructions should not
72 // be using a LOD term so it's effectively zero. Adding 'lod' to that does
73 // what we want.
74 //
75
76 vec4 texture1DLod(const sampler1D sampler, const float coord, const float lod)
77 {
78 vec4 coord4;
79 coord4.x = coord;
80 coord4.w = lod;
81 __asm vec4_tex_1d_bias __retVal, sampler, coord4;
82 }
83
84 vec4 texture1DProjLod(const sampler1D sampler, const vec2 coord, const float lod)
85 {
86 vec4 pcoord;
87 pcoord.x = coord.x / coord.y;
88 pcoord.w = lod;
89 __asm vec4_tex_1d_bias __retVal, sampler, pcoord;
90 }
91
92 vec4 texture1DProjLod(const sampler1D sampler, const vec4 coord, const float lod)
93 {
94 vec4 pcoord;
95 pcoord.x = coord.x / coord.z;
96 pcoord.w = lod;
97 __asm vec4_tex_1d_bias __retVal, sampler, pcoord;
98 }
99
100
101
102 vec4 texture2DLod(const sampler2D sampler, const vec2 coord, const float lod)
103 {
104 vec4 coord4;
105 coord4.xy = coord.xy;
106 coord4.w = lod;
107 __asm vec4_tex_2d_bias __retVal, sampler, coord4;
108 }
109
110 vec4 texture2DProjLod(const sampler2D sampler, const vec3 coord, const float lod)
111 {
112 vec4 pcoord;
113 pcoord.xy = coord.xy / coord.z;
114 pcoord.w = lod;
115 __asm vec4_tex_2d_bias __retVal, sampler, pcoord;
116 }
117
118 vec4 texture2DProjLod(const sampler2D sampler, const vec4 coord, const float lod)
119 {
120 vec4 pcoord;
121 pcoord.xy = coord.xy / coord.z;
122 pcoord.w = lod;
123 __asm vec4_tex_2d_bias __retVal, sampler, pcoord;
124 }
125
126
127 vec4 texture3DLod(const sampler3D sampler, const vec3 coord, const float lod)
128 {
129 vec4 coord4;
130 coord4.xyz = coord.xyz;
131 coord4.w = lod;
132 __asm vec4_tex_3d_bias __retVal, sampler, coord4;
133 }
134
135 vec4 texture3DProjLod(const sampler3D sampler, const vec4 coord, const float lod)
136 {
137 // do projection here (there's no vec4_tex_3d_bias_proj instruction)
138 vec4 pcoord;
139 pcoord.xyz = coord.xyz / coord.w;
140 pcoord.w = lod;
141 __asm vec4_tex_3d_bias __retVal, sampler, pcoord;
142 }
143
144
145 vec4 textureCubeLod(const samplerCube sampler, const vec3 coord, const float lod)
146 {
147 vec4 coord4;
148 coord4.xyz = coord;
149 coord4.w = lod;
150 __asm vec4_tex_cube __retVal, sampler, coord4;
151 }
152
153
154 vec4 shadow1DLod(const sampler1DShadow sampler, const vec3 coord, const float lod)
155 {
156 vec4 coord4;
157 coord4.xyz = coord;
158 coord4.w = lod;
159 __asm vec4_tex_1d_bias_shadow __retVal, sampler, coord4;
160 }
161
162 vec4 shadow1DProjLod(const sampler1DShadow sampler, const vec4 coord,
163 const float lod)
164 {
165 vec4 pcoord;
166 pcoord.x = coord.x / coord.w;
167 pcoord.z = coord.z;
168 pcoord.w = lod;
169 __asm vec4_tex_1d_bias_shadow __retVal, sampler, pcoord;
170 }
171
172
173 vec4 shadow2DLod(const sampler2DShadow sampler, const vec3 coord, const float lod)
174 {
175 vec4 coord4;
176 coord4.xyz = coord;
177 coord4.w = lod;
178 __asm vec4_tex_2d_bias_shadow __retVal, sampler, coord4;
179 }
180
181 vec4 shadow2DProjLod(const sampler2DShadow sampler, const vec4 coord,
182 const float lod)
183 {
184 vec4 pcoord;
185 pcoord.xy = coord.xy / coord.w;
186 pcoord.z = coord.z;
187 pcoord.w = lod;
188 __asm vec4_tex_2d_bias_shadow __retVal, sampler, pcoord;
189 }
190
191
192 //// GL_EXT_texture_array
193
194 vec4 texture1DArrayLod(const sampler1DArray sampler, const vec2 coord, const float lod)
195 {
196 vec4 coord4;
197 coord4.xy = coord;
198 coord4.w = lod;
199 __asm vec4_tex_1d_array_bias __retVal, sampler, coord4;
200 }
201
202
203 vec4 texture2DArrayLod(const sampler2DArray sampler, const vec3 coord, const float lod)
204 {
205 vec4 coord4;
206 coord4.xyz = coord;
207 coord4.w = lod;
208 __asm vec4_tex_2d_array_bias __retVal, sampler, coord4;
209 }
210