ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/shader.h
(Generate patch)

Comparing libgender/shader.h (file contents):
Revision 1.14 by root, Sun Oct 24 21:16:41 2004 UTC vs.
Revision 1.33 by root, Sun Nov 7 22:07:05 2004 UTC

1#ifndef SHADER_H 1#ifndef SHADER_H
2#define SHADER_H 2#define SHADER_H
3 3
4#include <cassert>
5
6#include <string>
7#include <set>
8#include <map>
4#include <sstream> 9#include <sstream>
5 10
6#include "opengl.h" 11#include "opengl.h"
7#include "util.h" 12#include "util.h"
8 13
9namespace shader { 14namespace shader {
10 15
11 using namespace std; 16 using namespace std;
12 17
13 const int NAMELEN = 32; 18 const int NAMELEN = 32;
19
20 struct shader_builder
21 {
22 static struct shader_builder *cur;
23
24 set<const void *> seen;
25
26 ostringstream global;
27 ostringstream local;
28 ostringstream code;
29
30 bool first (const void *p);
31
32 static void start ();
33 static string stop ();
34 };
14 35
15 template<class T> 36 template<class T>
16 struct sl_expr { 37 struct sl_expr {
17 const T t; 38 const T t;
18 sl_expr (const T &t) : t(t) { } 39 sl_expr (const T &t) : t(t) { }
19 void operator ()() const { t (); } 40 void operator ()() const { t (); }
20 template<typename expr> 41 template<typename expr>
21 const sl_expr &operator =(const expr &e) const; 42 const sl_expr &operator =(const expr &e) const;
22 }; 43 };
23 44
24 template<class A, class B>
25 struct sl_concat2
26 {
27 const A a; const B b;
28 sl_concat2 (const A &a, const B &b) : a(a), b(b) { }
29 void operator ()() const { a (); b (); }
30 };
31
32 template<class A, class B, class C>
33 struct sl_concat3
34 {
35 const A a; const B b; const C c;
36 sl_concat3 (const A &a, const B &b, const C &c) : a(a), b(b), c(c) { }
37 void operator ()() const { a (); b (); c (); }
38 };
39
40 template<class A, class B, class C, class D>
41 struct sl_concat4
42 {
43 const A a; const B b; const C c; const D d;
44 sl_concat4 (const A &a, const B &b, const C &c, const D &d) : a(a), b(b), c(c), d(d) { }
45 void operator ()() const { a (); b (); c (); d(); }
46 };
47
48 struct sl_func0 45 struct sl_func0
49 { 46 {
50 const char *name_par; 47 const char *name_par;
51 sl_func0 (const char *name_par) : name_par(name_par) { } 48 sl_func0 (const char *name_par) : name_par(name_par) { }
49
52 void begin () const; 50 void begin () const
51 {
52 shader_builder::cur->code << name_par;
53 }
54
53 void comma () const; 55 void comma () const
56 {
57 shader_builder::cur->code << ", ";
58 }
59
54 void end () const; 60 void end () const
61 {
62 shader_builder::cur->code << ")";
63 }
64
55 void operator ()() const 65 void operator ()() const
56 { 66 {
57 begin (); 67 begin ();
58 end (); 68 end ();
59 } 69 }
92 }; 102 };
93 103
94 class refcounted 104 class refcounted
95 { 105 {
96 template<class type> friend class ref; 106 template<class type> friend class ref;
97 mutable int refcnt; 107 mutable unsigned int refcnt;
98 void refcnt_inc () const { refcnt++; } 108 void refcnt_inc () const { refcnt++; }
109 void refcnt_dec () const { if (!--refcnt) refcnt_destroy (); }
99 void refcnt_dec () const; 110 void refcnt_destroy () const;
100 public: 111 public:
101 refcounted () : refcnt(0) { } 112 refcounted () : refcnt(0) { }
102 virtual ~refcounted (); 113 virtual ~refcounted ();
103 }; 114 };
104 115
204 extern const char str_sampler_cube []; 215 extern const char str_sampler_cube [];
205 216
206 typedef ref<struct var_i> var; 217 typedef ref<struct var_i> var;
207 typedef ref<struct uniform_i> uniform; 218 typedef ref<struct uniform_i> uniform;
208 219
209 struct shader_builder
210 {
211 vector<uniform> refs; // uniform parameters
212 vector<var> temps; // temporary variables
213 vector<var> streams; // varying inputs & outputs
214
215 ostringstream source;
216
217 template<typename type>
218 shader_builder &operator <<(const type &t)
219 {
220 source << t;
221 return *this;
222 }
223 };
224
225 struct fragment_i : refcounted 220 struct fragment_i : refcounted
226 { 221 {
227 virtual void build (shader_builder &b) = 0;
228 }; 222 };
229 223
230 typedef ref<fragment_i> fragment; 224 typedef ref<fragment_i> fragment;
231 225
232 struct lvalue_i : fragment_i 226 struct lvalue_i : fragment_i
235 229
236 // a simple predeclared variable with unspecified type 230 // a simple predeclared variable with unspecified type
237 struct gluvar_i : lvalue_i 231 struct gluvar_i : lvalue_i
238 { 232 {
239 const char *name; 233 const char *name;
240 void build (shader_builder &b); 234
235 void operator ()() const
236 {
237 shader_builder::cur->code << name;
238 }
239
241 gluvar_i (const char *name) : name (name) { } 240 gluvar_i (const char *name) : name (name) { }
242 }; 241 };
243 242
244 typedef auto_lvalue_ref1<gluvar_i, const char *> gluvar; 243 typedef auto_lvalue_ref1<gluvar_i, const char *> gluvar;
245 244
246 struct var_i : lvalue_i 245 struct var_i : lvalue_i
247 { 246 {
248 static unsigned int next_id; 247 static unsigned int next_id;
249 248
250 char name[NAMELEN]; 249 char name[NAMELEN];
250 const char *domainstr;
251 const char *typestr; 251 const char *typestr;
252 252
253 void build (shader_builder &b); 253 void operator ()() const;
254 virtual void build_decl (ostringstream &b); 254
255 255 var_i (const char *domainstr, const char *typestr);
256 var_i (const char *typestr);
257 ~var_i (); 256 ~var_i ();
258 }; 257 };
259 258
260 struct uniform_i : var_i 259 struct uniform_i : var_i
261 { 260 {
262 bool dirty;
263 GLint location; 261 GLint location ();
264
265 virtual void update () = 0;
266
267 void build (shader_builder &b);
268 void build_decl (ostringstream &b);
269
270 void update_location (GLint program)
271 {
272 location = glGetUniformLocationARB (program, name);
273 }
274 262
275 uniform_i (const char *strtype); 263 uniform_i (const char *strtype);
276 }; 264 };
277 265
278 template<int dimension, typename gltype, const char *strtype, void (*upd)(GLint, GLsizei, const gltype *)> 266 template<int dimension, typename gltype, const char *strtype>
279 struct uniform2_i : uniform_i 267 struct uniform2_i : uniform_i
280 { 268 {
281 gltype data[dimension]; 269 gltype data[dimension];
282 270
283 void update ()
284 {
285 if (dirty)
286 {
287 if (location >= 0)
288 upd (location, dimension, data);
289
290 dirty = false;
291 }
292 }
293
294 uniform2_i () : uniform_i (strtype) { } 271 uniform2_i () : uniform_i (strtype) { }
295 }; 272 };
296 273
297 template<int dimension, const char *strtype, void (*update)(GLint, GLsizei, const GLfloat *)> 274 template<int dimension, const char *strtype>
298 struct uniform_f_i : uniform2_i<dimension, GLfloat, strtype, update> 275 struct uniform_f_i : uniform2_i<dimension, GLfloat, strtype>
299 { 276 {
300 }; 277 };
301 278
302 struct uniform_1f_i : uniform_f_i<1, str_float, glUniform1fvARB> { 279 struct uniform_1f_i : uniform_f_i<1, str_float> {
303 void operator =(GLfloat v) 280 void set (GLfloat v)
304 { 281 {
305 data[0] = v; 282 data[0] = v;
306 dirty = true;
307 }
308 };
309 283
284 GLint loc = location ();
285 if (loc >= 0) // workaround for buggy drivers
286 glUniform1fvARB (loc, 1, data);
287 }
288 };
289
310 struct uniform_2f_i : uniform_f_i<2, str_vec2, glUniform2fvARB> { }; 290 struct uniform_2f_i : uniform_f_i<2, str_vec2> {
311 291 void set (GLfloat x, GLfloat y)
312 struct uniform_3f_i : uniform_f_i<3, str_vec3, glUniform3fvARB> {
313 void operator =(const vec3 &v)
314 { 292 {
315 data[0] = v.x; 293 data[0] = x;
316 data[1] = v.y; 294 data[1] = y;
295
296 GLint loc = location ();
297 if (loc >= 0) // workaround for buggy drivers
298 glUniform2fvARB (loc, 1, data);
299 }
300
301 void set (const vec2 &v) { set (v.x, v.y); }
302 };
303
304 struct uniform_3f_i : uniform_f_i<3, str_vec3> {
305 void set (GLfloat x, GLfloat y, GLfloat z)
306 {
307 data[0] = x;
308 data[1] = y;
317 data[2] = v.z; 309 data[2] = z;
318 dirty = true;
319 }
320 };
321 310
311 GLint loc = location ();
312 if (loc >= 0) // workaround for buggy drivers
313 glUniform3fvARB (loc, 1, data);
314 }
315
316 void set (const vec3 &v) { set (v.x, v.y, v.z); }
317 };
318
322 struct uniform_4f_i : uniform_f_i<4, str_vec4, glUniform4fvARB> { 319 struct uniform_4f_i : uniform_f_i<4, str_vec4> {
323#if 0 320 void set (GLfloat x, GLfloat y, GLfloat z, GLfloat w)
321 {
322 data[0] = x;
323 data[1] = y;
324 data[2] = z;
325 data[3] = w;
326
327 GLint loc = location ();
328 if (loc >= 0) // workaround for buggy drivers
329 glUniform4fvARB (loc, 1, data);
330 }
331
332 void set (const vec4 &v) { set (v.x, v.y, v.z, v.w); }
333 };
334
335 struct uniform_matrix_2f_i : uniform_f_i< 4, str_mat2>
336 {
337 void set (const GLfloat d[4])
338 {
339 memcpy (data, d, 4 * sizeof (GLfloat));
340
341 GLint loc = location ();
342 if (loc >= 0) // workaround for buggy drivers
343 glUniformMatrix2fvARB (loc, 1, 0, data);
344 }
345 };
346
347 struct uniform_matrix_3f_i : uniform_f_i< 9, str_mat3>
348 {
349 void set (const GLfloat d[9])
350 {
351 memcpy (data, d, 9 * sizeof (GLfloat));
352
353 GLint loc = location ();
354 if (loc >= 0) // workaround for buggy drivers
355 glUniformMatrix3fvARB (loc, 1, 0, data);
356 }
357 };
358
359 struct uniform_matrix_4f_i : uniform_f_i<16, str_mat4>
360 {
324 void operator =(const gl::matrix &m) 361 void set (const gl::matrix &m)
325 { 362 {
326 memcpy (data, m.data, 16 * sizeof (GLfloat)); 363 memcpy (data, m.data, 16 * sizeof (GLfloat));
327 dirty = true;
328 }
329#endif
330 };
331 364
332 inline void UniformMatrix2fv (GLint l, GLsizei s, const GLfloat *m) { glUniformMatrix2fvARB (l, s, 0, m); } 365 GLint loc = location ();
333 inline void UniformMatrix3fv (GLint l, GLsizei s, const GLfloat *m) { glUniformMatrix3fvARB (l, s, 0, m); } 366 if (loc >= 0) // workaround for buggy drivers
334 inline void UniformMatrix4fv (GLint l, GLsizei s, const GLfloat *m) { glUniformMatrix4fvARB (l, s, 0, m); } 367 glUniformMatrix4fvARB (loc, 1, 0, data);
335 368 }
336 struct uniform_matrix_2f_i : uniform_f_i< 4, str_mat2, UniformMatrix2fv> { }; 369 };
337 struct uniform_matrix_3f_i : uniform_f_i< 9, str_mat3, UniformMatrix3fv> { };
338 struct uniform_matrix_4f_i : uniform_f_i<16, str_mat4, UniformMatrix4fv> { };
339 370
340 template<class var_i> 371 template<class var_i>
341 struct var_ref : ref<var_i> 372 struct var_ref : ref<var_i>
342 { 373 {
343 var_ref (const char *glname = 0) 374 var_ref (const char *glname = 0)
354 typedef var_ref<uniform_4f_i> uniform_4f; 385 typedef var_ref<uniform_4f_i> uniform_4f;
355 typedef var_ref<uniform_matrix_2f_i> uniform_matrix_2f; 386 typedef var_ref<uniform_matrix_2f_i> uniform_matrix_2f;
356 typedef var_ref<uniform_matrix_3f_i> uniform_matrix_3f; 387 typedef var_ref<uniform_matrix_3f_i> uniform_matrix_3f;
357 typedef var_ref<uniform_matrix_4f_i> uniform_matrix_4f; 388 typedef var_ref<uniform_matrix_4f_i> uniform_matrix_4f;
358 389
390#if 0
391 // to be used for attributes
392
359 struct stream_i : var_i 393 struct stream_i : var_i
360 { 394 {
361 void build (shader_builder &b);
362 void build_decl (ostringstream &b);
363 stream_i (const char *strtype); 395 stream_i (const char *strtype);
364 }; 396 };
365 397
366 template<int dimension, GLenum gltype, const char *strtype> 398 template<int dimension, GLenum gltype, const char *strtype>
367 struct varying_i : stream_i 399 struct varying_i : stream_i
375 }; 407 };
376 408
377 template<int dimension, const char *strtype> 409 template<int dimension, const char *strtype>
378 struct varying_f_i : varying_i<dimension, GL_FLOAT, strtype> 410 struct varying_f_i : varying_i<dimension, GL_FLOAT, strtype>
379 { 411 {
380 void set (const gl::vertex_buffer_object &vb, GLint offset) 412 void set (const gl::vertex_buffer &vb, GLint offset)
381 { 413 {
382 varying_i<dimension, GL_FLOAT, strtype>::set (gl::format_stride (vb.format), (GLvoid *)(long)offset); 414 varying_i<dimension, GL_FLOAT, strtype>::set (gl::format_stride (vb.format), (GLvoid *)(long)offset);
383 } 415 }
384 }; 416 };
385 417
387 { 419 {
388 }; 420 };
389 421
390 struct varying_2f_i : varying_f_i<2, str_vec2> 422 struct varying_2f_i : varying_f_i<2, str_vec2>
391 { 423 {
392 void set_t (const gl::vertex_buffer_object &vb) 424 void set_t (const gl::vertex_buffer &vb)
393 { 425 {
394 set (vb, gl::format_offset_t (vb.format)); 426 set (vb, gl::format_offset_t (vb.format));
395 } 427 }
396 }; 428 };
397 429
398 struct varying_3f_i : varying_f_i<3, str_vec3> 430 struct varying_3f_i : varying_f_i<3, str_vec3>
399 { 431 {
400 void set_p (const gl::vertex_buffer_object &vb) 432 void set_p (const gl::vertex_buffer &vb)
401 { 433 {
402 set (vb, gl::format_offset_p (vb.format)); 434 set (vb, gl::format_offset_p (vb.format));
403 } 435 }
404 436
405 void set_n (const gl::vertex_buffer_object &vb) 437 void set_n (const gl::vertex_buffer &vb)
406 { 438 {
407 set (vb, gl::format_offset_n (vb.format)); 439 set (vb, gl::format_offset_n (vb.format));
408 } 440 }
409 }; 441 };
410 442
414 446
415 typedef var_ref<varying_1f_i> varying_1f; 447 typedef var_ref<varying_1f_i> varying_1f;
416 typedef var_ref<varying_2f_i> varying_2f; 448 typedef var_ref<varying_2f_i> varying_2f;
417 typedef var_ref<varying_3f_i> varying_3f; 449 typedef var_ref<varying_3f_i> varying_3f;
418 typedef var_ref<varying_4f_i> varying_4f; 450 typedef var_ref<varying_4f_i> varying_4f;
451#endif
452
453 struct varying_i : var_i
454 {
455 varying_i (const char *strtype);
456 };
419 457
420 struct temporary_i : var_i 458 struct temporary_i : var_i
421 { 459 {
422 void build (shader_builder &b);
423
424 temporary_i (const char *strtype); 460 temporary_i (const char *strtype);
425 }; 461 };
426 462
427 template<const char *strtype> 463 template<const char *strtype, class var_i>
428 struct temp_ref : ref<temporary_i> 464 struct glnvar_ref : ref<var_i>
429 { 465 {
430 temp_ref () 466 glnvar_ref ()
431 : ref<temporary_i> (*new temporary_i (strtype)) 467 : ref<var_i> (*new var_i (strtype))
432 { 468 {
433 } 469 }
434 470
435#if 0 471#if 0
436 template<typename expr> 472 template<typename expr>
437 temp_ref (const expr &e) 473 glnvar_ref (const sl_expr<expr> &e)
438 : ref<temporary_i> (*new temporary_i (strtype)) 474 : ref<var_i> (*new var_i (strtype))
439 { 475 {
440 (*this) = e; 476 (*this) = e;
441 } 477 }
442#endif 478#endif
443 479
444 template<typename expr> 480 template<typename expr>
445 const temp_ref &operator =(const expr &e) const; 481 const glnvar_ref &operator =(const expr &e) const;
446 }; 482 };
447 483
448 typedef temp_ref<str_float> temp_1f; 484 typedef glnvar_ref<str_float, temporary_i> temp_1f;
449 typedef temp_ref<str_vec2> temp_2f; 485 typedef glnvar_ref<str_vec2, temporary_i> temp_2f;
450 typedef temp_ref<str_vec3> temp_3f; 486 typedef glnvar_ref<str_vec3, temporary_i> temp_3f;
451 typedef temp_ref<str_vec4> temp_4f; 487 typedef glnvar_ref<str_vec4, temporary_i> temp_4f;
452 typedef temp_ref<str_mat2> temp_matrix_2f; 488 typedef glnvar_ref<str_mat2, temporary_i> temp_matrix_2f;
453 typedef temp_ref<str_mat3> temp_matrix_3f; 489 typedef glnvar_ref<str_mat3, temporary_i> temp_matrix_3f;
454 typedef temp_ref<str_mat4> temp_matrix_4f; 490 typedef glnvar_ref<str_mat4, temporary_i> temp_matrix_4f;
491
492 typedef glnvar_ref<str_float, varying_i> varying_1f;
493 typedef glnvar_ref<str_vec2, varying_i> varying_2f;
494 typedef glnvar_ref<str_vec3, varying_i> varying_3f;
495 typedef glnvar_ref<str_vec4, varying_i> varying_4f;
496 typedef glnvar_ref<str_mat2, varying_i> varying_matrix_2f;
497 typedef glnvar_ref<str_mat3, varying_i> varying_matrix_3f;
498 typedef glnvar_ref<str_mat4, varying_i> varying_matrix_4f;
499
500 struct texture_units
501 {
502 static int units[8];
503 static int unit_count;
504
505 static GLenum get_texture_unit ()
506 {
507 assert (unit_count);
508 return units[--unit_count];
509 }
510
511 static void put_texture_unit (GLenum unit)
512 {
513 assert (unit_count < 8);
514 units[unit_count++] = unit;
515 }
516 };
455 517
456 template<GLenum gltype, const char *strtype> 518 template<GLenum gltype, const char *strtype>
457 struct sampler_i : uniform_i 519 struct sampler_i : uniform_i, texture_units
458 { 520 {
459 GLuint unit; 521 int unit;
522 GLuint name;
460 523
461 void update () 524 void enable ()
462 { 525 {
463 if (dirty) 526#if DEBUG
527 assert (unit < 0);
528#endif
529 GLint loc = location ();
530
531 if (loc >= 0)
464 { 532 {
465 //cgGLSetTextureParameter (param, texture); 533 unit = get_texture_unit ();
466 dirty = false; 534 glActiveTexture (GL_TEXTURE0 + unit);
535 glBindTexture (gltype, name);
536 glUniform1iARB (loc, unit);
467 } 537 }
468 } 538 }
469 539
470 void begin () 540 void disable ()
471 {
472 cgGLEnableTextureParameter (unit);
473 } 541 {
542 if (unit >= 0)
543 {
544 put_texture_unit (unit);
545 unit = -1;
546 }
547 }
474 548
475 sampler_i (GLuint textureunit) : uniform_i (strtype), unit (textureunit) { } 549 template<class bufferclass, class vectype>
476 }; 550 void set (const gl::vertex_buffer &vb, const vectype bufferclass::*vp)
551 {
552 glTexCoordPointer (
553 vector_traits<vectype>::dimension (),
554 gl::type_traits<typename vector_traits<vectype>::basetype>::glenum (),
555 sizeof (bufferclass),
556 (GLvoid)(char bufferclass::*)vp
557 );
558 }
477 559
560 sampler_i (GLuint texture)
561 : uniform_i (strtype)
562 , name (texture)
563#if DEBUG
564 , unit (-1)
565#endif
566 {
567 }
568 };
569
478 struct sampler_1d_i : sampler_i<CG_SAMPLER1D, str_sampler_1d> 570 struct sampler_1d_i : sampler_i<GL_TEXTURE_1D, str_sampler_1d>
479 { 571 {
480 sampler_1d_i (GLuint textureunit) : sampler_i<CG_SAMPLER1D, str_sampler_1d> (textureunit) { } 572 sampler_1d_i (GLuint texture) : sampler_i<GL_TEXTURE_1D, str_sampler_1d> (texture) { }
481 }; 573 };
482 574
483 struct sampler_1d_shadow_i : sampler_i<CG_SAMPLER1D, str_sampler_1d_shadow> 575 struct sampler_1d_shadow_i : sampler_i<GL_TEXTURE_1D, str_sampler_1d_shadow>
484 { 576 {
485 sampler_1d_shadow_i (GLuint textureunit) : sampler_i<CG_SAMPLER1D, str_sampler_1d_shadow> (textureunit) { } 577 sampler_1d_shadow_i (GLuint texture) : sampler_i<GL_TEXTURE_1D, str_sampler_1d_shadow> (texture) { }
486 }; 578 };
487 579
488 struct sampler_2d_i : sampler_i<CG_SAMPLER2D, str_sampler_2d> 580 struct sampler_2d_i : sampler_i<GL_TEXTURE_2D, str_sampler_2d>
489 { 581 {
490 sampler_2d_i (GLuint textureunit) : sampler_i<CG_SAMPLER2D, str_sampler_2d> (textureunit) { } 582 sampler_2d_i (GLuint texture) : sampler_i<GL_TEXTURE_2D, str_sampler_2d> (texture) { }
491 }; 583 };
492 584
493 struct sampler_2d_shadow_i : sampler_i<CG_SAMPLER2D, str_sampler_2d_shadow> 585 struct sampler_2d_shadow_i : sampler_i<GL_TEXTURE_2D, str_sampler_2d_shadow>
494 { 586 {
495 sampler_2d_shadow_i (GLuint textureunit) : sampler_i<CG_SAMPLER2D, str_sampler_2d_shadow> (textureunit) { } 587 sampler_2d_shadow_i (GLuint texture) : sampler_i<GL_TEXTURE_2D, str_sampler_2d_shadow> (texture) { }
496 }; 588 };
497 589
498 struct sampler_2d_rect_i : sampler_i<CG_SAMPLERRECT, str_sampler_2d_rect> 590 struct sampler_2d_rect_i : sampler_i<GL_TEXTURE_2D, str_sampler_2d_rect>
499 { 591 {
500 sampler_2d_rect_i (GLuint textureunit) : sampler_i<CG_SAMPLERRECT, str_sampler_2d_rect> (textureunit) { } 592 sampler_2d_rect_i (GLuint texture) : sampler_i<GL_TEXTURE_2D, str_sampler_2d_rect> (texture) { }
501 }; 593 };
502 594
503 struct sampler_2d_rect_shadow_i : sampler_i<CG_SAMPLERRECT, str_sampler_2d_rect_shadow> 595 struct sampler_2d_rect_shadow_i : sampler_i<GL_TEXTURE_2D, str_sampler_2d_rect_shadow>
504 { 596 {
505 sampler_2d_rect_shadow_i (GLuint textureunit) : sampler_i<CG_SAMPLERRECT, str_sampler_2d_rect_shadow> (textureunit) { } 597 sampler_2d_rect_shadow_i (GLuint texture) : sampler_i<GL_TEXTURE_2D, str_sampler_2d_rect_shadow> (texture) { }
506 }; 598 };
507 599
508 struct sampler_3d_i : sampler_i<CG_SAMPLER3D, str_sampler_3d> 600 struct sampler_3d_i : sampler_i<GL_TEXTURE_3D, str_sampler_3d>
509 { 601 {
510 sampler_3d_i (GLuint textureunit) : sampler_i<CG_SAMPLER3D, str_sampler_3d> (textureunit) { } 602 sampler_3d_i (GLuint texture) : sampler_i<GL_TEXTURE_3D, str_sampler_3d> (texture) { }
511 }; 603 };
512 604
513 struct sampler_3d_rect_i : sampler_i<CG_SAMPLER3D, str_sampler_3d_rect> 605 struct sampler_3d_rect_i : sampler_i<GL_TEXTURE_3D, str_sampler_3d_rect>
514 { 606 {
515 sampler_3d_rect_i (GLuint textureunit) : sampler_i<CG_SAMPLER3D, str_sampler_3d_rect> (textureunit) { } 607 sampler_3d_rect_i (GLuint texture) : sampler_i<GL_TEXTURE_3D, str_sampler_3d_rect> (texture) { }
516 }; 608 };
517 609
518 struct sampler_cube_i : sampler_i<CG_SAMPLERCUBE, str_sampler_cube> 610 struct sampler_cube_i : sampler_i<GL_TEXTURE_CUBE_MAP, str_sampler_cube>
519 { 611 {
520 sampler_cube_i (GLuint textureunit) : sampler_i<CG_SAMPLERCUBE, str_sampler_cube> (textureunit) { } 612 sampler_cube_i (GLuint texture) : sampler_i<GL_TEXTURE_CUBE_MAP, str_sampler_cube> (texture) { }
521 }; 613 };
522 614
615 template<class sampler_i>
616 struct sampler_ref : auto_ref1<sampler_i, GLuint>
617 {
618 sampler_ref (GLuint texture)
619 : auto_ref1<sampler_i, GLuint> (texture)
620 {
621 }
622 };
623
523 typedef auto_ref1<sampler_1d_i, GLuint> sampler_1d; 624 typedef sampler_ref<sampler_1d_i> sampler_1d;
524 typedef auto_ref1<sampler_1d_shadow_i, GLuint> sampler_1d_shadow; 625 typedef sampler_ref<sampler_1d_shadow_i> sampler_1d_shadow;
525 typedef auto_ref1<sampler_2d_i, GLuint> sampler_2d; 626 typedef sampler_ref<sampler_2d_i> sampler_2d;
526 typedef auto_ref1<sampler_2d_shadow_i, GLuint> sampler_2d_shadow; 627 typedef sampler_ref<sampler_2d_shadow_i> sampler_2d_shadow;
527 typedef auto_ref1<sampler_2d_rect_i, GLuint> sampler_2d_rect; 628 typedef sampler_ref<sampler_2d_rect_i> sampler_2d_rect;
528 typedef auto_ref1<sampler_2d_rect_shadow_i, GLuint> sampler_2d_rect_shadow; 629 typedef sampler_ref<sampler_2d_rect_shadow_i> sampler_2d_rect_shadow;
529 typedef auto_ref1<sampler_3d_i, GLuint> sampler_3d; 630 typedef sampler_ref<sampler_3d_i> sampler_3d;
530 typedef auto_ref1<sampler_3d_rect_i, GLuint> sampler_3d_rect; 631 typedef sampler_ref<sampler_3d_rect_i> sampler_3d_rect;
531 typedef auto_ref1<sampler_cube_i, GLuint> sampler_cube; 632 typedef sampler_ref<sampler_cube_i> sampler_cube;
532 633
533 struct fragment_const_string_i : fragment_i
534 {
535 const char *str;
536
537 void build (shader_builder &b);
538
539 fragment_const_string_i (const char *str) : str(str) { }
540 };
541
542 typedef auto_ref1<fragment_const_string_i, const char *> fragment_const_string;
543
544 struct fragment_string_i : fragment_i
545 {
546 char *str;
547
548 void build (shader_builder &b);
549
550 fragment_string_i (const char *str) : str (strdup (str)) { }
551 ~fragment_string_i ();
552 };
553
554 struct fragment_vector_i : fragment_i, vector<fragment>
555 {
556 void build (shader_builder &b);
557
558 template<class fragment_i>
559 void append (const ref<fragment_i> &f)
560 {
561 push_back (f);
562 }
563
564 template<class expr>
565 void append (const sl_expr<expr> &e)
566 {
567 e ();
568 }
569
570 void append_const (const char *s)
571 {
572 push_back (*new fragment_const_string_i (s));
573 }
574
575 void append_string (const char *s)
576 {
577 push_back (*new fragment_string_i (s));
578 }
579 };
580
581 typedef ref<fragment_vector_i> fragment_vector;
582
583 struct shader_object_i : fragment_vector_i 634 struct shader_object_i : refcounted
584 { 635 {
585 GLenum type; 636 GLenum type;
586 GLuint id; // GLhandleARB, but 2.0 will use uint 637 GLuint id; // GLhandleARB, but 2.0 will use uint
587 638
588 string source (); 639 void compile (const string &source);
589 void compile ();
590 void start ();
591 void stop ();
592 640
593 shader_object_i (GLenum type); 641 shader_object_i (GLenum type);
594 ~shader_object_i (); 642 ~shader_object_i ();
595 }; 643 };
596 644
597 extern shader_object_i *cur; // record actions to this shader
598
599 template<GLenum type> 645 template<GLenum type>
600 struct shader_object : ref<shader_object_i> 646 struct shader_object : ref<shader_object_i>
601 { 647 {
602 shader_object () 648 shader_object ()
603 : ref<shader_object_i> (*new shader_object_i (type)) 649 : ref<shader_object_i> (*new shader_object_i (type))
606 }; 652 };
607 653
608 typedef shader_object<GL_VERTEX_SHADER_ARB> vertex_shader; 654 typedef shader_object<GL_VERTEX_SHADER_ARB> vertex_shader;
609 typedef shader_object<GL_FRAGMENT_SHADER_ARB> fragment_shader; 655 typedef shader_object<GL_FRAGMENT_SHADER_ARB> fragment_shader;
610 656
611 struct program_object 657 struct program_object_i : refcounted
612 { 658 {
659 static struct program_object_i *cur; // currently bound program
660
613 GLuint id; 661 GLuint id;
614 662
615 vertex_shader vsh; 663 map<uniform_i *,GLint> uloc; // uniform location
616 fragment_shader fsh;
617 664
618 program_object (); 665 program_object_i ();
619 ~program_object (); 666 ~program_object_i ();
667
668 void attach (const ref<shader_object_i> &shader)
669 {
670 glAttachObjectARB (id, shader->id);
671 }
620 672
621 void link (); 673 void link ();
622 };
623 674
624 template<typename T> 675 void enable ();
625 struct sl_append 676 void disable ();
626 {
627 T t;
628
629 sl_append (const T &t) : t(t) { }
630
631 void operator ()() const
632 {
633 cur->push_back (t);
634 }
635 }; 677 };
678
679 typedef auto_ref0<program_object_i> program_object;
680
681 // create a new program or return a cached one
682 program_object get_program (const string &vsh, const string &fsh);
636 683
637 template<int length> 684 template<int length>
638 struct sl_string 685 struct sl_string
639 { 686 {
640 char str[length]; 687 char str[length];
641 688
642 void operator ()() const 689 void operator ()() const
643 { 690 {
644 cur->push_back (*new fragment_string_i (str)); 691 shader_builder::cur->code << str;
645 } 692 }
646 }; 693 };
647 694
648 struct sl_float 695 struct sl_float
649 { 696 {
650 const GLfloat c; 697 const GLfloat c;
651 698
652 sl_float (GLfloat c) : c(c) { } 699 sl_float (GLfloat c) : c(c) { }
653 700
654 void operator ()() const; 701 void operator ()() const
655 };
656
657 template<class A, class B>
658 inline sl_expr< sl_concat2<A, B> >
659 concat (const A &a, const B &b)
660 { 702 {
661 typedef sl_concat2<A, B> expr; 703 shader_builder::cur->code << c;
662 return sl_expr<expr> (expr (a, b)); 704 }
663 } 705 };
664
665 template<class A, class B, class C>
666 inline sl_expr< sl_concat3<A, B, C> >
667 concat (const A &a, const B &b, const C &c)
668 {
669 typedef sl_concat3<A, B, C> expr;
670 return sl_expr<expr> (expr (a, b, c));
671 }
672
673 template<class A, class B, class C, class D>
674 inline sl_expr< sl_concat4<A, B, C, D> >
675 concat (const A &a, const B &b, const C &c, const D &d)
676 {
677 typedef sl_concat4<A, B, C, D> expr;
678 return sl_expr<expr> (expr (a, b, c, d));
679 }
680 706
681 template<typename expr> 707 template<typename expr>
682 struct sl_convert 708 struct sl_convert
683 { 709 {
684 typedef sl_expr<expr> T; 710 typedef sl_expr<expr> T;
719 }; 745 };
720 746
721 template<> 747 template<>
722 struct sl_convert<vec2> 748 struct sl_convert<vec2>
723 { 749 {
724 typedef sl_expr< sl_string<60> > T;
725 static const T convert (const vec2 &v); 750 static const sl_expr< sl_string<60> > convert (const vec2 &v);
726 }; 751 };
727 752
728 template<> 753 template<>
729 struct sl_convert<vec3> 754 struct sl_convert<vec3>
730 { 755 {
731 typedef sl_expr< sl_string<80> > T;
732 static const T convert (const vec3 &v); 756 static const sl_expr< sl_string<80> > convert (const vec3 &v);
733 }; 757 };
734 758
735 template<> 759 template<>
736 struct sl_convert<vec4> 760 struct sl_convert<vec4>
737 { 761 {
738 typedef sl_expr< sl_string<100> > T;
739 static const T convert (const vec4 &v); 762 static const sl_expr< sl_string<100> > convert (const vec4 &v);
763 };
764
765 template<class ref>
766 struct sl_ref
767 {
768 ref r;
769 sl_ref (const ref &r) : r(r) { }
770 void operator ()() const { r->operator ()(); }
740 }; 771 };
741 772
742 template<> 773 template<>
743 template<class V> 774 template<class var_i>
744 struct sl_convert< var_ref<V> > 775 struct sl_convert< var_ref<var_i> >
745 { 776 {
746 typedef sl_expr< sl_append< var_ref<V> > > T; 777 typedef sl_expr< sl_ref< var_ref<var_i> > > T;
747 static inline const T convert (const var_ref<V> &v) 778 static inline const T convert (const var_ref<var_i> &v)
748 { 779 {
749 return sl_append< var_ref<V> > (v); 780 return T (v);
750 } 781 }
751 }; 782 };
752 783
753 template<> 784 template<>
754 struct sl_convert<gluvar> 785 template<class gluvar_i>
755 { 786 struct sl_convert< auto_lvalue_ref1<gluvar_i, const char *> >
756 typedef sl_expr< sl_append<gluvar> > T;
757 static inline const T convert (const gluvar &v)
758 { 787 {
759 return sl_append<gluvar> (v); 788 typedef sl_expr< sl_ref< auto_lvalue_ref1<gluvar_i, const char *> > > T;
789 static inline const T convert (const auto_lvalue_ref1<gluvar_i, const char *> &v)
790 {
791 return T (v);
760 } 792 }
761 }; 793 };
762 794
763 template<> 795 template<>
764 template<const char *strtype> 796 template<const char *strtype, class var_i>
765 struct sl_convert< temp_ref<strtype> > 797 struct sl_convert< glnvar_ref<strtype, var_i> >
766 { 798 {
767 typedef sl_expr< sl_append< temp_ref<strtype> > > T; 799 typedef sl_expr< sl_ref< glnvar_ref<strtype, var_i> > > T;
768 static inline const T convert (const temp_ref<strtype> &v) 800 static inline const T convert (const glnvar_ref<strtype, var_i> &v)
769 {
770 return sl_expr< sl_append< temp_ref<strtype> > >(
771 sl_append< temp_ref<strtype> > (v)
772 );
773 } 801 {
802 return T (v);
803 }
774 }; 804 };
775 805
776 extern const fragment_const_string str_2sp; 806 template<>
777 extern const fragment_const_string str_equal; 807 template<class sampler_i>
778 extern const fragment_const_string str_comma; 808 struct sl_convert< sampler_ref<sampler_i> >
779 extern const fragment_const_string str_endl; 809 {
810 typedef sl_expr< sl_ref< sampler_ref<sampler_i> > > T;
811 static inline const T convert (const sampler_ref<sampler_i> &v)
812 {
813 return T (v);
814 }
815 };
780 816
781 template<class fragment, typename expr> 817 template<class lvalue, typename expr>
782 inline void sl_assign (const fragment &f, const expr &e) 818 inline void sl_assign (const lvalue &l, const expr &e)
783 { 819 {
784 cur->append (str_2sp); 820 shader_builder::cur->code << " ";
785 cur->append (f); 821 sl_convert<lvalue>::convert (l) ();
786 cur->append (str_equal); 822 shader_builder::cur->code << " = ";
787 sl_convert<expr>::convert (e) (); 823 sl_convert<expr>::convert (e) ();
788 cur->append (str_endl); 824 shader_builder::cur->code << ";\n";
789 } 825 }
790 826
791 template<class type> 827 template<class type>
792 template<typename expr> 828 template<typename expr>
793 inline const auto_lvalue_ref0<type> &auto_lvalue_ref0<type>::operator =(const expr &e) const 829 inline const auto_lvalue_ref0<type> &auto_lvalue_ref0<type>::operator =(const expr &e) const
810 { 846 {
811 sl_assign (*this, e); 847 sl_assign (*this, e);
812 return *this; 848 return *this;
813 } 849 }
814 850
815 template<const char *strtype> 851 template<const char *strtype, class var_i>
816 template<typename expr> 852 template<typename expr>
817 inline const temp_ref<strtype> &temp_ref<strtype>::operator =(const expr &e) const 853 inline const glnvar_ref<strtype, var_i> &glnvar_ref<strtype, var_i>::operator =(const expr &e) const
818 { 854 {
819 sl_assign (*this, e); 855 sl_assign (*this, e);
820 return *this; 856 return *this;
821 } 857 }
822 858
823 struct sl_append_const_string 859 namespace compile {
824 { 860 using namespace shader;
825 fragment_const_string str; 861
826 sl_append_const_string (const char *s) 862 template<typename T>
827 : str (s) 863 inline const sl_expr< sl_func1<typename sl_convert<T>::T> >
864 operator +(const T &t)
828 { } 865 {
866 return sl_func1<typename sl_convert<T>::T> ("+(", sl_convert<T>::convert (t));
867 }
829 868
869 template<typename T>
870 inline const sl_expr< sl_func1<typename sl_convert<T>::T> >
871 operator -(const T &t)
872 {
873 return sl_func1<typename sl_convert<T>::T> ("-(", sl_convert<T>::convert (t));
874 }
875
876 template<class A, class C>
877 struct sl_binop
878 {
879 const A a; const char *b; const C c;
880 sl_binop (const A &a, const char *b, const C &c) : a(a), b(b), c(c) { }
830 void operator ()() const 881 void operator ()() const
831 { 882 {
832 cur->push_back (str); 883 shader_builder::cur->code << "(";
884 a ();
885 shader_builder::cur->code << b;
886 c ();
887 shader_builder::cur->code << ")";
888 }
833 } 889 };
834 };
835 890
836 extern const sl_append_const_string str_lpar;
837 extern const sl_append_const_string str_rpar;
838
839 template<class A, class B, class C>
840 struct sl_binop
841 {
842 const A a; const B b; const C c;
843 sl_binop (const A &a, const B &b, const C &c) : a(a), b(b), c(c) { }
844 void operator ()() const { str_lpar (); a (); b (); c (); str_rpar (); }
845 };
846
847# define SHADER_BINOP(op, str) \ 891# define SHADER_BINOP(op) \
848 extern const sl_append_const_string str_ ## str; \
849 template<typename A, typename B> \ 892 template<typename A, typename B> \
850 inline const sl_expr< sl_binop< typename sl_convert<A>::T, \ 893 inline const sl_expr< sl_binop< typename sl_convert<A>::T, \
851 sl_append_const_string, \
852 typename sl_convert<B>::T > > \ 894 typename sl_convert<B>::T > > \
853 operator op(const A &a, const B &b) \ 895 operator op(const A &a, const B &b) \
854 { \ 896 { \
855 return sl_binop< typename sl_convert<A>::T, sl_append_const_string, typename sl_convert<B>::T > \ 897 return sl_binop< typename sl_convert<A>::T, typename sl_convert<B>::T > \
856 (sl_convert<A>::convert (a), str_ ## str, sl_convert<B>::convert (b)); \ 898 (sl_convert<A>::convert (a), " " # op " ", sl_convert<B>::convert (b)); \
857 } 899 }
858 900
859 SHADER_BINOP (+, plus); 901 SHADER_BINOP (+);
860 SHADER_BINOP (-, minus); 902 SHADER_BINOP (-);
861 SHADER_BINOP (*, mul); 903 SHADER_BINOP (*);
862 SHADER_BINOP (/, div); 904 SHADER_BINOP (/);
863 SHADER_BINOP (%, mod); 905 SHADER_BINOP (%);
864 906
907 SHADER_BINOP (<);
908 SHADER_BINOP (<=);
909 SHADER_BINOP (==);
910 SHADER_BINOP (!=);
911 SHADER_BINOP (>=);
912 SHADER_BINOP (>);
913
865# undef SHADER_BINOP 914# undef SHADER_BINOP
866 915
867 void swizzle_mask (sl_string<7> &s, int mask); 916 template<class A>
917 struct sl_swizzle
918 {
919 const A a;
920 const char *swizzle;
921 sl_swizzle (const A &a, const char *swizzle) : a(a), swizzle(swizzle) { }
922 void operator ()() const
923 {
924 shader_builder::cur->code << "(";
925 a ();
926 shader_builder::cur->code << ")." << swizzle;
927 }
928 };
868 929
930# define SHADER_SWIZZLE_OP(type) \
869 template<typename T> 931 template<typename T> \
870 inline const sl_expr< sl_concat3< sl_append_const_string, 932 inline const sl_expr< sl_swizzle<typename sl_convert<T>::T> > \
871 typename sl_convert<T>::T, 933 type (const T &t) \
872 sl_string<7> 934 { \
873 > > 935 return sl_swizzle<typename sl_convert<T>::T> (sl_convert<T>::convert (t), #type); \
874 swizzle (const T &t, int a, int b = 0, int c = 0, int d = 0) 936 }
937
938 // brute force is lovely, ain't it?
939 SHADER_SWIZZLE_OP (x ) SHADER_SWIZZLE_OP (xx ) SHADER_SWIZZLE_OP (xxx ) SHADER_SWIZZLE_OP (xxxx)
940 SHADER_SWIZZLE_OP (xxxy) SHADER_SWIZZLE_OP (xxxz) SHADER_SWIZZLE_OP (xxxw) SHADER_SWIZZLE_OP (xxy )
941 SHADER_SWIZZLE_OP (xxyx) SHADER_SWIZZLE_OP (xxyy) SHADER_SWIZZLE_OP (xxyz) SHADER_SWIZZLE_OP (xxyw)
942 SHADER_SWIZZLE_OP (xxz ) SHADER_SWIZZLE_OP (xxzx) SHADER_SWIZZLE_OP (xxzy) SHADER_SWIZZLE_OP (xxzz)
943 SHADER_SWIZZLE_OP (xxzw) SHADER_SWIZZLE_OP (xxw ) SHADER_SWIZZLE_OP (xxwx) SHADER_SWIZZLE_OP (xxwy)
944 SHADER_SWIZZLE_OP (xxwz) SHADER_SWIZZLE_OP (xxww) SHADER_SWIZZLE_OP (xy ) SHADER_SWIZZLE_OP (xyx )
945 SHADER_SWIZZLE_OP (xyxx) SHADER_SWIZZLE_OP (xyxy) SHADER_SWIZZLE_OP (xyxz) SHADER_SWIZZLE_OP (xyxw)
946 SHADER_SWIZZLE_OP (xyy ) SHADER_SWIZZLE_OP (xyyx) SHADER_SWIZZLE_OP (xyyy) SHADER_SWIZZLE_OP (xyyz)
947 SHADER_SWIZZLE_OP (xyyw) SHADER_SWIZZLE_OP (xyz ) SHADER_SWIZZLE_OP (xyzx) SHADER_SWIZZLE_OP (xyzy)
948 SHADER_SWIZZLE_OP (xyzz) SHADER_SWIZZLE_OP (xyzw) SHADER_SWIZZLE_OP (xyw ) SHADER_SWIZZLE_OP (xywx)
949 SHADER_SWIZZLE_OP (xywy) SHADER_SWIZZLE_OP (xywz) SHADER_SWIZZLE_OP (xyww) SHADER_SWIZZLE_OP (xz )
950 SHADER_SWIZZLE_OP (xzx ) SHADER_SWIZZLE_OP (xzxx) SHADER_SWIZZLE_OP (xzxy) SHADER_SWIZZLE_OP (xzxz)
951 SHADER_SWIZZLE_OP (xzxw) SHADER_SWIZZLE_OP (xzy ) SHADER_SWIZZLE_OP (xzyx) SHADER_SWIZZLE_OP (xzyy)
952 SHADER_SWIZZLE_OP (xzyz) SHADER_SWIZZLE_OP (xzyw) SHADER_SWIZZLE_OP (xzz ) SHADER_SWIZZLE_OP (xzzx)
953 SHADER_SWIZZLE_OP (xzzy) SHADER_SWIZZLE_OP (xzzz) SHADER_SWIZZLE_OP (xzzw) SHADER_SWIZZLE_OP (xzw )
954 SHADER_SWIZZLE_OP (xzwx) SHADER_SWIZZLE_OP (xzwy) SHADER_SWIZZLE_OP (xzwz) SHADER_SWIZZLE_OP (xzww)
955 SHADER_SWIZZLE_OP (xw ) SHADER_SWIZZLE_OP (xwx ) SHADER_SWIZZLE_OP (xwxx) SHADER_SWIZZLE_OP (xwxy)
956 SHADER_SWIZZLE_OP (xwxz) SHADER_SWIZZLE_OP (xwxw) SHADER_SWIZZLE_OP (xwy ) SHADER_SWIZZLE_OP (xwyx)
957 SHADER_SWIZZLE_OP (xwyy) SHADER_SWIZZLE_OP (xwyz) SHADER_SWIZZLE_OP (xwyw) SHADER_SWIZZLE_OP (xwz )
958 SHADER_SWIZZLE_OP (xwzx) SHADER_SWIZZLE_OP (xwzy) SHADER_SWIZZLE_OP (xwzz) SHADER_SWIZZLE_OP (xwzw)
959 SHADER_SWIZZLE_OP (xww ) SHADER_SWIZZLE_OP (xwwx) SHADER_SWIZZLE_OP (xwwy) SHADER_SWIZZLE_OP (xwwz)
960 SHADER_SWIZZLE_OP (xwww) SHADER_SWIZZLE_OP (y ) SHADER_SWIZZLE_OP (yx ) SHADER_SWIZZLE_OP (yxx )
961 SHADER_SWIZZLE_OP (yxxx) SHADER_SWIZZLE_OP (yxxy) SHADER_SWIZZLE_OP (yxxz) SHADER_SWIZZLE_OP (yxxw)
962 SHADER_SWIZZLE_OP (yxy ) SHADER_SWIZZLE_OP (yxyx) SHADER_SWIZZLE_OP (yxyy) SHADER_SWIZZLE_OP (yxyz)
963 SHADER_SWIZZLE_OP (yxyw) SHADER_SWIZZLE_OP (yxz ) SHADER_SWIZZLE_OP (yxzx) SHADER_SWIZZLE_OP (yxzy)
964 SHADER_SWIZZLE_OP (yxzz) SHADER_SWIZZLE_OP (yxzw) SHADER_SWIZZLE_OP (yxw ) SHADER_SWIZZLE_OP (yxwx)
965 SHADER_SWIZZLE_OP (yxwy) SHADER_SWIZZLE_OP (yxwz) SHADER_SWIZZLE_OP (yxww) SHADER_SWIZZLE_OP (yy )
966 SHADER_SWIZZLE_OP (yyx ) SHADER_SWIZZLE_OP (yyxx) SHADER_SWIZZLE_OP (yyxy) SHADER_SWIZZLE_OP (yyxz)
967 SHADER_SWIZZLE_OP (yyxw) SHADER_SWIZZLE_OP (yyy ) SHADER_SWIZZLE_OP (yyyx) SHADER_SWIZZLE_OP (yyyy)
968 SHADER_SWIZZLE_OP (yyyz) SHADER_SWIZZLE_OP (yyyw) SHADER_SWIZZLE_OP (yyz ) SHADER_SWIZZLE_OP (yyzx)
969 SHADER_SWIZZLE_OP (yyzy) SHADER_SWIZZLE_OP (yyzz) SHADER_SWIZZLE_OP (yyzw) SHADER_SWIZZLE_OP (yyw )
970 SHADER_SWIZZLE_OP (yywx) SHADER_SWIZZLE_OP (yywy) SHADER_SWIZZLE_OP (yywz) SHADER_SWIZZLE_OP (yyww)
971 SHADER_SWIZZLE_OP (yz ) SHADER_SWIZZLE_OP (yzx ) SHADER_SWIZZLE_OP (yzxx) SHADER_SWIZZLE_OP (yzxy)
972 SHADER_SWIZZLE_OP (yzxz) SHADER_SWIZZLE_OP (yzxw) SHADER_SWIZZLE_OP (yzy ) SHADER_SWIZZLE_OP (yzyx)
973 SHADER_SWIZZLE_OP (yzyy) SHADER_SWIZZLE_OP (yzyz) SHADER_SWIZZLE_OP (yzyw) SHADER_SWIZZLE_OP (yzz )
974 SHADER_SWIZZLE_OP (yzzx) SHADER_SWIZZLE_OP (yzzy) SHADER_SWIZZLE_OP (yzzz) SHADER_SWIZZLE_OP (yzzw)
975 SHADER_SWIZZLE_OP (yzw ) SHADER_SWIZZLE_OP (yzwx) SHADER_SWIZZLE_OP (yzwy) SHADER_SWIZZLE_OP (yzwz)
976 SHADER_SWIZZLE_OP (yzww) SHADER_SWIZZLE_OP (yw ) SHADER_SWIZZLE_OP (ywx ) SHADER_SWIZZLE_OP (ywxx)
977 SHADER_SWIZZLE_OP (ywxy) SHADER_SWIZZLE_OP (ywxz) SHADER_SWIZZLE_OP (ywxw) SHADER_SWIZZLE_OP (ywy )
978 SHADER_SWIZZLE_OP (ywyx) SHADER_SWIZZLE_OP (ywyy) SHADER_SWIZZLE_OP (ywyz) SHADER_SWIZZLE_OP (ywyw)
979 SHADER_SWIZZLE_OP (ywz ) SHADER_SWIZZLE_OP (ywzx) SHADER_SWIZZLE_OP (ywzy) SHADER_SWIZZLE_OP (ywzz)
980 SHADER_SWIZZLE_OP (ywzw) SHADER_SWIZZLE_OP (yww ) SHADER_SWIZZLE_OP (ywwx) SHADER_SWIZZLE_OP (ywwy)
981 SHADER_SWIZZLE_OP (ywwz) SHADER_SWIZZLE_OP (ywww) SHADER_SWIZZLE_OP (z ) SHADER_SWIZZLE_OP (zx )
982 SHADER_SWIZZLE_OP (zxx ) SHADER_SWIZZLE_OP (zxxx) SHADER_SWIZZLE_OP (zxxy) SHADER_SWIZZLE_OP (zxxz)
983 SHADER_SWIZZLE_OP (zxxw) SHADER_SWIZZLE_OP (zxy ) SHADER_SWIZZLE_OP (zxyx) SHADER_SWIZZLE_OP (zxyy)
984 SHADER_SWIZZLE_OP (zxyz) SHADER_SWIZZLE_OP (zxyw) SHADER_SWIZZLE_OP (zxz ) SHADER_SWIZZLE_OP (zxzx)
985 SHADER_SWIZZLE_OP (zxzy) SHADER_SWIZZLE_OP (zxzz) SHADER_SWIZZLE_OP (zxzw) SHADER_SWIZZLE_OP (zxw )
986 SHADER_SWIZZLE_OP (zxwx) SHADER_SWIZZLE_OP (zxwy) SHADER_SWIZZLE_OP (zxwz) SHADER_SWIZZLE_OP (zxww)
987 SHADER_SWIZZLE_OP (zy ) SHADER_SWIZZLE_OP (zyx ) SHADER_SWIZZLE_OP (zyxx) SHADER_SWIZZLE_OP (zyxy)
988 SHADER_SWIZZLE_OP (zyxz) SHADER_SWIZZLE_OP (zyxw) SHADER_SWIZZLE_OP (zyy ) SHADER_SWIZZLE_OP (zyyx)
989 SHADER_SWIZZLE_OP (zyyy) SHADER_SWIZZLE_OP (zyyz) SHADER_SWIZZLE_OP (zyyw) SHADER_SWIZZLE_OP (zyz )
990 SHADER_SWIZZLE_OP (zyzx) SHADER_SWIZZLE_OP (zyzy) SHADER_SWIZZLE_OP (zyzz) SHADER_SWIZZLE_OP (zyzw)
991 SHADER_SWIZZLE_OP (zyw ) SHADER_SWIZZLE_OP (zywx) SHADER_SWIZZLE_OP (zywy) SHADER_SWIZZLE_OP (zywz)
992 SHADER_SWIZZLE_OP (zyww) SHADER_SWIZZLE_OP (zz ) SHADER_SWIZZLE_OP (zzx ) SHADER_SWIZZLE_OP (zzxx)
993 SHADER_SWIZZLE_OP (zzxy) SHADER_SWIZZLE_OP (zzxz) SHADER_SWIZZLE_OP (zzxw) SHADER_SWIZZLE_OP (zzy )
994 SHADER_SWIZZLE_OP (zzyx) SHADER_SWIZZLE_OP (zzyy) SHADER_SWIZZLE_OP (zzyz) SHADER_SWIZZLE_OP (zzyw)
995 SHADER_SWIZZLE_OP (zzz ) SHADER_SWIZZLE_OP (zzzx) SHADER_SWIZZLE_OP (zzzy) SHADER_SWIZZLE_OP (zzzz)
996 SHADER_SWIZZLE_OP (zzzw) SHADER_SWIZZLE_OP (zzw ) SHADER_SWIZZLE_OP (zzwx) SHADER_SWIZZLE_OP (zzwy)
997 SHADER_SWIZZLE_OP (zzwz) SHADER_SWIZZLE_OP (zzww) SHADER_SWIZZLE_OP (zw ) SHADER_SWIZZLE_OP (zwx )
998 SHADER_SWIZZLE_OP (zwxx) SHADER_SWIZZLE_OP (zwxy) SHADER_SWIZZLE_OP (zwxz) SHADER_SWIZZLE_OP (zwxw)
999 SHADER_SWIZZLE_OP (zwy ) SHADER_SWIZZLE_OP (zwyx) SHADER_SWIZZLE_OP (zwyy) SHADER_SWIZZLE_OP (zwyz)
1000 SHADER_SWIZZLE_OP (zwyw) SHADER_SWIZZLE_OP (zwz ) SHADER_SWIZZLE_OP (zwzx) SHADER_SWIZZLE_OP (zwzy)
1001 SHADER_SWIZZLE_OP (zwzz) SHADER_SWIZZLE_OP (zwzw) SHADER_SWIZZLE_OP (zww ) SHADER_SWIZZLE_OP (zwwx)
1002 SHADER_SWIZZLE_OP (zwwy) SHADER_SWIZZLE_OP (zwwz) SHADER_SWIZZLE_OP (zwww) SHADER_SWIZZLE_OP (w )
1003 SHADER_SWIZZLE_OP (wx ) SHADER_SWIZZLE_OP (wxx ) SHADER_SWIZZLE_OP (wxxx) SHADER_SWIZZLE_OP (wxxy)
1004 SHADER_SWIZZLE_OP (wxxz) SHADER_SWIZZLE_OP (wxxw) SHADER_SWIZZLE_OP (wxy ) SHADER_SWIZZLE_OP (wxyx)
1005 SHADER_SWIZZLE_OP (wxyy) SHADER_SWIZZLE_OP (wxyz) SHADER_SWIZZLE_OP (wxyw) SHADER_SWIZZLE_OP (wxz )
1006 SHADER_SWIZZLE_OP (wxzx) SHADER_SWIZZLE_OP (wxzy) SHADER_SWIZZLE_OP (wxzz) SHADER_SWIZZLE_OP (wxzw)
1007 SHADER_SWIZZLE_OP (wxw ) SHADER_SWIZZLE_OP (wxwx) SHADER_SWIZZLE_OP (wxwy) SHADER_SWIZZLE_OP (wxwz)
1008 SHADER_SWIZZLE_OP (wxww) SHADER_SWIZZLE_OP (wy ) SHADER_SWIZZLE_OP (wyx ) SHADER_SWIZZLE_OP (wyxx)
1009 SHADER_SWIZZLE_OP (wyxy) SHADER_SWIZZLE_OP (wyxz) SHADER_SWIZZLE_OP (wyxw) SHADER_SWIZZLE_OP (wyy )
1010 SHADER_SWIZZLE_OP (wyyx) SHADER_SWIZZLE_OP (wyyy) SHADER_SWIZZLE_OP (wyyz) SHADER_SWIZZLE_OP (wyyw)
1011 SHADER_SWIZZLE_OP (wyz ) SHADER_SWIZZLE_OP (wyzx) SHADER_SWIZZLE_OP (wyzy) SHADER_SWIZZLE_OP (wyzz)
1012 SHADER_SWIZZLE_OP (wyzw) SHADER_SWIZZLE_OP (wyw ) SHADER_SWIZZLE_OP (wywx) SHADER_SWIZZLE_OP (wywy)
1013 SHADER_SWIZZLE_OP (wywz) SHADER_SWIZZLE_OP (wyww) SHADER_SWIZZLE_OP (wz ) SHADER_SWIZZLE_OP (wzx )
1014 SHADER_SWIZZLE_OP (wzxx) SHADER_SWIZZLE_OP (wzxy) SHADER_SWIZZLE_OP (wzxz) SHADER_SWIZZLE_OP (wzxw)
1015 SHADER_SWIZZLE_OP (wzy ) SHADER_SWIZZLE_OP (wzyx) SHADER_SWIZZLE_OP (wzyy) SHADER_SWIZZLE_OP (wzyz)
1016 SHADER_SWIZZLE_OP (wzyw) SHADER_SWIZZLE_OP (wzz ) SHADER_SWIZZLE_OP (wzzx) SHADER_SWIZZLE_OP (wzzy)
1017 SHADER_SWIZZLE_OP (wzzz) SHADER_SWIZZLE_OP (wzzw) SHADER_SWIZZLE_OP (wzw ) SHADER_SWIZZLE_OP (wzwx)
1018 SHADER_SWIZZLE_OP (wzwy) SHADER_SWIZZLE_OP (wzwz) SHADER_SWIZZLE_OP (wzww) SHADER_SWIZZLE_OP (ww )
1019 SHADER_SWIZZLE_OP (wwx ) SHADER_SWIZZLE_OP (wwxx) SHADER_SWIZZLE_OP (wwxy) SHADER_SWIZZLE_OP (wwxz)
1020 SHADER_SWIZZLE_OP (wwxw) SHADER_SWIZZLE_OP (wwy ) SHADER_SWIZZLE_OP (wwyx) SHADER_SWIZZLE_OP (wwyy)
1021 SHADER_SWIZZLE_OP (wwyz) SHADER_SWIZZLE_OP (wwyw) SHADER_SWIZZLE_OP (wwz ) SHADER_SWIZZLE_OP (wwzx)
1022 SHADER_SWIZZLE_OP (wwzy) SHADER_SWIZZLE_OP (wwzz) SHADER_SWIZZLE_OP (wwzw) SHADER_SWIZZLE_OP (www )
1023 SHADER_SWIZZLE_OP (wwwx) SHADER_SWIZZLE_OP (wwwy) SHADER_SWIZZLE_OP (wwwz) SHADER_SWIZZLE_OP (wwww)
1024
1025# undef SHADER_SWIZZLE_OP
1026
1027# define SHADER_FUNC0_(name, glname) \
1028 inline const sl_expr<sl_func0> \
1029 name () \
1030 { \
1031 return sl_func0 (#glname " ("); \
1032 }
1033
1034# define SHADER_FUNC0(name) SHADER_FUNC0_(name,name)
1035
1036# define SHADER_FUNC1_(name, glname) \
1037 template<typename A> \
1038 inline const sl_expr< sl_func1<typename sl_convert<A>::T> > \
1039 name (const A &a) \
1040 { \
1041 return sl_func1<typename sl_convert<A>::T> (#glname " (", sl_convert<A>::convert (a));\
1042 }
1043
1044# define SHADER_FUNC1(name) SHADER_FUNC1_(name,name)
1045
1046# define SHADER_FUNC2_(name, glname) \
1047 template<typename A, typename B> \
1048 inline const sl_expr< sl_func2<typename sl_convert<A>::T, typename sl_convert<B>::T> > \
1049 name (const A &a, const B &b) \
1050 { \
1051 return sl_func2<typename sl_convert<A>::T, typename sl_convert<B>::T> (#glname " (", sl_convert<A>::convert (a), sl_convert<B>::convert (b));\
1052 }
1053
1054# define SHADER_FUNC2(name) SHADER_FUNC2_(name,name)
1055
1056# define SHADER_FUNC3_(name, glname) \
1057 template<typename A, typename B, typename C> \
1058 inline const sl_expr< sl_func3<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T> > \
1059 name (const A &a, const B &b, const C &c) \
1060 { \
1061 return sl_func3<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T> (#glname " (", sl_convert<A>::convert (a), sl_convert<B>::convert (b), sl_convert<C>::convert (c));\
1062 }
1063
1064# define SHADER_FUNC3(name) SHADER_FUNC3_(name,name)
1065
1066# define SHADER_FUNC4_(name, glname) \
1067 template<typename A, typename B, typename C, typename D> \
1068 inline const sl_expr< sl_func4<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T, typename sl_convert<D>::T > > \
1069 name (const A &a, const B &b, const C &c, const D &d) \
1070 { \
1071 return sl_func4<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T, typename sl_convert<D>::T> (#glname " (", sl_convert<A>::convert (a), sl_convert<B>::convert (b), sl_convert<C>::convert (c), sl_convert<D>::convert (d));\
1072 }
1073
1074# define SHADER_FUNC4(name) SHADER_FUNC4_(name,name)
1075
1076 SHADER_FUNC1 (abs)
1077 SHADER_FUNC1 (acos)
1078 SHADER_FUNC1 (all)
1079 SHADER_FUNC1 (any)
1080 SHADER_FUNC1 (asin)
1081 SHADER_FUNC1 (atan)
1082 SHADER_FUNC2 (atan)
1083 SHADER_FUNC1 (ceil)
1084 SHADER_FUNC3 (clamp)
1085 SHADER_FUNC1 (cos)
1086 SHADER_FUNC2 (cross)
1087 SHADER_FUNC1 (dFdx)
1088 SHADER_FUNC1 (dFdy)
1089 SHADER_FUNC1 (degrees)
1090 SHADER_FUNC2 (distance)
1091 SHADER_FUNC2 (dot)
1092 SHADER_FUNC2_(equal, equal)
1093 SHADER_FUNC1 (exp)
1094 SHADER_FUNC1 (exp2)
1095 SHADER_FUNC3 (faceforward)
1096 SHADER_FUNC1 (floor)
1097 SHADER_FUNC1 (fract)
1098 SHADER_FUNC0 (ftransform)
1099 SHADER_FUNC1 (fwidth)
1100 SHADER_FUNC2_(greater_than_equal, greaterThanEqual)
1101 SHADER_FUNC2_(greater_then, greaterThan)
1102 SHADER_FUNC1 (inversesqrt)
1103 SHADER_FUNC1 (length)
1104 SHADER_FUNC2_(less_than, lessThan)
1105 SHADER_FUNC2_(less_than_equal, lessThanEqual)
1106 SHADER_FUNC1 (log)
1107 SHADER_FUNC1 (log2)
1108 SHADER_FUNC2_(matrix_comp_mult, matrixCompMult)
1109 SHADER_FUNC2 (max)
1110 SHADER_FUNC2 (min)
1111 SHADER_FUNC3 (mix)
1112 SHADER_FUNC2 (mod)
1113 SHADER_FUNC1 (noise1)
1114 SHADER_FUNC1 (noise2)
1115 SHADER_FUNC1 (noise3)
1116 SHADER_FUNC1 (noise4)
1117 SHADER_FUNC1 (normalize)
1118 SHADER_FUNC1 (gl_not) // TODO
1119 SHADER_FUNC2_(notequal, notEqual)
1120 SHADER_FUNC2 (pow)
1121 SHADER_FUNC1 (radians)
1122 SHADER_FUNC2 (reflect)
1123 SHADER_FUNC3 (refract)
1124 SHADER_FUNC2_(shadow_1d, shadow1D)
1125 SHADER_FUNC3_(shadow_1d, shadow1D)
1126 SHADER_FUNC3_(shadow_1d_lod, shadow1DLod)
1127 SHADER_FUNC2_(shadow_1d_proj, shadow1DProj)
1128 SHADER_FUNC3_(shadow_1d_proj, shadow1DProj)
1129 SHADER_FUNC3_(shadow_1d_proj_lod, shadow1DProjLod)
1130 SHADER_FUNC2_(shadow_2d, shadow2D)
1131 SHADER_FUNC3_(shadow_2d, shadow2D)
1132 SHADER_FUNC3_(shadow_2d_lod, shadow2DLod)
1133 SHADER_FUNC2_(shadow_2d_proj, shadow2DProj)
1134 SHADER_FUNC3_(shadow_2d_proj, shadow2DProj)
1135 SHADER_FUNC3_(shadow_2d_proj_lod, shadow2DProjLod)
1136 SHADER_FUNC1 (sign)
1137 SHADER_FUNC1 (sin)
1138 SHADER_FUNC3 (smoothstep)
1139 SHADER_FUNC1 (sqrt)
1140 SHADER_FUNC2 (step)
1141 SHADER_FUNC1 (tan)
1142 SHADER_FUNC2_(texture_1d, texture1D)
1143 SHADER_FUNC3_(texture_1d, texture1D)
1144 SHADER_FUNC3_(texture_1d_lod, texture1DLod)
1145 SHADER_FUNC2_(texture_1d_proj, texture1DProj)
1146 SHADER_FUNC3_(texture_1d_proj, texture1DProj)
1147 SHADER_FUNC3_(texture_1d_proj_lod, texture1DProjLod)
1148 SHADER_FUNC2_(texture_2d, texture2D)
1149 SHADER_FUNC3_(texture_2d, texture2D)
1150 SHADER_FUNC3_(texture_2d_lod, texture2DLod)
1151 SHADER_FUNC2_(texture_2d_proj, texture2DProj)
1152 SHADER_FUNC3_(texture_2d_proj, texture2DProj)
1153 SHADER_FUNC3_(texture_2d_proj_lod, texture2DProjLod)
1154 SHADER_FUNC2_(texture_3d, texture3D)
1155 SHADER_FUNC3_(texture_3d, texture3D)
1156 SHADER_FUNC3_(texture_3d_lod, texture3DLod)
1157 SHADER_FUNC2_(texture_3d_proj, texture3DProj)
1158 SHADER_FUNC3_(texture_3d_proj, texture3DProj)
1159 SHADER_FUNC3_(texture_3d_proj_lod, texture3DProjLod)
1160 SHADER_FUNC2_(texture_cube, textureCube)
1161 SHADER_FUNC3_(texture_cube, textureCube)
1162 SHADER_FUNC3_(texture_cude_lod, textureCubeLod)
1163 SHADER_FUNC1 (vec2) SHADER_FUNC2 (vec2)
1164 SHADER_FUNC1 (vec3) SHADER_FUNC2 (vec3) SHADER_FUNC3 (vec3)
1165 SHADER_FUNC1 (vec4) SHADER_FUNC2 (vec4) SHADER_FUNC3 (vec4) SHADER_FUNC4 (vec4)
1166 // floatx is out extension
1167 SHADER_FUNC1 (float2) SHADER_FUNC2 (float2)
1168 SHADER_FUNC1 (float3) SHADER_FUNC2 (float3) SHADER_FUNC3 (float3)
1169 SHADER_FUNC1 (float4) SHADER_FUNC2 (float4) SHADER_FUNC3 (float4) SHADER_FUNC4 (float4)
1170 SHADER_FUNC1 (mat2) SHADER_FUNC2 (mat2)
1171 SHADER_FUNC1 (mat3) SHADER_FUNC2 (mat3) SHADER_FUNC3 (mat3)
1172 SHADER_FUNC1 (mat4) SHADER_FUNC2 (mat4) SHADER_FUNC3 (mat4) SHADER_FUNC4 (mat4)
1173
1174# undef SHADER_FUNC0
1175# undef SHADER_FUNC0_
1176# undef SHADER_FUNC1
1177# undef SHADER_FUNC1_
1178# undef SHADER_FUNC2
1179# undef SHADER_FUNC2_
1180# undef SHADER_FUNC3
1181# undef SHADER_FUNC3_
1182# undef SHADER_FUNC4
1183# undef SHADER_FUNC5_
1184
1185 template<class A, class B, class C>
1186 struct sl_ifelse
875 { 1187 {
876 sl_string<7> s; 1188 const A a; const B b; const C c;
877 swizzle_mask (s, ((d * 5 + c) * 5 + b) * 5 + a); 1189 sl_ifelse (const A &a, const B &b, const C &c) : a(a), b(b), c(c) { }
878 return concat (str_lpar, sl_convert<T>::convert (t), s); 1190 void operator ()() const
1191 {
1192 shader_builder::cur->code << "(";
1193 a ();
1194 shader_builder::cur->code << ") ? (";
1195 b ();
1196 shader_builder::cur->code << ") : (";
1197 c ();
1198 shader_builder::cur->code << ")";
1199 }
1200 };
1201
1202 template<typename A, typename B, typename C>
1203 inline const sl_expr< sl_ifelse<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T> >
1204 ifelse (const A &a, const B &b, const C &c)
1205 {
1206 return sl_ifelse<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T>
1207 (sl_convert<A>::convert (a), sl_convert<B>::convert (b), sl_convert<C>::convert (c));
1208 }
1209
879 } 1210 }
880
881# define SHADER_SWIZZLE_OP(abcd,type) \
882 template<typename T> \
883 inline const sl_expr< sl_concat3< sl_append_const_string, \
884 typename sl_convert<T>::T, \
885 sl_string<7> \
886 > > \
887 type (const T &t) \
888 { \
889 return swizzle (t, (abcd / 1000) % 5, (abcd / 100) % 5, (abcd / 10) % 5, (abcd / 1) % 5); \
890 }
891
892 // brute force is lovely, ain't it?
893 SHADER_SWIZZLE_OP (1 , x ) SHADER_SWIZZLE_OP (11 , xx ) SHADER_SWIZZLE_OP (111 , xxx ) SHADER_SWIZZLE_OP (1111, xxxx)
894 SHADER_SWIZZLE_OP (1112, xxxy) SHADER_SWIZZLE_OP (1113, xxxz) SHADER_SWIZZLE_OP (1114, xxxw) SHADER_SWIZZLE_OP (112 , xxy )
895 SHADER_SWIZZLE_OP (1121, xxyx) SHADER_SWIZZLE_OP (1122, xxyy) SHADER_SWIZZLE_OP (1123, xxyz) SHADER_SWIZZLE_OP (1124, xxyw)
896 SHADER_SWIZZLE_OP (113 , xxz ) SHADER_SWIZZLE_OP (1131, xxzx) SHADER_SWIZZLE_OP (1132, xxzy) SHADER_SWIZZLE_OP (1133, xxzz)
897 SHADER_SWIZZLE_OP (1134, xxzw) SHADER_SWIZZLE_OP (114 , xxw ) SHADER_SWIZZLE_OP (1141, xxwx) SHADER_SWIZZLE_OP (1142, xxwy)
898 SHADER_SWIZZLE_OP (1143, xxwz) SHADER_SWIZZLE_OP (1144, xxww) SHADER_SWIZZLE_OP (12 , xy ) SHADER_SWIZZLE_OP (121 , xyx )
899 SHADER_SWIZZLE_OP (1211, xyxx) SHADER_SWIZZLE_OP (1212, xyxy) SHADER_SWIZZLE_OP (1213, xyxz) SHADER_SWIZZLE_OP (1214, xyxw)
900 SHADER_SWIZZLE_OP (122 , xyy ) SHADER_SWIZZLE_OP (1221, xyyx) SHADER_SWIZZLE_OP (1222, xyyy) SHADER_SWIZZLE_OP (1223, xyyz)
901 SHADER_SWIZZLE_OP (1224, xyyw) SHADER_SWIZZLE_OP (123 , xyz ) SHADER_SWIZZLE_OP (1231, xyzx) SHADER_SWIZZLE_OP (1232, xyzy)
902 SHADER_SWIZZLE_OP (1233, xyzz) SHADER_SWIZZLE_OP (1234, xyzw) SHADER_SWIZZLE_OP (124 , xyw ) SHADER_SWIZZLE_OP (1241, xywx)
903 SHADER_SWIZZLE_OP (1242, xywy) SHADER_SWIZZLE_OP (1243, xywz) SHADER_SWIZZLE_OP (1244, xyww) SHADER_SWIZZLE_OP (13 , xz )
904 SHADER_SWIZZLE_OP (131 , xzx ) SHADER_SWIZZLE_OP (1311, xzxx) SHADER_SWIZZLE_OP (1312, xzxy) SHADER_SWIZZLE_OP (1313, xzxz)
905 SHADER_SWIZZLE_OP (1314, xzxw) SHADER_SWIZZLE_OP (132 , xzy ) SHADER_SWIZZLE_OP (1321, xzyx) SHADER_SWIZZLE_OP (1322, xzyy)
906 SHADER_SWIZZLE_OP (1323, xzyz) SHADER_SWIZZLE_OP (1324, xzyw) SHADER_SWIZZLE_OP (133 , xzz ) SHADER_SWIZZLE_OP (1331, xzzx)
907 SHADER_SWIZZLE_OP (1332, xzzy) SHADER_SWIZZLE_OP (1333, xzzz) SHADER_SWIZZLE_OP (1334, xzzw) SHADER_SWIZZLE_OP (134 , xzw )
908 SHADER_SWIZZLE_OP (1341, xzwx) SHADER_SWIZZLE_OP (1342, xzwy) SHADER_SWIZZLE_OP (1343, xzwz) SHADER_SWIZZLE_OP (1344, xzww)
909 SHADER_SWIZZLE_OP (14 , xw ) SHADER_SWIZZLE_OP (141 , xwx ) SHADER_SWIZZLE_OP (1411, xwxx) SHADER_SWIZZLE_OP (1412, xwxy)
910 SHADER_SWIZZLE_OP (1413, xwxz) SHADER_SWIZZLE_OP (1414, xwxw) SHADER_SWIZZLE_OP (142 , xwy ) SHADER_SWIZZLE_OP (1421, xwyx)
911 SHADER_SWIZZLE_OP (1422, xwyy) SHADER_SWIZZLE_OP (1423, xwyz) SHADER_SWIZZLE_OP (1424, xwyw) SHADER_SWIZZLE_OP (143 , xwz )
912 SHADER_SWIZZLE_OP (1431, xwzx) SHADER_SWIZZLE_OP (1432, xwzy) SHADER_SWIZZLE_OP (1433, xwzz) SHADER_SWIZZLE_OP (1434, xwzw)
913 SHADER_SWIZZLE_OP (144 , xww ) SHADER_SWIZZLE_OP (1441, xwwx) SHADER_SWIZZLE_OP (1442, xwwy) SHADER_SWIZZLE_OP (1443, xwwz)
914 SHADER_SWIZZLE_OP (1444, xwww) SHADER_SWIZZLE_OP (2 , y ) SHADER_SWIZZLE_OP (21 , yx ) SHADER_SWIZZLE_OP (211 , yxx )
915 SHADER_SWIZZLE_OP (2111, yxxx) SHADER_SWIZZLE_OP (2112, yxxy) SHADER_SWIZZLE_OP (2113, yxxz) SHADER_SWIZZLE_OP (2114, yxxw)
916 SHADER_SWIZZLE_OP (212 , yxy ) SHADER_SWIZZLE_OP (2121, yxyx) SHADER_SWIZZLE_OP (2122, yxyy) SHADER_SWIZZLE_OP (2123, yxyz)
917 SHADER_SWIZZLE_OP (2124, yxyw) SHADER_SWIZZLE_OP (213 , yxz ) SHADER_SWIZZLE_OP (2131, yxzx) SHADER_SWIZZLE_OP (2132, yxzy)
918 SHADER_SWIZZLE_OP (2133, yxzz) SHADER_SWIZZLE_OP (2134, yxzw) SHADER_SWIZZLE_OP (214 , yxw ) SHADER_SWIZZLE_OP (2141, yxwx)
919 SHADER_SWIZZLE_OP (2142, yxwy) SHADER_SWIZZLE_OP (2143, yxwz) SHADER_SWIZZLE_OP (2144, yxww) SHADER_SWIZZLE_OP (22 , yy )
920 SHADER_SWIZZLE_OP (221 , yyx ) SHADER_SWIZZLE_OP (2211, yyxx) SHADER_SWIZZLE_OP (2212, yyxy) SHADER_SWIZZLE_OP (2213, yyxz)
921 SHADER_SWIZZLE_OP (2214, yyxw) SHADER_SWIZZLE_OP (222 , yyy ) SHADER_SWIZZLE_OP (2221, yyyx) SHADER_SWIZZLE_OP (2222, yyyy)
922 SHADER_SWIZZLE_OP (2223, yyyz) SHADER_SWIZZLE_OP (2224, yyyw) SHADER_SWIZZLE_OP (223 , yyz ) SHADER_SWIZZLE_OP (2231, yyzx)
923 SHADER_SWIZZLE_OP (2232, yyzy) SHADER_SWIZZLE_OP (2233, yyzz) SHADER_SWIZZLE_OP (2234, yyzw) SHADER_SWIZZLE_OP (224 , yyw )
924 SHADER_SWIZZLE_OP (2241, yywx) SHADER_SWIZZLE_OP (2242, yywy) SHADER_SWIZZLE_OP (2243, yywz) SHADER_SWIZZLE_OP (2244, yyww)
925 SHADER_SWIZZLE_OP (23 , yz ) SHADER_SWIZZLE_OP (231 , yzx ) SHADER_SWIZZLE_OP (2311, yzxx) SHADER_SWIZZLE_OP (2312, yzxy)
926 SHADER_SWIZZLE_OP (2313, yzxz) SHADER_SWIZZLE_OP (2314, yzxw) SHADER_SWIZZLE_OP (232 , yzy ) SHADER_SWIZZLE_OP (2321, yzyx)
927 SHADER_SWIZZLE_OP (2322, yzyy) SHADER_SWIZZLE_OP (2323, yzyz) SHADER_SWIZZLE_OP (2324, yzyw) SHADER_SWIZZLE_OP (233 , yzz )
928 SHADER_SWIZZLE_OP (2331, yzzx) SHADER_SWIZZLE_OP (2332, yzzy) SHADER_SWIZZLE_OP (2333, yzzz) SHADER_SWIZZLE_OP (2334, yzzw)
929 SHADER_SWIZZLE_OP (234 , yzw ) SHADER_SWIZZLE_OP (2341, yzwx) SHADER_SWIZZLE_OP (2342, yzwy) SHADER_SWIZZLE_OP (2343, yzwz)
930 SHADER_SWIZZLE_OP (2344, yzww) SHADER_SWIZZLE_OP (24 , yw ) SHADER_SWIZZLE_OP (241 , ywx ) SHADER_SWIZZLE_OP (2411, ywxx)
931 SHADER_SWIZZLE_OP (2412, ywxy) SHADER_SWIZZLE_OP (2413, ywxz) SHADER_SWIZZLE_OP (2414, ywxw) SHADER_SWIZZLE_OP (242 , ywy )
932 SHADER_SWIZZLE_OP (2421, ywyx) SHADER_SWIZZLE_OP (2422, ywyy) SHADER_SWIZZLE_OP (2423, ywyz) SHADER_SWIZZLE_OP (2424, ywyw)
933 SHADER_SWIZZLE_OP (243 , ywz ) SHADER_SWIZZLE_OP (2431, ywzx) SHADER_SWIZZLE_OP (2432, ywzy) SHADER_SWIZZLE_OP (2433, ywzz)
934 SHADER_SWIZZLE_OP (2434, ywzw) SHADER_SWIZZLE_OP (244 , yww ) SHADER_SWIZZLE_OP (2441, ywwx) SHADER_SWIZZLE_OP (2442, ywwy)
935 SHADER_SWIZZLE_OP (2443, ywwz) SHADER_SWIZZLE_OP (2444, ywww) SHADER_SWIZZLE_OP (3 , z ) SHADER_SWIZZLE_OP (31 , zx )
936 SHADER_SWIZZLE_OP (311 , zxx ) SHADER_SWIZZLE_OP (3111, zxxx) SHADER_SWIZZLE_OP (3112, zxxy) SHADER_SWIZZLE_OP (3113, zxxz)
937 SHADER_SWIZZLE_OP (3114, zxxw) SHADER_SWIZZLE_OP (312 , zxy ) SHADER_SWIZZLE_OP (3121, zxyx) SHADER_SWIZZLE_OP (3122, zxyy)
938 SHADER_SWIZZLE_OP (3123, zxyz) SHADER_SWIZZLE_OP (3124, zxyw) SHADER_SWIZZLE_OP (313 , zxz ) SHADER_SWIZZLE_OP (3131, zxzx)
939 SHADER_SWIZZLE_OP (3132, zxzy) SHADER_SWIZZLE_OP (3133, zxzz) SHADER_SWIZZLE_OP (3134, zxzw) SHADER_SWIZZLE_OP (314 , zxw )
940 SHADER_SWIZZLE_OP (3141, zxwx) SHADER_SWIZZLE_OP (3142, zxwy) SHADER_SWIZZLE_OP (3143, zxwz) SHADER_SWIZZLE_OP (3144, zxww)
941 SHADER_SWIZZLE_OP (32 , zy ) SHADER_SWIZZLE_OP (321 , zyx ) SHADER_SWIZZLE_OP (3211, zyxx) SHADER_SWIZZLE_OP (3212, zyxy)
942 SHADER_SWIZZLE_OP (3213, zyxz) SHADER_SWIZZLE_OP (3214, zyxw) SHADER_SWIZZLE_OP (322 , zyy ) SHADER_SWIZZLE_OP (3221, zyyx)
943 SHADER_SWIZZLE_OP (3222, zyyy) SHADER_SWIZZLE_OP (3223, zyyz) SHADER_SWIZZLE_OP (3224, zyyw) SHADER_SWIZZLE_OP (323 , zyz )
944 SHADER_SWIZZLE_OP (3231, zyzx) SHADER_SWIZZLE_OP (3232, zyzy) SHADER_SWIZZLE_OP (3233, zyzz) SHADER_SWIZZLE_OP (3234, zyzw)
945 SHADER_SWIZZLE_OP (324 , zyw ) SHADER_SWIZZLE_OP (3241, zywx) SHADER_SWIZZLE_OP (3242, zywy) SHADER_SWIZZLE_OP (3243, zywz)
946 SHADER_SWIZZLE_OP (3244, zyww) SHADER_SWIZZLE_OP (33 , zz ) SHADER_SWIZZLE_OP (331 , zzx ) SHADER_SWIZZLE_OP (3311, zzxx)
947 SHADER_SWIZZLE_OP (3312, zzxy) SHADER_SWIZZLE_OP (3313, zzxz) SHADER_SWIZZLE_OP (3314, zzxw) SHADER_SWIZZLE_OP (332 , zzy )
948 SHADER_SWIZZLE_OP (3321, zzyx) SHADER_SWIZZLE_OP (3322, zzyy) SHADER_SWIZZLE_OP (3323, zzyz) SHADER_SWIZZLE_OP (3324, zzyw)
949 SHADER_SWIZZLE_OP (333 , zzz ) SHADER_SWIZZLE_OP (3331, zzzx) SHADER_SWIZZLE_OP (3332, zzzy) SHADER_SWIZZLE_OP (3333, zzzz)
950 SHADER_SWIZZLE_OP (3334, zzzw) SHADER_SWIZZLE_OP (334 , zzw ) SHADER_SWIZZLE_OP (3341, zzwx) SHADER_SWIZZLE_OP (3342, zzwy)
951 SHADER_SWIZZLE_OP (3343, zzwz) SHADER_SWIZZLE_OP (3344, zzww) SHADER_SWIZZLE_OP (34 , zw ) SHADER_SWIZZLE_OP (341 , zwx )
952 SHADER_SWIZZLE_OP (3411, zwxx) SHADER_SWIZZLE_OP (3412, zwxy) SHADER_SWIZZLE_OP (3413, zwxz) SHADER_SWIZZLE_OP (3414, zwxw)
953 SHADER_SWIZZLE_OP (342 , zwy ) SHADER_SWIZZLE_OP (3421, zwyx) SHADER_SWIZZLE_OP (3422, zwyy) SHADER_SWIZZLE_OP (3423, zwyz)
954 SHADER_SWIZZLE_OP (3424, zwyw) SHADER_SWIZZLE_OP (343 , zwz ) SHADER_SWIZZLE_OP (3431, zwzx) SHADER_SWIZZLE_OP (3432, zwzy)
955 SHADER_SWIZZLE_OP (3433, zwzz) SHADER_SWIZZLE_OP (3434, zwzw) SHADER_SWIZZLE_OP (344 , zww ) SHADER_SWIZZLE_OP (3441, zwwx)
956 SHADER_SWIZZLE_OP (3442, zwwy) SHADER_SWIZZLE_OP (3443, zwwz) SHADER_SWIZZLE_OP (3444, zwww) SHADER_SWIZZLE_OP (4 , w )
957 SHADER_SWIZZLE_OP (41 , wx ) SHADER_SWIZZLE_OP (411 , wxx ) SHADER_SWIZZLE_OP (4111, wxxx) SHADER_SWIZZLE_OP (4112, wxxy)
958 SHADER_SWIZZLE_OP (4113, wxxz) SHADER_SWIZZLE_OP (4114, wxxw) SHADER_SWIZZLE_OP (412 , wxy ) SHADER_SWIZZLE_OP (4121, wxyx)
959 SHADER_SWIZZLE_OP (4122, wxyy) SHADER_SWIZZLE_OP (4123, wxyz) SHADER_SWIZZLE_OP (4124, wxyw) SHADER_SWIZZLE_OP (413 , wxz )
960 SHADER_SWIZZLE_OP (4131, wxzx) SHADER_SWIZZLE_OP (4132, wxzy) SHADER_SWIZZLE_OP (4133, wxzz) SHADER_SWIZZLE_OP (4134, wxzw)
961 SHADER_SWIZZLE_OP (414 , wxw ) SHADER_SWIZZLE_OP (4141, wxwx) SHADER_SWIZZLE_OP (4142, wxwy) SHADER_SWIZZLE_OP (4143, wxwz)
962 SHADER_SWIZZLE_OP (4144, wxww) SHADER_SWIZZLE_OP (42 , wy ) SHADER_SWIZZLE_OP (421 , wyx ) SHADER_SWIZZLE_OP (4211, wyxx)
963 SHADER_SWIZZLE_OP (4212, wyxy) SHADER_SWIZZLE_OP (4213, wyxz) SHADER_SWIZZLE_OP (4214, wyxw) SHADER_SWIZZLE_OP (422 , wyy )
964 SHADER_SWIZZLE_OP (4221, wyyx) SHADER_SWIZZLE_OP (4222, wyyy) SHADER_SWIZZLE_OP (4223, wyyz) SHADER_SWIZZLE_OP (4224, wyyw)
965 SHADER_SWIZZLE_OP (423 , wyz ) SHADER_SWIZZLE_OP (4231, wyzx) SHADER_SWIZZLE_OP (4232, wyzy) SHADER_SWIZZLE_OP (4233, wyzz)
966 SHADER_SWIZZLE_OP (4234, wyzw) SHADER_SWIZZLE_OP (424 , wyw ) SHADER_SWIZZLE_OP (4241, wywx) SHADER_SWIZZLE_OP (4242, wywy)
967 SHADER_SWIZZLE_OP (4243, wywz) SHADER_SWIZZLE_OP (4244, wyww) SHADER_SWIZZLE_OP (43 , wz ) SHADER_SWIZZLE_OP (431 , wzx )
968 SHADER_SWIZZLE_OP (4311, wzxx) SHADER_SWIZZLE_OP (4312, wzxy) SHADER_SWIZZLE_OP (4313, wzxz) SHADER_SWIZZLE_OP (4314, wzxw)
969 SHADER_SWIZZLE_OP (432 , wzy ) SHADER_SWIZZLE_OP (4321, wzyx) SHADER_SWIZZLE_OP (4322, wzyy) SHADER_SWIZZLE_OP (4323, wzyz)
970 SHADER_SWIZZLE_OP (4324, wzyw) SHADER_SWIZZLE_OP (433 , wzz ) SHADER_SWIZZLE_OP (4331, wzzx) SHADER_SWIZZLE_OP (4332, wzzy)
971 SHADER_SWIZZLE_OP (4333, wzzz) SHADER_SWIZZLE_OP (4334, wzzw) SHADER_SWIZZLE_OP (434 , wzw ) SHADER_SWIZZLE_OP (4341, wzwx)
972 SHADER_SWIZZLE_OP (4342, wzwy) SHADER_SWIZZLE_OP (4343, wzwz) SHADER_SWIZZLE_OP (4344, wzww) SHADER_SWIZZLE_OP (44 , ww )
973 SHADER_SWIZZLE_OP (441 , wwx ) SHADER_SWIZZLE_OP (4411, wwxx) SHADER_SWIZZLE_OP (4412, wwxy) SHADER_SWIZZLE_OP (4413, wwxz)
974 SHADER_SWIZZLE_OP (4414, wwxw) SHADER_SWIZZLE_OP (442 , wwy ) SHADER_SWIZZLE_OP (4421, wwyx) SHADER_SWIZZLE_OP (4422, wwyy)
975 SHADER_SWIZZLE_OP (4423, wwyz) SHADER_SWIZZLE_OP (4424, wwyw) SHADER_SWIZZLE_OP (443 , wwz ) SHADER_SWIZZLE_OP (4431, wwzx)
976 SHADER_SWIZZLE_OP (4432, wwzy) SHADER_SWIZZLE_OP (4433, wwzz) SHADER_SWIZZLE_OP (4434, wwzw) SHADER_SWIZZLE_OP (444 , www )
977 SHADER_SWIZZLE_OP (4441, wwwx) SHADER_SWIZZLE_OP (4442, wwwy) SHADER_SWIZZLE_OP (4443, wwwz) SHADER_SWIZZLE_OP (4444, wwww)
978
979# undef SHADER_SWIZZLE_OP
980
981# define SHADER_FUNC0_(name, glname) \
982 template<typename A> \
983 inline const sl_expr<sl_func0> \
984 name () \
985 { \
986 return sl_func0 (#glname " ("); \
987 }
988
989# define SHADER_FUNC0(name) SHADER_FUNC0_(name,name)
990
991# define SHADER_FUNC1_(name, glname) \
992 template<typename A> \
993 inline const sl_expr< sl_func1<typename sl_convert<A>::T> > \
994 name (const A &a) \
995 { \
996 return sl_func1<typename sl_convert<A>::T> (#glname " (", sl_convert<A>::convert (a));\
997 }
998
999# define SHADER_FUNC1(name) SHADER_FUNC1_(name,name)
1000
1001# define SHADER_FUNC2_(name, glname) \
1002 template<typename A, typename B> \
1003 inline const sl_expr< sl_func2<typename sl_convert<A>::T, typename sl_convert<B>::T> > \
1004 name (const A &a, const B &b) \
1005 { \
1006 return sl_func2<typename sl_convert<A>::T, typename sl_convert<B>::T> (#glname " (", sl_convert<A>::convert (a), sl_convert<B>::convert (b));\
1007 }
1008
1009# define SHADER_FUNC2(name) SHADER_FUNC2_(name,name)
1010
1011# define SHADER_FUNC3_(name, glname) \
1012 template<typename A, typename B, typename C> \
1013 inline const sl_expr< sl_func3<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T> > \
1014 name (const A &a, const B &b, const C &c) \
1015 { \
1016 return sl_func3<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T> (#glname " (", sl_convert<A>::convert (a), sl_convert<B>::convert (b), sl_convert<C>::convert (c));\
1017 }
1018
1019# define SHADER_FUNC3(name) SHADER_FUNC3_(name,name)
1020
1021# define SHADER_FUNC4_(name, glname) \
1022 template<typename A, typename B, typename C, typename D> \
1023 inline const sl_expr< sl_func4<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T, typename sl_convert<D>::T > > \
1024 name (const A &a, const B &b, const C &c, const D &d) \
1025 { \
1026 return sl_func4<typename sl_convert<A>::T, typename sl_convert<B>::T, typename sl_convert<C>::T, typename sl_convert<D>::T> (#glname " (", sl_convert<A>::convert (a), sl_convert<B>::convert (b), sl_convert<C>::convert (c), sl_convert<D>::convert (d));\
1027 }
1028
1029# define SHADER_FUNC4(name) SHADER_FUNC4_(name,name)
1030
1031 SHADER_FUNC1 (abs)
1032 SHADER_FUNC1 (acos)
1033 SHADER_FUNC1 (all)
1034 SHADER_FUNC1 (any)
1035 SHADER_FUNC1 (asin)
1036 SHADER_FUNC1 (atan)
1037 SHADER_FUNC2 (atan)
1038 SHADER_FUNC1 (ceil)
1039 SHADER_FUNC3 (clamp)
1040 SHADER_FUNC1 (cos)
1041 SHADER_FUNC2 (cross)
1042 SHADER_FUNC1 (dFdx)
1043 SHADER_FUNC1 (dFdy)
1044 SHADER_FUNC1 (degrees)
1045 SHADER_FUNC2 (distance)
1046 SHADER_FUNC2 (dot)
1047 SHADER_FUNC2_(equal, equal)
1048 SHADER_FUNC1 (exp)
1049 SHADER_FUNC1 (exp2)
1050 SHADER_FUNC3 (faceforward)
1051 SHADER_FUNC1 (floor)
1052 SHADER_FUNC1 (fract)
1053 SHADER_FUNC0 (ftransform)
1054 SHADER_FUNC1 (fwidth)
1055 SHADER_FUNC2_(greater_than_equal, greaterThanEqual)
1056 SHADER_FUNC2_(greater_then, greaterThan)
1057 SHADER_FUNC1 (inversesqrt)
1058 SHADER_FUNC1 (length)
1059 SHADER_FUNC2_(less_than, lessThan)
1060 SHADER_FUNC2_(less_than_equal, lessThanEqual)
1061 SHADER_FUNC1 (log)
1062 SHADER_FUNC1 (log2)
1063 SHADER_FUNC2_(matrix_comp_mult, matrixCompMult)
1064 SHADER_FUNC2 (max)
1065 SHADER_FUNC2 (min)
1066 SHADER_FUNC3 (mix)
1067 SHADER_FUNC2 (mod)
1068 SHADER_FUNC1 (noise1)
1069 SHADER_FUNC1 (noise2)
1070 SHADER_FUNC1 (noise3)
1071 SHADER_FUNC1 (noise4)
1072 SHADER_FUNC1 (normalize)
1073 SHADER_FUNC1 (gl_not) // TODO
1074 SHADER_FUNC2_(notequal, notEqual)
1075 SHADER_FUNC2 (pow)
1076 SHADER_FUNC1 (radians)
1077 SHADER_FUNC2 (reflect)
1078 SHADER_FUNC3 (refract)
1079 SHADER_FUNC2_(shadow_1d, shadow1D)
1080 SHADER_FUNC3_(shadow_1d, shadow1D)
1081 SHADER_FUNC3_(shadow_1d_lod, shadow1DLod)
1082 SHADER_FUNC2_(shadow_1d_proj, shadow1DProj)
1083 SHADER_FUNC3_(shadow_1d_proj, shadow1DProj)
1084 SHADER_FUNC3_(shadow_1d_proj_lod, shadow1DProjLod)
1085 SHADER_FUNC2_(shadow_2d, shadow2D)
1086 SHADER_FUNC3_(shadow_2d, shadow2D)
1087 SHADER_FUNC3_(shadow_2d_lod, shadow2DLod)
1088 SHADER_FUNC2_(shadow_2d_proj, shadow2DProj)
1089 SHADER_FUNC3_(shadow_2d_proj, shadow2DProj)
1090 SHADER_FUNC3_(shadow_2d_proj_lod, shadow2DProjLod)
1091 SHADER_FUNC1 (sign)
1092 SHADER_FUNC1 (sin)
1093 SHADER_FUNC3 (smoothstep)
1094 SHADER_FUNC1 (sqrt)
1095 SHADER_FUNC2 (step)
1096 SHADER_FUNC1 (tan)
1097 SHADER_FUNC2_(texture_1d, texture1D)
1098 SHADER_FUNC3_(texture_1d, texture1D)
1099 SHADER_FUNC3_(texture_1d_lod, texture1DLod)
1100 SHADER_FUNC2_(texture_1d_proj, texture1DProj)
1101 SHADER_FUNC3_(texture_1d_proj, texture1DProj)
1102 SHADER_FUNC3_(texture_1d_proj_lod, texture1DProjLod)
1103 SHADER_FUNC2_(texture_2d, texture2D)
1104 SHADER_FUNC3_(texture_2d, texture2D)
1105 SHADER_FUNC3_(texture_2d_lod, texture2DLod)
1106 SHADER_FUNC2_(texture_2d_proj, texture2DProj)
1107 SHADER_FUNC3_(texture_2d_proj, texture2DProj)
1108 SHADER_FUNC3_(texture_2d_proj_lod, texture2DProjLod)
1109 SHADER_FUNC2_(texture_3d, texture3D)
1110 SHADER_FUNC3_(texture_3d, texture3D)
1111 SHADER_FUNC3_(texture_3d_lod, texture3DLod)
1112 SHADER_FUNC2_(texture_3d_proj, texture3DProj)
1113 SHADER_FUNC3_(texture_3d_proj, texture3DProj)
1114 SHADER_FUNC3_(texture_3d_proj_lod, texture3DProjLod)
1115 SHADER_FUNC2_(texture_cube, textureCube)
1116 SHADER_FUNC3_(texture_cube, textureCube)
1117 SHADER_FUNC3_(texture_cude_lod, textureCubeLod)
1118 SHADER_FUNC1 (vec2) SHADER_FUNC2 (vec2)
1119 SHADER_FUNC1 (vec3) SHADER_FUNC2 (vec3) SHADER_FUNC3 (vec3)
1120 SHADER_FUNC1 (vec4) SHADER_FUNC2 (vec4) SHADER_FUNC3 (vec4) SHADER_FUNC4 (vec4)
1121 SHADER_FUNC1 (mat2) SHADER_FUNC2 (mat2)
1122 SHADER_FUNC1 (mat3) SHADER_FUNC2 (mat3) SHADER_FUNC3 (mat3)
1123 SHADER_FUNC1 (mat4) SHADER_FUNC2 (mat4) SHADER_FUNC3 (mat4) SHADER_FUNC4 (mat4)
1124
1125# undef SHADER_FUNC0
1126# undef SHADER_FUNC0_
1127# undef SHADER_FUNC1
1128# undef SHADER_FUNC1_
1129# undef SHADER_FUNC2
1130# undef SHADER_FUNC2_
1131# undef SHADER_FUNC3
1132# undef SHADER_FUNC3_
1133# undef SHADER_FUNC4
1134# undef SHADER_FUNC5_
1135
1136 void debdebdebdebug ();//D
1137} 1211}
1138 1212
1139#endif 1213#endif
1140 1214
1215#include "shader_vars.h"
1216
1217

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines