Hello,
I’m currently porting a ray tracer with bvh traversal (stack based) to CUDA. The tree traversal works in emu mode, but not on the device. It gives me an cudaErrorUnknown after traversal when copying the result image back to the host. Using brute force ray tracing the memcpy works fine, so that doesn’t seem to be the problem. The tree traversal works in other (non-CUDA) applications.
Furthermore, I get wrong pixels on my desktop after the error, you can see it in the attached screenshot.
I think I don’t copy the tree correctly to the device, so here’s the code:
struct BVHNode{
int splitAxis;
float3 bbmin, bbmax;
BVHNode *child0;
BVHNode *child1;
Triangle *tris;
int numTris;
};
//node = node on host
//node_d = node on device
void CopyBVHToDevice(BVHNode*& node, BVHNode*& node_d)
{
//allocate node on device and copy host node
cudaMalloc( (void**)&node_d, sizeof(BVHNode));
cudaMemcpy(node_d, node, sizeof(BVHNode), cudaMemcpyHostToDevice);
//allocate memory for triangle array and copy from host node triangles
cudaMalloc( (void**)&node_d->tris, sizeof(Triangle)*node->numTris);
cudaMemcpy(node_d->tris, node->tris, sizeof(Triangle)*node->numTris, cudaMemcpyHostToDevice);
//continue with child nodes
if(node->child0 !=0)
{
CopyBVHToDevice(node->child0, node_d->child0);
}
if(node->child1 !=0)
{
CopyBVHToDevice(node->child1, node_d->child1);
}
}
When printing out the node-addresses they all look valid, but the tree traversal code seems to stop working after the root node.
I hope I just made a stupid error and somebody can help me.
I’m working on Vista 64-Bit, NV GTX 260 (driver 177.84, latest CUDA sdk/toolkit), MS VS 2005 Pro, Q6600 CPU, 4 GB RAM, MSI P6N mainboard
[attachment=7457:attachment]