diff --git a/.github/workflows/analysis_workflow.yml b/.github/workflows/analysis_workflow.yml index 23c115139..7a7bfbbbe 100644 --- a/.github/workflows/analysis_workflow.yml +++ b/.github/workflows/analysis_workflow.yml @@ -27,23 +27,25 @@ jobs: # --------------------------------------------------------------------------- linux_sonarcloud: - name: 'Linux CentOS 7 VFX CY2022 SonarCloud ' + name: 'Linux VFX CY2023 SonarCloud' # Don't run on OCIO forks if: github.repository == 'AcademySoftwareFoundation/OpenColorIO' - # GH-hosted VM. The build runs in CentOS 7 'container' defined below. + # GH-hosted VM. The build runs in ASWF 'container' defined below. runs-on: ubuntu-latest container: # DockerHub: https://hub.docker.com/u/aswf # Source: https://github.com/AcademySoftwareFoundation/aswf-docker - image: aswf/ci-ocio:2022 + image: aswf/ci-ocio:2023 env: CXX: g++ CC: gcc steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 50 + - name: Install sonar-scanner and build-wrapper + uses: sonarsource/sonarcloud-github-c-cpp@v2 - name: Install docs env run: share/ci/scripts/linux/yum/install_docs_env.sh - name: Install tests env @@ -79,4 +81,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: sonar-scanner -X -Dsonar.login=$SONAR_TOKEN + run: sonar-scanner diff --git a/.github/workflows/ci-macarm.yml b/.github/workflows/ci-macarm.yml index 58b42d6f2..7009fbf2d 100644 --- a/.github/workflows/ci-macarm.yml +++ b/.github/workflows/ci-macarm.yml @@ -72,11 +72,11 @@ jobs: python-version: '3.11' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install docs env run: share/ci/scripts/macos/install_docs_env.sh if: matrix.build-docs == 'ON' diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index 9ac6e7544..cd076af1a 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -388,11 +388,11 @@ jobs: python-version: '3.7' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install docs env run: share/ci/scripts/macos/install_docs_env.sh if: matrix.build-docs == 'ON' @@ -533,11 +533,11 @@ jobs: python-version: '3.7' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install docs env run: | DOXYGEN_PATH=$GITHUB_WORKSPACE/doxygen diff --git a/.github/workflows/dependencies_latest.yml b/.github/workflows/dependencies_latest.yml index d37a9882e..d95d732c8 100644 --- a/.github/workflows/dependencies_latest.yml +++ b/.github/workflows/dependencies_latest.yml @@ -189,11 +189,11 @@ jobs: use-oiio: 'OFF' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install docs env run: share/ci/scripts/macos/install_docs_env.sh if: matrix.build-docs == 'ON' @@ -294,11 +294,11 @@ jobs: use-oiio: 'OFF' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install docs env run: | DOXYGEN_PATH=$GITHUB_WORKSPACE/doxygen diff --git a/.github/workflows/platform_latest.yml b/.github/workflows/platform_latest.yml index b57398be0..5270340ec 100644 --- a/.github/workflows/platform_latest.yml +++ b/.github/workflows/platform_latest.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - build: [1, 2, 3, 4] + build: [1, 2] include: # ------------------------------------------------------------------- # GCC @@ -46,7 +46,7 @@ jobs: build-python: ON build-type: Release build-shared: ON - cxx-standard: 20 + cxx-standard: 23 cxx-compiler: g++ cc-compiler: gcc compiler-desc: GCC @@ -55,7 +55,7 @@ jobs: build-python: OFF build-type: Debug build-shared: ON - cxx-standard: 20 + cxx-standard: 23 cxx-compiler: g++ cc-compiler: gcc compiler-desc: GCC @@ -63,30 +63,32 @@ jobs: # ------------------------------------------------------------------- # Clang # ------------------------------------------------------------------- - - build: 3 - build-python: ON - build-type: Release - build-shared: ON - cxx-standard: 20 - cxx-compiler: clang++ - cc-compiler: clang - compiler-desc: Clang - enable-sanitizer: OFF - - build: 4 - build-python: OFF - build-type: Debug - build-shared: ON - cxx-standard: 20 - cxx-compiler: clang++ - cc-compiler: clang - compiler-desc: Clang - enable-sanitizer: ON + # TODO: Re-enable clang when the following issue get fixed: + # https://github.com/actions/runner-images/issues/8659 + # - build: 3 + # build-python: ON + # build-type: Release + # build-shared: ON + # cxx-standard: 23 + # cxx-compiler: clang++ + # cc-compiler: clang + # compiler-desc: Clang + # enable-sanitizer: OFF + # - build: 4 + # build-python: OFF + # build-type: Debug + # build-shared: ON + # cxx-standard: 23 + # cxx-compiler: clang++ + # cc-compiler: clang + # compiler-desc: Clang + # enable-sanitizer: ON env: CXX: ${{ matrix.cxx-compiler }} CC: ${{ matrix.cc-compiler }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install tests env run: share/ci/scripts/linux/yum/install_tests_env.sh - name: Create build directories @@ -185,23 +187,23 @@ jobs: build-python: ON build-type: Release build-shared: ON - cxx-standard: 20 + cxx-standard: 23 enable-sanitizer: OFF python-version: '3.11' - build: 2 build-python: OFF build-type: Debug build-shared: ON - cxx-standard: 20 + cxx-standard: 23 enable-sanitizer: ON python-version: '3.11' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install tests env run: share/ci/scripts/macos/install_tests_env.sh - name: Create build directories @@ -298,21 +300,21 @@ jobs: build-python: ON build-type: Release build-shared: ON - cxx-standard: 20 + cxx-standard: 23 python-version: '3.11' - build: 2 build-python: ON build-type: Debug build-shared: ON - cxx-standard: 20 + cxx-standard: 23 python-version: '3.11' steps: - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install tests env run: share/ci/scripts/windows/install_tests_env.sh shell: bash diff --git a/.github/workflows/wheel_workflow.yml b/.github/workflows/wheel_workflow.yml index 022c30496..76838cbb4 100644 --- a/.github/workflows/wheel_workflow.yml +++ b/.github/workflows/wheel_workflow.yml @@ -51,7 +51,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build SDist run: pipx run build --sdist @@ -59,8 +59,9 @@ jobs: - name: Check metadata run: pipx run twine check dist/* - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-sdist path: dist/*.tar.gz # --------------------------------------------------------------------------- @@ -82,106 +83,107 @@ jobs: # ------------------------------------------------------------------- - build: CPython 3.7 64 bits manylinux_2_28 manylinux: manylinux_2_28 - python: cp37-manylinux* + python: cp37-manylinux_x86_64 arch: x86_64 - build: CPython 3.8 64 bits manylinux_2_28 manylinux: manylinux_2_28 - python: cp38-manylinux* + python: cp38-manylinux_x86_64 arch: x86_64 - build: CPython 3.9 64 bits manylinux_2_28 manylinux: manylinux_2_28 - python: cp39-manylinux* + python: cp39-manylinux_x86_64 arch: x86_64 - build: CPython 3.10 64 bits manylinux_2_28 manylinux: manylinux_2_28 - python: cp310-manylinux* + python: cp310-manylinux_x86_64 arch: x86_64 - build: CPython 3.11 64 bits manylinux_2_28 manylinux: manylinux_2_28 - python: cp311-manylinux* + python: cp311-manylinux_x86_64 arch: x86_64 - build: CPython 3.12 64 bits manylinux_2_28 manylinux: manylinux_2_28 - python: cp312-manylinux* + python: cp312-manylinux_x86_64 arch: x86_64 # ------------------------------------------------------------------- # CPython 64 bits manylinux2014 # ------------------------------------------------------------------- - - build: CPython 3.7 64 bits manylinux2014 + - build: CPython 3.7 64 bits manylinux2014 manylinux: manylinux2014 - python: cp37-manylinux* + python: cp37-manylinux_x86_64 arch: x86_64 - - build: CPython 3.8 64 bits manylinux2014 + - build: CPython 3.8 64 bits manylinux2014 manylinux: manylinux2014 - python: cp38-manylinux* + python: cp38-manylinux_x86_64 arch: x86_64 - - build: CPython 3.9 64 bits manylinux2014 + - build: CPython 3.9 64 bits manylinux2014 manylinux: manylinux2014 - python: cp39-manylinux* + python: cp39-manylinux_x86_64 arch: x86_64 - - build: CPython 3.10 64 bits manylinux2014 + - build: CPython 3.10 64 bits manylinux2014 manylinux: manylinux2014 - python: cp310-manylinux* + python: cp310-manylinux_x86_64 arch: x86_64 - - build: CPython 3.11 64 bits manylinux2014 + - build: CPython 3.11 64 bits manylinux2014 manylinux: manylinux2014 - python: cp311-manylinux* + python: cp311-manylinux_x86_64 arch: x86_64 - - build: CPython 3.12 64 bits manylinux2014 + - build: CPython 3.12 64 bits manylinux2014 manylinux: manylinux2014 - python: cp312-manylinux* + python: cp312-manylinux_x86_64 arch: x86_64 # ------------------------------------------------------------------- # CPython ARM 64 bits manylinux2014 # ------------------------------------------------------------------- - build: CPython 3.7 ARM 64 bits manylinux2014 manylinux: manylinux2014 - python: cp37-manylinux* + python: cp37-manylinux_aarch64 arch: aarch64 - build: CPython 3.8 ARM 64 bits manylinux2014 manylinux: manylinux2014 - python: cp38-manylinux* + python: cp38-manylinux_aarch64 arch: aarch64 - build: CPython 3.9 ARM 64 bits manylinux2014 manylinux: manylinux2014 - python: cp39-manylinux* + python: cp39-manylinux_aarch64 arch: aarch64 - build: CPython 3.10 ARM 64 bits manylinux2014 manylinux: manylinux2014 - python: cp310-manylinux* + python: cp310-manylinux_aarch64 arch: aarch64 - build: CPython 3.11 ARM 64 bits manylinux2014 manylinux: manylinux2014 - python: cp311-manylinux* + python: cp311-manylinux_aarch64 arch: aarch64 - build: CPython 3.12 ARM 64 bits manylinux2014 manylinux: manylinux2014 - python: cp312-manylinux* + python: cp312-manylinux_aarch64 arch: aarch64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Install Python with: python-version: '3.8' - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 + uses: pypa/cibuildwheel@v2.16.5 env: CIBW_BUILD: ${{ matrix.python }} CIBW_ARCHS: ${{ matrix.arch }} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.manylinux }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-${{ matrix.python }}-${{ matrix.manylinux }} path: ./wheelhouse/*.whl # --------------------------------------------------------------------------- @@ -202,58 +204,59 @@ jobs: # CPython 64 bits # ------------------------------------------------------------------- - build: CPython 3.7 64 bits - python: cp37-* + python: cp37-macosx_x86_64 arch: x86_64 - build: CPython 3.8 64 bits - python: cp38-* + python: cp38-macosx_x86_64 arch: x86_64 - build: CPython 3.9 64 bits - python: cp39-* + python: cp39-macosx_x86_64 arch: x86_64 - build: CPython 3.10 64 bits - python: cp310-* + python: cp310-macosx_x86_64 arch: x86_64 - build: CPython 3.11 64 bits - python: cp311-* + python: cp311-macosx_x86_64 arch: x86_64 - build: CPython 3.12 64 bits - python: cp312-* + python: cp312-macosx_x86_64 arch: x86_64 # ------------------------------------------------------------------- # CPython ARM 64 bits # ------------------------------------------------------------------- - build: CPython 3.8 ARM 64 bits - python: cp38-* + python: cp38-macosx_arm64 arch: arm64 - build: CPython 3.9 ARM 64 bits - python: cp39-* + python: cp39-macosx_arm64 arch: arm64 - build: CPython 3.10 ARM 64 bits - python: cp310-* + python: cp310-macosx_arm64 arch: arm64 - build: CPython 3.11 ARM 64 bits - python: cp311-* + python: cp311-macosx_arm64 arch: arm64 - build: CPython 3.12 ARM 64 bits - python: cp312-* + python: cp312-macosx_arm64 arch: arm64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Install Python with: python-version: '3.8' - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 + uses: pypa/cibuildwheel@v2.16.5 env: CIBW_BUILD: ${{ matrix.python }} CIBW_ARCHS: ${{ matrix.arch }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-${{ matrix.python }} path: ./wheelhouse/*.whl # --------------------------------------------------------------------------- @@ -274,40 +277,41 @@ jobs: # CPython 64 bits # ------------------------------------------------------------------- - build: CPython 3.7 64 bits - python: cp37-* + python: cp37-win_amd64 arch: AMD64 - build: CPython 3.8 64 bits - python: cp38-* + python: cp38-win_amd64 arch: AMD64 - build: CPython 3.9 64 bits - python: cp39-* + python: cp39-win_amd64 arch: AMD64 - build: CPython 3.10 64 bits - python: cp310-* + python: cp310-win_amd64 arch: AMD64 - build: CPython 3.11 64 bits - python: cp311-* + python: cp311-win_amd64 arch: AMD64 - build: CPython 3.12 64 bits - python: cp312-* + python: cp312-win_amd64 arch: AMD64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Install Python with: python-version: '3.8' - name: Build wheels - uses: pypa/cibuildwheel@v2.16.2 + uses: pypa/cibuildwheel@v2.16.5 env: CIBW_BUILD: ${{ matrix.python }} CIBW_ARCHS: ${{ matrix.arch }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-${{ matrix.python }} path: ./wheelhouse/*.whl @@ -316,12 +320,13 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: artifact + pattern: cibw-* path: dist + merge-multiple: true - uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/share/ci/scripts/multi/install_osl.sh b/share/ci/scripts/multi/install_osl.sh index cf693eb64..75c57b520 100755 --- a/share/ci/scripts/multi/install_osl.sh +++ b/share/ci/scripts/multi/install_osl.sh @@ -20,8 +20,6 @@ fi mkdir build cd build -# FIXME: Revert OSL_BUILD_TESTS to OFF when OSL 1.12 is released -# CMake configure fails when tests are off, only fixed in 1.12 dev branch if [[ $OSTYPE == 'darwin'* ]]; then cmake -DCMAKE_BUILD_TYPE=Release \ @@ -29,7 +27,7 @@ if [[ $OSTYPE == 'darwin'* ]]; then -DCMAKE_CXX_STANDARD=14 \ -DCMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang \ -DCMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ \ - -DOSL_BUILD_TESTS=ON \ + -DOSL_BUILD_TESTS=OFF \ -DVERBOSE=ON \ -DSTOP_ON_WARNING=OFF \ -DBoost_NO_BOOST_CMAKE=ON \ @@ -39,17 +37,26 @@ else # not macOS cmake -DCMAKE_BUILD_TYPE=Release \ ${INSTALL_TARGET:+"-DCMAKE_INSTALL_PREFIX="${INSTALL_TARGET}""} \ -DCMAKE_CXX_STANDARD=14 \ - -DOSL_BUILD_TESTS=ON \ + -DOSL_BUILD_TESTS=OFF \ -DVERBOSE=ON \ -DSTOP_ON_WARNING=OFF \ -DBoost_NO_BOOST_CMAKE=ON \ ../. fi +# OSL 1.13+ yield a permission error on mac OS. +# "file cannot create directory: /usr/local/cmake. Maybe need administrative privileges." +if [[ $OSTYPE == 'darwin'* ]]; then +sudo cmake --build . \ + --target install \ + --config Release \ + --parallel 2 +else # not macOS cmake --build . \ --target install \ --config Release \ --parallel 2 +fi cd ../.. rm -rf OpenShadingLanguage diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 2625242cf..9b0631922 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -179,8 +179,7 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS) # pybind11 2.9 fixes issues with MS Visual Studio 2022 (Debug). ocio_handle_dependency( pybind11 REQUIRED ALLOW_INSTALL MIN_VERSION 2.9.2 - RECOMMENDED_VERSION 2.9.2 - RECOMMENDED_VERSION_REASON "Pybind 2.10.0+ does not work with Python 2.7 anymore") + RECOMMENDED_VERSION 2.11.1) endif() endif() diff --git a/src/bindings/python/PyPackedImageDesc.cpp b/src/bindings/python/PyPackedImageDesc.cpp index a66a2a017..0b3e6a4e2 100644 --- a/src/bindings/python/PyPackedImageDesc.cpp +++ b/src/bindings/python/PyPackedImageDesc.cpp @@ -15,10 +15,7 @@ void bindPyPackedImageDesc(py::module & m) .def(py::init([](py::buffer & data, long width, long height, long numChannels) { PyPackedImageDesc * p = new PyPackedImageDesc(); - - py::gil_scoped_release release; p->m_data[0] = data; - py::gil_scoped_acquire acquire; py::buffer_info info = p->m_data[0].request(); checkBufferType(info, py::dtype("float32")); @@ -39,10 +36,7 @@ void bindPyPackedImageDesc(py::module & m) ptrdiff_t yStrideBytes) { PyPackedImageDesc * p = new PyPackedImageDesc(); - - py::gil_scoped_release release; p->m_data[0] = data; - py::gil_scoped_acquire acquire; py::buffer_info info = p->m_data[0].request(); checkBufferType(info, bitDepth); @@ -65,10 +59,7 @@ void bindPyPackedImageDesc(py::module & m) ChannelOrdering chanOrder) { PyPackedImageDesc * p = new PyPackedImageDesc(); - - py::gil_scoped_release release; p->m_data[0] = data; - py::gil_scoped_acquire acquire; py::buffer_info info = p->m_data[0].request(); checkBufferType(info, py::dtype("float32")); @@ -89,10 +80,7 @@ void bindPyPackedImageDesc(py::module & m) ptrdiff_t yStrideBytes) { PyPackedImageDesc * p = new PyPackedImageDesc(); - - py::gil_scoped_release release; p->m_data[0] = data; - py::gil_scoped_acquire acquire; py::buffer_info info = p->m_data[0].request(); checkBufferType(info, bitDepth); diff --git a/tests/osl/UnitTestOSL.cpp b/tests/osl/UnitTestOSL.cpp index e2dda7bc1..7f09055ed 100644 --- a/tests/osl/UnitTestOSL.cpp +++ b/tests/osl/UnitTestOSL.cpp @@ -26,7 +26,11 @@ struct MyUserData } // Make a retrieve-by-name function. +#if OSL_LIBRARY_VERSION_CODE >= 11300 + bool retrieve(OSL::ustringhash name, OSL::TypeDesc type, void * val, bool /*derivatives*/) +#else bool retrieve(OSL::ustring name, OSL::TypeDesc type, void * val, bool /*derivatives*/) +#endif { static const OSL::ustring ucolor_rgb("inColor.rgb"); if (name == ucolor_rgb && type == OIIO::TypeColor) @@ -61,9 +65,15 @@ struct MyUserData class MyRendererServices final : public OSL::RendererServices { public: +#if OSL_LIBRARY_VERSION_CODE >= 11300 + virtual bool get_userdata(bool derivatives, OSL::ustringhash name, + OSL::TypeDesc type, OSL::ShaderGlobals * sg, + void * val) +#else virtual bool get_userdata(bool derivatives, OSL::ustring name, OSL::TypeDesc type, OSL::ShaderGlobals * sg, void * val) +#endif { // In this case, our implementation of get_userdata just requests // it from the MyUserData, which we have arranged is pointed to @@ -137,6 +147,21 @@ void ExecuteOSLShader(const std::string & shaderName, OSL::TypeDesc(OSL::TypeDesc::STRING, output_names.size()), output_names.data()); +#if OSL_LIBRARY_VERSION_CODE >= 11300 + // Use the new symlocs API to say where to place outputs + OSL::SymLocationDesc outputRGB("outColor.rgb", OSL::TypePoint, false, + OSL::SymArena::Outputs, + 0 /* output arena offset of "out" */, + sizeof(OSL::Vec3) /* point to point stride */); + shadsys->add_symlocs(mygroup.get(), outputRGB); + + OSL::SymLocationDesc outputA("outColor.a", OSL::TypeFloat, false, + OSL::SymArena::Outputs, + sizeof(OSL::Vec3) /* output arena offset of "out" */, + sizeof(float) /* point to point stride */); + shadsys->add_symlocs(mygroup.get(), outputA); +#endif + // Now we want to create a context in which we can execute the shader. // We need one context per thread. OSL::PerThreadInfo * perthread = shadsys->create_thread_info(); @@ -146,6 +171,7 @@ void ExecuteOSLShader(const std::string & shaderName, // so we force that to happen now. shadsys->optimize_group(mygroup.get(), ctx); +#if OSL_LIBRARY_VERSION_CODE < 11300 // Get a ShaderSymbol* handle to the final output we care about. This // will greatly speed up retrieving the value later, rather than by // looking it up by name on every shade. @@ -156,6 +182,7 @@ void ExecuteOSLShader(const std::string & shaderName, const OSL::ShaderSymbol * outsymA = shadsys->find_symbol(*mygroup.get(), OSL::ustring("layer1"), OSL::ustring("outColor.a")); OSL_ASSERT(outsymA); +#endif for (size_t idx = 0; idx < inValues.size(); ++idx) { @@ -165,8 +192,14 @@ void ExecuteOSLShader(const std::string & shaderName, MyUserData userdata(inValues[idx]); shaderglobals.renderstate = &userdata; + Vec4 rgbaOut { 0.0, 0.0, 0.0 }; + // Run the shader (will automagically optimize and JIT the first time it executes). +#if OSL_LIBRARY_VERSION_CODE >= 11300 + if (!shadsys->execute(*ctx, *mygroup.get(), 0, 0, shaderglobals, nullptr, &rgbaOut)) +#else if (!shadsys->execute(*ctx, *mygroup.get(), shaderglobals)) +#endif { std::string errormessage; @@ -182,15 +215,21 @@ void ExecuteOSLShader(const std::string & shaderName, throw std::runtime_error(errormessage); } +#if OSL_LIBRARY_VERSION_CODE < 11300 const OSL::Vec3 outRGB = *(OSL::Vec3 *)shadsys->symbol_address(*ctx, outsymRGB); const float outA = *(float *)shadsys->symbol_address(*ctx, outsymA); + rgbaOut[0] = outRGB[0]; + rgbaOut[1] = outRGB[1]; + rgbaOut[2] = outRGB[2]; + rgbaOut[3] = outA; +#endif // Check the result. - if ( ComputeDiff(outValues[idx][0], outRGB[0], relativeComparison, minValue, threshold) - || ComputeDiff(outValues[idx][1], outRGB[1], relativeComparison, minValue, threshold) - || ComputeDiff(outValues[idx][2], outRGB[2], relativeComparison, minValue, threshold) - || ComputeDiff(outValues[idx][3], outA, relativeComparison, minValue, threshold)) + if ( ComputeDiff(outValues[idx][0], rgbaOut[0], relativeComparison, minValue, threshold) + || ComputeDiff(outValues[idx][1], rgbaOut[1], relativeComparison, minValue, threshold) + || ComputeDiff(outValues[idx][2], rgbaOut[2], relativeComparison, minValue, threshold) + || ComputeDiff(outValues[idx][3], rgbaOut[3], relativeComparison, minValue, threshold)) { std::stringstream str; str << "Values from [" @@ -200,7 +239,7 @@ void ExecuteOSLShader(const std::string & shaderName, << outValues[idx][0] << ", " << outValues[idx][1] << ", " << outValues[idx][2] << ", " << outValues[idx][3] << "], but OSL computed values are [" - << outRGB[0] << ", " << outRGB[1] << ", " << outRGB[2] << ", " << outA << "]."; + << rgbaOut[0] << ", " << rgbaOut[1] << ", " << rgbaOut[2] << ", " << rgbaOut[3] << "]."; throw std::runtime_error(str.str()); }