Skip to content

Commit

Permalink
Merge pull request #132 from AcademySoftwareFoundation/gpu-gain-example
Browse files Browse the repository at this point in the history
Gpu gain example
  • Loading branch information
garyo authored Mar 9, 2024
2 parents 36cf597 + 1b6861b commit eb626d9
Show file tree
Hide file tree
Showing 36 changed files with 2,145 additions and 155 deletions.
53 changes: 49 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: false
- name_prefix: Linux CentOS 7 VFX CY2022
release_prefix: linux-vfx2022
ostype: linux
Expand All @@ -43,6 +44,7 @@ jobs:
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: false
- name_prefix: Linux Rocky 8 VFX CY2023
release_prefix: linux-vfx2023
ostype: linux
Expand All @@ -57,6 +59,7 @@ jobs:
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: false
- name_prefix: Linux Ubuntu
release_prefix: linux-ubuntu
ostype: linux
Expand All @@ -70,6 +73,7 @@ jobs:
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: true
- name_prefix: MacOS
release_prefix: mac
ostype: mac
Expand All @@ -82,6 +86,7 @@ jobs:
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: false
- name_prefix: Windows
release_prefix: windows
ostype: windows
Expand All @@ -94,6 +99,20 @@ jobs:
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: true
- name_prefix: Windows no CUDA
release_prefix: windows-no-cuda
ostype: windows
os: windows-latest
container: null
has_cmake_presets: true
buildtype: Release
conan_version: 2.0.16
cxx-standard: 17
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
cuda: false
defaults:
run:
shell: bash
Expand Down Expand Up @@ -138,6 +157,25 @@ jobs:
brew:
brew-cask:

- name: Install CUDA Toolkit
uses: Jimver/[email protected]
id: cuda-toolkit-linux
if: matrix.ostype == 'linux' && matrix.cuda == true
with:
cuda: '12.1.0'
method: 'network'
sub-packages: '["nvcc", "cudart"]'
linux-local-args: '["--toolkit"]'

- name: Install CUDA Toolkit
uses: Jimver/[email protected]
id: cuda-toolkit-win
if: matrix.ostype == 'windows' && matrix.cuda == true
with:
cuda: '12.1.0'
method: 'network'
sub-packages: '["nvcc", "cudart", "visual_studio_integration"]'

# - name: Install system dependencies (CentOS)
# run: |
# rpm install libglvnd-devel
Expand All @@ -148,25 +186,32 @@ jobs:
- name: Configure project with cmake
run: |
[[ ${{ matrix.cuda }} = true ]] && CUDA=TRUE || CUDA=FALSE
if [[ ${{ matrix.has_cmake_presets }} = true ]]; then
# Sets up to build in e.g. build/Release
cmake --preset $CONAN_PRESET -DBUILD_EXAMPLE_PLUGINS=TRUE .
cmake --preset $CONAN_PRESET -DBUILD_EXAMPLE_PLUGINS=TRUE \
-DPLUGIN_INSTALLDIR=$(pwd)/$BUILD_DIR/Install \
-DOFX_SUPPORTS_OPENGLRENDER=TRUE \
-DOFX_SUPPORTS_CUDARENDER=$CUDA .
else
# VFX ref platforms 2022 & earlier have only cmake 3.19.
# Older cmake (<3.23) does not support presets, so invoke with explicit args.
cmake -S . -B $BUILD_DIR -G "Unix Makefiles" \
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/$BUILD_DIR/generators/conan_toolchain.cmake \
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_EXAMPLE_PLUGINS=TRUE
-DBUILD_EXAMPLE_PLUGINS=TRUE \
-DPLUGIN_INSTALLDIR=$(pwd)/$BUILD_DIR/Install \
-DOFX_SUPPORTS_OPENGLRENDER=TRUE \
-DOFX_SUPPORTS_CUDARENDER=$CUDA
fi
- name: Build with cmake
run: |
if [[ ${{ matrix.ostype }} = windows ]]; then
cmake --build $BUILD_DIR --config Release --parallel
cmake --build $BUILD_DIR --target install --config Release --parallel
else
cmake --build $BUILD_DIR --parallel
cmake --build $BUILD_DIR --target install --parallel
fi
- name: Build with make
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Examples/*/*.bundle
*~
ofx-docgen

ofxTestLog.txt
ofxPluginLog.txt
CMakeUserPresets.json
cmake-build.log

build*/
build.log
.cache/
Expand Down
55 changes: 49 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,70 @@
cmake_minimum_required(VERSION 3.16.0)
project(openfx VERSION 1.4.0 LANGUAGES CXX)
if(OFX_SUPPORTS_CUDARENDER AND NOT APPLE)
project(
openfx
VERSION 1.4.0
LANGUAGES CXX CUDA)
else()
project(
openfx
VERSION 1.4.0
LANGUAGES CXX) # no CUDA
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
add_definitions(-D_HAS_AUTO_PTR_ETC)
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
endif()

option(OFX_SUPPORTS_OPENGLRENDER
"Build with support for GPU rendering (OpenGL/CUDA/Metal/OpenCL)" ON)
option(BUILD_EXAMPLE_PLUGINS "Build example plugins" OFF)
option(OFX_SUPPORTS_OPENGLRENDER "Build with support for GPU rendering (OpenGL/CUDA/Metal/OpenCL)" ON)
if(APPLE)
option(OFX_SUPPORTS_OPENCLRENDER
"Build examples with support for OpenCL GPU rendering" ON)
else()
option(OFX_SUPPORTS_OPENCLRENDER
"Build examples with support for OpenCL GPU rendering" OFF)
endif()
option(OFX_SUPPORTS_CUDARENDER
"Build examples with support for CUDA GPU rendering" OFF)
option(PLUGIN_INSTALLDIR "Location to install plugins (default depends on OS)"
"")

if(APPLE)
set(OFX_SUPPORTS_CUDARENDER OFF)
endif()

if(OFX_SUPPORTS_OPENGLRENDER)
add_definitions(-DOFX_SUPPORTS_OPENGLRENDER)
endif()
if(OFX_SUPPORTS_OPENCLRENDER)
add_definitions(-DOFX_SUPPORTS_OPENCLRENDER)
endif()
if(OFX_SUPPORTS_CUDARENDER)
add_definitions(-DOFX_SUPPORTS_CUDARENDER)
set(CMAKE_CUDA_ARCHITECTURES "all-major")
endif()

# We use #if DEBUG in the examples
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")

# Flags
if(!MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated -Wno-deprecated-declarations"
)
endif()

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_BINARY_DIR} )
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_BINARY_DIR})

# Conan packages
find_package(EXPAT)
find_package(opengl_system)
find_package(opengl_system REQUIRED)

# Macros
include(OpenFX)
Expand Down
5 changes: 2 additions & 3 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(OFX_SUPPORT_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
file(GLOB_RECURSE OFX_SUPPORT_HEADER_FILES "${OFX_SUPPORT_HEADER_DIR}/*.h")
set(OFX_SUPPORT_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Support/include")

set(PLUGINS
Basic
Expand All @@ -19,7 +18,7 @@ foreach(PLUGIN IN LISTS PLUGINS)
add_ofx_plugin(${TGT} ${PLUGIN})
target_sources(${TGT} PUBLIC ${PLUGIN_SOURCES})
target_link_libraries(${TGT} ${CONAN_LIBS})
target_include_directories(${TGT} PUBLIC ${OFX_HEADER_DIR})
target_include_directories(${TGT} PUBLIC ${OFX_HEADER_DIR} ${OFX_SUPPORT_HEADER_DIR})
endforeach()

target_link_libraries(example-OpenGL PRIVATE opengl::opengl)
Expand Down
2 changes: 1 addition & 1 deletion Examples/DepthConverter/depthConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ describe(OfxImageEffectHandle effect)
if(gSupportsFloats) gDepthParamToBytes[i++] = 32;

// set some labels and the group it belongs to
gPropHost->propSetString(effectProps, kOfxPropLabel, 0, "OFX Depth Converter");
gPropHost->propSetString(effectProps, kOfxPropLabel, 0, "OFX Depth Converter Example");
gPropHost->propSetString(effectProps, kOfxImageEffectPluginPropGrouping, 0, "OFX Example");

// define the contexts we can be used in
Expand Down
24 changes: 24 additions & 0 deletions Examples/Info.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PLUGIN_NAME}</string>
<key>CFBundleExecutable</key>
<string>${PLUGIN_EXE}</string>
<key>CFBundleIdentifier</key>
<string>${BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>${BUNDLE_SIGNATURE}</string>
<key>CFBundleVersion</key>
<string>${PLUGIN_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Examples/Rectangle/rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ describe(OfxImageEffectHandle effect)
gPropHost->propSetString(effectProps, kOfxImageEffectPropSupportedPixelDepths, 2, kOfxBitDepthFloat);

// set some labels and the group it belongs to
gPropHost->propSetString(effectProps, kOfxPropLabel, 0, "OFX Rectangle");
gPropHost->propSetString(effectProps, kOfxPropLabel, 0, "OFX Rectangle Example");
gPropHost->propSetString(effectProps, kOfxImageEffectPluginPropGrouping, 0, "OFX Example");

// define the contexts we can be used in
Expand Down
Loading

0 comments on commit eb626d9

Please sign in to comment.