Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 87 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set(DEEPEERT_VERSION_MAJOR 0)
set(DEEPEERT_VERSION_MINOR 3)
set(DEEPEERT_VERSION_PATCH 2)
set(DEEPEERT_VERSION ${DEEPEERT_VERSION_MAJOR}.${DEEPEERT_VERSION_MINOR}.${DEEPEERT_VERSION_PATCH})

set(CMAKE_BUILD_TYPE_INIT "Release")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CUDA_ARCHITECTURES native)

cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0048 NEW)
project(DeePeeRT VERSION 0.1.0 LANGUAGES C CXX CUDA)
project(deepeeRT VERSION ${DEEPEERT_VERSION} LANGUAGES C CXX CUDA)

if(NOT SET_UP_CONFIGURATIONS_DONE)
set(SET_UP_CONFIGURATIONS_DONE 1)
Expand All @@ -33,14 +38,91 @@ if ((${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}))
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
endif()

option(DEEPEE_USE_LOCAL_CUBQL "Use *local* cuBQL" OFF)
mark_as_advanced(DEEPEE_USE_LOCAL_CUBQL)
if (DEEPEE_USE_LOCAL_CUBQL)
option(DEEPEERT_USE_LOCAL_CUBQL "Use *local* cuBQL" OFF)
mark_as_advanced(DEEPEERT_USE_LOCAL_CUBQL)
if (DEEPEERT_USE_LOCAL_CUBQL)
add_subdirectory(../cuBQL EXCLUDE_FROM_ALL builddir_cuBQL)
else()
add_subdirectory(submodules/cuBQL EXCLUDE_FROM_ALL builddir_cuBQL)
endif()

add_subdirectory(dp)
add_subdirectory(miniapp)

if (NOT (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}))
# don't build miniapp if this is a subproject
else()
# add_subdirectory(miniapp)
endif()


# ==================================================================
# install target(s)
# ==================================================================

include(GNUInstallDirs)

set(DEEPEERT_CMAKE_INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/deepeeRT-${DEEPEERT_VERSION}#${PROJECT_VERSION}
)

include(CMakePackageConfigHelpers)

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/dp/deepeeRTConfig.cmake.in"
"${PROJECT_BINARY_DIR}/deepeeRTConfig.cmake"
INSTALL_DESTINATION
${DEEPEERT_CMAKE_INSTALL_DESTINATION}
)

message("DEEPEERT_VERSION ${DEEPEERT_VERSION}")
write_basic_package_version_file(
"deepeeRTConfigVersion.cmake"
VERSION ${DEEPEERT_VERSION}
COMPATIBILITY SameMajorVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/deepeeRTConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/deepeeRTConfigVersion.cmake
DESTINATION
${DEEPEERT_CMAKE_INSTALL_DESTINATION}
)


install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/cmake
DESTINATION
${DEEPEERT_CMAKE_INSTALL_DESTINATION}
FILES_MATCHING
PATTERN *.cmake
PATTERN FinddeepeeRT.cmake EXCLUDE
)

install(
TARGETS
deepeeRT
# EXPORT deepeeRT
EXPORT deepeeRT-config
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_SKIP
# on Windows put the dlls into bin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
# ... and the import lib into the devel package
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(EXPORT deepeeRT-config
#install(EXPORT deepeeRT
DESTINATION ${DEEPEERT_CMAKE_INSTALL_DESTINATION}
NAMESPACE deepeeRT::
)

# configures the public api
configure_file(
${PROJECT_SOURCE_DIR}/include/deepeeRT/deepeeRT.in.h
include/deepeeRT/deepeeRT.h
)

install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/deepeeRT
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}
)

6 changes: 0 additions & 6 deletions dp/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,4 @@
#include "dp/Context.h"

namespace dp {

Backend::Backend(Context *const context)
: context(context),
gpuID(context->gpuID)
{}

} // ::dp
47 changes: 9 additions & 38 deletions dp/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@ namespace dp {
struct TrianglesDPGroup;
struct InstancesDPGroup;

/*! CAREFUL: this HAS to match the data layout of DPRRay in deepee.h !*/
/*! Internal representation of a ray in the input ray
queue. CAREFUL: this HAS to match the data layout of DPRRay in
deepee.h !*/
struct Ray {
vec3d origin;
vec3d direction;
double tMin;
double tMax;
};

/*! CAREFUL: this HAS to match the data layout of DPRHit in deepee.h !*/
/*! Internal representation of a hit in the hit queue to be traced
against. CAREFUL: this HAS to match the data layout of DPRHit in
deepee.h !*/
struct Hit {
/*! index of prim within the geometry it was created in. A value of
'-1' means 'no hit' */
int primID;

/* index of the instance that contained the hit point. Undefined if
on hit occurred */
int instID;

/*! user-supplied geom ID (the one specified during geometry create
call) for the geometry that contained the hit. Unlike primID and
instID this is *not* a linear ID, but whatever int64 value the
Expand All @@ -35,41 +41,6 @@ namespace dp {
double u, v;
};

/*! implements a group of double-precision triangles */
struct TrianglesDPImpl {
TrianglesDPImpl(TrianglesDPGroup *const fe) : fe(fe) {}
virtual ~TrianglesDPImpl() = default;
TrianglesDPGroup *const fe;
};

/*! implements a group of double-precision instances, including the
actual trace() method */
struct InstancesDPImpl {
InstancesDPImpl(InstancesDPGroup *const fe) : fe(fe) {}
virtual ~InstancesDPImpl() = default;

virtual void trace(Ray *rays,
Hit *hits,
int numRays) = 0;

InstancesDPGroup *const fe;
};

/*! implements an actual backend for a double-precision ray tracing
context. primarily acts as 'factory' for instance and geometry
groups that then do the actual work */
struct Backend {
Backend(Context *const context);
virtual ~Backend() = default;

virtual std::shared_ptr<InstancesDPImpl>
createInstancesDPImpl(dp::InstancesDPGroup *fe) = 0;

virtual std::shared_ptr<TrianglesDPImpl>
createTrianglesDPImpl(dp::TrianglesDPGroup *fe) = 0;

Context *const context;
int const gpuID;
};

static Context *createBackend(int gpuID);
} // ::dp
46 changes: 31 additions & 15 deletions dp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,52 @@

find_package(CUDAToolkit REQUIRED)

add_library(deepeeRT_common STATIC
Backend.h
Backend.cpp
add_library(deepeeRT_common INTERFACE#STATIC
)
target_include_directories(deepeeRT_common PUBLIC
${PROJECT_SOURCE_DIR}
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
target_include_directories(deepeeRT_common INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>/include
# $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
target_link_libraries(deepeeRT_common PUBLIC
target_link_libraries(deepeeRT_common INTERFACE#PUBLIC
cuBQL
CUDA::cuda_driver
CUDA::cudart_static
)
target_compile_definitions(deepeeRT_common INTERFACE#PUBLIC
-DdeepeeRT_STATIC=1)

add_library(deepeeRT STATIC
../include/deepee/deepee.h
../include/deepeeRT/deepeeRT.h
Backend.h
Backend.cpp
common.h
Triangles.h
Triangles.cu
Triangles.cpp
World.h
World.cu
World.cpp
Group.h
Group.cpp
Context.h
Context.cpp
Group.h
Group.cu
deepeeRT.cpp
)
target_include_directories(deepeeRT PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

add_subdirectory(cuBQL)
target_link_libraries(deepeeRT PUBLIC
deepeeRT_common
deepeeRT_cuBQL
target_link_libraries(deepeeRT PRIVATE#PUBLIC
$<BUILD_INTERFACE:deepeeRT_cuBQL>
$<BUILD_INTERFACE:deepeeRT_common>
)

set_target_properties(deepeeRT
PROPERTIES
CXX_VISIBILITY_PRESET hidden
CUDA_VISIBILITY_PRESET hidden
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
CUDA_USE_STATIC_CUDA_RUNTIME ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON
)
6 changes: 2 additions & 4 deletions dp/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ namespace dp {

Context::Context(int gpuID)
: gpuID(gpuID)
{
backend = std::make_shared<CuBQLCUDABackend>(this);
}

{}

} // ::dp

31 changes: 30 additions & 1 deletion dp/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,42 @@

#include "dp/common.h"
#include "dp/Backend.h"
#include <memory>

namespace dp {

struct InstanceGroup;
struct TriangleMesh;
struct TrianglesGroup;

struct Context {
static Context *create(int gpuID);

Context(int gpuID);

std::shared_ptr<Backend> backend;
/*! creates a 'world' as a grouping of triangle mesh groups, with
associated object-to-world space instance
transforms. Implements the dprTrace() API function */
virtual dp::InstanceGroup *
createInstanceGroup(const std::vector<dp::TrianglesGroup *> &groups,
const DPRAffine *transforms) = 0;

/*! creates an object that represents a single triangle
mesh. implements `dprCreateTrianglesDP()` */
virtual dp::TriangleMesh *
createTriangleMesh(uint64_t userData,
const vec3d *vertexArray,
int vertexCount,
const vec3i *indexArray,
int indexCount) = 0;

/*! creates an object that represents a group of multiple triangle
meshes that can then get instantiated. implements
`dprCreateTrianglesGroup()` */
virtual dp::TrianglesGroup *
createTrianglesGroup(const std::vector<dp::TriangleMesh *> &geoms) = 0;


/*! the cuda gpu ID that this device is going to run on */
int const gpuID;
};
Expand Down
14 changes: 14 additions & 0 deletions dp/Group.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

#include "dp/Group.h"
#include "dp/Context.h"

namespace dp {

Group::Group(Context *const context)
: context(context)
{}

} // ::dp

18 changes: 0 additions & 18 deletions dp/Group.cu

This file was deleted.

Loading