diff --git a/.github/workflows/docker_linuxes.yml b/.github/workflows/docker_linuxes.yml index 1fe51e40..afe834d1 100644 --- a/.github/workflows/docker_linuxes.yml +++ b/.github/workflows/docker_linuxes.yml @@ -84,6 +84,18 @@ jobs: - name: Run ctlrender within the Docker image run: docker run ctl:latest sh -c "ctlrender -ctl /usr/src/aces-dev/transforms/ctl/utilities/ACESutil.Unity.ctl /usr/src/aces-dev/images/ACES/SonyF35.StillLife.exr /tmp/testout.exr" + ubuntu-22-04-LTO: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build --no-cache --rm -f ./docker/Dockerfile_ubuntu_22.04_LTO -t ctl:latest . + + - name: Run unit tests (ctest) within the Docker image + run: docker run ctl:latest sh -c "cd ./build && ctest" + ubuntu-23-10: runs-on: ubuntu-latest diff --git a/.github/workflows/mac_debug.yml b/.github/workflows/mac_debug.yml index 76deafba..4bb40530 100644 --- a/.github/workflows/mac_debug.yml +++ b/.github/workflows/mac_debug.yml @@ -22,11 +22,11 @@ jobs: steps: - - name: uninstall openexr - run: brew uninstall --ignore-dependencies openexr + # - name: uninstall openexr + # run: brew uninstall --ignore-dependencies openexr - - name: uninstall imath - run: brew uninstall --ignore-dependencies imath + # - name: uninstall imath + # run: brew uninstall --ignore-dependencies imath - name: install dependencies - openexr v2.5 run: | @@ -38,7 +38,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -65,7 +65,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -77,7 +77,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -96,11 +96,11 @@ jobs: steps: - - name: uninstall openexr - run: brew uninstall --ignore-dependencies openexr + # - name: uninstall openexr + # run: brew uninstall --ignore-dependencies openexr - - name: uninstall imath - run: brew uninstall --ignore-dependencies imath + # - name: uninstall imath + # run: brew uninstall --ignore-dependencies imath - name: install dependencies - openexr v2.5 run: | @@ -112,7 +112,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -145,7 +145,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -157,7 +157,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 diff --git a/.github/workflows/mac_release.yml b/.github/workflows/mac_release.yml index 865db163..8f5f7454 100644 --- a/.github/workflows/mac_release.yml +++ b/.github/workflows/mac_release.yml @@ -48,11 +48,11 @@ jobs: steps: - - name: uninstall openexr - run: brew uninstall --ignore-dependencies openexr + # - name: uninstall openexr + # run: brew uninstall --ignore-dependencies openexr - - name: uninstall imath - run: brew uninstall --ignore-dependencies imath + # - name: uninstall imath + # run: brew uninstall --ignore-dependencies imath - name: install dependencies - openexr v2.5 run: | @@ -64,7 +64,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -91,7 +91,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -103,7 +103,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -130,7 +130,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=OFF .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -142,7 +142,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=OFF .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -169,7 +169,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=ON .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -181,7 +181,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=ON .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -232,11 +232,11 @@ jobs: steps: - - name: uninstall openexr - run: brew uninstall --ignore-dependencies openexr + # - name: uninstall openexr + # run: brew uninstall --ignore-dependencies openexr - - name: uninstall imath - run: brew uninstall --ignore-dependencies imath + # - name: uninstall imath + # run: brew uninstall --ignore-dependencies imath - name: install dependencies - openexr v2.5 run: | @@ -248,7 +248,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -281,7 +281,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -293,7 +293,7 @@ jobs: cd build && cmake .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -326,7 +326,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=OFF .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -338,7 +338,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=OFF .. && make && - make install + sudo make install - uses: actions/checkout@v3 @@ -371,7 +371,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=ON .. && make && - make install + sudo make install - name: install dependencies - openexr v3.1 run: | @@ -383,7 +383,7 @@ jobs: cd build && cmake -DBUILD_SHARED_LIBS=ON .. && make && - make install + sudo make install - uses: actions/checkout@v3 diff --git a/.github/workflows/ubuntu_debug.yml b/.github/workflows/ubuntu_debug.yml index f769d006..e705b9f0 100644 --- a/.github/workflows/ubuntu_debug.yml +++ b/.github/workflows/ubuntu_debug.yml @@ -170,6 +170,8 @@ jobs: runs-on: ubuntu-latest steps: + - name: run apt-get update + run: sudo apt-get -y update - name: install test tool - valgrind run: sudo apt-get -y install valgrind @@ -237,7 +239,9 @@ jobs: runs-on: ubuntu-latest steps: - + - name: run apt-get update + run: sudo apt-get -y update + - name: install test tool - valgrind run: sudo apt-get -y install valgrind diff --git a/.github/workflows/ubuntu_release.yml b/.github/workflows/ubuntu_release.yml index 99b24c52..db05da58 100644 --- a/.github/workflows/ubuntu_release.yml +++ b/.github/workflows/ubuntu_release.yml @@ -256,6 +256,8 @@ jobs: runs-on: ubuntu-latest steps: + - name: run apt-get update + run: sudo apt-get -y update - name: install test tool - valgrind run: sudo apt-get -y install valgrind @@ -306,7 +308,9 @@ jobs: runs-on: ubuntu-latest steps: - + - name: run apt-get update + run: sudo apt-get -y update + - name: install test tool - valgrind run: sudo apt-get -y install valgrind diff --git a/.github/workflows/windows_vcpkg_release.yml b/.github/workflows/windows_vcpkg_release.yml index 1231023c..c10c6d42 100644 --- a/.github/workflows/windows_vcpkg_release.yml +++ b/.github/workflows/windows_vcpkg_release.yml @@ -52,43 +52,6 @@ jobs: run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} working-directory: ${{github.workspace}} - test: - # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. - # You can convert this to a matrix build if you need cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: windows-latest - - steps: - - - name: install dependencies - imath - run: vcpkg install imath:x64-windows - - - name: install dependencies - openexr - run: vcpkg install openexr:x64-windows - - - name: install dependencies - tiff - run: vcpkg install tiff:x64-windows - - - name: check vcpkg install status - run: vcpkg list - - - uses: actions/checkout@v3 - - - name: Configure CMake - # # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" - - - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Install - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}} - working-directory: ${{github.workspace}} - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} - + # - name: Test + # working-directory: ${{github.workspace}}/build + # run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}} diff --git a/Dockerfile b/Dockerfile index bc01d26b..bd9f720b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,7 @@ RUN apt-get -y install libtiff-dev WORKDIR /usr/src/CTL COPY . . WORKDIR /usr/src/CTL/build +RUN rm -R * || true RUN cmake .. RUN make RUN make install diff --git a/Dockerfile_openexr3 b/Dockerfile_openexr3 index 2fd496ac..73b9df7d 100644 --- a/Dockerfile_openexr3 +++ b/Dockerfile_openexr3 @@ -47,6 +47,7 @@ RUN apt-get -y install libtiff-dev WORKDIR /usr/src/CTL COPY . . WORKDIR /usr/src/CTL/build +RUN rm -R * || true RUN cmake .. RUN make RUN make install diff --git a/ctlrender/tiff_file.cc b/ctlrender/tiff_file.cc index 49418564..506b0871 100644 --- a/ctlrender/tiff_file.cc +++ b/ctlrender/tiff_file.cc @@ -486,7 +486,7 @@ void tiff_read_failsafe(TIFF *t, float scale, ctl::dpx::fb *pixels) { pixels->init(w, h, 4); temp_buffer=(uint8_t *)alloca(w*h*4); - TIFFReadRGBAImage(t, w, h, (uint32 *)temp_buffer, 0); + TIFFReadRGBAImage(t, w, h, (uint32_t *)temp_buffer, 0); for(i=0; i (%s) function", module); + snprintf( message_text, 512, "CTL file must contain either a main or (%s) function", module); THROW(Iex::ArgExc, message_text); } diff --git a/docker/Dockerfile_ubuntu_22.04_LTO b/docker/Dockerfile_ubuntu_22.04_LTO new file mode 100644 index 00000000..9272d984 --- /dev/null +++ b/docker/Dockerfile_ubuntu_22.04_LTO @@ -0,0 +1,27 @@ +FROM ubuntu:22.04 + +RUN apt-get update + +# disable interactive install +ENV DEBIAN_FRONTEND noninteractive + +# install developement tools +RUN apt-get -y install cmake +RUN apt-get -y install g++ + +# install CTL dependencies +RUN apt-get -y install libopenexr-dev +RUN apt-get -y install libtiff-dev + +# build CTL +WORKDIR /usr/src/CTL +COPY . . +WORKDIR /usr/src/CTL/build +RUN rm -R * || true +RUN cmake .. -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_VERBOSE_MAKEFILE=on -DCMAKE_CXX_FLAGS="-Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" +RUN make +RUN make install + +# finalize docker environment +WORKDIR /usr/src/CTL + diff --git a/lib/IlmCtl/CtlType.cpp b/lib/IlmCtl/CtlType.cpp index 3a66557d..ff8d37f1 100644 --- a/lib/IlmCtl/CtlType.cpp +++ b/lib/IlmCtl/CtlType.cpp @@ -204,7 +204,12 @@ VoidType::VoidType (): DataType () bool VoidType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -282,7 +287,12 @@ BoolType::BoolType () : DataType () bool BoolType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -463,7 +473,12 @@ IntType::IntType () : DataType () bool IntType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -678,7 +693,12 @@ UIntType::UIntType () : DataType () bool UIntType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -892,7 +912,12 @@ HalfType::HalfType (): DataType () bool HalfType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -1076,7 +1101,12 @@ FloatType::FloatType (): DataType () bool FloatType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } @@ -1261,7 +1291,12 @@ StringType::StringType (): DataType () bool StringType::isSameTypeAs (const TypePtr &t) const { - return t && typeid (*this) == typeid (*t); + auto& t1 = *this; + const type_info& ti1 = typeid(t1); + auto& t2 = *t; + const type_info& ti2 = typeid(t2); + return t && ti1 == ti2; + //return t && typeid (*this) == typeid (*t); } diff --git a/lib/IlmCtlSimd/CtlSimdInterpreter.cpp b/lib/IlmCtlSimd/CtlSimdInterpreter.cpp index cdcf6a84..43a02dac 100644 --- a/lib/IlmCtlSimd/CtlSimdInterpreter.cpp +++ b/lib/IlmCtlSimd/CtlSimdInterpreter.cpp @@ -86,7 +86,7 @@ SimdInterpreter::SimdInterpreter(): Interpreter(), _data (new Data) { - _data->maxInstCount = 10000000; + _data->maxInstCount = 100000000; _data->abortCount = 0; // diff --git a/lib/IlmCtlSimd/CtlSimdXContext.cpp b/lib/IlmCtlSimd/CtlSimdXContext.cpp index 6797cc9a..1b9fa181 100644 --- a/lib/IlmCtlSimd/CtlSimdXContext.cpp +++ b/lib/IlmCtlSimd/CtlSimdXContext.cpp @@ -240,7 +240,11 @@ SimdXContext::countInstruction () if ((++_instCount & 0x01fff) == 0) { if (_maxInstCount && _instCount > _maxInstCount) - throw Ctl::MaxInstExc ("Maximum CTL instruction count exceeded."); + THROW(Ctl::MaxInstExc, "\nException Ctl::MaxInstExc thrown\n" << + "Maximum CTL instruction count _maxInstCount=" << _maxInstCount << + " exceeded, _instCount=" << _instCount << "\n" << + "Try increasing SimdInterpreter::Data->maxInstCount\n"); +// throw Ctl::MaxInstExc ("Maximum CTL instruction count exceeded."); if (_abortCount != _interpreter.abortCount()) throw Ctl::AbortExc ("CTL program aborted."); diff --git a/lib/IlmCtlSimd/halfExpLog.h b/lib/IlmCtlSimd/halfExpLog.h index 09dcfa2c..827ead9c 100644 --- a/lib/IlmCtlSimd/halfExpLog.h +++ b/lib/IlmCtlSimd/halfExpLog.h @@ -3,6 +3,7 @@ // Do not edit. // +#include extern const unsigned int log10Table[]; extern const unsigned int logTable[]; @@ -12,14 +13,22 @@ extern const unsigned short expTable[]; inline float log10_h (half x) { - return *(float *)(&log10Table[x.bits()]); + int i = log10Table[x.bits()]; + float f; + memcpy(&f, &i, sizeof(i)); + return f; + //return *(float *)(&log10Table[x.bits()]); } inline float log_h (half x) { - return *(float *)(&logTable[x.bits()]); + int i = logTable[x.bits()]; + float f; + memcpy(&f, &i, sizeof(i)); + return f; + //return *(float *)(&logTable[x.bits()]); } diff --git a/lib/IlmImfCtl/CMakeLists.txt b/lib/IlmImfCtl/CMakeLists.txt index 80f7a1a0..5f75bb19 100644 --- a/lib/IlmImfCtl/CMakeLists.txt +++ b/lib/IlmImfCtl/CMakeLists.txt @@ -35,6 +35,12 @@ target_link_libraries (IlmImfCtl $<$:IlmBase::Iex> ) +set_target_properties(IlmImfCtl + PROPERTIES + VERSION ${CTL_VERSION} + SOVERSION ${CTL_VERSION} +) + install(FILES ImfCtlApplyTransforms.h DESTINATION diff --git a/lib/dpx/CMakeLists.txt b/lib/dpx/CMakeLists.txt index 1c0b85e2..e9aa5bb5 100644 --- a/lib/dpx/CMakeLists.txt +++ b/lib/dpx/CMakeLists.txt @@ -33,4 +33,10 @@ target_link_libraries(ctldpx # $<$:IlmBase::Half> # $<$:IlmBase::IlmThread> # $<$:IlmBase::Iex> -# ) \ No newline at end of file +# ) + +set_target_properties(ctldpx + PROPERTIES + VERSION ${CTL_VERSION} + SOVERSION ${CTL_VERSION} +) diff --git a/lib/dpx/dpx.cc b/lib/dpx/dpx.cc index 67cbc430..bcf557ea 100644 --- a/lib/dpx/dpx.cc +++ b/lib/dpx/dpx.cc @@ -387,10 +387,11 @@ void dpx::write(std::ostream *os) cpu_is_little_endian=TRUE; } - _need_byteswap=FALSE; - if(cpu_is_little_endian!=little_endian) { - _need_byteswap=TRUE; - } + //_need_byteswap=FALSE; + //if(cpu_is_little_endian!=little_endian) { + // _need_byteswap=TRUE; + //} + _need_byteswap=TRUE; // struct tm source_creation_time_tm; // time_t source_creation_time_time; diff --git a/lib/dpx/dpx_raw.cc b/lib/dpx/dpx_raw.cc index 4f55a61a..353e674e 100644 --- a/lib/dpx/dpx_raw.cc +++ b/lib/dpx/dpx_raw.cc @@ -206,7 +206,10 @@ bool dpx::isnull(uint8_t v) { } bool dpx::isnull(float32_t v) { - return *((uint32_t *)&v)==(uint32_t)-1; + uint32_t u; + memcpy(&u, &v, sizeof(v)); + return (u == (uint32_t)-1) ? true : false; + //return *((uint32_t *)&v)==(uint32_t)-1; } } diff --git a/lib/dpx/dpx_rw.cc b/lib/dpx/dpx_rw.cc index 2c197806..7d9e9b5a 100644 --- a/lib/dpx/dpx_rw.cc +++ b/lib/dpx/dpx_rw.cc @@ -261,7 +261,8 @@ void rwinfo::write_init(std::ostream *o, dpx *h) { if(h->current_compliance!=h->compliance) { // XXX changed validation level... This will probably end in tears... } - if(h->current_endian_mode!=h->current_endian_mode) { + //if(h->current_endian_mode!=h->current_endian_mode) { + if(h->current_endian_mode!=h->endian_mode) { // XXX byteswap changed. this will probably end in tears... } } diff --git a/resources/test/ctl/throw_maxInstCount_exception.ctl b/resources/test/ctl/throw_maxInstCount_exception.ctl new file mode 100644 index 00000000..ca05a4fe --- /dev/null +++ b/resources/test/ctl/throw_maxInstCount_exception.ctl @@ -0,0 +1,21 @@ +const unsigned int loop_limit = UINT_MAX; + +void main + (input varying float rIn, + input varying float gIn, + input varying float bIn, + output varying float rOut, + output varying float gOut, + output varying float bOut + ) +{ + unsigned int x = 0; + for( unsigned int i = 0; i < loop_limit; i = i + 1) + { + x = i; + } + + rOut = x; + gOut = x; + bOut = x; +} diff --git a/resources/test/exr/colorbars_nuke_rgb_exr16.exr b/resources/test/exr/colorbars_nuke_rgb_exr16.exr new file mode 100644 index 00000000..b83b99f5 Binary files /dev/null and b/resources/test/exr/colorbars_nuke_rgb_exr16.exr differ diff --git a/unittest/ctlrender/CMakeLists.txt b/unittest/ctlrender/CMakeLists.txt index 1c05f708..67f24b25 100644 --- a/unittest/ctlrender/CMakeLists.txt +++ b/unittest/ctlrender/CMakeLists.txt @@ -126,3 +126,8 @@ if(OpenEXR_FOUND) add_test(NAME "ctlrender-invalid-output-filename-exr" COMMAND ctlrender -force -format exr -ctl "${TEST_FILES}/unity.ctl" "${TEST_FILES}/colorbars_nuke_rgb_exr16.exr" "${CTLRENDER_OUTPUT_FOLDER}/missing_folder/invalid_filename_out.exr") set_tests_properties("ctlrender-invalid-output-filename-exr" PROPERTIES WILL_FAIL TRUE) endif() + +# test for maxInstCount exception +add_test(NAME "ctlrender-maxInstCount-exception" COMMAND ctlrender -force -ctl "${PROJECT_SOURCE_DIR}/resources/test/ctl/throw_maxInstCount_exception.ctl" "${PROJECT_SOURCE_DIR}/resources/test/exr/colorbars_nuke_rgb_exr16.exr" "${CTLRENDER_OUTPUT_FOLDER}/maxInstCount_exception.exr") +set_tests_properties("ctlrender-maxInstCount-exception" PROPERTIES WILL_FAIL TRUE) +