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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines