### Example Applications Source: https://github.com/renderkit/oidn/blob/master/README.md Information about the example applications included with Intel Open Image Denoise. ```APIDOC ## Example Applications Intel Open Image Denoise ships with a couple of simple example applications. ### oidnDenoise `oidnDenoise` is a minimal working example demonstrating how to use Intel Open Image Denoise, which can be found at `apps/oidnDenoise.cpp`. It uses the C++11 convenience wrappers of the C99 API. This example is a simple command-line application that denoises the provided image, which can optionally have auxiliary feature images as well (e.g. albedo and normal). By default the images must be stored in the [Portable FloatMap](http://www.pauldebevec.com/Research/HDR/PFM/) (PFM) format, and the color values must be encoded in little-endian format. To enable other image formats (e.g. OpenEXR, PNG) as well, the project has to be rebuilt with OpenImageIO support enabled. Running `oidnDenoise` without any arguments or the `-h` argument will bring up a list of command-line options. ### oidnBenchmark `oidnBenchmark` is a basic command-line benchmarking application for measuring denoising speed, which can be found at `apps/oidnBenchmark.cpp`. Running `oidnBenchmark` with the `-h` argument will bring up a list of command-line options. ``` -------------------------------- ### Install CPU Device Module Source: https://github.com/renderkit/oidn/blob/master/devices/cpu/CMakeLists.txt Installs the CPU device library. If building a static library, it links the device library to the main OpenImageDenoise library. Otherwise, it strips symbols and installs it as a module. ```cmake if(OIDN_STATIC_LIB) oidn_install_static_module(OpenImageDenoise_device_cpu) target_link_libraries(OpenImageDenoise PRIVATE OpenImageDenoise_device_cpu) else() oidn_strip_symbols(OpenImageDenoise_device_cpu) oidn_install_module(OpenImageDenoise_device_cpu) endif() ``` -------------------------------- ### Install SYCL Module Source: https://github.com/renderkit/oidn/blob/master/devices/sycl/CMakeLists.txt Installs the SYCL device library as a module using a custom CMake macro. ```cmake oidn_install_module(OpenImageDenoise_device_sycl) ``` -------------------------------- ### Link Core Library and Install Source: https://github.com/renderkit/oidn/blob/master/devices/cuda/CMakeLists.txt Links the OpenImageDenoise core library and installs the CUDA device module. Also strips symbols for a smaller footprint. ```cmake target_link_libraries(OpenImageDenoise_device_cuda PRIVATE OpenImageDenoise_core) oidn_strip_symbols(OpenImageDenoise_device_cuda) oidn_install_module(OpenImageDenoise_device_cuda) ``` -------------------------------- ### Full Denoising Pipeline (C API) Source: https://context7.com/renderkit/oidn/llms.txt This C function demonstrates a complete denoising pipeline using the OpenImageDenoise C API. It includes device creation, buffer setup, filter configuration, execution, error checking, and cleanup. Ensure OpenImageDenoise is installed and headers are accessible. ```c #include #include #include #include int denoise_image(float* color, float* albedo, float* normal, float* output, int width, int height) { // Create device OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); if (!device) { const char* msg; oidnGetDeviceError(NULL, &msg); fprintf(stderr, "Error creating device: %s\n", msg); return -1; } oidnCommitDevice(device); size_t bufSize = width * height * 3 * sizeof(float); // Create buffers OIDNBuffer colorBuf = oidnNewBuffer(device, bufSize); OIDNBuffer albedoBuf = oidnNewBuffer(device, bufSize); OIDNBuffer normalBuf = oidnNewBuffer(device, bufSize); OIDNBuffer outputBuf = oidnNewBuffer(device, bufSize); // Copy input data to buffers memcpy(oidnGetBufferData(colorBuf), color, bufSize); memcpy(oidnGetBufferData(albedoBuf), albedo, bufSize); memcpy(oidnGetBufferData(normalBuf), normal, bufSize); // Create filter OIDNFilter filter = oidnNewFilter(device, "RT"); // Set images oidnSetFilterImage(filter, "color", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); oidnSetFilterImage(filter, "albedo", albedoBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); oidnSetFilterImage(filter, "normal", normalBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); oidnSetFilterImage(filter, "output", outputBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // Configure filter oidnSetFilterBool(filter, "hdr", true); oidnSetFilterInt(filter, "quality", OIDN_QUALITY_HIGH); // Commit and execute oidnCommitFilter(filter); oidnExecuteFilter(filter); // Check for errors const char* errorMessage; OIDNError error = oidnGetDeviceError(device, &errorMessage); if (error != OIDN_ERROR_NONE) { fprintf(stderr, "Denoising error: %s\n", errorMessage); oidnReleaseFilter(filter); oidnReleaseBuffer(colorBuf); oidnReleaseBuffer(albedoBuf); oidnReleaseBuffer(normalBuf); oidnReleaseBuffer(outputBuf); oidnReleaseDevice(device); return -1; } // Copy output memcpy(output, oidnGetBufferData(outputBuf), bufSize); // Cleanup oidnReleaseFilter(filter); oidnReleaseBuffer(colorBuf); oidnReleaseBuffer(albedoBuf); oidnReleaseBuffer(normalBuf); oidnReleaseBuffer(outputBuf); oidnReleaseDevice(device); return 0; } ``` -------------------------------- ### Install CMake package configuration files Source: https://github.com/renderkit/oidn/blob/master/CMakeLists.txt Exports targets and generates configuration files to support find_package() integration for the project. ```cmake install(EXPORT OpenImageDenoise_Exports DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenImageDenoise-${OIDN_VERSION} FILE OpenImageDenoiseTargets.cmake COMPONENT devel ) include(CMakePackageConfigHelpers) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/OpenImageDenoiseConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenImageDenoise-${OIDN_VERSION} ) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/OpenImageDenoiseConfigVersion.cmake COMPATIBILITY SameMajorVersion) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenImageDenoiseConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/OpenImageDenoiseConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenImageDenoise-${OIDN_VERSION} COMPONENT devel ) ``` -------------------------------- ### Include CPack for packaging Source: https://github.com/renderkit/oidn/blob/master/CMakeLists.txt Finalizes the installation configuration by including the CPack module. ```cmake include(CPack) ``` -------------------------------- ### Install SYCL Dependencies Source: https://github.com/renderkit/oidn/blob/master/devices/sycl/CMakeLists.txt Installs necessary SYCL runtime dynamic libraries based on the operating system and compiler location. ```cmake if(OIDN_INSTALL_DEPENDENCIES) get_filename_component(_dpcpp_compiler_dir ${CMAKE_CXX_COMPILER} PATH) if(WIN32) if(EXISTS "${_dpcpp_compiler_dir}/../bin/pi_level_zero.dll") file(GLOB _sycl_deps LIST_DIRECTORIES FALSE "${_dpcpp_compiler_dir}/../bin/sycl?.dll" "${_dpcpp_compiler_dir}/../bin/pi_level_zero.dll" "${_dpcpp_compiler_dir}/../bin/pi_win_proxy_loader.dll" "${_dpcpp_compiler_dir}/../bin/win_proxy_loader.dll" # deprecated ) else() file(GLOB _sycl_deps LIST_DIRECTORIES FALSE "${_dpcpp_compiler_dir}/../bin/sycl?.dll" "${_dpcpp_compiler_dir}/../bin/ur_loader.dll" "${_dpcpp_compiler_dir}/../bin/ur_adapter_level_zero.dll" "${_dpcpp_compiler_dir}/../bin/ur_win_proxy_loader.dll" ) endif() else() if(EXISTS "${_dpcpp_compiler_dir}/../lib/libpi_level_zero.so") file(GLOB _sycl_deps LIST_DIRECTORIES FALSE "${_dpcpp_compiler_dir}/../lib/libsycl.so.?" "${_dpcpp_compiler_dir}/../lib/libpi_level_zero.so" ) else() file(GLOB _sycl_deps LIST_DIRECTORIES FALSE "${_dpcpp_compiler_dir}/../lib/libsycl.so.?" "${_dpcpp_compiler_dir}/../lib/libur_loader.so" "${_dpcpp_compiler_dir}/../lib/libur_adapter_level_zero.so" "${_dpcpp_compiler_dir}/../lib/libumf.so" ) endif() endif() oidn_install_lib_files(${_sycl_deps}) endif() ``` -------------------------------- ### Install OpenImageDenoise_common target Source: https://github.com/renderkit/oidn/blob/master/common/CMakeLists.txt Installs the OpenImageDenoise_common target and its export set. This makes the library available for other projects to find and link against. ```cmake install(TARGETS OpenImageDenoise_common EXPORT OpenImageDenoise_Exports) ``` -------------------------------- ### Install TBB Dependencies in CMake Source: https://github.com/renderkit/oidn/blob/master/devices/cpu/CMakeLists.txt Installs TBB and its plugins using CMake. This script handles platform-specific plugin installation for Windows and non-macOS systems. It requires OIDN_INSTALL_DEPENDENCIES to be true. ```cmake if(OIDN_INSTALL_DEPENDENCIES) # Install TBB oidn_install_imported_lib(TBB::tbb) # Install TBB plugins if(NOT APPLE) if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") get_target_property(_tbb_lib TBB::tbb IMPORTED_LOCATION_DEBUG) set(_tbb_suffix "_debug") else() get_target_property(_tbb_lib TBB::tbb IMPORTED_LOCATION_RELEASE) set(_tbb_suffix "") endif() get_filename_component(_tbb_dir "${_tbb_lib}" DIRECTORY) if(WIN32) file(GLOB _tbb_deps LIST_DIRECTORIES FALSE "${_tbb_dir}/tbbbind${_tbb_suffix}\.dll" "${_tbb_dir}/tbbbind_?_?${_tbb_suffix}\.dll" ) else() file(GLOB _tbb_deps LIST_DIRECTORIES FALSE "${_tbb_dir}/libtbbbind${_tbb_suffix}\.so.?" "${_tbb_dir}/libtbbbind_?_?${_tbb_suffix}\.so.?" ) endif() oidn_install_lib_files(${_tbb_deps}) endif() endif() ``` -------------------------------- ### Basic Denoising with C99 API Source: https://github.com/renderkit/oidn/blob/master/doc/api.md Demonstrates basic image denoising using the C99 API. Ensure proper initialization and cleanup of device, buffer, and filter objects. This example assumes input/output buffers and auxiliary data are prepared. ```c #include ... // Create an Open Image Denoise device OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); // CPU or GPU if available // OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_CPU); oidnCommitDevice(device); // Create buffers for input/output images accessible by both host (CPU) and device (CPU/GPU) OIDNBuffer colorBuf = oidnNewBuffer(device, width * height * 3 * sizeof(float)); OIDNBuffer albedoBuf = ... // Create a filter for denoising a beauty (color) image using optional auxiliary images too // This can be an expensive operation, so try not to create a new filter for every image! OIDNFilter filter = oidnNewFilter(device, "RT"); // generic ray tracing filter oidnSetFilterImage(filter, "color", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // beauty oidnSetFilterImage(filter, "albedo", albedoBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // auxiliary oidnSetFilterImage(filter, "normal", normalBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // auxiliary oidnSetFilterImage(filter, "output", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // denoised beauty oidnSetFilterBool(filter, "hdr", true); // beauty image is HDR oidnCommitFilter(filter); // Fill the input image buffers float* colorPtr = (float*)oidnGetBufferData(colorBuf); ... // Filter the beauty image oidnExecuteFilter(filter); // Check for errors const char* errorMessage; if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) printf("Error: %s\n", errorMessage); // Cleanup oidnReleaseBuffer(colorBuf); ... oidnReleaseFilter(filter); oidnReleaseDevice(device); ``` -------------------------------- ### Install IntelLLVM compiler dependencies Source: https://github.com/renderkit/oidn/blob/master/CMakeLists.txt Conditionally installs required runtime libraries for the IntelLLVM compiler based on the operating system. ```cmake if(OIDN_INSTALL_DEPENDENCIES AND CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") get_filename_component(_icx_compiler_dir ${CMAKE_CXX_COMPILER} PATH) if(WIN32) file(GLOB _icx_deps LIST_DIRECTORIES FALSE "${_icx_compiler_dir}/../bin/libmmd.dll" ) else() file(GLOB _icx_deps LIST_DIRECTORIES FALSE "${_icx_compiler_dir}/../lib/libsvml.so" "${_icx_compiler_dir}/../lib/libirng.so" "${_icx_compiler_dir}/../lib/libimf.so" "${_icx_compiler_dir}/../lib/libintlc.so.?" ) endif() oidn_install_lib_files(${_icx_deps}) endif() ``` -------------------------------- ### Manage OIDN Device Parameters Source: https://github.com/renderkit/oidn/blob/master/doc/api.md Functions to get and set parameter values on a created device. Note that some parameters are constants and cannot be modified. ```c bool oidnGetDeviceBool(OIDNDevice device, const char* name); void oidnSetDeviceBool(OIDNDevice device, const char* name, bool value); int oidnGetDeviceInt (OIDNDevice device, const char* name); void oidnSetDeviceInt (OIDNDevice device, const char* name, int value); int oidnGetDeviceUInt(OIDNDevice device, const char* name); void oidnSetDeviceUInt(OIDNDevice device, const char* name, unsigned int value); ``` -------------------------------- ### Get and set integer parameters on an Open Image Denoise device Source: https://github.com/renderkit/oidn/blob/master/README.md Use these functions to retrieve or modify integer parameters of a created Open Image Denoise device. Note that some parameters are constants and cannot be set. ```cpp int oidnGetDeviceInt (OIDNDevice device, const char* name); void oidnSetDeviceInt (OIDNDevice device, const char* name, int value); ``` -------------------------------- ### Configure HIP Device Build Source: https://github.com/renderkit/oidn/blob/master/devices/CMakeLists.txt Configures the HIP device build by locating the ROCm installation and the HIP compiler, then adding the project via ExternalProject. ```cmake if(OIDN_DEVICE_HIP) # Check the generator if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_GENERATOR MATCHES "Unix Makefiles") message(FATAL_ERROR "Building with HIP support requires Ninja or Make") endif() # Find ROCm if(NOT ROCM_PATH) if(WIN32) set(_rocm_search_paths "$ENV{PROGRAMFILES}/AMD/ROCm/*") else() set(_rocm_search_paths "/opt/rocm") endif() find_path(ROCM_PATH NAMES bin/hipconfig bin/hipconfig.bat bin/hipconfig.exe bin/hipconfig.pl HINTS $ENV{ROCM_PATH} $ENV{HIP_PATH} $ENV{HIP_PATH_64} PATHS ${_rocm_search_paths} NO_DEFAULT_PATH DOC "ROCm installation path." ) mark_as_advanced(ROCM_PATH) if(ROCM_PATH) message(STATUS "Found ROCm: ${ROCM_PATH}") else() message(FATAL_ERROR "Failed to find ROCm.\nBuilding with HIP support requires ROCm. Please set the ROCM_PATH variable.") endif() endif() # Find HIP compiler find_program(OIDN_DEVICE_HIP_COMPILER NAMES clang++ HINTS ${ROCM_PATH} PATH_SUFFIXES bin llvm/bin NO_DEFAULT_PATH REQUIRED DOC "HIP compiler." ) mark_as_advanced(OIDN_DEVICE_HIP_COMPILER) # Add ROCm to CMAKE_PREFIX_PATH set(_hip_prefix_path CMAKE_PREFIX_PATH) list(APPEND _hip_prefix_path ${ROCM_PATH}/hip ${ROCM_PATH}) list(JOIN _hip_prefix_path "|" _hip_prefix_path_str) ExternalProject_Add(OpenImageDenoise_device_hip PREFIX hip SOURCE_DIR ${PROJECT_SOURCE_DIR}/devices/hip BINARY_DIR hip/build STAMP_DIR hip/stamp LIST_SEPARATOR | CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:STRING=${_hip_prefix_path_str} -DCMAKE_CXX_COMPILER:FILEPATH=${OIDN_DEVICE_HIP_COMPILER} ) endif() ``` -------------------------------- ### Define and Register OIDN Applications with CMake Source: https://github.com/renderkit/oidn/blob/master/apps/CMakeLists.txt Use the oidn_add_app macro to define new executables, link them against OIDN core and utility libraries, and configure installation paths. ```cmake add_subdirectory(utils) macro(oidn_add_app APP_NAME) add_executable(${APP_NAME} ${ARGN} ${OIDN_RESOURCE_FILE}) target_link_libraries(${APP_NAME} PRIVATE OpenImageDenoise_common OpenImageDenoise_utils OpenImageDenoise) install(TARGETS ${APP_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT apps) endmacro() oidn_add_app(oidnDenoise oidnDenoise.cpp) oidn_add_app(oidnBenchmark oidnBenchmark.cpp) oidn_add_app(oidnTest oidnTest.cpp "${PROJECT_SOURCE_DIR}/external/catch.hpp") ``` -------------------------------- ### Get and set unsigned integer parameters on an Open Image Denoise device Source: https://github.com/renderkit/oidn/blob/master/README.md Use these functions to retrieve or modify unsigned integer parameters of a created Open Image Denoise device. Note that some parameters are constants and cannot be set. ```cpp int oidnGetDeviceUInt(OIDNDevice device, const char* name); void oidnSetDeviceUInt(OIDNDevice device, const char* name, unsigned int value); ``` -------------------------------- ### Clone Intel Open Image Denoise Repository Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Clone the Intel Open Image Denoise repository using Git with the Git LFS extension installed. This is a required step for correct compilation. ```bash git clone --recursive https://github.com/OpenImageDenoise/oidn.git ``` -------------------------------- ### Configure CUDA Device Build Source: https://github.com/renderkit/oidn/blob/master/devices/CMakeLists.txt Configures the CUDA device build process using ExternalProject, including host compiler selection and cache argument setup. ```cmake if(OIDN_DEVICE_CUDA) # Options set(OIDN_DEVICE_CUDA_API "Driver" CACHE STRING "CUDA API to use (Driver, RuntimeStatic, RuntimeShared).") set_property(CACHE OIDN_DEVICE_CUDA_API PROPERTY STRINGS "Driver" "RuntimeStatic" "RuntimeShared") mark_as_advanced(OIDN_DEVICE_CUDA_API) # We need to build this an external project because we might need to switch to clang-cl # CMake does not support GNU-like compilers for CUDA if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT MSVC) # Check the generator if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_GENERATOR MATCHES "Unix Makefiles") message(FATAL_ERROR "Building with CUDA support requires Ninja or Make") endif() get_filename_component(_cxx_compiler_dir ${CMAKE_CXX_COMPILER} DIRECTORY) set(_host_compiler ${_cxx_compiler_dir}/clang-cl.exe) else() set(_host_compiler ${CMAKE_CXX_COMPILER}) endif() list(JOIN CMAKE_PREFIX_PATH "|" _prefix_path_str) set(_oidn_cuda_cache_args -DCMAKE_PREFIX_PATH:STRING=${_prefix_path_str} -DCMAKE_CXX_COMPILER:FILEPATH=${_host_compiler} -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/cuda/preinstall -DCMAKE_INSTALL_BINDIR:PATH=${CMAKE_INSTALL_BINDIR} -DCMAKE_INSTALL_LIBDIR:PATH=${CMAKE_INSTALL_LIBDIR} -DOIDN_ROOT_BINARY_DIR:PATH=${OIDN_ROOT_BINARY_DIR} -DOIDN_INSTALL_RPATH_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DOIDN_INSTALL_DEPENDENCIES:BOOL=${OIDN_INSTALL_DEPENDENCIES} -DOIDN_ZIP_MODE:BOOL=${OIDN_ZIP_MODE} -DOIDN_LIBRARY_NAME:STRING=${OIDN_LIBRARY_NAME} -DOIDN_LIBRARY_VERSIONED:STRING=${OIDN_LIBRARY_VERSIONED} -DOIDN_API_NAMESPACE:STRING=${OIDN_API_NAMESPACE} -DOIDN_WARN_AS_ERRORS:BOOL=${OIDN_WARN_AS_ERRORS} -DOIDN_SANITIZER:STRING=${OIDN_SANITIZER} -DOIDN_DEVICE_CUDA_API:STRING=${OIDN_DEVICE_CUDA_API} ) if(DEFINED CUDAToolkit_ROOT) list(APPEND _oidn_cuda_cache_args -DCUDAToolkit_ROOT:PATH=${CUDAToolkit_ROOT} ) endif() ExternalProject_Add(OpenImageDenoise_device_cuda PREFIX cuda SOURCE_DIR ${PROJECT_SOURCE_DIR}/devices/cuda BINARY_DIR cuda/build STAMP_DIR cuda/stamp LIST_SEPARATOR | CMAKE_CACHE_ARGS ${_oidn_cuda_cache_args} BUILD_ALWAYS TRUE DEPENDS OpenImageDenoise_core ) # Due to limitations of CMake, the module is pre-installed at build time to a temporary location, # and then copied to the real install location at install time. install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cuda/preinstall/ DESTINATION "." USE_SOURCE_PERMISSIONS ) endif() ``` -------------------------------- ### Get and set boolean parameters on an Open Image Denoise device Source: https://github.com/renderkit/oidn/blob/master/README.md Use these functions to retrieve or modify boolean parameters of a created Open Image Denoise device. Note that some parameters are constants and cannot be set. ```cpp bool oidnGetDeviceBool(OIDNDevice device, const char* name); void oidnSetDeviceBool(OIDNDevice device, const char* name, bool value); ``` -------------------------------- ### Create and enter build directory Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Standard commands to prepare a build directory for OIDN. ```bash mkdir oidn/build cd oidn/build ``` -------------------------------- ### List Available Devices (Command Line) Source: https://context7.com/renderkit/oidn/llms.txt Lists all available compute devices that Open Image Denoise can utilize. This is useful for verifying hardware compatibility and selection. ```bash # List available devices oidnDenoise --list_devices ``` -------------------------------- ### Basic Denoising (C++11 API) Source: https://github.com/renderkit/oidn/blob/master/README.md Demonstrates the standard workflow for initializing a device, creating buffers, configuring a filter, and executing the denoising process using the C++11 API. ```cpp #include ... // Create an Open Image Denoise device oidn::DeviceRef device = oidn::newDevice(); // CPU or GPU if available // oidn::DeviceRef device = oidn::newDevice(oidn::DeviceType::CPU); device.commit(); // Create buffers for input/output images accessible by both host (CPU) and device (CPU/GPU) oidn::BufferRef colorBuf = device.newBuffer(width * height * 3 * sizeof(float)); oidn::BufferRef albedoBuf = ... // Create a filter for denoising a beauty (color) image using optional auxiliary images too // This can be an expensive operation, so try no to create a new filter for every image! oidn::FilterRef filter = device.newFilter("RT"); // generic ray tracing filter filter.setImage("color", colorBuf, oidn::Format::Float3, width, height); // beauty filter.setImage("albedo", albedoBuf, oidn::Format::Float3, width, height); // auxiliary filter.setImage("normal", normalBuf, oidn::Format::Float3, width, height); // auxiliary filter.setImage("output", colorBuf, oidn::Format::Float3, width, height); // denoised beauty filter.set("hdr", true); // beauty image is HDR filter.commit(); // Fill the input image buffers float* colorPtr = (float*)colorBuf.getData(); ... // Filter the beauty image filter.execute(); // Check for errors const char* errorMessage; if (device.getError(errorMessage) != oidn::Error::None) std::cout << "Error: " << errorMessage << std::endl; ``` -------------------------------- ### Basic Denoising (C99 API) Source: https://github.com/renderkit/oidn/blob/master/README.md Demonstrates the standard workflow for initializing a device, creating buffers, configuring a filter, and executing the denoising process using the C99 API. ```cpp #include ... // Create an Open Image Denoise device OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); // CPU or GPU if available // OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_CPU); oidnCommitDevice(device); // Create buffers for input/output images accessible by both host (CPU) and device (CPU/GPU) OIDNBuffer colorBuf = oidnNewBuffer(device, width * height * 3 * sizeof(float)); OIDNBuffer albedoBuf = ... // Create a filter for denoising a beauty (color) image using optional auxiliary images too // This can be an expensive operation, so try not to create a new filter for every image! OIDNFilter filter = oidnNewFilter(device, "RT"); // generic ray tracing filter oidnSetFilterImage(filter, "color", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // beauty oidnSetFilterImage(filter, "albedo", albedoBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // auxiliary oidnSetFilterImage(filter, "normal", normalBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // auxiliary oidnSetFilterImage(filter, "output", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // denoised beauty oidnSetFilterBool(filter, "hdr", true); // beauty image is HDR oidnCommitFilter(filter); // Fill the input image buffers float* colorPtr = (float*)oidnGetBufferData(colorBuf); ... // Filter the beauty image oidnExecuteFilter(filter); // Check for errors const char* errorMessage; if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) printf("Error: %s\n", errorMessage); // Cleanup oidnReleaseBuffer(colorBuf); ... oidnReleaseFilter(filter); oidnReleaseDevice(device); ``` -------------------------------- ### Get and Set Filter Parameters Source: https://github.com/renderkit/oidn/blob/master/doc/api.md Functions for getting and setting boolean, integer, and float parameters on a filter. ```C bool oidnGetFilterBool (OIDNFilter filter, const char* name); void oidnSetFilterBool (OIDNFilter filter, const char* name, bool value); int oidnGetFilterInt (OIDNFilter filter, const char* name); void oidnSetFilterInt (OIDNFilter filter, const char* name, int value); float oidnGetFilterFloat(OIDNFilter filter, const char* name); void oidnSetFilterFloat(OIDNFilter filter, const char* name, float value); ``` -------------------------------- ### Display preprocessing script help Source: https://github.com/renderkit/oidn/blob/master/doc/training.md Command to view available options and help documentation for the preprocessing script. ```bash ./preprocess.py -h ``` -------------------------------- ### Device Creation and Initialization Source: https://context7.com/renderkit/oidn/llms.txt Learn how to create and initialize OIDN devices for different hardware backends (CPU, SYCL, CUDA, HIP, Metal) and configure device properties. ```APIDOC ## Device Creation and Initialization ### Description Creates a new Open Image Denoise device of the specified type. The device is the main entry point for all denoising operations and must be committed before use. Supports automatic device selection, CPU, SYCL (Intel GPUs), CUDA (NVIDIA GPUs), HIP (AMD GPUs), and Metal (Apple GPUs). ### C++11 API Examples ```cpp #include // Create device with automatic selection (fastest available) oidn::DeviceRef device = oidn::newDevice(); device.commit(); // Create CPU-only device oidn::DeviceRef cpuDevice = oidn::newDevice(oidn::DeviceType::CPU); cpuDevice.commit(); // Create CUDA device for NVIDIA GPUs oidn::DeviceRef cudaDevice = oidn::newDevice(oidn::DeviceType::CUDA); cudaDevice.commit(); ``` ### C99 API Example ```cpp // C99 API equivalent OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); oidnCommitDevice(device); ``` ### Configuring Device Properties ```cpp // Configure device before committing oidn::DeviceRef configuredDevice = oidn::newDevice(); configuredDevice.set("numThreads", 8); // Limit to 8 threads configuredDevice.set("setAffinity", true); // Enable thread affinity configuredDevice.set("verbose", 2); // Set verbosity level configuredDevice.commit(); // Get device properties after committing int versionMajor = configuredDevice.get("versionMajor"); int versionMinor = configuredDevice.get("versionMinor"); bool systemMemSupported = configuredDevice.get("systemMemorySupported"); ``` ### Physical Device Enumeration Query and select from available physical devices in the system. Physical devices are ordered approximately from fastest to slowest. ```cpp #include #include // Get number of physical devices int numDevices = oidn::getNumPhysicalDevices(); std::cout << "Found " << numDevices << " physical devices:" << std::endl; // Enumerate and query physical devices for (int i = 0; i < numDevices; i++) { oidn::PhysicalDeviceRef physDevice(i); std::string name = physDevice.get("name"); oidn::DeviceType type = physDevice.get("type"); std::cout << " Device " << i << ": " << name; if (type == oidn::DeviceType::CPU) std::cout << " (CPU)"; else if (type == oidn::DeviceType::CUDA) std::cout << " (CUDA)"; else if (type == oidn::DeviceType::SYCL) std::cout << " (SYCL)"; std::cout << std::endl; // Check UUID support and get UUID if available if (physDevice.get("uuidSupported")) { oidn::UUID uuid = physDevice.get("uuid"); // Use UUID for graphics API interop } } // Create device from specific physical device ID oidn::DeviceRef device = oidn::newDevice(0); // Use fastest device device.commit(); ``` ``` -------------------------------- ### Open CMake GUI on Windows Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Launches the graphical CMake configuration tool. ```batch cmake-gui .. ``` -------------------------------- ### Build the library with Ninja Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Executes the build process using the Ninja build system. ```bash ninja ``` -------------------------------- ### Open CMake configuration dialog Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Launches the terminal-based CMake configuration interface. ```bash ccmake .. ``` -------------------------------- ### Strip Symbols and Install HIP Device Module Source: https://github.com/renderkit/oidn/blob/master/devices/hip/CMakeLists.txt Applies symbol stripping to the HIP device library for reduced size and installs the module. This is a common post-build step for optimized deployment. ```cmake oidn_strip_symbols(OpenImageDenoise_device_hip) oidn_install_module(OpenImageDenoise_device_hip) ``` -------------------------------- ### Get Device Error and Message Source: https://github.com/renderkit/oidn/blob/master/README.md Retrieves the error code and a descriptive message for a given device. The error code is cleared after retrieval. Pass NULL as the device to get the error code for a failed device construction. ```cpp OIDNError oidnGetDeviceError(OIDNDevice device, const char** outMessage); ``` -------------------------------- ### Device Selection (Command Line) Source: https://context7.com/renderkit/oidn/llms.txt Specifies the compute device (e.g., CUDA or CPU) to be used for denoising. This allows users to leverage specific hardware accelerators. ```bash # Use specific device type oidnDenoise -d cuda --hdr noisy.pfm -o denoised.pfm oidnDenoise -d cpu --hdr noisy.pfm -o denoised.pfm ``` -------------------------------- ### Querying Buffer Information Source: https://github.com/renderkit/oidn/blob/master/README.md Functions to get the size and storage mode of an OIDN buffer. ```APIDOC ## Querying Buffer Information ### Description Queries the size in bytes and storage mode of an OIDN buffer. ### Method `oidnGetBufferSize`, `oidnGetBufferStorage` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp size_t oidnGetBufferSize (OIDNBuffer buffer); OIDNStorage oidnGetBufferStorage(OIDNBuffer buffer); ``` ### Response #### Success Response (200) - **size_t** (`oidnGetBufferSize`) - The size of the buffer in bytes. - **OIDNStorage** (`oidnGetBufferStorage`) - The storage mode of the buffer. #### Response Example None provided. ``` -------------------------------- ### Accessing Buffer Data (Direct Pointer) Source: https://github.com/renderkit/oidn/blob/master/README.md Function to get a direct pointer to the buffer data. ```APIDOC ## Accessing Buffer Data (Direct Pointer) ### Description Gets a pointer directly to the buffer data. Accessing data on the host is possible only if the buffer was created with `OIDN_STORAGE_HOST` or `OIDN_STORAGE_MANAGED`. ### Method `oidnGetBufferData` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp void* oidnGetBufferData(OIDNBuffer buffer); ``` ### Response #### Success Response (200) - **void*** (void*) - A pointer to the buffer data. Returns `NULL` if the buffer is empty. #### Response Example None provided. ``` -------------------------------- ### Create a new SYCL device for Open Image Denoise Source: https://github.com/renderkit/oidn/blob/master/README.md Create a SYCL device for Open Image Denoise, optionally providing SYCL queues for shared usage. Supports oneAPI Level Zero backend. ```cpp OIDNDevice oidnNewSYCLDevice(const sycl::queue* queues, int numQueues); ``` -------------------------------- ### OIDN Device Parameter Access Source: https://github.com/renderkit/oidn/blob/master/doc/api.md Functions for getting and setting boolean and integer parameters on an OIDN device. ```APIDOC ## OIDN Device Parameter Access ### Description Once a device is created, its parameters can be accessed using the following functions. Note that some parameters are constants and cannot be set. ### Get Boolean Parameter ```c bool oidnGetDeviceBool(OIDNDevice device, const char* name); ``` ### Set Boolean Parameter ```c void oidnSetDeviceBool(OIDNDevice device, const char* name, bool value); ``` ### Get Integer Parameter ```c int oidnGetDeviceInt(OIDNDevice device, const char* name); ``` ### Set Integer Parameter ```c void oidnSetDeviceInt(OIDNDevice device, const char* name, int value); ``` ### Get Unsigned Integer Parameter ```c int oidnGetDeviceUInt(OIDNDevice device, const char* name); ``` ### Set Unsigned Integer Parameter ```c void oidnSetDeviceUInt(OIDNDevice device, const char* name, unsigned int value); ``` ### Supported Device Parameters | Type | Name | Default | Description | |-------|---------------------|------------|-----------------------------------------------------------------------------| | `Int` | `type` | *constant* | Device type as an `OIDNDeviceType` value. | | `Int` | `version` | *constant* | Combined version number (major.minor.patch) with two decimal digits per component. | | `Int` | `versionMajor` | *constant* | Major version number. | | `Int` | `versionMinor` | *constant* | Minor version number. | | `Int` | `versionPatch` | *constant* | Patch version number. | | `Bool`| `systemMemorySupported`| *constant* | Indicates if the device can directly access memory allocated with the system. | ``` -------------------------------- ### Device Parameter Management Source: https://github.com/renderkit/oidn/blob/master/README.md Functions for getting and setting boolean and integer parameters on an Open Image Denoise device. ```APIDOC ## Device Parameter Management ### Description Allows applications to retrieve and modify parameter values associated with an Open Image Denoise device. Some parameters are read-only (constants) and cannot be set. ### Methods #### `oidnGetDeviceBool(OIDNDevice device, const char* name)` Retrieves a boolean parameter value from the device. **Parameters:** - **device** (OIDNDevice) - Required - The device handle. - **name** (const char*) - Required - The name of the boolean parameter. **Returns:** - `true` if the parameter is set to true, `false` otherwise. #### `oidnSetDeviceBool(OIDNDevice device, const char* name, bool value)` Sets a boolean parameter value on the device. **Parameters:** - **device** (OIDNDevice) - Required - The device handle. - **name** (const char*) - Required - The name of the boolean parameter. - **value** (bool) - Required - The boolean value to set. #### `oidnGetDeviceInt(OIDNDevice device, const char* name)` Retrieves an integer parameter value from the device. **Parameters:** - **device** (OIDNDevice) - Required - The device handle. - **name** (const char*) - Required - The name of the integer parameter. **Returns:** - The integer value of the parameter. #### `oidnSetDeviceInt(OIDNDevice device, const char* name, int value)` Sets an integer parameter value on the device. **Parameters:** - **device** (OIDNDevice) - Required - The device handle. - **name** (const char*) - Required - The name of the integer parameter. - **value** (int) - Required - The integer value to set. #### `oidnGetDeviceUInt(OIDNDevice device, const char* name)` Retrieves an unsigned integer parameter value from the device. **Parameters:** - **device** (OIDNDevice) - Required - The device handle. - **name** (const char*) - Required - The name of the unsigned integer parameter. **Returns:** - The unsigned integer value of the parameter. #### `oidnSetDeviceUInt(OIDNDevice device, const char* name, unsigned int value)` Sets an unsigned integer parameter value on the device. **Parameters:** - **device** (OIDNDevice) - Required - The device handle. - **name** (const char*) - Required - The name of the unsigned integer parameter. - **value** (unsigned int) - Required - The unsigned integer value to set. ### Notes - Attempting to set a constant parameter will result in an error. - Refer to the Open Image Denoise documentation for a list of supported parameters and their types. ``` -------------------------------- ### Visualize Training Progress with TensorBoard Source: https://github.com/renderkit/oidn/blob/master/doc/training.md Visualize training and validation losses, learning rate, and other statistics logged per epoch using TensorBoard. Ensure the --result flag points to your training output directory. ```bash ./visualize.py --result rt_hdr_alb ``` -------------------------------- ### Create a new HIP device for Open Image Denoise Source: https://github.com/renderkit/oidn/blob/master/README.md Create a HIP device for Open Image Denoise, specifying device IDs and streams. The current implementation supports only one pair. ```cpp OIDNDevice oidnNewHIPDevice(const int* deviceIDs, const hipStream_t* streams, int numPairs); ``` -------------------------------- ### Get and Set Filter Float Parameter Source: https://github.com/renderkit/oidn/blob/master/README.md Retrieves or sets a floating-point parameter for a filter. Use these functions for parameters that expect fractional values. ```cpp float oidnGetFilterFloat(OIDNFilter filter, const char* name); void oidnSetFilterFloat(OIDNFilter filter, const char* name, float value); ``` -------------------------------- ### Get and Set Filter Boolean Parameter Source: https://github.com/renderkit/oidn/blob/master/README.md Retrieves or sets a boolean parameter for a filter. Use these functions for parameters that expect true/false values. ```cpp bool oidnGetFilterBool (OIDNFilter filter, const char* name); void oidnSetFilterBool (OIDNFilter filter, const char* name, bool value); ``` -------------------------------- ### Source Intel oneAPI compiler environment on Linux/macOS Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Sets up the environment variables for the Intel oneAPI DPC++/C++ Compiler on Unix-like systems. ```bash source /opt/intel/oneAPI/compiler/latest/env/vars.sh ``` -------------------------------- ### Get Physical Device String Property Source: https://github.com/renderkit/oidn/blob/master/README.md Retrieve a string property of a physical device, such as its name, UUID, or LUID. Use the appropriate OIDNDeviceInfoKey. ```c++ const char* oidnGetPhysicalDeviceString(OIDNDeviceType type, int index, OIDNDeviceInfoKey key); ``` -------------------------------- ### Create a new Metal device for Open Image Denoise Source: https://github.com/renderkit/oidn/blob/master/README.md Create a Metal device for Open Image Denoise, specifying a single command queue. This is intended for use with Apple GPUs. ```cpp OIDNDevice oidnNewMetalDevice(const MTLCommandQueue_id* commandQueues, int numQueues); ``` -------------------------------- ### Denoising with Prefiltering (C++11 API) Source: https://github.com/renderkit/oidn/blob/master/README.md Shows how to prefilter auxiliary images before denoising the main beauty image using the C++11 API. ```cpp // Create a filter for denoising a beauty (color) image using prefiltered auxiliary images too oidn::FilterRef filter = device.newFilter("RT"); // generic ray tracing filter filter.setImage("color", colorBuf, oidn::Format::Float3, width, height); // beauty filter.setImage("albedo", albedoBuf, oidn::Format::Float3, width, height); // auxiliary filter.setImage("normal", normalBuf, oidn::Format::Float3, width, height); // auxiliary filter.setImage("output", outputBuf, oidn::Format::Float3, width, height); // denoised beauty filter.set("hdr", true); // beauty image is HDR filter.set("cleanAux", true); // auxiliary images will be prefiltered filter.commit(); // Create a separate filter for denoising an auxiliary albedo image (in-place) oidn::FilterRef albedoFilter = device.newFilter("RT"); // same filter type as for beauty albedoFilter.setImage("albedo", albedoBuf, oidn::Format::Float3, width, height); albedoFilter.setImage("output", albedoBuf, oidn::Format::Float3, width, height); albedoFilter.commit(); // Create a separate filter for denoising an auxiliary normal image (in-place) oidn::FilterRef normalFilter = device.newFilter("RT"); // same filter type as for beauty normalFilter.setImage("normal", normalBuf, oidn::Format::Float3, width, height); normalFilter.setImage("output", normalBuf, oidn::Format::Float3, width, height); normalFilter.commit(); // Prefilter the auxiliary images albedoFilter.execute(); normalFilter.execute(); // Filter the beauty image filter.execute(); ``` -------------------------------- ### Source Intel oneAPI compiler environment on Windows Source: https://github.com/renderkit/oidn/blob/master/doc/compilation.md Sets up the environment variables for the Intel oneAPI DPC++/C++ Compiler on Windows. ```batch C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat ``` -------------------------------- ### Set include directories for OpenImageDenoise_common Source: https://github.com/renderkit/oidn/blob/master/common/CMakeLists.txt Configures the include directories for the OpenImageDenoise_common library. This ensures that header files are found during compilation, both for build and install targets. ```cmake target_include_directories(OpenImageDenoise_common PUBLIC $ $ $ ) ``` -------------------------------- ### Get and Set Filter Integer Parameter Source: https://github.com/renderkit/oidn/blob/master/README.md Retrieves or sets an integer parameter for a filter. Use these functions for parameters that expect whole number values. ```cpp int oidnGetFilterInt (OIDNFilter filter, const char* name); void oidnSetFilterInt (OIDNFilter filter, const char* name, int value); ``` -------------------------------- ### Create a new Open Image Denoise device by physical device ID Source: https://github.com/renderkit/oidn/blob/master/README.md Create a logical device by specifying a physical device ID. This allows for direct selection of a specific physical device. ```cpp OIDNDevice oidnNewDeviceByID(int physicalDeviceID); ``` -------------------------------- ### Get Number of Physical Devices Source: https://github.com/renderkit/oidn/blob/master/README.md Query the number of supported physical devices available in the system. This is the first step in using the physical device API. ```c++ int oidnGetNumPhysicalDevices(OIDNDeviceType type); ```