feat: Implement CUDA support for VoxRaytracer, add CUDA tests for voxel image operations, and update CMake to enable CUDA compilation.
This commit is contained in:
@@ -48,6 +48,11 @@ int Vector4f0(Vector4f c) {
|
||||
|
||||
typedef VoxRaytracer Raytracer;
|
||||
|
||||
struct TestVoxel {
|
||||
float Value;
|
||||
int Count;
|
||||
};
|
||||
|
||||
int main() {
|
||||
BEGIN_TESTING(Math VoxRaytracer);
|
||||
|
||||
@@ -132,5 +137,41 @@ int main() {
|
||||
ray.PrintSelf(std::cout);
|
||||
}
|
||||
|
||||
#ifdef USE_CUDA
|
||||
{
|
||||
std::cout << "\n--- Testing CUDA Raytracer Accumulator ---\n";
|
||||
|
||||
VoxImage<TestVoxel> img_cuda(Vector3i(4, 4, 4));
|
||||
img_cuda.SetSpacing(Vector3f(2, 2, 2));
|
||||
img_cuda.SetPosition(Vector3f(-4, -4, -4));
|
||||
|
||||
Raytracer ray(img_cuda);
|
||||
|
||||
HLine3f line1;
|
||||
line1.origin << -3, -3, -3, 1;
|
||||
line1.direction << 1, 1, 1, 0;
|
||||
|
||||
HLine3f line2;
|
||||
line2.origin << -3, -3, 1, 1;
|
||||
line2.direction << 1, 1, -1, 0;
|
||||
|
||||
HLine3f lines[2] = {line1, line2};
|
||||
// Execute CUDA kernel wrapper over target VoxImage mapped internally into
|
||||
// VRAM
|
||||
ray.AccumulateLinesCUDA(lines, 2, img_cuda);
|
||||
|
||||
// Validate device synchronization returned data correctly pulling back to
|
||||
// host
|
||||
TEST1(img_cuda.Data().GetDevice() !=
|
||||
MemoryDevice::RAM); // Confirms VRAM executed
|
||||
|
||||
// Pull down checking values
|
||||
float l_val = img_cuda[img_cuda.Find(Vector4f(-3, -3, -3, 1))].Value;
|
||||
std::cout << "Accumulated Voxel test trace point length returned: " << l_val
|
||||
<< "\n";
|
||||
TEST1(l_val > 0.1f);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_TESTING
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user