clray
diff rt.cl @ 45:8047637961a2
fixed the issue of hitting maximum vertical image sizes for large kdtrees
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 29 Aug 2010 04:20:42 +0100 |
parents | f9eec11e5acc |
children | 30bf84881553 |
line diff
1.1 --- a/rt.cl Sat Aug 28 21:50:17 2010 +0100 1.2 +++ b/rt.cl Sun Aug 29 04:20:42 2010 +0100 1.3 @@ -1,4 +1,5 @@ 1.4 /* vim: set ft=opencl:ts=4:sw=4 */ 1.5 +#include "common.h" 1.6 1.7 struct RendInfo { 1.8 float4 ambient; 1.9 @@ -58,7 +59,6 @@ 1.10 float4 min, max; 1.11 }; 1.12 1.13 -#define MAX_NODE_FACES 32 1.14 struct KDNode { 1.15 struct AABBox aabb; 1.16 int face_idx[MAX_NODE_FACES]; 1.17 @@ -67,7 +67,6 @@ 1.18 int padding; 1.19 }; 1.20 1.21 -#define RAY_MAG 500.0 1.22 #define MIN_ENERGY 0.001 1.23 #define EPSILON 1e-5 1.24 1.25 @@ -176,7 +175,7 @@ 1.26 return dcol + scol; 1.27 } 1.28 1.29 -#define STACK_SIZE 64 1.30 +#define STACK_SIZE MAX_TREE_DEPTH 1.31 bool find_intersection(struct Ray ray, const struct Scene *scn, struct SurfPoint *spres, read_only image2d_t kdimg) 1.32 { 1.33 struct SurfPoint sp0; 1.34 @@ -369,20 +368,22 @@ 1.35 // read a KD-tree node from a texture scanline 1.36 void read_kdnode(int idx, struct KDNode *node, read_only image2d_t kdimg) 1.37 { 1.38 + int startx = KDIMG_NODE_WIDTH * (idx / KDIMG_MAX_HEIGHT); 1.39 + 1.40 int2 tc; 1.41 - tc.x = 0; 1.42 - tc.y = idx; 1.43 + tc.x = startx; 1.44 + tc.y = idx % KDIMG_MAX_HEIGHT; 1.45 1.46 node->aabb.min = read_imagef(kdimg, kdsampler, tc); tc.x++; 1.47 node->aabb.max = read_imagef(kdimg, kdsampler, tc); 1.48 1.49 - tc.x = 2 + MAX_NODE_FACES / 4; 1.50 + tc.x = startx + 2 + MAX_NODE_FACES / 4; 1.51 float4 pix = read_imagef(kdimg, kdsampler, tc); 1.52 node->num_faces = (int)pix.x; 1.53 node->left = (int)pix.y; 1.54 node->right = (int)pix.z; 1.55 1.56 - tc.x = 2; 1.57 + tc.x = startx + 2; 1.58 for(int i=0; i<node->num_faces; i+=4) { 1.59 float4 pix = read_imagef(kdimg, kdsampler, tc); tc.x++; 1.60 node->face_idx[i] = (int)pix.x;