Skip to content

Commit df7e100

Browse files
committed
Remove unused get_ray_directions and update test to use PixelCoordRange
1 parent 0c08abb commit df7e100

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

genmetaballs/src/cuda/core/camera.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ CUDA_CALLABLE bool PixelCoordRange::Sentinel::operator==(const Iterator& it) con
3030
return it.py >= py_end;
3131
}
3232

33-
CUDA_CALLABLE constexpr PixelCoordRange::Iterator PixelCoordRange::begin() const {
33+
CUDA_CALLABLE PixelCoordRange::Iterator PixelCoordRange::begin() const {
3434
return Iterator{px_start, px_end, py_start, px_start, py_start};
3535
}
3636

37-
CUDA_CALLABLE constexpr PixelCoordRange::Sentinel PixelCoordRange::end() const {
37+
CUDA_CALLABLE PixelCoordRange::Sentinel PixelCoordRange::end() const {
3838
return Sentinel{py_end};
3939
}

genmetaballs/src/cuda/core/camera.cuh

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <cstdint>
4-
#include <cuda/std/ranges>
54
#include <cuda/std/utility>
65
#include <cuda_runtime.h>
76

@@ -19,25 +18,9 @@ struct Intrinsics {
1918
// Returns the direction of the ray going through pixel (px, py) in camera frame.
2019
// For efficiency, this function does not check if the pixel is within bounds.
2120
CUDA_CALLABLE Vec3D get_ray_direction(uint32_t px, uint32_t py) const;
22-
23-
// Returns a 2D array of ray directions in camera frame in the specified pixel range
24-
// and store them in the provided buffer. By default, the full image is used
25-
template <MemoryLocation location>
26-
CUDA_CALLABLE Array2D<Vec3D, location>& get_ray_directions(Array2D<Vec3D, location>& buffer,
27-
uint32_t px_start = 0,
28-
uint32_t px_end = UINT32_MAX,
29-
uint32_t py_start = 0,
30-
uint32_t py_end = UINT32_MAX) const {
31-
for (auto i = max(0, px_start); i < min(height, px_end); ++i) {
32-
for (auto j = max(0, py_start); j < min(width, py_end); ++j) {
33-
buffer[i][j] = get_ray_direction(j, i);
34-
}
35-
}
36-
return buffer;
37-
}
3821
};
3922

40-
struct PixelCoordRange : public cuda::std::ranges::view_interface<PixelCoordRange> {
23+
struct PixelCoordRange {
4124
uint32_t px_start;
4225
uint32_t px_end;
4326
uint32_t py_start;
@@ -70,6 +53,6 @@ struct PixelCoordRange : public cuda::std::ranges::view_interface<PixelCoordRang
7053
};
7154

7255
// range methods
73-
CUDA_CALLABLE constexpr Iterator begin() const;
74-
CUDA_CALLABLE constexpr Sentinel end() const;
56+
CUDA_CALLABLE Iterator begin() const;
57+
CUDA_CALLABLE Sentinel end() const;
7558
};

tests/cpp_tests/test_camera.cu

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111

1212
namespace test_camera_gpu {
1313

14-
// CUDA kernel to call get_ray_directions on device with multiple threads
15-
// Each thread processes one row of the image
14+
// CUDA kernel to call get_ray_direction on device with multiple threads
15+
// Each thread processes one row of the image via PixelCoordRange
1616
__global__ void get_ray_directions_kernel(Intrinsics intrinsics,
1717
Array2D<Vec3D, MemoryLocation::DEVICE> ray_buffer) {
1818
uint32_t row_start = threadIdx.x * 2;
1919
uint32_t row_end = max(row_start + 2, intrinsics.height);
2020
uint32_t col_start = threadIdx.y * 2;
2121
uint32_t col_end = max(col_start + 2, intrinsics.width);
22-
intrinsics.get_ray_directions(ray_buffer, row_start, row_end, col_start, col_end);
22+
auto pixel_coords = PixelCoordRange{row_start, row_end, col_start, col_end};
23+
24+
for (auto [px, py] : pixel_coords) {
25+
ray_buffer[px][py] = intrinsics.get_ray_direction(px, py);
26+
}
2327
}
2428

2529
} // namespace test_camera_gpu

0 commit comments

Comments
 (0)