### Include CPack Source: https://github.com/openimagedenoise/oidn/blob/master/CMakeLists.txt Finalizes the installation process by including the CPack module. ```cmake # Has to be last include(CPack) ``` -------------------------------- ### Install CMake package configuration files Source: https://github.com/openimagedenoise/oidn/blob/master/CMakeLists.txt Exports targets and generates configuration files to support find_package integration. ```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 ) ``` -------------------------------- ### Install TBB dependencies via CMake Source: https://github.com/openimagedenoise/oidn/blob/master/devices/cpu/CMakeLists.txt Handles the installation of TBB libraries and platform-specific TBB bind plugins. Requires OIDN_INSTALL_DEPENDENCIES to be enabled. ```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() ``` -------------------------------- ### Preprocess training and validation datasets Source: https://github.com/openimagedenoise/oidn/blob/master/doc/training.md Example command to preprocess HDR color, albedo, and normal features for the RT filter. ```bash ./preprocess.py hdr alb nrm --filter RT --train_data rt_train --valid_data rt_valid ``` -------------------------------- ### Command-Line Tool - Basic HDR Denoising Source: https://context7.com/openimagedenoise/oidn/llms.txt Example of using the `oidnDenoise` command-line tool for basic High Dynamic Range (HDR) denoising with only color input. ```bash # Basic HDR denoising with color only oidnDenoise -hdr input.pfm -o output.pfm ``` -------------------------------- ### Install SYCL Dependencies Source: https://github.com/openimagedenoise/oidn/blob/master/devices/sycl/CMakeLists.txt Installs necessary SYCL runtime libraries based on the operating system (Windows or Unix) and the detected DPC++ compiler path. ```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/openimagedenoise/oidn/blob/master/common/CMakeLists.txt Installs the OpenImageDenoise_common target and its associated export rules. This makes the library available for other projects to use. ```cmake install(TARGETS OpenImageDenoise_common EXPORT OpenImageDenoise_Exports) ``` -------------------------------- ### Command-Line Tool - LDR Image Denoising Source: https://context7.com/openimagedenoise/oidn/llms.txt Example of using the `oidnDenoise` command-line tool for Low Dynamic Range (LDR) image denoising, assuming sRGB encoding. ```bash # LDR image (sRGB encoded) oidnDenoise -ldr input.pfm -o output.pfm ``` -------------------------------- ### Command-Line Tool - HDR Denoising with Aux Features Source: https://context7.com/openimagedenoise/oidn/llms.txt Example of using the `oidnDenoise` command-line tool for HDR denoising, including auxiliary features like albedo and normal maps. ```bash # With auxiliary features (albedo and normal) oidnDenoise -hdr color.pfm -alb albedo.pfm -nrm normal.pfm -o output.pfm ``` -------------------------------- ### Configure Open Image Denoise CMake Library Source: https://github.com/openimagedenoise/oidn/blob/master/api/CMakeLists.txt Defines the library target, sets versioning, manages include directories, and configures installation rules. ```cmake set(API_SOURCES api.cpp ) add_library(OpenImageDenoise ${OIDN_LIB_TYPE} ${API_SOURCES} ${OIDN_RESOURCE_FILE}) set_target_properties(OpenImageDenoise PROPERTIES OUTPUT_NAME ${OIDN_LIBRARY_NAME} ) if(OIDN_LIBRARY_VERSIONED) set_target_properties(OpenImageDenoise PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) endif() target_include_directories(OpenImageDenoise PUBLIC $ $ ) target_link_libraries(OpenImageDenoise PRIVATE OpenImageDenoise_core) if(NOT OIDN_STATIC_LIB) oidn_strip_symbols(OpenImageDenoise) endif() install(TARGETS OpenImageDenoise EXPORT OpenImageDenoise_Exports ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT lib ) ``` -------------------------------- ### Get and Set Device Parameters Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Functions to retrieve or modify device configuration parameters. ```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); ``` -------------------------------- ### Device Parameter Configuration Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md APIs for setting and getting various parameters on an Open Image Denoise device. ```APIDOC ## Device Parameter Configuration ### Description This section details how to configure parameters for Open Image Denoise devices, including general device properties and CPU-specific settings. ### General Device Parameters These parameters are supported by all device types. - **`managedMemorySupported`** (*constant*) - **Type**: `Bool` - **Description**: Indicates whether the device supports buffers created with managed storage (`OIDN_STORAGE_MANAGED`). - **`externalMemoryTypes`** (*constant*) - **Type**: `Int` - **Description**: A bitfield of `OIDNExternalMemoryTypeFlag` values representing the external memory types supported by the device. - **`verbose`** - **Type**: `Int` - **Default**: 0 - **Description**: Verbosity level of the console output (0-4). 0 means no output, higher values increase output. ### CPU-Specific Device Parameters These parameters are only supported by CPU devices. - **`numThreads`** - **Type**: `Int` - **Default**: 0 - **Description**: Maximum number of threads the library should use. 0 means automatic selection for best performance. - **`setAffinity`** - **Type**: `Bool` - **Default**: `true` - **Description**: Enables or disables thread affinitization (pinning software threads to hardware threads) for optimal performance. It is highly recommended to keep this enabled for CPU devices, but be aware of potential conflicts if the application also sets thread affinities. ``` -------------------------------- ### Device Parameters Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Details on how to get and set parameters for an Open Image Denoise device, including available parameter types and their descriptions. ```APIDOC ## Device Parameter Configuration ### Description After creating an `OIDNDevice`, its properties can be queried and modified using `oidnGetDevice*` and `oidnSetDevice*` functions. Some parameters are constants and cannot be changed. ### Getting and Setting Parameters - 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 unsigned 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 memory. | ``` -------------------------------- ### Add HIP Device Subdirectory Source: https://github.com/openimagedenoise/oidn/blob/master/devices/CMakeLists.txt Configures the build for HIP device support, including finding the ROCm installation and HIP compiler. Requires Ninja or Make generators. ```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} ``` -------------------------------- ### Install IntelLLVM compiler dependencies Source: https://github.com/openimagedenoise/oidn/blob/master/CMakeLists.txt Conditionally installs required runtime libraries when using the IntelLLVM compiler. ```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() ``` -------------------------------- ### Launch CMake GUI Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Open the CMake graphical interface to configure build options. ```bash cmake-gui .. ``` -------------------------------- ### Display preprocessing script help Source: https://github.com/openimagedenoise/oidn/blob/master/doc/training.md Command to view all available options for the preprocessing script. ```bash ./preprocess.py -h ``` -------------------------------- ### Create and navigate to build directory on Linux Source: https://github.com/openimagedenoise/oidn/blob/master/doc/compilation.md Create a dedicated build directory for OIDN and change into it. It's recommended to have separate build directories for different configurations. ```bash mkdir oidn/build cd oidn/build ``` -------------------------------- ### Set up Intel oneAPI DPC++/C++ Compiler on Windows Source: https://github.com/openimagedenoise/oidn/blob/master/doc/compilation.md Execute the 'vars.bat' script to add Intel's DPC++ compiler to your PATH, or use the dedicated Intel oneAPI command prompt. This is required for SYCL support. ```batch C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat ``` -------------------------------- ### Open CMake configuration dialog Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Launches the interactive CMake configuration interface. ```bash ccmake .. ``` -------------------------------- ### Device Parameter Configuration Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Functions to get and set configuration parameters on an existing OIDNDevice. ```APIDOC ## Device Configuration ### Description Get or set configuration parameters for a specific device instance. ### Methods - `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)` ### Parameters - **device** (OIDNDevice) - Required - The device handle. - **name** (char*) - Required - The name of the parameter. - **value** (bool/int/unsigned int) - Required - The value to set. ``` -------------------------------- ### OIDN Device Creation (C++11 API) Source: https://context7.com/openimagedenoise/oidn/llms.txt Shows how to create and manage devices using the C++11 wrapper with automatic reference counting. ```APIDOC ## oidn::newDevice - Create Device (C++11 API) ### Description C++11 wrapper with automatic reference counting for creating and managing devices. ### Method C++ Function Call ### Endpoint N/A (Library Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```cpp #include // Create device with automatic reference counting oidn::DeviceRef device = oidn::newDevice(); // Default device // or: oidn::DeviceRef device = oidn::newDevice(oidn::DeviceType::CUDA); // Configure and commit device.set("verbose", 1); device.commit(); // Check for errors const char* errorMessage; if (device.getError(errorMessage) != oidn::Error::None) std::cerr << "Error: " << errorMessage << std::endl; // Query device properties int version = device.get("version"); bool systemMemSupported = device.get("systemMemorySupported"); // Device automatically released when DeviceRef goes out of scope ``` ### Response #### Success Response (200) N/A (Function returns oidn::DeviceRef handle) #### Response Example N/A ``` -------------------------------- ### Create and Manage Denoising Device (C99 API) Source: https://context7.com/openimagedenoise/oidn/llms.txt Initializes a denoising device using the C99 API. Requires manual commit and release of the device object. ```cpp #include // Create a device (automatically selects best available) OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); // Or explicitly select device type: // OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_CPU); // OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_CUDA); // Configure device parameters (optional) oidnSetDeviceInt(device, "verbose", 1); // Enable console output // Commit changes before using the device oidnCommitDevice(device); // Check for errors const char* errorMessage; if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) printf("Device creation error: %s\n", errorMessage); // ... use device ... // Cleanup when done oidnReleaseDevice(device); ``` -------------------------------- ### Set up Intel oneAPI DPC++/C++ Compiler on Linux Source: https://github.com/openimagedenoise/oidn/blob/master/doc/compilation.md Source the 'vars.sh' script to add Intel's DPC++ compiler executables to your PATH. This is necessary before compiling with SYCL support. ```bash source /opt/intel/oneAPI/compiler/latest/env/vars.sh ``` -------------------------------- ### Query OIDN Buffer Properties Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Get the size in bytes and storage mode of an OIDN buffer. ```cpp size_t oidnGetBufferSize (OIDNBuffer buffer); ``` ```cpp OIDNStorage oidnGetBufferStorage(OIDNBuffer buffer); ``` -------------------------------- ### Create and Manage Denoising Device (C++11 API) Source: https://context7.com/openimagedenoise/oidn/llms.txt Initializes a device using the C++11 wrapper, which provides automatic reference counting for device management. ```cpp #include // Create device with automatic reference counting oidn::DeviceRef device = oidn::newDevice(); // Default device // or: oidn::DeviceRef device = oidn::newDevice(oidn::DeviceType::CUDA); // Configure and commit device.set("verbose", 1); device.commit(); // Check for errors const char* errorMessage; if (device.getError(errorMessage) != oidn::Error::None) std::cerr << "Error: " << errorMessage << std::endl; // Query device properties int version = device.get("version"); bool systemMemSupported = device.get("systemMemorySupported"); // Device automatically released when DeviceRef goes out of scope ``` -------------------------------- ### Create a device for specific compute APIs Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Initializes devices with support for SYCL, CUDA, HIP, or Metal interoperability. ```cpp OIDNDevice oidnNewSYCLDevice(const sycl::queue* queues, int numQueues); OIDNDevice oidnNewCUDADevice(const int* deviceIDs, const cudaStream_t* streams, int numPairs); OIDNDevice oidnNewHIPDevice(const int* deviceIDs, const hipStream_t* streams, int numPairs); OIDNDevice oidnNewMetalDevice(const MTLCommandQueue_id* commandQueues, int numQueues); ``` -------------------------------- ### Implement Basic HDR Denoising Workflow Source: https://context7.com/openimagedenoise/oidn/llms.txt Demonstrates a complete denoising pipeline including device initialization, buffer management, and filter execution for HDR images. Requires copying input data into OIDN buffers before processing. ```cpp #include #include #include void denoiseHDRImage(float* color, float* albedo, float* normal, int width, int height) { // Create device OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); oidnCommitDevice(device); const char* errorMessage; if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) { printf("Device error: %s\n", errorMessage); return; } size_t bufferSize = width * height * 3 * sizeof(float); // Create buffers OIDNBuffer colorBuf = oidnNewBuffer(device, bufferSize); OIDNBuffer albedoBuf = oidnNewBuffer(device, bufferSize); OIDNBuffer normalBuf = oidnNewBuffer(device, bufferSize); // Copy input data to buffers float* colorPtr = (float*)oidnGetBufferData(colorBuf); float* albedoPtr = (float*)oidnGetBufferData(albedoBuf); float* normalPtr = (float*)oidnGetBufferData(normalBuf); memcpy(colorPtr, color, bufferSize); memcpy(albedoPtr, albedo, bufferSize); memcpy(normalPtr, normal, bufferSize); // Create and configure filter OIDNFilter filter = oidnNewFilter(device, "RT"); 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", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); oidnSetFilterBool(filter, "hdr", true); oidnSetFilterInt(filter, "quality", OIDN_QUALITY_HIGH); oidnCommitFilter(filter); oidnExecuteFilter(filter); // Check for errors if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) { printf("Filter error: %s\n", errorMessage); } else { // Copy denoised result back memcpy(color, colorPtr, bufferSize); printf("Denoising completed successfully\n"); } // Cleanup oidnReleaseFilter(filter); oidnReleaseBuffer(colorBuf); oidnReleaseBuffer(albedoBuf); oidnReleaseBuffer(normalBuf); oidnReleaseDevice(device); } ``` -------------------------------- ### Get Open Image Denoise Buffer Storage Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Queries the storage mode of an Open Image Denoise buffer. ```c OIDNStorage oidnGetBufferStorage(OIDNBuffer buffer); ``` -------------------------------- ### Get Open Image Denoise Buffer Size Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Retrieves the size in bytes of an Open Image Denoise buffer. ```c size_t oidnGetBufferSize (OIDNBuffer buffer); ``` -------------------------------- ### Get Number of Physical Devices Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Query the total number of physical devices supported by Open Image Denoise in the system. ```c++ oidnGetNumPhysicalDevices(OIDN_DEVICE_TYPE_GPU); ``` -------------------------------- ### Create a Logical Device Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Initializes a new logical device based on the specified device type. ```cpp OIDNDevice oidnNewDevice(OIDNDeviceType type); ``` -------------------------------- ### Create and Configure Denoising Filter with oidnNewFilter Source: https://context7.com/openimagedenoise/oidn/llms.txt Initializes a filter object, sets input/output images, and configures parameters like HDR and quality modes. Requires calling oidnCommitFilter before execution. ```cpp #include // Create the RT (ray tracing) filter OIDNFilter filter = oidnNewFilter(device, "RT"); // Set input 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); // Set output (can be same as color for in-place denoising) oidnSetFilterImage(filter, "output", colorBuf, OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0); // Configure filter parameters oidnSetFilterBool(filter, "hdr", true); // HDR image oidnSetFilterBool(filter, "srgb", false); // Linear color space oidnSetFilterBool(filter, "cleanAux", false); // Aux images are noisy // Set quality mode oidnSetFilterInt(filter, "quality", OIDN_QUALITY_HIGH); // Best quality // or OIDN_QUALITY_BALANCED for interactive // or OIDN_QUALITY_FAST for real-time preview // Limit memory usage (optional) oidnSetFilterInt(filter, "maxMemoryMB", 4000); // Max 4GB // Commit filter configuration oidnCommitFilter(filter); // Execute denoising oidnExecuteFilter(filter); // Check for errors const char* errorMessage; if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) printf("Filter error: %s\n", errorMessage); oidnReleaseFilter(filter); ``` -------------------------------- ### Querying Number of Physical Devices Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Get the total number of physical devices (CPUs and GPUs) supported by Open Image Denoise. ```APIDOC ## GET /oidn/physicalDevices/count ### Description Retrieves the number of physical devices supported by the Open Image Denoise library. ### Method GET ### Endpoint /oidn/physicalDevices/count ### Response #### Success Response (200) - **count** (int) - The number of physical devices available. ``` -------------------------------- ### Get and Set Float Filter Parameters Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Retrieve or set floating-point parameters for a filter. These are used for parameters that accept float values. ```c float oidnGetFilterFloat(OIDNFilter filter, const char* name); ``` ```c void oidnSetFilterFloat(OIDNFilter filter, const char* name, float value); ``` -------------------------------- ### Get and Set Integer Filter Parameters Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Retrieve or set integer parameters for a filter. Use these functions for parameters that expect integer values. ```c int oidnGetFilterInt (OIDNFilter filter, const char* name); ``` ```c void oidnSetFilterInt (OIDNFilter filter, const char* name, int value); ``` -------------------------------- ### Logical Device Creation Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md APIs for creating and managing logical devices within Open Image Denoise. ```APIDOC ## Creating a New Logical Device ### Description Creates a new logical device for Open Image Denoise, allowing for isolated usage. ### Method C Function ### Endpoint N/A ### Parameters - **type** (OIDNDeviceType) - Required - The type of device implementation to create (e.g., CPU, SYCL, CUDA). ### Request Example ```c OIDNDevice device = oidnNewDevice(OIDNDeviceType::OIDN_DEVICE_TYPE_CPU); ``` ### Response - **device** (OIDNDevice) - A handle to the newly created logical device. ### Response Example ``` // Returns a non-null pointer representing the device handle 0x7f8b4c8d0a00 ``` ``` -------------------------------- ### OIDN Device Creation (C99 API) Source: https://context7.com/openimagedenoise/oidn/llms.txt Demonstrates how to create and configure a denoising device using the C99 API, including error handling and cleanup. ```APIDOC ## oidnNewDevice - Create a New Device ### Description Creates a denoising device of the specified type (CPU, SYCL/Intel GPU, CUDA/NVIDIA GPU, HIP/AMD GPU, or Metal/Apple GPU). The device must be committed before use. ### Method C Function Call ### Endpoint N/A (Library Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```cpp #include // Create a device (automatically selects best available) OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT); // Or explicitly select device type: // OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_CPU); // OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_CUDA); // Configure device parameters (optional) oidnSetDeviceInt(device, "verbose", 1); // Enable console output // Commit changes before using the device oidnCommitDevice(device); // Check for errors const char* errorMessage; if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE) printf("Device creation error: %s\n", errorMessage); // ... use device ... // Cleanup when done oidnReleaseDevice(device); ``` ### Response #### Success Response (200) N/A (Function returns OIDNDevice handle) #### Response Example N/A ``` -------------------------------- ### Get and Set Boolean Filter Parameters Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Retrieve or set boolean parameters for a filter. Ensure the parameter name is valid for the current filter. ```c bool oidnGetFilterBool (OIDNFilter filter, const char* name); ``` ```c void oidnSetFilterBool (OIDNFilter filter, const char* name, bool value); ``` -------------------------------- ### Device Creation Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Demonstrates various methods for creating an Open Image Denoise device, including default, CPU, SYCL, CUDA, HIP, and Metal devices, as well as creation by physical device ID, UUID, LUID, or PCI address. ```APIDOC ## Device Creation Methods ### Description This section outlines the different ways to create an `OIDNDevice` object, allowing selection of specific hardware or fallback to default options. ### Supported Device Types - `OIDN_DEVICE_TYPE_DEFAULT`: Selects the likely fastest device (same as physical device with ID 0). - `OIDN_DEVICE_TYPE_CPU`: Selects the CPU device. - `OIDN_DEVICE_TYPE_SYCL`: Selects a SYCL device (requires a supported Intel GPU). - `OIDN_DEVICE_TYPE_CUDA`: Selects a CUDA device (requires a supported NVIDIA GPU). - `OIDN_DEVICE_TYPE_HIP`: Selects a HIP device (requires a supported AMD GPU). - `OIDN_DEVICE_TYPE_METAL`: Selects a Metal device (requires a supported Apple GPU). ### Creating a Device #### Default Device ```c OIDNDevice oidnNewDevice(OIDNDeviceType type); ``` #### Device by Physical ID ```c OIDNDevice oidnNewDeviceByID(int physicalDeviceID); ``` #### Device by Unique Identifiers ```c OIDNDevice oidnNewDeviceByUUID(const void* uuid); OIDNDevice oidnNewDeviceByLUID(const void* luid); OIDNDevice oidnNewDeviceByPCIAddress(int pciDomain, int pciBus, int pciDevice, int pciFunction); ``` #### API-Specific Devices - **SYCL Device** ```c OIDNDevice oidnNewSYCLDevice(const sycl::queue* queues, int numQueues); ``` *Note: Only oneAPI Level Zero backend is supported. Multiple queues can be passed for a single SYCL root-device.* - **CUDA Device** ```c OIDNDevice oidnNewCUDADevice(const int* deviceIDs, const cudaStream_t* streams, int numPairs); ``` *Note: Currently supports only one pair of device ID and stream. `NULL` stream uses the default stream.* - **HIP Device** ```c OIDNDevice oidnNewHIPDevice(const int* deviceIDs, const hipStream_t* streams, int numPairs); ``` *Note: Currently supports only one pair of device ID and stream. `NULL` stream uses the default stream.* - **Metal Device** ```c OIDNDevice oidnNewMetalDevice(const MTLCommandQueue_id* commandQueues, int numQueues); ``` *Note: Supports a single command queue.* ``` -------------------------------- ### Get Physical Device String Property Source: https://github.com/openimagedenoise/oidn/blob/master/README.md Retrieve a string property of a physical device, such as its name, UUID, or LUID. Use appropriate indices for the desired property. ```c++ oidnGetPhysicalDeviceString(OIDN_DEVICE_TYPE_GPU, 0, OIDN_DEVICE_PROPERTY_UUID); ``` -------------------------------- ### Visualize Training Results Source: https://github.com/openimagedenoise/oidn/blob/master/doc/training.md Visualizes training and validation losses, and learning rate using TensorBoard. Ensure training statistics are logged per epoch. ```bash ./visualize.py --result rt_hdr_alb ``` -------------------------------- ### Denoising with Prefiltering (C++11 API) Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Demonstrates denoising a beauty image using prefiltered auxiliary images with the C++11 API. Requires separate filters for beauty and auxiliary images. ```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(); ``` -------------------------------- ### Add Application Target with CMake Source: https://github.com/openimagedenoise/oidn/blob/master/apps/CMakeLists.txt Defines a CMake macro to add an executable target, link necessary libraries, and install it. Use this macro to build applications that depend on OpenImageDenoise. ```cmake 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() ``` -------------------------------- ### Basic Denoising with C++11 API Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Demonstrates basic image denoising using the C++11 wrapper API. Ensure OpenImageDenoise/oidn.hpp is included. Uses RAII for resource management. ```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 not no 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; ``` -------------------------------- ### Build OIDN with Ninja on Linux Source: https://github.com/openimagedenoise/oidn/blob/master/doc/compilation.md After configuring CMake and generating build files, use Ninja to build the OIDN library. ```bash ninja ``` -------------------------------- ### Create Buffer with Storage Mode using oidnNewBufferWithStorage Source: https://context7.com/openimagedenoise/oidn/llms.txt Allocates buffers with specific storage modes to optimize memory usage. Includes examples for managed, host-pinned, and device-specific memory. ```cpp #include size_t bufferSize = width * height * 3 * sizeof(float); // Check if device supports managed memory bool managedSupported = oidnGetDeviceBool(device, "managedMemorySupported"); OIDNBuffer buffer; if (managedSupported) { // Use managed memory (automatically migrated between host/device) buffer = oidnNewBufferWithStorage(device, bufferSize, OIDN_STORAGE_MANAGED); } else { // Use host-pinned memory (accessible by both) buffer = oidnNewBufferWithStorage(device, bufferSize, OIDN_STORAGE_HOST); } // For dedicated GPUs, device storage may be faster but requires explicit copy OIDNBuffer deviceBuffer = oidnNewBufferWithStorage(device, bufferSize, OIDN_STORAGE_DEVICE); // Copy data to device buffer asynchronously float* hostData = /* your host image data */; oidnWriteBufferAsync(deviceBuffer, 0, bufferSize, hostData); // Synchronize before using oidnSyncDevice(device); // Copy results back float* outputData = malloc(bufferSize); oidnReadBuffer(deviceBuffer, 0, bufferSize, outputData); oidnReleaseBuffer(buffer); oidnReleaseBuffer(deviceBuffer); ``` -------------------------------- ### Configure CUDA API and Runtime Source: https://github.com/openimagedenoise/oidn/blob/master/devices/cuda/CMakeLists.txt Sets up the CUDA API type and runtime library linking based on the OIDN_DEVICE_CUDA_API variable. ```cmake if(OIDN_DEVICE_CUDA_API STREQUAL "Driver") add_library(curtn STATIC curtn.cpp) target_link_libraries(curtn PUBLIC CUDA::cuda_driver) target_compile_definitions(OpenImageDenoise_device_cuda PRIVATE OIDN_DEVICE_CUDA_API_DRIVER) target_link_libraries(OpenImageDenoise_device_cuda PRIVATE curtn) set(OIDN_CUDA_RUNTIME_LIBRARY "None") elseif(OIDN_DEVICE_CUDA_API STREQUAL "RuntimeStatic") set(OIDN_CUDA_RUNTIME_LIBRARY "Static") elseif(OIDN_DEVICE_CUDA_API STREQUAL "RuntimeShared") set(OIDN_CUDA_RUNTIME_LIBRARY "Shared") else() message(FATAL_ERROR "Invalid OIDN_DEVICE_CUDA_API value") endif() ``` -------------------------------- ### Clone Open Image Denoise Repository Source: https://github.com/openimagedenoise/oidn/blob/master/doc/compilation.md Clone the Intel Open Image Denoise repository using Git with the Git LFS extension installed. This extension is required for correct cloning. ```bash git clone --recursive https://github.com/OpenImageDenoise/oidn.git ``` -------------------------------- ### Get Open Image Denoise Buffer Data Pointer Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Obtains a direct pointer to the data of an Open Image Denoise buffer. Access is only permitted if the buffer was created with OIDN_STORAGE_HOST or OIDN_STORAGE_MANAGED. Returns NULL if the buffer is empty. ```c void* oidnGetBufferData(OIDNBuffer buffer); ``` -------------------------------- ### Device Creation and Management Source: https://github.com/openimagedenoise/oidn/blob/master/doc/api.md Functions for creating, retaining, releasing, and committing Open Image Denoise devices. ```APIDOC ## Device Creation and Management ### Description This section covers the core functions for managing Open Image Denoise devices, including creation, reference counting, and committing the device configuration. ### Functions - **`oidnNewDevice(type)`**: Creates a new Open Image Denoise device. - **Parameters**: - `type` (OIDNDeviceType) - Required - The type of the device to create (e.g., `OIDN_DEVICE_TYPE_CPU`, `OIDN_DEVICE_TYPE_GPU`). - **Returns**: An `OIDNDevice` handle to the newly created device. - **`oidnRetainDevice(device)`**: Increases the reference count of a device. - **Parameters**: - `device` (OIDNDevice) - Required - The device to retain. - **`oidnReleaseDevice(device)`**: Decreases the reference count of a device. If the count reaches zero, the device is deleted. - **Parameters**: - `device` (OIDNDevice) - Required - The device to release. - **`oidnCommitDevice(device)`**: Commits the parameters set on the device. This function must be called after setting all desired parameters and before using the device for other operations. A device can only be committed once. - **Parameters**: - `device` (OIDNDevice) - Required - The device to commit. ``` -------------------------------- ### Train and export custom denoising models Source: https://context7.com/openimagedenoise/oidn/llms.txt Use the Python training toolkit to preprocess data, train models, visualize progress, and export weights. ```bash # Preprocess training data cd training ./preprocess.py hdr alb nrm --filter RT \ --train_data my_train --valid_data my_valid # Train model ./train.py hdr alb --filter RT \ --train_data my_train --valid_data my_valid \ --result my_custom_model \ --quality high \ --num_epochs 2000 # Visualize training progress ./visualize.py --result my_custom_model # Test model with inference ./infer.py --result my_custom_model --input_data my_test \ --format exr png --metric ssim psnr # Export model weights for runtime use ./export.py --result my_custom_model # Produces: my_custom_model.tza ``` -------------------------------- ### Create Device Buffer with oidnNewBuffer Source: https://context7.com/openimagedenoise/oidn/llms.txt Allocates a buffer for image data accessible by both host and device. Requires manual cleanup using oidnReleaseBuffer. ```cpp #include int width = 1920, height = 1080; size_t numPixels = width * height; size_t bufferSize = numPixels * 3 * sizeof(float); // RGB float image // Create buffers for input and output OIDNBuffer colorBuf = oidnNewBuffer(device, bufferSize); OIDNBuffer albedoBuf = oidnNewBuffer(device, bufferSize); OIDNBuffer normalBuf = oidnNewBuffer(device, bufferSize); // Get pointer to buffer data for reading/writing float* colorPtr = (float*)oidnGetBufferData(colorBuf); float* albedoPtr = (float*)oidnGetBufferData(albedoBuf); float* normalPtr = (float*)oidnGetBufferData(normalBuf); // Fill buffers with rendered image data for (size_t i = 0; i < numPixels * 3; i++) { colorPtr[i] = /* your noisy rendered color */; albedoPtr[i] = /* your albedo AOV */; normalPtr[i] = /* your normal AOV */; } // Query buffer properties size_t size = oidnGetBufferSize(colorBuf); OIDNStorage storage = oidnGetBufferStorage(colorBuf); // Cleanup oidnReleaseBuffer(colorBuf); oidnReleaseBuffer(albedoBuf); oidnReleaseBuffer(normalBuf); ```