]> git.tdb.fi Git - libs/gl.git/blob - builtin_data/_builtin.glsl
Add declarations for most of the builtin functions in GLSL
[libs/gl.git] / builtin_data / _builtin.glsl
1 typedef vector(2) float vec2;
2 typedef vector(3) float vec3;
3 typedef vector(4) float vec4;
4 typedef vector(2) vec2 mat2;
5 typedef mat2 mat2x2;
6 typedef vector(3) vec2 mat3x2;
7 typedef vector(4) vec2 mat4x2;
8 typedef vector(2) vec3 mat2x3;
9 typedef vector(3) vec3 mat3;
10 typedef mat3 mat3x3;
11 typedef vector(4) vec3 mat4x3;
12 typedef vector(2) vec4 mat2x4;
13 typedef vector(3) vec4 mat3x4;
14 typedef vector(4) vec4 mat4;
15 typedef mat4 mat4x4;
16
17 typedef vector(2) int ivec2;
18 typedef vector(3) int ivec3;
19 typedef vector(4) int ivec4;
20
21 typedef image(dimensions=1, sampled) float sampler1D;
22 typedef image(dimensions=2, sampled) float sampler2D;
23 typedef image(dimensions=3, sampled) float sampler3D;
24 typedef image(dimensions=cube, sampled) float samplerCube;
25 typedef image(dimensions=1[], sampled) float sampler1DArray;
26 typedef image(dimensions=2[], sampled) float sampler2DArray;
27 typedef image(dimensions=cube[], sampled) float samplerCubeArray;
28 typedef image(dimensions=1, shadow, sampled) float sampler1DShadow;
29 typedef image(dimensions=2, shadow, sampled) float sampler2DShadow;
30 typedef image(dimensions=1[], shadow, sampled) float sampler1DArrayShadow;
31 typedef image(dimensions=2[], shadow, sampled) float sampler2DArrayShadow;
32 typedef image(dimensions=cube, shadow, sampled) float samplerCubeShadow;
33 typedef image(dimensions=cube[], shadow, sampled) float samplerCubeArrayShadow;
34
35 // BEGIN BUILTIN FUNCTIONS
36 float sin(float angle);
37 vec2 sin(vec2 angle);
38 vec3 sin(vec3 angle);
39 vec4 sin(vec4 angle);
40 float cos(float angle);
41 vec2 cos(vec2 angle);
42 vec3 cos(vec3 angle);
43 vec4 cos(vec4 angle);
44 float tan(float angle);
45 vec2 tan(vec2 angle);
46 vec3 tan(vec3 angle);
47 vec4 tan(vec4 angle);
48 float asin(float x);
49 vec2 asin(vec2 x);
50 vec3 asin(vec3 x);
51 vec4 asin(vec4 x);
52 float acos(float x);
53 vec2 acos(vec2 x);
54 vec3 acos(vec3 x);
55 vec4 acos(vec4 x);
56 float atan(float y, float x);
57 vec2 atan(vec2 y, vec2 x);
58 vec3 atan(vec3 y, vec3 x);
59 vec4 atan(vec4 y, vec4 x);
60 float sinh(float angle);
61 vec2 sinh(vec2 angle);
62 vec3 sinh(vec3 angle);
63 vec4 sinh(vec4 angle);
64 float cosh(float angle);
65 vec2 cosh(vec2 angle);
66 vec3 cosh(vec3 angle);
67 vec4 cosh(vec4 angle);
68 float tanh(float angle);
69 vec2 tanh(vec2 angle);
70 vec3 tanh(vec3 angle);
71 vec4 tanh(vec4 angle);
72 float asinh(float x);
73 vec2 asinh(vec2 x);
74 vec3 asinh(vec3 x);
75 vec4 asinh(vec4 x);
76 float acosh(float x);
77 vec2 acosh(vec2 x);
78 vec3 acosh(vec3 x);
79 vec4 acosh(vec4 x);
80 float atanh(float x);
81 vec2 atanh(vec2 x);
82 vec3 atanh(vec3 x);
83 vec4 atanh(vec4 x);
84 float pow(float x, float y);
85 vec2 pow(vec2 x, vec2 y);
86 vec3 pow(vec3 x, vec3 y);
87 vec4 pow(vec4 x, vec4 y);
88 float exp(float x);
89 vec2 exp(vec2 x);
90 vec3 exp(vec3 x);
91 vec4 exp(vec4 x);
92 float log(float x);
93 vec2 log(vec2 x);
94 vec3 log(vec3 x);
95 vec4 log(vec4 x);
96 float exp2(float x);
97 vec2 exp2(vec2 x);
98 vec3 exp2(vec3 x);
99 vec4 exp2(vec4 x);
100 float log2(float x);
101 vec2 log2(vec2 x);
102 vec3 log2(vec3 x);
103 vec4 log2(vec4 x);
104 float sqrt(float x);
105 vec2 sqrt(vec2 x);
106 vec3 sqrt(vec3 x);
107 vec4 sqrt(vec4 x);
108 float inversesqrt(float x);
109 vec2 inversesqrt(vec2 x);
110 vec3 inversesqrt(vec3 x);
111 vec4 inversesqrt(vec4 x);
112 float abs(float x);
113 vec2 abs(vec2 x);
114 vec3 abs(vec3 x);
115 vec4 abs(vec4 x);
116 int abs(int x);
117 ivec2 abs(ivec2 x);
118 ivec3 abs(ivec3 x);
119 ivec4 abs(ivec4 x);
120 float sign(float x);
121 vec2 sign(vec2 x);
122 vec3 sign(vec3 x);
123 vec4 sign(vec4 x);
124 int sign(int x);
125 ivec2 sign(ivec2 x);
126 ivec3 sign(ivec3 x);
127 ivec4 sign(ivec4 x);
128 float floor(float x);
129 vec2 floor(vec2 x);
130 vec3 floor(vec3 x);
131 vec4 floor(vec4 x);
132 float trunc(float x);
133 vec2 trunc(vec2 x);
134 vec3 trunc(vec3 x);
135 vec4 trunc(vec4 x);
136 float round(float x);
137 vec2 round(vec2 x);
138 vec3 round(vec3 x);
139 vec4 round(vec4 x);
140 float roundEven(float x);
141 vec2 roundEven(vec2 x);
142 vec3 roundEven(vec3 x);
143 vec4 roundEven(vec4 x);
144 float ceil(float x);
145 vec2 ceil(vec2 x);
146 vec3 ceil(vec3 x);
147 vec4 ceil(vec4 x);
148 float fract(float x);
149 vec2 fract(vec2 x);
150 vec3 fract(vec3 x);
151 vec4 fract(vec4 x);
152 float mod(float x, float y);
153 vec2 mod(vec2 x, vec2 y);
154 vec3 mod(vec3 x, vec3 y);
155 vec4 mod(vec4 x, vec4 y);
156 vec2 mod(vec2 x, float y);
157 vec3 mod(vec3 x, float y);
158 vec4 mod(vec4 x, float y);
159 float modf(float x, out float y);
160 vec2 modf(vec2 x, out vec2 y);
161 vec3 modf(vec3 x, out vec3 y);
162 vec4 modf(vec4 x, out vec4 y);
163 float min(float x, float y);
164 vec2 min(vec2 x, vec2 y);
165 vec3 min(vec3 x, vec3 y);
166 vec4 min(vec4 x, vec4 y);
167 int min(int x, int y);
168 ivec2 min(ivec2 x, ivec2 y);
169 ivec3 min(ivec3 x, ivec3 y);
170 ivec4 min(ivec4 x, ivec4 y);
171 vec2 min(vec2 x, float y);
172 vec3 min(vec3 x, float y);
173 vec4 min(vec4 x, float y);
174 ivec2 min(ivec2 x, int y);
175 ivec3 min(ivec3 x, int y);
176 ivec4 min(ivec4 x, int y);
177 float max(float x, float y);
178 vec2 max(vec2 x, vec2 y);
179 vec3 max(vec3 x, vec3 y);
180 vec4 max(vec4 x, vec4 y);
181 int max(int x, int y);
182 ivec2 max(ivec2 x, ivec2 y);
183 ivec3 max(ivec3 x, ivec3 y);
184 ivec4 max(ivec4 x, ivec4 y);
185 vec2 max(vec2 x, float y);
186 vec3 max(vec3 x, float y);
187 vec4 max(vec4 x, float y);
188 ivec2 max(ivec2 x, int y);
189 ivec3 max(ivec3 x, int y);
190 ivec4 max(ivec4 x, int y);
191 float clamp(float x, float minVal, float maxVal);
192 vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
193 vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
194 vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
195 int clamp(int x, int minVal, int maxVal);
196 ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal);
197 ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal);
198 ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal);
199 vec2 clamp(vec2 x, float minVal, float maxVal);
200 vec3 clamp(vec3 x, float minVal, float maxVal);
201 vec4 clamp(vec4 x, float minVal, float maxVal);
202 ivec2 clamp(ivec2 x, int minVal, int maxVal);
203 ivec3 clamp(ivec3 x, int minVal, int maxVal);
204 ivec4 clamp(ivec4 x, int minVal, int maxVal);
205 float mix(float x, float y, float a);
206 vec2 mix(vec2 x, vec2 y, vec2 a);
207 vec3 mix(vec3 x, vec3 y, vec3 a);
208 vec4 mix(vec4 x, vec4 y, vec4 a);
209 vec2 mix(vec2 x, vec2 y, float a);
210 vec3 mix(vec3 x, vec3 y, float a);
211 vec4 mix(vec4 x, vec4 y, float a);
212 float step(float edge, float x);
213 vec2 step(vec2 edge, vec2 x);
214 vec3 step(vec3 edge, vec3 x);
215 vec4 step(vec4 edge, vec4 x);
216 vec2 step(float edge, vec2 x);
217 vec3 step(float edge, vec3 x);
218 vec4 step(float edge, vec4 x);
219 float smoothstep(float edge0, float edge1, float x);
220 vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
221 vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
222 vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
223 vec2 smoothstep(float edge0, float edge1, vec2 x);
224 vec3 smoothstep(float edge0, float edge1, vec3 x);
225 vec4 smoothstep(float edge0, float edge1, vec4 x);
226 float fma(float a, float b, float c);
227 vec2 fma(vec2 a, vec2 b, vec2 c);
228 vec3 fma(vec3 a, vec3 b, vec3 c);
229 vec4 fma(vec4 a, vec4 b, vec4 c);
230 float length(float x);
231 float length(vec2 x);
232 float length(vec3 x);
233 float length(vec4 x);
234 float distance(float p0, float p1);
235 float distance(vec2 p0, vec2 p1);
236 float distance(vec3 p0, vec3 p1);
237 float distance(vec4 p0, vec4 p1);
238 float dot(float x, float y);
239 float dot(vec2 x, vec2 y);
240 float dot(vec3 x, vec3 y);
241 float dot(vec4 x, vec4 y);
242 vec3 cross(vec3 x);
243 float normalize(float x);
244 vec2 normalize(vec2 x);
245 vec3 normalize(vec3 x);
246 vec4 normalize(vec4 x);
247 float faceforward(float N, float I, float Nref);
248 vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
249 vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
250 vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
251 float reflect(float N, float I);
252 vec2 reflect(vec2 N, vec2 I);
253 vec3 reflect(vec3 N, vec3 I);
254 vec4 reflect(vec4 N, vec4 I);
255 float refract(float N, float I, float eta);
256 vec2 refract(vec2 N, vec2 I, float eta);
257 vec3 refract(vec3 N, vec3 I, float eta);
258 vec4 refract(vec4 N, vec4 I, float eta);
259 mat2 matrixCompMult(mat2 x, mat2 y);
260 mat3 matrixCompMult(mat3 x, mat3 y);
261 mat4 matrixCompMult(mat4 x, mat4 y);
262 mat2x3 matrixCompMult(mat2x3 x, mat2x3 y);
263 mat3x2 matrixCompMult(mat3x2 x, mat3x2 y);
264 mat2x4 matrixCompMult(mat2x4 x, mat2x4 y);
265 mat4x2 matrixCompMult(mat4x2 x, mat4x2 y);
266 mat3x4 matrixCompMult(mat3x4 x, mat3x4 y);
267 mat4x3 matrixCompMult(mat4x3 x, mat4x3 y);
268 mat2 transpose(mat2 m);
269 mat3 transpose(mat3 m);
270 mat4 transpose(mat4 m);
271 mat2 determinant(mat2 m);
272 mat3 determinant(mat3 m);
273 mat4 determinant(mat4 m);
274 mat2 inverse(mat2 m);
275 mat3 inverse(mat3 m);
276 mat4 inverse(mat4 m);
277 int textureSize(sampler1D sampler, int lod);
278 ivec2 textureSize(sampler2D sampler, int lod);
279 ivec3 textureSize(sampler3D sampler, int lod);
280 ivec2 textureSize(sampler1DArray sampler, int lod);
281 ivec3 textureSize(sampler2DArray sampler, int lod);
282 ivec2 textureSize(samplerCube sampler, int lod);
283 ivec3 textureSize(samplerCubeArray sampler, int lod);
284 int textureSize(sampler1DShadow sampler, int lod);
285 ivec2 textureSize(sampler2DShadow sampler, int lod);
286 ivec2 textureSize(samplerCubeShadow sampler, int lod);
287 ivec2 textureSize(sampler1DArrayShadow sampler, int lod);
288 ivec3 textureSize(sampler2DArrayShadow sampler, int lod);
289 ivec3 textureSize(samplerCubeArrayShadow sampler, int lod);
290 vec4 texture(sampler1D sampler, float P);
291 vec4 texture(sampler2D sampler, vec2 P);
292 vec4 texture(sampler3D sampler, vec3 P);
293 vec4 texture(sampler1DArray sampler, vec2 P);
294 vec4 texture(sampler2DArray sampler, vec3 P);
295 vec4 texture(samplerCube sampler, vec3 P);
296 vec4 texture(samplerCubeArray sampler, vec4 P);
297 float texture(sampler1DShadow sampler, vec3 P);
298 float texture(sampler2DShadow sampler, vec3 P);
299 float texture(samplerCubeShadow sampler, vec4 P);
300 float texture(sampler1DArrayShadow sampler, vec3 P);
301 float texture(sampler2DArrayShadow sampler, vec4 P);
302 float texture(samplerCubeArrayShadow sampler, vec4 P, float compare);
303 vec4 textureLod(sampler1D sampler, float P);
304 vec4 textureLod(sampler2D sampler, vec2 P);
305 vec4 textureLod(sampler3D sampler, vec3 P);
306 vec4 textureLod(sampler1DArray sampler, vec2 P);
307 vec4 textureLod(sampler2DArray sampler, vec3 P);
308 vec4 textureLod(samplerCube sampler, vec3 P);
309 vec4 textureLod(samplerCubeArray sampler, vec4 P);
310 vec4 texelFetch(sampler1D sampler, int P, int lod);
311 vec4 texelFetch(sampler2D sampler, ivec2 P, int lod);
312 vec4 texelFetch(sampler3D sampler, ivec3 P, int lod);
313 vec4 texelFetch(sampler1DArray sampler, ivec2 P, int lod);
314 vec4 texelFetch(sampler2DArray sampler, ivec3 P, int lod);
315 // END BUILTIN FUNCTIONS
316
317 #pragma MSP stage(vertex)
318 out gl_PerVertex
319 {
320   vec4 gl_Position;
321   float gl_ClipDistance[];
322 };
323
324 #pragma MSP stage(geometry)
325 in gl_PerVertex
326 {
327   vec4 gl_Position;
328   float gl_ClipDistance[];
329 } gl_in[];
330 out gl_PerVertex
331 {
332   vec4 gl_Position;
333   float gl_ClipDistance[];
334 };
335
336 void EmitVertex();
337 void EndPrimitive();