clray

changeset 7:575383f3a239

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 23 Jul 2010 01:22:03 +0100
parents b06518bb16e9
children deaf85acf6af
files rt.cl src/rt.cc
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/rt.cl	Tue Jul 20 20:02:41 2010 +0100
     1.2 +++ b/rt.cl	Fri Jul 23 01:22:03 2010 +0100
     1.3 @@ -25,6 +25,10 @@
     1.4  	global const struct Sphere *obj;
     1.5  };
     1.6  
     1.7 +struct Matrix4x4 {
     1.8 +	float m[16];
     1.9 +};
    1.10 +
    1.11  #define EPSILON 1e-6
    1.12  
    1.13  float4 shade(struct Ray ray, struct SurfPoint sp,
    1.14 @@ -37,7 +41,8 @@
    1.15  		global const struct RendInfo *rinf,
    1.16  		global const struct Sphere *sphlist,
    1.17  		global const struct Light *lights,
    1.18 -		global const struct Ray *primrays)
    1.19 +		global const struct Ray *primrays,
    1.20 +		global const struct Matrix4x4 xform)
    1.21  {
    1.22  	int idx = get_global_id(0);
    1.23  
     2.1 --- a/src/rt.cc	Tue Jul 20 20:02:41 2010 +0100
     2.2 +++ b/src/rt.cc	Fri Jul 23 01:22:03 2010 +0100
     2.3 @@ -25,6 +25,9 @@
     2.4  	cl_float4 pos, color;
     2.5  } __attribute__((packed));
     2.6  
     2.7 +struct Matrix4x4 {
     2.8 +	cl_float m[16];
     2.9 +};
    2.10  
    2.11  static Ray get_primary_ray(int x, int y, int w, int h, float vfov_deg);
    2.12  
    2.13 @@ -41,6 +44,10 @@
    2.14  	{{-10, 10, -20, 1}, {1, 1, 1, 1}}
    2.15  };
    2.16  
    2.17 +static Matrix4x4 xform = {
    2.18 +	{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}
    2.19 +};
    2.20 +
    2.21  static RendInfo rinf;
    2.22  
    2.23  
    2.24 @@ -74,6 +81,7 @@
    2.25  	prog->set_arg_buffer(2, ARG_RD, sizeof sphlist, sphlist);
    2.26  	prog->set_arg_buffer(3, ARG_RD, sizeof lightlist, lightlist);
    2.27  	prog->set_arg_buffer(4, ARG_RD, xsz * ysz * sizeof *prim_rays, prim_rays);
    2.28 +	prog->set_arg_buffer(5, ARG_RD, sizeof xform, &xform);
    2.29  
    2.30  	global_size = xsz * ysz;
    2.31  	return true;