Skip to content

Commit 0b646e3

Browse files
committed
Rename to cu/cuh
1 parent f477dc0 commit 0b646e3

File tree

13 files changed

+49
-38
lines changed

13 files changed

+49
-38
lines changed

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
project(ray-tracing-cuda LANGUAGES CXX)
1+
project(ray-tracing-cuda LANGUAGES CXX CUDA)
22

33
set(CMAKE_CXX_STANDARD 14)
44

55
add_subdirectory(third_party)
66

7-
find_package(CUDA REQUIRED)
8-
97
set(rt_root_dir "ray-tracing-cuda")
10-
file(GLOB_RECURSE rt_srcs "${rt_root_dir}/*.cc")
8+
file(GLOB_RECURSE rt_srcs "${rt_root_dir}/*.cu")
119
add_library(rt STATIC "${rt_srcs}")
1210
target_link_libraries(rt glm)
13-
target_include_directories(rt PUBLIC "${rt_root_dir}" "${CUDA_INCLUDE_DIRS}")
11+
target_include_directories(rt PUBLIC "${rt_root_dir}")
12+
set_target_properties(rt PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
13+
target_compile_features(rt PUBLIC cxx_std_14)
14+
15+
add_executable(hello "scenes/main.cu")
16+
target_link_libraries(hello rt)
17+
set_target_properties(hello PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
18+
target_compile_features(hello PUBLIC cxx_std_14)

ray-tracing-cuda/hitable.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ struct HitRecord;
66

77
#include <memory>
88

9-
#include "material.h"
10-
#include "ray.h"
9+
#include "material.cuh"
10+
#include "ray.cuh"
1111

1212
struct HitRecord {
1313
double t;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "hitable_list.h"
1+
#include "hitable_list.cuh"
22

33
using std::pair;
44

ray-tracing-cuda/main.cu

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "material.h"
1+
#include "material.cuh"
22

33
__device__ glm::vec3 Material::Emit(double u, double v,
44
const glm::vec3 &p) const {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Material;
55
#include <glm/glm.hpp>
66

77
#include "hitable.cuh"
8-
#include "ray.h"
8+
#include "ray.cuh"
99

1010
class Material {
1111
public:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "ray.h"
1+
#include "ray.cuh"
22

33
using glm::normalize;
44
using glm::vec3;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class Ray {
66
public:
77
Ray() = delete;
88
Ray(glm::vec3 position, glm::vec3 direction);
9-
glm::vec3 position() const;
10-
glm::vec3 direction() const;
9+
__device__ __host__ glm::vec3 position() const;
10+
__device__ __host__ glm::vec3 direction() const;
1111

1212
private:
1313
glm::vec3 position_, direction_;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "sphere.h"
1+
#include "sphere.cuh"
22

33
using namespace glm;
44

55
Sphere::Sphere(vec3 position, double radius, Material* material_ptr)
66
: radius_(radius), position_(position), material_ptr_(material_ptr) {}
77

8-
bool Sphere::Hit(const Ray& ray, std::pair<double, double> t_range,
8+
__device__ bool Sphere::Hit(const Ray& ray, std::pair<double, double> t_range,
99
HitRecord* out) const {
1010
double a = pow(length(ray.direction()), 2);
1111
double b = 2 * dot(ray.direction(), ray.position() - this->position());

0 commit comments

Comments
 (0)