Skip to content

Commit

Permalink
add basic TSD GitHub CI, add options to disable various features
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffamstutz committed Jan 7, 2025
1 parent 304ba3a commit 2d12a9c
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 43 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/tsd_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: TSD CI

on:
push:
branches: [ next_release ]
pull_request:
branches: [ main, next_release ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
config: [Release, Debug]

steps:
- uses: actions/checkout@v3

- name: Install Packages
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install -y libtbb-dev

- name: Configure ANARI-SDK CMake
run: >
cmake -LA -B ${{github.workspace}}/deps_build
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/deps
${{github.workspace}}/tsd/cmake/build_deps
- name: Build + install ANARI-SDK
run: cmake --build ${{github.workspace}}/deps_build --config ${{ matrix.config }}

- name: Configure TSD CMake
run: >
cmake -LA -B ${{github.workspace}}/build
-DBUILD_APPS_INTERACTIVE=OFF
-DCMAKE_PREFIX_PATH=${{github.workspace}}/deps
-DCMAKE_BUILD_TYPE=${{ matrix.config }}
-DTSD_USE_ASSIMP=OFF
-DTSD_USE_CUDA=OFF
-DTSD_USE_HDF5=OFF
-DTSD_USE_OPENGL=OFF
-DTSD_ENABLE_SERIALIZATION=OFF
${{github.workspace}}/tsd
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{ matrix.config }}

- name: Unit Tests
working-directory: ${{github.workspace}}/build
run: ctest -C ${{ matrix.config }}
20 changes: 0 additions & 20 deletions ci/.gitlab-ci.yml

This file was deleted.

11 changes: 0 additions & 11 deletions ci/build_linux.sh

This file was deleted.

7 changes: 0 additions & 7 deletions ci/build_win.ps1

This file was deleted.

9 changes: 8 additions & 1 deletion tsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

## Global options ##

option(BUILD_APPS_INTERACTIVE "Build interactive applications" ON)
option(TSD_ENABLE_SERIALIZATION "Use conduit to serialize contexts" OFF)
option(TSD_USE_HDF5 "Support loading AMR grids from HDF5" OFF)
option(TSD_USE_ASSIMP "Support loading geometry with libassimp" OFF)
option(TSD_USE_OPENGL "Use OpenGL interop in render pipeline" ON)

if (APPLE)
set(TSD_USE_CUDA OFF)
Expand All @@ -43,7 +45,12 @@ endif()

project(tsd LANGUAGES CXX)

find_package(anari ${ANARI_REQUIRED_VERSION} REQUIRED COMPONENTS viewer)
if (BUILD_APPS_INTERACTIVE)
find_package(anari ${ANARI_REQUIRED_VERSION} REQUIRED COMPONENTS viewer)
else()
find_package(anari ${ANARI_REQUIRED_VERSION} REQUIRED)
endif()

if (TSD_USE_CUDA)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
Expand Down
4 changes: 3 additions & 1 deletion tsd/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Copyright 2024 NVIDIA Corporation
## SPDX-License-Identifier: Apache-2.0

add_subdirectory(interactive)
if (BUILD_APPS_INTERACTIVE)
add_subdirectory(interactive)
endif()
add_subdirectory(simple)
add_subdirectory(tools)
53 changes: 53 additions & 0 deletions tsd/cmake/build_deps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required(VERSION 3.12)

if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX
"${CMAKE_BINARY_DIR}/install"
CACHE STRING "Final install location." FORCE)
endif()

project(tsd_dependencies)

include(superbuild_macros.cmake)

## Build projects ##

build_subproject(
NAME anari-sdk
URL "https://github.com/KhronosGroup/ANARI-SDK/archive/refs/heads/next_release.zip"
BUILD_ARGS
-DBUILD_EXAMPLES=OFF
-DBUILD_HDANARI=OFF
-DBUILD_HELIDE_DEVICE=OFF
-DBUILD_REMOTE_DEVICE=OFF
-DBUILD_TESTING=OFF
)
110 changes: 110 additions & 0 deletions tsd/cmake/build_deps/superbuild_macros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

## Included CMake modules ##

include(ExternalProject)
include(GNUInstallDirs)
include(ProcessorCount)

## Variables ##

ProcessorCount(PROCESSOR_COUNT)
set(NUM_BUILD_JOBS ${PROCESSOR_COUNT} CACHE STRING "Number of build jobs '-j <n>'")
set(DEFAULT_BUILD_COMMAND cmake --build . --config release -j ${NUM_BUILD_JOBS})
get_filename_component(INSTALL_DIR_ABSOLUTE
${CMAKE_INSTALL_PREFIX} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})

## Functions/macros ##

function(print)
foreach(arg ${ARGN})
message("${arg} = ${${arg}}")
endforeach()
endfunction()

macro(append_cmake_prefix_path)
list(APPEND CMAKE_PREFIX_PATH ${ARGN})
string(REPLACE ";" "|" CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
endmacro()

macro(setup_subproject_path_vars _NAME)
set(SUBPROJECT_NAME ${_NAME})

set(SUBPROJECT_INSTALL_PATH ${INSTALL_DIR_ABSOLUTE})

set(SUBPROJECT_SOURCE_PATH ${SUBPROJECT_NAME}/source)
set(SUBPROJECT_STAMP_PATH ${SUBPROJECT_NAME}/stamp)
set(SUBPROJECT_BUILD_PATH ${SUBPROJECT_NAME}/build)
endmacro()

macro(build_subproject)
# See cmake_parse_arguments docs to see how args get parsed here:
# https://cmake.org/cmake/help/latest/command/cmake_parse_arguments.html
set(oneValueArgs NAME URL)
set(multiValueArgs BUILD_ARGS DEPENDS_ON)
cmake_parse_arguments(BUILD_SUBPROJECT "" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})

# Setup SUBPROJECT_* variables (containing paths) for this function
setup_subproject_path_vars(${BUILD_SUBPROJECT_NAME})

# Build the actual subproject
ExternalProject_Add(${SUBPROJECT_NAME}
PREFIX ${SUBPROJECT_NAME}
DOWNLOAD_DIR ${SUBPROJECT_NAME}
STAMP_DIR ${SUBPROJECT_STAMP_PATH}
SOURCE_DIR ${SUBPROJECT_SOURCE_PATH}
BINARY_DIR ${SUBPROJECT_BUILD_PATH}
URL ${BUILD_SUBPROJECT_URL}
LIST_SEPARATOR | # Use the alternate list separator
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${SUBPROJECT_INSTALL_PATH}
-DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
-DCMAKE_INSTALL_DOCDIR=${CMAKE_INSTALL_DOCDIR}
-DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
${BUILD_SUBPROJECT_BUILD_ARGS}
BUILD_COMMAND ${DEFAULT_BUILD_COMMAND}
BUILD_ALWAYS OFF
)

if(BUILD_SUBPROJECT_DEPENDS_ON)
ExternalProject_Add_StepDependencies(${SUBPROJECT_NAME}
configure ${BUILD_SUBPROJECT_DEPENDS_ON}
)
endif()

# Place installed component on CMAKE_PREFIX_PATH for downstream consumption
append_cmake_prefix_path(${SUBPROJECT_INSTALL_PATH})
endmacro()
11 changes: 8 additions & 3 deletions tsd/src/render_pipeline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

project(render_pipeline LANGUAGES CXX)

find_package(OpenGL REQUIRED)

project_add_library(STATIC)
project_sources(PRIVATE RenderPass.cpp RenderPipeline.cpp)
project_include_directories(PUBLIC ${CMAKE_CURRENT_LIST_DIR}/..)
project_link_libraries(PUBLIC tsd OpenGL::GL)
project_link_libraries(PUBLIC tsd)

if (TSD_USE_CUDA)
project_link_libraries(PRIVATE CUDA::cudart)
Expand All @@ -23,3 +21,10 @@ else()
find_package(TBB REQUIRED)
project_link_libraries(PRIVATE TBB::tbb)
endif()

if (TSD_USE_OPENGL)
find_package(OpenGL REQUIRED)
project_link_libraries(PUBLIC tsd OpenGL::GL)
project_compile_definitions(PRIVATE ENABLE_OPENGL)
endif()

2 changes: 2 additions & 0 deletions tsd/src/render_pipeline/RenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ void OutlineRenderPass::render(Buffers &b, int stageId)
computeOutline(b, m_outlineId, getDimensions());
}

#ifdef ENABLE_OPENGL
///////////////////////////////////////////////////////////////////////////////
// CopyToGLImagePass //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -411,6 +412,7 @@ void CopyToGLImagePass::updateSize()
cudaGraphicsRegisterFlagsWriteDiscard);
#endif
}
#endif

///////////////////////////////////////////////////////////////////////////////
// Utility functions //////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions tsd/src/render_pipeline/RenderPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <vector>
// anari
#include <anari/anari_cpp.hpp>

#ifdef ENABLE_OPENGL
// OpenGL
#if __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif

namespace tsd {

Expand Down Expand Up @@ -106,6 +109,7 @@ struct OutlineRenderPass : public RenderPass
uint32_t m_outlineId{~0u};
};

#ifdef ENABLE_OPENGL
struct CopyToGLImagePass : public RenderPass
{
CopyToGLImagePass();
Expand All @@ -120,6 +124,7 @@ struct CopyToGLImagePass : public RenderPass
struct CopyToGLImagePassImpl;
CopyToGLImagePassImpl *m_impl{nullptr};
};
#endif

// Utility functions //////////////////////////////////////////////////////////

Expand Down

0 comments on commit 2d12a9c

Please sign in to comment.