summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2015-02-03 18:24:29 -0500
committerGravatar bunnei2015-02-04 22:15:44 -0500
commit8c93a28fed67fe9f93199aa6ff2e2444179bdb56 (patch)
treec79e65a21e9b912922c76480f6cb739d3d9f8ea5 /src
parentMerge pull request #534 from neobrain/disassembler-improvements (diff)
downloadyuzu-8c93a28fed67fe9f93199aa6ff2e2444179bdb56.tar.gz
yuzu-8c93a28fed67fe9f93199aa6ff2e2444179bdb56.tar.xz
yuzu-8c93a28fed67fe9f93199aa6ff2e2444179bdb56.zip
VideoCore: Added same-component swizzlers to math utility functions.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/math.h51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/video_core/math.h b/src/video_core/math.h
index 9622e7614..c176b225a 100644
--- a/src/video_core/math.h
+++ b/src/video_core/math.h
@@ -457,27 +457,41 @@ public:
457 const T& b() const { return z; } 457 const T& b() const { return z; }
458 const T& a() const { return w; } 458 const T& a() const { return w; }
459 459
460 // swizzlers - create a subvector of specific components 460 // Swizzlers - Create a subvector of specific components
461 // e.g. Vec2 uv() { return Vec2(x,y); } 461 // e.g. Vec2 uv() { return Vec2(x,y); }
462 // _DEFINE_SWIZZLER2 defines a single such function, DEFINE_SWIZZLER2 defines all of them for all component names (x<->r) and permutations (xy<->yx) 462
463 // _DEFINE_SWIZZLER2 defines a single such function
464 // DEFINE_SWIZZLER2_COMP1 defines one-component functions for all component names (x<->r)
465 // DEFINE_SWIZZLER2_COMP2 defines two component functions for all component names (x<->r) and permutations (xy<->yx)
463#define _DEFINE_SWIZZLER2(a, b, name) const Vec2<T> name() const { return Vec2<T>(a, b); } 466#define _DEFINE_SWIZZLER2(a, b, name) const Vec2<T> name() const { return Vec2<T>(a, b); }
464#define DEFINE_SWIZZLER2(a, b, a2, b2) \ 467#define DEFINE_SWIZZLER2_COMP1(a, a2) \
468 _DEFINE_SWIZZLER2(a, a, a##a); \
469 _DEFINE_SWIZZLER2(a, a, a2##a2)
470#define DEFINE_SWIZZLER2_COMP2(a, b, a2, b2) \
465 _DEFINE_SWIZZLER2(a, b, a##b); \ 471 _DEFINE_SWIZZLER2(a, b, a##b); \
466 _DEFINE_SWIZZLER2(a, b, a2##b2); \ 472 _DEFINE_SWIZZLER2(a, b, a2##b2); \
467 _DEFINE_SWIZZLER2(b, a, b##a); \ 473 _DEFINE_SWIZZLER2(b, a, b##a); \
468 _DEFINE_SWIZZLER2(b, a, b2##a2) 474 _DEFINE_SWIZZLER2(b, a, b2##a2)
469 475
470 DEFINE_SWIZZLER2(x, y, r, g); 476 DEFINE_SWIZZLER2_COMP2(x, y, r, g);
471 DEFINE_SWIZZLER2(x, z, r, b); 477 DEFINE_SWIZZLER2_COMP2(x, z, r, b);
472 DEFINE_SWIZZLER2(x, w, r, a); 478 DEFINE_SWIZZLER2_COMP2(x, w, r, a);
473 DEFINE_SWIZZLER2(y, z, g, b); 479 DEFINE_SWIZZLER2_COMP2(y, z, g, b);
474 DEFINE_SWIZZLER2(y, w, g, a); 480 DEFINE_SWIZZLER2_COMP2(y, w, g, a);
475 DEFINE_SWIZZLER2(z, w, b, a); 481 DEFINE_SWIZZLER2_COMP2(z, w, b, a);
476#undef DEFINE_SWIZZLER2 482 DEFINE_SWIZZLER2_COMP1(x, r);
483 DEFINE_SWIZZLER2_COMP1(y, g);
484 DEFINE_SWIZZLER2_COMP1(z, b);
485 DEFINE_SWIZZLER2_COMP1(w, a);
486#undef DEFINE_SWIZZLER2_COMP1
487#undef DEFINE_SWIZZLER2_COMP2
477#undef _DEFINE_SWIZZLER2 488#undef _DEFINE_SWIZZLER2
478 489
479#define _DEFINE_SWIZZLER3(a, b, c, name) const Vec3<T> name() const { return Vec3<T>(a, b, c); } 490#define _DEFINE_SWIZZLER3(a, b, c, name) const Vec3<T> name() const { return Vec3<T>(a, b, c); }
480#define DEFINE_SWIZZLER3(a, b, c, a2, b2, c2) \ 491#define DEFINE_SWIZZLER3_COMP1(a, a2) \
492 _DEFINE_SWIZZLER3(a, a, a, a##a##a); \
493 _DEFINE_SWIZZLER3(a, a, a, a2##a2##a2)
494#define DEFINE_SWIZZLER3_COMP3(a, b, c, a2, b2, c2) \
481 _DEFINE_SWIZZLER3(a, b, c, a##b##c); \ 495 _DEFINE_SWIZZLER3(a, b, c, a##b##c); \
482 _DEFINE_SWIZZLER3(a, c, b, a##c##b); \ 496 _DEFINE_SWIZZLER3(a, c, b, a##c##b); \
483 _DEFINE_SWIZZLER3(b, a, c, b##a##c); \ 497 _DEFINE_SWIZZLER3(b, a, c, b##a##c); \
@@ -491,11 +505,16 @@ public:
491 _DEFINE_SWIZZLER3(c, a, b, c2##a2##b2); \ 505 _DEFINE_SWIZZLER3(c, a, b, c2##a2##b2); \
492 _DEFINE_SWIZZLER3(c, b, a, c2##b2##a2) 506 _DEFINE_SWIZZLER3(c, b, a, c2##b2##a2)
493 507
494 DEFINE_SWIZZLER3(x, y, z, r, g, b); 508 DEFINE_SWIZZLER3_COMP3(x, y, z, r, g, b);
495 DEFINE_SWIZZLER3(x, y, w, r, g, a); 509 DEFINE_SWIZZLER3_COMP3(x, y, w, r, g, a);
496 DEFINE_SWIZZLER3(x, z, w, r, b, a); 510 DEFINE_SWIZZLER3_COMP3(x, z, w, r, b, a);
497 DEFINE_SWIZZLER3(y, z, w, g, b, a); 511 DEFINE_SWIZZLER3_COMP3(y, z, w, g, b, a);
498#undef DEFINE_SWIZZLER3 512 DEFINE_SWIZZLER3_COMP1(x, r);
513 DEFINE_SWIZZLER3_COMP1(y, g);
514 DEFINE_SWIZZLER3_COMP1(z, b);
515 DEFINE_SWIZZLER3_COMP1(w, a);
516#undef DEFINE_SWIZZLER3_COMP1
517#undef DEFINE_SWIZZLER3_COMP3
499#undef _DEFINE_SWIZZLER3 518#undef _DEFINE_SWIZZLER3
500}; 519};
501 520