From 6e538e9e757839b681e31697399e032793a0ef99 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Wed, 11 May 2022 16:37:11 -0600 Subject: [PATCH 01/34] bump version to v1.4.0. --- CMakeLists.txt | 2 +- gitlab/.gitlab-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b827dae..9055cfc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) ## Establish project ## -project(openvkl VERSION 1.3.0 LANGUAGES C CXX) +project(openvkl VERSION 1.4.0 LANGUAGES C CXX) ## Add openvkl specific macros ## diff --git a/gitlab/.gitlab-ci.yml b/gitlab/.gitlab-ci.yml index c88fc3c0..64da3384 100644 --- a/gitlab/.gitlab-ci.yml +++ b/gitlab/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: GIT_DEPTH: "15" KW_PROJECT_NAME: openvkl - OPENVKL_RELEASE_PACKAGE_VERSION: "1.3.0" + OPENVKL_RELEASE_PACKAGE_VERSION: "1.4.0" MACOSX_DEPLOYMENT_TARGET: "10.13" default: From e1989a3761493e690bf9ffd6a7c502f38b37b6fa Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 7 Jun 2022 13:46:04 -0600 Subject: [PATCH 02/34] CI: run additional tutorials for release binary tests. --- gitlab/release/linux-test.sh | 9 ++++++++- gitlab/release/macos-test.sh | 9 ++++++++- gitlab/release/windows-test.ps1 | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gitlab/release/linux-test.sh b/gitlab/release/linux-test.sh index ff432ce3..d4c9b113 100755 --- a/gitlab/release/linux-test.sh +++ b/gitlab/release/linux-test.sh @@ -2,6 +2,9 @@ ## Copyright 2020 Intel Corporation ## SPDX-License-Identifier: Apache-2.0 +# abort on any error +set -e + ROOT_DIR=$PWD #### Extract release package #### @@ -22,8 +25,12 @@ cmake ../examples/from_openvkl_install cmake --build . -#### Run tutorial to verify functionality ### +#### Run tutorial to verify functionality #### export LD_LIBRARY_PATH=${openvkl_DIR}/lib:${LD_LIBRARY_PATH} ./vklTutorial + +#### Run binaries from release package to verify functionality #### + +${openvkl_DIR}/bin/vklMinimal_06 diff --git a/gitlab/release/macos-test.sh b/gitlab/release/macos-test.sh index d56221a3..529b892b 100755 --- a/gitlab/release/macos-test.sh +++ b/gitlab/release/macos-test.sh @@ -2,6 +2,9 @@ ## Copyright 2020 Intel Corporation ## SPDX-License-Identifier: Apache-2.0 +# abort on any error +set -e + ROOT_DIR=$PWD #### Extract release package #### @@ -22,8 +25,12 @@ cmake ../examples/from_openvkl_install cmake --build . -#### Run tutorial to verify functionality ### +#### Run tutorial to verify functionality #### export DYLD_LIBRARY_PATH=${openvkl_DIR}/lib:${DYLD_LIBRARY_PATH} ./vklTutorial + +#### Run binaries from release package to verify functionality #### + +${openvkl_DIR}/bin/vklMinimal_06 diff --git a/gitlab/release/windows-test.ps1 b/gitlab/release/windows-test.ps1 index 1777f911..c5c415a5 100755 --- a/gitlab/release/windows-test.ps1 +++ b/gitlab/release/windows-test.ps1 @@ -24,10 +24,14 @@ cmake -L ` cmake --build . --config Release --target ALL_BUILD -- /m /nologo -#### Run tutorial to verify functionality ### +#### Run tutorial to verify functionality #### $env:PATH += ";$env:openvkl_DIR\bin" .\Release\vklTutorial.exe +#### Run binaries from release package to verify functionality #### + +vklMinimal_06.exe + exit $LASTEXITCODE From 6c38b6f616c9378738081defb5601395ee52715c Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Wed, 8 Jun 2022 14:37:34 -0600 Subject: [PATCH 03/34] superbuild: enable OpenVDB build on Windows (for TBB 2020 only). --- superbuild/CMakeLists.txt | 11 ++++------- superbuild/dependencies/dep_boost.cmake | 5 +++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index ae13e6aa..04ba5948 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -206,17 +206,11 @@ endif() # enabled, and to not attempt to find them in the environment. set(BUILD_OPENVDB_DEFAULT ON) mark_as_advanced(BUILD_OPENVDB_DEFAULT) -if (WIN32) - set(BUILD_OPENVDB_DEFAULT OFF) -endif() option(BUILD_OPENVDB "Enable OpenVDB to support loading .vdb files?" ${BUILD_OPENVDB_DEFAULT}) option(BUILD_BLOSC "Support loading compressed .vdb files using c-BLOSC? (Only used when BUILD_OPENVDB=ON)" ON) if (BUILD_OPENVDB) - if (WIN32) - message(FATAL_ERROR "Open VKL superbuild currently does not support building on Windows.") - set(BUILD_OPENVDB OFF) - elseif (CMAKE_VERSION VERSION_LESS 3.12) + if (CMAKE_VERSION VERSION_LESS 3.12) message(WARNING "Disabling OpenVDB support because the cmake version is too low (3.12 is required)") set(BUILD_OPENVDB OFF) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.3) @@ -225,6 +219,9 @@ if (BUILD_OPENVDB) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.1) message(WARNING "Disabling OpenVDB support because the icc compiler version is too low (19.1 is required)") set(BUILD_OPENVDB OFF) + elseif (WIN32 AND BUILD_TBB AND (NOT TBB_VERSION VERSION_LESS 2021)) + message(WARNING "Open VKL superbuild currently does not support building OpenVDB on Windows with TBB 2021") + set(BUILD_OPENVDB OFF) else() set(ILMBASE_VERSION "2.5.8") set(ILMBASE_URL "https://github.com/AcademySoftwareFoundation/openexr/archive/v${ILMBASE_VERSION}.zip" diff --git a/superbuild/dependencies/dep_boost.cmake b/superbuild/dependencies/dep_boost.cmake index 099cef94..a160ae60 100644 --- a/superbuild/dependencies/dep_boost.cmake +++ b/superbuild/dependencies/dep_boost.cmake @@ -12,6 +12,11 @@ set(BOOST_CONF "./bootstrap.sh") set(BOOST_BUILD "./b2") set(BOOST_LINK "shared") +if (WIN32) + set(BOOST_CONF "bootstrap.bat") + set(BOOST_BUILD "b2.exe") +endif() + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64|aarch64") set(BOOST_ARCH "arm") else() From e5186414fdb47f4b4dbd3e0d01021f82f75d8bbc Mon Sep 17 00:00:00 2001 From: Will Usher Date: Fri, 17 Jun 2022 19:09:32 +0000 Subject: [PATCH 04/34] Rework object creation registry to overwrite on plugin load This resolves an issue where we would end up with stale object creation function pointers in the registry after unloading and reloading the OpenVKL module --- openvkl/api/Device.cpp | 12 +++-- openvkl/api/Device.h | 2 + openvkl/common/ManagedObject.h | 11 ++-- openvkl/common/ObjectFactory.h | 58 +++++++++++++++++++++ openvkl/common/objectFactory.h | 61 ---------------------- openvkl/devices/cpu/api/CPUDevice.cpp | 66 ++++++++++++++++++++++++ openvkl/devices/cpu/exports.cpp | 74 ++------------------------- openvkl/devices/cpu/volume/Volume.h | 19 ++++++- 8 files changed, 163 insertions(+), 140 deletions(-) create mode 100644 openvkl/common/ObjectFactory.h delete mode 100644 openvkl/common/objectFactory.h diff --git a/openvkl/api/Device.cpp b/openvkl/api/Device.cpp index 576595a5..2a28c665 100644 --- a/openvkl/api/Device.cpp +++ b/openvkl/api/Device.cpp @@ -3,13 +3,15 @@ #include "Device.h" #include -#include "../common/objectFactory.h" #include "ispc_util_ispc.h" #include "rkcommon/tasking/tasking_system_init.h" #include "rkcommon/utility/StringManip.h" #include "rkcommon/utility/getEnvVar.h" namespace openvkl { + + static ObjectFactory g_devicesFactory; + namespace api { // helper functions @@ -110,10 +112,14 @@ namespace openvkl { std::stringstream ss; ss << cpuDeviceName << "_" << requestedDeviceWidth; - return objectFactory(nullptr, ss.str()); + return g_devicesFactory.createInstance(nullptr, ss.str()); } + return g_devicesFactory.createInstance(nullptr, deviceName); + } - return objectFactory(nullptr, deviceName); + void Device::registerType(const std::string &type, FactoryFcn f) + { + g_devicesFactory.registerType(type, f); } void Device::commit() diff --git a/openvkl/api/Device.h b/openvkl/api/Device.h index 581b437a..5937902d 100644 --- a/openvkl/api/Device.h +++ b/openvkl/api/Device.h @@ -5,6 +5,7 @@ #include #include +#include "../common/ObjectFactory.h" #include "../common/VKLCommon.h" #include "../common/simd.h" #include "openvkl/openvkl.h" @@ -33,6 +34,7 @@ namespace openvkl { virtual ~Device() override = default; static Device *createDevice(const std::string &deviceName); + static void registerType(const std::string &type, FactoryFcn f); // error tracking VKLError lastErrorCode = VKL_NO_ERROR; diff --git a/openvkl/common/ManagedObject.h b/openvkl/common/ManagedObject.h index 4e1d89f0..6068b707 100644 --- a/openvkl/common/ManagedObject.h +++ b/openvkl/common/ManagedObject.h @@ -4,8 +4,8 @@ #pragma once #include "../api/Device.h" +#include "ObjectFactory.h" #include "VKLCommon.h" -#include "objectFactory.h" #include "rkcommon/memory/IntrusivePtr.h" #include "rkcommon/memory/RefCount.h" #include "rkcommon/utility/ParameterizedObject.h" @@ -68,7 +68,6 @@ namespace openvkl { size_t expectedSize, T valIfNotFound); - // throws an error if the named Data parameter is present and not compact void requireParamDataIsCompact(const char *name); @@ -87,14 +86,16 @@ namespace openvkl { }; template - inline OPENVKL_CLASS *createInstanceHelper(Device *device, - const std::string &type) + inline OPENVKL_CLASS *createInstanceHelper( + Device *device, + const std::string &type, + ObjectFactory &factory) { static_assert(std::is_base_of::value, "createInstanceHelper<>() is only for VKL classes, not" " generic types!"); - auto *object = objectFactory(device, type); + auto *object = factory.createInstance(device, type); // denote the subclass type in the ManagedObject base class. if (object) { diff --git a/openvkl/common/ObjectFactory.h b/openvkl/common/ObjectFactory.h new file mode 100644 index 00000000..89f499ae --- /dev/null +++ b/openvkl/common/ObjectFactory.h @@ -0,0 +1,58 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include "VKLCommon.h" +#include "logging.h" +#include "openvkl/VKLDataType.h" + +namespace openvkl { + + // Function pointer type for creating a concrete instance of a subtype of + // this class. + template + using FactoryFcn = T *(*)(); + + template + struct ObjectFactory + { + T *createInstance(Device *device, const std::string &type); + + void registerType(const std::string &type, FactoryFcn f); + + private: + std::map> registry; + }; + + template + T *ObjectFactory::createInstance(Device *device, + const std::string &type) + { + const auto type_string = stringFor(VKL_TYPE); + + T *object = nullptr; + if (registry.count(type) != 0) { + // Create a concrete instance of the requested subtype. + object = (*registry[type])(); + } + + if (object == nullptr) { + registry.erase(type); + throw std::runtime_error( + "Could not find " + type_string + " of type: " + type + + ". Make sure you have the correct VKL libraries linked."); + } + + return object; + } + + template + void ObjectFactory::registerType(const std::string &type, + FactoryFcn f) + { + registry[type] = f; + } + +} // namespace openvkl diff --git a/openvkl/common/objectFactory.h b/openvkl/common/objectFactory.h deleted file mode 100644 index c739ebd7..00000000 --- a/openvkl/common/objectFactory.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include "VKLCommon.h" -#include "logging.h" -#include "openvkl/VKLDataType.h" -#include "rkcommon/os/library.h" - -namespace openvkl { - - template - inline T *objectFactory(Device *device, const std::string &type) - { - // Function pointer type for creating a concrete instance of a subtype of - // this class. - using creationFunctionPointer = T *(*)(); - - // Function pointers corresponding to each subtype. - static std::map symbolRegistry; - const auto type_string = stringFor(VKL_TYPE); - - // Find the creation function for the subtype if not already known. - if (symbolRegistry.count(type) == 0) { - postLogMessage(device, VKL_LOG_DEBUG) - << "trying to look up " << type_string << " type '" << type - << "' for the first time"; - - // Construct the name of the creation function to look for. - std::string creationFunctionName = - "openvkl_create_" + type_string + "__" + type; - - // Look for the named function. - symbolRegistry[type] = - (creationFunctionPointer)rkcommon::getSymbol(creationFunctionName); - - // The named function may not be found if the requested subtype is not - // known. - if (!symbolRegistry[type]) { - postLogMessage(device, VKL_LOG_WARNING) - << "WARNING: unrecognized " << type_string << " type '" << type - << "'."; - } - } - - // Create a concrete instance of the requested subtype. - auto *object = symbolRegistry[type] ? (*symbolRegistry[type])() : nullptr; - - if (object == nullptr) { - symbolRegistry.erase(type); - throw std::runtime_error( - "Could not find " + type_string + " of type: " + type + - ". Make sure you have the correct VKL libraries linked."); - } - - return object; - } - -} // namespace openvkl diff --git a/openvkl/devices/cpu/api/CPUDevice.cpp b/openvkl/devices/cpu/api/CPUDevice.cpp index 6d5ada53..55518714 100644 --- a/openvkl/devices/cpu/api/CPUDevice.cpp +++ b/openvkl/devices/cpu/api/CPUDevice.cpp @@ -3,6 +3,7 @@ #include "CPUDevice.h" #include "../common/Data.h" +#include "../common/ObjectFactory.h" #include "../common/export_util.h" #include "../common/ispc_isa.h" #include "../iterator/Iterator.h" @@ -810,7 +811,72 @@ namespace openvkl { } // namespace cpu_device } // namespace openvkl +#define VKL_MAKE_TARGET_WIDTH_NAME(name) \ + CONCAT1(name, CONCAT1(_, VKL_TARGET_WIDTH)) + +#define VKL_WRAP_DEVICE_REGISTRATION(internal_name) \ + extern "C" OPENVKL_DLLEXPORT openvkl::api::Device *CONCAT1( \ + openvkl_create_device__, internal_name)(); + +#define VKL_WRAP_VOLUME_REGISTRATION(internal_name) \ + extern "C" OPENVKL_DLLEXPORT openvkl::cpu_device::Volume \ + *CONCAT1(openvkl_create_volume__, internal_name)(); + +VKL_WRAP_DEVICE_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_cpu)) + +VKL_WRAP_VOLUME_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_amr)) +VKL_WRAP_VOLUME_REGISTRATION( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegular)) +VKL_WRAP_VOLUME_REGISTRATION( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredSpherical)) +VKL_WRAP_VOLUME_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_unstructured)) +VKL_WRAP_VOLUME_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_vdb)) +VKL_WRAP_VOLUME_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_particle)) + +#define VKL_REGISTER_DEVICE_FACTORY_FCN(internal_name, external_name) \ + openvkl::Device::registerType( \ + TOSTRING(external_name), \ + CONCAT1(openvkl_create_device__, internal_name)) + +#define VKL_REGISTER_VOLUME_FACTORY_FCN(internal_name, external_name) \ + openvkl::cpu_device::Volume::registerType( \ + TOSTRING(external_name), \ + CONCAT1(openvkl_create_volume__, internal_name)) + extern "C" OPENVKL_DLLEXPORT void CONCAT1(openvkl_init_module_cpu_device_, VKL_TARGET_WIDTH)() { + VKL_REGISTER_DEVICE_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_cpu), + VKL_MAKE_TARGET_WIDTH_NAME(cpu)); + + VKL_REGISTER_VOLUME_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_amr), + VKL_MAKE_TARGET_WIDTH_NAME(amr)); + + VKL_REGISTER_VOLUME_FACTORY_FCN( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegular), + VKL_MAKE_TARGET_WIDTH_NAME(structuredRegular)); + + VKL_REGISTER_VOLUME_FACTORY_FCN( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredSpherical), + VKL_MAKE_TARGET_WIDTH_NAME(structuredSpherical)); + + VKL_REGISTER_VOLUME_FACTORY_FCN( + VKL_MAKE_TARGET_WIDTH_NAME(internal_unstructured), + VKL_MAKE_TARGET_WIDTH_NAME(unstructured)); + + VKL_REGISTER_VOLUME_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_vdb), + VKL_MAKE_TARGET_WIDTH_NAME(vdb)); + + VKL_REGISTER_VOLUME_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_particle), + VKL_MAKE_TARGET_WIDTH_NAME(particle)); + + // support deprecated snake case names (a warning will be triggered if these + // are used) + VKL_REGISTER_VOLUME_FACTORY_FCN( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegular), + VKL_MAKE_TARGET_WIDTH_NAME(structured_regular)); + + VKL_REGISTER_VOLUME_FACTORY_FCN( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredSpherical), + VKL_MAKE_TARGET_WIDTH_NAME(structured_spherical)); } diff --git a/openvkl/devices/cpu/exports.cpp b/openvkl/devices/cpu/exports.cpp index 00673689..7c377902 100644 --- a/openvkl/devices/cpu/exports.cpp +++ b/openvkl/devices/cpu/exports.cpp @@ -8,83 +8,19 @@ // available in the top level module library, as exports from dependencies will // not be visible. -#define VKL_WRAP_DEVICE_REGISTRATION( \ - module_name, internal_name, external_name) \ - extern "C" OPENVKL_DLLEXPORT void openvkl_init_module_##module_name(); \ - \ - extern "C" OPENVKL_DLLEXPORT ::openvkl::api::Device \ - *openvkl_create_device__##internal_name(); \ - \ - extern "C" OPENVKL_DLLEXPORT ::openvkl::api::Device \ - *openvkl_create_device__##external_name() \ - { \ - return openvkl_create_device__##internal_name(); \ - } - -#define VKL_WRAP_VOLUME_REGISTRATION(internal_name, external_name) \ - extern "C" OPENVKL_DLLEXPORT ::openvkl::ManagedObject \ - *openvkl_create_volume__##internal_name(); \ - \ - extern "C" OPENVKL_DLLEXPORT ::openvkl::ManagedObject \ - *openvkl_create_volume__##external_name() \ - { \ - return openvkl_create_volume__##internal_name(); \ - } +#define VKL_WRAP_MODULE_REGISTRATION(module_name) \ + extern "C" OPENVKL_DLLEXPORT void openvkl_init_module_##module_name(); #if VKL_TARGET_WIDTH_ENABLED_4 -VKL_WRAP_DEVICE_REGISTRATION(cpu_device_4, internal_cpu_4, cpu_4) - -VKL_WRAP_VOLUME_REGISTRATION(internal_amr_4, amr_4) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredRegular_4, structuredRegular_4) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredSpherical_4, - structuredSpherical_4) -VKL_WRAP_VOLUME_REGISTRATION(internal_unstructured_4, unstructured_4) -VKL_WRAP_VOLUME_REGISTRATION(internal_vdb_4, vdb_4) -VKL_WRAP_VOLUME_REGISTRATION(internal_particle_4, particle_4) - -// support deprecated snake case names (a warning will be triggered if these are -// used) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredRegular_4, structured_regular_4) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredSpherical_4, - structured_spherical_4) +VKL_WRAP_MODULE_REGISTRATION(cpu_device_4) #endif #if VKL_TARGET_WIDTH_ENABLED_8 -VKL_WRAP_DEVICE_REGISTRATION(cpu_device_8, internal_cpu_8, cpu_8) - -VKL_WRAP_VOLUME_REGISTRATION(internal_amr_8, amr_8) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredRegular_8, structuredRegular_8) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredSpherical_8, - structuredSpherical_8) -VKL_WRAP_VOLUME_REGISTRATION(internal_unstructured_8, unstructured_8) -VKL_WRAP_VOLUME_REGISTRATION(internal_vdb_8, vdb_8) -VKL_WRAP_VOLUME_REGISTRATION(internal_particle_8, particle_8) - -// support deprecated snake case names (a warning will be triggered if these are -// used) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredRegular_8, structured_regular_8) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredSpherical_8, - structured_spherical_8) +VKL_WRAP_MODULE_REGISTRATION(cpu_device_8) #endif #if VKL_TARGET_WIDTH_ENABLED_16 -VKL_WRAP_DEVICE_REGISTRATION(cpu_device_16, internal_cpu_16, cpu_16) - -VKL_WRAP_VOLUME_REGISTRATION(internal_amr_16, amr_16) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredRegular_16, - structuredRegular_16) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredSpherical_16, - structuredSpherical_16) -VKL_WRAP_VOLUME_REGISTRATION(internal_unstructured_16, unstructured_16) -VKL_WRAP_VOLUME_REGISTRATION(internal_vdb_16, vdb_16) -VKL_WRAP_VOLUME_REGISTRATION(internal_particle_16, particle_16) - -// support deprecated snake case names (a warning will be triggered if these are -// used) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredRegular_16, - structured_regular_16) -VKL_WRAP_VOLUME_REGISTRATION(internal_structuredSpherical_16, - structured_spherical_16) +VKL_WRAP_MODULE_REGISTRATION(cpu_device_16) #endif // calls init functions in [4, 8, 16] devices to ensure proper linkage diff --git a/openvkl/devices/cpu/volume/Volume.h b/openvkl/devices/cpu/volume/Volume.h index 6978e14c..4843f77b 100644 --- a/openvkl/devices/cpu/volume/Volume.h +++ b/openvkl/devices/cpu/volume/Volume.h @@ -4,8 +4,8 @@ #pragma once #include "../common/ManagedObject.h" +#include "../common/ObjectFactory.h" #include "../common/export_util.h" -#include "../common/objectFactory.h" #include "../iterator/Iterator.h" #include "../sampler/Sampler.h" #include "Volume_ispc.h" @@ -42,6 +42,8 @@ namespace openvkl { virtual ~Volume() override = default; static Volume *createInstance(Device *device, const std::string &type); + static void registerType(const std::string &type, + FactoryFcn> f); virtual Sampler *newSampler() = 0; @@ -60,6 +62,8 @@ namespace openvkl { protected: void *ispcEquivalent{nullptr}; + + static ObjectFactory volumeFactory; }; // Inlined definitions //////////////////////////////////////////////////// @@ -68,7 +72,15 @@ namespace openvkl { inline Volume *Volume::createInstance(Device *device, const std::string &type) { - return createInstanceHelper, VKL_VOLUME>(device, type); + return createInstanceHelper, VKL_VOLUME>( + device, type, volumeFactory); + } + + template + inline void Volume::registerType(const std::string &type, + FactoryFcn> f) + { + volumeFactory.registerType(type, f); } template @@ -77,6 +89,9 @@ namespace openvkl { return ispcEquivalent; } + template + ObjectFactory, VKL_VOLUME> Volume::volumeFactory; + #define VKL_REGISTER_VOLUME(InternalClass, external_name) \ VKL_REGISTER_OBJECT( \ ::openvkl::ManagedObject, volume, InternalClass, external_name) From 5eeefe84d2bb8cf976ec059f8360dc1502a684fb Mon Sep 17 00:00:00 2001 From: "David E. DeMarle" Date: Wed, 23 Mar 2022 19:03:32 -0400 Subject: [PATCH 05/34] Move to sharedstruct host and device side framework This change brings VKL's ispc structs into the cpp class hierarchy and makes them directly accesible from ispc and cpp level code. This is in preparation for Xe host and device side execution. The specific changes were as follows: Bring over the shared struct header from OSPRay (multiple inheritance with CRTP pattern). Align cpp class and ispc struct inheritance to be 1:1 with a few dummy structs in key places. More super.super is a side effect. Move structs in foo.ih to fooShared.h. Apply macros from ispc_cpp_itnerop.h and make function signatures void * from cpp side in fooShared.h to make ispc structs cpp compilable. Apply shared struct to Volumes, IteratorContext, Samplers and Data. Get rid of this->ispcEquivalent in favor of this->getSh(). Struct's destructors are now noop's because cpp class destruction does it automatically. Also need to move the method implementations into cpp. Changed VdbVolume and AMRVolume _create to _Construct for consistency with other volumes. Add a couple of ISPC_STRUCT_ defines to prevent structs from being redeclared from includes. Unify all samplers to take volume references like vdb to avoid for sharedstruct's variadic constructors to support both between refs and pointers. Note that the ValueRanges.range, vdbSampler.denseLeafSample, and IteratorContext self->values are all still dynamically allocated. --- openvkl/common/Data.h | 15 +- openvkl/common/Data.ih | 10 +- openvkl/common/DataShared.h | 32 ++++ openvkl/common/StructShared.h | 177 ++++++++++++++++++ .../devices/cpu/iterator/DefaultIterator.cpp | 2 +- .../devices/cpu/iterator/DefaultIterator.h | 2 +- .../devices/cpu/iterator/DefaultIterator.ih | 2 +- .../devices/cpu/iterator/DefaultIterator.ispc | 9 +- .../cpu/iterator/GridAcceleratorIterator.cpp | 8 +- .../cpu/iterator/GridAcceleratorIterator.ispc | 26 +-- openvkl/devices/cpu/iterator/Iterator.ih | 146 +++++++-------- .../devices/cpu/iterator/IteratorContext.cpp | 52 ++--- .../devices/cpu/iterator/IteratorContext.h | 32 ++-- .../devices/cpu/iterator/IteratorContext.ih | 31 --- .../devices/cpu/iterator/IteratorContext.ispc | 70 ++++--- .../cpu/iterator/IteratorContextShared.h | 80 ++++++++ .../cpu/iterator/UnstructuredIterator.cpp | 2 +- .../cpu/iterator/UnstructuredIterator.ih | 2 +- .../cpu/iterator/UnstructuredIterator.ispc | 19 +- openvkl/devices/cpu/sampler/Sampler.cpp | 1 - openvkl/devices/cpu/sampler/Sampler.h | 25 ++- openvkl/devices/cpu/sampler/Sampler.ih | 34 +--- openvkl/devices/cpu/sampler/Sampler.ispc | 20 +- openvkl/devices/cpu/sampler/SamplerShared.h | 69 +++++++ openvkl/devices/cpu/volume/GridAccelerator.ih | 12 +- .../cpu/volume/GridAcceleratorShared.h | 22 +++ .../cpu/volume/SharedStructuredVolume.ih | 67 +------ .../cpu/volume/SharedStructuredVolume.ispc | 78 +++++--- .../cpu/volume/StructuredRegularVolume.cpp | 17 +- .../devices/cpu/volume/StructuredSampler.h | 55 +++--- .../cpu/volume/StructuredSamplerShared.h | 19 ++ .../cpu/volume/StructuredSphericalVolume.cpp | 19 +- .../devices/cpu/volume/StructuredVolume.cpp | 2 +- openvkl/devices/cpu/volume/StructuredVolume.h | 13 +- .../cpu/volume/StructuredVolumeShared.h | 99 ++++++++++ .../devices/cpu/volume/UnstructuredSampler.h | 28 +-- .../cpu/volume/UnstructuredSamplerBase.ih | 2 +- .../cpu/volume/UnstructuredSamplerShared.h | 21 +++ .../devices/cpu/volume/UnstructuredVolume.cpp | 18 +- .../devices/cpu/volume/UnstructuredVolume.h | 8 +- .../devices/cpu/volume/UnstructuredVolume.ih | 81 +------- .../cpu/volume/UnstructuredVolume.ispc | 71 ++++--- .../cpu/volume/UnstructuredVolumeBase.h | 43 +++++ .../cpu/volume/UnstructuredVolumeBaseShared.h | 30 +++ .../cpu/volume/UnstructuredVolumeShared.h | 78 ++++++++ openvkl/devices/cpu/volume/Volume.h | 18 +- openvkl/devices/cpu/volume/Volume.ih | 7 +- openvkl/devices/cpu/volume/Volume.ispc | 2 +- openvkl/devices/cpu/volume/VolumeShared.h | 27 +++ openvkl/devices/cpu/volume/amr/AMR.ih | 80 +------- openvkl/devices/cpu/volume/amr/AMRSampler.h | 36 ++-- openvkl/devices/cpu/volume/amr/AMRShared.h | 114 +++++++++++ openvkl/devices/cpu/volume/amr/AMRVolume.cpp | 22 ++- openvkl/devices/cpu/volume/amr/AMRVolume.h | 6 +- openvkl/devices/cpu/volume/amr/AMRVolume.ih | 18 +- openvkl/devices/cpu/volume/amr/AMRVolume.ispc | 53 +++--- .../devices/cpu/volume/amr/AMRVolumeShared.h | 27 +++ openvkl/devices/cpu/volume/amr/CellRef.ih | 3 +- openvkl/devices/cpu/volume/amr/KDTree.ih | 10 +- openvkl/devices/cpu/volume/amr/KDTreeShared.h | 12 ++ .../cpu/volume/amr/method_current.ispc | 6 +- .../devices/cpu/volume/amr/method_finest.ispc | 6 +- .../devices/cpu/volume/amr/method_octant.ispc | 6 +- .../cpu/volume/particle/ParticleSampler.h | 29 +-- .../cpu/volume/particle/ParticleVolume.cpp | 16 +- .../cpu/volume/particle/ParticleVolume.h | 7 +- .../cpu/volume/particle/ParticleVolume.ih | 22 --- .../cpu/volume/particle/ParticleVolume.ispc | 66 +++---- .../volume/particle/ParticleVolumeShared.h | 26 +++ .../devices/cpu/volume/vdb/VdbIterator.cpp | 2 +- openvkl/devices/cpu/volume/vdb/VdbIterator.ih | 2 +- .../devices/cpu/volume/vdb/VdbIterator.ispc | 15 +- .../cpu/volume/vdb/VdbLeafAccessObserver.ih | 28 +-- .../cpu/volume/vdb/VdbSampleInner.ih.in | 2 +- openvkl/devices/cpu/volume/vdb/VdbSampler.cpp | 31 +-- openvkl/devices/cpu/volume/vdb/VdbSampler.h | 6 +- openvkl/devices/cpu/volume/vdb/VdbSampler.ih | 27 +-- .../devices/cpu/volume/vdb/VdbSampler.ispc | 97 +++++----- .../volume/vdb/VdbSamplerDispatchInner.ih.in | 24 +-- .../devices/cpu/volume/vdb/VdbSamplerShared.h | 52 +++++ .../cpu/volume/vdb/VdbSampler_nearest.ih | 71 +++---- .../vdb/VdbSampler_traverseAndSample.ih | 30 +-- .../cpu/volume/vdb/VdbSampler_tricubic.ih | 89 ++++----- .../cpu/volume/vdb/VdbSampler_trilinear.ih | 66 +++---- openvkl/devices/cpu/volume/vdb/VdbVolume.cpp | 6 +- openvkl/devices/cpu/volume/vdb/VdbVolume.h | 10 +- openvkl/devices/cpu/volume/vdb/VdbVolume.ih | 16 -- openvkl/devices/cpu/volume/vdb/VdbVolume.ispc | 9 +- .../devices/cpu/volume/vdb/VdbVolumeShared.h | 26 +++ openvkl/include/openvkl/ispc_cpp_interop.h | 3 +- 90 files changed, 1737 insertions(+), 1143 deletions(-) create mode 100644 openvkl/common/DataShared.h create mode 100644 openvkl/common/StructShared.h delete mode 100644 openvkl/devices/cpu/iterator/IteratorContext.ih create mode 100644 openvkl/devices/cpu/iterator/IteratorContextShared.h create mode 100644 openvkl/devices/cpu/sampler/SamplerShared.h create mode 100644 openvkl/devices/cpu/volume/GridAcceleratorShared.h create mode 100644 openvkl/devices/cpu/volume/StructuredSamplerShared.h create mode 100644 openvkl/devices/cpu/volume/StructuredVolumeShared.h create mode 100644 openvkl/devices/cpu/volume/UnstructuredSamplerShared.h create mode 100644 openvkl/devices/cpu/volume/UnstructuredVolumeBase.h create mode 100644 openvkl/devices/cpu/volume/UnstructuredVolumeBaseShared.h create mode 100644 openvkl/devices/cpu/volume/UnstructuredVolumeShared.h create mode 100644 openvkl/devices/cpu/volume/VolumeShared.h create mode 100644 openvkl/devices/cpu/volume/amr/AMRShared.h create mode 100644 openvkl/devices/cpu/volume/amr/AMRVolumeShared.h create mode 100644 openvkl/devices/cpu/volume/amr/KDTreeShared.h delete mode 100644 openvkl/devices/cpu/volume/particle/ParticleVolume.ih create mode 100644 openvkl/devices/cpu/volume/particle/ParticleVolumeShared.h create mode 100644 openvkl/devices/cpu/volume/vdb/VdbSamplerShared.h delete mode 100644 openvkl/devices/cpu/volume/vdb/VdbVolume.ih create mode 100644 openvkl/devices/cpu/volume/vdb/VdbVolumeShared.h diff --git a/openvkl/common/Data.h b/openvkl/common/Data.h index f6d7931b..cde8e328 100644 --- a/openvkl/common/Data.h +++ b/openvkl/common/Data.h @@ -7,20 +7,7 @@ #include "ManagedObject.h" #include "Traits.h" #include "openvkl/openvkl.h" - -#ifndef __ISPC_STRUCT_Data1D__ -#define __ISPC_STRUCT_Data1D__ -namespace ispc { - struct Data1D - { - const uint8_t *addr; - uint64_t byteStride; - uint64_t numItems; - VKLDataType dataType; - bool compact; - }; -} // namespace ispc -#endif +#include "DataShared.h" namespace openvkl { diff --git a/openvkl/common/Data.ih b/openvkl/common/Data.ih index e25dc5e2..e9176c60 100644 --- a/openvkl/common/Data.ih +++ b/openvkl/common/Data.ih @@ -6,15 +6,7 @@ #include "openvkl/VKLDataType.h" #include "rkcommon/math/math.ih" #include "rkcommon/math/vec.ih" - -struct Data1D -{ - const uint8 *addr; - uint64 byteStride; - uint64 numItems; - uint32 dataType; - bool compact; -}; +#include "DataShared.h" // in all inlined functions here, ok to pass-by-value, will be inlined and // optimized diff --git a/openvkl/common/DataShared.h b/openvkl/common/DataShared.h new file mode 100644 index 00000000..badb20f5 --- /dev/null +++ b/openvkl/common/DataShared.h @@ -0,0 +1,32 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "openvkl/ispc_cpp_interop.h" + +#ifndef __ISPC_STRUCT_Data1D__ +#define __ISPC_STRUCT_Data1D__ + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct Data1D + { + const vkl_uint8 *addr; + vkl_uint64 byteStride; + vkl_uint64 numItems; +#ifdef __cplusplus + VKLDataType dataType; +#else + vkl_uint32 dataType; +#endif + bool compact; + }; + +#ifdef __cplusplus +} // namespace ispc +#endif // __cplusplus + +#endif diff --git a/openvkl/common/StructShared.h b/openvkl/common/StructShared.h new file mode 100644 index 00000000..859abbe5 --- /dev/null +++ b/openvkl/common/StructShared.h @@ -0,0 +1,177 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include +#include + +namespace ispc { + + // Shared structure members may use ispc specific types + using uint8 = uint8_t; + using int32 = int32_t; + using uint32 = uint32_t; + using int64 = int64_t; +} // namespace ispc + +namespace openvkl { + + /* + Usage: + derive from AddStructShared + + We use multiple inheritance with a virtual base class, thus only a single + instance of structSharedPtr is present, which will be initialized first. + StructSharedGet adds getSh returning the correctly typed pointer. It is + derived from first to handle the memory allocation with the maximum size of + the final StructShared. StructSharedGet does not have any data to ensure + final classes can be C-style casted to ManagedObject* (this pointer stays + the same). + */ + + inline void *BufferSharedCreate(size_t size) + { + return malloc(size); + } + + inline void BufferSharedDelete(void *ptr) + { + free(ptr); + } + + template + T *BufferSharedCreate(size_t count, const T *data) + { + T *ptr = (T *)BufferSharedCreate(sizeof(T) * count); + if (data) + memcpy(ptr, data, sizeof(T) * count); + return ptr; + } + + template + inline T *StructSharedCreate() + { + return new (BufferSharedCreate(sizeof(T))) T; + } + + struct StructSharedPtr + { + ~StructSharedPtr(); + + template + friend struct StructSharedGet; + + template + friend struct AddStructShared; + + private: + void *structSharedPtr{nullptr}; + }; + + template + struct StructSharedGet + { + StructSharedGet(void **); + T *getSh() const; + }; + + // Traits ///////////////////////////////////////////////////// + + template + struct make_void + { + using type = void; + }; + + template + using void_t = typename make_void::type; + + template + struct get_base_structshared_or + { + using type = S; + }; + + template + struct get_base_structshared_or> + { + using type = typename T::StructShared_t; + }; + + template + struct get_super_or + { + using type = S; + }; + + template + struct get_super_or> + { + using type = decltype(S::super); + }; + + // AddStructShared //////////////////////////////////////////// + + template + struct AddStructShared + : public StructSharedGet>, + public Base, + public virtual StructSharedPtr + { + using StructShared_t = Struct; + using StructSharedGet>::getSh; + static_assert( + std::is_same::type, + typename get_super_or::type>::value, + "StructShared_t needs to have 'super' member of type " + "Base::StructShared_t"); + template + AddStructShared(Args &&...args) + : StructSharedGet>( + &structSharedPtr), + Base(std::forward(args)...) + { + } + }; + + // Inlined definitions //////////////////////////////////////// + + inline StructSharedPtr::~StructSharedPtr() + { + BufferSharedDelete(structSharedPtr); + } + + template + StructSharedGet::StructSharedGet(void **ptr) + { + if (!*ptr) + *ptr = StructSharedCreate(); + } + + template + T *StructSharedGet::getSh() const + { + return static_cast(static_cast(this)->structSharedPtr); + } + + // Testing //////////////////////////////////////////////////// + namespace test { + // clang-format off +struct A {}; +struct B { char b; }; +struct D1 { B super; }; +struct D2 { D1 super; char c; }; + +struct ShouldPass1 : public AddStructShared {}; +struct ShouldPass2 : public AddStructShared {}; +struct ShouldPass3 : public AddStructShared {}; + +//struct ShouldFail1 : public AddStructShared {}; +//struct ShouldFail2 : public AddStructShared {}; +//struct ShouldFail3 : public AddStructShared {}; + // clang-format on + } // namespace test + +} // namespace openvkl diff --git a/openvkl/devices/cpu/iterator/DefaultIterator.cpp b/openvkl/devices/cpu/iterator/DefaultIterator.cpp index 0072d584..1e7a6ac1 100644 --- a/openvkl/devices/cpu/iterator/DefaultIterator.cpp +++ b/openvkl/devices/cpu/iterator/DefaultIterator.cpp @@ -27,7 +27,7 @@ namespace openvkl { CALL_ISPC(DefaultIntervalIterator_Initialize, static_cast(valid), ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange, diff --git a/openvkl/devices/cpu/iterator/DefaultIterator.h b/openvkl/devices/cpu/iterator/DefaultIterator.h index 4944eade..8abb5469 100644 --- a/openvkl/devices/cpu/iterator/DefaultIterator.h +++ b/openvkl/devices/cpu/iterator/DefaultIterator.h @@ -88,7 +88,7 @@ namespace openvkl { static_cast(valid), ispcStorage, intervalIterator.getIspcStorage(), - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)×); diff --git a/openvkl/devices/cpu/iterator/DefaultIterator.ih b/openvkl/devices/cpu/iterator/DefaultIterator.ih index 9a8ef62d..274f084d 100644 --- a/openvkl/devices/cpu/iterator/DefaultIterator.ih +++ b/openvkl/devices/cpu/iterator/DefaultIterator.ih @@ -4,7 +4,7 @@ #pragma once #include "Iterator.ih" -#include "IteratorContext.ih" +#include "IteratorContextShared.h" #include "rkcommon/math/box.ih" #include "rkcommon/math/vec.ih" diff --git a/openvkl/devices/cpu/iterator/DefaultIterator.ispc b/openvkl/devices/cpu/iterator/DefaultIterator.ispc index 3062f2bc..49dad3b8 100644 --- a/openvkl/devices/cpu/iterator/DefaultIterator.ispc +++ b/openvkl/devices/cpu/iterator/DefaultIterator.ispc @@ -5,6 +5,7 @@ #include "../math/box_utility.ih" #include "../volume/Volume.ih" #include "DefaultIterator.ih" +#include "common/ValueRanges.ih" // Ignore warning about exporting uniform-pointer-to-varying, as this is in // fact legal. @@ -127,7 +128,7 @@ export void EXPORT_UNIQUE(DefaultIntervalIterator_iterateInterval, imask, _self, _interval, - self->super.context->valueRanges, + self->super.context->super.valueRanges, false, _result); } @@ -203,7 +204,7 @@ export void EXPORT_UNIQUE(DefaultHitIterator_iterateHit, intervalIterator->iterate((const int *uniform) & needInterval, self->intervalIteratorState, &self->currentInterval, - self->context->super.valueRanges, + self->context->super.super.valueRanges, elementaryCellIteration, (int *uniform) & haveInterval); @@ -230,11 +231,11 @@ export void EXPORT_UNIQUE(DefaultHitIterator_iterateHit, varying Hit *uniform hit = (varying Hit * uniform) _hit; hit->t = inf; bool foundHit = - intersectSurfacesBisection(self->context->super.sampler, + intersectSurfacesBisection(self->context->super.super.sampler, self->origin, self->direction, self->currentInterval.tRange, - self->context->super.attributeIndex, + self->context->super.super.attributeIndex, self->time, self->currentInterval.nominalDeltaT, self->context->numValues, diff --git a/openvkl/devices/cpu/iterator/GridAcceleratorIterator.cpp b/openvkl/devices/cpu/iterator/GridAcceleratorIterator.cpp index 552b46d4..62680523 100644 --- a/openvkl/devices/cpu/iterator/GridAcceleratorIterator.cpp +++ b/openvkl/devices/cpu/iterator/GridAcceleratorIterator.cpp @@ -25,7 +25,7 @@ namespace openvkl { CALL_ISPC(GridAcceleratorIteratorV_Initialize, static_cast(valid), ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange, @@ -52,7 +52,7 @@ namespace openvkl { { CALL_ISPC(GridAcceleratorIteratorU_Initialize, ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange, @@ -87,7 +87,7 @@ namespace openvkl { CALL_ISPC(GridAcceleratorIteratorV_Initialize, static_cast(valid), ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange, @@ -118,7 +118,7 @@ namespace openvkl { { CALL_ISPC(GridAcceleratorIteratorU_Initialize, ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange, diff --git a/openvkl/devices/cpu/iterator/GridAcceleratorIterator.ispc b/openvkl/devices/cpu/iterator/GridAcceleratorIterator.ispc index de4c742b..794ac79d 100644 --- a/openvkl/devices/cpu/iterator/GridAcceleratorIterator.ispc +++ b/openvkl/devices/cpu/iterator/GridAcceleratorIterator.ispc @@ -6,7 +6,7 @@ #include "../common/ValueRanges.ih" #include "../volume/GridAccelerator.ih" #include "../volume/SharedStructuredVolume.ih" -#include "../iterator/IteratorContext.ih" +#include "../iterator/IteratorContextShared.h" #include "GridAcceleratorIterator.ih" export void EXPORT_UNIQUE(GridAcceleratorIterator_declare_types_dummy, @@ -52,7 +52,8 @@ export uniform int EXPORT_UNIQUE(GridAcceleratorIteratorV_sizeOf) self->time = *((univary float *uniform)_time); \ \ const SharedStructuredVolume *uniform volume = \ - (const SharedStructuredVolume *uniform)self->context->sampler->volume; \ + (const SharedStructuredVolume *uniform) \ + self->context->super.sampler->volume; \ \ self->boundingBoxTRange = intersectBox( \ self->origin, self->direction, volume->boundingBox, self->tRange); \ @@ -118,7 +119,8 @@ export void EXPORT_UNIQUE(GridAcceleratorIteratorV_Initialize, } \ \ const SharedStructuredVolume *uniform volume = \ - (const SharedStructuredVolume *uniform)self->context->sampler->volume; \ + (const SharedStructuredVolume *uniform) \ + self->context->super.sampler->volume; \ \ while (GridAccelerator_nextCell(volume->accelerator, \ self, \ @@ -127,12 +129,13 @@ export void EXPORT_UNIQUE(GridAcceleratorIteratorV_Initialize, univary box1f cellValueRange; \ GridAccelerator_getCellValueRange(volume->accelerator, \ self->intervalState.currentCellIndex, \ - self->context->attributeIndex, \ + self->context->super.attributeIndex, \ cellValueRange); \ \ univary bool returnInterval = false; \ \ - if (valueRangesOverlap(self->context->valueRanges, cellValueRange)) { \ + if (valueRangesOverlap(self->context->super.valueRanges, \ + cellValueRange)) { \ returnInterval = true; \ } \ \ @@ -177,7 +180,7 @@ export void EXPORT_UNIQUE(GridAcceleratorIteratorV_iterateInterval, (univary GridAcceleratorIterator * uniform) _self; \ \ const HitIteratorContext *uniform hitContext = \ - (const HitIteratorContext *uniform) self->context; \ + (const HitIteratorContext *uniform)self->context; \ \ univary Hit *uniform hit = (univary Hit * uniform) _hit; \ \ @@ -194,7 +197,8 @@ export void EXPORT_UNIQUE(GridAcceleratorIteratorV_iterateInterval, } \ \ const SharedStructuredVolume *uniform volume = \ - (const SharedStructuredVolume *uniform)self->context->sampler->volume; \ + (const SharedStructuredVolume *uniform) \ + self->context->super.sampler->volume; \ \ /* first iteration */ \ __vkl_concat(cif_, univary)(self->hitState.currentCellIndex.x == -1) \ @@ -212,19 +216,19 @@ export void EXPORT_UNIQUE(GridAcceleratorIteratorV_iterateInterval, univary box1f cellValueRange; \ GridAccelerator_getCellValueRange(volume->accelerator, \ self->hitState.currentCellIndex, \ - self->context->attributeIndex, \ + self->context->super.attributeIndex, \ cellValueRange); \ \ univary bool cellValueRangeOverlap = \ - valueRangesOverlap(self->context->valueRanges, cellValueRange); \ + valueRangesOverlap(self->context->super.valueRanges, cellValueRange); \ \ if (cellValueRangeOverlap) { \ univary bool foundHit = \ - intersectSurfacesNewton(self->context->sampler, \ + intersectSurfacesNewton(self->context->super.sampler, \ self->origin, \ self->direction, \ self->hitState.currentCellTRange, \ - self->context->attributeIndex, \ + self->context->super.attributeIndex, \ self->time, \ 0.5f * step, \ hitContext->numValues, \ diff --git a/openvkl/devices/cpu/iterator/Iterator.ih b/openvkl/devices/cpu/iterator/Iterator.ih index 7eea18ea..19b52b66 100644 --- a/openvkl/devices/cpu/iterator/Iterator.ih +++ b/openvkl/devices/cpu/iterator/Iterator.ih @@ -6,24 +6,25 @@ #include "../common/Hit.ih" #include "../common/Interval.ih" #include "../sampler/Sampler.ih" +#include "openvkl/iterator.isph" #include "rkcommon/math/box.ih" #include "rkcommon/math/math.ih" -#include "openvkl/iterator.isph" /* * Intersect isosurfaces along the given ray using Newton-Raphson iteration. */ #define template_intersectSurfacesNewton(univary) \ - inline univary bool intersectSurfacesNewton(const Sampler *uniform sampler, \ - const univary vec3f &origin, \ - const univary vec3f &direction, \ - const univary box1f &tRange, \ - const uniform uint32 attributeIndex, \ - const univary float &time, \ - const uniform float step, \ - const uniform int numValues, \ - const float *uniform values, \ - univary Hit &hit) \ + inline univary bool intersectSurfacesNewton( \ + const SamplerShared *uniform sampler, \ + const univary vec3f &origin, \ + const univary vec3f &direction, \ + const univary box1f &tRange, \ + const uniform uint32 attributeIndex, \ + const univary float &time, \ + const uniform float step, \ + const uniform int numValues, \ + const float *uniform values, \ + univary Hit &hit) \ { \ /* our bracketing sample t-values will always be in multiples of `step`, \ to avoid artifacts / differences in hits between neighboring rays, or when \ @@ -34,23 +35,17 @@ const univary int minTIndex = floor(tRange.lower / step); \ const univary int maxTIndex = ceil(tRange.upper / step); \ \ - univary float t0 = minTIndex * step; \ - univary float sample0 = \ - sampler->computeSample_##univary(sampler, \ - origin + t0 * direction, \ - attributeIndex, \ - time); \ + univary float t0 = minTIndex * step; \ + univary float sample0 = sampler->computeSample_##univary( \ + sampler, origin + t0 * direction, attributeIndex, time); \ \ univary float t; \ \ for (univary int i = minTIndex; i < maxTIndex; i++) { \ t = (i + 1) * step; \ \ - const univary float sample = \ - sampler->computeSample_##univary(sampler, \ - origin + t * direction, \ - attributeIndex, \ - time); \ + const univary float sample = sampler->computeSample_##univary( \ + sampler, origin + t * direction, attributeIndex, time); \ \ univary float tHit = inf; \ univary float epsilon = inf; \ @@ -96,13 +91,13 @@ template_intersectSurfacesNewton(varying); * Intersect isosurfaces along the given ray using bisection method. */ -static const uniform float BISECT_T_TOL_ABS = 1e-6f; -static const uniform float BISECT_T_TOL_FACTOR = 0.01f; -static const uniform float BISECT_VALUE_TOL = 1e-6f; +static const uniform float BISECT_T_TOL_ABS = 1e-6f; +static const uniform float BISECT_T_TOL_FACTOR = 0.01f; +static const uniform float BISECT_VALUE_TOL = 1e-6f; static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; #define template_intersectSurfacesBisection(univary) \ - inline univary float bisect(const Sampler *uniform sampler, \ + inline univary float bisect(const SamplerShared *uniform sampler, \ const univary vec3f &origin, \ const univary vec3f &direction, \ const uniform uint32 attributeIndex, \ @@ -129,16 +124,13 @@ static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; break; \ } \ \ - univary float sampleMid = \ - sampler->computeSample_##univary(sampler, \ - origin + tMid * direction, \ - attributeIndex, \ - time); \ + univary float sampleMid = sampler->computeSample_##univary( \ + sampler, origin + tMid * direction, attributeIndex, time); \ \ /* sampling at boundaries between unstructured cells can rarely lead to \ NaN values (indicating outside of cell) due to numerical issues; in this \ - case we know we have already bracketed an isovalue, so return the nearest \ - result */ \ + case we know we have already bracketed an isovalue, so return the \ + nearest result */ \ if (isnan(sampleMid)) { \ if (abs(isovalue - sample0) < abs(isovalue - sample)) { \ return t0; \ @@ -170,7 +162,7 @@ static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; } \ \ inline univary bool intersectSurfacesBisection( \ - const Sampler *uniform sampler, \ + const SamplerShared *uniform sampler, \ const univary vec3f &origin, \ const univary vec3f &direction, \ const univary box1f &tRange, \ @@ -183,23 +175,17 @@ static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; { \ assert(tRange.lower < tRange.upper); \ \ - univary float t0 = tRange.lower; \ - univary float sample0 = \ - sampler->computeSample_##univary(sampler, \ - origin + t0 * direction, \ - attributeIndex, \ - time); \ + univary float t0 = tRange.lower; \ + univary float sample0 = sampler->computeSample_##univary( \ + sampler, origin + t0 * direction, attributeIndex, time); \ \ { \ univary int iters = 0; \ - while (iters < BISECT_MAX_BACKTRACK_ITERS && \ - isnan(sample0) && t0 < tRange.upper) { \ + while (iters < BISECT_MAX_BACKTRACK_ITERS && isnan(sample0) && \ + t0 < tRange.upper) { \ t0 += max(1e-5f, 1e-5f * step); \ - sample0 = \ - sampler->computeSample_##univary(sampler, \ - origin + t0 * direction, \ - attributeIndex, \ - time); \ + sample0 = sampler->computeSample_##univary( \ + sampler, origin + t0 * direction, attributeIndex, time); \ iters++; \ } \ } \ @@ -207,25 +193,19 @@ static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; univary float t; \ \ while (t0 < tRange.upper) { \ - const univary float h = min(step, tRange.upper-t0); \ - t = t0 + h; \ - univary float sample = \ - sampler->computeSample_##univary(sampler, \ - origin + t * direction, \ - attributeIndex, \ - time); \ + const univary float h = min(step, tRange.upper - t0); \ + t = t0 + h; \ + univary float sample = sampler->computeSample_##univary( \ + sampler, origin + t * direction, attributeIndex, time); \ univary float ts = t; \ \ { \ univary int iters = 0; \ - while (iters < BISECT_MAX_BACKTRACK_ITERS && \ - isnan(sample) && ts > t0) { \ + while (iters < BISECT_MAX_BACKTRACK_ITERS && isnan(sample) && \ + ts > t0) { \ ts -= max(1e-5f, 1e-5f * step); \ - sample = \ - sampler->computeSample_##univary(sampler, \ - origin + ts * direction, \ - attributeIndex, \ - time); \ + sample = sampler->computeSample_##univary( \ + sampler, origin + ts * direction, attributeIndex, time); \ iters++; \ } \ } \ @@ -238,29 +218,28 @@ static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; /* hit at bracket entrance */ \ if (abs(sample0 - values[i]) < BISECT_VALUE_TOL) { \ if (t0 < tHit && t0 <= tRange.upper) { \ - tHit = t0; \ - value = values[i]; \ - epsilon = 0.125f * step; \ + tHit = t0; \ + value = values[i]; \ + epsilon = 0.125f * step; \ } \ - } \ - /* hit inside bracket */ \ + } /* hit inside bracket */ \ else if (!isnan(sample0 + sample) && \ (values[i] - sample0) * (values[i] - sample) < 0.f) { \ /* we have bracketed a crossing; bisect */ \ univary float error; \ - univary float tIso = bisect(sampler, \ - origin, \ - direction, \ - attributeIndex, \ - time, \ - t0, \ - sample0, \ - ts, \ - sample, \ - values[i], \ - min(BISECT_T_TOL_ABS, \ - BISECT_T_TOL_FACTOR *h), \ - error); \ + univary float tIso = \ + bisect(sampler, \ + origin, \ + direction, \ + attributeIndex, \ + time, \ + t0, \ + sample0, \ + ts, \ + sample, \ + values[i], \ + min(BISECT_T_TOL_ABS, BISECT_T_TOL_FACTOR * h), \ + error); \ \ if (tIso < tHit && tIso <= tRange.upper) { \ tHit = tIso; \ @@ -269,12 +248,13 @@ static const uniform float BISECT_MAX_BACKTRACK_ITERS = 10; } \ } \ \ - /* check hit at tRange upper limit, after any bisection has occurred */ \ + /* check hit at tRange upper limit, after any bisection has occurred \ + */ \ if (t == tRange.upper && abs(sample - values[i]) < BISECT_VALUE_TOL) { \ if (ts < tHit && ts <= tRange.upper) { \ - tHit = ts; \ - value = values[i]; \ - epsilon = 0.125f * step; \ + tHit = ts; \ + value = values[i]; \ + epsilon = 0.125f * step; \ } \ } \ } \ diff --git a/openvkl/devices/cpu/iterator/IteratorContext.cpp b/openvkl/devices/cpu/iterator/IteratorContext.cpp index 4e894163..a0d167d7 100644 --- a/openvkl/devices/cpu/iterator/IteratorContext.cpp +++ b/openvkl/devices/cpu/iterator/IteratorContext.cpp @@ -132,9 +132,9 @@ namespace openvkl { template IntervalIteratorContext::~IntervalIteratorContext() { - if (this->ispcEquivalent) { - CALL_ISPC(IntervalIteratorContext_Destructor, this->ispcEquivalent); - this->ispcEquivalent = nullptr; + if (this->SharedStructInitialized) { + CALL_ISPC(IntervalIteratorContext_Destructor, this->getSh()); + this->SharedStructInitialized = false; } } @@ -172,17 +172,20 @@ namespace openvkl { mapToMaxIteratorDepth(*this, intervalResolutionHint); const bool elementaryCellIteration = (intervalResolutionHint == 1.f); - if (this->ispcEquivalent) { - CALL_ISPC(IntervalIteratorContext_Destructor, this->ispcEquivalent); + if (this->SharedStructInitialized) { + CALL_ISPC(IntervalIteratorContext_Destructor, this->getSh()); } - this->ispcEquivalent = CALL_ISPC(IntervalIteratorContext_Constructor, - this->getSampler().getISPCEquivalent(), - this->attributeIndex, - valueRanges.size(), - (const ispc::box1f *)valueRanges.data(), - maxIteratorDepth, - elementaryCellIteration); + CALL_ISPC(IntervalIteratorContext_Constructor, + this->getSampler().getSh(), + this->attributeIndex, + valueRanges.size(), + (const ispc::box1f *)valueRanges.data(), + maxIteratorDepth, + elementaryCellIteration, + this->getSh()); + + this->SharedStructInitialized = true; } template struct IntervalIteratorContext; @@ -194,9 +197,9 @@ namespace openvkl { template HitIteratorContext::~HitIteratorContext() { - if (this->ispcEquivalent) { - CALL_ISPC(HitIteratorContext_Destructor, this->ispcEquivalent); - this->ispcEquivalent = nullptr; + if (this->SharedStructInitialized) { + CALL_ISPC(HitIteratorContext_Destructor, this->getSh()); + this->SharedStructInitialized = false; } } @@ -234,16 +237,19 @@ namespace openvkl { maxIteratorDepth = mapToMaxIteratorDepth(*this, 0.5f); } - if (this->ispcEquivalent) { - CALL_ISPC(HitIteratorContext_Destructor, this->ispcEquivalent); + if (this->SharedStructInitialized) { + CALL_ISPC(HitIteratorContext_Destructor, this->getSh()); } - this->ispcEquivalent = CALL_ISPC(HitIteratorContext_Constructor, - this->getSampler().getISPCEquivalent(), - this->attributeIndex, - values.size(), - (const float *)values.data(), - maxIteratorDepth); + CALL_ISPC(HitIteratorContext_Constructor, + this->getSampler().getSh(), + this->attributeIndex, + values.size(), + (const float *)values.data(), + maxIteratorDepth, + this->getSh()); + + this->SharedStructInitialized = true; } template struct HitIteratorContext; diff --git a/openvkl/devices/cpu/iterator/IteratorContext.h b/openvkl/devices/cpu/iterator/IteratorContext.h index fe782175..e56f492d 100644 --- a/openvkl/devices/cpu/iterator/IteratorContext.h +++ b/openvkl/devices/cpu/iterator/IteratorContext.h @@ -4,6 +4,8 @@ #pragma once #include "../common/ManagedObject.h" +#include "openvkl/common/StructShared.h" +#include "IteratorContextShared.h" using namespace rkcommon::math; @@ -18,7 +20,8 @@ namespace openvkl { /////////////////////////////////////////////////////////////////////////// template - struct IteratorContext : public ManagedObject + struct IteratorContext + : public AddStructShared { IteratorContext(const Sampler &sampler); @@ -26,15 +29,12 @@ namespace openvkl { virtual void commit() = 0; - void *getISPCEquivalent() const; - const Sampler &getSampler() const; protected: Ref> sampler; int attributeIndex = 0; - - void *ispcEquivalent{nullptr}; + bool SharedStructInitialized = false; }; // Inlined definitions //////////////////////////////////////////////////// @@ -48,13 +48,6 @@ namespace openvkl { template inline IteratorContext::~IteratorContext() { - assert(!ispcEquivalent); // Detect leaks in derived classes if possible. - } - - template - inline void *IteratorContext::getISPCEquivalent() const - { - return ispcEquivalent; } template @@ -68,13 +61,15 @@ namespace openvkl { /////////////////////////////////////////////////////////////////////////// template - struct IntervalIteratorContext : public IteratorContext + struct IntervalIteratorContext + : public AddStructShared, + ispc::IntervalIteratorContext> { IntervalIteratorContext(const Sampler &sampler) - : IteratorContext(sampler) + : AddStructShared, ispc::IntervalIteratorContext>( + sampler) { } - virtual ~IntervalIteratorContext(); void commit() override; @@ -88,10 +83,13 @@ namespace openvkl { // iteration is often implemented using interval iteration, and we would // like to use the same context for that purpose. template - struct HitIteratorContext : public IntervalIteratorContext + struct HitIteratorContext + : public AddStructShared, + ispc::HitIteratorContext> { HitIteratorContext(const Sampler &sampler) - : IntervalIteratorContext(sampler) + : AddStructShared, + ispc::HitIteratorContext>(sampler) { } diff --git a/openvkl/devices/cpu/iterator/IteratorContext.ih b/openvkl/devices/cpu/iterator/IteratorContext.ih deleted file mode 100644 index 0cfb470c..00000000 --- a/openvkl/devices/cpu/iterator/IteratorContext.ih +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "../common/ValueRanges.ih" - -struct Sampler; - -struct IntervalIteratorContext -{ - const Sampler *uniform sampler; - - uniform uint32 attributeIndex; - - uniform ValueRanges valueRanges; - - uniform uint32 maxIteratorDepth; - uniform bool elementaryCellIteration; -}; - -// hit iterator contexts inherit from interval contexts; this is because hit -// iteration is often implemented using interval iteration, and we would like to -// use the same context for that purpose. -struct HitIteratorContext -{ - uniform IntervalIteratorContext super; - - uniform int numValues; - float *uniform values; -}; diff --git a/openvkl/devices/cpu/iterator/IteratorContext.ispc b/openvkl/devices/cpu/iterator/IteratorContext.ispc index 6d35f3d8..e905b7af 100644 --- a/openvkl/devices/cpu/iterator/IteratorContext.ispc +++ b/openvkl/devices/cpu/iterator/IteratorContext.ispc @@ -2,32 +2,35 @@ // SPDX-License-Identifier: Apache-2.0 #include "../common/export_util.h" -#include "IteratorContext.ih" + +#include "../common/ValueRanges.ih" +#define __ISPC_STRUCT_box1f__ +#define __ISPC_STRUCT_ValueRanges__ +#include "IteratorContextShared.h" /////////////////////////////////////////////////////////////////////////////// // Interval iterator context ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -export void *uniform EXPORT_UNIQUE(IntervalIteratorContext_Constructor, - void *uniform sampler, - const uniform uint32 attributeIndex, - const uniform int numValueRanges, - const box1f *uniform valueRanges, - const uniform uint32 maxIteratorDepth, - const uniform bool elementaryCellIteration) +export void EXPORT_UNIQUE(IntervalIteratorContext_Constructor, + void *uniform sampler, + const uniform uint32 attributeIndex, + const uniform int numValueRanges, + const box1f *uniform valueRanges, + const uniform uint32 maxIteratorDepth, + const uniform bool elementaryCellIteration, + void *uniform _self) { uniform IntervalIteratorContext *uniform self = - uniform new uniform IntervalIteratorContext; - - self->sampler = (const Sampler *uniform)sampler; - self->attributeIndex = attributeIndex; + (uniform IntervalIteratorContext * uniform) _self; - ValueRanges_Constructor(self->valueRanges, numValueRanges, valueRanges); + self->super.sampler = (const SamplerShared *uniform)sampler; + self->super.attributeIndex = attributeIndex; - self->maxIteratorDepth = maxIteratorDepth; - self->elementaryCellIteration = elementaryCellIteration; + ValueRanges_Constructor(self->super.valueRanges, numValueRanges, valueRanges); - return self; + self->super.maxIteratorDepth = maxIteratorDepth; + self->super.elementaryCellIteration = elementaryCellIteration; } export void EXPORT_UNIQUE(IntervalIteratorContext_Destructor, @@ -36,24 +39,23 @@ export void EXPORT_UNIQUE(IntervalIteratorContext_Destructor, uniform IntervalIteratorContext *uniform self = (uniform IntervalIteratorContext * uniform) _self; - ValueRanges_Destructor(self->valueRanges); - - delete self; + ValueRanges_Destructor(self->super.valueRanges); } /////////////////////////////////////////////////////////////////////////////// // Hit iterator context /////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -export void *uniform EXPORT_UNIQUE(HitIteratorContext_Constructor, - void *uniform sampler, - const uniform uint32 attributeIndex, - const uniform int numValues, - const float *uniform values, - const uniform uint32 maxIteratorDepth) +export void EXPORT_UNIQUE(HitIteratorContext_Constructor, + void *uniform sampler, + const uniform uint32 attributeIndex, + const uniform int numValues, + const float *uniform values, + const uniform uint32 maxIteratorDepth, + void *uniform _self) { uniform HitIteratorContext *uniform self = - uniform new uniform HitIteratorContext; + (uniform HitIteratorContext * uniform) _self; self->numValues = numValues; self->values = uniform new uniform float[numValues]; @@ -63,17 +65,15 @@ export void *uniform EXPORT_UNIQUE(HitIteratorContext_Constructor, } // superclass parameters - self->super.sampler = (const Sampler *uniform)sampler; - self->super.attributeIndex = attributeIndex; + self->super.super.sampler = (const SamplerShared *uniform)sampler; + self->super.super.attributeIndex = attributeIndex; - ValueRanges_Constructor(self->super.valueRanges, numValues, values); + ValueRanges_Constructor(self->super.super.valueRanges, numValues, values); - self->super.maxIteratorDepth = maxIteratorDepth; + self->super.super.maxIteratorDepth = maxIteratorDepth; // always attempt to use elementary cell iteration for hit iteration - self->super.elementaryCellIteration = true; - - return self; + self->super.super.elementaryCellIteration = true; } export void EXPORT_UNIQUE(HitIteratorContext_Destructor, void *uniform _self) @@ -83,7 +83,5 @@ export void EXPORT_UNIQUE(HitIteratorContext_Destructor, void *uniform _self) delete[] self->values; - ValueRanges_Destructor(self->super.valueRanges); - - delete self; + ValueRanges_Destructor(self->super.super.valueRanges); } diff --git a/openvkl/devices/cpu/iterator/IteratorContextShared.h b/openvkl/devices/cpu/iterator/IteratorContextShared.h new file mode 100644 index 00000000..0191f99b --- /dev/null +++ b/openvkl/devices/cpu/iterator/IteratorContextShared.h @@ -0,0 +1,80 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "openvkl/ispc_cpp_interop.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct SamplerShared; + +#ifdef __cplusplus + +#ifndef __ISPC_STRUCT_box1f__ +#define __ISPC_STRUCT_box1f__ + struct box1f + { + float lower; + float upper; + }; +#endif + +#ifndef __ISPC_STRUCT_ValueRanges__ +#define __ISPC_STRUCT_ValueRanges__ + struct ValueRanges + { + int numRanges; + box1f *ranges; + box1f rangesMinMax; + }; +#endif + +#else +#include "../devices/cpu/common/ValueRanges.ih" +#endif + +#ifndef __ISPC_STRUCT_IteratorContext__ +#define __ISPC_STRUCT_IteratorContext__ + struct IteratorContext + { + const SamplerShared *VKL_INTEROP_UNIFORM sampler; + + VKL_INTEROP_UNIFORM uint32 attributeIndex; + + VKL_INTEROP_UNIFORM ValueRanges valueRanges; + + VKL_INTEROP_UNIFORM uint32 maxIteratorDepth; + VKL_INTEROP_UNIFORM bool elementaryCellIteration; + }; +#endif + +#ifndef __ISPC_STRUCT_IntervalIteratorContext__ +#define __ISPC_STRUCT_IntervalIteratorContext__ + struct IntervalIteratorContext + { + VKL_INTEROP_UNIFORM IteratorContext super; + }; +#endif + +#ifndef __ISPC_STRUCT_HitIteratorContext__ +#define __ISPC_STRUCT_HitIteratorContext__ + + // hit iterator contexts inherit from interval contexts; this is because hit + // iteration is often implemented using interval iteration, and we would like + // to use the same context for that purpose. + struct HitIteratorContext + { + VKL_INTEROP_UNIFORM IntervalIteratorContext super; + + VKL_INTEROP_UNIFORM int numValues; + float *VKL_INTEROP_UNIFORM values; + }; + +#endif + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/iterator/UnstructuredIterator.cpp b/openvkl/devices/cpu/iterator/UnstructuredIterator.cpp index c374b741..6b80938a 100644 --- a/openvkl/devices/cpu/iterator/UnstructuredIterator.cpp +++ b/openvkl/devices/cpu/iterator/UnstructuredIterator.cpp @@ -34,7 +34,7 @@ namespace openvkl { CALL_ISPC(UnstructuredIterator_Initialize, static_cast(valid), ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange, diff --git a/openvkl/devices/cpu/iterator/UnstructuredIterator.ih b/openvkl/devices/cpu/iterator/UnstructuredIterator.ih index 60769b5f..e9311635 100644 --- a/openvkl/devices/cpu/iterator/UnstructuredIterator.ih +++ b/openvkl/devices/cpu/iterator/UnstructuredIterator.ih @@ -4,7 +4,7 @@ #pragma once #include "Iterator.ih" -#include "IteratorContext.ih" +#include "IteratorContextShared.h" #include "DefaultIterator.ih" #include "../volume/UnstructuredSamplerBase.ih" #include "../volume/UnstructuredVolume.ih" diff --git a/openvkl/devices/cpu/iterator/UnstructuredIterator.ispc b/openvkl/devices/cpu/iterator/UnstructuredIterator.ispc index f628f6b6..efc1e799 100644 --- a/openvkl/devices/cpu/iterator/UnstructuredIterator.ispc +++ b/openvkl/devices/cpu/iterator/UnstructuredIterator.ispc @@ -53,13 +53,14 @@ export void EXPORT_UNIQUE(UnstructuredIterator_Initialize, elementaryCellIterationSupported; self->sampler = - (UnstructuredSamplerBase * uniform)(self->super.context->sampler); + (UnstructuredSamplerBase * uniform)(self->super.context->super.sampler); self->origin = *((varying vec3f * uniform) _origin); self->direction = *((varying vec3f * uniform) _direction); self->tRange = *((varying box1f * uniform) _tRange); const VKLUnstructuredBase *uniform volume = - (const VKLUnstructuredBase *uniform)self->super.context->sampler->volume; + (const VKLUnstructuredBase *uniform) + self->super.context->super.sampler->volume; self->traversalState.node = (uint64)(volume->bvhRoot); self->traversalState.bitstack = 0; @@ -131,13 +132,15 @@ static box1f evalNodeStacklessV(const varying UnstructuredIterator *uniform UnstructuredTraversalState &hitState) { const UnstructuredSamplerBase *uniform sampler = - (const UnstructuredSamplerBase *uniform)iterator->super.context->sampler; + (const UnstructuredSamplerBase *uniform) + iterator->super.context->super.sampler; while (1) { uniform bool isInner = (node->nominalLength.x >= 0); - if (isInner && (elementaryCellIteration || - node->level < iterator->super.context->maxIteratorDepth)) { + if (isInner && + (elementaryCellIteration || + node->level < iterator->super.context->super.maxIteratorDepth)) { uniform InnerNode *uniform inner = (uniform InnerNode * uniform) node; box1f intersectedTRange0; @@ -238,7 +241,7 @@ static box1f evalNodeStacklessV(const varying UnstructuredIterator *uniform // only supported for leaf node's with one cell const VKLUnstructuredVolume *uniform volume = (const VKLUnstructuredVolume *uniform) - iterator->super.context->sampler->volume; + iterator->super.context->super.sampler->volume; intersectLeaf_varying( iterator->origin, iterator->direction, @@ -399,8 +402,8 @@ export void EXPORT_UNIQUE(UnstructuredIterator_iterateInterval, imask, _self, _interval, - self->super.context->valueRanges, + self->super.context->super.valueRanges, self->super.elementaryCellIterationSupported && - self->super.context->elementaryCellIteration, + self->super.context->super.elementaryCellIteration, _result); } diff --git a/openvkl/devices/cpu/sampler/Sampler.cpp b/openvkl/devices/cpu/sampler/Sampler.cpp index 6e5b6878..fa53e697 100644 --- a/openvkl/devices/cpu/sampler/Sampler.cpp +++ b/openvkl/devices/cpu/sampler/Sampler.cpp @@ -10,7 +10,6 @@ namespace openvkl { template Sampler::~Sampler() { - assert(!ispcEquivalent); // Detect leaks in derived classes if possible. } template diff --git a/openvkl/devices/cpu/sampler/Sampler.h b/openvkl/devices/cpu/sampler/Sampler.h index 9e7bd091..4141edc9 100644 --- a/openvkl/devices/cpu/sampler/Sampler.h +++ b/openvkl/devices/cpu/sampler/Sampler.h @@ -10,6 +10,8 @@ #include "../observer/Observer.h" #include "openvkl/openvkl.h" #include "rkcommon/math/vec.h" +#include "openvkl/common/StructShared.h" +#include "SamplerShared.h" using namespace rkcommon; @@ -66,9 +68,9 @@ namespace openvkl { class Volume; template - struct Sampler : public ManagedObject + struct Sampler : public AddStructShared { - Sampler() = default; + Sampler() {} // not = default, due to ICC 19 compiler bug Sampler(Sampler &&) = delete; Sampler &operator=(Sampler &&) = delete; Sampler(const Sampler &) = delete; @@ -150,10 +152,6 @@ namespace openvkl { virtual const IteratorFactory &getHitIteratorFactory() const = 0; - void *getISPCEquivalent() const; - - protected: - void *ispcEquivalent{nullptr}; }; // Inlined definitions //////////////////////////////////////////////////// @@ -239,12 +237,6 @@ namespace openvkl { } } - template - void *Sampler::getISPCEquivalent() const - { - return ispcEquivalent; - } - /////////////////////////////////////////////////////////////////////////// // SamplerBase is the base class for all concrete sampler types. @@ -258,9 +250,14 @@ namespace openvkl { class IntervalIteratorFactory, template class HitIteratorFactory> - struct SamplerBase : public Sampler + struct SamplerBase + : public AddStructShared, ispc::SamplerBaseShared> { - explicit SamplerBase(VolumeT &volume) : volume(&volume) {} + explicit SamplerBase(VolumeT &volume) + : AddStructShared, ispc::SamplerBaseShared>(), + volume(&volume) + { + } VolumeT &getVolume() override { diff --git a/openvkl/devices/cpu/sampler/Sampler.ih b/openvkl/devices/cpu/sampler/Sampler.ih index b5325bff..815b06b7 100644 --- a/openvkl/devices/cpu/sampler/Sampler.ih +++ b/openvkl/devices/cpu/sampler/Sampler.ih @@ -8,42 +8,16 @@ #include "../volume/Volume.ih" #include "../common/export_util.h" -struct Sampler -{ - const Volume *uniform volume; - - // these functions do not yet support multi-attribute volumes. they are used - // in generic stream-wide sampling and gradient implementations, as well as in - // hit iterator surface intersection functions (which today only support the - // first attribute). - - uniform float (*uniform computeSample_uniform)( - const Sampler *uniform _self, - const uniform vec3f &objectCoordinates, - const uniform uint32 attributeIndex, - const uniform float &time); - - varying float (*uniform computeSample_varying)( - const Sampler *uniform _self, - const varying vec3f &objectCoordinates, - const uniform uint32 attributeIndex, - const varying float &time); - - varying vec3f (*uniform computeGradient_varying)( - const Sampler *uniform _self, const varying vec3f &objectCoordinates); - - // Samplers may choose to implement these filter modes. - VKLFilter filter; - VKLFilter gradientFilter; -}; +#include "SamplerShared.h" /* * Initialize the given sampler object. Use this from your derived samplers * to initialize the super member. */ -export Sampler *uniform EXPORT_UNIQUE(Sampler_create, - const void* uniform _volume); +export void EXPORT_UNIQUE(Sampler_create, + const void* uniform _volume, + void *uniform _sampler); export void EXPORT_UNIQUE(Sampler_destroy, void *uniform _sampler); diff --git a/openvkl/devices/cpu/sampler/Sampler.ispc b/openvkl/devices/cpu/sampler/Sampler.ispc index ed05ef83..a44b3ae5 100644 --- a/openvkl/devices/cpu/sampler/Sampler.ispc +++ b/openvkl/devices/cpu/sampler/Sampler.ispc @@ -3,13 +3,13 @@ #include "Sampler.ih" -export Sampler *uniform EXPORT_UNIQUE(Sampler_create, - const void* uniform _volume) +export void EXPORT_UNIQUE(Sampler_create, + const void* uniform _volume, + void* uniform _sampler) { - Sampler *uniform sampler = uniform new Sampler; - memset(sampler, 0, sizeof(uniform Sampler)); - sampler->volume = (const Volume *uniform) _volume; - return sampler; + SamplerShared *uniform sampler = (SamplerShared *uniform)_sampler; + memset(sampler, 0, sizeof(uniform SamplerShared)); + sampler->volume = (const VolumeShared *uniform) _volume; } export void EXPORT_UNIQUE(Sampler_setFilters, @@ -17,7 +17,7 @@ export void EXPORT_UNIQUE(Sampler_setFilters, uniform VKLFilter filter, uniform VKLFilter gradientFilter) { - Sampler *uniform sampler = (Sampler *uniform)_sampler; + SamplerShared *uniform sampler = (SamplerShared *uniform)_sampler; sampler->filter = filter; sampler->gradientFilter = gradientFilter; } @@ -25,7 +25,7 @@ export void EXPORT_UNIQUE(Sampler_setFilters, export void EXPORT_UNIQUE(Sampler_destroy, void *uniform _sampler) { - Sampler *uniform sampler = (Sampler *uniform)_sampler; + SamplerShared *uniform sampler = (SamplerShared *uniform)_sampler; delete sampler; } @@ -37,7 +37,7 @@ export void EXPORT_UNIQUE(Sampler_sample_N_export, const vec3f *uniform objectCoordinates, float *uniform samples) { - Sampler *uniform self = (Sampler * uniform) _self; + SamplerShared *uniform self = (SamplerShared * uniform) _self; varying float time = 0.f; @@ -53,7 +53,7 @@ export void EXPORT_UNIQUE(Sampler_gradient_N_export, const vec3f *uniform objectCoordinates, vec3f *uniform gradients) { - Sampler *uniform self = (Sampler * uniform) _self; + SamplerShared *uniform self = (SamplerShared * uniform) _self; foreach (i = 0 ... N) { varying vec3f oc = objectCoordinates[i]; diff --git a/openvkl/devices/cpu/sampler/SamplerShared.h b/openvkl/devices/cpu/sampler/SamplerShared.h new file mode 100644 index 00000000..6df605c4 --- /dev/null +++ b/openvkl/devices/cpu/sampler/SamplerShared.h @@ -0,0 +1,69 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "openvkl/VKLFilter.h" +#include "openvkl/ispc_cpp_interop.h" +#include "../volume/VolumeShared.h" + +#ifdef __cplusplus +namespace ispc { +#else +#include "rkcommon/math/vec.ih" +#endif // __cplusplus + +#ifndef __ISPC_STRUCT_SamplerShared__ +#define __ISPC_STRUCT_SamplerShared__ + + struct SamplerShared + { + const VolumeShared *VKL_INTEROP_UNIFORM volume; + + // these functions do not yet support multi-attribute volumes. they are used + // in generic stream-wide sampling and gradient implementations, as well as + // in hit iterator surface intersection functions (which today only support + // the first attribute). + +#ifdef __cplusplus + void *computeSample_uniform; + + void *computeSample_varying; + + void *computeGradient_varying; +#else + uniform float (*uniform computeSample_uniform)( + const SamplerShared *uniform _self, + const uniform vec3f &objectCoordinates, + const uniform uint32 attributeIndex, + const uniform float &time); + + varying float (*uniform computeSample_varying)( + const SamplerShared *uniform _self, + const varying vec3f &objectCoordinates, + const uniform uint32 attributeIndex, + const varying float &time); + + varying vec3f (*uniform computeGradient_varying)( + const SamplerShared *uniform _self, + const varying vec3f &objectCoordinates); +#endif + + // Samplers may choose to implement these filter modes. + VKLFilter filter; + VKLFilter gradientFilter; + }; + +#endif + +#ifndef __ISPC_STRUCT_SamplerBaseShared__ +#define __ISPC_STRUCT_SamplerBaseShared__ + struct SamplerBaseShared + { + SamplerShared super; + }; +#endif + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/GridAccelerator.ih b/openvkl/devices/cpu/volume/GridAccelerator.ih index 47aa4014..777012b4 100644 --- a/openvkl/devices/cpu/volume/GridAccelerator.ih +++ b/openvkl/devices/cpu/volume/GridAccelerator.ih @@ -7,17 +7,11 @@ #include "rkcommon/math/box.ih" #include "rkcommon/math/vec.ih" +#include "GridAcceleratorShared.h" + struct GridAcceleratorIterator; struct SharedStructuredVolume; -struct GridAccelerator -{ - uniform vec3i bricksPerDimension; - uniform size_t cellCount; - box1f *uniform cellValueRanges; - SharedStructuredVolume *uniform volume; -}; - GridAccelerator *uniform GridAccelerator_Constructor(void *uniform volume); void GridAccelerator_Destructor(GridAccelerator *uniform accelerator); @@ -42,4 +36,4 @@ void GridAccelerator_getCellValueRange(GridAccelerator *uniform accelerator, void GridAccelerator_getCellValueRange(GridAccelerator *uniform accelerator, const uniform vec3i &cellIndex, uniform uint32 attributeIndex, - uniform box1f &valueRange); \ No newline at end of file + uniform box1f &valueRange); diff --git a/openvkl/devices/cpu/volume/GridAcceleratorShared.h b/openvkl/devices/cpu/volume/GridAcceleratorShared.h new file mode 100644 index 00000000..ab781a77 --- /dev/null +++ b/openvkl/devices/cpu/volume/GridAcceleratorShared.h @@ -0,0 +1,22 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct SharedStructuredVolume; + + struct GridAccelerator + { + VKL_INTEROP_UNIFORM vec3i bricksPerDimension; + VKL_INTEROP_UNIFORM size_t cellCount; + box1f *VKL_INTEROP_UNIFORM cellValueRanges; + SharedStructuredVolume *VKL_INTEROP_UNIFORM volume; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/SharedStructuredVolume.ih b/openvkl/devices/cpu/volume/SharedStructuredVolume.ih index 4904afc7..958e4316 100644 --- a/openvkl/devices/cpu/volume/SharedStructuredVolume.ih +++ b/openvkl/devices/cpu/volume/SharedStructuredVolume.ih @@ -19,72 +19,7 @@ enum SharedStructuredVolumeGridType structured_spherical }; -typedef varying float (*uniform ComputeSampleInnerVaryingFunc)( - const SharedStructuredVolume *uniform self, - const varying vec3f &clampedLocalCoordinates, - const uniform VKLFilter filter, - const uniform uint32 attributeIndex, - const varying float ×); - -typedef uniform float (*uniform ComputeSampleInnerUniformFunc)( - const SharedStructuredVolume *uniform self, - const uniform vec3f &clampedLocalCoordinates, - const uniform VKLFilter filter, - const uniform uint32 attributeIndex, - const uniform float& times); - -typedef varying vec3f (*uniform ComputeGradientVaryingFunc)( - const SharedStructuredVolume *uniform _self, - const varying vec3f &objectCoordinates, - const uniform VKLFilter filter, - const uniform uint32 attributeIndex, - const varying float &time); - -typedef varying range1f (*uniform ComputeVoxelRangeFunc)( - const SharedStructuredVolume *uniform self, - const varying vec3i &localCoordinates, - const uniform uint32 attributeIndex); - -struct SharedStructuredVolume -{ - Volume super; - - uniform uint32 numAttributes; - Data1D *uniform attributesData; - - uniform uint32 temporallyStructuredNumTimesteps; - uniform Data1D temporallyUnstructuredIndices; - uniform Data1D temporallyUnstructuredTimes; - - uniform vec3i dimensions; - - uniform SharedStructuredVolumeGridType gridType; - uniform vec3f gridOrigin; - uniform vec3f gridSpacing; - - uniform box3f boundingBox; - - uniform vec3f localCoordinatesUpperBound; - - GridAccelerator *uniform accelerator; - - // offsets, in voxels, for one step in x,y,z direction; ONLY valid if - // bytesPerSlice < 2G. - uniform uint32 voxelOfs_dx, voxelOfs_dy, voxelOfs_dz; - - // This is only used by the legacy sample wrappers - remove once those - // have disappeared. - VKLFilter filter; - - // varying functions - ComputeVoxelRangeFunc *uniform computeVoxelRange; - - ComputeSampleInnerVaryingFunc *uniform computeSamplesInner_varying; - ComputeGradientVaryingFunc computeGradient_varying; - - // uniform functions - ComputeSampleInnerUniformFunc *uniform computeSamplesInner_uniform; -}; +#include "StructuredVolumeShared.h" /////////////////////////////////////////////////////////////////////////////// // Coordinate transformations for all supported structured volume types /////// diff --git a/openvkl/devices/cpu/volume/SharedStructuredVolume.ispc b/openvkl/devices/cpu/volume/SharedStructuredVolume.ispc index ad0e2832..442ff88d 100644 --- a/openvkl/devices/cpu/volume/SharedStructuredVolume.ispc +++ b/openvkl/devices/cpu/volume/SharedStructuredVolume.ispc @@ -1859,6 +1859,8 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_getBoundingBox, boundingBox = self->boundingBox; } +#include "StructuredSamplerShared.h" + export void EXPORT_UNIQUE(SharedStructuredVolume_sample_export, uniform const int *uniform imask, const void *uniform _sampler, @@ -1867,7 +1869,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sample_export, const void *uniform _time, void *uniform _samples) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -1889,7 +1893,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sample_uniform_export, const void *uniform _time, void *uniform _sample) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -1910,7 +1916,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sample_N_export, const float *uniform time, float *uniform samples) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -1931,7 +1939,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_gradient_export, const void *uniform _time, void *uniform _gradients) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -1956,7 +1966,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_gradient_N_export, const float *uniform time, vec3f *uniform gradients) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -1978,7 +1990,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sampleM_export, const void *uniform _time, float *uniform samples) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -2021,7 +2035,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sampleM_uniform_export, const void *uniform _time, float *uniform samples) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -2059,7 +2075,9 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sampleM_N_export, const float *uniform time, float *uniform samples) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; const SharedStructuredVolume *uniform self = (const SharedStructuredVolume *uniform)sampler->volume; @@ -2092,8 +2110,8 @@ export void EXPORT_UNIQUE(SharedStructuredVolume_sampleM_N_export, } } -export void *uniform EXPORT_UNIQUE(SharedStructuredVolume_Destructor, - void *uniform _self) +export void EXPORT_UNIQUE(SharedStructuredVolume_Destructor, + void *uniform _self) { uniform SharedStructuredVolume *uniform self = (uniform SharedStructuredVolume * uniform) _self; @@ -2103,17 +2121,15 @@ export void *uniform EXPORT_UNIQUE(SharedStructuredVolume_Destructor, if (self->accelerator) { GridAccelerator_Destructor(self->accelerator); } - - delete self; } -export void *uniform EXPORT_UNIQUE(SharedStructuredVolume_Constructor) +export void EXPORT_UNIQUE(SharedStructuredVolume_Constructor, + void *uniform _self) { uniform SharedStructuredVolume *uniform self = - uniform new uniform SharedStructuredVolume; - memset(self, 0, sizeof(uniform SharedStructuredVolume)); + (uniform SharedStructuredVolume * uniform) _self; - return self; + memset(self, 0, sizeof(uniform SharedStructuredVolume)); } export uniform bool EXPORT_UNIQUE( @@ -2238,12 +2254,14 @@ export void *uniform EXPORT_UNIQUE(SharedStructuredVolume_createAccelerator, // wrappers to enable setting old-style function pointers in the Volume // superclass; restricts to first attribute varying float computeSample_varying_0_iterator_wrapper( - const Sampler *uniform _sampler, + const SamplerShared *uniform _sampler, const varying vec3f &objectCoordinates, const uniform uint32 attributeIndex, const varying float &time) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; assert(sampler); return SharedStructuredVolume_computeSample_varying( @@ -2255,12 +2273,14 @@ varying float computeSample_varying_0_iterator_wrapper( } uniform float computeSample_uniform_0_iterator_wrapper( - const Sampler *uniform _sampler, + const SamplerShared *uniform _sampler, const uniform vec3f &objectCoordinates, const uniform uint32 attributeIndex, const uniform float &time) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const StructuredSamplerShared *uniform ssampler = + (const StructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = (const SamplerShared *uniform)_sampler; assert(sampler); return SharedStructuredVolume_computeSample_uniform( @@ -2271,16 +2291,18 @@ uniform float computeSample_uniform_0_iterator_wrapper( time); } -export Sampler *uniform EXPORT_UNIQUE(StructuredSampler_create, - const void *uniform _volume) +export void EXPORT_UNIQUE(StructuredSampler_create, + const void *uniform _volume, + void *uniform _self) { - Sampler *uniform sampler = CALL_ISPC(Sampler_create, _volume); + StructuredSamplerShared *uniform ssampler = + (StructuredSamplerShared * uniform) _self; + memset(ssampler, 0, sizeof(uniform StructuredSamplerShared)); + + SamplerShared *uniform sampler = &ssampler->super.super; + sampler->volume = (const VolumeShared *uniform)_volume; sampler->computeSample_uniform = computeSample_uniform_0_iterator_wrapper; sampler->computeSample_varying = computeSample_varying_0_iterator_wrapper; - return sampler; } -export void EXPORT_UNIQUE(StructuredSampler_destroy, void *uniform _sampler) -{ - CALL_ISPC(Sampler_destroy, _sampler); -} +export void EXPORT_UNIQUE(StructuredSampler_destroy, void *uniform _sampler) {} diff --git a/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp b/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp index a8a992e4..748abc5a 100644 --- a/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp +++ b/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp @@ -12,12 +12,13 @@ namespace openvkl { { StructuredVolume::commit(); - if (!this->ispcEquivalent) { - this->ispcEquivalent = CALL_ISPC(SharedStructuredVolume_Constructor); + if (!this->SharedStructInitialized) { + CALL_ISPC(SharedStructuredVolume_Constructor, this->getSh()); + this->SharedStructInitialized = true; - if (!this->ispcEquivalent) { + if (!this->SharedStructInitialied) { throw std::runtime_error( - "could not create ISPC-side object for StructuredRegularVolume"); + "could not initialized device-side object for StructuredRegularVolume"); } } @@ -25,7 +26,7 @@ namespace openvkl { ispcs(this->attributesData); bool success = CALL_ISPC(SharedStructuredVolume_set, - this->ispcEquivalent, + this->getSh(), ispcAttributesData.size(), ispcAttributesData.data(), this->temporallyStructuredNumTimesteps, @@ -38,14 +39,14 @@ namespace openvkl { (ispc::VKLFilter)this->filter); if (!success) { - CALL_ISPC(SharedStructuredVolume_Destructor, this->ispcEquivalent); - this->ispcEquivalent = nullptr; + CALL_ISPC(SharedStructuredVolume_Destructor, this->getSh()); + this->SharedStructInitialized = false; throw std::runtime_error("failed to commit StructuredRegularVolume"); } CALL_ISPC( - Volume_setBackground, this->ispcEquivalent, this->background->data()); + Volume_setBackground, this->getSh(), this->background->data()); // must be last this->buildAccelerator(); diff --git a/openvkl/devices/cpu/volume/StructuredSampler.h b/openvkl/devices/cpu/volume/StructuredSampler.h index cd30e812..70624d07 100644 --- a/openvkl/devices/cpu/volume/StructuredSampler.h +++ b/openvkl/devices/cpu/volume/StructuredSampler.h @@ -14,6 +14,8 @@ #include "StructuredVolume.h" #include "Volume_ispc.h" #include "openvkl/VKLFilter.h" +#include "../common/StructShared.h" +#include "StructuredSamplerShared.h" namespace openvkl { namespace cpu_device { @@ -23,12 +25,14 @@ namespace openvkl { class IntervalIteratorFactory, template class HitIteratorFactory> - struct StructuredSampler : public SamplerBase + struct StructuredSampler + : public AddStructShared, + ispc::StructuredSamplerShared> { - StructuredSampler(StructuredVolume *volume); + StructuredSampler(StructuredVolume &volume); ~StructuredSampler() override; void commit() override; @@ -89,7 +93,6 @@ namespace openvkl { ///////////////////////////////////////////////////////////////////////// protected: - using Sampler::ispcEquivalent; using SamplerBase class HitIteratorFactory> inline StructuredSampler:: - StructuredSampler(StructuredVolume *volume) - : SamplerBase(*volume), - filter(volume->getFilter()), - gradientFilter(volume->getGradientFilter()) + StructuredSampler(StructuredVolume &volume) + : AddStructShared, + ispc::StructuredSamplerShared>(volume), + filter(volume.getFilter()), + gradientFilter(volume.getGradientFilter()) { - assert(volume); - ispcEquivalent = - CALL_ISPC(StructuredSampler_create, volume->getISPCEquivalent()); + CALL_ISPC(StructuredSampler_create, volume.getSh(), this->getSh()); } template :: ~StructuredSampler() { - CALL_ISPC(StructuredSampler_destroy, ispcEquivalent); - ispcEquivalent = nullptr; + CALL_ISPC(StructuredSampler_destroy, this->getSh()); } template hasParam("filter") ? filter : gradientFilter); CALL_ISPC(Sampler_setFilters, - ispcEquivalent, + this->getSh(), (ispc::VKLFilter)filter, (ispc::VKLFilter)gradientFilter); } @@ -170,7 +171,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertValidTime(time[0]); CALL_ISPC(SharedStructuredVolume_sample_uniform_export, - ispcEquivalent, + this->getSh(), &objectCoordinates, attributeIndex, &time, @@ -194,7 +195,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(SharedStructuredVolume_sample_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, attributeIndex, &time, @@ -217,7 +218,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(SharedStructuredVolume_sample_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, attributeIndex, @@ -242,7 +243,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(SharedStructuredVolume_gradient_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, attributeIndex, time, @@ -265,7 +266,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(SharedStructuredVolume_gradient_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, attributeIndex, @@ -289,7 +290,7 @@ namespace openvkl { assertValidAttributeIndices(volume, M, attributeIndices); assertValidTime(time[0]); CALL_ISPC(SharedStructuredVolume_sampleM_uniform_export, - ispcEquivalent, + this->getSh(), &objectCoordinates, M, attributeIndices, @@ -315,7 +316,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(SharedStructuredVolume_sampleM_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, M, attributeIndices, @@ -340,7 +341,7 @@ namespace openvkl { assertValidAttributeIndices(volume, M, attributeIndices); assertAllValidTimes(N, times); CALL_ISPC(SharedStructuredVolume_sampleM_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, M, diff --git a/openvkl/devices/cpu/volume/StructuredSamplerShared.h b/openvkl/devices/cpu/volume/StructuredSamplerShared.h new file mode 100644 index 00000000..24723467 --- /dev/null +++ b/openvkl/devices/cpu/volume/StructuredSamplerShared.h @@ -0,0 +1,19 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "../sampler/SamplerShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct StructuredSamplerShared + { + SamplerBaseShared super; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp b/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp index 2c58cb1a..671ba61b 100644 --- a/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp +++ b/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp @@ -11,7 +11,7 @@ namespace openvkl { template Sampler *StructuredSphericalVolume::newSampler() { - return new StructuredSphericalSampler(this); + return new StructuredSphericalSampler(*this); } template @@ -19,12 +19,13 @@ namespace openvkl { { StructuredVolume::commit(); - if (!this->ispcEquivalent) { - this->ispcEquivalent = CALL_ISPC(SharedStructuredVolume_Constructor); + if (!this->SharedStructInitialized) { + CALL_ISPC(SharedStructuredVolume_Constructor, this->getSh()); + this->SharedStructInitialized = true; - if (!this->ispcEquivalent) { + if (!this->SharedStructInitialized) { throw std::runtime_error( - "could not create ISPC-side object for " + "could not initialize device-side object for " "StructuredSphericalVolume"); } } @@ -83,7 +84,7 @@ namespace openvkl { ispcs(this->attributesData); bool success = CALL_ISPC(SharedStructuredVolume_set, - this->ispcEquivalent, + this->getSh(), ispcAttributesData.size(), ispcAttributesData.data(), this->temporallyStructuredNumTimesteps, @@ -96,14 +97,14 @@ namespace openvkl { (ispc::VKLFilter)this->filter); if (!success) { - CALL_ISPC(SharedStructuredVolume_Destructor, this->ispcEquivalent); - this->ispcEquivalent = nullptr; + CALL_ISPC(SharedStructuredVolume_Destructor, this->getSh()); + this->SharedStructInitialized = false; throw std::runtime_error("failed to commit StructuredSphericalVolume"); } CALL_ISPC( - Volume_setBackground, this->ispcEquivalent, this->background->data()); + Volume_setBackground, this->getSh(), this->background->data()); // must be last this->buildAccelerator(); diff --git a/openvkl/devices/cpu/volume/StructuredVolume.cpp b/openvkl/devices/cpu/volume/StructuredVolume.cpp index e42f14f4..803f277c 100644 --- a/openvkl/devices/cpu/volume/StructuredVolume.cpp +++ b/openvkl/devices/cpu/volume/StructuredVolume.cpp @@ -11,7 +11,7 @@ namespace openvkl { template Sampler *StructuredVolume::newSampler() { - return new StructuredRegularSampler(this); + return new StructuredRegularSampler(*this); } template struct StructuredVolume; diff --git a/openvkl/devices/cpu/volume/StructuredVolume.h b/openvkl/devices/cpu/volume/StructuredVolume.h index c6325f2d..cecd0993 100644 --- a/openvkl/devices/cpu/volume/StructuredVolume.h +++ b/openvkl/devices/cpu/volume/StructuredVolume.h @@ -12,12 +12,15 @@ #include "Volume.h" #include "openvkl/VKLFilter.h" #include "rkcommon/tasking/parallel_for.h" +#include "openvkl/common/StructShared.h" +#include "StructuredVolumeShared.h" namespace openvkl { namespace cpu_device { template - struct StructuredVolume : public Volume + struct StructuredVolume + : public AddStructShared, ispc::SharedStructuredVolume> { ~StructuredVolume(); @@ -64,8 +67,8 @@ namespace openvkl { template StructuredVolume::~StructuredVolume() { - if (this->ispcEquivalent) { - CALL_ISPC(SharedStructuredVolume_Destructor, this->ispcEquivalent); + if (this->SharedStructInitialized) { + CALL_ISPC(SharedStructuredVolume_Destructor, this->getSh()); } } @@ -159,7 +162,7 @@ namespace openvkl { { ispc::box3f bb; CALL_ISPC( - SharedStructuredVolume_getBoundingBox, this->ispcEquivalent, bb); + SharedStructuredVolume_getBoundingBox, this->getSh(), bb); return box3f(vec3f(bb.lower.x, bb.lower.y, bb.lower.z), vec3f(bb.upper.x, bb.upper.y, bb.upper.z)); @@ -183,7 +186,7 @@ namespace openvkl { inline void StructuredVolume::buildAccelerator() { void *accelerator = CALL_ISPC(SharedStructuredVolume_createAccelerator, - this->ispcEquivalent); + this->getSh()); vec3i bricksPerDimension; bricksPerDimension.x = diff --git a/openvkl/devices/cpu/volume/StructuredVolumeShared.h b/openvkl/devices/cpu/volume/StructuredVolumeShared.h new file mode 100644 index 00000000..f859f1f9 --- /dev/null +++ b/openvkl/devices/cpu/volume/StructuredVolumeShared.h @@ -0,0 +1,99 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "VolumeShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct GridAccelerator; + +#ifdef __cplusplus + + typedef void *ComputeSampleInnerVaryingFunc; + + typedef void *ComputeSampleInnerUniformFunc; + + typedef void *ComputeGradientVaryingFunc; + + typedef void *ComputeVoxelRangeFunc; + +#else + +typedef varying float (*uniform ComputeSampleInnerVaryingFunc)( + const SharedStructuredVolume *uniform self, + const varying vec3f &clampedLocalCoordinates, + const uniform VKLFilter filter, + const uniform uint32 attributeIndex, + const varying float ×); + +typedef uniform float (*uniform ComputeSampleInnerUniformFunc)( + const SharedStructuredVolume *uniform self, + const uniform vec3f &clampedLocalCoordinates, + const uniform VKLFilter filter, + const uniform uint32 attributeIndex, + const uniform float ×); + +typedef varying vec3f (*uniform ComputeGradientVaryingFunc)( + const SharedStructuredVolume *uniform _self, + const varying vec3f &objectCoordinates, + const uniform VKLFilter filter, + const uniform uint32 attributeIndex, + const varying float &time); + +typedef varying range1f (*uniform ComputeVoxelRangeFunc)( + const SharedStructuredVolume *uniform self, + const varying vec3i &localCoordinates, + const uniform uint32 attributeIndex); + +#endif // __cplusplus + + struct SharedStructuredVolume + { + VolumeShared super; + + VKL_INTEROP_UNIFORM uint32 numAttributes; + Data1D *VKL_INTEROP_UNIFORM attributesData; + + VKL_INTEROP_UNIFORM uint32 temporallyStructuredNumTimesteps; + VKL_INTEROP_UNIFORM Data1D temporallyUnstructuredIndices; + VKL_INTEROP_UNIFORM Data1D temporallyUnstructuredTimes; + + VKL_INTEROP_UNIFORM vec3i dimensions; + + VKL_INTEROP_UNIFORM SharedStructuredVolumeGridType gridType; + VKL_INTEROP_UNIFORM vec3f gridOrigin; + VKL_INTEROP_UNIFORM vec3f gridSpacing; + + VKL_INTEROP_UNIFORM box3f boundingBox; + + VKL_INTEROP_UNIFORM vec3f localCoordinatesUpperBound; + + GridAccelerator *VKL_INTEROP_UNIFORM accelerator; + + // offsets, in voxels, for one step in x,y,z direction; ONLY valid if + // bytesPerSlice < 2G. + VKL_INTEROP_UNIFORM uint32 voxelOfs_dx, voxelOfs_dy, voxelOfs_dz; + + // This is only used by the legacy sample wrappers - remove once those + // have disappeared. + VKLFilter filter; + + // varying functions + ComputeVoxelRangeFunc *VKL_INTEROP_UNIFORM computeVoxelRange; + + ComputeSampleInnerVaryingFunc *VKL_INTEROP_UNIFORM + computeSamplesInner_varying; + ComputeGradientVaryingFunc computeGradient_varying; + + // uniform functions + ComputeSampleInnerUniformFunc *VKL_INTEROP_UNIFORM + computeSamplesInner_uniform; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/UnstructuredSampler.h b/openvkl/devices/cpu/volume/UnstructuredSampler.h index c013f3c2..5c2fd7cd 100644 --- a/openvkl/devices/cpu/volume/UnstructuredSampler.h +++ b/openvkl/devices/cpu/volume/UnstructuredSampler.h @@ -11,6 +11,8 @@ #include "UnstructuredVolume.h" #include "UnstructuredVolume_ispc.h" #include "Volume_ispc.h" +#include "openvkl/common/StructShared.h" +#include "UnstructuredSamplerShared.h" namespace openvkl { namespace cpu_device { @@ -23,9 +25,10 @@ namespace openvkl { template struct UnstructuredSampler - : public UnstructuredSamplerBase + : public AddStructShared, + ispc::UnstructuredSamplerShared> { - UnstructuredSampler(UnstructuredVolume *volume); + UnstructuredSampler(UnstructuredVolume &volume); ~UnstructuredSampler() override; void computeSampleV(const vintn &valid, @@ -53,7 +56,6 @@ namespace openvkl { const float *times) const override final; private: - using Sampler::ispcEquivalent; using UnstructuredSamplerBase::volume; }; @@ -61,19 +63,17 @@ namespace openvkl { template inline UnstructuredSampler::UnstructuredSampler( - UnstructuredVolume *volume) - : UnstructuredSamplerBase(*volume) + UnstructuredVolume &volume) + : AddStructShared, ispc::UnstructuredSamplerShared>(volume) { - assert(volume); - ispcEquivalent = CALL_ISPC(VKLUnstructuredSampler_Constructor, - volume->getISPCEquivalent()); + CALL_ISPC( + VKLUnstructuredSampler_Constructor, volume.getSh(), this->getSh()); } template inline UnstructuredSampler::~UnstructuredSampler() { - CALL_ISPC(VKLUnstructuredSampler_Destructor, ispcEquivalent); - ispcEquivalent = nullptr; + CALL_ISPC(VKLUnstructuredSampler_Destructor, this->getSh()); } template @@ -88,7 +88,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VKLUnstructuredVolume_sample_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, &samples); } @@ -104,7 +104,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(Sampler_sample_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, samples); @@ -122,7 +122,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VKLUnstructuredVolume_gradient_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, &gradients); } @@ -138,7 +138,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(Sampler_gradient_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, (ispc::vec3f *)gradients); diff --git a/openvkl/devices/cpu/volume/UnstructuredSamplerBase.ih b/openvkl/devices/cpu/volume/UnstructuredSamplerBase.ih index faf7b3c4..410ddb97 100644 --- a/openvkl/devices/cpu/volume/UnstructuredSamplerBase.ih +++ b/openvkl/devices/cpu/volume/UnstructuredSamplerBase.ih @@ -5,5 +5,5 @@ struct UnstructuredSamplerBase { - Sampler super; + SamplerShared super; }; diff --git a/openvkl/devices/cpu/volume/UnstructuredSamplerShared.h b/openvkl/devices/cpu/volume/UnstructuredSamplerShared.h new file mode 100644 index 00000000..e7e8456f --- /dev/null +++ b/openvkl/devices/cpu/volume/UnstructuredSamplerShared.h @@ -0,0 +1,21 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "../sampler/SamplerShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + +#ifndef __ISPC_STRUCT_UnstructuredSamplerShared__ +#define __ISPC_STRUCT_UnstructuredSamplerShared__ + struct UnstructuredSamplerShared + { + SamplerBaseShared super; + }; +#endif +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/UnstructuredVolume.cpp b/openvkl/devices/cpu/volume/UnstructuredVolume.cpp index 5d0540be..427b0bfa 100644 --- a/openvkl/devices/cpu/volume/UnstructuredVolume.cpp +++ b/openvkl/devices/cpu/volume/UnstructuredVolume.cpp @@ -62,8 +62,9 @@ namespace openvkl { template UnstructuredVolume::~UnstructuredVolume() { - if (this->ispcEquivalent) { - CALL_ISPC(VKLUnstructuredVolume_Destructor, this->ispcEquivalent); + if (this->SharedStructInitialized) { + CALL_ISPC(VKLUnstructuredVolume_Destructor, this->getSh()); + this->SharedStructInitialized = false; } if (rtcBVH) @@ -75,7 +76,7 @@ namespace openvkl { template void UnstructuredVolume::commit() { - Volume::commit(); + UnstructuredVolumeBase::commit(); // hex method planar/nonplanar @@ -202,15 +203,16 @@ namespace openvkl { computeOverlappingNodeMetadata(rtcRoot); - if (!this->ispcEquivalent) { - this->ispcEquivalent = CALL_ISPC(VKLUnstructuredVolume_Constructor); + if (!this->SharedStructInitialized) { + CALL_ISPC(VKLUnstructuredVolume_Constructor, this->getSh()); + this->SharedStructInitialized = true; } - CALL_ISPC(Volume_setBackground, this->ispcEquivalent, background->data()); + CALL_ISPC(Volume_setBackground, this->getSh(), background->data()); CALL_ISPC( VKLUnstructuredVolume_set, - this->ispcEquivalent, + this->getSh(), (const ispc::box3f &)bounds, ispc(vertexPosition), index32Bit ? ispc(index32) : ispc(index64), @@ -231,7 +233,7 @@ namespace openvkl { template Sampler *UnstructuredVolume::newSampler() { - return new UnstructuredSampler(this); + return new UnstructuredSampler(*this); } template diff --git a/openvkl/devices/cpu/volume/UnstructuredVolume.h b/openvkl/devices/cpu/volume/UnstructuredVolume.h index 048491ea..4d316e6c 100644 --- a/openvkl/devices/cpu/volume/UnstructuredVolume.h +++ b/openvkl/devices/cpu/volume/UnstructuredVolume.h @@ -8,13 +8,17 @@ #include "../common/math.h" #include "UnstructuredBVH.h" #include "UnstructuredVolume_ispc.h" -#include "Volume.h" +#include "UnstructuredVolumeBase.h" +#include "UnstructuredVolumeShared.h" +#include "openvkl/common/StructShared.h" namespace openvkl { namespace cpu_device { template - struct UnstructuredVolume : public Volume + struct UnstructuredVolume + : public AddStructShared, + ispc::VKLUnstructuredVolume> { ~UnstructuredVolume(); diff --git a/openvkl/devices/cpu/volume/UnstructuredVolume.ih b/openvkl/devices/cpu/volume/UnstructuredVolume.ih index c63ee79b..30a66c42 100644 --- a/openvkl/devices/cpu/volume/UnstructuredVolume.ih +++ b/openvkl/devices/cpu/volume/UnstructuredVolume.ih @@ -6,51 +6,9 @@ #include "../common/Data.ih" #include "rkcommon/math/vec.ih" #include "rkcommon/math/box.ih" - +#include "UnstructuredVolumeShared.h" #include "Volume.ih" -typedef enum -{ - VKL_TETRAHEDRON = 10, - VKL_HEXAHEDRON = 12, - VKL_WEDGE = 13, - VKL_PYRAMID = 14 -} CellType; - -struct Node -{ - uniform vec3f nominalLength; - uniform box1f valueRange; - uniform int level; - uniform Node *uniform parent; -}; - -struct LeafNode -{ - uniform Node super; - uniform box3fa bounds; -}; - -struct LeafNodeSingle -{ - uniform LeafNode super; - uniform uint64 cellID; -}; - -struct LeafNodeMulti -{ - uniform LeafNode super; - uniform uint64 numCells; - uniform uint64 *uniform cellIDs; -}; - -struct InnerNode -{ - uniform Node super; - uniform box3fa bounds[2]; - uniform Node *uniform children[2]; -}; - inline uniform Node *uniform sibling(uniform Node *uniform node) { uniform InnerNode *uniform parent = @@ -111,43 +69,6 @@ void traverseBVHMulti(uniform Node *uniform root, vec3f &result, const vec3f &pos); -struct VKLUnstructuredBase -{ - Volume super; - - uniform box3f boundingBox; - uniform Node *uniform bvhRoot; -}; - -struct VKLUnstructuredVolume -{ - VKLUnstructuredBase super; - - // vertex data - uniform Data1D vertex; - uniform Data1D vertexValue; // attribute value at each vertex - - // index data - uniform Data1D index; // indices into vertices array - uniform bool index32Bit; // true if index is 32-bit integer, false if 64-bit - - // cell data - uniform Data1D cell; // cell offsets in indices array - uniform bool - cell32Bit; // true if cell offset is 32-bit integer, false if 64-bit - uniform uint32 cellSkipIds; // skip indices when index array contain other - // data e.g. size - uniform Data1D cellType; // cell type array - uniform Data1D cellValue; // attribute value at each cell - - const vec3f *uniform faceNormals; - const float *uniform iterativeTolerance; - - uniform vec3f gradientStep; - - uniform bool hexIterative; -}; - #define template_intersectRayCell(univary) \ univary box1f intersectRayCell_##univary( \ const univary vec3f &origin, \ diff --git a/openvkl/devices/cpu/volume/UnstructuredVolume.ispc b/openvkl/devices/cpu/volume/UnstructuredVolume.ispc index 06a405c3..f00c4aec 100644 --- a/openvkl/devices/cpu/volume/UnstructuredVolume.ispc +++ b/openvkl/devices/cpu/volume/UnstructuredVolume.ispc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "../common/export_util.h" -#include "UnstructuredSamplerBase.ih" +#include "UnstructuredSamplerShared.h" #include "UnstructuredVolume.ih" inline bool pointInAABBTest(const uniform box3fa &box, const vec3f &point) @@ -133,10 +133,10 @@ template_traverseBVHMulti(intersectAndGradientPrimM, vec3f); // stackless traversal; this approach may be useful with traversal caches in the // future inline void traverseBVH(uniform Node *uniform root, - const void *uniform userPtr, - uniform intersectAndSamplePrim userFunc, - float &result, - const vec3f &samplePos) + const void *uniform userPtr, + uniform intersectAndSamplePrim userFunc, + float &result, + const vec3f &samplePos) { uniform Node *uniform node = root; uniform uint32 bitstack = 0; @@ -1276,7 +1276,7 @@ template_intersectRayCell(varying); #undef template_intersectRayCell inline varying float VKLUnstructuredVolume_sample( - const Sampler *uniform sampler, + const SamplerShared *uniform sampler, const varying vec3f &worldCoordinates, const uniform uint32 _attributeIndex, const varying float &_time) @@ -1296,8 +1296,9 @@ inline varying float VKLUnstructuredVolume_sample( return results; } -inline varying vec3f VKLUnstructuredVolume_computeGradient( - const Sampler *uniform sampler, const varying vec3f &objectCoordinates) +inline varying vec3f +VKLUnstructuredVolume_computeGradient(const SamplerShared *uniform sampler, + const varying vec3f &objectCoordinates) { // Cast to the actual Volume subtype. const VKLUnstructuredVolume *uniform self = @@ -1313,7 +1314,8 @@ inline varying vec3f VKLUnstructuredVolume_computeGradient( // boundaries (as determined by NaN sample values outside any volume cell) vec3f gradient; - float sample = VKLUnstructuredVolume_sample(sampler, objectCoordinates, 0, time); + float sample = + VKLUnstructuredVolume_sample(sampler, objectCoordinates, 0, time); gradient.x = VKLUnstructuredVolume_sample( sampler, @@ -1376,14 +1378,17 @@ export void EXPORT_UNIQUE(VKLUnstructuredVolume_sample_export, const void *uniform _objectCoordinates, void *uniform _samples) { - const Sampler *uniform sampler = (const Sampler *uniform) _sampler; + const UnstructuredSamplerShared *uniform usampler = + (const UnstructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = &usampler->super.super; if (imask[programIndex]) { const varying vec3f *uniform objectCoordinates = (const varying vec3f *uniform)_objectCoordinates; varying float time = 0.f; varying float *uniform samples = (varying float *uniform)_samples; - *samples = VKLUnstructuredVolume_sample(sampler, *objectCoordinates, 0, time); + *samples = + VKLUnstructuredVolume_sample(sampler, *objectCoordinates, 0, time); } } @@ -1393,30 +1398,27 @@ export void EXPORT_UNIQUE(VKLUnstructuredVolume_gradient_export, const void *uniform _objectCoordinates, void *uniform _gradients) { - const Sampler *uniform sampler = (const Sampler *uniform) _sampler; + const UnstructuredSamplerShared *uniform usampler = + (const UnstructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = &usampler->super.super; if (imask[programIndex]) { const varying vec3f *uniform objectCoordinates = (const varying vec3f *uniform)_objectCoordinates; varying vec3f *uniform gradients = (varying vec3f * uniform) _gradients; - *gradients = VKLUnstructuredVolume_computeGradient(sampler, *objectCoordinates); + *gradients = + VKLUnstructuredVolume_computeGradient(sampler, *objectCoordinates); } } -export void *uniform EXPORT_UNIQUE(VKLUnstructuredVolume_Constructor) +export void EXPORT_UNIQUE(VKLUnstructuredVolume_Constructor, + void *uniform _self) { - uniform VKLUnstructuredVolume *uniform self = - uniform new uniform VKLUnstructuredVolume; - memset(self, 0, sizeof(uniform VKLUnstructuredVolume)); - - return self; + memset(_self, 0, sizeof(uniform VKLUnstructuredVolume)); } export void EXPORT_UNIQUE(VKLUnstructuredVolume_Destructor, void *uniform _self) { - VKLUnstructuredVolume *uniform volume = - (VKLUnstructuredVolume * uniform) _self; - delete volume; } export void EXPORT_UNIQUE(VKLUnstructuredVolume_set, @@ -1459,28 +1461,25 @@ export void EXPORT_UNIQUE(VKLUnstructuredVolume_set, make_vec3f(0.01f * reduce_min(self->super.boundingBox.upper - self->super.boundingBox.lower)); - self->super.bvhRoot = (uniform Node * uniform) bvhRoot; + self->super.bvhRoot = (uniform Node * uniform) bvhRoot; } -export UnstructuredSamplerBase *uniform -EXPORT_UNIQUE(VKLUnstructuredSampler_Constructor, void *uniform _volume) +export void EXPORT_UNIQUE(VKLUnstructuredSampler_Constructor, + void *uniform _volume, + void *uniform _self) { - UnstructuredSamplerBase *uniform sampler = - uniform new UnstructuredSamplerBase; - memset(sampler, 0, sizeof(uniform UnstructuredSamplerBase)); + UnstructuredSamplerShared *uniform usampler = + (UnstructuredSamplerShared * uniform) _self; + memset(usampler, 0, sizeof(uniform UnstructuredSamplerShared)); - sampler->super.volume = (const Volume *uniform)_volume; - sampler->super.computeSample_varying = VKLUnstructuredVolume_sample; - sampler->super.computeGradient_varying = - VKLUnstructuredVolume_computeGradient; + SamplerShared *uniform sampler = &usampler->super.super; - return sampler; + sampler->volume = (const VolumeShared *uniform)_volume; + sampler->computeSample_varying = VKLUnstructuredVolume_sample; + sampler->computeGradient_varying = VKLUnstructuredVolume_computeGradient; } export void EXPORT_UNIQUE(VKLUnstructuredSampler_Destructor, void *uniform _sampler) { - UnstructuredSamplerBase *uniform sampler = - (UnstructuredSamplerBase * uniform) _sampler; - delete sampler; } diff --git a/openvkl/devices/cpu/volume/UnstructuredVolumeBase.h b/openvkl/devices/cpu/volume/UnstructuredVolumeBase.h new file mode 100644 index 00000000..d822bdde --- /dev/null +++ b/openvkl/devices/cpu/volume/UnstructuredVolumeBase.h @@ -0,0 +1,43 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "../common/Data.h" +#include "../common/export_util.h" +#include "../common/math.h" +#include "Volume.h" +#include "UnstructuredVolumeBaseShared.h" +#include "openvkl/common/StructShared.h" + +namespace openvkl { + namespace cpu_device { + + template + struct UnstructuredVolumeBase + : public AddStructShared, ispc::VKLUnstructuredBase> + { + std::string toString() const override; + + UnstructuredVolumeBase(){}; // not = default, due to ICC 19 compiler bug + ~UnstructuredVolumeBase(){}; + + virtual void commit() override; + }; + + // Inlined definitions //////////////////////////////////////////////////// + + template + inline std::string UnstructuredVolumeBase::toString() const + { + return "openvkl::UnstructuredVolumeBase"; + } + + template + void UnstructuredVolumeBase::commit() + { + Volume::commit(); + } + + } // namespace cpu_device +} // namespace openvkl diff --git a/openvkl/devices/cpu/volume/UnstructuredVolumeBaseShared.h b/openvkl/devices/cpu/volume/UnstructuredVolumeBaseShared.h new file mode 100644 index 00000000..5f9cd443 --- /dev/null +++ b/openvkl/devices/cpu/volume/UnstructuredVolumeBaseShared.h @@ -0,0 +1,30 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "VolumeShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + +struct Node +{ + VKL_INTEROP_UNIFORM vec3f nominalLength; + VKL_INTEROP_UNIFORM box1f valueRange; + VKL_INTEROP_UNIFORM int level; + VKL_INTEROP_UNIFORM Node *VKL_INTEROP_UNIFORM parent; +}; + +struct VKLUnstructuredBase +{ + VolumeShared super; + + VKL_INTEROP_UNIFORM box3f boundingBox; + VKL_INTEROP_UNIFORM Node *VKL_INTEROP_UNIFORM bvhRoot; +}; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/UnstructuredVolumeShared.h b/openvkl/devices/cpu/volume/UnstructuredVolumeShared.h new file mode 100644 index 00000000..a71ffb05 --- /dev/null +++ b/openvkl/devices/cpu/volume/UnstructuredVolumeShared.h @@ -0,0 +1,78 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "UnstructuredVolumeBaseShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + typedef enum + { + VKL_TETRAHEDRON = 10, + VKL_HEXAHEDRON = 12, + VKL_WEDGE = 13, + VKL_PYRAMID = 14 + } CellType; + + struct LeafNode + { + VKL_INTEROP_UNIFORM Node super; + VKL_INTEROP_UNIFORM box3fa bounds; + }; + + struct LeafNodeSingle + { + VKL_INTEROP_UNIFORM LeafNode super; + VKL_INTEROP_UNIFORM vkl_uint64 cellID; + }; + + struct LeafNodeMulti + { + VKL_INTEROP_UNIFORM LeafNode super; + VKL_INTEROP_UNIFORM vkl_uint64 numCells; + VKL_INTEROP_UNIFORM vkl_uint64 *VKL_INTEROP_UNIFORM cellIDs; + }; + + struct InnerNode + { + VKL_INTEROP_UNIFORM Node super; + VKL_INTEROP_UNIFORM box3fa bounds[2]; + VKL_INTEROP_UNIFORM Node *VKL_INTEROP_UNIFORM children[2]; + }; + + struct VKLUnstructuredVolume + { + VKLUnstructuredBase super; + + // vertex data + VKL_INTEROP_UNIFORM Data1D vertex; + VKL_INTEROP_UNIFORM Data1D vertexValue; // attribute value at each vertex + + // index data + VKL_INTEROP_UNIFORM Data1D index; // indices into vertices array + VKL_INTEROP_UNIFORM bool + index32Bit; // true if index is 32-bit integer, false if 64-bit + + // cell data + VKL_INTEROP_UNIFORM Data1D cell; // cell offsets in indices array + VKL_INTEROP_UNIFORM bool + cell32Bit; // true if cell offset is 32-bit integer, false if 64-bit + VKL_INTEROP_UNIFORM uint32 cellSkipIds; // skip indices when index array + // contain other data e.g. size + VKL_INTEROP_UNIFORM Data1D cellType; // cell type array + VKL_INTEROP_UNIFORM Data1D cellValue; // attribute value at each cell + + const vec3f *VKL_INTEROP_UNIFORM faceNormals; + const float *VKL_INTEROP_UNIFORM iterativeTolerance; + + VKL_INTEROP_UNIFORM vec3f gradientStep; + + VKL_INTEROP_UNIFORM bool hexIterative; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/Volume.h b/openvkl/devices/cpu/volume/Volume.h index 4843f77b..5b25590b 100644 --- a/openvkl/devices/cpu/volume/Volume.h +++ b/openvkl/devices/cpu/volume/Volume.h @@ -11,6 +11,8 @@ #include "Volume_ispc.h" #include "openvkl/openvkl.h" #include "rkcommon/math/box.h" +#include "openvkl/common/StructShared.h" +#include "VolumeShared.h" #define THROW_NOT_IMPLEMENTED \ throw std::runtime_error(std::string(__FUNCTION__) + \ @@ -36,9 +38,9 @@ namespace openvkl { // Volume ///////////////////////////////////////////////////////////////// template - struct Volume : public ManagedObject + struct Volume : public AddStructShared { - Volume() = default; + Volume() {} // not = default, due to ICC 19 compiler bug virtual ~Volume() override = default; static Volume *createInstance(Device *device, const std::string &type); @@ -53,17 +55,15 @@ namespace openvkl { virtual range1f getValueRange(unsigned int attributeIndex) const = 0; - void *getISPCEquivalent() const; - virtual Observer *newObserver(const char *type) { return nullptr; } protected: - void *ispcEquivalent{nullptr}; - static ObjectFactory volumeFactory; + + bool SharedStructInitialized = false; }; // Inlined definitions //////////////////////////////////////////////////// @@ -83,12 +83,6 @@ namespace openvkl { volumeFactory.registerType(type, f); } - template - inline void *Volume::getISPCEquivalent() const - { - return ispcEquivalent; - } - template ObjectFactory, VKL_VOLUME> Volume::volumeFactory; diff --git a/openvkl/devices/cpu/volume/Volume.ih b/openvkl/devices/cpu/volume/Volume.ih index d84ab39e..9e08d68b 100644 --- a/openvkl/devices/cpu/volume/Volume.ih +++ b/openvkl/devices/cpu/volume/Volume.ih @@ -5,12 +5,7 @@ #include "rkcommon/math/vec.ih" #include "../common/export_util.h" - -struct Volume -{ - // Background value, per attribute. - const float *uniform background; -}; +#include "VolumeShared.h" export void EXPORT_UNIQUE(Volume_setBackground, void *uniform _volume, diff --git a/openvkl/devices/cpu/volume/Volume.ispc b/openvkl/devices/cpu/volume/Volume.ispc index 4c8d93ea..bdbe030a 100644 --- a/openvkl/devices/cpu/volume/Volume.ispc +++ b/openvkl/devices/cpu/volume/Volume.ispc @@ -8,6 +8,6 @@ export void EXPORT_UNIQUE(Volume_setBackground, void *uniform _volume, const float *uniform background) { - Volume *uniform volume = (Volume * uniform) _volume; + VolumeShared *uniform volume = (VolumeShared * uniform) _volume; volume->background = background; } diff --git a/openvkl/devices/cpu/volume/VolumeShared.h b/openvkl/devices/cpu/volume/VolumeShared.h new file mode 100644 index 00000000..3b9e00fe --- /dev/null +++ b/openvkl/devices/cpu/volume/VolumeShared.h @@ -0,0 +1,27 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "openvkl/ispc_cpp_interop.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + +// this hack prevents .ispc -> ispc.h code from redeclaring. TODO: something +// better +#ifndef __ISPC_STRUCT_VolumeShared__ +#define __ISPC_STRUCT_VolumeShared__ + + struct VolumeShared + { + // Background value, per attribute. + const float *VKL_INTEROP_UNIFORM background; + }; + +#endif + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/amr/AMR.ih b/openvkl/devices/cpu/volume/amr/AMR.ih index 559ae5d9..76a23b3b 100644 --- a/openvkl/devices/cpu/volume/amr/AMR.ih +++ b/openvkl/devices/cpu/volume/amr/AMR.ih @@ -9,6 +9,7 @@ #include "../common/Data.ih" // ours #include "KDTree.ih" +#include "AMRShared.h" inline vec3f lerp(const box3f box, const vec3f w) { @@ -56,85 +57,6 @@ template_AMR_getVoxel(float); template_AMR_getVoxel(double); #undef template_getVoxel -/*! enum to symbolically iterate the 8 corners of an octant */ -enum { C000=0, C001,C010,C011,C100,C101,C110,C111 }; - -struct AMRBrick -{ - /*! bounding box of integer coordinates of cells. note that - this EXCLUDES the width of the rightmost cell: ie, a 4^3 - box at root level pos (0,0,0) would have a _box_ of - [(0,0,0)-(3,3,3)] (because 3,3,3 is the highest valid - coordinate in this box!), while its bounds would be - [(0,0,0)-(4,4,4)]. Make sure to NOT use box.size() for the - grid dimensions, since this will always be one lower than - the dims of the grid.... */ - box3i box; - //! level this brick is at - int level; - // width of each cell in this level - float cellWidth; - - /* world bounds, including entire cells. ie, a 4^3 root brick - at (0,0,0) would have bounds [(0,0,0)-(4,4,4)] (as opposed - to the 'box' value, see above!) */ - box3f bounds; - // pointer to the actual data values stored in this brick - Data1D *value; - // dimensions of this box's data - vec3i dims; - // scale factor from grid space to world space (ie,1.f/cellWidth) - float gridToWorldScale; - - // rcp(bounds.upper-bounds.lower); - vec3f bounds_scale; - // dimensions, in float - vec3f f_dims; -}; - -struct AMRLeaf -{ - AMRBrick **brickList; - box3f bounds; - range1f valueRange; -}; - -struct AMRLevel -{ - float cellWidth; - /* do not use these values: they are computed on the C side, at - apparently different accuracy than when they get computed on the - ISPC side - this gets "sometimes" inconsistent results */ - float doNotUse_rcpCellWidth; - float doNotUse_halfCellWidth; - int level; -}; - -struct AMR -{ - /*! "item list" array - each leaf node in the tree points into this - array, and the 'num' elements following the pointed-to-location - are the bricks stored at this leaf */ - AMRLeaf *leaf; - // AMRBrick *uniform *uniform item; - KDTreeNode *node; - AMRLevel *level; - AMRLevel *finestLevel; - uint32 numNodes; - uint32 numLeaves; - uint32 numLevels; - float finestLevelCellWidth; - - box3f worldBounds; - vec3f maxValidPos; - - //! Voxel type. - uniform VKLDataType voxelType; - - //! Voxel data accessor. - float (*uniform getVoxel)(Data1D *uniform data, const varying uint32 index); -}; - inline float nextafter(const float f, const float s) { const float af = abs(f); diff --git a/openvkl/devices/cpu/volume/amr/AMRSampler.h b/openvkl/devices/cpu/volume/amr/AMRSampler.h index b7c4e78c..997ef88c 100644 --- a/openvkl/devices/cpu/volume/amr/AMRSampler.h +++ b/openvkl/devices/cpu/volume/amr/AMRSampler.h @@ -6,6 +6,7 @@ #include "../../common/export_util.h" #include "../../iterator/UnstructuredIterator.h" #include "../../sampler/Sampler.h" +#include "../UnstructuredSamplerShared.h" #include "AMRVolume.h" #include "AMRVolume_ispc.h" #include "Sampler_ispc.h" @@ -13,6 +14,7 @@ #include "method_current_ispc.h" #include "method_finest_ispc.h" #include "method_octant_ispc.h" +#include "openvkl/common/StructShared.h" namespace openvkl { namespace cpu_device { @@ -24,9 +26,10 @@ namespace openvkl { UnstructuredHitIteratorFactory>; template - struct AMRSampler : public AMRSamplerBase + struct AMRSampler : public AddStructShared, + ispc::UnstructuredSamplerShared> { - AMRSampler(AMRVolume *volume); + AMRSampler(AMRVolume &volume); ~AMRSampler() override; void commit() override; @@ -56,26 +59,23 @@ namespace openvkl { const float *time) const override final; protected: - using Sampler::ispcEquivalent; using AMRSamplerBase::volume; }; // Inlined definitions //////////////////////////////////////////////////// template - inline AMRSampler::AMRSampler(AMRVolume *volume) - : AMRSamplerBase(*volume) + inline AMRSampler::AMRSampler(AMRVolume &volume) + : AddStructShared, ispc::UnstructuredSamplerShared>( + volume) { - assert(volume); - ispcEquivalent = - CALL_ISPC(AMRSampler_create, volume->getISPCEquivalent()); + CALL_ISPC(AMRSampler_create, volume.getSh(), this->getSh()); } template inline AMRSampler::~AMRSampler() { - CALL_ISPC(AMRSampler_destroy, ispcEquivalent); - ispcEquivalent = nullptr; + CALL_ISPC(AMRSampler_destroy, this->getSh()); } template @@ -83,13 +83,13 @@ namespace openvkl { { const VKLAMRMethod amrMethod = (VKLAMRMethod)( this->template getParam("method", volume->getAMRMethod())); - + ispc::SamplerShared *ss = &(this->getSh()->super.super); if (amrMethod == VKL_AMR_CURRENT) - CALL_ISPC(AMR_install_current, ispcEquivalent); + CALL_ISPC(AMR_install_current, ss); else if (amrMethod == VKL_AMR_FINEST) - CALL_ISPC(AMR_install_finest, ispcEquivalent); + CALL_ISPC(AMR_install_finest, ss); else if (amrMethod == VKL_AMR_OCTANT) - CALL_ISPC(AMR_install_octant, ispcEquivalent); + CALL_ISPC(AMR_install_octant, ss); else throw std::runtime_error("AMRSampler: illegal method specified"); } @@ -106,7 +106,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(AMRVolume_sample_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, &samples); } @@ -122,7 +122,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, time); CALL_ISPC(Sampler_sample_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, samples); @@ -140,7 +140,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(AMRVolume_gradient_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, &gradients); } @@ -156,7 +156,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, time); CALL_ISPC(Sampler_gradient_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, (ispc::vec3f *)gradients); diff --git a/openvkl/devices/cpu/volume/amr/AMRShared.h b/openvkl/devices/cpu/volume/amr/AMRShared.h new file mode 100644 index 00000000..c46d0042 --- /dev/null +++ b/openvkl/devices/cpu/volume/amr/AMRShared.h @@ -0,0 +1,114 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#ifdef __cplusplus +#include "rkcommon/math/box.h" +#else +#include "rkcommon/math/box.ih" +#endif +// ospray +#include "../common/DataShared.h" +#include "openvkl/VKLDataType.h" +// ours +#include "KDTreeShared.h" + +/*! enum to symbolically iterate the 8 corners of an octant */ +enum +{ + C000 = 0, + C001, + C010, + C011, + C100, + C101, + C110, + C111 +}; + +struct AMRBrick +{ + /*! bounding box of integer coordinates of cells. note that + this EXCLUDES the width of the rightmost cell: ie, a 4^3 + box at root level pos (0,0,0) would have a _box_ of + [(0,0,0)-(3,3,3)] (because 3,3,3 is the highest valid + coordinate in this box!), while its bounds would be + [(0,0,0)-(4,4,4)]. Make sure to NOT use box.size() for the + grid dimensions, since this will always be one lower than + the dims of the grid.... */ + box3i box; + //! level this brick is at + int level; + // width of each cell in this level + float cellWidth; + + /* world bounds, including entire cells. ie, a 4^3 root brick + at (0,0,0) would have bounds [(0,0,0)-(4,4,4)] (as opposed + to the 'box' value, see above!) */ + box3f bounds; +// pointer to the actual data values stored in this brick +#ifdef __cplusplus + ispc::Data1D *value; +#else + Data1D *value; +#endif + // dimensions of this box's data + vec3i dims; + // scale factor from grid space to world space (ie,1.f/cellWidth) + float gridToWorldScale; + + // rcp(bounds.upper-bounds.lower); + vec3f bounds_scale; + // dimensions, in float + vec3f f_dims; +}; + +struct AMRLeaf +{ + AMRBrick **brickList; + box3f bounds; + range1f valueRange; +}; + +struct AMRLevel +{ + float cellWidth; + /* do not use these values: they are computed on the C side, at + apparently different accuracy than when they get computed on the + ISPC side - this gets "sometimes" inconsistent results */ + float doNotUse_rcpCellWidth; + float doNotUse_halfCellWidth; + int level; +}; + +struct AMR +{ + /*! "item list" array - each leaf node in the tree points into this + array, and the 'num' elements following the pointed-to-location + are the bricks stored at this leaf */ + AMRLeaf *leaf; + // AMRBrick *uniform *uniform item; + KDTreeNode *node; + AMRLevel *level; + AMRLevel *finestLevel; + vkl_uint32 numNodes; + vkl_uint32 numLeaves; + vkl_uint32 numLevels; + float finestLevelCellWidth; + + box3f worldBounds; + vec3f maxValidPos; + + //! Voxel type. + VKL_INTEROP_UNIFORM VKLDataType voxelType; + + //! Voxel data accessor. + float (*VKL_INTEROP_UNIFORM getVoxel)( +#ifdef __cplusplus + ispc::Data1D *VKL_INTEROP_UNIFORM data, +#else + Data1D *VKL_INTEROP_UNIFORM data, +#endif + const VKL_INTEROP_VARYING vkl_uint32 index); +}; diff --git a/openvkl/devices/cpu/volume/amr/AMRVolume.cpp b/openvkl/devices/cpu/volume/amr/AMRVolume.cpp index ac2cb176..6838f446 100644 --- a/openvkl/devices/cpu/volume/amr/AMRVolume.cpp +++ b/openvkl/devices/cpu/volume/amr/AMRVolume.cpp @@ -64,14 +64,16 @@ namespace openvkl { template AMRVolume::AMRVolume() { - this->ispcEquivalent = CALL_ISPC(AMRVolume_create, this); + CALL_ISPC(AMRVolume_Constructor, this->getSh()); + this->SharedStructInitialized = true; } template AMRVolume::~AMRVolume() { - if (this->ispcEquivalent) { - CALL_ISPC(AMRVolume_Destructor, this->ispcEquivalent); + if (this->SharedStructInitialized) { + CALL_ISPC(AMRVolume_Destructor, this->getSh()); + this->SharedStructInitialized = false; } if (rtcBVH) @@ -98,7 +100,7 @@ namespace openvkl { if (data != nullptr) // TODO: support data updates { CALL_ISPC( - Volume_setBackground, this->ispcEquivalent, background->data()); + Volume_setBackground, this->getSh(), background->data()); return; } @@ -154,17 +156,17 @@ namespace openvkl { this->template getParam("gridSpacing", vec3f(1.f)); spacing = gridSpacing; - CALL_ISPC(Volume_setBackground, this->ispcEquivalent, background->data()); + CALL_ISPC(Volume_setBackground, this->getSh(), background->data()); CALL_ISPC(AMRVolume_set, - this->ispcEquivalent, + this->getSh(), (ispc::box3f &)bounds, samplingStep, (const ispc::vec3f &)gridOrigin, (const ispc::vec3f &)gridSpacing); CALL_ISPC(AMRVolume_setAMR, - this->ispcEquivalent, + this->getSh(), accel->node.size(), &accel->node[0], accel->leaf.size(), @@ -178,7 +180,7 @@ namespace openvkl { // This enables empty space skipping within the hierarchical structure tasking::parallel_for(accel->leaf.size(), [&](size_t leafID) { CALL_ISPC( - AMRVolume_computeValueRangeOfLeaf, this->ispcEquivalent, leafID); + AMRVolume_computeValueRangeOfLeaf, this->getSh(), leafID); }); // compute value range over the full volume @@ -189,13 +191,13 @@ namespace openvkl { // need to do this after value ranges are known buildBvh(); - CALL_ISPC(AMRVolume_setBvh, this->ispcEquivalent, (void *)(rtcRoot)); + CALL_ISPC(AMRVolume_setBvh, this->getSh(), (void *)(rtcRoot)); } template Sampler *AMRVolume::newSampler() { - return new AMRSampler(this); + return new AMRSampler(*this); } template diff --git a/openvkl/devices/cpu/volume/amr/AMRVolume.h b/openvkl/devices/cpu/volume/amr/AMRVolume.h index 27c58a29..42cea893 100644 --- a/openvkl/devices/cpu/volume/amr/AMRVolume.h +++ b/openvkl/devices/cpu/volume/amr/AMRVolume.h @@ -7,6 +7,9 @@ #include "../Volume.h" #include "AMRAccel.h" #include "rkcommon/memory/RefCount.h" +#include "AMRVolumeShared.h" +#include "../UnstructuredVolumeBase.h" +#include "openvkl/common/StructShared.h" using namespace rkcommon::memory; @@ -14,7 +17,8 @@ namespace openvkl { namespace cpu_device { template - struct AMRVolume : public Volume + struct AMRVolume + : public AddStructShared, ispc::AMRVolume> { AMRVolume(); ~AMRVolume() override; diff --git a/openvkl/devices/cpu/volume/amr/AMRVolume.ih b/openvkl/devices/cpu/volume/amr/AMRVolume.ih index c0a866ca..c7976104 100644 --- a/openvkl/devices/cpu/volume/amr/AMRVolume.ih +++ b/openvkl/devices/cpu/volume/amr/AMRVolume.ih @@ -3,24 +3,10 @@ #pragma once -#include "../Volume.ih" -#include "AMR.ih" -#include "../UnstructuredVolume.ih" - -struct AMRVolume -{ - VKLUnstructuredBase super; - - uniform vec3f gridSpacing; - uniform vec3f gridOrigin; - uniform box3f boundingBox; - uniform float samplingStep; - - AMR amr; -}; +#include "AMRVolumeShared.h" inline void AMRVolume_transformObjectToLocal( - const AMRVolume *uniform volume, + const AMRVolume *VKL_INTEROP_UNIFORM volume, const varying vec3f &objectCoordinates, varying vec3f &localCoordinates) { diff --git a/openvkl/devices/cpu/volume/amr/AMRVolume.ispc b/openvkl/devices/cpu/volume/amr/AMRVolume.ispc index 940d5995..60fb64b1 100644 --- a/openvkl/devices/cpu/volume/amr/AMRVolume.ispc +++ b/openvkl/devices/cpu/volume/amr/AMRVolume.ispc @@ -4,13 +4,13 @@ // ours //#include "CellRef.ih" // #include "AMRCommon.h" -#include "../UnstructuredSamplerBase.ih" +#include "../UnstructuredSamplerShared.h" #include "AMR.ih" -#include "AMRVolume.ih" +#include "AMRVolumeShared.h" #include "common/export_util.h" #include "sampler/Sampler.ih" -static vec3f AMRVolume_computeGradient(const Sampler *uniform sampler, +static vec3f AMRVolume_computeGradient(const SamplerShared *uniform sampler, const varying vec3f &pos) { // Cast to the actual Volume subtype. @@ -53,18 +53,13 @@ static vec3f AMRVolume_computeGradient(const Sampler *uniform sampler, return (gradient / gradientStep); } -export void *uniform EXPORT_UNIQUE(AMRVolume_create, void *uniform cppE) +export void EXPORT_UNIQUE(AMRVolume_Constructor, void *uniform _self) { - AMRVolume *uniform self = uniform new uniform AMRVolume; + uniform AMRVolume *uniform self = (uniform AMRVolume * uniform) _self; memset(self, 0, sizeof(uniform AMRVolume)); - return self; } -export void EXPORT_UNIQUE(AMRVolume_Destructor, void *uniform _self) -{ - AMRVolume *uniform volume = (AMRVolume * uniform) _self; - delete volume; -} +export void EXPORT_UNIQUE(AMRVolume_Destructor, void *uniform _self) {} export void EXPORT_UNIQUE(AMRVolume_computeValueRangeOfLeaf, const void *uniform _self, @@ -157,7 +152,9 @@ export void EXPORT_UNIQUE(AMRVolume_sample_export, const void *uniform _objectCoordinates, void *uniform _samples) { - const Sampler *uniform sampler = (const Sampler *uniform)_sampler; + const UnstructuredSamplerShared *uniform usampler = + (const UnstructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = &usampler->super.super; if (imask[programIndex]) { const varying vec3f *uniform objectCoordinates = @@ -176,35 +173,33 @@ export void EXPORT_UNIQUE(AMRVolume_gradient_export, const void *uniform _objectCoordinates, void *uniform _gradients) { + const UnstructuredSamplerShared *uniform usampler = + (const UnstructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = &usampler->super.super; + if (imask[programIndex]) { const varying vec3f *uniform objectCoordinates = (const varying vec3f *uniform)_objectCoordinates; varying vec3f *uniform gradients = (varying vec3f * uniform) _gradients; - *gradients = AMRVolume_computeGradient((const Sampler *uniform)_sampler, - *objectCoordinates); + *gradients = AMRVolume_computeGradient(sampler, *objectCoordinates); } } -export UnstructuredSamplerBase *uniform EXPORT_UNIQUE(AMRSampler_create, - void *uniform _volume) +export void EXPORT_UNIQUE(AMRSampler_create, + void *uniform _volume, + void *uniform _sampler) { - UnstructuredSamplerBase *uniform sampler = - uniform new UnstructuredSamplerBase; - memset(sampler, 0, sizeof(uniform UnstructuredSamplerBase)); + UnstructuredSamplerShared *uniform usampler = + (UnstructuredSamplerShared * uniform) _sampler; + memset(usampler, 0, sizeof(uniform UnstructuredSamplerShared)); + SamplerShared *uniform sampler = &usampler->super.super; - sampler->super.volume = (const Volume *uniform)_volume; + sampler->volume = (const VolumeShared *uniform)_volume; // computeSample functions set in AMR_install* functions - sampler->super.computeGradient_varying = AMRVolume_computeGradient; - - return sampler; + sampler->computeGradient_varying = AMRVolume_computeGradient; } -export void EXPORT_UNIQUE(AMRSampler_destroy, void *uniform _sampler) -{ - UnstructuredSamplerBase *uniform sampler = - (UnstructuredSamplerBase * uniform) _sampler; - delete sampler; -} +export void EXPORT_UNIQUE(AMRSampler_destroy, void *uniform _sampler) {} diff --git a/openvkl/devices/cpu/volume/amr/AMRVolumeShared.h b/openvkl/devices/cpu/volume/amr/AMRVolumeShared.h new file mode 100644 index 00000000..c8cc26e2 --- /dev/null +++ b/openvkl/devices/cpu/volume/amr/AMRVolumeShared.h @@ -0,0 +1,27 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "AMRShared.h" +#include "../UnstructuredVolumeBaseShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct AMRVolume + { + VKLUnstructuredBase super; + + VKL_INTEROP_UNIFORM vec3f gridSpacing; + VKL_INTEROP_UNIFORM vec3f gridOrigin; + VKL_INTEROP_UNIFORM box3f boundingBox; + VKL_INTEROP_UNIFORM float samplingStep; + + AMR amr; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/amr/CellRef.ih b/openvkl/devices/cpu/volume/amr/CellRef.ih index a30636c1..26cd947b 100644 --- a/openvkl/devices/cpu/volume/amr/CellRef.ih +++ b/openvkl/devices/cpu/volume/amr/CellRef.ih @@ -5,7 +5,6 @@ // ours #include "AMR.ih" -#include "AMRVolume.ih" /*! a reference to a given cell on a given level; this is what a 'node location' kernel will return */ struct CellRef @@ -37,4 +36,4 @@ extern CellRef findCell(const AMR *uniform self, const float minWidth); extern CellRef findLeafCell(const AMR *uniform self, - const varying vec3f &_worldSpacePos); \ No newline at end of file + const varying vec3f &_worldSpacePos); diff --git a/openvkl/devices/cpu/volume/amr/KDTree.ih b/openvkl/devices/cpu/volume/amr/KDTree.ih index 5f1a0aa5..8a221b74 100644 --- a/openvkl/devices/cpu/volume/amr/KDTree.ih +++ b/openvkl/devices/cpu/volume/amr/KDTree.ih @@ -3,13 +3,7 @@ #pragma once -/*! ispc equivalent of the c++-side kdtree that we build over the - boxes */ -struct KDTreeNode -{ - uint32 dim_and_ofs; - uint32 pos_or_numItems; -}; +#include "KDTreeShared.h" inline uint32 getDim(const KDTreeNode & node) { @@ -59,4 +53,4 @@ inline uniform float getPos(const uniform KDTreeNode & node) inline uniform float getNumItems(const uniform KDTreeNode & node) { return node.pos_or_numItems; -} \ No newline at end of file +} diff --git a/openvkl/devices/cpu/volume/amr/KDTreeShared.h b/openvkl/devices/cpu/volume/amr/KDTreeShared.h new file mode 100644 index 00000000..61dceb77 --- /dev/null +++ b/openvkl/devices/cpu/volume/amr/KDTreeShared.h @@ -0,0 +1,12 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +/*! ispc equivalent of the c++-side kdtree that we build over the + boxes */ +struct KDTreeNode +{ + vkl_uint32 dim_and_ofs; + vkl_uint32 pos_or_numItems; +}; diff --git a/openvkl/devices/cpu/volume/amr/method_current.ispc b/openvkl/devices/cpu/volume/amr/method_current.ispc index e6c65aac..a9b4f933 100644 --- a/openvkl/devices/cpu/volume/amr/method_current.ispc +++ b/openvkl/devices/cpu/volume/amr/method_current.ispc @@ -5,9 +5,9 @@ #include "CellRef.ih" #include "DualCell.ih" #include "common/export_util.h" -#include "sampler/Sampler.ih" +#include "sampler/SamplerShared.h" -varying float AMR_current(const Sampler *uniform self, +varying float AMR_current(const SamplerShared *uniform self, const varying vec3f &P, const uniform uint32 _attributeIndex, const varying float &_time) @@ -33,6 +33,6 @@ varying float AMR_current(const Sampler *uniform self, export void EXPORT_UNIQUE(AMR_install_current, void *uniform _sampler) { - Sampler *uniform sampler = (Sampler * uniform) _sampler; + SamplerShared *uniform sampler = (SamplerShared * uniform) _sampler; sampler->computeSample_varying = AMR_current; } diff --git a/openvkl/devices/cpu/volume/amr/method_finest.ispc b/openvkl/devices/cpu/volume/amr/method_finest.ispc index f0ca8534..b7027373 100644 --- a/openvkl/devices/cpu/volume/amr/method_finest.ispc +++ b/openvkl/devices/cpu/volume/amr/method_finest.ispc @@ -5,9 +5,9 @@ #include "CellRef.ih" #include "DualCell.ih" #include "common/export_util.h" -#include "sampler/Sampler.ih" +#include "sampler/SamplerShared.h" -varying float AMR_finest(const Sampler *uniform self, +varying float AMR_finest(const SamplerShared *uniform self, const varying vec3f &P, const uniform uint32 _attributeIndex, const varying float &_time) @@ -30,6 +30,6 @@ varying float AMR_finest(const Sampler *uniform self, export void EXPORT_UNIQUE(AMR_install_finest, void *uniform _sampler) { - Sampler *uniform sampler = (Sampler * uniform) _sampler; + SamplerShared *uniform sampler = (SamplerShared * uniform) _sampler; sampler->computeSample_varying = AMR_finest; } diff --git a/openvkl/devices/cpu/volume/amr/method_octant.ispc b/openvkl/devices/cpu/volume/amr/method_octant.ispc index 884930d2..dc22a341 100644 --- a/openvkl/devices/cpu/volume/amr/method_octant.ispc +++ b/openvkl/devices/cpu/volume/amr/method_octant.ispc @@ -5,7 +5,7 @@ #include "CellRef.ih" #include "DualCell.ih" #include "common/export_util.h" -#include "sampler/Sampler.ih" +#include "sampler/SamplerShared.h" #define DBG(a) @@ -441,7 +441,7 @@ varying float doOctant(const AMR *uniform self, return lerp(O); } -varying float AMR_octant(const Sampler *uniform self, +varying float AMR_octant(const SamplerShared *uniform self, const varying vec3f &P, const uniform uint32 _attributeIndex, const varying float &time) @@ -462,6 +462,6 @@ varying float AMR_octant(const Sampler *uniform self, export void EXPORT_UNIQUE(AMR_install_octant, void *uniform _sampler) { - Sampler *uniform sampler = (Sampler * uniform) _sampler; + SamplerShared *uniform sampler = (SamplerShared * uniform) _sampler; sampler->computeSample_varying = AMR_octant; } diff --git a/openvkl/devices/cpu/volume/particle/ParticleSampler.h b/openvkl/devices/cpu/volume/particle/ParticleSampler.h index e9758b1b..1771fc23 100644 --- a/openvkl/devices/cpu/volume/particle/ParticleSampler.h +++ b/openvkl/devices/cpu/volume/particle/ParticleSampler.h @@ -7,10 +7,12 @@ #include "../../common/export_util.h" #include "../../iterator/UnstructuredIterator.h" #include "../../sampler/Sampler.h" +#include "../UnstructuredSamplerShared.h" #include "ParticleVolume.h" #include "ParticleVolume_ispc.h" #include "Sampler_ispc.h" #include "Volume_ispc.h" +#include "openvkl/common/StructShared.h" namespace openvkl { namespace cpu_device { @@ -22,9 +24,11 @@ namespace openvkl { UnstructuredHitIteratorFactory>; template - struct ParticleSampler : public ParticleSamplerBase + struct ParticleSampler + : public AddStructShared, + ispc::UnstructuredSamplerShared> { - ParticleSampler(ParticleVolume *volume); + ParticleSampler(ParticleVolume &volume); ~ParticleSampler(); void computeSampleV(const vintn &valid, @@ -52,26 +56,23 @@ namespace openvkl { const float *times) const override final; protected: - using Sampler::ispcEquivalent; using ParticleSamplerBase::volume; }; // Inlined definitions //////////////////////////////////////////////////// template - inline ParticleSampler::ParticleSampler(ParticleVolume *volume) - : ParticleSamplerBase(*volume) + inline ParticleSampler::ParticleSampler(ParticleVolume &volume) + : AddStructShared, + ispc::UnstructuredSamplerShared>(volume) { - assert(volume); - ispcEquivalent = CALL_ISPC(VKLParticleSampler_Constructor, - volume->getISPCEquivalent()); + CALL_ISPC(VKLParticleSampler_Constructor, volume.getSh(), this->getSh()); } template inline ParticleSampler::~ParticleSampler() { - CALL_ISPC(VKLParticleSampler_Destructor, ispcEquivalent); - ispcEquivalent = nullptr; + CALL_ISPC(VKLParticleSampler_Destructor, this->getSh()); } template @@ -86,7 +87,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VKLParticleVolume_sample_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, &samples); } @@ -102,7 +103,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(Sampler_sample_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, samples); @@ -120,7 +121,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VKLParticleVolume_gradient_export, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, &gradients); } @@ -136,7 +137,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(Sampler_gradient_N_export, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, (ispc::vec3f *)gradients); diff --git a/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp b/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp index 0b19f6ba..f5a5677d 100644 --- a/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp +++ b/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp @@ -59,8 +59,9 @@ namespace openvkl { template ParticleVolume::~ParticleVolume() { - if (this->ispcEquivalent) { - CALL_ISPC(VKLParticleVolume_Destructor, this->ispcEquivalent); + if (this->SharedStructInitialized) { + CALL_ISPC(VKLParticleVolume_Destructor, this->getSh()); + this->SharedStructInitialized = false; } if (rtcBVH) @@ -136,14 +137,15 @@ namespace openvkl { buildBvhAndCalculateBounds(); - if (!this->ispcEquivalent) { - this->ispcEquivalent = CALL_ISPC(VKLParticleVolume_Constructor); + if (!this->SharedStructInitialized) { + CALL_ISPC(VKLParticleVolume_Constructor, this->getSh()); + this->SharedStructInitialized = true; } - CALL_ISPC(Volume_setBackground, this->ispcEquivalent, background->data()); + CALL_ISPC(Volume_setBackground, this->getSh(), background->data()); CALL_ISPC(VKLParticleVolume_set, - this->ispcEquivalent, + this->getSh(), (const ispc::box3f &)bounds, ispc(positions), ispc(radii), @@ -160,7 +162,7 @@ namespace openvkl { template Sampler *ParticleVolume::newSampler() { - return new ParticleSampler(this); + return new ParticleSampler(*this); } template diff --git a/openvkl/devices/cpu/volume/particle/ParticleVolume.h b/openvkl/devices/cpu/volume/particle/ParticleVolume.h index 34a77966..fdfaf14a 100644 --- a/openvkl/devices/cpu/volume/particle/ParticleVolume.h +++ b/openvkl/devices/cpu/volume/particle/ParticleVolume.h @@ -6,10 +6,11 @@ #include "../../common/export_util.h" #include "../UnstructuredBVH.h" #include "../UnstructuredVolume.h" -#include "../Volume.h" #include "../common/Data.h" #include "../common/math.h" +#include "ParticleVolumeShared.h" #include "ParticleVolume_ispc.h" +#include "openvkl/common/StructShared.h" #define MAX_PRIMS_PER_LEAF VKL_TARGET_WIDTH @@ -67,14 +68,14 @@ namespace openvkl { }; template - struct ParticleVolume : public Volume + struct ParticleVolume : public AddStructShared, + ispc::VKLParticleVolume> { ~ParticleVolume(); void commit() override; Sampler *newSampler() override; - box3f getBoundingBox() const override; unsigned int getNumAttributes() const override; diff --git a/openvkl/devices/cpu/volume/particle/ParticleVolume.ih b/openvkl/devices/cpu/volume/particle/ParticleVolume.ih deleted file mode 100644 index 5fe142df..00000000 --- a/openvkl/devices/cpu/volume/particle/ParticleVolume.ih +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2020 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "../common/Data.ih" -#include "rkcommon/math/box.ih" -#include "rkcommon/math/vec.ih" - -#include "../UnstructuredVolume.ih" -#include "../Volume.ih" - -struct VKLParticleVolume -{ - VKLUnstructuredBase super; - - uniform float clampMaxCumulativeValue; - uniform float radiusSupportFactor; - uniform Data1D positions; - uniform Data1D radii; - uniform Data1D weights; -}; diff --git a/openvkl/devices/cpu/volume/particle/ParticleVolume.ispc b/openvkl/devices/cpu/volume/particle/ParticleVolume.ispc index 74a1b3c7..e863dde3 100644 --- a/openvkl/devices/cpu/volume/particle/ParticleVolume.ispc +++ b/openvkl/devices/cpu/volume/particle/ParticleVolume.ispc @@ -1,9 +1,13 @@ // Copyright 2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 +#include "../../common/Data.ih" #include "../../common/export_util.h" -#include "../UnstructuredSamplerBase.ih" -#include "ParticleVolume.ih" +#include "../UnstructuredSamplerShared.h" +#include "../UnstructuredVolume.ih" +#include "ParticleVolumeShared.h" +#include "rkcommon/math/box.ih" +#include "rkcommon/math/vec.ih" inline void getParticleContributionsGaussian( const VKLParticleVolume *uniform self, @@ -103,7 +107,7 @@ static bool intersectAndGradientParticle(const void *uniform userData, } inline varying float VKLParticleVolume_sample( - const Sampler *uniform sampler, + const SamplerShared *uniform sampler, const varying vec3f &objectCoordinates, const uniform uint32 _attributeIndex, const varying float &_time) @@ -126,8 +130,9 @@ inline varying float VKLParticleVolume_sample( return sampleResult; } -inline varying vec3f VKLParticleVolume_computeGradient( - const Sampler *uniform sampler, const varying vec3f &objectCoordinates) +inline varying vec3f +VKLParticleVolume_computeGradient(const SamplerShared *uniform sampler, + const varying vec3f &objectCoordinates) { const VKLParticleVolume *uniform self = (const VKLParticleVolume *uniform)sampler->volume; @@ -149,14 +154,17 @@ export void EXPORT_UNIQUE(VKLParticleVolume_sample_export, const void *uniform _objectCoordinates, void *uniform _samples) { + const UnstructuredSamplerShared *uniform usampler = + (const UnstructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = &usampler->super.super; + if (imask[programIndex]) { const varying vec3f *uniform objectCoordinates = (const varying vec3f *uniform)_objectCoordinates; varying float time = 0.f; varying float *uniform samples = (varying float *uniform)_samples; - *samples = VKLParticleVolume_sample( - (const Sampler *uniform)_sampler, *objectCoordinates, 0, time); + *samples = VKLParticleVolume_sample(sampler, *objectCoordinates, 0, time); } } @@ -166,30 +174,27 @@ export void EXPORT_UNIQUE(VKLParticleVolume_gradient_export, const void *uniform _objectCoordinates, void *uniform _gradients) { + const UnstructuredSamplerShared *uniform usampler = + (const UnstructuredSamplerShared *uniform)_sampler; + const SamplerShared *uniform sampler = &usampler->super.super; + if (imask[programIndex]) { const varying vec3f *uniform objectCoordinates = (const varying vec3f *uniform)_objectCoordinates; varying vec3f *uniform gradients = (varying vec3f * uniform) _gradients; - *gradients = VKLParticleVolume_computeGradient( - (const Sampler *uniform)_sampler, *objectCoordinates); + *gradients = VKLParticleVolume_computeGradient(sampler, *objectCoordinates); } } -export void *uniform EXPORT_UNIQUE(VKLParticleVolume_Constructor) +export void EXPORT_UNIQUE(VKLParticleVolume_Constructor, void *uniform _self) { uniform VKLParticleVolume *uniform self = - uniform new uniform VKLParticleVolume; + (uniform VKLParticleVolume * uniform) _self; memset(self, 0, sizeof(uniform VKLParticleVolume)); - - return self; } -export void EXPORT_UNIQUE(VKLParticleVolume_Destructor, void *uniform _self) -{ - VKLParticleVolume *uniform volume = (VKLParticleVolume * uniform) _self; - delete volume; -} +export void EXPORT_UNIQUE(VKLParticleVolume_Destructor, void *uniform _self) {} export void EXPORT_UNIQUE(VKLParticleVolume_set, void *uniform _self, @@ -213,23 +218,20 @@ export void EXPORT_UNIQUE(VKLParticleVolume_set, self->super.bvhRoot = (uniform Node * uniform) bvhRoot; } -export UnstructuredSamplerBase *uniform -EXPORT_UNIQUE(VKLParticleSampler_Constructor, void *uniform _volume) +export void EXPORT_UNIQUE(VKLParticleSampler_Constructor, + void *uniform _volume, + void *uniform _self) { - UnstructuredSamplerBase *uniform sampler = - uniform new UnstructuredSamplerBase; - memset(sampler, 0, sizeof(uniform UnstructuredSamplerBase)); - - sampler->super.volume = (const Volume *uniform)_volume; - sampler->super.computeSample_varying = VKLParticleVolume_sample; - sampler->super.computeGradient_varying = VKLParticleVolume_computeGradient; - - return sampler; + UnstructuredSamplerShared *uniform usampler = + (UnstructuredSamplerShared * uniform) _self; + memset(usampler, 0, sizeof(uniform UnstructuredSamplerShared)); + SamplerShared *uniform sampler = &usampler->super.super; + + sampler->volume = (const VolumeShared *uniform)_volume; + sampler->computeSample_varying = VKLParticleVolume_sample; + sampler->computeGradient_varying = VKLParticleVolume_computeGradient; } export void EXPORT_UNIQUE(VKLParticleSampler_Destructor, void *uniform _sampler) { - UnstructuredSamplerBase *uniform sampler = - (UnstructuredSamplerBase * uniform) _sampler; - delete sampler; } diff --git a/openvkl/devices/cpu/volume/particle/ParticleVolumeShared.h b/openvkl/devices/cpu/volume/particle/ParticleVolumeShared.h new file mode 100644 index 00000000..f2c246d3 --- /dev/null +++ b/openvkl/devices/cpu/volume/particle/ParticleVolumeShared.h @@ -0,0 +1,26 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "../UnstructuredVolumeBaseShared.h" +#include "../common/DataShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + struct VKLParticleVolume + { + VKLUnstructuredBase super; + + VKL_INTEROP_UNIFORM float clampMaxCumulativeValue; + VKL_INTEROP_UNIFORM float radiusSupportFactor; + VKL_INTEROP_UNIFORM Data1D positions; + VKL_INTEROP_UNIFORM Data1D radii; + VKL_INTEROP_UNIFORM Data1D weights; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/vdb/VdbIterator.cpp b/openvkl/devices/cpu/volume/vdb/VdbIterator.cpp index 094e44c8..cbb61718 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbIterator.cpp +++ b/openvkl/devices/cpu/volume/vdb/VdbIterator.cpp @@ -21,7 +21,7 @@ namespace openvkl { CALL_ISPC(VdbIterator_Initialize, static_cast(valid), ispcStorage, - context->getISPCEquivalent(), + context->getSh(), (void *)&origin, (void *)&direction, (void *)&tRange); diff --git a/openvkl/devices/cpu/volume/vdb/VdbIterator.ih b/openvkl/devices/cpu/volume/vdb/VdbIterator.ih index ca7fcc0a..7198ed57 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbIterator.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbIterator.ih @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "../../iterator/DefaultIterator.ih" -#include "../../iterator/IteratorContext.ih" +#include "../../iterator/IteratorContextShared.h" #include "Dda.ih" #include "VdbGrid.h" diff --git a/openvkl/devices/cpu/volume/vdb/VdbIterator.ispc b/openvkl/devices/cpu/volume/vdb/VdbIterator.ispc index 934b59ea..4963097a 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbIterator.ispc +++ b/openvkl/devices/cpu/volume/vdb/VdbIterator.ispc @@ -4,7 +4,7 @@ #include "VdbGrid.h" #include "VdbIterator.ih" #include "VdbQueryVoxelDense.ih" -#include "VdbSampler.ih" +#include "VdbSamplerShared.h" #include "common/export_util.h" #include "math/box_utility.ih" #include "rkcommon/math/math.ih" @@ -48,8 +48,9 @@ export void EXPORT_UNIQUE(VdbIterator_Initialize, self->super.iterate = VdbIterator_iterateIntervalInternal; self->super.elementaryCellIterationSupported = false; - const uniform VdbSampler *uniform sampler = - (const uniform VdbSampler *uniform)(self->super.context->sampler); + const uniform VdbSamplerShared *uniform sampler = + (const uniform VdbSamplerShared *uniform)( + self->super.context->super.sampler); const uniform VdbGrid *uniform grid = sampler->grid; self->grid = grid; @@ -84,7 +85,7 @@ export void EXPORT_UNIQUE(VdbIterator_Initialize, ddaInit(rayOrg, rayDir, tRangeIntersected.lower, - self->super.context->maxIteratorDepth, + self->super.context->super.maxIteratorDepth, self->dda); } } @@ -119,7 +120,7 @@ inline void VdbIterator_iterateIntervalInternal( self->dda.idx[DDA_STATE_Y_OFFSET(self->dda.level)], self->dda.idx[DDA_STATE_Z_OFFSET(self->dda.level)], self->dda.level, - self->super.context->attributeIndex, + self->super.context->super.attributeIndex, inputValueRanges, voxel); } else { @@ -128,7 +129,7 @@ inline void VdbIterator_iterateIntervalInternal( self->dda.idx[DDA_STATE_Y_OFFSET(self->dda.level)], self->dda.idx[DDA_STATE_Z_OFFSET(self->dda.level)], self->dda.level, - self->super.context->attributeIndex, + self->super.context->super.attributeIndex, inputValueRanges, voxel); } @@ -169,7 +170,7 @@ export void EXPORT_UNIQUE(VdbIterator_iterateInterval, VdbIterator_iterateIntervalInternal(imask, _self, _interval, - self->super.context->valueRanges, + self->super.context->super.valueRanges, false, _result); } diff --git a/openvkl/devices/cpu/volume/vdb/VdbLeafAccessObserver.ih b/openvkl/devices/cpu/volume/vdb/VdbLeafAccessObserver.ih index e8cad776..78e45e38 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbLeafAccessObserver.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbLeafAccessObserver.ih @@ -4,10 +4,10 @@ #pragma once #include "../../observer/ObserverRegistry.ih" -#include "VdbSampler.ih" +#include "VdbSamplerShared.h" inline uniform bool VdbLeafAccessObserver_isObservable( - const VdbSampler *uniform sampler) + const VdbSamplerShared *uniform sampler) { assert(sampler); return sampler->leafAccessObservers && @@ -15,18 +15,18 @@ inline uniform bool VdbLeafAccessObserver_isObservable( 0); } -#define __define_leaf_access_observer(univary) \ - inline void VdbLeafAccessObserver_observe_##univary( \ - const VdbSampler *uniform sampler, const univary uint32 leafIndex) \ - { \ - assert(sampler->leafAccessObservers); \ - ObserverRegistry *uniform registry = \ - ((ObserverRegistry * uniform) sampler->leafAccessObservers); \ - for (uniform size_t i = 0; i < registry->size; ++i) { \ - uint32 *uniform accessBuffer = ((uint32 * uniform) registry->data[i]); \ - /* NOTE: this is not synchronized between threads! */ \ - accessBuffer[leafIndex] = 1; \ - } \ +#define __define_leaf_access_observer(univary) \ + inline void VdbLeafAccessObserver_observe_##univary( \ + const VdbSamplerShared *uniform sampler, const univary uint32 leafIndex) \ + { \ + assert(sampler->leafAccessObservers); \ + ObserverRegistry *uniform registry = \ + ((ObserverRegistry * uniform) sampler->leafAccessObservers); \ + for (uniform size_t i = 0; i < registry->size; ++i) { \ + uint32 *uniform accessBuffer = ((uint32 * uniform) registry->data[i]); \ + /* NOTE: this is not synchronized between threads! */ \ + accessBuffer[leafIndex] = 1; \ + } \ } __define_leaf_access_observer(uniform) diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampleInner.ih.in b/openvkl/devices/cpu/volume/vdb/VdbSampleInner.ih.in index d2efc9e1..ba6ebe98 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampleInner.ih.in +++ b/openvkl/devices/cpu/volume/vdb/VdbSampleInner.ih.in @@ -31,7 +31,7 @@ * is used when all sample locations are in the same leaf node. */ inline void VdbSampler_sampleInner_@VKL_VDB_UNIVARY_IN@_@VKL_VDB_UNIVARY_OUT@_@VKL_VDB_LEVEL@( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const univary_in uint64 voxelOffset, const univary_out vec3ui &domainOffset, univary_out uint64 &voxel) diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler.cpp b/openvkl/devices/cpu/volume/vdb/VdbSampler.cpp index 24a8a678..0fbae683 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler.cpp +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler.cpp @@ -10,18 +10,19 @@ namespace openvkl { namespace cpu_device { template - VdbSampler::VdbSampler(VdbVolume &volume) : VdbSamplerBase(volume) + VdbSampler::VdbSampler(VdbVolume &volume) + : AddStructShared, ispc::VdbSamplerShared>(volume) { - ispcEquivalent = CALL_ISPC(VdbSampler_create, - volume.getISPCEquivalent(), - leafAccessObservers.getIE()); + CALL_ISPC(VdbSampler_create, + volume.getSh(), + leafAccessObservers.getIE(), + this->getSh()); } template VdbSampler::~VdbSampler() { - CALL_ISPC(VdbSampler_destroy, ispcEquivalent); - ispcEquivalent = nullptr; + CALL_ISPC(VdbSampler_destroy, this->getSh()); } template @@ -42,7 +43,7 @@ namespace openvkl { "maxSamplingDepth", volume->getMaxSamplingDepth()); CALL_ISPC(VdbSampler_set, - ispcEquivalent, + this->getSh(), (ispc::VKLFilter)filter, (ispc::VKLFilter)gradientFilter, maxSamplingDepth); @@ -57,7 +58,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertValidTime(time[0]); CALL_ISPC(VdbSampler_computeSample_uniform, - ispcEquivalent, + this->getSh(), &objectCoordinates, static_cast(time), attributeIndex, @@ -75,7 +76,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VdbSampler_computeSample, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, static_cast(time), attributeIndex, @@ -92,7 +93,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(VdbSampler_computeSample_stream, - ispcEquivalent, + this->getSh(), N, (const ispc::vec3f *)objectCoordinates, times, @@ -111,7 +112,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VdbSampler_computeGradient, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, static_cast(time), attributeIndex, @@ -128,7 +129,7 @@ namespace openvkl { assert(attributeIndex < volume->getNumAttributes()); assertAllValidTimes(N, times); CALL_ISPC(VdbSampler_computeGradient_stream, - ispcEquivalent, + this->getSh(), N, (const ispc::vec3f *)objectCoordinates, times, @@ -147,7 +148,7 @@ namespace openvkl { assertValidAttributeIndices(volume, M, attributeIndices); assertValidTime(time[0]); CALL_ISPC(VdbSampler_computeSampleM_uniform, - ispcEquivalent, + this->getSh(), &objectCoordinates, static_cast(time), M, @@ -168,7 +169,7 @@ namespace openvkl { assertValidTimes(valid, time); CALL_ISPC(VdbSampler_computeSampleM, static_cast(valid), - ispcEquivalent, + this->getSh(), &objectCoordinates, static_cast(time), M, @@ -188,7 +189,7 @@ namespace openvkl { assertValidAttributeIndices(volume, M, attributeIndices); assertAllValidTimes(N, times); CALL_ISPC(VdbSampler_computeSampleM_stream, - ispcEquivalent, + this->getSh(), N, (ispc::vec3f *)objectCoordinates, times, diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler.h b/openvkl/devices/cpu/volume/vdb/VdbSampler.h index 58b74c69..f76e2495 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler.h +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler.h @@ -10,6 +10,8 @@ #include "VdbVolume.h" #include "openvkl/openvkl.h" #include "openvkl/vdb.h" +#include "openvkl/common/StructShared.h" +#include "VdbSamplerShared.h" namespace openvkl { namespace cpu_device { @@ -21,7 +23,8 @@ namespace openvkl { VdbHitIteratorFactory>; template - struct VdbSampler : public VdbSamplerBase + struct VdbSampler + : public AddStructShared, ispc::VdbSamplerShared> { explicit VdbSampler(VdbVolume &volume); ~VdbSampler() override; @@ -89,7 +92,6 @@ namespace openvkl { } private: - using Sampler::ispcEquivalent; using VdbSamplerBase::volume; ObserverRegistry leafAccessObservers; diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler.ih b/openvkl/devices/cpu/volume/vdb/VdbSampler.ih index d1632cea..a2ab30c8 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler.ih @@ -3,29 +3,4 @@ #pragma once -#include "VdbGrid.h" -#include "sampler/Sampler.ih" - -typedef varying float (*uniform DenseLeafSamplingVaryingFunc)( - const VdbGrid *uniform grid, - uniform uint32 attributeIndex, - const varying vec3ui &offset, - const varying float &time); - -typedef uniform float (*uniform DenseLeafSamplingUniformFunc)( - const VdbGrid *uniform grid, - uniform uint32 attributeIndex, - const uniform vec3ui &offset, - uniform float time); - -struct VdbSampler -{ - Sampler super; - - const VdbGrid *uniform grid; - const void *uniform leafAccessObservers; - vkl_uint32 maxSamplingDepth; - - DenseLeafSamplingVaryingFunc *uniform denseLeafSample_varying; - DenseLeafSamplingUniformFunc *uniform denseLeafSample_uniform; -}; +#include "VdbSamplerShared.h" diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler.ispc b/openvkl/devices/cpu/volume/vdb/VdbSampler.ispc index 1049bf20..1c1c3086 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler.ispc +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler.ispc @@ -3,9 +3,10 @@ #include #include "VdbGrid.h" -#include "VdbSampler.ih" +#include "../../sampler/Sampler.ih" +#include "VdbSamplerShared.h" #include "VdbSampler_filter.ih" -#include "VdbVolume.ih" +#include "VdbVolumeShared.h" #include "common/export_util.h" // --------------------------------------------------------------------------- @@ -21,7 +22,8 @@ export void EXPORT_UNIQUE(VdbSampler_computeSample, void *uniform _samples) { if (imask[programIndex]) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); @@ -35,14 +37,14 @@ export void EXPORT_UNIQUE(VdbSampler_computeSample, xfmPoint(sampler->grid->objectToIndex, *objectCoordinates); if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, *sample = VdbSampler_interpolate_dense, sampler, indexCoordinates, *time, attributeIndex); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, *sample = VdbSampler_interpolate, sampler, indexCoordinates, @@ -59,7 +61,8 @@ export void EXPORT_UNIQUE(VdbSampler_computeSample_uniform, const uniform uint32 attributeIndex, void *uniform _samples) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); @@ -72,14 +75,14 @@ export void EXPORT_UNIQUE(VdbSampler_computeSample_uniform, xfmPoint(sampler->grid->objectToIndex, *objectCoordinates); if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, *sample = VdbSampler_interpolate_dense, sampler, indexCoordinates, *time, attributeIndex); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, *sample = VdbSampler_interpolate, sampler, indexCoordinates, @@ -96,12 +99,13 @@ export void EXPORT_UNIQUE(VdbSampler_computeSample_stream, const uniform uint32 attributeIndex, float *uniform samples) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate_dense, sampler, N, @@ -110,7 +114,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeSample_stream, attributeIndex, samples); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate, sampler, N, @@ -131,7 +135,8 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM, float *uniform samples) { if (imask[programIndex]) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); @@ -143,7 +148,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM, xfmPoint(sampler->grid->objectToIndex, *objectCoordinates); if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate_dense, sampler, indexCoordinates, @@ -152,7 +157,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM, attributeIndices, samples); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate, sampler, indexCoordinates, @@ -172,7 +177,8 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM_uniform, const uint32 *uniform attributeIndices, float *uniform samples) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); @@ -185,7 +191,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM_uniform, const float *uniform time = (const float *uniform)_time; if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate_dense, sampler, indexCoordinates, @@ -194,7 +200,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM_uniform, attributeIndices, samples); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate, sampler, indexCoordinates, @@ -214,12 +220,13 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM_stream, const uint32 *uniform attributeIndices, float *uniform samples) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate_dense, sampler, N, @@ -229,7 +236,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeSampleM_stream, attributeIndices, samples); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, VdbSampler_interpolate, sampler, N, @@ -254,7 +261,8 @@ export void EXPORT_UNIQUE(VdbSampler_computeGradient, void *uniform _gradients) { if (imask[programIndex]) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); @@ -269,14 +277,14 @@ export void EXPORT_UNIQUE(VdbSampler_computeGradient, vec3f gradient; if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.gradientFilter, + __vkl_switch_filter(sampler->super.super.gradientFilter, gradient = VdbSampler_computeGradient_dense, sampler, indexCoordinates, *time, attributeIndex); } else { - __vkl_switch_filter(sampler->super.gradientFilter, + __vkl_switch_filter(sampler->super.super.gradientFilter, gradient = VdbSampler_computeGradient, sampler, indexCoordinates, @@ -297,12 +305,13 @@ export void EXPORT_UNIQUE(VdbSampler_computeGradient_stream, const uniform uint32 attributeIndex, vec3f *uniform gradients) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.gradientFilter, + __vkl_switch_filter(sampler->super.super.gradientFilter, VdbSampler_computeGradient_dense, sampler, N, @@ -311,7 +320,7 @@ export void EXPORT_UNIQUE(VdbSampler_computeGradient_stream, attributeIndex, gradients); } else { - __vkl_switch_filter(sampler->super.gradientFilter, + __vkl_switch_filter(sampler->super.super.gradientFilter, VdbSampler_computeGradient, sampler, N, @@ -327,12 +336,13 @@ export void EXPORT_UNIQUE(VdbSampler_computeGradient_stream, // ----------------------------------------------------------------------------- float VdbSampler_iterator_computeSample_varying( - const Sampler *uniform _sampler, + const SamplerShared *uniform _sampler, const varying vec3f &objectCoordinates, const uniform uint32 attributeIndex, const varying float &time) { - const VdbSampler *uniform sampler = (const VdbSampler *uniform)_sampler; + const VdbSamplerShared *uniform sampler = + (const VdbSamplerShared *uniform)_sampler; assert(sampler); assert(sampler->grid); @@ -342,14 +352,14 @@ float VdbSampler_iterator_computeSample_varying( float sample = 0.f; if (sampler->grid->dense) { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, sample = VdbSampler_interpolate_dense, sampler, indexCoordinates, time, attributeIndex); } else { - __vkl_switch_filter(sampler->super.filter, + __vkl_switch_filter(sampler->super.super.filter, sample = VdbSampler_interpolate, sampler, indexCoordinates, @@ -486,8 +496,8 @@ export void EXPORT_UNIQUE(VdbSampler_computeValueRange, range->lower = pos_inf; range->upper = neg_inf; - uniform VdbSampler sampler; - memset(&sampler, 0, sizeof(uniform VdbSampler)); + uniform VdbSamplerShared sampler; + memset(&sampler, 0, sizeof(uniform VdbSamplerShared)); sampler.grid = (const VdbGrid *uniform)_grid; sampler.maxSamplingDepth = VKL_VDB_NUM_LEVELS - 1; @@ -547,24 +557,23 @@ export void EXPORT_UNIQUE(VdbSampler_computeValueRange, // Construction. // ----------------------------------------------------------------------------- -export void *uniform -EXPORT_UNIQUE(VdbSampler_create, - const void *uniform _volume, - const void *uniform leafAccessObservers) +export void EXPORT_UNIQUE(VdbSampler_create, + const void *uniform _volume, + const void *uniform leafAccessObservers, + void *uniform _sampler) { - VdbSampler *uniform sampler = uniform new VdbSampler; - memset(sampler, 0, sizeof(uniform VdbSampler)); + VdbSamplerShared *uniform sampler = (VdbSamplerShared * uniform) _sampler; + memset(sampler, 0, sizeof(uniform VdbSamplerShared)); // Generic sampler interface - this is used by iterators. const VdbVolume *uniform volume = (const VdbVolume *uniform)_volume; - sampler->super.volume = &volume->super; + sampler->super.super.volume = &volume->super; // Our internal sampling interface. The sampler object is passed into the // inner loop. const VdbVolume *uniform vdbVolume = (const VdbVolume *uniform)volume; sampler->grid = volume->grid; sampler->leafAccessObservers = leafAccessObservers; - return sampler; } export void EXPORT_UNIQUE(VdbSampler_set, @@ -573,11 +582,11 @@ export void EXPORT_UNIQUE(VdbSampler_set, uniform VKLFilter gradientFilter, uniform vkl_uint32 maxSamplingDepth) { - VdbSampler *uniform sampler = (VdbSampler * uniform) _sampler; + VdbSamplerShared *uniform sampler = (VdbSamplerShared * uniform) _sampler; CALL_ISPC(Sampler_setFilters, &sampler->super, filter, gradientFilter); // For hit iterators. - sampler->super.computeSample_varying = + sampler->super.super.computeSample_varying = VdbSampler_iterator_computeSample_varying; sampler->maxSamplingDepth = maxSamplingDepth; @@ -620,7 +629,7 @@ export void EXPORT_UNIQUE(VdbSampler_set, export void EXPORT_UNIQUE(VdbSampler_destroy, void *uniform _sampler) { - VdbSampler *uniform sampler = (VdbSampler * uniform) _sampler; + VdbSamplerShared *uniform sampler = (VdbSamplerShared * uniform) _sampler; if (sampler->denseLeafSample_varying) { delete[] sampler->denseLeafSample_varying; @@ -629,6 +638,4 @@ export void EXPORT_UNIQUE(VdbSampler_destroy, void *uniform _sampler) if (sampler->denseLeafSample_uniform) { delete[] sampler->denseLeafSample_uniform; } - - delete sampler; } diff --git a/openvkl/devices/cpu/volume/vdb/VdbSamplerDispatchInner.ih.in b/openvkl/devices/cpu/volume/vdb/VdbSamplerDispatchInner.ih.in index 8cc24a6c..65ba8f1c 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSamplerDispatchInner.ih.in +++ b/openvkl/devices/cpu/volume/vdb/VdbSamplerDispatchInner.ih.in @@ -32,10 +32,10 @@ * into varying traversal. */ inline void VdbSampler_dispatchInner_uniform_uniform_@VKL_VDB_LEVEL@( - const VdbSampler *uniform sampler, - const uniform uint64 nodeIndex, - const uniform vec3ui &domainOffset, - uniform uint64 &voxel) + const VdbSamplerShared *uniform sampler, + const uniform uint64 nodeIndex, + const uniform vec3ui &domainOffset, + uniform uint64 &voxel) { assert(nodeIndex < sampler->grid->levels[@VKL_VDB_LEVEL@].numNodes); const uniform uint64 voxelIdx = @@ -53,10 +53,10 @@ inline void VdbSampler_dispatchInner_uniform_uniform_@VKL_VDB_LEVEL@( } inline void VdbSampler_dispatchInner_uniform_varying_@VKL_VDB_LEVEL@( - const VdbSampler *uniform sampler, - const uniform uint64 nodeIndex, - const varying vec3ui &domainOffset, - varying uint64 &voxel) + const VdbSamplerShared *uniform sampler, + const uniform uint64 nodeIndex, + const varying vec3ui &domainOffset, + varying uint64 &voxel) { assert(nodeIndex < sampler->grid->levels[@VKL_VDB_LEVEL@].numNodes); const varying uint64 voxelIdx = @@ -92,10 +92,10 @@ inline void VdbSampler_dispatchInner_uniform_varying_@VKL_VDB_LEVEL@( * as well skip the test above. */ inline void VdbSampler_dispatchInner_varying_varying_@VKL_VDB_LEVEL@( - const VdbSampler *uniform sampler, - const varying uint64 nodeIndex, - const varying vec3ui &domainOffset, - varying uint64 &voxel) + const VdbSamplerShared *uniform sampler, + const varying uint64 nodeIndex, + const varying vec3ui &domainOffset, + varying uint64 &voxel) { assert(nodeIndex < sampler->grid->levels[@VKL_VDB_LEVEL@].numNodes); const varying uint64 voxelIdx = diff --git a/openvkl/devices/cpu/volume/vdb/VdbSamplerShared.h b/openvkl/devices/cpu/volume/vdb/VdbSamplerShared.h new file mode 100644 index 00000000..558c94df --- /dev/null +++ b/openvkl/devices/cpu/volume/vdb/VdbSamplerShared.h @@ -0,0 +1,52 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "VdbGrid.h" + +#include "openvkl/ispc_cpp_interop.h" + +#include "../../sampler/SamplerShared.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + +#ifdef __cplusplus + typedef void *DenseLeafSamplingVaryingFunc; + + typedef void *DenseLeafSamplingUniformFunc; +#else +typedef varying float (*uniform DenseLeafSamplingVaryingFunc)( + const VdbGrid *uniform grid, + uniform uint32 attributeIndex, + const varying vec3ui &offset, + const varying float &time); + +typedef uniform float (*uniform DenseLeafSamplingUniformFunc)( + const VdbGrid *uniform grid, + uniform uint32 attributeIndex, + const uniform vec3ui &offset, + uniform float time); +#endif + +#ifndef __ISPC_STRUCT_VdbSamplerShared__ +#define __ISPC_STRUCT_VdbSamplerShared__ + + struct VdbSamplerShared + { + SamplerBaseShared super; + + const VdbGrid *VKL_INTEROP_UNIFORM grid; + const void *VKL_INTEROP_UNIFORM leafAccessObservers; + vkl_uint32 maxSamplingDepth; + + DenseLeafSamplingVaryingFunc *VKL_INTEROP_UNIFORM denseLeafSample_varying; + DenseLeafSamplingUniformFunc *VKL_INTEROP_UNIFORM denseLeafSample_uniform; + }; + +#endif +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler_nearest.ih b/openvkl/devices/cpu/volume/vdb/VdbSampler_nearest.ih index ee88c8f3..82222cfe 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler_nearest.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler_nearest.ih @@ -13,7 +13,7 @@ // for vertex-centered data, we need to offset the index coordinate by one half // voxel for correct results. inline uniform float VdbSampler_getNearestIndexOffset( - const VdbSampler *uniform sampler) + const VdbSamplerShared *uniform sampler) { return sampler->grid->constantCellData ? 0.f : 0.5f; } @@ -22,7 +22,8 @@ inline uniform float VdbSampler_getNearestIndexOffset( * Nearest neighbor interpolation is the fastest version, but also gives * blocky results. This should be good for indirect light etc. */ -inline float VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, +inline float VdbSampler_interpolateNearest(const VdbSamplerShared *uniform + sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -39,7 +40,7 @@ inline float VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, } inline float VdbSampler_interpolate_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -55,13 +56,13 @@ inline float VdbSampler_interpolate_denseNearest( return VdbSampler_traverseAndSample_dense(sampler, ic, time, attributeIndex); } -inline void VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, - const vec3f &indexCoordinates, - const float &time, - const uniform uint32 M, - const uint32 *uniform - attributeIndices, - float *uniform samples) +inline void VdbSampler_interpolateNearest( + const VdbSamplerShared *uniform sampler, + const vec3f &indexCoordinates, + const float &time, + const uniform uint32 M, + const uint32 *uniform attributeIndices, + float *uniform samples) { assert(!sampler->grid->dense); @@ -84,7 +85,7 @@ inline void VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 M, @@ -108,7 +109,7 @@ inline void VdbSampler_interpolate_denseNearest( } inline uniform float VdbSampler_interpolateNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 attributeIndex) @@ -125,7 +126,7 @@ inline uniform float VdbSampler_interpolateNearest( } inline uniform float VdbSampler_interpolate_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 attributeIndex) @@ -141,13 +142,13 @@ inline uniform float VdbSampler_interpolate_denseNearest( return VdbSampler_traverseAndSample_dense(sampler, ic, time, attributeIndex); } -inline void VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, - const uniform vec3f &indexCoordinates, - const uniform float time, - const uniform uint32 M, - const uint32 *uniform - attributeIndices, - float *uniform samples) +inline void VdbSampler_interpolateNearest( + const VdbSamplerShared *uniform sampler, + const uniform vec3f &indexCoordinates, + const uniform float time, + const uniform uint32 M, + const uint32 *uniform attributeIndices, + float *uniform samples) { assert(!sampler->grid->dense); @@ -168,7 +169,7 @@ inline void VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 M, @@ -189,13 +190,13 @@ inline void VdbSampler_interpolate_denseNearest( } } -inline void VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, - const uniform unsigned int N, - const vec3f *uniform - objectCoordinates, - const float *uniform times, - const uint32 uniform attributeIndex, - float *uniform samples) +inline void VdbSampler_interpolateNearest( + const VdbSamplerShared *uniform sampler, + const uniform unsigned int N, + const vec3f *uniform objectCoordinates, + const float *uniform times, + const uint32 uniform attributeIndex, + float *uniform samples) { assert(!sampler->grid->dense); @@ -215,7 +216,7 @@ inline void VdbSampler_interpolateNearest(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -240,7 +241,7 @@ inline void VdbSampler_interpolate_denseNearest( } inline void VdbSampler_interpolateNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -275,7 +276,7 @@ inline void VdbSampler_interpolateNearest( } inline void VdbSampler_interpolate_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -310,7 +311,7 @@ inline void VdbSampler_interpolate_denseNearest( * say everywhere...) */ inline vec3f VdbSampler_computeGradientNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -321,7 +322,7 @@ inline vec3f VdbSampler_computeGradientNearest( } inline vec3f VdbSampler_computeGradient_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -332,7 +333,7 @@ inline vec3f VdbSampler_computeGradient_denseNearest( } inline void VdbSampler_computeGradientNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -347,7 +348,7 @@ inline void VdbSampler_computeGradientNearest( } inline void VdbSampler_computeGradient_denseNearest( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler_traverseAndSample.ih b/openvkl/devices/cpu/volume/vdb/VdbSampler_traverseAndSample.ih index c611d9a4..40e17988 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler_traverseAndSample.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler_traverseAndSample.ih @@ -5,7 +5,7 @@ #include "VdbGrid.h" #include "VdbLeafAccessObserver.ih" -#include "VdbSampler.ih" +#include "VdbSamplerShared.h" #include "VdbSampler_denseHandler.ih" #include "VdbSampler_leafHandler.ih" #include "VdbSampler_packedHandler.ih" @@ -82,7 +82,7 @@ inline bool VdbSampler_isInDomain(const uniform vec3ui &activeSize, // --------------------------------------------------------------------------- // Uniform traversal. -noinline void VdbSampler_traverse(const VdbSampler *uniform sampler, +noinline void VdbSampler_traverse(const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, uniform uint64 &voxel, uniform vec3ui &domainOffset) @@ -102,7 +102,7 @@ noinline void VdbSampler_traverse(const VdbSampler *uniform sampler, } // Varying traversal. -noinline void VdbSampler_traverse(const VdbSampler *uniform sampler, +noinline void VdbSampler_traverse(const VdbSamplerShared *uniform sampler, const vec3i &ic, uint64 &voxel, vec3ui &domainOffset) @@ -143,7 +143,7 @@ noinline void VdbSampler_traverse(const VdbSampler *uniform sampler, // varying voxels at uniform / varying offsets, and are used just below. #define template_VdbSampler_sample_inner(univaryVoxel, univaryOffset) \ inline univaryOffset float VdbSampler_sample_inner( \ - const VdbSampler *uniform sampler, \ + const VdbSamplerShared *uniform sampler, \ const univaryVoxel uint64 &voxel, \ const univaryOffset vec3ui &domainOffset, \ const univaryOffset float &time, \ @@ -191,7 +191,7 @@ noinline void VdbSampler_traverse(const VdbSampler *uniform sampler, .valueRange[voxelOffset * grid->numAttributes + attributeIndex]; \ sample = 0.5f * (valueRange.lower + valueRange.upper); \ } else if (!VdbSampler_isInDomain(grid->activeSize, domainOffset)) { \ - sample = sampler->super.volume->background[attributeIndex]; \ + sample = sampler->super.super.volume->background[attributeIndex]; \ } \ return sample; \ } @@ -205,7 +205,7 @@ template_VdbSampler_sample_inner(uniform, uniform); // Note: This function may seem unnecessary in the uniform path. However, // keeping this thin wrapper ensures that downstream code is as uniform as // possible. -noinline uniform float VdbSampler_sample(const VdbSampler *uniform sampler, +noinline uniform float VdbSampler_sample(const VdbSamplerShared *uniform sampler, const uniform uint64 voxel, const uniform vec3ui &domainOffset, const uniform float time, @@ -218,7 +218,7 @@ noinline uniform float VdbSampler_sample(const VdbSampler *uniform sampler, } // Varying sampling. -noinline float VdbSampler_sample(const VdbSampler *uniform sampler, +noinline float VdbSampler_sample(const VdbSamplerShared *uniform sampler, const uint64 &voxel, const vec3ui &domainOffset, const float &time, @@ -244,7 +244,7 @@ noinline float VdbSampler_sample(const VdbSampler *uniform sampler, // --------------------------------------------------------------------------- noinline uniform float VdbSampler_traverseAndSample( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, const uniform float time, const uniform uint32 attributeIndex) @@ -265,7 +265,7 @@ noinline uniform float VdbSampler_traverseAndSample( sampler, voxelU, domainOffset, time, attributeIndex); } - return sampler->super.volume->background[attributeIndex]; + return sampler->super.super.volume->background[attributeIndex]; } inline uniform bool reduce_equal(const vec3ui &v, vec3ui *uniform uv) @@ -274,7 +274,7 @@ inline uniform bool reduce_equal(const vec3ui &v, vec3ui *uniform uv) reduce_equal(v.z, &(uv->z)); } -noinline float VdbSampler_traverseAndSample(const VdbSampler *uniform sampler, +noinline float VdbSampler_traverseAndSample(const VdbSamplerShared *uniform sampler, const vec3i &ic, const float &time, const uniform uint32 attributeIndex) @@ -305,13 +305,13 @@ noinline float VdbSampler_traverseAndSample(const VdbSampler *uniform sampler, sampler, voxel, domainOffset, time, attributeIndex); } } - return sampler->super.volume->background[attributeIndex]; + return sampler->super.super.volume->background[attributeIndex]; } // Specialized versions of the above, for dense volumes. inline uniform float VdbSampler_traverseAndSample_dense( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, const uniform float time, const uniform uint32 attributeIndex) @@ -326,11 +326,11 @@ inline uniform float VdbSampler_traverseAndSample_dense( return sampler->denseLeafSample_uniform[attributeIndex]( sampler->grid, attributeIndex, domainOffset, time); } - return sampler->super.volume->background[attributeIndex]; + return sampler->super.super.volume->background[attributeIndex]; } inline float VdbSampler_traverseAndSample_dense( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, const float &time, const uniform uint32 attributeIndex) @@ -345,5 +345,5 @@ inline float VdbSampler_traverseAndSample_dense( return sampler->denseLeafSample_varying[attributeIndex]( sampler->grid, attributeIndex, domainOffset, time); } - return sampler->super.volume->background[attributeIndex]; + return sampler->super.super.volume->background[attributeIndex]; } diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler_tricubic.ih b/openvkl/devices/cpu/volume/vdb/VdbSampler_tricubic.ih index e8556d8f..e6335a54 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler_tricubic.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler_tricubic.ih @@ -579,11 +579,11 @@ inline vec3f VdbSampler_tricubicPolynomialGradient( // Note: These wrappers are necessary for two reasons; They help clean up the // code below, and also help avoid nested foreach errors! -inline void VdbSampler_traverseVoxelValuesTricubic(const VdbSampler *uniform - sampler, - const uniform vec3i &ic, - uint64 *uniform voxel, - vec3ui *uniform domainOffset) +inline void VdbSampler_traverseVoxelValuesTricubic( + const VdbSamplerShared *uniform sampler, + const uniform vec3i &ic, + uint64 *uniform voxel, + vec3ui *uniform domainOffset) { assert(!sampler->grid->dense); @@ -598,11 +598,11 @@ inline void VdbSampler_traverseVoxelValuesTricubic(const VdbSampler *uniform }); } -inline void VdbSampler_traverseVoxelValuesTricubic(const VdbSampler *uniform - sampler, - const vec3i &ic, - uint64 *uniform voxel, - vec3ui *uniform domainOffset) +inline void VdbSampler_traverseVoxelValuesTricubic( + const VdbSamplerShared *uniform sampler, + const vec3i &ic, + uint64 *uniform voxel, + vec3ui *uniform domainOffset) { assert(!sampler->grid->dense); @@ -618,7 +618,7 @@ inline void VdbSampler_traverseVoxelValuesTricubic(const VdbSampler *uniform } inline void VdbSampler_computeVoxelValuesTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, const uint64 *uniform voxel, const vec3ui *uniform domainOffset, @@ -637,7 +637,7 @@ inline void VdbSampler_computeVoxelValuesTricubic( } inline void VdbSampler_computeVoxelValuesTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, const uint64 *uniform voxel, const vec3ui *uniform domainOffset, @@ -656,7 +656,7 @@ inline void VdbSampler_computeVoxelValuesTricubic( } inline void VdbSampler_computeVoxelValuesTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, const uniform float time, const uniform uint32 attributeIndex, @@ -671,7 +671,7 @@ inline void VdbSampler_computeVoxelValuesTricubic( } inline void VdbSampler_computeVoxelValuesTricubic_dense( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, const uniform float time, const uniform uint32 attributeIndex, @@ -686,7 +686,7 @@ inline void VdbSampler_computeVoxelValuesTricubic_dense( } inline void VdbSampler_computeVoxelValuesTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, const float &time, const uniform uint32 attributeIndex, @@ -701,7 +701,7 @@ inline void VdbSampler_computeVoxelValuesTricubic( } inline void VdbSampler_computeVoxelValuesTricubic_dense( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, const float &time, const uniform uint32 attributeIndex, @@ -717,7 +717,7 @@ inline void VdbSampler_computeVoxelValuesTricubic_dense( // Single attribute uniform. inline uniform float VdbSampler_interpolateTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 attributeIndex) @@ -742,7 +742,7 @@ inline uniform float VdbSampler_interpolateTricubic( } inline uniform float VdbSampler_interpolate_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 attributeIndex) @@ -767,7 +767,8 @@ inline uniform float VdbSampler_interpolate_denseTricubic( } // Single attribute varying. -inline float VdbSampler_interpolateTricubic(const VdbSampler *uniform sampler, +inline float VdbSampler_interpolateTricubic(const VdbSamplerShared *uniform + sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -793,7 +794,7 @@ inline float VdbSampler_interpolateTricubic(const VdbSampler *uniform sampler, } inline float VdbSampler_interpolate_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -819,13 +820,13 @@ inline float VdbSampler_interpolate_denseTricubic( } // Single attribute stream. -inline void VdbSampler_interpolateTricubic(const VdbSampler *uniform sampler, - const uniform unsigned int N, - const vec3f *uniform - objectCoordinates, - const float *uniform times, - const uint32 uniform attributeIndex, - float *uniform samples) +inline void VdbSampler_interpolateTricubic( + const VdbSamplerShared *uniform sampler, + const uniform unsigned int N, + const vec3f *uniform objectCoordinates, + const float *uniform times, + const uint32 uniform attributeIndex, + float *uniform samples) { assert(!sampler->grid->dense); @@ -839,7 +840,7 @@ inline void VdbSampler_interpolateTricubic(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -859,7 +860,7 @@ inline void VdbSampler_interpolate_denseTricubic( // Multi attribute uniform. inline void VdbSampler_interpolateTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 M, @@ -895,7 +896,7 @@ inline void VdbSampler_interpolateTricubic( } inline void VdbSampler_interpolate_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 M, @@ -927,13 +928,13 @@ inline void VdbSampler_interpolate_denseTricubic( } // Multi attribute varying. -inline void VdbSampler_interpolateTricubic(const VdbSampler *uniform sampler, - const vec3f &indexCoordinates, - const float &time, - const uniform uint32 M, - const uint32 *uniform - attributeIndices, - float *uniform samples) +inline void VdbSampler_interpolateTricubic( + const VdbSamplerShared *uniform sampler, + const vec3f &indexCoordinates, + const float &time, + const uniform uint32 M, + const uint32 *uniform attributeIndices, + float *uniform samples) { assert(!sampler->grid->dense); @@ -964,7 +965,7 @@ inline void VdbSampler_interpolateTricubic(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 M, @@ -997,7 +998,7 @@ inline void VdbSampler_interpolate_denseTricubic( // Multi attribute stream. inline void VdbSampler_interpolateTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -1038,7 +1039,7 @@ inline void VdbSampler_interpolateTricubic( } inline void VdbSampler_interpolate_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -1076,7 +1077,7 @@ inline void VdbSampler_interpolate_denseTricubic( // Gradient varying. inline vec3f VdbSampler_computeGradientTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -1102,7 +1103,7 @@ inline vec3f VdbSampler_computeGradientTricubic( } inline vec3f VdbSampler_computeGradient_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -1129,7 +1130,7 @@ inline vec3f VdbSampler_computeGradient_denseTricubic( // Gradient stream. inline void VdbSampler_computeGradientTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -1150,7 +1151,7 @@ inline void VdbSampler_computeGradientTricubic( } inline void VdbSampler_computeGradient_denseTricubic( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, diff --git a/openvkl/devices/cpu/volume/vdb/VdbSampler_trilinear.ih b/openvkl/devices/cpu/volume/vdb/VdbSampler_trilinear.ih index 2499c89d..db256013 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbSampler_trilinear.ih +++ b/openvkl/devices/cpu/volume/vdb/VdbSampler_trilinear.ih @@ -31,7 +31,7 @@ * This is used for both sampling and gradient computation! */ inline void VdbSampler_computeVoxelValuesTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, const float &time, const uniform uint32 attributeIndex, @@ -177,7 +177,7 @@ template_computeVoxelValuesTrilinear_dense_fast_inner_32(double); #undef template_computeVoxelValuesTrilinear_dense_fast_inner_32 inline void VdbSampler_computeVoxelValuesTrilinear_dense( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, const float &time, const uniform uint32 attributeIndex, @@ -239,7 +239,7 @@ inline void VdbSampler_computeVoxelValuesTrilinear_dense( } inline void VdbSampler_computeVoxelValuesTrilinear_dense( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3i &ic, const uniform float time, const uniform uint32 attributeIndex, @@ -304,7 +304,7 @@ inline void VdbSampler_computeVoxelValuesTrilinear_dense( * Traverse for the eight corners required in trilinear interpolation. */ inline void VdbSampler_traverseVoxelValuesTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3i &ic, uint64 *uniform voxel, // Array of VKL_TARGET_WIDTH * 8 elements! vec3ui *uniform domainOffset) // Array of VKL_TARGET_WIDTH * 8 elements! @@ -327,7 +327,7 @@ inline void VdbSampler_traverseVoxelValuesTrilinear( * interpolation for given pre-traversed voxel and domain offset. */ inline void VdbSampler_computeVoxelValuesTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uint64 *uniform voxel, // Array of VKL_TARGET_WIDTH * 8 elements! const vec3ui *uniform domainOffset, // Array of VKL_TARGET_WIDTH * 8 elements! @@ -353,7 +353,7 @@ inline void VdbSampler_computeVoxelValuesTrilinear( * The implementation is optimized to exploit SIMD. */ inline varying float VdbSampler_interpolateTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -376,7 +376,7 @@ inline varying float VdbSampler_interpolateTrilinear( } inline varying float VdbSampler_interpolate_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -398,13 +398,13 @@ inline varying float VdbSampler_interpolate_denseTrilinear( lerp(delta.y, lerp(delta.z, s[4], s[5]), lerp(delta.z, s[6], s[7]))); } -inline void VdbSampler_interpolateTrilinear(const VdbSampler *uniform sampler, - const vec3f &indexCoordinates, - const float &time, - const uniform uint32 M, - const uint32 *uniform - attributeIndices, - float *uniform samples) +inline void VdbSampler_interpolateTrilinear( + const VdbSamplerShared *uniform sampler, + const vec3f &indexCoordinates, + const float &time, + const uniform uint32 M, + const uint32 *uniform attributeIndices, + float *uniform samples) { assert(!sampler->grid->dense); @@ -433,7 +433,7 @@ inline void VdbSampler_interpolateTrilinear(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 M, @@ -467,7 +467,7 @@ inline void VdbSampler_interpolate_denseTrilinear( * above if we know that there is only one query. */ inline uniform float VdbSampler_interpolateTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 attributeIndex) @@ -496,7 +496,7 @@ inline uniform float VdbSampler_interpolateTrilinear( } inline uniform float VdbSampler_interpolate_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 attributeIndex) @@ -522,7 +522,7 @@ inline uniform float VdbSampler_interpolate_denseTrilinear( } inline void VdbSampler_interpolateTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 M, @@ -569,7 +569,7 @@ inline void VdbSampler_interpolateTrilinear( } inline void VdbSampler_interpolate_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform vec3f &indexCoordinates, const uniform float time, const uniform uint32 M, @@ -598,13 +598,13 @@ inline void VdbSampler_interpolate_denseTrilinear( } } -inline void VdbSampler_interpolateTrilinear(const VdbSampler *uniform sampler, - const uniform unsigned int N, - const vec3f *uniform - objectCoordinates, - const float *uniform times, - const uint32 uniform attributeIndex, - float *uniform samples) +inline void VdbSampler_interpolateTrilinear( + const VdbSamplerShared *uniform sampler, + const uniform unsigned int N, + const vec3f *uniform objectCoordinates, + const float *uniform times, + const uint32 uniform attributeIndex, + float *uniform samples) { assert(!sampler->grid->dense); @@ -618,7 +618,7 @@ inline void VdbSampler_interpolateTrilinear(const VdbSampler *uniform sampler, } inline void VdbSampler_interpolate_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -637,7 +637,7 @@ inline void VdbSampler_interpolate_denseTrilinear( } inline void VdbSampler_interpolateTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -678,7 +678,7 @@ inline void VdbSampler_interpolateTrilinear( } inline void VdbSampler_interpolate_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -718,7 +718,7 @@ inline void VdbSampler_interpolate_denseTrilinear( * Gradients in trilinear fields. */ inline vec3f VdbSampler_computeGradientTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -749,7 +749,7 @@ inline vec3f VdbSampler_computeGradientTrilinear( } inline vec3f VdbSampler_computeGradient_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, const vec3f &indexCoordinates, const float &time, const uniform uint32 attributeIndex) @@ -780,7 +780,7 @@ inline vec3f VdbSampler_computeGradient_denseTrilinear( } inline void VdbSampler_computeGradientTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, @@ -801,7 +801,7 @@ inline void VdbSampler_computeGradientTrilinear( } inline void VdbSampler_computeGradient_denseTrilinear( - const VdbSampler *uniform sampler, + const VdbSamplerShared *uniform sampler, uniform unsigned int N, const vec3f *uniform objectCoordinates, const float *uniform times, diff --git a/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp b/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp index e49ed6be..875eb905 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp +++ b/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp @@ -684,7 +684,7 @@ namespace openvkl { "background", grid->numAttributes, VKL_BACKGROUND_UNDEFINED); CALL_ISPC( - Volume_setBackground, this->ispcEquivalent, background->data()); + Volume_setBackground, this->getSh(), background->data()); const uint64_t numLeafDataPointers = grid->numLeaves * static_cast(grid->numAttributes); @@ -1008,11 +1008,11 @@ namespace openvkl { nodeToTileNodeIndex); CALL_ISPC(VdbVolume_setGrid, - this->ispcEquivalent, + this->getSh(), reinterpret_cast(grid)); computeValueRanges( - leafOffsets, *leafLevel, *leafFormat, this->ispcEquivalent, grid); + leafOffsets, *leafLevel, *leafFormat, this->getSh(), grid); // Aggregate value ranges for all attributes valueRanges.clear(); diff --git a/openvkl/devices/cpu/volume/vdb/VdbVolume.h b/openvkl/devices/cpu/volume/vdb/VdbVolume.h index c6537e61..7e8ea52b 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbVolume.h +++ b/openvkl/devices/cpu/volume/vdb/VdbVolume.h @@ -14,6 +14,8 @@ #include "VdbVolume_ispc.h" #include "rkcommon/containers/aligned_allocator.h" #include "rkcommon/memory/RefCount.h" +#include "VdbVolumeShared.h" +#include "openvkl/common/StructShared.h" using namespace rkcommon::memory; @@ -81,7 +83,7 @@ namespace openvkl { /////////////////////////////////////////////////////////////////////////// template - struct VdbVolume : public Volume + struct VdbVolume : public AddStructShared, ispc::VdbVolume> { VdbVolume(const VdbVolume &) = delete; VdbVolume &operator=(const VdbVolume &) = delete; @@ -212,14 +214,16 @@ namespace openvkl { template VdbVolume::VdbVolume() { - this->ispcEquivalent = CALL_ISPC(VdbVolume_create); + CALL_ISPC(VdbVolume_Constructor, this->getSh()); + this->SharedStructInitialized = true; } template VdbVolume::~VdbVolume() { cleanup(); - CALL_ISPC(VdbVolume_destroy, this->ispcEquivalent); + CALL_ISPC(VdbVolume_destroy, this->getSh()); + this->SharedStructInitialized = false; } } // namespace cpu_device diff --git a/openvkl/devices/cpu/volume/vdb/VdbVolume.ih b/openvkl/devices/cpu/volume/vdb/VdbVolume.ih deleted file mode 100644 index 92e8cea1..00000000 --- a/openvkl/devices/cpu/volume/vdb/VdbVolume.ih +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2019 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "../Volume.ih" -#include "VdbGrid.h" - -varying float VdbVolume_sample(const VdbGrid *uniform grid, - const varying vec3i &ic); - -struct VdbVolume -{ - Volume super; - const VdbGrid *uniform grid; -}; diff --git a/openvkl/devices/cpu/volume/vdb/VdbVolume.ispc b/openvkl/devices/cpu/volume/vdb/VdbVolume.ispc index ccdc72da..50720515 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbVolume.ispc +++ b/openvkl/devices/cpu/volume/vdb/VdbVolume.ispc @@ -1,7 +1,7 @@ // Copyright 2019 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "VdbVolume.ih" +#include "VdbVolumeShared.h" #include "common/export_util.h" /* @@ -17,11 +17,10 @@ export void EXPORT_UNIQUE(VdbVolume__declare_types_dummy, /* * Factory for ISPC versions of the volume. */ -export void *uniform EXPORT_UNIQUE(VdbVolume_create) +export void EXPORT_UNIQUE(VdbVolume_Constructor, void *uniform _self) { - VdbVolume *uniform self = uniform new uniform VdbVolume; + uniform VdbVolume *uniform self = (uniform VdbVolume * uniform) _self; memset(self, 0, sizeof(uniform VdbVolume)); - return self; } /* @@ -29,8 +28,6 @@ export void *uniform EXPORT_UNIQUE(VdbVolume_create) */ export void EXPORT_UNIQUE(VdbVolume_destroy, void *uniform _self) { - VdbVolume *uniform volume = (VdbVolume * uniform) _self; - delete volume; } /* diff --git a/openvkl/devices/cpu/volume/vdb/VdbVolumeShared.h b/openvkl/devices/cpu/volume/vdb/VdbVolumeShared.h new file mode 100644 index 00000000..1384ce76 --- /dev/null +++ b/openvkl/devices/cpu/volume/vdb/VdbVolumeShared.h @@ -0,0 +1,26 @@ +// Copyright 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "../VolumeShared.h" + +#include "VdbGrid.h" + +#ifdef __cplusplus +namespace ispc { +#endif // __cplusplus + + VKL_INTEROP_VARYING float VdbVolume_sample( + const VdbGrid *VKL_INTEROP_UNIFORM grid, + const VKL_INTEROP_VARYING vec3i &ic); + + struct VdbVolume + { + VolumeShared super; + const VdbGrid *VKL_INTEROP_UNIFORM grid; + }; + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/openvkl/include/openvkl/ispc_cpp_interop.h b/openvkl/include/openvkl/ispc_cpp_interop.h index 09b89d63..26cdbfb1 100644 --- a/openvkl/include/openvkl/ispc_cpp_interop.h +++ b/openvkl/include/openvkl/ispc_cpp_interop.h @@ -18,7 +18,7 @@ #define VKL_INTEROP_CONSTEXPR #define VKL_INTEROP_UNIFORM uniform - +#define VKL_INTEROP_VARYING varying #else // defined(ISPC) #if defined(__cplusplus) @@ -28,6 +28,7 @@ #endif #define VKL_INTEROP_UNIFORM +#define VKL_INTEROP_VARYING #endif // defined(ISPC) From 4e8e6afbdae8d02bcdc1835dda4d0b37bde91248 Mon Sep 17 00:00:00 2001 From: Krishnan Ramachandran Date: Tue, 2 Aug 2022 13:34:27 +0100 Subject: [PATCH 06/34] Use CMAKE_BUILD_TYPE in the OpenVDB install command --- superbuild/dependencies/dep_openvdb.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/superbuild/dependencies/dep_openvdb.cmake b/superbuild/dependencies/dep_openvdb.cmake index 82b56595..43468985 100644 --- a/superbuild/dependencies/dep_openvdb.cmake +++ b/superbuild/dependencies/dep_openvdb.cmake @@ -19,7 +19,6 @@ endif() set(OPENVKL_EXTRA_OPENVDB_OPTIONS -DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON) mark_as_advanced(OPENVKL_EXTRA_OPENVDB_OPTIONS) - ExternalProject_Add(${COMPONENT_NAME} PREFIX ${COMPONENT_NAME} DOWNLOAD_DIR ${COMPONENT_NAME} @@ -35,7 +34,7 @@ ExternalProject_Add(${COMPONENT_NAME} -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} -DCMAKE_INSTALL_DOCDIR=${CMAKE_INSTALL_DOCDIR} -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DOPENVDB_BUILD_BINARIES:BOOL=OFF -DOPENVDB_BUILD_CORE:BOOL=ON -DOPENVDB_BUILD_DOCS:BOOL=OFF @@ -54,7 +53,7 @@ ExternalProject_Add(${COMPONENT_NAME} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${OPENVKL_EXTRA_OPENVDB_OPTIONS} BUILD_COMMAND ${DEFAULT_BUILD_COMMAND} - INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install + INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE} BUILD_ALWAYS OFF ) From b5191856e8cebe3418527f31050cc0fb7461026c Mon Sep 17 00:00:00 2001 From: Krzysztof Raszkowski Date: Mon, 1 Aug 2022 17:07:57 +0200 Subject: [PATCH 07/34] ci: Remove Ubuntu 16.04 build & testing --- gitlab/.gitlab-ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/gitlab/.gitlab-ci.yml b/gitlab/.gitlab-ci.yml index 64da3384..58b4d732 100644 --- a/gitlab/.gitlab-ci.yml +++ b/gitlab/.gitlab-ci.yml @@ -234,12 +234,6 @@ build-centos8-module-cmake: - docker - modules -build-ubuntu16.04: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu16.04 - script: - - gitlab/build.sh -G Ninja - build-ubuntu18.04: <<: *build_job_docker image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu18.04 @@ -401,12 +395,6 @@ test-functional-centos8-module-cmake: needs: - build-centos8-module-cmake -test-functional-ubuntu16.04: - <<: *test_functional_job_docker_ubuntu - image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu16.04 - needs: - - build-ubuntu16.04 - test-functional-ubuntu18.04: <<: *test_functional_job_docker_ubuntu image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu18.04 From 267d2127552c76536b7deaef0cd9f7632e3aade9 Mon Sep 17 00:00:00 2001 From: Krzysztof Raszkowski Date: Tue, 2 Aug 2022 19:51:08 +0200 Subject: [PATCH 08/34] boost: Disable support for the zstd filters. --- superbuild/dependencies/dep_boost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superbuild/dependencies/dep_boost.cmake b/superbuild/dependencies/dep_boost.cmake index a160ae60..9e94d6a7 100644 --- a/superbuild/dependencies/dep_boost.cmake +++ b/superbuild/dependencies/dep_boost.cmake @@ -34,7 +34,7 @@ ExternalProject_Add(${COMPONENT_NAME} URL_HASH SHA256=${BOOST_HASH} CONFIGURE_COMMAND ${BOOST_CONF} BUILD_COMMAND ${BOOST_BUILD} -d0 --with-system --with-iostreams --with-regex --layout=system - --prefix=${COMPONENT_PATH} variant=release threading=multi address-model=64 + --prefix=${COMPONENT_PATH} variant=release threading=multi address-model=64 -s NO_ZSTD=1 link=${BOOST_LINK} architecture=${BOOST_ARCH} install INSTALL_COMMAND "" BUILD_ALWAYS OFF From b69e26db3c19bc55a65f0c4cdfb9cdb4d7f35efe Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 23 Aug 2022 15:58:15 -0600 Subject: [PATCH 09/34] CI: set Git safe directory for release and scan jobs. --- gitlab/.gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitlab/.gitlab-ci.yml b/gitlab/.gitlab-ci.yml index 58b4d732..e8c864a9 100644 --- a/gitlab/.gitlab-ci.yml +++ b/gitlab/.gitlab-ci.yml @@ -99,6 +99,7 @@ stages: <<: *master_release_devel_only stage: release before_script: + - git config --global --add safe.directory $CI_PROJECT_DIR - git submodule sync - git submodule init - git submodule update @@ -658,6 +659,7 @@ build-kw-scan: script: - gitlab/build-kw-scan.sh before_script: + - git config --global --add safe.directory $CI_PROJECT_DIR - git submodule sync - git submodule init - git submodule update From c30b3239b17a9a3084ba26e9bbcd7da5a5b01c03 Mon Sep 17 00:00:00 2001 From: Krzysztof Raszkowski Date: Thu, 1 Sep 2022 14:53:26 +0000 Subject: [PATCH 10/34] ci: add github actions workflows --- .github/workflows/ci.linux.yml | 483 +++++++++++++++++++++++++++++++ .github/workflows/ci.mac.yml | 84 ++++++ .github/workflows/ci.windows.yml | 52 ++++ .github/workflows/release.yml | 144 +++++++++ 4 files changed, 763 insertions(+) create mode 100644 .github/workflows/ci.linux.yml create mode 100644 .github/workflows/ci.mac.yml create mode 100644 .github/workflows/ci.windows.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.linux.yml b/.github/workflows/ci.linux.yml new file mode 100644 index 00000000..cdc6073f --- /dev/null +++ b/.github/workflows/ci.linux.yml @@ -0,0 +1,483 @@ +## Copyright 2022 Intel Corporation +## SPDX-License-Identifier: Apache-2.0 + +name: CI Linux Workflow +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-centos7: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:7 + artifact-out: build-centos7 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh + + test-centos7: + needs: build-centos7 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos7 + image: centos:7 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-centos7-icc: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:7 + artifact-out: build-centos7-icc + artifact-path: ./build/install ./build/openvkl/build + cmd: | + module load cmake + module load intel/2019.4 + export CC=icc + export CXX=icpc + export CXXFLAGS="-static-intel -fPIC" + gitlab/build.sh + + test-centos7-icc: + needs: build-centos7-icc + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos7-icc + image: centos:7 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-centos7-icc15: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + #ICC 2015 req. old GCC (<7.0?) this is why we're using old docker image + image: ospray/docker-images:centos7-mod + cmd: | + module load cmake + module load intel/2015 + export CC=icc + export CXX=icpc + export CXXFLAGS="-static-intel -fPIC" + gitlab/build.sh + + build-centos7-icx: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:7 + artifact-out: build-centos7-icx + artifact-path: ./build/install ./build/openvkl/build + cmd: | + module load cmake + module load intel/2022.1 + export CC=icx + export CXX=icpx + export CXXFLAGS="-fPIC -fp-model=precise" + export LDFLAGS="-static-intel" + gitlab/build.sh + + test-centos7-icx: + needs: build-centos7-icx + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos7-icx + image: centos:7 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-centos7-icx-tbb2020: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:7 + artifact-out: build-centos7-icx-tbb2020 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + module load cmake + module load intel/2022.1 + export CC=icx + export CXX=icpx + export CXXFLAGS="-fPIC -fp-model=precise" + export LDFLAGS="-static-intel" + gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" + + test-centos7-icx-tbb2020: + needs: build-centos7-icx-tbb2020 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos7-icx-tbb2020 + image: centos:7 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-centos7-icx-tbb2020-avx512_8: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:7 + artifact-out: build-centos7-icx-tbb2020-avx512_8 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + module load cmake + module load intel/2022.1 + export CC=icx + export CXX=icpx + export CXXFLAGS="-fPIC -fp-model=precise" + export LDFLAGS="-static-intel" + gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_ISA_AVX512SKX_8_WIDE=ON -DOPENVKL_ISA_AVX512SKX=OFF" + + test-centos7-icx-tbb2020-avx512_8: + needs: build-centos7-icx-tbb2020-avx512_8 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos7-icx-tbb2020-avx512_8 + image: centos:7 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-centos8: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-centos8 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -G Ninja + + test-centos8: + needs: build-centos8 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos8 + image: centos:8 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + # uses a newer CMake which allows OpenVDB to build + build-centos8-module-cmake: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-centos8-module-cmake + artifact-path: ./build/install ./build/openvkl/build + cmd: | + module load cmake + gitlab/build.sh -G Ninja -D TBB_VERSION=2020.3 -D TBB_HASH="" + + test-centos8-module-cmake: + needs: build-centos8-module-cmake + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos8-module-cmake + image: centos:8 + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-ubuntu18_04: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ubuntu:18.04 + artifact-out: build-ubuntu18_04 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF + + build-ubuntu20_04: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ubuntu:20.04 + artifact-out: build-ubuntu20_04 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF + + build-ubuntu22_04: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ubuntu:22.04 + artifact-out: build-ubuntu22_04 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF + + test-ubuntu18_04: + needs: build-ubuntu18_04 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-ubuntu18_04 + image: ubuntu:18.04 + cmd: | + export LD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + test-ubuntu20_04: + needs: build-ubuntu20_04 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-ubuntu20_04 + image: ubuntu:20.04 + cmd: | + export LD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + test-ubuntu22_04: + needs: build-ubuntu22_04 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-ubuntu22_04 + image: ubuntu:22.04 + cmd: | + export LD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-arch: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-arch + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh + + test-arch: + needs: build-arch + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-arch + image: ospray/docker-images:arch + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-arch-clang: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-arch-clang + artifact-path: ./build/install ./build/openvkl/build + cmd: | + export CC=clang + export CXX=clang++ + gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF + + test-arch-clang: + needs: build-arch-clang + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-arch-clang + image: ospray/docker-images:arch + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-arch-address-sanitizer: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-arch-address-sanitizer + artifact-path: ./build/install ./build/openvkl/build + cmd: | + export CFLAGS=-fsanitize=address + export CXXFLAGS=-fsanitize=address + export LDFLAGS=-fsanitize=address + gitlab/build.sh -D BUILD_GLFW=OFF -D BUILD_OPENVDB=OFF + + test-arch-address-sanitizer: + needs: build-arch-address-sanitizer + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-arch-address-sanitizer + image: ospray/docker-images:arch + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-arch-debug: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-arch-debug + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D CMAKE_BUILD_TYPE=Debug -D BUILD_GLFW=OFF + + test-arch-debug: + needs: build-arch-debug + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-arch-debug + image: ospray/docker-images:arch + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-arch-TBB2020: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-arch-TBB2020 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" + + test-arch-TBB2020: + needs: build-arch-TBB2020 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-arch-TBB2020 + image: ospray/docker-images:arch + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-arch-devel-rkdeps: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-arch-devel-rkdeps + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D RKCOMMON_VERSION=devel -D RKCOMMON_HASH="" -D EMBREE_VERSION=devel -D EMBREE_HASH="" + + test-arch-devel-rkdeps: + needs: build-arch-devel-rkdeps + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-arch-devel-rkdeps + image: ospray/docker-images:arch + cmd: | + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-linux-arch: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: ospray/docker-images:arch + artifact-out: build-linux-arch + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF + + test-linux-arch: + needs: build-linux-arch + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + runs-on: '[ "Linux", "docker", "avx512" ]' + artifact-in: build-linux-arch + image: ospray/docker-images:arch + cmd: | + export LD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-from-install-centos7: + needs: build-centos7 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-centos7 + image: centos:7 + cmd: | + gitlab/build-from-install.sh + + kw-build-scan-report: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/static_analysis.yml@main + with: + project: openvkl + submodules: true + prebuild: | + mkdir build + cd build + export LD_LIBRARY_PATH=`pwd`/install/lib:${LD_LIBRARY_PATH} + cmake -DBUILD_JOBS=`nproc` -DBUILD_DEPENDENCIES_ONLY=ON -DBUILD_GLFW=OFF "$@" ../superbuild + cmake --build . + mkdir openvkl_build + cd openvkl_build + DEP_INSTALL_DIR=`pwd`/../install + export rkcommon_DIR=$DEP_INSTALL_DIR + export embree_DIR=$DEP_INSTALL_DIR + cmake -DISPC_EXECUTABLE=$DEP_INSTALL_DIR/bin/ispc -DBUILD_EXAMPLES=OFF -DRKCOMMON_TBB_ROOT=$DEP_INSTALL_DIR ../.. + build: cmake --build ./build/openvkl_build diff --git a/.github/workflows/ci.mac.yml b/.github/workflows/ci.mac.yml new file mode 100644 index 00000000..29f42f33 --- /dev/null +++ b/.github/workflows/ci.mac.yml @@ -0,0 +1,84 @@ +## Copyright 2022 Intel Corporation +## SPDX-License-Identifier: Apache-2.0 + +name: CI Mac Workflow +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-macOS: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + submodules: true + runs-on: '[ "macOS", "build", "avx2" ]' + artifact-out: build-macOS + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh + + test-macOS: + needs: build-macOS + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + runs-on: '[ "macOS", "build", "avx2" ]' + artifact-in: build-macOS + cmd: | + export DYLD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-macOS-TBB2020: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + submodules: true + runs-on: '[ "macOS", "build", "avx2" ]' + artifact-out: build-macOS-TBB2020 + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" + + test-macOS-TBB2020: + needs: build-macOS-TBB2020 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + runs-on: '[ "macOS", "build", "avx2" ]' + artifact-in: build-macOS-TBB2020 + cmd: | + export DYLD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-macOS-arm: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + submodules: true + runs-on: '[ "macOS", "build", "arm" ]' + artifact-out: build-macOS-arm + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON + + test-macOS-arm: + needs: build-macOS-arm + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + runs-on: '[ "macOS", "build", "arm" ]' + artifact-in: build-macOS-arm + cmd: | + export DYLD_LIBRARY_PATH=./build/install/lib + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes diff --git a/.github/workflows/ci.windows.yml b/.github/workflows/ci.windows.yml new file mode 100644 index 00000000..701c1c6b --- /dev/null +++ b/.github/workflows/ci.windows.yml @@ -0,0 +1,52 @@ +## Copyright 2022 Intel Corporation +## SPDX-License-Identifier: Apache-2.0 + +name: CI Windows Workflow +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-windows-msvc15: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main + with: + submodules: true + runs-on: '[ "Windows", "build" ]' + artifact-out: build-windows-msvc15 + artifact-path: ./build/install + cmd: gitlab\build.bat "Visual Studio 15 2017 Win64" "v141" + + build-windows-msvc15-TBB2020: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main + with: + submodules: true + runs-on: '[ "Windows", "build" ]' + artifact-out: build-windows-msvc15-TBB2020 + artifact-path: ./build/install + cmd: gitlab\build.bat "Visual Studio 15 2017 Win64" "v141" '"-DTBB_VERSION=2020.3"' '"-DTBB_HASH="""' + + test-windows-msvc15: + needs: build-windows-msvc15 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main + with: + runs-on: '[ "Windows", "build" ]' + artifact-in: build-windows-msvc15 + cmd: | + gitlab\run_tests.bat + + test-windows-msvc15-TBB2020: + needs: build-windows-msvc15-TBB2020 + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main + with: + runs-on: '[ "Windows", "build" ]' + artifact-in: build-windows-msvc15-TBB2020 + cmd: | + gitlab\run_tests.bat diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..16bf0d03 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,144 @@ +## Copyright 2022 Intel Corporation +## SPDX-License-Identifier: Apache-2.0 + +name: Release Workflow +on: + push: + branches: + - '*release*' + - 'devel' + - 'master' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + kw-build-scan-report: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/static_analysis.yml@main + with: + project: openvkl + submodules: true + prebuild: | + mkdir build + cd build + export LD_LIBRARY_PATH=`pwd`/install/lib:${LD_LIBRARY_PATH} + cmake -DBUILD_JOBS=`nproc` -DBUILD_DEPENDENCIES_ONLY=ON -DBUILD_GLFW=OFF "$@" ../superbuild + cmake --build . + mkdir openvkl_build + cd openvkl_build + DEP_INSTALL_DIR=`pwd`/../install + export rkcommon_DIR=$DEP_INSTALL_DIR + export embree_DIR=$DEP_INSTALL_DIR + cmake -DISPC_EXECUTABLE=$DEP_INSTALL_DIR/bin/ispc -DBUILD_EXAMPLES=OFF -DRKCOMMON_TBB_ROOT=$DEP_INSTALL_DIR ../.. + build: cmake --build ./build/openvkl_build + + + release-linux: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + runs-on: '[ "Linux", "docker" ]' + image: centos:7 + artifact-out: release-linux + artifact-path: ./*.gz + cmd: | + export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + module load cmake + module load intel/2022.1 + export CC=icx + export CXX=icpx + export CXXFLAGS="-fPIC -fp-model=precise" + export LDFLAGS="-static-intel" + gitlab/release/linux.sh + + release-windows: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main + with: + submodules: true + runs-on: '[ "Windows", "NAS", "build" ]' + artifact-out: release-windows + artifact-path: ./*.zip + cmd: | + $env:OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + $OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + gitlab/release/windows.ps1 "Visual Studio 15 2017 Win64" "v141" + + release-macos: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + submodules: true + runs-on: '[ "macOS", "sign", "avx2" ]' + artifact-out: release-macos + artifact-path: ./*.zip + cmd: | + export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + gitlab/release/macos.sh + + release-linux-test: + needs: release-linux + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + runs-on: '[ "Linux", "docker" ]' + image: centos:7 + artifact-in: release-linux + cmd: | + export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + gitlab/release/linux-test.sh + + release-windows-test: + needs: release-windows + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main + with: + runs-on: '[ "Windows" ]' + artifact-in: release-windows + cmd: | + $env:OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + $OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + gitlab/release/windows-test.ps1 "Visual Studio 15 2017 Win64" "v141" + + release-macos-test: + needs: release-macos + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + runs-on: '[ "macOS", "avx2" ]' + artifact-in: release-macos + cmd: | + export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + gitlab/release/macos-test.sh + + binary-analysis: + needs: + - release-linux + - release-macos + - release-windows + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/binary_analysis.yml@main + with: + project: openvkl + artifact-in-linux: release-linux + artifact-in-macos: release-macos + artifact-in-windows: release-windows + path: "*.zip *.gz" + + antivirus-scan: + needs: + - release-linux + - release-macos + - release-windows + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/antivirus_scan.yml@main + with: + project: openvkl + artifact-in-linux: release-linux + artifact-in-macos: release-macos + artifact-in-windows: release-windows + path: "*.zip *.gz" From 5e8103ac8cdb44eb25099df6004e8fe194d88087 Mon Sep 17 00:00:00 2001 From: Trevor Thomson Date: Tue, 11 Oct 2022 09:26:29 -0400 Subject: [PATCH 11/34] CI: Update macos runs-on tags --- .github/workflows/ci.mac.yml | 8 ++++---- .github/workflows/release.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.mac.yml b/.github/workflows/ci.mac.yml index 29f42f33..f7f3972e 100644 --- a/.github/workflows/ci.mac.yml +++ b/.github/workflows/ci.mac.yml @@ -16,7 +16,7 @@ jobs: uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: submodules: true - runs-on: '[ "macOS", "build", "avx2" ]' + runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' artifact-out: build-macOS artifact-path: ./build/install ./build/openvkl/build cmd: | @@ -27,7 +27,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: - runs-on: '[ "macOS", "build", "avx2" ]' + runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' artifact-in: build-macOS cmd: | export DYLD_LIBRARY_PATH=./build/install/lib @@ -40,7 +40,7 @@ jobs: uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: submodules: true - runs-on: '[ "macOS", "build", "avx2" ]' + runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' artifact-out: build-macOS-TBB2020 artifact-path: ./build/install ./build/openvkl/build cmd: | @@ -51,7 +51,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: - runs-on: '[ "macOS", "build", "avx2" ]' + runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' artifact-in: build-macOS-TBB2020 cmd: | export DYLD_LIBRARY_PATH=./build/install/lib diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16bf0d03..ff072886 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,7 +73,7 @@ jobs: uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: submodules: true - runs-on: '[ "macOS", "sign", "avx2" ]' + runs-on: '[ "macOS", "sign", "avx2", "x86_64" ]' artifact-out: release-macos artifact-path: ./*.zip cmd: | @@ -109,7 +109,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: - runs-on: '[ "macOS", "avx2" ]' + runs-on: '[ "macOS", "avx2", "x86_64" ]' artifact-in: release-macos cmd: | export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" From 26a0ccc1ebd9ec8ab060fd92bc80611b018bee70 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Wed, 12 Oct 2022 09:31:59 -0600 Subject: [PATCH 12/34] CI: fix Klocwork job. --- .github/workflows/ci.linux.yml | 1 + .github/workflows/release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/ci.linux.yml b/.github/workflows/ci.linux.yml index cdc6073f..c53feb1e 100644 --- a/.github/workflows/ci.linux.yml +++ b/.github/workflows/ci.linux.yml @@ -480,4 +480,5 @@ jobs: export rkcommon_DIR=$DEP_INSTALL_DIR export embree_DIR=$DEP_INSTALL_DIR cmake -DISPC_EXECUTABLE=$DEP_INSTALL_DIR/bin/ispc -DBUILD_EXAMPLES=OFF -DRKCOMMON_TBB_ROOT=$DEP_INSTALL_DIR ../.. + cd ../.. build: cmake --build ./build/openvkl_build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff072886..bcc2653b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,7 @@ jobs: export rkcommon_DIR=$DEP_INSTALL_DIR export embree_DIR=$DEP_INSTALL_DIR cmake -DISPC_EXECUTABLE=$DEP_INSTALL_DIR/bin/ispc -DBUILD_EXAMPLES=OFF -DRKCOMMON_TBB_ROOT=$DEP_INSTALL_DIR ../.. + cd ../.. build: cmake --build ./build/openvkl_build From dc15bd8e6107bdae222dfaa43b37ae183dfd1dee Mon Sep 17 00:00:00 2001 From: Krzysztof Raszkowski Date: Mon, 17 Oct 2022 22:19:35 +0200 Subject: [PATCH 13/34] Move ISPC Volume_setBackground function to scalar VolumeShared --- openvkl/devices/cpu/CMakeLists.txt | 1 - openvkl/devices/cpu/iterator/DefaultIterator.ispc | 1 - openvkl/devices/cpu/sampler/Sampler.ih | 1 - .../devices/cpu/volume/SharedStructuredVolume.ih | 1 - .../devices/cpu/volume/StructuredRegularVolume.cpp | 3 +-- openvkl/devices/cpu/volume/StructuredSampler.h | 1 - .../cpu/volume/StructuredSphericalVolume.cpp | 3 +-- openvkl/devices/cpu/volume/UnstructuredSampler.h | 1 - openvkl/devices/cpu/volume/UnstructuredVolume.cpp | 3 +-- openvkl/devices/cpu/volume/UnstructuredVolume.ih | 1 - openvkl/devices/cpu/volume/Volume.h | 12 +++++++++--- openvkl/devices/cpu/volume/Volume.ih | 12 ------------ openvkl/devices/cpu/volume/Volume.ispc | 13 ------------- openvkl/devices/cpu/volume/amr/AMRSampler.h | 1 - openvkl/devices/cpu/volume/amr/AMRVolume.cpp | 5 ++--- .../devices/cpu/volume/particle/ParticleSampler.h | 1 - .../devices/cpu/volume/particle/ParticleVolume.cpp | 2 +- openvkl/devices/cpu/volume/vdb/VdbVolume.cpp | 3 +-- 18 files changed, 16 insertions(+), 49 deletions(-) delete mode 100644 openvkl/devices/cpu/volume/Volume.ih delete mode 100644 openvkl/devices/cpu/volume/Volume.ispc diff --git a/openvkl/devices/cpu/CMakeLists.txt b/openvkl/devices/cpu/CMakeLists.txt index 3fb36e0b..db9627da 100644 --- a/openvkl/devices/cpu/CMakeLists.txt +++ b/openvkl/devices/cpu/CMakeLists.txt @@ -69,7 +69,6 @@ foreach(TARGET_WIDTH 4 8 16) volume/StructuredSphericalVolume.cpp volume/UnstructuredVolume.cpp volume/UnstructuredVolume.ispc - volume/Volume.ispc volume/vdb/VdbVolume.cpp volume/vdb/VdbVolume.ispc volume/vdb/VdbSampler.cpp diff --git a/openvkl/devices/cpu/iterator/DefaultIterator.ispc b/openvkl/devices/cpu/iterator/DefaultIterator.ispc index 49dad3b8..29a3c713 100644 --- a/openvkl/devices/cpu/iterator/DefaultIterator.ispc +++ b/openvkl/devices/cpu/iterator/DefaultIterator.ispc @@ -3,7 +3,6 @@ #include "../common/export_util.h" #include "../math/box_utility.ih" -#include "../volume/Volume.ih" #include "DefaultIterator.ih" #include "common/ValueRanges.ih" diff --git a/openvkl/devices/cpu/sampler/Sampler.ih b/openvkl/devices/cpu/sampler/Sampler.ih index 815b06b7..476ca10c 100644 --- a/openvkl/devices/cpu/sampler/Sampler.ih +++ b/openvkl/devices/cpu/sampler/Sampler.ih @@ -5,7 +5,6 @@ #include "openvkl/VKLFilter.h" #include "openvkl/ispc_cpp_interop.h" -#include "../volume/Volume.ih" #include "../common/export_util.h" #include "SamplerShared.h" diff --git a/openvkl/devices/cpu/volume/SharedStructuredVolume.ih b/openvkl/devices/cpu/volume/SharedStructuredVolume.ih index 958e4316..fe5d2ec9 100644 --- a/openvkl/devices/cpu/volume/SharedStructuredVolume.ih +++ b/openvkl/devices/cpu/volume/SharedStructuredVolume.ih @@ -4,7 +4,6 @@ #pragma once #include "../common/Data.ih" -#include "Volume.ih" #include "rkcommon/math/box.ih" #include "rkcommon/math/vec.ih" #include "openvkl/VKLDataType.h" diff --git a/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp b/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp index 748abc5a..9a7fbb89 100644 --- a/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp +++ b/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp @@ -45,8 +45,7 @@ namespace openvkl { throw std::runtime_error("failed to commit StructuredRegularVolume"); } - CALL_ISPC( - Volume_setBackground, this->getSh(), this->background->data()); + this->setBackground(this->background->data()); // must be last this->buildAccelerator(); diff --git a/openvkl/devices/cpu/volume/StructuredSampler.h b/openvkl/devices/cpu/volume/StructuredSampler.h index 70624d07..1f09aec2 100644 --- a/openvkl/devices/cpu/volume/StructuredSampler.h +++ b/openvkl/devices/cpu/volume/StructuredSampler.h @@ -12,7 +12,6 @@ #include "StructuredRegularVolume.h" #include "StructuredSphericalVolume.h" #include "StructuredVolume.h" -#include "Volume_ispc.h" #include "openvkl/VKLFilter.h" #include "../common/StructShared.h" #include "StructuredSamplerShared.h" diff --git a/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp b/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp index 671ba61b..87f91acf 100644 --- a/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp +++ b/openvkl/devices/cpu/volume/StructuredSphericalVolume.cpp @@ -103,8 +103,7 @@ namespace openvkl { throw std::runtime_error("failed to commit StructuredSphericalVolume"); } - CALL_ISPC( - Volume_setBackground, this->getSh(), this->background->data()); + this->setBackground(this->background->data()); // must be last this->buildAccelerator(); diff --git a/openvkl/devices/cpu/volume/UnstructuredSampler.h b/openvkl/devices/cpu/volume/UnstructuredSampler.h index 5c2fd7cd..5911da63 100644 --- a/openvkl/devices/cpu/volume/UnstructuredSampler.h +++ b/openvkl/devices/cpu/volume/UnstructuredSampler.h @@ -10,7 +10,6 @@ #include "Sampler_ispc.h" #include "UnstructuredVolume.h" #include "UnstructuredVolume_ispc.h" -#include "Volume_ispc.h" #include "openvkl/common/StructShared.h" #include "UnstructuredSamplerShared.h" diff --git a/openvkl/devices/cpu/volume/UnstructuredVolume.cpp b/openvkl/devices/cpu/volume/UnstructuredVolume.cpp index 427b0bfa..4e2cb328 100644 --- a/openvkl/devices/cpu/volume/UnstructuredVolume.cpp +++ b/openvkl/devices/cpu/volume/UnstructuredVolume.cpp @@ -207,8 +207,7 @@ namespace openvkl { CALL_ISPC(VKLUnstructuredVolume_Constructor, this->getSh()); this->SharedStructInitialized = true; } - - CALL_ISPC(Volume_setBackground, this->getSh(), background->data()); + this->setBackground(background->data()); CALL_ISPC( VKLUnstructuredVolume_set, diff --git a/openvkl/devices/cpu/volume/UnstructuredVolume.ih b/openvkl/devices/cpu/volume/UnstructuredVolume.ih index 30a66c42..b007feaf 100644 --- a/openvkl/devices/cpu/volume/UnstructuredVolume.ih +++ b/openvkl/devices/cpu/volume/UnstructuredVolume.ih @@ -7,7 +7,6 @@ #include "rkcommon/math/vec.ih" #include "rkcommon/math/box.ih" #include "UnstructuredVolumeShared.h" -#include "Volume.ih" inline uniform Node *uniform sibling(uniform Node *uniform node) { diff --git a/openvkl/devices/cpu/volume/Volume.h b/openvkl/devices/cpu/volume/Volume.h index 5b25590b..83c1d6eb 100644 --- a/openvkl/devices/cpu/volume/Volume.h +++ b/openvkl/devices/cpu/volume/Volume.h @@ -8,11 +8,10 @@ #include "../common/export_util.h" #include "../iterator/Iterator.h" #include "../sampler/Sampler.h" -#include "Volume_ispc.h" +#include "VolumeShared.h" +#include "openvkl/common/StructShared.h" #include "openvkl/openvkl.h" #include "rkcommon/math/box.h" -#include "openvkl/common/StructShared.h" -#include "VolumeShared.h" #define THROW_NOT_IMPLEMENTED \ throw std::runtime_error(std::string(__FUNCTION__) + \ @@ -64,9 +63,16 @@ namespace openvkl { static ObjectFactory volumeFactory; bool SharedStructInitialized = false; + + void setBackground(const float *background); }; // Inlined definitions //////////////////////////////////////////////////// + template + inline void Volume::setBackground(const float *background) + { + this->getSh()->background = background; + } template inline Volume *Volume::createInstance(Device *device, diff --git a/openvkl/devices/cpu/volume/Volume.ih b/openvkl/devices/cpu/volume/Volume.ih deleted file mode 100644 index 9e08d68b..00000000 --- a/openvkl/devices/cpu/volume/Volume.ih +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2019 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "rkcommon/math/vec.ih" -#include "../common/export_util.h" -#include "VolumeShared.h" - -export void EXPORT_UNIQUE(Volume_setBackground, - void *uniform _volume, - const float *uniform background); diff --git a/openvkl/devices/cpu/volume/Volume.ispc b/openvkl/devices/cpu/volume/Volume.ispc deleted file mode 100644 index bdbe030a..00000000 --- a/openvkl/devices/cpu/volume/Volume.ispc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2020 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 - -#include "../common/export_util.h" -#include "Volume.ih" - -export void EXPORT_UNIQUE(Volume_setBackground, - void *uniform _volume, - const float *uniform background) -{ - VolumeShared *uniform volume = (VolumeShared * uniform) _volume; - volume->background = background; -} diff --git a/openvkl/devices/cpu/volume/amr/AMRSampler.h b/openvkl/devices/cpu/volume/amr/AMRSampler.h index 997ef88c..6a217cac 100644 --- a/openvkl/devices/cpu/volume/amr/AMRSampler.h +++ b/openvkl/devices/cpu/volume/amr/AMRSampler.h @@ -10,7 +10,6 @@ #include "AMRVolume.h" #include "AMRVolume_ispc.h" #include "Sampler_ispc.h" -#include "Volume_ispc.h" #include "method_current_ispc.h" #include "method_finest_ispc.h" #include "method_octant_ispc.h" diff --git a/openvkl/devices/cpu/volume/amr/AMRVolume.cpp b/openvkl/devices/cpu/volume/amr/AMRVolume.cpp index 6838f446..fb24da90 100644 --- a/openvkl/devices/cpu/volume/amr/AMRVolume.cpp +++ b/openvkl/devices/cpu/volume/amr/AMRVolume.cpp @@ -99,8 +99,7 @@ namespace openvkl { if (data != nullptr) // TODO: support data updates { - CALL_ISPC( - Volume_setBackground, this->getSh(), background->data()); + this->setBackground(background->data()); return; } @@ -156,7 +155,7 @@ namespace openvkl { this->template getParam("gridSpacing", vec3f(1.f)); spacing = gridSpacing; - CALL_ISPC(Volume_setBackground, this->getSh(), background->data()); + this->setBackground(background->data()); CALL_ISPC(AMRVolume_set, this->getSh(), diff --git a/openvkl/devices/cpu/volume/particle/ParticleSampler.h b/openvkl/devices/cpu/volume/particle/ParticleSampler.h index 1771fc23..b4c51605 100644 --- a/openvkl/devices/cpu/volume/particle/ParticleSampler.h +++ b/openvkl/devices/cpu/volume/particle/ParticleSampler.h @@ -11,7 +11,6 @@ #include "ParticleVolume.h" #include "ParticleVolume_ispc.h" #include "Sampler_ispc.h" -#include "Volume_ispc.h" #include "openvkl/common/StructShared.h" namespace openvkl { diff --git a/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp b/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp index f5a5677d..de48b722 100644 --- a/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp +++ b/openvkl/devices/cpu/volume/particle/ParticleVolume.cpp @@ -142,7 +142,7 @@ namespace openvkl { this->SharedStructInitialized = true; } - CALL_ISPC(Volume_setBackground, this->getSh(), background->data()); + this->setBackground(background->data()); CALL_ISPC(VKLParticleVolume_set, this->getSh(), diff --git a/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp b/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp index 875eb905..890f478f 100644 --- a/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp +++ b/openvkl/devices/cpu/volume/vdb/VdbVolume.cpp @@ -683,8 +683,7 @@ namespace openvkl { background = this->template getParamDataT( "background", grid->numAttributes, VKL_BACKGROUND_UNDEFINED); - CALL_ISPC( - Volume_setBackground, this->getSh(), background->data()); + this->setBackground(background->data()); const uint64_t numLeafDataPointers = grid->numLeaves * static_cast(grid->numAttributes); From a89423d56af37771ecc037c7c5a3e6c94eb3ac00 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Mon, 10 Oct 2022 16:15:14 -0600 Subject: [PATCH 14/34] add OPENVKL_DEVICE_CPU_* CMake flags for toggling enablement of volume types. note, these flags are hidden / advanced, and may be changed in the future. --- openvkl/devices/cpu/CMakeLists.txt | 187 ++++++++++++++---- openvkl/devices/cpu/api/CPUDevice.cpp | 24 +++ .../devices/cpu/iterator/IteratorContext.cpp | 78 ++++++-- .../cpu/volume/StructuredRegularVolume.cpp | 7 +- 4 files changed, 246 insertions(+), 50 deletions(-) diff --git a/openvkl/devices/cpu/CMakeLists.txt b/openvkl/devices/cpu/CMakeLists.txt index db9627da..caae3399 100644 --- a/openvkl/devices/cpu/CMakeLists.txt +++ b/openvkl/devices/cpu/CMakeLists.txt @@ -11,6 +11,151 @@ include_directories_ispc( option(VKL_BUILD_VDB_ITERATOR_SIZE_HELPER "Build helper program that computes sizeof(VdbIterator)" OFF) +# for toggling enablement of specific volume types +option(OPENVKL_DEVICE_CPU_AMR "enable CPU device AMR volume type" ON) +option(OPENVKL_DEVICE_CPU_PARTICLE "enable CPU device particle volume type" ON) +option(OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR "enable CPU device structuredRegular volume type" ON) +option(OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY "enable CPU device structuredRegular (legacy) volume type" OFF) +option(OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL "enable CPU device structuredSpherical volume type" ON) +option(OPENVKL_DEVICE_CPU_UNSTRUCTURED "enable CPU device unstructured volume type" ON) +option(OPENVKL_DEVICE_CPU_VDB "enable CPU device VDB volume type" ON) + +# these options are not documented, marked as advanced, and may change in the future +mark_as_advanced( + OPENVKL_DEVICE_CPU_AMR + OPENVKL_DEVICE_CPU_PARTICLE + OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR + OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY + OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL + OPENVKL_DEVICE_CPU_UNSTRUCTURED + OPENVKL_DEVICE_CPU_VDB +) + +if(${OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR} AND ${OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY}) + message(FATAL_ERROR "cannot enable both OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR and OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY") +endif() + +# sources common to multiple volume types +set(SOURCES_COMMON_AMR_PARTICLE_UNSTRUCTURED + iterator/UnstructuredIterator.cpp + iterator/UnstructuredIterator.ispc + volume/UnstructuredVolume.ispc +) + +set(SOURCES_COMMON_STRUCTURED_REGULAR_VDB + volume/vdb/VdbVolume.cpp + volume/vdb/VdbVolume.ispc + volume/vdb/VdbSampler.cpp + volume/vdb/VdbSampler.ispc + volume/vdb/VdbInnerNodeObserver.cpp + volume/vdb/VdbIterator.cpp + volume/vdb/VdbIterator.ispc + volume/vdb/VdbLeafAccessObserver.cpp +) + +set(SOURCES_COMMON_STRUCTURED_REGULAR_LEGACY_SPHERICAL + iterator/GridAcceleratorIterator.cpp + iterator/GridAcceleratorIterator.ispc + iterator/GridAcceleratorIteratorSize.ispc + volume/GridAccelerator.ispc + volume/SharedStructuredVolume.ispc + volume/StructuredVolume.cpp +) + +# source files per volume type +set(SOURCES_AMR + volume/amr/AMRAccel.cpp + volume/amr/AMRData.cpp + volume/amr/AMRVolume.cpp + volume/amr/AMRVolume.ispc + volume/amr/CellRef.ispc + volume/amr/DualCell.ispc + volume/amr/method_current.ispc + volume/amr/method_finest.ispc + volume/amr/method_octant.ispc +) + +set(SOURCES_PARTICLE + volume/particle/ParticleVolume.cpp + volume/particle/ParticleVolume.ispc +) + +set(SOURCES_STRUCTURED_REGULAR + volume/vdb/DenseVdbVolume.cpp +) + +set(SOURCES_STRUCTURED_REGULAR_LEGACY + volume/StructuredRegularVolume.cpp +) + +set(SOURCES_STRUCTURED_SPHERICAL + volume/StructuredSphericalVolume.cpp +) + +set(SOURCES_UNSTRUCTURED + volume/UnstructuredVolume.cpp +) + +# generate source file additions for optional volume types +list(APPEND OPTIONAL_VOLUME_SOURCES) +list(APPEND OPTIONAL_VOLUME_DEFINITIONS "") + +if(${OPENVKL_DEVICE_CPU_AMR}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_AMR}) + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_AMR=1") +endif() + +if(${OPENVKL_DEVICE_CPU_PARTICLE}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_PARTICLE}) + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_PARTICLE=1") +endif() + +if(${OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_STRUCTURED_REGULAR}) + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=1") +endif() + +if(${OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_STRUCTURED_REGULAR_LEGACY}) + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=1") +endif() + +if(${OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_STRUCTURED_SPHERICAL}) + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=1") +endif() + +if(${OPENVKL_DEVICE_CPU_UNSTRUCTURED}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_UNSTRUCTURED}) + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_UNSTRUCTURED=1") +endif() + +if(${OPENVKL_DEVICE_CPU_VDB}) + # uses common sources only: SOURCES_COMMON_STRUCTURED_REGULAR_VDB + list(APPEND OPTIONAL_VOLUME_DEFINITIONS "OPENVKL_DEVICE_CPU_VDB=1") +endif() + +# common source files +if(${OPENVKL_DEVICE_CPU_AMR} OR + ${OPENVKL_DEVICE_CPU_PARTICLE} OR + ${OPENVKL_DEVICE_CPU_UNSTRUCTURED}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_COMMON_AMR_PARTICLE_UNSTRUCTURED}) +endif() + +if(${OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR} OR + ${OPENVKL_DEVICE_CPU_VDB}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_COMMON_STRUCTURED_REGULAR_VDB}) +endif() + +if(${OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY} OR + ${OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL}) + list(APPEND OPTIONAL_VOLUME_SOURCES ${SOURCES_COMMON_STRUCTURED_REGULAR_LEGACY_SPHERICAL}) +endif() + +# definitions for ISPC components +set(OPTIONAL_VOLUME_DEFINITIONS_ISPC ${OPTIONAL_VOLUME_DEFINITIONS}) +list(TRANSFORM OPTIONAL_VOLUME_DEFINITIONS_ISPC PREPEND "-D") + # width-specific builds foreach(TARGET_WIDTH 4 8 16) @@ -32,52 +177,24 @@ foreach(TARGET_WIDTH 4 8 16) set(ISPC_TARGETS_OVERRIDE ${OPENVKL_ISPC_TARGET_LIST_16}) endif() - set(ISPC_DEFINITIONS "-DVKL_TARGET_WIDTH=${TARGET_WIDTH}") + set(ISPC_DEFINITIONS + "-DVKL_TARGET_WIDTH=${TARGET_WIDTH}" + ${OPTIONAL_VOLUME_DEFINITIONS_ISPC} + ) openvkl_add_library_ispc(${TARGET_NAME} SHARED api/CPUDevice.cpp api/CPUDevice.ispc iterator/DefaultIterator.cpp iterator/DefaultIterator.ispc - iterator/GridAcceleratorIterator.cpp - iterator/GridAcceleratorIterator.ispc - iterator/GridAcceleratorIteratorSize.ispc iterator/IteratorContext.cpp iterator/IteratorContext.ispc - iterator/UnstructuredIterator.cpp - iterator/UnstructuredIterator.ispc observer/Observer.cpp observer/ObserverRegistry.cpp observer/ObserverRegistry.ispc sampler/Sampler.cpp sampler/Sampler.ispc - volume/amr/AMRAccel.cpp - volume/amr/AMRData.cpp - volume/amr/AMRVolume.cpp - volume/amr/AMRVolume.ispc - volume/amr/CellRef.ispc - volume/amr/DualCell.ispc - volume/amr/method_current.ispc - volume/amr/method_finest.ispc - volume/amr/method_octant.ispc - volume/particle/ParticleVolume.cpp - volume/particle/ParticleVolume.ispc - volume/GridAccelerator.ispc - volume/SharedStructuredVolume.ispc - volume/StructuredVolume.cpp - volume/StructuredRegularVolume.cpp - volume/StructuredSphericalVolume.cpp - volume/UnstructuredVolume.cpp - volume/UnstructuredVolume.ispc - volume/vdb/VdbVolume.cpp - volume/vdb/VdbVolume.ispc - volume/vdb/VdbSampler.cpp - volume/vdb/VdbSampler.ispc - volume/vdb/VdbInnerNodeObserver.cpp - volume/vdb/VdbIterator.cpp - volume/vdb/VdbIterator.ispc - volume/vdb/VdbLeafAccessObserver.cpp - volume/vdb/DenseVdbVolume.cpp + ${OPTIONAL_VOLUME_SOURCES} ) unset(ISPC_DEFINITIONS) @@ -91,7 +208,9 @@ foreach(TARGET_WIDTH 4 8 16) ) target_compile_definitions(${TARGET_NAME} PRIVATE - "VKL_TARGET_WIDTH=${TARGET_WIDTH}") + "VKL_TARGET_WIDTH=${TARGET_WIDTH}" + ${OPTIONAL_VOLUME_DEFINITIONS} + ) set(width_compile_options "") openvkl_get_compile_options_for_width(${TARGET_WIDTH} width_compile_options) diff --git a/openvkl/devices/cpu/api/CPUDevice.cpp b/openvkl/devices/cpu/api/CPUDevice.cpp index 55518714..5acb9130 100644 --- a/openvkl/devices/cpu/api/CPUDevice.cpp +++ b/openvkl/devices/cpu/api/CPUDevice.cpp @@ -827,6 +827,8 @@ VKL_WRAP_DEVICE_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_cpu)) VKL_WRAP_VOLUME_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_amr)) VKL_WRAP_VOLUME_REGISTRATION( VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegular)) +VKL_WRAP_VOLUME_REGISTRATION( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegularLegacy)) VKL_WRAP_VOLUME_REGISTRATION( VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredSpherical)) VKL_WRAP_VOLUME_REGISTRATION(VKL_MAKE_TARGET_WIDTH_NAME(internal_unstructured)) @@ -849,34 +851,56 @@ extern "C" OPENVKL_DLLEXPORT void CONCAT1(openvkl_init_module_cpu_device_, VKL_REGISTER_DEVICE_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_cpu), VKL_MAKE_TARGET_WIDTH_NAME(cpu)); +#if OPENVKL_DEVICE_CPU_AMR VKL_REGISTER_VOLUME_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_amr), VKL_MAKE_TARGET_WIDTH_NAME(amr)); +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR VKL_REGISTER_VOLUME_FACTORY_FCN( VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegular), VKL_MAKE_TARGET_WIDTH_NAME(structuredRegular)); +#endif + +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY + VKL_REGISTER_VOLUME_FACTORY_FCN( + VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegularLegacy), + VKL_MAKE_TARGET_WIDTH_NAME(structuredRegular)); +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL VKL_REGISTER_VOLUME_FACTORY_FCN( VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredSpherical), VKL_MAKE_TARGET_WIDTH_NAME(structuredSpherical)); +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED VKL_REGISTER_VOLUME_FACTORY_FCN( VKL_MAKE_TARGET_WIDTH_NAME(internal_unstructured), VKL_MAKE_TARGET_WIDTH_NAME(unstructured)); +#endif +#if OPENVKL_DEVICE_CPU_VDB VKL_REGISTER_VOLUME_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_vdb), VKL_MAKE_TARGET_WIDTH_NAME(vdb)); +#endif +#if OPENVKL_DEVICE_CPU_PARTICLE VKL_REGISTER_VOLUME_FACTORY_FCN(VKL_MAKE_TARGET_WIDTH_NAME(internal_particle), VKL_MAKE_TARGET_WIDTH_NAME(particle)); +#endif // support deprecated snake case names (a warning will be triggered if these // are used) +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR VKL_REGISTER_VOLUME_FACTORY_FCN( VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredRegular), VKL_MAKE_TARGET_WIDTH_NAME(structured_regular)); +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL VKL_REGISTER_VOLUME_FACTORY_FCN( VKL_MAKE_TARGET_WIDTH_NAME(internal_structuredSpherical), VKL_MAKE_TARGET_WIDTH_NAME(structured_spherical)); +#endif } diff --git a/openvkl/devices/cpu/iterator/IteratorContext.cpp b/openvkl/devices/cpu/iterator/IteratorContext.cpp index a0d167d7..e66b5f41 100644 --- a/openvkl/devices/cpu/iterator/IteratorContext.cpp +++ b/openvkl/devices/cpu/iterator/IteratorContext.cpp @@ -6,13 +6,28 @@ #include "../common/export_util.h" #include "../sampler/Sampler.h" #include "../volume/Volume.h" -#include "../volume/vdb/VdbVolume.h" -#include "../volume/vdb/DenseVdbVolume.h" #include "IteratorContext_ispc.h" #include "rkcommon/math/range.h" -#include "../volume/UnstructuredVolume.h" + +#if OPENVKL_DEVICE_CPU_VDB +#include "../volume/vdb/VdbVolume.h" +#endif + +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR +#include "../volume/vdb/DenseVdbVolume.h" +#endif + +#if OPENVKL_DEVICE_CPU_AMR #include "../volume/amr/AMRVolume.h" +#endif + +#if OPENVKL_DEVICE_CPU_PARTICLE #include "../volume/particle/ParticleVolume.h" +#endif + +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED +#include "../volume/UnstructuredVolume.h" +#endif namespace openvkl { namespace cpu_device { @@ -34,6 +49,9 @@ namespace openvkl { const Volume &volume = iteratorContext.getSampler().getVolume(); + bool foundVolume = false; + +#if OPENVKL_DEVICE_CPU_VDB || OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR if (dynamic_cast *>(&volume)) { // handles both DenseVdbVolume (structuredRegular) and VdbVolume @@ -45,27 +63,48 @@ namespace openvkl { assert(VKL_VDB_NUM_LEVELS == 4); hintToDepth.emplace_back(0.8f, 3); - } else if (dynamic_cast *>(&volume) || - dynamic_cast *>(&volume) || - dynamic_cast *>(&volume)) { + foundVolume = true; + } +#endif + + bool isAMR = false; + bool isParticle = false; + bool isUnstructured = false; + +#if OPENVKL_DEVICE_CPU_AMR + isAMR = dynamic_cast *>(&volume); +#endif +#if OPENVKL_DEVICE_CPU_PARTICLE + isParticle = dynamic_cast *>(&volume); +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED + isUnstructured = dynamic_cast *>(&volume); +#endif + + if (isAMR || isParticle || isUnstructured) { // these volume types all use a BVH-based iterator // we should have these volume types inherit from a common base int bvhDepth = 0; - if (dynamic_cast *>(&volume)) { +#if OPENVKL_DEVICE_CPU_AMR + if (isAMR) { const auto *v = dynamic_cast *>(&volume); bvhDepth = v->getBvhDepth(); - } else if (dynamic_cast *>(&volume)) { + } +#endif +#if OPENVKL_DEVICE_CPU_PARTICLE + if (isParticle) { const auto *v = dynamic_cast *>(&volume); bvhDepth = v->getBvhDepth(); - } else if (dynamic_cast *>(&volume)) { + } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED + if (isUnstructured) { const auto *v = dynamic_cast *>(&volume); bvhDepth = v->getBvhDepth(); - } else { - throw std::runtime_error( - "could not map intervalResolutionHint value"); } +#endif int defaultDepth = bvhDepth > 6 ? 6 : bvhDepth / 2; const float defaultRangeBegin = 0.45f; @@ -92,9 +131,11 @@ namespace openvkl { // mapping defined for intervalResolutionHint == 1 hintToDepth.emplace_back(1.f, bvhDepth); + + foundVolume = true; } - else { + if (!foundVolume) { // volume type does not support maxIteratorDepth parameter (result will // go unused) return 0; @@ -227,6 +268,7 @@ namespace openvkl { const Volume &volume = this->getSampler().getVolume(); +#if OPENVKL_DEVICE_CPU_VDB && OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR if (dynamic_cast *>(&volume) && !dynamic_cast *>(&volume)) { // VdbVolume, but not DenseVdbVolume. @@ -236,6 +278,16 @@ namespace openvkl { } else { maxIteratorDepth = mapToMaxIteratorDepth(*this, 0.5f); } +#elif OPENVKL_DEVICE_CPU_VDB + if (dynamic_cast *>(&volume)) { + // VdbVolume (DenseVdbVolume not enabled here; see above comment) + maxIteratorDepth = mapToMaxIteratorDepth(*this, 1.f); + } else { + maxIteratorDepth = mapToMaxIteratorDepth(*this, 0.5f); + } +#else + maxIteratorDepth = mapToMaxIteratorDepth(*this, 0.5f); +#endif if (this->SharedStructInitialized) { CALL_ISPC(HitIteratorContext_Destructor, this->getSh()); diff --git a/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp b/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp index 9a7fbb89..3f126503 100644 --- a/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp +++ b/openvkl/devices/cpu/volume/StructuredRegularVolume.cpp @@ -16,7 +16,7 @@ namespace openvkl { CALL_ISPC(SharedStructuredVolume_Constructor, this->getSh()); this->SharedStructInitialized = true; - if (!this->SharedStructInitialied) { + if (!this->SharedStructInitialized) { throw std::runtime_error( "could not initialized device-side object for StructuredRegularVolume"); } @@ -51,8 +51,9 @@ namespace openvkl { this->buildAccelerator(); } - //VKL_REGISTER_VOLUME(StructuredRegularVolume, - // CONCAT1(internal_structuredRegular_, VKL_TARGET_WIDTH)) + // this is the old / legacy structured regular implementation! + VKL_REGISTER_VOLUME(StructuredRegularVolume, + CONCAT1(internal_structuredRegularLegacy_, VKL_TARGET_WIDTH)) } // namespace cpu_device } // namespace openvkl From ba9fc9d150bd60e84e631e3c22349c6d8b316e07 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 13 Oct 2022 15:56:13 -0500 Subject: [PATCH 15/34] CI: add additional workflow for testing enablement of individual volume types. --- .github/workflows/ci.linux.single_volume.yml | 161 +++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 .github/workflows/ci.linux.single_volume.yml diff --git a/.github/workflows/ci.linux.single_volume.yml b/.github/workflows/ci.linux.single_volume.yml new file mode 100644 index 00000000..18740d3e --- /dev/null +++ b/.github/workflows/ci.linux.single_volume.yml @@ -0,0 +1,161 @@ +## Copyright 2022 Intel Corporation +## SPDX-License-Identifier: Apache-2.0 + +name: CI Single Volume Workflow +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-amr: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-amr + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=ON -DOPENVKL_DEVICE_CPU_PARTICLE=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=OFF -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=OFF -DOPENVKL_DEVICE_CPU_VDB=OFF" + + build-particle: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-particle + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=OFF -DOPENVKL_DEVICE_CPU_PARTICLE=ON -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=OFF -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=OFF -DOPENVKL_DEVICE_CPU_VDB=OFF" + + build-structuredRegular: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-structuredRegular + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=OFF -DOPENVKL_DEVICE_CPU_PARTICLE=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=ON -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=OFF -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=OFF -DOPENVKL_DEVICE_CPU_VDB=OFF" + + build-structuredRegularLegacy: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-structuredRegularLegacy + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=OFF -DOPENVKL_DEVICE_CPU_PARTICLE=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=ON -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=OFF -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=OFF -DOPENVKL_DEVICE_CPU_VDB=OFF" + + build-structuredSpherical: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-structuredSpherical + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=OFF -DOPENVKL_DEVICE_CPU_PARTICLE=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=ON -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=OFF -DOPENVKL_DEVICE_CPU_VDB=OFF" + + build-unstructured: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-unstructured + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=OFF -DOPENVKL_DEVICE_CPU_PARTICLE=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=OFF -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=ON -DOPENVKL_DEVICE_CPU_VDB=OFF" + + build-vdb: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:8 + artifact-out: build-vdb + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_DEVICE_CPU_AMR=OFF -DOPENVKL_DEVICE_CPU_PARTICLE=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_REGULAR_LEGACY=OFF -DOPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL=OFF -DOPENVKL_DEVICE_CPU_UNSTRUCTURED=OFF -DOPENVKL_DEVICE_CPU_VDB=ON" + + # test jobs - per volume type + + test-amr: + needs: build-amr + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-amr + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes + + test-particle: + needs: build-particle + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-particle + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes + + test-structuredRegular: + needs: build-structuredRegular + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-structuredRegular + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes + + test-structuredRegularLegacy: + needs: build-structuredRegularLegacy + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-structuredRegularLegacy + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes + + test-structuredSpherical: + needs: build-structuredSpherical + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-structuredSpherical + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes + + test-unstructured: + needs: build-unstructured + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-unstructured + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes + + test-vdb: + needs: build-vdb + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + artifact-in: build-vdb + image: centos:8 + cmd: | + ./build/openvkl/build/vklTests --durations yes From 2591c4f6d9bf3ebec889531449138f56c578c782 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 25 Oct 2022 15:52:32 -0500 Subject: [PATCH 16/34] only include functional tests for enabled volume types --- openvkl/devices/cpu/CMakeLists.txt | 4 + testing/apps/tests/amr_volume_sampling.cpp | 2 + testing/apps/tests/amr_volume_value_range.cpp | 2 + testing/apps/tests/hit_iterator.cpp | 10 +- testing/apps/tests/hit_iterator_epsilon.cpp | 23 +++-- testing/apps/tests/interval_iterator.cpp | 12 +++ testing/apps/tests/multi_device.cpp | 2 + .../apps/tests/particle_volume_gradients.cpp | 2 + .../particle_volume_interval_iterator.cpp | 2 + testing/apps/tests/particle_volume_radius.cpp | 2 + .../apps/tests/particle_volume_sampling.cpp | 2 + .../tests/particle_volume_value_range.cpp | 2 + testing/apps/tests/simd_conformance.cpp | 48 +++++++-- testing/apps/tests/stream_gradients.cpp | 8 ++ testing/apps/tests/stream_sampling.cpp | 10 ++ ...d_regular_volume_gradients_motion_blur.cpp | 2 + .../tests/structured_regular_volume_multi.cpp | 2 + .../structured_regular_volume_sampling.cpp | 2 + ...ed_regular_volume_sampling_motion_blur.cpp | 2 + .../structured_regular_volume_strides.cpp | 2 + ...ructured_spherical_volume_bounding_box.cpp | 2 + .../structured_spherical_volume_sampling.cpp | 2 + .../tests/structured_volume_gradients.cpp | 9 +- .../tests/structured_volume_value_range.cpp | 98 +++++++++++++------ .../tests/unstructured_volume_gradients.cpp | 4 +- .../tests/unstructured_volume_sampling.cpp | 2 + .../tests/unstructured_volume_strides.cpp | 2 + .../tests/unstructured_volume_value_range.cpp | 2 + testing/apps/tests/vdb_volume.cpp | 2 + testing/apps/tests/vdb_volume_dense.cpp | 2 + .../tests/vdb_volume_inner_node_observer.cpp | 2 + testing/apps/tests/vdb_volume_motion_blur.cpp | 2 + testing/apps/tests/vdb_volume_multi.cpp | 2 + testing/apps/tests/vectorized_gradients.cpp | 6 ++ .../apps/tests/vectorized_hit_iterator.cpp | 2 + .../tests/vectorized_interval_iterator.cpp | 2 + testing/apps/tests/vectorized_sampling.cpp | 6 +- 37 files changed, 239 insertions(+), 49 deletions(-) diff --git a/openvkl/devices/cpu/CMakeLists.txt b/openvkl/devices/cpu/CMakeLists.txt index caae3399..d65ae03c 100644 --- a/openvkl/devices/cpu/CMakeLists.txt +++ b/openvkl/devices/cpu/CMakeLists.txt @@ -246,6 +246,10 @@ endforeach(TARGET_WIDTH) # shared library linking to all width-specific targets add_library(openvkl_module_cpu_device SHARED exports.cpp ${VKL_RESOURCE}) +target_compile_definitions(openvkl_module_cpu_device PUBLIC + ${OPTIONAL_VOLUME_DEFINITIONS} +) + foreach(TARGET_WIDTH 4 8 16) if (TARGET_WIDTH_ENABLED_${TARGET_WIDTH}) target_compile_definitions(openvkl_module_cpu_device PUBLIC diff --git a/testing/apps/tests/amr_volume_sampling.cpp b/testing/apps/tests/amr_volume_sampling.cpp index 90255509..444e6a98 100644 --- a/testing/apps/tests/amr_volume_sampling.cpp +++ b/testing/apps/tests/amr_volume_sampling.cpp @@ -55,6 +55,7 @@ void amr_sampling_at_shell_boundaries(vec3i dimensions, vec3i step = vec3i(1)) vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_AMR TEST_CASE("AMR volume sampling", "[volume_sampling]") { initializeOpenVKL(); @@ -66,3 +67,4 @@ TEST_CASE("AMR volume sampling", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/amr_volume_value_range.cpp b/testing/apps/tests/amr_volume_value_range.cpp index a6f37c88..10340552 100644 --- a/testing/apps/tests/amr_volume_value_range.cpp +++ b/testing/apps/tests/amr_volume_value_range.cpp @@ -28,6 +28,7 @@ void computed_vs_api_value_range(vec3i dimensions) apiValueRange.upper == computedValueRange.upper)); } +#if OPENVKL_DEVICE_CPU_AMR TEST_CASE("AMR volume value range", "[volume_value_range]") { initializeOpenVKL(); @@ -36,3 +37,4 @@ TEST_CASE("AMR volume value range", "[volume_value_range]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/hit_iterator.cpp b/testing/apps/tests/hit_iterator.cpp index 97c24a13..7b0c6a4c 100644 --- a/testing/apps/tests/hit_iterator.cpp +++ b/testing/apps/tests/hit_iterator.cpp @@ -84,6 +84,7 @@ TEST_CASE("Hit iterator", "[hit_iterators]") SECTION("scalar hit iteration") { +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structured volumes: single attribute") { std::unique_ptr v( @@ -134,7 +135,9 @@ TEST_CASE("Hit iterator", "[hit_iterators]") directions[i - 1]); } } +#endif +#if OPENVKL_DEVICE_CPU_VDB SECTION("VDB volumes: single attribute") { for (const auto &repackNodes : {true, false}) { @@ -207,7 +210,9 @@ TEST_CASE("Hit iterator", "[hit_iterators]") } } } +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION( "structured volumes: isovalues at grid accelerator macrocell " "boundaries") @@ -254,7 +259,7 @@ TEST_CASE("Hit iterator", "[hit_iterators]") reversedIsovalues, defaultExpectedTValues, vkl_vec3f{0.5f, 0.5f, 2.f}, - //vkl_vec3f{8.f, 8.f, 18.f}, + // vkl_vec3f{8.f, 8.f, 18.f}, vkl_vec3f{0.f, 0.f, -1.f}); } @@ -289,7 +294,9 @@ TEST_CASE("Hit iterator", "[hit_iterators]") } } } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED SECTION("unstructured volumes") { std::unique_ptr v( @@ -306,6 +313,7 @@ TEST_CASE("Hit iterator", "[hit_iterators]") defaultIsoValues, defaultExpectedTValues); } +#endif } shutdownOpenVKL(); diff --git a/testing/apps/tests/hit_iterator_epsilon.cpp b/testing/apps/tests/hit_iterator_epsilon.cpp index e9649b91..876088b7 100644 --- a/testing/apps/tests/hit_iterator_epsilon.cpp +++ b/testing/apps/tests/hit_iterator_epsilon.cpp @@ -175,31 +175,42 @@ TEST_CASE("Hit iterator epsilon", "[hit_iterators]") isovalues.push_back(f); } - std::vector sectionNames{"structured volumes", - "unstructured volumes", - "VDB volumes (repackNodes=true)", - "VDB volumes (repackNodes=false)", - "AMR volumes", - "particle volumes"}; + std::vector sectionNames; std::vector> testingVolumes; +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR + sectionNames.push_back("structured volumes"); testingVolumes.push_back( std::make_shared(dimensions, gridOrigin, gridSpacing)); +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED + sectionNames.push_back("unstructured volumes"); testingVolumes.push_back(std::make_shared( dimensions, gridOrigin, gridSpacing, VKL_HEXAHEDRON, false)); +#endif +#if OPENVKL_DEVICE_CPU_VDB + sectionNames.push_back("VDB volumes (repackNodes=true)"); testingVolumes.push_back(std::make_shared( getOpenVKLDevice(), dimensions, gridOrigin, gridSpacing, true)); + sectionNames.push_back("VDB volumes (repackNodes=false)"); testingVolumes.push_back(std::make_shared( getOpenVKLDevice(), dimensions, gridOrigin, gridSpacing, false)); +#endif +#if OPENVKL_DEVICE_CPU_AMR + sectionNames.push_back("AMR volumes"); testingVolumes.push_back(std::make_shared>( dimensions, gridOrigin, gridSpacing)); +#endif +#if OPENVKL_DEVICE_CPU_PARTICLE + sectionNames.push_back("particle volumes"); testingVolumes.push_back(std::make_shared(1000)); +#endif if (sectionNames.size() != testingVolumes.size()) { throw std::runtime_error("test configuration error"); diff --git a/testing/apps/tests/interval_iterator.cpp b/testing/apps/tests/interval_iterator.cpp index 63c14ba6..0218d7e8 100644 --- a/testing/apps/tests/interval_iterator.cpp +++ b/testing/apps/tests/interval_iterator.cpp @@ -344,6 +344,7 @@ TEST_CASE("Interval iterator", "[interval_iterators]") const vec3f gridOrigin(0.f); const vec3f gridSpacing(1.f / (128.f - 1.f)); +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structured volumes") { auto v = rkcommon::make_unique>( @@ -351,7 +352,9 @@ TEST_CASE("Interval iterator", "[interval_iterators]") scalar_single_attribute_interval_iterator_tests(v); } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED SECTION("unstructured volumes") { auto v = rkcommon::make_unique( @@ -359,7 +362,9 @@ TEST_CASE("Interval iterator", "[interval_iterators]") scalar_single_attribute_interval_iterator_tests(v); } +#endif +#if OPENVKL_DEVICE_CPU_VDB SECTION("VDB volumes") { for (const auto &repackNodes : {true, false}) { @@ -379,6 +384,7 @@ TEST_CASE("Interval iterator", "[interval_iterators]") } } } +#endif } SECTION("multi attribute interval iteration") @@ -388,6 +394,7 @@ TEST_CASE("Interval iterator", "[interval_iterators]") const vec3f gridOrigin(0.f); const vec3f gridSpacing(1.f / (128.f - 1.f)); +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structured volumes") { std::shared_ptr v( @@ -400,7 +407,9 @@ TEST_CASE("Interval iterator", "[interval_iterators]") scalar_multi_attribute_interval_iterator_tests(v); } +#endif +#if OPENVKL_DEVICE_CPU_VDB SECTION("VDB volumes") { for (const auto &repackNodes : {true, false}) { @@ -423,8 +432,10 @@ TEST_CASE("Interval iterator", "[interval_iterators]") } } } +#endif } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structured volumes: interval nominalDeltaT") { // use a different volume to facilitate nominalDeltaT tests @@ -498,6 +509,7 @@ TEST_CASE("Interval iterator", "[interval_iterators]") } } } +#endif shutdownOpenVKL(); } diff --git a/testing/apps/tests/multi_device.cpp b/testing/apps/tests/multi_device.cpp index 1a7dbbe9..1250c042 100644 --- a/testing/apps/tests/multi_device.cpp +++ b/testing/apps/tests/multi_device.cpp @@ -127,6 +127,7 @@ bool test_sampling(const std::shared_ptr deviceContext) return success; } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Multiple devices", "[multi_device]") { vklLoadModule("cpu_device"); @@ -199,3 +200,4 @@ TEST_CASE("Multiple devices", "[multi_device]") REQUIRE(threadedTestFailures == 0); } +#endif diff --git a/testing/apps/tests/particle_volume_gradients.cpp b/testing/apps/tests/particle_volume_gradients.cpp index 67e23981..3d140b42 100644 --- a/testing/apps/tests/particle_volume_gradients.cpp +++ b/testing/apps/tests/particle_volume_gradients.cpp @@ -46,6 +46,7 @@ void gradients_at_particle_centers(size_t numParticles, vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_PARTICLE TEST_CASE("Particle volume gradients", "[volume_gradients]") { initializeOpenVKL(); @@ -69,3 +70,4 @@ TEST_CASE("Particle volume gradients", "[volume_gradients]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/particle_volume_interval_iterator.cpp b/testing/apps/tests/particle_volume_interval_iterator.cpp index 0fba86e7..120a5623 100644 --- a/testing/apps/tests/particle_volume_interval_iterator.cpp +++ b/testing/apps/tests/particle_volume_interval_iterator.cpp @@ -98,6 +98,7 @@ void interval_iteration(size_t numParticles, vklRelease(sampler); } +#if OPENVKL_DEVICE_CPU_PARTICLE TEST_CASE("Particle volume interval iterator", "[interval_iterators]") { initializeOpenVKL(); @@ -121,3 +122,4 @@ TEST_CASE("Particle volume interval iterator", "[interval_iterators]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/particle_volume_radius.cpp b/testing/apps/tests/particle_volume_radius.cpp index 07979167..00c3f413 100644 --- a/testing/apps/tests/particle_volume_radius.cpp +++ b/testing/apps/tests/particle_volume_radius.cpp @@ -48,6 +48,7 @@ static void sampling_at_particle_centers(VKLVolume vklVolume, vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_PARTICLE TEST_CASE("Particle volume radius", "[volume_sampling]") { initializeOpenVKL(); @@ -132,3 +133,4 @@ TEST_CASE("Particle volume radius", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/particle_volume_sampling.cpp b/testing/apps/tests/particle_volume_sampling.cpp index afddd710..68766d00 100644 --- a/testing/apps/tests/particle_volume_sampling.cpp +++ b/testing/apps/tests/particle_volume_sampling.cpp @@ -81,6 +81,7 @@ void sampling_at_random_points(size_t numParticles, vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_PARTICLE TEST_CASE("Particle volume sampling", "[volume_sampling]") { initializeOpenVKL(); @@ -105,3 +106,4 @@ TEST_CASE("Particle volume sampling", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/particle_volume_value_range.cpp b/testing/apps/tests/particle_volume_value_range.cpp index 15d443e3..6c549453 100644 --- a/testing/apps/tests/particle_volume_value_range.cpp +++ b/testing/apps/tests/particle_volume_value_range.cpp @@ -53,6 +53,7 @@ void computed_vs_api_value_range(size_t numParticles, } } +#if OPENVKL_DEVICE_CPU_PARTICLE TEST_CASE("Particle volume value range", "[volume_value_range]") { initializeOpenVKL(); @@ -79,3 +80,4 @@ TEST_CASE("Particle volume value range", "[volume_value_range]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/simd_conformance.cpp b/testing/apps/tests/simd_conformance.cpp index b7a73368..07fd156e 100644 --- a/testing/apps/tests/simd_conformance.cpp +++ b/testing/apps/tests/simd_conformance.cpp @@ -163,19 +163,40 @@ void max_iterator_size_conformance_test(VKLDevice device) size_t maxIntervalSize = 0; size_t maxHitSize = 0; - for (const char *volumeType : {"amr", - "structuredRegular", - "structuredSpherical", - "particle", - "unstructured", - "vdb"}) { - VKLVolume volume = vklNewVolume(device, volumeType); + std::vector volumeTypes; + +#if OPENVKL_DEVICE_CPU_AMR + volumeTypes.push_back("amr"); +#endif + +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR + volumeTypes.push_back("structuredRegular"); +#endif + +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL + volumeTypes.push_back("structuredSpherical"); +#endif + +#if OPENVKL_DEVICE_CPU_PARTICLE + volumeTypes.push_back("particle"); +#endif + +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED + volumeTypes.push_back("unstructured"); +#endif + +#if OPENVKL_DEVICE_CPU_VDB + volumeTypes.push_back("vdb"); +#endif + + for (const auto &volumeType : volumeTypes) { + VKLVolume volume = vklNewVolume(device, volumeType.c_str()); VKLSampler sampler = vklNewSampler(volume); vklCommit(sampler); VKLIntervalIteratorContext intervalContext = vklNewIntervalIteratorContext(sampler); VKLHitIteratorContext hitContext = vklNewHitIteratorContext(sampler); - maxIntervalSize = std::max( + maxIntervalSize = std::max( maxIntervalSize, vklGetIntervalIteratorSize(intervalContext)); maxHitSize = std::max(maxHitSize, vklGetHitIteratorSize(hitContext)); @@ -185,8 +206,19 @@ void max_iterator_size_conformance_test(VKLDevice device) vklRelease(volume); } +#define ALL_VOLUMES_ENABLED \ + (OPENVKL_DEVICE_CPU_AMR && OPENVKL_DEVICE_CPU_PARTICLE && \ + OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR && \ + OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL && \ + OPENVKL_DEVICE_CPU_UNSTRUCTURED && OPENVKL_DEVICE_CPU_VDB) + +#if ALL_VOLUMES_ENABLED REQUIRE(maxIntervalSize == INTERVAL_MACRO); REQUIRE(maxHitSize == HIT_MACRO); +#else + REQUIRE(maxIntervalSize <= INTERVAL_MACRO); + REQUIRE(maxHitSize <= HIT_MACRO); +#endif } TEST_CASE("Max iterator size", "[simd_conformance]") diff --git a/testing/apps/tests/stream_gradients.cpp b/testing/apps/tests/stream_gradients.cpp index 58b124a1..67b13bf7 100644 --- a/testing/apps/tests/stream_gradients.cpp +++ b/testing/apps/tests/stream_gradients.cpp @@ -13,27 +13,34 @@ TEST_CASE("Stream gradients", "[volume_gradients]") { initializeOpenVKL(); +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structuredRegular") { auto v = std::make_shared>( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_gradients(v); } +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL SECTION("structuredSpherical") { auto v = std::make_shared>( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_gradients(v); } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED SECTION("unstructured") { auto v = std::make_shared( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_gradients(v); } +#endif +#if OPENVKL_DEVICE_CPU_VDB SECTION("vdb") { auto v1 = std::make_shared( @@ -44,6 +51,7 @@ TEST_CASE("Stream gradients", "[volume_gradients]") getOpenVKLDevice(), vec3i(128), vec3f(0.f), vec3f(1.f), false); test_stream_gradients(v2); } +#endif shutdownOpenVKL(); } diff --git a/testing/apps/tests/stream_sampling.cpp b/testing/apps/tests/stream_sampling.cpp index 7009f852..d12b6a99 100644 --- a/testing/apps/tests/stream_sampling.cpp +++ b/testing/apps/tests/stream_sampling.cpp @@ -12,34 +12,43 @@ TEST_CASE("Stream sampling", "[volume_sampling]") { initializeOpenVKL(); +#if OPENVKL_DEVICE_CPU_AMR SECTION("AMR") { auto v = std::make_shared>( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_sampling(v); } +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structuredRegular") { auto v = std::make_shared>( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_sampling(v); } +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL SECTION("structuredSpherical") { auto v = std::make_shared>( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_sampling(v); } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED SECTION("unstructured") { auto v = std::make_shared( vec3i(128), vec3f(0.f), vec3f(1.f)); test_stream_sampling(v); } +#endif +#if OPENVKL_DEVICE_CPU_VDB SECTION("VDB") { auto v1 = std::make_shared( @@ -50,6 +59,7 @@ TEST_CASE("Stream sampling", "[volume_sampling]") getOpenVKLDevice(), vec3i(128), vec3f(0.f), vec3f(1.f), false); test_stream_sampling(v2); } +#endif shutdownOpenVKL(); } diff --git a/testing/apps/tests/structured_regular_volume_gradients_motion_blur.cpp b/testing/apps/tests/structured_regular_volume_gradients_motion_blur.cpp index d97fce1e..fd1a0366 100644 --- a/testing/apps/tests/structured_regular_volume_gradients_motion_blur.cpp +++ b/testing/apps/tests/structured_regular_volume_gradients_motion_blur.cpp @@ -155,6 +155,7 @@ inline void gradients_on_vertices_vs_procedural_values_varying_TUV_data() vklRelease(volume); } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Structured regular volume gradient sampling with motion blur", "[volume_sampling]") { @@ -215,3 +216,4 @@ TEST_CASE("Structured regular volume gradient sampling with motion blur", shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_regular_volume_multi.cpp b/testing/apps/tests/structured_regular_volume_multi.cpp index 1c2bc7b2..9a5ae928 100644 --- a/testing/apps/tests/structured_regular_volume_multi.cpp +++ b/testing/apps/tests/structured_regular_volume_multi.cpp @@ -11,6 +11,7 @@ using namespace rkcommon; using namespace openvkl::testing; +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Structured regular volume multiple attributes", "[volume_multi_attributes]") { @@ -67,3 +68,4 @@ TEST_CASE("Structured regular volume multiple attributes", shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_regular_volume_sampling.cpp b/testing/apps/tests/structured_regular_volume_sampling.cpp index 54674126..3a9e4939 100644 --- a/testing/apps/tests/structured_regular_volume_sampling.cpp +++ b/testing/apps/tests/structured_regular_volume_sampling.cpp @@ -8,6 +8,7 @@ using namespace rkcommon; using namespace openvkl::testing; +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Structured regular volume sampling", "[volume_sampling]") { initializeOpenVKL(); @@ -121,3 +122,4 @@ TEST_CASE("Structured regular volume sampling", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_regular_volume_sampling_motion_blur.cpp b/testing/apps/tests/structured_regular_volume_sampling_motion_blur.cpp index 52c50e3e..29f163c2 100644 --- a/testing/apps/tests/structured_regular_volume_sampling_motion_blur.cpp +++ b/testing/apps/tests/structured_regular_volume_sampling_motion_blur.cpp @@ -168,6 +168,7 @@ inline void sampling_on_vertices_vs_procedural_values_varying_TUV_data() vklRelease(volume); } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Structured regular volume sampling with motion blur", "[volume_sampling]") { @@ -232,3 +233,4 @@ TEST_CASE("Structured regular volume sampling with motion blur", shutdownOpenVKL(); } +#endif \ No newline at end of file diff --git a/testing/apps/tests/structured_regular_volume_strides.cpp b/testing/apps/tests/structured_regular_volume_strides.cpp index 1b570760..054f58c8 100644 --- a/testing/apps/tests/structured_regular_volume_strides.cpp +++ b/testing/apps/tests/structured_regular_volume_strides.cpp @@ -9,6 +9,7 @@ using namespace rkcommon; using namespace openvkl::testing; +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Structured regular volume strides", "[volume_strides]") { initializeOpenVKL(); @@ -111,3 +112,4 @@ TEST_CASE("Structured regular volume strides", "[volume_strides]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_spherical_volume_bounding_box.cpp b/testing/apps/tests/structured_spherical_volume_bounding_box.cpp index eba0cca9..6835b417 100644 --- a/testing/apps/tests/structured_spherical_volume_bounding_box.cpp +++ b/testing/apps/tests/structured_spherical_volume_bounding_box.cpp @@ -88,6 +88,7 @@ void test_bounding_box(const vec3i &dimensions, } } +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL TEST_CASE("Structured spherical volume bounding box", "[volume_bounding_box]") { initializeOpenVKL(); @@ -160,3 +161,4 @@ TEST_CASE("Structured spherical volume bounding box", "[volume_bounding_box]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_spherical_volume_sampling.cpp b/testing/apps/tests/structured_spherical_volume_sampling.cpp index 2df28e41..5278d90b 100644 --- a/testing/apps/tests/structured_spherical_volume_sampling.cpp +++ b/testing/apps/tests/structured_spherical_volume_sampling.cpp @@ -62,6 +62,7 @@ void sampling_on_interior_vertices_vs_procedural_values(vec3i dimensions, vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL TEST_CASE("Structured spherical volume sampling", "[volume_sampling]") { initializeOpenVKL(); @@ -163,3 +164,4 @@ TEST_CASE("Structured spherical volume sampling", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_volume_gradients.cpp b/testing/apps/tests/structured_volume_gradients.cpp index 4d536976..1c9551ea 100644 --- a/testing/apps/tests/structured_volume_gradients.cpp +++ b/testing/apps/tests/structured_volume_gradients.cpp @@ -28,7 +28,7 @@ void scalar_gradients(float tolerance = 0.1f, bool skipBoundaries = true) auto v = rkcommon::make_unique( dimensions, gridOrigin, gridSpacing); - VKLVolume vklVolume = v->getVKLVolume(getOpenVKLDevice()); + VKLVolume vklVolume = v->getVKLVolume(getOpenVKLDevice()); VKLSampler vklSampler = vklNewSampler(vklVolume); vklCommit(vklSampler); @@ -66,10 +66,13 @@ void scalar_gradients(float tolerance = 0.1f, bool skipBoundaries = true) vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR || \ + OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL TEST_CASE("Structured volume gradients", "[volume_gradients]") { initializeOpenVKL(); +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("XYZStructuredRegularVolume") { scalar_gradients>(); @@ -79,11 +82,15 @@ TEST_CASE("Structured volume gradients", "[volume_gradients]") { scalar_gradients>(); } +#endif +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL SECTION("XYZStructuredSphericalVolume") { scalar_gradients>(); } +#endif shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/structured_volume_value_range.cpp b/testing/apps/tests/structured_volume_value_range.cpp index eb18d303..605b9b59 100644 --- a/testing/apps/tests/structured_volume_value_range.cpp +++ b/testing/apps/tests/structured_volume_value_range.cpp @@ -38,46 +38,82 @@ void computed_vs_api_value_range(vec3i dimensions = vec3i(128)) apiValueRange.upper == computedValueRange.upper)); } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR || \ + OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL TEST_CASE("Structured volume value range", "[volume_value_range]") { initializeOpenVKL(); - SECTION("unsigned char") +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR + SECTION("structuredRegular") { - computed_vs_api_value_range(); - computed_vs_api_value_range(); + SECTION("unsigned char") + { + computed_vs_api_value_range(); + } + + SECTION("short") + { + computed_vs_api_value_range(); + } + + SECTION("unsigned short") + { + computed_vs_api_value_range(); + } + + SECTION("half") + { + computed_vs_api_value_range(); + } + + SECTION("float") + { + computed_vs_api_value_range(); + } + + SECTION("double") + { + computed_vs_api_value_range(); + } } +#endif - SECTION("short") +#if OPENVKL_DEVICE_CPU_STRUCTURED_SPHERICAL + SECTION("structuredSpherical") { - computed_vs_api_value_range(); - computed_vs_api_value_range(); - } - - SECTION("unsigned short") - { - computed_vs_api_value_range(); - computed_vs_api_value_range(); - } - - SECTION("half") - { - computed_vs_api_value_range(); - computed_vs_api_value_range(); - } - - SECTION("float") - { - computed_vs_api_value_range(); - computed_vs_api_value_range(); - } - - SECTION("double") - { - computed_vs_api_value_range(); - computed_vs_api_value_range(); + SECTION("unsigned char") + { + computed_vs_api_value_range(); + } + + SECTION("short") + { + computed_vs_api_value_range(); + } + + SECTION("unsigned short") + { + computed_vs_api_value_range(); + } + + SECTION("half") + { + computed_vs_api_value_range(); + } + + SECTION("float") + { + computed_vs_api_value_range(); + } + + SECTION("double") + { + computed_vs_api_value_range(); + } } +#endif shutdownOpenVKL(); } - +#endif diff --git a/testing/apps/tests/unstructured_volume_gradients.cpp b/testing/apps/tests/unstructured_volume_gradients.cpp index f78f38f2..6c680546 100644 --- a/testing/apps/tests/unstructured_volume_gradients.cpp +++ b/testing/apps/tests/unstructured_volume_gradients.cpp @@ -21,7 +21,7 @@ void xyz_scalar_gradients(VKLUnstructuredCellType primType) primType, false)); - VKLVolume vklVolume = v->getVKLVolume(getOpenVKLDevice()); + VKLVolume vklVolume = v->getVKLVolume(getOpenVKLDevice()); VKLSampler vklSampler = vklNewSampler(vklVolume); vklCommit(vklSampler); @@ -54,6 +54,7 @@ void xyz_scalar_gradients(VKLUnstructuredCellType primType) vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED TEST_CASE("Unstructured volume gradients", "[volume_gradients]") { initializeOpenVKL(); @@ -65,3 +66,4 @@ TEST_CASE("Unstructured volume gradients", "[volume_gradients]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/unstructured_volume_sampling.cpp b/testing/apps/tests/unstructured_volume_sampling.cpp index f5727f38..dea7a7f6 100644 --- a/testing/apps/tests/unstructured_volume_sampling.cpp +++ b/testing/apps/tests/unstructured_volume_sampling.cpp @@ -94,6 +94,7 @@ void scalar_sampling_test_prim_geometry(VKLUnstructuredCellType primType, vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED TEST_CASE("Unstructured volume sampling", "[volume_sampling]") { initializeOpenVKL(); @@ -188,3 +189,4 @@ TEST_CASE("Unstructured volume sampling", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/unstructured_volume_strides.cpp b/testing/apps/tests/unstructured_volume_strides.cpp index 92ccceff..aca569ff 100644 --- a/testing/apps/tests/unstructured_volume_strides.cpp +++ b/testing/apps/tests/unstructured_volume_strides.cpp @@ -3,6 +3,7 @@ #include "unstructured_volume.h" +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED TEST_CASE("Unstructured volume strides", "[volume_strides]") { initializeOpenVKL(); @@ -62,3 +63,4 @@ TEST_CASE("Unstructured volume strides", "[volume_strides]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/unstructured_volume_value_range.cpp b/testing/apps/tests/unstructured_volume_value_range.cpp index 4bc33b81..86f6aacf 100644 --- a/testing/apps/tests/unstructured_volume_value_range.cpp +++ b/testing/apps/tests/unstructured_volume_value_range.cpp @@ -30,6 +30,7 @@ void computed_vs_api_value_range(vec3i dimensions, apiValueRange.upper == computedValueRange.upper)); } +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED TEST_CASE("Unstructured volume value range", "[volume_value_range]") { initializeOpenVKL(); @@ -56,3 +57,4 @@ TEST_CASE("Unstructured volume value range", "[volume_value_range]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vdb_volume.cpp b/testing/apps/tests/vdb_volume.cpp index 912c60a7..9e80f9fc 100644 --- a/testing/apps/tests/vdb_volume.cpp +++ b/testing/apps/tests/vdb_volume.cpp @@ -12,6 +12,7 @@ using openvkl::testing::TestingVdbTorusVolume; using openvkl::testing::WaveletVdbVolumeFloat; using openvkl::testing::XYZVdbVolumeFloat; +#if OPENVKL_DEVICE_CPU_VDB TEST_CASE("VDB volume leaf validation", "[validation]") { initializeOpenVKL(); @@ -914,3 +915,4 @@ TEST_CASE("VDB volume special cases", "[interval_iterators]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vdb_volume_dense.cpp b/testing/apps/tests/vdb_volume_dense.cpp index 1b5ce762..03196c6f 100644 --- a/testing/apps/tests/vdb_volume_dense.cpp +++ b/testing/apps/tests/vdb_volume_dense.cpp @@ -315,6 +315,7 @@ static void test_volume_equivalence_rotation(VKLVolume vklVolume1, } } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR && OPENVKL_DEVICE_CPU_VDB TEST_CASE("VDB volume dense consistency", "[volume_sampling]") { initializeOpenVKL(); @@ -398,3 +399,4 @@ TEST_CASE("VDB volume dense consistency", "[volume_sampling]") } #endif } +#endif diff --git a/testing/apps/tests/vdb_volume_inner_node_observer.cpp b/testing/apps/tests/vdb_volume_inner_node_observer.cpp index 644eb279..472f6e8f 100644 --- a/testing/apps/tests/vdb_volume_inner_node_observer.cpp +++ b/testing/apps/tests/vdb_volume_inner_node_observer.cpp @@ -128,6 +128,7 @@ inline void inner_node_tests(VKLVolume vklVolume, vec3i dimensions) vklRelease(vklSampler); } +#if OPENVKL_DEVICE_CPU_VDB TEST_CASE("VDB volume inner node observer", "[volume_observers]") { initializeOpenVKL(); @@ -181,3 +182,4 @@ TEST_CASE("VDB volume inner node observer", "[volume_observers]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vdb_volume_motion_blur.cpp b/testing/apps/tests/vdb_volume_motion_blur.cpp index 81d84373..e4272f9b 100644 --- a/testing/apps/tests/vdb_volume_motion_blur.cpp +++ b/testing/apps/tests/vdb_volume_motion_blur.cpp @@ -7,6 +7,7 @@ using namespace openvkl::testing; using openvkl::testing::WaveletVdbVolumeFloat; +#if OPENVKL_DEVICE_CPU_VDB TEST_CASE("VDB volume motion blur", "[volume_sampling]") { initializeOpenVKL(); @@ -43,3 +44,4 @@ TEST_CASE("VDB volume motion blur", "[volume_sampling]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vdb_volume_multi.cpp b/testing/apps/tests/vdb_volume_multi.cpp index 9723338e..14361f86 100644 --- a/testing/apps/tests/vdb_volume_multi.cpp +++ b/testing/apps/tests/vdb_volume_multi.cpp @@ -11,6 +11,7 @@ using namespace rkcommon; using namespace openvkl::testing; +#if OPENVKL_DEVICE_CPU_VDB TEST_CASE("VDB volume multiple attributes", "[volume_multi_attributes]") { initializeOpenVKL(); @@ -119,3 +120,4 @@ TEST_CASE("VDB volume multiple attributes", "[volume_multi_attributes]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vectorized_gradients.cpp b/testing/apps/tests/vectorized_gradients.cpp index 9c12fa8c..de7abd75 100644 --- a/testing/apps/tests/vectorized_gradients.cpp +++ b/testing/apps/tests/vectorized_gradients.cpp @@ -96,6 +96,7 @@ TEST_CASE("Vectorized gradients", "[volume_gradients]") { initializeOpenVKL(); +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION( "randomized vectorized gradients varying calling width and masks: " "structured volumes") @@ -108,7 +109,9 @@ TEST_CASE("Vectorized gradients", "[volume_gradients]") randomized_vectorized_gradients(volume); } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED SECTION( "randomized vectorized gradients varying calling width and masks: " "unstructured volumes") @@ -121,7 +124,9 @@ TEST_CASE("Vectorized gradients", "[volume_gradients]") randomized_vectorized_gradients(volume); } +#endif +#if OPENVKL_DEVICE_CPU_VDB SECTION( "randomized vectorized gradients varying calling width and masks: " "vdb volumes") @@ -142,6 +147,7 @@ TEST_CASE("Vectorized gradients", "[volume_gradients]") randomized_vectorized_gradients(volume2); } +#endif shutdownOpenVKL(); } diff --git a/testing/apps/tests/vectorized_hit_iterator.cpp b/testing/apps/tests/vectorized_hit_iterator.cpp index acfe5ec9..4fc47e76 100644 --- a/testing/apps/tests/vectorized_hit_iterator.cpp +++ b/testing/apps/tests/vectorized_hit_iterator.cpp @@ -169,6 +169,7 @@ void vector_hit_iteration_time_varying( } } +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Vectorized hit iterator", "[hit_iterators]") { initializeOpenVKL(); @@ -672,3 +673,4 @@ TEST_CASE("Vectorized hit iterator", "[hit_iterators]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vectorized_interval_iterator.cpp b/testing/apps/tests/vectorized_interval_iterator.cpp index 696dd884..b0f8f3a1 100644 --- a/testing/apps/tests/vectorized_interval_iterator.cpp +++ b/testing/apps/tests/vectorized_interval_iterator.cpp @@ -11,6 +11,7 @@ using namespace rkcommon; using namespace openvkl::testing; +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR TEST_CASE("Vectorized interval iterator", "[interval_iterators]") { initializeOpenVKL(); @@ -1081,3 +1082,4 @@ TEST_CASE("Vectorized interval iterator", "[interval_iterators]") shutdownOpenVKL(); } +#endif diff --git a/testing/apps/tests/vectorized_sampling.cpp b/testing/apps/tests/vectorized_sampling.cpp index c1c76ae3..a1034f02 100644 --- a/testing/apps/tests/vectorized_sampling.cpp +++ b/testing/apps/tests/vectorized_sampling.cpp @@ -16,7 +16,7 @@ void test_vectorized_sampling() auto v = rkcommon::make_unique(vec3i(128), vec3f(0.f), vec3f(1.f)); - VKLVolume vklVolume = v->getVKLVolume(getOpenVKLDevice()); + VKLVolume vklVolume = v->getVKLVolume(getOpenVKLDevice()); VKLSampler vklSampler = vklNewSampler(vklVolume); vklCommit(vklSampler); @@ -92,15 +92,19 @@ TEST_CASE("Vectorized sampling", "[volume_sampling]") { initializeOpenVKL(); +#if OPENVKL_DEVICE_CPU_STRUCTURED_REGULAR SECTION("structured") { test_vectorized_sampling>(); } +#endif +#if OPENVKL_DEVICE_CPU_UNSTRUCTURED SECTION("unstructured") { test_vectorized_sampling(); } +#endif shutdownOpenVKL(); } From 5e554900f926e96f165f49cf63e4cf352d991d4a Mon Sep 17 00:00:00 2001 From: Krzysztof Raszkowski Date: Tue, 15 Nov 2022 15:26:08 +0100 Subject: [PATCH 17/34] ci: add workflow with benchmarks --- .github/workflows/benchmark.yml | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..2f0b1e60 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,75 @@ +## Copyright 2022 Intel Corporation +## SPDX-License-Identifier: Apache-2.0 + +name: Benchmark + +on: + schedule: + - cron: '30 1 * * *' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + +### BUILD JOBS ### + build-centos7-icx: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main + with: + submodules: true + image: centos:7 + artifact-out: build-centos7-icx + artifact-path: ./build/install ./build/openvkl/build + cmd: | + module load cmake + module load intel/2022.1 + export CC=icx + export CXX=icpx + export CXXFLAGS="-fPIC -fp-model=precise" + export LDFLAGS="-static-intel" + gitlab/build.sh + +### Benchmarks ### + + benchmark-x8280-1: + needs: build-centos7-icx + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main + with: + runs-on: '["vis-perf-x8280-1"]' + cmd: | + gitlab/run-benchmarks.sh + artifact-in: build-centos7-icx + + benchmark-x8380-1: + if: github.event_name != 'schedule' + needs: build-centos7-icx + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main + with: + runs-on: '["vis-perf-x8380-1"]' + cmd: | + gitlab/run-benchmarks.sh + artifact-in: build-centos7-icx + + benchmark-a3970x-1: + if: github.event_name != 'schedule' + needs: build-centos7-icx + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main + with: + runs-on: '["vis-perf-a3970x-1"]' + cmd: | + gitlab/run-benchmarks.sh + artifact-in: build-centos7-icx + + benchmark-i9-12900k-1: + if: github.event_name != 'schedule' + needs: build-centos7-icx + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/perf.yml@main + with: + runs-on: '["vis-perf-i9-12900k-1"]' + cmd: | + gitlab/run-benchmarks.sh + artifact-in: build-centos7-icx + From f4d7f220b4823e2cc1b26ba6c9f09107d6291edf Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Mon, 13 Feb 2023 14:25:47 -0700 Subject: [PATCH 18/34] move to and require Embree v4.0.0. --- CMakeLists.txt | 2 +- openvkl/devices/cpu/volume/UnstructuredBVH.h | 2 +- superbuild/CMakeLists.txt | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c240d212..125943cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ get_target_property(RKCOMMON_INCLUDE_DIRS rkcommon::rkcommon # rkcommon includes FindTBB.cmake, needed by Embree set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${rkcommon_DIR}) -find_package(embree 3.13.1 REQUIRED) +find_package(embree 4.0.0 REQUIRED) openvkl_create_embree_target() ## Build library, examples, and tests ## diff --git a/openvkl/devices/cpu/volume/UnstructuredBVH.h b/openvkl/devices/cpu/volume/UnstructuredBVH.h index 9d6d86a4..cc36f377 100644 --- a/openvkl/devices/cpu/volume/UnstructuredBVH.h +++ b/openvkl/devices/cpu/volume/UnstructuredBVH.h @@ -6,7 +6,7 @@ #include #include #include "../common/math.h" -#include "embree3/rtcore.h" +#include "embree4/rtcore.h" #include "rkcommon/tasking/parallel_for.h" namespace openvkl { diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index c5a5d467..ce934e3b 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -166,23 +166,23 @@ endif() option(BUILD_EMBREE "Build Intel Embree or search in environment?" ON) option(BUILD_EMBREE_FROM_SOURCE "Build Embree from source or use pre-built version? (Only used when BUILD_EMBREE=ON)" ON) if (BUILD_EMBREE) - set(EMBREE_VERSION "v3.13.5" CACHE STRING "Embree version to download") + set(EMBREE_VERSION "v4.0.0" CACHE STRING "Embree version to download") if (BUILD_EMBREE_FROM_SOURCE) set(_EMBREE_URL "https://github.com/embree/embree/archive/${EMBREE_VERSION}.zip") - set(_EMBREE_HASH "036be94d1023ce8d31d3f054a7b00505dfda057f26f8f7fc1865392fbc50656d") + set(_EMBREE_HASH "e00d1f6f19ff12d7067420a081afc994744d4862f95c527bfb0436f5f0908794") else() # Embree binary package URLs do not use the "v" prefix string(REPLACE "v" "" EMBREE_VERSION_NUMBER ${EMBREE_VERSION}) set(EMBREE_BASE_URL "https://github.com/embree/embree/releases/download/${EMBREE_VERSION}") if (APPLE) set(_EMBREE_URL "${EMBREE_BASE_URL}/embree-${EMBREE_VERSION_NUMBER}.x86_64.macosx.zip") - set(_EMBREE_HASH "699c10a62b4440abd50b01ad2b8e855236ebae2029b6081c9627049ad886e6da") + set(_EMBREE_HASH "837c49702d688623b48ba40ee10fb39f9dd39be6b73ccb4d910c32c5d5415836") elseif (WIN32) set(_EMBREE_URL "${EMBREE_BASE_URL}/embree-${EMBREE_VERSION_NUMBER}.x64.vc14.windows.zip") - set(_EMBREE_HASH "0ea932e2d5953c6816490a6c7e384646f7d35c59092286a00abf47cd931b8ac6") + set(_EMBREE_HASH "4f375d71d70b4fcf1dd18ca88f26a1255ff0d827bf3db62a88f204cc9089dc1f") else() set(_EMBREE_URL "${EMBREE_BASE_URL}/embree-${EMBREE_VERSION_NUMBER}.x86_64.linux.tar.gz") - set(_EMBREE_HASH "6454c9793e50213f681a34be3b0128f263caad0d663a1409f0bc2f98644bfa98") + set(_EMBREE_HASH "524842e2f141dca0db584c33a0821176373e7058f3ec2201bfb19d9e9a1b80b9") endif() endif() set(EMBREE_URL "${_EMBREE_URL}" CACHE STRING "URL of the Embree source archive.") From e7163c478a7a7ee907c7580f88cb87f48e1e6cfa Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Wed, 15 Feb 2023 12:22:14 -0700 Subject: [PATCH 19/34] CI: remove build-centos7-icc15 job. --- .github/workflows/ci.linux.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/ci.linux.yml b/.github/workflows/ci.linux.yml index c53feb1e..bb62003c 100644 --- a/.github/workflows/ci.linux.yml +++ b/.github/workflows/ci.linux.yml @@ -62,21 +62,6 @@ jobs: ./build/openvkl/build/vklTutorialISPC ./build/openvkl/build/vklTests --durations yes - build-centos7-icc15: - secrets: inherit - uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main - with: - submodules: true - #ICC 2015 req. old GCC (<7.0?) this is why we're using old docker image - image: ospray/docker-images:centos7-mod - cmd: | - module load cmake - module load intel/2015 - export CC=icc - export CXX=icpc - export CXXFLAGS="-static-intel -fPIC" - gitlab/build.sh - build-centos7-icx: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main From 1efce659ceeca31441602c39a08847a07c276b8a Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 16 Feb 2023 11:37:39 -0700 Subject: [PATCH 20/34] CI: use force-delete flag in build jobs. --- .github/workflows/benchmark.yml | 1 + .github/workflows/ci.linux.single_volume.yml | 7 +++++++ .github/workflows/ci.linux.yml | 17 +++++++++++++++++ .github/workflows/ci.mac.yml | 3 +++ .github/workflows/ci.windows.yml | 2 ++ .github/workflows/release.yml | 3 +++ 6 files changed, 33 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 2f0b1e60..073b1313 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -19,6 +19,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:7 artifact-out: build-centos7-icx diff --git a/.github/workflows/ci.linux.single_volume.yml b/.github/workflows/ci.linux.single_volume.yml index 18740d3e..f7a2625c 100644 --- a/.github/workflows/ci.linux.single_volume.yml +++ b/.github/workflows/ci.linux.single_volume.yml @@ -15,6 +15,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-amr @@ -26,6 +27,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-particle @@ -37,6 +39,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-structuredRegular @@ -48,6 +51,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-structuredRegularLegacy @@ -59,6 +63,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-structuredSpherical @@ -70,6 +75,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-unstructured @@ -81,6 +87,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-vdb diff --git a/.github/workflows/ci.linux.yml b/.github/workflows/ci.linux.yml index bb62003c..b0c24af1 100644 --- a/.github/workflows/ci.linux.yml +++ b/.github/workflows/ci.linux.yml @@ -15,6 +15,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:7 artifact-out: build-centos7 @@ -38,6 +39,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:7 artifact-out: build-centos7-icc @@ -66,6 +68,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:7 artifact-out: build-centos7-icx @@ -95,6 +98,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:7 artifact-out: build-centos7-icx-tbb2020 @@ -124,6 +128,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:7 artifact-out: build-centos7-icx-tbb2020-avx512_8 @@ -153,6 +158,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-centos8 @@ -177,6 +183,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: centos:8 artifact-out: build-centos8-module-cmake @@ -201,6 +208,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ubuntu:18.04 artifact-out: build-ubuntu18_04 @@ -212,6 +220,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ubuntu:20.04 artifact-out: build-ubuntu20_04 @@ -223,6 +232,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ubuntu:22.04 artifact-out: build-ubuntu22_04 @@ -273,6 +283,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-arch @@ -296,6 +307,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-arch-clang @@ -321,6 +333,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-arch-address-sanitizer @@ -347,6 +360,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-arch-debug @@ -370,6 +384,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-arch-TBB2020 @@ -393,6 +408,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-arch-devel-rkdeps @@ -416,6 +432,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true image: ospray/docker-images:arch artifact-out: build-linux-arch diff --git a/.github/workflows/ci.mac.yml b/.github/workflows/ci.mac.yml index f7f3972e..dca3b7a1 100644 --- a/.github/workflows/ci.mac.yml +++ b/.github/workflows/ci.mac.yml @@ -15,6 +15,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' artifact-out: build-macOS @@ -39,6 +40,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' artifact-out: build-macOS-TBB2020 @@ -63,6 +65,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "macOS", "build", "arm" ]' artifact-out: build-macOS-arm diff --git a/.github/workflows/ci.windows.yml b/.github/workflows/ci.windows.yml index 701c1c6b..2d5ed5f7 100644 --- a/.github/workflows/ci.windows.yml +++ b/.github/workflows/ci.windows.yml @@ -15,6 +15,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "Windows", "build" ]' artifact-out: build-windows-msvc15 @@ -25,6 +26,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "Windows", "build" ]' artifact-out: build-windows-msvc15-TBB2020 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5185164e..8eab88d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,6 +41,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "Linux", "docker" ]' image: centos:7 @@ -60,6 +61,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/windows.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "Windows", "NAS", "build" ]' artifact-out: release-windows @@ -73,6 +75,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: + force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "macOS", "sign", "avx2", "x86_64" ]' artifact-out: release-macos From 123ad8317a6aabd6338edb87fbb7891c0f6f42f2 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 14 Feb 2023 12:48:12 -0700 Subject: [PATCH 21/34] superbuild: update to GLFW 3.3.8 and apply patch. --- .gitattributes | 3 +- .../imgui-1.83/examples/libs/gl3w/GL/gl3w.c | 2 +- superbuild/CMakeLists.txt | 4 +- superbuild/dependencies/dep_glfw.cmake | 6 + superbuild/dependencies/glfw.patch | 112 ++++++++++++++++++ 5 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 superbuild/dependencies/glfw.patch diff --git a/.gitattributes b/.gitattributes index d8f243ea..f5c7d578 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -*.rc text working-tree-encoding=UTF-16LE-BOM eol=CRLF \ No newline at end of file +*.rc text working-tree-encoding=UTF-16LE-BOM eol=CRLF +glfw.patch eol=lf diff --git a/examples/interactive/imgui-1.83/examples/libs/gl3w/GL/gl3w.c b/examples/interactive/imgui-1.83/examples/libs/gl3w/GL/gl3w.c index 464e0177..2e3e6fcd 100644 --- a/examples/interactive/imgui-1.83/examples/libs/gl3w/GL/gl3w.c +++ b/examples/interactive/imgui-1.83/examples/libs/gl3w/GL/gl3w.c @@ -13,7 +13,7 @@ static HMODULE libgl; static void open_libgl(void) { - libgl = LoadLibraryA("opengl32.dll"); + libgl = LoadLibraryExA("opengl32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); } static void close_libgl(void) diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index ce934e3b..fece70a7 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -193,10 +193,10 @@ endif() option(BUILD_GLFW "Build glfw or search in environment?" ON) if (BUILD_GLFW) - set(GLFW_VERSION "3.2.1") + set(GLFW_VERSION "3.3.8") set(GLFW_URL "https://github.com/glfw/glfw/archive/${GLFW_VERSION}.zip" CACHE STRING "URL of the GLFW source archive.") - set(GLFW_HASH "0c623f65a129c424d0fa45591694fde3719ad4a0955d4835182fda71b255446f" + set(GLFW_HASH "8106e1a432305a8780b986c24922380df6a009a96b2ca590392cb0859062c8ff" CACHE STRING "SHA256 hash of the GLFW source archive.") include(dep_glfw) endif() diff --git a/superbuild/dependencies/dep_glfw.cmake b/superbuild/dependencies/dep_glfw.cmake index a65f57a8..df768be4 100644 --- a/superbuild/dependencies/dep_glfw.cmake +++ b/superbuild/dependencies/dep_glfw.cmake @@ -16,6 +16,12 @@ ExternalProject_Add(${COMPONENT_NAME} BINARY_DIR ${COMPONENT_NAME}/build URL ${GLFW_URL} URL_HASH SHA256=${GLFW_HASH} + # `patch` is not available on all systems, so use `git apply` instead. Note + # that we initialize a Git repo in the GLFW download directory to allow the + # Git patching approach to work. Also note that we don't want to actually + # check out the GLFW Git repo, since we want our GLFW_HASH security checks + # to still function correctly. + PATCH_COMMAND git init -q . && git apply -v -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/glfw.patch CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_INSTALL_PREFIX:PATH=${COMPONENT_PATH} diff --git a/superbuild/dependencies/glfw.patch b/superbuild/dependencies/glfw.patch new file mode 100644 index 00000000..d2f58d7c --- /dev/null +++ b/superbuild/dependencies/glfw.patch @@ -0,0 +1,112 @@ +From 8dfd5804447a1f35c15e650737fee3694bc71f26 Mon Sep 17 00:00:00 2001 +From: Florian Reibold +Date: Mon, 6 Feb 2023 17:29:44 +0100 +Subject: [PATCH] fix LoadLibraryA + +--- + src/null_platform.h | 2 +- + src/wgl_context.c | 2 +- + src/win32_init.c | 12 ++++++------ + src/win32_platform.h | 2 +- + 4 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/src/null_platform.h b/src/null_platform.h +index 708975d1..d916b922 100644 +--- a/src/null_platform.h ++++ b/src/null_platform.h +@@ -43,7 +43,7 @@ + #include "null_joystick.h" + + #if defined(_GLFW_WIN32) +- #define _glfw_dlopen(name) LoadLibraryA(name) ++ #define _glfw_dlopen(name) LoadLibraryExA(name,NULL,LOAD_LIBRARY_SEARCH_SYSTEM32) + #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) + #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) + #else +diff --git a/src/wgl_context.c b/src/wgl_context.c +index 72ad11de..5c42fa81 100644 +--- a/src/wgl_context.c ++++ b/src/wgl_context.c +@@ -416,7 +416,7 @@ GLFWbool _glfwInitWGL(void) + if (_glfw.wgl.instance) + return GLFW_TRUE; + +- _glfw.wgl.instance = LoadLibraryA("opengl32.dll"); ++ _glfw.wgl.instance = LoadLibraryExA("opengl32.dll",NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (!_glfw.wgl.instance) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, +diff --git a/src/win32_init.c b/src/win32_init.c +index 885f32fa..5e698cc2 100644 +--- a/src/win32_init.c ++++ b/src/win32_init.c +@@ -82,7 +82,7 @@ static GLFWbool loadLibraries(void) + return GLFW_FALSE; + } + +- _glfw.win32.user32.instance = LoadLibraryA("user32.dll"); ++ _glfw.win32.user32.instance = LoadLibraryExA("user32.dll",NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (!_glfw.win32.user32.instance) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, +@@ -105,7 +105,7 @@ static GLFWbool loadLibraries(void) + _glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi) + GetProcAddress(_glfw.win32.user32.instance, "GetSystemMetricsForDpi"); + +- _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll"); ++ _glfw.win32.dinput8.instance = LoadLibraryExA("dinput8.dll",NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (_glfw.win32.dinput8.instance) + { + _glfw.win32.dinput8.Create = (PFN_DirectInput8Create) +@@ -126,7 +126,7 @@ static GLFWbool loadLibraries(void) + + for (i = 0; names[i]; i++) + { +- _glfw.win32.xinput.instance = LoadLibraryA(names[i]); ++ _glfw.win32.xinput.instance = LoadLibraryExA(names[i],NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (_glfw.win32.xinput.instance) + { + _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities) +@@ -139,7 +139,7 @@ static GLFWbool loadLibraries(void) + } + } + +- _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll"); ++ _glfw.win32.dwmapi.instance = LoadLibraryExA("dwmapi.dll",NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (_glfw.win32.dwmapi.instance) + { + _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled) +@@ -152,7 +152,7 @@ static GLFWbool loadLibraries(void) + GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor"); + } + +- _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll"); ++ _glfw.win32.shcore.instance = LoadLibraryExA("shcore.dll",NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (_glfw.win32.shcore.instance) + { + _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness) +@@ -161,7 +161,7 @@ static GLFWbool loadLibraries(void) + GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor"); + } + +- _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll"); ++ _glfw.win32.ntdll.instance = LoadLibraryExA("ntdll.dll",NULL,LOAD_LIBRARY_SEARCH_SYSTEM32); + if (_glfw.win32.ntdll.instance) + { + _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo) +diff --git a/src/win32_platform.h b/src/win32_platform.h +index bf703d7e..55b8425b 100644 +--- a/src/win32_platform.h ++++ b/src/win32_platform.h +@@ -289,7 +289,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( + #define _GLFW_WNDCLASSNAME L"GLFW30" + #endif + +-#define _glfw_dlopen(name) LoadLibraryA(name) ++#define _glfw_dlopen(name) LoadLibraryExA(name,NULL,LOAD_LIBRARY_SEARCH_SYSTEM32) + #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) + #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) + +-- +2.38.1.windows.1 + From 12fe92d406059fbd81cc4f80939a0277af92d93b Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 16 Feb 2023 14:47:33 -0700 Subject: [PATCH 22/34] move to and require rkcommon v1.11.0. --- CMakeLists.txt | 2 +- superbuild/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 125943cb..70b69b29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ openvkl_configure_build_type() openvkl_configure_global_build_flags() openvkl_configure_ispc_isa() -set(RKCOMMON_VERSION_REQUIRED 1.8.0) +set(RKCOMMON_VERSION_REQUIRED 1.11.0) find_package(rkcommon ${RKCOMMON_VERSION_REQUIRED} REQUIRED) get_target_property(RKCOMMON_INCLUDE_DIRS rkcommon::rkcommon INTERFACE_INCLUDE_DIRECTORIES) diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index fece70a7..9998445d 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -153,10 +153,10 @@ endif() option(BUILD_RKCOMMON "Build rkcommon or search in environment?" ON) if (BUILD_RKCOMMON) - set(RKCOMMON_VERSION "v1.10.0" CACHE STRING "rkcommon version to download") + set(RKCOMMON_VERSION "v1.11.0" CACHE STRING "rkcommon version to download") set(RKCOMMON_URL "https://github.com/ospray/rkcommon/archive/${RKCOMMON_VERSION}.zip" CACHE STRING "URL of the rkcommon archive.") - set(RKCOMMON_HASH "eb968868b85254680c59ff3e091e9a7634d407cf0375d2b52840bf9044716a48" + set(RKCOMMON_HASH "8e70462a2d6a882040b9968ed7d820dbae56d02668041b186afccc9043ab3df9" CACHE STRING "SHA256 hash of the rkcommon archive.") include(dep_rkcommon) endif() From dd45ab0f55c61d4130638d04ab92756a77f7314b Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 16 Feb 2023 14:55:18 -0700 Subject: [PATCH 23/34] loadLocalModule: use anchoring. --- openvkl/common/VKLCommon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openvkl/common/VKLCommon.cpp b/openvkl/common/VKLCommon.cpp index a01d7244..2aab265e 100644 --- a/openvkl/common/VKLCommon.cpp +++ b/openvkl/common/VKLCommon.cpp @@ -16,7 +16,8 @@ namespace openvkl { { const std::string libName = "openvkl_module_" + moduleName; - rkcommon::loadLibrary(libName); + rkcommon::loadLibrary(libName, + reinterpret_cast(&loadLocalModule)); std::string initSymName = "openvkl_init_module_" + moduleName; void *initSym = rkcommon::getSymbol(initSymName); From 37740961425327fb78b05a32af843b3bf27d2c88 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 21 Feb 2023 15:05:32 -0700 Subject: [PATCH 24/34] CPU device: use loadLocalModule() for loading cpu_[4,8,16] libs. this guarantees anchored loads from libopenvkl_module_cpu_device to libopenvkl_module_cpu_device_[4,8,16] --- openvkl/devices/cpu/CMakeLists.txt | 2 -- openvkl/devices/cpu/exports.cpp | 21 +++++++++++++++---- .../devices/cpu/iterator/IteratorContext.h | 2 +- openvkl/devices/cpu/sampler/Sampler.h | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/openvkl/devices/cpu/CMakeLists.txt b/openvkl/devices/cpu/CMakeLists.txt index d65ae03c..5db9a793 100644 --- a/openvkl/devices/cpu/CMakeLists.txt +++ b/openvkl/devices/cpu/CMakeLists.txt @@ -263,8 +263,6 @@ target_include_directories(openvkl_module_cpu_device target_link_libraries(openvkl_module_cpu_device PUBLIC openvkl - PRIVATE - ${ACTIVE_WIDTH_TARGETS} ) openvkl_install_library(openvkl_module_cpu_device) diff --git a/openvkl/devices/cpu/exports.cpp b/openvkl/devices/cpu/exports.cpp index 7c377902..0dcd8acd 100644 --- a/openvkl/devices/cpu/exports.cpp +++ b/openvkl/devices/cpu/exports.cpp @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include "api/CPUDevice.h" -#include "openvkl/common/ManagedObject.h" +#include "../common/ManagedObject.h" +#include "../common/VKLCommon.h" // For Windows in particular, we need registered object creation functions // available in the top level module library, as exports from dependencies will @@ -27,14 +28,26 @@ VKL_WRAP_MODULE_REGISTRATION(cpu_device_16) extern "C" OPENVKL_DLLEXPORT void openvkl_init_module_cpu_device() { #if VKL_TARGET_WIDTH_ENABLED_4 - openvkl_init_module_cpu_device_4(); + try { + openvkl::loadLocalModule("cpu_device_4"); + } catch (const std::exception &e) { + openvkl::postLogMessage(nullptr, e.what(), VKL_LOG_ERROR); + } #endif #if VKL_TARGET_WIDTH_ENABLED_8 - openvkl_init_module_cpu_device_8(); + try { + openvkl::loadLocalModule("cpu_device_8"); + } catch (const std::exception &e) { + openvkl::postLogMessage(nullptr, e.what(), VKL_LOG_ERROR); + } #endif #if VKL_TARGET_WIDTH_ENABLED_16 - openvkl_init_module_cpu_device_16(); + try { + openvkl::loadLocalModule("cpu_device_16"); + } catch (const std::exception &e) { + openvkl::postLogMessage(nullptr, e.what(), VKL_LOG_ERROR); + } #endif } diff --git a/openvkl/devices/cpu/iterator/IteratorContext.h b/openvkl/devices/cpu/iterator/IteratorContext.h index e56f492d..5288aa69 100644 --- a/openvkl/devices/cpu/iterator/IteratorContext.h +++ b/openvkl/devices/cpu/iterator/IteratorContext.h @@ -4,7 +4,7 @@ #pragma once #include "../common/ManagedObject.h" -#include "openvkl/common/StructShared.h" +#include "../common/StructShared.h" #include "IteratorContextShared.h" using namespace rkcommon::math; diff --git a/openvkl/devices/cpu/sampler/Sampler.h b/openvkl/devices/cpu/sampler/Sampler.h index 4141edc9..3904e4ed 100644 --- a/openvkl/devices/cpu/sampler/Sampler.h +++ b/openvkl/devices/cpu/sampler/Sampler.h @@ -10,7 +10,7 @@ #include "../observer/Observer.h" #include "openvkl/openvkl.h" #include "rkcommon/math/vec.h" -#include "openvkl/common/StructShared.h" +#include "../common/StructShared.h" #include "SamplerShared.h" using namespace rkcommon; From bc8a46d70ec6bca633b4ea083f1e1b1ce3fd4e46 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 21 Feb 2023 15:22:01 -0700 Subject: [PATCH 25/34] openvkl.isph: include version.h. --- CMakeLists.txt | 14 ++++++++++++++ examples/ispc/CMakeLists.txt | 2 -- openvkl/CMakeLists.txt | 13 +------------ openvkl/include/openvkl/openvkl.isph | 1 + 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70b69b29..d886a19a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,20 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) include(openvkl_macros) include(openvkl_ispc) +## Version header ## + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/openvkl/include/${PROJECT_NAME}/version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/openvkl/include/${PROJECT_NAME}/version.h + @ONLY +) + +include_directories_ispc(${CMAKE_CURRENT_BINARY_DIR}/openvkl/include/${PROJECT_NAME}) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvkl/include/${PROJECT_NAME}/version.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} +) + ## openvkl specific configuration ## option(BUILD_EXAMPLES "Build example applications." ON) diff --git a/examples/ispc/CMakeLists.txt b/examples/ispc/CMakeLists.txt index a8ad4b39..98386321 100644 --- a/examples/ispc/CMakeLists.txt +++ b/examples/ispc/CMakeLists.txt @@ -1,8 +1,6 @@ ## Copyright 2019 Intel Corporation ## SPDX-License-Identifier: Apache-2.0 -include(openvkl_ispc) - macro(add_executable_ispc name) set(ISPC_SOURCES "") set(OTHER_SOURCES "") diff --git a/openvkl/CMakeLists.txt b/openvkl/CMakeLists.txt index ae9f6157..5c861eef 100644 --- a/openvkl/CMakeLists.txt +++ b/openvkl/CMakeLists.txt @@ -79,23 +79,12 @@ install(FILES ${PROJECT_SOURCE_DIR}/CHANGELOG.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) -## Version header ## - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/version.h.in - ${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.h - @ONLY -) - +# needed for build-time generated version.h target_include_directories(${PROJECT_NAME} PUBLIC $ ) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} -) - ## Add OpenVKL devices ## add_subdirectory(devices) diff --git a/openvkl/include/openvkl/openvkl.isph b/openvkl/include/openvkl/openvkl.isph index 408a2b27..ef018e07 100644 --- a/openvkl/include/openvkl/openvkl.isph +++ b/openvkl/include/openvkl/openvkl.isph @@ -9,4 +9,5 @@ #include "device.isph" #include "iterator.isph" #include "sampler.isph" +#include "version.h" #include "volume.isph" From fcf390c856a584ec84ae2886b60025d97f548e03 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 23 Feb 2023 08:37:02 -0700 Subject: [PATCH 26/34] CI: correct tags for macOS jobs. --- .github/workflows/ci.mac.yml | 8 ++++---- .github/workflows/release.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.mac.yml b/.github/workflows/ci.mac.yml index dca3b7a1..9151872a 100644 --- a/.github/workflows/ci.mac.yml +++ b/.github/workflows/ci.mac.yml @@ -17,7 +17,7 @@ jobs: with: force-delete: true # guarantees .gitattributes are respected in working dir submodules: true - runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' + runs-on: '[ "macOS", "build", "x86_64" ]' artifact-out: build-macOS artifact-path: ./build/install ./build/openvkl/build cmd: | @@ -28,7 +28,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: - runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' + runs-on: '[ "macOS", "build", "x86_64" ]' artifact-in: build-macOS cmd: | export DYLD_LIBRARY_PATH=./build/install/lib @@ -42,7 +42,7 @@ jobs: with: force-delete: true # guarantees .gitattributes are respected in working dir submodules: true - runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' + runs-on: '[ "macOS", "build", "x86_64" ]' artifact-out: build-macOS-TBB2020 artifact-path: ./build/install ./build/openvkl/build cmd: | @@ -53,7 +53,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: - runs-on: '[ "macOS", "build", "avx2", "x86_64" ]' + runs-on: '[ "macOS", "build", "x86_64" ]' artifact-in: build-macOS-TBB2020 cmd: | export DYLD_LIBRARY_PATH=./build/install/lib diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8eab88d9..b019f0c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,7 +77,7 @@ jobs: with: force-delete: true # guarantees .gitattributes are respected in working dir submodules: true - runs-on: '[ "macOS", "sign", "avx2", "x86_64" ]' + runs-on: '[ "macOS", "sign", "x86_64" ]' artifact-out: release-macos artifact-path: ./*.zip cmd: | @@ -113,7 +113,7 @@ jobs: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: - runs-on: '[ "macOS", "avx2", "x86_64" ]' + runs-on: '[ "macOS", "build", "x86_64" ]' artifact-in: release-macos cmd: | export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" From f89a894b977b4e15e47da9f7833543069c24b506 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 23 Feb 2023 08:49:00 -0700 Subject: [PATCH 27/34] CI: remove no longer used scripts. --- gitlab/.gitlab-ci.yml | 742 ----------------------------------- gitlab/bdba.sh | 61 --- gitlab/build-kw-scan.sh | 50 --- gitlab/kw-check-issues.sh | 21 - gitlab/kw-gen-report.sh | 39 -- gitlab/source-scan-protex.sh | 31 -- gitlab/store-files.sh | 11 - 7 files changed, 955 deletions(-) delete mode 100644 gitlab/.gitlab-ci.yml delete mode 100755 gitlab/bdba.sh delete mode 100755 gitlab/build-kw-scan.sh delete mode 100755 gitlab/kw-check-issues.sh delete mode 100755 gitlab/kw-gen-report.sh delete mode 100755 gitlab/source-scan-protex.sh delete mode 100755 gitlab/store-files.sh diff --git a/gitlab/.gitlab-ci.yml b/gitlab/.gitlab-ci.yml deleted file mode 100644 index 3b96cc90..00000000 --- a/gitlab/.gitlab-ci.yml +++ /dev/null @@ -1,742 +0,0 @@ -## Copyright 2019 Intel Corporation -## SPDX-License-Identifier: Apache-2.0 - -variables: - GIT_DEPTH: "15" - KW_PROJECT_NAME: openvkl - OPENVKL_RELEASE_PACKAGE_VERSION: "1.4.0" - MACOSX_DEPLOYMENT_TARGET: "10.13" - -default: - interruptible: true - retry: - max: 2 - when: - - unknown_failure - - api_failure - - runner_system_failure - - scheduler_failure - -stages: - - pre - - build - - test - - benchmark - - scan1 - - scan2 - - release - - release-test - - scan-binaries - -## Job Templates ## - -.job_template: &base_build_job - stage: build - script: - - gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF - artifacts: - paths: - - build/install - - build/openvkl/build - before_script: - - git config --global --add safe.directory $CI_PROJECT_DIR - - git submodule sync - - git submodule init - - git submodule update - -.job_template: &build_job_docker - <<: *base_build_job - tags: - - docker - -.job_template: &build_job_docker_centos7_modules - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7-mod - script: - - gitlab/build.sh - tags: - - docker - - modules - -.job_template: &base_build_from_install_job - stage: test - script: - - gitlab/build-from-install.sh - -.job_template: &build_from_install_job_docker - <<: *base_build_from_install_job - tags: - - docker - -.job_template: &base_functional_test_job - stage: test - script: - - ./build/openvkl/build/vklTutorial - - ./build/openvkl/build/vklTutorialISPC - - ./build/openvkl/build/vklTests --durations yes - -.job_template: &test_functional_job_docker - <<: *base_functional_test_job - tags: - - docker - -# Ubuntu test runs require LD_LIBRARY_PATH to be set -.job_template: &test_functional_job_docker_ubuntu - <<: *test_functional_job_docker - script: - - export LD_LIBRARY_PATH=./build/install/lib - - ./build/openvkl/build/vklTutorial - - ./build/openvkl/build/vklTutorialISPC - - ./build/openvkl/build/vklTests --durations yes - -.job_template: &master_release_devel_only - only: - - master - - /release/ - - devel - -.job_template: &base_release_job - <<: *master_release_devel_only - stage: release - before_script: - - git config --global --add safe.directory $CI_PROJECT_DIR - - git submodule sync - - git submodule init - - git submodule update - -.job_template: &base_release_test_job - <<: *master_release_devel_only - stage: release-test - -## Job Templates: Benchmarks ## - -.job_template: &base_benchmark_job - stage: benchmark - needs: - - build-centos7-icx - script: - - gitlab/run-benchmarks.sh - -# the below can be merged in to run only specific benchmark suites - -.job_template: &benchmark_select_structured - variables: - BENCHMARK_SUITE: ^StructuredVolume$ - -.job_template: &benchmark_select_structured-multi - variables: - BENCHMARK_SUITE: ^StructuredVolumeMulti$ - -.job_template: &benchmark_select_vdb - variables: - BENCHMARK_SUITE: ^VDBVolume$ - -.job_template: &benchmark_select_vdb-multi - variables: - BENCHMARK_SUITE: ^VDBVolumeMulti$ - -.job_template: &benchmark_select_examples - variables: - BENCHMARK_SUITE: ^ExampleRenderers$ - -## Pre Jobs ## - -# Do not allow pipelines for master, release, or devel branches to be -# interrupted. See https://gitlab.com/gitlab-org/gitlab/-/issues/34221 -non-interruptible-pipeline: - <<: *master_release_devel_only - stage: pre - interruptible: false - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - script: - - echo this is a non-interruptible pipeline - tags: - - docker - -## Build Jobs ## - -build-centos7: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - script: - - gitlab/build.sh - -build-centos7-icc: - <<: *build_job_docker_centos7_modules - script: - - module load cmake - - module load intel/2019.4 - - export CC=icc - - export CXX=icpc - - export CXXFLAGS="-static-intel -fPIC" - - gitlab/build.sh - -build-centos7-icc15: - <<: *build_job_docker_centos7_modules - script: - - module load cmake - - module load intel/2015 - - export CC=icc - - export CXX=icpc - - export CXXFLAGS="-static-intel -fPIC" - - gitlab/build.sh - -build-centos7-icx: - <<: *build_job_docker - image: $DOCKER_REGISTRY/centos:7 # enables modules and loads devtoolset-7 - script: - - module load cmake - - module load intel/2022.1 - - export CC=icx - - export CXX=icpx - - export CXXFLAGS="-fPIC -fp-model=precise" - - export LDFLAGS="-static-intel" - - gitlab/build.sh - -build-centos7-icx-tbb2020: - <<: *build_job_docker - image: $DOCKER_REGISTRY/centos:7 # enables modules and loads devtoolset-7 - script: - - module load cmake - - module load intel/2022.1 - - export CC=icx - - export CXX=icpx - - export CXXFLAGS="-fPIC -fp-model=precise" - - export LDFLAGS="-static-intel" - - gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" - -build-centos7-icx-tbb2020-avx512_8: - <<: *build_job_docker - image: $DOCKER_REGISTRY/centos:7 # enables modules and loads devtoolset-7 - script: - - module load cmake - - module load intel/2022.1 - - export CC=icx - - export CXX=icpx - - export CXXFLAGS="-fPIC -fp-model=precise" - - export LDFLAGS="-static-intel" - - gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_ISA_AVX512SKX_8_WIDE=ON -DOPENVKL_ISA_AVX512SKX=OFF" - -build-centos8: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos8 - script: - - gitlab/build.sh -G Ninja - -# uses a newer CMake which allows OpenVDB to build -build-centos8-module-cmake: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos8 - script: - - module use $SHARED_MODULES_PATH - - module load cmake - - gitlab/build.sh -G Ninja -D TBB_VERSION=2020.3 -D TBB_HASH="" - tags: - - docker - - modules - -build-ubuntu18.04: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu18.04 - script: - - gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF - -build-ubuntu20.04: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu20.04 - script: - - gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF - -build-ubuntu22.04: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ubuntu:22.04 - script: - - gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF - -build-arch: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - -build-arch-clang: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - script: - - export CC=clang - - export CXX=clang++ - - gitlab/build.sh -G Ninja -D BUILD_GLFW=OFF - -build-arch-address-sanitizer: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - script: - - export CFLAGS=-fsanitize=address - - export CXXFLAGS=-fsanitize=address - - export LDFLAGS=-fsanitize=address - - gitlab/build.sh -D BUILD_GLFW=OFF -D BUILD_OPENVDB=OFF - -build-arch-debug: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - script: - - gitlab/build.sh -D CMAKE_BUILD_TYPE=Debug -D BUILD_GLFW=OFF - -build-arch-devel-rkdeps: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - script: - - gitlab/build.sh -D RKCOMMON_VERSION=devel -D RKCOMMON_HASH="" -D EMBREE_VERSION=devel -D EMBREE_HASH="" - allow_failure: true - -build-arch-TBB2020: - <<: *build_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - script: - - gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" - -build-macOS: - <<: *base_build_job - stage: build - script: - - gitlab/build.sh - tags: - - osx - - clang - -build-macOS-TBB2020: - <<: *base_build_job - stage: build - script: - - gitlab/build.sh -D TBB_VERSION=2020.3 -D TBB_HASH="" - tags: - - osx - - clang - -build-macOS-arm: - <<: *base_build_job - stage: build - script: - - gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON - tags: - - mac-arm - -build-windows-msvc15: - stage: build - script: - - gitlab\build.bat "Visual Studio 15 2017 Win64" "v141" - tags: - - msvc15 - - win10 - artifacts: - paths: - - build/install - expire_in: 3 day - -build-windows-msvc15-TBB2020: - stage: build - script: - - gitlab\build.bat "Visual Studio 15 2017 Win64" "v141" '"-DTBB_VERSION=2020.3"' '"-DTBB_HASH="""' - tags: - - msvc15 - - win10 - artifacts: - paths: - - build/install - expire_in: 3 day - -## Build From Install Jobs ## - -build-from-install-centos7: - <<: *build_from_install_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: - - build-centos7 - -## Functional Test Jobs ## - -test-functional-centos7: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: - - build-centos7 - -# ensures icc-built binaries can run without Intel runtimes -test-functional-centos7-icc: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: - - build-centos7-icc - -test-functional-centos7-icx: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: - - build-centos7-icx - -test-functional-centos7-icx-tbb2020: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: - - build-centos7-icx-tbb2020 - -test-functional-centos7-icx-tbb2020-avx512_8: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: - - build-centos7-icx-tbb2020-avx512_8 - -test-functional-centos8: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos8 - needs: - - build-centos8 - -test-functional-centos8-module-cmake: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:centos8 - needs: - - build-centos8-module-cmake - -test-functional-ubuntu18.04: - <<: *test_functional_job_docker_ubuntu - image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu18.04 - needs: - - build-ubuntu18.04 - -test-functional-ubuntu20.04: - <<: *test_functional_job_docker_ubuntu - image: $DOCKER_REGISTRY/ospray/docker-images:ubuntu20.04 - needs: - - build-ubuntu20.04 - -test-functional-ubuntu22.04: - <<: *test_functional_job_docker_ubuntu - image: $DOCKER_REGISTRY/ubuntu:22.04 - needs: - - build-ubuntu22.04 - -test-functional-arch: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - needs: - - build-arch - -test-functional-arch-clang: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - needs: - - build-arch-clang - -test-functional-arch-address-sanitizer: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - needs: - - build-arch-address-sanitizer - -test-functional-arch-debug: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - needs: - - build-arch-debug - -test-functional-arch-devel-rkdeps: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - needs: - - build-arch-devel-rkdeps - allow_failure: true - -test-functional-arch-TBB2020: - <<: *test_functional_job_docker - image: $DOCKER_REGISTRY/ospray/docker-images:arch - needs: - - build-arch-TBB2020 - -test-functional-macOS: - <<: *base_functional_test_job - needs: - - build-macOS - tags: - - osx - - clang - script: - - export DYLD_LIBRARY_PATH=./build/install/lib - - ./build/openvkl/build/vklTutorial - - ./build/openvkl/build/vklTutorialISPC - - ./build/openvkl/build/vklTests --durations yes - -test-functional-macOS-TBB2020: - <<: *base_functional_test_job - needs: - - build-macOS-TBB2020 - tags: - - osx - - clang - script: - - export DYLD_LIBRARY_PATH=./build/install/lib - - ./build/openvkl/build/vklTutorial - - ./build/openvkl/build/vklTutorialISPC - - ./build/openvkl/build/vklTests --durations yes - -test-functional-macOS-arm: - <<: *base_functional_test_job - needs: - - build-macOS-arm - tags: - - mac-arm - script: - - export DYLD_LIBRARY_PATH=./build/install/lib - - ./build/openvkl/build/vklTests --durations yes - -test-functional-windows-msvc15: - <<: *base_functional_test_job - script: - - gitlab\run_tests.bat - needs: - - build-windows-msvc15 - tags: - - msvc15 - - win10 - -test-functional-windows-msvc15-TBB2020: - <<: *base_functional_test_job - script: - - gitlab\run_tests.bat - needs: - - build-windows-msvc15-TBB2020 - tags: - - msvc15 - - win10 - -## Benchmark Jobs ## - -# All pipelines have these manual benchmark jobs - one for all benchmarks, -# plus one job for each suite. - -# vis-perf-x8280-1 - -.job_template: &manual_benchmark_x8280-1 - <<: *base_benchmark_job - when: manual - tags: - - vis-perf-x8280-1 - -all-x8280-1: - <<: *manual_benchmark_x8280-1 - -structured-x8280-1: - <<: [*manual_benchmark_x8280-1, *benchmark_select_structured] - -structured-multi-x8280-1: - <<: [*manual_benchmark_x8280-1, *benchmark_select_structured-multi] - -vdb-x8280-1: - <<: [*manual_benchmark_x8280-1, *benchmark_select_vdb] - -vdb-multi-x8280-1: - <<: [*manual_benchmark_x8280-1, *benchmark_select_vdb-multi] - -examples-x8280-1: - <<: [*manual_benchmark_x8280-1, *benchmark_select_examples] - -# vis-perf-a-1 - -.job_template: &manual_benchmark_a-1 - <<: *base_benchmark_job - when: manual - tags: - - vis-perf-a-1 - -all-a-1: - <<: *manual_benchmark_a-1 - -structured-a-1: - <<: [*manual_benchmark_a-1, *benchmark_select_structured] - -structured-multi-a-1: - <<: [*manual_benchmark_a-1, *benchmark_select_structured-multi] - -vdb-a-1: - <<: [*manual_benchmark_a-1, *benchmark_select_vdb] - -vdb-multi-a-1: - <<: [*manual_benchmark_a-1, *benchmark_select_vdb-multi] - -examples-a-1: - <<: [*manual_benchmark_a-1, *benchmark_select_examples] - -# Benchmark jobs meant for scheduled (nightly, weekly, ...) builds. -# The builds must define RUN_SCHEDULE_BENCHMARKS to run the job, and may use -# environment variables to configure the benchmark behavior. -benchmark-x8280-1-schedule: - <<: *base_benchmark_job - only: - variables: - - $RUN_SCHEDULE_BENCHMARKS - tags: - - vis-perf-x8280-1 - -benchmark-a-1-schedule: - <<: *base_benchmark_job - only: - variables: - - $RUN_SCHEDULE_BENCHMARKS - tags: - - vis-perf-a-1 - -## KW Jobs ## - -build-kw-scan: - stage: scan1 - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - script: - - gitlab/build-kw-scan.sh - before_script: - - git config --global --add safe.directory $CI_PROJECT_DIR - - git submodule sync - - git submodule init - - git submodule update - tags: [docker] - artifacts: - paths: - - ./klocwork/* - needs: [] - -check-kw-issues: - stage: scan2 - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: [build-kw-scan] - script: - - gitlab/kw-check-issues.sh - tags: - - docker - allow_failure: true - -gen-kw-report: - stage: scan2 - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - needs: [build-kw-scan] - tags: [docker] - script: - - gitlab/kw-gen-report.sh - - gitlab/store-files.sh $CI_PROJECT_NAME $CI_PIPELINE_ID klocwork "klocwork/report.log" - artifacts: - paths: - - ./klocwork/* - -## Protex Job ## - -source-protex-scan: - stage: scan1 - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - script: - - gitlab/source-scan-protex.sh - tags: - - docker - needs: [] - allow_failure: true - -## Release Jobs ## - -release-linux-icx: - <<: *base_release_job - image: $DOCKER_REGISTRY/centos:7 # enables modules and loads devtoolset-7 - script: - - module load cmake - - module load intel/2022.1 - - export CC=icx - - export CXX=icpx - - export CXXFLAGS="-fPIC -fp-model=precise" - - export LDFLAGS="-static-intel" - - gitlab/release/linux.sh - needs: [] - tags: - - docker - - modules - artifacts: - paths: - - ./*.gz - -release-macOS: - <<: *base_release_job - script: - - gitlab/release/macos.sh - needs: [] - tags: - - osx - - clang - - sign - artifacts: - paths: - - ./*.zip - -release-windows: - <<: *base_release_job - script: - - gitlab/release/windows.ps1 "Visual Studio 15 2017 Win64" "v141" - needs: [] - tags: - - msvc15 - - win10 - artifacts: - paths: - - ./*.zip - -## Release Test Jobs ## - -release-linux-test: - <<: *base_release_test_job - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - script: - - gitlab/release/linux-test.sh - tags: - - docker - needs: - - release-linux-icx - -release-macOS-test: - <<: *base_release_test_job - script: - - gitlab/release/macos-test.sh - tags: - - osx - - clang - needs: - - release-macOS - -release-windows-test: - <<: *base_release_test_job - script: - - gitlab/release/windows-test.ps1 "Visual Studio 15 2017 Win64" "v141" - tags: - - msvc15 - - win10 - needs: - - release-windows - -scan-bdba-bin: - <<: *master_release_devel_only - stage: scan-binaries - image: $DOCKER_REGISTRY/ospray/docker-images:centos7 - tags: [docker] - needs: [release-linux-icx, release-macOS, release-windows] - script: - - gitlab/bdba.sh "openvkl-*" - - gitlab/store-files.sh $CI_PROJECT_NAME $CI_PIPELINE_ID bdba "openvkl-*.pdf" - - gitlab/store-files.sh $CI_PROJECT_NAME $CI_PIPELINE_ID bdba "openvkl-*.csv" - artifacts: - paths: - - openvkl-*.pdf - - openvkl-*.csv - allow_failure: true - -av: - <<: *master_release_devel_only - stage: scan-binaries - tags: [docker] - image: $DOCKER_REGISTRY/clamav:ubuntu20.04 - needs: [release-linux-icx, release-macOS, release-windows] - script: - - freshclam | tee -a /tmp/av_scan.log - - clamscan -va --max-filesize=1024M --max-scansize=1024M --alert-broken --alert-exceeds-max openvkl-* | tee -a /tmp/av_scan.log - - gitlab/store-files.sh $CI_PROJECT_NAME $CI_PIPELINE_ID av /tmp/av_scan.log - allow_failure: true diff --git a/gitlab/bdba.sh b/gitlab/bdba.sh deleted file mode 100755 index ecbb965e..00000000 --- a/gitlab/bdba.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -## Copyright 2019 Intel Corporation -## SPDX-License-Identifier: Apache-2.0 - -files=$1 -jq_tool="$SHARED_TOOLS_PATH/jq-linux64" -logfile="bdba.log" -failed=0 -for file_path in $files ; do - echo -e "\n" >> $logfile - #upload file - upload_response=`curl -k -H "Authorization: Bearer $BDBA_TOKEN" -H "Group: $BDBA_GROUP" -T $file_path "$BDBA_SERVER/api/upload/"` - product_id=`echo "$upload_response" | $jq_tool -r '.results.product_id'` - if [ $product_id == "null" ]; then - echo "Cannot upload file $file_path" >> $logfile - failed=1 - continue - fi - report_url=`echo "$upload_response" | $jq_tool -r '.results.report_url'` - - echo "Scan upload of $file_path completed - product id: $product_id ($report_url)" >> $logfile - - set +e - MAX_RETRY=600 - - RETRY_COUNTER="0" - while [ $RETRY_COUNTER -lt $MAX_RETRY ]; do - response=`curl -s -X GET -H "Authorization: Bearer $BDBA_TOKEN" -k $BDBA_SERVER/api/product/$product_id/` - CMD_RETURN_CODE=$? - - status=`echo "$response" | $jq_tool -r '.results.status'` - verdict=`echo "$response" | $jq_tool -r '.results.summary.verdict.short'` - if [ $CMD_RETURN_CODE == 0 ] && [[ $status == "R" ]]; then - echo $response | python -m json.tool - echo "Verdict: $verdict" >> $logfile - if [ $verdict != "Pass" ] && [ $verdict != "null" ]; then - echo "There is a problem - please check report $report_url" >> $logfile - failed=1 - fi - # Download pdf report & components list - file_name=`basename "$file_path"` - echo "File name: $file_name" - curl -H "Authorization: Bearer $BDBA_TOKEN" -k $BDBA_SERVER/api/product/$product_id/pdf-report?cvss_version=3 -o ${file_name}_report.pdf - curl -H "Authorization: Bearer $BDBA_TOKEN" -k $BDBA_SERVER/api/product/$product_id/csv-libs -o ${file_name}_components.csv - break - fi - RETRY_COUNTER=$[$RETRY_COUNTER+1] - echo "Scan not finished yet, [$RETRY_COUNTER/$MAX_RETRY] - checking again ... " - sleep 20 - done - - set -e - if [ $RETRY_COUNTER -ge $MAX_RETRY ]; then - failed=62 - continue - fi -done - -cat $logfile - -exit $failed diff --git a/gitlab/build-kw-scan.sh b/gitlab/build-kw-scan.sh deleted file mode 100755 index bc14da16..00000000 --- a/gitlab/build-kw-scan.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -x -## Copyright 2019 Intel Corporation -## SPDX-License-Identifier: Apache-2.0 - -set -e -KW_SERVER_PATH=$KW_PATH/server -KW_CLIENT_PATH=$KW_PATH/client -export KLOCWORK_LTOKEN=/tmp/ltoken -echo "$KW_SERVER_IP;$KW_SERVER_PORT;$KW_USER;$KW_LTOKEN" > $KLOCWORK_LTOKEN -mkdir -p $CI_PROJECT_DIR/klocwork -log_file=$CI_PROJECT_DIR/klocwork/build.log - -mkdir build -cd build - -# NOTE(jda) - Some Linux OSs need to have TBB on LD_LIBRARY_PATH at build time -export LD_LIBRARY_PATH=`pwd`/install/lib:${LD_LIBRARY_PATH} - -cmake --version - -cmake \ - -DBUILD_JOBS=`nproc` \ - -DBUILD_DEPENDENCIES_ONLY=ON \ - -DBUILD_GLFW=OFF \ - "$@" ../superbuild - -cmake --build . - -mkdir openvkl_build -cd openvkl_build - -DEP_INSTALL_DIR=`pwd`/../install - -export rkcommon_DIR=$DEP_INSTALL_DIR -export embree_DIR=$DEP_INSTALL_DIR - -cmake \ - -DISPC_EXECUTABLE=$DEP_INSTALL_DIR/bin/ispc \ - -DBUILD_EXAMPLES=OFF \ - -DRKCOMMON_TBB_ROOT=$DEP_INSTALL_DIR \ - ../.. - -# build -$KW_CLIENT_PATH/bin/kwinject make -j `nproc` | tee -a $log_file -$KW_SERVER_PATH/bin/kwbuildproject -v --classic --url http://$KW_SERVER_IP:$KW_SERVER_PORT/$KW_PROJECT_NAME --tables-directory $CI_PROJECT_DIR/kw_tables kwinject.out | tee -a $log_file -$KW_SERVER_PATH/bin/kwadmin --url http://$KW_SERVER_IP:$KW_SERVER_PORT/ load --force --name build-$CI_JOB_ID $KW_PROJECT_NAME $CI_PROJECT_DIR/kw_tables | tee -a $log_file - -# Store kw build name for check status later -echo "build-$CI_JOB_ID" > $CI_PROJECT_DIR/klocwork/build_name - diff --git a/gitlab/kw-check-issues.sh b/gitlab/kw-check-issues.sh deleted file mode 100755 index 79c0c318..00000000 --- a/gitlab/kw-check-issues.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -xe -## Copyright 2020 Intel Corporation -## SPDX-License-Identifier: Apache-2.0 - -KW_ISSUES_FILE=/tmp/issues -KW_SERVER_API_URL=http://$KW_SERVER_IP:$KW_SERVER_PORT/review/api -KW_BUILD_NAME=$(cat $CI_PROJECT_DIR/klocwork/build_name) - -echo "Checking for issues in $KW_BUILD_NAME ..." -curl -f --data "action=search&project=$KW_PROJECT_NAME&query=build:'$KW_BUILD_NAME'%20status:Analyze,Fix,Fix%20in%20Next%20Release,Fix%20in%20Later%20Release,Defer,Filter&user=$KW_USER<oken=$KW_LTOKEN" $KW_SERVER_API_URL -o $KW_ISSUES_FILE -getCriticalCount() { - cat $KW_ISSUES_FILE | wc -l -} -if [ -f $KW_ISSUES_FILE ]; then - echo "Issues found - $(getCriticalCount) in $KW_BUILD_NAME"; - while IFS= read -r line; do echo $line | python -m json.tool; done < $KW_ISSUES_FILE - exit 1; -else - echo "There are no issues which should be take care in $KW_BUILD_NAME" -fi - diff --git a/gitlab/kw-gen-report.sh b/gitlab/kw-gen-report.sh deleted file mode 100755 index c364b62b..00000000 --- a/gitlab/kw-gen-report.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -xe -## Copyright 2020 Intel Corporation -## SPDX-License-Identifier: Apache-2.0 - -KW_SERVER_API_URL=http://$KW_SERVER_IP:$KW_SERVER_PORT/review/api -KW_BUILD_NAME=$(cat $CI_PROJECT_DIR/klocwork/build_name) -KW_BUILD_LOG_FILE=$CI_PROJECT_DIR/klocwork/build.log - -export PATH="$SHARED_TOOLS_PATH:$PATH" - -[ -f $KW_BUILD_LOG_FILE ] || (echo "Build log file not found. Expected to be in: $KW_BUILD_LOG_FILE." ; exit 1;) - -mkdir -p $CI_PROJECT_DIR/klocwork -report_file=$CI_PROJECT_DIR/klocwork/report.log -echo "------------------" >> $report_file -echo "Report generated at: "$(date '+%d/%m/%Y %H:%M:%S') >> $report_file -echo "Project source code url: $CI_PROJECT_URL" >> $report_file -echo "Project source code sha: $CI_COMMIT_SHA" >> $report_file -echo "Klocwork server: http://$KW_SERVER_IP:$KW_SERVER_PORT" >> $report_file -echo "------------------" >> $report_file - -echo -e "\n\n\n" >> $report_file - -# Get all issues list and put to report file -column_list=".id, .code, .severity, .state, .status, .taxonomyName, .owner, .url, .file, .line" -echo "------------------" >> $report_file -echo "Issues list:" >> $report_file -echo "------------------" >> $report_file -echo $column_list | sed 's/\\t/ ,/g' | column -t -s, >> $report_file -echo "------------------" >> $report_file -curl -f --data "action=search&project=$KW_PROJECT_NAME&query=build:'$KW_BUILD_NAME'&user=$KW_USER<oken=$KW_LTOKEN" $KW_SERVER_API_URL | jq-linux64 "[${column_list}] | @tsv" | sed 's/\\t/|/g' | column -t -s'|' | cut -d'"' -f2 >> $report_file - -echo -e "\n\n\n" >> $report_file - -# Attach build log to report file -echo "------------------" >> $report_file -echo "Build & scan log:" >> $report_file -echo "------------------" >> $report_file -cat $KW_BUILD_LOG_FILE >> $report_file diff --git a/gitlab/source-scan-protex.sh b/gitlab/source-scan-protex.sh deleted file mode 100755 index 273540eb..00000000 --- a/gitlab/source-scan-protex.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -PROTEX_ROOT=/NAS/tools/ip_protex/protex_v7.8 -BDSTOOL=$PROTEX_ROOT/bin/bdstool -SERVER_URL=https://amrprotex008.devtools.intel.com/ -PROTEX_PROJECT_NAME=c_openvkl_20491 -SRC_PATH=$CI_PROJECT_DIR/ - -export _JAVA_OPTIONS=-Duser.home=$PROTEX_ROOT/home - -# enter source code directory before scanning -cd $SRC_PATH - -$BDSTOOL new-project --server $SERVER_URL $PROTEX_PROJECT_NAME |& tee ip_protex.log -if grep -q "fail\|error\|fatal\|not found" ip_protex.log; then - exit 1 -fi - -$BDSTOOL analyze --server $SERVER_URL |& tee -a ip_protex.log -if grep -q "fail\|error\|fatal\|not found" ip_protex.log; then - exit 1 -fi - -if grep -E "^Files pending identification: [0-9]+$" ip_protex.log; then - echo "Protex scan FAILED!" - exit 1 -fi - -echo "Protex scan PASSED!" -exit 0 - diff --git a/gitlab/store-files.sh b/gitlab/store-files.sh deleted file mode 100755 index cffe2f57..00000000 --- a/gitlab/store-files.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -xe -## Copyright 2019 Intel Corporation -## SPDX-License-Identifier: Apache-2.0 - -project_name=$1 -build_id=$2 -group_name=$3 -files=$4 -STORAGE_DIR=$STORAGE_PATH/$project_name/$build_id/$group_name/ -mkdir -p $STORAGE_DIR -cp $files $STORAGE_DIR/ From a85b69e34b4acae009078991288507b8266048be Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 23 Feb 2023 08:49:49 -0700 Subject: [PATCH 28/34] update version to v1.3.2. --- .github/workflows/release.yml | 16 ++++++++-------- CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b019f0c9..85030d9c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: artifact-out: release-linux artifact-path: ./*.gz cmd: | - export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + export OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" module load cmake module load intel/2022.1 export CC=icx @@ -67,8 +67,8 @@ jobs: artifact-out: release-windows artifact-path: ./*.zip cmd: | - $env:OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" - $OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + $env:OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" + $OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" gitlab/release/windows.ps1 "Visual Studio 15 2017 Win64" "v141" release-macos: @@ -81,7 +81,7 @@ jobs: artifact-out: release-macos artifact-path: ./*.zip cmd: | - export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + export OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" gitlab/release/macos.sh release-linux-test: @@ -93,7 +93,7 @@ jobs: image: centos:7 artifact-in: release-linux cmd: | - export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + export OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" gitlab/release/linux-test.sh release-windows-test: @@ -104,8 +104,8 @@ jobs: runs-on: '[ "Windows" ]' artifact-in: release-windows cmd: | - $env:OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" - $OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + $env:OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" + $OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" gitlab/release/windows-test.ps1 "Visual Studio 15 2017 Win64" "v141" release-macos-test: @@ -116,7 +116,7 @@ jobs: runs-on: '[ "macOS", "build", "x86_64" ]' artifact-in: release-macos cmd: | - export OPENVKL_RELEASE_PACKAGE_VERSION="1.4.0" + export OPENVKL_RELEASE_PACKAGE_VERSION="1.3.2" gitlab/release/macos-test.sh binary-analysis: diff --git a/CMakeLists.txt b/CMakeLists.txt index d886a19a..75a80e28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ cmake_policy(SET CMP0074 NEW) ## Establish project ## -project(openvkl VERSION 1.4.0 LANGUAGES C CXX) +project(openvkl VERSION 1.3.2 LANGUAGES C CXX) ## Add openvkl specific macros ## From 5444b1dac2a8ae7225e4fd13af99614408266b86 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Thu, 23 Feb 2023 13:13:39 -0700 Subject: [PATCH 29/34] update to latest versions of dependencies. --- superbuild/CMakeLists.txt | 18 +++++++++--------- testing/external/catch.hpp | 28 +++++++++++++++++----------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index 9998445d..332f5138 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -116,7 +116,7 @@ endif() option(BUILD_TBB "Build Intel Threading Building Blocks or search in environment?" ON) option(BUILD_TBB_FROM_SOURCE "Build Intel Threading Building Blocks from source or use pre-built version?" OFF) if (BUILD_TBB) - set(TBB_VERSION "2021.5.0" CACHE STRING "TBB version to download") + set(TBB_VERSION "2021.8.0" CACHE STRING "TBB version to download") if (BUILD_TBB_FROM_SOURCE) if (TBB_VERSION VERSION_LESS 2021) message(FATAL_ERROR "Only TBB 2021 and later are supported when building TBB from source") @@ -124,7 +124,7 @@ if (BUILD_TBB) string(REGEX REPLACE "(^[0-9]+\.[0-9]+\.[0-9]+$)" "v\\1" TBB_ARCHIVE ${TBB_VERSION}) set(_TBB_URL "https://github.com/oneapi-src/oneTBB/archive/refs/tags/${TBB_ARCHIVE}.zip") - set(_TBB_HASH "83ea786c964a384dd72534f9854b419716f412f9d43c0be88d41874763e7bb47") + set(_TBB_HASH "a99635a411d86315b37c72ab525de59cd47aa5bd765c5544640ab08f971f83fe") else() if (TBB_VERSION VERSION_LESS 2021) set(TBB_BASE_URL "https://github.com/oneapi-src/oneTBB/releases/download/v${TBB_VERSION}/tbb-${TBB_VERSION}") @@ -133,15 +133,15 @@ if (BUILD_TBB) endif() if (APPLE) set(_TBB_URL "${TBB_BASE_URL}-mac.tgz") - set(_TBB_HASH "388c1c25314e3251e38c87ade2323af74cdaae2aec9b68e4c206d61c30ef9c33") + set(_TBB_HASH "9d620781d12d36a279bb27f4feb8c3b25d12c133e0d5b8661b867405d2445ee8") set(TBB_LIB_SUBDIR "") elseif(WIN32) set(_TBB_URL "${TBB_BASE_URL}-win.zip") - set(_TBB_HASH "096c004c7079af89fe990bb259d58983b0ee272afa3a7ef0733875bfe09fcd8e") + set(_TBB_HASH "b9265d4dc5b74e27176c6a6b696882935f605191d014a62c010c9610904e7f65") set(TBB_LIB_SUBDIR "intel64/vc14") else() set(_TBB_URL "${TBB_BASE_URL}-lin.tgz") - set(_TBB_HASH "74861b1586d6936b620cdab6775175de46ad8b0b36fa6438135ecfb8fb5bdf98") + set(_TBB_HASH "ee410e991bb44ce11437fbf93abedc7c4b1d0cb254e9b91cc2e0ddb0f5375566") set(TBB_LIB_SUBDIR "intel64/gcc4.8") endif() endif() @@ -237,20 +237,20 @@ if (BUILD_OPENVDB) CACHE STRING "SHA256 hash of the zlib archive.") include(dep_zlib) - set(BOOST_VERSION "1.80.0") + set(BOOST_VERSION "1.81.0") string(REPLACE "." "_" BOOST_FILE_BASE "${BOOST_VERSION}") set(BOOST_BASE_URL "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost") set(_BOOST_URL "${BOOST_BASE_URL}_${BOOST_FILE_BASE}.tar.gz") - set(_BOOST_HASH "4b2136f98bdd1f5857f1c3dea9ac2018effe65286cf251534b6ae20cc45e1847") + set(_BOOST_HASH "205666dea9f6a7cfed87c7a6dfbeb52a2c1b9de55712c9c1a87735d7181452b6") set(BOOST_URL "${_BOOST_URL}" CACHE STRING "URL of the boost archive.") set(BOOST_HASH "${_BOOST_HASH}" CACHE STRING "SHA256 hash of the boost archive.") include(dep_boost) if (BUILD_BLOSC) - set(BLOSC_VERSION "1.21.1") + set(BLOSC_VERSION "1.21.2") set(BLOSC_URL "https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.zip" CACHE STRING "URL of the c-BLOSC archive.") - set(BLOSC_HASH "abdf8ad8e5f8a876d67b38d16ff0c40c0456cdce1dcbafe58b589671ff55d31a" + set(BLOSC_HASH "a1dd1fa4bad3b97d1fd8a1f20923dd8161028ccf674a07da62662891c3219aa4" CACHE STRING "SHA256 hash of the c-BLOSC archive.") include(dep_blosc) endif() diff --git a/testing/external/catch.hpp b/testing/external/catch.hpp index d2a12427..9b309bdd 100644 --- a/testing/external/catch.hpp +++ b/testing/external/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v2.13.9 - * Generated: 2022-04-12 22:37:23.260201 + * Catch v2.13.10 + * Generated: 2022-10-16 11:01:23.452308 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. @@ -15,7 +15,7 @@ #define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 9 +#define CATCH_VERSION_PATCH 10 #ifdef __clang__ # pragma clang system_header @@ -7395,8 +7395,6 @@ namespace Catch { template struct ObjectStorage { - using TStorage = typename std::aligned_storage::value>::type; - ObjectStorage() : data() {} ObjectStorage(const ObjectStorage& other) @@ -7439,7 +7437,7 @@ namespace Catch { return *static_cast(static_cast(&data)); } - TStorage data; + struct { alignas(T) unsigned char data[sizeof(T)]; } data; }; } @@ -7949,7 +7947,7 @@ namespace Catch { #if defined(__i386__) || defined(__x86_64__) #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ #elif defined(__aarch64__) - #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #define CATCH_TRAP() __asm__(".inst 0xd43e0000") #endif #elif defined(CATCH_PLATFORM_IPHONE) @@ -13558,7 +13556,7 @@ namespace Catch { // Handle list request if( Option listed = list( m_config ) ) - return static_cast( *listed ); + return (std::min) (MaxExitCode, static_cast(*listed)); TestGroup tests { m_config }; auto const totals = tests.execute(); @@ -15391,7 +15389,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 13, 9, "", 0 ); + static Version version( 2, 13, 10, "", 0 ); return version; } @@ -17526,12 +17524,20 @@ namespace Catch { #ifndef __OBJC__ +#ifndef CATCH_INTERNAL_CDECL +#ifdef _MSC_VER +#define CATCH_INTERNAL_CDECL __cdecl +#else +#define CATCH_INTERNAL_CDECL +#endif +#endif + #if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) // Standard C/C++ Win32 Unicode wmain entry point -extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { +extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) { #else // Standard C/C++ main entry point -int main (int argc, char * argv[]) { +int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) { #endif return Catch::Session().run( argc, argv ); From 3379aa825ade9c1b3f75faa3795d2d0b3aa0ee09 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Fri, 24 Feb 2023 11:55:22 -0700 Subject: [PATCH 30/34] expose ISPC neon-i32x8 target via OPENVKL_ISA_NEON2X CMake param; and add CI jobs. --- .github/workflows/ci.mac.yml | 41 ++++++++++++++++++---- cmake/openvklConfig.cmake.in | 1 + cmake/openvkl_ispc.cmake | 14 +++++++- openvkl/devices/cpu/api/CPUDevice.ispc | 2 +- openvkl/devices/cpu/common/ispc_isa.h | 2 +- testing/apps/tests/vectorized_sampling.cpp | 5 +++ 6 files changed, 56 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.mac.yml b/.github/workflows/ci.mac.yml index 9151872a..c9a5c07a 100644 --- a/.github/workflows/ci.mac.yml +++ b/.github/workflows/ci.mac.yml @@ -61,27 +61,56 @@ jobs: ./build/openvkl/build/vklTutorialISPC ./build/openvkl/build/vklTests --durations yes - build-macOS-arm: + build-macOS-arm-neon: secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: force-delete: true # guarantees .gitattributes are respected in working dir submodules: true runs-on: '[ "macOS", "build", "arm" ]' - artifact-out: build-macOS-arm + artifact-out: build-macOS-arm-neon artifact-path: ./build/install ./build/openvkl/build cmd: | - gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON + gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_ISA_NEON=ON -DOPENVKL_ISA_NEON2X=OFF" - test-macOS-arm: - needs: build-macOS-arm + + test-macOS-arm-neon: + needs: build-macOS-arm-neon + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + runs-on: '[ "macOS", "build", "arm" ]' + artifact-in: build-macOS-arm-neon + cmd: | + export DYLD_LIBRARY_PATH=./build/install/lib + export OPENVKL_LOG_LEVEL=debug # gives prints of current ISA and SIMD width + ./build/openvkl/build/vklTutorial + ./build/openvkl/build/vklTutorialISPC + ./build/openvkl/build/vklTests --durations yes + + build-macOS-arm-neon2x: + secrets: inherit + uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main + with: + force-delete: true # guarantees .gitattributes are respected in working dir + submodules: true + runs-on: '[ "macOS", "build", "arm" ]' + artifact-out: build-macOS-arm-neon2x + artifact-path: ./build/install ./build/openvkl/build + cmd: | + gitlab/build.sh -DBUILD_TBB_FROM_SOURCE=ON -D OPENVKL_EXTRA_OPTIONS="-DOPENVKL_ISA_NEON=OFF -DOPENVKL_ISA_NEON2X=ON" + + + test-macOS-arm-neon2x: + needs: build-macOS-arm-neon2x secrets: inherit uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/macos.yml@main with: runs-on: '[ "macOS", "build", "arm" ]' - artifact-in: build-macOS-arm + artifact-in: build-macOS-arm-neon2x cmd: | export DYLD_LIBRARY_PATH=./build/install/lib + export OPENVKL_LOG_LEVEL=debug # gives prints of current ISA and SIMD width ./build/openvkl/build/vklTutorial ./build/openvkl/build/vklTutorialISPC ./build/openvkl/build/vklTests --durations yes diff --git a/cmake/openvklConfig.cmake.in b/cmake/openvklConfig.cmake.in index 3d625b97..1daea93f 100644 --- a/cmake/openvklConfig.cmake.in +++ b/cmake/openvklConfig.cmake.in @@ -17,6 +17,7 @@ set(OPENVKL_ISA_AVX2 @OPENVKL_ISA_AVX2@) set(OPENVKL_ISA_AVX512KNL @OPENVKL_ISA_AVX512KNL@) set(OPENVKL_ISA_AVX512SKX @OPENVKL_ISA_AVX512SKX@) set(OPENVKL_ISA_NEON @OPENVKL_ISA_NEON@) +set(OPENVKL_ISA_NEON2X @OPENVKL_ISA_NEON2X@) ## Standard signal that the package was found ## diff --git a/cmake/openvkl_ispc.cmake b/cmake/openvkl_ispc.cmake index df90d317..5e69804c 100644 --- a/cmake/openvkl_ispc.cmake +++ b/cmake/openvkl_ispc.cmake @@ -96,7 +96,13 @@ macro(openvkl_configure_ispc_isa) message(FATAL_ERROR "Only one AVX512 ISA may be enabled; choose either AVX512KNL, AVX512SKX or AVX512SKX_8_WIDE") endif() else() - option(OPENVKL_ISA_NEON "Enables NEON ISA." ON) + # only one Neon target can be enabled; default to NEON2X + option(OPENVKL_ISA_NEON "Enables NEON ISA." OFF) + option(OPENVKL_ISA_NEON2X "Enables NEON2X ISA." ON) + + if (OPENVKL_ISA_NEON AND OPENVKL_ISA_NEON2X) + message(FATAL_ERROR "Only one Neon ISA may be enabled; choose either NEON or NEON2X") + endif() endif() # generate final ISPC target lists; both a full list of all targets, and lists @@ -118,6 +124,12 @@ macro(openvkl_configure_ispc_isa) message(STATUS "OpenVKL NEON ISA target enabled.") endif() + if (OPENVKL_ISA_NEON2X) + set(OPENVKL_ISPC_TARGET_LIST ${OPENVKL_ISPC_TARGET_LIST} neon-i32x8) + set(OPENVKL_ISPC_TARGET_LIST_8 ${OPENVKL_ISPC_TARGET_LIST_8} neon-i32x8) + message(STATUS "OpenVKL NEON2X ISA target enabled.") + endif() + if (OPENVKL_ISA_AVX) set(OPENVKL_ISPC_TARGET_LIST ${OPENVKL_ISPC_TARGET_LIST} avx) set(OPENVKL_ISPC_TARGET_LIST_8 ${OPENVKL_ISPC_TARGET_LIST_8} avx) diff --git a/openvkl/devices/cpu/api/CPUDevice.ispc b/openvkl/devices/cpu/api/CPUDevice.ispc index 8857095f..2eb90c8c 100644 --- a/openvkl/devices/cpu/api/CPUDevice.ispc +++ b/openvkl/devices/cpu/api/CPUDevice.ispc @@ -14,7 +14,7 @@ export uniform int32 EXPORT_UNIQUE(ISPC_getProgramCount) export uniform uint32 EXPORT_UNIQUE(ISPC_getTarget) { #if defined(ISPC_TARGET_NEON) - return VKL_ISPC_TARGET_NEON; + return VKL_ISPC_TARGET_NEON; // same for both NEON and NEON2X #elif defined(ISPC_TARGET_SSE2) return VKL_ISPC_TARGET_SSE2; #elif defined(ISPC_TARGET_SSE4) diff --git a/openvkl/devices/cpu/common/ispc_isa.h b/openvkl/devices/cpu/common/ispc_isa.h index 3cf42d4f..7aca9805 100644 --- a/openvkl/devices/cpu/common/ispc_isa.h +++ b/openvkl/devices/cpu/common/ispc_isa.h @@ -33,7 +33,7 @@ inline std::string stringForVKLISPCTarget(VKLISPCTarget target) { switch (target) { case VKL_ISPC_TARGET_NEON: - return "NEON"; + return "NEON"; // same for both NEON and NEON2X case VKL_ISPC_TARGET_SSE2: return "SSE2"; case VKL_ISPC_TARGET_SSE4: diff --git a/testing/apps/tests/vectorized_sampling.cpp b/testing/apps/tests/vectorized_sampling.cpp index a1034f02..aedbd281 100644 --- a/testing/apps/tests/vectorized_sampling.cpp +++ b/testing/apps/tests/vectorized_sampling.cpp @@ -80,7 +80,12 @@ void test_vectorized_sampling() INFO("sample = " << i + 1 << " / " << width << ", calling width = " << callingWidth); +#ifdef __ARM_NEON + static constexpr float tolerance = 1e-3f; + REQUIRE(sampleTruth == Approx(samples[i]).margin(tolerance)); +#else REQUIRE(sampleTruth == Approx(samples[i])); +#endif } } } From 5ffc9698cda444ad2858d575f3e9c5f1c2eb2072 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Mon, 27 Feb 2023 10:08:59 -0700 Subject: [PATCH 31/34] retain previous OPENVKL_ISA_NEON default. OPENVKL_ISA_NEON2X can be enabled explicitly by the user (but only one NEON target can be enabled at once, so OPENVKL_ISA_NEON would then need to also be disabled). --- cmake/openvkl_ispc.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/openvkl_ispc.cmake b/cmake/openvkl_ispc.cmake index 5e69804c..9fb65219 100644 --- a/cmake/openvkl_ispc.cmake +++ b/cmake/openvkl_ispc.cmake @@ -97,8 +97,8 @@ macro(openvkl_configure_ispc_isa) endif() else() # only one Neon target can be enabled; default to NEON2X - option(OPENVKL_ISA_NEON "Enables NEON ISA." OFF) - option(OPENVKL_ISA_NEON2X "Enables NEON2X ISA." ON) + option(OPENVKL_ISA_NEON "Enables NEON ISA." ON) + option(OPENVKL_ISA_NEON2X "Enables NEON2X ISA." OFF) if (OPENVKL_ISA_NEON AND OPENVKL_ISA_NEON2X) message(FATAL_ERROR "Only one Neon ISA may be enabled; choose either NEON or NEON2X") From 1e035c33d2ce9acb1c816c05e461ada30e1d1122 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Mon, 27 Feb 2023 14:39:02 -0700 Subject: [PATCH 32/34] superbuild: update Blosc install dirs. --- superbuild/dependencies/dep_blosc.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/superbuild/dependencies/dep_blosc.cmake b/superbuild/dependencies/dep_blosc.cmake index 1690a83c..2b6ebb73 100644 --- a/superbuild/dependencies/dep_blosc.cmake +++ b/superbuild/dependencies/dep_blosc.cmake @@ -19,6 +19,10 @@ ExternalProject_Add(${COMPONENT_NAME} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_INSTALL_PREFIX:PATH=${COMPONENT_PATH} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_DOCDIR=${CMAKE_INSTALL_DOCDIR} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} From 38dbecfbd3c41efeed6b73d1b24c0f01736978d6 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Tue, 28 Feb 2023 06:46:40 -0700 Subject: [PATCH 33/34] superbuild: update to ISPC v1.19.0. --- cmake/openvkl_ispc.cmake | 2 +- superbuild/CMakeLists.txt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/openvkl_ispc.cmake b/cmake/openvkl_ispc.cmake index 9fb65219..70bd2140 100644 --- a/cmake/openvkl_ispc.cmake +++ b/cmake/openvkl_ispc.cmake @@ -4,7 +4,7 @@ option(OPENVKL_ISPC_FAST_MATH "enable ISPC fast-math optimizations" OFF) # ISPC versions to look for, in decending order (newest first) -set(ISPC_VERSION_WORKING "1.18.0") +set(ISPC_VERSION_WORKING "1.19.0" "1.18.0") list(GET ISPC_VERSION_WORKING -1 ISPC_VERSION_REQUIRED) if (NOT ISPC_EXECUTABLE) diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index 332f5138..f49192eb 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -95,17 +95,17 @@ option(BUILD_OPENVKL_BENCHMARKS option(BUILD_ISPC "Build the Intel SPMD Program Compiler or search in environment?" ON) if (BUILD_ISPC) - set(ISPC_VERSION "1.18.0") + set(ISPC_VERSION "1.19.0") set(ISPC_BASE_URL "https://github.com/ispc/ispc/releases/download/v${ISPC_VERSION}") if (APPLE) set(_ISPC_URL "${ISPC_BASE_URL}/ispc-v${ISPC_VERSION}-macOS.tar.gz") - set(_ISPC_HASH "d1435b541182406ff6b18446d31ecceef0eae3aed7654391ae676d3142e0000d") + set(_ISPC_HASH "f61993807ba00d5deeb46f65be7e38d7c95bcfb6e6e114993afa53b44320556c") elseif(WIN32) set(_ISPC_URL "${ISPC_BASE_URL}/ispc-v${ISPC_VERSION}-windows.zip") - set(_ISPC_HASH "9210bb2d9d3711367faccb37acf49966696132560b565471c1c6121f4924a17e") + set(_ISPC_HASH "3f2953f9328290adfd0143707dce13e342f6df1099b3be5148a25e41347f958c") else() set(_ISPC_URL "${ISPC_BASE_URL}/ispc-v${ISPC_VERSION}-linux.tar.gz") - set(_ISPC_HASH "6c379bb97962e9de7d24fd48b3f7e647dc42be898e9d187948220268c646b692") + set(_ISPC_HASH "f99a0afd4c8b5e8aceb46af8e90a7ba0813bf4c4111044ced27d498591304f9c") endif() set(ISPC_URL "${_ISPC_URL}" CACHE STRING "URL of the ISPC archive.") set(ISPC_HASH "${_ISPC_HASH}" CACHE STRING "SHA256 hash of the ISPC archive.") From 424624354a9ea3062878f07ea96dc8f145f7cb36 Mon Sep 17 00:00:00 2001 From: Greg Johnson Date: Mon, 27 Feb 2023 14:42:01 -0700 Subject: [PATCH 34/34] update changelog and rebuild README.md. --- CHANGELOG.md | 8 ++++++++ README.md | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f7e7912..3c7c74ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Version History --------------- +### Open VKL 1.3.2 + +- Move to and require latest versions of RenderKit dependencies: Embree v4.0.0 + and rkcommon v1.11.0 +- ARM support: expose ISPC neon-i32x8 target via OPENVKL_ISA_NEON2X CMake + option +- Superbuild updates to latest versions of dependencies + ### Open VKL 1.3.1 - Superbuild updates to latest versions of dependencies diff --git a/README.md b/README.md index 870cc129..8f8abcfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Intel® Open Volume Kernel Library -This is release v1.3.1 of Intel® Open VKL. For changes and new features +This is release v1.3.2 of Intel® Open VKL. For changes and new features see the [changelog](CHANGELOG.md). Visit http://www.openvkl.org for more information. @@ -33,6 +33,14 @@ example renderers to demonstrate how to best use the Open VKL API. ## Version History +### Open VKL 1.3.2 + +- Move to and require latest versions of RenderKit dependencies: Embree + v4.0.0 and rkcommon v1.11.0 +- ARM support: expose ISPC neon-i32x8 target via OPENVKL_ISA_NEON2X + CMake option +- Superbuild updates to latest versions of dependencies + ### Open VKL 1.3.1 - Superbuild updates to latest versions of dependencies