diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3a145a3e..bc18b57c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -542,6 +542,63 @@ jobs: build/*.cmake build/testsuite/*/*.* + icx-vp2022: + name: "Linux VFXP-2022 icx/C++17 llvm13 py3.9 boost1.76 exr3.1 oiio2.3 avx2" + runs-on: ubuntu-latest + container: + image: aswftesting/ci-osl:2022-clang13 + env: + CXX: icpx + CC: icx + CMAKE_CXX_STANDARD: 17 + OPENIMAGEIO_VERSION: master + PYBIND11_VERSION: v2.9.0 + PYTHON_VERSION: 3.9 + USE_BATCHED: b8_AVX2_noFMA + USE_SIMD: avx2,f16c + OSL_CMAKE_FLAGS: -DSTOP_ON_WARNING=OFF + USE_OPENVDB: 0 + + steps: + - uses: actions/checkout@v2 + - name: Prepare ccache timestamp + id: ccache_cache_keys + shell: bash + run: | + echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`" + - name: ccache + id: ccache + uses: actions/cache@v2 + with: + path: /tmp/ccache + key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }} + restore-keys: | + ${{ github.job }}- + - name: Build setup + run: | + src/build-scripts/ci-startup.bash + - name: Dependencies + run: | + sudo rm -rf /usr/local/include/OpenImageIO + sudo rm -rf /usr/local/lib*/cmake/OpenImageIO + sudo rm -rf /usr/local/lib*/libOpenImageIO* + sudo rm -rf /usr/local/lib*/python3.9/site-packages/OpenImageIO* + src/build-scripts/gh-installdeps.bash + - name: Build + run: | + src/build-scripts/ci-build.bash + - name: Testsuite + run: | + src/build-scripts/ci-test.bash + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: osl-${{github.job}} + path: | + build/CMake* + build/*.cmake + build/testsuite/*/*.* + linux-latest-release: # Test against development master for relevant dependencies, latest # supported releases of everything else. diff --git a/CMakeLists.txt b/CMakeLists.txt index 98b26a1a5..f22c9ce93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,21 @@ include_directories ( ) +# Make sure our math calculations are consistent, +# especially division. Different compilers may have choose to use +# reciprocal division losing precision causing slightly different +# results which can lead to aliasing differences when running the testsuite +# Disable reciprocal division +if (CMAKE_COMPILER_IS_INTEL) + if (MSVC) + add_compile_options("/Qprec-div") + else () + add_compile_options("-prec-div") + endif () +elseif (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG OR CMAKE_COMPILER_IS_INTELCLANG) + add_compile_options("-fno-reciprocal-math") +endif () + # Tell CMake to process the sub-directories add_subdirectory (src/include) add_subdirectory (src/liboslcomp) diff --git a/src/build-scripts/gh-installdeps.bash b/src/build-scripts/gh-installdeps.bash index 1f6f05af3..d5cd1a6cd 100755 --- a/src/build-scripts/gh-installdeps.bash +++ b/src/build-scripts/gh-installdeps.bash @@ -40,11 +40,18 @@ if [[ "$ASWF_ORG" != "" ]] ; then popd fi - if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then + if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d sudo yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic set +e; source /opt/intel/oneapi/setvars.sh; set -e - icpc --version + if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then + echo "Verifying installation of Intel(r) C++ Compiler:" + icpc --version + fi + if [[ "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then + echo "Verifying installation of Intel(r) oneAPI DPC++/C++ Compiler:" + icpx --version + fi fi else @@ -80,14 +87,19 @@ else time sudo apt-get install -y g++-11 fi - if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then + if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list time sudo apt-get update time sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic set +e; source /opt/intel/oneapi/setvars.sh; set -e - icpc --version + if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then + icpc --version + fi + if [[ "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then + icpx --version + fi fi # Nonstandard python versions diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index e4a2b747d..54f8975c7 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -51,7 +51,8 @@ else () set (GCC_VERSION 0) endif () -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang" + OR CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") # If using any flavor of clang, set CMAKE_COMPILER_IS_CLANG. If it's # Apple's variety, set CMAKE_COMPILER_IS_APPLECLANG and # APPLECLANG_VERSION_STRING, otherwise for generic clang set @@ -65,6 +66,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan if (VERBOSE) message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}") endif () + elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") + set (CMAKE_COMPILER_IS_INTELCLANG 1) + string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) + if (VERBOSE) + message (STATUS "The compiler is Intel Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}") + endif () else () string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) if (VERBOSE) diff --git a/src/include/OSL/Imathx/Imathx.h b/src/include/OSL/Imathx/Imathx.h index ecb5f6527..89d9b2963 100644 --- a/src/include/OSL/Imathx/Imathx.h +++ b/src/include/OSL/Imathx/Imathx.h @@ -246,7 +246,7 @@ affineInverse(const Matrix44 &m) // differently than the LLVM IR version. // NOTE: only using "inline" to get ODR (One Definition Rule) behavior static inline OSL_HOSTDEVICE Matrix44 -#if !OSL_INTEL_COMPILER +#if !OSL_INTEL_CLASSIC_COMPILER_VERSION OSL_GNUC_ATTRIBUTE(optimize("fp-contract=off")) #endif nonAffineInverse(const Matrix44 &source); diff --git a/src/include/OSL/mask.h b/src/include/OSL/mask.h index 864ea1d53..a23bba241 100644 --- a/src/include/OSL/mask.h +++ b/src/include/OSL/mask.h @@ -21,7 +21,7 @@ OSL_NAMESPACE_ENTER using std::popcount; using std::countr_zero; -#elif OSL_INTEL_COMPILER +#elif OSL_INTEL_CLASSIC_COMPILER_VERSION OSL_FORCEINLINE int popcount(uint32_t x) noexcept { return _mm_popcnt_u32(x);} OSL_FORCEINLINE int popcount(uint64_t x) noexcept { return _mm_popcnt_u64(x); } diff --git a/src/include/OSL/oslnoise.h b/src/include/OSL/oslnoise.h index 167d00fca..a2d988ab5 100644 --- a/src/include/OSL/oslnoise.h +++ b/src/include/OSL/oslnoise.h @@ -640,7 +640,7 @@ OSL_FORCEINLINE OSL_HOSTDEVICE Dual2 select(const bool b, const Dual2 ( @@ -2247,7 +2247,7 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Dual2 &result, const H &hash, // With Dual2 data types, a lot of code is generated below // which caused some runaway compiler memory consumption when vectorizing -#if !OSL_INTEL_COMPILER +#if !OSL_INTEL_CLASSIC_COMPILER_VERSION auto l_result = OIIO::lerp ( OIIO::trilerp (grad (hash (X , Y , Z , W ), fx , fy , fz , fw ), grad (hash (X+1, Y , Z , W ), fx-1.0f, fy , fz , fw ), diff --git a/src/include/OSL/platform.h b/src/include/OSL/platform.h index ab94b6df0..3607cb556 100644 --- a/src/include/OSL/platform.h +++ b/src/include/OSL/platform.h @@ -28,9 +28,10 @@ // Notes: // __GNUC__ is defined for gcc and all clang varieties -// __clang__ is defined for all clang varieties (generic and Apple) +// __clang__ is defined for all clang varieties (generic, Apple, and Intel) // __apple_build_version__ is only defined for Apple clang // __INTEL_COMPILER is defined only for icc +// __INTEL_LLVM_COMPILER is defined only for icx // _MSC_VER is defined for MSVS compiler (not gcc/clang/icc even on Windows) // _WIN32 is defined on Windows regardless of compiler // __CUDACC__ is defined any time we are compiling a module for Cuda @@ -51,7 +52,7 @@ // 30402 for clang 3.4.2), or 0 if not a generic Clang release. // N.B. This will be 0 for the clang Apple distributes (which has different // version numbers entirely). -#if defined(__clang__) && !defined(__apple_build_version__) +#if defined(__clang__) && !defined(__apple_build_version__) && !defined(__INTEL_LLVM_COMPILER) # define OSL_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__) #else # define OSL_CLANG_VERSION 0 @@ -60,27 +61,45 @@ // Define OSL_APPLE_CLANG_VERSION to hold an encoded Apple Clang version // (e.g. 70002 for clang 7.0.2), or 0 if not an Apple Clang release. #if defined(__clang__) && defined(__apple_build_version__) +# if defined(__INTEL_LLVM_COMPILER) +# error Not expected for __INTEL_LLVM_COMPILER to be defined with an __apple_build_version__ +# endif # define OSL_APPLE_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__) #else # define OSL_APPLE_CLANG_VERSION 0 #endif +// The classic Intel(r) C++ Compiler on OSX may still define __clang__ +// combine with testing OSL_INTEL_CLASSIC_COMPILER_VERSION to further differentiate if needed. -// Define OSL_INTEL_COMPILER to hold an encoded Intel compiler version -// (e.g. 1900), or 0 if not an Intel compiler. +// Define OSL_INTEL_CLASSIC_COMPILER_VERSION to hold an encoded Intel(r) C++ Compiler version +// (e.g. 1900), or 0 if not an Intel(r) C++ Compiler. #if defined(__INTEL_COMPILER) -# define OSL_INTEL_COMPILER __INTEL_COMPILER +# define OSL_INTEL_CLASSIC_COMPILER_VERSION __INTEL_COMPILER +#else +# define OSL_INTEL_CLASSIC_COMPILER_VERSION 0 +#endif + +// Define OSL_INTEL_LLVM_COMPILER_VERSION to hold an encoded Intel(r) LLVM Compiler version +// (e.g. 20220000), or 0 if not an Intel(r) LLVM Compiler. +// Define OSL_INTEL_CLANG_VERSION to hold the encoded Clang version the +// Intel(r) LLVM Compiler is based on (e.g. 140000), +// or 0 if not an Intel(r) LLVM compiler. +#if defined(__INTEL_LLVM_COMPILER) +# define OSL_INTEL_LLVM_COMPILER_VERSION __INTEL_LLVM_COMPILER +# define OSL_INTEL_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__) #else -# define OSL_INTEL_COMPILER 0 +# define OSL_INTEL_LLVM_COMPILER_VERSION 0 +# define OSL_INTEL_CLANG_VERSION 0 #endif -// Intel's compiler on OSX may still define __clang__ -// and we have need to know when using a true clang compiler -#if !defined(__INTEL_COMPILER) && defined(__clang__) - #define OSL_NON_INTEL_CLANG __clang__ +// Define OSL_ANY_CLANG to 0 or 1 to indicate if any Clang based compiler is in use +#if defined(__clang__) +# define OSL_ANY_CLANG 1 #else - #define OSL_NON_INTEL_CLANG 0 +# define OSL_ANY_CLANG 0 #endif + // Tests for MSVS versions, always 0 if not MSVS at all. #if defined(_MSC_VER) # define OSL_MSVS_AT_LEAST_2013 (_MSC_VER >= 1800) @@ -243,6 +262,15 @@ #define OSL_OMP_PRAGMA(aUnQuotedPragma) #endif +#define OSL_OMP_SIMD_LOOP(...) OSL_OMP_PRAGMA(omp simd __VA_ARGS__) +#if (OSL_GCCVERSION || OSL_INTEL_CLASSIC_COMPILER_VERSION) +# define OSL_OMP_COMPLEX_SIMD_LOOP(...) OSL_OMP_SIMD_LOOP(__VA_ARGS__) +#else + // Ignore requests to vectorize complex/nested SIMD loops for certain + // compilers/versions that are not currently vectorizing complex loops. +# define OSL_OMP_COMPLEX_SIMD_LOOP(...) +#endif + // OSL_FORCEINLINE is a function attribute that attempts to make the // function always inline. On many compilers regular 'inline' is only // advisory. Put this attribute before the function return type, just like diff --git a/src/include/OSL/sfmath.h b/src/include/OSL/sfmath.h index faae11f5c..497df90d9 100644 --- a/src/include/OSL/sfmath.h +++ b/src/include/OSL/sfmath.h @@ -68,7 +68,7 @@ namespace sfm OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if OSL_INTEL_COMPILER +#if OSL_INTEL_CLASSIC_COMPILER_VERSION // std::isinf wasn't vectorizing and was branchy. This slightly // perturbed version fairs better and is branch free when vectorized // with the Intel compiler. @@ -263,7 +263,7 @@ namespace sfm } } -#if OSL_CLANG_VERSION && !OSL_INTEL_COMPILER +#if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION // To make clang's loop vectorizor happy // we need to make sure result of min and max diff --git a/src/include/OSL/wide.h b/src/include/OSL/wide.h index 47476689a..0ecb6d21b 100644 --- a/src/include/OSL/wide.h +++ b/src/include/OSL/wide.h @@ -1853,7 +1853,7 @@ struct WideImpl[], WidthT, true /*IsConstT */> { } // namespace pvt -#if OSL_INTEL_COMPILER || OSL_GNUC_VERSION +#if OSL_INTEL_CLASSIC_COMPILER_VERSION || OSL_GNUC_VERSION // Workaround for error #3466: inheriting constructors must be inherited from a direct base class # define __OSL_INHERIT_BASE_CTORS(DERIVED, BASE) \ using Base = typename DERIVED::BASE; \ @@ -3139,7 +3139,8 @@ template OSL_FORCEINLINE bool testIfAnyLaneIsNonZero(const Wide& wvalues) { -#if OSL_NON_INTEL_CLANG +#if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION \ + && !OSL_INTEL_LLVM_COMPILER_VERSION int anyLaneIsOn = 0; OSL_OMP_PRAGMA(omp simd simdlen(WidthT) reduction(max : anyLaneIsOn)) for (int i = 0; i < WidthT; ++i) { @@ -3149,7 +3150,8 @@ testIfAnyLaneIsNonZero(const Wide& wvalues) return anyLaneIsOn; #else // NOTE: do not explicitly vectorize as it would require a - // reduction. Instead let compiler optimize this itself. + // reduction. Instead let compiler optimize/auto-vectorize this by itself + // which can produce less/better code than a full blown openmp reduction. bool anyLaneIsOn = false; for (int i = 0; i < WidthT; ++i) { if (wvalues[i] != DataT(0)) diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt index d49cbc175..d94e679b6 100644 --- a/src/liboslexec/CMakeLists.txt +++ b/src/liboslexec/CMakeLists.txt @@ -97,6 +97,12 @@ set ( liboslexec_override_limits ../liboslnoise/wide/wide_gabor3_isotropic_enabled ) +set ( liboslexec_require_INF_NaN + shadingsys.cpp + wide/wide_shadingsys + wide/wide_optest_float + ) + set (local_lib oslexec) set (lib_src shadingsys.cpp closure.cpp @@ -144,6 +150,31 @@ FLEX_BISON ( ../liboslcomp/osllex.l ../liboslcomp/oslgram.y osl lib_src compiler set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS" ) + +macro ( REQUIRE_INF_NAN SRC ) + if (CMAKE_COMPILER_IS_INTELCLANG) + # if -ffast-math is enabled to to the underlying compiler, + # inf's and NaN's may not be handled properly (by design) + if (MSVC) + set_property(SOURCE ${SRC} APPEND PROPERTY COMPILE_OPTIONS "/fp:precise") + #message (STATUS "SOURCE ${SRC} APPEND PROPERTY COMPILE_OPTIONS /fp:precise") + else () + #set_property(SOURCE $SRC} APPEND PROPERTY COMPILE_OPTIONS "-fp-model=precise") + # Disabling fast-math should be enough to enable proper support of INF and NaN + set_property(SOURCE ${SRC} APPEND PROPERTY COMPILE_OPTIONS "-fno-fast-math") + #message (STATUS "SOURCE ${SRC} APPEND PROPERTY COMPILE_OPTIONS -fno-fast-math") + endif() + endif() +endmacro ( ) + +# Apply complilation options as needed +foreach(src ${lib_src}) + if (${src} IN_LIST liboslexec_require_INF_NaN) + set(SRC "${CMAKE_CURRENT_SOURCE_DIR}/${src}") + REQUIRE_INF_NAN ( ${SRC} ) + endif() +endforeach(src) + macro ( LLVM_COMPILE llvm_src srclist ) get_filename_component ( llvmsrc_we ${llvm_src} NAME_WE ) set ( llvm_asm "${CMAKE_CURRENT_BINARY_DIR}/${llvmsrc_we}.s" ) @@ -422,7 +453,11 @@ foreach(batched_target ${BATCHED_TARGET_LIST}) # it as soon as clang addresses this issue. list (APPEND TARGET_CXX_OPTS "-fno-unroll-loops") - list (APPEND TARGET_CXX_OPTS "-fopenmp") + if (CMAKE_COMPILER_IS_INTELCLANG) + list (APPEND TARGET_CXX_OPTS "-qopenmp-simd") + else () + list (APPEND TARGET_CXX_OPTS "-fopenmp") + endif () # Uncomment next section to investigate failures in vectorization #list (APPEND TARGET_CXX_OPTS @@ -484,6 +519,11 @@ foreach(batched_target ${BATCHED_TARGET_LIST}) endif() endif() endif() + + if (${target_src} IN_LIST liboslexec_require_INF_NaN) + REQUIRE_INF_NAN ( ${TARGET_SRC} ) + endif() + endforeach(target_src) add_library ( ${batched_target_lib} MODULE ${TARGET_LIB_SOURCES} ) diff --git a/src/liboslexec/opcolor_impl.h b/src/liboslexec/opcolor_impl.h index 00414585f..706a59f62 100644 --- a/src/liboslexec/opcolor_impl.h +++ b/src/liboslexec/opcolor_impl.h @@ -243,7 +243,7 @@ hsv_to_rgb (const COLOR3& hsv) // Avoid switch statement vectorizor doesn't like // Also avoid if/else nest which some optimizers might // convert back into a switch statement -# if OSL_CLANG_VERSION && !OSL_INTEL_COMPILER +# if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION // Clang was still transforming series of if's back into a switch. // Alternate between == and <= comparisons to avoid # define __OSL_ASC_EQ <= diff --git a/src/liboslexec/wide/wide_opcolor.cpp b/src/liboslexec/wide/wide_opcolor.cpp index 5a364b672..7fd707e5b 100644 --- a/src/liboslexec/wide/wide_opcolor.cpp +++ b/src/liboslexec/wide/wide_opcolor.cpp @@ -84,12 +84,10 @@ __OSL_MASKED_OP2(blackbody,Wv,Wf) } if (testIfAnyLaneIsNonZero(wcomputeRequired)) { -#if !OSL_CLANG_VERSION || OSL_INTEL_COMPILER - // Clang was unable to vectorize the nested loop in the real computation - // which is why we have split off the fast path of using the lookup table - // so it can be vectorized independently - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + // Complex nested loop in the real computation may not vectorize in + // in all compilers, which is why we have split off the fast path of + // using the lookup table so it can be vectorized independently + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { float temperature = wL[lane]; int computeRequired = wcomputeRequired[lane]; diff --git a/src/liboslexec/wide/wide_opmatrix.cpp b/src/liboslexec/wide/wide_opmatrix.cpp index e2b201b2e..3d580e2f9 100644 --- a/src/liboslexec/wide/wide_opmatrix.cpp +++ b/src/liboslexec/wide/wide_opmatrix.cpp @@ -433,6 +433,7 @@ OSL_BATCHOP void __OSL_MASKED_OP3(div, Wm, Wf, Wm)(void* wr_, void* wa_, if (testIfAnyLaneIsNonZero(wnotAffine)) { invoke([=]() -> void { + // DO NOT VECTORIZE the slow path for (int lane = 0; lane < __OSL_WIDTH; ++lane) { if (wnotAffine[lane]) { OSL_DASSERT(wresult.mask().is_on(lane)); @@ -1319,6 +1320,7 @@ impl_transform_normal_masked(void* Pin, void* Pout, Wide wM, if (testIfAnyLaneIsNonZero(wnotAffine)) { invoke([=]() -> void { + // DO NOT VECTORIZE the slow path for (int lane = 0; lane < __OSL_WIDTH; ++lane) { if (wnotAffine[lane]) { OSL_DASSERT(wresult.mask().is_on(lane)); @@ -1357,9 +1359,14 @@ impl_transform_normal_masked(void* Pin, void* Pout, const Matrix44& M, // Transform with Normal semantics - Matrix44 invM; + Matrix44 invM{Imath::UNINITIALIZED}; if (OSL_UNLIKELY(!test_if_affine(M))) { - invM = OSL::nonAffineInverse(M); + // Isolate expensive unlikley code + // in its own function as to not influence + // the optimization of the fast path + invoke([&]() -> void { + invM = OSL::nonAffineInverse(M); + }); } else { invM = OSL::affineInverse(M); } diff --git a/src/liboslexec/wide/wide_opspline.cpp b/src/liboslexec/wide/wide_opspline.cpp index f74256ca2..1d8e0c470 100644 --- a/src/liboslexec/wide/wide_opspline.cpp +++ b/src/liboslexec/wide/wide_opspline.cpp @@ -540,10 +540,7 @@ void splineinverse_evaluate_loop_over_wide( OSL_FORCEINLINE_BLOCK { -#if !OSL_CLANG_VERSION || OSL_INTEL_COMPILER - // Clang was unable to vectorize the nested loops - OSL_OMP_PRAGMA(omp simd simdlen(vec_width)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(vec_width)) for(int lane=0; lane < vec_width; ++lane) { X_Type x = wX[lane]; auto knots = wK[lane]; diff --git a/src/liboslexec/wide/wide_opstring.cpp b/src/liboslexec/wide/wide_opstring.cpp index e4c1ce1ac..30eeb2a9c 100644 --- a/src/liboslexec/wide/wide_opstring.cpp +++ b/src/liboslexec/wide/wide_opstring.cpp @@ -73,8 +73,9 @@ OSL_BATCHOP void __OSL_MASKED_OP2(strlen, Wi, Ws)(void* wr_, void* ws_, OSL_FORCEINLINE_BLOCK { +#if (!OSL_CLANG_VERSION || OSL_INTEL_CLASSIC_COMPILER_VERSION) + // Clang 11 generated SIMD crashes at runtime // TODO: investigate clang crash when vectorizing -#if !OSL_NON_INTEL_CLANG // Clang 11 generated SIMD crashes OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) #endif for (int lane = 0; lane < __OSL_WIDTH; ++lane) { diff --git a/src/liboslexec/wide/wide_shadingsys.cpp b/src/liboslexec/wide/wide_shadingsys.cpp index 194324f6a..03a3e8265 100644 --- a/src/liboslexec/wide/wide_shadingsys.cpp +++ b/src/liboslexec/wide/wide_shadingsys.cpp @@ -2,28 +2,12 @@ // SPDX-License-Identifier: BSD-3-Clause // https://github.com/AcademySoftwareFoundation/OpenShadingLanguage -//#include -//#include -//#include -//#include -//#include -//#include - #include #include #include #include -//#include "OSL/genclosure.h" -//#include "OSL/oslquery.h" - -//#include -//#include -//#include -//#include -//#include -//#include #include #include "oslexec_pvt.h" diff --git a/src/liboslnoise/wide/wide_gabornoise.h b/src/liboslnoise/wide/wide_gabornoise.h index 78be6db53..199235e61 100644 --- a/src/liboslnoise/wide/wide_gabornoise.h +++ b/src/liboslnoise/wide/wide_gabornoise.h @@ -41,9 +41,7 @@ wide_gabor(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; Vec3 direction = wDirection[lane]; @@ -71,9 +69,7 @@ wide_gabor(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; const Dual2 y = wY[lane]; @@ -100,9 +96,7 @@ wide_gabor(Masked> wResult, Wide> wP, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 P = wP[lane]; Vec3 direction = wDirection[lane]; @@ -128,9 +122,7 @@ wide_gabor3(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; Vec3 direction = wDirection[lane]; @@ -157,9 +149,7 @@ wide_gabor3(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; const Dual2 y = wY[lane]; @@ -186,9 +176,7 @@ wide_gabor3(Masked> wResult, Wide> wP, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 P = wP[lane]; Vec3 direction = wDirection[lane]; @@ -215,9 +203,7 @@ wide_pgabor(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; const float xperiod = wXp[lane]; @@ -249,9 +235,7 @@ wide_pgabor(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; const Dual2 y = wY[lane]; @@ -284,9 +268,7 @@ wide_pgabor(Masked> wResult, Wide> wP, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 P = wP[lane]; Vec3 Pperiod = wPp[lane]; @@ -315,9 +297,7 @@ wide_pgabor3(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; const float xperiod = wXp[lane]; @@ -349,9 +329,7 @@ wide_pgabor3(Masked> wResult, Wide> wX, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 x = wX[lane]; const Dual2 y = wY[lane]; @@ -384,9 +362,7 @@ wide_pgabor3(Masked> wResult, Wide> wP, sfm::GaborUniformParams gup(*opt); __OSL_SETUP_WIDE_DIRECTION -#if !OSL_NON_INTEL_CLANG // Control flow too complex for clang's loop vectorizor - OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH)) -#endif + OSL_OMP_COMPLEX_SIMD_LOOP(simdlen(__OSL_WIDTH)) for (int lane = 0; lane < __OSL_WIDTH; ++lane) { const Dual2 P = wP[lane]; Vec3 Pperiod = wPp[lane]; diff --git a/src/testrender/CMakeLists.txt b/src/testrender/CMakeLists.txt index 6c005288a..cde271d32 100644 --- a/src/testrender/CMakeLists.txt +++ b/src/testrender/CMakeLists.txt @@ -40,6 +40,13 @@ if (USE_OPTIX) DESTINATION ${OSL_PTX_INSTALL_DIR}) endif() +if (CMAKE_COMPILER_IS_INTELCLANG) + # To better match existing test results + add_compile_options("-fp-model=precise") + # Better performance is likely by not requiring a precise floating point + # model, although with slightly different numerical results. +endif () + add_executable (testrender ${testrender_srcs}) target_link_libraries (testrender diff --git a/src/testshade/CMakeLists.txt b/src/testshade/CMakeLists.txt index f9cd19820..563bc32fd 100644 --- a/src/testshade/CMakeLists.txt +++ b/src/testshade/CMakeLists.txt @@ -15,20 +15,6 @@ if (BUILD_BATCHED) ) endif() -if (CMAKE_COMPILER_IS_INTEL) - # Make sure our shader globals are calculated consistently - # especially those with division. We want to avoid aliasing - # difference when running the testsuite - if (MSVC) - #add_definitions("/fp:precise") - add_definitions("/Qprec-div") - else () - #add_definitions("-fp-model precise") - add_definitions("-prec-div") - endif () -endif () - - if (USE_OPTIX) set ( testshade_cuda_srcs cuda/optix_grid_renderer.cu diff --git a/testsuite/area-reg/run.py b/testsuite/area-reg/run.py index f869e15b0..c773bc8ee 100644 --- a/testsuite/area-reg/run.py +++ b/testsuite/area-reg/run.py @@ -5,15 +5,15 @@ # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_area_point_u_point.tif test_area_u_point") -command += testshade("--vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_point.tif test_area_v_point") -command += testshade("--vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_dpoint.tif test_area_v_dpoint") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_area_point_u_point.tif test_area_u_point") +command += testshade("--center --vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_point.tif test_area_v_point") +command += testshade("--center --vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_dpoint.tif test_area_v_dpoint") outputs.append ("out_area_point_u_point.tif") outputs.append ("out_area_point_v_point.tif") outputs.append ("out_area_point_v_dpoint.tif") -command += testshade("--vary_pdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_point_B.tif test_area_v_point_B") -command += testshade("--vary_pdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_dpoint_B.tif test_area_v_dpoint_B") +command += testshade("--center --vary_pdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_point_B.tif test_area_v_point_B") +command += testshade("--center --vary_pdxdy -t 1 -g 64 64 -od uint8 -o Cout out_area_point_v_dpoint_B.tif test_area_v_dpoint_B") outputs.append ("out_area_point_v_point_B.tif") outputs.append ("out_area_point_v_dpoint_B.tif") diff --git a/testsuite/arithmetic-reg/run.py b/testsuite/arithmetic-reg/run.py index 215eeb548..5f1bf7559 100755 --- a/testsuite/arithmetic-reg/run.py +++ b/testsuite/arithmetic-reg/run.py @@ -6,7 +6,7 @@ def run_multi_type_test (opname, tagname, options) : global command - command += testshade("-g 32 32 --param numStripes 16 "+options+" -od uint8 -o out_float out_float_"+tagname+".tif -o out_color out_color_"+tagname+".tif -o out_point out_point_"+tagname+".tif -o out_vector out_vector_"+tagname+".tif -o out_normal out_normal_"+tagname+".tif test_"+opname) + command += testshade("--center -t 1 -g 32 32 --param numStripes 16 "+options+" -od uint8 -o out_float out_float_"+tagname+".tif -o out_color out_color_"+tagname+".tif -o out_point out_point_"+tagname+".tif -o out_vector out_vector_"+tagname+".tif -o out_normal out_normal_"+tagname+".tif test_"+opname) global outputs outputs.append ("out_float_"+tagname+".tif") outputs.append ("out_color_"+tagname+".tif") @@ -22,7 +22,7 @@ def run_unary_tests (opname) : return # Run unary tests with varying and a 2nd time with uniform(u) argument to the op -# Choose not to test variation of a constant argument, as that should be constant folded +# Choose not to test variation of a constant argument, as that should be constant folded run_unary_tests ("neg") run_unary_tests ("neg_u") @@ -49,7 +49,7 @@ def run_unary_tests (opname) : def run_int_test (opname, tagname, options) : global command - command += testshade("-g 32 32 --param numStripes 16 "+options+" -od uint8 -o out_int out_int_"+tagname+".tif test_"+opname) + command += testshade("--center -t 1 -g 32 32 --param numStripes 16 "+options+" -od uint8 -o out_int out_int_"+tagname+".tif test_"+opname) global outputs outputs.append ("out_int_"+tagname+".tif") return diff --git a/testsuite/exponential/ref/out.icx.txt b/testsuite/exponential/ref/out.icx.txt new file mode 100644 index 000000000..9452fb043 --- /dev/null +++ b/testsuite/exponential/ref/out.icx.txt @@ -0,0 +1,67 @@ +Compiled test.osl -> test.oso + log (2.71828) = 1 + log (2.71828, 27) = 0.303413 + log2 (2.71828) = 1.4427 + log10 (2.71828) = 0.434295 + logb (2.71828) = 1 + exp (2.71828) = 15.1543 + exp2 (2.71828) = 6.58092 + expm1 (2.71828) = 14.1543 + erf (2.71828) = 0.999879 + erfc (2.71828) = 0.000121176 + log (27.1828) = 3.30259 + log (27.1828, 27) = 1.00205 + log2 (27.1828) = 4.76462 + log10 (27.1828) = 1.43429 + logb (27.1828) = 4 + exp (27.1828) = 6.38773e+11 + exp2 (27.1828) = 1.5235e+08 + expm1 (27.1828) = 6.38773e+11 + erf (27.1828) = 1 + erfc (27.1828) = 0 + log (2, 2) = 1 + log (10, 10) = 1 + pow (2, 1.5) = 2.82842 + pow (-2, 1.5) = 0 + pow (-2, 0) = 1 + pow (-2, 3) = -8 + pow (0, 3) = 0 + pow (0, -3) = 0 + pow (0, 0) = 1 + pow (2.2, 2) = 4.84 + pow (-2.2, 2) = 4.84 + pow (1e+20, 2) = 3.40282e+38 [should be clamped, not inf!] + pow (2.5, 1) = 2.5 + log (2.71828 2.71828 2.71828) = 1 1 1 + log (2.71828 2.71828 2.71828, 27) = 0.303413 0.303413 0.303413 + log2 (2.71828 2.71828 2.71828) = 1.4427 1.4427 1.4427 + log10 (2.71828 2.71828 2.71828) = 0.434295 0.434295 0.434295 + logb (2.71828 2.71828 2.71828) = 1 1 1 + exp (2.71828 2.71828 2.71828) = 15.1543 15.1543 15.1543 + exp2 (2.71828 2.71828 2.71828) = 6.58092 6.58092 6.58092 + expm1 (2.71828 2.71828 2.71828) = 14.1543 14.1543 14.1543 + log (27.1828 27.1828 27.1828) = 3.30259 3.30259 3.30259 + log (27.1828 27.1828 27.1828, 27) = 1.00205 1.00205 1.00205 + log2 (27.1828 27.1828 27.1828) = 4.76462 4.76462 4.76462 + log10 (27.1828 27.1828 27.1828) = 1.43429 1.43429 1.43429 + logb (27.1828 27.1828 27.1828) = 4 4 4 + exp (27.1828 27.1828 27.1828) = 6.38773e+11 6.38773e+11 6.38773e+11 + exp2 (27.1828 27.1828 27.1828) = 1.5235e+08 1.5235e+08 1.5235e+08 + expm1 (27.1828 27.1828 27.1828) = 6.38773e+11 6.38773e+11 6.38773e+11 + log (2 2 2, 2) = 1 1 1 + log (10 10 10, 10) = 1 1 1 + pow (2 2 2, 1.5) = 2.82842 2.82842 2.82842 + pow (-2 -2 -2, 1.5) = 0 0 0 + pow (-2 -2 -2, 0) = 1 1 1 + pow (-2 -2 -2, 3) = -8 -8 -8 + pow (0 0 0, 3) = 0 0 0 + pow (0 0 0, -3) = 0 0 0 + pow (0 0 0, 0) = 1 1 1 + pow (2 2 2, 1.5 1.5 1.5) = 2.82842 2.82842 2.82842 + pow (-2 -2 -2, 1.5 1.5 1.5) = 0 0 0 + pow (-2 -2 -2, 0 0 0) = 1 1 1 + pow (-2 -2 -2, 3 3 3) = -8 -8 -8 + pow (0 0 0, 3 3 3) = 0 0 0 + pow (0 0 0, -3 -3 -3) = 0 0 0 + pow (0 0 0, 0 0 0) = 1 1 1 + diff --git a/testsuite/geomath/ref/out.icx.txt b/testsuite/geomath/ref/out.icx.txt new file mode 100644 index 000000000..0bf077b21 --- /dev/null +++ b/testsuite/geomath/ref/out.icx.txt @@ -0,0 +1,90 @@ +Compiled test.osl -> test.oso + hypot (3, 4) = 5 + hypot (3, 4, 5) = 7.07107 + reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0 + reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0 + faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1 + faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1 + testing total-internal reflection: + refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0 + frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0 + testing regular refraction: + refract (-0.436436 -0.218218 -0.872872, 0.267261 0.534522 0.801784, 0.862069) = -0.415346 -0.266336 -0.869801 + --> verify refract(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + fresnel: Kr= 0.00557255 Kt = 0.739022 R = 0.0623479 0.77935 0.62348 T = -0.415346 -0.266336 -0.869801 + --> verify fresnel(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + Varying: + hypot (0, 0) = 0 + hypot (0, 0, 0) = 0 + reflect (0 -1 0, 0 1 0) = 0 1 0 + refract (0.408248 -0.408248 -0.816497, 0 0 1, 0.75188) = 0.306954 -0.306954 -0.900866 + --> verify refract(): 1/1.33 = sin(25.7301)/sin(35.2637) => 0.75188 ?= 0.75188 + fresnel() -> Kr= 0.0222824 Kt = 0.552726 R = 0.408248 -0.408248 0.816497 T = 0.306954 -0.306954 -0.900866 + --> verify fresnel(): 1/1.33 = sin(25.7301)/sin(35.2637) => 0.75188 ?= 0.75188 + hypot (3, 4) = 5 + hypot (3, 4, 5) = 7.07107 + reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0 + reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0 + faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1 + faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1 + testing total-internal reflection: + refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0 + frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0 + testing regular refraction: + refract (-0.436436 -0.218218 -0.872872, 0.267261 0.534522 0.801784, 0.862069) = -0.415346 -0.266336 -0.869801 + --> verify refract(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + fresnel: Kr= 0.00557255 Kt = 0.739022 R = 0.0623479 0.77935 0.62348 T = -0.415346 -0.266336 -0.869801 + --> verify fresnel(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + Varying: + hypot (1, 0) = 1 + hypot (1, 0, 1) = 1.41421 + reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0 + refract (0.801784 -0.267261 -0.534522, 0 0 1, 0.75188) = 0.602845 -0.200948 -0.772138 + --> verify refract(): 1/1.33 = sin(39.4519)/sin(57.6878) => 0.75188 ?= 0.75188 + fresnel() -> Kr= 0.0505776 Kt = 0.53673 R = 0.801784 -0.267261 0.534522 T = 0.602845 -0.200948 -0.772138 + --> verify fresnel(): 1/1.33 = sin(39.4519)/sin(57.6878) => 0.75188 ?= 0.75188 + hypot (3, 4) = 5 + hypot (3, 4, 5) = 7.07107 + reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0 + reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0 + faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1 + faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1 + testing total-internal reflection: + refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0 + frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0 + testing regular refraction: + refract (-0.436436 -0.218218 -0.872872, 0.267261 0.534522 0.801784, 0.862069) = -0.415346 -0.266336 -0.869801 + --> verify refract(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + fresnel: Kr= 0.00557255 Kt = 0.739022 R = 0.0623479 0.77935 0.62348 T = -0.415346 -0.266336 -0.869801 + --> verify fresnel(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + Varying: + hypot (0, 1) = 1 + hypot (0, 1, 1) = 1.41421 + reflect (0 -1 0, 0.707107 0.707107 0) = 1 0 0 + refract (0.408248 0.408248 -0.816497, 0 0 1, 0.75188) = 0.306954 0.306954 -0.900866 + --> verify refract(): 1/1.33 = sin(25.7301)/sin(35.2637) => 0.75188 ?= 0.75188 + fresnel() -> Kr= 0.0222824 Kt = 0.552726 R = 0.408248 0.408248 0.816497 T = 0.306954 0.306954 -0.900866 + --> verify fresnel(): 1/1.33 = sin(25.7301)/sin(35.2637) => 0.75188 ?= 0.75188 + hypot (3, 4) = 5 + hypot (3, 4, 5) = 7.07107 + reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0 + reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0 + faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1 + faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1 + testing total-internal reflection: + refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0 + frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0 + testing regular refraction: + refract (-0.436436 -0.218218 -0.872872, 0.267261 0.534522 0.801784, 0.862069) = -0.415346 -0.266336 -0.869801 + --> verify refract(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + fresnel: Kr= 0.00557255 Kt = 0.739022 R = 0.0623479 0.77935 0.62348 T = -0.415346 -0.266336 -0.869801 + --> verify fresnel(): 1/1.16 = sin(18.0571)/sin(21.073) => 0.862069 ?= 0.86207 + Varying: + hypot (1, 1) = 1.41421 + hypot (1, 1, 2) = 2.44949 + reflect (0.447214 -0.894427 0, 0.707107 0.707107 0) = 0.894427 -0.447214 0 + refract (0.801784 0.267261 -0.534522, 0 0 1, 0.75188) = 0.602845 0.200948 -0.772138 + --> verify refract(): 1/1.33 = sin(39.4519)/sin(57.6878) => 0.75188 ?= 0.75188 + fresnel() -> Kr= 0.0505776 Kt = 0.53673 R = 0.801784 0.267261 0.534522 T = 0.602845 0.200948 -0.772138 + --> verify fresnel(): 1/1.33 = sin(39.4519)/sin(57.6878) => 0.75188 ?= 0.75188 + diff --git a/testsuite/length-reg/run.py b/testsuite/length-reg/run.py index f4cb82e6a..d44787f1a 100644 --- a/testsuite/length-reg/run.py +++ b/testsuite/length-reg/run.py @@ -5,12 +5,12 @@ # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout sout_vector_u_vector.tif test_length_u_vector") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout sout_vector_v_vector.tif test_length_v_vector") -command += testshade("--vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout sout_vector_v_dvector.tif test_length_v_dvector") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout sout_normal_u_normal.tif test_length_u_normal") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout sout_normal_v_normal.tif test_length_v_normal") -command += testshade("--vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout sout_normal_v_dnormal.tif test_length_v_dnormal") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout sout_vector_u_vector.tif test_length_u_vector") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout sout_vector_v_vector.tif test_length_v_vector") +command += testshade("--center --vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout sout_vector_v_dvector.tif test_length_v_dvector") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout sout_normal_u_normal.tif test_length_u_normal") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout sout_normal_v_normal.tif test_length_v_normal") +command += testshade("--center --vary_udxdy --vary_vdxdy -t 1 -g 64 64 -od uint8 -o Cout sout_normal_v_dnormal.tif test_length_v_dnormal") outputs.append ("sout_vector_u_vector.tif") outputs.append ("sout_vector_v_vector.tif") outputs.append ("sout_vector_v_dvector.tif") diff --git a/testsuite/matrix-arithmetic-reg/run.py b/testsuite/matrix-arithmetic-reg/run.py index 00ad24a02..f20ab1117 100644 --- a/testsuite/matrix-arithmetic-reg/run.py +++ b/testsuite/matrix-arithmetic-reg/run.py @@ -5,31 +5,31 @@ # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage # multiply float and matrix -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_u_matrix.tif test_u_float_mul_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_v_matrix.tif test_u_float_mul_v_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_u_matrix.tif test_v_float_mul_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_v_matrix.tif test_v_float_mul_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_u_matrix.tif test_u_float_mul_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_v_matrix.tif test_u_float_mul_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_u_matrix.tif test_v_float_mul_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_v_matrix.tif test_v_float_mul_v_matrix") outputs.append ("out_u_float_mul_u_matrix.tif") outputs.append ("out_u_float_mul_v_matrix.tif") outputs.append ("out_v_float_mul_u_matrix.tif") outputs.append ("out_v_float_mul_v_matrix.tif") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_u_matrix_masked.tif test_u_float_mul_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_v_matrix_masked.tif test_u_float_mul_v_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_u_matrix_masked.tif test_v_float_mul_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_v_matrix_masked.tif test_v_float_mul_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_u_matrix_masked.tif test_u_float_mul_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_mul_v_matrix_masked.tif test_u_float_mul_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_u_matrix_masked.tif test_v_float_mul_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_mul_v_matrix_masked.tif test_v_float_mul_v_matrix_masked") outputs.append ("out_u_float_mul_u_matrix_masked.tif") outputs.append ("out_u_float_mul_v_matrix_masked.tif") outputs.append ("out_v_float_mul_u_matrix_masked.tif") outputs.append ("out_v_float_mul_v_matrix_masked.tif") # multiply matrix and float -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_float.tif test_u_matrix_mul_u_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_float.tif test_u_matrix_mul_v_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_float.tif test_v_matrix_mul_u_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_float.tif test_v_matrix_mul_v_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_int.tif test_v_matrix_mul_v_int") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_conditional.tif test_v_matrix_mul_v_conditional") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_float.tif test_u_matrix_mul_u_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_float.tif test_u_matrix_mul_v_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_float.tif test_v_matrix_mul_u_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_float.tif test_v_matrix_mul_v_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_int.tif test_v_matrix_mul_v_int") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_conditional.tif test_v_matrix_mul_v_conditional") outputs.append ("out_u_matrix_mul_u_float.tif") outputs.append ("out_u_matrix_mul_v_float.tif") outputs.append ("out_v_matrix_mul_u_float.tif") @@ -37,10 +37,10 @@ outputs.append ("out_v_matrix_mul_v_int.tif") outputs.append ("out_v_matrix_mul_v_conditional.tif") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_float_masked.tif test_u_matrix_mul_u_float_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_float_masked.tif test_u_matrix_mul_v_float_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_float_masked.tif test_v_matrix_mul_u_float_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_float_masked.tif test_v_matrix_mul_v_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_float_masked.tif test_u_matrix_mul_u_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_float_masked.tif test_u_matrix_mul_v_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_float_masked.tif test_v_matrix_mul_u_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_float_masked.tif test_v_matrix_mul_v_float_masked") outputs.append ("out_u_matrix_mul_u_float_masked.tif") outputs.append ("out_u_matrix_mul_v_float_masked.tif") outputs.append ("out_v_matrix_mul_u_float_masked.tif") @@ -48,19 +48,19 @@ # multiply matrix and matrix -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_matrix.tif test_u_matrix_mul_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_matrix.tif test_u_matrix_mul_v_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_matrix.tif test_v_matrix_mul_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_matrix.tif test_v_matrix_mul_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_matrix.tif test_u_matrix_mul_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_matrix.tif test_u_matrix_mul_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_matrix.tif test_v_matrix_mul_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_matrix.tif test_v_matrix_mul_v_matrix") outputs.append ("out_u_matrix_mul_u_matrix.tif") outputs.append ("out_u_matrix_mul_v_matrix.tif") outputs.append ("out_v_matrix_mul_u_matrix.tif") outputs.append ("out_v_matrix_mul_v_matrix.tif") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_matrix_masked.tif test_u_matrix_mul_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_matrix_masked.tif test_u_matrix_mul_v_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_matrix_masked.tif test_v_matrix_mul_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_matrix_masked.tif test_v_matrix_mul_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_u_matrix_masked.tif test_u_matrix_mul_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_mul_v_matrix_masked.tif test_u_matrix_mul_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_u_matrix_masked.tif test_v_matrix_mul_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_mul_v_matrix_masked.tif test_v_matrix_mul_v_matrix_masked") outputs.append ("out_u_matrix_mul_u_matrix_masked.tif") outputs.append ("out_u_matrix_mul_v_matrix_masked.tif") outputs.append ("out_v_matrix_mul_u_matrix_masked.tif") @@ -68,57 +68,57 @@ # divide float by matrix -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_u_matrix.tif test_u_float_div_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_v_matrix.tif test_u_float_div_v_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_u_matrix.tif test_v_float_div_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_v_matrix.tif test_v_float_div_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_u_matrix.tif test_u_float_div_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_v_matrix.tif test_u_float_div_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_u_matrix.tif test_v_float_div_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_v_matrix.tif test_v_float_div_v_matrix") outputs.append ("out_u_float_div_u_matrix.tif") outputs.append ("out_u_float_div_v_matrix.tif") outputs.append ("out_v_float_div_u_matrix.tif") outputs.append ("out_v_float_div_v_matrix.tif") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_u_matrix_masked.tif test_u_float_div_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_v_matrix_masked.tif test_u_float_div_v_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_u_matrix_masked.tif test_v_float_div_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_v_matrix_masked.tif test_v_float_div_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_u_matrix_masked.tif test_u_float_div_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_float_div_v_matrix_masked.tif test_u_float_div_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_u_matrix_masked.tif test_v_float_div_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_float_div_v_matrix_masked.tif test_v_float_div_v_matrix_masked") outputs.append ("out_u_float_div_u_matrix_masked.tif") outputs.append ("out_u_float_div_v_matrix_masked.tif") outputs.append ("out_v_float_div_u_matrix_masked.tif") outputs.append ("out_v_float_div_v_matrix_masked.tif") # divide matrix by float -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_float.tif test_u_matrix_div_u_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_float.tif test_u_matrix_div_v_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_float.tif test_v_matrix_div_u_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_float.tif test_v_matrix_div_v_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_float.tif test_u_matrix_div_u_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_float.tif test_u_matrix_div_v_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_float.tif test_v_matrix_div_u_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_float.tif test_v_matrix_div_v_float") outputs.append ("out_u_matrix_div_u_float.tif") outputs.append ("out_u_matrix_div_v_float.tif") outputs.append ("out_v_matrix_div_u_float.tif") outputs.append ("out_v_matrix_div_v_float.tif") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_float_masked.tif test_u_matrix_div_u_float_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_float_masked.tif test_u_matrix_div_v_float_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_float_masked.tif test_v_matrix_div_u_float_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_float_masked.tif test_v_matrix_div_v_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_float_masked.tif test_u_matrix_div_u_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_float_masked.tif test_u_matrix_div_v_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_float_masked.tif test_v_matrix_div_u_float_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_float_masked.tif test_v_matrix_div_v_float_masked") outputs.append ("out_u_matrix_div_u_float_masked.tif") outputs.append ("out_u_matrix_div_v_float_masked.tif") outputs.append ("out_v_matrix_div_u_float_masked.tif") outputs.append ("out_v_matrix_div_v_float_masked.tif") # divide matrix by matrix -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_matrix.tif test_u_matrix_div_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_matrix.tif test_u_matrix_div_v_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_matrix.tif test_v_matrix_div_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_matrix.tif test_v_matrix_div_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_matrix.tif test_u_matrix_div_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_matrix.tif test_u_matrix_div_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_matrix.tif test_v_matrix_div_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_matrix.tif test_v_matrix_div_v_matrix") outputs.append ("out_u_matrix_div_u_matrix.tif") outputs.append ("out_u_matrix_div_v_matrix.tif") outputs.append ("out_v_matrix_div_u_matrix.tif") outputs.append ("out_v_matrix_div_v_matrix.tif") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_matrix_masked.tif test_u_matrix_div_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_matrix_masked.tif test_u_matrix_div_v_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_matrix_masked.tif test_v_matrix_div_u_matrix_masked") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_matrix_masked.tif test_v_matrix_div_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_u_matrix_masked.tif test_u_matrix_div_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_u_matrix_div_v_matrix_masked.tif test_u_matrix_div_v_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_u_matrix_masked.tif test_v_matrix_div_u_matrix_masked") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_v_matrix_div_v_matrix_masked.tif test_v_matrix_div_v_matrix_masked") outputs.append ("out_u_matrix_div_u_matrix_masked.tif") outputs.append ("out_u_matrix_div_v_matrix_masked.tif") outputs.append ("out_v_matrix_div_u_matrix_masked.tif") @@ -126,8 +126,8 @@ # negate matrix -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_neg_u_matrix.tif test_neg_u_matrix") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_neg_v_matrix.tif test_neg_v_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_neg_u_matrix.tif test_neg_u_matrix") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_neg_v_matrix.tif test_neg_v_matrix") outputs.append ("out_neg_u_matrix.tif") outputs.append ("out_neg_v_matrix.tif") @@ -135,4 +135,3 @@ # expect a few LSB failures failthresh = 0.008 failpercent = 3 - diff --git a/testsuite/matrix-compref-reg/run.py b/testsuite/matrix-compref-reg/run.py index 7bcd73943..76bb79b5b 100644 --- a/testsuite/matrix-compref-reg/run.py +++ b/testsuite/matrix-compref-reg/run.py @@ -4,18 +4,18 @@ # SPDX-License-Identifier: BSD-3-Clause # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage -command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_compref_u_matrix_const_index.tif test_compref_u_matrix_const_index") -command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_compref_v_matrix_const_index.tif test_compref_v_matrix_const_index") +command += testshade("--center -t 1 -g 256 256 -od uint8 -o Cout out_compref_u_matrix_const_index.tif test_compref_u_matrix_const_index") +command += testshade("--center -t 1 -g 256 256 -od uint8 -o Cout out_compref_v_matrix_const_index.tif test_compref_v_matrix_const_index") outputs.append ("out_compref_u_matrix_const_index.tif") outputs.append ("out_compref_v_matrix_const_index.tif") -command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_compref_u_matrix_u_index.tif test_compref_u_matrix_u_index") -command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_compref_v_matrix_u_index.tif test_compref_v_matrix_u_index") +command += testshade("--center -t 1 -g 256 256 -od uint8 -o Cout out_compref_u_matrix_u_index.tif test_compref_u_matrix_u_index") +command += testshade("--center -t 1 -g 256 256 -od uint8 -o Cout out_compref_v_matrix_u_index.tif test_compref_v_matrix_u_index") outputs.append ("out_compref_u_matrix_u_index.tif") outputs.append ("out_compref_v_matrix_u_index.tif") -command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_compref_u_matrix_v_index.tif test_compref_u_matrix_v_index") -command += testshade("-t 1 -g 256 256 -od uint8 -o Cout out_compref_v_matrix_v_index.tif test_compref_v_matrix_v_index") +command += testshade("--center -t 1 -g 256 256 -od uint8 -o Cout out_compref_u_matrix_v_index.tif test_compref_u_matrix_v_index") +command += testshade("--center -t 1 -g 256 256 -od uint8 -o Cout out_compref_v_matrix_v_index.tif test_compref_v_matrix_v_index") outputs.append ("out_compref_u_matrix_v_index.tif") outputs.append ("out_compref_v_matrix_v_index.tif") diff --git a/testsuite/max-reg/run.py b/testsuite/max-reg/run.py index 92c1ba7c6..d807d758a 100644 --- a/testsuite/max-reg/run.py +++ b/testsuite/max-reg/run.py @@ -5,26 +5,26 @@ # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage # max(float,float) includes masking -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_u_float_u_float.tif test_max_u_float_u_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_u_float_v_float.tif test_max_u_float_v_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_v_float_u_float.tif test_max_v_float_u_float") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_v_float_v_float.tif test_max_v_float_v_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_u_float_u_float.tif test_max_u_float_u_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_u_float_v_float.tif test_max_u_float_v_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_v_float_u_float.tif test_max_v_float_u_float") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_v_float_v_float.tif test_max_v_float_v_float") # Derivs includes masking -command += testshade("--vary_udxdy --vary_udxdy -t 1 -g 64 64 -od uint8 -o Cout out_max_v_dfloat_v_dfloat.tif test_max_v_dfloat_v_dfloat") +command += testshade("--center --vary_udxdy --vary_udxdy -t 1 -g 64 64 -od uint8 -o Cout out_max_v_dfloat_v_dfloat.tif test_max_v_dfloat_v_dfloat") # max(int, int) (includes masking) -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_u_int_u_int.tif test_max_u_int_u_int") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_u_int_v_int.tif test_max_u_int_v_int") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_v_int_u_int.tif test_max_v_int_u_int") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_v_int_v_int.tif test_max_v_int_v_int") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_u_int_u_int.tif test_max_u_int_u_int") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_u_int_v_int.tif test_max_u_int_v_int") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_v_int_u_int.tif test_max_v_int_u_int") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_v_int_v_int.tif test_max_v_int_v_int") # max(vec, vec) (including Masking) -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_u_vec_u_vec.tif test_max_u_vec_u_vec") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_u_vec_v_vec.tif test_max_u_vec_v_vec") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_v_vec_v_vec.tif test_max_v_vec_v_vec") -command += testshade("-t 1 -g 64 64 -od uint8 -o Cout out_max_v_vec_u_vec.tif test_max_v_vec_u_vec") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_u_vec_u_vec.tif test_max_u_vec_u_vec") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_u_vec_v_vec.tif test_max_u_vec_v_vec") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_v_vec_v_vec.tif test_max_v_vec_v_vec") +command += testshade("--center -t 1 -g 64 64 -od uint8 -o Cout out_max_v_vec_u_vec.tif test_max_v_vec_u_vec") # Derivs includes masking -command += testshade("--vary_udxdy --vary_udxdy -t 1 -g 64 64 -od uint8 -o Cout out_max_v_dvec_v_dvec.tif test_max_v_dvec_v_dvec") +command += testshade("--center --vary_udxdy --vary_udxdy -t 1 -g 64 64 -od uint8 -o Cout out_max_v_dvec_v_dvec.tif test_max_v_dvec_v_dvec") outputs = [ "out_max_u_float_u_float.tif", diff --git a/testsuite/spline-boundarybug/ref/out.icx.txt b/testsuite/spline-boundarybug/ref/out.icx.txt new file mode 100644 index 000000000..37ff0f0bf --- /dev/null +++ b/testsuite/spline-boundarybug/ref/out.icx.txt @@ -0,0 +1,5 @@ +Compiled test.osl -> test.oso +(0.600000,0.000000) +(0.600000,0.000000) +(0.600000,0.306263) + diff --git a/testsuite/trig/ref/out.txt b/testsuite/trig/ref/out.txt index c6a52e8d7..b6212fd18 100644 --- a/testsuite/trig/ref/out.txt +++ b/testsuite/trig/ref/out.txt @@ -1,17 +1,17 @@ Compiled test.osl -> test.oso cos (-3.14159) = -1 - sin (-3.14159) = 1.19209e-07 - sincos (-3.14159) = 1.19209e-07 -1 - tan (-3.14159) = -5.96046e-08 + sin (-3.14159) = 0 + sincos (-3.14159) = 0 -1 + tan (-3.14159) = 0 acos (-3.14159) = 3.14159 asin (-3.14159) = -1.5708 atan (-3.14159) = -1.26262 atan2 (-3.14159, -6.28319) = -2.67794 degrees (-3.14159) = -180 radians (-3.14159) = -0.0548311 - cos (-1.5708) = -2.38419e-07 + cos (-1.5708) = 0 sin (-1.5708) = -1 - sincos (-1.5708) = -1 -2.38419e-07 + sincos (-1.5708) = -1 0 tan (-1.5708) = 2.28773e+07 acos (-1.5708) = 3.14159 asin (-1.5708) = -1.5708 @@ -48,9 +48,9 @@ Compiled test.osl -> test.oso atan2 (0.785398, 1.5708) = 0.46365 degrees (0.785398) = 45 radians (0.785398) = 0.0137078 - cos (1.5708) = -2.38419e-07 + cos (1.5708) = 0 sin (1.5708) = 1 - sincos (1.5708) = 1 -2.38419e-07 + sincos (1.5708) = 1 0 tan (1.5708) = -2.28773e+07 acos (1.5708) = 0 asin (1.5708) = 1.5708 @@ -59,9 +59,9 @@ Compiled test.osl -> test.oso degrees (1.5708) = 90 radians (1.5708) = 0.0274156 cos (3.14159) = -1 - sin (3.14159) = -1.19209e-07 - sincos (3.14159) = -1.19209e-07 -1 - tan (3.14159) = 5.96046e-08 + sin (3.14159) = 0 + sincos (3.14159) = 0 -1 + tan (3.14159) = 0 acos (3.14159) = 0 asin (3.14159) = 1.5708 atan (3.14159) = 1.26262 @@ -69,18 +69,18 @@ Compiled test.osl -> test.oso degrees (3.14159) = 180 radians (3.14159) = 0.0548311 cos (-3.14159 -3.14159 -3.14159) = -1 -1 -1 - sin (-3.14159 -3.14159 -3.14159) = 1.19209e-07 1.19209e-07 1.19209e-07 - sincos (-3.14159 -3.14159 -3.14159) = 1.19209e-07 1.19209e-07 1.19209e-07 -1 -1 -1 - tan (-3.14159 -3.14159 -3.14159) = -5.96046e-08 -5.96046e-08 -5.96046e-08 + sin (-3.14159 -3.14159 -3.14159) = 0 0 0 + sincos (-3.14159 -3.14159 -3.14159) = 0 0 0 -1 -1 -1 + tan (-3.14159 -3.14159 -3.14159) = 0 0 0 acos (-3.14159 -3.14159 -3.14159) = 3.14159 3.14159 3.14159 asin (-3.14159 -3.14159 -3.14159) = -1.5708 -1.5708 -1.5708 atan (-3.14159 -3.14159 -3.14159) = -1.26262 -1.26262 -1.26262 atan2 (-3.14159 -3.14159 -3.14159, -6.28319 -6.28319 -6.28319) = -2.67794 -2.67794 -2.67794 degrees (-3.14159 -3.14159 -3.14159) = -180 -180 -180 radians (-3.14159 -3.14159 -3.14159) = -0.0548311 -0.0548311 -0.0548311 - cos (-1.5708 -1.5708 -1.5708) = -2.38419e-07 -2.38419e-07 -2.38419e-07 + cos (-1.5708 -1.5708 -1.5708) = 0 0 0 sin (-1.5708 -1.5708 -1.5708) = -1 -1 -1 - sincos (-1.5708 -1.5708 -1.5708) = -1 -1 -1 -2.38419e-07 -2.38419e-07 -2.38419e-07 + sincos (-1.5708 -1.5708 -1.5708) = -1 -1 -1 0 0 0 tan (-1.5708 -1.5708 -1.5708) = 2.28773e+07 2.28773e+07 2.28773e+07 acos (-1.5708 -1.5708 -1.5708) = 3.14159 3.14159 3.14159 asin (-1.5708 -1.5708 -1.5708) = -1.5708 -1.5708 -1.5708 @@ -118,9 +118,9 @@ Compiled test.osl -> test.oso atan2 (0.785398 0.785398 0.785398, 1.5708 1.5708 1.5708) = 0.46365 0.46365 0.46365 degrees (0.785398 0.785398 0.785398) = 45 45 45 radians (0.785398 0.785398 0.785398) = 0.0137078 0.0137078 0.0137078 - cos (1.5708 1.5708 1.5708) = -2.38419e-07 -2.38419e-07 -2.38419e-07 + cos (1.5708 1.5708 1.5708) = 0 0 0 sin (1.5708 1.5708 1.5708) = 1 1 1 - sincos (1.5708 1.5708 1.5708) = 1 1 1 -2.38419e-07 -2.38419e-07 -2.38419e-07 + sincos (1.5708 1.5708 1.5708) = 1 1 1 0 0 0 tan (1.5708 1.5708 1.5708) = -2.28773e+07 -2.28773e+07 -2.28773e+07 acos (1.5708 1.5708 1.5708) = 0 0 0 asin (1.5708 1.5708 1.5708) = 1.5708 1.5708 1.5708 @@ -129,9 +129,9 @@ Compiled test.osl -> test.oso degrees (1.5708 1.5708 1.5708) = 90 90 90 radians (1.5708 1.5708 1.5708) = 0.0274156 0.0274156 0.0274156 cos (3.14159 3.14159 3.14159) = -1 -1 -1 - sin (3.14159 3.14159 3.14159) = -1.19209e-07 -1.19209e-07 -1.19209e-07 - sincos (3.14159 3.14159 3.14159) = -1.19209e-07 -1.19209e-07 -1.19209e-07 -1 -1 -1 - tan (3.14159 3.14159 3.14159) = 5.96046e-08 5.96046e-08 5.96046e-08 + sin (3.14159 3.14159 3.14159) = 0 0 0 + sincos (3.14159 3.14159 3.14159) = 0 0 0 -1 -1 -1 + tan (3.14159 3.14159 3.14159) = 0 0 0 acos (3.14159 3.14159 3.14159) = 0 0 0 asin (3.14159 3.14159 3.14159) = 1.5708 1.5708 1.5708 atan (3.14159 3.14159 3.14159) = 1.26262 1.26262 1.26262 diff --git a/testsuite/trig/test.osl b/testsuite/trig/test.osl index 58795b2cc..9112e0bdc 100644 --- a/testsuite/trig/test.osl +++ b/testsuite/trig/test.osl @@ -6,6 +6,7 @@ #define M_PI 3.14159265358979 #endif +#include "../common/shaders/pretty.h" shader test () @@ -15,93 +16,93 @@ test () float b = 2.0*a; float s, c; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = -M_PI/2; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = -M_PI/4; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = 0; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = M_PI/4; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = M_PI/2; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = M_PI; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); } { @@ -109,93 +110,93 @@ test () vector b = 2.0*a; vector s, c; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = -M_PI/2; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = -M_PI/4; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = 0; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = M_PI/4; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = M_PI/2; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); a = M_PI; b = 2.0*a; sincos(a, s, c); - printf (" cos (%g) = %g\n", a, cos(a)); - printf (" sin (%g) = %g\n", a, sin(a)); - printf (" sincos (%g) = %g %g\n", a, s, c); - printf (" tan (%g) = %g\n", a, tan(a)); - printf (" acos (%g) = %g\n", a, acos(a)); - printf (" asin (%g) = %g\n", a, asin(a)); - printf (" atan (%g) = %g\n", a, atan(a)); - printf (" atan2 (%g, %g) = %g\n", a, b, atan2(a,b)); - printf (" degrees (%g) = %g\n", a, degrees(a)); - printf (" radians (%g) = %g\n", a, radians(a)); + printf (" cos (%g) = %g\n", pretty(a), pretty(cos(a))); + printf (" sin (%g) = %g\n", pretty(a), pretty(sin(a))); + printf (" sincos (%g) = %g %g\n", pretty(a), pretty(s), pretty(c)); + printf (" tan (%g) = %g\n", pretty(a), pretty(tan(a))); + printf (" acos (%g) = %g\n", pretty(a), pretty(acos(a))); + printf (" asin (%g) = %g\n", pretty(a), pretty(asin(a))); + printf (" atan (%g) = %g\n", pretty(a), pretty(atan(a))); + printf (" atan2 (%g, %g) = %g\n", pretty(a), pretty(b), pretty(atan2(a,b))); + printf (" degrees (%g) = %g\n", pretty(a), pretty(degrees(a))); + printf (" radians (%g) = %g\n", pretty(a), pretty(radians(a))); } } diff --git a/testsuite/vector/test.osl b/testsuite/vector/test.osl index 78c72b99a..8e5d92d8c 100644 --- a/testsuite/vector/test.osl +++ b/testsuite/vector/test.osl @@ -2,6 +2,8 @@ // SPDX-License-Identifier: BSD-3-Clause // https://github.com/AcademySoftwareFoundation/OpenShadingLanguage +#include "../common/shaders/pretty.h" + shader test (vector vparam = vector (.1, .7, .2), vector vparam2 = vector (.1), @@ -9,8 +11,8 @@ test (vector vparam = vector (.1, .7, .2), { vector X = vector (1, 0, 0); - printf (" parameter initialization test: vparam = %g\n", vparam); - printf (" parameter initialization test2: vparam2 = %g\n", vparam2); + printf (" parameter initialization test: vparam = %g\n", pretty(vparam)); + printf (" parameter initialization test2: vparam2 = %g\n", pretty(vparam2)); printf ("\n"); printf ("Test vector functions\n\n"); @@ -20,56 +22,56 @@ test (vector vparam = vector (.1, .7, .2), { float a = 0.1, b = 0.2, c = 0.5; - printf (" vector (%g) = %g\n", a, vector(a)); - printf (" vector (%g, %g, %g) = %g\n", a, b, c, vector(a,b,c)); + printf (" vector (%g) = %g\n", pretty(a), pretty(vector(a))); + printf (" vector (%g, %g, %g) = %g\n", pretty(a), pretty(b), pretty(c), pretty(vector(a,b,c))); } { vector V = vector (0, 1, 2); printf (" V = vector (%g) has components %g, %g, %g\n", - V, V[0], V[1], V[2]); + pretty(V), pretty(V[0]), pretty(V[1]), pretty(V[2])); V[1] = 8; - printf (" After V[1] = 8, V = (%g)\n", V); + printf (" After V[1] = 8, V = (%g)\n", pretty(V)); V[2] = 0.5; - printf (" After V[2] = 0.5, V = (%g)\n", V); + printf (" After V[2] = 0.5, V = (%g)\n", pretty(V)); printf (" V = vector (%g) has xyz components %g, %g, %g\n", - V, V.x, V.y, V.z); + pretty(V), pretty(V.x), pretty(V.y), pretty(V.z)); V.x = 14.5; - printf (" After V.x = 14.5, V = (%g)\n", V); + printf (" After V.x = 14.5, V = (%g)\n", pretty(V)); V.y = 15.5; - printf (" After V.y = 15.5, V = (%g)\n", V); + printf (" After V.y = 15.5, V = (%g)\n", pretty(V)); V.z = 16.5; - printf (" After V.z = 16.5, V = (%g)\n", V); + printf (" After V.z = 16.5, V = (%g)\n", pretty(V)); } { vector V = vector (0, 8, 0.5); printf (" V = %g\n", V); - printf (" dot ((%g), (%g)) = %g\n", V, V, dot(V,V)); - printf (" dot ((%g), (%g)) = %g\n", V, Y, dot(V,Y)); - printf (" cross ((%g), (%g)) = %g\n", X, Y, cross(X,Y)); - printf (" length (%g) = %g\n", Y, length(Y)); - printf (" length (%g) = %g\n", XY, length(XY)); - printf (" distance ((%g), (%g)) = %g\n", X, Y, distance(X,Y)); - printf (" distance ((%g), (%g)) = %g\n", X, XY, distance(X,XY)); + printf (" dot ((%g), (%g)) = %g\n", pretty(V), pretty(V), pretty(dot(V,V))); + printf (" dot ((%g), (%g)) = %g\n", pretty(V), pretty(Y), pretty(dot(V,Y))); + printf (" cross ((%g), (%g)) = %g\n", pretty(X), pretty(Y), pretty(cross(X,Y))); + printf (" length (%g) = %g\n", pretty(Y), pretty(length(Y))); + printf (" length (%g) = %g\n", pretty(XY), pretty(length(XY))); + printf (" distance ((%g), (%g)) = %g\n", pretty(X), pretty(Y), pretty(distance(X,Y))); + printf (" distance ((%g), (%g)) = %g\n", pretty(X), pretty(XY), pretty(distance(X,XY))); printf (" distance ((%g), (%g), (%g)) = %g\n", - X, Y, X, distance(X,Y,X)); + pretty(X), pretty(Y), pretty(X), pretty(distance(X,Y,X))); printf (" distance ((%g), (%g), (%g)) = %g\n", - X, Y, Y, distance(X,Y,Y)); + pretty(X), pretty(Y), pretty(Y), pretty(distance(X,Y,Y))); point Q = point(0.5,0.5,0); printf (" distance ((%g), (%g), (%g)) = %g\n", - X, Y, Q, distance(X,Y,Q)); + pretty(X), pretty(Y), pretty(Q), pretty(distance(X,Y,Q))); Q = point(0.5,0.5,0.5); printf (" distance ((%g), (%g), (%g)) = %g\n", - X, Y, Q, distance(X,Y,Q)); + pretty(X), pretty(Y), pretty(Q), pretty(distance(X,Y,Q))); Q = point(2,1,0); printf (" distance ((%g), (%g), (%g)) = %g\n", - X, Y, Q, distance(X,Y,Q)); - printf (" normalize (%g) = %g\n", XY, normalize(XY)); - printf (" normalize (%g) = %g\n", V, normalize(V)); - printf (" normalize (%g) = %g\n", Zero, normalize(Zero)); + pretty(X), pretty(Y), pretty(Q), pretty(distance(X,Y,Q))); + printf (" normalize (%g) = %g\n", pretty(XY), pretty(normalize(XY))); + printf (" normalize (%g) = %g\n", pretty(V), pretty(normalize(V))); + printf (" normalize (%g) = %g\n", pretty(Zero), pretty(normalize(Zero))); } printf (" rotate(%g, PI/2, (0,0,0), (0,0,1)) = %g\n", - X, rotate (X, M_PI/2, point(0,0,0), point(0,0,1))); + pretty(X), pretty(rotate (X, M_PI/2, point(0,0,0), point(0,0,1)))); }