From db650be13b2968e448a8a57300f83ffbb17a75d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Wed, 4 Dec 2024 10:54:34 +0100 Subject: [PATCH 1/3] Optimize (orthonormal) frame() --- rkcommon/math/LinearSpace.h | 13 +++++++++---- rkcommon/math/LinearSpace.ih | 11 +++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/rkcommon/math/LinearSpace.h b/rkcommon/math/LinearSpace.h index 195886d..69bc323 100644 --- a/rkcommon/math/LinearSpace.h +++ b/rkcommon/math/LinearSpace.h @@ -438,10 +438,15 @@ namespace rkcommon { template inline LinearSpace3 frame(const T &N) { - const T dx0 = cross(T(one, zero, zero), N); - const T dx1 = cross(T(zero, one, zero), N); - const T dx = normalize(dot(dx0, dx0) > dot(dx1, dx1) ? dx0 : dx1); - const T dy = normalize(cross(N, dx)); + // Duff et al., "Building an Orthonormal Basis, Revisited", JCGT 2017 + const typename T::Scalar sgn = N.z < (typename T::Scalar)zero + ? -(typename T::Scalar)one + : (typename T::Scalar)one; + const typename T::Scalar a = -(typename T::Scalar)one / (sgn + N.z); + const typename T::Scalar b = N.x * N.y * a; + const T dx = + T((typename T::Scalar)one + sgn * N.x * N.x * a, sgn * b, -sgn * N.x); + const T dy = T(b, sgn + N.y * N.y * a, -N.y); return LinearSpace3(dx, dy, N); } diff --git a/rkcommon/math/LinearSpace.ih b/rkcommon/math/LinearSpace.ih index a624404..8df6b9d 100644 --- a/rkcommon/math/LinearSpace.ih +++ b/rkcommon/math/LinearSpace.ih @@ -187,10 +187,13 @@ __define_comp_ops(); */ \ inline univary LinearSpace3f frame(const univary vec3f N) \ { \ - const univary vec3f dx0 = make_vec3f(0.0f, N.z, -N.y); \ - const univary vec3f dx1 = make_vec3f(-N.z, 0.0f, N.x); \ - const univary vec3f dx = normalize(abs(N.x) < abs(N.y) ? dx0 : dx1); \ - const univary vec3f dy = cross(N, dx); \ + /* Duff et al., "Building an Orthonormal Basis, Revisited", JCGT 2017 */ \ + const univary float sgn = N.z < 0.0f ? -1.0f : 1.0f; \ + const univary float a = -1.0f / (sgn + N.z); \ + const univary float b = N.x * N.y * a; \ + const univary vec3f dx = \ + make_vec3f(1.0f + sgn * N.x * N.x * a, sgn * b, -sgn * N.x); \ + const univary vec3f dy = make_vec3f(b, sgn + N.y * N.y * a, -N.y); \ return make_LinearSpace3f(dx, dy, N); \ } \ inline univary LinearSpace3f rcp(const univary LinearSpace3f l) \ From 69396fa746a05b2b2a7b56e11ca2c2d1a9356e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Tue, 28 Oct 2025 10:02:12 +0100 Subject: [PATCH 2/3] Bump CMake minimum required version to 3.10, closes #15 --- CMakeLists.txt | 6 +----- README.md | 2 +- cmake/FindTBB.cmake | 3 +-- cmake/rkcommon_macros.cmake | 43 ++----------------------------------- 4 files changed, 5 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69b6400..1a18d31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,7 @@ ## Global CMake options ## -if (RKCOMMON_TASKING_SYSTEM STREQUAL "OpenMP") - cmake_minimum_required(VERSION 3.9) # NOTE(jda): rely on OpenMP targets -else() - cmake_minimum_required(VERSION 3.5) -endif() +cmake_minimum_required(VERSION 3.10) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/README.md b/README.md index bc42587..f76a530 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ used by various components of IntelĀ® Rendering Toolkit (Render Kit). ### Requirements -- CMake +- CMake v3.10 or higher - C++11 compiler - TBB 4.4.3 or higher (by default, other tasking system options available via the `RKCOMMON_TASKING_SYSTEM` CMake variable) diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake index c3d86de..a1381f6 100644 --- a/cmake/FindTBB.cmake +++ b/cmake/FindTBB.cmake @@ -36,8 +36,7 @@ # #=============================================================================== -# We use INTERFACE libraries, which are only supported in 3.x -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.10) # These two are used to automatically find the root and include directories. set(_TBB_INCLUDE_SUBDIR "include") diff --git a/cmake/rkcommon_macros.cmake b/cmake/rkcommon_macros.cmake index 7e58916..4207e75 100644 --- a/cmake/rkcommon_macros.cmake +++ b/cmake/rkcommon_macros.cmake @@ -1,45 +1,6 @@ ## Copyright 2009 Intel Corporation ## SPDX-License-Identifier: Apache-2.0 -# use a backported version of find_dependency(), renamed as -# find_dependency_39(), from CMake 3.9.0, which correctly supports passing -# components to find_package(). this allows us to maintain our current minimum -# CMake version of 3.1. -macro(find_dependency_39 dep) - if (NOT ${dep}_FOUND) - set(cmake_fd_quiet_arg) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(cmake_fd_quiet_arg QUIET) - endif() - set(cmake_fd_required_arg) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(cmake_fd_required_arg REQUIRED) - endif() - - get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY - _CMAKE_${dep}_TRANSITIVE_DEPENDENCY - ) - - find_package(${dep} ${ARGN} - ${cmake_fd_quiet_arg} - ${cmake_fd_required_arg} - ) - - if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) - set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) - endif() - - if (NOT ${dep}_FOUND) - set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") - set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) - return() - endif() - set(cmake_fd_required_arg) - set(cmake_fd_quiet_arg) - set(cmake_fd_exact_arg) - endif() -endmacro() - ## Macro for printing CMake variables ## macro(print var) message("${var} = ${${var}}") @@ -210,7 +171,7 @@ macro(rkcommon_create_tasking_target FROM_INSTALL) # If not found try getting older TBB via module (FindTBB.cmake) unset(TBB_DIR CACHE) if (${FROM_INSTALL}) - find_dependency_39(TBB 4.4 REQUIRED tbb tbbmalloc) + find_dependency(TBB 4.4 REQUIRED tbb tbbmalloc) else() find_package(TBB 4.4 REQUIRED tbb tbbmalloc) endif() @@ -220,7 +181,7 @@ macro(rkcommon_create_tasking_target FROM_INSTALL) endif() endif() elseif(RKCOMMON_TASKING_OPENMP) - find_dependency_39(OpenMP) + find_dependency(OpenMP) if (OPENMP_FOUND) list(APPEND RKCOMMON_TASKING_LIBS OpenMP::OpenMP_CXX) set(RKCOMMON_TASKING_DEFINITIONS RKCOMMON_TASKING_OMP) From c11d719b076491127335ee69e8bf535efafa3e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=BCnther?= Date: Tue, 28 Oct 2025 10:20:31 +0100 Subject: [PATCH 3/3] CI: Bump icx to 2025.1 --- .github/workflows/ci.linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.linux.yml b/.github/workflows/ci.linux.yml index b555065..5b70df7 100644 --- a/.github/workflows/ci.linux.yml +++ b/.github/workflows/ci.linux.yml @@ -30,8 +30,8 @@ jobs: uses: intel-innersource/libraries.devops.renderkit.workflows/.github/workflows/docker.yml@main with: image: rockylinux:8 + dpcpp-version: intel/2025.1 cmd: | - module load intel/2022.1 export CC=icx export CXX=icpx export LDFLAGS="-static-intel"