diff options
author | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 16:20:36 -0500 |
---|---|---|
committer | Morten Hustveit <morten.hustveit@gmail.com> | 2014-12-02 16:20:36 -0500 |
commit | a9fd902610a81d0bcbfde0fbc7377d839a41ffa2 (patch) | |
tree | e35744a5e0a2d304f05e9480f1eb3a887aaf6c96 /ray.c | |
parent | 4ddcfc0bb65d82d4e3fd2d424912086a4b454fdf (diff) |
ray.c: Use __builtin_expect to mark sphere collisions as unlikely
This saves 10ms/frame on yelena.
Diffstat (limited to 'ray.c')
-rw-r--r-- | ray.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -16,6 +16,14 @@ #define TAU 6.28318531 +#if __GNUC__ >= 3 +# define unlikely(cond) __builtin_expect ((cond), 0) +# define likely(cond) __builtin_expect ((cond), 1) +#else +# define unlikely(cond) (cond) +# define likely(cond) (cond) +#endif + typedef struct { float position[3]; float radius; @@ -56,7 +64,7 @@ trace(const float s[3], const float d[3], float pixel[3], int n, unsigned int ma t = sphere_intersect(y, r, s, d, objects[j].position, objects[j].radius); - if(t > 0) { + if(unlikely(t > 0)) { for(m = 0; m < LENGTH(lights); ++m) { for(i = 0; i < 3; ++i) l[i] = lights[m].position[i] - y[i]; |