diff --git a/CHANGES.md b/CHANGES.md index f38e3c8a..d318e1bf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,22 @@ # Imath Release Notes +* [Version 3.0.2](#version-302-may-16-2021) May 16, 2021 * [Version 3.0.1](#version-301-april-1-2021) April 1, 2021 * [Version 3.0.1-beta](#version-301-beta-march-28-2021) March 28, 2021 * [Version 3.0.0-beta](#version-300-beta-march-15-2021) March 15, 2021 * [Inherited History from OpenEXR](#inherited-history-from-openexr) +## Version 3.0.2 (May 16, 2021) + +Patch release with miscellaneous bug/build fixes: + +* \[[#142](https://github.com/AcademySoftwareFoundation/Imath/pull/142)\] Fix order of ${IMATH_SOVERSION}.${IMATH_SOREVISION}.${IMATH_SOAGE} +* \[[#140](https://github.com/AcademySoftwareFoundation/Imath/pull/140)\] Fix regression in succf()/predf() +* \[[#139](https://github.com/AcademySoftwareFoundation/Imath/pull/139)\] Clean up setting of Imath version +* \[[#137](https://github.com/AcademySoftwareFoundation/Imath/pull/137)\] Don't impose C++14 on downstream projects +* \[[#135](https://github.com/AcademySoftwareFoundation/Imath/pull/135)\] Add section on python bindings +* \[[#133](https://github.com/AcademySoftwareFoundation/Imath/pull/133)\] Lib version + ## Version 3.0.1 (April 1, 2021) First release of Imath independent of OpenEXR. diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bb8547c..f8ee0373 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,10 +12,28 @@ if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif() -# Version numbers are maintained in config/version.cmake -include(config/version.cmake) +# Imath version -project(Imath VERSION ${IMATH_VERSION} LANGUAGES C CXX) +project(Imath VERSION 3.0.2 LANGUAGES C CXX) + +set(IMATH_VERSION_EXTRA "" CACHE STRING "Extra version tag string for Imath build") + +# See https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +set(IMATH_SOVERSION 28) +set(IMATH_SOREVISION 0) +set(IMATH_SOAGE 0) +set(IMATH_LIB_VERSION "${IMATH_SOVERSION}.${IMATH_SOREVISION}.${IMATH_SOAGE}") + +set(IMATH_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR}) +set(IMATH_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR}) +set(IMATH_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH}) +set(IMATH_VERSION ${CMAKE_PROJECT_VERSION}) +if (NOT IMATH_VERSION_EXTRA STREQUAL "") + set(IMATH_VERSION "${CMAKE_PROJECT_VERSION}-${IMATH_VERSION_EXTRA}") +endif() +set(IMATH_VERSION_API "${IMATH_VERSION_MAJOR}_${IMATH_VERSION_MINOR}") + +message(STATUS "Configure Imath Version: ${IMATH_VERSION} Lib API: ${IMATH_LIB_VERSION}") # ImathSetup.cmake declares all the configuration variables visible # in cmake-gui or similar and the rest of the global diff --git a/config/ImathConfig.h.in b/config/ImathConfig.h.in index 544a5095..df2d42a6 100644 --- a/config/ImathConfig.h.in +++ b/config/ImathConfig.h.in @@ -46,6 +46,9 @@ (uint32_t(IMATH_VERSION_MINOR) << 16) | \ (uint32_t(IMATH_VERSION_PATCH) << 8)) +// IMATH_LIB_VERSION is the library API version: SOCURRENT.SOAGE.SOREVISION +#define IMATH_LIB_VERSION_STRING "@IMATH_LIB_VERSION@" + // // By default, opt into the interoparability constructors and assignments. diff --git a/config/LibraryDefine.cmake b/config/LibraryDefine.cmake index 7770d71c..faf430e0 100644 --- a/config/LibraryDefine.cmake +++ b/config/LibraryDefine.cmake @@ -14,7 +14,16 @@ function(IMATH_DEFINE_LIBRARY libname) ${IMATH_CURLIB_HEADERS} ${IMATH_CURLIB_SOURCES}) - target_compile_features(${objlib} PUBLIC cxx_std_${IMATH_CXX_STANDARD}) + # Use ${IMATH_CXX_STANDARD} to determine the standard we use to compile + # Imath itself. But the headers only require C++11 features, so that's + # all we need to pass on as interface reqirements to downstream projects. + # For example, it's fine for an Imath built with C++14 to be called from + # an app that is compiled with C++11; Imath needn't force the app to + # also use C++14. + target_compile_features(${objlib} + PRIVATE cxx_std_${IMATH_CXX_STANDARD} + INTERFACE cxx_std_11 ) + if(IMATH_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS) target_compile_definitions(${objlib} PRIVATE ${IMATH_CURLIB_PRIV_EXPORT}) if(WIN32) diff --git a/config/version.cmake b/config/version.cmake deleted file mode 100644 index 58efebb9..00000000 --- a/config/version.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenEXR Project. - - -# From https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -# -# - If the library source code has changed at all since the last -# update, then increment revision (‘c.r.a’ becomes ‘c.r+1.a’). -# -# - If any interfaces have been added, removed, or changed since the -# last update, increment current, and set revision to 0. -# -# - If any interfaces have been added since the last public release, -# then increment age. -# -# - If any interfaces have been removed or changed since the last -# public release, then set age to 0. - -set(IMATH_VERSION_MAJOR 3) -set(IMATH_VERSION_MINOR 0) -set(IMATH_VERSION_PATCH 1) -set(IMATH_VERSION ${IMATH_VERSION_MAJOR}.${IMATH_VERSION_MINOR}.${IMATH_VERSION_PATCH}) -set(IMATH_VERSION_API ${IMATH_VERSION_MAJOR}_${IMATH_VERSION_MINOR}) -set(IMATH_SOCURRENT 27) -set(IMATH_SOREVISION 0) -set(IMATH_SOAGE 0) -math(EXPR IMATH_SOVERSION "${IMATH_SOCURRENT} - ${IMATH_SOAGE}") -set(IMATH_LIB_VERSION "${IMATH_SOVERSION}.${IMATH_SOAGE}.${IMATH_SOREVISION}") -message(STATUS "Configure Imath Version: ${IMATH_VERSION} Lib API: ${IMATH_LIB_VERSION}") diff --git a/docs/PortingGuide2-3.md b/docs/PortingGuide2-3.md index 6eba9712..dfaee538 100644 --- a/docs/PortingGuide2-3.md +++ b/docs/PortingGuide2-3.md @@ -464,6 +464,10 @@ Other changes: * When compiling for CUDA, the `complex` type comes from `thrust` rather than `std` +### `Shear6` in ImathShear.h + +* `baseTypeMin()` is replaced with `baseTypeLowest()` + ### ImathVecAlgo.h The following functions are no longer defined for integer-based @@ -503,5 +507,27 @@ vectors, because such behavior is not clearly defined: constructors that take as an argument any data object of similar size and layout. +## Python Changes: + +In general, the changes at the C++ level are reflected in the python +bindings. In particular: + +* The following methods are removed for integer-based + vector and matrix objects and arrays: + + - `length()` + - `normalize()` + - `normalizeExc()` + - `normalizeNonNull()` + - `normalized()` + - `normalizedExc()` + - `normalizedNonNull()` + +* `baseTypeMin()` is replaced with `baseTypeLowest()` for: + - `Vec2`, `Vec3`, `Vec4` + - `Color3`, `Color4` + - `Matrix22`, `Matrix33`, `Matrix44` + - `Box` + - `Shear6` diff --git a/src/Imath/ImathFun.cpp b/src/Imath/ImathFun.cpp index 62ecadfd..793927c5 100644 --- a/src/Imath/ImathFun.cpp +++ b/src/Imath/ImathFun.cpp @@ -27,7 +27,7 @@ succf (float f) noexcept u.i = 0x00000001; } - else if (u.i > 0) + else if (u.f > 0) { // Positive float, normalized or denormalized. // Incrementing the largest positive float @@ -65,7 +65,7 @@ predf (float f) noexcept u.i = 0x80000001; } - else if (u.i > 0) + else if (u.f > 0) { // Positive float, normalized or denormalized. diff --git a/src/ImathTest/testFun.cpp b/src/ImathTest/testFun.cpp index abb2bd33..56db842e 100644 --- a/src/ImathTest/testFun.cpp +++ b/src/ImathTest/testFun.cpp @@ -8,6 +8,10 @@ #endif #include "ImathFun.h" +#if __cplusplus >= 202002L +# include +#endif +#include #include #include #include @@ -18,16 +22,32 @@ using namespace std; #if ULONG_MAX == 18446744073709551615LU typedef long unsigned int Int64; #else -typedef long long unsigned int Int64; + typedef long long unsigned int Int64; +#endif + +#if __cplusplus < 202002L + template + static inline To + bit_cast (From from) + { + static_assert (sizeof (From) == sizeof (To), "Type sizes do not match"); + union + { + From f; + To t; + } u; + u.f = from; + return u.t; + } #endif void -testf (float f) +testf (float f, bool changeExpected = true) { printf ("\n"); - float sf = IMATH_INTERNAL_NAMESPACE::succf (f); - float pf = IMATH_INTERNAL_NAMESPACE::predf (f); + float sf = IMATH_INTERNAL_NAMESPACE::succf (f); + float pf = IMATH_INTERNAL_NAMESPACE::predf (f); float spf = IMATH_INTERNAL_NAMESPACE::succf (IMATH_INTERNAL_NAMESPACE::predf (f)); float psf = IMATH_INTERNAL_NAMESPACE::predf (IMATH_INTERNAL_NAMESPACE::succf (f)); @@ -36,15 +56,29 @@ testf (float f) printf ("pf %.9g\n", pf); printf ("spf %.9g\n", spf); printf ("psf %.9g\n", psf); + + fflush (stdout); + + if (changeExpected) + { + assert (pf < f); + assert (f < sf); + } + else + { + // No bit change expected if input was inf or NaN + assert (bit_cast (pf) == bit_cast (f)); + assert (bit_cast (sf) == bit_cast (f)); + } } void -testd (double d) +testd (double d, bool changeExpected = true) { printf ("\n"); - double sd = IMATH_INTERNAL_NAMESPACE::succd (d); - double pd = IMATH_INTERNAL_NAMESPACE::predd (d); + double sd = IMATH_INTERNAL_NAMESPACE::succd (d); + double pd = IMATH_INTERNAL_NAMESPACE::predd (d); double spd = IMATH_INTERNAL_NAMESPACE::succd (IMATH_INTERNAL_NAMESPACE::predd (d)); double psd = IMATH_INTERNAL_NAMESPACE::predd (IMATH_INTERNAL_NAMESPACE::succd (d)); @@ -53,6 +87,20 @@ testd (double d) printf ("pd %.18lg\n", pd); printf ("spd %.18lg\n", spd); printf ("psd %.18lg\n", psd); + + fflush (stdout); + + if (changeExpected) + { + assert (pd < d); + assert (d < sd); + } + else + { + // No bit change expected if input was inf or NaN + assert (bit_cast (pd) == bit_cast (d)); + assert (bit_cast (sd) == bit_cast (d)); + } } void @@ -196,15 +244,13 @@ testFun() testf (7); testf (0.7); - union - { - float f; - int i; - } u; + union {float f; int i;} u; u.i = 0x7f800000; // inf - testf (u.f); + testf (u.f, false); + u.i = 0xff800000; // -inf + testf (u.f, false); u.i = 0x7f800001; // nan - testf (u.f); + testf (u.f, false); u.i = 0x7f7fffff; // FLT_MAX testf (u.f); u.i = 0xff7fffff; // -FLT_MAX @@ -218,15 +264,13 @@ testFun() testd (7); testd (0.7); - union - { - double d; - Int64 i; - } v; + union {double d; Int64 i;} v; v.i = 0x7ff0000000000000ULL; // inf - testd (v.d); + testd (v.d, false); + v.i = 0xfff0000000000000ULL; // -inf + testd (v.d, false); v.i = 0x7ff0000000000001ULL; // NAN - testd (v.d); + testd (v.d, false); v.i = 0x7fefffffffffffffULL; // FLT_MAX testd (v.d); v.i = 0xffefffffffffffffULL; // -FLT_MAX diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index c8647465..8825289b 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -21,7 +21,7 @@ endif() include(config/PyImathSetup.cmake) # we have a strong dependence on Imath being an exact match -find_package(Imath ${IMATH_VERSION} EXACT REQUIRED CONFIG) +find_package(Imath ${CMAKE_PROJECT_VERSION} REQUIRED CONFIG) # we are building a python extension, so of course we depend on # python as well. Except we don't know which version...