clray
diff src/rt.cc @ 28:97cfd9675310
trying to pass the kdtree to the kernel
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 21 Aug 2010 03:42:49 +0100 |
parents | 8b2f2ad14ae7 |
children | 353d80127627 |
line diff
1.1 --- a/src/rt.cc Tue Aug 17 20:35:00 2010 +0100 1.2 +++ b/src/rt.cc Sat Aug 21 03:42:49 2010 +0100 1.3 @@ -16,6 +16,7 @@ 1.4 KARG_PRIM_RAYS, 1.5 KARG_XFORM, 1.6 KARG_INVTRANS_XFORM, 1.7 + KARG_KDTREE, 1.8 1.9 NUM_KERNEL_ARGS 1.10 }; 1.11 @@ -25,6 +26,7 @@ 1.12 int xsz, ysz; 1.13 int num_faces, num_lights; 1.14 int max_iter; 1.15 + int kd_depth; 1.16 }; 1.17 1.18 struct Ray { 1.19 @@ -61,6 +63,7 @@ 1.20 rinf.num_faces = scn->get_num_faces(); 1.21 rinf.num_lights = sizeof lightlist / sizeof *lightlist; 1.22 rinf.max_iter = 6; 1.23 + rinf.kd_depth = kdtree_depth(scn->kdtree); 1.24 1.25 /* calculate primary rays */ 1.26 prim_rays = new Ray[xsz * ysz]; 1.27 @@ -82,6 +85,13 @@ 1.28 return false; 1.29 } 1.30 1.31 + const KDNodeGPU *kdbuf = scn->get_kdtree_buffer(); 1.32 + if(!kdbuf) { 1.33 + fprintf(stderr, "failed to create kdtree buffer\n"); 1.34 + return false; 1.35 + } 1.36 + int num_kdnodes = scn->get_num_kdnodes(); 1.37 + 1.38 /* setup argument buffers */ 1.39 prog->set_arg_buffer(KARG_FRAMEBUFFER, ARG_WR, xsz * ysz * 4 * sizeof(float)); 1.40 prog->set_arg_buffer(KARG_RENDER_INFO, ARG_RD, sizeof rinf, &rinf); 1.41 @@ -91,6 +101,7 @@ 1.42 prog->set_arg_buffer(KARG_PRIM_RAYS, ARG_RD, xsz * ysz * sizeof *prim_rays, prim_rays); 1.43 prog->set_arg_buffer(KARG_XFORM, ARG_RD, 16 * sizeof(float)); 1.44 prog->set_arg_buffer(KARG_INVTRANS_XFORM, ARG_RD, 16 * sizeof(float)); 1.45 + prog->set_arg_buffer(KARG_KDTREE, ARG_RD, num_kdnodes * sizeof *kdbuf, kdbuf); 1.46 1.47 if(prog->get_num_args() < NUM_KERNEL_ARGS) { 1.48 return false;