Compare commits

..
607 Commits
Author SHA1 Message Date
Clifford Yapp f63a460949 Pick up additional release changes 2024-10-11 22:13:24 -04:00
Clifford Yapp 4daf4d3717 Merge tag 'v1.13.11.0' into RELEASE 2024-10-11 22:11:26 -04:00
Larry Gritz 9ed80c18fc Stage v1.13.11.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-09-02 22:17:19 -07:00
Larry Gritz 88276b569f Adjust to OIIO change to IC/TS API (#1850)
Didn't catch them all in #1848 -- missed the BatchedRendererServices side.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-08-18 21:33:24 -07:00
Larry Gritz 2aca8a1a70 build(deps): Adjust to OIIO change to IC/TS API (#1848)
On the OIIO side, there's a PR in review that changes the ImageCache
and TextureSystem APIs to return shared_ptr instead of raw.
(https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4377)
This is destined for the upcoming OIIO 3.0 release.

This patch on the OSL side ensures that we build cleanly against both
OIIO 2.x and 3.0.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-08-18 21:33:24 -07:00
Larry Gritz ab43e6aee6 ci: unbreak CI for OIIO auto-build of OCIO for icx case (#1849)
Some explanation is needed:

OIIO master recently added the ability to auto-build OCIO when a new
enough one is not found at its build time, and bumped the minimum OCIO
to 2.2.

Sometimes this is triggered by OSL's CI, when OCIO < 2.2, so building
OIIO also triggers building of OCIO.

All fine, except for the case when we are testing Intel's icx
compiler, which OCIO's build system does not recognize and fails to
build. So we make a little modification here that lets us, just for
that case, ensure that OCIO is pre-built with gcc even though we're
building OIIO and OSL with icx.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-08-18 21:33:23 -07:00
Larry Gritz 80755a0ad9 build: change deprecated OIIO_CONSTEXPR14 to constexpr
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-08-18 21:33:23 -07:00
sfriedmapixar e01696b79b fix(batched): Assume BatchedRendererServices texture derivatives are in st space. (#1828)
The convention in the single-point RendererServices is that the texture call returns
derivatives in st space, and they are transformed to xy space before returning
from the wrapper to RenderServices.  This change makes BatchedRendererServices
follow the same convention.

---------

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2024-08-18 18:05:25 -07:00
Larry Gritz f27825ac6f Deal with OIIO deprecations (1844)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 22:17:28 -04:00
Larry Gritz f19fc760fa fix: Handle OIIO deprecations (1844)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 22:17:14 -04:00
Larry Gritz 67d820d25a build: Make finding bison work better on Apple Silicon Macs + homebrew (#1822)
Homebrew changes location by default on the new ARM-based Macs.
Check the new paths, too.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 22:15:24 -04:00
Larry Gritz ec83eeff0b build: llvm 18 compat issue - include libclangAPINotes (#1812)
Fixes #1809

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 22:15:14 -04:00
Larry Gritz 1b3aa7abe3 cleanup: Switch away from a long-deprecated OIIO method (#1842)
cleanup: Switch away from some long-deprecated OIIO functions

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 22:14:43 -04:00
Larry Gritz cc8f0d03e1 ci: deal with CentOS 7 EOL and disappearance of yum mirrors (#1839)
This was breaking CI for us. Hard break for icc/icx tests, since those
REQUIRED a yum install of the intel compilers. Softer undetected break
for all the ASWF <= 2022 containers based on CentOS 7, which were not
failing outright but were failing to install certain optional
packages.

The solution (for now) is to configure yum to exclude the missing repo.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 19:14:21 -04:00
Larry Gritz 73fc3ba685 cleanup: Switch away from deprecated OIIO function names (#1838)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 19:14:10 -04:00
Larry Gritz 07b81ef7ac Fix GHA CI after they upgraded nodejs (#1837)
They upgraded to a version that requires a glibc newer than is in
the pre-2023 ASWF containers.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-07-22 19:13:55 -04:00
John Mertic 23e684f3c7 admin: Change release notice icon to use the icon vs the normal logo so it shows up better (#1777)
Signed-off-by: John Mertic <jmertic@linuxfoundation.org>
2024-07-22 19:13:30 -04:00
Clifford Yapp 1cb17d3092 Update OSL to v1.13.10.0 2024-06-26 10:52:24 -04:00
Larry Gritz 90477c990d cleanup: Switch some deprecated TypeDesc names to modern ones (#1806)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-24 09:07:15 -07:00
Larry Gritz 10ec529e22 ci: Mods to CI to deal with OIIO master raising dependency mins (#1833)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-24 06:42:12 -07:00
Larry Gritz 853f87b9fe cleanup: OIIO deprecations (#1834)
Various minor changes to eliminate reference to some long-ago
deprecated OIIO items (mostly which simply alias to std versions)
before then disappear for real.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-23 21:07:08 -07:00
sfriedmapixar 53578ae635 fix: make backfacing shadeop indicate backfacing shader-global is needed (#1827)
The backfacing shadeop now directly accesses the backfacing field
on the shader globals rather than calculating it from N and I.
This updates the shader-globals-needed query to reflect that
change.

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2024-06-23 21:06:25 -07:00
Larry Gritz e28c970266 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-02 10:16:10 -07:00
Larry Gritz f265b4f7c0 Stage v1.13.10.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-02 09:25:17 -07:00
Larry Gritz e81beb12d0 docs: Fixes to documentation of new oren_nayar_diffuse_bsdf parameters (#1820)
Fixes to documentation of new oren_nayar_diffuse_bsdf parameters

* The new parameter was explained, but not added to the function
  prototype in the docs.
* The semi-deprecated languagespec.tex was fixed, but it slipped our minds
  that we've shifted the docs to markdown for ReadTheDocs (the real place
  we should have changed was stdlib.md).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-02 09:25:17 -07:00
Christopher Kulla b0e2a455b3 Implement new Oren-Nayar model from OpenPBR (#1817)
* Implement new EON mode for Oren-Nayar closures (via an opt-in keyword arg for backwards compatibility)
* Add test for energy conserving Oren-Nayar (on half the sphere so we keep checking the old mode as well)

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2024-06-01 13:07:32 -07:00
Larry Gritz ab48d84e21 docs: fix outdated or wrong repo URLs (#1811)
* Fix references to old OIIO home
* Fix embarrassing release notes generating script botch that
  accidentally used OpenImageIO URLs where OSL URLs were needed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-01 13:05:16 -07:00
Larry Gritz fabb9d2231 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-06-01 13:01:30 -07:00
Larry Gritz 8b88ad8873 Stage for v1.13.9.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-05-01 11:49:01 -07:00
Larry Gritz 37af00a3da cleanup: change OSL_CONSTEXPR14 to constexpr (#1805)
We've been C++14 minimum for a long time now, we can just say constexpr.

Change a couple of stray OIIO_CONSTEXPR14 occurrences as well.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-29 15:46:48 -07:00
Larry Gritz 910a967655 Suppress leak sanitizer warnings about internals of robin_hash (#1807)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-29 12:45:19 -07:00
Larry Gritz 25c7d4d8bf fix: Fix ifdef typo (#1804)
fix: Fix typo

This is the only way that makes any sense -- define OIIO_HIDE_FORMAT
if it ISN'T already defined.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-29 12:43:35 -07:00
Larry Gritz b87cceb29c Add full LLVM 18 support (#1803)
Some methods and enums got renamed from LLVM 17 -> 18, etc.

Also some adjustment to warning messages about version mixing
between clang and llvm.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-28 21:24:02 -07:00
مهدي شينون (Mehdi Chinoune) 9b3ed783ac build(deps): Initial support for LLVM-18 (#1773)
Signed-off-by: مهدي شينون (Mehdi Chinoune) <mehdi.chinoune@hotmail.com>
2024-04-28 21:24:02 -07:00
Larry Gritz a49f8e03d4 build: print commit hash of locally built dependencies (#1798)
Especially for our "bleeding edge" test that builds from the current
master of several dependencies, sometimes our tests fail not because
of anything we've done, but because of a change in one of the
dependencies.  To help track down exactly which change broke the
dependency, make sure our CI build logs print the specific commit hash
of those packages that we built.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-28 19:28:46 -07:00
Larry Gritz 3b45595c54 ci: Lock down to OIIO 2.5 for icc tests (#1799)
Background: Intel's icc is essentially discontinued and we think all
the renderers using OSL have moved on to the newer icx, but Alex Wells
still likes to sometime use icc for its better facilities for some
SIMD code generation sleuthing that he does. So we keep it in our CI
matrix to esure we don't break it for OSL until it is truly
unavoidable or he doesn't feel like he needs it anymore.

Some recent changes to OIIO's simd.h, from PR 4187 in that project,
seem to tweak what appears to be a compiler bug in icc -- bugs were
also noted in OIIO in the course of this PR and some workarounds were
put there just for icc to make OIIO's own tests pass. Well, once that
went in, OSL's CI tests for the icc case also started failing.  It's
only texture derivatives that are broken, and in a weird wy that
smells like a compiler icc bug with SIMD generation similar to what we
discovered on the OIIO side.

Like I said, this is a discontinued compiler that no major renderers
are still using, so it doesn't seem worth tracking it down any further
to find a true fix. So let's just lock that one test case down to OIIO
2.5 (the current release) to avoid the changes that will eventually be
in OIIO 2.6/3.0 and hope that we fully retire icc before OIIO 2.5 is
no longer supported by OSL.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-28 19:28:32 -07:00
Larry Gritz ea2b85537a build: Propagate cpp version (#1797)
OIIO recently pushed its master to be C++17 minimum. When using a C++17-minimum OIIO, you need to build OSL with C++17 as well. This broke a couple CI cases for OSL.

There were a few spots where we were hard-coded to C++14 on the OSL side rather than even using the C++ version specified for the OSL build, so these are some fixes here to address this.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-28 19:28:10 -07:00
sfriedmapixar c294cddad9 Make isconnected() work with downstream renderer "connections." (#1782)
The isconnected() returns 2 when used on an output that is connected to another downstream shader node -- this can be used to limit computation to only the outputs used.  However, that misses the important case of where the renderer has declared a shader node output as a renderer output, which happens often when using OSL purely for pattern generation purposes.  This change makes that case also return 2.

The isconnected test has been updated to include testing this functionality.

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2024-04-28 19:27:14 -07:00
Larry Gritz 9176da32e0 docs: More detail about supported platforms in INSTALL.md (#1796)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-28 19:26:59 -07:00
Larry Gritz 0cc4ff4b1d Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-01 11:49:20 -07:00
Larry Gritz 89ba4196a5 Stage for v1.13.8.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-01 11:43:55 -07:00
Larry Gritz 060c89d007 cleanup: Change long-deprecated OIIO macro to new one (#1788)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-04-01 11:08:40 -07:00
sfriedmapixar b86f0b94bb fix: Print closure missing error message at compile time instead of run time. (#1781)
Prevent complications on the GPU by printing error messages at compile time instead of generating code to print them at runtime when a closure doesn't exist.

---------

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2024-04-01 11:08:31 -07:00
sfriedmapixar e9a78a2824 fix: calculatenormal needs fliphandedness (#1783)
* Have OSL indicate when it needs fliphandedness in shader globals.

* Add testsuite test to check that calculatenormal() triggers a globals_needed flipHandedness value.

---------

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2024-04-01 11:07:57 -07:00
Larry Gritz 2c7c4f2f36 ci: Allow triggering CI workflow from web (#1779)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-03-07 21:28:06 -08:00
Larry Gritz 54f36c42bb ci: Fix broken Macos-13 CI (#1780)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-03-07 21:27:58 -08:00
Alex Wells 5eac061c6e fix(batched): codegen bug for compref with varying index (#1776)
Fix bug in batched codegen of compref when the index is varying.
The loadvalue was left to defaulted to uniform load, which we can't store into a varying/wide result.
Fixed similar bug in getmessage, and added check for spline knotcount to be uniform (although varying support could be added).

This bug exposed a missed optimization in BatchedAnalyser where a early out (return) needs to change the conditional to be varying to support masking.  However no check was being done to see if the loop control existed higher in the callstack.  So now the execution scope tracks loop nesting depth to see if the current function is really in a loop or not.  This allows the loop control flow to remain uniform (avoiding masking and more complex control flow).

Added nestloop-reg to testsuite to reproduce bug and verify its fixed.

---------

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2024-03-07 21:27:48 -08:00
Larry Gritz b9907e1636 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-03-07 21:27:32 -08:00
Larry Gritz 5e47ef444e Stage for v1.13.7.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-03-01 14:55:56 -08:00
olegul e94b0fec1e fix: Mute partio error prints (#1774)
Signed-off-by: Ole Gulbrandsen <olecgi@gmail.com>
2024-03-01 13:02:36 -08:00
Larry Gritz ee3403a916 Increase timeout for slow MacOS-13 runner
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-27 17:51:08 -08:00
Larry Gritz da77f89205 ci: Test with Mac ARM runner (#1770)
Tweak results for ARM tests that have minor numerical differences and
update references.

Set parallel build level to nprocs+2 instead of hard-coding to be
better for the new runners having more cores than they used to.

Speed up macosx build of deps by using unity build of OIIO.

Fix runtest, was clobbering parameters to oiiodiff

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-27 16:48:58 -08:00
Larry Gritz 5fede29c6e docs: Fix links to RTD docs from github landing page (#1768)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-15 13:35:49 -08:00
Larry Gritz 434914e7ee admin: Switch release announcement workflow to jmertic's awesome action (#1766)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-15 13:35:43 -08:00
Larry Gritz 726dc3ff0c Stage for release of v1.13.6.1
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-01 00:22:53 -08:00
Larry Gritz a88d708bc8 admin: git blame ignore for recent formatting change
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-01 00:20:17 -08:00
Larry Gritz 90d94caecb style: Reformat with clang-format 17 (modified PR 1761)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-01 00:18:36 -08:00
Larry Gritz 5da8e8c8bb style: Raise our formatting standard to clang-format 17 (#1761)
We had been using clang-format 14. Bump to 17 as our official
reference standard for formatting.

Moved the clang-format CI test from an aswf container to bare Ubuntu
to make it run faster -- it doesn't need to do a real build, so
there's no point wasting 2 minutes or so downloading a container holding
library dependencies it won't need.

Also fix a duplicate line in .clang-format that newer clang-format
complained about.

Document that it's specifically clang-format 17 that is our formatting
standard

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-02-01 00:18:36 -08:00
Tim Grant 9ceac106fa fix: Fix NVPTX TargetMachine leak, etc. (#1763)
* Delete the NVPTX target machine in the LLVM_Util destructor.

* Initalize m_nvptx_target_machine to nullptr.

* Workaround clang/CUDA12 texref issue.

* Remove the unnecessary null check before deleting the NVPTX TargetMachine.

---------

Signed-off-by: Tim Grant <tgrant@nvidia.com>
2024-01-23 10:33:03 -08:00
Larry Gritz 726049ad49 fix(build): Remove unused ustrings (#1764)
A recent change in OIIO master made some of the ustring methods
"trivial", and somehow that makes these variables warn about being
unused, which it did not do before.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-01-18 16:22:28 -08:00
Larry Gritz 710d1154b3 ci: test against LLVM 17 (#1760)
Bump the "bleeding edge" test to LLVM 17, the "stable latest releases"
test to 16.

Cover clang 17 compilation with MacOS-13 build

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-01-09 20:28:33 -08:00
Larry Gritz 04645499ab admin: Account for duplicate emails in the .mailmap (#1759)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-12-28 13:22:00 -08:00
Larry Gritz 0d9ab3c495 Stage for v1.13.6.0 (beta 1)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-12-20 12:26:30 -08:00
Larry Gritz 3d52f3906b build: handle case where OIIO uses a different Imath than OSL (#1758)
This can come up if, for example, you build an OIIO using a static
Imath library that's more recent than what you're forced to use for
your OSL build. (Don't ask, you don't want to know.) So we need
to see half.h before we include any OIIO headers. But it's the OIIO
headers that adjudicated where we get half.h from, so we need to
be a little more explicit in, of all places, rend_lib.h of testrender.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-12-03 00:32:42 -08:00
Alex Wells e154a220b6 fix(build): Partio build errors on pointcloud functions for MSVC (#1757)
Fixes #1755: Build error on MSVC with Partio

Explicitly mark unsupported/unused PointCould copy/move constructors and assignment operators as deleted.
Change SortedPointRecord index type from int to uint32_t and add static_cast during construction to avoid a warning.

Change SortedPointRecord index type from uint32_t to Partio::ParticleIndex to handle 64bit indices (where we can)
clang-format changes

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2023-11-27 18:57:40 -08:00
Rasmus Bonnedal da8f2be156 build: Fix struct align/pack for MSVC (#1754)
Signed-off-by: Rasmus Bonnedal <rasmus.bonnedal@gmail.com>
2023-11-20 13:56:04 -08:00
Alex Wells bc864771df build: refactor icc/icx specific pragma macros (#1756)
Added OSL_INTEL_CLASSIC_PRAGMA(...) which only emits for Intel(r) Classic C++ Compiler, previously OSL_INTEL_PRAGMA did that.
As many Intel compiler specicif pragmas are now supported by icx and icc,
redefined OSL_INTEL_PRAGMA to emit for the classic and llvm based Intel compilers (icc and icx).
Updated some uses of OSL_INTEL_PRAGMA to OSL_INTEL_CLASSIC_PRAGMA as appropriate.

Fixed long icx 2023.1.0, 2023.2.0, 2023.2.1 build times for certain files by removing the "-mllvm -inline-threshold=100000" flag for all but 1 file avoiding the overhead of optimization passes being applied to inlined code that wasn't actually part of the SIMD loop that we truly needed inlined.  icx now supports "#pragma forceinline recursive" which allows us to target just the SIMD loops to be inlined (as we did for icc).

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2023-11-20 13:54:22 -08:00
Larry Gritz b38487532d ci: Test ABI compliance (#1748)
This patch adds a new test to the CI matrix: verifying that we do not
break the ABI during releases. This is based on similar work done a
couple months ago in OpenImageIO.

Basically, in addition to building the current checkout, it also
builds a checkout of the designated "ABI standard" (generally, the
first non-beta release of a major version), then generates ABI dumps
of both versions and runs the ABI compliance checker using the tools
from https://github.com/lvc

Making two builds sounds expensive, but both builds are rigged to be
minimal, since only the libraries are needed for ABI checks (we can
turn off the binary tools, unit tests, python bindings, etc.), and of
course the test suite need not run. So actually, it's less expensive
than most of the test matrix entries, and it helps ensure that we
don't accidentally break ABI when we don't mean to.

I'm not sure how many false positives we'll have. We might need to
adjust the methodology slightly as we gain experience with this.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-11-17 15:27:53 -08:00
Larry Gritz 7985893a76 build: Better cmake verbose behavior (#1752)
When we bumped to cmake 3.15 minimum recently, we changed lots of
constructs like this:

    if (VERBOSE)
        message (STATUS "blah")
    endif ()

to this:

    message (VERBOSE "blah")

but I didn't realize that this was not enough, and to do it right
requires CMAKE_MESSAGE_LOG_LEVEL. So even when VERBOSE=ON, we weren't
actually getting all the verbose messages. Here, we fix it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-11-17 12:50:11 -08:00
Alex Wells 58ae6a1551 fix: batched pointcloud if "index" is not passed (#1753)
Fixes #1750

Batched shading crashes in point_cloud search if "index" is not passed as an attribute.
Fixed by allocating space for indices on stack before calling into underlying search algorithm which requires them (thus crashed if not provided).

Added 2 new tests to exercise it with no indices provided and with indices array provided but not long enough.

    testsuite/pointcloud/rdcloud_varying_mismatch.osl
    testsuite/pointcloud/rdcloud_varying_no_index.osl

Added alternative test results for
testsuite/pointcloud/ref/out_rdcloud_varying_mismatch.macos.tif
testsuite/geomath/ref/out.icx.alt.txt

Format change for wide_oppointcloud.cpp

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2023-11-17 11:44:05 -08:00
Rasmus Bonnedal 9320db9f2a testrender: Fix wrong offset of MxSheen param (#1751)
Signed-off-by: Rasmus Bonnedal <rasmus.bonnedal@gmail.com>
2023-11-15 16:42:10 -08:00
Larry Gritz 4d39f8099f admin: Fix typo in slack-release-notifier version (#1749)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-11-01 19:50:56 -07:00
Larry Gritz cbb0e28159 Stage for v1.12.14.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-31 15:27:44 -07:00
Larry Gritz 41a45b68ea docs: Regenerate PDF docs before 1.13 release (#1747)
This is probably the last time we'll regen the PDF docs, since we
are mid-transition to ReadTheDocs. We will probably not directly
distribute a PDF version with 1.14 or subsequent releases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-27 15:18:51 -07:00
Larry Gritz 8374278a07 ci: For clarity, use the term 'runner' instead of 'os' (#1743)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-27 14:13:33 -07:00
Larry Gritz 78b861f34a ci: Skip analysis and scorecard workflows on push if only docs changed (#1744)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-26 18:04:40 -07:00
Larry Gritz c9a37f5cd3 build: Fixes to build and test against OpenImageIO 2.5 (#1742)
The newly released OIIO 2.5 (and changes in master) adjusts a few of
its minimum dependencies (cmake, openexr, fmt) in ways that break some
of our CI test cases for OSL 1.12, and also deprecated a helper method
called ustringHash that OSL referenced in a few places.

These have already been addressed in the OSL main branch (what will
soon be OSL 1.13), and in some cases OSL-next has also bumped some of
the very same dependencies.

But this PR is dealing with the 1.12 branch, in which we cannot raise
minimum dependencies that OSL requires. So here we are only adjusting
which versions of those dependencies we are using or building for the
specific tests in our CI matrix that use the sufficiently new OIIO that
it needs the updated changes.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-26 16:27:24 -07:00
Larry Gritz 7710b1be46 fix: SymOverrideInfo bitfields should be the same type (#1745)
Stephen Friedman alerted me to the fact that on Windows, bit fields
within a struct will only be combined if they are the same type.  We
were a bit sloppy in the defintion of SymOverrideInfo, and that was
causing the struct to end up a different size in Windows.  I think the
solution is that all those bit fields should be `unsigned int`.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-26 15:50:17 -07:00
Larry Gritz 0e55efbd99 ci: Disable MacOS-11 CI (#1746)
The MacOS 11 CI seems to be broken on GitHub's runners. I'm not sure
why, but since it's old and getting various deprecation warnings from
Homebrew and GH, I'm inclined to just disable it rather than work hard
to keep this old version of the OS running.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-26 15:49:27 -07:00
Larry Gritz 0d4c343759 docs: First stab at ReadTheDocs (#1736)
Convert the LaTeX docs to Sphinx + Myst Markdown extension

I think this is in decent shape. It's going to need a lot of thorough
proofreading to ensure that thing got lost or mangled on the way from
the original docs. I suspect we will have several follow-up PRs to fix
thing.

After we're reasonably happy with it, we'll eventually remove the
.tex and the pdf.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-05 12:10:57 -07:00
Larry Gritz 9636c8c66c admin: Update pull request template (#1741)
It gave a VERY old link to the SPI CLA, which we no longer use.  In
fact, because we have CLA enforcement through the CLA bot, there is
not really a need to have it in the checklist... nobody can forget.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-05 10:20:01 -07:00
Larry Gritz 784bf53e88 admin: Alert slack "release-announcements" channel upon OSL release (#1740)
Add a GHA workflow that is triggered up on drafting a release, which
will echo a notice to the ASWF slack `#release-announcements` channel.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-05 10:19:13 -07:00
Larry GritzandBrecht Van Lommel c59d74f72c build: Bump Cuda minimum to 9.0 (#1737)
Based on Brecht's tests, we realize that OSL doesn't work at all with
Cuda 8.0 (which didn't support the C++14 that we use), so we're
raising the minimum to 9.0. And there are some flaky tests with 9 and
10, so we're making the recommended minimum be 11.0.

It's not our policy to change the minimum versions of dependencies on
release branches, but I think we should backport this to the release
branch. I believe what this change is doing is not removing actual
support for old versions, but rather, correctly documenting what has
been working (or not) for quite some time.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-10-04 22:04:20 -07:00
cdfec4f31d LLVM 16 and 17 support (#1730)
* Bump minimum supported LLVM version to 17
* Rename `makeArrayRef` to `toArrayRef` to avoid `llvm::makeArrayRef`
  deprecation warnings.
* Minor required changes related to `llvm::Align`.
* Disable `initializeInstrumentation` and `createPruneEHPass` which
  were remove and appear to serve no purpose now.
* Add assert when using default optimization levels with legacy pass
  manager, which is no longer supported.

This depends on both opaque pointers and new pass manager support.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Keep CMAKE_CXX_STANDARD warning for LLVM 16

* Enable LLVM 17 too, adjust for changes in new pass manager PR

* Fix OptiX data layout mismatch with LLVM 16+

i128:128 was already in the NVPTX backend since LLVM 6, the docs
this was taken from seem outdated. Unclear it started failing now,
but the data layout seems clearly incomplete without this.

* Modify CI to run the bleeding edge test on LLVM 16

* Manually make global variable names valid for PTX

* Fix build with older LLVM

---------

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Tim Grant <tgrant@nvidia.com>
2023-10-03 19:26:30 -07:00
Larry Gritz 3567aac515 build(deps): Raise OpenEXR min to 2.4 (#1734)
Only for OSL 1.13. Will not be backported to the current release.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-03 10:47:54 -07:00
Larry GritzandBrecht Van Lommel 00ea8a80fd build: Bump Cuda minimum to 9.0 (#1737)
Based on Brecht's tests, we realize that OSL doesn't work at all with
Cuda 8.0 (which didn't support the C++14 that we use), so we're
raising the minimum to 9.0. And there are some flaky tests with 9 and
10, so we're making the recommended minimum be 11.0.

It's not our policy to change the minimum versions of dependencies on
release branches, but I think we should backport this to the release
branch. I believe what this change is doing is not removing actual
support for old versions, but rather, correctly documenting what has
been working (or not) for quite some time.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-10-02 22:39:26 -07:00
Brecht Van Lommel a95116f793 ci: Fix python-oslquery test failure on macOS (#1739)
Use the absolute path to the Python executable to avoid picking up
a different executable with the same version.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2023-10-02 22:37:31 -07:00
Brecht Van Lommel b8a100e427 ci: Fix GPU job not actually enabling OptiX (#1738)
In #1668 USE_OPTIX changed to OSL_USE_OPTIX, but CI was not updated.

Also fix use of CPU SIMD flags for compiling CUDA bitcode

---------

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2023-10-02 22:34:49 -07:00
Brecht Van Lommel 0210c88374 testing: Fix tests passing when test commands fail (#1733)
PR #1563 accidentally changed tests to accept failing commands by
default. (This seems to have been a mistake -- a temporary change
added when debugging that LG neglected to remove before submitting
the PR.)

This can cause tests to pass even though the program crashed, when
a previous run created the correct output file.

---------

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2023-09-28 15:17:34 -07:00
Brecht Van Lommel baca4c2de6 LLVM new pass manager support (#1729)
LLVM 16 removes support for default optimizations levels (O1, O2, O3)
from the legacy pass manager, which are used by OSL. This adds supports
for the new pass manager while keeping the legacy pass manager working
for older LLVM versions.

* Enable new pass manager for LLVM 15+
* Both default and custom optimization levels have been implemented
* But the performance and correctness beyond passing tests has not been
  verified
* `ptx_compile_group` still uses the legacy pass manager

* Fix unecessary alias analysis and wrong #endif placement

* Fix LLVM 16 compatibility

* Ensure running prevent bitmasks pass is reentrant, and initialize once

* Make compiling with the new and legacy pass manager mutually exclusive

LLVM 17 removes even more legacy pass manager functions. With these
changes LLVM 17 works as well.

* OptiX fix, avoid using legacy pass manager for opt command since it does
not support default -O levels anymore

* Only enable new pass manager for LLVM 16+

---------

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2023-09-28 12:00:54 -07:00
Brecht Van Lommel e4766b4516 LLVM opaque pointers support (#1728)
* LLVM opaque pointers support

New LLVM versions require opaque pointers, that is you can no longer tell
from a pointer value which data type it points to.

* Remove deprecated GEP and op_load methods without type, and refactor
  code to always pass the type.
* Add element type argument to op_scatter and op_gather.
* Eliminate pointer type comparison which no longer work with
  opaque pointers.
* Keep interactive params marked as uniform in batched analysis, so
  we can deduce uniform/varying correctly from just the symbol
* Enable opaque pointers on LLVM 15, except when using OptiX

OptiX opaque pointers were not tested yet and left disabled. It is
likely broken due to the sneaky conversion in
`BackendLLVM::llvm_store_value` between `int64` and `char*`, but we
can no longer compare the pointer type. This function is called from
many places and it's unclear to me when this happens.

According to a4e779c4 this code is only temporary, so this may resolve
itself as the ustring refactoring gets completed.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Fix debug_uninit and pointcloud batched testsß

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Variable renaming and comment for clarity

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Add/restore debug names for groupdata access

Make batched backend more consistent with the regular backend.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Rename scalar_type to component_type

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Alternative interactive param fix based on feedback from Alex

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* OptiX fixes

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

* Use opaque pointers only for LLVM 16+

To avoid potentially breaking LLVM 15 with OptiX.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>

---------

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2023-09-27 22:09:15 -07:00
Larry Gritz f00da4f788 RS::get_texture_info make robust to empty shaderglobals param (#1731)
The unconditional dereferencing of the sg pointer is only necessary if
texture_thread_info is not supplied. And for that matter, the
texture_thread_info is only necessary if the texture_handle is not
supplied.

So rearranging the nesting skips a bunch of the work, and the need
for the caller to supply the sg if they have the texture_thread_info,
nor for them to need texture_thread_info if they already have the
handle.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-25 19:55:09 -07:00
Alex Wells e327241a30 fix(batch): Fix Force LLVM Boolean (#1717)
Fixes #1716:  Crash assigning boolean expression to int in batched mode

Modifying BatchedAnalysis::establish_symbols_forced_llvm_bool to excluded renderer outputs to fix the issue.
Added new test compassign-bool to recreate the issue and verify it is fixed.

Comprehensive Fix for Issue 1716:  Crash assigning boolean expression to int in batched mode

Rearchitected BatchedAnalysis::establish_symbols_forced_llvm_bool to track a BoolStatus per Symbol evaluating all operations that write to the symbol. Only if all ops that write to it always produce a logically boolean result will the BoolStatus be set to Yes.

There is another set of ops that could produce a logically boolean result if their inputs were also boolean.  In that case the BoolStatus is set to Maybe and its input symbols tracked (as they may not have a known BoolStatus yet) and deferred for a follow on pass.

After the initial pass is made, if there were any deferred Symbols, we can check their dependencies to see if they have a known BoolStatus and we can set the Symbol's BoolStatus to Yes or No depending on those input dependencies.  If the BoolStatus of any dependencies is still Unknown, we just defer it again.  We continue making passes over deferred Symbols until we have established a known BoolStatus for them all.  Afterwards we use forced_llvm_bool(true) on the Symbols where BoolStatus is Yes.

Improved support for storing forced_llvm_bool Symbol values by automatically converting from int->bool and then a vector of bools (mask) to the platforms native mask type (might be vector of integers on platforms without native mask support).

Fixed bug in BatchedAnalysis where arrays of closures were not being marked as varying, only closures where.
Allow GroupData to hold actual boolean or native mask data type vs. integers when a Symbol is forced_llvm_bool.
Improved batched GroupData layout calculation to use llvm offset and alignment calculations based on the actual DataLayout (might consider upgrading the scalar code gen to do the same).

Fixed bug where results of partial results from RendererServices::get_userdata allowed initops to execute unmasked effectively overwriting the results from RendererServices::get_userdata.  Issue stemmed from op_useparam not being modelled properly by BatchedAnalysis.

Added new test compassign-bool to recreate the issue and verify it is fixed.
Added new test closure-layered to recreate the issue and verify it is fixed.
Added new test userdata-partial recreate the issue and verify it is fixed.

Fixed bug in analysis of forced_llvm_bool for getattribute, whose return value is always a bool but result parameter when it is an integer should NOT be forced_llvm_bool.
Added test getattribute-shading to recreate the issue and verify its fixed.

Added testsuite/getattribute-shading/ref/out-scalar.txt to support builds that exclude batched.

---------

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2023-09-21 08:11:39 -07:00
Larry Gritz a569d4f0be CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-15 12:47:56 -07:00
Larry Gritz 46250b4c10 build(deps): Raise minimum CMake dependency from 3.12 to 3.15 (#1724)
This bump brings access to the following interesting features (not a
comprehensive list):

- 3.13  Nov 21, 2018

    - -B, -S let you specify source and build directories without the "cd" dance
    - target_link_options()
    - ctest --progress / CTEST_PROGRESS_OUTPUT

- 3.14  Mar 14, 2019

    - cmake --build now supports -v/--verbose
    - file(CREATE_LINK )

- 3.15  Jul 17, 2019

    - env CMAKE_GENERATOR can be used instead of -G
    - when using --build, the --target can now list multiple targets (and also can be `-t`)
    - --install can be used separately without running through the whole build
    - message() now supports NOTICE, VERBOSE, DEBUG and TRACE.
    - CMAKE_FIND_PACKAGE_PREFER_CONFIG variable
    - Enable C++20 for Apple Clang

Make sure all CI cases have a new enough cmake

Use message(VERBOSE ...) feature to simplify lots of `if` blocks.

Clean up code for older cmake versions

Freshen some of our CI build_<dependency>.bash scripts.

Note that this will NOT be backported to the current release branch,
but it will be part of the upcoming 1.13 family of releases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-15 09:20:02 -07:00
Larry Gritz e235661479 Change RendererServices::get_texture_handle back to ustring (#1726)
We were overzealous in switching everything to ustringhash.  The
filename argument to get_texture_handle should allow taking a ustring.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-12 10:45:11 -07:00
Larry Gritz fdc0579931 The recently added SS::find_symloc can have const args (#1723)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-12 10:44:30 -07:00
Chris Hellmuth d4faecd79d perf(gpu): Move qualifying GroupData params onto stack (#1710)
On SPI Arnold, we are seeing GroupData as a bottleneck for GPU performance. Regardless of whether the buffer is backed by local or global memory, it's off-chip and slow to access.

This change moves qualifying parameters out of the GroupData struct and onto the stack. On GPU this makes those parameters more likely to be stored in registers, leading to better performance.
Qualifying parameter details

The qualifying parameters are all the output parameters minus three exceptions.

A typical output parameter's lifetime is scoped to the execution of the instance it is associated with. The parameter is initialized at the beginning of instance execution, accessed during the body of the instance, and after the instance body its final state is broadcast to all its downstream connections. This lifetime makes output parameters a good fit for stack storage.

The three exceptions:

  - output parameters can be connected upstream and written to before instance execution
  - output closures are initialized at the beginning of shader execution
  - output parameters can be renderer outputs and read after instance execution

These are all identifiable at code generation time and can be flagged as disqualifying.

Improvements

On internal scenes, this change improves performance by about 15% on GPU. On CPU there aren't any performance regressions, but we don't see significant gains either. It also improves ptx generation and compilation by about 10%, and slightly lowers our memory footprint due to the GroupData size reduction.
Tests

Exceptions 2 & 3 are covered by existing tests. A new test is added for exception 1, and for the case of successful optimization. This patch was also run through our internal shading testsuite.

---------

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-09-11 10:06:30 -07:00
Tim Grant f449749f24 OptiX PTX pipeline overhaul (#1680)
## Description

This PR is an overhaul of PTX compilation in OSL. The goal is to minimize the size of the generated PTX to help reduce time spent in subsequent stages (e.g., module creation, pipeline linking, etc.).

### rend_lib

The main functional change is in how the functions defined in rend_lib.cu are handled. In the current setup, rend_lib.cu is compiled to a standalone PTX file using nvcc. The functions are considered `extern` in generated shaders, and the dependencies are satisfied when the final pipeline is linked together. Since the functions are `extern`, they are not available for optimization when each shader is generated. This prevents the inlining of small functions, which incurs a lot of function call overhead in terms of PTX size and run-time cost.

So instead of compiling rend_lib.cu separately, it is compiled to LLVM bitcode along with the rest of the "shadeops" sources. This bitcode is used to seed the LLVM Module for each shader. This makes the definitions available when each shader is being generated and optimized, which allows the optimizer to make better decisions. It also allows for better control of inlining decisions which affect the size and quality of the generated PTX.

### shadeops

Another significant functional change is in how the shadeops functions (including those defined in rend_lib.cu) are treated. In the current pipeline, each shader must carry along with it definitions for all non-inlined shadeops functions that are used. This bloats the size of the PTX for each shader, and results in many duplicate copies of those functions existing in the final linked pipeline.

In the new pipeline, the unified shadeops+rend_lib bitcode is compiled to PTX using the offline `llc` tool. This PTX is used by the renderer to create a single "shadeops" module that provides the definitions for those functions. This makes it possible to drop the definitions for those functions from the PTX for each shader, which can significantly reduce the size of the generated PTX.

### quirks

This PR contains some interesting "quirks" which are largely fallout from compiling rend_lib.cu using clang instead of nvcc:

- The clang-generated PTX is processed by a Python script to transform some function & symbol declarations to better match what was generated by nvcc. It might be possible to add the right decorators to the C++/CUDA code to get the correct visibility for these symbols, but I was not successful in doing so.
- It was necessary to change the function signatures for some of the rend_lib functions to use `void*` instead of the actual OSL types (e.g., `OSL::Color3*`). Trying to use the actual types produces an LLVM assertion failure, for reasons that I don't understand.
- I have enabled flush-to-zero (FTZ) for clang-compiled code, to better match the behavior of nvcc. I added a CMake variable to enable or disable FTZ in the event that somebody wants to disable it.
- I have added some alignment hints on pointer accesses in rend_lib.cu. clang does not appear to be able to deduce the alignment of pointers in many cases, which turns things like `memcpy` and `memset` into long series of byte operations. Functions like `osl_get_matrix` are bloated substantially if the hints aren't provided.

---------

Signed-off-by: Tim Grant <tgrant@nvidia.com>
2023-09-08 13:03:32 -07:00
Larry Gritz facfe0b74a Fix default fmt logic changing in latest openimageio release (#1725)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-05 18:38:05 -07:00
Larry Gritz 8c2d8c03b4 Fix default fmt logic changing in latest openimageio release (#1725)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-05 18:37:28 -07:00
Larry Gritz 373e359b49 build(deps): Raise minimum OpenImageIO version to 2.4 (#1722)
This is just for future-looking OSL 1.13 releases, it won't be
backported to the 1.12 release branch.

Remember that by the time we release OSL 1.13 as a supported release
family, OIIO will also have done its annual release, of 2.5. So our
minimum of OIIO 2.4 means that we will be supporting the current
release, as well as the prior year's release (and, of course, we
always stay compatible with OIIO's trunk as it evolves). So we're
really keeping compatibility with 3 major releases, which seems like
plenty to juggle.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-03 18:50:36 -07:00
Curtis Black 7afd948737 feat: Add API for building attribute getter free functions. (#1704)
Adds a new RendererServices API build_attribute_getter which allows for building custom free functions that provide values for attributes, effectively replacing both get_attribute and get_array_attribute.

This new API is invoked at material compilation time to allow render developers to provide specialized functions capable of taking advantage of known compile time information. This will allow for many optimization opportunities, such as replacing run-time map lookups with direct memory reads from known locations, remove brancing required for checking if derivatives are needed, branching on type-conversions if required, etc.

This PR currently implements this approach for attributes, a future PR could do the same for user-data.
Tests

TestShade provides an example implementation showing how this compile time information can be used to select an appropriate function to use as the attribute provider, and how to configure the function signature.

---------

Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
2023-09-01 09:44:44 -07:00
Larry Gritz 473bbfcdbd ci: Fix broken CI from new OIIO that needs newer cmake and openexr (#1719)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-26 14:23:49 -07:00
Tim Grant 05f4acee5b fix: Add missing members to ShaderGlobals in rend_lib.h (#1721)
* Add the missing thread_index and shade_index members to the copy of ShaderGlobals in testshade/cuda/rend_lib.h.

* Reorder the ShaderGlobals members in rend_lib.h to match the definition in shaderglobals.h.

---------

Signed-off-by: Tim Grant <tgrant@nvidia.com>
2023-08-25 14:33:07 -07:00
Larry Gritz a4e779c44f fix: Handle mixed string casting that plagues optix codegen (#1718)
The string situation is still a bit tricky on the OptiX side.  There's
a full overhaul of that coming separately as we continue to shift to
an all-ustringhash world.

But in the mean time, we were getting some testsuite failures that
were because of a mismatch between times we think of a gpu-side
ustring as a char* and when it's a uint64. IN FACT, they are always
the hashes, but we backed ourselves into a corner where sometimes that
64 bit pattern is passed around as a pointer, ugh.

This small patch attempts to catch this case and just do the
appropriate cast to compensate. It's a band-aid, a more comprehensive
fix is coming, as I said.

This gets us down to just ONE filing optix test case, which I will
tackle separately.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-23 21:11:49 -07:00
Larry Gritz 271f8bc30e fix: Recent journaling changes break with some fmtlib versions (#1715)
Certain fmt library versions don't automatically know how to format
atomics. Explicitly load them to turn into regular ints to avoid new
build errors introduced by the recent journaling changes.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-22 17:47:52 -07:00
Larry Gritz 2cdd061a5f docs: Move logos and add an icon-only logo (#1707)
Move from cryptically named ASWF/images to more descriptive ASWF/logos.

Add an icon only version of the logo.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-20 17:46:23 -07:00
Larry Gritz 17e0449263 docs: Update logos (#1705)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-20 17:41:26 -07:00
Larry Gritz 9e30a4e6df ci: Lock down icx version (#1706)
Intel's servers have again updated the default icx that you get when
you install from their yum repository, and the new one seems
incompatible with our libstdc++ toolchain. So lock down on 2023.1.0
for now so that our CI can pass.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-17 23:00:34 -07:00
Larry Gritz 3df1aa2f98 docs: Move logos and add an icon-only logo (#1707)
Move from cryptically named ASWF/images to more descriptive ASWF/logos.

Add an icon only version of the logo.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-17 23:00:04 -07:00
Larry Gritz afc44289fc ci: Simplify build_llvm.bash script (#1703)
* Remove leftover logic from when we used TravisCI.
* Pick a default for LLVM_DISTRO_NAME so it works when the script is run
  standalone when not on GitHub Actions CI.
* Switch the logic about file location to enumerate only the couple of
  old versions that uses the old download location, rather than trying
  to enumerate an ever-growing set of modern releases that use the current
  download location.
* Comment o say that when LLVM 10+ is the floor, the old case can go away
  entirely.

Also bump the CI "bleeding edge" test to use LLVM 15.0.6.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-17 22:59:08 -07:00
Larry Gritz 3bf59982e5 Restore stubs for printf (fixes OptiX problems with 1702) (#1711)
The recently merged PR 1702 fails all the OptiX tests. I tracked down
the problem and it's that the patch was a bit too aggressive about
removing things no longer needed. The intent was that even if you
don't use the new journaling, nothing should break. But it does break
for OptiX, and this patch restores some of the functions 1702 removed
(like the implementation of osl_printf) and some other necessary
stubs.

This takes us from failing all ~150 OptiX oriented tests to failing
only 4, which I believe are unrelated to 1702 and are merely revealed
by them. I will fix those in a separate PR.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-17 21:12:54 -07:00
Steena Monteiro cce40c38b8 Rs fmt specification - Journaling Algorithm for error, warning, fprintf (#1702)
* Journaling Algorithm for error, warning, fprintf

Removes dependence on ShadingContext and OIIO for logging error, warning, printf, and fprintf calls
for use on CPU and device, and tracks logging calls per thread index and shade index.
All calls to shader execution track thread index; ShaderGlobals contains shade_index (for processing
fmt specification calls) and thread_index for allocating memory per thread.

* Add new customization points in RendererServices for reporting errors, warnings, printf, and fprintf.
These customization points accept a fmtlib style format specifier (vs. printf style) whose argument types are represented as EncodedTypes (encodedtypes.h) and can be subsequently decoded via a utility function.

Removes dependence on ShadingContext and OSL::ErrorHandler for logging error, warning, printf, and fprintf calls
for use on CPU and device during Shader execution.  ShadingContext and OSL::ErrorHandler remain utilized during shader compilation/JIT.

Journal Buffer approach:  each thread gets its own chain of pages within the shared journal buffer for recording errors, warnings, etc.  By maintaining a separate chain per thread we can record errors (etc.) in a non-blocking fashion. Shade index is recorded for use by error reporter to sort messages but it is not used at present.
Using a Journal buffer is up to a Renderer.  The Renderer use the new customization points (rs_errorfmt, rs_filefmt, rs_printfmt, rs_warningfmt or their virtual function equivalents) to interact with a journal::Writer and journal buffer owned by its RenderState.  The Renderer would of have to allocate and initialized the journal buffer with the requested page size and number of threads before executing a shader. After a shader is done executing, the contents of the journal buffer can be transfered back to the host and processed with a journal::Reader, which reports them through a journal::Reporter's virtual interface. Intent is for Renderers's to use the Journal buffer and provide their own overriden version of the journal::Reporter.  Testshade provides example usage.  For legacy purposes, the default virtual RendererServices will route errors to ShadingSystem's OSL::ErrorHandler, but intent is for Renderer's to switch over to using a Journal buffer or their own custom logging.

NOTE:  OSL library functions as well use Renderer Service free functions can directly call OSL::filefmt, OSL::printfmt, OSL::errorfmt, OSL::warningfmt which wrappers to the underlying free functions (who may record the messages into a journal buffer).

Added a new hashcode datatype in typespec.cpp; represented as "h" in function arguments in builtindecl.
To print closures added a new OSL function osl_closure_to_ustringhash to return a ustringhash_pod value directly.

Shader execute functions now require a zero-based thread_index to identify the calling thread; used for journalling.
RendererServices::get_texture_info parameter ShadingContext * changed to ShaderGlobals * (aka ExecutionContext).

ShaderGlobals now tracks both shade_index and thread_index.
As we look to hide/remove ShaderGlobals in the future, we still need a context object to replace the role the ShaderGlobals struct is currently serving (just minus the actual shader global variables).  As a first step towards this goal, we introduce the concept of an ExecutionContext and OpaqueExecutionContext.  These just alias to ShaderGlobals currently, but start to establish the idea of hiding its contents.  Instead of direct memory access to the ExecutionContext/ShaderGlobals new getter functions have been added that accept an OpaqueExecutionContext and provide the requested data.  When inlined there should be no performance penalty, and reliance on the ShaderGlobals implementation detail will be reduced.  IE:
    inline const Vec3 & get_P(OpaqueExecContextPtr oec);
    template<typename RenderStateT> RenderStateT* get_rs(OpaqueExecContextPtr oec);
    inline int get_raytype(OpaqueExecContextPtr oec);
Updated free function renderer services and opcolor to use the ExecContext, but left the rest alone to minimize size of this PR.

We introduce opfmt.cpp that provides shim function for llvm_gen to call, where the shim adapts datatypes from llvm to c++ forwarding calls to the free function renderer service error, warning, print, fileprint functions.

Split llvm_gen_printf into llvm_gen_printf_legacy, for string format calls or when using optix, and the new llvm_gen_print_fmt which will convert the printf style specifier to the fmtlib format that the Renderer Service customization points are expecting.

fprintf by default no longer writes out to a file, is routed to journal::Reporter::report_file_print which could be overriden (example in TestShade to maintain existing behavior).  However for security reasons, we do not recommend allowing OSL shader's direct file system but instead just an annotated log entry.

To maintain existing behavior of disallowing output of repeated errors/warnings over a history window, we have provided 2 classes that could be used during reporting: TrackRecentlyReported and Report2ErrorHandler.  TrackRecentlyReported can turn on/off limitting errors and warnings and control the history capacity.  Report2ErrorHandler simply reports errors to an existing OSL::ErrorHandler to allow for easy integration.  However we expect Renderers to not use Report2ErrorHandler and provide their own to directly interact with their logging systems.


---------

Signed-off-by: Steena Monteiro <steena.monteiro@intel.com>
2023-08-17 16:31:34 -07:00
Larry Gritz 1863d04edc admin: Add missing copyright notice to many files (#1708)
Our latest license scan from LF reveailed that the usual copyright and
license declaration was missing on many shader source files in
testsuite. This was never intentional, it was simply overlooked for
certain test files. Just add the standard notice to those files.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-17 15:36:16 -07:00
Brecht Van Lommel 06c42d5c18 fix(build): duplicate osl lexing symbols when building as static libraries (#1709)
Like other oslcomp source files that are duplicated in oslexec, this
duplication should only be done for shared library builds where the
symbols are hidden from each other.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2023-08-11 00:06:25 -07:00
Larry Gritz 8dae508b4f docs: Update logos (#1705)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-20 22:00:58 -07:00
Larry Gritz 2d29966c48 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 17:49:33 -07:00
Larry Gritz 0be867f7bf Stage release v1.12.13.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 15:34:49 -07:00
Larry Gritz 362b01ecdd ci: switch oiio obsolete branch names to immutable tags
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-20 10:54:22 -07:00
Alejandro Conty b4f0517f0c fix: Zero derivs for interactive params when needed (#1700)
Sometimes an interactive param is used in a way that gets
flagged as needing derivs. But we were neither allocating space
for that nor zeroing them. This resulted on memory corruption.

This fixes incorrect renders in a production context where params are
often tagged as needing derivs.

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2023-06-20 10:50:42 -07:00
Larry Gritz 5e10537608 ci: Switch OIIO dev-2.3 branch to using v2.3.21.0 tag (#1701)
OIIO's 2.3 family is obsolete and no longer updating, so we removed
the branch marker. (Branch markers should always indicate places where
development may happen.)

But we still reference that named branch in a couple places for OSL's CI,
so just replace it with the immutable tag of the last release in the 2.3
family.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-19 13:15:02 -07:00
Larry Gritz 657dab9da0 fix: Avoid deprecated OSLQuery ctr in test example (#1699)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-15 17:11:26 -07:00
Larry Gritz 4962ac2a1b fix: Avoid deprecated OSLQuery ctr in test example (#1699)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 17:47:12 -07:00
Larry Gritz 26ad18688d ci: Add VFX Platform 2023 tests using new ASWF containers (#1696)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 15:06:36 -07:00
Larry Gritz a5857c5525 docs: Amend the filmography (#1695)
docs: Update the filmography

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 15:06:05 -07:00
Mitch Prater e2a3153667 docs: Fixed booboos from the previous README commit. (#1694)
Fixed booboos from the previous commit.
2023-06-14 15:05:49 -07:00
Mitch Prater 34fa5c3755 docs: README.md: added filmography and Siggraph OSL course info. (#1692)
Updated README.md to include LAIKA films and added Siggraph OSL course info to Documentation.
2023-06-14 15:05:38 -07:00
Chris Hellmuth 1956e83954 gpu: OptiX direct callable API that owns groupdata buffer (#1683)
On gpu, the renderer currently owns a shader's groupdata params buffer so that it can pass its pointer to both the init and entry functions.

The downside of this approach is that in order to avoid dynamic memory allocation, the renderer must commit to a buffer size at build time. Using a conservative size to accommodate potentially large shaders can lead to gigabytes of unnecessary memory footprint.

This patch adds a new OptiX direct callable alternative to the existing init and entry callables. This new function allocates a perfectly-sized groupdata params buffer, so that the gpu only pays for the memory it needs, and then it calls init and entry.

Particularly large shaders can require larger buffers than there is space on the cuda stack. To handle this case, there is a new option, "max_optix_groupdata_alloc". Any shader requiring a groupdata buffer larger than this value will not allocate its own buffer, and instead use the pointer passed in by the renderer (presumably coming from a global memory pool).

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-06-14 13:04:02 -07:00
Larry Gritz 50ccc8736f docs: Amend the filmography (#1695)
docs: Update the filmography

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 11:09:42 -07:00
Larry Gritz 6a5c50e3f3 build: Fix for Apple clang 14+ warnings (#1697)
build: Fix for Apple clang 14 warnings

Add a MacOS 13 test to the CI matrix.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 11:09:05 -07:00
Larry Gritz 49aac8740d fix: Have ReParameter only copy data when it changes (#1698)
For GPU in particular, this prevents needless transfers to the device
when no values actually change.

Also, keep track of some statistics about how much ReParameter is
being used. (Which also help to verify that this change works as
intended.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 11:08:22 -07:00
Larry Gritz c06df65331 ci: Add VFX Platform 2023 tests using new ASWF containers (#1696)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-13 14:59:15 -07:00
Alejandro Conty 4e9e640e5b fix: Don't try to ReParameter symbols not in the group (#1693)
Sometimes, after optimization, symbols tagged as interactive
get removed because they are unused. But ReParameter is failing
with errors because it goes looking for the removed symbol to
master, which is, of course, not interactive. This patch avoids
that so the symbol is not found and we just return false.

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2023-06-09 10:34:13 -07:00
Mitch Prater b76a53a779 docs: Fixed booboos from the previous README commit. (#1694)
Fixed booboos from the previous commit.
2023-06-09 08:58:41 -07:00
Mitch Prater 4e958e92c1 docs: README.md: added filmography and Siggraph OSL course info. (#1692)
Updated README.md to include LAIKA films and added Siggraph OSL course info to Documentation.
2023-06-06 16:38:08 -07:00
Larry Gritz 67a3c0b93c build: Changes to support fmt 10.0 (#1691)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 18:33:26 -07:00
Larry Gritz 188ec977a5 build: Changes to support fmt 10.0 (#1691)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 18:25:53 -07:00
Larry Gritz 60dcec97e7 cleanup: switch deprecated oiio simd names to modern (#1679)
Oops, I noticed that OSL was still using deprecated OIIO::simd type
aliases (float4, int4, bool4) instead of the modern vfloat4, vint4,
vbool4.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 09:41:41 -07:00
Larry Gritz 417088e91a docs: Update CONTRIBUTING (#1689)
Tighten up some of the explanations and update obsolete parts of the
CONTRIBUTING document.

This doesn't change any of our policies or procedures. But some advice
was out of date or no longer applicable (for example, now that we use
clang-format, we do not need to detail all the formatting rules, they
are enforced automatically).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:35:52 -07:00
Larry Gritz cf47571daa ci: Fix package name for icc (#1690)
The Intel yum repo renamed this package a couple weeks ago, and it
broke our CI. Update to the new name.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:34:46 -07:00
Larry Gritz c9672c8a0d admin: Fix incorrect links in CONTRIBUTING (#1688)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:34:26 -07:00
Larry Gritz 16d217a21f ci: Fix package name for icc (#1690)
The Intel yum repo renamed this package a couple weeks ago, and it
broke our CI. Update to the new name.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:31:41 -07:00
Larry Gritz 6a2e2960ef admin: Fix incorrect links in CONTRIBUTING (#1688)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-25 16:53:37 -07:00
Chris Hellmuth 606beade27 testing: interactive parameter initialization in optix testrender (#1687)
This change updates testrender's optix implementation of reparameter,
and adds a new test.

Previously we were grabbing the pointers from incorrect SBT records, so
this moves them into a global lookup table.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-05-25 16:41:48 -07:00
Larry Gritz 71a9310f0b feat(gpu)!: GPU/OptiX support of ReParameter (#1686)
BREAKING CHANGE: to RendererServices ABI (including for CPU) and to
the renderer-side setup when using OptiX.

This overhauls the implementation of how interactively-editable
parameters work, where they live in memory, and get it all working on
GPU/OptiX so that renderers can support interactive adjustment of
those params without recompiling shaders.

The basic gist is as follows:

* We continue work to finish making a clean separation between
  "interpolated" parameters and "interactive" (editable) parameters.

* Interpolated params are collected and put into a separate memory
  area -- a separate per-group allocation on both the CPU and GPU
  (where applicable). It needs to remember the offset into this arena
  where each of the interpolated parameters resides. These allocations
  and eventual release are taken care of by the OSL shading system,
  they live in the ShaderGroup. When the group is set up, this block
  of memory is initialized with the correct initial values of the
  params and are ready to go.

* The implementation of ReParameter writes to this special memory
  area also, that's how it works now (both CPU and GPU).

* How does the OSL library know how to allocate, free, and copy to the
  device memory? It doesn't! Instead, we add new RendererServices
  methods `device_alloc()`, `device_free()`, and
  `copy_to_device()`. It's up to the renderer to provide those, so
  that the OSL library doesn't itself need to know about the Cuda
  runtime. These are trivial, there's really only one implementation
  that makes sense, and you can copy it from the ones in testshade and
  testrender.

* Interactive parameters are NOT constant folded during runtime
  optimization.

* The shader entry points themselves now take an extra parameter in
  the main call -- this will be the pointer to the beginning of the
  shader group's interactive parameter arena.

* When JITing, references to interactive parameters know to retrieve
  them from their designated offset into the interactive parameter
  area.

* This means that the renderer-side OptiX/Cuda code is responsible for
  adding this extra pointer parameter to the call to the shader entry
  points. You can see how this is done in the testshade and testrender
  Cuda code.

* It's up to the renderer to figure out how to make the OptiX hit program
  aware of the interactive parameter pointer for that particular material,
  in order to pass it to the osl shader entry point. The way I did it in
  testshade and testrender is using a field in the struct that's given
  to each entry of the shader binding table and can be retrieved on the
  OptiX side via optixGetSbtDataPointer(). In testshade/testrender, a
  data pointer already existed which wasn't used. In a real renderer, you
  may need to add a field or come up with whatever other way you want
  to somehow get this pointer, which can be retrieved via

      shadingsys->getattribute(shadergroupptr, "device_interactive_params",
                               TypeDesc::PTR, &myptr);

  you can see how I do that in optixraytracer.cpp (testrender) and in
  optixgridrender.cpp (testshade).

A number of other things you will see that's worth calling out:

I added a device_ptr utility template that is just a wrapper around a
device side pointer that makes it hard to accidentally dereference it
on the host side.

Since I was changing RendererServices anyway, I also remove unused
register_global, fetch_global, global_map which were unused. They were
leftovers from the way we handled strings in OptiX 6.x.

Encapsulate cuda global symbol name mangling into
BackendLLVM::global_unique_symname(). I did this early on, turns out
it wasn't necessary, but I still like that encapsulation, so I'm
keeping it.

I bumped the 3rd set of digits in the version to reflect that the
changes in RendererServices break ABI. This is only in main, it
obviously cannot be backported to a release branch.

All tests pass for scalar and batch and optix.

I added a new simple reparam test, and renamed the old reparem to
reparam-array. Oddly, the reparam-array test doesn't work properly on
optix (it had never been tried before), but it also failed in optix at
main -- so it's not related to this patch! Putting that on my list of
other oddities to investigate later. It may just be a quirk of
testshade, I'm not really sure yet.

Added to BackendLLVM (and batched) a llvm_ptr_type(TypeSpec) method
that returns the LLVM type of a pointer to the specified type.

Note: This patch doesn't account for the face that a parameter marked
"interactive" could prevent a shader from correctly building for the GPU
because it used the kind of construct that is fine in shader source code but
only will work on GPU if it can be resolved to be a constant by the time
we get done with the runtime optimization (as pointed out by Stephen
Friedman. We'll come back to the problem later with a more robust and
automatic fix -- and if we are lucky, Stephen will have the opportunity to
upstream the approach he already has.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-23 13:25:28 -07:00
Pascal LecocqandPascal Lecocq 5c49a7c6b5 fix(optix): fix userdata derivatives for interpolated params on GPU (#1685)
Following #1657, it turns out we forgot to zero initialize the userdata derivatives for the optix path.
This leads to some rendering glitches caused by the memory garbage left in those derivatives.

Signed-off-by: Pascal Lecocq <pascal.lecocq@gmail.com>
Co-authored-by: Pascal Lecocq <plecocq@imageworks.com>
2023-05-20 11:25:03 -07:00
Larry Gritz abdc966a19 Give ShadingSystemImpl a handy use_optix() method (#1682)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-10 21:48:46 -07:00
Larry Gritz 374543f040 cleanup: switch deprecated oiio simd names to modern (#1679)
Oops, I noticed that OSL was still using deprecated OIIO::simd type
aliases (float4, int4, bool4) instead of the modern vfloat4, vint4,
vbool4.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-10 14:06:53 -07:00
Larry Gritz 089268b87d build(cmake): Fix incorrect variable name to control symbol visibility (#1681)
As Fabrice Macagno pointed out on the oiio-dev mail list, we weren't
setting the correct variable name CMAKE_CXX_VISIBILITY_PRESET.

And, oops, this also revealed that there were some things that needed
to be declared public that were not (because, specifically, they
needed to be called across library boundaries by the per-ISA dynamic
libraries used by batch shading!).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-09 19:25:00 -07:00
Larry Gritz 74b2b30669 refactor: Get rid of needless error check (#1677)
This was apparently something I put in to track down a possible
llvm-side problem many years ago. I haven't seen the error message in
recent memory (and it was only enabled at SPI anway), so I guess it
was a red herring or has long since been fixed. Get this cruft out of
here.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-09 18:24:03 -07:00
Larry Gritz 91699ba7d3 docs: Update (and typo fixes) to project intake checklist (#1676)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-06 08:27:49 -07:00
Larry Gritz 4afe9244e8 Remove extra pdf file that should not have been checked in
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-02 18:35:18 -07:00
AidanWelch e8fce16d36 Docs: Improve documentation of trace function (#1671)
Improve the documentation of optional parameters of trace to more accurately describe behavior.

Signed-off-by: Aidan Welch <aidan@freedwave.com>
2023-05-02 18:33:35 -07:00
Declan Russell 76f187e4d0 Fix constant float values being converted to ints (#1674)
This issue was caused by 8c52d48 . The problem is that the constant float values are being turned into ints. The PR restores the previous behavior and preserves the float format.

Note from LG explaining:

When outputting the oso and using fmt library to write the value, {} (equivalent to {:g}) prints the "simplest" text representation that, when re-parsed as a float, will give you the SAME binary float value. So the "true" value of -9.99999996e+11 is printed as -1000000000000, which when reparsed will give you the closest float to that, which is the original value. (Remember that the value of -1e12 is not exactly representable as a float.)

But if both will parse to the same float, why does the shader print -2147483648.000000 instead of -999999995904.000000? That's the interesting part.

The answer, and the real core of the problem, is that when we parse the oso file it sees -1000000000000 and thinks it's an int, lexically. Now, once it gets to figuring out what to do with that, if the initial value of a float parameter looks like an int, it's still no problem, it will convert the int to the equivalent float.

Except that in this case, because the text that looked lexically like an int is out of range for a 32 bit int, it gets INT_MIN, so by the time it's converted back to float, it's -2147483648.000000

Your fix works (at least in this instance) because it forces the value to print in a way that lexically can only be a float and not an int.

Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-05-02 18:32:34 -07:00
Declan Russell 7678df2971 build: Fix builds when USE_PYTHON=OFF (#1675)
This issue was caused by 5efe15a. Essentially, we now use Python_EXECUTABLE to execute the serialize-bc.py script. Therefore, we have to run find_package(python) so that the Python_EXECUTABLE variable gets setup.

Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-05-02 18:32:11 -07:00
Larry Gritz ed9857c416 build: Change cmake option USE_OPTIX -> OSL_USE_OPTIX (#1668)
This avoids some possible confusion with other projects, or if this
is built as a subproject.

Also, change from the C++ side having an OSL_USE_OPTIX defined -- only
for building OSL itself -- to having it always defined in oslconfig.h
and set to 0 or 1 depending on whether OptiX support was turned on at
build time. This allows app-side use of OSL headers to know if it's
dealing with an OptiX-capable OSL build.

Clean up OSL_USE_OPTIX and OSL_USE_BATCHED symbol defs

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-02 18:02:59 -07:00
AidanWelch cd22f602a4 Docs: Improve documentation of trace function (#1671)
Improve the documentation of optional parameters of trace to more accurately describe behavior.

Signed-off-by: Aidan Welch <aidan@freedwave.com>
2023-05-02 15:09:39 -07:00
Declan Russell 17d211a3d3 Fix constant float values being converted to ints (#1674)
This issue was caused by 8c52d48 . The problem is that the constant float values are being turned into ints. The PR restores the previous behavior and preserves the float format.

Note from LG explaining:

When outputting the oso and using fmt library to write the value, {} (equivalent to {:g}) prints the "simplest" text representation that, when re-parsed as a float, will give you the SAME binary float value. So the "true" value of -9.99999996e+11 is printed as -1000000000000, which when reparsed will give you the closest float to that, which is the original value. (Remember that the value of -1e12 is not exactly representable as a float.)

But if both will parse to the same float, why does the shader print -2147483648.000000 instead of -999999995904.000000? That's the interesting part.

The answer, and the real core of the problem, is that when we parse the oso file it sees -1000000000000 and thinks it's an int, lexically. Now, once it gets to figuring out what to do with that, if the initial value of a float parameter looks like an int, it's still no problem, it will convert the int to the equivalent float.

Except that in this case, because the text that looked lexically like an int is out of range for a 32 bit int, it gets INT_MIN, so by the time it's converted back to float, it's -2147483648.000000

Your fix works (at least in this instance) because it forces the value to print in a way that lexically can only be a float and not an int.

Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-05-02 10:46:28 -07:00
Declan Russell 20299563ee build: Fix builds when USE_PYTHON=OFF (#1675)
This issue was caused by 5efe15a. Essentially, we now use Python_EXECUTABLE to execute the serialize-bc.py script. Therefore, we have to run find_package(python) so that the Python_EXECUTABLE variable gets setup.

Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-05-02 09:23:35 -07:00
Larry Gritz 9ffb5fb2a3 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-01 11:11:40 -07:00
Larry Gritz f61edf2fdf Stage release v1.12.12.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-01 09:35:32 -07:00
Alejandro Conty b2190faa27 Fix userdata binding corner case (#1673)
This includes two fixes:

 1) When registering symbols that need user data, sort the entries in
 the set so the layer number is ignored. A needed udata iteam shouldn't
 depend on the layer and separating them makes find_userdata_index()
 sometimes find an index with different derivs status.

 2) osl_bind_interpolated_param() is memcpy'ing derivs that might not
 be there, yielding corrupted derivs and possibly a crash.

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2023-04-24 22:06:52 -07:00
Alejandro Conty 5600d020a0 Fix userdata binding corner case (#1673)
This includes two fixes:

 1) When registering symbols that need user data, sort the entries in
 the set so the layer number is ignored. A needed udata iteam shouldn't
 depend on the layer and separating them makes find_userdata_index()
 sometimes find an index with different derivs status.

 2) osl_bind_interpolated_param() is memcpy'ing derivs that might not
 be there, yielding corrupted derivs and possibly a crash.

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2023-04-24 10:59:10 -07:00
Chris Hellmuth 37f4bbc1a2 Make recent run-layer optimizations optional, and fix init ops-related false positive (#1672)
My initial implementation of the run layer check optimizations didn’t account for the fact that init ops for symbols have their llvm code generated before we build basic blocks from the OSL IR.

This caused the code to be wrong in two ways: 1) the set of known run layer calls was being reset between instances too late in the pipeline, so a useparam inside an init op would actually be checking the previously compiled layer’s set, and 2) even when reset earlier, it assumed valid basic block ids existed for the init ops when they did not.

So, if a layer had a useparam inside one of its init ops that generally matched the same code location as a useparam in the previously compiled layer, the run layer check could be incorrectly omitted.

I’ve updated the code so that the default optimization behavior is reverted to the way it was before #1665, and added a new option opt_useparam that can be turned on to enable a fixed, restricted version of the optimization that only applies to code in the main section.

I'm working on a test that properly triggers the issue.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-04-20 10:37:46 -07:00
cmstein b13b7f08b0 fix for ReParameterization corner case (#1670)
Take into account whether a parameter can change due to interactivity
when comparing parameters for "mergeability".

This proposed patch fixes a corner case we were seeing during live rendering with ReParameterization.

We were experiencing a problem when ss->ReParameterize() wasn't successfully applying parameter changes for us.

In our situation, a shader's parameter, "A", was marked with lockgeom=0 (ie. "live" or "editable") and was set via ss->Parameter(). This parameter was connected (through a series of copies and network links) to another shader's parameter, "B", downstream whose initialized value (ie. the one specified in the .osl/.oso file) matched A's set value. When this happened, A's shading layer was getting marked as "mergeable" and deleted, and we wouldn't see any updates to A via "reparameterization" take effect.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2023-04-13 11:22:45 -07:00
Chris Hellmuth 7ebfbc4a05 Apply recent run layer call optimization to batched execution (#1669)
Copy-paste the run layer call checks from #1665 into the batched execution mode.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-04-12 09:43:56 -07:00
Larry Gritz e402988611 Fix type ambiguity that was giving warnings (#1667)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-11 16:24:05 -07:00
Larry Gritz 88be276ec1 Clean up OptiX comments (#1666)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-11 16:14:51 -07:00
Curtis Black 35aa264dc8 Add type information for needed attributes. (#1650)
We can currently query which attribute names and scopes are requested in a shader. This PR extends that idea to also allow querying the attribute types. This now more closely matches the equivalent available queries for user data.

For example, this shader:

```
shader Shader
{
  color c;
  getattribute("user_color", c);
  
  string s;
  getattribute("user_string", s);
}
```

allows us to do this:

```
int nattr = 0;
if (shadingSys->getattribute(shaderRef.get(), "num_attributes_needed", nattr) && nattr)
{
  // this already works
  OIIO::ustring* names = nullptr;
  shadingSys->getattribute(shaderRef.get(), "attributes_needed", OSL::TypeDesc::PTR, &names);
  
  // this is the added feature
  OIIO::TypeDesc* types = nullptr;
  shadingSys->getattribute(shaderRef.get(), "attribute_types", OSL::TypeDesc::PTR, &types);
  
  // nattr: 2
  // names: ["user_color", "user_string"]
  // types: [OIIO::TypeColor, OIIO::TypeString]
}
```

The motivation behind this feature is to perform additional type validation at material compile time when determining what primvars can be provided to the shader.

One side-effect of this change to be aware of is that, as mentioned in the code comments, if the same name is requested multiple times with different types, it will now be reported multiple times. Hopefully this is not too much of an issue as the same behaviour also occurs when an attribute is requested in multiple scopes, or when user data is requested with multiple types.

Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
2023-04-10 18:51:28 -07:00
Curtis Black 6f1fedb08d Add type information for needed attributes. (#1650)
We can currently query which attribute names and scopes are requested in a shader. This PR extends that idea to also allow querying the attribute types. This now more closely matches the equivalent available queries for user data.

For example, this shader:

```
shader Shader
{
  color c;
  getattribute("user_color", c);
  
  string s;
  getattribute("user_string", s);
}
```

allows us to do this:

```
int nattr = 0;
if (shadingSys->getattribute(shaderRef.get(), "num_attributes_needed", nattr) && nattr)
{
  // this already works
  OIIO::ustring* names = nullptr;
  shadingSys->getattribute(shaderRef.get(), "attributes_needed", OSL::TypeDesc::PTR, &names);
  
  // this is the added feature
  OIIO::TypeDesc* types = nullptr;
  shadingSys->getattribute(shaderRef.get(), "attribute_types", OSL::TypeDesc::PTR, &types);
  
  // nattr: 2
  // names: ["user_color", "user_string"]
  // types: [OIIO::TypeColor, OIIO::TypeString]
}
```

The motivation behind this feature is to perform additional type validation at material compile time when determining what primvars can be provided to the shader.

One side-effect of this change to be aware of is that, as mentioned in the code comments, if the same name is requested multiple times with different types, it will now be reported multiple times. Hopefully this is not too much of an issue as the same behaviour also occurs when an attribute is requested in multiple scopes, or when user data is requested with multiple types.

Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
2023-04-10 18:38:59 -07:00
Larry Gritz 0bd014cfe2 Switch lockgeom to interpolated and interactive (#1662)
* Switch lockgeom to interpolated and interactive

Establish two new metadata hints about shader parameters:

  - "interpolated" means that the parameter comes from the geometry
    somehow and may be bound with a different value at different
    points on the surfaces, or different values for different
    primitives that share the material. This corresponds to concepts
    known variously as "geometric primitive data/variables", "user
    data", or "vertex variables", depending on the renderer.

  - "interactive" means that the user desires the parameter to be
    allowed to change when the scene is interactively rerendered,
    without incurring a full recompile of the shader. (Variables not
    so marked might still be capable of being changed, but not
    necessarily without a re-JIT of the shaders.)

Both of these require that the parameter not be fully constant-folded
or optimized away during runtime optimizeation or JIT, and thus
supplant the old "lockgeom=0" hint. But their semantics may differ in
other ways, so we thought it was worth introducing a separation, and
at the same time, finally fixing the mis-design of "lockgeom" (which
in retrospect is both a confusing name and also has the 0|1 sense
backwards, thwarting even my own intuition every time I use it).

We introduce new variants of `ShadingSystem::Parameter()` that changes
the optional `bool lockgeom` parameter for a new enum `ParamHints`
that allows for future expansion with more hinted properties.  For
now, the old calls still work (lockgeom=false is the same as passing
ParamHints::interpolated) and this does not introduce any break to
backwards ABI compatibility at this time.

In this PR, "interpolated" is basically the replacement for the old
lockgeom (though the sense is reversed). The "interactive" hint is put
in place but doesn't do anything especially useful at the moment that
is different from interpolated.  A few more things are coming down the
pike in subsequent PRs: (1) Make interactive work and fully hook it up
to ReParameter(), including on GPU. (2) Make a new global SS option
that says if you're building shaders for an interactive render or an
offline render. (If offline, the even "interactive" hinted params
should be constant-folded.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-08 15:34:26 -07:00
Chris Hellmuth 209c672b0b Don't insert redundant run layer calls inside a basic block (#1665)
This patch is a very simple part one of work to optimize the number of conditional run layer calls that OSL makes, which take the form:

    if (!groupdata->run[parentlayer])
        parent_layer([...]);

After examining our slowest JIT’ing shaders on gpu, @tgrant-nv showed us that these run layer calls were significantly bloating our ptx and slowing down their compilation. Many of them are unnecessary because static analysis can show we are guaranteed to have already run the layer in question.

For example, reading different fields from a connected struct like below will often generate multiple conditional run layer calls:

```
struct Pair {
    float x;
    float y;
};

shader example_shader(Pair p = {})
{
    if ([…]) {
        float xx = p.x;
        float yy = p.y;
        […]
    }
}
```

Since this is not really a performance issue on cpu (runtime overhead is just checking the conditional bit), OSL doesn’t make a huge effort to optimize away these redundant cases. Each useparam op will be careful not to insert more than one per layer, and code that is called unconditionally in the main section of the shader will also not have redundant checks, but there are plenty of examples like above that are not currently removed.

This patch takes a basic first step, adding metrics to track run layer call counts and removing duplicate run layer calls inside a basic block, covering cases like the example above.

On my set of production test scenes, this alone removes anywhere from 20-50% of total run layer calls, with our biggest shaders seeing the most improvement. Total ptx line reduction varies between 3-20%, and optix module compilation (jit time) is reduced between 1-15%.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-04-08 11:28:31 -07:00
Larry Gritz 5c1617fec2 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-05 14:14:58 -07:00
Larry Gritz f1c2299ff7 Stage for release of 1.12.11.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-05 14:12:18 -07:00
Larry Gritz c7aee41a1c Build: verify that OSL can build with clang16 (#1664)
But note: OSL does not yet work with LLVM 16.

Because homebrew recently upgraded its default llvm to 16.0, there may
be users for whom builds now break. The solution is:

    brew install llvm@14
    cmake ... -DLLVM_ROOT=/usr/local/opt/llvm@14

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-05 10:32:00 -07:00
Larry Gritz 49cda0a472 Build: verify that OSL can build with clang16 (#1664)
But note: OSL does not yet work with LLVM 16.

Because homebrew recently upgraded its default llvm to 16.0, there may
be users for whom builds now break. The solution is:

    brew install llvm@14
    cmake ... -DLLVM_ROOT=/usr/local/opt/llvm@14

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-05 09:00:48 -07:00
Larry Gritz 79ab666246 build: proper warnings about LLVM 16 (#1658)
LLVM 16 was just released. I'm pretty sure we won't build properly
against it because of the phase-out of typed pointers in LLVM IR, so
warn prominently so that anybody building against it who has problems
will know why.

Also, LLVM itself has bumped their toolchain requirements with the
release of 16. Technically, I'm not sure if that extends to projects
using the LLVM APIs, but warn anyway and hope for the best. If it
fails, at least the warning will supply an explanation.

At a later time, we'll need to upgrade the code on our side to have the
option of using opaque pointers so we can run with LLVM 16+.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-02 17:33:38 -07:00
Larry Gritz c8b59032fb ci: Bump 'latest dependencies' tests to OpenEXR 3.1.7 (#1663)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-02 17:31:12 -07:00
Larry Gritz 0a9070cb62 Build: Fix cuda compilation flags for LLVM 15 (#1659)
For LLVM 15+, we need to disable opaque pointers. We did this for
regular bitcode generation in llvm_macros.cmake, but neglected to make
the corresponding change for copmiling to ptx in cuda_macros.cmake.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-02 17:30:36 -07:00
Larry Gritz 787d8ce94e ci: Bump 'latest dependencies' tests to OpenEXR 3.1.7 (#1663)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-31 23:46:34 -07:00
Larry Gritz 89f1e69d88 Fix warnings about Qt compilation and enums (#1661)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-31 11:29:14 -07:00
Massimo Paladin fff0c5985d Remove SonarCloud cache setup as it is now offered by default (#1660)
Signed-off-by: Massimo Paladin <massimo.paladin@gmail.com>

No need to configure the cache anymore, SonarCloud now has an automatic analysis caching.
See https://docs.sonarcloud.io/advanced-setup/languages/c-c-objective-c/#analysis-cache.
2023-03-27 16:06:28 -07:00
Larry Gritz a047c065b7 Build: Fix cuda compilation flags for LLVM 15 (#1659)
For LLVM 15+, we need to disable opaque pointers. We did this for
regular bitcode generation in llvm_macros.cmake, but neglected to make
the corresponding change for copmiling to ptx in cuda_macros.cmake.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-27 11:22:27 -07:00
Larry Gritz bc735d02cf build: proper warnings about LLVM 16 (#1658)
LLVM 16 was just released. I'm pretty sure we won't build properly
against it because of the phase-out of typed pointers in LLVM IR, so
warn prominently so that anybody building against it who has problems
will know why.

Also, LLVM itself has bumped their toolchain requirements with the
release of 16. Technically, I'm not sure if that extends to projects
using the LLVM APIs, but warn anyway and hope for the best. If it
fails, at least the warning will supply an explanation.

At a later time, we'll need to upgrade the code on our side to have the
option of using opaque pointers so we can run with LLVM 16+.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-22 00:03:32 -07:00
Chris Hellmuth f64f6effc0 Enable userdata derivatives for interpolated params on GPU (#1657)
When generating calls to osl_bind_interpolated_param in llvm_instance.cpp, the userdata_has_derivs field is set to true if the parameter's derivatives are needed, but the code does not take into account that on gpu there is no space allocated for these derivatives.

This leads to an incorrect derivatives pointer getting passed into the renderer, which the renderer will use to write into unrelated groupdata fields.

For our renders, getting the correct image was worth the 1-2% inflation of groupdata struct size that we observed by simply re-enabling gpu userdata derivatives. If desired, adding an option to turn them on/off is straightforward, but I didn't want to preemptively bloat the code if it's not necessary.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-03-22 00:02:38 -07:00
Larry Gritz 80dee64963 Qt6 compatibility (#1655)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-18 10:25:13 -07:00
Larry Gritz 901bea3aac Be more careful about paths to look for llvm (#1656)
In particular, `${LLVM_ROOT}/bin` will end up being (incorrectly!)
`/bin` if LLVM_ROOT is empty. That is bad if some other llvm-config
happens to be in /bin.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-18 10:25:00 -07:00
Larry Gritz a620231929 Qt6 compatibility (#1655)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-18 10:23:29 -07:00
Larry Gritz df818a7045 Be more careful about paths to look for llvm (#1656)
In particular, `${LLVM_ROOT}/bin` will end up being (incorrectly!)
`/bin` if LLVM_ROOT is empty. That is bad if some other llvm-config
happens to be in /bin.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-18 10:23:03 -07:00
Larry Gritz b7a1a87dc7 ci: update runners (#1651)
* Stop using the deprecated, soon to be removed, ubuntu-18.04 runners
  and switch to 20.04.
* Bump the "latest" test openexr to 3.1.6
* Update INSTALL.md to document some things we're already testing and
  are known to work.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 22:57:57 -07:00
Larry Gritz 0c60a1a170 Fix missing // clang-format on in oslc.c (#1652)
We had turned it off in one function to preserve formatting, but
failed to turn it on at the end of the function. This led to several
small functions not being clang-formatted, now fixed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 22:57:05 -07:00
Larry Gritz bee79468e0 oslc: simple constant folding of binary expressions on the oslc side (#1653)
The runtime optimization does a great job of constant folding, and
we'd pushed it there because, with instance parameter values and
shader network connections known, it can find so much more opportunity
to optimize than we could in oslc.

However, there is one pesky problem, which is that shader parameters
that are initialized to even simple expressions such as 3+1 end up
with "init ops", which although later constant folded by the time the
shader is JITed, make it impossible to know the value via OSLQuery.

So this patch just takes the simplest cases -- certain `int OP int`
and `float OP float` expressions involving literal constants, and
performs the operation as it's parsing the code. So

         int val = 3 + 1;

actually just immediately is turned into `val = 4` instead of making
an "add".

To reiterate, the add would never have happened while executing the
shader -- at runtime in the renderer, when it's time to optimize and
JIT the shader, it would know it's a constant 4 value. This is
strictly about making oslc directly output an .oso file that knows
that parameter `val` has default value 4 instead of throwing up its
hands and saying "it's math code that will be evaluated later."

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 11:57:25 -07:00
Larry Gritz f8ad0281aa Make compile_report attribute an int instead of just 0/1 (#1654)
In particular, 1 prints a short version of the compile report (just
the fact that it happened and the time), >1 prints more verbose info.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 11:56:45 -07:00
Larry Gritz b9cb0ae74c ci: update runners (#1651)
* Stop using the deprecated, soon to be removed, ubuntu-18.04 runners
  and switch to 20.04.
* Bump the "latest" test openexr to 3.1.6
* Update INSTALL.md to document some things we're already testing and
  are known to work.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-13 15:38:22 -07:00
Larry Gritz 5879868561 Fix missing // clang-format on in oslc.c (#1652)
We had turned it off in one function to preserve formatting, but
failed to turn it on at the end of the function. This led to several
small functions not being clang-formatted, now fixed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-13 11:15:52 -07:00
Larry Gritz 98cc66a2e2 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-02 10:28:51 -08:00
Larry Gritz 5592be9f11 CHANGES and stage release for 1.12.10.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-01 10:28:54 -08:00
Larry Gritz 517d10934f Update ref images from 1649
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-01 01:07:09 -08:00
Christopher Kulla 8ac55309ab testrender: Don't use the cached background map on the first bounce (#1649)
* testrender: Don't use the cached background map on the first bounce (camera ray)

* testrender: Change the default resolution of the background so that importance sampling is enabled by default

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2023-03-01 01:07:09 -08:00
Larry Gritz c5fe678c9e Update ref images from 1649
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-01 00:52:18 -08:00
Christopher Kulla dbe8c214e4 testrender: Don't use the cached background map on the first bounce (#1649)
* testrender: Don't use the cached background map on the first bounce (camera ray)

* testrender: Change the default resolution of the background so that importance sampling is enabled by default

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2023-03-01 00:36:47 -08:00
Larry Gritz c882e823c1 fix: add missing fmod variants (#1643)
Apparently some varieties of fmod(triple,float) -- which were not
documented in the spec but were intended to work and did allow that
combination in oslc -- were not fully implemented in the runtime.

* Add all these tests to the arithmetic-reg test, to fully test all
  possible argument type and unif/vary/const combinations once and for
  all for fmod. Also add some more rudimentary testing to miscmath.

* Implement the missing bits and/or avoid the code paths that rely
  on the unimplemented parts.

The implementation of fmod for funny -- both for batch and non-batch,
it's got one code path that just directly generates code and doesn't
need any functional implementation in llvm_ops at all, and a second
code path that uses the functional implementations to work around
(different, in each case!) what appears to be bugs or limitations in
long-ago LLVM versions we don't need any more.  I'm trying to assess
whether those are still needed at all in the oldest versions of LLVM
we are using, and if not, I may amend even more simplification to this
whole thing.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-28 16:38:26 -08:00
Larry Gritz a5777fddc5 Set up ray types for testrender (#1648)
Try to set ray types correctly for rays -- a little naive now, only
using "camera", "shadow", and "diffuse" for all rays (leave
distinguishing between reflection, refraction, diffuse, glossy for
another day, and currently testrender doesn't support subsurface or
displacement, but maybe someday).

Also, for testshade, improve efficency -- don't decode raytype on
every point.  For each individual shade, testshade was converting the
name of the raytype from a string to a ustring, then decoding to a
bitfield. Pull it all out of the loops by computing the bitfield once.

Adjust glass shaders to not change behavior based on raytype:
The code path that was supposed to suppress noisy caustic rays never
worked properly before because we never set the ray type in
testrender. Now that testrender sets it -- but does not distinguish
between the different types of secondary rays -- the code path is
active, but incorrect, and causes tests to fail. Just remove the
offending clause for now and return to the old behavior of the shader
(no attempt to eliminate caustic rays). Later, we should revamp the
glass shader entirely by switching to the newer MaterialX-inspired
closures.

Note: when you specify a resolution in the Background command in our 
scene xml, it will  run the shader out of any ray context at all (therefore
having no raytype) in order to populate an environment map that will be
used as needed. If you omit the resolution, no importance sampling is
used at all, so it's much noisier. I think the right approach is to do both --
populate the map for importance sampling, but run the shader on the rays
themselves to get higher quality visible results.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-28 16:38:16 -08:00
Larry Gritz fbe141b42b fix: add missing fmod variants (#1643)
Apparently some varieties of fmod(triple,float) -- which were not
documented in the spec but were intended to work and did allow that
combination in oslc -- were not fully implemented in the runtime.

* Add all these tests to the arithmetic-reg test, to fully test all
  possible argument type and unif/vary/const combinations once and for
  all for fmod. Also add some more rudimentary testing to miscmath.

* Implement the missing bits and/or avoid the code paths that rely
  on the unimplemented parts.

The implementation of fmod for funny -- both for batch and non-batch,
it's got one code path that just directly generates code and doesn't
need any functional implementation in llvm_ops at all, and a second
code path that uses the functional implementations to work around
(different, in each case!) what appears to be bugs or limitations in
long-ago LLVM versions we don't need any more.  I'm trying to assess
whether those are still needed at all in the oldest versions of LLVM
we are using, and if not, I may amend even more simplification to this
whole thing.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-27 16:33:09 -08:00
Larry Gritz a68a972602 Set up ray types for testrender (#1648)
Try to set ray types correctly for rays -- a little naive now, only
using "camera", "shadow", and "diffuse" for all rays (leave
distinguishing between reflection, refraction, diffuse, glossy for
another day, and currently testrender doesn't support subsurface or
displacement, but maybe someday).

Also, for testshade, improve efficency -- don't decode raytype on
every point.  For each individual shade, testshade was converting the
name of the raytype from a string to a ustring, then decoding to a
bitfield. Pull it all out of the loops by computing the bitfield once.

Adjust glass shaders to not change behavior based on raytype:
The code path that was supposed to suppress noisy caustic rays never
worked properly before because we never set the ray type in
testrender. Now that testrender sets it -- but does not distinguish
between the different types of secondary rays -- the code path is
active, but incorrect, and causes tests to fail. Just remove the
offending clause for now and return to the old behavior of the shader
(no attempt to eliminate caustic rays). Later, we should revamp the
glass shader entirely by switching to the newer MaterialX-inspired
closures.

Note: when you specify a resolution in the Background command in our 
scene xml, it will  run the shader out of any ray context at all (therefore
having no raytype) in order to populate an environment map that will be
used as needed. If you omit the resolution, no importance sampling is
used at all, so it's much noisier. I think the right approach is to do both --
populate the map for importance sampling, but run the shader on the rays
themselves to get higher quality visible results.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-27 14:41:00 -08:00
Larry Gritz c14bcd2785 Fix mismatched strides when calling OCIO for transformc with derivs (#1646)
We were getting an exception thrown on the OCIO side, because we were
passing 0 for the y stride (which, us humans know, should have been fine
since there was only one row, so the stride shouldn't have mattered).
Now pass the right stride even though we don't need to step from row
to row.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:44:54 -08:00
Larry Gritz a23c42fcc6 ci: Fix broken Mac CI (#1647)
Make sure LLVM_ROOT/bin (either as a cmake var or as an env var) end
up in the hints list when searching for llvm-config.

Without this, one of our Mac CI jobs was ending up with clang 14 and
llvm 15, and that was causing problems. The particular test was
supposed to be using 14 for both.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:44:44 -08:00
Larry Gritz 434f04d336 docs: Update credits
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:44:27 -08:00
Larry Gritz a1002c61c1 Typo in test shaders (#1644)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:43:36 -08:00
Chris Hellmuth 92b0135971 Expose llvm groupdata size as a shadergroup attribute (#1642)
Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-02-20 13:43:13 -08:00
pellerington 3896d22a21 Changed snprintf formatting to satisfy some compilers. (#1640)
Signed-off-by: Peter Ellerington <elleringtonp@gmail.com>
2023-02-20 13:42:35 -08:00
Larry Gritz 23edc185a0 Fix mismatched strides when calling OCIO for transformc with derivs (#1646)
We were getting an exception thrown on the OCIO side, because we were
passing 0 for the y stride (which, us humans know, should have been fine
since there was only one row, so the stride shouldn't have mattered).
Now pass the right stride even though we don't need to step from row
to row.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:40:44 -08:00
Larry Gritz 203dcecafe ci: Fix broken Mac CI (#1647)
Make sure LLVM_ROOT/bin (either as a cmake var or as an env var) end
up in the hints list when searching for llvm-config.

Without this, one of our Mac CI jobs was ending up with clang 14 and
llvm 15, and that was causing problems. The particular test was
supposed to be using 14 for both.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-17 23:35:45 -08:00
Larry Gritz bbbc28d2ff docs: Update credits
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-17 23:04:33 -08:00
Larry Gritz 649f0b86a3 Typo in test shaders (#1644)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-08 18:21:39 -08:00
Larry Gritz 31e92ddc06 RendererServices API for letting get_texture_handle consider colorspace (#1641)
This makes some minor changes to the RS APIs to add an additional
optional parameter to get_texture_handle so it takes a `TextureOpt*`
to accommodate a similar change on the OIIO TextureSystem side
from https://github.com/OpenImageIO/oiio/pull/3761

The purpose here is to add color management options to texture calls.
However, please note that this PR only reserves a public API change we
know we'll want, but it does not fully implement the color management.
Further work will be needed, as follows:

* Current calls to RS::get_texture_handle should be updated to pass
  the TextureOpt*. (This is a formality for future-proofing in case
  future TS or alternate TS implementations want to bake the color
  space choice into the texture handle itself. But the OIIO change
  doesn't currently rely on that at the moment.)

* When the texture.h symbol `OIIO_TEXTURESYSTEM_SUPPORTS_COLORSPACE`
  exists, we are building against an OIIO that has the new int field
  `colortransformid` in the TextureOpt and TextureOptBatch structures.
  We should fill this in with a nonzero value when we want the texture
  call to be doing a color transformation as it reads texture tiles.

* Use the new TextureSystem:get_colortransform_id() to get that color
  transform ID given two named from/to color spaces. We agreed that
  it's a reasonable restriction that the color space names should be
  known by the end of runtime optimization, so that should be constant
  foldable.

* Recognize new optional argument(s) to the texture() call family that
  lets the caller specify the presumed color space of the texture,
  and use that value (with constant folded lookup of the ID, above)
  to set the value in the TextureOpt.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-04 14:49:48 -08:00
Chris Hellmuth 9ae5b69fd8 Expose llvm groupdata size as a shadergroup attribute (#1642)
Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-02-04 14:48:59 -08:00
Larry Gritz 500381cc64 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-30 14:23:01 -08:00
Larry Gritz b2b5e5eaba CHANGES and stage for v1.12.9.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-30 14:22:07 -08:00
Declan Russell 8e420b4bc8 Fix some windows GPU build errors (#1638)
Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-01-30 09:45:33 -08:00
Declan Russell 3bd3778610 Fix some windows GPU build errors (#1638)
Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-01-30 08:56:50 -08:00
cmstein a90ed53f88 adding relaxed type-equivalency to ReParameter() (#1639)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2023-01-27 18:59:26 -08:00
danieldresser-ie 7ee3e36dbb Fix bug with masked wide llvm_gen_closure() (#1637)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-27 18:59:10 -08:00
Larry Gritz 18d79314df Fix doc typo
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-27 18:58:56 -08:00
pellerington a8d3ac06e6 Changed snprintf formatting to satisfy some compilers. (#1640)
Signed-off-by: Peter Ellerington <elleringtonp@gmail.com>
2023-01-27 15:58:39 -08:00
cmstein c0a5998c19 adding relaxed type-equivalency to ReParameter() (#1639)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2023-01-25 14:27:24 -08:00
danieldresser-ie 5dad5076bc Fix bug with masked wide llvm_gen_closure() (#1637)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-25 11:47:10 -08:00
Larry Gritz 317c59ed73 Fix doc typo
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-25 09:58:08 -08:00
Larry Gritz 66c9b61d72 platform.h: fully define bitcast template (#1635)
Ported from OIIO. This lets us not have to depend on the specific
definition in OIIO's fmath.h, and in particular not worry about
whether it's a new enough version of OIIO that the old bit_cast is now
marked as deprecated.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-12 22:48:55 -08:00
Larry Gritz 8036e174fb Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-12 15:18:10 -08:00
danieldresser-ie 6f9c907db8 Remove unnecessary setting of locale::global (#1636)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-12 15:16:50 -08:00
Larry Gritz b20183d13e Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-12 15:16:23 -08:00
danieldresser-ie b064b25721 Remove unnecessary setting of locale::global (#1636)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-12 15:14:14 -08:00
Larry Gritz 8d1d9f0cf6 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-03 17:02:40 -08:00
Larry Gritz cdbc05a2b2 CHANGES and stage for v1.12.8.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-03 14:00:02 -08:00
Alex Wells b218c1853b Fix batched support for closures with array types (#1630)
Fixed batched support for closures with array types.
Enabled testsuite/userdata-custom/BATCHED (follow up to PR1620/PR1621).

Added modified version of PR1625 (Fix Issues with Derivative of getattribute) from danieldresser-ie
changing default behavior of MaskedData<DataT>::assign_all_from_scalar(const void *) to zero out Dx Dy when DataT has derviatives.
Added testsuite/userdata-custom
Fixed bug in testshades handling of userdata with derivatives.

Added bool LLVM_Util::is_type_array(llvm::Type* type)
      llvm::Type* LLVM_Util::element_type_of(llvm::Type* array_type)

Fixed icx compiler warning with src/liboslexec/osogram.y
Fixed unreferenced function warning in src/testrender/shading.cpp

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2023-01-02 19:13:56 -08:00
danieldresser-ie a2b9334422 Fix Batched Mode Crash When Adding A Default Initialized Closure (#1624)
This is another fix I'm attempting without really understanding all this LLVM stuff.

I started by adding a simple test case that attempts to add two closure parameters, where one has not been set.  This crashes or returns random values from uninitialized memory, matching a problem I ran into while trying to get batched mode working in Gaffer.

I investigated some, and found that add_closure_closure is assuming closure pointers are stored with the width of the current batch, but build_llvm_init is creating uniform closures.  I checked with @sfriedmapixar, who confirmed that all the batched closure code is assuming wide closures, so it seems build_llvm_init is what needs fixing.

Adding a `sym.make_varying();` to build_llvm_init appears to fix the problem ... I really don't know enough about the overall structure to know if this is the right place to make this fix, or if it could have other consequences, but it's enough to get this test passing, so hopefully someone who does know the background can review it.

Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-02 19:13:55 -08:00
danieldresser-ie c17553af3f Add new testshade closure to allow testing all parameter types (#1621)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-02 19:13:55 -08:00
danieldresser-ie b08c484bca Fix issue with closure keyparams batched (#1619) (#1620)
When evaluating varying closure keyword parameters in batched execution,
the value of the first lane in the batch would be used for the whole
batch.

Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-02 19:13:55 -08:00
Larry Gritz e5f0833d51 Fix: make various STRDECL definitions consistent in constness
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 19:11:17 -08:00
Patrick Mours 6979f995d9 Remove dependency on OptiX SDK for building core OSL with OptiX support (#1627)
Signed-off-by: Patrick Mours <pmours@nvidia.com>
2023-01-02 19:10:38 -08:00
Larry Gritz a0c3665725 Temp workaround for botched aswftesting container yum (#1633)
It seems something in the latest builds of the aswftesting/ci-osl:2022
containers has changed, and explicitly running /usr/bin/yum (instead of
the broken /usr/local/bin/yum) fixes it for now. This was completely
breaking the icc & icx tests, which require yum to install the Intel
compilers.

Also, bump up to the -clang14 containers for those tests, just to
get to a more recent LLVM.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 17:50:00 -08:00
Larry Gritz b88122e7ca CI: Fix Mac CI breakage (#1629)
To save build time, we had OSL's Mac CI tests use the homebrew
installation of openimageio. But... Homebrew recently switched its
default python to 3.11, which didn't match the versions we're testing
OSL against here and broke the python bindings, so need to make a few
adjustments.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 17:49:44 -08:00
Larry Gritz 1c196d935c Temp workaround for botched aswftesting container yum (#1633)
It seems something in the latest builds of the aswftesting/ci-osl:2022
containers has changed, and explicitly running /usr/bin/yum (instead of
the broken /usr/local/bin/yum) fixes it for now. This was completely
breaking the icc & icx tests, which require yum to install the Intel
compilers.

Also, bump up to the -clang14 containers for those tests, just to
get to a more recent LLVM.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 17:08:20 -08:00
Larry Gritz 100490bf8d CI: Fix build break by adjusting fmt version (#1631)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 11:48:46 -08:00
Larry Gritz a878883eeb CI: Fix build break by adjusting fmt version (#1631)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-20 12:28:50 -08:00
Alex Wells 1b3c96603c Fix batched support for closures with array types (#1630)
Fixed batched support for closures with array types.
Enabled testsuite/userdata-custom/BATCHED (follow up to PR1620/PR1621).

Added modified version of PR1625 (Fix Issues with Derivative of getattribute) from danieldresser-ie
changing default behavior of MaskedData<DataT>::assign_all_from_scalar(const void *) to zero out Dx Dy when DataT has derviatives.
Added testsuite/userdata-custom
Fixed bug in testshades handling of userdata with derivatives.

Added bool LLVM_Util::is_type_array(llvm::Type* type)
      llvm::Type* LLVM_Util::element_type_of(llvm::Type* array_type)

Fixed icx compiler warning with src/liboslexec/osogram.y
Fixed unreferenced function warning in src/testrender/shading.cpp

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-12-17 12:13:52 -08:00
Larry Gritz e468ef7595 CI: Fix Mac CI breakage (#1629)
To save build time, we had OSL's Mac CI tests use the homebrew
installation of openimageio. But... Homebrew recently switched its
default python to 3.11, which didn't match the versions we're testing
OSL against here and broke the python bindings, so need to make a few
adjustments.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-16 13:39:32 -08:00
Patrick Mours fae61e699f Remove dependency on OptiX SDK for building core OSL with OptiX support (#1627)
Signed-off-by: Patrick Mours <pmours@nvidia.com>
2022-12-16 12:20:24 -08:00
Larry Gritz 7130058741 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-03 12:37:54 -08:00
Larry Gritz 7394f997db Stage for v1.12.7.1
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-03 11:15:25 -08:00
Larry Gritz f7399cee8e CMake: Adjust how version overrides work (#1617)
Related to https://github.com/OpenImageIO/oiio/pull/3653

Kai Pastor (dg0yt) points out that the recent change I made both in
OIIO and OSL to make the version a cache variable has some unexpected
side effects that can lead to unexpeted behavior by inadvertently
retaining a version number upon recompiles if the cache itself was not
cleared, and this can happen unexpectedly even when the user isn't
trying to override the version.

This patch changes the behavior as follows:

You must use the special `-DOSL_VERSION_OVERRIDE=...` to override the
version.

  * if you do so, you are playing with fire and get what you deserve
    if you misuse it or change branches and don't remember to clear
    the cache.

If you do a normal build (without trying to override the version),

  * you will get the real version number because it IS NOT cached
  * if you switch branches, you'll always get the right version number
  * ...but switching branches without clearing the cache can still, as
    always, have other subtle behavior differences versus doing a
    truly fresh build from scratch.

So in short, it still allows a way to override the version if you
really want to, but if you are not trying to do that, you can no
longer get yourself inadvertently into unexpected trouble.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-03 11:12:54 -08:00
Larry Gritz 7b6854823d CMake: Adjust how version overrides work (#1617)
Related to https://github.com/OpenImageIO/oiio/pull/3653

Kai Pastor (dg0yt) points out that the recent change I made both in
OIIO and OSL to make the version a cache variable has some unexpected
side effects that can lead to unexpeted behavior by inadvertently
retaining a version number upon recompiles if the cache itself was not
cleared, and this can happen unexpectedly even when the user isn't
trying to override the version.

This patch changes the behavior as follows:

You must use the special `-DOSL_VERSION_OVERRIDE=...` to override the
version.

  * if you do so, you are playing with fire and get what you deserve
    if you misuse it or change branches and don't remember to clear
    the cache.

If you do a normal build (without trying to override the version),

  * you will get the real version number because it IS NOT cached
  * if you switch branches, you'll always get the right version number
  * ...but switching branches without clearing the cache can still, as
    always, have other subtle behavior differences versus doing a
    truly fresh build from scratch.

So in short, it still allows a way to override the version if you
really want to, but if you are not trying to do that, you can no
longer get yourself inadvertently into unexpected trouble.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-03 11:10:30 -08:00
Larry Gritz 5dd94cf83d CI: No longer add the ppa:ubuntu-toolchain-r/test repository (#1618)
Lately, it has been experiencing intermittent availability problems
that causes our CI to fail while setting up dependencies.

What happens if we don't use the problematic ubuntu-toolchain-r at all?

Nothing, it seems. So eliminate it.

I think that once upon a time, it was necessary to add this repo to
get certain new packages? But maybe they are mainstream enough now
that it's not necessary to add this repo? In any case, it doesn't seem
to hurt anything, it's one less moving part that can't fail if it's
not there.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-02 22:22:56 -08:00
Larry Gritz 78ba7b8f0d CI: Test against OpenColorIO 2.2 (#1616)
Also fix ocio brew install on Mac

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-02 22:22:25 -08:00
danieldresser-ie f84126fb3e Fix Batched Mode Crash When Adding A Default Initialized Closure (#1624)
This is another fix I'm attempting without really understanding all this LLVM stuff.

I started by adding a simple test case that attempts to add two closure parameters, where one has not been set.  This crashes or returns random values from uninitialized memory, matching a problem I ran into while trying to get batched mode working in Gaffer.

I investigated some, and found that add_closure_closure is assuming closure pointers are stored with the width of the current batch, but build_llvm_init is creating uniform closures.  I checked with @sfriedmapixar, who confirmed that all the batched closure code is assuming wide closures, so it seems build_llvm_init is what needs fixing.

Adding a `sym.make_varying();` to build_llvm_init appears to fix the problem ... I really don't know enough about the overall structure to know if this is the right place to make this fix, or if it could have other consequences, but it's enough to get this test passing, so hopefully someone who does know the background can review it.

Signed-off-by: Daniel Dresser <danield@image-engine.com>
2022-11-30 16:32:25 -08:00
Larry Gritz 395e58d6bf CI: No longer add the ppa:ubuntu-toolchain-r/test repository (#1618)
Lately, it has been experiencing intermittent availability problems
that causes our CI to fail while setting up dependencies.

What happens if we don't use the problematic ubuntu-toolchain-r at all?

Nothing, it seems. So eliminate it.

I think that once upon a time, it was necessary to add this repo to
get certain new packages? But maybe they are mainstream enough now
that it's not necessary to add this repo? In any case, it doesn't seem
to hurt anything, it's one less moving part that can't fail if it's
not there.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-11-29 16:23:31 -08:00
danieldresser-ie 75401bda4c Add new testshade closure to allow testing all parameter types (#1621)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2022-11-23 13:44:26 -08:00
danieldresser-ie 8530aa059a Fix issue with closure keyparams batched (#1619) (#1620)
When evaluating varying closure keyword parameters in batched execution,
the value of the first lane in the batch would be used for the whole
batch.

Signed-off-by: Daniel Dresser <danield@image-engine.com>
2022-11-23 09:08:06 -08:00
Larry Gritz 2dd1883f95 CI: Adjust when jobs are run to cut needless CI (#1615)
Changes:
* Scorecards and analysis -- allow new to cancel running old
* Scorecard only runs on main repo, no need to run on forks
* Nightly CI only runs on main repo, no need to run on forks

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-11-14 11:55:10 -08:00
Dieter De Baets 410c04ead8 Add clangSupport as dependency to fix linker error (#1613)
Signed-off-by: Dieter De Baets <dieter.baets@unity3d.com>
2022-11-14 11:54:55 -08:00
Larry Gritz bd7fd4cf8c Checkpoint to phase 2 of the great ustringhash conversion (#1612)
Reminder: phase 1 changed the RendererServices APIs to be based
completely on ustringhash for public method calls, not ustring.

This PR starts along the path of phase 2.

In oslconfig.h, I define a new type `ustringrep` which is the
in-memory/in-shader CPU-side representation of a ustring. Currently,
it's still equivalent to a ustring.

I also define a type called `ustring_pod`, which is the "plain old
data" representation inside a ustringrep (i.e., a const char* when
it's a ustring, and a uint64_t when it's a ustringhash). For reasons
not important, it's exceedingly hard to pass a true
ustring/ustringhash as parameters to or from LLVM-jitted code without
running afoul of LLVM's type checking, so it's just easier to pass the
underlying data type.

So the main work of phase 2 is to change everything related to shader
data from a ustring into a ustringrep, and things passed as const
char* into passing a ustring_pod. In some sense, it's just renaming
and type conversion plumbing.  When that's done, phase 3 is to throw
the switch and change the definition of ustringrep to ustringhash (and
of course fix everything that's broken).

This PR does not complete phase 2, but takes a big bite out of it.
It's an arbitrary bite, not much rhyme or reason to which specific
parts I did so far. Just working on it piece by piece and felt that
this was a place where much has been done, everything still works, and
it's a reviewable chunk without getting too much out of control.

Areas I worked on are related to range_check, raytype, getattribute,
bind_interpolated_param, uninit_check, range_check, naninf_check,
getmessage/setmessage, some texture setup, pointcloud.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-11-04 14:42:03 -07:00
Larry Gritz 61ea4c9a31 CI: Test against OpenColorIO 2.2 (#1616)
Also fix ocio brew install on Mac

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-11-04 00:49:59 -07:00
Larry Gritz afec48ebde CI: Adjust when jobs are run to cut needless CI (#1615)
Changes:
* Scorecards and analysis -- allow new to cancel running old
* Scorecard only runs on main repo, no need to run on forks
* Nightly CI only runs on main repo, no need to run on forks

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-11-03 23:11:03 -07:00
Dieter De Baets 9ef1741056 Add clangSupport as dependency to fix linker error (#1613)
Signed-off-by: Dieter De Baets <dieter.baets@unity3d.com>
2022-11-02 08:29:43 -07:00
Larry Gritz a31fba5505 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-30 11:43:24 -07:00
Larry Gritz 98587dfdf8 CHANGES and stage for 1.12.7.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-30 11:10:36 -07:00
Larry Gritz 1e8ef316ac Try to have more optix-only parts hidden behind OSL_USE_OPTIX (#1608)
This seems to have shifted just enough things around to make
clang-format want to re-jigger a few things.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-23 19:18:38 -07:00
Larry Gritz 822518f920 Testing: run pointcloud tests when partio is found (#1611)
Wow, this has been lurking for a while. Our Findpartio.cmake tries
looking for a partio exported config, but if not found, falls back
to a simple code to find it manually.

All was fine with the fallback code, which if found would set both
"partio_FOUND" and "PARTIO_FOUND". But the config file, if found --
only for the newer partio versions -- only set partio_FOUND. And in
that circumstance, we were not seting up the pointcloud tests!

Although the partio tests were running in CI (thankfully), I was not
running them locally on my machine with a new-ish partio.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-23 18:03:23 -07:00
Larry Gritz aafb5cb74e Testing: run pointcloud tests when partio is found (#1611)
Wow, this has been lurking for a while. Our Findpartio.cmake tries
looking for a partio exported config, but if not found, falls back
to a simple code to find it manually.

All was fine with the fallback code, which if found would set both
"partio_FOUND" and "PARTIO_FOUND". But the config file, if found --
only for the newer partio versions -- only set partio_FOUND. And in
that circumstance, we were not seting up the pointcloud tests!

Although the partio tests were running in CI (thankfully), I was not
running them locally on my machine with a new-ish partio.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-20 08:43:27 -07:00
Damien Courtois 442b265940 fixed broken links to Isotropix products (#1598)
Signed-off-by: Damien Courtois <dcourtois@isotropix.com>
2022-10-19 15:46:24 -07:00
Damien Courtois d0e49675e5 fixed broken links to Isotropix products (#1598)
Signed-off-by: Damien Courtois <dcourtois@isotropix.com>
2022-10-19 09:16:34 -07:00
Larry Gritz 09bfd07da7 OSL::bitcast utility (#1610)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-19 09:15:37 -07:00
Larry Gritz dde0a3451a OSL::bitcast utility (#1610)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-19 08:08:52 -07:00
Chris Hellmuth 3187864f9b Fix ptx symbol visibility regression (#1609)
* Address -Winconsistent-missing-override clang warning

* Fix ptx definitions of OSL_CONSTANT_DATA arrays

LLVM 14 introduced two ptx regressions to our file-scoped static variables:
1) They gained the .visible directive
2) They stopped being optimized out when unused

This lead to duplicate symbol errors when building an OptiX pipeline with
multiple shaders.

We attempted a fix using anonymous namespaces in #1561, but kept the static
keyword, resulting in a partial solution.

Removing static generates ptx that matches LLVM 12 for the affected variable
definitions.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2022-10-17 16:23:28 -07:00
Larry Gritz 74a53ff545 Improve testing coverage (partial port of #1607)
Looking at the code coverage report and trying to get a higher
coverage amount, employing two strategies: (a) remove unused code
that is not covered because it's... unused; and (b) test things
that are used but aren't in the test run. Details follow.

Disable contents of dump_struct_data_layout when OSL_DEV is not
defined, it will never be called in any other circumstances -- it's
strictly a debugging tool, not part of the shipping library.

When OSL_USE_OPTIX is not enabled, exclude compiling contents of
ptx_compile_group.

get_alignment can also be OSL_DEV only as well as simplified

Arbitrarily pick a couple of render tests to use llvm_opt levels 12
and 13 to verify that they work correctly. (That's a couple hundred
lines of pass setup code that wouldn't otherwise be included in the
coverage analysis, nor tested in the testsuite.) This also required us
to add the --llvm_opt command to testrender, as it is in testshade.

Make the analysis run build for avx512 as well for more code coverage.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-14 00:04:11 -07:00
Larry Gritz 66747ac1e6 Move string representation entirely to ustringhash -- phase I (#1603)
The first step of the great ustringhash conversion: This changes all
RendererServices methods (i.e., callbacks to the renderer from the
shader JITed code) that used to take ustring parameters, switched to
take ustringhash instead.

The second step -- which I will tackle after this part is merged --
will be to fully switch the in-memory representation of strings during
shading execution to ustringhash on the CPU (thus matching how we've
been doing it on GPU and making a number of data stuctures and
representations identical/shared for CPU and GPU).

But in the mean time, this lets renderers get started changing their
RendererServices specializations. Just like with OSL's internal
implementation, it may be easier for renderers to break the job into
phase I (rendererservices) and phase II (in-memory rep).

Some notes and guideposts:

* In oslconfig.h, define ustringrep to alias to either ustring or
  ustringhash, depending on a new (but temporary) CMake variable
  `OSL_USTRINGREP_IS_HASH`, which is OFF for now, meaning that
  ustringrep is still ustring.

* Also in oslconfig.h, several helper conversion functions among
  ustring, ustringhash, ustringrip.

* RendererServices and BatchedRendererServices (and their various
  subclasses in testshade and testrender): change the method
  signatures from ustring to ustringhash for all methods that are
  reachable from shader code.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-11 15:54:23 -07:00
Larry Gritz d867d98a50 Improve testing coverage (#1607)
Looking at the code coverage report and trying to get a higher
coverage amount, employing two strategies: (a) remove unused code
that is not covered because it's... unused; and (b) test things
that are used but aren't in the test run. Details follow.

Remove deprecated version of LLVM_Util::make_function.

Disable contents of dump_struct_data_layout when OSL_DEV is not
defined, it will never be called in any other circumstances -- it's
strictly a debugging tool, not part of the shipping library.

When OSL_USE_OPTIX is not enabled, exclude compiling contents of
ptx_compile_group.

get_alignment can also be OSL_DEV only as well as simplified

Arbitrarily pick a couple of render tests to use llvm_opt levels 12
and 13 to verify that they work correctly. (That's a couple hundred
lines of pass setup code that wouldn't otherwise be included in the
coverage analysis, nor tested in the testsuite.) This also required us
to add the --llvm_opt command to testrender, as it is in testshade.

Make the analysis run build for avx512 as well for more code coverage.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-11 14:46:55 -07:00
Larry Gritz 6069b7cfc0 Fully deprecate LLVM_Util::internalize_module_functions (#1606)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 18:04:57 -07:00
Dan Horák 6ae6aef389 include the immintrin.h header only when needed (#1605)
The immintrin.h header is required for the implementation of the
popcount and coutr_zero function only when the Intel compiler is used.
Move the inclusion accordingly. The current state breaks build on
platforms that don't provide the header, but provide the alternative
means (gcc/clang built-ins, etc).

Signed-off-by: Dan Horák <dan@danny.cz>
2022-10-10 15:21:17 -07:00
Dan Horák 41cc6d78db include the immintrin.h header only when needed (#1605)
The immintrin.h header is required for the implementation of the
popcount and coutr_zero function only when the Intel compiler is used.
Move the inclusion accordingly. The current state breaks build on
platforms that don't provide the header, but provide the alternative
means (gcc/clang built-ins, etc).

Signed-off-by: Dan Horák <dan@danny.cz>
2022-10-10 14:08:13 -07:00
Larry Gritz 8561a817ea Disabling dso testshade to fix coverage missing testshade.cpp (#1604)
We compile testshade.cpp twice -- one for a special "does it compile
as a DSO" check but that isn't run from the testsuite. This was
causing the coverage analysis to think nothing in testshade.cpp (at
least one copy of it) was getting run, which is technically true, and
counting all of its lines as untested for the coverage analysis. Just
exclude that funny dso build from the coverage case.

Also exclude anything in src/build-scripts from coverage analysis,
that's not code that ships, so to speak.

We're trying to chip away at untested code bit by bit to get our
coverage to over 80% of lines. We're getting close.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 00:06:55 -07:00
Larry Gritz cfaf643d0e Remove unused cuda variable that was warning (#1602)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-07 12:13:13 -07:00
Larry Gritz c505c4ca5f Hashing cleanup for ustrings (#1599)
Define std::hash for ustring and ustringhash, when not using an OIIO
new enough to do so.

Define std::less for ustringhash, when not using an OIIO new enough
to have operator< defined for ustringhash (will be fixed separately).

No need now for ustringHash, which is also unwisely similar to
ustringhash, just use std::hash instead.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 17:14:41 -07:00
Larry Gritz 318f0e488e CHANGES and bump version to 1.13.1.0 after ShaderGlobals change
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 15:36:14 -07:00
Steena Monteiro b22c9b7c84 Shading state uniform (#1585)
* Reduce dependency on ShadingContext and ShadingSystem objects
for accessing the ShadingSystem and consequently the ColorSystem. In its current form
it is not device-friendly.

We introduce a self-contained pvt::ShadingStateUniform that maintains a proper
state and is independent of the ShadingContext and ShadingSystem. We add an
opaque pointer to ShadingStateUniform in the ShaderGlobals structure.
Update uses of ColorSystem in opcolor.cpp to go through
ShaderGlobals::shadingStateUniform.  Also update uses of m_commonspace_synonym
and m_unknown_coordsys_error in opmatrix.cpp to go through
ShaderGlobals::shadingStateUniform.

NOTE: The ShadingStateUniform is private and an OSL implementation detail and
does not change the public interface other than adding an opaque pointer to
ShaderGlobals.

* Fixed LLVM representation to accommodate ShaderGlobals::shadingStateUniform.

* Added missing Copyright Contributors license to shading_state_uniform.h

* Removed m_commonspace_synonym data member
Moved ShadingStateUniform closer to its use in osl_prepend_matrix_from

* Fixed clang-format diffs. Added void* shadingStateUniform to ShaderGlobals in rend_lib.h. Needed for proper working.

* Added shadingStateUniform to wide_opmatrix and batched_shader_globals.h
Adjusted batched struct data layout check in codegen.

* Reordered headers to include shading_state_uniform.h with the other headers
from liboslexec

Signed-off-by: Steena Monteiro <steena.monteiro@intel.com>
2022-10-06 15:29:55 -07:00
Larry Gritz bd491d025e Git rid of the last remnants of the Cuda string_table (#1600)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 14:59:13 -07:00
Larry Gritz 4a44416156 Try to enable Sonar Cloud static analysis (#1551)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz a30b4f4290 Fix LPE leak in error condition (#1594)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz f31791b23a Fix memory leaks found by static analysis in leparse.cpp (#1593)
Several places in leparse.cpp were found by static analysis to have
memory leaks -- results of calling _parse() that, in the case of
early exists in error conditions, never got deleted.

I also did some other modernization: changed NULL to nullptr, changed
some loops to more compact range-for, utilize some Strutil helpers
that will be more efficient than the alternative std::string
manipulation.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz 4a9fc9cc87 OSL_ALLOCA (#1589)
We use OIIO_ALLOCA in many places. Make an OSL version and put it
in platform.h.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz 3e6c52366b CI: Move clang-format test to main section (#1588)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz a014de80fe Make testshade --help print texturesystem options and hardware info (#1584)
This was meant to work all along, which is why this patch is so small!

But a tiny detail -- not explicitly passing info about the `--help`
argument -- made ArgParse substitute its own default, which exits
after printing the usage info. But, as I apparently meant to do all
along, if you specify it explicitly, you get to handle it, and the way
we handled it alsp printed the extra information.

Anyway, with this patch, `testshade --help` not only prints all the
testshade command options, but also it prints some information at the
end about some of the build settings of OSL, versions of key
dependencies, hardware info, and a run-down of the ShadingSystem
options. This can be helpful for debugging.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz e8bbd79b70 CI: Set up a dynamic analysis test using address and leak sanitizers (#1581)
- There are a handful of tests we disable entirely with because they
  are irrelevant or just cannot be made to be clean (and that's ok).

- Tests with sanitizers run slow, so we increase timeouts, and also
  set AA to 1 for render tests to speed them up.  We rig it so a
  non-matching output won't fail, and that's ok because every other CI
  test is checking the results; here we have no reason to believe
  results will differ from other tests, we just need to run with
  sanitizers turned on.

- In testing.cmake, we rig texture tests to disable the leak
  sanitizer, because we can't eliminate some completely benign leaks
  from the texture system, and because they are called from JITed
  code, we don't get a clean stack trace of things that happen in OIIO
  and therefore we just can't enumerate the allowed exceptions. So we
  trust that OIIO itself tests the texture system adequately and is
  able to ignore the benign "leaks."

- We already submitted PRs and merged the little fixes that were
  discovered by enabling address and leak sanitizers. This is just the
  final bit to turn it on for CI runs from here on out.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz b75ce26416 Fix memory leak in ASTvariable_declaration (#1576)
* Fix memory leak in ASTvariable_declaration

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Alex Wells c193b0753e CI: address regressions with new icx compiler (#1601)
Some explicit SIMD loops were technically illegal because each lane was not truly independent, fixed by adding "reduction" clause.  Some Mask objects had to be replaced with just "int" to allow it to be specified in the reduction clause.

icx v2022.2.0 does apppear to have some regressions for large amounts of Dual code in a couple use cases, added alternative(improved) Single Statement Assignment (SSA) version of OIIO::fast_sincos which allowed unit tests to pass.  Consider updating OIIO fmath.h to use SSA coding style (which would allow this workaround to be removed).
Another regression with transform_normals was avoiding by introducing an OSL_UNLIKELY(condition) to generate a branch vs. masked execution, this change is a general improvement and should be left in.

Avoid flex_bison produced warning in osogram.cpp "variable 'osonerrs' set but not used".

Due to a number of regressions that appear to be fixed in next revision, choose to skip icx 2022.2 and continue CI for the time being with icx 2022.1 until the next release.

Because multiple (possibly newer) versions of oneapi may be installed, use a config file to specific a specific compiler and tbb version NOTE: Individual oneapi components may independent version numbering.

For centos images, use a config file to specificy a specific oneapi compiler and tbb version

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-10-06 10:53:11 -07:00
Alex Wells 6140c72aa6 CI: address regressions with new icx compiler (#1601)
Some explicit SIMD loops were technically illegal because each lane was not truly independent, fixed by adding "reduction" clause.  Some Mask objects had to be replaced with just "int" to allow it to be specified in the reduction clause.

icx v2022.2.0 does apppear to have some regressions for large amounts of Dual code in a couple use cases, added alternative(improved) Single Statement Assignment (SSA) version of OIIO::fast_sincos which allowed unit tests to pass.  Consider updating OIIO fmath.h to use SSA coding style (which would allow this workaround to be removed).
Another regression with transform_normals was avoiding by introducing an OSL_UNLIKELY(condition) to generate a branch vs. masked execution, this change is a general improvement and should be left in.

Avoid flex_bison produced warning in osogram.cpp "variable 'osonerrs' set but not used".

Due to a number of regressions that appear to be fixed in next revision, choose to skip icx 2022.2 and continue CI for the time being with icx 2022.1 until the next release.

Because multiple (possibly newer) versions of oneapi may be installed, use a config file to specific a specific compiler and tbb version NOTE: Individual oneapi components may independent version numbering.

For centos images, use a config file to specificy a specific oneapi compiler and tbb version

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-10-06 09:44:58 -07:00
Larry Gritz 7fcdc3f71c Run analysis upon push to main
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-05 11:19:35 -07:00
Larry Gritz 22feb208c2 CI: fix analysis run after OIIO upgrade
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-05 09:27:36 -07:00
Larry Gritz ab65bbad4b CHANGES and other minor docs adjustments after the 1.12 release
Also belatedly bump the version in main to 1.13.0.3

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-02 15:45:15 -07:00
Larry Gritz 64c66949e7 CI: Improvements to the coverage analysis (#1596)
* For analysis, USE_QT=0 will disable osltoy from building (since we
  don't/can't test it in the testsuite, it's unexecuted but really
  shouldn't count against our code coverage metric).

* Exclude Imath duplicate headers from Sonar analysis.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-02 15:42:18 -07:00
Larry Gritz 2fe18079a3 Raise OIIO minimum to 2.3 (#1591)
Traditionally, OSL has supported building against the current and also
the previous supported version of OIIO, but not necessarily any older.

With OIIO 2.4 released (any day now), and OSL "main" is actually going
to be next year's supported release, it seems reasonable to change the
forward-looking development of OSL to have a minimum of OIIO 2.3,
which means that OSL-next will support OIIO 2.3, 2.4, and the
currently-in-progress 2.5 (or whatever it's called by that point).

The main reason to do this bump is because we'd like to depend on the
ustringhash class, and possibly other things we will probably be able
to easily backport to 2.3 but not to 2.2.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 18:23:09 -07:00
Larry Gritz e0a66c7bc6 Fix LPE leak in error condition (#1594)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 17:03:31 -07:00
Larry Gritz cf725983de Batched analysis: ReadEvent remove uninitialized members (#1575)
The little ReadEvent class had two members that are never set when
OSL_DEV is not defined, nor are they accessible (the accessor
functions also are disabled based on OSL_DEV). It looked to the static
analyzer like the data members were uninitialized, which they
were. Add OSL_DEV guards around the declarations of those members as
well, so they aren't even present in the struct when not needed for
this debugging mode.

Food for thought: another alternative is to keep the members but just
remove the OSL_DEV guards entirely -- just let the two int data
members be used all the time, not just for OSL_DEV. It's too small to
have any perf penalty, and it unclutters the declaration by removing
all those `#ifdef` lines.

For that matter, I also wonder if there's any real point to having
private members and accessor functions for this tiny internal-only
class, and maybe it's better to just let it be compact declaration
of a simple `struct` with three directly accessible data members.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 16:46:37 -07:00
Larry Gritz fc16c8dde2 Rewrite confusing loop in testshade for clarity (#1574)
In testshade, there was a "loop" that wasn't really a loop, and it
was getting flagged by static analysis as being fishy. This patch
rewrites it as an "if".

Also take the opportunity to change from stream output to OSL::print
formatted output.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 16:46:37 -07:00
Larry Gritz 257ca66afe Build/test: parameterize the timeout for expensive tests (#1571)
We had hard-coded longer allowable timeouts for particular testsuite
tests. But for the static analysis runs, it takes extra long and we
need a way to tell it to increase the timeouts even more, and to
exclude the longest running tests from the analysis coverage run (it's
not necessary to run those tests, they don't increase coverage enough
to justify being an hours long run).

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 16:46:37 -07:00
Larry Gritz fde2a3e5ee Rename compiler-generated constants non-sequentially (#1570)
In the course of our runtime optimization of shader networks, we
generate lots of new constant symbols (for example, as we optimize an
"a = b + c" into "a = newconst" if b and c can be determined to be
constants). The new constants are named with a numerical suffix doled
out in a sequental manner.

I've always thought that maybe it would be helpful for me when
debugging optimizer output if the name of the symbol also revealed the
value of the constant it held (when possible). Never did anything
about it.

Now it turns out that this has an application for JIT to PTX, where
the PTX cache can save compilation-to-PTX time if it encounters LLVM
IR that is exactly the same as it has seen before and is cache.  If
the constants are generated in a different order, it generates
non-functional, purely text differences in the code we generate, and
this means the PTX cache doesn't function as efficiently as possible.

So this change alters the compiler-generated constant naming for two
cases: int constants, and string constants. The int constants append
the value of the integer (using '_' instead of '-' for negatives), and
the string constants append the hexidecimal value of the ustring hash
for that string. In both cases it does this without using or
incrementing the `m_next_newconst` counter that it uses to
sequentially name the other types that can't easily encode the value
to generate a unique name.

It's really to help the PTX cache, but as a side benefit, it will
be slightly easier for me to make sense of the optimized code when
I need to read it with my own eyes while debugging.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 16:46:37 -07:00
Larry Gritz 6906daebdc Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 16:46:37 -07:00
Larry Gritz d80bbaa50a Stage for release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 16:43:53 -07:00
Larry Gritz a1a77b86ab LLVM 15.0 support (#1592)
* A variety of changes to get a clean build and passing tests when
  using LLVM 15.0.

* I've noticed problems when using LLVM 15 but building with earlier
  clang, so the cmake scripts now print a warning in that case, so if
  users encounter trouble they have a hint about what to do to fix it.

* For our CI tests on Mac, force the MacOS-11 test to use llvm 14,
  and the MacOS-12 test to use llvm 15.

IMPORTANT TO-DO / CAVEATS:

1. When doing JIT at optlevel 12 or 13, I had to disable a number of
   passes that don't seem to exist anymore in LLVM 15. This is enough
   to get it working, and to be honest, I don't know if anybody uses
   these opt levels.  But we need to revisit this, because I don't
   know if there these are cases where the names of the passes merely
   changed or that new passes take their place (in which case we
   should add the new passes, not stop after merely disabling the
   deprecated ones). For that matter, optlevel modes 11, 12, 13 are
   supposed to match what clang does for -O1, -O2, -O3, and that
   changes from one release to the next, so we should probably revisit
   this list and make sure it's matching clang's current choices
   (which I assume are crafted and periodically revised by clang's
   authors).

2. LLVM 15 switches to "opaque pointers". It still supports typed
   pointers...  for now. But as you can see in the diffs, I had to
   disable a variety of deprecation warnings and take some other
   actions to put LLVM 15 in the old "opaque ptr" mode to match our
   use of LLVM <= 14. But this is only temporary, because the typed
   pointer mode is expected to be removed entirely in LLVM 16. So at
   some point in the next few months, we are going to need to support
   opaque pointers in our use of LLVM. (Also note: for a while, we're
   going to have a bunch of ugly `#if` guards or other logic to
   support both opaque pointers for users with llvm >= 16 and also
   typed pointers for users with llvm <= 14, until such time as our
   LLVM minimum is at least 15, which I expect is not a reasonable
   assumption for at least a couple years.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-29 10:12:44 -07:00
Larry Gritz 267c93104b Fixes to compile with clang 15 (#1586)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-29 10:12:38 -07:00
Larry Gritz e4e5088ed6 LLVM 15.0 support (#1592)
* A variety of changes to get a clean build and passing tests when
  using LLVM 15.0.

* I've noticed problems when using LLVM 15 but building with earlier
  clang, so the cmake scripts now print a warning in that case, so if
  users encounter trouble they have a hint about what to do to fix it.

* For our CI tests on Mac, force the MacOS-11 test to use llvm 14,
  and the MacOS-12 test to use llvm 15.

IMPORTANT TO-DO / CAVEATS:

1. When doing JIT at optlevel 12 or 13, I had to disable a number of
   passes that don't seem to exist anymore in LLVM 15. This is enough
   to get it working, and to be honest, I don't know if anybody uses
   these opt levels.  But we need to revisit this, because I don't
   know if there these are cases where the names of the passes merely
   changed or that new passes take their place (in which case we
   should add the new passes, not stop after merely disabling the
   deprecated ones). For that matter, optlevel modes 11, 12, 13 are
   supposed to match what clang does for -O1, -O2, -O3, and that
   changes from one release to the next, so we should probably revisit
   this list and make sure it's matching clang's current choices
   (which I assume are crafted and periodically revised by clang's
   authors).

2. LLVM 15 switches to "opaque pointers". It still supports typed
   pointers...  for now. But as you can see in the diffs, I had to
   disable a variety of deprecation warnings and take some other
   actions to put LLVM 15 in the old "opaque ptr" mode to match our
   use of LLVM <= 14. But this is only temporary, because the typed
   pointer mode is expected to be removed entirely in LLVM 16. So at
   some point in the next few months, we are going to need to support
   opaque pointers in our use of LLVM. (Also note: for a while, we're
   going to have a bunch of ugly `#if` guards or other logic to
   support both opaque pointers for users with llvm >= 16 and also
   typed pointers for users with llvm <= 14, until such time as our
   LLVM minimum is at least 15, which I expect is not a reasonable
   assumption for at least a couple years.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-29 10:10:58 -07:00
Larry Gritz aea281dcad Fix memory leaks found by static analysis in leparse.cpp (#1593)
Several places in leparse.cpp were found by static analysis to have
memory leaks -- results of calling _parse() that, in the case of
early exists in error conditions, never got deleted.

I also did some other modernization: changed NULL to nullptr, changed
some loops to more compact range-for, utilize some Strutil helpers
that will be more efficient than the alternative std::string
manipulation.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-29 09:57:19 -07:00
Larry Gritz b5aba16147 OSL_ALLOCA (#1589)
We use OIIO_ALLOCA in many places. Make an OSL version and put it
in platform.h.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-27 15:31:12 -07:00
Larry Gritz 4ba1678561 Fixes to compile with clang 15 (#1586)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-27 14:55:29 -07:00
Larry Gritz 8417f8eb04 CI: Move clang-format test to main section (#1588)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-27 11:24:39 -07:00
Larry Gritz d08f476b3c OSL v1.12.6.1-RC1 release candidate for 1.12
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-24 14:45:19 -07:00
Larry Gritz 7e9ddadc0f Docs: Some minor updates to CONTRIBUTIONS and INSTALL docs (#1582)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-22 14:49:37 -07:00
Mark Sisson 0cdf072c22 add .envrc to .gitignore (#1583)
direnv (https://github.com/direnv/direnv) can be used for local developer workflow enhancements.  direnv uses .envrc file for configuration.  Because .envrc is usually specific to a developer workflow, it is generally not committed.

Signed-off-by: Mark Sisson <5761292+marksisson@users.noreply.github.com>
2022-09-22 14:49:33 -07:00
Larry Gritz 55029e388f Make testshade --help print texturesystem options and hardware info (#1584)
This was meant to work all along, which is why this patch is so small!

But a tiny detail -- not explicitly passing info about the `--help`
argument -- made ArgParse substitute its own default, which exits
after printing the usage info. But, as I apparently meant to do all
along, if you specify it explicitly, you get to handle it, and the way
we handled it alsp printed the extra information.

Anyway, with this patch, `testshade --help` not only prints all the
testshade command options, but also it prints some information at the
end about some of the build settings of OSL, versions of key
dependencies, hardware info, and a run-down of the ShadingSystem
options. This can be helpful for debugging.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-21 17:13:34 -07:00
Larry Gritz 89c033bda9 Docs: Some minor updates to CONTRIBUTIONS and INSTALL docs (#1582)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-21 16:33:13 -07:00
Mark Sisson 0b57ae6b03 add .envrc to .gitignore (#1583)
direnv (https://github.com/direnv/direnv) can be used for local developer workflow enhancements.  direnv uses .envrc file for configuration.  Because .envrc is usually specific to a developer workflow, it is generally not committed.

Signed-off-by: Mark Sisson <5761292+marksisson@users.noreply.github.com>
2022-09-20 15:59:32 -07:00
Chris Hellmuth 9f033074fa Docs: Minor spec typos (#1580)
* Fix minor spec typos

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2022-09-19 18:33:48 -07:00
Larry Gritz 6588caafa6 CI: Set up a dynamic analysis test using address and leak sanitizers (#1581)
- There are a handful of tests we disable entirely with because they
  are irrelevant or just cannot be made to be clean (and that's ok).

- Tests with sanitizers run slow, so we increase timeouts, and also
  set AA to 1 for render tests to speed them up.  We rig it so a
  non-matching output won't fail, and that's ok because every other CI
  test is checking the results; here we have no reason to believe
  results will differ from other tests, we just need to run with
  sanitizers turned on.

- In testing.cmake, we rig texture tests to disable the leak
  sanitizer, because we can't eliminate some completely benign leaks
  from the texture system, and because they are called from JITed
  code, we don't get a clean stack trace of things that happen in OIIO
  and therefore we just can't enumerate the allowed exceptions. So we
  trust that OIIO itself tests the texture system adequately and is
  able to ignore the benign "leaks."

- We already submitted PRs and merged the little fixes that were
  discovered by enabling address and leak sanitizers. This is just the
  final bit to turn it on for CI runs from here on out.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-19 18:28:56 -07:00
Chris Hellmuth b11fb97626 Docs: Minor spec typos (#1580)
* Fix minor spec typos

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2022-09-15 13:47:53 -07:00
Larry Gritz 7a885c68b6 CHANGES and designate this spot as 1.13.0.2
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-13 15:25:10 -07:00
Larry Gritz 6d9db5a761 Build: Make the version number be a cmake cache variable (#1579)
Rather than specify the version in the usual project() statement,

    project (OSL VERSION 1.13.0.0 ...)

this patch decouples it

    set (OSL_VERSION "1.13.0.0" CACHE STRING "Version")
    project (OSL VERSION ${OSLVERSION} ...)

thus allowing the possibility of overriding the version number at
build confuguration time (`cmake -DOSL_VERSION=3.1.4.1`).

This should be used with extreme caution. Probably never used by most
people. I don't need to describe all the ways that things can go
sideways if you make your build of x.y.z.w actually be arbitrarily
different from the x.y.z.w that everyone else uses and that is
documented.

That said, there are two scenarios I have in mind for which this
ability is very useful:

1. Sometimes, we add or deprecate API features "in advance" by having
   an `#if` enable or disable code based on the version, essentially
   putting in place changes that can't be enabled yet because they
   would break compatibility rules, but we want to integrate the code
   now and have it become active upon reaching a particular future
   version in which that incompatibility will be allowed. The version
   number override makes it easy to test this by quickly doing a build
   "as if" we had already bumped the version number to see what will
   happen when we actually do.

2. Every once in a while we need to do an internal build that, to
   conform to version compatibility rules, needs to appear to still be
   part of a past version family. This lets individual sites play some
   games with version number overrides rather than have to create new
   branches and tags for certain one-off internal releases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-13 15:17:01 -07:00
Larry Gritz 32278d3f77 Build: Make the version number be a cmake cache variable (#1579)
Rather than specify the version in the usual project() statement,

    project (OSL VERSION 1.13.0.0 ...)

this patch decouples it

    set (OSL_VERSION "1.13.0.0" CACHE STRING "Version")
    project (OSL VERSION ${OSLVERSION} ...)

thus allowing the possibility of overriding the version number at
build confuguration time (`cmake -DOSL_VERSION=3.1.4.1`).

This should be used with extreme caution. Probably never used by most
people. I don't need to describe all the ways that things can go
sideways if you make your build of x.y.z.w actually be arbitrarily
different from the x.y.z.w that everyone else uses and that is
documented.

That said, there are two scenarios I have in mind for which this
ability is very useful:

1. Sometimes, we add or deprecate API features "in advance" by having
   an `#if` enable or disable code based on the version, essentially
   putting in place changes that can't be enabled yet because they
   would break compatibility rules, but we want to integrate the code
   now and have it become active upon reaching a particular future
   version in which that incompatibility will be allowed. The version
   number override makes it easy to test this by quickly doing a build
   "as if" we had already bumped the version number to see what will
   happen when we actually do.

2. Every once in a while we need to do an internal build that, to
   conform to version compatibility rules, needs to appear to still be
   part of a past version family. This lets individual sites play some
   games with version number overrides rather than have to create new
   branches and tags for certain one-off internal releases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-13 15:06:49 -07:00
Larry Gritz 6cd6849580 Bug fix: assigning init-op param its default value as instance got lost (#1578)
This is a tricky situation to describe. Consider this shader:

    shader test (float A = 0.5,
                 float B = A)
    {
        printf("A = %g, B = %g\n", A, B);
    }

By default, A is 0.5 and B gets A's value, also 0.5. If you give A a
different instance value, like 1.0, then B will also get the same
value, they'll both be 1.0.  If you give B an instance value, that
will be used for B rather than copying A's value, like this:

    $ testshade  -param B 1.0 -shader test test
    A = 0.5, B = 1

But there is a corner case bug: if we assign B an instance value of
0.0, it will incorrectly fall into a special case where it thinks it
gets a default value, only coincidentally because 0.0 is in an unused
slot for the default value (unused because it has no default -- its
default comes from "init ops", that assignment).

    $ testshade  -param B 0.0 -shader test test
    A = 0.5, B = 0.5

!!!

Reading the patch should be self-explanatory for what the bug is and
how we fix it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-12 17:52:03 -07:00
Larry GritzandAlex Wells db1dcc1053 Fix overrunning allocation region in debug common_ancestor_between (#1577)
Signed-off-by: Alex Wells <alex.m.wells@intel.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Alex Wells <alex.m.wells@intel.com>
2022-09-12 17:52:03 -07:00
Larry Gritz af15fb3b3d Docs: RELEASING.md (#1572)
I've tried to write a complete set of step-by-step instructions for
everything about how to coordinate and deploy a release. This is a
living document, we will amend over time. I'm sure there must be
things I've forgotten.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-12 17:52:03 -07:00
Larry Gritz 9e9acd1592 Bump version after beta tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-12 17:52:03 -07:00
Larry Gritz c8dd33f5a3 Bug fix: assigning init-op param its default value as instance got lost (#1578)
This is a tricky situation to describe. Consider this shader:

    shader test (float A = 0.5,
                 float B = A)
    {
        printf("A = %g, B = %g\n", A, B);
    }

By default, A is 0.5 and B gets A's value, also 0.5. If you give A a
different instance value, like 1.0, then B will also get the same
value, they'll both be 1.0.  If you give B an instance value, that
will be used for B rather than copying A's value, like this:

    $ testshade  -param B 1.0 -shader test test
    A = 0.5, B = 1

But there is a corner case bug: if we assign B an instance value of
0.0, it will incorrectly fall into a special case where it thinks it
gets a default value, only coincidentally because 0.0 is in an unused
slot for the default value (unused because it has no default -- its
default comes from "init ops", that assignment).

    $ testshade  -param B 0.0 -shader test test
    A = 0.5, B = 0.5

!!!

Reading the patch should be self-explanatory for what the bug is and
how we fix it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-12 16:49:49 -07:00
Larry Gritz 1a7670600c Fix memory leak in ASTvariable_declaration (#1576)
* Fix memory leak in ASTvariable_declaration

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-08 21:02:15 -07:00
Larry Gritz a6ff40b0b2 Docs: RELEASING.md (#1572)
I've tried to write a complete set of step-by-step instructions for
everything about how to coordinate and deploy a release. This is a
living document, we will amend over time. I'm sure there must be
things I've forgotten.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-08 18:50:49 -07:00
Larry GritzandAlex Wells 54cf8b209c Fix overrunning allocation region in debug common_ancestor_between (#1577)
Signed-off-by: Alex Wells <alex.m.wells@intel.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Alex Wells <alex.m.wells@intel.com>
2022-09-08 10:12:21 -07:00
Larry Gritz 2e941e612f Batched analysis: ReadEvent remove uninitialized members (#1575)
The little ReadEvent class had two members that are never set when
OSL_DEV is not defined, nor are they accessible (the accessor
functions also are disabled based on OSL_DEV). It looked to the static
analyzer like the data members were uninitialized, which they
were. Add OSL_DEV guards around the declarations of those members as
well, so they aren't even present in the struct when not needed for
this debugging mode.

Food for thought: another alternative is to keep the members but just
remove the OSL_DEV guards entirely -- just let the two int data
members be used all the time, not just for OSL_DEV. It's too small to
have any perf penalty, and it unclutters the declaration by removing
all those `#ifdef` lines.

For that matter, I also wonder if there's any real point to having
private members and accessor functions for this tiny internal-only
class, and maybe it's better to just let it be compact declaration
of a simple `struct` with three directly accessible data members.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-07 22:54:01 -07:00
Larry Gritz 051f2bfe2f Rewrite confusing loop in testshade for clarity (#1574)
In testshade, there was a "loop" that wasn't really a loop, and it
was getting flagged by static analysis as being fishy. This patch
rewrites it as an "if".

Also take the opportunity to change from stream output to OSL::print
formatted output.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-06 11:23:48 -07:00
Larry Gritz f13463e6b6 Build/test: parameterize the timeout for expensive tests (#1571)
We had hard-coded longer allowable timeouts for particular testsuite
tests. But for the static analysis runs, it takes extra long and we
need a way to tell it to increase the timeouts even more, and to
exclude the longest running tests from the analysis coverage run (it's
not necessary to run those tests, they don't increase coverage enough
to justify being an hours long run).

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-04 18:00:50 -07:00
Larry Gritz cd2fa1650d Rename compiler-generated constants non-sequentially (#1570)
In the course of our runtime optimization of shader networks, we
generate lots of new constant symbols (for example, as we optimize an
"a = b + c" into "a = newconst" if b and c can be determined to be
constants). The new constants are named with a numerical suffix doled
out in a sequental manner.

I've always thought that maybe it would be helpful for me when
debugging optimizer output if the name of the symbol also revealed the
value of the constant it held (when possible). Never did anything
about it.

Now it turns out that this has an application for JIT to PTX, where
the PTX cache can save compilation-to-PTX time if it encounters LLVM
IR that is exactly the same as it has seen before and is cache.  If
the constants are generated in a different order, it generates
non-functional, purely text differences in the code we generate, and
this means the PTX cache doesn't function as efficiently as possible.

So this change alters the compiler-generated constant naming for two
cases: int constants, and string constants. The int constants append
the value of the integer (using '_' instead of '-' for negatives), and
the string constants append the hexidecimal value of the ustring hash
for that string. In both cases it does this without using or
incrementing the `m_next_newconst` counter that it uses to
sequentially name the other types that can't easily encode the value
to generate a unique name.

It's really to help the PTX cache, but as a side benefit, it will
be slightly easier for me to make sense of the optimized code when
I need to read it with my own eyes while debugging.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-02 10:07:13 -07:00
Larry Gritz c23da3df34 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 18:39:03 -07:00
Larry Gritz 95c1408d27 Rebuild PDF docs
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 18:33:19 -07:00
Larry Gritz 60975da4e2 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 18:17:02 -07:00
Larry Gritz c25cdd4eab Bump version and designate beta
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 18:01:05 -07:00
Larry Gritz 01284d3af8 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 18:01:05 -07:00
Larry Gritz c0185c1482 Rebuild PDF docs
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 15:58:50 -07:00
Larry Gritz 93866b7c77 Deal with deprecated bit_cast function in OIIO 2.5 (#1569)
Today's branching of OIIO 2.4 and subsequent changing of its master
branch to think it's "2.5" seems to have triggered an automatic fuse
that annotates a particular function in OIIO as deprecated for version
2.5 and beyond. OSL was still calling the old version, so some
immediate changes are necessary to call the correct new name when
using a new OIIO.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 15:58:50 -07:00
Larry Gritz e278f4c24a Deal with deprecated bit_cast function in OIIO 2.5 (#1569)
Today's branching of OIIO 2.4 and subsequent changing of its master
branch to think it's "2.5" seems to have triggered an automatic fuse
that annotates a particular function in OIIO as deprecated for version
2.5 and beyond. OSL was still calling the old version, so some
immediate changes are necessary to call the correct new name when
using a new OIIO.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 15:32:42 -07:00
Larry Gritz d9db605bed Make sure all clang-format changes are in .git-blame-ignore-revs (#1568)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 12:21:10 -07:00
Larry Gritz 365f2c4b2b Sonar static analysis improvements (#1567)
* Exclude osltoy from coverage analysis, since we don't have a way to
  run it from CI
* Run batch shading for analysis to get better code coverage
* llvm_gen_select: extra check that we can't overrun memory of cond[]

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-31 16:56:19 -07:00
Larry Gritz ac59af9bd1 Make sure all clang-format changes are in .git-blame-ignore-revs (#1568)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-31 16:55:48 -07:00
Larry Gritz 13d2c1914f New closure docs (#1564)
* Change the languagespec to document the new MaterialX-synchronized
  closures.

* Document the old ones as "deprecated" -- still supported for 1.x but
  assumed to be on the slate for removal in OSL 2.x.

* Change stdosl.h so that the new closures, instead of being seen only
  if MATERIALX_CLOSURES is defined, to being enabled by default, but
  (for now) can be disabled if NO_MATERIALX_CLOSURES is defined.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-31 14:23:23 -07:00
Larry Gritz 61d10d6aaf CI: test against python 3.10, gcc 12, latest fmt, update INSTALL (#1565)
Mostly, updating the "latest versions" test to the current latest
versions.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-31 14:23:09 -07:00
Larry Gritz 9d5d6203b9 New closure docs (#1564)
* Change the languagespec to document the new MaterialX-synchronized
  closures.

* Document the old ones as "deprecated" -- still supported for 1.x but
  assumed to be on the slate for removal in OSL 2.x.

* Change stdosl.h so that the new closures, instead of being seen only
  if MATERIALX_CLOSURES is defined, to being enabled by default, but
  (for now) can be disabled if NO_MATERIALX_CLOSURES is defined.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-31 14:22:06 -07:00
Larry Gritz 1a66a2b8dd CI: test against python 3.10, gcc 12, latest fmt, update INSTALL (#1565)
Mostly, updating the "latest versions" test to the current latest
versions.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-31 14:21:08 -07:00
Chris Hellmuth 3b97ecef47 Generate deterministic ptx for OptiX cache hits (#1566)
Removing the suffix ids and callseq comments generated by global counters
leads to deterministic ptx in a multithreaded environment.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2022-08-30 10:56:55 -07:00
Larry Gritz 3601a3fd1c Simplify clang-format call now that we include virtually everything (#1562)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-29 09:30:54 -07:00
Larry Gritz 2d6210a893 Sonar warning fixes and improvements (based on #1563)
* Minor changes to fix a couple more warnings given by SonarCloud
  static analysis.

* Get the code coverage enabled, it wasn't running properly.

* testrender: allow secret TESTRENDER_AA to override command line --aa

* runtest.py: allow secret OSL_TESTSUITE_SKIP_DIFF to force skipping
  the reference comparison step.

* For analysis run, set TESTRENDER_AA=1 to keep the tests from being
  prohibitively expensive, and OSL_TESTSUITE_SKIP_DIFF=1 to keep it
  from failing because the aa=1 images are different.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-29 09:30:54 -07:00
Larry Gritz 26e8da310b Fix OptiX + clang14 issue with duplicate symbols (#1561)
We had been using clang/llvm 12 and when trying out 14 I started
getting test failures with OptiX complaining about duplicate
symbols. They all seemed to be the things we declared as
OSL_CONSTANT_DATA. It looks like there's a difference in llvm 12 vs 14
in how the generated PTX marks its symbol visibility.

The solution (thanks to a clever suggestion by Alex Conty) was just to
enclose those declarations in anonymous namespaces. Works like a
charm!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-29 09:30:54 -07:00
Larry Gritz 07b2d9fb15 Fix minor bugs and warnings uncovered by SonarCloud (#1556)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 23:26:22 -07:00
Larry Gritz 6c06652cfd Fixes needed to support OptiX 7.4 (#1559)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 23:25:14 -07:00
Larry Gritz ed5b5a2a0c Simplify clang-format call now that we include virtually everything (#1562)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 12:52:48 -07:00
Larry Gritz 37cbab5bad Sonar warning fixes and improvements (#1563)
* Minor changes to fix a couple more warnings given by SonarCloud
  static analysis.

* Get the code coverage enabled, it wasn't running properly.

* testrender: allow secret TESTRENDER_AA to override command line --aa

* runtest.py: allow secret OSL_TESTSUITE_SKIP_DIFF to force skipping
  the reference comparison step.

* For analysis run, set TESTRENDER_AA=1 to keep the tests from being
  prohibitively expensive, and OSL_TESTSUITE_SKIP_DIFF=1 to keep it
  from failing because the aa=1 images are different.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 12:52:07 -07:00
Larry Gritz 11127b72b5 Fix OptiX + clang14 issue with duplicate symbols (#1561)
We had been using clang/llvm 12 and when trying out 14 I started
getting test failures with OptiX complaining about duplicate
symbols. They all seemed to be the things we declared as
OSL_CONSTANT_DATA. It looks like there's a difference in llvm 12 vs 14
in how the generated PTX marks its symbol visibility.

The solution (thanks to a clever suggestion by Alex Conty) was just to
enclose those declarations in anonymous namespaces. Works like a
charm!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-27 15:47:47 -07:00
Larry Gritz d5d87f1e64 More detailed messages when encountering failed OptiX calls (#1560)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-26 18:22:54 -07:00
Larry Gritz fa6f228b87 Fix minor bugs and warnings uncovered by SonarCloud (#1556)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-26 14:01:05 -07:00
Larry Gritz 4ee62cd2ef clang-format: the very last piece of the puzzle (#1555)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-26 13:45:47 -07:00
Larry Gritz 21f1a2f47e Fixes needed to support OptiX 7.4 (#1559)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-24 11:34:17 -07:00
Larry Gritz 5be7c6bd4e clang-format: the very last piece of the puzzle (#1555)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-23 13:32:31 -07:00
Christopher Kulla 68c67633f5 Add missing cases for MaterilaX closure refraction index detection (#1557)
This allows the refraction index to be detected even if a medium closure
is not present. Additionally, the medium detection now traverses layer()
closures.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-23 00:07:48 -07:00
Larry Gritz 6f65f91b49 Testing: Try to fix testsuite/render-microfacet failures (#1558)
There seems to be just a teensy bit of nondeterminism or
platform-variance in this one test that we haven't tracked down the
source of yet, that moves some specular fireflies around. Smells like
maybe an uninitialized variable somewhere in testrender? Because it
doesn't happen on any other test and we haven't detected it in our
real renderer, we don't currently suspect that it's an actual error
in oslexec.

Big hack: Re-run failed "render" tests up to 5 additional times before
giving up.

This makes me feel dirty. But it makes tests pass for now. Eventually we
will find the embarrassing testrender bug that is responsible for the
occasionally different specular sampling noise.

Also slightly bump up the error tolerance for this test.

Also add one alternative that seems to frequently pop up.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-23 00:07:40 -07:00
Larry Gritz 475a109281 CI: For Mac, test python 3.9 for MacOS11, and 3.10 for MacOS12 (#1554)
This cleans up some recently-failing CI tests.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-23 00:07:28 -07:00
Christopher Kulla 9f8e92ce93 Add missing cases for MaterilaX closure refraction index detection (#1557)
This allows the refraction index to be detected even if a medium closure
is not present. Additionally, the medium detection now traverses layer()
closures.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-23 00:03:59 -07:00
Larry Gritz 4bbaca7fe5 Testing: Try to fix testsuite/render-microfacet failures (#1558)
There seems to be just a teensy bit of nondeterminism or
platform-variance in this one test that we haven't tracked down the
source of yet, that moves some specular fireflies around. Smells like
maybe an uninitialized variable somewhere in testrender? Because it
doesn't happen on any other test and we haven't detected it in our
real renderer, we don't currently suspect that it's an actual error
in oslexec.

Big hack: Re-run failed "render" tests up to 5 additional times before
giving up.

This makes me feel dirty. But it makes tests pass for now. Eventually we
will find the embarrassing testrender bug that is responsible for the
occasionally different specular sampling noise.

Also slightly bump up the error tolerance for this test.

Also add one alternative that seems to frequently pop up.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-22 14:38:27 -07:00
Larry Gritz cf1b4ef3e6 CI: For Mac, test python 3.9 for MacOS11, and 3.10 for MacOS12 (#1554)
This cleans up some recently-failing CI tests.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 22:23:16 -07:00
Larry Gritz c3e36affa8 CHANGES and other misc docs fixups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 17:16:11 -07:00
Larry Gritz 91eb43227a CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 17:15:38 -07:00
Larry Gritz 8c2a10268f CHANGES and other misc docs fixups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 00:22:29 -07:00
Larry Gritz ec8ec11cfd Fix typo error that prevented correct typecheck of ternary (#1552)
Didn't properly detect the disallowed use of arrays for the false
clause because we checked `t` twice.

Yay for static analysis!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 00:22:29 -07:00
Larry Gritz 61bb9ac11e Fix spelling
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 00:22:29 -07:00
Larry Gritz e9a614ba53 Bump patch level 2022-08-19 19:10:20 -07:00
Larry Gritz d57a462462 GPU string fix -- needed missing cast (#1553)
Fix slightly incorrect code generation when getting a string address
for GPU.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-19 14:21:57 -07:00
Larry Gritz ac114aded4 Fix typo error that prevented correct typecheck of ternary (#1552)
Didn't properly detect the disallowed use of arrays for the false
clause because we checked `t` twice.

Yay for static analysis!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-14 22:08:51 -07:00
Larry Gritz 74fc27de12 Try to enable Sonar Cloud static analysis (#1551)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-12 08:25:13 -07:00
Larry Gritz bd7d138f04 Spell check comments (#1550)
Yay for "codespell"

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-04 17:31:51 -07:00
Larry Gritz 38015b6be2 Another round of clang-format (#1540)
* Another round of clang-format

* Bump the standard clang-format we use for CI from clang11 to clang14.
  This will make some minor additional changes.

* Due to a mismatched target name, we weren't actually checking the
  formatting in CI on all the files we thought we were, and therefore
  not assuring that certain code was correctly formatted. So there is
  some fixup needed, which is included here.

* And a bunch of files we didn't try to do before, either.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-04 17:05:36 -07:00
Alejandro Conty d42c5d3e1d Switch testrender to cone tracing (#1543)
The idea is to stop propagating derivs through BSDFs, which we
never did properly. Instead we trace rays with radius + spread,
which we turn into OSL derivs in SG when we hit a surface. Then
when bouncing off a surface we use the BSDF roughness to set the
spread. In addition we also:

  * Return BSDF samples/eval as a small struct Sample(). This
    avoids output parameters in the methods.
  * Stop passing a full ShaderGlobals to the BSDF methods. Pass
    a viewing direction wo instead so they could run in a simpler
    context.

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2022-08-03 23:25:09 -07:00
Larry Gritz 826b6767c9 Spell check comments (#1550)
Yay for "codespell"

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-03 20:44:27 -07:00
Larry Gritz 89d5db2b5c Another round of clang-format (#1540)
* Another round of clang-format

* Bump the standard clang-format we use for CI from clang11 to clang14.
  This will make some minor additional changes.

* Due to a mismatched target name, we weren't actually checking the
  formatting in CI on all the files we thought we were, and therefore
  not assuring that certain code was correctly formatted. So there is
  some fixup needed, which is included here.

* And a bunch of files we didn't try to do before, either.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-03 10:05:33 -07:00
Alejandro Conty 1dd33050da Switch testrender to cone tracing (#1543)
The idea is to stop propagating derivs through BSDFs, which we
never did properly. Instead we trace rays with radius + spread,
which we turn into OSL derivs in SG when we hit a surface. Then
when bouncing off a surface we use the BSDF roughness to set the
spread. In addition we also:

  * Return BSDF samples/eval as a small struct Sample(). This
    avoids output parameters in the methods.
  * Stop passing a full ShaderGlobals to the BSDF methods. Pass
    a viewing direction wo instead so they could run in a simpler
    context.

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2022-08-02 10:56:07 -07:00
Larry Gritz 162b355bc8 Testing: Adjust comparison thresholds to account for platform diffs (#1549)
Also fix a CI test label -- we had a duplicate.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-02 13:10:08 -04:00
Christopher Kulla d383680521 Implement MaterialX medium closure and use it to drive the refraction closures (#1547)
This simplifies the logic around the ior which drives reflection/transmission (fresnel effect)
from the ior which drives refraction (and total internal reflection). Setting both iors equal to each other
gives the expected physical behavior.

Also tweak the bsdf constructor to support variadic arguments which simplifies a bunch of code.

Add a new test to validate the refractive version of generalized_schlick_bsdf.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-02 13:10:03 -04:00
Christopher Kulla 95ed032dcd Add furnace tests for MaterialX closures (#1542)
Implement get_albedo for the sheen closure, based on fit derived by the MaterialX team

Add optional mode to testrender to visualize the result of the get_albedo method. This can be useful for validation of the get_albedo method.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-02 13:06:27 -04:00
Larry Gritz 0879638dda Testing: Adjust comparison thresholds to account for platform diffs (#1549)
Also fix a CI test label -- we had a duplicate.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-02 09:46:35 -07:00
Christopher Kulla 8a7b9b96ba Implement MaterialX medium closure and use it to drive the refraction closures (#1547)
This simplifies the logic around the ior which drives reflection/transmission (fresnel effect)
from the ior which drives refraction (and total internal reflection). Setting both iors equal to each other
gives the expected physical behavior.

Also tweak the bsdf constructor to support variadic arguments which simplifies a bunch of code.

Add a new test to validate the refractive version of generalized_schlick_bsdf.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-02 06:09:25 -07:00
Christopher Kulla 23ea0644f8 Add furnace tests for MaterialX closures (#1542)
Implement get_albedo for the sheen closure, based on fit derived by the MaterialX team

Add optional mode to testrender to visualize the result of the get_albedo method. This can be useful for validation of the get_albedo method.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-01 15:25:31 -07:00
Larry Gritz 0c5544e4dc Increase error threshold for tests (#1546)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-01 10:47:51 -04:00
Christopher Kulla 54844fe68d Implement microfacet based MaterialX closures (#1541)
* Implement reflective microfacet based MaterialX closures

Add test cases for dielectric, conductor and generalized schlick closures

Signed-off-by: Chris Kulla <ckulla@gmail.com>

* Implement refraction case in microfacet closures

Signed-off-by: Chris Kulla <ckulla@gmail.com>

* Update reference images

Signed-off-by: Chris Kulla <ckulla@gmail.com>

* Relax diff threshold on render tests

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-01 10:47:43 -04:00
Larry Gritz bd6d856b0e Increase error threshold for tests (#1546)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-01 07:46:26 -07:00
Christopher Kulla 6424177e3a Implement microfacet based MaterialX closures (#1541)
* Implement reflective microfacet based MaterialX closures

Add test cases for dielectric, conductor and generalized schlick closures

Signed-off-by: Chris Kulla <ckulla@gmail.com>

* Implement refraction case in microfacet closures

Signed-off-by: Chris Kulla <ckulla@gmail.com>

* Update reference images

Signed-off-by: Chris Kulla <ckulla@gmail.com>

* Relax diff threshold on render tests

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-08-01 07:09:28 -07:00
Larry Gritz 760561d74e Label ci jobs better (#1545)
This was resulting in confusing artifact names for the Intel compiler
cases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-31 19:32:28 -04:00
Larry Gritz 354eb8576c Fix error message for texture-errormsg test (#1544)
It printed the u,v coordinates where the error was first discovered.
This is not necessarily deterministic, of course!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-31 19:32:22 -04:00
Larry Gritz 0b92d2b03b Label ci jobs better (#1545)
This was resulting in confusing artifact names for the Intel compiler
cases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-31 16:29:58 -07:00
Larry Gritz bf04610296 Fix error message for texture-errormsg test (#1544)
It printed the u,v coordinates where the error was first discovered.
This is not necessarily deterministic, of course!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-30 04:32:56 -07:00
Adrien Herubel a725f2b97e Layer closure implementation in testrender (#1538)
* Add support for layer closure with dielectric reflections as top layers, and a test with nested layer closures

* Add support for sheen in the layer closure

Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-24 14:28:57 -07:00
Adrien Herubel ff9560f401 Layer closure implementation in testrender (#1538)
* Add support for layer closure with dielectric reflections as top layers, and a test with nested layer closures

* Add support for sheen in the layer closure

Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-24 14:27:56 -07:00
Adrien Herubel 29e8d0bf50 Missing documentation for the exponent parameter in the generalized_schlick_bsdf, and missing storage for the parameter (#1539)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-24 11:31:19 -07:00
Adrien Herubel e0d6a21438 Missing documentation for the exponent parameter in the generalized_schlick_bsdf, and missing storage for the parameter (#1539)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-24 11:29:40 -07:00
Christopher Kulla 422c0966a6 Implement MaterialX closure sheen_bsdf (#1537)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-22 18:15:28 -07:00
Christopher Kulla 9b706d30bf Implement MaterialX closure burley_diffuse_bsdf (#1536)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-22 18:15:23 -07:00
Christopher Kulla ceda8c0d23 Implement basic support for MaterialX closures in testrender (#1533)
* Extend the bsdf interface in testrender to use Color3 instead of float in preparation for MaterialX closures which are almost all tinted

  * Add stub parameters and IDs for all MaterialX closures

  * Register all MaterialX closure types

  * Implement most MaterialX closures, reusing the existing implementations for now

This commit is mainly intended to do the busy work of adding the new closures, no new BSDFs are actually implemented yet. This means that some of
the closures are handled in a very rudimentary way, ignoring some key parameters. The intent is to improve support for these over time.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-22 18:15:16 -07:00
Christopher Kulla b561a67ad1 Modernize sampler in testrender (#1534)
The sampler implementation in testrender was very close to the 2020 article from Brent Burley. This patch
catches up to best practices, including a faster owen scrambler from Nathan Vegdahl and recognizing that
the index scrambling can be achived by the same owen scrambler method (which saves a bunch of logic and runs
faster). Finally, avoid the redundant bit reversals and use compiler intrinsics when available to benefit
from hardware instructions (for ARM or GPUs). Finally the integer hash constants were updated to the latest
from the hash prospector project.

While more optimizations are certainly possible, this is a reasonable balance between quality and speed.

Update reference images for new sampler

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-22 18:15:10 -07:00
Larry Gritz 4e34e8dd20 Mark DCO task as long since done (#1532)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-22 18:14:46 -07:00
Christopher Kulla da794de6fd Implement MaterialX closure sheen_bsdf (#1537)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-20 14:12:46 -07:00
Christopher Kulla a1e941c43b Implement MaterialX closure burley_diffuse_bsdf (#1536)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-20 10:52:55 -07:00
Christopher Kulla 3bb41960fd Implement basic support for MaterialX closures in testrender (#1533)
* Extend the bsdf interface in testrender to use Color3 instead of float in preparation for MaterialX closures which are almost all tinted

  * Add stub parameters and IDs for all MaterialX closures

  * Register all MaterialX closure types

  * Implement most MaterialX closures, reusing the existing implementations for now

This commit is mainly intended to do the busy work of adding the new closures, no new BSDFs are actually implemented yet. This means that some of
the closures are handled in a very rudimentary way, ignoring some key parameters. The intent is to improve support for these over time.

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-19 09:05:20 -07:00
Christopher Kulla 95fa78d3fd Modernize sampler in testrender (#1534)
The sampler implementation in testrender was very close to the 2020 article from Brent Burley. This patch
catches up to best practices, including a faster owen scrambler from Nathan Vegdahl and recognizing that
the index scrambling can be achived by the same owen scrambler method (which saves a bunch of logic and runs
faster). Finally, avoid the redundant bit reversals and use compiler intrinsics when available to benefit
from hardware instructions (for ARM or GPUs). Finally the integer hash constants were updated to the latest
from the hash prospector project.

While more optimizations are certainly possible, this is a reasonable balance between quality and speed.

Update reference images for new sampler

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-18 23:22:51 -07:00
Larry Gritz eff3dede3a Mark DCO task as long since done (#1532)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-18 08:53:45 -07:00
Larry Gritz 7b4c7cffd7 GPU string overhaul (#1531)
* GPU string overhaul

Big string cleanup, yet again, for GPU. We still had this tricky
double indirection happening with strings for OptiX -- the string was
a pointer to a "global", which in turn held the hash. No, throw all
that out.  Just directly store strings as the ustring hash on
OptiX. No extra indirection. Many fewer differences between how things
are handled on OptiX versus CPU (except for the fact itself that the
"string" holds the hash rather than the char*).

Some details worth noting:

* LLVM_Util loses "type_string()" and calls it "type_ustring()" to
  emphasize it's the type we're using to represent a ustring, and
  definitely not a C or C++std string. Also, LLVM_Util itself now lets
  the caller tell it whether it prefers that the representation of a
  ustring be the charptr or the hash, and then handles most of the
  details internally. The BackendLLVM, then, makes that decision early
  on, charptr for CPU and hash for GPU.

* Several more spots in LLVM_Util and BackendLLVM have been plumbed to
  pass around llvm IR SSA variable names to try to make the resulting
  LLVM IR more readable when I'm trying to debug it. (This was
  strictly debugging scaffalding aid for me, but comes along for the
  ride because it's useful to keep.) I also added a
  BackendLLVM::llnamefmt to format strings, which only does the
  formatting when the shading system knows it's going to save the IR
  for inspection, and otherwise (that is, in production) it does not
  do the string formatting or pass the names along, so it's not doing
  all that string manipulation when no human is going to be looking at
  the IR dumps.

* A lot of clunky OptiX-only code disappears.

* Some side effects of my reducing complexity of the IR as I debugged:
  there were times we were generating redundant pointer casting in the
  IR, such as grabbing a pointer, then casting it to a void*, then
  casting back to some other kind of pointer. In some cases I reduced
  that quite a bit. Again, this was mostly just a scramble to make the
  IR more readable while I debugged, but it probably has a minor
  performance gain as well since it reduced somewhat the sheer amount
  of IR we generate and pass to the optimizer and JIT.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

* Remove register_string entirely from RendererServices

Signed-off-by: Larry Gritz <lg@larrygritz.com>

* Remove more register_string remnants

Signed-off-by: Larry Gritz <lg@larrygritz.com>

* comment typo

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-13 08:36:12 -07:00
Adrien Herubel 905058ee13 Fix permission error and build errors when running serialize-bc.py on Linux (#1527)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-06 08:56:52 -07:00
Adrien Herubel 8281721bde Fix permission error and build errors when running serialize-bc.py on Linux (#1527)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-06 08:55:50 -07:00
Larry Gritz d3e443b766 Security policy fixes (#1529)
* Set up a SECURITY.md explaining how to confidentially report
  vulnerabilities.

* Create scorecards.yml workflow to run OSSF scorecard to check supply
  chain security issues.

* Use exact SHA's for actions versions to guard against hijacked
  actions repos that might try to substutite something else at the
  version tag we use.

* Make sure actions we use don't get write perms on our repo.

* Tried to use harden-runner action to ensure no actions on the runner
  overwrite source code or have unauthorized outgoing net connections
  during the GHA run, but currently leaving it disabled because of too
  many false positives -- it flags every dependency download as a case
  of altering source code. Which it technically is, but it doesn't
  matter for any jobs that aren't producing any artifacts that will be
  consumed or relied on by users.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-30 23:13:39 -07:00
Larry Gritz 2ece55aa97 Security policy fixes (#1529)
* Set up a SECURITY.md explaining how to confidentially report
  vulnerabilities.

* Create scorecards.yml workflow to run OSSF scorecard to check supply
  chain security issues.

* Use exact SHA's for actions versions to guard against hijacked
  actions repos that might try to substutite something else at the
  version tag we use.

* Make sure actions we use don't get write perms on our repo.

* Tried to use harden-runner action to ensure no actions on the runner
  overwrite source code or have unauthorized outgoing net connections
  during the GHA run, but currently leaving it disabled because of too
  many false positives -- it flags every dependency download as a case
  of altering source code. Which it technically is, but it doesn't
  matter for any jobs that aren't producing any artifacts that will be
  consumed or relied on by users.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-30 17:23:39 -07:00
Larry Gritz d860eae924 Allow naming of llvm symbols for many ops (#1530)
Most LLVM API IR calls that generate ops allow an optional name of the
llvm symbol that will hold the result of the operation. By default, it
will make one up, such as "%37", "%38", etc. Needless to say, these
are difficult to understand when reading volumes of IR dumped for
debugging purposes.

So in this patch, I'm starting to expose the ability for our own code
to pass names through our wrapper functions. I needed this for some
deep debugging.

I haven't instrumented the entire set, just trying it on for some of
the specific areas I needed to debug. But this is a useful first step.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-30 16:23:13 -07:00
Larry Gritz 88c471a315 Allow naming of llvm symbols for many ops (#1530)
Most LLVM API IR calls that generate ops allow an optional name of the
llvm symbol that will hold the result of the operation. By default, it
will make one up, such as "%37", "%38", etc. Needless to say, these
are difficult to understand when reading volumes of IR dumped for
debugging purposes.

So in this patch, I'm starting to expose the ability for our own code
to pass names through our wrapper functions. I needed this for some
deep debugging.

I haven't instrumented the entire set, just trying it on for some of
the specific areas I needed to debug. But this is a useful first step.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-30 16:03:53 -07:00
Adrien Herubel 71a518e9a5 Remove unwanted characters causing compilation errors in the MaterialX closure definitions (#1528)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-06-24 11:16:40 -07:00
Adrien Herubel 11afddc8da Remove unwanted characters causing compilation errors in the MaterialX closure definitions (#1528)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-06-24 11:15:59 -07:00
Larry Gritz f7cac87979 Remove OptiX 6 support (#1524)
This makes OptiX 7.0 the minimum version we accept, and greatly
simplifies a lot of code we were separately maintaining for 6 and 7.

This will go into main AFTER the release branch for 1.12 is split off.
The dropping of OptiX 6 will be a 1.13 (or whatever we call it) change.

Don't build the optix modules at all when not USE_OPTIX.
Totally remove stringtable.
Other simplifications stemming from these.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-20 16:18:40 -07:00
Larry Gritz 5401e8417b Bump version to 1.13 after branching for 1.12 (#1523)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-20 11:14:38 -07:00
Larry Gritz 2bbd6610c8 Remove confusing licensing comment (#1521)
The implementation of simplex noise we've been using is public domain,
but looks like when we pasted the license notice into our repo, there
was one stray sentence (probably left over from an earlier license
scheme Stefan Gustavson used?) that makes reference to GPL. But the
software and its repo are NOT -- it's very clear that it's public
domain: https://github.com/stegu/perlin-noise/blob/master/LICENSE.md

So remove this confusing sentence.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-20 11:13:23 -07:00
Larry Gritz 5bcee23e34 Branch for eventual release, call it alpha (#1522)
Aiming to declare a stable beta soon and release circa SIGGRAPH.

Primarily, this branch is to allow us to continue changing main in
ways that would be destabilizing before the release.
New things that go in main that are risk or break compatibility
will not be backported to this new branch.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-20 11:10:51 -07:00
Larry Gritz c61a85e217 Remove confusing licensing comment (#1521)
The implementation of simplex noise we've been using is public domain,
but looks like when we pasted the license notice into our repo, there
was one stray sentence (probably left over from an earlier license
scheme Stefan Gustavson used?) that makes reference to GPL. But the
software and its repo are NOT -- it's very clear that it's public
domain: https://github.com/stegu/perlin-noise/blob/master/LICENSE.md

So remove this confusing sentence.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-20 11:09:01 -07:00
Larry Gritz 08cda36387 Fix recent ArgParse change (#1520)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-15 10:11:41 -07:00
Larry Gritz caa8a2d252 Change OSL's ArgParse use to the modern syntax (#1519)
We'd been waiting until the minimum OIIO requirement was high enough
to include support for the newer syntax.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-10 11:15:17 -07:00
Larry Gritz 21eac9d921 Revert some formatting (#1518)
In a few of my big clang-format revisions, I was over-zealous, and did
not realize that I was making the command line option parsing unreadable.
Revert those secions.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-08 11:26:58 -07:00
Larry Gritz d75384da6d ci: Bump OpenColorIO for 'latest' tests (#1516)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-05 22:05:49 -07:00
Larry Gritz 008907161d Typo fix in assertions (#1517)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-05 22:05:11 -07:00
Larry Gritz 102430c835 style: more clang-format (#1515)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-05 20:44:35 -07:00
Larry Gritz ce0e6e1d4f Regularize output formatting to avoid per-platform discrepancies (#1514)
Recent OIIO and fmt changes slightly changed this one place's output
with some version/platform combinations. Also make it match exactly
between the example-deformer and example-batch-deformer tests.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-05 19:05:09 -07:00
Larry Gritz 8c6ffdd911 More clang-format (#1512)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-05 12:37:05 -07:00
Larry Gritz a5a8f9d745 Fix incorrect m44*v4 in vector4.h (#1513)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-03 09:27:51 -07:00
Larry Gritz 1c715483b4 Adjust string formatters after change in fmt master (#1510)
fmt master seems to have just deprecated the default ability of
fmt::sprintf("%s") to printing anything that allows stream
output. This breaks use of Strutil::sprintf formatting of ustrings.

This isn't yet in any tagged release of fmtlib, but I'm trying to get
ahead of it.

The quick fix is to just change those handful of places that still use
sprintf convention with nonstandard types to use std::format style
calls, which we are slowly converting to anyway. (And maybe a couple
other spots while I was at it.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-25 22:39:41 -07:00
Larry Gritz 08706b7cba More clang-format (this time, testrender and liboslnoise) (#1511)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-25 21:52:04 -07:00
Larry Gritz c1045f2c28 clang-format
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-22 00:00:36 -07:00
Alex Wells 46d451ce74 Turn on clang-format
Signed-off-by: Alex Wells <alex.m.wells@intel.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-22 00:00:36 -07:00
Tim Grant 1c57fc61d8 clang-format
Signed-off-by: Tim Grant <tgrant@nvidia.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-22 00:00:36 -07:00
cmstein e56851056d clang-format
Signed-off-by: cmstein <cstein@imageworks.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-22 00:00:36 -07:00
Larry Gritz 28399fefc8 Add files to the clang-format list
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-16 12:42:28 -07:00
Larry Gritz 7f2e83794e clang-format (general)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-16 12:42:28 -07:00
sfriedmapixar 1f73b075c9 clang-format
Signed-off-by: sfriedmapixar <sfriedma@pixar.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-16 12:42:28 -07:00
Alex Wells b4026fd169 Turn on clang-format
Signed-off-by: Alex Wells <alex.m.wells@intel.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-16 12:42:28 -07:00
Larry Gritz efeb577933 More printf -> fmt conversion (#1506)
Banish the last of the sprintf calls (except the handful that need
to be there, because such formatting is still supported in shaders
themselves, so something needs to understand them).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-13 13:34:22 -07:00
Larry Gritz fdd8ff04a3 Constant folding of startswith() (#1507)
We have constant folded endswith() for a long time. Dunno why we
overlooked startswith, but here it is.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-12 22:47:03 -07:00
Larry Gritz 89cc2374c7 More conversion of old printf style to std::format style (#1504)
Another semi-random collection of conversions. Bit by bit.

These are all internals, none of it involves public interfaces.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-11 11:12:45 -07:00
Larry Gritz 5fc4ee50f6 A couple tweaks in how we build OIIO for OSL's CI (#1505)
* Use unity build to speed up OIIO build (for sufficiently new OIIO).
* Build OIIO with STOP_ON_WARNING=OFF, so that if a compiler upgrades
  and makes new warnings for OIIO, that doesn't break OSL's CI build.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-11 08:03:17 -07:00
sfriedmapixar d8a9993f63 Batched closures (#1500)
Add support for closures to the batched interface.

The renderer interface for closures, including registering
and processing them remains unchanged.

The Ci variable in BatchedShaderGlobals has moved from
the uniform portion to the varying portion, which may
require changes to any renderer code that was utilizing
the BatchedShaderGlobals.

To utilize closures with the batched interface, you register
the closures per usual, then once shading has finished,
the Ci in BatchedShaderGlobals will contain an Block of pointers
to the roots of a closure trees that can be processed
independently just like in the normal single-point interface.

This initial implementation is largely functional, however,
there may be more optimization gains available in the code
that copies the run-time SIMD values and scatters them
to the separate closure-data locations.

One remaining un-implemented feature is passing
_closures_ via get/setmessage() when using the batched
shading interface, and the locations where that would
need to be implemented are marked in the source.

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>

* Address batched closures review comments:
* Remove unneded Block specializations for pointers.
* Rename null variable to null_value.
* remove a 0 default param to rop.llvm_void_ptr in batched_llvm_gen.cpp:llvm_gen_mul
* Optimizations to masking and loading in wide_opclosure.cpp
* Fix LLVM11+ builds by using llvm_vecor_type instead of llvm::VectorType::get

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>

* Remove unneeded oslclosure.h in wide.h now that we aren't explicitly instantiating the templates.

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2022-05-11 07:11:20 -07:00
Larry Gritz 96fe1eff44 CHANGES and bump version in advance of next developer preview
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-10 22:15:26 -07:00
Larry Gritz 033dae3772 CI: adjust to upgrading Intel Clang compiler to 2022.1.0 (#1501)
The Intel OneAPI LLVM-based C++ compiler, as we download it from Intel
for our CI, bumped from 2022.0.0 to 2022.1.0.

New warning popped up -- newest Intel LLVM-based compiler warns about
overriding certain floating point math flags.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-09 22:56:14 -07:00
Christopher Kulla 5efe15a79e Windows build fixes for recent free function render services (#1502)
* Fix warnings from stdint on windows by pre-including the standard header

* Make sure register_JIT_Global is a public symbol since it needs to be called by client code

* Fix how llvm-as, llvm-link and python are invoked by cmake so they can be properly found on Windows platforms

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-05-09 16:03:51 -07:00
Larry Gritz 3d00dbcd55 More conversion of internals to std::format style, bit by bit (#1493)
There's no rhyme or reason to this particular set of changes... I just
picked a few files and did the obvious conversion. Will do more in
subsequent PRs.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-04 09:45:06 -07:00
Larry Gritz 10b72648a8 CI: add a test that builds with clang14 (#1498)
A few minor changes were needed to address new warnings.

clang14 warns if you use bitwise `|` or `&` in an `if`, but there are
some places where we do that purposely to avoid branches.
Disable clang14 warnings about bitwise ops for all of liboslexec.

Also some batch shading related vectorized loops fail to vectorize
with clang14 -- though they worked fine with clang12 -- and so we
needed to mark those as "complex" SIMD loops. Is this a regression
with clang14?

Revise simd loop pragma for wide_transformc due to llvm14 regression

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-03 22:43:35 -07:00
Steena Monteiro e5dd190874 rs_free_function (#1494)
In order to move towards shader execution on devices, we need to replace
host side interactions with new concepts that can exist on the device (or host).
The current virtual function based RendererServices exemplifies this dependency
on host side objects.

To break the dependency we introduce free function based renderer services (rs_free_function.h)
To simplify its introduction, we only added the renderer service free functions required by opmatrix.cpp.
Goal is to have a single opmatrix that can be compiled for host or device (eventually).
Renderers can provide llvm bitcode representation of their renderer service
free functions to the ShadingSystem.  During shader compilation/JIT the
renderer's bitcode is combined with opmatrix.cpp bitcode along with the JIT'd shader network.
The idea is the combined LLVM IR representation can then be lowered to the target
(be it on the host or device[SPIRV|PTX]).  Thus a renderer's free function implementation can be shared.

opmatrix.cpp now only calls the free functions (not virtual RendererServices).
However liboslexec on the host contains an rs_fallback.cpp which forwards
calls through the existing virtual RendererServices for seamless compatibility
when a renderer does not provide bitcode for the renderer services.

Testshade has been modified to optionally to provide rs_bitcode,
utilizing a new Cmake macro, EMBED_LLVM_BITCODE_IN_CPP, to turn rs_simplerend.cpp (the free function implementation)
into bitcode.

Free functions can be enabled via --use-rs-bitcode flag in testshade.

Free functions need access to RenderState values because they lack a this
pointer like the RendererServices virtual methods have. Added a RenderState
containing minimal set of values required by free functions.
Testshade/SimpleRenderer is responsible for setting RenderState values.

Added ShadingSystem attribute rs_bitcode to hold renderer services free function bitcode (provided by the renderer)

Renderers using global variables (like ustring's) not in strdecls.h must register their global variables' addresses
using OSL::register_JIT_Global (const char *global_var_name, void *global_var_addr).
This is necessary for the JIT process to resolve global variables that are embedded in RendererServices bitcode.
A validation step occurs that emits an error with a list of unmapped global variables.

RendererServices can reference strings with the STRING_PARAM(varname) macro.
By default, STRING_PARAM(varname) works for any string in strdecls.h.
For any string NOT in strdecls.h, it will map to a global variable with a prefix of "RS_".
For example, STRING_PARAM(raster) maps to a global ustring RS_raster.
NOTE:  C linkage with a "RS_" prefix is used to allow for unmangled
non-colliding global symbol names, so its easier to pass them to
OSL::register_JIT_Global(name, addr) for host execution
NOTE:  the STRING_PARAMS macro adapts to OSL_HOST_RS_BITCODE macro
to utilize the RS_ prefix.  RS_ prefixed versions of all OSL::Strings
intances have been created by rs_free_function.h, so the same STRING_PARAMS
macro can be used for renderer service or OSL strings.
NOTE:  We expect the handling of strings to change in the future possibly being replaced by Handles entirely

It is the renderer's responsibility to instantiate any NEW ustring global variables with the proper RS_ prefix;
It is the renderer's free function implementation to import/extern any of these NEW global variables with the proper RS_ prefix;
For testshade, a rs_strdecls.h has been added and is utilized to instance the RS_ global variables and register their addresses with OSL in simplerend.cpp.
rs_strdecls.h is also used by rs_simplerend.cpp (free function implementation) to create the externs with the RS_ prefix.

NOTE: DO NOT instantiate global variables inside the free function renderer services, because we strip global constructors as part of the pruning process.

Added LLVM_Util::validate_global_mapping to identify unresolved globals.

Added utility macro __OSL_STRINGIFY(string_value) in oslversion.h.in so the
proper naming prefix is used and we don't have multiple implementations around.

Added liboslexec build step to produce bitcode containing OSL library functions that depend on free functions (here, opmatrix.cpp)

Added a new Cmake EMBED_LLVM_BITCODE_IN_CPP function in llvm_macros.cmake that replaces the LLVM_COMPILE macro
and provides for both linking and serializing multiple OSL cpp files.

Fixed cuda.macro to use new location of serialize-bc.py in src/build-scripts.
Fixed formatting issues.

Disabled erasing llvm.global_ctors from LLVM module because of issues on MacOS Apple Clang.
Left as future work.

Added better error checking for module_from_bitcode().

Signed-off-by: Steena Monteiro <steena.monteiro@intel.com>
2022-05-03 21:22:02 -07:00
sfriedmapixar 880b44620a Fix for memory error on teardown of testrender due to late destruction of shader shared pointers. (#1499)
Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2022-05-03 21:17:13 -07:00
Larry Gritz 0a55421f34 More comprehensive warnings about things that don't optimize away (#1497)
New classes of warnings triggered when enabling option "opt_warnings":

* Creation of new strings mid-shader.
* Access to the characters of strings mid-shader.

We already warned about texture access by name that could not be
turned into a handle.

In all of these cases, we only warn *after* runtime optimization, so that shader
idioms in the source code that appear to do these forbidden things will not warn
as long as they can be reduced to safe operations in the course of the runtime
optimization step.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-05-02 11:39:36 -07:00
Larry Gritz b7a87285a1 Build: cmake improvements (ported from OIIO) (#1495)
checked_find_package:

* Optional SETVARIABLES gives a list of vars to set to TRUE if the package
  is found.
* Optional DEBUG flag turns on extra debugging information about how the
  package is found.
* Optional PREFER_CONFIG uses a dependency's exported config, if available,
  rather than our Find module.
* Global ALWAYS_PREFER_CONFIG option can be set to ON to always prefer
  config over Find modules for all dependencies.

fancy_add_executable:

* -DENABLE_INSTALL_<executable>=OFF lets you turn off the installation
  of an executable.

other:

* Change the target name for doing the clang-format over the code to
  "run-clang-format", because "clang-format" is an imported target name
  of the libclang exported cmake (which we may wish to use soon).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-29 18:43:52 -07:00
Tim Grant b0d8cb82a2 OptiX matrix fixes (#1485)
* Pass some extra headers to NVCC_COMPILE to make sure that the PTX files are regenerated whenever those headers are changed.

Signed-off-by: Tim Grant <tgrant@nvidia.com>

* Don't generate PTX for rend_lib.cu when using OptiX 6.

Signed-off-by: Tim Grant <tgrant@nvidia.com>

* Fix the callable program signature for the init and group functions in the OptiX wrappers.

Signed-off-by: Tim Grant <tgrant@nvidia.com>

* Fix issues with the LLVM arguments for osl_printf when targeting CUDA.

Signed-off-by: Tim Grant <tgrant@nvidia.com>

* Fix llvm_gen_construct_triple for OptiX. The 'to' argument was not handled correctly.

Signed-off-by: Tim Grant <tgrant@nvidia.com>

* Improve support for CUDA osl_get_matrix.

Signed-off-by: Tim Grant <tgrant@nvidia.com>

* Add basic support for named transforms to testshade/testrender.

Signed-off-by: Tim Grant <tgrant@nvidia.com>
2022-04-28 23:17:11 -07:00
Larry Gritz 9cfca9397b Support for LLVM 14 (#1492)
API changes we had to take into account:
* TargetRegistry.h location
* No more DisableTailCalls field in PassManagerBuilder.

Needed to update the ref image for render-microfacet test, some sparklies changed.
Looks like the new LLVM probably JITs to ever so slightly different math code, tickling
some LSB differences that at 1 sample per pixel, results in some different sampling
directions leading to fireflies. We decided to just commit a new ref image and move on.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-27 23:55:08 -07:00
Larry Gritz a056e181c2 Fix generated OSLConfig.cmake -- wrong Imath version (#1489)
In our generated OSLConfig.cmake, we inserted a find_dependency(Imath)
that accidentally demanded the OpenEXR_VERSION (should have been
Imath_VERSION). That works fine as long as Imath version is the same
(or higher) than the OpenEXR version. But if the installed OpenEXR
version is somehow ahead of the Imath version, it will fail.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-21 13:14:43 -07:00
Larry Gritz d8000dfc2c CI: bump 'latest' openexr and pybind11 versions (#1488)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-18 18:11:26 -07:00
Larry Gritz 8feaff41fe More fmt conversion (#1490)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-18 14:59:33 -07:00
Larry Gritz 97d5337283 Some fmt conversion (#1487)
A small instalment on the long-term shift from printf-style formatting
to std::format style formatting.

Define preprocessor OSL_INTERNAL, which is defined when compiling OSL
itself, but will not be defined for downstream projects using the OSL
headers.

When building OSL, enable the symbol OIIO_ERRORHANDLER_HIDE_PRINTF,
which causes ErrorHandler methods using the old conventions to be
marked as deprecated and generate warnings.

Clean up all the calls revealed by those warnings. (And
opportunistically clean up some other things that happened to be in
the same files.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-15 18:56:35 -07:00
Brecht Van Lommel 87913529e1 Add ACES2065-1 and ACEScg as shading system color spaces (#1486)
To make functions like blackbody, wavelength and luminance work with these
color spaces.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2022-04-15 16:58:39 -07:00
Larry Gritz 4e96ab13dd Bump version for developer snapshot v1.12.4.5
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-08 15:40:50 -07:00
Larry Gritz 2e1c0a95c2 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-08 14:41:07 -07:00
Christopher Kulla 096fab8da7 Fix minor warnings about pointer casts on windows (#1484)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-04-08 12:34:31 -07:00
Christopher Kulla aeba1f2db4 Add Visual Studio Code folder to gitignore (#1483)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-04-08 11:23:07 -07:00
Larry Gritz 7e34ce27c7 Hide Matrix22 definition better -- it's not part of any public API (#1480)
Also change the one exception mentioned to a std one, matching
Imath 3.x and insulating us from any of the old Iex custom exceptions
from Imath 2.x.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-04-01 16:38:24 -07:00
Larry Gritz 8589d4dd7b CHANGES and bump version for developer snapshot v1.12.4.4
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-28 18:46:49 -07:00
Larry Gritz 20bcc714b9 Fix GPU codegen crash (#1479)
llvm_load_device_string wasn't considering temporary string variables,
only declared local variables.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-28 18:22:22 -07:00
Larry Gritz a1dc6d7c87 Print all 4 version numbers in help messages (#1477)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-28 13:24:27 -07:00
Larry Gritz e493510d81 Add Alex Wells to TSC, per recent vote (#1478)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-22 16:47:48 -07:00
Larry Gritz 9b3f15b170 Fixes for recent OIIO TextureSystem API changes (#1476)
Changed a function signature in OIIO master that threw us off here
just a tad, as there was no direct type conversion the compiler could
figure out on its own. Easy adjustment gives it the right hint.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-15 16:51:03 -07:00
Larry Gritz 8c52d48965 Convert osof() to oslfmt() using the std::format convention (#1470)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-10 09:05:12 -08:00
Larry Gritz 9b33a7af3b CI: refactor ci.yml to use strategy matrix (#1474)
This eliminates a huge amount of redundancy in our CI descriptions --
instead of the entire CI logic replicated for each test in its own
universe, we group tests into (a) all the ones based on ASWF VFX
Platform containers, (b) non-VFXP-year oddballs run on Ubuntu, (c) Mac
tests, (d) clang-format verification. Each has the build logic
expressed once, and a short list of variables that change for each
individual test of that category.

This organization is much easier to read, maintain, modify tests, or
add new test variants, and cuts the size of the ci.yml file by over 50%.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-09 21:40:25 -08:00
Alex Wells 2a186f8bc4 Enable icx compiler to vectorize OSL_OMP_COMPLEX_SIMD_LOOP (#1475)
Avoid many clang vectorization workarounds for OSL_INTEL_LLVM_COMPILER_VERSION
Added Makefile option VEC_REPORT to turn on generation of optimization reports
Reduce impact of REQUIRE_INF_NAN for icx by explicitly honoring inf, nan, and signed zeros vs. disabling fast-math

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-03-09 16:38:14 -08:00
Alex Wells 2ab1c5e322 CI: Add icx test, and other changes to support it (#1473)
Add compiler support for Intel(r) oneAPI DPC++/C++ Compiler (based on LLVM technology).

Detect if CMAKE_CXX_COMPILER_ID matches "IntelLLVM" and set CMAKE_COMPILER_IS_INTELCLANG=1
NOTE:  CMAKE_COMPILER_IS_INTEL will not be set, that is reserved for the classic Intel(r) C++ Compiler.

Define OSL_INTEL_LLVM_COMPILER 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.

Ensure OSL_CLANG_VERSION is when its a vanilla clang compiler, not apple or Intel(r) oneAPI DPC++/C++ Compiler.

Added OSL_ANY_CLANG which is set for any clang based compiler.

Removed OSL_NON_CLANG_COMPILER.
Updated uses of OSL_NON_CLANG_COMPILER with more specific and understandable combinations of OSL_ANY_CLANG, OSL_INTEL_CLANG_VERSION, and OSL_INTEL_COMPILER.

Make sure our math calculations are consistent,
especially division.  Different compilers may have choose to use
reciprocal division loosing precision causing slightly different
results which can lead to aliasing differences when running the testsuite
Disabled reciprocal division for all projects.

if -ffast-math is enabled to to the underlying compiler, inf's and NaN's may not be handled properly (by design)
When building liboslexec, ensure any source files that require proper INF or NaN handling have additional command line flags passed if needed (as the default behavior maybe -ffast-math):
    shadingsys.cpp
    wide/wide_shadingsys
    wide/wide_optest_float

Enable unitialized Matrix44, because all of its members get overwritten anyway, in impl_transform_normal_masked.

Added alternative test results where needed, wsing '.icx.' as shorthand for the Intel(r) oneAPI DPC++/C++ Compiler in alternative test result filenames.
Changed some tests to use the pretty(value) which clamps values close to 0 to be 0 to avoid lots of different alternative rest result files when using printf.
Added "--center" option to several regression tests to avoid aliasing in results between SIMD batched and scalar execution.

* Added icx-vp2022 to CI plan.

* To better clarify the classic vs. LLVM based Intel compilers and that they have version #'s not just 0 or 1,
renamed OSL_INTEL_COMPILER to OSL_INTEL_CLASSIC_COMPILER_VERSION
renamed OSL_INTEL_LLVM_COMPILER to OSL_INTEL_LLVM_COMPILER_VERSION

Removed unnecessary FMT_VERSION and OPENIMAGEIO_CMAKE_FLAGS from the icx-vp2022 worklow, added back USE_SIMD.
Fix spelling of losing.

Added OSL_OMP_COMPLEX_SIMD_LOOP(...) which is enabled or disabled in platform.h based on which compilers/versions can handle vectorizing complex nested control flow.  This makes it cleaner to document which loops need to vectorization conditionally controlled and centralizes where it is managed.

* Removed extra fp-model=consistent for icx-vp2022 workflow

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-03-08 09:45:45 -08:00
Larry Gritz 7366046f47 CI: Add test that uses the Intel icc/icpc compiler. (#1459)
(and a bunch of minor changes to support this)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-04 10:17:46 -08:00
Larry Gritz 1773995dbc Build: allow -Werror to be disabled even on CI branches (#1471)
Slight reworking of -Werror logic to let the default behavior be
changed by setting a cmake variable. In particular, this allows us to
make a CI build disable -Werror when we need to.

Previously, having the "OSL_CI" env variable set trumped all else and
forced -Werror. Now it just contributes to the default behavior, but
setting `-DSTOP_ON_WARNING=OFF` and cmake config time can still
disable it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-04 00:08:16 -08:00
Larry Gritz 2bdd9b567a Testsuite: allow using oiiotool for image diffs instead of idiff (#1472)
Additionally, allow custom command line arguments to run after each
image is loaded, but before the comparison.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-03-01 17:40:15 -08:00
Larry Gritz 9ee6b08f76 Make exported cmake configs relocatable by using relative paths (#1466)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-25 13:41:01 -08:00
Larry Gritz 77df61003c Start switching over from sprintf to fmt (#1469)
Turn on warnings about OIIO::Strutil::format and ustring::format

We should be using Strutil::sprintf / ustring::sprintf, or upgrading
entirely to Strutil::fmt::format / ustring::fmtformat.

Some day, the plain "format" will be deprecated, then disappear, then
reappear as compatible with std::format (as are fmt::format/fmtformat now).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-25 12:50:34 -08:00
Larry Gritz 701dcab948 Fix botched handling of OPENIMAGEIO_CMAKE_FLAGS during CI builds (#1468)
The gh-installdeps.bash file accidentally squashed any value that
the env variable already had. Oops.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-25 09:50:31 -08:00
Larry Gritz 97a4ac8338 Avoid OIIO::string_view::str() (#1467)
The str() method was not part of the final C++17 std::string_view.
To ensure future interchangeability with std::string_view, change the
few places where we call str() in the OSL code base.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-23 16:50:35 -08:00
sfriedmapixar c2b1d86c69 Add N/I to globals needed list when backfacing() shadeop is used (#1462)
* Track that the backfacing() shadeop requires N and I shader globals.

* Test ensuring that N and I are reported as needed shader globals when a backfacing() shadeop is used.

Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
2022-02-23 16:03:30 -08:00
Alex Wells 0392aea57e Implement Batched pointcloud_search, pointcloud_get, and pointcloud_write. (#1464)
* Implement Batched pointcloud_search, pointcloud_get, and pointcloud_write.

Updated behavior of scalar pointcloud_search and pointcloud_get to not code gen branch with code gen runtime error for maxpoints/num_points larger than array size.  Instead now it codgens a clamp of the maxpoints/num_points to the arraysize.  This allows code to continue executing, and if accessed outside of the range, existing codgen range checks will still emit a runtime error.

Extracted class PointCloud defnition and some helper functions to pointcloud.h so it can be shared between batched and scalar implementation.
Moved PointCloud out of anonymous namespace to OSL::pvt so a single implementation (including static maps) could be shared between batched and scalar implementation.

Refactored implementation of
template<typename DataT, int WidthT> struct Masked;
template<typename DataT> struct Ref;

to flatten class hierarchy and fix bug where derivatives of unbounded arrays could not be constructed, IE:
MaskedDx<int[]> myDeriv(ptr, arraylength);

Added                                  MaskedData::assign_val_lane_from_scalar
Renamed MaskedData::assign_val_from to MaskedData::assign_val_from_wide
Renamed MaskedData::assign_all_from to MaskedData::assign_all_from_scalar

Updated BatchedAnalysis to indicate that results of pointcloud_search, pointcloud_get, and pointcloud_write are always varying regardless of the symbols passed in.
Updated debugging in BatchedAnalysis to emit unmangled symbol names.

Properly implement (was broken previously) BatchedBackendLLVM::llvm_zero_derivs(const Symbol& sym, llvm::Value* count) including using code gen loop to reduce code bloat.

* Fixed warnings about BatchedRendererServices<WidthT>::pointcloud_get and BatchedRendererServices<WidthT>::pointcloud_write not returning a value.

* Fixed unused variable "ok" in batched pointcloud_write.
Fixed undefined type when building with USE_PARTIO=0

* Update pointcloud tests to avoid non-deterministic results for unsorted results and out of range max_points/num_points.
Added support for NOOPTIMIZE file tag for batched regression tests.
Made array-length-reg NOOPTIMIZE so its code gen would actually execute vs. constant fold.
Fixed bug for storing arraylength result in varying result symbol.

* Fix missing virtual function overrides of MyBatchedRendererServices in example-batched-deformer

* Change varying point cloud tests to use pixel centers in order to avoid situations where point cloud could provice multiple data points at equal distances causing non-determinism.

* More changes to avoid non-determinism in pointcloud test results

* Add alternate reference images for point cloud results that were coming back slightly different for essentially identical distances.

* Fixed bug in llvm_gen for raytype where the wrong type was passed as a parameter for a string.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-02-19 10:17:35 -08:00
Larry Gritz 89207ef83a Fix testrender sphere tangents, per MaterialX suggestion (#1465)
Fix erroneous computation of sphere tangents

Add render-uv test to check

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-19 09:10:03 -08:00
Larry Gritz d34c3f584c Adapt to OpenEXR/Imath changing branch master -> main (#1463)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-14 14:34:57 -08:00
Larry Gritz 72d530702e CHANGES and bump version to dev snapshot v1.12.4.2
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-11 12:03:26 -08:00
Larry Gritz bf185d1245 CI and build miscellaneous fixes (#1461)
(many ported/replicated from various recent OIIO PRs)

* CI: bump to latest dependency releases

* Bugs fixed in build_opencolorio.bash, it botched some of the
  directory choices when customizing where to place and build
  it. Also, switch to the more standard BUILD_SHARED_LIBS cmake
  variable to control whether to build dynamic or static libraries.

* Correctly handle the cmake variable VISIBILITY_MAP_FILE being set to
  "" on the command line as a way to disable using the visibility map
  file entirely.

* On Linux, also set link flags `--exclude-libs ALL` to hide symbols
  from any embedded static library dependencies, to prevent clashes
  with other versions of those libraries that may be compiled into a
  DCC app.

* Some other minor touch-ups in compiler.cmake.

* Refresh build_openexr.bash with the latest changes from OIIO.

* CI workflow: revise failed build artifact storage to capture cmake
  files.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-11 12:00:30 -08:00
Larry Gritz 58a25f1bea Favor our choice of Imath includes over OIIO's. (#1460)
New OIIO guards the contents of its Imath.h with the
`OIIO_IMATH_H_INCLUDED` preprocessor symbol. This lets us in OSL
pre-define it to absolutely ensure that OSL headers are including
exactly the Imath headers they want, not accidentally getting the ones
that OIIO includes.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-11 11:05:22 -08:00
Larry Gritz b816c21b19 Wean ourselves off of OIIO::string_view::c_str() (#1458)
OIIO's string_view::c_str() was cute, but it's a little dicey and it's
not present in the C++20 std::string_view. We didn't use it in a ton
of places, so replace with other idioms so that in the future we are
better able to interchange with or switch to std::string_view (when
our minimum supported C++ standard is high enough).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-28 14:32:50 -08:00
Larry Gritz c476b4727d oslc: detect using type name as an variable identifier (#1457)
Here was the construct it was confused by:

    struct Data {
        float height;
    };

    Data foo(Data a, float b)
    {
        return Data;   // <----- what's this madness?
    }

Curiously, this revealed a source code error in one of our other tests,
oslc-err-struct-print, which had not been detected previously!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-27 16:56:21 -08:00
Alex Wells f7fccf6a3a Implement batched version userdata and output placement. (#1455)
Added Wide<const int, WidthT> wide_shadeindex, void* userdata_base_ptr, void* output_base_ptr to BatchedExecutor interface (and underlying implementation) that allows each data lane
of a batch to utilize a different shade index in combination with a uniform userdata and output base pointer.

Fixed bug in batched version of llvm_gen_compassign where index was being loaded as uniform value even when it was varying (really just caused assert/extra output in Release).
For scalar and batched, avoid generating code for init ops or default values when a sym_loc is found because unlike get_userdata, when supplied sym_loc can't fail.

Improved LLVM_Util::op_scatter to handle scalar destination data types, previously only wide destination were required but to handle scatter results from SOA wide data layout to AOS
output placement layout scalar destinations need to be supported.

Updated BatchedRendererServices to be less abstract replacing several pure virtual functions with default noop versions to better match behavior of RendererServices.

Changed testshade to utilize output placement by default in batched mode.
Added NOSCALAR option to testing framework to allow for batched only tests.

Added testsuite/example-batched-deformer to exercise userdata placement and simple example of utilizing batched interface.

Added alternate output for example-batched-deformer to account for some rounding differences.

Added comment to note that the batched implementation assumes that SymLocationDesc::offset is readable at point 0 (because we clamp masked off lanes to 0 vs. adding conditionals).
Renamed local variable wide_index_to_output to wide_index_for_userdata to more accurately describe how it is used.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-25 13:23:28 -08:00
Alex Wells 72acb7caf1 Implement batched versions of isnan, isinf, and isfinite. (#1456)
Implement batched versions of isnan, isinf, and isfinite.

Added batched regression testsuite ieee-fp-reg.

NOTE:  its really difficult to test isnan(value) == true,
as its unclear to actually generate a NAN in OSL because
most functions are "safe" and check/avoid NAN's

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-25 12:26:33 -08:00
Larry Gritz 40223e513b Bump version for developer preview build 2022-01-20 12:33:07 -08:00
Larry Gritz e71dfec941 CI: Bump OpenColorIO and fmt "latest" versions (#1452)
They have recently had new releases. Make our CI keep up.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-20 10:22:54 -08:00
Larry Gritz 0e4a7e6f90 Separate C++ that we build with from that we demand downstream (#1454)
We were passing along, in the exported cmake config files, a demand
for downstream clients to use a C++ standard version equal to that
which we used to build OSL itself. But that's not necessary. We may
choose to build with C++17 (for example), but all of our public APIs
are safe to use for C++14.

Split the build-time options to CMAKE_CXX_STANDARD for the standard we
build this project with, and DOWNSTREAM_CXX_STANDARD for the standard
we are declaring is the minimum to *use* the library.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-20 09:16:56 -08:00
Alex Wells 7baa2937b0 Odds and ends to enable BATCHED execution of most testsuite (#1453)
* Enable BATCHED execution of most testsuite entries that don't use closures or point cloud.

Added batched implementation of hash function.

Updated batched implementation to use the symbol.get_int(), symbol.get_float(), and symbol.get_string() methods vs. *(int*)symbol.data() approach.

Fixed bug in batched code gen where mangled symbol names were output as part of debug uninit warnings and range checking.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fixed reparameter in batched execution.
Updated batched behavior for unlocked geom shader output parameters to function like scalar version.
Fixed batched bug when non-entry layers are executed and execution masks are compared producing a <i1x16> instead of i1 for use in conditional operation.

Added more reparameter test cases to cover arrays and arrays of aggregate types.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Enabled command line assignable user data for batched execution in testshade, which fixes testsuite/userdata-passthrough
Changed print_outputs for batched execution to not use << operator which includes parenthesis, but instead output each componenet with spaces to match the non-batched print_outputs.

renamed MaskedData<...>::assign_from(void* ptr_wide_data) to assign_val_from(const void* ptr_wide_data) to better reflect that only the value is assigned, and Dx and Dy are NOT assigned.
Added MaskedData<...>::assign_all_from(const void* ptr_data) to take a scalar DataT and broadcast it to all lanes of the MaskedData, masked off lanes are NOT overwritten, and value, Dx, Dy are assigned.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Apply clang-format to wide.h
Add some paranetheses to conditional to avoid warning.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Wrapped all printf arguments with pretty() in testsuite/geomath/test.osl to avoid small floating point differences from affecting printed results in test.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Add testsuite/geomath/ref/out-alt.txt to allow for minute floating point differences with some compiler/platform combinations.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-13 15:38:43 -08:00
Larry Gritz c79e4a7a4b Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-10 14:59:39 -08:00
Larry Gritz 7f40f3687c Rebuild pdf language spec docs
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-10 13:01:34 -08:00
Larry Gritz 4c7c3922ea CHANGES and docs touchups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-10 13:00:21 -08:00
Dieter De Baets 6814224f0e windows compile fix (#1451)
Signed-off-by: Dieter De Baets <debaetsd@gmail.com>
2022-01-10 10:30:34 -08:00
Larry Gritz 0b8ddec6d9 Remove out of date MaterialX shaders (#1450)
We used to build MaterialX shaders on our end. Now it's all done in
the MaterialX project itself, and along the way, we failed to keep in
sync with them. (And even if we had "kept up", what does that even mean?
We want OSL to be independent of any particular MX release, but the MX
shaders may change from release to release. Better to be entirely on
their side of the fence.)

We turned off building these shaders by default a long
time ago, now let's finally remove the last remnants and urge everyone
to rely on the MaterialX project for this material.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-07 15:20:28 -08:00
Alex Wells 5c43516282 Add batched support for trace, setmessage, and getmessage (#1448)
Added MaskedData::assign_from(void *ptr_wide_data) to perform a masked copy of wide data at some address.
Added enum class RenderServices::TraceOpt::LLVMMemberIndex to correlate C++ data members with LLVM type generated by BatchedBackendLLVM::llvm_type_batched_trace_options()

Fixed bug in BatchedBackendLLVM::llvm_load_arg where array types where only properly broadcasting uniform to varying arguments for the 0th element of the array.

For batched implemented trace options as a LLVM type with direct code gen to alloca, init default values, and set optional values vs. callbacks.  Same code could be resused for non-batched impl.

Added BatchedMessageBuffer to context and BatchedMessageList to wide_opmessage.cpp to allow a shared buffer to be cleared by the ShadingSystem while allowing target specific compilation of SIMD import/export of message values into the list to compile in wide_opmessage.cpp.

Extended testshade's SimpleRenderer and BatchedSimpleRenderer to implement trace and getmessage to allow new tests to exercise some basic functionality.

Added new batched regression tests:
  message-reg
  trace-reg

Added new test:  message-no-closure which is a simplied version of message with no closures

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Temporarily disable simd compilation of message import and export data to test if that is cause of crash in bleeding edge CI workflow.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Temporarily disable more simd compilation of batched message test if that is cause of crash in bleeding edge CI workflow.
Temporarily run only message-reg test for bleeding edge CI workflow

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Temporarily run only message-reg.regress.batched.opt for bleeding edge CI workflow

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fix alignment of MessageBlock allocation so that reads/writes can be assumed aligned to Block<> data members

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Re-enable disabled simd statements from trouble shooting bleeding edge CI.
Re-neable all tests for bleeding edge workflow.
Applied clang-format to wide_opmessage.cpp

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-06 16:58:29 -08:00
Larry Gritz 450a9e37cf CI: pybind11 adjustments (#1449)
* pybind11 2.9.0 release -- bump the vfx2022 and "latest" CI tests to
  use it.
* Adjust other CI test pybind11 versions to get good coverage across all
  the pybind11 releases, and to synchronize the vfx platfom tests with
  the pybind11 release that was current for its respective year.
* Sync build_scripts/build_pybind11.bash with the latest in OIIO, including
  bumping the default pybind11 version we download to 2.8.1.
* Opportunistic touch-up of warnings about llvm version to bring
  into sync with our actual current requirements.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-05 13:00:20 -08:00
Larry Gritz 7e2bcbb122 RuntimeOptimizer: Fix messages & unknown_message_sent initialization (#1447)
Alex Wells pointed out that they were never explicitly initialized.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-14 18:21:46 -08:00
Larry Gritz 535b560b0d Update films and product list
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-12 15:28:29 -08:00
Larry Gritz eb35c6185a Bump LLVM minimum from 7 to 9 (#1441)
Among other cruft that existed to support versions 7 and 8, this lets
us completely get rid of PrePromoteLogicalOpsOnBitMasks custom pass,
which is only needed for LLVM < 8.

Also get rid of some cmake checks for LLVM versions that require
C++14 or higher -- not necessary now that C++14 is our minimum.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-09 12:58:38 -08:00
Alex Wells 4faeda1234 Add batched support for dict find, dict next, dict value. (#1445)
* Add batched support for dict find, dict next, dict value.
Implementation takes advantage of uniform values and only does lookup once and broadcasts results if necessary.
When nodeid is varying, it falls back to simple loop over active data lanes performing lookups.

* Added new regression test xml-reg.
Enabled BATCHED execution of existing xml test

* Add new wide_opdictionary.cpp missed in original commit

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-12-09 12:16:28 -08:00
Larry Gritz 15e0273eec Use a project-specific var for whether we're running in CI (#1446)
Maybe somebody else is building this as a subproject or has a variable
called "CI"?

* For our CI runs, set an env variable "OSL_CI" (not just generic "CI").

* Default STOP_ON_WARNING to be off for supported releases, only on by
  default for main branch where we're actively developing. Because you
  want downstream users who are building supported releases to not get
  tripped up when their compiler upgrades and there's a new warning.

* Make sure STOP_ON_WARNING is true for our CI runs, even for release
  branches -- but now check OSL_CI, not CI, in case somebody else has
  set that.

Fixes #1428

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-02 23:42:58 -08:00
Larry Gritz 5b775c7fc7 CMake tweaks (#1443)
* Make PROJECT_VERSION_RELEASE_TYPE be a cache string, so individual
  build configs or sites can override it.

* Make OSL_SUPPORTED_RELEASE be an overrideable option, and make
  OSL_DEV_RELEASE be driven by it, rather than (possibly incorrectly)
  independently set.

* Change OSL_IS_SUBPROJECT to PROJECT_IS_TOP_LEVEL (and with the opposite
  sense), to match CMake 21+ behavior. And no need to set it ourselves if
  using cmake 21+.

* All of the clang-format stuff should only apply if PROJECT_IS_TOP_LEVEL.

* Add a TIME_COMMANDS option to help debug performance of the build.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-01 12:20:57 -08:00
Alex WellsandLarry Gritz e7ca0926c9 Pr/batched texture (#1436)
* Add batched support for 2d texture calls, gettextureinfo.

To enable, added:
  bool RenderServices::is_udim (TextureHandle *texture_handle)
  TextureSystem::TextureHandle* BatchedRendererServices::resolve_udim_uniform(...,TextureSystem::TextureHandle*, float S, float T)
  void BatchedRendererServices::resolve_udim(...,TextureSystem::TextureHandle*,Wide<const float> wS, Wide<const float> wT, Masked<TextureSystem::TextureHandle*> wresult)

which allows batched code gen to resolve_udim's for varying S & T and bin the resulting TextureHandle* and make calls to get_texture_info_uniform with a single resolved udim texture handle, then broadcast the results to data lanes with matching TextureHandle *'s.

Added extensive new regression tests:
    gettextureinfo-reg
    gettextureinfo-udim-reg
    texture-opts-reg

Enabled BATCHED execution of existing tests:
    gettextureinfo-udim
    gettextureinfo
    texture-alpha-derivs
    texture-alpha
    texture-blur
    texture-connected-options
    texture-derivs
    texture-errormsg
    texture-firstchannel
    texture-interp
    texture-missingalpha
    texture-missingcolor
    texture-simple
    texture-smallderivs
    texture-swirl
    texture-udim
    texture-width
    texture-withderivs
    texture-wrap

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Removed some commented out includes

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Add conditional compilation dependent on OIIO version to enable RendererServices::is_udim

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fix clang-format issues

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fix bug in testing.cmake where non-existant OPENIMAGEIO_VERSION was being checked, when it should have been OpenImageIO_VERSION.

Added quiet option to oiio-tool calls in regression tests to allow produced out.txt to match between baseline and batched runs.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Added optional silent=False argument to oiiotool in test suite, allowing us to avoid generating warnings for file already exists that was causing differences when comparing baseline/out.txt and out.txt in regression tests

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Added missing batched texture option rnd for the llvm code gen representation

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fixed compilations issues with OIIO 2.4 by enabling "rnd" batched texture option.
Fixed some other compilation issues when OSL_DEV is defined.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Cleared up some comments around populating rnd.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Add support for batched texture3d.

Discovered mismatch between documentation, llvm_gen implementation, and oslc when passing user derivatives to texture3d.
oslc and documentation expect optional parameters "vector dpdx, vector dpdy, vector dpdz",
however llvm_gen and optexture implementation only accept "vector dpdx, vector dpdy"
and use 0 for dpdz when calling into the texture subsystem.

This commit includes changes to oslc to make the compiler match the implementation of accepting only "vector dpdx, vector dpdy".

Enable BATCHED execution of testsuite/texture3d
Add new regression test textur3d-opts-reg

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Revert oslc to make the compiler match the documentation of accepting only user inputs that include dpdz:  "vector dpdx, vector dpdy, vector dpdz".
Fixed llvm_gen and optexture to properly extract user dpdz from texture3d options or initialize a Vec3(0) and pass through to texture subsystem.
Modified batched_llvm_gen and wide_optexture to properly extract user dpdz from texture3d options or initialize a Wide<Vec3>(0) and pass through to texture subsystem.
Updated texture3d-opts-reg test to pass dpdz for calls taking user derivatives.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Added batched support for environment.

Added BatchedRendererServices::environment virtual method

Added new test environment
Added new regression test environment-opt-reg

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* clang-format of batched_rendererservices.h

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Rename testsuite/environment-opts-reg to testsuite/texture-environment-opts-reg to line up with a different PR adding testsuite/texture-environment.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Removed some environment option test for "wrap" as that is an unsupported option for environment.
Added test and handling for "time" option to batched texture3d.  Current choice is to just silently ignore "time" as currently supported 3d formats do not support time.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Removed redundant environment test as texture-environment covers it.
Enabled BATCHED execution of texture-environment

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Extended test timouts further for arithmetic-reg.regress.batched.opt and transform-reg.regress.batched.opt which were causing spurious CI timeouts.
Reduced some multipliers of user supplied derivs to environment tests to reduce differences in results.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

Co-authored-by: Larry Gritz <lg@larrygritz.com>
2021-11-30 18:35:11 -08:00
Larry Gritz a33abee2ad Docs: fix missing "errormessage" explanation for environment and texture3d (#1442)
It was documnted for texture(), but not for the others, for which it
also has worked for many years.

Thanks for Alex Wells for pointing this out.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 15:57:40 -08:00
Larry Gritz 9d42d4a6f7 Testing: Adjust timeout strategy (#1440)
I recently bumped the ctest per-test timeout to 300s because one of the
batched shading regression tests was occasionally taking longer than the
prior limit of 240s.

But there is a better way: Individual tests can have their timeouts
set individually via set_tests_properties(TIMEOUT), so I raised the
timeout to 300s for all tests whose names contain "-reg", also kept it
rather long (the old 240s) for the long render tests that are all named
"render-". Then for everything else, we can actually lower the default
to 60s, since no other tests should be long-running.

(For the curious, the reason these batched regression tests are so
expensive is that they test a bunch of combinations, and they first
run the test in the non-batch scalar mode, then again in batched mode,
and compare the results to ensure that the batch code never deviates
from scalar. This makes them take at least twice as long as they
ordinarily would. But also remember that these are only run for the
few CI test matrix entries where we are specifically testing batch
shading.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 11:52:30 -08:00
Larry Gritz 81dacc2e3b Add testsuite coverage of environment() (#1438)
Can you believe we never had a test?

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 09:10:39 -08:00
Larry Gritz 1e84fc03ce Fix minor CI issues (#1439)
* Increase testing timeout, some of the batch shading regression tests
  seem to take longer than the prior 240s limit.

* Turn off OpenVDB when using the osl:2021 in combination with OpenEXR
  3.x -- the version of OpenVDB in the 2021 container is too old to
  understand OpenEXR 3.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 08:59:12 -08:00
Larry Gritz 5ec96f37a7 CI adjustments (#1434)
* Use LLVM 13 / clang 13 for the VFX Platform 2022 test.

* Add MacOS-11 test

* Poke around how to use arbitrary LLVM versions via Conan. (Works! But
  I have not yet enabled it.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-20 10:32:53 -08:00
Larry Gritz 748b895e05 Restore unit tests for texture3d (#1437)
OIIO master recently removed support for Field3D, which is rarely used
and the project is effectively unmaintained and isn't able to build
against the newer OpenEXR releases that we want to encourage people to
use.

So the primary purpose of this patch is to switch our unit test for
texture3d from using a field3d file (and thus would not run when using
newer OIIO) to a roughly equivalent test using openvdb (which is
supported, assuming OIIO is built in the presence of OpenVDB).

But, ha, I discovered two things, either one of which means that we
had actually not been unit testing texture3d at all lately: (1) To
discover whether the installed OIIO supported openvdb (and therefore
whether to bother running the test), we were relying on a totally
nonexistant OPENIMAGEIO_BIN cmake varaible. I don't know what that was
supposed to be (did I mean OIIOTOOL_BIN? but that also is not a
thing), but anyway, it caused it to always skip the test. (2) Oh boy,
the OIIO that we were relying on for may tests, provided by the ASWF
docker containers, was an OIIO that was not built in the presence of
OpenVDB (even though our OSL testing containers DO have OpenVDB), so
again it skipped the test because it needs that OIIO-side support for
texture3d() to know how to read openvdb files. Fix this by building
OIIO from scratch with openvdb support when doing the "VFX Platform
2022" test, rather than relying on the one in the container.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-19 23:42:37 -08:00
cmstein 1ff9aec2f1 osl_get_attribute() should use device strings when compiling for OptiX. (#1435)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-11-17 11:13:26 -08:00
Larry Gritz 47ddafda31 Raise OIIO minimum to 2.2 going forward (#1426)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 20:08:38 -08:00
Larry Gritz 0fedeb4212 CI: Update some of the 'latest' released versions we build against (#1433)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:24:54 -08:00
Larry Gritz 95def2d57b Banish the last of the sscanf calls (#1432)
Because they can fail with some locales. Replace with OIIO::Strutil
parsing functions that are locale-independent.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:24:34 -08:00
Larry Gritz 41f645902f Minor docs changes for changing master branch name to main (#1431)
Renaming the master branch to main is imminent. Here are the few
places where we refer directly to branch names that will no longer
exist.

While searching for "master/", I also noticed a couple files that
had the wrong project's copyright boilerplate on it (a lot of the
cmake scripts I write and submit to both projects simultaneously).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:22:09 -08:00
Larry Gritz 2120647911 Catch up to change in OIIO TextureOptBatch in development (#1430)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-04 23:29:54 -07:00
Larry Gritz 75d06a6c94 CI: OCIO renamed their master branch to main (#1429)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-03 16:27:13 -07:00
Larry Gritz ac544e8c9c CMake: use the more compact TARGET_NAME_IF_EXISTS to know if target exists (#1425)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-03 00:39:22 -07:00
Larry Gritz 6b6637e271 Fix one spot where we should have used OIIO::ofstream instead of std. (#1424)
This is primarily for the sake of mingw, but also is the proper kind
of stream to pass to OIIO::Filesystem::open.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:29:55 -07:00
Larry Gritz 0f44f46973 build: Be careful about default installation directory (#1421)
Use a cmake idiom so that you need an explicit -DCMAKE_INSTALL_PREFIX=
in order to write over /usr/local or any potentially sensitive area.
In the absence of this being set explicitly, it will configure the
cmake build so that an "install" ends up in ./dist (which is what the
Makefile wrapper did all along).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:29:31 -07:00
Larry Gritz bf02d4a98b Changes to work with LLVM 13 (#1420)
And a few places to let it compile with clang 13's new warnings.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:29:08 -07:00
Alex Wells 03a31f506e Implement spline and spline inverse for batched SIMD implementation (#1422)
Added
    template <int M00, int M01, int M02, int M03,
              int M10, int M11, int M12, int M13,
              int M20, int M21, int M22, int M23,
              int M30, int M31, int M32, int M33, int DivisorT>
    struct sfm::StaticMatrix44
to model a matrix whose elements are known at compile time.  Internally it utilizes proxys instead of floats in order to optimize for special cases of 0, 1, -1 elements and not even generate math when possible.  The StaticMatrix44 is used by wide_opspline.cpp to create specialized functions for each of the spline basis types.  A dispatch function routes the compile time optimized spline or spline inverse routine.

Altered splineimpl.h to provide "int basis_type_of(StringParam basis_name)" to allow the batched implementation to map a string to spline enum value used as an index in the dispatch function to functions optimized for each type of spline basis (instead of generic 4x4 matrix implementation)

Added "T sfm::select_val(bool cond, const T left, const T right)" as alternative to the ternary operator which appeared to possibly take address of its arguments which prevented privatization of those variables when compiled inside a SIMD loop.

Added note to BatchedAnalysis implementation identifying that local variables scope is lost between .osl and .oso and when a function is inlined multiple times, its local variables could be treated as varying when they could have been uniform if somehow identified as a local variable by the Analyzer.

Enable BATCHED testing of:
  spline-boundarybug
  spline-derivbug
  spline-nonuniformknots
  spline
  splineinverse-ident
  splineinverse

Added new BATCHED_REGRESSION tests:
  spline-reg
  splineinverse-knots-ascend-reg
  splineinverse-knots-descend-reg

Added sfm::Inverter to remove nested loop behavior of batched splineinverse as OIIO::invert has a loop which was called from inside the search interval loop, created a nested loop.  Under SIMD/SIMT the nested loop could execute incoherently.  Instead we choose to use the class sfm::Inverter to manage state between is_bracketed_by(min,max), meant to be called from the search interval loop, and bracketed_invert(min,max) meant to be called after exiting the search interval loop, avoiding a nested loop that could be executed at different interval's for each SIMD/SIMT lane/thread.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-10-18 22:13:51 -07:00
Larry Gritz 1d9eec69ab Rebuild docs and minor touchups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-08 14:38:53 -07:00
Larry Gritz e26a597e3f CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-08 14:29:59 -07:00
Larry Gritz bee949cd3b Changes to OSL ownership of color systems (#1405)
Patrick Hodoul pointed out that we were forcing OpenColorIO to
initialize and read configs as soon as the ShadingSystem was
created. In this patch, we're changing to a lazy creation approach.

We remove the `OCIOColorSystem m_ocio_system` member and the
ocio_transform() method from ShadingSystem. Put them in the
ShadingContext instead. This allows lock-free access because each
context is used by only one thread at a time.

Within the OCIOColorSystem, make the `OIIO::ColorConfig` be a
shared_ptr rather than a member, so it can be created lazily.  If the
Context's OCIOColorSystem needs a config and doesn't have its own yet,
it asks the ShadingSystem, which allocates one the first time (and
only that one time).

So, in short, SS allocates *one* shared ColorConfig, the first time
any context asks for one. The Context only asks the SS for this once
per context (i.e., once per thread). Individual shades just use the
ColorConfig of their context, not needing to lock for it (except for
that brief lock the first time any context asks for the very first
ColorConfig that's needed).

Some things were guarded by `OIIO_HAS_COLORPROCESSOR`, which is silly
because we no longer support OIIO versions so old that it's not
defined.  But then OSL `undef`ed it for Cuda. I replaced these guards
by a more straightforward direct test of whether it was Cuda code.

I added a sample OCIO config to testsuite so we can use it for tests.
In particular, the new testsuite/ocio -- test using OCIO for color
transforms.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-05 13:45:11 -07:00
Larry Gritz 0d1d2de350 Fix oslc missing a write error on function parameter (#1417)
Fixes 1416

In OSL, function parameters must be marked as `output` or they are not
supposed to be writable. In issuing errors when a write is performed on
something not writable, we missed an interesting case:

```
void g(output float b) {
    b = 1;  // ok, since b is marked as output
}

void f(float a) {
    g(a);  // <--- should be disallowed, g is writing to f's non-output param
}

float x;
f(x);
```

This patch catches cases like these. The new error looks like this:

`test.osl:22: error: cannot write to non-output parameter "a", as passed to function g() as arg 1 (output parameter "b")`

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-05 13:42:46 -07:00
Alex Wells 54727f9dee More batched gen ops (#1413)
* Add batched SIMD implementation for all color operations.

Added batched llvm code gen for: llvm_gen_blackbody, llvm_gen_luminance, llvm_gen_transformc (including code gen of loop to identify unique "from" and "to" space combinations to call library function with).

Made ColorSystem const correct.
Pulled much of ColorSystem's implementation into src/liboslexec/opcolor_impl.h so it could be inlined in both opcolor.cpp and wide_opcolor.cpp.
To enable SIMD fast path for ColorSystem::blackbody_rgb added new methods to expose underlying lookup table optimization.
    bool can_lookup_blackbody(float T /*Kelvin*/) const;

    Color3 lookup_blackbody_rgb (float T /*Kelvin*/) const;

    Color3 compute_blackbody_rgb (float T /*Kelvin*/) const;
When can_lookup_blackbody() returns true
then lookup_blackbody_rgb can be safely called,
otherwise the expensive compute_blackbody_rgb is required.

Updated implementation of ColorSystem to succesfully vectorize on multiple compilers, optimized lookup table data types and indexed dereferences to generate prefered 32bit indexed gathers vs 64bit gathers which require multiple instructions and registers.

To improve code generation and less chances of aliasing issues, changed nested M[i][j] operator access to Matrix in ImathMatrix.h to directly access underlying 2d array M.x[i][j] also changed Vector operator V[i] to directly access V.x, V.y, V.z in OSL/IMathx/IMath*.h

Moved helper testIfAnyLaneIsNonZero from wide_opmatrix.cpp to be testIfAnyLaneIsNonZero in OSL/wide.h

Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

Enabled BATCHED execution of existing testsuites: blackbody, color, transformc, wavelength_color
Added new testsuite BATCHED regression tests:  blackbody-reg, color-reg, luminance-reg, transformc-reg, wavelength_color-reg
Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

* Adopt OIIO calls to fast_cbrt and fast_expm1 for blackbody computation.
Use single precision for bb_spectrum object/operator and manually implement std::pow(wlm,-5.0f) to better enable vectorization.
Reduced masked code generation for rgb_to_hsl.
Removed duplicated code by implementing ColorSystem::blackbody_rgb(T) in terms of ColorSystem::can_lookup_blackbody(T), ColorSystem::lookup_blackbody_rgb(T), and ColorSystem::compute_blackbody_rgb(T).  Removed some casting to uint16_t that was unnecessary.

Removed some test shaders that were not intended to be promoted.

* Implement batched llvm code generation for ops: andor, bitwise_binary_op, clamp, get_simple_SG_field, isconstant, select, unary_op, mix

Fixed bug in BatchedAnalysis where the complement operator was being treated as always having a boolean result.  In reality the result of complement or other bitwise operation would only be boolean if its input parameters were forced to be boolean (left TODO note for future improvement).

Fixed bug in printf where integer who is forced_llvm_bool() is formatted as a float was not converted to an integer first.

Enabled BATCHED for execution for tests:  and-or-not-synonyms, isconstant, logic, select.
Expanded testsuite/shaderglobals to exercise/access all shader global data members.

Add regression tests: andor-reg, bitwise-and-reg bitwise-or-reg bitwise-shl-reg
bitwise-shr-reg bitwise-xor-reg, complement-reg, mix-reg, select-reg

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-10-05 11:57:37 -07:00
Brendan P 1d7362b331 Added Redshift renderer to list of renderers/tools that support OSL. (#1419)
Signed-off-by: brendisurfs <brendan.prednis@protonmail.com>
2021-10-02 09:58:20 -07:00
cmstein 7b2cdacdea fixing return type (#1418)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-10-01 19:36:13 -07:00
Derek Haase ea550aa5c8 Changing DNEG board member from Derek to Clint (#1415)
Signed-off-by: Derek Haase <derekhaase@gmail.com>
2021-09-30 13:38:14 -07:00
Larry Gritz 4f169d8b38 Raise OpenEXR/Imath minimum to 2.3 (#1406)
Remember that our current 'master' is really aiming for a release in
late 2021 at the earliest, and thus will be a version primarily
intended to be used widely in 2022. Release branches never drop
supported dependencies, so the 1.11 branch will continue to support
OpenEXR all the way back to 2.0.

VFX Platform guidance is to support the current year, plus up to 3 years
prior, so that means that for 2022-ish software, we should support back
to 2019 dependency ecosystem.

For OpenEXR, 2019 state of the art was 2.3 -- that's still dreadfully
old, and is no longer getting even critical or security bug fixes. But
it still means that we can comfortably upgrade our advertised minimum
OpenEXR from 2.0+ to 2.3+ and eliminate some build and dependency
logic that was dedicated to dealing with 2.0..2.2.

We're also raising the OpenEXR/Imath "recommended minimum" (build-time
warning, but not rejection) to 2.4. Even that is shaky, but the fact
that it's still in wide use and was officially (though IMHO unwisely)
the VFX Platform 2021 recommendation, means we can't yell at people
too much about it.

It is possible that by the time we make a supported OSL 1.12 release,
we will bump even further to OpenEXR 2.4 as the minimum. We'll make
that decision later. It would depend on our being confident that even
though 2.3 is technically within the 3 year window we try to support,
we cannot discern that anybody is actually using it (who would also
need the most recent OSL in the same app).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-09-28 10:08:33 -07:00
Luya Tshimbalanga 8682211d0b Fix compatibility with LLVM 12 and up (#1412)
Upstream LLVM stopped using the compatibility
spellings of OF_{None,Text,Append} from version 12 and up.

https://reviews.llvm.org/D101650

Signed-off-by: Luya Tshimbalanga <luya@fedoraproject.org>
2021-09-28 10:08:01 -07:00
Alex Wells 15c81df232 Add batched SIMD implementation for all color operations. (#1408)
Added batched llvm code gen for: llvm_gen_blackbody, llvm_gen_luminance, llvm_gen_transformc (including code gen of loop to identify unique "from" and "to" space combinations to call library function with).

Made ColorSystem const correct.
Pulled much of ColorSystem's implementation into src/liboslexec/opcolor_impl.h so it could be inlined in both opcolor.cpp and wide_opcolor.cpp.
To enable SIMD fast path for ColorSystem::blackbody_rgb added new methods to expose underlying lookup table optimization.
    bool can_lookup_blackbody(float T /*Kelvin*/) const;

    Color3 lookup_blackbody_rgb (float T /*Kelvin*/) const;

    Color3 compute_blackbody_rgb (float T /*Kelvin*/) const;
When can_lookup_blackbody() returns true
then lookup_blackbody_rgb can be safely called,
otherwise the expensive compute_blackbody_rgb is required.

Updated implementation of ColorSystem to succesfully vectorize on multiple compilers, optimized lookup table data types and indexed dereferences to generate prefered 32bit indexed gathers vs 64bit gathers which require multiple instructions and registers.

To improve code generation and less chances of aliasing issues, changed nested M[i][j] operator access to Matrix in ImathMatrix.h to directly access underlying 2d array M.x[i][j] also changed Vector operator V[i] to directly access V.x, V.y, V.z in OSL/IMathx/IMath*.h

Moved helper testIfAnyLaneIsNonZero from wide_opmatrix.cpp to be testIfAnyLaneIsNonZero in OSL/wide.h

Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

Enabled BATCHED execution of existing testsuites: blackbody, color, transformc, wavelength_color
Added new testsuite BATCHED regression tests:  blackbody-reg, color-reg, luminance-reg, transformc-reg, wavelength_color-reg
Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Adopt OIIO calls to fast_cbrt and fast_expm1 for blackbody computation.
Use single precision for bb_spectrum object/operator and manually implement std::pow(wlm,-5.0f) to better enable vectorization.
Reduced masked code generation for rgb_to_hsl.
Removed duplicated code by implementing ColorSystem::blackbody_rgb(T) in terms of ColorSystem::can_lookup_blackbody(T), ColorSystem::lookup_blackbody_rgb(T), and ColorSystem::compute_blackbody_rgb(T).  Removed some casting to uint16_t that was unnecessary.

Removed some test shaders that were not intended to be promoted.

* Added additional test result for black body because the change from double to single precision caused a few results to differ slightly (max delta 0.0000534058)

* Incorporated changes from PR to "fix color conversion from RGB to xyY"

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-09-27 15:49:11 -07:00
cmstein 8f9206ab46 Removing race condition when compiling for OptiX 7 (#1411)
This change now requires renderers to manually link in the compiled rend_lib.cu
PTX code when using OptiX 7.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-09-27 10:53:46 -07:00
ix-bruiz 3f87e75821 Fix color conversion from RGB to xyY (#1410)
Signed-off-by: Benoit Ruiz <bruiz@isotropix.com>
2021-09-23 15:32:41 -07:00
ix-bruiz f471ab5e0c Fix missing hostdevice modifier on some matrix operators (#1409)
Signed-off-by: Benoit Ruiz <bruiz@isotropix.com>
2021-09-22 10:05:40 -07:00
Nicolas Guiard 22105d2982 Changed the prototype of osl_get_attribute callback in liboslexec (#1404)
Changed the prototype of osl_get_attribute callback in liboslexec in
order it takes a copy of the attribute TypeDesc casted into a long long
instead of taking a pointer to it. This allows to make it work properly
on GPU else we have an invalid pointer.

Signed-off-by: nicolas <nicolas@isotropix.com>
2021-09-13 23:56:55 -07:00
Larry Gritz 879545c359 CI minor version updates (#1403)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-09-12 21:13:36 -07:00
cmstein 1b05f9a6a0 Fix problem with unresolved symbols on GPU (#1401)
Fix problem with unresolved symbols when multiple shaders call certain (#1401)functions on the GPU (ie. osl_printf()).

This fixes a problem I was seeingon the GPU: if I had two shaders that contained a printf(), then the second shader group would report osl_printf as being an unresolved function (the first shader group was fine). If I looked at the PTX for the second shader group, osl_printf was tagged as a "weak" function. Removing the "weak" attribute resolves the problem.

I'm not sure why osl_printf and rend_get_userdata should be different from the other functions in rend_lib.cu.

This is easily reproduced in testsuite/testoptix by adding a printf() to checkerboard.osl and microfacet_test.osl.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-09-02 18:08:37 -07:00
Alex Wells cb3bdb4b4e Removed clang and gcc attributes that disabled optimizations for nonAffineInverse. (#1400)
Added clang pragma and gcc attribute to disable Fused Multiply Add for nonAffineInverse to allow offline compilers to produce results closer to those of LLVM IR compilation (which has FMA disabled by default) which produced the reference images of the testsuite.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-09-01 13:07:04 -07:00
Larry Gritz 692c9b4498 Position-specific gettextureinfo() for UDIM textures (#1398)
Newly added functionality in TextureSystem (only in OIIO >= 2.3.7)
allows us to add a new flavor of gettextureinfo that takes texture
coordinates, and in the case of UDIM textures, will retrieve the info
for the particular UDIM texture that will be used for the given
position:

    int gettextureinfo (string texturename, string paramname,
                        float s, float t, output TYPE destination)

NOTE: Use with caution, this will be more expensive than ordinary
calls to gettextureinfo that will tend to constant-fold effectively,
since the s,t coordinates are runtime-determined and won't be known
for runtime optimization.

If built against older versions of TextureSystem that lack support for
the new is_udim() and udim_resolve() methods, this new gettextureinfo
will simply use the old gettextureinfo() without coordinates, and thus
will not be able to retrieve position-specific texture info.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 09:12:11 -07:00
Larry Gritz e901657f81 Bump some CI dependency versions (#1399)
Most important: make sure we have a proper VFXPlatfom-2022 like test,
with Python 3.9 and OpenEXR/Imath 3.1.

Fix a few of the "name" entries for tests to match the set of versions
actually present on those images.

Remove apt-get install of libboost-regex-dev, since we use only
std::regex now that we're no longer using gcc4.8.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 09:11:50 -07:00
Larry Gritz 881c704d11 Build: collapse build and dist hierarchy (#1396)
Similar to a recent change in OIIO... For historical reasons, our
wrapper makefiles assume that we build in `build/ARCH[.variant]`, so
maybe build/linux64, build/linux64.debug, etc.

Get rid of this extra bit of hierarchy, it no longer serves us and
it's contrary to modern cmake practice.

Also used this as an excuse to remove some SPI build script
customization that we no longer use.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 09:11:09 -07:00
Larry Gritz df18d97283 Give Symbol virtual destructor to fix UB because of derived classes. (#1397)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-24 09:28:31 -07:00
Larry Gritz 30d2a4a089 Userdata input placement (#1391)
This is analogous to the "output placement" that we added recently, but
for input of userdata.

Reminder: "userdata" means shader parameters marked as lockgeom=0 that
are expected to be supplied on a per-shade basis, such as interpolated
vertex data on geometric primitives. The primitive data binds by name to
matching shader parameters.

This patch concerns how the shader gets this per-point data.

Old school: in the middle of the shader, when userdata is needed, the
shader calls osl_bind_interpolated_param(), which makes a callback to
RendererServices::get_userdata(), which... does something magical and
renderer-specific to retrieve the data by name.  This is expensive and
also challenging to implement on the GPU (which is why it remains
unimplemented).

This patch changes the methodology to the following, which is somewhat
analogous to how we did output placement:

0. It is assumed that there is an arena of memory where the userdata
   is going to be, and the pointer to its start is passed down to the
   shader via execute() (just like how the shaderglobals and output
   arena pointers are passed), along with an index of the current
   shade point.

1. The renderer pre-declares SymLocationDesc records for the userdata,
   which specifies the offsets and strides within the arena where the
   data can be found.

2. Prior to launching the shader execute(), the renderer is expected
   fill in those values in the userdata arena for the points to be
   shaded.

3. When JITing the part of the shader that initializes those userdata
   parameter values, we simply JIT a simple data copy directly from
   the computed position within the arena (offsetting the right amount
   for this data, at this shade index) -- just a couple of
   instructions per shade, no function calls, no RendererServices
   callbacks, no name lookups!

4. There is no 4. That's it.

See the changes to osldeformer.cpp for an example of how this looks from
the renderer side. It's really straightforward.

Currently, if there is no SymLocationDesc for a lockgeom=0 parameter
that needs initialization, it will fall back to the old callback. We
may fully deprecate the old way, but not for a while, so this is back
compatible for now.

This seems to work, passes all tests, doesn't break anything, and works
for the osldeformer example!

There is follow-up work to do: I think we can pretty easily do the
same thing for ShaderGlobals ("make your own SG struct"), named marix
retrieval, and other attributes. Will do those in subsequent PRs if
this meets everybody's approval.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-19 14:52:27 -07:00
Larry Gritz 06c9d0d1c7 Test: don't clobber LD_LIBRARY_PATH for optix tests (#1395)
Well intentioned attempt to ensure that Cuda runtime library was in
the library path when tests were run, but it clobbered the existing
LD_LIBRARY_PATH.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-18 16:26:21 -07:00
Alex Wells d4f54bc76a PR/BatchedNoise (#1394)
Add batched code gen to generate a loop to calls to OSL library noise functions with binning of varying noisetypes and options.  For example if half of a SIMD batch uses gabor option "bandwidth" of 10 and the other half default "bandwidth" of 1, then gabornoise will be called twice (once with bandwith option set to 10 and a mask with the 1st half of SIMD lanes enabled, then a 2nd time with bandwith option set to 1 and a mask with the 2nd half of SIMD lanes enabled.

Added batched OSL noise library functions which compile with outer loop explicit vectorization.  NOTE:  Perlin and some other noises have SIMD intrinsics that work on multiple data elements (block vectorization).  When the the active number of lanes in a batch is below a tunable threshold, the legacy block vectorization version is called.  This avoids the worst case scenarios of 1 active SIMD lane executing, and allows the 3-4 wide x,y,z data element version to run instead.

Add previosly omitted /Qopenmp-simd and -fopenmp compiler flags along with -DOSL_OPENMP_SIMD to cause OpenMP outer loop explicit SIMD vectorization of loops in batched OSL libraries.

Fix Mask::invoke_foreach to be OSL_NOINLINE, it was mistakenly set to OSL_FORCEINLINE

Update oslnoise.h to access target specific library sfm namespace

Improve compile time for 4d perlin noise with Dual arguments by using a 2 iteration loops to avoid repeating a large amount of code.

Changed ShadingSystemImpl::count_noise(void) to count_noise (int number=1) to allow batched version to update the call count with the number of active lanes in the current mask.

Fixed sfm::scalar_gabor3 and sfm::scalar_pgabor3 to not use the loop array index when storing partial results, when vectorizing an aliasing issue on the stack caused incorrect results.

Enabled BATCHED execution of all noise tests.
Added new tests: noise-generic, pnoise-generic
Added new BATCHED_REGRESSION tests:  noise-gabor-reg, noise-reg, pnoise-reg

Avoid issue with constant folding in hashnoise with different compilers causing slightly different results from sin & cos to cause massively different results due to aliasing in hashnoise.

* Add openmp-simd and target compiler flags when CMAKE_COMPILER_IS_GNUCC for batched target specific liboslexec libraries
Move filter_gabor_kernel_2d from gabornoise.h to .cpp to avoid unused function warning.

* Revert to reference 4d perlin noise for Clang vectorization.

* Utilize reference filter_gabor_kernel_2d which uses its own gabor_mul_m22_v2(const Matrix22& m, const Vec2& v) instead of relying on Imath version which differs in naming between OSL/matrix22.h and <Imath/ImathMatrix.h>
Move filter_gabor_kernel_2d back from gabornoise.cpp to .h to share it between gabornoise.cpp and sfm_gabornoise.h.
Disable Clang vectorization of strlen because resulting binary causes crashes in testsuite (TODO: investigate)

* To avoid "may be used uninitialized in this function [-Werror=maybe-uninitialized]" messages add extra (unnecessary) initialization, as its a unlikely fallback case shouldn't affect performance much.

* Disabled GCC optimizations for nonAffineInverse to allow results to match LLVM-IR version for Matrix44 inversion.
Implemented better optimization for transform normal when matrix is uniform.

* Mark nonAffineInverse definition as OSL_HOSTDEVICE to match its forward declaration.

* Added environment variable TESTSHADE_LLVM_JIT_FMA to force FMA generation for JIT'd code, needed to produce reference i mages for tests.

Fixed warning message that was accessing a null pointer when testshade requests FMA without specifiying a target.

Added out_LLVM_JIT_FMA.tif image for hashnoise tests whose results vastly differ for small changes in input values, so we need a 2nd test image to compare against when FMA is enabled for LLVM JIT.

* Rearranged local stack variables inside of sfm::simplexnoise4 to instantiate Vec4 locals closer where they are used.  This was necessary to get correct results with gcc (even with vectorization disabled), suspect issue with register overflow or stack stomping.

* Fix issue with impl_transform_normal_masked failing to vectorize when only the result is varying.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-08-18 15:31:32 -07:00
Larry Gritz 92a6055ab9 Add include to prepare for upcoming OIIO change (#1393)
OIIO 2.3 will rearrange some header files slightly. If you need to use
ImageCache, you must include imagecache.h (duh!). We were accidentally
relying on some leaked definitions in other header files, which will
soon be removed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-04 10:37:00 -07:00
Larry Gritz e3f40d764e CI: Bump some of the "latest" releases (#1392)
latest OpenEXR/Imath -> 3.1.0
latest pybind11 -> 2.7.0
latest fmt -> 8.0.0

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-03 08:05:51 -07:00
Larry Gritz 79cc3a3268 Convert some uses of temp vectors to span (#1390)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-03 08:05:29 -07:00
Larry Gritz 0406e48cef More string format convention modernization (#1389)
* OSLQuery::errorf (public)
* ShadingSysImpl::errorf, etc. (internals)
* Context::errorf (internals)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-22 22:58:17 -07:00
Larry Gritz 4bfdefdba5 Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-21 23:45:05 -07:00
Larry Gritz cd0fa5d7d7 CHANGES etc
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-20 20:45:24 -07:00
Larry Gritz 2f3c21ff7c Move from some long-deprecated OIIO things to modern equivalents (#1388)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-20 20:44:18 -07:00
Alex Wells 27cc863108 PR/BatchedMath -- algebraic, trig, transcendental (#1385)
Implement batched versions algebraic, trigonometric, and transcendental OSL library functions.
Add extensive regression tests to exercise binary and ternary operations with combinations of uniform, varying, and constant arguments.
Added some reusable xmacros for shaders in the testsuite/common/shader's directory to create unary, binary, and ternary test shaders.

Increase timeout of CI tests from 180 seconds to 240 seconds to allow comprehensive regression tests to complete.
Alternative is to break regression tests into separate test directories so the individually finish faster.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-07-08 11:38:44 -07:00
Larry Gritz d6ec4b828f Sanitize filenames when using "archive_groupname" (#1383)
This feature (used, very possibly, only by me, for debugging) lets me
force OSL to write an archive that contains the oso files and a
serialized version of the shader network.

If no explicit name is given (by the "archive_filename" attribute), it
picks a name based on the shader group name. But that may not be a
safe string for a valid filename. We already eliminated anything
before the last slash, but it turns out that a colon (':') and pipe ('|')
can also really mess things up. So this small change protects against that.

For the actual commands sent to system(), escape special characters
in the strings and enclose any arguments that come from the user in
double quotes. That prevents shenanigans like asking for an archive
filename called "; rm -r *". By enclosing in double quotes, we'll
end up with a badly named filename produced by tar, rather than
possibly an arbitrary command being executed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-01 23:08:15 -07:00
Larry Gritz 98e3aca1c9 Remove last calls to ambiguous OIIO format functions (#1382)
Background: OIIO now has errorf that are explicitly printf-like, and
errorfmt that are explicitly std::format-like, and also an old style
error() that is ambiguous.  The ambiguous calls are (at this moment)
aliases to the printf ones, but will be deprecated at some point (and
may, later when it seems safe, get reborn as the std::format compliant
behavior).

This roots out and removes the last few calls to the old ambiguous
ones from the OSL codebase.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-01 23:06:34 -07:00
Larry Gritz b0ed183b90 CI gcc and llvm testing changes (#1381)
* Update the "bleeding edge" CI test to gcc-11, and also LLVM 12,
  which we hadn't tested before.
* A "latest releases" CI test uses gcc10 and LLVM 11.
* Turns out that nothing else on the OSL side needed to be fixed to
  accommodate gcc 11 (though you need a very up-to-date OIIO if you
  want to compile it with gcc11 unless you turn warnings off).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-21 10:29:06 -07:00
Larry Gritz cfc679ad8b CI: speed up OIIO build for CI by not building its tests (#1380)
Was using the wrong notation before.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-21 10:28:30 -07:00
Larry Gritz b9ca59ea61 CI: have a clang11 test, also test batched shading with clang (#1379)
Along the way, discovered a couple clang-specific warnings when using
C++17.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-21 10:28:16 -07:00
Alex Wells 135b087017 PR/BatchedMatrix (#1378)
* Implement batched matrix ops, including transform, determinant, transpose, and construction and getmatrix with spaces, multiplication, division, negation.
Moved helpers det2x2, det3x3, and det4x4 from opmatrix.cpp to Imathx.h so they could be shared with the wide_opmatrix.cpp.
Enabled BATCHED testing for matrix and transform testsuites
Added new BATCHED_REGRESSION testsuites array-reg, matrix-arithmetic-reg, matrix-compref-reg, matrix-reg, transform-reg to more fully exercise combinations of uniform and varying data types and indexing variables.

* Removed #if 0 code block of determinant match that was moved to Imathx.h

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-06-15 18:31:56 -07:00
Larry Gritz 7f8a1a1702 Now that gcc minimum is gcc6, remove use of boost::regex (#1377)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-02 10:57:05 -07:00
Larry Gritz d755edf4f4 Bump minimum C++ to 14 and update compiler mins to match (#1369)
As discussed at the TSC meeting and on the mail list, I won't merge this
change until June 1. It will only be in master (future OSL 1.12), not
backported to any release branch.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-01 15:39:53 -07:00
Alex Wells 0c0e6d4b42 Batched control flow and string ops (#1373)
* Implement batched loop control flow (including, break, continue) along with early outs (return, exit).  Also add batched support for printf and other string operations.  Implement batched support for shadingsystem ops like bind_interpolated_param, get_userdata, rangecheck, uninitcheck_values, and nancheck.  Implement batched support for negate, min/max, arraycopy, compassign, mxcompref, mxcompassign, .Added BATCHED_REGRESSION tests to the suite to exercise control flow and string ops and compare scaler and batched results.  Enabled various tests to also execute in BATCHED mode.  Enable unoptimized BATCHED mode testing, as constfolding was avoiding any work in optimized mode for some tests.
Fixed bug in testshaded batched mode that inverted population of x and y shader global values, but only noticed in order of side effects like printf in shaders.
Added buffered file support to ShadingSystem to allow batched fprint to write out to files in the correct order.
Fixed bug in BatchedAnalysis which was not handling unlocked geom correctly by requiring unlocked input parameters be varying inorder to accept Wide results from BatchedRendererServices::get_userdata.

LLVM_Util had previously added support managing masks, and its strategy should
be reviewed before trying to understand this commit's changes:

    // Overview of masking strategy
    //
    // For if/then based on a conditional, the result of the conditional is
    // conditionals written to a symbol that is a wide boolean.  To handle
    // nesting we will keep a stack of conditional masks.  When a new
    // conditional mask is pushed, it is combined with the previous mask on
    // the top of the stack.  It is the top of the mask stack that is used
    // as the mask for any instructions requiring masking.  When a
    // conditional scope is exited, we just pop the top of the conditional
    // mask stack.
    //
    // Loops are handled by pushing their conditional result onto the
    // conditional mask stack, and popping it back off at the end of the
    // loop.
    //
    // Handling of early outs (exit, return, break, continue) is done by
    // storing a mask representing the lanes which are going to be
    // deactivated (or continue executing) to an allocated location in the
    // stack. We actually have to store these early out masks, so that we
    // can apply it to the conditional mask stack.  As that stack unwinds,
    // any early out masks are applied to the top of the conditional mask
    // stack.  As there are different types of early outs that apply to
    // different control flow scopes and multiple types can be present at
    // the same time for different data lanes, we must store these early
    // out masks at separate locations on the stack.
    //
    // To handle 'exit', we allocate a 'shader mask' that is initially
    // populated with a startMaskValue representing the active lanes in a
    // shader global batch.  For example perhaps only 7 of 16 data lanes
    // are populated, the startMaskValue would store that value and push it
    // onto the conditional mask stack.  We require a location on the stack
    // for this 'shader mask' in order for an 'exit' statement to modify it
    // and cause a subset of the lanes to be deactivated.  If an exit was
    // processed, the 'shader mask' is where it will be stored and pulled
    // from when applying to the unwinding conditional mask stack.
    //
    // To handle 'return', we allocate a 'function mask' that is initially
    // populated with a startMaskValue representing the active lanes when
    // an inlined function was called.  This startMaskValue should just be
    // value at the top of the conditional mask stack.  As function calls
    // can be nested, we maintain a stack of function masks.  We require a
    // location on the stack for each 'function mask' in order for a
    // 'return' statement to modify it and cause a subset of the lanes to
    // be deactivated.  If an return was processed, the 'return mask' is
    // where it will be stored and pulled from when applying to the
    // unwinding conditional mask stack. When a function scope is exited,
    // the function mask is popped so any return's processed would apply to
    // the outer function mask vs. the one just exited.
    //
    // To handle 'break', we use the condition symbol's location on the
    // stack to directly disable data lanes for the loop execution.  As we
    // already had a location to store the conditional symbol's mask, no
    // need to allocate or store a separate one.  However code will need to
    // reload the condition's value when a break 'could have been' called
    // vs. relying on a conditional result already in a register.
    //
    // To handle 'continue', we allocate a 'continue mask' that is
    // initially populated with a 0 representing the deactived lanes by
    // 'continue' operations. We require a location on the stack for each
    // 'continue mask' in order for a 'continue' statement to modify it and
    // cause a subset of the lanes to be deactivated.  If an continue was
    // processed, the 'continue mask' is where it will be stored and pulled
    // from when applying to the unwinding conditional mask stack. When a
    // loop's scope is exited, the continue mask is popped so it would't be
    // applied to an outer loop.
    //
    // The logic of when and how to actually apply these masks is handled
    // by the caller, tracking/storing the different stacks and masks is
    // handled here.  And queries exist to see how many early outs
    // operations have been processed, these counts can be used by the
    // caller to determine which to generate code to apply each of them.

In our case BatchedBackendLLVM is the caller and during code gen will be calling:
    push_shader_instance(llvm::Value* startMaskValue) and pop_shader_instance()
    push_function_mask(llvm::Value* startMaskValue) and pop_function_mask()
    push_masked_loop(llvm::Value* location_of_control_mask, llvm::Value* location_of_continue_mask) and pop_masked_loop()
And to handle if/then/else be calling
    push_mask(llvm::Value *mask, bool negate, bool absolute) and pop_mask()
By checking masked_exit_count(), masked_return_count(), masked_break_count(), and masked_continue_count()
before and after code gen of a function call, then block, else block, loop body, etc.
we can detect if a exit, return, break or continue existed in the generated scope
and then can call apply_exit_to_mask_stack(), apply_return_to_mask_stack(),
apply_break_to_mask_stack(), or apply_continue_to_mask_stack() when needed.

Add utility function "foreach_unique" to provide scalar execution of a Functor
for each unique value in the a Wide data block along with a mask identify which
data lanes match the unique value.

Add utility function "unproxy(const T &elem)" to extract value type from a proxied
element.  This is alternative to static_cast<ValueType>(elem), and better self documents.

Fixed compatibility bug where llvm 9+ asserted that bool was not a valid datatype for llvm::ConstantDataVector::getSplat.
Added LLVM_Util::test_mask_lane(llvm::Value *mask, llvm::Value * lane_index) to test a mask with a variable lane index.

* Updated OIIO::vformat calls to OIIO::sprintf.
Conditionally compile buffered_file_output_mutex to avoid unused variable warning when not building with USE_BATCHED.
Ran couple files through clang-format.

* Initialize local variable mask_slot to avoid maybe-uninitialized errors

* Fixed paths to additional oiiodiff that runs when a test fails to find a match to use the /baseline subdir when performing a BATCHED_REGRESSION test.
Improved control-flow-test to use 0.5 default value instead of 0 to tell difference between actual assignment and 0's on the heap.

* Changed some control-flow-reg tests to use non-zero default values to tell difference between uninitialized heap and setting of default values.
Changed order of parameters so that any initops that contain an "exit" are the final parameter so the exit doesn't skip assigning default values.  Otherwise those parameters would be uninitialized data and cause intermitent CI failures.

* Deleted extraneious cmakefile settings for clang

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-06-01 15:38:58 -07:00
Larry Gritz bc5b969a59 CMake fixes (#1376)
* "SOVERSION" option was set twice, oops!
* Stray "OIIO" in a name that should have been this project's name.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-26 09:23:01 -07:00
Larry Gritz ae2edaceb8 CI: Bump OpenEXR versions to the latest patches in each branch (#1374)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-25 22:55:34 -07:00
Niklas Harrysson 35c9ae7e22 Add declarations of MaterialX closures (#1371)
This PR adds closure declarations for the MaterialX PBS nodes. A discussion of their design has been ongoing in a thread at the MaterialX GitHub repo. The full history of this discussion can be found here: https://github.com/materialx/MaterialX/pull/614

Signed-off-by: Niklas Harrysson <niklas.harrysson@gmail.com>
2021-05-25 22:55:01 -07:00
Larry Gritz 908000e595 Fix SPI compilation (everybody else can ignore).
Mostly just getting rid of support for compilers and boost versions we
no longer use. But also some openexr version finding fixes.
2021-05-22 09:35:03 -07:00
Larry Gritz 11ba289f5f Build: llvm-config --system-libs needs --static for LLVM_STATIC (#1375)
This fixes CI in the Mac test. Something about the Homebrew upgrade to llvm 12.0.0_1 made this fix necessary to build.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-22 09:15:57 -07:00
Larry Gritz 9f91311c78 CI: Change our clang-format standard to clang11 (#1372)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-21 16:06:02 -07:00
Larry Gritz 1435e3a202 Output variable placement (#1328)
Up until now, client apps declare which output variables are "renderer
outputs" before shader groups are compiled, and also after a shader is
executed, it is up to the app to extract the individual output values
and do with them what it needs to do. Those outputs live on the shader
heap (the temp storage used to run the shader), and information about
where it lives on the heap can be retrieved via find_symbol() and
symbol_address().

New paradigm:

Various inputs and outputs of shaders live in different memory arenas,
and for those inputs/outputs, the app declares (prior to shader group
compilation) which arena it lives in, its offset within the arena, and
the stride between entries (for different shades, such as different
rays in flight, different points on a mesh, pixels in an image, etc.).
The shader JITs into code that automatically pull inputs from their
sources and copy outputs to their destinations with no need for client
app code to call find_symbol or symbol_address or do any extra data
copies.

This symbol location data is communicated to the shading system through
new calls to add_symlocs() passing a new struct called a SymLocationDesc,
which has the aformentioned arena, offset, stride, etc.

Right now, the only supported arena is Outputs, and the actual call
signature to execute(), and to the shader JIT code itself, includes
extra parameters for the base pointer to the output arena (this could
conceivably change from shade to shade) and the integer shade index of
this shade.

I've tried to set this up in a general way, so that additional arenas
will be added later -- places where ShaderGlobals can be customized,
UserData, etc. Also there are placeholders for being able to talk about
absolute addreses and offsets into the heap, though I don't use them
at the moment. Some of the flexibility may be later removed as we learn
more about how we want to use this.

To show it in action, I have modified the "osldeformer" example to use
this new method to place the outputs directly where we want them.
It's just storing results into an array. The output arena base pointer
is the start of the array, the offset of the single output is 0, and
the stride is the size of each array element (one 3-float point).

As a much more complex example, testshade also uses the new technique
(unless you use --no-output-placement, but I'm not sure how long I'll
keep that). This is a good example of storing to images. Testshade thinks
of itself as shading pixels in an image, so there is an ImageBuf for every
renderer output (think of it like an AOV). The output arena base pointer
is the address of the (0,0) pixel of the ImageBuf for the first AOV; the
"offset" of each output variable is the address difference between that
AOV's first ImageBuf pixel and the arena base pointer, the stride is the
pixel data size for each output, and the shadeindex is the pixel index of
that shade.

It all works. Crazy!

OK, not quite all. Here's what hasn't been done yet:

  * testrender does not yet use the new API (only testshade)
  * GPU (have only tried CPU so far)
  * Batch shading -- I don't want to mess with this while Alex is
    still integrating all his work. We'll go back and catch the batch
    shading up after he's all done.

These will come in subsequent PRs.

All the old calls should still work, so this ought not to be a source
compatibility break for renderers using OSL. Not at this point, anyway.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-13 13:25:11 -07:00
Larry Gritz f2d0668c93 CI: Fix which openexr version is used for vfxp 2021 test
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-13 11:30:41 -07:00
Larry Gritz 7f2c3a6c0e CI script typo kept mac from recognizing ARCH properly (#1370)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-11 20:45:40 -07:00
Larry Gritz 0a97b2a96e Some minor cmake touch-ups (#1368)
* Left out some imath targets in liboslnoise

* Conform a couple libraries to conventions of the ${local_lib} notation
  we use in the othe rlibraries.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-11 20:43:03 -07:00
Larry Gritz f94bb6df40 CHANGES & docs fixes
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 16:28:50 -07:00
Larry Gritz 1e77b38d23 CI: Make sure we have some test coverage for batched shading mode (#1367)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-07 22:51:50 -07:00
Larry Gritz 6882703746 CI Mac fix: this was no longer necessary, and seemed to be problematic (#1366)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-05 18:11:52 -07:00
Larry Gritz 444261a11e Bump the default C++ mode to 14 (#1362)
This leaves the minimum C++ at 11, but bumps the default (if not set by
the user via CMAKE_CXX_STANDARD) from 11 to 14.

This is meant to start identifying any problems people have switching
to 14. We anticipate a hard switch to 14 minimum before the next OSL
major release. This change is in master only (i.e. future OSL), we would
never change minimum or default C++ standard in the supported release
branches (currently OSL 1.11.x).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-04 14:02:08 -07:00
Alex Wells 4292cc9974 USE_BATCHED cmake option listing target library to build. New BATCHED_REGRESSION testing mode. (#1357)
* Introduce cmake option USE_BATCHED to enabling building batched SIMD shader execution for a comma separated list of batch sizes, ISA's, and noFMA: (0, b8_AVX, b8_AVX2, b8_AVX2_noFMA, b8_AVX512, b8_AVX512_noFMA, b16_AVX512, b16_AVX512_noFMA)
When USE_BATCHED is set, -DOSL_USE_BATCHED=1 will be passed allowing for source files to conditionally compile in batched execution support.
When USE_BATCHED is set, cmake variable BUILD_BATCHED=True and projects can conditionally add batched sources to be built.
Updated OSL source with #ifdef OSL_USE_BATCHED/#endif were needed.
Improved/streamlined liboslexec/CMakeLists.txt to iterate over targets in USE_BATCHED vs. hardcoding all variants.
Updated _OSL_SUPPORTS_* defines to match USE_BATCHED values simplying creating compiler definitions in Cmake.

Added new BATCHED_REGRESSION testing mode, when a file named BATCHED_REGRESSION exists in a testsuite folder, the run.py will be executed and its output files copied to "./baseline".  The same run.py is then run again but with environment variable TESTSHADE_BATCHED=1, which cause testshade to execute in batched mode.  Then the results/image comparison happens between the batched output files and those in "./baseline".  The "./ref" dir is never used in a regression test.
Presence of BATCHED_REGRESSION prevents non-regression tests from being created for a folder.

Converted arithmetic-cov to be a BATCHED_REGRESSION test.
Removed testsuite/arithmetic-cov/ref image files.

Renamed ShadingSystem::supports_batch_execution_at(int width) to ShadingSystem::configure_batch_execution_at(int width) to better identify its behavior:  based on currently set attributes for llvm_jit_target and llvm_jit_fma, test if current machine is capable of supporting batched execution at the specified width.  If no specific llvm_jit_target was requested, sets llvm_jit_target and llvm_jit_fma to the supported configuration for the requested width.  Returns true if supported, false otherwise

Fix bug in batched Matrix*Matrix code generation where the order of arguments were being reversed (swap was intended to transform float*Matrix to a Matrix*float function call, but accidentally happened for Matrix*Matrix)

* Moved define of OSL_USE_BATCHED to oslconfig.h.in
Fixed order of includes in batched*.cpp so oslconfig.h is higher

* Renamed testsuite/arithmetic-cov to testsuite/arithmetic-reg to better represent it is a regression test.
Changed #ifdef OSL_USE_BATCHED to #if OSL_USE_BATCHED and rely on it being set to 0 or 1 by <OSL/oslconfig.h>

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-04-29 21:04:21 -07:00
Brecht Van Lommel ab7107cf23 Fix crash generating closure functions calls with LLVM 11 (#1361)
Generating code for prepare_closure and gen_closure was crashing.
The code now matches the implementation of the removed LLVM function.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2021-04-22 09:15:10 -07:00
Larry Gritz eccd335d78 Revert "SPI: Remove old cruft related to spcomp2, rez, and gcc-4.8"
This reverts commit 63026c7279.

I removed it prematurely and not carefully enough.
2021-04-20 09:12:12 -07:00
John Haddon 8dafa41262 OSLCompiler : Check for write errors (#1360)
Fixes #1352

Signed-off-by: John Haddon <jhaddon@cinesite.com>
2021-04-20 09:08:47 -07:00
Larry Gritz 58ca5c2f8d Build: be robust to certain OpenEXR 2.x config files (#1356)
Ever since adding OpenEXR 3.0 support, we had some cases where
installations that built the 2.x IlmBase and OpenEXR portions
separately and installing to separate areas, had trouble being found
properly.

Remove the need to include OpenEXR/OpenEXRConfig.h

Also make some minor changes to ci.yml to make sure we are documenting
the right openexr versions used for each test.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-19 13:53:29 -07:00
Larry Gritz e9d0dc3ec4 Update several stray references to the old repo URL (#1353)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-12 19:35:52 -07:00
Larry Gritz 7d6310d17c CMake 3.20 safety (#1354)
It seems that our liberal use of cmake argument `--config` should only
be used in conjunction with the `--build` flag, not for the initial
configuration step. Apparently this was just silently ignored for a
long time, but for CMake 3.20, it is an error and breaks a lot of our
CI cases and our build_blah.bash scripts.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-02 15:46:23 -07:00
Alex Wells 8727d61ec1 More work on batched shading -- ISA specific modules (#1345)
* Added building of ISA specific shared libraries lib_b16_AVX512_oslexec, lib_b8_AVX2_oslexec, lib_b8_AVX512_oslexec, lib_b8_AVX_oslexec to house precompiled OSL library functions that execute over batches of 8 or 16 in SIMD for the ISA.  Compiler flags for OpenMP simd code gen and ISA targets has been added for Intel(r) C++ Compiler (ICC) and CLang (newer versions of GCC 6+ might be possible, but untested).

Implement batched llvm code gen for:  generic function calls, useparam, compare ops,  addition, subtraction, multiplication, division, modulus, assignment, component reference, construct triple, construct color, derivative extraction.  Stubbed out all other code gen functions with TBD asserts.

Populate OpDescriptiors with valid wide version of llvm-generating routine

Added wide_opalgebraic.cpp which uses X-macros (instead of #define like llvm_ops.cpp) to define wide(batched) versions of OSL library functions:  sqrt, inversesqrt, floor, ceil, trunc, round, sign, abs, fabs, fmod, and step.
The X-macro wrappers follow a pattern of manufacturing a target specific library function name with enough parameter types embeded in its name to uniquely identify it (vs. other versions).  Then it declares local Wide<T> or Masked<T> wrappers that convert any void */char * parameters to references to Block<T,WidthT> data blocks of wide SOA data.  Then an explicit OpenMP simd loop iterates over the data lanes and extract a local scalar values from the Wide|Masked wrappers, then the scalar implementation of the library function is then inlined using the local scalar values.  Finally the result is writen back out to the data lane inside the Wide|Masked wrapper.  This paradigm allows scalar implementations to be resused inside simd loops and avoid having to use intrinsics or assembly.  It also allows the same implementation to be recompiled for different target ISA's and varius Widths (8|16).  The build system will create copy of each  wide_*.cpp to a target and batch size specific named b(8|16)_(AVX512|AVX2|AVX)_wide*.cpp and build it with different -D__OSL_TARGET_ISA and -D__OSL_WIDTH values which inturn will manufacture uniquie function names.  Sometimes scalar algorithms/functions can be refactored to provide better performance when executing inside a SIMD loop.  sfmath.h (SIMD friendly math) houses these alternative math functions, although many improvements have already been moved into OIIO as they benefit (or do no harm) to scalar code gen.

Made ShadingContext remember the ShaderGroup it just optimized.  This allows symbol queries without actually jitting or executing a shader.

Improved TestShade to not actually execute the shader during setup_output_images, but to instead explicitly JIT scalar or batched version of the ShaderGroup (primarily to make sure JIT happens during the "setup" stage vs. lazily later).
Fix TestShade to explicitly set the number of OIIO worker threads to avoid overhead (and debugging confusion) of OIIO thread pools being created even when "-t 1" was requested.

Modified ShadingSystem to only perform group_post_jit_cleanup (delete operations of shader group) only if both scalar and wide JIT's have occured or if RendererServices doesn't support batching.  Without this changed the operations were being deleted before a batched JIT could occur.

Extended testsuite framework to look for file named "BATCHED" which causes another run of the test with TESTSHADE_BATCHED=1
Added testsuite new tests with BATCHED enabled for passing tgh shaderglobal values, and increased coverage of arithmetic tests with reference images for float, color, point, vector, normal data types along with Dx Dy results.

Added utility macros  __OSL_CONCAT,  __OSL_CONCAT3, ...,  __OSL_CONCAT10 to be able to easily manufacture function names.
Added macro __OSL_WIDE_PVT to give each target specific library its own namespace avoiding collisions should multiple libraries be loaded.
Added sfm::negate(const T &x) with optimized implementation.

Disabled some unreferenced functions warnings for ICC and removed some unused functions from batched_analysis.cpp
Updated BatchedBackendLLVM to match behavior of BackendLLVM by configuring its LLVM_Util based on ShadingSystem attributes.

Disable clang format for X macro based building of initializer arrays to prevent clang format from reordering the #include files.
Fix control flow in factory function TargetLibraryHelper::build to not trigger assert unnecessarily.

Limit list of OSL library functions in builtindecl_wide_xmacro to just those we have implemented so far because all functions listed must exist in the target specific library for it to successfully be loaded and resolved.

Added LLVM_Util::op_zero_if(llvm::Value *cond, llvm::Value *v) which allows its implementation to work around an LLVM issue where expensive instructions to produce the value (div, sqrt, etc) are duplicated (once with a mask, once without).

Fix bug in ShadingSystem::supports_batch_execution_at where jit_fma was being accidentally negated causing rest of logic to fail.
Implement ShadingSystem::BatchedExecutor<WidthT>::jit_group

* In Cmake, changed ISA specific target libraries from SHARED to MODULE so that on OSX they will be named .so instead of .dylib.
Moved new arithmetic tests into their own subdirectory arithmetic-cov so that the existing arithmetic test can run in non-batched mode as it uses printf which is still TBD for the batched version.
Fixed bug where shader ops weren't being cleaned up unless batched jit had occured.
Fixed compilation issue with newer LLVM versions and LLVMUtil::zero_if

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-04-01 23:35:15 -07:00
Larry Gritz 63026c7279 SPI: Remove old cruft related to spcomp2, rez, and gcc-4.8
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-01 23:04:55 -07:00
Larry Gritz c32c1ed799 Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-29 21:46:35 -07:00
2267 changed files with 216195 additions and 35255 deletions
+2 -2
View File
@@ -4,7 +4,6 @@
Language: Cpp
BasedOnStyle: WebKit
SpaceBeforeParens: ControlStatements
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
@@ -84,6 +83,7 @@ IncludeCategories:
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
@@ -128,7 +128,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: c++14
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
+41
View File
@@ -6,3 +6,44 @@ bdb473cbdb119f3d9060d48f75f965cbd45f6d7a
# More clang-format: liboslquery, oslinfo, oslc, osl.imageio, osltoy (#1220)
bf366d7a90c46599b82071dac6dbef7c5e3ca157
# Turn on clang-format for cpp files in testsuite (#1269)
00c895fc642eb89685797c292048bdff15d675e7
5e848fb761261521a3ee7cd8a4f6814f32fe4a47
# CI: Change our clang-format standard to clang11 (#1372)
91d22ebe2f65d4ed0599e421172a15d99fe0e1b4
# More clang-format (this time, testrender and liboslnoise) (#1511)
08706b7cbac781b6a9389780428016be985d9d89
# clang-format #1509
b4026fd1695c08532557b3ba1c2142323087ccf9
1f73b075c99861afa42fac44567b37f797bc72f2
7f2e83794e6fa63d5180653cffb77be2cc38b32b
28399fefc890442b5ac020e7a90cee0d5bf9f03c
e56851056d33233b0bb8324faac251907099961a
1c57fc61d8ab7c3f309be4335e4c71c26399edd4
46d451ce74d00e904874df476ebeca19bb119ea9
c1045f2c2845a98e661c7181932a031eb3c76063
# More clang-format (#1512)
8c6ffdd911b9eb7db4adf41ab88891360452d7c5
# style: more clang-format (#1515)
102430c83554fe7e328cd8c3317db00507bcfaba
# Revert some formatting (#1518)
21eac9d9215d071b0a7b9ce2c32f189ed0c62c4a
# Another round of clang-format (#1540)
38015b6be28643254aea530154b7860136cf5e15
89d5db2b5c5fda79184d8245d903e580fc6a4e9c
# clang-format: the very last piece of the puzzle (#1555)
4ee62cd2ef05543f818f4d95a19efc1d684a7381
5be7c6bd4e7bd2e560cb6be8c06f11985384a87a
# Raise CI formatting standard to clang-format 17
a9ce35135e6c022d538a4a184fee1b5ce908aed8
90d94caecbb97141c9df63abc634be6e8394b6c3
+4 -3
View File
@@ -15,8 +15,9 @@
<!-- Put an 'x' in the boxes as you complete the checklist items -->
- [ ] I have read the [contribution guidelines](../CONTRIBUTING.md).
- [ ] I have previously submitted a [Contributor License Agreement](http://opensource.imageworks.com/cla/).
- [ ] I have updated the documentation, if applicable.
- [ ] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
- [ ] My code follows the prevailing code style of this project.
- [ ] My code follows the prevailing code style of this project. If I haven't
already run clang-format v17 before submitting, I definitely will look at
the CI test that runs clang-format and fix anything that it highlights as
being nonconforming.
+134
View File
@@ -0,0 +1,134 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
name: Analysis
on:
schedule:
# Run nightly while we're still working our way through the warnings
- cron: "0 8 * * *"
# Run unconditionally once weekly
# - cron: "0 0 * * 0"
push:
branches:
- main
- '*analysis*'
paths-ignore:
- '**.md'
- '**.rst'
- '**.tex'
# Allow manual kicking off of the workflow from github.com
workflow_dispatch:
permissions: read-all
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
aswf:
name: "SonarCloud Analysis"
if: |
github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
strategy:
fail-fast: false
matrix:
include:
- desc: sonar gcc9/C++14 llvm13 py3.9 boost1.76 exr3.1 oiio2.3 avx2
nametag: static-analysis-sonar
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang13
cxx_std: 14
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.9.0
simd: avx2,f16c
batched: b8_AVX2,b16_AVX512
coverage: 1
# skip_tests: 1
sonar: 1
setenvs: export SONAR_SCANNER_VERSION=4.7.0.2747
SONAR_SERVER_URL="https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR=bw_output
OSL_CMAKE_BUILD_WRAPPER="build-wrapper-linux-x86-64 --out-dir bw_output"
CMAKE_BUILD_TYPE=Debug
CMAKE_UNITY_BUILD=OFF
CODECOV=1
TESTRENDER_AA=1
OSL_TESTSUITE_SKIP_DIFF=1
CTEST_TEST_TIMEOUT=1200
OSL_CMAKE_FLAGS="-DOSL_TEST_BIG_TIMEOUT=1200 -DUSE_QT=0"
CTEST_EXCLUSIONS="broken|noise-reg.regress|noise-gabor-reg.regress"
runs-on: ${{ matrix.os }}
container:
image: aswf/ci-osl:${{matrix.vfxyear}}${{matrix.vfxsuffix}}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
OPENIMAGEIO_VERSION: ${{matrix.openimageio_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
USE_BATCHED: ${{matrix.batched}}
USE_SIMD: ${{matrix.simd}}
# DEBUG_CI: 1
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
fetch-depth: '0'
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Remove existing OIIO
if: matrix.openimageio_ver != ''
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*
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- name: Code coverage
if: matrix.coverage == '1'
run: src/build-scripts/ci-coverage.bash
- name: Sonar-scanner
if: matrix.sonar == 1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner -X --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="build/bw_output" --define sonar.cfamily.gcov.reportsPath="_coverage"
+489 -514
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenshadingLanguage
name: Publish Release Notice to ASWF Slack
on:
release:
types:
- published
# published should cover both 'released' and 'prereleased'
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Notify Slack
id: slack
with:
project_name: "Open Shading Language"
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel: "#release-announcements"
project_logo: "https://artwork.aswf.io/projects/openshadinglanguage/Icon/Color/openshadinglanguage-Icon-Color.png"
uses: jmertic/slack-release-notifier@main
+75
View File
@@ -0,0 +1,75 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
name: Scorecards supply-chain security
on:
# Only the default branch is supported.
branch_protection_rule:
schedule:
- cron: '44 20 * * 6'
push:
branches: [ "main", "scorecard" ]
paths-ignore:
- '**.md'
- '**.rst'
- '**.tex'
# Declare default permissions as read only.
permissions: read-all
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
analysis:
name: Scorecards analysis
if: |
github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Used to receive a badge. (Upcoming feature)
id-token: write
steps:
- name: "Checkout code"
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@3e15ea8318eee9b333819ec77a36aca8d39df13e # v1.1.1
with:
results_file: results.sarif
results_format: sarif
# (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results for public repositories to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with:
sarif_file: results.sarif
+3
View File
@@ -8,3 +8,6 @@ build
\#*\#
*.pyc
*.log
.vscode
.envrc
+47
View File
@@ -0,0 +1,47 @@
# This file establishes email equivalences so we can resolve what look like
# multiple authors, but actually are the same author who has used multiple
# emails over the course of their involvement with the project.
#
# The format is any of the following:
# <CANONICAL-EMAIL> <alternate-email>
# CANONICAL-NAME <CANONICAL-EMAIL> <alternate-email>
# CANONICAL-NAME <CANONICAL-EMAIL> alternate-name <alternate-email>
#
# You can check for duplicates with this command:
# git shortlog -sne --all
# That command (and others) will use this file to collapse the duplicates.
#
# If you see any duplicates we don't account for here, or if you look at your
# own entry here and want a different name or email to be your canonical one
# (we may not have guessed correctly and matched your preferences), please
# file a PR with the edits to this file.
Adam Martinez <amartinez.cg@gmail.com> amartinez-cg <amartinez.cg@gmail.com>
Alejandro Conty <aconty@imageworks.com> aconty <aconty@gmail.com>
Alejandro Conty <aconty@imageworks.com> Alejandro Conty <aconty@gmail.com>
Alex M. Wells <alex.m.wells@intel.com> <alex.m.wells@intel.com>
Alex M. Wells <alex.m.wells@intel.com> <AlexMWells@users.noreply.github.com>
Alex M. Wells <alex.m.wells@intel.com> <awells-np@argon.sea.pixar.com>
Alexis Oblet <alob@mikrosimage.eu> Alexis Oblet <aoblet@users.noreply.github.com>
Brecht Van Lommel <brecht@blender.org> <brecht@solidangle.com>
Brecht Van Lommel <brecht@blender.org> Brecht Van Lommel <brechtvanlommel@gmail.com>
Chris Kulla <ckulla@gmail.com> <ckulla@imageworks.com>
Chris Kulla <ckulla@gmail.com> <fpsunflower@users.noreply.github.com>
Chris Kulla <ckulla@gmail.com> Christopher Kulla <ckulla@gmail.com>
Chris Kulla <ckulla@gmail.com> fpsunflower <ckulla@gmail.com>
Clifford Stein <cstein@imageworks.com> Cliff Stein <clifford.stein@gmail.com>
Clifford Stein <cstein@imageworks.com> cmstein <cstein@imageworks.com>
Declan Russell <declan.russell@autodesk.com> Declan Russell <i7709212@bournemouth.ac.uk>
Derek Haase <derekhaase@gmail.com> Derek Haase <dhaase@imageworks.com>
Esteban Tovagliari <ramenhdr@gmail.com> est77 <ramenhdr@gmail.com>
Henri Fousse <henri.fousse@free.fr> darkhorse64 <henri.fousse@free.fr>
Larry Gritz <lg@imageworks.com> <larrygritz@gmail.com>
Larry Gritz <lg@imageworks.com> <lg@larrygritz.com>
Roman Zulak <marsupial@users.noreply.github.com> <rzulak@imageworks.com>
Roman Zulak <marsupial@users.noreply.github.com> Frederich Munch <marsupial@users.noreply.github.com>
Roman Zulak <marsupial@users.noreply.github.com> marsupial <marsupial@users.noreply.github.com>
Ronan Keryell <Ronan.Keryell@amd.com> Ronan Keryell <Ronan.Keryell@silkan.com>
Steena Monteiro <steena.monteiro@intel.com> steena.monteiro <smonteir@ortce-sklaw.jf.intel.com>
Sven-Hendrik Haase <sh@lutzhaase.com> Sven-Hendrik Haase <svenstaro@gmail.com>
Tim Grant <tgrant@nvidia.com> Tim Grant <87798327+tgrant-nv@users.noreply.github.com>
Tim Grant <tgrant@nvidia.com> timgrant <timgrant@users.noreply.github.com>
+29
View File
@@ -0,0 +1,29 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# Build documentation with Sphinx
sphinx:
configuration: src/doc/conf.py
# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- htmlzip
# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: src/doc/requirements.txt
+1 -1
View File
@@ -200,7 +200,7 @@ must comply with the terms of this Charter.
- **i.** All new inbound code contributions to the Project must be made
using the BSD 3-Clause License (available here:
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/LICENSE)
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/LICENSE.md)
(the "Project License").
- **ii.** All new inbound code contributions must:

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

+5 -4
View File
@@ -5,13 +5,14 @@ This is a checklist for TSC's to review as part of the intake process. The TSC s
- Existing Project Governance
- [X] Project License exists ( [LICENSE.md](../LICENSE.md) ) and is OSI-approved
- [X] Any third-party components/dependencies included are listed along with their licenses ( [THIRD_PARTY.md](../THIRD_PARTY.md) )
- [X] Governance defined, outlining community roles and how decsions are made ( [GOVERNANCE.md](../GOVERNANCE.md] )
- [X] Governance defined, outlining community roles and how decisions are made ( [GOVERNANCE.md](../GOVERNANCE.md) )
- Closed by https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1137
- [X] Contribution Policy defined ( [CONTRIBUTING.md](../CONTRIBUTING.md) )
- Closed by https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1137
- [X] Code of Conduct defined ( existing or pull from [ASWF Sample Project](https://github.com/AcademySoftwareFoundation/aswf-sample-project/blob/master/CODE_OF_CONDUCT.md) )
- Closed by https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1137
- [ ] Release methodology defined ( [release.md](process/release.md) )
- [X] Release methodology defined ( [RELEASING.md](../docs/RELEASING.md) )
- Closed by https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1572
- New Project Governance
- [X] TSC members identified
- [X] First TSC meeting held
@@ -41,7 +42,7 @@ This is a checklist for TSC's to review as part of the intake process. The TSC s
- [X] New project announcement done ( https://www.aswf.io/osl-joins-aswf/ )
- [X] Project added to ASWF website and ASWF landscape
- Graduation
- [ ] CII Badge achieved
- [X] OpenSSF Best Practices Badge achieved
- [ ] Committer Diversity established
- [ ] Commit/Contribution growth during incubation
- [ ] Committers defined in the project ( [COMMITTERS.csv](COMMITTERS.csv) or [COMMITTERS.yml](COMMITTERS.yml) )
@@ -50,4 +51,4 @@ This is a checklist for TSC's to review as part of the intake process. The TSC s
- [X] License scan completed and no issues found
- Minor issues were found but already fixed in PR https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1145
- [X] Code repository imported to ASWF GitHub organization
- [ ] Developer Certificate of Origin past commit signoff done and DCO Probot enabled.
- [X] Developer Certificate of Origin post commit signoff done and DCO Probot enabled.
+646 -13
View File
@@ -1,17 +1,437 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Release 1.12 -- ?? (compared to 1.11)
--------------------------------------------------
Release 1.13.11.0 -- 1 Sep 2024 (compared to 1.13.10.0)
---------------------------------------------------------
- *fix/batched*: Assume BatchedRendererServices texture derivatives are in st space. [#1828](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1828) (by sfriedmapixar) (1.13.10.0)
- *fix*: Make backfacing shadeop indicate backfacing shader-global is needed [#1827](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1827) (by sfriedmapixar) (1.13.10.0)
- *deps*: Handle various OpenImageIO deprecations and changes in the run-up to OIIO 3.0 [#1834](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1834) [#1806](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1806) [#1838](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1838) [#1842](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1842) [#1850](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1850) (1.13.10.0)
- *deps*: Adjust to OIIO change to IC/TS API [#1848](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1848) (1.13.10.0)
- *deps*: Llvm 18 compat issue - include libclangAPINotes [#1812](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1812) (1.13.10.0)
- *deps*: Make finding bison work better on Apple Silicon Macs + homebrew [#1822](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1822) (1.13.10.0)
- *ci*: Mods to CI to deal with OIIO master raising dependency mins [#1833](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1833) (1.13.10.0)
- *ci*: Deal with CentOS 7 EOL and disappearance of yum mirrors [#1839](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1839) (1.13.10.0)
- *ci*: Fix GHA CI after they upgraded nodejs [#1837](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1837) (1.13.10.0)
- *admin*: Change release notice icon to use the icon vs the normal logo so it shows up better [#1777](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1777) (by John Mertic) (1.13.10.0)
Release 1.13.10.0 -- 1 June 2024 (compared to 1.13.9.0)
--------------------------------------------------------
- *testrender*: Implement new Oren-Nayar model from OpenPBR [#1817](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1817) (by Christopher Kulla)
- *docs*: Fix outdated or wrong repo URLs [#1811](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1811)
Release 1.13.9.0 -- 1 May 2024 (compared to 1.13.8.0)
--------------------------------------------------------
- *deps*: Support for LLVM-18 [#1773](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1773) (by مهدي شينون (Mehdi Chinoune) [#1803](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1803) (by Larry Gritz)
- *fix*: Make isconnected() work with downstream renderer "connections." [#1782](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1782) (by sfriedmapixar)
- *cleanup*: Change OSL_CONSTEXPR14 to constexpr [#1805](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1805)
- *internals build*: Fix ifdef typo [#1804](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1804)
- *build*: Propagate cpp version [#1797](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1797)
- *build*: Print commit hash of locally built dependencies [#1798](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1798)
- *ci*: Lock down to OIIO 2.5 for icc tests [#1799](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1799)
- *ci*: Suppress leak sanitizer warnings about internals of robin_hash [#1807](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1807)
- *docs*: More detail about supported platforms in INSTALL.md [#1796](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1796)
Release 1.13.8.0 -- 1 Apr 2024 (compared to 1.13.7.0)
--------------------------------------------------------
* *fix(batched)*: Codegen bug for compref with varying index for batched shading [#1776](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1776) (by Alex Wells)
* *fix*: Calculatenormal needs fliphandedness [#1783](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1783) (by sfriedmapixar)
* *fix*: Print closure missing error message at compile time instead of run time. [#1781](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1781) (by sfriedmapixar)
* *int*: Change long-deprecated OIIO macro to new one [#1788](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1788)
* *ci*: Fix broken Macos-13 CI [#1780](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1780)
Release 1.13.7.0 -- 1 Mar 2024 (compared to 1.13.6.1)
--------------------------------------------------------
* *fix*: Mute partio error prints [#1774](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1774) (by olegul)
* *ci*: Test with Mac ARM runner [#1770](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1770)
* *docs*: Fix links to RTD docs from github landing page [#1768](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1768)
* *admin*: Switch release announcement workflow to jmertic's awesome action [#1766](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1766)
<br>
Release 1.13 -- Feb 1, 2024 (compared to 1.12)
===============================================
- beta 1: December 20, 2023
- release v1.13.6.1: Feb 1, 2024
### New minimum dependencies and compatibility changes:
* For GPU/OptiX mode, OptiX 6.0 support has been removed. For GPU rendering
with OptiX, a minimum of OptiX 7.0 is required, and the Cuda minimum has
been raised to 9.0 [#1737](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1737)
* The minimum version OpenImageIO has been raised from 2.2 to 2.4. [#1591](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1591) [#1722](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1722)
* The minimum CMake dependency has been raised from 3.12 to 3.15
[#1724](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1724) (1.13.5.0)
* The minimum Imath/OpenEXR has been raised from 2.3 to 2.4. (Note: OSL 1.13
is probably the last major release family that will support Imath/OpenEXR
2.x.)
### OSL Language and oslc compiler:
* There have been no substantive changes to the OSL language in this release.
### ⛰️ API changes, new options, new ShadingSystem features (for renderer writers):
* A new `shadingStateUniform` pointer field was added to ShaderGlobals for
planned future expansion and improved GPU support. #1585 (1.13.1.0)
* Adding relaxed type-equivalency to ReParameter() [#1639](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1639) (by cmstein) (1.13.2.1)
* Expose llvm groupdata size as a shadergroup attribute
[#1642](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1642) (by Chris Hellmuth) (1.13.4.0)
* RendererServices API for letting get_texture_handle consider colorspace
[#1641](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1641) (1.13.4.0)
* Make "compile_report" attribute an int instead of just 0/1. Passing 1 makes
a brief report, values >1 are more verbose. (Zero still prints no report.)
[#1654](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1654) (1.13.4.0)
* Switch `lockgeom` to `interpolated` and `interactive`. The `lockgeom=0`
was confusing. Now we use `interpolated=1` to mean "don't optimize it away
because it might be interpolated across the geometry and thus won't have
the same value at all points being shaded," and the subtly different
`interactive=1` to mean "don't optimize it away because although it will
always take on the same value at all points at the same time, the user
might want to interactively adjust the value and we don't want to have
to recompile the shader group if that happens."
[#1662](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1662) (1.13.4.0)
* Add type information for needed attributes. [#1650](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1650) (by Curtis Black) (1.13.4.0)
* Add API for building attribute getter free functions.
[#1704](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1704) (by Curtis Black) (1.13.5.0)
* Rs fmt specification - Journaling Algorithm for error, warning, fprintf
[#1702](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1702) (by Steena Monteiro) [#1711](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1711) [#1715](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1715) (1.13.5.0)
### 🚀 SIMD batched shading mode
* Fix some array overruns (asymptomatic, but still potentially buggy) in
common_ancestor_between. #1577 (1.13.0.2)
* Fix issue with closure keyword parameters. #1620 (1.13.2.0/1.12.8.0)
* Fix crash when adding a default initialized closure. #1624
(1.13.2.0/1.12.8.0)
* Fix support for closures with array types. #1630 (1.13.2.0/1.12.8.0)
* Fix bug with masked wide llvm_gen_closure() [#1637](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1637) (by danieldresser-ie) (1.13.2.1)
* Fix Force LLVM Boolean [#1717](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1717) (by Alex Wells)
* Batched pointcloud if "index" is not passed [#1753](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1753) (by Alex Wells)
### 🚀 OptiX GPU rendering
* OptiX 6.0 support has been removed. For GPU rendering with OptiX, a minimum
of OptiX 7.0 is required.
* Big overhaul/simplification of how strings are represented on the GPU: the
extra level of indirection to global variables is removed, and strings are
simply represented in ordinary variables as the hash of their characters.
#1531 (1.13.0.0) #1553 (1.13.0.1)
* Better PTX cache hit rate by eliminating several sources of not being
strictly deterministic in the PTX text we were generating. #1566 #1570
(1.13.0.1)
* Fix PTX symbol visibility issues. #1609 (1.13.2.0)
* Hide more code that is only used for OptiX mode, when OptiX is disabled.
#1608 (1.13.2.0)
* Remove dependency on OptiX SDK for building core OSL with OptiX support. You
can now build OSL with OptiX support enabled even if you don't have the
OptiX SDK headers present at build time. But you will still need them to
build your OptiX-based application that uses OSL for GPU rendering. #1627
(1.13.2.0/1.12.8.0)
* GPU/OptiX support of ReParameter [#1686](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1686) (1.13.4.0)
* Fix userdata derivatives for interpolated params on GPU [#1685](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1685) (by Pascal Lecocq) (1.13.4.0)
* Enable userdata derivatives for interpolated params on GPU
[#1657](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1657) (by Chris Hellmuth) (1.13.4.0)
* Move qualifying GroupData params onto stack for higher performance.
[#1710](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1710) (by Chris Hellmuth) (1.13.5.0)
* Handle mixed string casting that plagues optix codegen [#1718](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1718) (1.13.5.0)
* Add missing members to ShaderGlobals in rend_lib.h [#1721](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1721) (by Tim Grant) (1.13.5.0)
* OptiX direct callable API that owns groupdata buffer
[#1683](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1683) (by Chris Hellmuth) (1.13.5.0)
* OptiX PTX pipeline overhaul [#1680](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1680) (by Tim Grant) (1.13.5.0)
* Perf: Don't insert redundant run layer calls inside a basic block
[#1665](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1665) [#1669](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1669) [#1672](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1672) (by Chris Hellmuth) (1.13.4.0)
* Fix NVPTX TargetMachine leak, etc. [#1763](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1763) (by Tim Grant)
### 🐛/🔧 Internals: fixes, improvements, and developer concerns
* Fix memory leak in oslc ASTvariable_declaration. #1576 (1.13.0.2)
* Fix memory leaks in LPE code in error conditions. #1593 #1594 (1.13.0.3)
* Fix mismatched strides when calling OCIO for transformc with derivs [#1646](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1646) (1.13.4.0)
* Set up ray types for testrender [#1648](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1648) (1.13.4.0)
* Fix userdata binding corner case [#1673](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1673) (by Alejandro Conty) (1.13.4.0)
* Fix constant float values being converted to ints [#1674](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1674) (by Declan Russell) (1.13.4.0)
* Don't try to ReParameter symbols not in the group [#1693](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1693) (by Alejandro Conty) (1.13.5.0)
* Have ReParameter only copy data when it changes [#1698](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1698) (1.13.5.0)
* Avoid deprecated OSLQuery ctr in test example [#1699](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1699) (1.13.5.0)
* Zero derivs for interactive params when needed [#1700](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1700) (by Alejandro Conty) (1.13.5.0)
* oslc bug fix: shader params whose default values involve "init ops" could be
incorrectly initialized if their values came from instance parameters set to
zero. #1578 (1.13.0.2)
* oslc: Add missing `fmod()` variants [#1643](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1643) (1.13.4.0)
* Simple constant folding of binary expressions now happen on the oslc side
[#1653](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1653) (1.13.4.0)
* platform.h:
* New `OSL_ALLOCA` macro to allocate on the stack. #1589 (1.13.0.3)
* Define OSL::bitcast utility. #1610 (1.13.2.0)
* Make sure that std::hash is defined for ustring and ustringhash. #1599
(1.13.1.1)
* Deprecate LLVMUtil::internalize_module_functions. #1606 (1.13.1.0)
* Work toward always representing strings in shaders as ustringhash rather
than ustring: phase 1 #1603 phase2 #1612 (1.13.2.0) [#1726](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1726) (1.13.5.0)
* Remove unnecessary setting of locale::global [#1636](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1636) (by danieldresser-ie) (1.13.2.1)
* Fully define bitcast template [#1635](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1635) (1.13.2.1)
* Fix for ReParameter corner case [#1670](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1670) (by cmstein) (1.13.4.0)
* Switch deprecated oiio simd names to modern [#1679](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1679) (1.13.4.0)
* Give ShadingSystemImpl a handy use_optix() method [#1682](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1682) (1.13.4.0)
* Fix default fmt logic changing in latest openimageio release [#1725](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1725) (1.13.5.0)
* The recently added SS::find_symloc can have const args [#1723](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1723) (1.13.5.0)
* SymOverrideInfo bitfields should be the same type [#1745](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1745)
* Fix wrong offset of MxSheen param [#1751](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1751) (by Rasmus Bonnedal)
* Make get_texture_info robust to empty shaderglobals param [#1731](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1731)
### 🏗 Build/test/CI and platform ports
* CMake build system and scripts:
* The version number is now a cache variable, and so can be overridden at
build time using `-DOSL_VERSION=...`. Use with extreme caution! #1579
(1.13.0.2) Revised again to reduce changes of user error in #1617
(1.13.2.0/1.12.7.1)
* Add clangSupport library as dependency to fix linker error on some
platforms. #1613 (1.13.2.0/1.12.7.1)
* Fix incorrect CMake variable name to control symbol visibility
[#1681](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1681) (1.13.4.0)
* Change cmake option `USE_OPTIX` -> `OSL_USE_OPTIX` [#1668](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1668) (1.13.4.0)
* Fix duplicate osl lexing symbols when building as static libraries
[#1709](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1709) (by Brecht Van Lommel) (1.13.5.0)
* Better cmake verbose behavior [#1752](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1752)
* Dependency version support:
* Fix some issues that came up with the new icx 2022.0 compiler. #1601
(1.13.1.0)
* Test against OpenColorIO 2.2. #1616 (1.13.2.0/1.12.7.1)
* Proper warnings about LLVM 16 [#1658](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1658) (1.13.4.0)
* Fix cuda compilation flags for LLVM 15 [#1659](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1659) (1.13.4.0)
* Verify that OSL can build with clang16 [#1664](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1664) (1.13.4.0)
* Be more careful about paths to look for llvm [#1656](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1656) (1.13.4.0)
* Qt6 compatibility [#1655](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1655) (1.13.4.0)
* Fix warnings about Qt compilation and enums [#1661](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1661) (1.13.4.0)
* Changes to support fmt 10.0 [#1691](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1691) (1.13.5.0)
* Raise OpenEXR minimum to 2.4 [#1734](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1734)
* Fix Partio build errors on pointcloud functions for MSVC [#1757](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1757) (by Alex Wells)
* Bump Cuda minimum to 9.0 [#1737](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1737)
* LLVM 16 and 17 support: LLVM opaque pointers support [#1728](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1728),
LLVM new pass manager support [#1729](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1729),
finish LLVM 16 and 17 support [#1730](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1730) (all by Brecht Van Lommel)
* Testing and Continuous integration (CI) systems:
* Dynamic analysis using address and leak sanitizers. #1581 (1.13.0.3)
* `testshade --help` now prints TextureSystem options and all hardware
information. #1584 (1.13.0.3)
* Improvements to SonarCloud and coverage analysis. #1596 (1.13.0.3)
#1607 (1.13.1.0)
* Disabling the dso version of testshade for the coverage analysis test.
#1604 (1.13.1.0)
* Be sure to run pointcloud tests when partio is found. #1611 (1.13.2.0)
* testshade: better testing of all closure parameter types. #1621
(1.13.2.0/1.12.8.0)
* Don't use the cached background map on the first bounce
[#1649](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1649) (by Christopher Kulla) (1.13.4.0)
* Fix builds when USE_PYTHON=OFF [#1675](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1675) (by Declan Russell) (1.13.4.0)
* Remove SonarCloud cache setup as it is now offered by default
[#1660](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1660) (by Massimo Paladin) (1.13.4.0)
* *ci*: Simplify build_llvm.bash script [#1703](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1703) (1.13.5.0)
* Test interactive parameter initialization in optix testrender [#1687](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1687) (by Chris Hellmuth) (1.13.5.0)
* Fix GPU job not actually enabling OptiX [#1738](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1738) (by Brecht Van Lommel)
* Fix python-oslquery test failure on macOS [#1739](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1739) (by Brecht Van Lommel)
* Disable MacOS-11 CI [#1746](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1746)
* Skip analysis and scorecard workflows on push if only docs changed [#1744](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1744)
* For clarity, use the term 'runner' instead of 'os' [#1743](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1743)
* Test ABI compliance [#1748](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1748)
* Fix tests passing when test commands fail [#1733](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1733) (by Brecht Van Lommel)
* *ci*: Test against LLVM 17 [#1760](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1760)
* Platform support:
* Include `immintrin.h` only when needed. #1605 (1.13.1.0)
* Changed snprintf formatting to satisfy some compilers.
[#1640](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1640) (by pellerington) (1.13.4.0)
* Fix some windows GPU build errors [#1638](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1638) (by Declan Russell) (1.13.4.0)
* Fix for Apple clang 14+ warnings [#1697](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1697) (1.13.5.0)
* Fix struct align/pack for MSVC [#1754](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1754) (by Rasmus Bonnedal)
* Refactor icc/icx specific pragma macros [#1756](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1756) (by Alex Wells)
### 📚 Documentation
* First stab at ReadTheDocs -- new [Experimental OSL Documentation on
ReadTheDocs](https://open-shading-language.readthedocs.io/)
is still a little rough, but eventually will be our primary documentation.
[#1736](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1736)
* `doc/RELEASING.md` documents our release process and versioning policies.
#1572 (1.13.0.2)
* Improve documentation of `trace` function [#1671](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1671) (by AidanWelch) (1.13.4.0)
* Update CONTRIBUTING [#1689](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1689) (1.13.5.0)
* Update logos [#1705](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1705), Move logos and add an icon-only logo [#1707](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1707) (1.13.5.0)
### 🏢 Project Administration
* Alert slack "release-announcements" channel upon OSL release [#1740](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1740) [#1749](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1749)
* Update pull request template [#1741](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1741)
* Account for duplicate emails in the .mailmap [#1759](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1759)
---
---
---
Release 1.12.13.0 -- 1 July 2023 (compared to 1.12.12.0)
--------------------------------------------------------
- *fix*: Fix constant float values being converted to ints
[#1674](https://github.com/OpenShadingLanguage/oiio/pull/1674) (by Declan Russell)
- *build*: Fix builds when USE_PYTHON=OFF
[#1675](https://github.com/OpenShadingLanguage/oiio/pull/1675) (by Declan Russell)
- *build*: Changes to support fmt 10.0
[#1691](https://github.com/OpenShadingLanguage/oiio/pull/1691)
- *cleanup*: Switch deprecated oiio simd names to modern
[#1679](https://github.com/OpenShadingLanguage/oiio/pull/1679)
- *testing*: Avoid deprecated OSLQuery ctr in test example
[#1699](https://github.com/OpenShadingLanguage/oiio/pull/1699)
- *ci*: Fix package name for icc
[#1690](https://github.com/OpenShadingLanguage/oiio/pull/1690)
- *ci*: Add VFX Platform 2023 tests using new ASWF containers
[#1696](https://github.com/OpenShadingLanguage/oiio/pull/1696)
- *ci*: Switch oiio obsolete branch names to immutable tags
[#1701](https://github.com/OpenShadingLanguage/oiio/pull/1701)
- *docs*: Improve documentation of `trace` function
[#1671](https://github.com/OpenShadingLanguage/oiio/pull/1671) (by AidanWelch)
- *docs*: README.md: added filmography and Siggraph OSL course info.
[#1692](https://github.com/OpenShadingLanguage/oiio/pull/1692)
[#1694](https://github.com/OpenShadingLanguage/oiio/pull/1694) (by Mitch Prater)
- *docs*: Amend the filmography
[#1695](https://github.com/OpenShadingLanguage/oiio/pull/1695)
- *docs*: Fix incorrect links in CONTRIBUTING
[#1688](https://github.com/OpenShadingLanguage/oiio/pull/1688)
Release 1.12.12.0 -- 1 May 2023 (compared to 1.12.11.0)
--------------------------------------------------------
* New ShadingSystem getattribute query for shader groups: "attribute_types"
retrieves a pointer to the array of TypeDesc values describing the
attributes retrieved by existing "attributes_needed" and "attribute_scopes".
#1650
* Fix a bug with binding userdata when it's used by more than one shader
within the group and they disagree about whether derivatives are needed when
retrieving the attribute. #1673
Release 1.12.11.0 -- 5 Apr 2023 (compared to 1.12.10.0)
--------------------------------------------------------
* Build: Add Qt 6.x compatibility (Qt is only used for `osltoy`). #1655
* Build: more careful about paths to look for LLVM. #1656
* Build: Fix Cuda compilation flags for LLVM 15. #1659
* Notice: OSL does not yet build properly against the newly release LLVM 16.
You must use LLVM 9-15. For Mac users who get their llvm from Homebrew,
please be aware that Homebrew has changed its default llvm to 16, so you'll
need to `brew install llvm@14` and make your OSL CMake define:
`-DLLVM_ROOT=/usr/local/opt/llvm@14`
Release 1.12.10.0 -- 1 Mar 2023 (compared to 1.12.9.0)
--------------------------------------------------------
* feat(testrender): Modify testrender so that it correctly sets raytype to
"camera" for camera rays, "shadow" for shadow rays, and "diffuse" for all
secondary rays. Also rerun the shades for background shader group on the
camera rays rather than use the cached map. This helps the MaterialX project
use testrender for certain unit tests and verification. #1648 #1649
* feat: Expose llvm groupdata size as a shadergroup attribute
"llvm_groupdata_size". #1642
* fix: Crash could result from uncaught exception in OpenColorIO when calling
transformc with derivatives for color spaces that require OCIO. #1646
* fix: certain uses of fmod() in shaders could fail to generate LLVM code
correctly, due to a missing implementation for the fmod(triple,float)
varieties. #1643
* build: Change snprintf formatting to satisfy some compilers. #1640
* CI: Fix broken Mac ci. #1647
Release 1.12.9.0 -- 1 Feb 2023 (compared to 1.12.8.0)
-------------------------------------------------------
* Remove unnecessary setting of locale::global. #1630
* Batch shading: Fix bug with masked wide closure generation. #1637
* Make sure ReParameter() has the same relaxed type checking rules as
Parameter(). Before, it was stricter about type conversion. #1639
* Windows: Fix some GPU build errors. #1638
Release 1.12.8.0 -- 3 Jan 2023 (compared to 1.12.7.1)
-------------------------------------------------------
* Remove dependency on OptiX SDK for building core OSL with OptiX support.
You can now build OSL with OptiX support enabled even if you don't have the
OptiX SDK headers present at build time. But you will still need them to
build your OptiX-based application that uses OSL for GPU rendering. #1627
* Batch mode: fix issue with closure keyword parameters. #1620
* Batch mode: fix crash when adding a default initialized closure. #1624
* Batch mode: Fix support for closures with array types. #1630
* testshade: better testing of all closure parameter types. #1621
* Fix various CI breaks as dependencies shifted. #1629 #1631 #1633
Release 1.12.7.1 -- 1 Dec 2022 (compared to 1.12.7.0)
-------------------------------------------------------
* Add clangSupport library as dependency to fix linker error on some
platforms. #1613
* Test against OpenColorIO 2.2. #1616
* Build: Fix how version overrides work to reduce the chance of user mistakes.
#1617
Release 1.12.7.0 -- 1 Nov 2022 (compared to 1.12.6.2)
-------------------------------------------------------
* Optix: Change naming of certain compiler-generated constants in a way that
improves use of the PTX cache. #1570
* Batch: Fix uninitialized members in ReadEvent internals. #1575
* `testshade --help` now prints TextureSystem options and hardware info. #1584
* oslc: Fix memory leak in ASTvariable_declaration. #1576
* Fix memory leaks in light path expression code. #1593 #1594
* Include the immintrin.h header only when needed. #1605
* icx: Improvements to fix problems exposed by new icx 2022.2 compiler. #1601
* Testing: CMake cache variables to control the testing timeout length. #1571
* CI: Add a dynamic analysis test using address and leak sanitizers. #1581
* CI: Now using SonarCloud static analysis. #1551
* CI: Many improvements in testing code coverage #1607
* CI: Make sure to run pointcloud tests when partio is found. #1611
* Developers: platform.h now defines OSL_ALLOCA macro. #1589
* Developers: platform.h now defines OSL::bitcast utility. #1610
Release 1.12 -- 1 Oct 2022 (compared to 1.11)
----------------------------------------------
Big Deal Changes:
* **Batch shading**: A fully operational "batch shading" support when using
CPUs supporting the Intel AVX2 or AVX512 instruction set architectures,
allows shading 8 or 16 points at a time, accelerated by using SIMD
instructions. (Changes contributed by Intel.)
* **OptiX**: A reasonable subset of the OSL language can run on NVIDIA GPUs
for Cuda or OptiX-based renderers.
* **Standardized material closures**: Synchronize with MaterialX on a minimum
standard set of material closures. This is reflected in both the OSL spec as
well as reference implementations of those closures in testrender. #1533
#1536 #1537 #1538 #1539 #1541 #1542 #1547 #1557
Dependency and standards requirements changes:
* OpenImageIO 2.1-2.3: Support for OIIO 2.0 has been dropped.
* The minimum (and default) compilation mode is now C++14. C++17 and 20 are
also supported. #1362 #1369 (1.12.2)
* Minimum compilers are now gcc 6.1 (no more support for gcc 4.8), MSVS
2017 or newer (no more support for 2015).
* Minimum LLVM is now 9.0. Support for LLVM 7 and 8 have ben dropped.
#1441 (1.12.3)
* Minimum OpenImageIO is now 2.2: Support for OIIO 2.0 and 2.1 have been
dropped. #1426 (1.12.3)
* Minimum OpenEXR version is now 2.3 (raised from 2.0). #1406 (1.12.3)
OSL Language and oslc compiler:
* `#pragma error "message"` and `#pragma warning "message"` can be used to
conditionally inject a compile-time error or warning. #1300 (1.12.1)
* Check for errors when when writing oso files (for example, disk volume
full). #1360 (1.12.2/1.11.14)
* A new flavor of `gettextureinfo(texturename, paramname, s, t, destination)`
allows for querying of texture metadata about the particular UDIM tile
that will be used for particular (s,t) texture coordinates. #1398 (1.12.3)
* Better error detection when OSL user functions write to function parameters
that are not marked as output. #1417 (1.12.3)
* Detect and better error message when using a type name where a variable
identifier should be. #1457 (1.12.4.2)
OSL Standard library:
* vector2.h is updated with a mod() function for vector2. #1312 (1.12.1/1.11.12)
* Preliminary work for adding standard MaterialX closures. 31371 (1.12.2)
* Fix previously-broken color conversions from RGB to xyY. #1410 (1.12.3)
* Fully removed MaterialX shaders (get those from the MaterialX project).
#1450 (1.12.3)
* Fix incorrect implementation of `matrix4 * vector4` in vector4.h #1513
(1.12.5.0)
API changes, new options, new ShadingSystem features (for renderer writers):
* Custom experimental llvm optimization levels 10, 11, 12, and 13. These
@@ -19,22 +439,52 @@ API changes, new options, new ShadingSystem features (for renderer writers):
-O1, -O2, -O3) but we think for shaders are just as performant but with
lower JIT time. These are currently experimental, but we are benchmarking
to determine if they should be the new defaults. #1250 (1.12.0.0)
* ShadingSystem attribute "searcpath:library" gives a searchpath for finding
runtime-loadable implementation modules for ISA-optimized operaionts.
* ShadingSystem attribute "searchpath:library" gives a searchpath for finding
runtime-loadable implementation modules for ISA-optimized operations.
#1310 (1.12.1)
* Output variable placement -- now you can designate where shader outputs
should go and the shader will put results there, instead of the app using
find_symbol() and symbol_address after the shader is executed. #1328 (1.12.2)
* Userdata input placement -- now you can designate where interpolated
userdata should be copied from directly, rather then via callbacks to
RendererServices::get_userdata(). #1391 (1.12.3)
* Better hiding of the Matrix22 class, which was never actually part of the
public APIs. #1480 (1.12.4.5)
* Add ACES2065-1 and ACEScg as shading system color spaces (#1486) (1.12.4.6)
* Expanded warnings (via enabling the "opt_warnings" attribute of the
ShadingSystem) for operations that try to create new strings mid-shader, or
that need to access the characters of strings mid-shader. These are only
triggered for those cases that cannot be resolved by the end of the "runtime
optimization" phase. #1497 (1.12.4.6)
Continued work on experimental SIMD batched shading mode:
SIMD batched shading mode:
* Added support for masked operations to LLVMUtil. #1248 #1250 (1.12.0.0)
* Add interface to ShadingSystem for batched execution. #1272 (1.12.0.1)
* Add interface to batched RendererServices. #1276 (1.12.0.1)
* Batched testshade. #1298 (1.12.1)
* ShadingSystem plumbing to support batched execution. #1301 (1.12.1)
* Batched analsys to figure out which symbols need to be varying or uniform,
* Batched analysis to figure out which symbols need to be varying or uniform,
and which operations require masking. #1313 #1318 #1322 (1.12.1)
* Additional infrastructure for batched analsys. #1316 (1.12.1)
* Additional infrastructure for batched analysis. #1316 (1.12.1)
* Add implementation for BatchedBackendLLVM. #1330 (1.12.1)
* ISA-specific modules. #1345 (1.12.2)
* Introduction of CI testing of batched mode. #1357 #1367 (1.12.2)
* Control flow and string ops. #1372 (1.12.2)
* Matrix operations. #1378 (1.12.2) #1485 (1.12.4.6)
* Batched algebraic, trig, and transcendental functions. #1385 (1.12.2)
* Batched noise. #1394 (1.12.3)
* Batched implementation of all color operations. #1408 (1.12.3)
* Batched bitwise ops. #1413 (1.12.3)
* Batched spline and spline inverse. #1422 (1.12.3)
* Batched texture, gettextureinfo, texture3d, environment. #1436 (1.12.3)
* Batched dictionary functionality (dict_find, etc.) #1445 (1.12.3)
* Enable batched execution of most testsuite. #1453 (1.12.4.1)
* Batched isnan, isinf, isfinite. #1456 (1.12.4.2)
* Batched userdata and output placement. #1455 (1.12.4.2)
* Batched pointcloud functions. #1464 (1.12.4.4)
* Batched closures (#1500)
Continued work on experimental OptiX rendering:
OptiX rendering:
* Explicitly set the OptiX pipeline stack size. #1254 (1.12.0.0)
* CI tests now at least compile and build with USE_OPTIX=1 (though not yet
run the tests). #1281 (1.12.0.1)
@@ -43,8 +493,20 @@ Continued work on experimental OptiX rendering:
* Overhaul in how strings are communicated to the GPU side. #1309 (1.12.1)
* Removal of runtime compilation of Cuda (libnvrtc dependency eliminated).
#1309 (1.12.1)
* Fix problems with unresolved symbols on GPU, particularly when multiple
shaders call certain functions like printf. #1401 (1.12.3)
* Changed prototype of osl_get_attribute callback to work properly on
GPU. #1404 (1.12.3)
* Fix missing hostdevice modifier on some matrix operators. #1409 (1.12.3)
* Fix race conditions when compiling for OptiX 7. #1411 (1.12.3)
* osl_get_attribute() uses device strings when compiling for OptiX.
#1435 (1.12.3)
* Fix issue with OptiX + clang 14 with duplicate symbols. #1561 (1.12.6.0)
Performance improvements:
* Less mutex locking around use and retrieval of ColorSystem related to
doing color transforms. #1405 (1.12.3)
* Constant folding of `startswith()`. #1507 (1.12.5.0)
Bug fixes and other improvements (internals):
* Fix derivatives of texture calls when only derivatives of the "alpha"
@@ -71,6 +533,25 @@ Bug fixes and other improvements (internals):
outputs (the semantics of doing so are very fishy). #1296 (1.12.1)
* Eliminate unnecessary error messages to stderr for broken point clouds.
#1333 (1.12.1/1.11.13)
* Fix undefined behavior that could result in crashes that resulted from
the Symbol class having no virtual destructor. #1397 (1.12.3)
* Fix in runtime optimizer where tracking of messages and unknown messages
relied on uninitialized variables. #1447 (1.11.17/1.12.3)
* Stop internally using OIIO::string_view::c_str(), which will someday be
removed. #1458 (1.12.4.2)
* Correctly track that the backfacing() function requires N and I shader
globals. #1462 (1.12.4.4)
* Print all 4 levels of version numbers in help messages. #1477 (1.12.4.4)
* Fix GPU code generation crash. #1479 (1.12.4.4)
* Work to transition internals to use modern std::format notation for
formatted output. #1487 #1490 (1.12.4.6) #1504 #1506 (1.12.5.0)
* testrender improvements:
* Fix testrender memory error on teardown. #1499 (1.12.4.6)
* Modernize the sampler in testrender, improving quality and performance.
#1534 (1.12.6.0)
* Switch to cone tracing for derivatives. #1543 (1.12.6.0)
* Fix error that prevented correct typecheck of ternary operator. #1552
(1.12.6.0)
Internals/developer concerns:
* Use the `final` keyword in certain internal classes where applicable.
@@ -78,6 +559,28 @@ Internals/developer concerns:
* Minor fixes to the internal TypeSpec and Symbol classes. #1267 (1.12.0.1)
* Switch from deprecated call to OIIO::parallel_image to the new version.
#1317 (1.11.11/1.12.1)
* The "archive_groupname" handling is now careful to sanitize the filenames
it deals with, closing some security and safety holes. #1383 (1.12.2)
* More migration of string formatting to new std::format style. #1389 (1.12.3)
#1469 #1470 (1.12.4.4)
* llvm_util: Switch some uses of ptr+len to span. #1390 (1.12.3)
* OSL no longer uses sscanf internally (which has icky locale-dependent
behavior), and instead use locale-independent OIIO::Strutil utilities
whenever we need to parse strings. #1432 (1.12.3)
* Avoid use of OIIO::string_view::str() which is not corresponding to the
official C++17 std::string_view. #1467 (1.12.4.4)
* Prototype of "free function" approach that will someday mostly supplant
the way we use RendererServices, and will help to unlock feature completion
for GPU and other back ends. This experimental feature is not expected
to be used in OSL 1.12. #1494 (1.12.5.0)
* Work on gradually converting printf-style formatted strings to fmt /
std::format style. #1493 (1.12.5.0)
* LLVM_Util: allow naming of llvm symbols to help with IR debugging. #1530
(1.12.6.0)
* clang-format the code base. #1508 #1509 #1511 #1512 #1515 #1518 #1540
(1.12.5.0) #1555 #1562 #1568 (1.12.6.0)
* A round of spell-checking all the comments in the code base. #1550
(1.12.5.0)
Build & test system improvements:
* CMake build system and scripts:
@@ -94,29 +597,99 @@ Build & test system improvements:
- Make the CMake build scripts more friendly to being a subproject.
#1304 #1319 (1.11.11/1.12.1)
- We weren't properly hiding non-public symbols. #1337 (1.12.1/1.11.12)
- Fully split oslquery and oslnoise libraries from oslxec, no more
- Fully split oslquery and oslnoise libraries from oslexec, no more
redundant modules put into both. #1346 #1348 (1.12.1)
- Support for CMake 3.20 #1354 (1.12.2/1.11.14)
- Important change to `Makefile` wrapper: We have a 'Makefile' that just
wraps cmake for ease of use. This has changed its practice of putting
builds in `build/ARCH` to just `build` (and local installs from
`dist/ARCH` to `dist`) to better match common cmake practice. So where
your local builds end up may shift a bit. #1396 (1.12.3)
- Be more careful about not writing over a sensitive install area
unless CMAKE_INSTALL_PREFIX is explicitly set. #1421 (1.12.3)
- PROJECT_VERSION_RELEASE_TYPE and OSL_SUPPORTED_RELEASE are now
cache variables that can have build-time overrides. #1443 (1.12.3)
- Use PROJECT_IS_TOP_LEVEL (not OSL_IS_SUBPROJECT) to confirm with
CMake 21 conventions. #1443 (1.12.3)
- New TIME_COMMANDS option, when enabled, can help debug performance of
the build. #1443 (1.12.3)
- New CMake variable `DOWNSTREAM_CXX_STANDARD` sets the downstream
minimum C++ requirement, separately from `CMAKE_CXX_STANDARD` which sets
what we build OSL itself with. Clarify that currently, OSL can be used
downstream by C++14, even if it is built with C++17 or higher. #1454
(1.12.4.1)
- Make exported cmake configs relocatable by using relative paths. #1466
(1.12.4.4)
* Dependency version support:
- Build properly against Cuda 11 and OptiX 7.1. #1232 (1.12.0.1)
and up to OptiX 7.4 #1559 (1.12.6.0)
- PugiXML build fixes on some systems. #1262 (1.12.0.1/1.11.8)
- Cuda/OptiX back end: Add `__CUDADEVRT_INTERNAL__` define to bitcode
generation, needed to avoid duplicate cudaMalloc symbols with CUDA9+
#1271 (1.12.0.1)
- Build against LLVM 11 #1274 (1.12.0.1) and LLVM 12 #1351 (1.12.1.0).
- Build against LLVM 11 #1274 (1.12.0.1), LLVM 12 #1351 (1.12.1.0)
#1412 (1.12.3), LLVM 13 #1420 (1.12.3), LLVM 14 #1492 (1.12.4.6)
LLVM 15 #1592 (1.12.6.2)
- Fix build break against recent OIIO master change where m_mutex field
was removed from ImageInput. #1281 (1.12.0.1/1.11.9)
- Work to ensure that OIIO will build correctly against the upcoming
Imath 3.0 and OpenEXR 3.0. #1299 (1.11.10/1.12.1) #1332 (1.11.11/1.12.1)
#1341 (1.11.12/1.12.1)
#1341 (1.11.12/1.12.1) #1356 #1368 (1.11.13/1.12.2) #1489 (1.12.4.6)
- Improved finding of llvm components when using static libraries. #1375
(1.12.2)
- No longer use boost regex, completely rely on std::regex now that OSL
is C++14 minimum. #1377. (1.12.2)
- Support for OpenImageIO 2.3 changes. #1393 (1.12.3)
- Some rearrangement of `#include` and other trickery ensures that OSL
always includes headers from its favored version of Imath, rather than
the ones that OIIO prefers (in cases where OIIO and OSL were each based
on different Imath versions). #1460 (1.12.4.2)
- Various fixes for functionality and warnings for Intel icc and icx
compilers. #1459 #1473 #1475. (1.12.4.4)
- Fixes for recent OIIO TextureSystem changes that hide Imath types.
#1476 (1.12.4.4)
- Changes to work correctly with OpenImageIO 2.4 and its master being
the start of 2.5. #1569 (1.12.6.0)
* Testing and Continuous integration (CI) systems:
- Eliminate the old Travis CI and Appveyor. #1334 #1338 (1.12.1)
- Use ccache + GitHub 'cache' action to greatly speed up CI runs. #1335
(1.12.1)
- Divide the CI stages into separate steps, combine dependency-building
scripts for CentOS and Ubuntu ito a single script. #1338 (1.12.1)
- CI tests clang11, also batched shading with clang. #1379 (1.12.2)
- CI speeds up OIIO builds by not building its tests. #1380 (1.12.2)
- CI tests gcc11 #1381 (1.12.2) and gcc12 #1565 (1.12.6)
- Deal with OpenColorIO changing its master branch to "main". #1429
(1.12.3)
- Fix tests for texture3d now that OIIO has dropped support for Field3D.
#1437 (1.12.3)
- Test against LLVM13/clang13 for the VFX Platform 2022 tests. #1434
(1.12.3)
- CI test against MacOS-11 #1434 (1.12.3) and MacOS-12 #1554 (1.12.6)
#1522 (1.12.5)
- Add testsuite coverage of environment(). #1438 (1.12.3)
- Use a project-specific environment variable `OSL_CI` instead of the more
generic `CI` to avoid clashes with other systems. #1446 (1.12.3)
- Deal with OpenEXR and Imath changing its master branch to "main". #1463
(1.12.4.4)
- testrender fix sphere tangents, per MaterialX suggestion. #1465
(1.12.4.4)
- Allow testsuite tests to use oiiotool for image diffs instead of idiff.
#1472 (1.12.4.4)
- Allow `-Werror` to be disabled even on CI branches. #1471 (1.12.4.4)
- CI Tests against the Intel icc and icx compilers! #1459 #1473 (1.12.4.4)
#1501 (1.12.5.0)
- Overhaul of GHA ci.yml to use strategy matrix. #1474 (1.12.4.4)
- Test against clang 14 and fix new warnings. #1498 (1.12.5.0)
- Test against clang 15 and fix new warnings. #1586 (1.12.6.2)
- A scorecards workflow guards against a variety of security issues of
the CI system itself. #1529 (1.12.6.0)
- Enable SonarCloud static analysis. #1551 #1556 #1563 (1.12.6.0)
* Platform support:
- Various Windows compile fixes. #1263 #1285 (1.12.0.1)
- Windows+Cuda build fixes. #1292 (1.12.0.1)
- Fix warnings about pointer casts on Windows. #1484 (1.12.4.5)
- Various Windows build fixes. #1502 (1.12.5.0)
* The oso and osl lexers/parsers are now given internal symbol names that
are fully versioned, to avoid possible clash if multiple OSL releases are
both linked into the same application. #1255 (1.12.0.0)
@@ -129,8 +702,68 @@ Documentation:
(1.11.11/1.12.1)
* First steps in new documentation and scripts for building OSL on Windows.
#1326 (1.12.1)
* Fix missing explanation of the optional "errormessage" parameter to
environment() and texture3d(). #1442 (1.12.3/1.11.17)
* A SECURITY.md file explains how to confidentially report vulnerabilities.
#1529 (1.12.6)
* Document all the new MaterialX closures. #1564
Release 1.11.17.0 -- 7 Jan 2022 (compared to 1.11.16.0)
-------------------------------------------------------
* Fix in runtime optimizer where tracking of messages and unknown messages
relied on uninitialized variables. #1447
* Minor changes related to OpenColorIO changing their master branch name to
"main". #1431
* Testing: Get texture3d tests operational again. #1437
* Docs: Fix missing "errormessage" explanation for environment() and
texture3d(). #1442
* Build/cmake fixes: Make PROJECT_VERSION_RELEASE_TYPE and
OSL_SUPPORTED_RELEASE be cache strings, so they can be overridden; change
OSL_IS_SUBPROJECT to PROJECT_IS_TOP_LEVEL (and change its sense) to match
CMake 21+ behavior; add a TIME_COMMANDS option to help debug performance of
the build. #1443
Release 1.11.16.0 -- 1 Nov 2021 (compared to 1.11.15.0)
-------------------------------------------------------
* Fixes to work with LLVM 13, and to compile with clang 13. #1412 #1420
Release 1.11.15.0 -- 1 Sep 2021 (compared to 1.11.14.2)
-------------------------------------------------------
* Changes for compatibility with OpenImageIO 2.3. #1393 #1388
* Fix potential crashes (or at least undefined behavior) due to missing
virtual destructor of internal Symbol type. #1397
Release 1.11.14.2 -- 1 Jul 2021 (compared to 1.11.14.1)
-------------------------------------------------------
* Fix warnings that occur when compiling with clang and C++17 mode. #1379
* CI/testing: Additional CI tests for clang+c++17 (#1379), gcc11 (#1381),
llvm 12 (#1381), speed up CI builds by not building the testing components
of OIIO (#1380).
Release 1.11.14.1 -- 1 Jun 2021 (compared to 1.11.14.0)
-------------------------------------------------------
* Fix library setup for LLVM installations consisting of static libraries.
This fixes a build problem that can crop up on MacOS using
Homebrew-installed LLVM 12. #1375
Release 1.11.14 -- 10 May 2021 (compared to 1.11.13)
----------------------------------------------------
* oslc/OSLCompiler: Check for errors when when writing oso (for example,
disk volume full). #1360
* Fix crash generating closure function calls with LLVM 11. #1361
* Build: LLVM 12 compatibility. #1351
* Build: Support for CMake 3.20 #1354
* Build: Be robust to certain OpenEXR 2.x config fies. #1356
* Build: Fixes to deal with newer OIIO builds that are C++14.
Release 1.11.13 -- 1 Apr 2021 (compared to 1.11.12)
----------------------------------------------------
* Updated vector2.h with a `mod(vector2,vector2)` function. #1312
* Fix unnecesary error messages to stderr when encountering broken point
clouds. #1333
Release 1.11.12 -- 1 Mar 2021 (compared to 1.11.11)
----------------------------------------------------
* Build: Changes for smooth compile against upcoming Imath 3.0. #1332 #1341
@@ -541,7 +1174,7 @@ Build & test system improvements:
use clang library components for preprocessing. #1089 (1.11.3)
* Add an optional build-time `EXTRA_WARNINGS` option (default: OFF) that
enables even more picky than usual warnings. Fix many warnings that cropped
up during testing, mostly related to unused function paramters. #1106 (1.11.3)
up during testing, mostly related to unused function parameters. #1106 (1.11.3)
* The testsuite can run in parallel, with a number of threads set by the
environment variable `CTEST_PARALLEL_LEVEL`. #1119 (1.11.4)
* oslconfig.h is now generated by a cmake configure_file step, from
+84 -27
View File
@@ -2,28 +2,55 @@
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
cmake_minimum_required (VERSION 3.12)
project (OSL VERSION 1.12.1.0
cmake_minimum_required (VERSION 3.15)
set (OSL_VERSION "1.13.11.0")
set (OSL_VERSION_OVERRIDE "" CACHE STRING
"Version override (use with caution)!")
mark_as_advanced (OSL_VERSION_OVERRIDE)
if (OSL_VERSION_OVERRIDE)
set (OSL_VERSION ${OSL_VERSION_OVERRIDE})
endif ()
project (OSL VERSION ${OSL_VERSION}
LANGUAGES CXX C
HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/OpenShadingLanguage")
set (PROJ_NAME ${PROJECT_NAME}) # short name
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
set (PROJECT_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
set (PROJECT_VERSION_RELEASE_TYPE "" CACHE STRING
"Build type, for example: dev, beta2, RC1 (empty string for normal release)")
set (${PROJECT_NAME}_VERSION_RELEASE_TYPE ${PROJECT_VERSION_RELEASE_TYPE})
set (${PROJECT_NAME}_SUPPORTED_RELEASE 0) # Change to 1 after release branch
set (PROJECT_AUTHORS "Contributors to the Open Shading Language project")
option (${PROJECT_NAME}_SUPPORTED_RELEASE
"Set ON for supported release branch, OFF for master" ON)
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
set (${PROJECT_NAME}_DEV_RELEASE OFF)
else ()
set (${PROJECT_NAME}_DEV_RELEASE ON)
endif ()
# Identify whether this is included as a subproject of something else
if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
set (${PROJECT_NAME}_IS_SUBPROJECT ON)
message (STATUS "${PROJECT_NAME} is configuring as a CMake subproject")
# Set PROJECT_IS_TOP_LEVEL to ON if if this is the top level project (not
# if this is included as a subproject of something else). Note that this is
# handled automatically for CMake >= 3.21.
if (CMAKE_VERSION VERSION_LESS 3.21)
if ("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
set (PROJECT_IS_TOP_LEVEL ON)
endif ()
endif ()
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif ()
# If the user hasn't configured cmake with an explicit
# -DCMAKE_INSTALL_PREFIX=..., then set it to safely install into ./dist, to
# help prevent the user from accidentally writing over /usr/local or whatever.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND PROJECT_IS_TOP_LEVEL)
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist" CACHE PATH
"Installation location" FORCE)
endif()
message (STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
message (STATUS "CMake ${CMAKE_VERSION}")
message (STATUS "CMake system = ${CMAKE_SYSTEM}")
@@ -61,11 +88,11 @@ include (GNUInstallDirs)
option (VERBOSE "Print lots of messages while compiling" OFF)
set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING
"Customized outer namespace base name (version will be added)")
option (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH "Should the inner namespace include the patch number" OFF)
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
CACHE STRING "Set the SO version in the SO name of the output library")
if (VERBOSE)
set (CMAKE_MESSAGE_LOG_LEVEL "VERBOSE" CACHE STRING "CMake log level to display")
else ()
set (CMAKE_MESSAGE_LOG_LEVEL "STATUS" CACHE STRING "CMake log level to display")
endif ()
set (OSL_LIBNAME_SUFFIX "" CACHE STRING
"Optional name appended to ${PROJECT_NAME} libraries that are built")
option (OSL_BUILD_TESTS "Build the unit tests, testshade, testrender" ON)
@@ -76,8 +103,8 @@ else ()
endif ()
option (OSL_BUILD_PLUGINS "Bool OSL plugins, for example OIIO plugin" ON)
option (OSL_BUILD_SHADERS "Build shaders" ON)
option (OSL_BUILD_MATERIALX "Build MaterialX shaders" OFF)
option (USE_OPTIX "Include OptiX support" OFF)
option (OSL_USE_OPTIX "Include OptiX support" OFF)
message(STATUS "OSL_USE_OPTIX: ${OSL_USE_OPTIX}")
set (OPTIX_EXTRA_LIBS CACHE STRING "Extra lib targets needed for OptiX")
set (CUDA_EXTRA_LIBS CACHE STRING "Extra lib targets needed for CUDA")
set (CUDA_TARGET_ARCH "sm_60" CACHE STRING "CUDA GPU architecture (e.g. sm_50)")
@@ -86,6 +113,7 @@ set (OSL_SHADER_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/shade
set (OSL_PTX_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/ptx"
CACHE STRING "Directory where OptiX PTX files will be installed")
set (CMAKE_DEBUG_POSTFIX "" CACHE STRING "Library naming postfix for Debug builds (e.g., '_debug')")
option (OSL_USTRINGREP_IS_HASH "Always use ustringhash for strings" OFF)
set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::TextureSystem")
@@ -105,20 +133,27 @@ if (OIIO_FMATH_SIMD_FRIENDLY)
add_definitions (-DOIIO_FMATH_SIMD_FRIENDLY=1)
endif ()
if (USE_OPTIX)
add_definitions ("-DOSL_USE_OPTIX=1")
endif ()
# Define OSL_INTERNAL symbol only when building OSL itself, will not be
# defined for downstream projects using OSL.
add_definitions (-DOSL_INTERNAL=1)
# To make sure we aren't relying on deprecated OIIO features, we define
# OIIO_DISABLE_DEPRECATED before including any OIIO headers.
add_definitions (-DOIIO_DISABLE_DEPRECATED=900000)
# Set the default namespace. For symbol hiding reasons, it's important that
# the project name is a subset of the namespace name.
set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING
"Customized outer namespace base name (version will be added)")
option (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH
"Should the inner namespace include the patch number" ${${PROJECT_NAME}_DEV_RELEASE})
set (PROJ_NAMESPACE "${${PROJ_NAME}_NAMESPACE}")
string(REGEX MATCH ${PROJECT_NAME} NAMESPACE_HAS_PROJECT_NAME ${PROJ_NAMESPACE})
if (NOT NAMESPACE_HAS_PROJECT_NAME)
set (PROJ_NAMESPACE ${PROJECT_NAME}_${PROJ_NAMESPACE})
endif ()
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE}_v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}")
if (OIIO_NAMESPACE_INCLUDE_PATCH)
if (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH)
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE_V}_${PROJECT_VERSION_PATCH}")
endif ()
message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
@@ -142,9 +177,10 @@ include (pythonutils)
include (externalpackages)
include (flexbison)
include (cuda_macros)
include (llvm_macros)
# Include all our testing apparatus and utils, but not if it's a subproject
if (${PROJECT_NAME}_BUILD_TESTS AND NOT ${PROJECT_NAME}_IS_SUBPROJECT)
if (${PROJECT_NAME}_BUILD_TESTS AND PROJECT_IS_TOP_LEVEL)
include (testing)
endif ()
@@ -159,6 +195,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)
@@ -168,7 +219,7 @@ add_subdirectory (src/liboslnoise)
add_subdirectory (src/oslc)
add_subdirectory (src/oslinfo)
if (OSL_BUILD_TESTS)
if (OSL_BUILD_TESTS AND BUILD_TESTING)
add_subdirectory (src/testshade)
add_subdirectory (src/testrender)
endif ()
@@ -177,15 +228,12 @@ if (OSL_BUILD_PLUGINS)
add_subdirectory (src/osl.imageio)
endif ()
if (USE_QT AND Qt5_FOUND)
if (USE_QT AND (Qt5_FOUND OR Qt6_FOUND) AND NOT DISABLE_OSLTOY)
add_subdirectory (src/osltoy)
endif ()
if (OSL_BUILD_SHADERS)
add_subdirectory (src/shaders)
if (OSL_BUILD_MATERIALX)
add_subdirectory (src/shaders/MaterialX)
endif ()
endif ()
option (INSTALL_DOCS "Install documentation" ON)
@@ -246,16 +294,25 @@ configure_package_config_file ("${PROJECT_SOURCE_DIR}/src/cmake/Config.cmake.in"
install (FILES "${OSL_PROJECT_CONFIG}" "${OSL_VERSION_CONFIG}"
DESTINATION "${OSL_CONFIG_INSTALL_DIR}")
install (FILES src/cmake/llvm_macros.cmake DESTINATION cmake)
set (PERMISSION_FLAGS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ)
install (FILES src/build-scripts/serialize-bc.py
DESTINATION build-scripts
PERMISSIONS ${PERMISSION_FLAGS})
# install targets files
install (EXPORT OSL_EXPORTED_TARGETS
DESTINATION ${OSL_CONFIG_INSTALL_DIR}
FILE ${OSL_TARGETS_EXPORT_NAME}
NAMESPACE ${PROJECT_NAME}::)
if (${PROJECT_NAME}_BUILD_TESTS AND NOT ${PROJECT_NAME}_IS_SUBPROJECT)
if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING AND ${PROJECT_NAME}_BUILD_TESTS)
osl_add_all_tests()
endif ()
if (NOT ${PROJECT_NAME}_IS_SUBPROJECT)
if (PROJECT_IS_TOP_LEVEL)
include (packaging)
endif ()
+71 -117
View File
@@ -19,11 +19,10 @@ Contributors should be reading the osl-dev mail list:
You can sign up for the mail list on your own using the link above.
We also have an `openshadinglanguage` channel on the
[ASWF Slack](https://slack.aswf.io/). But note that the Slack channel is
not archived, so while it's ok for fleeting comments, it is unreliable as
a permanent repository of useful information. Serious discussions that are
we would want to refer to over time should be sent to the mail list instead.
The [ASWF Slack](https://slack.aswf.io/) has an `openshadinglanguage` channel.
Sign up for the Slack on your own, then under "channels", select "browse
channels" and you should see the openshadinglanguage channel (among those of
the other projects and working groups).
Bug Reports and Issue Tracking
@@ -55,15 +54,16 @@ Contributor License Agreement (CLA) and Intellectual Property
To protect the project -- and the contributors! -- we do require a
Contributor License Agreement (CLA) for anybody submitting changes.
* [Corporate CLA](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/ASWF/OSL-CLA-corporate.md)
* [Corporate CLA](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/ASWF/CLA-corporate.md) :
If you are writing the code as part of your job, or if there is any
possibility that your employers might think they own any intellectual
property you create. This needs to be executed by someone who has
signatory power for the company.
* [Individual]((https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/ASWF/OSL-CLA-individual.md)).
If you are an individual writing the code on your own time and you're SURE
you are the sole owner of any intellectual property you contribute.
* [Individual CLA](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/ASWF/CLA-individual.md) :
If you are an individual writing the code on your own time, using your own
equipment, and you're SURE you are the sole owner of any intellectual
property you contribute.
The easiest way to sign CLAs is digitally [using EasyCLA](https://corporate.v1.easycla.lfx.linuxfoundation.org).
Companies who prefer not to use the online tools may sign, scan, and email
@@ -79,8 +79,7 @@ Please note that these CLAs are based on the Apache 2.0 CLAs, and differ
minimally, only as much as was required to correctly describe the EasyCLA
process and our use of a CLA manager.
** Contribution sign off
**Contribution sign off**
ASWF requires the use of the [Developer’s Certificate of Origin 1.1
(DCO)](https://developercertificate.org/), which is the same mechanism that
@@ -115,7 +114,9 @@ repository. The protocol is like this:
own repository on GitHub, and then clone it to get a repository on your
local machine.
2. Edit, compile, and test your changes.
2. Edit, compile, and test your changes. Run clang-format (see the
instructions on coding style below). Our current formatting standard,
as checked by our CI, uses clang-format 17.0.
3. Push your changes to your fork (each unrelated pull request to a separate
"topic branch", please).
@@ -127,30 +128,26 @@ component that deserves extended discussion or debate among the wider OSL
community, then it may be prudent to email osl-dev pointing everybody to
the pull request URL and discussing any issues you think are important.
6. The reviewer will look over the code and critique on the "comments" area,
6. All pull requests automatically launch CI jobs on GitHub Actions to
ensure that the build completes and that the tests suite runs correctly, for
a variety of platform, compiler, library, and flag combinations. The status
of the CI tests for your PR will be displayed on the GitHub PR page. We will
not accept PRs that don't build cleanly or pass the existing testsuite.
7. The reviewer will look over the code and critique on the "comments" area,
or discuss in email. Reviewers may ask for changes, explain problems they
found, congratulate the author on a clever solution, etc. But until somebody
says "LGTM" (looks good to me), the code should not be committed. Sometimes
this takes a few rounds of give and take. Please don't take it hard if your
first try is not accepted. It happens to all of us.
7. After approval, one of the senior developers (with commit approval to the
8. After approval, one of the senior developers (with commit approval to the
official main repository) will merge your fixes into the master branch.
Coding Style
------------
There are two overarching rules:
1. When making changes, conform to the style and conventions of the surrounding code.
2. Strive for clarity, even if that means occasionally breaking the
guidelines. Use your head and ask for advice if your common sense seems to
disagree with the conventions.
Below we try to enumerate the guidelines embodied in the code.
#### File conventions
C++ implementation should be named `*.cpp`. Headers should be named `.h`.
@@ -158,111 +155,73 @@ All headers should contain
#pragma once
All source files should begin with these three lines:
All source files should begin with the copyright and license, which can be
found in the [LICENSE](LICENSE) file (or cut and pasted from any other other source
file). Two notes on this:
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
* For NEW source files, please change the copyright year to the present. DO
NOT edit existing files only to update the copyright year, it just creates
pointless deltas and offers no increased protection.
as a comment in the syntax of whatever source code is used in that file (for
example, for python or shell files, use `#` rather than `//`).
* Occasionally a file contains substantial code from another project
and will also list its copyright. Do NOT copy that notice to any new files,
it really only applies to the particular file in which it appears.
Occasionally a file may contain substantial code from another project and will
also list its original copyright and license information. Do NOT alter that
notice or copy it to any new files, it really only applies to the particular
file in which it appears.
#### Formatting
NEVER alter somebody else's code to reformat just because you found
something that violates the rules. Let the group/author/leader know, and
resist the temptation to change it yourself.
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) v17
to uniformly format our source code prior to PR submission. Make sure that
clang-format is installed on your local machine, and just run
Each line of text in your code should be at most 80 characters long.
Exceptions are allowed for those rare cases where letting a line be longer
(and wrapping on an 80-character window) is actually a better and clearer
alternative than trying to split it into two lines. Sometimes this happens,
but it's extremely rare.
make clang-format
Indent 4 spaces at a time, and use actual spaces, not tabs. For files that
must use tabs for some reason, tabs should always be on 8's. Most editors
have a setting that forces indentations to be spaces. With emacs, you can do
this:
and it will automatically reformat your code according to the configuration
file found in the `.clang-format` file at the root directory of the OSL
source code checkout.
(setq c-default-style "bsd")
(setq-default indent-tabs-mode nil)
One of the CI test matrix entries runs clang-format and fails if any
diffs were generated (that is, if any of your code did not 100% conform to
the `.clang-format` formatting configuration). If it fails, clicking on that
test log will show you the diffs generated, so that you can easily correct
it on your end and update the PR with the formatting fixes.
Opening brace on the same line as the condition or loop.
If you don't have clang-format set up on your machine, and your patch is not
very long, you may find that it's more convenient to just submit it and hope
for the best, and if it doesn't pass the CI test, look at the diffs in the log
for the "clang-format" CI run and make the corrections by hand and then submit
an update to the patch (i.e. relying on CI to run clang-format for you).
One statement per line, except in rare cases where violating this rule makes
the code more clear.
Because the basic formatting is automated by clang-format, we won't
enumerate the rules here.
Three (3) consecutive empty lines between function or class method
implementations, one blank line between method declarations within a class
definition. Put a single blank line within a function if it helps to
visually separate different sequential tasks. Don't put multiple blank lines
in a row within a function, or blank lines right after an opening brace or
right before a closing brace. The goal is to use just enough white space to
help developers visually parse the code (for example, spotting at a glance
where new functions begin), but not so much as to spread it out or be
confusing.
For the occasional non-clang-format regions of code, NEVER alter somebody
else's code to reformat just because you found something that violates the
rules. Let the group/author/leader know, and resist the temptation to change
it yourself.
For if, for, while, etc., put a space before the paren, but NOT inside the parens. For example:
Each line of text in your code, including comments, should be at most 80
characters long. Exceptions are allowed for those rare cases where letting a
line be longer (and wrapping on an 80-character window) is actually a better
and clearer alternative than trying to split it into two lines. Sometimes this
happens, but it's extremely rare.
if (foo) // Yes
if(foo) // No
if ( foo ) // No
We prefer three (3) consecutive empty lines between freestanding functions or
class definitions, one blank line between method declarations within a class
definition. Put a single blank line within a function if it helps to visually
separate different sequential tasks, but don't put multiple blank lines in a
row within a function, or blank lines right after an opening brace or right
before a closing brace. The goal is to use just enough white space to help
developers visually parse the code (for example, spotting at a glance where
new functions begin), but not so much as to spread it out or be confusing.
Function calls should have a space between the function name and the opening
parenthesis, NO space inside the parenthesis, except for a single blank
space between each argument. For example:
x = foo (a, b); // Yes, this is always ok
x = foo ( a, b ); // No
x = foo (a,b); // No
x = foo(a, b); // No
x = foo(a); // Occasionally, this just looks better, when the function name is short,
// and there's just one very short argument. What can I say, I do it too.
Function declarations: function names should begin at column 0 for a full
function definition. (It's ok to violate this rule for very short inline
functions within class definitions.)
Here is a short code fragment that shows some of these rules in action:
static int
function (int a, int b)
{
int x = a + b;
if (a == 0 || b == 0) {
x += 1;
x *= 4;
} else {
x -= 3;
}
for (int i = 0; i < 3; ++i) {
x += a * i;
x *= foo (i); // function call
}
return x;
}
Don't ever reformat, re-indent, change whitespace, or make any other such
changes to working code. If you're adding just a few lines or fixing a bug
in existing code, stick to the style of the surrounding code. In very rare
circumstances, and with consensus of the group, reformatting is sometimes
helpful to improve code readability, but it should be done as a separate
formatting-only checkin.
#### Identifiers
In general, classes and templates should start with upper case and capitalize new words:
class CustomerList;
In general, local variables should start with lower case.
In general, classes and templates should start with upper case and
capitalize new words: `class CustomerList;` In general, local variables
should start with lower case. Macros should be `ALL_CAPS`, if used at all.
If your class is extremely similar to, or modeled after, something in the
standard library, Boost, or something else we interoperate with, it's ok to
@@ -274,8 +233,6 @@ were standards.
template <class T> shared_ptr;
class scoped_mutex;
Macros should be ALL_CAPS, if used at all.
Names of data should generally be nouns. Functions/methods are trickier: a
the name of a function that returns a value but has no side effects should
be a noun, but a procedure that performs an action should be a verb.
@@ -306,7 +263,7 @@ Prefer C++11 `std` rather than Boost or other third party libraries, where
both can do the same task.
If you see a third party library already used as a dependency (such as OIIO,
Boost, Ilmbase, or LLVM), feel free to any of its public features in OSL
Boost, Imath, or LLVM), feel free to any of its public features in OSL
internals (provided those features are present in the minimum version of
that library that we support).
@@ -330,9 +287,6 @@ protected members of classes), please use Doxygen-style comments. They looks
like this:
/// Explanation of a class. Note THREE slashes!
/// Also, you need at least two lines like this. If you don't have enough
/// for two lines, make one line blank like this:
///
class myclass {
....
float foo; ///< Doxygen comments on same line look like this
+2 -1
View File
@@ -134,11 +134,12 @@ Current voting members of the TSC are:
* Eric Enderton - NVIDIA
* Stephen Friedman - Pixar
* Nicolas Guiard - Isotropix
* Derek Haase - DNEG
* Clint Hanson - DNEG
* Adrien Herubel - Autodesk
* Lee Kerley - Sony Pictures Imageworks
* Mitch Prater - Laika
* Brecht Van Lommel - Blender
* Alex Wells - Intel
### TSC Nomination and Succession
+56 -44
View File
@@ -4,7 +4,14 @@
Building OSL
============
OSL currently compiles and runs cleanly on Linux, Mac OS X, and Windows.
OSL currently compiles and runs cleanly on Linux (x86_64), Mac OS X (x86_64
and aarch64), and Windows (x86_64). It may build and run on other platforms as
well, but we don't officially support or test other than these platforms.
Shader execution is supported on the native architectures of those x86_64 and
aarch64 platforms, a special batched 8- or 16-wide SIMD execution mode
requiring x86_64 with AVX2 or AVX-512 instructions, as well as on NVIDIA GPUs
using Cuda+OptiX.
Dependencies
------------
@@ -12,19 +19,16 @@ Dependencies
OSL requires the following dependencies or tools.
NEW or CHANGED dependencies since the last major release are **bold**.
* Build system: [CMake](https://cmake.org/) 3.12 or newer (tested through 3.20)
* Build system: [CMake](https://cmake.org/) **3.15 or newer** (tested through 3.29)
* A suitable C++11 compiler to build OSL itself, which may be any of:
- GCC 4.8.5 or newer (tested through gcc 10)
- Clang 3.4 or newer (tested through clang 12)
- Microsoft Visual Studio 2015 or newer
- Intel C++ compiler icc version 13 (?) or newer
* A suitable C++14 or C++17 compiler to build OSL itself, which may be any of:
- GCC 6.1 or newer (tested through gcc 12.1)
- Clang 3.4 or newer (tested through clang 18)
- Microsoft Visual Studio 2017 or newer
- Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler
version 2022 or newer.
OSL should compile also properly with C++14 or C++17, but they are not
required (unless you are using LLVM >= 10, in which case at least C++14
is needed).
* **[OpenImageIO](http://openimageio.org) 2.1 or newer** (tested through 2.2)
* **[OpenImageIO](http://openimageio.org) 2.4 or newer** (tested through 2.5 and master)
OSL uses OIIO both for its texture mapping functionality as well as
numerous utility classes. If you are integrating OSL into an existing
@@ -43,31 +47,37 @@ NEW or CHANGED dependencies since the last major release are **bold**.
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X).
* **[LLVM](http://www.llvm.org) 7, 8, 9, 10, 11, or 12**, including clang
libraries.
* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, 15, 16, 17, or 18, including
clang libraries.
Note that LLVM 10+ is not compatible with C++11, and requires C++14 or
later. If you *must* build OSL with C++11, you need to use an LLVM that
is LLVM 9 or earlier.
* (optional) For GPU rendering on NVIDIA GPUs:
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.
* [Cuda](https://developer.nvidia.com/cuda-downloads) 9.0 or higher. It is
recommended that you use 11.0 or higher.
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.73)
* [Ilmbase](http://openexr.com/downloads.html) 2.0 or newer (tested through 2.5)
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.85)
* [Ilmbase or Imath](https://github.com/AcademySoftwareFoundation/Imath) 2.4
or newer (recommended: 3.1 or higher; tested through 3.2)
NOTE: OSL 1.13.x is the last release family that will support
Imath/OpenEXR 2.x.
* [Flex](https://github.com/westes/flex) 2.5.35 or newer and
[GNU Bison](https://www.gnu.org/software/bison/) 2.7 or newer.
Note that on some MacOS/xcode releases, the system-installed Bison is too
old, and it's better to install a newer Bison (via Homebrew is one way to
do this easily).
* [PugiXML](http://pugixml.org/)
* [PugiXML](http://pugixml.org/) >= 1.8 (we have tested through 1.13).
* (optional) [Partio](https://www.disneyanimation.com/technology/partio.html)
If it is not found at build time, the OSL `pointcloud` functions will not
be operative.
* (optional) Python: If you are building the Python bindings or running the
testsuite:
* Python >= 2.7 (tested against 2.7, 3.6, 3.7, 3.8)
* pybind11 >= 2.4.2 (Tested through 2.5)
* NumPy
* (optional) Qt >= 5.6 (tested through 5.15). If not found at build time,
the `osltoy` application will be disabled.
testsuite:
* Python >= 2.7 (tested against 2.7, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12)
NOTE: OSL 1.13.x is the last release family that will support Python 2.7.
* pybind11 >= 2.4.2 (Tested through 2.12. Note that pybind11 v2.10+ does
not support Python < 3.6.)
* NumPy
* (optional) Qt5 >= 5.6 or Qt6 (tested Qt5 through 5.15 and Qt6 through 6.7).
If not found at build time, the `osltoy` application will be disabled.
@@ -76,13 +86,13 @@ Build process
Here are the steps to check out, build, and test the OSL distribution:
0. Install and build dependencies.
1. Install and build dependencies.
1. Check out a copy of the source code from the Git repository:
2. Check out a copy of the source code from the Git repository:
git clone https://github.com/AcademySoftwareFoundation/OpenShadingLanguage.git osl
2. Change to the distribution directory and 'make'
3. Change to the distribution directory and 'make'
cd osl
make
@@ -93,27 +103,29 @@ Here are the steps to check out, build, and test the OSL distribution:
options, and note that 'make nuke' will blow everything away for the
freshest possible compile.
NOTE: If the build breaks due to compiler warnings which have been
elevated to errors, you can try "make clean" followed by
"make STOP_ON_WARNING=0", that create a build that will only stop for
You can also ignore the top level Makefile wrapper, and instead use
CMake directly:
cmake -B build -S .
cmake --build build --target install
NOTE: If the build breaks due to compiler warnings which have been elevated
to errors, you can try "make clean" followed by "make STOP_ON_WARNING=0",
or if using cmake directly, add `-DSTOP_ON_WARNING=0` to the cmake
configuration command. That will create a build that will only stop for
full errors, not warnings.
3. After compilation, you'll end up with a full OSL distribution in
dist/ARCH, where ARCH is the architecture you are building on, one of
"linux", "linux64", "macosx", "windows", or "windows64".
4. After compilation, you'll end up with a full OSL distribution in
dist/
Note: The default is to make an optimized "release" build. If
instead type 'make debug' at the top level, you will end up with
a debug build (no optimization, full symbols) in "dist/ARCH.debug".
4. Add the "dist/ARCH/bin" to your $PATH, and "dist/ARCH/lib" to your
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on OS X), or copy the contents
5. Add the "dist/bin" to your $PATH, and "dist/lib" to your
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on MacOS), or copy the contents
of those files to appropriate directories. Public include files
(those needed when building applications that incorporate OSL)
can be found in "dist/ARCH/include", and documentation can be found
in "dist/ARCH/share/doc".
can be found in "dist/include", and documentation can be found
in "dist/share/doc".
5. After building (and setting your library path), you can run the
6. After building (and setting your library path), you can run the
test suite with:
make test
+29 -30
View File
@@ -22,15 +22,6 @@ working_dir := ${shell pwd}
# Figure out which architecture we're on
include ${working_dir}/src/make/detectplatform.mk
# Presence of make variables DEBUG and PROFILE cause us to make special
# builds, which we put in their own areas.
ifdef DEBUG
variant +=.debug
endif
ifdef PROFILE
variant +=.profile
endif
MY_MAKE_FLAGS ?=
MY_NINJA_FLAGS ?=
MY_CMAKE_FLAGS ?=
@@ -47,17 +38,15 @@ endif
# Set up variables holding the names of platform-dependent directories --
# set these after evaluating site-specific instructions
top_build_dir ?= build
build_dir ?= ${top_build_dir}/${platform}${variant}
top_dist_dir ?= dist
dist_dir ?= ${top_dist_dir}/${platform}${variant}
build_dir ?= build
dist_dir ?= dist
INSTALL_PREFIX ?= ${working_dir}/${dist_dir}
VERBOSE ?= ${SHOWCOMMANDS}
ifneq (${VERBOSE},)
MY_MAKE_FLAGS += VERBOSE=${VERBOSE}
MY_CMAKE_FLAGS += -DVERBOSE:BOOL=${VERBOSE}
MY_CMAKE_FLAGS += -DVERBOSE:BOOL=${VERBOSE} --log-level=VERBOSE
ifneq (${VERBOSE},0)
MY_NINJA_FLAGS += -v
TEST_FLAGS += -V
@@ -124,10 +113,6 @@ ifneq (${OSL_BUILD_SHADERS},)
MY_CMAKE_FLAGS += -DOSL_BUILD_SHADERS:BOOL=${OSL_BUILD_SHADERS}
endif
ifneq (${OSL_BUILD_MATERIALX},)
MY_CMAKE_FLAGS += -DOSL_BUILD_MATERIALX:BOOL=${OSL_BUILD_MATERIALX}
endif
ifdef DEBUG
CMAKE_BUILD_TYPE=Debug
endif
@@ -167,6 +152,14 @@ ifneq (${USE_SIMD},)
MY_CMAKE_FLAGS += -DUSE_SIMD:STRING="${USE_SIMD}"
endif
ifneq (${USE_BATCHED},)
MY_CMAKE_FLAGS += -DUSE_BATCHED:STRING="${USE_BATCHED}"
endif
ifneq (${VEC_REPORT},)
MY_CMAKE_FLAGS += -DVEC_REPORT:BOOL="${VEC_REPORT}"
endif
ifneq (${TEST},)
TEST_FLAGS += -R ${TEST}
endif
@@ -216,7 +209,10 @@ ifneq (${BUILD_MISSING_DEPS},)
endif
ifneq (${USE_OPTIX},)
MY_CMAKE_FLAGS += -DUSE_OPTIX:BOOL=${USE_OPTIX}
MY_CMAKE_FLAGS += -DOSL_USE_OPTIX:BOOL=${USE_OPTIX}
endif
ifneq (${OSL_USE_OPTIX},)
MY_CMAKE_FLAGS += -DOSL_USE_OPTIX:BOOL=${OSL_USE_OPTIX}
endif
ifneq (${USE_PYTHON},)
@@ -247,7 +243,7 @@ endif
#########################################################################
# Top-level documented targets
all: dist
all: install
# 'make debug' is implemented via recursive make setting DEBUG
debug:
@@ -267,7 +263,7 @@ config:
cd ${build_dir} ; \
${CMAKE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${MY_CMAKE_FLAGS} ../.. ; \
${MY_CMAKE_FLAGS} ${working_dir} ; \
fi)
@@ -305,7 +301,7 @@ clang-format: config
)
# 'make dist' is just a synonym for 'make install'
# DEPRECATED: 'make dist' is just a synonym for 'make install'
dist : install
TEST_FLAGS += --force-new-ctest-process --output-on-failure
@@ -337,10 +333,10 @@ clean:
realclean: clean
${CMAKE} -E remove_directory ${dist_dir}
# 'make nuke' blows away the build and dist areas for all platforms
# DEPRECATED: use 'make realclean'
nuke:
${CMAKE} -E remove_directory ${top_build_dir}
${CMAKE} -E remove_directory ${top_dist_dir}
${CMAKE} -E remove_directory ${build_dir}
${CMAKE} -E remove_directory ${dist_dir}
#########################################################################
@@ -357,7 +353,6 @@ help:
@echo " make profile Build and install for profiling"
@echo " make clean Remove the temporary files in ${build_dir}"
@echo " make realclean Remove both ${build_dir} AND ${dist_dir}"
@echo " make nuke Remove ALL of build and dist (not just ${platform})"
@echo " make test Run tests"
@echo " make testall Run all tests, even broken ones"
@echo " make clang-format Run clang-format on all the source files"
@@ -368,7 +363,7 @@ help:
@echo " STOP_ON_WARNING=0 Do not stop building if compiler warns"
@echo " OSL_SITE=xx Use custom site build mods"
@echo " MYCC=xx MYCXX=yy Use custom compilers"
@echo " CMAKE_CXX_STANDARD=14 Compile in C++14 mode (default is C++11)"
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)"
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"
@@ -391,7 +386,7 @@ help:
@echo " BOOST_ROOT=path Custom Boost installation"
@echo " USE_QT=0 Skip anything that needs Qt"
@echo " LLVM-related options:"
@echo " LLVM_VERSION=7.0 Specify which LLVM version to use"
@echo " LLVM_VERSION=12.0 Specify which LLVM version to use"
@echo " LLVM_DIRECTORY=xx Specify where LLVM lives"
@echo " LLVM_NAMESPACE=xx Specify custom LLVM namespace"
@echo " LLVM_STATIC=1 Use static LLVM libraries"
@@ -402,11 +397,15 @@ help:
@echo " USE_FAST_MATH=1 Use faster, but less accurate math (set to 0 for libm defaults)"
@echo " OSL_BUILD_TESTS=0 Don't build unit tests, testshade, testrender"
@echo " OSL_BUILD_SHADERS=0 Don't build any shaders"
@echo " OSL_BUILD_MATERIALX=1 Build MaterialX shaders"
@echo " USE_SIMD=arch Build with SIMD support (comma-separated choices:"
@echo " 0, sse2, sse3, ssse3, sse4.1, sse4.2, f16c,"
@echo " avx, avx2, avx512f)"
@echo " USE_OPTIX=1 Build the OptiX test renderer"
@echo " OSL_USE_OPTIX=1 Build the OptiX test renderer"
@echo " USE_BATCHED=targets Build batched SIMD execution of shaders for (comma-separated choices:"
@echo " 0, b8_AVX, b8_AVX2, b8_AVX2_noFMA,"
@echo " b8_AVX512, b8_AVX512_noFMA,"
@echo " b16_AVX512, b16_AVX512_noFMA)"
@echo " VEC_REPORT=0 Generate compiler vectorization reports"
@echo " make test, extra options:"
@echo " TEST=regex Run only tests matching the regex"
@echo ""
+132 -30
View File
@@ -1,7 +1,7 @@
<div align="center">
<img src="https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/src/doc/Figures/osl-short.png" width=256 height=128>
<img src="ASWF/logos/openshadinglanguage-stacked-Shaded.png">
<H1>Open Shading Language</H1>
<!-- <H1>Open Shading Language</H1> -->
</div>
[![Open Shading Language Reel 2020](http://img.youtube.com/vi/nmwMz1YnGPA/0.jpg)](https://www.youtube.com/watch?v=nmwMz1YnGPA "Open Shading Language Reel 2020")
@@ -9,7 +9,7 @@
[![Build Status](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/workflows/CI/badge.svg)](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/actions)
[![License](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/LICENSE.md)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3061/badge)](https://bestpractices.coreinfrastructure.org/projects/3061)
[![Documentation Status](https://readthedocs.org/projects/open-shading-language/badge/?version=main)](https://open-shading-language.readthedocs.io/en/main/?badge=main)
Introduction
@@ -219,13 +219,15 @@ inferred from public sources, or that we've been told is ok to list here. If
an OSL-using project is missing and it's not a secret, just email the OSL
project leader or submit a PR with edits to this file.*
Renderers and other tools with OSL support (in approximate order of
adding OSL support):
* Sony Pictures Imageworks: in-house "Arnold" renderer
### Renderers and other production tools with OSL support
(In approximate order of adding OSL support)
* [Sony Pictures Imageworks: in-house "Arnold" renderer](https://dl.acm.org/doi/10.1145/3180495)
* [Blender/Cycles](https://docs.blender.org/manual/en/dev/render/shader_nodes/osl.html)
* [Chaos Group: V-Ray](https://www.chaosgroup.com/)
* [Pixar: PhotoRealistic RenderMan RIS](https://renderman.pixar.com)
* [Isotropix: Clarisse](http://www.isotropix.com/clarisse)
* Isotropix: [Clarisse iFX](https://www.isotropix.com/products/clarisse/ifx) / [Clarisse BUiLDER](https://www.isotropix.com/products/clarisse/builder) / [Angie](https://www.isotropix.com/products/angie)
* [Autodesk Beast](http://www.autodesk.com/products/beast/overview)
* [Appleseed](http://appleseedhq.net)
* [Animal Logic: Glimpse renderer](https://www.fxguide.com/featured/a-glimpse-at-animal-logic/)
@@ -234,8 +236,15 @@ adding OSL support):
* Ubisoft motion picture group's proprietary renderer
* [Autodesk/SolidAngle: Arnold](https://www.solidangle.com/arnold/)
* [Autodesk: 3DS Max 2019](https://help.autodesk.com/view/3DSMAX/2019/ENU/?guid=__developer_3ds_max_sdk_features_rendering_osl_html)
* [Maxon: Redshift](https://www.maxon.net/en/redshift)
### Significant work using OSL, grouped by year of release date:
(Here we are considering "significant work" to mean a feature film released
theatrically or on a major streaming platform, TV/streaming series heavily
featuring visual effects or animation, or short films that have won or been
nominated for major awards.)
Films using OSL (grouped by year of release date):
* **(2012)**
Men in Black 3, The Amazing Spider-Man, Hotel Transylvania
* **(2013)**
@@ -270,6 +279,7 @@ Films using OSL (grouped by year of release date):
Ghostbusters,
Star Trek Beyond,
Suicide Squad,
Kubo and the Two Strings,
Kingsglaive: Final Fantasy XV,
Storks,
Miss Peregrine's Home for Peculiar Children,
@@ -304,7 +314,7 @@ Films using OSL (grouped by year of release date):
* **(2018)**
Peter Rabbit,
Black Panther,
Annnihilation,
Annihilation,
Red Sparrow,
Pacific Rim Uprising,
Avengers Infinity War,
@@ -345,23 +355,89 @@ Films using OSL (grouped by year of release date):
Angry Birds 2,
The Art of Racing in the Rain,
Secret Life of Pets,
The Mandalorian,
The Mandalorian (S1),
The Dark Crystal: Age of Resistance,
The King,
Jumanji: The Next Level,
Richard Jewell,
Game of Thrones,
Lost in Space,
* **(2020 / upcoming)**
Game of Thrones (S8),
Lost in Space (S1),
Togo,
Missing Link
* **(2020)**
Underwater,
Birds of Prey,
Onward,
Bloodshot,
Greyhound,
The Old Guard,
Mulan,
Tenet,
The New Mutants,
Artemis Fowl,
The Eight Hundred,
Over the Moon,
Wonder Woman 1984,
Soul,
The Mandalorian (S2),
The Boys (S2),
Umbrella Academy (S2)
* **(2021)**
Chaos Walking,
Peter Rabbit 2: The Runaway,
The Falcon and the Winder Soldier,
Secret Magic Control Agency,
Zack Snyder's Justice League,
The Mitchells vs the Machines,
Jupiter's Legacy,
Luca,
F9,
Vivo,
Jungle Cruise,
Cinderella,
Dune,
No Time To Die,
Ron's Gone Wrong,
Venom: Let There Be Carnage,
Last Night in Soho,
Ghostbusters: Afterlife,
Spider-Man 3: No Way Home,
Matrix Resurrections,
Sing 2
* **(2022)**
Hotel Transylvania 4: Transformania,
Death on the Nile,
Uncharted,
Turning Red,
The Adam Project,
Doctor Strange in the Multiverse of Madness,
Love, Death, and Robots: In Vaulted Halls Entombed,
Jurassic World: Dominion,
Lightyear,
Thor: Love and Thunder,
The Sea Beast,
DC League of Super Pets,
Minions: Rise of Gru,
Bullet Train,
Slumberland,
Glass Onion,
Archive 81 (series),
Moon Night (series),
Obi-Wan Kenobi (series),
The Boys (S3),
Andor (S1)
* **(2023)**
Ant-Man and the Wasp: Quantumania,
The Mandalorian S3,
The Magician's Elephant,
Super Mario Bros Film,
Guardians of the Galaxy 3,
Spider-Man: Across the Spider-Verse,
Elemental,
The Marvels,
Leo
* **(2024 / upcoming)**
Ghostbusters: Frozen Empire,
...
@@ -380,6 +456,24 @@ The OSL language specification can be found at
distribution) or in the share/doc/OSL/osl-languagespec.pdf file of an
installed binary distribution.
[Experimental OSL Documentation on ReadTheDocs](https://open-shading-language.readthedocs.io/)
This will be the future documentation. It's probably as complete as the PDF,
but it needs some proofreading, so the PDF is still considered the
authoritative source for now. But some time soon, the old PDF specification
will be deprecated in favor of
this online documentation.
<!-- is the best place to start if you are interested in how to use OSL,
its APIs. -->
There is also a [PDF
version](https://readthedocs.org/projects/open-shading-language/downloads/pdf/latest/).
For those interested in learning to program shaders in OSL, there is the
[Siggraph 2022 Educator's Forum](https://dl.acm.org/doi/proceedings/10.1145/3532724)
[OSL Shaders for RenderMan](https://dl.acm.org/doi/abs/10.1145/3532724.3535604) course,
which uses RenderMan in the examples and
[Supplementary Materials](https://github.com/LaikaStudios/OSLShadersForRenderMan),
but which is primarily about shader writing in OSL.
Contact & reporting problems
----------------------------
@@ -395,9 +489,13 @@ certain is a legit problem in the code, and for which you can give clear
instructions for how to reproduce, should be [reported as
issues](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues).
If confidentiality precludes a public question or issue, you may contact the
project administrator privately at [lg@imageworks.com](lg@imageworks.com),
including for security-related issues.
If you think you've found a potential vulnerability in OSL, please
confidentially report it by emailing the project administrators at
[security@openshadinglanguage.org](security@openshadinglanguage.org).
If any other issue requires confidentiality that precludes a public question
or issue, you may contact the project administrator privately at
[lg@larrygritz.com](lg@larrygritz.com).
Contributing
@@ -416,12 +514,11 @@ Contacts, Links, and References
[Read or subscribe to the OSL development mail list](https://lists.aswf.io/g/osl-dev)
[Most recent PDF of the OSL language specification](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/src/doc/osl-languagespec.pdf
[Most recent PDF of the OSL language specification](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/doc/osl-languagespec.pdf
)
[OSL home page at SPI](http://openshadinglanguage.org)
[OSL home page](http://openshadinglanguage.org)
[Sony Pictures Imageworks main open source page](http://opensource.imageworks.com)
@@ -433,17 +530,22 @@ The current project leadership is documented in the
Many people have contributed features, bug fixes, and other changes to OSL
over the years: Steve Agland, Shane Ambler, Martijn Berger, Farchad
Bidgolirad, Nicholas Bishop, Solomon Boulos, Stefan Bruens, Stefan Büttner,
Matthaus G. Chajdas, Alejandro Conty, Thomas Dinges, Luke Emrose, Louis
Feng, Mark Final, Henri Fousse, Syoyo Fujita, Tim Grant, Larry Gritz, Derek
Haase, Sven-Hendrik Haase, John Haddon, Daniel Heckenberg, Thiago Ize, Matt
Johnson, Ronan Keryell, Chris Kulla, Elvic Liang, Max Liani, Adam Martinez,
John Mertic, Bastien Montagne, Steena Monteiro, Alexis Oblet, Erich Ocean,
Mikko Ohtamaa, Jino Park, Alexei Pawlow, Jay Reynolds, Declan Russell,
Patrick Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Cliff
Stein, Stephan Steinbach, Esteban Tovagliari, Brecht Van Lommel, Alexander
von Knorring, Alex Wells, Roman Zulak. (Listed alphabetically; if we've left
anybody out, it is inadvertent, please let us know.)
Bidgolirad, Nicholas Bishop, Curtis Black, Rasmus Bonnedal, Solomon Boulos,
Stefan Bruens, Stefan Büttner, Matthaus G. Chajdas, Clark Chen, Alejandro
Conty, Damien Courtois, Dieter De Baets, Thomas Dinges, Daniel Dresser, Mads
Drøschler, Peter Ellerington, Luke Emrose, Louis Feng, Mark Final, Henri
Fousse, Stephen Friedman, Syoyo Fujita, Tim Grant, Larry Gritz, Nicolas
Guiard, Ole Gulbrandsen, Euan Haahr, Derek Haase, Sven-Hendrik Haase, John
Haddon, Niklas Harrysson, Daniel Heckenberg, Chris Hellmuth, Adrien Herubel,
Dan Horák, Thiago Ize, Matt Johnson, Ronan Keryell, Chris Kulla, Elvic Liang,
Max Liani, Adam Martinez, John Mertic, Bastien Montagne, Steena Monteiro, John
Mertic, Patrick Mours, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park,
Alexei Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick Scheibe,
Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip Shukla,
Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, Brecht
Van Lommel, Thibault Vergne, Alexander von Knorring, Aidan Welch, Alex Wells,
Roman Zulak. (Listed alphabetically; if we've left anybody out, it is
inadvertent, please let us know.)
We cannot possibly express sufficient gratitude to the managers at Sony
Pictures Imageworks who allowed this project to proceed, supported it
+27
View File
@@ -0,0 +1,27 @@
# Security Policy
## Supported Versions
This gives guidance about which branches are supported with patches to
security vulnerabilities.
| Version / branch | Supported |
| --------- | ---------------------------------------------------- |
| main | :white_check_mark: :construction: ALL fixes immediately, but this is a branch under development with a frequently unstable ABI and occasionally unstable API. |
| 1.12.x | :white_check_mark: All fixes that can be backported without breaking ABI compatibility. New tagged releases monthly. |
| 1.11.x | :warning: Only the most critical fixes, only if they can be easily backported. |
| <= 1.10.x | :x: No longer receiving patches of any kind. |
## Reporting a Vulnerability
If you think you've found a potential vulnerability in OSL, please report it
by emailing the project administrators at
[security@openshadinglanguage.org](security@openshadinglanguage.org). Only the
project administrators have access to these messages. Include detailed steps to
reproduce the issue, and any other information that could aid an
investigation. Our policy is to respond to vulnerability reports within 14
days.
Our policy is to address critical security vulnerabilities rapidly and post
patches as quickly as possible.
+24 -6
View File
@@ -12,12 +12,6 @@ In no particular order:
BSD 3-Clause License
SPDX-License-Identifier: BSD-3-Clause
* OpenImageIO Copyright (c) Larry Gritz, et al.
https://github.com/OpenImageIO/oiio
Many bits of code flow back and forth between OIIO and OSL, especially
parts of the CMake build system.
* OpenEXR, Copyright (c) Contributors to the OpenEXR Project.
https://github.com/AcademySoftwareFoundation/OpenEXR
@@ -107,6 +101,30 @@ Public domain
but of course I'd appreciate it if you kept my name somewhere.
-------------------------------------------------------------------------
Apache 2.0 License.
SPDX-License-Identifier: Apache-2.0
* OpenImageIO Copyright (c) Contributors to the OpenImageIO Project.
https://github.com/AcademySoftwareFoundation/OpenImageIO
Many bits of code flow back and forth between OIIO and OSL, especially
parts of the CMake build system.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-------------------------------------------------------------------------
Modified Apache 2.0 License
+1 -1
View File
@@ -2,7 +2,7 @@
The OSL Documentation Project is a work in progress.
The plan is to adopt the OCIO Documentation Project's methodology for maintaining and building documention of various kinds as it becomes the blueprint for the ASWF.
The plan is to adopt the OCIO Documentation Project's methodology for maintaining and building documentation of various kinds as it becomes the blueprint for the ASWF.
There is much work to be done here.
+341
View File
@@ -0,0 +1,341 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
# Release Procedures for Open Shading Language
## Version nomenclature and release cadence
### The meaning of the version parts
Our release numbers are of the form `MAJOR.MINOR.PATCH.TWEAK`, and we follow
an almost-semantic-versioning scheme.
MAJOR changes are those that break backward-compatibility of the public APIs,
requiring existing application code to change their source code where it calls
OSL API functions in order to compile and work correctly.
MINOR changes guarantee API backward-compatibility with prior releases that
have the same major number, but can introduce ABI or link incompatibilities.
Applications using OSL need to be recompiled to move to a new minor release,
but should not need to change their source code. Minor releases are allowed
to drop support for sufficiently old compilers and dependencies.
PATCH changes guarantee both API and ABI/link backward-compatibility with
prior releases that have the same minor number. Features and new public API
calls may be added (thus deviating from strict semantic versioning), but only
if they preserve ABI/link compatibility. This means that standalone functions
or static methods may be added, but existing functions will not change their
parameters, and no new virtual methods or struct data layouts change for patch
releases (for classes in public header files). Application code can be
re-linked to a new patch release without needing to be recompiled. We also
guarantee that any compilers or dependencies supported for the first release
of a minor series will continue to be supported for all patches to that minor
series.
TWEAK changes are restricted to critical bug fixes or build breaks that do
not alter public APIs in any way.
### Cadence of releases
Major (arbitrarily incompatible) releases happen rarely, usually with multiple
years between them.
Minor (API backward-compatible) releases are scheduled annually, targeted at
late summer (SIGGRAPH time) to be in beta, and early autumn for a full
release.
Patch (API and ABI backward-compatible) releases are scheduled monthly,
usually aiming for the first day of each month.
Tweak (fully forward and backward compatible) releases are not regularly
scheduled, and only happen sporadically, when a critical fix is needed in
between scheduled patch releases.
### Things are different in "main"
The "main" branch is where ongoing development occurs without any
compatibility guarantees. We don't always know if the next year's release from
main will turn out to be major (API breaking) or minor (only ABI breaking).
Some studios or products need the most up-to-date enhancements, and thus tend
to build OSL from the "main" branch rather than using tagged releases. For
these users, we try to set version numbers and occasionally tag in main, to
send a signal about which points in main seem safe to rely on various
compatibility levels. However, the rules are slightly different than we use
for releases.
In the "main" branch:
- TWEAK changes within "main" only guarantee ABI back-compatibility, but may
have additions or non-bug-fix behavior changes (akin to patch releases
within a release branch).
- PATCH changes within "main" are allowed to break ABI or API (changes that
would require minor or major releases, if they were not in "main").
- Beware of unmarked breaks in compatibility of commits in main that are
in between developer preview tags.
---
## Branch and tag names
**Branches** are places where commits containing new development may be added
(and thus the branch markers will move over time). Branch names obey the
following conventions:
- `main` is the area for arbitrary changes intended for the next year's major
or minor release.
- `dev-1.2` are the areas for staging additions to the next month's patch
release for the designated minor version series.
- `release` is a special branch marker that is always set to the latest tag of
the currently supported, stable release family. People can count on
"release" always being the latest stable release, whatever that may be at
the time.
**Tags** indicate releases or developer previews, and once a commit is
tagged, it is permanent and will never be moved. Tag names obey the following
conventions:
- `v1.2.3.4` is a specific public stable release, corresponding to official
major, minor, public, or tweak releases.
- `v1.2.3.4-alpha`, `v1.2.3.4-beta`, or `v1.2.3.4-RC1` are pre-releases for an
upcoming public stable release, at the alpha, beta, or release candidate
stages, respectively.
- `v1.2.3.4-dev` is a "developer preview" within "main." It is not an official
supported release, and while the numbering may indicate compatibility versus
other recent developer previews, they should not be assumed to be compatible
with any prior official stable releases.
*Very* occasionally, other branch or tag names (with custom suffixes or
different naming schemes) may be used for special purposes by particular
developers or users, but should not be considered reliable or permanent, and
in general should be ignored by anyone who didn't make the tag or branch.
---
## Release Procedures
### Soft freeze for monthly tweak releases:
We freely backport *safe*, non-ABI-breaking changes by cherry-picking them
from main to the supported branch continually throughout most of the month.
In the seven days before the new month, we do a "soft freeze" where only
important bug fixes are backported. Hold on to any other patches you wish to
backport until after the monthly patch release (i.e., save them for the next
month's release so you never have a release that contains changes that are
only a few days old, and therefore not as well tested). You may, of course,
continue to backport fixes to documentation or other non-code parts of the
project during this soft freeze.
### Branching for annual major/minor releases
By mid-June (about 1-2 months before the beta of a new annual big release),
you should branch and mark it as an alpha.
At the tip of "main," create a new branch named `dev-MAJOR.MINOR` that will be
the staging area for the next release.
Customarily, at that point we add a commit to main (but not to the new
dev-MAJ.MIN branch) that bumps main's version to the next minor level, to
avoid any confusion between builds from main versus what will be the next
release branch. This starts the divergence between main and the release
branch, and henceforth, any big or compatibility-breaking changes will only be
committed to main and not backported to the release branch. (Though we are
loose about this rule during the alpha period and allow continued breaking
changes in the alpha, but by the time we call it beta, we allow no more
breaking changes.)
### Prior to a release
1. Update CI dependencies: Ensure that the "latest" CI test specifies the
current releases of the dependencies and compilers (check their home
pages), and that the [INSTALL.md](../INSTALL.md) file correctly documents
the version ranges that we expect to work and that we actively test.
2. Release notes: [CHANGES.md](../CHANGES.md) should be updated to reflect
all the new features and fixes. Looking at the notes from older releases
should provide a good example of what we're aiming for.
- Patch and tweak releases can be brief one-line descriptions (often the
first line of the commit messages involved), presented in a single
section in either chronological or any other order that seems right.
- Minor or major releases have a much more extensive, prose-based
description of all changes since the last minor release, broken into
sections (dependency changes, major new features, enhancements and fixes,
internals and developer goodies, testing/CI/ports, etc.) and ordered for
readability and relevance.
3. Ensure docs are up to date:
- Actually read the [README.md](../README.md), [INSTALL.md](../INSTALL.md),
and other repository docs and make sure all the information is up to
date. Check the "contributor credits" in the README against the recent
repo history to be sure new contributors are listed. Also check the
list of films and make sure it includes any recent productions that are
known to have used OSL.
- Skim the primary user documentation to look for any obvious errors,
especially the parts that describe new features. In the case of PDF docs
(such as osl-languagespec.pdf), make sure that a new PDF book is built if
the documentation source has been changed since the last release.
- If we are using any online docs (like readthedocs), make sure it is
building and looks correct on the web site.
4. Make sure the the top-level CMakeLists.txt file is updated:
- The version on the `project()` call should be correct.
- The `PROJECT_VERSION_RELEASE_TYPE` variable should be set to "alpha" or
"beta" if appropriate, "RC" for release candidate, or empty string `""`
for most supported releases, and "dev" only for the main branch or
developer previews.
- The `${PROJECT_NAME}_SUPPORTED_RELEASE` variable should be `ON` for any
release branch, `OFF` for main.
5. Make sure everything passes the usual CI workflow. Also check the daily or
weekly "analysis" workflows to make sure there aren't any important
warnings that should be fixed.
### Staging alpha / beta / release candidate (annual minor/major releases only)
For monthly patch releases, we don't have any formal alpha/beta/RC stages.
For the annual minor or major releases we have a staged release:
- `alpha` is everything after we have branched, in which we think all the big
new features have been added, and while we will make continued changes and
fixes, we are aiming for increased stability and to minimize additional
breaking changes prior to the release.
- `beta` should be about one month prior to the final release date. We create
a tag `v1.2.3.4-beta` and announce the beta (see below "Making the
release"). Once we tag a beta, we try very hard not to allow any further
changes that change the API or are not ABI-compatible (i.e., safe fixes
only).
- `RC` or release candidates around one week prior to the final release date.
This is a trial run, hopefully identical to the final release (except for
removing the RC label and making a new tag). The only changes allowed after
RC are fixes to the most critical bugs or build breaks that would be bad for
users to encounter. If critical problems are found with RC1, they should be
fixed and immediately re-tagged as RC2, etc. All other fixes should be
postponed until the next month's patch release.
### Making the release
A final release is made on the scheduled date, provided the latest RC has
survived for at least a few days of testing without finding any critical
problems. Don't make the release final until you are sure there are no
truly critical bugs or build breaks that users will encounter.
The following are the steps for making the release:
1. Edit the top-level CMakeLists.txt to remove any RC designation
(i.e., `PROJECT_VERSION_RELEASE_TYPE` should be set to `""`).
2. Edit CHANGES.md to reflect the correct date of the release and ensure it
includes any last-minute changes that were made during beta or release
candidate stages.
3. Push it to **your** GitHub, make sure it passes CI.
4. Tag the release: `git tag v1.2.3.4` (no more beta, RC, or dev suffix).
5. If this will now be the recommended stable release, move the `release`
branch marker to the same position.
6. Push it to GitHub: `git push aswf release --tags`
(This example assumes "aswf" is the name of the remote for the GitHub
`AcademySoftwareFoundation/OpenShadingLanguage` repo.)
7. Draft a release on GitHub: On
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/releases
select "Draft a new release." Choose the new tag you just pushed. Make the
release title "Open Shading Language v1.2.3.4" (and beta, etc., designation
if applicable). In the description, paste the release notes for this
release (from Changes.md). If this is a beta or release candidate, check
"this is a pre-release" box at the bottom.
8. Announce the release on the [osl-dev mail list](https://lists.aswf.io/g/osl-dev)
with the subject "Release: OSL v1.2.3.4" and using one of these templates
for the body of the email.
For a monthly patch release:
> We have tagged v1.2.3.4 as the latest production release and moved the
> "release" branch marker to that point. This is guaranteed to be API,
> ABI, and link back-compatible with prior 1.2 releases. Release notes
> are below.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
For an annual major/minor release:
> OSL version 1.2 has been released! Officially tagged as "v1.2.3.4", we
> have also moved the "release" branch tag to this position. Henceforth,
> 1.2 is the supported production release family. The API is now frozen --
> we promise that subsequent 1.2.x releases (which should happen monthly)
> will not break back-compatibility of API, ABI, or linkage, compared to
> this release. Please note that this release is *not* ABI or link
> compatible with 1.1 or older releases.
>
> Release notes for 1.2 outlining all the changes since last year's
> release are below.
>
> Please note that a few of the build and runtime dependencies have
> changed their minimum supported versions. (List here any important
> changes to dependencies, compilers, or C++ standard that users should be
> aware of.)
>
> (List here anything else that people should know about this release
> family that may be surprising if they haven't followed the last year of
> development closely, or that they must know even if they are too lazy to
> read the release notes. If this is a major release that is not
> backward-compatible with prior versions, warn about that here.)
>
> Enjoy, and please report any problems. We will continue to make patch
> releases to the 1.2 family roughly monthly, which will contain bug fixes
> and non-breaking enhancements.
>
> The older 1.1 series of releases is now considered obsolete. We will
> continue for now to make 1.1 patch releases, but over time, these will
> become less frequent and be reserved for only the most critical bug
> fixes.
>
> The "main" branch is now progressing toward an eventual 1.3 release next
> summer. As usual, you are welcome to use main for real work, but we do
> not make any compatibility guarantees and don't guarantee continuing API
> compatibility in main.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
For a beta leading up to the annual major/minor release:
> OSL version 1.2 is now in beta, tagged as "v1.2.3.4-beta". We
> will try very hard not to make any further API or ABI changes between
> now and the final release (unless it is absolutely necessary to fix
> an important problem identified during beta testing). The final 1.2
> release is scheduled for [DATE GOES HERE], so please try building and
> testing the beta so we are sure to find any problems.
>
> Release notes for 1.2 outlining all the changes since last year's
> release are below.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
### After the release
Odds and ends to do after the tag is pushed and the announcements are sent:
- Re-read RELEASING.md and ensure that the instructions match what you
have done. Update as necessary.
- For annual beta releases, post a short message to the "Open Shading
Language" channel of the ASWF slack. It can be a one-line announcement and
then just a link to the GitHub release page for this version.
@@ -0,0 +1,112 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Inlining Options for OptiX and CUDA
===================================
When compiling shaders for OptiX and CUDA (and in general), there is a tradeoff
between compile speed and shade-time performance. The LLVM optimizer generally
does a good job of balancing these concerns, but there might be cases where a
renderer can give additional hints to the optimizer to tip the balance one way
or the other.
Aggressive inlining can increase the run-time performance, but can negatively
impact the compile speed. Inlining can be very helpful with small functions
where the function call overhead tends to dwarf the useful instructions, so it
is important to inline such functions when possible.
Choosing to __not__ inline certain functions (e.g., very large noise functions)
allows them to be excluded from the module prior to running the LLVM optimizer
and JIT engine, which can greatly improve the compile time. This is particularly
beneficial when a function is not likely to be inlined anyway; removing such
large functions from the module prior to optimization can speed up compilation
considerably without affecting the generated PTX.
ShadingSystem Attributes
------------------------
There are a number of `ShadingSystem` attributes to help control the inlining
behavior. The default settings should work well in most circumstances, but they
can be adjusted to favor compile speed over shade-time performance, or vice
versa.
* `optix_no_inline_thresh`: Don't inline functions greater-than or equal-to the
threshold. This allows them to be excluded from the module prior to
optimization, which reduces the size of module and can greatly speed up the
optimization and JIT stages.
* `optix_force_inline_thresh`: Force inline functions less-than or equal-to the
threshold. This tends to be most helpful with relatively low values, < 30.
* `optix_no_inline`: Don't inline any functions. Offers the best compile times
at the expense of shade-time performance. This option is not recommended, but is
included for benchmarking and tuning purposes.
* `optix_no_inline_layer_funcs`: Don't inline the shader layer functions. This
can moderately improve compile times at the expense of shade-time performance.
* `optix_merge_layer_funcs`: Allow layer functions that are only called once to
be merged into their caller, even if `optix_no_inline_layer_funcs` is set. This
can help restore some of the shade-time performance lost by enabling
`optix_no_inline_layer_funcs`.
* `optix_no_inline_rend_lib`: Don't inline any functions defined in the
renderer-supplied `rend_lib` module. As an alternative, the renderer can simply
not supply the LLVM bitcode for the `rend_lib` module to the `ShadingSystem`.
Inline/Noinline Function Registration
-------------------------------------
In addition to the `ShadingSystem` attributes, individual functions can be
registered with the `ShadingSystem` as `inline` or `noinline`. Functions can
be unregistered to restore the default inlining behavior. This registration
takes precedence over the `ShadingSystem` inlining attributes, which allows
very fine-grained control when needed.
```C++
// Register
shadingsys->register_inline_function(ustring("osl_abs_ff"));
shadingsys->register_noinline_function(ustring("osl_gabornoise_dfdfdf"));
// Unregister
shadingsys->unregister_inline_function(ustring("osl_abs_ff"));
shadingsys->unregister_noinline_function(ustring("osl_gabornoise_dfdfdf"));
```
It might be best to prefer the `ShadingSystem` attributes to control the inlining
behavior, and to strategically register functions when it is known to be
beneficial through benchmarking and profiling.
Tuning and Analysis
-------------------
We have added a Python script (`src/build-scripts/analyze-ptx.py`) to help
identify functions that might be good candidates for inlining/noinling. This
script will generate a summary of the functions in the input PTX file, with a
list of all functions and their sizes in CSV format. It will also generate a
graphical reprensentation of the callgraph in DOT and PDF format.
An example tuning workflow might include the following steps:
1. Run `analyze-ptx.py` on the "shadeops" and "rend_lib" PTX files to generate
a list of the functions contained in those modules.
```bash
$ analyze_ptx.py shadeop_cuda.ptx
$ analyze_ptx.py rend_lib_myrender.ptx
```
2. Run `analyze-ptx.py` on the generated PTX for a representative shader:
```bash
$ analyze_ptx.py myshader.ptx
```
3. View the summary file (`myshader-summary.txt`) and the callgraph
(`myshader-callgraph.gv`) to deterimine which library functions were _not_
inlined. They will appear as boxes with a dashed outline in the callgraph.
In particular, be on the lookout for trivial functions (e.g., `osl_floor_ff`)
which have not been inlined. If such functions appear, that might be a sign
that the inline thresholds need to be adjusted, or that it might be
beneficial to register specific functions.
+5 -5
View File
@@ -1,7 +1,7 @@
#
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: Modified Apache 2.0 License
# Coyright Notice From Pixar USD (Modified Apache 2.0 License)
# Copyright Notice From Pixar USD (Modified Apache 2.0 License)
# 90% of the content is changed to be compatible for installing OSL and its dependencies
#
# Based on USD build_scripts by Pixar Animation Studio
@@ -1331,8 +1331,8 @@ OPENVDB = Dependency("OpenVDB", InstallOpenVDB, "include/openvdb/openvdb.h")
############################################################
# OpenImageIO
# OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/Release-2.2.7.0.zip"
OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/Release-2.1.20.0.zip"
# OIIO_URL = "https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/Release-2.2.7.0.zip"
OIIO_URL = "https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/Release-2.1.20.0.zip"
def InstallOpenImageIO(context, force, buildArgs):
@@ -1381,9 +1381,9 @@ OPENIMAGEIO = Dependency(
# Use v1.1.0 on MacOS and Windows since v1.0.9 doesn't build properly on
# those platforms.
if Linux():
OCIO_URL = "https://github.com/imageworks/OpenColorIO/archive/v1.0.9.zip"
OCIO_URL = "https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/v1.0.9.zip"
else:
OCIO_URL = "https://github.com/imageworks/OpenColorIO/archive/v1.1.0.zip"
OCIO_URL = "https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/v1.1.0.zip"
def InstallOpenColorIO(context, force, buildArgs):
+43 -337
View File
@@ -7,98 +7,33 @@ ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits)
endif
# For SpComp2 builds, do:
#
# make OSL_SPCOMP2=1 spcomp2_install
# or
# make OSL_SPCOMP2=1 SPCOMP2_LOCAL_PATH=/test/path spcomp2_install_local
#
# For Arnold builds, do:
#
# make OSL_ARNOLD=1
#
# For a Rez-bound build, do:
#
# make OSL_SPIREZ=1
#
# (Options: OSL_REZ_NAME=blah REZ_PACKAGE_ROOT=path)
#
# Otherwise a default 'make' will make a fully generic OSL build.
OSL_SPCOMP2 ?= 0
OSL_ARNOLD ?= 0
OSL_SPIREZ ?= 0
OSL_REZ_NAME ?= OSL
OSL_VERS = $(shell grep "OSL VERSION" CMakeLists.txt | egrep -o "[0-9.]+")
ONEVERS = $(shell site/spi/format_version.py ${OSL_VERS})
OSL_SPCOMP2_VERSION ?= ${ONEVERS}
ifeq (${OSL_SPCOMP2},1)
$(info Building for SpComp2)
OSL_ARNOLD := 0
NAMESPACE ?= 'OSL_SpComp2'
SOVERSION ?= ${OSL_SPCOMP2_VERSION}
PYLIB_LIB_PREFIX ?= 1
PYLIB_INCLUDE_SONAME ?= 1
OPENIMAGEIO_SPCOMP2_VERSION ?= 20103
OPENEXR_VERSION ?= 2.2.0
else ifeq (${OSL_ARNOLD},1)
$(info Building for Arnold)
NAMESPACE ?= 'OSL_Arnold'
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
OPENEXR_VERSION ?= 2.4.0
else ifeq (${OSL_SPIREZ},1)
$(info Building for Rez distribution)
NAMESPACE ?= 'OSL'
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
MY_CMAKE_FLAGS += -DOSL_SPIREZ=1 -DOSL_REZ_PACKAGE_NAME=${OSL_REZ_NAME}
MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
OPENIMAGEIO_VERSION ?= 2.2.0.0
OPENEXR_VERSION ?= 2.4.0
$(info Building against OpenImageIO ${OPENIMAGEIO_VERSION})
else
$(info Building generic OSL)
NAMESPACE ?= 'OSL'
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
endif
$(info Building generic OSL)
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
#$(info MAKECMDGOALS = $(MAKECMDGOALS))
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
## Detect which SPI platform and set $platform, $COMPILER,
## and PYTHON_VERSION. Lots of other decisions are based on these.
ifeq (${SP_OS}, rhel7)
# Rhel7 (current)
platform := rhel7
SPI_COMPILER_PLATFORM ?= gcc-6.3
ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
SPCOMP2_COMPILER ?= gcc48m64
CMAKE_CXX_STANDARD ?= 11
else
SPCOMP2_COMPILER ?= gcc63
ifeq (${SPI_COMPILER_PLATFORM},gcc-6.3)
CMAKE_CXX_STANDARD ?= 14
endif
SP_PLATFORM ?= linux
SP_PROC ?= x86_64
SP_REZ_OS ?= CentOS-7
LLVM_VERSION ?= 12.0.0
else ifeq (${platform}, macosx)
# Generic OSX machines (including LG's laptop)
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
SP_OS ?= macosx
SP_PLATFORM ?= macosx
SP_PROC ?= x86_64
SP_REZ_OS ?= MacOS
else
$(error Unknown SP_OS=${SP_OS} platform=${platform})
endif # endif ${SP_OS}
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS} -DSP_PLATFORM=${SP_PLATFORM}
MY_CMAKE_FLAGS += -DSP_PROC=${SP_PROC} -DSP_REZ_OS=${SP_REZ_OS}
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS}
MY_CMAKE_FLAGS += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOSL_SPI=1" -DOSL_SITE:STRING=spi
MY_CMAKE_FLAGS += -DOSL_SITE:STRING=spi
MY_CMAKE_FLAGS += -DSPI_TESTS=1
MY_CMAKE_FLAGS += -DOSL_NAMESPACE_INCLUDE_PATCH=1
REZ_PACKAGE_ROOT ?= /shots/spi/home/software/packages
@@ -119,33 +54,15 @@ ifeq (${SP_OS}, rhel7)
export CCACHE_CPP2 ?= 1
# Override lib64 and use SPI convention of lib
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_LIBDIR="${INSTALL_PREFIX}/lib"
ifeq (${OSL_SPCOMP2},1)
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
else ifeq (${OSL_SPIREZ},1)
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
else ifeq (${OSL_ARNOLD},1)
OSL_LIBNAME_SUFFIX ?= _Arnold
endif
#
# Compilers:
#
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_8.0.0
ifeq (${COMPILER},clang6)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_6.0.1
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang7)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_7.0.1
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang8)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_8.0.0
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang9)
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_12.0.0
LLVM_DIRECTORY ?= /shots/spi/home/software/packages/llvm/${LLVM_VERSION}/${SPI_COMPILER_PLATFORM}
ifeq (${COMPILER},clang9)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/9.0.1-1/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
@@ -157,6 +74,10 @@ ifeq (${SP_OS}, rhel7)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/11.0.0/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang12)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/12.0.0-final/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER}, gcc6)
@@ -171,11 +92,6 @@ ifeq (${SP_OS}, rhel7)
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
MY_CMAKE_FLAGS += -DCMAKE_C_FLAGS="--gcc-toolchain=/usr" \
-DCMAKE_CXX_FLAGS="--gcc-toolchain=/usr" \
-DTOOLCHAIN_FLAGS="--gcc-toolchain=/usr"
endif
MY_CMAKE_FLAGS +=
-DLLVM_STATIC=1 \
@@ -186,33 +102,9 @@ ifeq (${SP_OS}, rhel7)
# Boost
#
BOOSTVERS ?= 1.70
BOOSTSPSUFFIX ?=
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
MY_CMAKE_FLAGS += -DBOOST_VERS_SP=${BOOSTVERSSP}
# $(info BOOSTVERSSP ${BOOSTVERSSP})
ifeq (${BOOSTVERS},1.55)
SPBOOST_INC_DIR ?= /usr/include/boost_${BOOSTVERSSP}
SPBOOST_LIB_DIR ?= /usr/lib64/boost_${BOOSTVERSSP}
ifeq (${BOOSTSPSUFFIX}, sp)
SPBOOST_LIBNAMESTART ?= lib${BOOSTSPSUFFIX}boost_${shell echo ${BOOSTVERS} | sed "s/\\./_/"}_0
else
SPBOOST_LIBNAMESTART ?= lib${BOOSTSPSUFFIX}boost
endif
SPBOOST_LIBNAMEEND ?= -gcc48-mt-${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${BOOSTVERS} \
-DBoost_INCLUDE_DIRS=${SPBOOST_INC_DIR} \
-DBoost_LIBRARY_DIRS=${SPBOOST_LIB_DIR} \
-DBoost_LIBRARIES:STRING="${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_filesystem${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_regex${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_system${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_thread${SPBOOST_LIBNAMEEND}.so"
else
# Our Boost >= 1.61 setup is MUCH simpler and more standard
SPBOOST_INC_DIR := /usr/include/boostroot/boost${BOOSTVERSSP}.0
SPBOOST_LIB_DIR := /usr/lib64/boostroot/boost${BOOSTVERSSP}.0
MY_CMAKE_FLAGS += \
-DBOOST_INCLUDEDIR=${SPBOOST_INC_DIR} \
-DBOOST_LIBRARYDIR=${SPBOOST_LIB_DIR}
endif
MY_CMAKE_FLAGS += \
-DBOOST_INCLUDEDIR=/usr/include/boostroot/boost${BOOSTVERS}.0 \
-DBOOST_LIBRARYDIR=/usr/lib64/boostroot/boost${BOOSTVERS}.0
#
# Python
@@ -220,11 +112,7 @@ ifeq (${SP_OS}, rhel7)
Python_INCLUDE_DIR ?= /usr/include/python${PYTHON_VERSION}
PYTHON_LIBRARY_DIR ?= /usr/lib64
Python_LIBRARY ?= ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
ifeq (${PYTHON_VERSION},3.6)
# Special sauce for Python 3.6
Python_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
Python_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
else ifeq (${PYTHON_VERSION},3.7)
ifeq (${PYTHON_VERSION},3.7)
# Special sauce for Python 3.7
Python_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
Python_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
@@ -241,53 +129,32 @@ ifeq (${SP_OS}, rhel7)
# Set our preferred OpenEXR path, but allow env variable to override
# with custom/test version.
ifneq (${OPENEXR_VERSION},)
# If OPENEXR_VERSION is set, grab from the rez area
OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
else ifeq (${OpenEXR_ROOT},)
# If not getting from rez, get from the system install
MY_CMAKE_FLAGS += \
-DOPENEXR_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_LIBRARY_DIR=/usr/lib64/OpenEXR2
endif
OPENEXR_VERSION ?= 2.4.1-2
OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}
$(info OpenEXR_ROOT = $(OpenEXR_ROOT))
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
Partio_VERSION ?= 1.10.6
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
MY_CMAKE_FLAGS += -Dpartio_ROOT="${partio_ROOT}"
pugixml_VERSION ?= 1.10.0
pugixml_ROOT ?= ${REZ_PACKAGE_ROOT}/pugixml/${pugixml_VERSION}/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -Dpugixml_ROOT="${pugixml_ROOT}"
# set up OSL distribution environment
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
ifeq (${OSL_SPIREZ},1)
OpenImageIO_ROOT := ${REZ_PACKAGE_ROOT}/OpenImageIO/${OPENIMAGEIO_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
$(info OpenImageIO_ROOT ${OpenImageIO_ROOT})
else ifeq (${OSL_SPCOMP2},1)
OpenImageIO_ROOT := $(SPCOMP2_ROOT)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)
else ifeq (${OSL_ARNOLD},1)
OpenImageIO_ROOT ?= ${working_dir}/../OpenImageIO_local/dist/${platform}${variant}/
else ifneq (${OpenImageIO_ROOT},)
# User supplied something
endif
ifneq ($(OpenImageIO_ROOT),)
MY_CMAKE_FLAGS += -DOpenImageIO_ROOT=${OpenImageIO_ROOT}
endif
# Cuda/OptiX
USE_OPTIX ?= 1
OSL_USE_OPTIX ?= 1
CUDA_VERSION ?= 11.1.1
OPTIX_VERSION ?= 7.2.0
# CUDA_TOOLKIT_ROOT_DIR = $(shell rez-env -b cuda-${CUDA_VERSION} ${SPI_COMPILER_PLATFORM} -c "echo '$CUDA_TOOLKIT_ROOT'")
CUDA_TOOLKIT_ROOT_DIR ?= /shots/spi/home/lib/arnold/rhel7/cuda_${CUDA_VERSION}
OptiX_ROOT ?= /shots/spi/home/lib/arnold/rhel7/optix_${OPTIX_VERSION}
OPTIXHOME = ${OptiX_ROOT}
MY_CMAKE_FLAGS += -DUSE_OPTIX=${USE_OPTIX} \
MY_CMAKE_FLAGS += -DOSL_USE_OPTIX=${OSL_USE_OPTIX} \
-DCUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR} \
-DCUDA_EXTRA_LIBS=${CUDA_EXTRA_LIBS} \
-DOPTIXHOME=${OPTIXHOME} -DOPTIX_EXTRA_LIBS=lzma
@@ -299,53 +166,33 @@ else ifeq (${platform}, macosx)
CMAKE_CXX_STANDARD ?= 14
USE_SIMD ?= sse4.2
MY_CMAKE_FLAGS += -DCMAKE_BUILD_WITH_INSTALL_RPATH=1
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/lib"
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
BOOSTVERS=${BOOSTVERS}${BOOSTSPSUFFIX}
LLVM_DIRECTORY ?= /usr/local/opt/llvm
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, gcc48)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc5)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc6)
ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc8)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc9)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER},clang6)
else ifeq (${COMPILER},clang14)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@6/6.0.1_2/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm@6/6.0.1_2/bin/clang++
else ifeq (${COMPILER},clang7)
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
else ifeq (${COMPILER},clang15)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@7/7.0.1_1/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm@7/7.0.1_1/bin/clang++
else ifeq (${COMPILER},clang8)
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++
else ifeq (${COMPILER},clang16)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@8/8.0.1_1/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm/8.0.1/bin/clang++
else ifeq (${COMPILER},clang9)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@9/9.0.1/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm@9/9.0.1/bin/clang++
else ifeq (${COMPILER},clang10)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm/10.0.0/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm/10.0.0/bin/clang++
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@16/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@16/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
@@ -353,163 +200,22 @@ else ifeq (${platform}, macosx)
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
-DCMAKE_C_COMPILER=${LLVM_ROOT}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_ROOT}/bin/clang++
else ifeq (${COMPILER},llvm)
# "llvm" means "use the clang from our llvm"
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
-DCMAKE_C_COMPILER=${LLVM_ROOT}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_ROOT}/bin/clang++
endif
# end generic OSX
else
$(error Unknown SP_OS=${SP_OS} platform=${platform})
$(error Unknown SP_OS=${SP_OS})
endif # endif ${SP_OS}
ifeq (${OSL_SPIREZ},1)
# Rpath touch-ups
# NOTE: This MUST match the order and naming of the Rez variants
# set in rez/package.py.in
REZ_INSTALL_PATH := ${REZ_PACKAGE_ROOT}/${OSL_REZ_NAME}/${OSL_VERS}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}/cuda-${CUDA_VERSION}/optix-${OPTIX_VERSION}
MY_CMAKE_FLAGS += -DOSL_REZ_INSTALL_PATH=${REZ_INSTALL_PATH}
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_RPATH="${REZ_INSTALL_PATH}/lib;@executable_path/../lib;${OpenImageIO_ROOT}/lib"
INSTALL_PREFIX := ${working_dir}/dist/${platform}
endif
ifneq (${VERBOSE},)
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
endif
############################################################################
# SpComp2 magic incantations follow. Here be dragons.
############################################################################
CPPSTDSUFFIX=
SPCOMP2_INSTALL_ROOT ?= $(SPCOMP2_ROOT)
BOOSTVERSSP?=${BOOSTVERS}${BOOSTSPSUFFIX}
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
OIIO_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OpenImageIO/${SPARCH}/v${OPENIMAGEIO_SPCOMP2_VERSION}
# $(info New rhel7 OIIO_SPCOMP2_PATH is ${OIIO_SPCOMP2_PATH})
PYVERNOSPACE=${shell echo ${PYTHON_VERSION} | sed "s/\\.//"}
SPPYARCH=$(SPARCH)-py$(PYVERNOSPACE)
all: dist
local: dist
.PHONY: spcomp2_install spcomp2_install_local clean all
spi: MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
spi: debug dist
spcomp2_install_local: SPCOMP2_INSTALL_ROOT = $(SPCOMP2_LOCAL_PATH)
spcomp2_install_local: spcomp2_install
comma:= ,
empty:=
space:= $(empty) $(empty)
#OSL_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OSL/${SP_OS}-${SPCOMP2_COMPILER}$(CPPSTDSUFFIX)-boost${SPCOMP2_BOOSTVERS_SUFFIX}/v${OSL_SPCOMP2_VERSION}
#$(info New rhel7 OSL_SPCOMP2_PATH is ${OSL_SPCOMP2_PATH})
#INSTALL_SPCOMP2_CURRENT = $(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)
#INSTALL_BIN_LOCATION = $(INSTALL_SPCOMP2_CURRENT)/bin
SPCOMP2_RPATH_OPT ?= ${OpenImageIO_ROOT}/lib:${partio_ROOT}/lib
SPCOMP2_RPATH_DEBUG ?= ${OpenImageIO_ROOT}/lib:${partio_ROOT}/lib/debug
#PYSPCOMP2_RPATH_OPT ?= ${SPCOMP2_RPATH_OPT}:${OSL_SPCOMP2_PATH}/lib:${PYTHON_LIBRARY_DIR}
#PYSPCOMP2_RPATH_DEBUG ?= ${SPCOMP2_RPATH_DEBUG}:${OSL_SPCOMP2_PATH}/lib/debug:${PYTHON_LIBRARY_DIR}
spcomp2: MY_CMAKE_FLAGS += \
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)/lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
-DPYLIB_LIB_PREFIX:BOOL=ON \
-DPYMODULE_SUFFIX="V${OSL_SPCOMP2_VERSION}"
spcomp2: dist
spcomp2_debug: MY_CMAKE_FLAGS += \
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)/lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
-DPYLIB_LIB_PREFIX:BOOL=ON \
-DPYMODULE_SUFFIX="V${OSL_SPCOMP2_VERSION}"
spcomp2_debug: debug
spcomp2_install_fixup_rhel7: spcomp2 spcomp2_debug
echo $(SPCOMP2_INSTALL_ROOT)
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslexec${OSL_LIBNAME_SUFFIX}.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslexec.so
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslcomp${OSL_LIBNAME_SUFFIX}.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslcomp.so
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslquery${OSL_LIBNAME_SUFFIX}.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslquery.so
# patchelf --set-rpath ${PYSPCOMP2_RPATH_OPT} ${dist_dir}/python/libPyOSL.so
# patchelf --set-rpath ${PYSPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/python/libPyOSL.so
# This goal can't start with 'install' because something elsewhere picks
# it up and starts doing bad things
spcomp2_install: spcomp2_install_fixup_${SP_OS}
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
--project=oslexec \
--version=$(OSL_SPCOMP2_VERSION) \
--root=$(SPCOMP2_INSTALL_ROOT) \
--arch=$(SPARCH) \
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
--namespace=${NAMESPACE} \
--srcdir=${dist_dir}/lib \
--builddir_o=${dist_dir}/lib \
--builddir_d=${dist_dir}.debug/lib
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
--project=oslquery \
--version=$(OSL_SPCOMP2_VERSION) \
--root=$(SPCOMP2_INSTALL_ROOT) \
--arch=$(SPARCH) \
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
--namespace=${NAMESPACE} \
--srcdir=${dist_dir}/lib \
--builddir_o=${dist_dir}/lib \
--builddir_d=${dist_dir}.debug/lib
#perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
# --project=oslcomp \
# --version=$(OSL_SPCOMP2_VERSION) \
# --root=$(SPCOMP2_INSTALL_ROOT) \
# --arch=$(SPARCH) \
# --headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
# --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
# --namespace=${NAMESPACE} \
# --srcdir=${dist_dir}/lib \
# --builddir_o=${dist_dir}/lib \
# --builddir_d=${dist_dir}.debug/lib
#perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
# --project=PyOSL \
# --version=$(OSL_SPCOMP2_VERSION) \
# --root=$(SPCOMP2_INSTALL_ROOT) \
# --arch=$(SPPYARCH) \
# --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread"\
# --namespace=${NAMESPACE} \
# --srcdir=${dist_dir}/python \
# --builddir_o=${dist_dir}/python \
# --builddir_d=${dist_dir}.debug/python
-72
View File
@@ -1,72 +0,0 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Build a variant for Rez/general use
-----------------------------------
Skip this section if you are instead building for SpComp2.
Note: For testing or to make your own local rez package, you can customize
either the rez package name, or the rez install location name, with make
flags `OSL_REZ_NAME=blah REZ_PACKAGE_ROOT=/path/to/my/rez/pkgs` appended
to the `make` commands of any of the variants listed below. For example,
make OSL_SPIREZ=1 OSL_REZ_NAME=oiio_test REZ_PACKAGE_ROOT=/path/to/my/rez/pkgs
Variants:
# C++11/gcc4.8 compat, Python 2.7, Boost 1.55, OptiX 6, Cuda 10.1
# OIIO 2.2.0.0, OpenEXR 2.2
make nuke
make spi OSL_SPIREZ=1 BOOSTVERS=1.55 USE_OPTIX=1 CUDA_VERSION=10.1 OPTIX_VERSION=6.0.0 OPENIMAGEIO_VERSION=2.2.0.0 OPENEXR_VERSION=2.2.0 PYTHON_VERSION=2.7
# C++11/gcc6.3 compat, Python 2.7, Boost 1.70, OptiX 6, Cuda 10.1
# OIIO 2.2.0.0, OpenEXR 2.4
make nuke
make spi OSL_SPIREZ=1 SPI_COMPILER_PLATFORM=gcc-6.3 BOOSTVERS=1.70 USE_OPTIX=1 CUDA_VERSION=10.1 OPTIX_VERSION=6.0.0 OPENIMAGEIO_VERSION=2.2.0.0 OPENEXR_VERSION=2.4.0 PYTHON_VERSION=2.7
You can do any of these on your local machine.
Rez/general release (do for each variant)
-----------------------------------------
This must be done from compile42 (for correct write permissions on certain
shared directories), even if you did the build itself locally.
For any of the variants that you built above:
( cd dist/rhel7 ; rez release --skip-repo-errors )
That command will release the dist to the studio.
Appwrapper binary releases
--------------------------
We don't currently do this.
<!---
This step is for the ONE general/rez variant that we believe is the
canonical source of command line oslc and oslinfo. After building and
releasing as above,
cp dist/rhel7/OSL_*.xml /shots/spi/home/lib/app_cfg/OSL
That will make appcfg aware of the release.
To also make this release the new facility default:
db-any spi/home/OSL.bin highest /shots/spi/home/lib/app_cfg/OSL/OSL_A.B.C.D.xml
where A.B.C.D is the version.
--->
SpComp2 build and release
-------------------------
Phasing out support for this.
-11
View File
@@ -3,18 +3,7 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
option (${PROJ_NAME}_SPIREZ "Enable extra bits for building for SPI Rez install" OFF)
set (${PROJ_NAME}_REZ_PACKAGE_NAME CACHE STRING "${PROJECT_NAME}")
if (${PROJ_NAME}_SPIREZ)
message (STATUS "Creating package.py from package.py.in")
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/rez/package.py.in" "${CMAKE_BINARY_DIR}/package.py")
set (appcfg_filename "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}.xml")
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/appcfg.xml.in" "${appcfg_filename}")
install (FILES ${CMAKE_BINARY_DIR}/package.py
"${PROJECT_SOURCE_DIR}/site/spi/rez/CMakeLists.txt"
${appcfg_filename}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT developer)
endif ()
-31
View File
@@ -1,31 +0,0 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
cmake_minimum_required(VERSION 2.8)
project(OSL)
include(RezBuild)
rez_install_dirs(
include lib share
# python
DESTINATION .
)
# Bin specified separately so it can be marked as EXECUTABLE, otherwise it
# installs with only read permissions.
rez_install_dirs(
bin
DESTINATION .
EXECUTABLE
)
rez_install_cmake(
DESTINATION .
INCLUDE_DIRS include
LIBRARY_DIRS lib
LIBRARIES oslexec oslcomp oslquery
oslexec_d oslcomp_d oslquery_d
)
-59
View File
@@ -1,59 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#
# Documentation on packages and available attributes can be found at:
# https://github.com/nerdvegas/rez/wiki/Package-Definition-Guide
name = '@OSL_REZ_PACKAGE_NAME@'
version = '@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@'
description = \
"""
Rez package of Open Shading Language (OSL)
"""
authors = ['Larry Gritz <lg@imageworks.com>']
# Add dependencies to other Rez packages here
requires = [
'platform-@SP_PLATFORM@', 'arch-@SP_PROC@', 'os-@SP_REZ_OS@',
'OpenImageIO-@OPENIMAGEIO_VERSION_MAJOR@.@OPENIMAGEIO_VERSION_MINOR@.@OPENIMAGEIO_VERSION_PATCH@'
]
#build_command = 'python {root}/build.py'
# Rez has a limitation where it is not possible to add variants to a package that
# does not have any: https://github.com/nerdvegas/rez/wiki/Variants#single-variants.
# Unless you are 100% certain that your package will NEVER require any variants,
# you should define your package with at least one variant.
variants = [
[
'@SPI_COMPILER_PLATFORM@',
'python-@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@',
'boost-@BOOST_VERS_SP@',
'cuda-@CUDA_VERSION@',
'optix-@OPTIX_VERSION@'
],
]
def commands():
# Add import statements here, not at the top of the file!
# Uncomment if you have executables under bin/
env.PATH.append("{root}/bin")
env.LD_LIBRARY_PATH.append("{root}/lib")
# Uncomment if you have Python code under python/
env.PYTHONPATH.append("{root}/python")
# For SpImport.Packages, append the python directory
#env.SPIMPORT_PACKAGES.append("{root}/python")
if building:
env.CMAKE_MODULE_PATH.append('{root}')
# Add env vars or custom code you want executed only at build time
+25
View File
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the Open Shading Language Project.
sonar.host.url=https://sonarcloud.io
# Required metadata
sonar.organization=academysoftwarefoundation
sonar.projectName=OpenShadingLanguage
sonar.projectVersion=1.12
sonar.projectKey=AcademySoftwareFoundation_OpenShadingLanguage
# Project links
sonar.links.homepage=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
sonar.links.ci=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/actions
sonar.links.scm=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
sonar.links.issue=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues
# Source properties
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.exclusions=src/include/OSL/Imath/*.h,src/build-scripts/*
# C/C++ analyzer properties
sonar.cfamily.build-wrapper-output=build/bw_output
sonar.cfamily.gcov.reportsPath=_coverage
-273
View File
@@ -1,273 +0,0 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT (openexr)
SET(OPENEXR_VERSION_MAJOR "2")
SET(OPENEXR_VERSION_MINOR "2")
SET(OPENEXR_VERSION_PATCH "0")
SET(OPENEXR_VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH})
SET(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
# enable the tests
ENABLE_TESTING()
# distro building
SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENEXR_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${OPENEXR_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${OPENEXR_VERSION_PATCH}")
SET(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${OPENEXR_VERSION}"
)
set(CPACK_SOURCE_IGNORE_FILES
"/.git*;/.cvs*;${CPACK_SOURCE_IGNORE_FILES}")
INCLUDE ( CPack )
# Allow the developer to select if Dynamic or Static libraries are built
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON)
OPTION (USE_ZLIB_WINAPI "Use ZLib Win API" OFF)
OPTION (NAMESPACE_VERSIONING "Use Namespace Versioning" ON)
OPTION (BUILD_UTILS "Build the binary/utility programs" ON)
OPTION (BUILD_TESTS "Build the tests" ON)
# Setup osx rpathing
SET (CMAKE_MACOSX_RPATH 1)
SET (BUILD_WITH_INSTALL_RPATH 1)
ADD_DEFINITIONS ( -DHAVE_CONFIG_H -DILM_IMF_TEST_IMAGEDIR="${CMAKE_SOURCE_DIR}/IlmImfTest/" )
INCLUDE_DIRECTORIES (
${CMAKE_CURRENT_BINARY_DIR}/config
IlmImf
IlmImfUtil
exrmaketiled
exrenvmap
exrmakepreview
exrmultiview
IlmImfFuzzTest
)
FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
IF (NOT WIN32)
SET ( PTHREAD_LIB pthread )
ENDIF()
INCLUDE_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/include/OpenEXR )
LINK_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/lib )
MESSAGE ( "ILMBASE_PACKAGE_PREFIX = " ${ILMBASE_PACKAGE_PREFIX})
SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
SET (LIB_TYPE SHARED)
IF (WIN32)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF ()
ENDIF ()
IF (USE_ZLIB_WINAPI)
ADD_DEFINITIONS(-DZLIB_WINAPI)
ENDIF ()
# Test for GCC-style inline asm support with AVX instructions
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES (
"
int main()
{
#if defined(__GNUC__) && defined(__SSE2__)
int n = 0;
int eax = 0;
int edx = 0;
__asm__(
\"xgetbv ;\"
\"vzeroupper \"
: \"=a\"(eax), \"=d\"(edx) : \"c\"(n) : );
#else
#error No GCC style inline asm supported for AVX instructions
#endif
}
" HAVE_GCC_INLINE_ASM_AVX)
# Check if sysconf(_SC_NPROCESSORS_ONLN) can be used for CPU count
CHECK_CXX_SOURCE_COMPILES (
"
#include <unistd.h>
int main()
{
sysconf(_SC_NPROCESSORS_ONLN);
}
" HAVE_SYSCONF_NPROCESSORS_ONLN)
##########################
# OpenEXRConfig.h generation
##########################
IF (WIN32)
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
ELSEIF (APPLE)
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_DARWIN 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#include <string.h>\n" )
ELSE ()
# Linux
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LINUX_PROCFS 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LARGE_STACK 1\n" )
ENDIF()
IF (NAMESPACE_VERSIONING)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1\n")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf_${OPENEXR_VERSION_API}\n\n" )
ELSE ()
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 0\n")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf\n\n" )
ENDIF ()
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_VERSION_STRING \"${OPENEXR_VERSION}\"\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_PACKAGE_STRING \"OpenEXR ${OPENEXR_VERSION}\"\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
#define OPENEXR_VERSION_MAJOR ${OPENEXR_VERSION_MAJOR}
#define OPENEXR_VERSION_MINOR ${OPENEXR_VERSION_MINOR}
#define OPENEXR_VERSION_PATCH ${OPENEXR_VERSION_PATCH}
")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
// Version as a single hex number, e.g. 0x01000300 == 1.0.3
#define OPENEXR_VERSION_HEX ((OPENEXR_VERSION_MAJOR << 24) | \\
(OPENEXR_VERSION_MINOR << 16) | \\
(OPENEXR_VERSION_PATCH << 8))\n
")
IF (HAVE_GCC_INLINE_ASM_AVX)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX 1\n" )
ENDIF()
IF (HAVE_SYSCONF_NPROCESSORS_ONLN)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN 1\n" )
ENDIF()
SET (OPENEXR_LIBSUFFIX "")
SET (ILMBASE_LIBSUFFIX "")
IF (NAMESPACE_VERSIONING)
SET ( OPENEXR_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
# assume same NAMESPACE_VERSION setting for IlmBase for now
SET ( ILMBASE_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
ENDIF ()
##########################
# IlmImf library
##########################
ADD_SUBDIRECTORY ( IlmImf )
SET_TARGET_PROPERTIES ( IlmImf
PROPERTIES
VERSION 22.0.0
SOVERSION 22
OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}"
)
##########################
# IlmImfUtil library
##########################
ADD_SUBDIRECTORY ( IlmImfUtil )
SET_TARGET_PROPERTIES ( IlmImfUtil
PROPERTIES
VERSION 22.0.0
SOVERSION 22
OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}"
)
##########################
# Example Code
##########################
ADD_SUBDIRECTORY ( IlmImfExamples )
##########################
# Tests
##########################
if (BUILD_TESTS)
ADD_SUBDIRECTORY ( IlmImfTest )
ADD_SUBDIRECTORY ( IlmImfUtilTest )
ADD_SUBDIRECTORY ( IlmImfFuzzTest )
endif ()
##########################
# Binaries / Utilities
##########################
if (BUILD_UTILS)
ADD_SUBDIRECTORY ( exrheader )
ADD_SUBDIRECTORY ( exrmaketiled )
ADD_SUBDIRECTORY ( exrstdattr )
ADD_SUBDIRECTORY ( exrmakepreview )
ADD_SUBDIRECTORY ( exrenvmap )
ADD_SUBDIRECTORY ( exrmultiview )
ADD_SUBDIRECTORY ( exrmultipart )
endif ()
##########################
# Installation
##########################
INSTALL ( FILES
${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
)
# Documentation
INSTALL ( FILES
doc/TechnicalIntroduction.pdf
doc/ReadingAndWritingImageFiles.pdf
doc/OpenEXRFileLayout.pdf
doc/MultiViewOpenEXR.pdf
doc/InterpretingDeepPixels.pdf
doc/TheoryDeepPixels.pdf
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}
)
# Examples
INSTALL ( FILES
IlmImfExamples/main.cpp
IlmImfExamples/drawImage.cpp
IlmImfExamples/rgbaInterfaceExamples.cpp
IlmImfExamples/rgbaInterfaceTiledExamples.cpp
IlmImfExamples/generalInterfaceExamples.cpp
IlmImfExamples/lowLevelIoExamples.cpp
IlmImfExamples/previewImageExamples.cpp
IlmImfExamples/generalInterfaceTiledExamples.cpp
IlmImfExamples/generalInterfaceTiledExamples.h
IlmImfExamples/drawImage.h
IlmImfExamples/rgbaInterfaceExamples.h
IlmImfExamples/generalInterfaceExamples.h
IlmImfExamples/rgbaInterfaceTiledExamples.h
IlmImfExamples/lowLevelIoExamples.h
IlmImfExamples/previewImageExamples.h
IlmImfExamples/namespaceAlias.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}/examples
)
# LG additions
if (DEFINED ENV{APPVEYOR})
add_definitions ("/W0")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /W0")
endif ()
@@ -1,273 +0,0 @@
# yue.nicholas@gmail.com
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h")
ADD_EXECUTABLE ( b44ExpLogTable
b44ExpLogTable.cpp
)
TARGET_LINK_LIBRARIES ( b44ExpLogTable
Half
Iex${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB}
)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/b44ExpLogTable > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
DEPENDS b44ExpLogTable
)
else ()
message (STATUS "Skipping build of b44ExpLogTable.h")
endif ()
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h")
ADD_EXECUTABLE ( dwaLookups
dwaLookups.cpp
)
TARGET_LINK_LIBRARIES ( dwaLookups
Half
Iex${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB}
)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/dwaLookups > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
DEPENDS dwaLookups
)
else ()
message (STATUS "Skipping build of dwaLookups.h")
endif ()
SET ( ILMIMF_SRCS
ImfAttribute.cpp
ImfBoxAttribute.cpp
ImfCRgbaFile.cpp
ImfChannelList.cpp
ImfChannelListAttribute.cpp
ImfFloatAttribute.cpp
ImfFrameBuffer.cpp
ImfHeader.cpp
ImfIO.cpp
ImfInputFile.cpp
ImfIntAttribute.cpp
ImfLineOrderAttribute.cpp
ImfMatrixAttribute.cpp
ImfOpaqueAttribute.cpp
ImfOutputFile.cpp
ImfRgbaFile.cpp
ImfStringAttribute.cpp
ImfVecAttribute.cpp
ImfHuf.cpp
ImfThreading.cpp
ImfWav.cpp
ImfLut.cpp
ImfCompressor.cpp
ImfRleCompressor.cpp
ImfZipCompressor.cpp
ImfPizCompressor.cpp
ImfB44Compressor.cpp
ImfDwaCompressor.cpp
ImfMisc.cpp
ImfCompressionAttribute.cpp
ImfDoubleAttribute.cpp
ImfConvert.cpp
ImfPreviewImage.cpp
ImfPreviewImageAttribute.cpp
ImfVersion.cpp
ImfChromaticities.cpp
ImfChromaticitiesAttribute.cpp
ImfKeyCode.cpp
ImfKeyCodeAttribute.cpp
ImfTimeCode.cpp
ImfTimeCodeAttribute.cpp
ImfRational.cpp
ImfRationalAttribute.cpp
ImfFramesPerSecond.cpp
ImfStandardAttributes.cpp
ImfStdIO.cpp
ImfEnvmap.cpp
ImfEnvmapAttribute.cpp
ImfScanLineInputFile.cpp
ImfTiledInputFile.cpp
ImfTiledMisc.cpp
ImfTiledOutputFile.cpp
ImfTiledRgbaFile.cpp
ImfTileDescriptionAttribute.cpp
ImfTileOffsets.cpp
ImfRgbaYca.cpp
ImfPxr24Compressor.cpp
ImfTestFile.cpp
ImfStringVectorAttribute.cpp
ImfMultiView.cpp
ImfAcesFile.cpp
ImfMultiPartOutputFile.cpp
ImfGenericOutputFile.cpp
ImfOutputPartData.cpp
ImfMultiPartInputFile.cpp
ImfGenericInputFile.cpp
ImfPartType.cpp
ImfInputPartData.cpp
ImfOutputPart.cpp
ImfTiledOutputPart.cpp
ImfInputPart.cpp
ImfTiledInputPart.cpp
ImfDeepScanLineInputPart.cpp
ImfDeepScanLineOutputPart.cpp
ImfDeepScanLineInputFile.cpp
ImfDeepScanLineOutputFile.cpp
ImfDeepTiledInputPart.cpp
ImfDeepTiledOutputPart.cpp
ImfDeepTiledInputFile.cpp
ImfDeepTiledOutputFile.cpp
ImfDeepFrameBuffer.cpp
ImfDeepCompositing.cpp
ImfCompositeDeepScanLine.cpp
ImfDeepImageStateAttribute.cpp
ImfFastHuf.cpp
ImfFloatVectorAttribute.cpp
ImfRle.cpp
ImfSystemSpecific.cpp
ImfZip.cpp
)
IF (BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DILMIMF_EXPORTS)
ENDIF()
ADD_LIBRARY ( IlmImf ${LIB_TYPE}
${ILMIMF_SRCS}
)
TARGET_LINK_LIBRARIES ( IlmImf
Half
Iex${ILMBASE_LIBSUFFIX}
Imath${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB} ${ZLIB_LIBRARIES}
)
ADD_DEPENDENCIES ( IlmImf b44ExpLogTable )
SET_SOURCE_FILES_PROPERTIES (
ImfB44Compressor.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
)
ADD_DEPENDENCIES ( IlmImf dwaLookups )
SET_SOURCE_FILES_PROPERTIES (
ImfDwaCompressor.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
)
# Libraries
INSTALL ( TARGETS
IlmImf
DESTINATION
${CMAKE_INSTALL_PREFIX}/lib
)
# Headers
INSTALL ( FILES
ImfForward.h
ImfExport.h
ImfAttribute.h
ImfBoxAttribute.h
ImfCRgbaFile.h
ImfChannelList.h
ImfChannelListAttribute.h
ImfCompressionAttribute.h
ImfDoubleAttribute.h
ImfFloatAttribute.h
ImfFrameBuffer.h
ImfHeader.h
ImfIO.h
ImfInputFile.h
ImfIntAttribute.h
ImfLineOrderAttribute.h
ImfMatrixAttribute.h
ImfOpaqueAttribute.h
ImfOutputFile.h
ImfRgbaFile.h
ImfStringAttribute.h
ImfVecAttribute.h
ImfHuf.h
ImfWav.h
ImfLut.h
ImfArray.h
ImfCompression.h
ImfLineOrder.h
ImfName.h
ImfPixelType.h
ImfVersion.h
ImfXdr.h
ImfConvert.h
ImfPreviewImage.h
ImfPreviewImageAttribute.h
ImfChromaticities.h
ImfChromaticitiesAttribute.h
ImfKeyCode.h
ImfKeyCodeAttribute.h
ImfTimeCode.h
ImfTimeCodeAttribute.h
ImfRational.h
ImfRationalAttribute.h
ImfFramesPerSecond.h
ImfStandardAttributes.h
ImfEnvmap.h
ImfEnvmapAttribute.h
ImfInt64.h
ImfRgba.h
ImfTileDescription.h
ImfTileDescriptionAttribute.h
ImfTiledInputFile.h
ImfTiledOutputFile.h
ImfTiledRgbaFile.h
ImfRgbaYca.h
ImfTestFile.h
ImfThreading.h
ImfB44Compressor.h
ImfStringVectorAttribute.h
ImfMultiView.h
ImfAcesFile.h
ImfMultiPartOutputFile.h
ImfGenericOutputFile.h
ImfMultiPartInputFile.h
ImfGenericInputFile.h
ImfPartType.h
ImfPartHelper.h
ImfOutputPart.h
ImfTiledOutputPart.h
ImfInputPart.h
ImfTiledInputPart.h
ImfDeepScanLineOutputFile.h
ImfDeepScanLineOutputPart.h
ImfDeepScanLineInputFile.h
ImfDeepScanLineInputPart.h
ImfDeepTiledInputFile.h
ImfDeepTiledInputPart.h
ImfDeepTiledOutputFile.h
ImfDeepTiledOutputPart.h
ImfDeepFrameBuffer.h
ImfDeepCompositing.h
ImfCompositeDeepScanLine.h
ImfNamespace.h
ImfMisc.h
ImfDeepImageState.h
ImfDeepImageStateAttribute.h
ImfFloatVectorAttribute.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
)
+413
View File
@@ -0,0 +1,413 @@
#!/usr/bin/env python3
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
import getopt
import graphviz
import itertools
import os
import re
import sys
from collections import OrderedDict
from dataclasses import dataclass, field
from typing import Dict
#-------------------------------------------------------------------------------
# PTX parsing helpers
#-------------------------------------------------------------------------------
# pre-compile some regex patterns to speed up parsing
call_ptn = re.compile(r"^\s*(call\.uni).*$")
dec_ptn = re.compile(r"^\s*(\.pragma|\.extern|\.visible|\.func|\.local|\.global|\.reg|\.param|LBB[0-9_]+\:)(.*)$")
fn_ptn = re.compile(r"^(\.visible \.func|\.visible \.entry|\.weak \.func|\.func).*[\s]+([a-zA-Z0-9_]+)[\(\)]*$")
inst_ptn = re.compile(r"^\s*([@!%p0-9 ]*)([a-zA-Z0-9\.]+)\s*([a-zA-Z0-9\$\.,% _\[\]{}+-]+);.*$")
mem_ptn = re.compile(r"^\s*(st|ld).*;$")
ret_ptn = re.compile(r"^\s*(ret);.*$")
def get_func_name(line):
match = fn_ptn.match(line)
if match:
return match.group(2)
else:
return ""
def is_func_or_decl(line):
match = fn_ptn.match(line)
if match:
return True
else:
return False
def is_call_start(line):
if line.find("call.uni") != -1:
return True
else:
return False
def is_instruction(line):
match = call_ptn.match(line)
if match:
return True
if len(line) < 4:
return False
if not line.endswith(';'):
return False
match = dec_ptn.match(line)
if not match:
return True
else:
return False
def is_mem_inst(line):
match = mem_ptn.match(line)
if match:
return True
else:
return False
def parse_inst(line):
if not is_instruction(line):
return "", "", ""
match = call_ptn.match(line)
if match:
return "", "call.uni", ""
match = ret_ptn.match(line)
if match:
return "", "ret", ""
match = inst_ptn.match(line)
if match:
return match.group(1), match.group(2), match.group(3)
else:
return "", "", ""
#-------------------------------------------------------------------------------
@dataclass
class FuncStats:
func_name: str = ""
inst_count: int = 0
call_count: int = 0
mem_count: int = 0
call_dict: Dict[str, int] = field(default_factory=dict) # func name, count
inst_dict: Dict[str, int] = field(default_factory=dict) # inst, count
@dataclass
class FileStats:
total_funcs: int = 0
total_insts: int = 0
total_mem_insts: int = 0
total_calls: int = 0
extern_funcs: Dict[str, int] = field(default_factory=dict) # func name, count
func_calls: Dict[str, int] = field(default_factory=dict) # func name, count
summary_dict: Dict[str, str] = field(default_factory=dict) # func name, summary
inst_dict: Dict[str, int] = field(default_factory=dict) # inst, count
largest_function: str = ""
largest_size: int = 0
csv_string: str = ""
#-------------------------------------------------------------------------------
def parse_ptx(ptx_filename):
# read the raw PTX into a string
raw_ptx = ""
with open(ptx_filename, 'r') as ptx_file:
raw_ptx = ptx_file.read()
# variables to keep track of the parsing state
begin_func_or_decl = False
begin_call = False
in_func = False
brace_count = 0
func_stats = FuncStats()
func_dict = {}
for line in raw_ptx.splitlines():
# strip off comments
if line.find("//") != -1:
line = line[:line.find("//")]
# trim whitespace and trailing commas
line = line.strip(" \t\n\r,")
# keep track of when we hit a function declaration or definition
if is_func_or_decl(line):
begin_func_or_decl = True
func_stats.func_name = get_func_name(line)
# keep track of braces so we can have some picture of nesting
brace_count = brace_count + line.count('{')
brace_count = brace_count - line.count('}')
# if we hit a call.uni, we need to look for the name of the callee
# on the next pass
if is_call_start(line):
begin_call = True
func_stats.call_count = func_stats.call_count + 1
elif begin_call:
begin_call = False
func_stats.call_dict[line] = func_stats.call_dict.get(line, 0) + 1
pred, opcode, args = parse_inst(line)
if in_func and opcode != "":
func_stats.inst_count = func_stats.inst_count + 1
func_stats.mem_count = func_stats.mem_count + is_mem_inst(line)
inst = opcode
func_stats.inst_dict[inst] = func_stats.inst_dict.get((inst), 0) + 1
if begin_func_or_decl and brace_count == 1:
in_func = True
begin_func_or_decl = False
# exiting the function -- save off the stats
if in_func and brace_count == 0:
func_dict[func_stats.func_name] = func_stats
# prepare for the next iteration
func_stats = FuncStats()
begin_func_or_decl = False
begin_call = False
in_func = False
brace_count = 0
return func_dict
#-------------------------------------------------------------------------------
def gather_file_stats(func_dict):
file_stats = FileStats()
file_stats.total_funcs = len(func_dict)
file_stats.csv_string = "Function Name, Total Instructions, Memory Instructions, Function Calls\n"
# print the function statistics
for key, entry in sorted(func_dict.items()):
func_name = entry.func_name
file_stats.total_insts += entry.inst_count
file_stats.total_mem_insts += entry.mem_count
file_stats.total_calls += entry.call_count
# keep track of the largest function
if entry.inst_count > file_stats.largest_size:
file_stats.largest_function = func_name
file_stats.largest_size = entry.inst_count
# clamp the counts to prevent divide-by-zero
inst_count = max(1, entry.inst_count)
mem_count = max(1, entry.mem_count)
call_count = max(1, entry.call_count)
summary_string = ""
summary_string += " Function: {}\n".format(func_name)
summary_string += " Total Instructions: {}\n".format(inst_count)
summary_string += " Memory Instructions: {} ({:.2f}%)\n".format(mem_count, 100 * float(mem_count)/inst_count)
summary_string += " Total Calls: {}\n".format(entry.call_count)
summary_string += "\n"
summary_string += "Top 10 Function Calls (name, count, %):\n"
for name, count in itertools.islice(sorted(entry.call_dict.items(), key=lambda item: -item[1]), 0, 11):
summary_string += " {}, {}, {:.2f}%\n".format(name, count, 100 * float(count)/max(1,file_stats.total_calls))
# print the instruction mix
summary_string += "\n"
summary_string += "Instruction Mix (name, count, %):\n"
for inst, count in sorted(entry.inst_dict.items()):
summary_string += " {}, {}, {:.2f}%\n".format(inst, count, 100 * float(count)/inst_count)
file_stats.inst_dict[inst] = file_stats.inst_dict.get((inst), 0) + count
# print the call mix
summary_string += "\n"
summary_string += "Function Calls (name, count, %):\n"
for name, count in sorted(entry.call_dict.items()):
file_stats.func_calls[name] = file_stats.func_calls.get((name), 0) + count
summary_string += " {}, {}, {:.2f}%\n".format(name, count, 100 * float(count)/call_count)
if not name in func_dict:
file_stats.extern_funcs[name] = 1
file_stats.summary_dict[func_name] = summary_string
file_stats.csv_string += "{},{},{},{}\n".format(func_name, entry.inst_count, entry.mem_count, entry.call_count)
return file_stats
#-------------------------------------------------------------------------------
def generate_summary(func_dict, file_stats, out_name):
summary_string = "Overall Stats\n"
summary_string += " Total Functions: {}\n".format(file_stats.total_funcs)
summary_string += " Total Instructions: {}\n".format(file_stats.total_insts)
summary_string += " Memory Instructions: {} ({:.2f}%)\n".format(file_stats.total_mem_insts, 100 * float(file_stats.total_mem_insts)/max(1, file_stats.total_insts))
summary_string += " Total Calls: {}\n".format(file_stats.total_calls)
summary_string += " Biggest Function: {} ({} instructions)\n".format(file_stats.largest_function, file_stats.largest_size)
summary_string += "\n"
summary_string += "Top 10 Function Calls (name, count, %):\n"
for name, count in itertools.islice(sorted(file_stats.func_calls.items(), key=lambda item: -item[1]), 0, 11):
summary_string += " {}, {}, {:.2f}%\n".format(name, count, 100 * float(count)/max(1,file_stats.total_calls))
summary_string += "\n"
summary_string += "Function Call Counts (name, count, %):\n"
for name, count in sorted(file_stats.func_calls.items()):
summary_string += " {}, {}, {:.2f}%\n".format(name, count, 100 * float(count)/max(1,file_stats.total_calls))
summary_string += "\n"
summary_string += "Instruction Mix (name, count, %):\n"
for name, count in sorted(file_stats.inst_dict.items()):
summary_string += " {}, {}, {:.2f}%\n".format(name, count, 100 * float(count)/max(1,file_stats.total_insts))
summary_string += "\n"
summary_string += "Uncalled Functions:\n"
for name, count in sorted(func_dict.items()):
if not name in file_stats.func_calls:
summary_string += " {}\n".format(name)
summary_string += "\n"
summary_string += "Extern Functions:\n"
for name, val in sorted(file_stats.extern_funcs.items()):
summary_string += " {}\n".format(name)
with open("{}-summary.txt".format(out_name), "w") as summary_file:
summary_file.write(summary_string)
for func_name, summary in sorted(file_stats.summary_dict.items()):
summary_file.write("\n#---------------------------------------\n")
summary_file.write(summary)
with open("{}.csv".format(out_name), "w") as csv_file:
csv_file.write(file_stats.csv_string)
return summary_string
#-------------------------------------------------------------------------------
def wrap_name(name):
wrapped_name = ""
cur_line = ""
last_char = ''
wrap_len = 20
split_pos = 0
line_pos = 0
for cur_char in name:
cur_line = cur_line + cur_char
line_pos = line_pos + 1
if not cur_char.isalpha():
# prefer to split at non-alphabetic characters
split_pos = line_pos
elif last_char.isupper() and not cur_char.isupper():
# otherwise, prefer to split at the first capitalized letter
# of some group
split_pos = line_pos - 2
if line_pos == wrap_len:
wrapped_name = wrapped_name + cur_line[:split_pos] + '\n'
cur_line = cur_line[split_pos:]
line_pos = len(cur_line)
last_char = cur_char
wrapped_name = wrapped_name + cur_line + '\n'
return wrapped_name.strip(" \t\n\r,")
#-------------------------------------------------------------------------------
def generate_callgraph(func_dict, file_stats, out_name):
callgraph = graphviz.Digraph("{} Call Graph".format(out_name),
filename="{}-callgraph.gv".format(out_name),
engine="dot")
callgraph.attr("graph", rankdir="TB")
callgraph.attr("graph", splines="true")
callgraph.attr("graph", concentrate="false")
callgraph.attr("graph", clusterrank="none")
callgraph.attr("node", fontname="Courier New")
callgraph.attr("node", shape="square")
callgraph.attr("node", nojustify="true")
callgraph.attr("node", width="2.5")
callgraph.attr("node", height="2.5")
callgraph.attr("edge", penwidth="3")
callgraph.attr("edge", constrain="false")
# create a summary node
with callgraph.subgraph(name="Summary") as c:
c.attr("graph", rankdir="TB")
c.attr("graph", splines="true")
c.attr("graph", concentrate="false")
c.attr("graph", clusterrank="none")
c.attr("node", fontname="Courier New")
c.attr("node", shape="square")
c.attr("node", nojustify="false")
c.attr("node", width="2.5")
c.attr("node", height="2.5")
c.attr("edge", penwidth="3")
c.attr("edge", constrain="false")
c.node(name="SUMMARY",
label="Summary\linsts: {}\lfuncs: {}\lcalls: {}\l".format
(file_stats.total_insts, file_stats.total_funcs, file_stats.total_calls))
# create the nodes
for func_name, entry in sorted(func_dict.items()):
num_calls_to = 0
if func_name in file_stats.func_calls:
num_calls_to = file_stats.func_calls[func_name]
label = "{}\n\ninsts: {}\lcalls from: {}\lcalls to: {}\l".format(
wrap_name(func_name),
entry.inst_count,
entry.call_count,
num_calls_to)
callgraph.node(name=wrap_name(func_name), label=label)
# create nodes for the extern functions
callgraph.attr("node", style="dashed")
for key, entry in sorted(file_stats.extern_funcs.items()):
func_name = key
callgraph.node(wrap_name(func_name))
# cycle through a handful of edge colors to add a little eye candy
color_idx = 0
edge_colors = [ "#FF000080", # red
"#00800F80", # green
"#FFAF0080", # orange
"#0000FF80", # blue
"#40404080" ] # gray
# create the edges
for key, entry in sorted(func_dict.items()):
func_name = entry.func_name
callgraph.attr("edge", color=edge_colors[color_idx])
for calleeName, count in sorted(entry.call_dict.items()):
callgraph.attr("edge", tooltip="{} -> {}".format(func_name, calleeName))
callgraph.edge(wrap_name(func_name), wrap_name(calleeName))
color_idx = (color_idx + 1) % len(edge_colors)
callgraph.render()
return
#-------------------------------------------------------------------------------
def main():
if len(sys.argv) != 2:
sys.exit("Wrong number of arguments\nUsage: $ parse-ptx.py <path-to-PTX-file>")
in_name = sys.argv[1]
if not os.path.isfile(in_name):
sys.exit("Unable to open PTX file")
out_name = os.path.splitext(os.path.basename(in_name))[0]
func_dict = parse_ptx(in_name)
file_stats = gather_file_stats(func_dict)
generate_summary(func_dict, file_stats, out_name)
generate_callgraph(func_dict, file_stats, out_name)
return
if __name__ == "__main__":
main()
#-------------------------------------------------------------------------------
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Utility script to download and build abi checking tools
#
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Exit the whole script if any command fails.
set -ex
# Where to install the final results
: ${LOCAL_DEPS_DIR:=${PWD}/ext}
: ${ABITOOLS_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
mkdir -p ${LOCAL_DEPS_DIR}
pushd ${LOCAL_DEPS_DIR}
git clone https://github.com/lvc/vtable-dumper
pushd vtable-dumper ; make install prefix=${ABITOOLS_INSTALL_DIR} ; popd
git clone https://github.com/lvc/abi-dumper
pushd abi-dumper ; make install prefix=${ABITOOLS_INSTALL_DIR} ; popd
git clone https://github.com/lvc/abi-compliance-checker
pushd abi-compliance-checker ; make install prefix=${ABITOOLS_INSTALL_DIR} ; popd
popd
# ls -R ${LOCAL_DEPS_DIR}
export PATH=${PATH}:${ABITOOLS_INSTALL_DIR}/bin
+2 -2
View File
@@ -12,7 +12,7 @@ set -ex
echo "Building cmake"
uname
CMAKE_VERSION=${CMAKE_VERSION:=3.12.4}
CMAKE_VERSION=${CMAKE_VERSION:=3.18.5}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
CMAKE_INSTALL_DIR=${CMAKE_INSTALL_DIR:=${LOCAL_DEPS_DIR}/cmake}
@@ -26,7 +26,7 @@ fi
if [[ `uname` == "Linux" && `uname -m` == "aarch64" ]] ; then
mkdir -p ${CMAKE_INSTALL_DIR} || true
curl --location https://anaconda.org/conda-forge/cmake/3.17.0/download/linux-aarch64/cmake-3.17.0-h28c56e5_0.tar.bz2 -o cmake-3.17.0-h28c56e5_0.tar.bz2
tar -xjvf cmake-3.17.0-h28c56e5_0.tar.bz2 -C ${CMAKE_INSTALL_DIR}
tar -xjf cmake-3.17.0-h28c56e5_0.tar.bz2 -C ${CMAKE_INSTALL_DIR}
export PATH=${CMAKE_INSTALL_DIR}/bin:$PATH
# In case we ever need to build from scratch:
+10 -18
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Utility script to download and build LLVM & clang
#
@@ -14,26 +14,18 @@ uname
if [[ `uname` == "Linux" ]] ; then
LLVM_VERSION=${LLVM_VERSION:=8.0.0}
LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR:=${PWD}/llvm-install}
if [[ "$GITHUB_WORKFLOW" != "" ]] ; then
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=ubuntu-18.04}
elif [[ "$TRAVIS_DIST" == "trusty" ]] ; then
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=ubuntu-14.04}
elif [[ "$TRAVIS_DIST" == "xenial" ]] ; then
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=ubuntu-16.04}
elif [[ "$TRAVIS_DIST" == "bionic" ]] ; then
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=ubuntu-18.04}
else
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=error}
fi
: ${LLVM_VERSION:=14.0.0}
: ${LLVM_INSTALL_DIR:=${PWD}/llvm-install}
: ${LLVM_DISTRO_NAME:=ubuntu-18.04}
LLVMTAR=clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-${LLVM_DISTRO_NAME}.tar.xz
echo LLVMTAR = $LLVMTAR
if [[ "$LLVM_VERSION" == "10.0.0" ]] || [[ "$LLVM_VERSION" == "11.0.0" ]] ; then
if [[ "$LLVM_VERSION" == "9.0.0" ]] || [[ "$LLVM_VERSION" == "9.0.1" ]] ;
then
# old -- get rid of this when LLVM 10 is the newest we allow
curl --location http://releases.llvm.org/${LLVM_VERSION}/${LLVMTAR} -o $LLVMTAR
else
# new
curl --location https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/${LLVMTAR} -o $LLVMTAR
else
curl --location http://releases.llvm.org/${LLVM_VERSION}/${LLVMTAR} -o $LLVMTAR
fi
ls -l $LLVMTAR
tar xf $LLVMTAR
@@ -43,5 +35,5 @@ if [[ `uname` == "Linux" ]] ; then
mv clang+llvm*/* $LLVM_INSTALL_DIR
export LLVM_DIRECTORY=$LLVM_INSTALL_DIR
export PATH=${LLVM_INSTALL_DIR}/bin:$PATH
ls -a $LLVM_DIRECTORY
# ls -a $LLVM_DIRECTORY
fi
+18 -11
View File
@@ -11,13 +11,15 @@ set -ex
# Which OCIO to retrieve, how to build it
OPENCOLORIO_REPO=${OPENCOLORIO_REPO:=https://github.com/AcademySoftwareFoundation/OpenColorIO.git}
OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v1.1.1}
OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v2.2.1}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_SOURCE_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build}
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENCOLORIO_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE:=Release}
OPENCOLORIO_CXX=${OPENCOLORIO_CXX:=g++}
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
# Just need libs:
OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
@@ -25,7 +27,7 @@ OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
-DOCIO_BUILD_GPU_TESTS=OFF \
-DOCIO_BUILD_PYTHON=OFF -DOCIO_BUILD_PYGLUE=OFF \
-DOCIO_BUILD_JAVA=OFF \
-DOCIO_BUILD_STATIC=${OCIO_BUILD_STATIC:=OFF}"
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"
BASEDIR=`pwd`
pwd
echo "OpenColorIO install dir will be: ${OPENCOLORIO_INSTALL_DIR}"
@@ -34,18 +36,23 @@ mkdir -p ${LOCAL_DEPS_DIR}
pushd ${LOCAL_DEPS_DIR}
# Clone OpenColorIO project from GitHub and build
if [[ ! -e OpenColorIO ]] ; then
echo "git clone ${OPENCOLORIO_REPO} OpenColorIO"
git clone ${OPENCOLORIO_REPO} OpenColorIO
if [[ ! -e ${OPENCOLORIO_SOURCE_DIR} ]] ; then
echo "git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}"
git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}
fi
cd OpenColorIO
cd ${OPENCOLORIO_SOURCE_DIR}
echo "git checkout ${OPENCOLORIO_VERSION} --force"
git checkout ${OPENCOLORIO_VERSION} --force
mkdir -p build
cd build
time cmake --config Release -DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} -DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" ${OPENCOLORIO_BUILDOPTS} ..
time cmake --build . --config Release --target install
echo "Building OpenColorIO from commit" `git rev-parse --short HEAD`
time cmake -S . -B ${OPENCOLORIO_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
-DCMAKE_CXX_COMPILER=${OPENCOLORIO_CXX} \
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS}
time cmake --build ${OPENCOLORIO_BUILD_DIR} --config Release --target install
popd
# ls -R ${OPENCOLORIO_INSTALL_DIR}
+19 -61
View File
@@ -11,8 +11,8 @@
set -ex
# Which OpenEXR to retrieve, how to build it
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/openexr/openexr.git}
OPENEXR_VERSION=${OPENEXR_VERSION:=v2.4.1}
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/AcademySoftwareFoundation/openexr.git}
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.1.11}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
@@ -20,7 +20,6 @@ OPENEXR_SOURCE_DIR=${OPENEXR_SOURCE_DIR:=${LOCAL_DEPS_DIR}/openexr}
OPENEXR_BUILD_DIR=${OPENEXR_BUILD_DIR:=${LOCAL_DEPS_DIR}/openexr-build}
OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENEXR_BUILD_TYPE=${OPENEXR_BUILD_TYPE:=Release}
CMAKE_GENERATOR=${CMAKE_GENERATOR:="Unix Makefiles"}
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
BASEDIR=$PWD
@@ -29,74 +28,35 @@ pwd
echo "Building OpenEXR ${OPENEXR_VERSION}"
echo "OpenEXR build dir will be: ${OPENEXR_BUILD_DIR}"
echo "OpenEXR install dir will be: ${OPENEXR_INSTALL_DIR}"
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
echo "OpenEXR Build type is ${OPENEXR_BUILD_TYPE}"
if [[ "$CMAKE_GENERATOR" == "" ]] ; then
OPENEXR_GENERATOR_CMD="-G \"$CMAKE_GENERATOR\""
fi
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
# Clone OpenEXR project (including IlmBase) from GitHub and build
if [[ ! -e ${OPENEXR_SOURCE_DIR} ]] ; then
echo "git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}"
git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}
fi
mkdir -p ${OPENEXR_INSTALL_DIR} && true
mkdir -p ${OPENEXR_BUILD_DIR} && true
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force
echo "Building OpenEXR from commit" `git rev-parse --short HEAD`
if [[ ${OPENEXR_VERSION} == "v2.2.0" ]] || [[ ${OPENEXR_VERSION} == "v2.2.1" ]] \
|| [[ ${OPENEXR_VERSION} == "v2.2.2" ]] ; then
mkdir -p ${OPENEXR_BUILD_DIR}/IlmBase && true
mkdir -p ${OPENEXR_BUILD_DIR}/OpenEXR && true
cd ${OPENEXR_BUILD_DIR}/IlmBase
cmake --config ${OPENEXR_BUILD_TYPE} ${OPENEXR_GENERATOR_CMD} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
-DCMAKE_CXX_STANDARD=11 \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/IlmBase
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
cd ${OPENEXR_BUILD_DIR}/OpenEXR
cmake --config ${OPENEXR_BUILD_TYPE} ${OPENEXR_GENERATOR_CMD} \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}\;${OPENEXR_INSTALL_DIR}" \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DBUILD_UTILS=0 -DBUILD_TESTS=0 \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/OpenEXR
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
elif [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
# Simplified setup for 2.3+
cd ${OPENEXR_BUILD_DIR}
cmake --config ${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DOPENEXR_BUILD_UTILS=0 \
-DOPENEXR_BUILD_TESTS=0 \
-DOPENEXR_BUILD_PYTHON_LIBS=0 \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
else
# Simplified setup for 2.4+
cd ${OPENEXR_BUILD_DIR}
cmake --config ${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DOPENEXR_BUILD_UTILS=0 \
-DBUILD_TESTING=0 \
-DPYILMBASE_ENABLE=0 \
-DOPENEXR_VIEWERS_ENABLE=0 \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
fi
cmake -S . -B ${OPENEXR_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DOPENEXR_BUILD_UTILS=0 \
-DBUILD_TESTING=0 \
-DPYILMBASE_ENABLE=0 \
-DOPENEXR_VIEWERS_ENABLE=0 \
-DINSTALL_OPENEXR_EXAMPLES=0 \
-DOPENEXR_INSTALL_EXAMPLES=0 \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS}
time cmake --build ${OPENEXR_BUILD_DIR} --target install --config ${OPENEXR_BUILD_TYPE}
popd
@@ -110,5 +70,3 @@ export ILMBASE_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
export OPENEXR_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
export LD_LIBRARY_PATH=$OPENEXR_ROOT/lib:$LD_LIBRARY_PATH
export ILMBASE_ROOT_DIR=$OPENEXR_INSTALL_DIR
export OPENEXR_ROOT_DIR=$OPENEXR_INSTALL_DIR
+5 -4
View File
@@ -9,11 +9,11 @@
# Exit the whole script if any command fails.
set -ex
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=OpenImageIO/oiio}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=master}
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=AcademySoftwareFoundation/OpenImageIO}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=release}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENIMAGEIO_SRCDIR=${OPENIMAGEIO_SRCDIR:=${LOCAL_DEPS_DIR}/OpenImageIO}
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build/$PLATFORM}
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build}
OPENIMAGEIO_INSTALLDIR=${OPENIMAGEIO_INSTALLDIR:=${LOCAL_DEPS_DIR}/dist}
OPENIMAGEIO_CMAKE_FLAGS=${OPENIMAGEIO_CMAKE_FLAGS:=""}
OPENIMAGEIO_BUILD_TYPE=${OPENIMAGEIO_BUILD_TYPE:=Release}
@@ -32,6 +32,7 @@ mkdir -p ${OPENIMAGEIO_BUILD_DIR} && true
pushd $OPENIMAGEIO_SRCDIR
git fetch --all -p
git checkout $OPENIMAGEIO_VERSION --force
echo "Building OpenImageIO from commit" `git rev-parse --short HEAD`
if [[ "$USE_SIMD" != "" ]] ; then
OPENIMAGEIO_CMAKE_FLAGS="$OPENIMAGEIO_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
@@ -42,7 +43,7 @@ fi
# if [[ "$ARCH" == "windows64" ]] ; then
pushd ${OPENIMAGEIO_BUILD_DIR}
cmake ../.. -G "$CMAKE_GENERATOR" \
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="$OPENIMAGEIO_BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX="$OPENIMAGEIO_INSTALLDIR" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
+11 -10
View File
@@ -11,7 +11,7 @@ set -ex
# Repo and branch/tag/commit of pugixml to download if we don't have it yet
PUGIXML_REPO=${PUGIXML_REPO:=https://github.com/zeux/pugixml.git}
PUGIXML_VERSION=${PUGIXML_VERSION:=v1.10}
PUGIXML_VERSION=${PUGIXML_VERSION:=v1.11.4}
# Where to put pugixml repo source (default to the ext area)
PUGIXML_SRC_DIR=${PUGIXML_SRC_DIR:=${PWD}/ext/pugixml}
@@ -34,18 +34,19 @@ if [[ ! -e ${PUGIXML_SRC_DIR} ]] ; then
git clone ${PUGIXML_REPO} ${PUGIXML_SRC_DIR}
fi
cd ${PUGIXML_SRC_DIR}
echo "git checkout ${PUGIXML_VERSION} --force"
git checkout ${PUGIXML_VERSION} --force
echo "Building pugixml from commit" `git rev-parse --short HEAD`
mkdir -p ${PUGIXML_BUILD_DIR}
cd ${PUGIXML_BUILD_DIR}
time cmake --config Release \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PUGIXML_INSTALL_DIR} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTS=OFF \
${PUGIXML_BUILD_OPTS} ..
time cmake --build . --config Release --target install
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${PUGIXML_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PUGIXML_INSTALL_DIR} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTS=OFF \
${PUGIXML_BUILD_OPTS} ..
time cmake --build ${PUGIXML_BUILD_DIR} --config Release --target install
fi
# ls -R ${PUGIXML_INSTALL_DIR}
popd
+11 -9
View File
@@ -11,7 +11,7 @@ set -ex
# Repo and branch/tag/commit of pybind11 to download if we don't have it yet
PYBIND11_REPO=${PYBIND11_REPO:=https://github.com/pybind/pybind11.git}
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.4.3}
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.8.1}
# Where to put pybind11 repo source (default to the ext area)
PYBIND11_SRC_DIR=${PYBIND11_SRC_DIR:=${PWD}/ext/pybind11}
@@ -20,7 +20,7 @@ PYBIND11_BUILD_DIR=${PYBIND11_BUILD_DIR:=${PYBIND11_SRC_DIR}/build}
# Install area for pybind11 (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
PYBIND11_INSTALL_DIR=${PYBIND11_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
#PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
if [[ "${PYTHON_VERSION}" != "" ]] ; then
PYBIND11_BUILD_OPTS+=" -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION}"
@@ -38,16 +38,18 @@ if [[ ! -e ${PYBIND11_SRC_DIR} ]] ; then
git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}
fi
cd ${PYBIND11_SRC_DIR}
echo "git checkout ${PYBIND11_VERSION} --force"
git checkout ${PYBIND11_VERSION} --force
echo "Building pybind11 from commit" `git rev-parse --short HEAD`
mkdir -p ${PYBIND11_BUILD_DIR}
cd ${PYBIND11_BUILD_DIR}
time cmake --config Release \
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
-DPYBIND11_TEST=OFF \
${PYBIND11_BUILD_OPTS} ..
time cmake --build . --config Release --target install
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${PYBIND11_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
-DPYBIND11_TEST=OFF \
${PYBIND11_BUILD_OPTS}
time cmake --build ${PYBIND11_BUILD_DIR} --config Release --target install
fi
# ls -R ${PYBIND11_INSTALL_DIR}
popd
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Important: set -ex causes this whole script to terminate with error if
# any command in it fails. This is crucial for CI tests.
set -e
# Arguments to this script are:
# BUILDDIR_NEW BUILDDIR_OLD LIBRARIES...
BUILDDIR_NEW=$1
shift
BUILDDIR_OLD=$1
shift
LIBS=$*
#
# First, create ABI dumps from both builds
#
ABI_ARGS="-bin-only -skip-cxx -public-headers $PWD/dist/include/OSL "
echo "ABI_CHECK: PWD=${PWD} "
ls -l $BUILDDIR_NEW
ls -l $BUILDDIR_OLD
for dir in $BUILDDIR_NEW $BUILDDIR_OLD ; do
for lib in $LIBS ; do
abi-dumper $ABI_ARGS ${dir}/lib/${lib}.so -o ${dir}/abi-${lib}.dump
done
done
echo "Saved ABI dumps"
#
# Run the ABI compliance checker, saving the outputs to files
#
for lib in $LIBS ; do
abi-compliance-checker -l $lib -old $BUILDDIR_OLD/abi-$lib.dump -new $BUILDDIR_NEW/abi-$lib.dump | tee ${lib}-abi-results.txt || true
echo -e "\x1b[33;1m"
echo -e "$lib"
fgrep "Binary compatibility:" ${lib}-abi-results.txt
echo -e "\x1b[33;0m"
done
#
# If the "Binary compatibility" summary results say anything other than 100%,
# we fail!
#
for lib in $LIBS ; do
if [[ `fgrep "Binary compatibility:" ${lib}-abi-results.txt | grep -v 100\%` != "" ]] ; then
cp -r compat_reports ${BUILDDIR_NEW}/compat_reports
exit 1
fi
done
+17 -3
View File
@@ -12,17 +12,31 @@ if [[ "$USE_SIMD" != "" ]] ; then
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
fi
pushd build/$PLATFORM
cmake ../.. -G "$CMAKE_GENERATOR" \
if [[ -n "$CODECOV" ]] ; then
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DCODECOV=${CODECOV}"
fi
pushd build
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_INSTALL_PREFIX="$OSL_ROOT" \
-DUSE_PYTHON="${USE_PYTHON:=1}" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
-DUSE_BATCHED="${USE_BATCHED:=0}" \
-DCMAKE_INSTALL_LIBDIR="$OSL_ROOT/lib" \
-DCMAKE_CXX_STANDARD="$CMAKE_CXX_STANDARD" \
$OSL_CMAKE_FLAGS -DVERBOSE=1
time cmake --build . --target ${BUILDTARGET:=install} --config ${CMAKE_BUILD_TYPE}
# Save a copy of the generated files for debugging broken CI builds.
mkdir cmake-save || /bin/true
cp -r CMake* *.cmake cmake-save
: ${BUILDTARGET:=install}
if [[ "$BUILDTARGET" != "none" ]] ; then
echo "Parallel build ${CMAKE_BUILD_PARALLEL_LEVEL} of target ${BUILDTARGET}"
time ${OSL_CMAKE_BUILD_WRAPPER} cmake --build . --target ${BUILDTARGET} --config ${CMAKE_BUILD_TYPE}
fi
popd
if [[ "${DEBUG_CI:=0}" != "0" ]] ; then
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Run code coverage analysis
# This assumes that the build occurred with CODECOV=1 andtests have already
# fully run.
set -ex
echo "Performing code coverage analysis"
mkdir _coverage
pushd _coverage
ls -R ../build/src/
# Remove files or directories we want to exclude from code coverage analysis,
# generally because we don't expect to execute any of their code during our
# CI. (Because it's only used interactively, or is fallback code only used
# when certain dependencies are not found.) Including these when we know we
# won't be calling them during coverage gathering will just make our coverage
# percentage look artifically low.
rm -f ../build/src/osltoy/CMakeFiles/osltoy.dir/*.cpp.{gcno,gcda}
# The sed command below converts from:
# ../build/src/liboslexec/CMakeFiles/oslexec.dir/foo.gcno
# to:
# ../src/liboslexec/foo.cpp
for g in $(find ../build -name "*.gcno" -type f); do
echo "Processing $g"
echo "dirname $g = $(dirname $g) to " `$(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\.cpp\.cpp/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')`
gcov -l -p -o $(dirname "$g") $(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')
done
popd
+27 -31
View File
@@ -8,27 +8,6 @@
# Since it sets many env variables needed by the caller, it should be run
# with 'source', not in a separate shell.
# Figure out the platform
if [[ $$RUNNER_OS == macOS ]] ; then
export ARCH=macosx
elif [[ $RUNNER_OS == Linux ]] ; then
export ARCH=linux64
elif [[ $RUNNER_OS == Windows ]] ; then
export ARCH=windows64
elif [[ `uname -m` == aarch64 ]] ; then
export ARCH=aarch64
else
export ARCH=unknown
fi
export PLATFORM=$ARCH
if [[ "${DEBUG:=0}" != "0" ]] ; then
export PLATFORM=${PLATFORM}.debug
fi
echo "Architecture is $ARCH"
echo "Build platform name is $PLATFORM"
# Environment variables we always need
export PATH=/usr/local/bin/_ccache:/usr/lib/ccache:$PATH
export USE_CCACHE=${USE_CCACHE:=1}
@@ -39,12 +18,12 @@ if [[ "${RUNNER_OS}" == "macOS" ]] ; then
fi
mkdir -p $CCACHE_DIR
export OSL_ROOT=$PWD/dist/$PLATFORM
export OSL_ROOT=$PWD/dist
export DYLD_LIBRARY_PATH=$OSL_ROOT/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$OSL_ROOT/lib:$LD_LIBRARY_PATH
export OIIO_LIBRARY_PATH=$OSL_ROOT/lib:${OIIO_LIBRARY_PATH}
export LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt
export ASAN_OPTIONS=print_suppressions=0
export ASAN_OPTIONS=print_suppressions=0:detect_odr_violation=1
export USE_PYTHON=${USE_PYTHON:=1}
export PYTHON_VERSION=${PYTHON_VERSION:="2.7"}
@@ -54,17 +33,12 @@ export PYTHONPATH=$OSL_ROOT/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPAT
export BUILD_MISSING_DEPS=${BUILD_MISSING_DEPS:=1}
export COMPILER=${COMPILER:=gcc}
export CXX=${CXX:=g++}
export CI=true
export OSL_CI=true
export USE_NINJA=${USE_NINJA:=1}
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD:=11}
export PARALLEL=${PARALLEL:=4}
export PAR_MAKEFLAGS=-j${PARALLEL}
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:=${PARALLEL}}
export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:=${PARALLEL}}
export LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=$HOME/ext}
export CMAKE_PREFIX_PATH=${LOCAL_DEPS_DIR}/dist:${CMAKE_PREFIX_PATH}
export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$LD_LIBRARY_PATH
@@ -73,7 +47,29 @@ export DYLD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$DYLD_LIBRARY_PATH
export TESTSUITE_CLEANUP_ON_SUCCESS=${TESTSUITE_CLEANUP_ON_SUCCESS:=1}
mkdir -p build/$PLATFORM dist/$PLATFORM
# For CI, default to building missing dependencies automatically
export OpenImageIO_BUILD_MISSING_DEPS=${OpenImageIO_BUILD_MISSING_DEPS:=all}
# Parallel builds
if [[ `uname -s` == "Linux" ]] ; then
echo "procs: " `nproc`
head -40 /proc/cpuinfo
export PARALLEL=${PARALLEL:=$((2 + `nproc`))}
elif [[ "${RUNNER_OS}" == "macOS" ]] ; then
echo "procs: " `sysctl -n hw.ncpu`
sysctl machdep.cpu.features
export PARALLEL=${PARALLEL:=$((2 + `sysctl -n hw.ncpu`))}
elif [[ "${RUNNER_OS}" == "Windows" ]] ; then
# Presumably Windows
export PARALLEL=${PARALLEL:=$((2 + ${NUMBER_OF_PROCESSORS}))}
else
export PARALLEL=${PARALLEL:=6}
fi
export PAR_MAKEFLAGS=-j${PARALLEL}
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:=${PARALLEL}}
export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:=${PARALLEL}}
mkdir -p build dist
echo "HOME = $HOME"
echo "PWD = $PWD"
@@ -88,7 +84,7 @@ env | sort
if [[ `uname -s` == "Linux" ]] ; then
head -40 /proc/cpuinfo
elif [[ $ARCH == macosx ]] ; then
elif [[ ${RUNNER_OS} == "macOS" ]] ; then
sysctl machdep.cpu.features
fi
+18 -4
View File
@@ -8,12 +8,26 @@
# any command in it fails. This is crucial for CI tests.
set -ex
: ${CTEST_EXCLUSIONS:="broken"}
: ${CTEST_TEST_TIMEOUT:=60}
$OSL_ROOT/bin/testshade --help
echo "Parallel test " ${CTEST_PARALLEL_LEVEL}
pushd build/$PLATFORM
time ctest -C ${CMAKE_BUILD_TYPE} -E broken --force-new-ctest-process \
--output-on-failure --timeout ${CTEST_TEST_TIMEOUT:=180} ${CTEST_ARGS}
echo "Parallel test ${CTEST_PARALLEL_LEVEL}"
echo "Default timeout ${CTEST_TEST_TIMEOUT}"
echo "Test exclusions '${CTEST_EXCLUSIONS}'"
echo "CTEST_ARGS '${CTEST_ARGS}'"
pushd build
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process --output-on-failure \
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS} \
|| \
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process \
--rerun-failed --repeat until-pass:5 -R render --output-on-failure \
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS}
# The weird construct above allows the render-* tests to run multiple times
popd
+2 -2
View File
@@ -73,7 +73,7 @@ from __future__ import print_function, absolute_import
###
### Only one main doc region will be output by the `docdeep` program,
### specified with the `-d` command line argument. Any other doc-regions
### will not be included in the documention output of that run.
### will not be included in the documentation output of that run.
###
### However, one doc-region may *include* the text of another doc-region
### as follows:
@@ -114,7 +114,7 @@ from __future__ import print_function, absolute_import
### For pre-code comments, the contiguous comment region associated with
### a declaration immediately precedes the declaration. Such a comment
### set has its first line start with `///>`. For post-code comments,
### the documentaiton comments follows the code declaration, and this is
### the documentation comments follows the code declaration, and this is
### designated by having its first line start with `///<`. I like to
### just remember that the `<` or `>` points in the direction of the code
### declaration that the comment applies to.
Binary file not shown.
+114 -18
View File
@@ -12,40 +12,97 @@ set -ex
# Install system packages when those are acceptable for dependencies.
#
if [[ "$ASWF_ORG" != "" ]] ; then
# Using ASWF CentOS container
# Using ASWF container
export PATH=/opt/rh/devtoolset-6/root/usr/bin:/usr/local/bin:$PATH
#ls /etc/yum.repos.d
sudo yum install -y giflib giflib-devel && true
sudo yum install -y opencv opencv-devel && true
sudo yum install -y Field3D Field3D-devel && true
sudo yum install -y ffmpeg ffmpeg-devel && true
if [[ "$ASWF_VFXPLATFORM_VERSION" == "2021" || "$ASWF_VFXPLATFORM_VERSION" == "2022" ]] ; then
# CentOS 7 based containers need the now-nonexistant centos repo to be
# excluded or all the subsequent yum install commands will fail.
yum-config-manager --disable centos-sclo-rh && true
sed -i 's,^mirrorlist=,#,; s,^#baseurl=http://mirror\.centos\.org/centos/$releasever,baseurl=https://vault.centos.org/7.9.2009,' /etc/yum.repos.d/CentOS-Base.repo
fi
sudo /usr/bin/yum install -y giflib giflib-devel && true
# sudo /usr/bin/yum install -y ffmpeg ffmpeg-devel && true
if [[ "${CONAN_LLVM_VERSION}" != "" ]] ; then
mkdir conan
pushd conan
# Simple way to conan install just one package:
# conan install clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1 -g deploy -g virtualenv
# But the below method can accommodate multiple requirements:
echo "[imports]" >> conanfile.txt
echo "., * -> ." >> conanfile.txt
echo "[requires]" >> conanfile.txt
echo "clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1" >> conanfile.txt
time conan install .
echo "--ls--"
ls -R .
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
export LLVM_ROOT=$PWD
popd
fi
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then
# Lock down icc to 2022.1 because newer versions hosted on the Intel
# repo require a glibc too new for the ASWF CentOS7-based containers
# we run CI on.
sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d
sudo /usr/bin/yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2022.1.0.x86_64
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
elif [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
# Lock down icx to 2023.1 because newer versions hosted on the Intel
# repo require a libstd++ too new for the ASWF containers we run CI on
# because their default install of gcc 9 based toolchain.
sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d
sudo yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.1.0.x86_64
# sudo yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
set +e; source /opt/intel/oneapi/setvars.sh; set -e
echo "Verifying installation of Intel(r) oneAPI DPC++/C++ Compiler:"
icpx --version
fi
else
# Using native Ubuntu runner
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
# sudo add-apt-repository ppa:ubuntu-toolchain-r/test
time sudo apt-get update
time sudo apt-get -q install -y \
git cmake ninja-build ccache g++ \
libboost-dev libboost-thread-dev \
libboost-filesystem-dev libboost-regex-dev \
libboost-dev libboost-thread-dev libboost-filesystem-dev \
libilmbase-dev libopenexr-dev \
python-dev python-numpy \
libtiff-dev libgif-dev libpng-dev \
flex bison libbison-dev \
libpugixml-dev \
libopencolorio-dev \
qt5-default
libopencolorio-dev
if [[ "${QT_VERSION:-5}" == "5" ]] ; then
time sudo apt-get -q install -y \
qt5-default || /bin/true
elif [[ "${QT_VERSION}" == "6" ]] ; then
time sudo apt-get -q install -y \
qt6-base-dev || /bin/true
fi
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH
if [[ "$CXX" == "g++-4.8" ]] ; then
time sudo apt-get install -y g++-4.8
elif [[ "$CXX" == "g++-6" ]] ; then
# Nonstandard python versions
if [[ "${PYTHON_VERSION}" == "3.9" ]] ; then
time sudo apt-get -q install -y python3.9-dev python3-numpy
pip3 --version
pip3 install numpy
elif [[ "$PYTHON_VERSION" == "2.7" ]] ; then
time sudo apt-get -q install -y python-dev python-numpy
else
pip3 install numpy
fi
if [[ "$CXX" == "g++-6" ]] ; then
time sudo apt-get install -y g++-6
elif [[ "$CXX" == "g++-7" ]] ; then
time sudo apt-get install -y g++-7
@@ -55,11 +112,31 @@ else
time sudo apt-get install -y g++-9
elif [[ "$CXX" == "g++-10" ]] ; then
time sudo apt-get install -y g++-10
elif [[ "$CXX" == "g++-11" ]] ; then
time sudo apt-get install -y g++-11
elif [[ "$CXX" == "g++-12" ]] ; then
time sudo apt-get install -y g++-12
fi
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=2022.1.0-3768
# Because multiple (possibly newer) versions of oneAPI may be installed,
# use a config file to specify compiler and tbb versions
# NOTE: oneAPI components have independent version numbering.
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
fi
source src/build-scripts/build_llvm.bash
fi
if [[ "$CMAKE_VERSION" != "" ]] ; then
source src/build-scripts/build_cmake.bash
fi
cmake --version
if [[ "$OPTIX_VERSION" != "" ]] ; then
@@ -81,6 +158,11 @@ if [[ "$OPTIX_VERSION" != "" ]] ; then
fi
#
# Packages we need to build from scratch.
#
source src/build-scripts/build_pybind11.bash
if [[ "$OPENEXR_VERSION" != "" ]] ; then
@@ -93,22 +175,36 @@ fi
# fi
if [[ "$OPENCOLORIO_VERSION" != "" ]] ; then
# Temporary (?) fix: GH ninja having problems, fall back to make
CMAKE_GENERATOR="Unix Makefiles" \
source src/build-scripts/build_opencolorio.bash
fi
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then
# There are many parts of OIIO we don't need to build
# There are many parts of OIIO we don't need to build for OSL's tests
export ENABLE_iinfo=0 ENABLE_iv=0 ENABLE_igrep=0
export ENABLE_iconvert=0 ENABLE_testtex=0
# For speed of compiling OIIO, disable the file formats that we don't
# need for OSL's tests
export ENABLE_BMP=0 ENABLE_cineon=0 ENABLE_DDS=0 ENABLE_DPX=0 ENABLE_FITS=0
export ENABLE_ICO=0 ENABLE_iff=0 ENABLE_jpeg2000=0 ENABLE_PNM=0 ENABLE_PSD=0
export ENABLE_RLA=0 ENABLE_SGI=0 ENABLE_SOCKET=0 ENABLE_SOFTIMAGE=0
export ENABLE_TARGA=0 ENABLE_WEBP=0
export OPENIMAGEIO_MAKEFLAGS="OIIO_BUILD_TESTS=0 USE_OPENGL=0"
# We don't need to run OIIO's tests
export OPENIMAGEIO_CMAKE_FLAGS+=" -DOIIO_BUILD_TESTING=OFF -DOIIO_BUILD_TESTS=0"
# Don't let warnings in OIIO break OSL's CI run
export OPENIMAGEIO_CMAKE_FLAGS+=" -DSTOP_ON_WARNING=OFF"
export OPENIMAGEIO_CMAKE_FLAGS+=" -DUSE_OPENGL=0"
export OPENIMAGEIO_CMAKE_FLAGS+=" -DUSE_OPENCV=0 -DUSE_FFMPEG=0 -DUSE_QT=0"
if [[ "${OPENIMAGEIO_UNITY:-1}" != "0" ]] ; then
# Speed up the OIIO build by doing a "unity" build. (Note: this is
# only a savings in CI where there are only 1-2 cores available.)
export OPENIMAGEIO_CMAKE_FLAGS+=" -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_MODE=BATCH"
fi
source src/build-scripts/build_openimageio.bash
fi
if [[ "$ABI_CHECK" != "" ]] ; then
source src/build-scripts/build_abi_tools.bash
fi
# Save the env for use by other stages
src/build-scripts/save-env.bash
+2 -2
View File
@@ -5,9 +5,9 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# DEP_DIR="$PWD/ext/dist"
DEP_DIR="$PWD/dist/$PLATFORM"
DEP_DIR="$PWD/dist"
mkdir -p "$DEP_DIR"
INT_DIR="build/$PLATFORM"
INT_DIR="build"
VCPKG_INSTALLATION_ROOT=/c/vcpkg
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:=.}
+26 -22
View File
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# This script, which assumes it is runnign on a Mac OSX with Homebrew
# This script, which assumes it is running on a Mac OSX with Homebrew
# installed, does a "brew install" in all packages reasonably needed by
# OSL and its dependencies.
@@ -19,48 +19,52 @@ if [[ `which brew` == "" ]] ; then
exit 1
fi
# set -ex
#brew update >/dev/null
if [[ "${DO_BREW_UPDATE:=0}" != "0" ]] ; then
brew update >/dev/null
fi
echo ""
echo "Before my brew installs:"
brew list --versions
brew install --display-times -q gcc ccache cmake ninja boost || true
brew link --overwrite gcc
brew unlink python@2.7 || true
brew unlink python@3.9 || true
brew unlink python@3.8 || true
brew install --display-times -q python@${PYTHON_VERSION} || true
# brew unlink python@3.8 || true
# brew unlink python@3.9 || true
brew unlink python@3.10 || true
brew link --overwrite --force python@${PYTHON_VERSION} || true
brew upgrade --display-times -q cmake || true
brew install --display-times -q libtiff ilmbase openexr
brew install --display-times -q libpng giflib webp jpeg-turbo freetype
brew install --display-times -q opencolorio partio pugixml
#brew upgrade --display-times -q cmake || true
brew install --display-times -q imath openexr opencolorio || true
#brew install --display-times -q freetype
brew install --display-times -q partio pugixml || true
brew install --display-times -q pybind11 numpy || true
brew install --display-times -q tbb || true
brew install --display-times -q openvdb || true
brew install --display-times -q flex bison
brew install --display-times -q fmt
brew install --display-times -q llvm${LLVMBREWVER}
brew install --display-times -q qt
if [[ "${USE_QT}" != "0" ]] ; then
brew install --display-times -q qt${QT_VERSION}
fi
echo ""
echo "After brew installs:"
brew list --versions
# Needed on some systems
if [[ $PYTHON_VERSION != "2.7" ]] ; then
pip3 install numpy
else
pip install numpy
fi
pip${PYTHON_VERSION} install numpy || true
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export PATH=/usr/local/opt/qt5/bin:$PATH
export PATH=/usr/local/opt/python/libexec/bin:$PATH
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
export PATH=/usr/local/opt/llvm${LLVMBREWVER}/bin:$PATH
export LLVM_DIRECTORY=/usr/local/opt/llvm${LLVMBREWVER}
export LLVM_ROOT=/usr/local/opt/llvm${LLVMBREWVER}
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH
export PATH=${HOMEBREW_PREFIX}/opt/qt5/bin:$PATH
export PATH=${HOMEBREW_PREFIX}/opt/python/libexec/bin:$PATH
export PYTHONPATH=${HOMEBREW_PREFIX}/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
# export PATH=${HOMEBREW_PREFIX}/opt/llvm${LLVMBREWVER}/bin:$PATH
export LLVM_DIRECTORY=${HOMEBREW_PREFIX}/opt/llvm${LLVMBREWVER}
export LLVM_ROOT=${HOMEBREW_PREFIX}/opt/llvm${LLVMBREWVER}
export PATH=${HOMEBREW_PREFIX}/opt/flex/bin:${HOMEBREW_PREFIX}/opt/bison/bin:$PATH
# Save the env for use by other stages
src/build-scripts/save-env.bash
+4 -5
View File
@@ -1,5 +1,4 @@
leak:Imf_2_2
leak:Imf_2_3
leak:Imf_2_4
leak:libIlmImf
leak:oslgram.y
# Small leaks that make CI fail, suppress until cause is identified.
leak:__cxa_thread_atexit
leak:std::string::_Rep::_S_create
leak:tsl::detail_robin_hash::robin_hash
+7
View File
@@ -0,0 +1,7 @@
[oneAPI]
name=Intel® oneAPI repository
baseurl=https://yum.repos.intel.com/oneapi
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
+3
View File
@@ -0,0 +1,3 @@
default=exclude
compiler=2022.1.0
tbb=2021.6.0
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Open a PTX file and:
# * add the `.visible` directive to all functions
# * add the `.visible` directive to global/constant variables
from __future__ import print_function, absolute_import
import re
import sys
in_name = sys.argv[1]
out_name = sys.argv[2]
ptx = ""
with open(in_name, 'r') as ptx_in:
ptx = ptx_in.read()
ptx = re.sub(r'(?m)^(\.const .align)', ".visible .const .align", ptx)
ptx = re.sub(r'(?m)^(\.global .align)', ".visible .global .align", ptx)
ptx = re.sub(r'(?m)^(\.func)', ".visible .func", ptx)
with open(out_name, 'w') as ptx_out:
ptx_out.write(ptx)
+4
View File
@@ -1,5 +1,9 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Save the env for use by other stages. Exclude things that we know aren't
# needed.
printenv \
+1
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
+17 -6
View File
@@ -7,17 +7,28 @@
include(CMakeFindDependencyMacro)
# add here all the find_dependency() whenever switching to config based dependencies
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.5)
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 3.0)
find_dependency(Imath @Imath_VERSION@)
elseif (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.4 AND @FOUND_OPENEXR_WITH_CONFIG@)
find_dependency(IlmBase @OpenEXR_VERSION@)
find_dependency(OpenEXR @OpenEXR_VERSION@)
# N.B. Only do this for OpenEXR >= 2.5, difficult to rely on their
# exported configs before that.
find_dependency(ZLIB @ZLIB_VERSION@) # Because OpenEXR doesn't do it
find_dependency(Threads) # Because OpenEXR doesn't do it
endif ()
find_dependency(OpenImageIO @OpenImageIO_VERSION@ REQUIRED)
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set_and_check (@PROJECT_NAME@_INCLUDES "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set_and_check (@PROJECT_NAME@_LIB_DIR "@CMAKE_INSTALL_FULL_LIBDIR@")
# Compute the installation prefix relative to this file
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
# There's no guarantee that CMAKE_INSTALL_XXXDIR is a relative path so we extract the final component to handle absolute paths
get_filename_component(_INCLUDE_DIR_NAME "@CMAKE_INSTALL_INCLUDEDIR@" NAME)
get_filename_component(_LIB_DIR_NAME "@CMAKE_INSTALL_LIBDIR@" NAME)
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_INCLUDES "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_LIB_DIR "${_IMPORT_PREFIX}/${_LIB_DIR_NAME}")
#...logic to determine installedPrefix from the own location...
#set (@PROJECT_NAME@_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@")
+2 -2
View File
@@ -1,6 +1,6 @@
# Copyright 2008-present Contributors to the OpenImageIO project.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Is the named package "enabled" via our disabling convention? If either
# USE_pkgname (or the all-uppercase USE_PKGNAME, or ENABLE_pkgname, or
+65 -20
View File
@@ -3,10 +3,27 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
set (REQUIED_DEPS "" CACHE STRING
set (REQUIRED_DEPS "" CACHE STRING
"Additional dependencies to consider required (semicolon-separated list, or ALL)")
set (OPTIONAL_DEPS "" CACHE STRING
"Additional dependencies to consider optional (semicolon-separated list, or ALL)")
option (ALWAYS_PREFER_CONFIG "Prefer a dependency's exported config file if it's available" OFF)
# Utility function to list the names and values of all variables matching
# the pattern (case-insensitive)
function (dump_matching_variables pattern)
string (TOLOWER ${pattern} _pattern_lower)
get_cmake_property(_allvars VARIABLES)
list (SORT _allvars)
foreach (_var IN LISTS _allvars)
string (TOLOWER ${_var} _var_lower)
if (_var_lower MATCHES ${_pattern_lower})
message (STATUS " ${_var} = ${${_var}}")
endif ()
endforeach ()
endfunction ()
# checked_find_package(Pkgname ...) is a wrapper for find_package, with the
@@ -20,8 +37,11 @@ set (OPTIONAL_DEPS "" CACHE STRING
# turned off explicitly from one of these sources.
# * Print a message if the package is enabled but not found. This is based
# on ${Pkgname}_FOUND or $PKGNAME_FOUND.
# * Optional DEFINITIONS <string> are passed to add_definitions if the
# * Optional DEFINITIONS <string>... are passed to add_definitions if the
# package is found.
# * Optional SETVARIABLES <id>... is a list of CMake variables to set to
# TRUE if the package is found (they will not be set or changed if the
# package is not found).
# * Optional PRINT <list> is a list of variables that will be printed
# if the package is found, if VERBOSE is on.
# * Optional DEPS <list> is a list of hard dependencies; for each one, if
@@ -42,6 +62,10 @@ set (OPTIONAL_DEPS "" CACHE STRING
# version, accepting but warning if it is below this number (even
# if above the true minimum version accepted). The warning message
# can give an optional explanation, passed as RECOMMEND_MIN_REASON.
# * Optional PREFER_CONFIG, if supplied, tries to use an exported config
# file from the package before using a FindPackage.cmake module.
# * Optional DEBUG turns on extra debugging information related to how
# this package is found.
#
# N.B. This needs to be a macro, not a function, because the find modules
# will set(blah val PARENT_SCOPE) and we need that to be the global scope,
@@ -49,16 +73,20 @@ set (OPTIONAL_DEPS "" CACHE STRING
macro (checked_find_package pkgname)
cmake_parse_arguments(_pkg # prefix
# noValueKeywords:
"REQUIRED"
"REQUIRED;PREFER_CONFIG;DEBUG"
# singleValueKeywords:
"ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON"
# multiValueKeywords:
"DEFINITIONS;PRINT;DEPS"
"DEFINITIONS;PRINT;DEPS;SETVARIABLES"
# argsToParse:
${ARGN})
string (TOLOWER ${pkgname} pkgname_lower)
string (TOUPPER ${pkgname} pkgname_upper)
if (NOT VERBOSE)
set (_pkg_VERBOSE ${VERBOSE})
if (_pkg_DEBUG)
set (_pkg_VERBOSE ON)
endif ()
if (NOT _pkg_VERBOSE)
set (${pkgname}_FIND_QUIETLY true)
set (${pkgname_upper}_FIND_QUIETLY true)
endif ()
@@ -85,8 +113,19 @@ macro (checked_find_package pkgname)
set (_quietskip true)
endif ()
endif ()
set (_config_status "")
if (_enable OR _pkg_REQUIRED)
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
# was already found
elseif (_pkg_PREFER_CONFIG OR ALWAYS_PREFER_CONFIG)
find_package (${pkgname} CONFIG ${_pkg_UNPARSED_ARGUMENTS})
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
set (_config_status "from CONFIG")
endif ()
endif ()
if (NOT (${pkgname}_FOUND OR ${pkgname_upper}_FOUND))
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
endif()
if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
AND ${pkgname}_VERSION
AND (_pkg_VERSION_MIN OR _pkg_VERSION_MAX))
@@ -106,21 +145,11 @@ macro (checked_find_package pkgname)
set (${pkgname}_VERSION ${${_vervar}})
endif ()
endforeach ()
message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${ColorReset}")
if (VERBOSE)
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
${_pkg_PRINT})
list (REMOVE_DUPLICATES _vars_to_print)
foreach (_v IN LISTS _vars_to_print)
if (NOT "${${_v}}" STREQUAL "")
message (STATUS " ${_v} = ${${_v}}")
endif ()
endforeach ()
endif ()
message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${_config_status}${ColorReset}")
add_definitions (${_pkg_DEFINITIONS})
foreach (_v IN LISTS _pkg_SETVARIABLES)
set (${_v} TRUE)
endforeach ()
if (_pkg_RECOMMEND_MIN)
if (${${pkgname}_VERSION} VERSION_LESS ${_pkg_RECOMMEND_MIN})
message (STATUS "${ColorYellow}Recommend ${pkgname} >= ${_pkg_RECOMMEND_MIN} ${_pkg_RECOMMEND_MIN_REASON} ${ColorReset}")
@@ -148,6 +177,22 @@ macro (checked_find_package pkgname)
message (FATAL_ERROR "${ColorRed}${pkgname} is required, aborting.${ColorReset}")
endif ()
endif()
if (_pkg_VERBOSE AND (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_DEBUG))
if (_pkg_DEBUG)
dump_matching_variables (${pkgname})
endif ()
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
${_pkg_PRINT})
list (REMOVE_DUPLICATES _vars_to_print)
foreach (_v IN LISTS _vars_to_print)
if (NOT "${${_v}}" STREQUAL "")
message (STATUS " ${_v} = ${${_v}}")
endif ()
endforeach ()
endif ()
else ()
if (NOT _quietskip)
message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}")
+2 -2
View File
@@ -1,6 +1,6 @@
# Copyright 2008-present Contributors to the OpenImageIO project.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Define color codes for pretty terminal output
+153 -143
View File
@@ -15,23 +15,23 @@
###########################################################################
# Print some basic status about the system and compiler
#
if (VERBOSE)
message (STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message (STATUS "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}")
message (STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
endif ()
message (STATUS "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message (VERBOSE "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message (VERBOSE "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}")
message (VERBOSE "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
message (STATUS "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
###########################################################################
# C++ language standard
#
set (CMAKE_CXX_STANDARD 11 CACHE STRING
"C++ standard to prefer (11, 14, 17, 20, etc.)")
set (CMAKE_CXX_STANDARD 14 CACHE STRING
"C++ standard to build with (14, 17, 20, etc.)")
set (DOWNSTREAM_CXX_STANDARD 14 CACHE STRING
"C++ minimum standard to impose on downstream clients")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
message (STATUS "Building for C++${CMAKE_CXX_STANDARD}")
message (STATUS "Building with C++${CMAKE_CXX_STANDARD}, downstream minimum C++${DOWNSTREAM_CXX_STANDARD}")
###########################################################################
@@ -42,14 +42,13 @@ if (CMAKE_COMPILER_IS_GNUCC)
execute_process (COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (VERBOSE)
message (STATUS "Using gcc ${GCC_VERSION} as the compiler")
endif ()
message (VERBOSE "Using gcc ${GCC_VERSION} as the compiler")
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
@@ -60,37 +59,45 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
set (CMAKE_CXX_COMPILER_ID "AppleClang")
set (CMAKE_COMPILER_IS_APPLECLANG 1)
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" APPLECLANG_VERSION_STRING ${clang_full_version_string})
if (VERBOSE)
message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
endif ()
set (ANY_CLANG_VERSION_STRING ${APPLECLANG_VERSION_STRING})
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
set (CMAKE_COMPILER_IS_INTELCLANG 1)
string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string})
set (ANY_CLANG_VERSION_STRING ${INTELCLANG_VERSION_STRING})
message (VERBOSE "The compiler is Intel Clang: ${CMAKE_CXX_COMPILER_ID} version ${INTELCLANG_VERSION_STRING}")
else ()
set (CMAKE_COMPILER_IS_GENERICCLANG 1)
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
if (VERBOSE)
message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}")
endif ()
set (ANY_CLANG_VERSION_STRING ${CLANG_VERSION_STRING})
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}")
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set (CMAKE_COMPILER_IS_INTEL 1)
if (VERBOSE)
message (STATUS "Using Intel as the compiler")
endif ()
message (VERBOSE "Using Intel as the compiler")
endif ()
###########################################################################
# Turn on more detailed warnings and optionally consider warnings as errors
#
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
if (NOT ${PROJECT_NAME}_SUPPORTED_RELEASE OR DEFINED ENV{${PROJECT_NAME}_CI})
# For development branches (i.e., not a supported release), or when
# running CI, default to treating all warnings as errors.
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
else ()
# For release branches not doing a CI build default to just printing
# warnings but not letting them stop the build.
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" OFF)
endif()
option (EXTRA_WARNINGS "Enable lots of extra pedantic warnings" OFF)
if (NOT MSVC)
add_compile_options ("-Wall")
if (EXTRA_WARNINGS)
add_compile_options ("-Wextra")
endif ()
if (STOP_ON_WARNING OR DEFINED ENV{CI})
if (STOP_ON_WARNING)
add_compile_options ("-Werror")
# N.B. Force CI builds to use -Werror, even if STOP_ON_WARNING has
# been switched off by default, which we may do in release branches.
endif ()
endif ()
@@ -106,11 +113,11 @@ endif ()
# give more fine-grained control for hiding symbols, because sometimes
# dependent libraries may not be well behaved and need extra hiding.
#
set (CXX_VISIBILITY_PRESET "hidden" CACHE STRING "Symbol visibility (hidden or default")
set (CMAKE_CXX_VISIBILITY_PRESET "hidden" CACHE STRING "Symbol visibility (hidden or default")
option (VISIBILITY_INLINES_HIDDEN "Hide symbol visibility of inline functions" ON)
set (VISIBILITY_MAP_FILE "${PROJECT_SOURCE_DIR}/src/build-scripts/hidesymbols.map" CACHE FILEPATH "Visibility map file")
set (C_VISIBILITY_PRESET ${CXX_VISIBILITY_PRESET})
if (${CXX_VISIBILITY_PRESET} STREQUAL "hidden" AND
set (CMAKE_C_VISIBILITY_PRESET ${CMAKE_CXX_VISIBILITY_PRESET})
if (${CMAKE_CXX_VISIBILITY_PRESET} STREQUAL "hidden" AND VISIBILITY_MAP_FILE AND
(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND
(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU"))
# Linux/FreeBSD/Hurd: also hide all the symbols of dependent libraries
@@ -144,9 +151,17 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
add_compile_options ("-Wno-unused-local-typedefs")
endif ()
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.9)
# Don't warn about using unknown preprocessor symbols in #if'set
# Don't warn about using unknown preprocessor symbols in `#if`
add_compile_options ("-Wno-expansion-to-defined")
endif ()
# Suppress warnings about our strategic use of bitwise operations in place
# of logical operators to produce branchless code in some places.
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0
OR APPLECLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0
OR INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0)
add_compile_options ("-Wno-bitwise-instead-of-logical")
endif ()
# disable warning in flex-generated code
add_compile_options ("-Wno-null-conversion")
add_compile_options ("-Wno-error=strict-overflow")
@@ -174,6 +189,11 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
add_compile_options ("-fno-math-errno")
endif ()
if (INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 2022.1.0)
# New versions of icx warn about changing certain floating point options
add_compile_options ("-Wno-overriding-t-option")
endif ()
if (MSVC)
# Microsoft specific options
string (REGEX REPLACE "/W[1-4]" "/W1" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
@@ -191,6 +211,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
endif ()
# Remember the -std flags we need will be used later for custom Cuda builds
set (CSTD_FLAGS "")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_INTEL)
set (CSTD_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
@@ -198,6 +219,10 @@ endif ()
# We will use this for ccache and timing
set (MY_RULE_LAUNCH "")
###########################################################################
# Use ccache if found
#
@@ -211,12 +236,30 @@ if (CCACHE_FOUND AND USE_CCACHE)
if (CMAKE_COMPILER_IS_CLANG AND USE_QT AND (NOT DEFINED ENV{CCACHE_CPP2}))
message (STATUS "Ignoring ccache because clang + Qt + env CCACHE_CPP2 is not set")
else ()
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
set (MY_RULE_LAUNCH ccache)
endif ()
endif ()
###########################################################################
# Build time debugging aid: time all compile & link commands
#
# Note, though, that this is not especially helpful when doing a parallel
# build. If you wish to time individual compile commands, it's best to also
# set `-j 1` or CMAKE_BUILD_PARALLEL_LEVEL to 1.
option (TIME_COMMANDS "Time each compile and link command" OFF)
if (TIME_COMMANDS)
set (MY_RULE_LAUNCH "${CMAKE_COMMAND} -E time ${MY_RULE_LAUNCH}")
endif ()
# Note: This must be after any option that alters MY_RULE_LAUNCH
if (MY_RULE_LAUNCH)
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${MY_RULE_LAUNCH})
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ${MY_RULE_LAUNCH})
endif ()
###########################################################################
# Option to force use of libc++ (the LLVM project's alternate C++ standard
# library). Currently this only has an effect if using clang as the
@@ -263,9 +306,7 @@ if (NOT USE_SIMD STREQUAL "")
else ()
string (REPLACE "," ";" SIMD_FEATURE_LIST ${USE_SIMD})
foreach (feature ${SIMD_FEATURE_LIST})
if (VERBOSE)
message (STATUS "SIMD feature: ${feature}")
endif ()
message (VERBOSE "SIMD feature: ${feature}")
if (MSVC OR CMAKE_COMPILER_IS_INTEL)
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "/arch:${feature}")
else ()
@@ -283,6 +324,33 @@ if (NOT USE_SIMD STREQUAL "")
add_compile_options (${SIMD_COMPILE_FLAGS})
endif ()
###########################################################################
# Batched SIMD shader execution options.
#
# The USE_BATCHED option may be set to indicate that support for batched
# SIMD shader execution be compiled along with targe specific libraries
set (USE_BATCHED "" CACHE STRING "Build batched SIMD shader execution for (0, b8_AVX, b8_AVX2, b8_AVX2_noFMA, b8_AVX512, b8_AVX512_noFMA, b16_AVX512, b16_AVX512_noFMA)")
option (VEC_REPORT "Enable compiler's reporting system for vectorization" OFF)
set (BATCHED_SUPPORT_DEFINES "")
set (BATCHED_TARGET_LIBS "")
set (OSL_BUILD_BATCHED 0)
if (NOT USE_BATCHED STREQUAL "")
message (STATUS "Compiling with batched SIMD targets ${USE_BATCHED}")
if (NOT USE_BATCHED STREQUAL "0")
set (OSL_BUILD_BATCHED 1)
string (REPLACE "," ";" BATCHED_TARGET_LIST ${USE_BATCHED})
foreach (batched_target ${BATCHED_TARGET_LIST})
if (VERBOSE)
message (STATUS "BATCHED target: ${batched_target}")
endif ()
list (APPEND BATCHED_SUPPORT_DEFINES "__OSL_SUPPORTS_${batched_target}")
endforeach()
else ()
message (STATUS "Compiling with NO batched SIMD targets, USE_BATCHED=0")
endif ()
else ()
message (STATUS "Compiling with NO batched SIMD targets, USE_BATCHED is empty")
endif ()
###########################################################################
# Preparation to test for compiler/language features
@@ -292,26 +360,6 @@ endif ()
include (CMakePushCheckState)
include (CheckCXXSourceRuns)
###########################################################################
# Find out if it's safe for us to use std::regex or if we need boost.regex.
# This is primarily about gcc 4.8 having a broken regex implementation.
# This will be obsolete once our minimum supported gcc is >= 4.9.
#
cmake_push_check_state ()
check_cxx_source_runs("
#include <regex>
int main() {
std::string r = std::regex_replace(std::string(\"abc\"), std::regex(\"b\"), \" \");
return r == \"a c\" ? 0 : -1;
}"
USE_STD_REGEX)
cmake_pop_check_state ()
if (USE_STD_REGEX)
add_definitions (-DUSE_STD_REGEX)
else ()
add_definitions (-DUSE_BOOST_REGEX)
endif ()
###########################################################################
# Code coverage options
@@ -319,11 +367,9 @@ endif ()
option (CODECOV "Build code coverage tests" OFF)
if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
message (STATUS "Compiling for code coverage analysis")
add_compile_options ("-ftest-coverage -fprofile-arcs -O0")
add_compile_options (-ftest-coverage -fprofile-arcs)
add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
link_libraries(gcov)
endif ()
@@ -337,22 +383,9 @@ if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
foreach (feature ${SANITIZE_FEATURE_LIST})
message (STATUS " sanitize feature: ${feature}")
add_compile_options (-fsanitize=${feature})
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${feature}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=${feature}")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${feature}")
add_link_options (-fsanitize=${feature})
endforeach()
add_compile_options (-g -fno-omit-frame-pointer)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (SANITIZE_ON_LINUX 1)
endif ()
if (CMAKE_COMPILER_IS_GNUCC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_compile_options ("-fuse-ld=gold")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=gold")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
set (SANITIZE_LIBRARIES "asan;pthread")
# set (SANITIZE_LIBRARIES "asan" "ubsan")
endif()
if (CMAKE_COMPILER_IS_GNUCC)
# turn on glibcxx extra annotations to find vector writes past end
add_definitions ("-D_GLIBCXX_SANITIZE_VECTOR=1")
@@ -380,7 +413,7 @@ if (CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy"
DOC "Path to clang-tidy executable")
message (STATUS "CLANG_TIDY_EXE ${CLANG_TIDY_EXE}")
if (CLANG_TIDY_EXE AND NOT ${CMAKE_VERSION} VERSION_LESS 3.6)
if (CLANG_TIDY_EXE)
set (CMAKE_CXX_CLANG_TIDY
"${CLANG_TIDY_EXE}"
)
@@ -414,66 +447,46 @@ endif ()
# correct any deviations. If clang-format is found on the system, a
# "clang-format" build target will trigger a reformatting.
#
set (CLANG_FORMAT_EXE_HINT "" CACHE PATH "clang-format executable's directory (will search if not specified")
set (CLANG_FORMAT_INCLUDES # "src/*.h" "src/*.cpp"
"src/include/*.h"
"src/liboslcomp/*.cpp"
"src/liboslcomp/*.h"
"src/liboslexec/batched_rendservices.cpp"
"src/liboslquery/*.cpp"
"src/liboslquery/*.h"
"src/oslinfo/*.cpp"
"src/oslc/*.cpp"
"src/osl.imageio/*.cpp"
"src/osltoy/*.cpp"
"src/osltoy/*.h"
"testsuite/*.cpp"
CACHE STRING "Glob patterns to include for clang-format")
set (CLANG_FORMAT_EXCLUDES
# Files "imported and modified" that we don't want to reformat, so
# they continue to match their upstream versions.
"src/include/OSL/Imathx/*"
"src/include/OSL/matrix22.h"
# Files that are currently being modified with the SIMD batch
# shading -- we'll reformat those only after that project work is
# completed, to avoid nasty merge conflicts.
"src/include/OSL/rendererservices.h"
"src/include/OSL/*llvm*"
"src/liboslexec/*llvm*"
"src/liboslexec/oslexec_pvt.h"
# Files that are currently being modified with the OptiX work --
# we'll reformat those only after that project work is completed, to
# avoid nasty merge conflicts.
"src/include/OSL/device_string.h"
"src/include/OSL/oslexec.h"
"src/testrender/cuda/*"
# Header files in testsuite are almost certainly osl headers, not C++
"testsuite/*.h"
""
CACHE STRING "Glob patterns to exclude for clang-format")
find_program (CLANG_FORMAT_EXE
NAMES clang-format bin/clang-format
HINTS ${CLANG_FORMAT_EXE_HINT} ENV CLANG_FORMAT_EXE_HINT
ENV LLVM_DIRECTORY
NO_DEFAULT_PATH
DOC "Path to clang-format executable")
find_program (CLANG_FORMAT_EXE NAMES clang-format bin/clang-format)
if (CLANG_FORMAT_EXE)
message (STATUS "clang-format found: ${CLANG_FORMAT_EXE}")
# Start with the list of files to include when formatting...
file (GLOB_RECURSE FILES_TO_FORMAT ${CLANG_FORMAT_INCLUDES})
# ... then process any list of excludes we are given
foreach (_pat ${CLANG_FORMAT_EXCLUDES})
file (GLOB_RECURSE _excl ${_pat})
list (REMOVE_ITEM FILES_TO_FORMAT ${_excl})
endforeach ()
# message (STATUS "clang-format file list: ${FILES_TO_FORMAT}")
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target (clang-format
COMMAND "${CLANG_FORMAT_EXE}" -i -style=file ${FILES_TO_FORMAT} )
else ()
message (STATUS "clang-format not found.")
# Note: skip all of this checking, setup, and cmake-format target if this
# is being built as a subproject.
if (PROJECT_IS_TOP_LEVEL)
set (CLANG_FORMAT_EXE_HINT "" CACHE PATH "clang-format executable's directory (will search if not specified")
set (CLANG_FORMAT_INCLUDES "src/*.cpp" "src/*.h" "src/*.cu"
CACHE STRING "Glob patterns to include for clang-format")
set (CLANG_FORMAT_EXCLUDES
# Files "imported and modified" that we don't want to reformat, so
# they continue to match their upstream versions.
"src/include/OSL/Imathx/*"
"src/include/OSL/matrix22.h"
# Header files in testsuite are almost certainly osl headers, not C++
"testsuite/*.h"
# Header files in shaders are OSL, not C++
"src/shaders/*.h"
CACHE STRING "Glob patterns to exclude for clang-format")
find_program (CLANG_FORMAT_EXE
NAMES clang-format bin/clang-format
HINTS ${CLANG_FORMAT_EXE_HINT} ENV CLANG_FORMAT_EXE_HINT
ENV LLVM_DIRECTORY
NO_DEFAULT_PATH
DOC "Path to clang-format executable")
find_program (CLANG_FORMAT_EXE NAMES clang-format bin/clang-format)
if (CLANG_FORMAT_EXE)
message (STATUS "clang-format found: ${CLANG_FORMAT_EXE}")
# Start with the list of files to include when formatting...
file (GLOB_RECURSE FILES_TO_FORMAT ${CLANG_FORMAT_INCLUDES})
# ... then process any list of excludes we are given
foreach (_pat ${CLANG_FORMAT_EXCLUDES})
file (GLOB_RECURSE _excl ${_pat})
list (REMOVE_ITEM FILES_TO_FORMAT ${_excl})
endforeach ()
# message (STATUS "clang-format file list: ${FILES_TO_FORMAT}")
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target (clang-format
COMMAND "${CLANG_FORMAT_EXE}" -i -style=file ${FILES_TO_FORMAT} )
else ()
message (STATUS "clang-format not found.")
endif ()
endif ()
@@ -502,9 +515,7 @@ else ()
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
CACHE STRING "Set the SO version for dynamic libraries")
endif ()
if (VERBOSE)
message(STATUS "Setting SOVERSION to: ${SOVERSION}")
endif ()
message(VERBOSE "Setting SOVERSION to: ${SOVERSION}")
###########################################################################
@@ -535,9 +546,10 @@ endif ()
###########################################################################
# Any extra logic to be run only for CI builds goes here.
# We expect our own CI runs to define env variable ${PROJECT_NAME}_CI
#
if (DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS})
add_definitions ("-D${PROJ_NAME}_CI=1" "-DBUILD_CI=1")
if (DEFINED ENV{${PROJECT_NAME}_CI})
add_definitions (-D${PROJ_NAME}_CI=1 -DBUILD_CI=1)
if (APPLE)
# Keep Mono framework from being incorrectly searched for include
# files on GitHub Actions CI.
@@ -565,9 +577,7 @@ else ()
# add the automatically determined parts of the RPATH that
# point to directories outside the build tree to the install RPATH
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if (VERBOSE)
message (STATUS "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_RPATH}")
endif ()
message (VERBOSE "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_RPATH}")
endif ()
# OSL considerations because we run oslc in the course of building:
# Use (i.e. don't skip) the full RPATH for the build tree
+139 -18
View File
@@ -3,15 +3,37 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
set ($OSL_EXTRA_NVCC_ARGS "" CACHE STRING "Custom args passed to nvcc when compiling CUDA code")
set (CUDA_OPT_FLAG_NVCC "-O3" CACHE STRING "The optimization level to use when compiling CUDA/C++ files with nvcc")
set (CUDA_OPT_FLAG_CLANG "-O3" CACHE STRING "The optimization level to use when compiling CUDA/C++ files with clang")
# FTZ is enabled by default since it offers the best performance,
# but it may be disabled to debug numerical issues, to better match
# host behavior, etc.
set (CUDA_NO_FTZ OFF CACHE BOOL "Do not enable force-to-zero when compiling for CUDA")
if (CUDA_NO_FTZ)
add_definitions ("-DOSL_CUDA_NO_FTZ=1")
endif ()
# Compile a CUDA file to PTX using NVCC
function ( NVCC_COMPILE cuda_src ptx_generated extra_nvcc_args )
function ( NVCC_COMPILE cuda_src extra_headers ptx_generated extra_nvcc_args )
get_filename_component ( cuda_src_we ${cuda_src} NAME_WE )
get_filename_component ( cuda_src_dir ${cuda_src} DIRECTORY )
set (cuda_ptx "${CMAKE_CURRENT_BINARY_DIR}/${cuda_src_we}.ptx" )
set (${ptxlist} ${${ptxlist}} ${cuda_ptx} )
set (${ptx_generated} ${cuda_ptx} PARENT_SCOPE)
file ( GLOB cuda_headers "${cuda_src_dir}/*.h" )
list (APPEND cuda_headers ${extra_headers})
list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
list (TRANSFORM OPENEXR_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OPENEXR_INCLUDES)
list (TRANSFORM OpenImageIO_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OpenImageIO_INCLUDES)
if (NOT CUDA_NO_FTZ)
set (NVCC_FTZ_FLAG "--ftz=true")
endif ()
add_custom_command ( OUTPUT ${cuda_ptx}
COMMAND ${CUDA_NVCC_EXECUTABLE}
@@ -21,14 +43,17 @@ function ( NVCC_COMPILE cuda_src ptx_generated extra_nvcc_args )
"-I${CMAKE_BINARY_DIR}/include"
"-I${PROJECT_SOURCE_DIR}/src/include"
"-I${PROJECT_SOURCE_DIR}/src/cuda_common"
"-I${OpenImageIO_INCLUDES}"
"-I${IMATH_INCLUDES}"
${ALL_OpenImageIO_INCLUDES}
${ALL_IMATH_INCLUDES}
${ALL_OPENEXR_INCLUDES}
"-I${Boost_INCLUDE_DIRS}"
"-DFMT_DEPRECATED=\"\""
${LLVM_COMPILE_FLAGS}
-DOSL_USE_FAST_MATH=1
-m64 -arch ${CUDA_TARGET_ARCH} -ptx
--std=c++14 -dc -O3 --use_fast_math --expt-relaxed-constexpr
--std=c++${CMAKE_CXX_STANDARD}
-dc --use_fast_math ${CUDA_OPT_FLAG_NVCC} ${NVCC_FTZ_FLAG}
--expt-relaxed-constexpr
${extra_nvcc_args}
${OSL_EXTRA_NVCC_ARGS}
${cuda_src} -o ${cuda_ptx}
@@ -46,13 +71,11 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
# Setup the compile flags
get_property (CURRENT_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
if (VERBOSE)
message (STATUS "Current #defines are ${CURRENT_DEFINITIONS}")
endif ()
message (VERBOSE "Current #defines are ${CURRENT_DEFINITIONS}")
foreach (def ${CURRENT_DEFINITIONS})
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-D${def}")
endforeach()
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} ${SIMD_COMPILE_FLAGS} ${CSTD_FLAGS})
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} ${CSTD_FLAGS})
# Setup the bitcode generator
if (NOT LLVM_BC_GENERATOR)
@@ -67,9 +90,35 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
if (NOT LLVM_BC_GENERATOR)
message (FATAL_ERROR "You must have a valid llvm bitcode generator (clang++) somewhere.")
endif ()
if (VERBOSE)
message (STATUS "Using LLVM_BC_GENERATOR ${LLVM_BC_GENERATOR} to generate bitcode.")
endif()
message (VERBOSE "Using LLVM_BC_GENERATOR ${LLVM_BC_GENERATOR} to generate bitcode.")
if (NOT LLVM_AS_TOOL)
find_program (LLVM_AS_TOOL NAMES "llvm-as"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_LINK_TOOL)
find_program (LLVM_LINK_TOOL NAMES "llvm-link"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_LLC_TOOL)
find_program (LLVM_LLC_TOOL NAMES "llc"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_OPT_TOOL)
find_program (LLVM_OPT_TOOL NAMES "opt"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# fix compilation error when using MSVC
@@ -81,24 +130,53 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
set (CLANG_MSVC_FIX "${CLANG_MSVC_FIX} -Wno-ignored-attributes -Wno-unknown-attributes")
endif ()
if (NOT LLVM_OPAQUE_POINTERS AND ${LLVM_VERSION} VERSION_GREATER_EQUAL 15.0)
# Until we fully support opaque pointers, we need to disable
# them when using LLVM 15.
list (APPEND LLVM_COMPILE_FLAGS -Xclang -no-opaque-pointers)
endif ()
if (NOT CUDA_NO_FTZ)
set (CLANG_FTZ_FLAG "-fcuda-flush-denormals-to-zero")
endif ()
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "12.0")
# The textureReference API was removed in CUDA 12.0, but it's still referenced
# in the clang headers, so compilation will fail with 12.0 and newer toolkits
# due to the missing definitions.
#
# We don't actually require any of the clang CUDA texture intrinsics, so we can
# side-step the issue by preventing them from being included by the preprocessor.
set (CUDA_TEXREF_FIX "-D__CLANG_CUDA_TEXTURE_INTRINSICS_H__")
endif()
list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
list (TRANSFORM OPENEXR_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OPENEXR_INCLUDES)
list (TRANSFORM OpenImageIO_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OpenImageIO_INCLUDES)
add_custom_command (OUTPUT ${bc_cuda}
COMMAND ${LLVM_BC_GENERATOR}
"-I${OPTIX_INCLUDES}"
"-I${CUDA_INCLUDES}"
"-I${CMAKE_CURRENT_SOURCE_DIR}"
"-I${CMAKE_SOURCE_DIR}/src/liboslexec"
"-I${CMAKE_BINARY_DIR}/include"
"-I${PROJECT_SOURCE_DIR}/src/include"
"-I${PROJECT_SOURCE_DIR}/src/cuda_common"
"-I${OpenImageIO_INCLUDES}"
"-I${ILMBASE_INCLUDE_DIR}"
${ALL_OpenImageIO_INCLUDES}
${ALL_IMATH_INCLUDES}
${ALL_OPENEXR_INCLUDES}
"-I${Boost_INCLUDE_DIRS}"
${LLVM_COMPILE_FLAGS} ${CUDA_LIB_FLAGS} ${CLANG_MSVC_FIX}
${LLVM_COMPILE_FLAGS} ${CUDA_LIB_FLAGS} ${CLANG_MSVC_FIX} ${CUDA_TEXREF_FIX}
-D__CUDACC__ -DOSL_COMPILING_TO_BITCODE=1 -DNDEBUG -DOIIO_NO_SSE -D__CUDADEVRT_INTERNAL__
--language=cuda --cuda-device-only --cuda-gpu-arch=${CUDA_TARGET_ARCH}
-Wno-deprecated-register -Wno-format-security
-O3 -fno-math-errno -ffast-math -S -emit-llvm ${extra_clang_args}
-fno-math-errno -ffast-math ${CUDA_OPT_FLAG_CLANG} ${CLANG_FTZ_FLAG} -S -emit-llvm ${extra_clang_args}
${src} -o ${asm_cuda}
COMMAND "${LLVM_DIRECTORY}/bin/llvm-as" -f -o ${bc_cuda} ${asm_cuda}
COMMAND ${LLVM_AS_TOOL} -f -o ${bc_cuda} ${asm_cuda}
DEPENDS ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
@@ -113,8 +191,51 @@ function ( LLVM_COMPILE_CUDA llvm_src headers prefix llvm_bc_cpp_generated extra
MAKE_CUDA_BITCODE (${llvm_src} "" llvm_bc "${extra_clang_args}")
add_custom_command (OUTPUT ${llvm_bc_cpp}
COMMAND python "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
MAIN_DEPENDENCY ${llvm_src}
DEPENDS "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
function ( MAKE_EMBEDDED_CPP symbol_name output_cpp input_file )
add_custom_command ( OUTPUT ${output_cpp}
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py"
${input_file} ${output_cpp} "${symbol_name}"
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${linked_bc}
${input_file} ${exec_headers} ${PROJECT_PUBLIC_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
function ( CUDA_SHADEOPS_COMPILE prefix output_bc output_ptx input_srcs headers )
set (linked_bc "${CMAKE_CURRENT_BINARY_DIR}/linked_${prefix}.bc")
set (linked_ptx "${CMAKE_CURRENT_BINARY_DIR}/${prefix}.ptx")
set (${output_bc} ${linked_bc} PARENT_SCOPE )
set (${output_ptx} ${linked_ptx} PARENT_SCOPE )
foreach ( shadeops_src ${input_srcs} )
MAKE_CUDA_BITCODE ( ${shadeops_src} "_cuda" shadeops_bc "" )
list ( APPEND shadeops_bc_list ${shadeops_bc} )
endforeach ()
if (LLVM_NEW_PASS_MANAGER)
# There is no --nvptx-assign-valid-global-names flag for the new
# pass manager, but it appears to run this pass by default.
string(REPLACE "-O" "O" opt_tool_flags ${CUDA_OPT_FLAG_CLANG})
set (opt_tool_flags -passes="default<${opt_tool_flags}>")
else()
set (opt_tool_flags ${CUDA_OPT_FLAG_CLANG} --nvptx-assign-valid-global-names)
endif ()
# Link all of the individual LLVM bitcode files, and emit PTX for the linked bitcode
add_custom_command ( OUTPUT ${linked_bc} ${linked_ptx}
COMMAND ${LLVM_LINK_TOOL} ${shadeops_bc_list} -o ${linked_bc}
COMMAND ${LLVM_OPT_TOOL} ${opt_tool_flags} ${linked_bc} -o ${linked_bc}
COMMAND ${LLVM_LLC_TOOL} --march=nvptx64 -mcpu=${CUDA_TARGET_ARCH} ${linked_bc} -o ${linked_ptx}
# This script converts all of the .weak functions defined in the PTX into .visible functions.
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/process-ptx.py"
${linked_ptx} ${linked_ptx}
DEPENDS ${shadeops_bc_list} ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${input_srcs} ${headers}
"${CMAKE_SOURCE_DIR}/src/build-scripts/process-ptx.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
+100 -68
View File
@@ -49,14 +49,13 @@ if (BOOST_CUSTOM)
# Boost_VERSION, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES.
else ()
set (Boost_COMPONENTS filesystem system thread)
if (NOT USE_STD_REGEX)
list (APPEND Boost_COMPONENTS regex)
endif ()
# The FindBoost.cmake interface is broken if it uses boost's installed
# cmake output (e.g. boost 1.70.0, cmake <= 3.14). Specifically it fails
# to set the expected variables printed below. So until that's fixed
# force FindBoost.cmake to use the original brute force path.
set (Boost_NO_BOOST_CMAKE ON)
if (NOT DEFINED Boost_NO_BOOST_CMAKE)
set (Boost_NO_BOOST_CMAKE ON)
endif ()
checked_find_package (Boost REQUIRED
VERSION_MIN 1.55
COMPONENTS ${Boost_COMPONENTS}
@@ -83,31 +82,33 @@ checked_find_package (ZLIB REQUIRED) # Needed by several packages
# IlmBase & OpenEXR
checked_find_package (OpenEXR REQUIRED
VERSION_MIN 2.0
RECOMMEND_MIN 2.2
VERSION_MIN 2.4
RECOMMEND_MIN 2.5
RECOMMEND_MIN_REASON
"OpenEXR 2.2 is the oldest version our CI tests against, and the minimum that supports DWA compression"
"Even extremely critical patches are no longer supplied to < 2.5"
PRINT IMATH_INCLUDES
)
# Force Imath includes to be before everything else to ensure that we have
# the right Imath/OpenEXR version, not some older version in the system
# library. This shoudn't be necessary, except for the common case of people
# library. This shouldn't be necessary, except for the common case of people
# building against Imath/OpenEXR 3.x when there is still a system-level
# install version of 2.x.
include_directories(BEFORE ${IMATH_INCLUDES})
if (CMAKE_COMPILER_IS_CLANG AND OPENEXR_VERSION VERSION_LESS 2.3)
# clang C++ >= 11 doesn't like 'register' keyword in old exr headers
add_compile_options (-Wno-deprecated-register)
endif ()
if (MSVC AND NOT LINKSTATIC)
add_definitions (-DOPENEXR_DLL) # Is this needed for new versions?
endif ()
if (OPENEXR_VERSION VERSION_GREATER_EQUAL 2.5.99)
set (OSL_USING_IMATH 3)
else ()
set (OSL_USING_IMATH 2)
endif ()
# OpenImageIO
checked_find_package (OpenImageIO REQUIRED
VERSION_MIN 2.1.9)
VERSION_MIN 2.4
DEFINITIONS -DOIIO_HIDE_FORMAT=1)
checked_find_package (pugixml REQUIRED
VERSION_MIN 1.8)
@@ -115,7 +116,8 @@ checked_find_package (pugixml REQUIRED
# LLVM library setup
checked_find_package (LLVM REQUIRED
VERSION_MIN 7.0
VERSION_MIN 9.0
VERSION_MAX 18.9
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
@@ -128,27 +130,52 @@ add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}")
if (LLVM_NAMESPACE)
add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}")
endif ()
if (LLVM_VERSION VERSION_GREATER_EQUAL 10.0.0 AND
CMAKE_CXX_STANDARD VERSION_LESS 14)
message (FATAL_ERROR
"LLVM 10+ requires C++14 or higher (was ${CMAKE_CXX_STANDARD}). "
"To build against this LLVM ${LLVM_VERSION}, you need to set "
"build option CMAKE_CXX_STANDARD=14. The minimum requirements "
"for that are gcc >= 5.1, clang >= 3.5, Apple clang >= 7, "
"icc >= 7, MSVS >= 2017. "
"If you must use C++11, you need to build against LLVM 9 or earlier.")
endif ()
if (APPLE AND LLVM_VERSION VERSION_EQUAL 10.0.1 AND EXISTS "/usr/local/Cellar/llvm")
message (WARNING
"${ColorYellow}If you are using LLVM 10.0.1 installed by Homebrew, "
"please note that a known bug in LLVM may produce a link error where "
"it says it can't find libxml2.tbd. If you encounter this, please "
"try downgrading to LLVM 9: \n"
" brew uninstall llvm \n"
" brew install llvm@9 \n"
" export LLVM_DIRECTORY=/usr/local/opt/llvm@9 "
"try upgrading to a newer LLVM: \n"
" brew upgrade llvm \n"
"${ColorReset}\n")
endif ()
if (LLVM_VERSION VERSION_GREATER_EQUAL 15.0 AND CMAKE_COMPILER_IS_CLANG
AND ANY_CLANG_VERSION_STRING VERSION_LESS 15.0)
message (WARNING
"${ColorYellow}"
"If you are using LLVM 15 or higher, you should also use clang version "
"15 or higher, or you may get build errors.${ColorReset}\n")
endif ()
if (LLVM_VERSION VERSION_GREATER_EQUAL 16.0)
if (CMAKE_CXX_STANDARD VERSION_LESS 17)
message (WARNING "${ColorYellow}LLVM 16+ requires C++17 or higher. "
"Please set CMAKE_CXX_STANDARD to 17 or higher.${ColorReset}\n")
endif ()
if (CMAKE_COMPILER_IS_GNUCC AND (GCC_VERSION VERSION_LESS 7.0))
message (WARNING "${ColorYellow}LLVM 16+ requires gcc 7.0 or higher.${ColorReset}\n")
endif ()
if (CMAKE_COMPILER_IS_CLANG AND (CLANG_VERSION_STRING VERSION_LESS 5.0
OR APPLE_CLANG_VERSION_STRING VERSION_LESS 5.0))
message (WARNING "${ColorYellow}LLVM 16+ requires clang 5.0 or higher.${ColorReset}\n")
endif ()
endif ()
# Use opaque pointers starting with LLVM 16
if (${LLVM_VERSION} VERSION_GREATER_EQUAL 16.0)
set(LLVM_OPAQUE_POINTERS ON)
add_definitions (-DOSL_LLVM_OPAQUE_POINTERS)
else()
set(LLVM_OPAQUE_POINTERS OFF)
endif()
# Enable new pass manager for LLVM 16+
if (${LLVM_VERSION} VERSION_GREATER_EQUAL 16.0)
set(LLVM_NEW_PASS_MANAGER ON)
add_definitions (-DOSL_LLVM_NEW_PASS_MANAGER)
else()
set(LLVM_NEW_PASS_MANAGER OFF)
endif()
checked_find_package (partio)
@@ -158,60 +185,66 @@ find_python ()
# Qt -- used for osltoy
set (qt5_modules Core Gui Widgets)
if (OPENGL_FOUND)
list (APPEND qt5_modules OpenGL)
endif ()
option (USE_QT "Use Qt if found" ON)
checked_find_package (Qt5 COMPONENTS ${qt5_modules})
if (USE_QT AND NOT Qt5_FOUND AND APPLE)
message (STATUS " If you think you installed qt5 with Homebrew and it still doesn't work,")
message (STATUS " try: export PATH=/usr/local/opt/qt5/bin:$PATH")
if (USE_QT)
checked_find_package (Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets)
if (NOT Qt6_FOUND)
checked_find_package (Qt5 COMPONENTS Core Gui Widgets OpenGL)
endif ()
if (NOT Qt5_FOUND AND NOT Qt6_FOUND AND APPLE)
message (STATUS " If you think you installed qt with Homebrew and it still doesn't work,")
message (STATUS " try: export PATH=/usr/local/opt/qt/bin:$PATH")
endif ()
endif ()
# CUDA setup
if (USE_CUDA OR USE_OPTIX)
if (NOT CUDA_TOOLKIT_ROOT_DIR AND NOT $ENV{CUDA_TOOLKIT_ROOT_DIR} STREQUAL "")
set (CUDA_TOOLKIT_ROOT_DIR $ENV{CUDA_TOOLKIT_ROOT_DIR})
endif ()
if (OSL_USE_OPTIX)
if (USE_LLVM_BITCODE)
if (NOT CUDA_TOOLKIT_ROOT_DIR AND NOT $ENV{CUDA_TOOLKIT_ROOT_DIR} STREQUAL "")
set (CUDA_TOOLKIT_ROOT_DIR $ENV{CUDA_TOOLKIT_ROOT_DIR})
endif ()
if (NOT CUDA_FIND_QUIETLY OR NOT OptiX_FIND_QUIETLY)
message (STATUS "CUDA_TOOLKIT_ROOT_DIR = ${CUDA_TOOLKIT_ROOT_DIR}")
endif ()
if (NOT CUDA_FIND_QUIETLY OR NOT OptiX_FIND_QUIETLY)
message (STATUS "CUDA_TOOLKIT_ROOT_DIR = ${CUDA_TOOLKIT_ROOT_DIR}")
endif ()
checked_find_package (CUDA REQUIRED
VERSION_MIN 8.0
PRINT CUDA_INCLUDES)
set (CUDA_INCLUDES ${CUDA_TOOLKIT_ROOT_DIR}/include)
include_directories (BEFORE "${CUDA_INCLUDES}")
checked_find_package (CUDA REQUIRED
VERSION_MIN 9.0
RECOMMEND_MIN 11.0
RECOMMEND_MIN_REASON
"We don't actively test CUDA older than 11"
PRINT CUDA_INCLUDES)
set (CUDA_INCLUDES ${CUDA_TOOLKIT_ROOT_DIR}/include)
include_directories (BEFORE "${CUDA_INCLUDES}")
STRING (FIND ${LLVM_TARGETS} "NVPTX" nvptx_index)
if (NOT ${nvptx_index} GREATER -1)
message (FATAL_ERROR "NVPTX target is not available in the provided LLVM build")
endif()
STRING (FIND ${LLVM_TARGETS} "NVPTX" nvptx_index)
if (NOT ${nvptx_index} GREATER -1)
message (FATAL_ERROR "NVPTX target is not available in the provided LLVM build")
endif()
set (CUDA_LIB_FLAGS "--cuda-path=${CUDA_TOOLKIT_ROOT_DIR}")
set (CUDA_LIB_FLAGS "--cuda-path=${CUDA_TOOLKIT_ROOT_DIR}")
find_library(cuda_lib NAMES cudart
PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/x64"
REQUIRED)
set(CUDA_LIBRARIES ${cuda_lib})
find_library(cuda_lib NAMES cudart
PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"
REQUIRED)
set(CUDA_LIBRARIES ${cuda_lib})
# testrender & testshade need libnvrtc
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "10.0")
find_library(nvrtc_lib NAMES nvrtc
PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/x64"
REQUIRED)
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${nvrtc_lib})
# testrender & testshade need libnvrtc
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "10.0")
find_library(nvrtc_lib NAMES nvrtc
PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"
REQUIRED)
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${nvrtc_lib})
set(CUDA_EXTRA_LIBS ${CUDA_EXTRA_LIBS} dl)
set(CUDA_EXTRA_LIBS ${CUDA_EXTRA_LIBS} dl)
endif()
endif()
# OptiX setup
if (USE_OPTIX)
if (OSL_USE_OPTIX AND OSL_BUILD_TESTS)
checked_find_package (OptiX REQUIRED
VERSION_MIN 5.1)
VERSION_MIN 7.0)
include_directories (BEFORE "${OPTIX_INCLUDES}")
if (NOT USE_LLVM_BITCODE OR NOT USE_FAST_MATH)
message (FATAL_ERROR "Enabling OptiX requires USE_LLVM_BITCODE=1 and USE_FAST_MATH=1")
@@ -224,7 +257,6 @@ if (USE_CUDA OR USE_OPTIX)
target_compile_definitions (${TARGET} PRIVATE "-DPTX_PATH=\"${OSL_PTX_INSTALL_DIR}\"")
target_link_libraries (${TARGET} PRIVATE ${CUDA_LIBRARIES} ${CUDA_EXTRA_LIBS} ${OPTIX_LIBRARIES} ${OPTIX_EXTRA_LIBS})
endfunction()
else ()
function (osl_optix_target TARGET)
endfunction()
+8 -2
View File
@@ -12,6 +12,9 @@
# The executable may be disabled individually using any of the usual
# check_is_enabled() conventions (e.g. -DENABLE_<executable>=OFF).
#
# If -DENABLE_INSTALL_<executable>=OFF was specified, the target will be built
# (in the build area) but will not be installed.
#
# Usage:
#
# fancy_add_executable ([ NAME targetname ... ]
@@ -42,13 +45,16 @@ macro (fancy_add_executable)
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
endif ()
if (_target_DEFINITIONS)
target_compile_definitions (${_target_name} PRIVATE ${_target_DEFINITIONS})
target_compile_definitions (${_target_NAME} PRIVATE ${_target_DEFINITIONS})
endif ()
if (_target_LINK_LIBRARIES)
target_link_libraries (${_target_NAME} PRIVATE ${_target_LINK_LIBRARIES})
endif ()
set_target_properties (${_target_NAME} PROPERTIES FOLDER "Tools")
install_targets (${_target_NAME})
check_is_enabled (INSTALL_${_target_NAME} _target_NAME_INSTALL_enabled)
if (_target_NAME_INSTALL_enabled)
install_targets (${_target_NAME})
endif ()
else ()
message (STATUS "${ColorRed}Disabling ${_target_NAME} ${ColorReset}")
endif ()
+10 -9
View File
@@ -21,9 +21,14 @@
# MacOS/xcode in /usr/bin, which seems to be too old for the reentrant
# parser directives we use. Only do this if there is no BISON_ROOT
# specifying a particular Bison to use.
if (APPLE AND EXISTS /usr/local/opt
AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT})
find_program(BISON_EXECUTABLE NAMES /usr/local/opt/bison/bin/bison
if (APPLE AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT}
AND (EXISTS /usr/local/opt OR EXISTS /opt/homebrew
OR DEFINED ENV{HOMEBREW_PREFIX}))
find_program(BISON_EXECUTABLE
NAMES
ENV{HOMEBREW_PREFIX}/opt/bison/bin/bison
/opt/homebrew/opt/bison/bin/bison
/usr/local/opt/bison/bin/bison
DOC "path to the bison executable")
endif()
@@ -38,9 +43,7 @@ if ( FLEX_EXECUTABLE AND BISON_EXECUTABLE )
# XXX: This may be excessive now that OSL::pvt::ExtraArg is mangled into the function signature
add_definitions(-D${prefix}parse=${PROJ_NAMESPACE_V}_${prefix}parse)
if (VERBOSE)
message (STATUS "FLEX_BISON flex=${flexsrc} bison=${bisonsrc} prefix=${prefix}")
endif ()
message (VERBOSE "FLEX_BISON flex=${flexsrc} bison=${bisonsrc} prefix=${prefix}")
get_filename_component ( bisonsrc_we ${bisonsrc} NAME_WE )
set ( bisonoutputcxx "${CMAKE_CURRENT_BINARY_DIR}/${bisonsrc_we}.cpp" )
set ( bisonoutputh "${CMAKE_CURRENT_BINARY_DIR}/${bisonsrc_we}.h" )
@@ -54,9 +57,7 @@ if ( FLEX_EXECUTABLE AND BISON_EXECUTABLE )
get_filename_component ( FLEX_UP ${FLEX_EXECUTABLE} PATH )
get_filename_component ( FLEX_UP_UP ${FLEX_UP} PATH )
set ( FLEX_INCLUDE_DIR "${FLEX_UP_UP}/include" )
if (VERBOSE)
message (STATUS "Flex include dir = ${FLEX_INCLUDE_DIR}")
endif ()
message (VERBOSE "Flex include dir = ${FLEX_INCLUDE_DIR}")
include_directories ( ${FLEX_INCLUDE_DIR} )
# include_directories ( ${CMAKE_CURRENT_BINARY_DIR} )
+124
View File
@@ -0,0 +1,124 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# TODO: Use CMAKE_CURRENT_FUNCTION_LIST_DIR in cmake-3.17
set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_cpp extra_clang_args include_dirs)
message (VERBOSE "EMBED_LLVM_BITCODE_IN_CPP src_list=${src_list}")
foreach ( src ${src_list} )
get_filename_component ( src_we ${src} NAME_WE )
set ( src_asm "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.s" )
set ( src_bc "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.bc" )
message (VERBOSE "EMBED_LLVM_BITCODE_IN_CPP in=${src}")
message (VERBOSE "EMBED_LLVM_BITCODE_IN_CPP asm=${src_asm}")
message (VERBOSE "EMBED_LLVM_BITCODE_IN_CPP bc=${src_bc}")
list ( APPEND src_bc_list ${src_bc} )
get_property (CURRENT_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
message (VERBOSE "Current #defines are ${CURRENT_DEFINITIONS}")
foreach (def ${CURRENT_DEFINITIONS})
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-D${def}")
endforeach()
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} ${SIMD_COMPILE_FLAGS} ${CSTD_FLAGS} ${TOOLCHAIN_FLAGS})
# Avoid generating __dso_handle external global
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-fno-use-cxa-atexit")
# Figure out what program we will use to make the bitcode.
if (NOT LLVM_BC_GENERATOR)
find_program (LLVM_BC_GENERATOR NAMES "clang++"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_BC_GENERATOR)
message (FATAL_ERROR "You must have a valid llvm bitcode generator (clang++) somewhere.")
endif ()
message (VERBOSE "Using LLVM_BC_GENERATOR ${LLVM_BC_GENERATOR} to generate bitcode.")
if (NOT LLVM_AS_TOOL)
find_program (LLVM_AS_TOOL NAMES "llvm-as"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_LINK_TOOL)
find_program (LLVM_LINK_TOOL NAMES "llvm-link"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
# Fix specific problem I had on new Apple systems (e.g. Mavericks) with
# LLVM/libc++ installed -- for some reason, LLVM 3.4 wasn't finding it,
# so in that specific case, append another -I to point it in the right
# direction.
#if (APPLE AND ${LLVM_BC_GENERATOR} MATCHES ".*clang.*")
# exec_program ( "${LLVM_BC_GENERATOR}" ARGS --version OUTPUT_VARIABLE MY_CLANG_VERSION )
# string (REGEX REPLACE "clang version ([0-9][.][0-9]+).*" "\\1" MY_CLANG_VERSION "${MY_CLANG_VERSION}")
# if ((${MY_CLANG_VERSION} VERSION_GREATER "3.3")
# AND (EXISTS "/usr/lib/libc++.dylib")
# AND (EXISTS "/Library/Developer/CommandLineTools/usr/lib/c++/v1"))
# set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-I/Library/Developer/CommandLineTools/usr/lib/c++/v1")
# endif ()
#endif ()
list (TRANSFORM include_dirs PREPEND -I
OUTPUT_VARIABLE ALL_INCLUDE_DIRS)
if (NOT LLVM_OPAQUE_POINTERS AND ${LLVM_VERSION} VERSION_GREATER_EQUAL 15.0)
# Until we fully support opaque pointers, we need to disable
# them when using LLVM 15.
list (APPEND LLVM_COMPILE_FLAGS -Xclang -no-opaque-pointers)
endif ()
# Command to turn the .cpp file into LLVM assembly language .s, into
# LLVM bitcode .bc, then back into a C++ file with the bc embedded!
add_custom_command ( OUTPUT ${src_bc}
COMMAND ${LLVM_BC_GENERATOR}
${LLVM_COMPILE_FLAGS}
${ALL_INCLUDE_DIRS}
-DOSL_COMPILING_TO_BITCODE=1
-Wno-deprecated-register
# the following 2 warnings can be restored when all 3rd parties have fixed their export macros
# (dllimport attribute is not supported when compiling for Cuda and triggers a ton of warnings)
-Wno-ignored-attributes -Wno-unknown-attributes
-O3 -fno-math-errno -S -emit-llvm ${extra_clang_args}
-o ${src_asm} ${src}
COMMAND ${LLVM_AS_TOOL} -f -o ${src_bc} ${src_asm}
# Do NOT setup a MAIN_DEPENDENCY because only 1 may exist
# and we may have the several outputs dependent on the same source
DEPENDS ${src} ${exec_headers} ${PROJECT_PUBLIC_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endforeach ()
message (VERBOSE "^^^^^^^^^^^^^^^^^^^^^^^^^^" )
message (VERBOSE "src_bc_list: ${src_bc_list} ")
message (VERBOSE "^^^^^^^^^^^^^^^^^^^^^^^^^^" )
# Link all of the individual LLVM bitcode files
set ( linked_src_bc "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.bc" )
add_custom_command ( OUTPUT ${linked_src_bc}
COMMAND ${LLVM_LINK_TOOL} -internalize ${src_bc_list} -o ${linked_src_bc}
DEPENDS ${src_bc_list} ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src_list}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
# Serialize the linked bitcode into a CPP file
set ( src_bc_cpp "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.bc.cpp" )
add_custom_command ( OUTPUT ${src_bc_cpp}
COMMAND ${Python_EXECUTABLE} "${_THIS_MODULE_BASE_DIR}/../build-scripts/serialize-bc.py"
${linked_src_bc} ${src_bc_cpp} ${output_name}
DEPENDS "${_THIS_MODULE_BASE_DIR}/../build-scripts/serialize-bc.py" ${linked_src_bc}
${exec_headers} ${PROJECT_PUBLIC_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
# add generated .cpp with embedded bitcode to the list of sources
set ( ${list_to_append_cpp} ${${list_to_append_cpp}} ${src_bc_cpp} PARENT_SCOPE )
endfunction ( )
+39 -25
View File
@@ -23,7 +23,13 @@
# try to find llvm-config, with a specific version if specified
if (LLVM_DIRECTORY)
set (LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
list (APPEND LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
endif ()
if (LLVM_ROOT)
list (APPEND LLVM_CONFIG_PATH_HINTS "${LLVM_ROOT}/bin")
endif ()
if (DEFINED ENV{LLVM_ROOT})
list (APPEND LLVM_CONFIG_PATH_HINTS "$ENV{LLVM_ROOT}/bin")
endif ()
list (APPEND LLVM_CONFIG_PATH_HINTS
"/usr/local/opt/llvm/${LLVM_VERSION}/bin/"
@@ -58,9 +64,35 @@ execute_process (COMMAND ${LLVM_CONFIG} --includedir
execute_process (COMMAND ${LLVM_CONFIG} --targets-built
OUTPUT_VARIABLE LLVM_TARGETS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --system-libs
OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
############ HACK ##############
# On OSX, the Homebrew (and maybe any build) of LLVM 10.0 seems to have a
# link conflict with its dependency on the llvm libc++ and the system
# libc++, both can end up dynamically linked and lead to very subtle and
# frustrating behavior failures (in particular, osl's use of libclang will
# botch include file parsing any time LD_LIBRARY_PATH doesn't have the llvm
# libc++ first).
#
# It seems that this is not a problem when linking against the llvm and
# libclang libraries statically. So on apple and when LLVM 10+ are involved,
# just force that choice. Other than larger executables, it seems harmless,
# and in any case a better choice than this beastly bug.
#
# We can periodically revisit this with new version of LLVM, maybe they will
# fix things and we won't require this preemptive static linking.
if (APPLE AND LLVM_VERSION VERSION_GREATER_EQUAL 10.0)
set (LLVM_STATIC ON)
endif ()
if (LLVM_STATIC)
execute_process (COMMAND ${LLVM_CONFIG} --system-libs --link-static
OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
else ()
execute_process (COMMAND ${LLVM_CONFIG} --system-libs
OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
string (REPLACE " " ";" LLVM_SYSTEM_LIBRARIES "${LLVM_SYSTEM_LIBRARIES}")
find_library ( LLVM_LIBRARY
@@ -94,8 +126,9 @@ if (LLVM_VERSION VERSION_GREATER_EQUAL 9.0 AND (LLVM_SHARED_MODE STREQUAL "share
endif ()
foreach (COMPONENT clangFrontend clangDriver clangSerialization
clangParse clangSema clangAnalysis clangAST clangBasic
clangEdit clangLex)
clangParse clangSema clangAnalysis clangAST
clangASTMatchers clangBasic clangEdit clangLex
clangSupport clangAPINotes)
find_library ( _CLANG_${COMPONENT}_LIBRARY
NAMES ${COMPONENT}
PATHS ${LLVM_LIB_DIR})
@@ -105,25 +138,6 @@ foreach (COMPONENT clangFrontend clangDriver clangSerialization
endforeach ()
############ HACK ##############
# On OSX, the Homebrew (and maybe any build) of LLVM 10.0 seems to have a
# link conflict with its dependency on the llvm libc++ and the system
# libc++, both can end up dynamically linked and lead to very subtle and
# frustrating behavior failures (in particular, osl's use of libclang will
# botch include file parsing any time LD_LIBRARY_PATH doesn't have the llvm
# libc++ first).
#
# It seems that this is not a problem when linking against the llvm and
# libclang libraries statically. So on apple and when LLVM 10+ are involved,
# just force that choice. Other than larger executables, it seems harmless,
# and in any case a better choice than this beastly bug.
#
# We can periodically revisit this with new version of LLVM, maybe they will
# fix things and we won't require this preemptive static linking.
if (APPLE AND LLVM_VERSION VERSION_GREATER_EQUAL 10.0)
set (LLVM_STATIC ON)
endif ()
# shared llvm library may not be available, this is not an error if we use LLVM_STATIC.
if ((LLVM_LIBRARY OR LLVM_LIBRARIES OR LLVM_STATIC) AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
if (LLVM_STATIC)
+14 -158
View File
@@ -7,7 +7,7 @@
# I'm afraid this is a mess, due to needing to support a wide range of
# OpenEXR versions.
#
# For OpenEXR & Imath 3.0, this will establish the following imported
# For OpenEXR & Imath 3.x, this will establish the following imported
# targets:
#
# Imath::Imath
@@ -24,14 +24,12 @@
# IlmBase::IlmThread
# OpenEXR::IlmImf
#
# For all versions -- but for OpenEXR < 2.4 the only thing this sets --
# are the following CMake variables:
# For all version, the following CMake variables:
#
# OPENEXR_FOUND true, if found
# OPENEXR_INCLUDES directory where OpenEXR headers are found
# OPENEXR_LIBRARIES libraries for OpenEXR + IlmBase
# OPENEXR_VERSION OpenEXR version (accurate for >= 2.0.0,
# otherwise will just guess 1.6.1)
# OPENEXR_VERSION OpenEXR version
# IMATH_INCLUDES directory where Imath headers are found
# ILMBASE_INCLUDES directory where IlmBase headers are found
# ILMBASE_LIBRARIES libraries just IlmBase
@@ -48,8 +46,9 @@ find_package(OpenEXR CONFIG)
if (TARGET OpenEXR::OpenEXR AND TARGET Imath::Imath)
# OpenEXR 3.x if both of these targets are found
set (FOUND_OPENEXR_WITH_CONFIG 1)
if (NOT OpenEXR_FIND_QUIETLY)
message (STATUS "Found CONFIG for OpenEXR 3 (OPENEXR_VERSION=${OpenEXR_VERSION})")
message (STATUS "Found CONFIG for OpenEXR 3 (OpenEXR_VERSION=${OpenEXR_VERSION})")
endif ()
# Mimic old style variables
@@ -74,10 +73,12 @@ if (TARGET OpenEXR::OpenEXR AND TARGET Imath::Imath)
list (APPEND ILMBASE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif ()
elseif (TARGET OpenEXR::IlmImf AND TARGET IlmBase::Imath AND OPENEXR_VERSION VERSION_GREATER_EQUAL 2.4)
elseif (TARGET OpenEXR::IlmImf AND TARGET IlmBase::Imath AND
(OPENEXR_VERSION VERSION_GREATER_EQUAL 2.4 OR OpenEXR_VERSION VERSION_GREATER_EQUAL 2.4))
# OpenEXR 2.4 or 2.5 with exported config
set (FOUND_OPENEXR_WITH_CONFIG 1)
if (NOT OpenEXR_FIND_QUIETLY)
message (STATUS "Found CONFIG for OpenEXR 2 (OPENEXR_VERSION=${OpenEXR_VERSION})")
message (STATUS "Found CONFIG for OpenEXR 2 (OpenEXR_VERSION=${OpenEXR_VERSION})")
endif ()
# Mimic old style variables
@@ -102,155 +103,10 @@ elseif (TARGET OpenEXR::IlmImf AND TARGET IlmBase::Imath AND OPENEXR_VERSION VER
list (APPEND ILMBASE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif ()
else ()
# OpenEXR 2.x older versions without a config or whose configs we don't
# trust.
# Other standard issue macros
include (FindPackageHandleStandardArgs)
include (SelectLibraryConfigurations)
find_package (ZLIB REQUIRED)
# Link with pthreads if required
find_package (Threads)
if (CMAKE_USE_PTHREADS_INIT)
set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
endif ()
# Attempt to find OpenEXR with pkgconfig
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
if (NOT Ilmbase_ROOT AND NOT ILMBASE_ROOT
AND NOT DEFINED ENV{Ilmbase_ROOT} AND NOT DEFINED ENV{ILMBASE_ROOT})
pkg_check_modules(_ILMBASE QUIET IlmBase>=2.0.0)
endif ()
if (NOT OpenEXR_ROOT AND NOT OPENEXR_ROOT
AND NOT DEFINED ENV{OpenEXR_ROOT} AND NOT DEFINED ENV{OPENEXR_ROOT})
pkg_check_modules(_OPENEXR QUIET OpenEXR>=2.0.0)
endif ()
endif (PKG_CONFIG_FOUND)
# List of likely places to find the headers -- note priority override of
# ${OPENEXR_ROOT}/include.
# ILMBASE is needed in case ilmbase an openexr are installed in separate
# directories, like NixOS does
set (GENERIC_INCLUDE_PATHS
${OPENEXR_ROOT}/include
$ENV{OPENEXR_ROOT}/include
${ILMBASE_ROOT}/include
$ENV{ILMBASE_ROOT}/include
${_ILMBASE_INCLUDEDIR}
${_OPENEXR_INCLUDEDIR}
/usr/local/include
/usr/include
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/sw/include
/opt/local/include )
# Find the include file locations.
find_path (ILMBASE_INCLUDE_PATH OpenEXR/IlmBaseConfig.h
HINTS ${ILMBASE_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}
${GENERIC_INCLUDE_PATHS} )
find_path (OPENEXR_INCLUDE_PATH OpenEXR/OpenEXRConfig.h
HINTS ${OPENEXR_INCLUDE_DIR}
${GENERIC_INCLUDE_PATHS} )
# Try to figure out version number
if (DEFINED _OPENEXR_VERSION AND NOT "${_OPENEXR_VERSION}" STREQUAL "")
set (OPENEXR_VERSION "${_OPENEXR_VERSION}")
string (REGEX REPLACE "([0-9]+)\\.[0-9\\.]+" "\\1" OPENEXR_VERSION_MAJOR "${_OPENEXR_VERSION}")
string (REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" OPENEXR_VERSION_MINOR "${_OPENEXR_VERSION}")
elseif (EXISTS "${OPENEXR_INCLUDE_PATH}/OpenEXR/ImfMultiPartInputFile.h")
# Must be at least 2.0
file(STRINGS "${OPENEXR_INCLUDE_PATH}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_STRING .*$")
string (REGEX MATCHALL "[0-9]+[.0-9]+" OPENEXR_VERSION ${TMP})
file(STRINGS "${OPENEXR_INCLUDE_PATH}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_MAJOR .*$")
string (REGEX MATCHALL "[0-9]+" OPENEXR_VERSION_MAJOR ${TMP})
file(STRINGS "${OPENEXR_INCLUDE_PATH}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_MINOR .*$")
string (REGEX MATCHALL "[0-9]+" OPENEXR_VERSION_MINOR ${TMP})
else ()
# Assume an old one, predates 2.x that had versions
set (OPENEXR_VERSION 1.6.1)
set (OPENEXR_MAJOR 1)
set (OPENEXR_MINOR 6)
endif ()
# List of likely places to find the libraries -- note priority override of
# ${OPENEXR_ROOT}/lib.
set (GENERIC_LIBRARY_PATHS
${OPENEXR_ROOT}/lib
${ILMBASE_ROOT}/lib
${OPENEXR_INCLUDE_PATH}/../lib
${ILMBASE_INCLUDE_PATH}/../lib
${_ILMBASE_LIBDIR}
${_OPENEXR_LIBDIR}
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/sw/lib
/opt/local/lib
$ENV{PROGRAM_FILES}/OpenEXR/lib/static )
# message (STATUS "Generic lib paths: ${GENERIC_LIBRARY_PATHS}")
# Handle request for static libs by altering CMAKE_FIND_LIBRARY_SUFFIXES.
# We will restore it at the end of this file.
set (_openexr_orig_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
if (OpenEXR_USE_STATIC_LIBS)
if (WIN32)
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else ()
set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif ()
endif ()
# Look for the libraries themselves, for all the components.
# This is complicated because the OpenEXR libraries may or may not be
# built with version numbers embedded.
set (_openexr_components IlmThread IlmImf Imath Iex Half)
foreach (COMPONENT ${_openexr_components})
string (TOUPPER ${COMPONENT} UPPERCOMPONENT)
# First try with the version embedded
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY
NAMES ${COMPONENT}-${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}
${COMPONENT}
${COMPONENT}-${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}_d
${COMPONENT}_d
HINTS ${OPENEXR_LIBRARY_DIR} $ENV{OPENEXR_LIBRARY_DIR}
${GENERIC_LIBRARY_PATHS} )
endforeach ()
find_package_handle_standard_args (OpenEXR
REQUIRED_VARS ILMBASE_INCLUDE_PATH OPENEXR_INCLUDE_PATH
OPENEXR_IMATH_LIBRARY OPENEXR_ILMIMF_LIBRARY
OPENEXR_IEX_LIBRARY OPENEXR_HALF_LIBRARY
)
if (OPENEXR_FOUND)
set (OpenEXR_VERSION ${OPENEXR_VERSION})
set (ILMBASE_FOUND TRUE)
set (ILMBASE_INCLUDES ${ILMBASE_INCLUDE_PATH})
set (IMATH_INCLUDES ${ILMBASE_INCLUDE_PATH})
set (OPENEXR_INCLUDES ${OPENEXR_INCLUDE_PATH})
set (ILMBASE_INCLUDE_DIR ${ILMBASE_INCLUDE_PATH})
set (IMATH_INCLUDE_DIR ${ILMBASE_INCLUDE_PATH})
set (OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDE_PATH})
set (ILMBASE_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ILMBASE_PTHREADS} CACHE STRING "The libraries needed to use IlmBase")
set (OPENEXR_LIBRARIES ${OPENEXR_ILMIMF_LIBRARY} ${ILMBASE_LIBRARIES} ${ZLIB_LIBRARIES} CACHE STRING "The libraries needed to use OpenEXR")
set (FINDOPENEXR_FALLBACK TRUE)
endif ()
mark_as_advanced(
OPENEXR_ILMIMF_LIBRARY
OPENEXR_IMATH_LIBRARY
OPENEXR_IEX_LIBRARY
OPENEXR_HALF_LIBRARY
OPENEXR_VERSION)
# Restore the original CMAKE_FIND_LIBRARY_SUFFIXES
set (CMAKE_FIND_LIBRARY_SUFFIXES ${_openexr_orig_suffixes})
# Correct for how old OpenEXR config exports set the directory one
# level lower than we prefer it.
string(REGEX REPLACE "include/OpenEXR$" "include" ILMBASE_INCLUDES "${ILMBASE_INCLUDES}")
string(REGEX REPLACE "include/OpenEXR$" "include" IMATH_INCLUDES "${IMATH_INCLUDES}")
string(REGEX REPLACE "include/OpenEXR$" "include" OPENEXR_INCLUDES "${OPENEXR_INCLUDES}")
endif ()
+3 -7
View File
@@ -10,16 +10,12 @@
# PARTIO_LIBRARIES - library to link against
# PARTIO_FOUND - true if Partio was found.
# Hack! perfer a config if it can be found
# Hack! prefer a config if it can be found
find_package(partio CONFIG)
if (PARTIO_FOUND OR partio_FOUND)
if (VERBOSE)
message (STATUS "partio found via config")
endif ()
message (VERBOSE "partio found via config")
else ()
if (VERBOSE)
message (STATUS "partio falling back to FindPartio.cmake")
endif ()
message (VERBOSE "partio falling back to FindPartio.cmake")
find_path (PARTIO_INCLUDE_DIR NAMES Partio.h)
+1 -1
View File
@@ -16,7 +16,7 @@ find_package (pugixml CONFIG)
if (TARGET pugixml::pugixml)
# New pugixml (>= 1.11) has nice config files we can rely on and makes a
# pugixml::pugixml target.
message (STATUS "Found CONFIG for pugixml (>=1.11)")
message (VERBOSE "Found CONFIG for pugixml (>=1.11)")
set (PUGIXML_FOUND true)
set (pugixml_FOUND true)
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright Contributors to the Open Shading Languge project.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
+9 -16
View File
@@ -20,12 +20,9 @@ macro (find_python)
# Attempt to find the desired version, but fall back to other
# additional versions.
unset (_req)
if (USE_PYTHON)
set (_req REQUIRED)
if (PYTHON_VERSION)
list (APPEND _req EXACT)
endif ()
set (_req REQUIRED)
if (PYTHON_VERSION)
list (APPEND _req EXACT)
endif ()
checked_find_package (Python ${PYTHON_VERSION}
${_req}
@@ -46,11 +43,9 @@ macro (find_python)
if (NOT DEFINED PYTHON_SITE_DIR)
set (PYTHON_SITE_DIR "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_FOUND}/site-packages")
endif ()
if (VERBOSE)
message (STATUS " Python site packages dir ${PYTHON_SITE_DIR}")
message (STATUS " Python to include 'lib' prefix: ${PYLIB_LIB_PREFIX}")
message (STATUS " Python to include SO version: ${PYLIB_INCLUDE_SONAME}")
endif ()
message (VERBOSE " Python site packages dir ${PYTHON_SITE_DIR}")
message (VERBOSE " Python to include 'lib' prefix: ${PYLIB_LIB_PREFIX}")
message (VERBOSE " Python to include SO version: ${PYLIB_INCLUDE_SONAME}")
endmacro()
@@ -64,7 +59,7 @@ macro (setup_python_module)
set (target_name ${lib_TARGET})
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_COMPILER_ID} STREQUAL "Intel")
# Seems to be a problem on some systems, with pybind11 and python headers
set_property (SOURCE ${lib_SOURCES} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-macro-redefined ")
endif ()
@@ -77,7 +72,7 @@ macro (setup_python_module)
PRIVATE
pybind11::pybind11
Python::Python
${lib_LIBS} ${SANITIZE_LIBRARIES})
${lib_LIBS})
if (APPLE)
set_target_properties (${target_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif ()
@@ -98,9 +93,7 @@ macro (setup_python_module)
endif ()
if (PYLIB_INCLUDE_SONAME)
if (VERBOSE)
message(STATUS "Setting Py${lib_MODULE} SOVERSION to: ${SOVERSION}")
endif ()
message(VERBOSE "Setting Py${lib_MODULE} SOVERSION to: ${SOVERSION}")
set_target_properties(${target_name} PROPERTIES
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
SOVERSION ${SOVERSION} )
+214 -49
View File
@@ -1,4 +1,4 @@
# Copyright Contributors to the Open Shading Languge project.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
@@ -16,6 +16,10 @@ add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/testsuite/runtest.py")
add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest.py" )
set (OSL_TEST_BIG_TIMEOUT 800 CACHE STRING "Timeout for tests that take a long time")
# add_one_testsuite() - set up one testsuite entry
#
# Usage:
@@ -26,10 +30,12 @@ add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest
# [COMMAND cmd...] - optional override of launch command
# )
#
macro (add_one_testsuite testname testsrcdir)
cmake_parse_arguments (_tst "" "" "ENV;COMMAND" ${ARGN})
set (testsuite "${CMAKE_SOURCE_DIR}/testsuite")
set (testdir "${CMAKE_BINARY_DIR}/testsuite/${testname}")
file (MAKE_DIRECTORY "${testdir}")
if (NOT _tst_COMMAND)
set (_tst_COMMAND ${Python_EXECUTABLE} "${testsuite}/runtest.py" ${testdir})
if (MSVC_IDE)
@@ -45,7 +51,17 @@ macro (add_one_testsuite testname testsrcdir)
OSL_TESTSUITE_SRC=${testsrcdir}
OSL_TESTSUITE_CUR=${testdir}
)
file (MAKE_DIRECTORY "${testdir}")
# We need to suppress the leak sanitizer for "texture" tests, because of a
# minor leak inside OIIO (140 bytes! -- inconsequential) but which we
# can't use the suppressions list becuase the leaks come from calls made
# inside JITed code for which there is not a good stack trace. Any real
# leaks from OIIO or its dependencies we assume will be caught by lsan on
# the OIIO side, where there is no JIT to complicate things.
if (${testname} MATCHES "^texture" OR ${testname} MATCHES "gettextureinfo")
list (APPEND _tst_ENV ASAN_OPTIONS=detect_leaks=0:$ENV{ASAN_OPTIONS})
endif ()
add_test ( NAME ${testname} COMMAND ${_tst_COMMAND} )
# message ("Test -- env ${_tst_ENV} cmd ${_tst_COMMAND}")
set_tests_properties (${testname} PROPERTIES ENVIRONMENT "${_tst_ENV}" )
@@ -53,10 +69,14 @@ macro (add_one_testsuite testname testsrcdir)
# from piling up together, allocate a few cores each.
if (${testname} MATCHES "^render-")
set_tests_properties (${testname} PROPERTIES LABELS render
PROCESSORS 4 COST 10)
PROCESSORS 4 COST 10 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
# For debug builds, render tests are very slow, so give them a longer timeout
if (${testname} MATCHES "render-" AND ${CMAKE_BUILD_TYPE} STREQUAL Debug)
set_tests_properties (${testname} PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
# Some labeling for fun
if (${testname} MATCHES "^texture-")
if (${testname} MATCHES "^texture")
set_tests_properties (${testname} PROPERTIES LABELS texture
PROCESSORS 2 COST 4)
endif ()
@@ -68,9 +88,15 @@ macro (add_one_testsuite testname testsrcdir)
set_tests_properties (${testname} PROPERTIES LABELS optix)
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "10.0")
# Make sure libnvrtc-builtins.so is reachable
set_property (TEST ${testname} APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CUDA_TOOLKIT_ROOT_DIR}/lib64)
set_property (TEST ${testname} APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CUDA_TOOLKIT_ROOT_DIR}/lib64:$ENV{LD_LIBRARY_PATH})
endif()
endif ()
if (${testname} MATCHES "-reg")
# These are batched shading regression tests. Some are quite
# long, so give them a higher cost and timeout.
set_tests_properties (${testname} PROPERTIES LABELS batchregression
COST 15 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
endmacro ()
@@ -82,6 +108,8 @@ macro ( TESTSUITE )
set (_ats_LABEL "broken")
endif ()
set (test_all_optix $ENV{TESTSUITE_OPTIX})
set (test_all_batched $ENV{TESTSUITE_BATCHED})
set (test_all_rs_bitcode $ENV{TESTSUITE_RS_BITCODE})
# Add the tests if all is well.
set (ALL_TEST_LIST "")
set (_testsuite "${CMAKE_SOURCE_DIR}/testsuite")
@@ -98,9 +126,10 @@ macro ( TESTSUITE )
# Run the test unoptimized, unless it matches a few patterns that
# we don't test unoptimized (or has an OPTIMIZEONLY marker file).
if (NOT _testname MATCHES "^getattribute-shader" AND
NOT _testname MATCHES "optix" AND
NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
if (NOT _testname MATCHES "optix"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 )
endif ()
@@ -108,18 +137,32 @@ macro ( TESTSUITE )
# optimization, triggered by setting TESTSHADE_OPT env variable.
# Skip OptiX-only tests and those with a NOOPTIMIZE marker file.
if (NOT _testname MATCHES "optix"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 )
endif ()
# Run the same test again with aggressive -O2 runtime
# optimization, triggered by setting TESTSHADE_OPT env variable.
# Skip OptiX-only tests and those with a NOOPTIMIZE marker file.
if (NOT _testname MATCHES "optix"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE"
AND NOT EXISTS "${_testsrcdir}/NORSBITCODE")
add_one_testsuite ("${_testname}.opt.rs_bitcode" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_RS_BITCODE=1)
endif ()
# When building for OptiX support, also run it in OptiX mode
# if there is an OPTIX marker file in the directory.
# If an environment variable $TESTSUITE_OPTIX is nonzero, then
# run all tests with OptiX, even if there's no OPTIX marker.
if (USE_OPTIX
if (OSL_USE_OPTIX
AND (EXISTS "${_testsrcdir}/OPTIX" OR test_all_optix OR _testname MATCHES "optix")
AND NOT EXISTS "${_testsrcdir}/NOOPTIX"
AND NOT EXISTS "${_testsrcdir}/NOOPTIX-FIXME")
AND NOT EXISTS "${_testsrcdir}/NOOPTIX-FIXME"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
# Unoptimized
if (NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}.optix" "${_testsrcdir}"
@@ -128,53 +171,135 @@ macro ( TESTSUITE )
# and optimized
add_one_testsuite ("${_testname}.optix.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_OPTIX=1 )
if (NOT EXISTS "${_testsrcdir}/NOFUSED")
# and fused
add_one_testsuite ("${_testname}.optix.fused" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_OPTIX=1 TESTSHADE_FUSED=1 )
endif()
endif ()
endforeach ()
if (VERBOSE)
message (STATUS "Added tests: ${ALL_TEST_LIST}")
endif ()
endmacro ()
if (OSL_BUILD_BATCHED)
# When building for Batched support, also run it in Batched mode
# if there is an BATCHED marker file in the directory.
# If an environment variable $TESTSUITE_BATCHED is nonzero, then
# run all tests in Batched mode, even if there's no BATCHED marker.
if ((EXISTS "${_testsrcdir}/BATCHED" OR test_all_batched OR _testname MATCHES "batched")
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED-FIXME"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}.batched" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 TESTSHADE_BATCHED=1 )
endif ()
if ((EXISTS "${_testsrcdir}/BATCHED" OR test_all_batched OR _testname MATCHES "batched")
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED-FIXME"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.batched.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_BATCHED=1 )
endif ()
# When building for Batched support, optionally run a regression test
# if there is an BATCHED_REGRESSION marker file in the directory.
if ((EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
# optimized for right now
add_one_testsuite ("${_testname}.regress.batched.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 OSL_REGRESSION_TEST=BATCHED )
endif ()
if ((EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
AND EXISTS "${_testsrcdir}/NOOPTIMIZE")
# not optimized
add_one_testsuite ("${_testname}.regress.batched" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 OSL_REGRESSION_TEST=BATCHED )
endif ()
endif ()
# if there is an RS_BITCODE marker file in the directory.
if ((EXISTS "${_testsrcdir}/RS_BITCODE" OR test_all_rs_bitcode)
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/RS_BITCODE_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.rsbitcode.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_RS_BITCODE=1 )
endif ()
# if there is an RS_BITCODE_REGRESSION marker file in the directory.
if (EXISTS "${_testsrcdir}/RS_BITCODE_REGRESSION" OR (
test_all_rs_bitcode AND EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
# optimized for right now
add_one_testsuite ("${_testname}.regress.rsbitcode.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 OSL_REGRESSION_TEST=RS_BITCODE )
endif ()
endforeach ()
message (VERBOSE "Added tests: ${ALL_TEST_LIST}")
endmacro ()
macro (osl_add_all_tests)
# List all the individual testsuite tests here, except those that need
# special installed tests.
TESTSUITE ( aastep allowconnect-err and-or-not-synonyms arithmetic
array array-derivs array-range array-aassign
blackbody blendmath breakcont
TESTSUITE ( aastep allowconnect-err andor-reg and-or-not-synonyms
arithmetic area-reg arithmetic-reg
array array-reg array-copy-reg array-derivs array-range
array-aassign array-assign-reg array-length-reg
bitwise-and-reg bitwise-or-reg bitwise-shl-reg bitwise-shr-reg bitwise-xor-reg
blackbody blackbody-reg blendmath breakcont breakcont-reg
bug-array-heapoffsets bug-locallifetime bug-outputinit
bug-param-duplicate bug-peep bug-return
cellnoise closure closure-array color comparison
compile-buffer
calculatenormal-reg
cellnoise closure closure-array closure-layered closure-parameters closure-zero closure-conditional
color color-reg colorspace comparison
complement-reg compile-buffer compassign-bool compassign-reg
component-range
connect-components
control-flow-reg connect-components
const-array-params const-array-fill
debugnan debug-uninit
derivs derivs-muldiv-clobber
draw_string
error-dupes error-serialized
example-deformer
example-batched-deformer
exit exponential
fprintf
filterwidth-reg
for-reg format-reg fprintf
function-earlyreturn function-simple function-outputelem
function-overloads function-redef
geomath getattribute-camera getattribute-shader
getsymbol-nonheap gettextureinfo
group-outputs groupstring
geomath getattribute-camera getattribute-shader getattribute-shading
getsymbol-nonheap gettextureinfo gettextureinfo-reg
gettextureinfo-udim gettextureinfo-udim-reg
globals-needed
group-outputs groupdata-opt groupstring
hash hashnoise hex hyperb
ieee_fp if incdec initlist initops intbits isconnected isconstant
ieee_fp ieee_fp-reg if if-reg incdec initlist
initops initops-instance-clash
intbits isconnected
isconstant
layers layers-Ciassign layers-entry layers-lazy layers-lazyerror
layers-nonlazycopy layers-repeatedoutputs
linearstep
logic loop matrix message
length-reg linearstep
logic loop luminance-reg
matrix matrix-reg matrix-arithmetic-reg
matrix-compref-reg max-reg message message-no-closure message-reg
mergeinstances-duplicate-entrylayers
mergeinstances-nouserdata mergeinstances-vararray
metadata-braces miscmath missing-shader
metadata-braces min-reg miscmath missing-shader
mix-reg
named-components
nestedloop-reg
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
noise-gabor-reg
noise-generic
noise-perlin noise-simplex
pnoise pnoise-cell pnoise-gabor pnoise-perlin
noise-reg
normalize-reg
pnoise pnoise-cell pnoise-gabor
pnoise-generic pnoise-perlin
pnoise-reg
operator-overloading
opt-warnings
oslc-comma oslc-D oslc-M
@@ -188,7 +313,9 @@ macro (osl_add_all_tests)
oslc-err-outputparamvararray oslc-err-paramdefault
oslc-err-struct-array-init oslc-err-struct-ctr
oslc-err-struct-dup oslc-err-struct-print
oslc-err-type-as-variable
oslc-err-unknown-ctr
oslc-literalfold
oslc-pragma-warnerr
oslc-warn-commainit
oslc-variadic-macro
@@ -198,14 +325,31 @@ macro (osl_add_all_tests)
osl-imageio
paramval-floatpromotion
pragma-nowarn
printf-reg
printf-whole-array
raytype raytype-specialized reparam
raytype raytype-reg raytype-specialized regex-reg
reparam reparam-arrays testoptix-reparam
render-background render-bumptest
render-cornell render-furnace-diffuse
render-microfacet render-oren-nayar render-veachmis render-ward
select shortcircuit spline splineinverse splineinverse-ident
render-mx-furnace-burley-diffuse
render-mx-furnace-oren-nayar
render-mx-furnace-sheen
render-mx-burley-diffuse
render-mx-dielectric render-mx-dielectric-glass
render-mx-conductor
render-mx-generalized-schlick render-mx-generalized-schlick-glass
render-mx-layer
render-mx-sheen
render-microfacet render-oren-nayar
render-uv render-veachmis render-ward
render-raytypes
select select-reg shaderglobals shortcircuit
smoothstep-reg
spline spline-reg splineinverse splineinverse-ident
splineinverse-knots-ascend-reg splineinverse-knots-descend-reg
spline-boundarybug spline-derivbug
string
split-reg
string string-reg
struct struct-array struct-array-mixture
struct-err struct-init-copy
struct-isomorphic-overload struct-layers
@@ -213,40 +357,52 @@ macro (osl_add_all_tests)
struct-nested struct-nested-assign struct-nested-deep
ternary
testshade-expr
test-fmt-arrays test-fmt-fileprint
test-fmt-cxpf test-fmt-noise test-fmt-matrixcolor
test-fmt-stpf test-fmt-errorwarning test-fmt-errorwarning-repeats
texture-alpha texture-alpha-derivs
texture-blur texture-connected-options
texture-derivs texture-errormsg
texture-derivs texture-environment texture-errormsg
texture-environment-opts-reg
texture-firstchannel texture-interp
texture-missingalpha texture-missingcolor texture-simple
texture-missingalpha texture-missingcolor texture-opts-reg texture-simple
texture-smallderivs texture-swirl texture-udim
texture-width texture-withderivs texture-wrap
trace-reg
trailing-commas
transcendental-reg
transitive-assign
transform transformc trig typecast
transform transform-reg transformc transformc-reg trig trig-reg
typecast
unknown-instruction
userdata userdata-passthrough
userdata userdata-partial userdata-custom userdata-passthrough
vararray-connect vararray-default
vararray-deserialize vararray-param
vecctr vector
wavelength_color Werror xml )
vecctr vector vector-reg
wavelength_color wavelength_color-reg Werror xml xml-reg )
# Only run the ocio test if the OIIO we are using has OCIO support
if (OpenImageIO_HAS_OpenColorIO)
TESTSUITE ( ocio )
endif ()
# Add tests that require the Python bindings if we built them.
# We also exclude these tests if this is a sanitizer build on Linux,
# because the Python interpreter itself won't be linked with the right asan
# We also exclude these tests if this is a sanitizer build, because the
# Python interpreter itself won't be linked with the right asan
# libraries to run correctly.
if (USE_PYTHON AND NOT SANITIZE_ON_LINUX)
if (USE_PYTHON AND NOT SANITIZE)
TESTSUITE ( python-oslquery )
endif ()
# Only run field3d-related tests if the local OIIO was built with f3d support.
execute_process ( COMMAND ${OPENIMAGEIO_BIN} --help
# Only run openvdb-related tests if the local OIIO has openvdb support.
execute_process ( COMMAND ${OpenImageIO_LIB_DIR}/../bin/oiiotool --help
OUTPUT_VARIABLE oiiotool_help )
if (oiiotool_help MATCHES "field3d")
TESTSUITE ( texture-field3d )
if (oiiotool_help MATCHES "openvdb")
TESTSUITE ( texture3d texture3d-opts-reg )
endif()
# Only run pointcloud tests if Partio is found
if (PARTIO_FOUND)
if (partio_FOUND)
TESTSUITE ( pointcloud pointcloud-fold )
endif ()
@@ -255,4 +411,13 @@ macro (osl_add_all_tests)
TESTSUITE ( testoptix testoptix-noise example-cuda)
endif ()
# Some regression tests have a lot of combinations and may need more time to finish
if (OSL_BUILD_BATCHED)
set_tests_properties (arithmetic-reg.regress.batched.opt
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
set_tests_properties (transform-reg.regress.batched.opt
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
set_tests_properties (matrix-reg.regress.rsbitcode.opt
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endmacro()
+1 -3
View File
@@ -38,9 +38,7 @@ macro (docdeep_generate)
# ^^ syntax: prefix options one-arg-keywords multi-arg-keywords args
set (oslfile ${_docdeep_SOURCE})
set (mdfile "${_docdeep_NAME}.md.html")
if (VERBOSE)
message (STATUS "docdeep will make '${mdfile}'")
endif ()
message (VERBOSE "docdeep will make '${mdfile}'")
set (docdeep_program ${CMAKE_SOURCE_DIR}/src/build-scripts/docdeep.py)
add_custom_command (OUTPUT ${mdfile}
COMMAND ${Python_EXECUTABLE} ${docdeep_program} -d ${_docdeep_NAME} -s docs.css
+2556
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+32
View File
@@ -30,3 +30,35 @@ clean:
.PHONY: clean
doxygen:
echo "make doxygen TBD"
doxygen Doxyfile
touch doxygen.turd
doxygen.turd: doxygen
doxygenclean:
cmake -E remove_directory ../../build/doxygen
cmake -E remove doxygen.turd
cmake -E remove_directory ../../build/sphinx
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
SPHINXBUILDDIR = ../../build/sphinx
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
sphinx : Makefile conf.py
# @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(SPHINXBUILDDIR)" $(SPHINXOPTS) $(O)
$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(SPHINXBUILDDIR)" $(SPHINXOPTS)
sphinxpdf : Makefile conf.py
# @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(SPHINXBUILDDIR)" $(SPHINXOPTS) $(O)
$(SPHINXBUILD) -b latex "$(SOURCEDIR)" "$(SPHINXBUILDDIR)/latex" $(SPHINXOPTS)
$(MAKE) -C $(SPHINXBUILDDIR)/latex all-pdf
# $(SPHINXBUILD) -b latexpdf "$(SOURCEDIR)" "$(SPHINXBUILDDIR)/latex" $(SPHINXOPTS)
+307
View File
@@ -0,0 +1,307 @@
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
-->
(chap-bigpicture=)
# The Big Picture
This chapter attempts to lay out the major concepts of OSL,
define key nomenclature, and sketch out how individual shaders fit
together in the context of a renderer as a whole.
<!--
Other than the background material of this chapter, the rest of this
specification deals strictly with the language itself. In the future,
there will be separate (shorter) documents explaining in detail the use
of the language compiler, the renderer-side issues, the library and APIs
for how a renderer actually causes shaders to be evaluated, and so on.
-->
#### A shader is code that performs a discrete task
A shader is a program, with inputs and outputs, that performs a specific
task when rendering a scene, such as determining the appearance behavior
of a material or light. The program code is written in OSL, the
specification of which comprises this document.
For example, here is a simple `gamma` shader that performs
simple gamma correction on is `Cin` input, storing the result
in its output `Cout`:
```{image} Figures/shaderschematic.png
:width: 6.0in
```
The shader's inputs and outputs are called *shader parameters*.
Parameters have default values, specified in the shader code, but may
also be given new values by the renderer at runtime.
#### Shader instances
A particular shader may be used many times in a scene, on different
objects or as different layers in a shader group. Each separate use of
a shader is called a *shader instance*. Although all instances of
a shader are comprised of the same program code, each instance may
override any or all of its default parameter values with its own set of
*instance values*.
Below is a schematic showing a `gamma` instance with the `gam` parameter
overridden with an instance-specific value of `2.2`.
```{image} Figures/instanceschematic.png
:width: 200px
```
#### Shader groups, layers, and connections
A *shader group* is an ordered sequence of individual shaders called *layers*
that are executed in turn. Output parameters of an earlier-executed layer may
be *connected* to an input parameter of a later-executed layer. This connected
network of layers is sometimes called a *shader network* or a *shader DAG*
(directed acyclic graph). Of course, it is fine for the shader group to
consist of a single shader layer.
Below is a schematic showing how several shader instances may be
connected to form a shader group.
```{image} Figures/groupschematic.png
:width: 6.0in
```
And here is sample pseudo-code shows how the above network may be assembled
using an API in the renderer [^rendererapi]:
```
ShaderGroupBegin ()
Shader ("texturemap", /* shader name */
"tex1", /* layer name */
"string name", "rings.tx") /* instance variable */
Shader ("texturemap", "tex2", "string name", "grain.tx")
Shader ("gamma", "gam1", "float gam", 2.2)
Shader ("gamma", "gam2", "float gam", 1)
Shader ("wood", "wood1")
ConnectShaders ("tex1", /* layer name A */
"Cout", /* an output parameter of A */
"gam1", /* layer name B */
"Cin") /* Connect this layer of B to A's Cout */
ConnectShaders ("tex2", "Cout", "gam2", "Cin")
ConnectShaders ("gam1", "Cout", "wood1", "rings")
ConnectShaders ("gam2", "Cout", "wood1", "grain")
ShaderGroupEnd ()
```
Or, expressed as serialized text (as detailed in Chapter [](chap-shader-groups):
param string name "rings.tx" ;
shader "texturemap" "tex1" ;
param string name "grain.tx" ;
shader "texturemap" "tex2" ;
param float gam 2.2 ;
shader "gamma" "gam1" ;
param float gam 1.0 ;
shader "gamma" "gam2" ;
shader "wood" "wood1" ;
connect tex1.Cout gam1.Cin ;
connect tex2.Cout gam2.Cin ;
connect gam1.Cout wood1.rings ;
connect gam2.Cout wood1.grain ;
The rules for which data types may be connected are generally the same as
the rules determining which variables may be assigned to each other in OSL
source code:
* `source` and `dest` are the same data type.
* `source` and `dest` are both *triples* (`color`, `point`,
`vector`, or `normal`), even if they are not the same kind of triple.
* `source` is an `int` and `dest` is a `float`.
* `source` is a `float` or `int` and `dest` is a
*triple* (the scalar value will be replicated for all three components
of the triple).
* `source` is a single component of an aggregate type (e.g. one
channel of a `color`) and `dest` is a `float` (or vice versa).
#### Geometric primitives
The *scene* consists of primarily of geometric primitives,
light sources, and cameras.
*Geometric primitives* are shapes such as NURBS, subdivision surfaces,
polygons, and curves. The exact set of supported primitives may vary
from renderer to renderer.
Each geometric primitive carries around a set of named *primitive
variables* (also sometimes called *interpolated values* or
*user data*). Nearly all shape types will have, among their primitive
variables, control point positions that, when interpolated, actually
designate the shape. Some shapes will also allow the specification of
normals or other shape-specific data. Arbitrary user data may also be
attached to a shape as primitive variables. Primitive variables may be
interpolated in a variety of ways: one constant value per primitive, one
constant value per face, or per-vertex values that are interpolated
across faces in various ways.
If a shader input parameter's name and type match the name and type
of a primitive variable on the object (and that input parameters is
not already explicitly connected to another layer's output), the
interpolated primitive variable will override the instance value or
default.
#### Attribute state and shader assignments
Every geometric primitive has a collection of *attributes* (sometimes
called the *graphics state*) that includes its transformation
matrix, the list of which lights illuminate it, whether it is one-sided
or two-sided, shader assignments, etc. There may also be a long list of
renderer-specific or user-designated attributes associated with each
object. A particular attribute state may be shared among many geometric
primitives.
The attribute state also includes shader assignments --- the shaders or
shader groups for each of several *shader uses*, such as surface
shaders that designate how light reflects or emits from each point on a shape,
displacement shaders that can add fine detail to the shape on a
point-by-point basis, and volume shaders that describe how light is
scattered within a region of space. A particular renderer may have
additional shader types that it supports.
#### Shader execution state: parameter binding and global variables
When the body of code of an individual shader is about to execute, all
its parameters are *bound* --- that is, take on specific values
(from connections from other layers, interpolated primitive variables,
instance values, or defaults, in that order).
Certain state about the position on the surface where the shading is
being run is stored in so-called *global variables*. This includes
such useful data as the 3D coordinates of the point being shaded, the
surface normal and tangents at that point, etc.
Additionally, the shader may query other information about other
elements of the attribute state attached to the primitive, and
information about the renderer as a whole (rendering options, etc.).
#### Surface and volume shaders compute closures
Surface shaders (and volume shaders) do not by themselves compute the
final color of light emanating from the surface (or along a volume).
Rather, they compute a *closure*, which is a symbolic representation
describing the appearance of the surface, that may be more fully
evaluated later. This is in effect a parameterized formula, in which
some inputs have definite numeric values, but others may depend on
quantities not yet known (such as the direction from which the surface
is being viewed, and the amount of light from each source that is
arriving at the surface).
For example, a surface shader may compute its result like this:
color paint = texture ("file.tx", u, v);
Ci = paint * diffuse (N);
In this example, the variable `paint` will take on a specific numeric
value (by looking up from a texture map). But the `diffuse()` function
returns a `color closure`, not a definite numeric `color`. The output
variable `Ci` that represents the appearance of the surface is also a `color
closure`, whose numeric value is not known yet, except that it will be the
product of `paint`` and a Lambertian reflectance.
```{image} Figures/shaderexecschematic.png
```
The closures output by surface and volume shaders can do a number of
interesting things that a mere number cannot:
* Evaluate: given input and output light directions, compute the
proportion of light propagating from input to output.
* Sample: given just an input (or output) direction, choose a
scattering direction with a probability distribution that is
proportional to the amount of light that will end up going in various
directions.
* Integrate: given all lights and a view direction, compute
the total amount of light leaving the surface in the view direction.
* Recompute: given changes only to lights (or only to one light),
recompute the integrated result without recomputing other lights or
any of the calculations that went into assembling constants in the
closure (such as texture lookups, noise functions, etc.).
<!--
At present, we are assuming that the primitive closure functions (such
as `diffuse`, `ward`, `cooktorrance`, etc.) are all built
into the renderer, or implemented as renderer plugins. At a later time,
possibly in a later draft or maybe not until a truly later version of
the spec, we will fully spec it out so that closure primitive functions
may be written in OSL. But I fear that if we do it too soon,
we'll screw it up. But, yes, the eventual goal is for you to be able to
write these primitive functions in the language itself.
-->
#### Integrators
The renderer contains a number of *integrators* (selectable via the
renderer's API) which will combine the color closures computed by
surfaces and volumes with the light sources and view-dependent
information, to yield the amount of light visible to the camera.
```{image} Figures/integratorschematic.png
:width: 6.0in
```
<!--
At present, this document is written as if the integrators are built
into the renderer itself (or implemented as renderer plug-ins). At a
later time, we intend to make it possible for integrators themselves
to be written in OSL.
-->
#### Units
You can tell the renderer (through a global option) what units the scene
is using for distance and time. Then the shader has a built-in function
called `transformu()` that works a lot like `transform()`, but
instead of converting between coordinate systems, it converts among
units. For example,
```
displacement bumpy (float bumpdist = 1,
string bumpunits = "cm")
{
// convert bumpdist to common units
float spacing = transformu (bumpunits, "common", bumpdist);
float n = noise (P / spacing);
displace (n);
}
```
So you can write a shader to achieve some effect in real world units,
and that shader is totally reusable on another show that used different
modeling units.
It knows all the standard names like `cm`, `in`, `km`,
etc., and can convert among any of those, as well as between named
coordinate systems. For example,
```
float x = transformu ("object", "mm", 1);
```
now `x` is the number of millimeters per unit of "object" space on
that primitive.
[^rendererapi]: This document does not dictate a specific renderer API for
declaring shader instances, groups, and connections; the code above is just
an example of how it might be done.
+139
View File
@@ -0,0 +1,139 @@
#!/usr/bin/env python3
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from __future__ import absolute_import
import sys
import os
import shlex
import subprocess
# -- Project information -----------------------------------------------------
# The master toctree document.
master_doc = 'index'
default_role = 'code'
project = 'Open Shading Language'
copyright = 'Contributors to the Open Shading Language project'
author = 'Larry Gritz, editor'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
# LG addition: we search for it in the CMakeLists.txt so we don't need to
# keep modifying this file:
version = '0.0'
release = '0.0.0'
import re
version_regex = re.compile(r'set \(OSL_VERSION \"?((\d+\.\d+)\.\d+)\.\d+\"?\)')
f = open('../../CMakeLists.txt')
for l in f:
aa=re.search(version_regex, l)
if aa is not None:
release = aa.group(1)
version = aa.group(2)
break
f.close()
print ("OSL docs version = {}, release = {}".format(version, release))
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# add custom extensions directory to python path
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), 'extensions/sphinxtr'))
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../ext/breathe'))
#import html_mods
#import latex_mods
extensions = [
'breathe',
'myst_parser',
'sphinx_tabs.tabs',
]
myst_enable_extensions = [
# "amsmath",
"attrs_inline",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
# "html_admonition",
# "html_image",
# "linkify",
# "replacements",
# "smartquotes",
# "strikethrough",
# "substitution",
# "tasklist",
]
myst_heading_anchors = 3
# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
#html_theme = 'astropy-sphinx-theme'
# html_theme = 'sphinx_rtd_theme'
html_theme = 'furo'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Breathe options
breathe_projects = { "osl": "../../build/doxygen/xml" }
breathe_default_project = "osl"
breathe_domain_by_extension = {'h': 'cpp'}
breathe_default_members = ()
primary_domain = 'cpp'
highlight_language = 'cpp'
read_the_docs_build = os.getenv('READTHEDOCS') == 'True'
if read_the_docs_build:
print ("cwd =", os.getcwd())
print ("checkpoint -- rtd build")
if not os.path.exists('../../build/doxygen') :
os.makedirs ('../../build/doxygen')
print ("checkpoint 2 -- rtd build")
subprocess.call('echo "Calling Doxygen"', shell=True)
subprocess.call(['doxygen'], shell=True)
subprocess.call('echo "Ran Doxygen"', shell=True)
+31
View File
@@ -0,0 +1,31 @@
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
-->
# Copyright Notice
The code that implements Open Shading Language is licensed under the BSD
3-clause (also sometimes known as "new BSD" or "modified BSD") license.
```{include} ../../LICENSE.md
```
This manual and other text documentation about OSL are licensed under the
Creative Commons Attribution 4.0 International License.
```{image} figures/CC-BY.png
:alt: Beautiful Sunset
:width: 200px
:align: center
```
http://creativecommons.org/licenses/by/4.0/
OSL incorporates code from several other software packages with
compatible licenses. Copies of their licenses are reproduced here:
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/THIRD-PARTY.md
+709
View File
@@ -0,0 +1,709 @@
---
numbering:
heading_1: true
heading_2: true
heading_3: true
---
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
-->
(chap-types)=
# Data types
OSL provides several built-in simple data types for performing
computations inside your shader:
Type | Explanation
:---------- | :-----------
`int` | Integer data
`float` | Scalar floating-point data (numbers)
`point`, `vector`, `normal` | Three-dimensional positions, directions, and face orientations
`color` | Spectral reflectivities and light energy values
`matrix` | $4 \times 4$ transformation matrices
`string` | Character strings (such as filenames)
`void` | Indicates functions that do not return a value
In addition, you may create arrays and structures (much like C), and
OSL has a new type of data structure called a *closure*.
The remainder of this chapter will describe the simple and aggregate
data types available in OSL.
(sec-datatypes-int)=
## `int`
The basic type for discrete numeric values is `int`. The size of
the `int` type is renderer-dependent, but is guaranteed to be at
least 32 bits.
Integer constants are constructed the same way as in C. The following
are examples of `int` constants: `1`, `-2`, etc. Integer
constants may be specified as hexadecimal, for example: `0x01cf`.
Unlike C, no unsigned, bool, char, short, or long types are supplied.
This is to simplify the process of writing shaders (as well as
implementing shading systems).
The following operators may be used with `int` values (in order of
decreasing precedence, with each box holding operators of the same
precedence):
Operation | Result | Explanation
:--------- | :------ | :---
*int* `++` | `int` | post-increment by 1
*int* `--` | `int` | post-decrement by 1
| |
| |
`++` *int* | `int` | pre-increment by 1
`--` *int* | `int` | pre-decrement by 1
`-` *int* | `int` | unary negation
`~` *int* | `int` | bitwise complement (1 and 0 bits flipped)
`!` *int* | `int` | boolean `not' (1 if operand is zero, otherwise 0)
| |
| |
*int* `*` *int* | `int` | multiplication
*int* `/` *int* | `int` | division
*int* `%` *int* | `int` | modulus
| |
| |
*int* `+` *int* | `int` | addition
*int* `-` *int* | `int` | subtraction
| |
| |
*int* `<<` *int* | `int` | shift left
*int* `>>` *int* | `int` | shift right
| |
| |
*int* `<` *int* | `int` | 1 if the first value is less than the second, else 0
*int* `<=` *int* | `int` | 1 if the first value is less or equal to the second, else 0
*int* `>` *int* | `int` | 1 if the first value is greater than the second, else 0
*int* `>=` *int* | `int` | 1 if the first value is greater than or equal to the second, else 0
| |
| |
*int* `==` *int* | `int` | 1 if the two values are equal, else 0
*int* `!=` *int* | `int` | 1 if the two values are different, else 0
| |
| |
*int* `&` *int* | `int` | bitwise and
| |
| |
*int* `^` *int* | `int` | bitwise exclusive or
| |
| |
*int* `\|` *int* | `int` | bitwise or
| |
| |
*int* `&&` *int* | `int` | boolean and (1 if both operands are nonzero, otherwise 0)
| |
| |
*int* `\|\|` *int* | `int` | boolean or (1 if either operand is nonzero, otherwise 0)
Note that the `not`, `and`, and `or` keywords are synonyms for `!`, `&&`, and
`||`, respectively.
## `float`
The basic type for scalar floating-point numeric values is `float`. The
size of the `float` type is renderer-dependent, but is guaranteed to
be at least IEEE 32-bit float (the standard C `float` data type).
Individual renderer implementations may choose to implement `float` with
even more precision (such as using the C `double` as the underlying
representation).
Floating-point constants are constructed the same way as in C. The following
are examples of `float` constants: `1.0`, `2.48`, `-4.3e2`.
An `int` may be used in place of a `float` when used with any valid
`float` operator. In such cases, the `int` will be promoted to a
`float` and the resulting expression will be `float`. An `int` may
also be passed to a function that expects a `float` parameters, with the
`int` automatically promoted to `float`.
The following operators may be used with `float` values (in order of
decreasing precedence, with each box holding operators of the same
precedence):
Operation | Result | Explanation
:--------- | :------ | :---
*float* `++` | `float` | post-increment by 1
*float* `--` | `float` | post-decrement by 1
| |
| |
`++` *float* | `float` | pre-increment by 1
`--` *float* | `float` | pre-decrement by 1
`-` *float* | `float` | unary negation
| |
| |
*float* `*` *float* | `float` | multiplication
*float* `/` *float* | `float` | division
| |
| |
*float* `+` *float* | `float` | addition
*float* `-` *float* | `float` | subtraction
| |
| |
*float* `<` *float* | `int` | 1 if the first value is less than the second, else 0
*float* `<=` *float* | `int` | 1 if the first value is less or equal to the second, else 0
*float* `>` *float* | `int` | 1 if the first value is greater than the second, else 0
*float* `>=` *float* | `int` | 1 if the first value is greater than or equal to the second, else 0
| |
| |
*float* `==` *float* | `int` | 1 if the two values are equal, else 0
*float* `!=` *float* | `int` | 1 if the two values are different, else 0
## `color`
The `color` type is used to represent 3-component (RGB) spectral
reflectivities and light energies. You can assemble a
color out of three floats, either representing an RGB triple or some
other color space known to the renderer, as well as from a single
float (replicated for all three channels). Following are some examples:
```
color (0, 0, 0) // black
color ("rgb", .75, .5, .5) // pinkish
color ("hsv", .2, .5, .63) // specify in "hsv" space
color (0.5) // same as color (0.5, 0.5, 0.5)
```
All these expressions above return colors in "rgb" space. Even the third
example returns a color in "rgb" space --- specifically, the RGB value of the
color that is equivalent to hue 0.2, saturation 0.5, and value 0.63. In other
words, when assembling a color from components given relative to a specific
color space in this manner, there is an implied transformation to "rgb" space.
The following table lists the built-in color spaces.
% \caption{Names of color spaces.}\label{tab:colorspacenames}
| | |
:--------- | :------
`"rgb"` | The coordinate system that all colors start out in, and in which the renderer expects to find colors that are set by your shader.
`"hsv"` | hue, saturation, and value.
`"hsl"` | hue, saturation, and lightness.
`"YIQ"` | the color space used for the NTSC television standard.
`"XYZ"` | CIE *XYZ* coordinates.
`"xyY"` | CIE *xyY* coordinates.
Colors may be assigned another color or a `float` value (which sets
all three components to the value). For example:
```
color C;
C = color (0, 0.3, 0.3);
C = 0.5; // same as C = color (0.5, 0.5, 0.5)
```
Colors can have their individual components examined and set using the
`[]` array access notation. For example:
```
color C;
float g = C[1]; // get the green component
C[0] = 0.5; // set the red component
```
Components 0, 1, and 2 are red, green, and blue, respectively.
It is an error to access a color component with an index outside the
$[0...2]$ range.
Color variables may also have their components referenced using "named
components" that look like accessing structure fields named `r`, `g`, and `b`,
as synonyms for `[0]`, `[1]`, and `[2]`, respectively:
```
float green = C.g; // get the green component
C.r = 0.5; // set the red component
```
The following operators may be used with `color` values (in order of
decreasing precedence, with each box holding operators of the same
precedence):
Operation | Result | Explanation
:--------- | :------ | :---
*color* `[` *int* `]` | `float` | component access
| |
| |
`-` *color* | `color` | unary negation
| |
| |
*color* `*` *color* | `color` | component-wise multiplication
*color* `*` *float* | `color` | scaling
*float* `*` *color* | `color` | scaling
*color* `/` *color* | `color` | component-wise division
*color* `/` *float* | `color` | scaling
*float* `/` *color* | `color` | scaling
| |
| |
*color* `+` *color* | `color` | component-wise addition
*color* `-` *color* | `color` | component-wise subtraction
| |
| |
*color* `==` *color* | `int` | 1 if the two values are equal, else 0
*color* `!=` *color* | `int` | 1 if the two values are different, else 0
All of the binary operators may combine a scalar value (`float` or
`int`) with a `color`, treating the scalar if it were a `color` with
three identical components.
## Point-like types: `point`, `vector`, `normal`
Points, vectors, and normals are similar data types with identical
structures but subtly different semantics. We will frequently refer to
them collectively as the "point-like" data types when making
statements that apply to all three types.
A `point` is a position in 3D space. A `vector` has a length and
direction, but does not exist in a particular location. A `normal` is a
special type of vector that is *perpendicular* to a surface, and
thus describes the surface's orientation. Such a perpendicular vector
uses different transformation rules than ordinary vectors, as we will
describe below.
All of these point-like types are internally represented by three
floating-point numbers that uniquely describe a position or
direction relative to the three axes of some coordinate system.
All points, vectors, and normals are described relative to some
coordinate system. All data provided to a shader (surface information,
graphics state, parameters, and vertex data) are relative to one
particular coordinate system that we call the `"common"` coordinate
system. The `"common"` coordinate system is one that is convenient
for the renderer's shading calculations.
You can "assemble" a point-like type out of three floats using a
constructor:
```
point (0, 2.3, 1)
vector (a, b, c)
normal (0, 0, 1)
```
These expressions are interpreted as a point, vector, and normal
whose three components are the floats given, relative to "common" space .
As with colors, you may also specify the coordinates relative to some other
coordinate system:
```
Q = point ("object", 0, 0, 0);
```
This example assigns to `Q` the point at the origin of "object" space.
However, this statement does *not* set the components of `Q` to (0,0,0)!
Rather, `Q` will contain the "common" space coordinates of the point that is
at the same location as the origin of "object" space. In other words, the
point constructor that specifies a space name implicitly specifies a
transformation to "common" space. This type of constructor also can be used
for vectors and normals.
The choice of "common" space is renderer-dependent, though will usually
be equivalent to either "camera" space or "world" space.
Some computations may be easier in a coordinate system other than
"common" space. For example, it is much more convenient to apply a
"solid texture" to a moving object in its "object" space than in
"common" space. For these reasons, OSL provides a built-in
`transform()` function that
allows you to transform points, vectors, and normals
among different coordinate systems (see Section [](#sec-stdlib-geom)). Note,
however, that OSL does not keep track of which point variables are
in which coordinate systems. It is the responsibility of the shader
programmer to keep track of this and ensure that, for example, lighting
computations are performed using quantities in "common" space.
Several coordinate systems are predefined by name, listed in the following
table. Additionally, a renderer will probably allow for additional coordinate
systems to be named in the scene description, and these names may also be
referenced inside your shader to designate transformations.
% \caption{Names of predeclared geometric spaces.\label{tab:spacenames}}
`"common"`
: The coordinate system that all spatial values start out in and the one in
which all lighting calculations are carried out. Note that the choice of
`"common"` space may be different on each renderer.
`"object"`
: The local coordinate system of the graphics primitive (sphere, patch, etc.)
that we are shading.
`"shader"`
: The local coordinate system active at the time that the shader was
instanced.
`"world"`
: The world coordinate system designated in the scene.
`"camera"`
: The coordinate system with its origin at the center of the camera lens,
$x$-axis pointing right, $y$-axis pointing up, and $z$-axis pointing into
the screen.
`"screen"`
: The coordinate system of the camera's image plane (after perspective
transformation, if any). Coordinate (0,0) of `"screen"` space is looking
along the $z$-axis of "camera" space.
`"raster"`
: 2D pixel coordinates, with (0,0) as the upper-left
corner of the image and (xres, yres) as the lower-right corner.
`"NDC"`
: 2D Normalized Device Coordinates --- like raster space, but normalized so
that $x$ and $y$ both run from 0 to 1 across the whole image, with (0,0)
being at the upper left of the image, and (1,1) being at the lower right.
Point types can have their individual components examined and set using
the `[]` array access notation. For example:
```
point P;
float y = P[1]; // get the y component
P[0] = 0.5; // set the x component
```
Components 0, 1, and 2 are $x$, $y$, and $z$, respectively.
It is an error to access a point component with an index outside the
$[0...2]$ range.
Point-like variables may also have their components referenced using "named
components" that look like accessing structure fields named `x`, `y`, and `z`,
as synonyms for `[0]`, `[1]`, and `[2]`, respectively:
```
float yval = P.y; // get the [1] or y component
P.x = 0.5; // set the [0] or x component
```
The following operators may be used with point-like values (in order of
decreasing precedence, with each box holding operators of the same
precedence):
Operation | Result | Explanation
:--------- | :------ | :---
*ptype* `[` `int` `]` | `float` | component access
| |
| |
`-` *ptype* | `vector` | component-wise unary negation
| |
| |
*ptype* `*` *ptype* | *ptype* | component-wise multiplication
`float` `*` *ptype* | *ptype* | scaling of all components
*ptype* `*` `float` | *ptype* | scaling of all components
*ptype* `/` *ptype* | *ptype* | component-wise division
*ptype* `/` `float` | *ptype* | division of all components
`float` `/` *ptype* | *ptype* | division by all components
| |
| |
*ptype* `+` *ptype* | *ptype* | component-wise addition
*ptype* `-` *ptype* | `vector` | component-wise subtraction
| |
| |
*ptype* `==` *ptype* | `int` | 1 if the two values are equal, else 0
*ptype* `!=` *ptype* | `int` | 1 if the two values are different, else 0
The generic *ptype* is listed in places where any of `point`, `vector`, or
`normal` may be used.
All of the binary operators may combine a scalar value (`float` or `int`) with
a point-like type, treating the scalar if it were point-like with three
identical components.
## `matrix`
OSL has a `matrix` type that represents the transformation matrix required to
transform points and vectors between one coordinate system and another.
Matrices are represented internally by 16 floats (a $4 \times 4$ homogeneous
transformation matrix).
A `matrix` can be constructed from a single float or 16 floats. For example:
```
matrix zero = 0; // makes a matrix with all 0 components
matrix ident = 1; // makes the identity matrix
// Construct a matrix from 16 floats
matrix m = matrix (m00, m01, m02, m03, m10, m11, m12, m13,
m20, m21, m22, m23, m30, m31, m32, m33);
```
Assigning a single floating-point number $x$ to a matrix will result
in a matrix with diagonal components all being $x$ and other
components being zero (i.e., $x$ times the identity matrix).
Constructing a matrix with 16 floats will create the matrix whose
components are those floats, in row-major order.
Similar to point-like types, a `matrix` may be constructed in
reference to a named space:
```
// Construct matrices relative to something other than "common"
matrix q = matrix ("shader", 1);
matrix m = matrix ("world", m00, m01, m02, m03, m10, m11, m12, m13,
m20, m21, m22, m23, m30, m31, m32, m33);
```
The first form creates the matrix that transforms points from "shader" space
to "common" space. Transforming points by this matrix is identical to calling
`transform("shader", "common", ...)`. The second form prepends the
current-to-world transformation matrix onto the $4 \times 4$ matrix with
components $m_{0,0} ... m_{3,3}$. Note that although we have used `"shader"`
and `"world"` space in our examples, any named space is acceptable.
A matrix may also be constructed from the names of two coordinate
systems, yielding the matrix that transforms coordinates from the
first named space to the second named space:
```
matrix m = matrix ("object", "world");
```
The example returns the *object-to-world* transformation matrix.
Matrix variables can be tested for equality and inequality with the `==` and
`!=` boolean operators. Also, the `*` operator between matrices denotes
matrix multiplication, while `m1 / m2` denotes multiplying `m1` by the inverse
of matrix `m2`. Thus, a matrix can be inverted by writing `1/m`. In
addition, some functions will accept matrix variables as arguments, as
described in Section [](#chap-stdlibrary).
Individual components of a matrix variable may be set or accessed using array
notation, for example,
```
matrix M;
float x = M[row][col];
M[row][col] = 1;
```
Valid component indices are integers on $[0...3]$. It is an error to access a
matrix component with either a row or column outside this range.
The following operators may be used with matrices (in order of decreasing
precedence, with each box holding operators of the same precedence):
Operation | Result | Explanation
:--------- | :------ | :---
*matrix* `[` *int* `][` *int* `]` | `float` | component access (row, column)
| |
| |
`-` *matrix* | `matrix` | unary negation
| |
| |
*matrix* `*` *matrix* | `matrix` | matrix multiplication
*matrix* `*` *float* | `matrix` | component-wise scaling
*float* `*` *matrix* | `matrix` | component-wise scaling
*matrix* `/` *matrix* | `matrix` | multiply the first matrix by the *inverse of the second
*matrix* `/` *float* | `matrix` | component-wise division
*float* `/` *matrix* | `matrix` | multiply the *float* by the *inverse of the matrix
| |
| |
*matrix* `==` *matrix* | *int* | 1 if the two values are equal, else 0
*matrix* `!=` *matrix* | *int* | 1 if the two values are different, else 0
## `string`
The `string` type may hold character strings. The main application
of strings is to provide the names of files where textures may be
found. Strings can be compared using `==` and `!=`.
String constants are denoted by surrounding the characters with double
quotes, as in `"I am a string literal"`. As in C programs, string
literals may contain escape sequences such as `\n` (newline),
`\r` (carriage return), `\t` (tab), `\"` (double quote),
`\\` (backslash).
Two quote-quoted string literals that are separated only by whitespace
(spaces, tabs, or newlines) will be automatically concatenated into a
single string literal. In other words,
```text
"foo" "bar"
```
is exactly equivalent to `"foobar"`.
## `void`
The `void` type is used to designate a function that does not return a value.
No variable may have type `void`.
## Arrays
Arrays of any of the basic types are supported, provided that they
are 1D and statically sized, using the usual syntax for C-like languages:
```
float d[10]; // Declare an uninitialized array
float c[3] = { 0.1, 0.2, 3.14 }; // Initialize the array
float f = c[1]; // Access one element
```
The built-in function `arraylength()` returns the number of elements in an
array. For example:
```
float c[3];
int clen = arraylength(c); // should return 3
```
There are two circumstances when arrays do not need to have a declared
length --- an array parameter to a function, and a shader parameter that
is an array. This is indicated by empty array brackets, as shown in the
following example:
```
float sum (float x[])
{
float s = 0;
for (int i = 0; i < arraylength(x); ++i)
s += x[i];
return s;
}
```
It is allowed in OSL to copy an entire array at once using the `=` operator,
provided that the arrays contain elements of the same type and that the
destination array is at least as long as the source array. For example:
```
float array[4], anotherarray[4];
...
anotherarray = array;
```
## Structures
Structures are used to group several fields of potentially different types
into a single object that can be referred to by name. You may then use the
structure type name to declare structure variables as you would for any of the
built-in types. Structure elements are accessed using the `.` ("dot")
operator. The syntax for declaring and using structures is similar to C or
C++:
```
struct RGBA { // Define a structure type
color rgb;
float alpha;
};
RGBA col; // Declare a structure
r.rgb = color (1, 0, 0); // Assign to one field
color c = r.rgb; // Read from a structure field
RGBA b = { color(.1,.2,.3), 1 }; // Member-by-member initialization
```
You can use "constructor expressions" for a your struct types much like
you can construct built-in types like `color` or `point`:
> *struct_name* `(` *first_member_value*, ... `}`
For example,
```
RGBA c = RGBA(col,alpha); // Constructor syntax
RGBA add (RGBA a, RGBA b)
{
return RGBA (a.rgb+b.rgb, a.a+b.a); // return expression
}
// pass constructor expression as a parameter:
RGBA d = add (c, RGBA(color(.3,.4,.5), 0));
```
You may also use the *compound initializer list* syntax to construct a type
when it can be deduced from context which compound type is required. For
example, this is equivalent to the preceding example:
```
RGBA c = {col,alpha}; // deduce by what is being assigned to
RGBA add (RGBA a, RGBA b)
{
return { a.rgb+b.rgb, a.a+b.a }; // deduce by func return type
}
RGBA d = add (c, {{.3,.4,.5}, 0}); // deduce by expected arg type
```
It is permitted to have a structure field that is an array, as well as to have
an array of structures. But it is not currently permitted to "nest" arrays
(that is, to have an array of structs which contain members that are arrays).
```
struct A {
color a;
float b[4]; // Ok: struct may contain an array
};
RGBA vals[4]; // Ok: Array of structures
vals[0].a = 0;
A d[5]; // NO: Array of structures that contain arrays
```
## Closures
A `closure`is an expression or function call that will be stored, along
with necessary contextual information, to be evaluated at a later time.
In general, the type "`closure` *gentype*" behaves exactly like a
*gentype*, except that its numeric values may not be examined or
used for the duration of the shader's execution. For example, a
`color closure` behaves mostly like a color --- you can multiply it by a
scalar, assign it to a `color closure` variable, etc. --- but you may not
assign it to an ordinary `color` or examine its individual component's
numeric values.
It is legal to assign `0` to a closure, which is understood to mean setting it
to a *null closure* (even though in all other circumstances, assigning a
`float` to a `closure`would not be allowed).
At present, the only type of `closure`supported by OSL is the `color closure`,
and the only allowed operations are those that let you form a linear
combination of `color closure`'s. Additional closure types and operations are
reserved for future use.
Allowable operations on `color closure` include:
Operation | Result | Explanation
:--------- | :------ | :---
`-` *colorclosure* | `color closure` | unary negation
| |
| |
*color* `*` *colorclosure* | `color closure` | component-wise scaling
*colorclosure* `*` *color* | `color closure` | component-wise scaling
*float* `*` *colorclosure* | `color closure` | scaling
*colorclosure* `*` *float* | `color closure` | scaling
| |
| |
*colorclosure* `+` *colorclosure* | `color closure` | component-wise addition
% *colorclosure* `-` *colorclosure* | `color closure` | component-wise subtraction
+174
View File
@@ -0,0 +1,174 @@
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
-->
(chap-glossary)=
# Glossary
Attribute state
: The set of variables that determines all the properties (other than shape)
of a *geometric primitive* --- such as its local transformation matrix,
the surface, displacement, and volume shaders to be used, which light
sources illuminate objects that share the attribute state, whether
surfaces are one-sided or two-sided, etc. Basically all of the options
that determine the behavior and appearance of the primitives, that are not
determined by the shape itself or the code of the shaders. A single
attribute state may be shared among multiple geometric primitives. Also
sometimes called *graphics state*.
BSDF
: Bidirectional scattering distribution function, a function that describes
light scattering properties of a surface.
Built-in function
: A function callable from within a shader, where the implementation of the
function is provided by the renderer (as opposed to a function that the
shader author writes in OSL itself).
Closure
: A symbolic representation of a function to be called, and values for its
parameters, that are packaged up to be evaluated at a later time to yield
a final numeric value.
Connection
: A routing of the value of an *output parameter* of one *shader layer* to
an *input parameter* of another shader layer within the same *shader
group*.
Default parameter value
: The initial value of a *shader parameter*, if the renderer does not
override it with an *instance value*, an interpolated *primitive
variable*, or a *connection* to an output parameter of another *layer*
within the *group*. The default value of a shader parameter is explicitly
given in the code for that shader, and may either be a constant or a
computed expression.
EDF
: Emission distribution function, a function that describes the distribution
of light emitted by a light source.
Geometric primitive
: A single shape, such as a NURBS patch, a polygon or subdivision mesh, a
hair primitive, etc.
Global variables
: The set of "built-in" variables describing the common renderer inputs to
all shaders (as opposed to shader-specific parameters). These include
position (`P`), surface normal (`N`), surface tangents (`dPdu`, `dPdv`),
as well as standard radiance output (`Ci`). Different *shader types*
support different subsets of the global variables.
Graphics state
: See *attribute state*.
Group
: See *shader group*.
Input parameter
: A read-only *shader parameter* that provides a value to control a
shader's behavior. Can also refer to a read-only parameter to a
*shader function*.
Instance value
: A constant value that overrides a default parameter value for a
particular *shader instance*. Each instance of a shader may have a
completely different set of instance values for its parameters.
Layer
: See *shader layer*.
Output parameter
: A read/write *shader parameter* allows a shader to provide outputs beyond
the *global variables* such as `Ci`. Can also refer to a read/write
parameter to a *shader function*, allowing a function to provide more
outputs than a simple return value.
Primitive
: Usually refers to a *geometric primitive*.
Primitive variable
: A named variable, and values, attached to an individual geometric
primitive. Primitive variables may have one of several *interpolation
methods* --- such as a single value for the whole primitive, a value for
each piece or face of the primitive, or per-vertex values that are
smoothly interpolated across the surface.
% Public method
%
% : A function within a shader that has an entry point that is visible and
% directly callable by the renderer, as opposed to merely being called from
% other code within the shader. Public methods must be *top-level* (not
% defined within other functions) and must be preceded by the `public`
% keyword.
Shader
: A small self-contained program written in OSL, used to extend the
functionality of a renderer with custom behavior of materials and lights.
A particular shader may have multiple *shader instances* within a scene,
each of which has its unique *instance parameters*, transformation, etc.
Shader function
: A function written in OSL that may be called from within a shader.
Shader group
: An ordered collection of *shader instances* (individually called the
*layers* of a group) that are executed to collectively determine material
properties or displacement of a geometric primitive, emission of a light
source, or scattering properties of a volume. In addition to executing
sequentially, layers within a group may optionally have any of their input
parameters explicitly connected to output parameters of other layers
within the group in an acyclic manner (thus, sometimes being referred to
as a *shader network*).
Shader instance
: A particular reference to a *shader*, with a unique set of *instance
values*, transformation, and potentially other attributes. Each shader
instance is a separate entity, despite their sharing executable code.
Shader network
: See *shader group*.
Shader layer
: An individual *shader instance* within a *shader group*.
Shader parameter
: A named input or output variable of a shader. *Input parameters* provide
"knobs" that control the behavior of a shader; *output parameters*
additional provide a way for shaders to produce additional output beyond
the usual *global variables*.
Shading
: The computations within a renderer that implement the behavior and visual
appearance of materials and lights.
VDF
: Volumetric distribution function, a function that describes the scattering
properties of a volume.
+239
View File
@@ -0,0 +1,239 @@
---
numbering:
heading_1: true
heading_2: true
heading_3: true
---
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
-->
(chap-grammar)=
# Formal Language Grammar
This section gives the complete syntax of OSL. Syntactic structures that have
a name ending in `-opt` are optional. Structures surrounded by curly braces
`{ }` may be repeated 0 or more times. Text in `typewriter` face indicates
literal text. The $\epsilon$ character is used to indicate that it is
acceptable for there to be nothing (empty, no token).
#### Lexical elements
\<digit\> ::= "`0`" | "`1`" | "`2`" | "`3`" | "`4`" | "`5`" | "`6`" | "`7`" | "`8`" | "`9`"
\<digit-sequence\> ::= \<digit\> { \<digit\> }
\<hexdigit\> ::= \<digit\> | "`a`" | "`A`" | "`b`" | "`B`" | "`c`" | "`C`" | "`d`" | "`D`" | "`e`" | "`E`" | "`f`" | "`F`"
\<hexdigit-sequence\> ::= \<hexdigit\> { \<hexdigit\> }
\<integer\> ::= \<sign\> \<digit-sequence\>
<br>$~~~~~~~~~~$ | \<sign\> "`0x`" \<hexdigit-sequence\>
\<floating-point\> ::= \<digit-sequence\> \<decimal-part-opt\> \<exponent-opt\>
<br>$~~~~~~~~~~$ | \<decimal-part\> \<exponent-opt\>
\<decimal-part\> ::= '`.`' { \<digit\> }
\<exponent\> ::= '`e`' \<sign\> \<digit-sequence\>
\<sign\> ::= '`-`' | '`+`' | $\epsilon$
\<number\> ::= \<integer\>
<br>$~~~~~~~~~~$ | \<floating-point\>
\<char-sequence\> ::= { \<any-char\> }
\<stringliteral> ::= `"` \<char-sequence\> `"`
\<identifier\> ::= \<letter-or-underscore\> { \<letter-or-underscore-or-digit\> }
#### Overall structure
\<shader-file\> ::= { \<global-declaration\> }
\<global-declaration\> ::= \<function-declaration\>
<br>$~~~~~~~~~~$ | \<struct-declaration\>
<br>$~~~~~~~~~~$ | \<shader-declaration\>
\<shader-declaration\> ::= <br>$~~~~~~~~~~~~$ $~~~~~~~~~~$
\<shadertype\> \<identifier\> \<metadata-block-opt\>
"(" \<shader-formal-params-opt\> ")" "{" \<statement-list\> "}"
\<shadertype\> ::= "displacement" | "shader" | "surface" | "volume"
\<shader-formal-params\> ::= \<shader-formal-param\> { "," \<shader-formal-param\> }
\<shader-formal-param\> ::= \<outputspec\> \<typespec\> \<identifier\>
\<initializer\> \<metadata-block-opt\>
<br>$~~~~~~~~~~$ | \<outputspec\> \<typespec\> \<identifier\> \<arrayspec\>
\<initializer-list\> \<metadata-block-opt\>
\<metadata-block> ::= "[[" \<metadata\> { "," \<metadata\> } "]]"
\<metadata\> ::= \<simple-typespec\> \<identifier\> \<initializer\>
#### Declarations
\<function-declaration\> ::= <br>$~~~~~~~~~~~~$ \<typespec\> \<identifier\>
"(" \<function-formal-params-opt\> ")" "{" \<statement-list\> "}"
\<function-formal-params\> ::= \<function-formal-param\> { "," \<function-formal-param\> }
\<function-formal-param\> ::= \<outputspec\> \<typespec\> \<identifier\> \<arrayspec-opt\>
\<outputspec> ::= "output" | $\epsilon$
\<struct-declaration\> ::= "struct" \<identifier\> "{" \<field-declarations> "}" ";"
\<field-declarations\> ::= \<field-declaration\> { \<field-declaration\> }
\<field-declaration\> ::= \<typespec\> \<typed-field-list\> ";"
\<typed-field-list\> ::= \<typed-field\> { "," \<typed-field\> }
\<typed-field\> ::= \<identifier\> \<arrayspec-opt\>
\<local-declaration\> ::= \<function-declaration\>
<br>$~~~~~~~~~~$ | \<variable-declaration\>
\<arrayspec> ::= "[" \<integer\> "]"
<br>$~~~~~~~~~~$ | "[" "]"
\<variable-declaration\> ::= \<typespec\> \<def-expressions> ";"
\<def-expressions\> ::= \<def-expression\> { "," <def-expression\> }
\<def-expression\> ::= \<identifier\> \<initializer-opt\>
<br>$~~~~~~~~~~$ | \<identifier\> \<arrayspec\> \<initializer-list-opt\>
\<initializer\> ::= "=" \<expression\>
\<initializer-list\> ::= "=" \<compound-initializer\>
\<compound-initializer\> ::= "{" \<init-expression-list\> "}"
\<init-expression-list\> ::= \<init-expression\> { "," \<init-expression\> }
\<init-expression\> ::= \<expression\> | \<compound-initializer\>
\<typespec\> ::= \<simple-typename>
<br>$~~~~~~~~~~$ | "closure" \<simple-typename\>
<br>$~~~~~~~~~~$ | \<identifier-structname\>
\<simple-typename\> ::=
"color"
| "float"
| "matrix"
| "normal"
| "point"
| "string"
| "vector"
| "void"
#### Statements
\<statement-list\> ::= \<statement\> { \<statement\> }
\<statement\> ::=
\<compound-expression-opt\> ";"
<br>$~~~~~~~~~~$ | \<scoped-statements\>
<br>$~~~~~~~~~~$ | \<local-declaration\>
<br>$~~~~~~~~~~$ | \<conditional-statement\>
<br>$~~~~~~~~~~$ | \<loop-statement\>
<br>$~~~~~~~~~~$ | \<loopmod-statement\>
<br>$~~~~~~~~~~$ | \<return-statement\>
\<scoped-statements> ::= "{" \<statement-list-opt\> "}"
\<conditional-statement\> ::= <br>$~~~~~~~~~~~~$ "if" "(" \<compound-expression\> ")" \<statement\>
<br>$~~~~~~~~~~$ | "if" "(" \<compound-expression\> ")" \<statement\> "else" \<statement\>
\<loop-statement\> ::= <br>$~~~~~~~~~~~~$ "while" "(" \<compound-expression\> ")" \<statement\>
<br>$~~~~~~~~~~$ | "do" \<statement\> "while" "(" \<compound-expression\> ")" ";"
<br>$~~~~~~~~~~$ | "for" "(" \<for-init-statement-opt\> \<compound-expression-opt\> ";"
\<compound-expression-opt\> ")" \<statement\>
\<for-init-statement\> ::= <br>$~~~~~~~~~~~~$ \<expression-opt\> ";"
<br>$~~~~~~~~~~$ | \<variable-declaration\>
\<loopmod-statement\> ::= "break" ";"
<br>$~~~~~~~~~~$ | "continue" ";"
\<return-statement\> ::= "return" \<expression-opt\> ";"
#### Expressions
\<expression-list\> ::= \<expression\> { "," \<expression\> }
\<expression\> ::= \<number\>
<br>$~~~~~~~~~~$ | \<stringliteral\>
<br>$~~~~~~~~~~$ | \<type-constructor\>
<br>$~~~~~~~~~~$ | \<incdec-op\> \<variable-ref\>
<br>$~~~~~~~~~~$ | \<expression\> \<binary-op\> \<expression\>
<br>$~~~~~~~~~~$ | \<unary-op\> \<expression\>
<br>$~~~~~~~~~~$ | "(" \<compound-expression\> ")"
<br>$~~~~~~~~~~$ | \<function-call\>
<br>$~~~~~~~~~~$ | \<assign-expression\>
<br>$~~~~~~~~~~$ | \<ternary-expression\>
<br>$~~~~~~~~~~$ | \<typecast-expression\>
<br>$~~~~~~~~~~$ | \<variable-ref\>
<br>$~~~~~~~~~~$ | \<compound-initializer\>
\<compound-expression\> ::= \<expression\> { "," \<expression\> }
\<variable-lvalue\> ::= \<identifier\> \<array-deref-opt\> \<component-deref-opt\>
<br>$~~~~~~~~~~$ | \<variable_lvalue> "[" \<expression\> "]"
<br>$~~~~~~~~~~$ | \<variable_lvalue> "." \<identifier\>
\<variable-ref\> ::= \<identifier\> \<array-deref-opt\>
\<array-deref> ::= "[" \<expression\> "]"
\<component-deref> ::= "[" \<expression\> "]"
<br>$~~~~~~~~~~$ | "." \<component-field\>
\<component-field\> ::= "x" | "y" | "z" | "r" | "g" | "b"
\<binary-op> ::= "*" | "/" | "\%"
<br>$~~~~~~~~~~$ | "+" | "-"
<br>$~~~~~~~~~~$ | "<<" | ">>"
<br>$~~~~~~~~~~$ | "<" | "<=" | ">" | ">="
<br>$~~~~~~~~~~$ | "==" | "!="
<br>$~~~~~~~~~~$ | "&"
<br>$~~~~~~~~~~$ | "^"
<br>$~~~~~~~~~~$ | "|"
<br>$~~~~~~~~~~$ | "&&" | "and"
<br>$~~~~~~~~~~$ | "||" | "or"
\<unary-op> ::= "-" | "~" | "!" | "not"
\<incdec-op> ::= "++" | "--"
\<type-constructor\> ::= \<typespec> "(" \<expression-list\> ")"
\<function-call\> ::= \<identifier\> "(" \<function-args-opt\> ")"
\<function-args\> ::= \<expression\> { "," \<expression\> }
\<assign-expression\> ::= \<variable-lvalue\> \<assign-op\> \<expression\>
\<assign-op> ::= "=" | "*=" | "/=" | "+=" | "-=" | "&=" | "|=" | "^=" |
"<<=" | ">>="
\<ternary-expression\> ::= \<expression\> "?" \<expression\> ":" \<expression\>
\<typecast-expression\> ::= "(" \<simple-typename> ")" \<expression\>
+403
View File
@@ -0,0 +1,403 @@
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
-->
# Gross syntax, shader types, parameters
The overall structure of a shader is as follows:
> *optional-function-or-struct-declarations* \
\
shader-type shader-name `(` optional-parameters `)` \
`{` \
*statements* \
`}`
Note that *statements* may include function or structure definitions, local
variable declarations, or public methods, as well as ordinary execution
instructions (such as assignments, etc.).
## Shader types
Shader types include the following: `surface`, `displacement`, `light`,
`volume`, and generic `shader`. Some operations may only be performed from
within certain types of shaders (e.g., one may only call `displace()` or alter
`P` in a displacement shader), and some global variables may only be accessed
from within certain types of shaders (e.g., `dPdu` is not defined inside a
volume shader).
Following are brief descriptions of the basic types of shaders:
`surface` shaders
: Surface shaders determine the basic material properties of a surface and
how it reacts to light. They are responsible for computing a
`color closure` that describes the material, and optionally setting
other user-defined output variables. They may not alter
the position of the surface.
Surface shaders are written as if they describe the behavior of a single
point on the primitive, and the renderer will choose the positions
surface at which the shader must be evaluated.
Surface shaders also are used to describe emissive objects, i.e., light
sources. OSL does not need a separate shader type to describe lights.
`displacement` shaders
: Displacement shaders alter the position and shading normal (or,
optionally, just the shading normal) to make a piece of geometry appear
deformed, wrinkled, or bumpy. They are the only kind of shader that
is allowed to alter a primitive's position.
`volume` shaders
: Volume shaders describe how a participating medium (air, smoke, glass,
etc.) reacts to light and affects the appearance of objects on the other
side of the medium. They are similar to `surface` shaders, except
that they may be called from positions that do not lie upon (and are not
necessarily associated with) any particular primitive.
`shader` generic shaders
: Generic shaders are used for utility code, generic routines that may be
called as individual layers in a shader group. Generic shaders need not
specify a shader type, and therefore may be reused from inside surface,
displacement, or volume shader groups. But as a result, they may
not contain any functionality that cannot be performed from inside all
shader types (for example, they may not alter `P`, which can only be done
from within a displacement shader).
## Shader parameters
An individual shader has (optionally) many *parameters* whose
values may be set in a number of ways so that a single shader may have
different behaviors or appearances when used on different objects.
### Shader parameter syntax
Shader parameters are specified in the shader declaration, in
parentheses after the shader's name. This is much like the parameters
to an OSL function (or a function in C or similar languages),
except that shader parameters must have an *initializer*, giving a
default value for the parameter. Shader parameter default initializers
may be expressions (i.e., may be computed rather than restricted to
numeric constants), and are evaluated in the order that the parameters
are declared, and may include references to previously-declared
parameters. Formally, the grammar for a simple parameter
declaration looks like this:
> *type parametername* `=` *default-expression*
where *type* is one of the data types described in Chapter [](#chap-types),
*parametername* is the name of the parameter, and *default-expression* is a
valid expression (see Section [](#sec-expressions)). Multiple parameters are
simply separated by commas:
> *type1 parameter1* `=` *expr1* `,` *type2 parameter2* `=` *expr2* `,` ...
Fixed-length, one-dimensional array parameters are declared as follows:
> *type parametername* `[` *array-length* `] = {` *expr0* `,` *expr1* ... `}`
where *array-length* is a positive integer constant giving the length of the
array, and the initializer is a series of initializing expressions listed
between curly braces. The first initializing expression provides the
initializer for the first element of the array, the second expression provides
the initializer for the second element of the array, and so on. If the number
of initializing expressions is less than the length of the array, any
additional array elements will have undefined values.
Arrays may also be declared without a set length:
> *type parametername* `[ ] = {` *expr0* `,` *expr1* ... `}`
where no array length is found between the square brackets.
This indicates that the array's length will be determined based on
whatever is passed in --- a connection from the output of another shader
in the group (take on the length of that output), an instance value
(take on the length specified by the declaration of the instance value),
or a primitive variable (length determined by its declaration on the
primitive). If no instance value, primitive value, or connection is
supplied, then the number of initializing expressions will determine the
length, as well as the default values, of the array.
Structure parameters are also straightforward to declare:
> *structure-type parametername* `= {` *expr0* `,` *expr1* ... `}`
where *structure-type* is the name of a previously-declared `struct` type, and
the *expr* initializers correspond to each respective field within the
structure. An initializer of appropriate type is required for every field of
the structure.
### Shader output parameters
Shader parameters are, by default, read-only in the body of the
shader. However, special \emph{output parameters} may be altered
by execution of the shader. Parameters may be designated outputs
by use of the {\cf output} keyword immediately prior to the
type declaration of the parameter:
> `output` *type parametername* `=` *expr*
(Output parameters may be arrays and structures, but we will omit spelling out
the obvious syntax here.)
Output parameters may be connected to inputs of later-run shader layers in the
shader group, may be queried by later-run shaders in the group via message
passing (i.e., `getmessage()` calls), or used by the renderer as an output
image channel (in a manner described through the renderer's API).
### Shader parameter example
Here is an example of a shader declaration, with several parameters:
```
surface wood (
/* Simple params with constant initializers */
float Kd = 0.5,
color woodcolor = color (.7, .5, .3),
string texturename = "wood.tx",
/* Computed from an earlier parameter */
color ringcolor = 0.25 * woodcolor,
/* Fixed-length array */
color paintcolors[3] = { color(0,.25,0.7), color(1,1,1),
color(0.75,0.5,0.2) },
/* variable-length array */
int pattern[] = { 2, 4, 2, 1 },
/* output parameter */
output color Cunlit = 0
)
{
...
}
```
### How shader parameters get their values
Shader parameters get their values in the following manner,
in order of decreasing priority:
1. If the parameter has been designated by the renderer to be connected to an
output parameter of a previously-executed shader layer within the shader
group, that is the value it will get.
2. If the parameter matches the name and type of a per-primitive, per-face, or
per-vertex *primitive variable* on the particular piece of geometry
being shaded, the parameter's value will be computed by interpolating the
primitive variable for each position that must be shaded.
3. If there is no connection or primitive variable, the parameter may will
take on an *instance value*, if that parameter was given an explicit
per-instance value at the time that the renderer referenced the shader
(associating it with an object or set of objects).
4. If none of these overrides is present, the parameter's value will be
determined by executing the parameter initialization code in the shader.
This triage is performed per parameter, in order of declaration. So, for
example, in the code sample above where the default value for `ringcolor1 is a
scaled version of `woodcolor`, this relationship would hold whether
`woodcolor` was the default, an instance value, an interpolated primitive
value, or was connected to another layer's output. Unless `ringcolor` itself
was given an instance, primitive, or connection value, in which case that's
what would be used.
## Shader metadata
A shader may optionally include *metadata* (data *about* the
shader, as opposed to data *used by* the shader). Metadata may be
used to annotate the shader or any of its individual parameters with
additional hints or information that will be compiled into the shader
and may be queried by applications. A common use of metadata is to
specify user interface hints about shader parameters --- for example,
that a particular parameter should only take on integer values, should
have an on/off checkbox, is intended to be a filename, etc.
Metadata is specified inside double brackets `[[` and `]]` enclosing a
comma-separated list of metadata items. Each metadatum looks like a parameter
declaration --- having a data type, name, and initializer. However, metadata
may only be simple types or arrays of simple types (not structs or closures)
and their value initializers must be numeric or string constants (not computed
expressions).
Metadata about the shader as a whole is placed between the shader name
and the parameter list. Metadata about shader parameters are placed
immediately after the parameter's initializing expression, but before
the comma or closing parentheses that terminates the parameter
description.
Below is an example shader declaration showing the use of shader and
parameter metadata:
```
surface wood
[[ string help = "Realistic wood shader" ]]
(
float Kd = 0.5
[[ string help = "Diffuse reflectivity",
float min = 0, float max = 1 ]] ,
color woodcolor = color (.7, .5, .3)
[[ string help = "Base color of the wood" ]],
color ringcolor = 0.25 * woodcolor
[[ string help = "Color of the dark rings" ]],
string texturename = "wood.tx"
[[ string help = "Texture map for the grain",
string widget = "filename" ]],
int pattern = 0
[[ string widget = "mapper",
string options = "oak:0|elm:1|walnut:2" ]]
)
{
...
}
```
The metadata are not semantically meaningful; that is, the metadata does
not affect the actual execution of the shader. Most metadata exist only
to be embedded in the compiled shader and able to be queried by other
applications, such as to construct user interfaces for shader assignment
that allow usage tips, appropriate kinds of widgets for setting each
parameter, etc.
The choice of metadata and their meaning is completely up to the shader
writer and/or modeling system. However, we propose some conventions
below. These conventions are not intended to be comprehensive, nor to
meet all your needs --- merely to establish a common nomenclature for
the most common metadata uses.
The use of metadata is entirely optional on the part of the shader
writer, and any application that queries shader metadata is free to
honor or ignore any metadata it finds.
string label
: A short label to be displayed in the UI for this parameter. If not
present, the parameter name itself should be used as the widget label.
string help
: Help text that describes the purpose and use of the shader or parameter.
string page
: Helps to group related widgets by ``page.''
string widget
: The type of widget that should be used to adjust this parameter.
Suggested widget types:
"number"
: Provide a slider and/or numeric input. This is the default widget type for
`float` or `int` parameters. Numeric inputs also may be influenced by the
following metadata: `min`, `max`, `sensitivity`, `digits`, `slider`,
`slidermin`, `slidermax`, `slidercenter`, `sliderexponent`.
"string"
: Provide a text entry widget. This is the default widget type for
{\cf string} parameters.
"boolean"
: Provide a pop-up menu with "Yes" and "No" options. Works on strings
or numbers. With strings, "Yes" and "No" values are used, with
numbers, 0 and 1 are used.
"checkBox"
: A boolean widget displayed as a checkbox. Works on strings or
numbers. With strings, "Yes" and "No" values are used, with numbers,
0 and 1 are used.
"popup"
: A pop-up menu of literal choices. This widget further requires
parameter metadata `options` (a string listing the supported
menu items, delimited by the `|` character), and optionally `editable`
(an integer, which if nonzero means the widget should allow the
text field should be directly editable). For example:
```
string wrap = "default"
[[ string widget = "popup",
string options = "default|black|clamp|periodic|mirror" ]]
```
"mapper"
: A pop-up with associative choices (an enumerated type, if the values are
integers). This widget further requires parameter metadata `options`, a
`|`-delimited string with "key:value" pairs. For example:
```
int pattern = 0
[[ string widget = "mapper",
string options = "oak:0|elm:1|walnut:2" ]]
```
"filename"
: A file selection dialog.
"null"
: A hidden widget.
float min, float max, int min, int max
: The minimum and/or maximum value that the parameter may take on.
float sensitivity, int sensitivity
: The precision or step size for incrementing or decrementing the value
(within the appropriate min/max range).
int digits
: The number of digits to show (-1 for full precision).
int slider
: If nonzero, enables display of a slider sub-widget. This also respects the
following additional metadata that control the slider specifically:
`slidermin` (minimum value for the slider, `slidermax` (maximum value for
the slider), `slidercenter` (origin value for the slider), `sliderexponent`
(nonlinear slider options).
string URL
: Provides a URL for full documentation of the shader or parameter.
string units
: Gives the assumed units, if any, for the parameter (e.g., `cm`, `sec`,
`degrees`). The compiler or renderer may issue a warning if it detects that
this assumption is being violated (for example, the compiler can warn if a
`degrees` variable is passed as the argument to `cos`).
% We never implemented this:
% ## Public methods
%
% Ordinary (non-public) functions inside a shader may be called only from
% within the shader; they do not generate entry points that the renderer
% is aware of.
%
% A *public method* is a function that may be directly called by the
% renderer. Only top-level local functions of a shader --- that is,
% declared within the braces that define the local scope of the shader,
% but not within any other such function --- may be public methods. A
% function may be designated a public method by using the `public`
% keyword immediately before the function declaration:
%
% > *shader-type shader-name* `(` *params* `)` \
% > `{` \
% >
% > `public` *return-type* *function-name* `(` *optional-parameters* `)` \
% > `{` \
% > *statements* \
% > `}` \
% >
% > ...\\
% > `}`
% A given renderer will publish a list of public methods (names, arguments
% expected, and return value) that has particular meaning for that
% renderer. For example, a renderer may honor a public method
% ```
% public float maxdisplacement ()
% ```
% that computes and returns the maximum distance
% that a displacement shader will move any surface points.
% At some later point, this spec will recommend several ``standard''
% public methods that should be honored by most renderers.
+83
View File
@@ -0,0 +1,83 @@
..
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
.. image::
../../ASWF/logos/openshadinglanguage-stacked-Shaded.png
=============================================
Open Shading Language |version| Documentation
=============================================
.. only:: not latex
Editor: Larry Gritz, OSL Chief Architect
Open Shading Language (OSL) is a small but rich language for programmable
shading in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation.
Quick Links:
`GitHub repository <https://github.com/AcademySoftwareFoundation/OpenShadingLanguage>`_ /
`Developer mail list <https://lists.aswf.io/g/osl-dev>`_ /
`BSD License <https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/master/LICENSE.md>`_
------------
.. default-role:: code
.. only:: not latex
Contents
--------
.. toctree::
:caption: Introduction
copyr
.. toctree::
:caption: The OSL Language Specification
:maxdepth: 2
:numbered: 2
intro
bigpicture
lexical
grosssyntax
datatypes
syntax
stdlib
grammar
shadergroups
glossary
.. comment
This is where we would put additional documentation sections
in the future.
.. comment
Helpful links when writing documentation:
Doxygen docs:
http://www.doxygen.nl/manual/index.html
Sphinx docs:
http://www.sphinx-doc.org/en/master/contents.html
http://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cpp-domain
Breathe docs:
https://github.com/michaeljones/breathe
https://breathe.readthedocs.io/en/latest/directives.html
RST:
sphinx-tabs plugin for Sphinx:
https://pypi.org/project/sphinx-tabs/
https://sphinx-tabs.readthedocs.io/en/latest/#
+193
View File
@@ -0,0 +1,193 @@
<!--
Copyright Contributors to the Open Shading Language project.
SPDX-License-Identifier: CC-BY-4.0
SPDX-License-Identifier: BSD-3-Clause
-->
(chap-introduction=)
# Introduction
Welcome to Open Shading Language!
Open Shading Language (OSL) is a small but rich language for
programmable shading in advanced renderers and other applications, ideal
for describing materials, lights, displacement, and pattern generation.
OSL was developed by Sony Pictures Imageworks for use in its in-house
renderer used for feature film animation and visual effects. The
language specification was developed with input by other visual effects
and animation studios who also wish to use it.
OSL is distributed under the "New BSD" license. In short, you are free
to use it in your own applications, whether they are free or commercial,
open or proprietary, as well as to modify the OSL code as you desire,
provided that you retain the original copyright notices as described in
the license.
#### How OSL is different from other shading languages
OSL has syntax similar to C, as well as other shading languages.
However, it is specifically designed for advanced rendering algorithms
and has features such as radiance closures, BSDFs, and deferred ray
tracing as first-class concepts.
OSL has several unique characteristics not found in other shading
languages (certainly not all together). Here are some things you will
find are different in OSL compared to other languages:
* **Surface and volume shaders compute radiance closures, not final colors.**
OSL's surface and volume shaders compute an explicit symbolic
description, called a "closure," of the way a surface or volume
scatters light, in units of radiance. These radiance closures may be
evaluated in particular directions, sampled to find important
directions, or saved for later evaluation and re-evaluation.
This new approach is ideal for a physically-based renderer that
supports ray tracing and global illumination.
In contrast, other shading languages usually compute just a surface
color as visible from a particular direction. These old shaders are
"black boxes" that a renderer can do little with but execute to for
this once piece of information (for example, there is no effective way
to discover from them which directions are important to sample).
Furthermore, the physical units of lights and surfaces are often
underspecified, making it very difficult to ensure that shaders are
behaving in a physically correct manner.
* **Surface and volume shaders do not loop over lights or shoot rays.**
There are no "light loops" or explicitly traced rays in OSL surface
shaders. Instead, surface shaders compute a radiance closure
describing how the surface scatters light, and a part of the renderer
called an "integrator" evaluates the closures for a particular set of
light sources and determines in which directions rays should be
traced. Effects that would ordinarily require explicit ray tracing,
such as reflection and refraction, are simply part of the radiance
closure and look like any other BSDF.
Advantages of this approach include that integration and sampling may
be batched or re-ordered to increase ray coherence; a "ray budget" can
be allocated to optimally sample the BSDF; the closures may be used by
for bidirectional ray tracing or Metropolis light transport; and the
closures may be rapidly re-evaluated with new lighting without having
to re-run the shaders.
* **Surface and light shaders are the same thing.**
OSL does not have a separate kind of shader for light sources. Lights
are simply surfaces that are emissive, and all lights are area lights.
* **Transparency is just another kind of illumination.**
You don't need to explicitly set transparency/opacity variables in the
shader. Transparency is just another way for light to interact with a
surface, and is included in the main radiance closure computed by a
surface shader.
* **Renderer outputs (AOV's) are specified using "light path expressions."**
Sometimes it is desirable to output images containing individual
lighting components such as specular, diffuse, reflection, individual
lights, etc. In other languages, this is usually accomplished by
adding a plethora of "output variables" to the shaders that collect
these individual quantities.
OSL shaders need not be cluttered with any code or output variables to
accomplish this. Instead, there is a regular-expression-based
notation for describing which light paths should contribute to which
outputs. This is all done on the renderer side (though supported by
the OSL implementation). If you desire a new output, there is no need
to modify the shaders at all; you only need to tell the renderer the
new light path expression.
* **Shaders are organized into networks.**
OSL shaders are not monolithic, but rather can be organized into
networks of shaders (sometimes called a shader group, graph, or DAG),
with named outputs of some nodes being connected to named inputs of
other nodes within the network. These connections may be done
dynamically at render time, and do not affect compilation of
individual shader nodes. Furthermore, the individual nodes are
evaluated lazily, only their outputs are "pulled" from the later nodes
that depend on them (shader writers may remain blissfully unaware of
these details, and write shaders as if everything is evaluated
normally).
* **No "uniform" and "varying" keywords in the language.**
OSL shaders are evaluated in SIMD fashion, executing shaders on many
points at once, but there is no need to burden shader writers with
declaring which variables need to be uniform or varying.
In the open source OSL implementation, this is done both automatically
and dynamically, meaning that a variable can switch back and forth
between uniform and varying, on an instruction-by-instruction basis,
depending on what is assigned to it.
* **Arbitrary derivatives without grids or extra shading points.**
In OSL, you can take derivatives of any computed quantity in a shader,
and use arbitrary quantities as texture coordinates and expect correct
filtering. This does not require that shaded points be arranged in a
rectangular grid, or have any particular connectivity, or that any
"extra points" be shaded.
In the open source OSL implementation, this is possible because
derivatives are not computed by finite differences with neighboring
points, but rather by "automatic differentiation," computing partial
differentials for the variables that lead to derivatives, without any
intervention required by the shader writer.
## Acknowledgments
The original designer and project leader of OSL is Larry Gritz. Other early
developers of OSL are (in order of joining the project): Cliff Stein, Chris
Kulla, Alejandro Conty, Jay Reynolds, Solomon Boulos, Adam Martinez, Brecht
Van Lommel.
Additionally, many others have contributed features, bug fixes, and other
changes: Steve Agland, Shane Ambler, Martijn Berger, Farchad Bidgolirad,
Nicholas Bishop, Stefan Büttner, Matthaus G. Chajdas, Thomas Dinges, Henri
Fousse, Syoyo Fujita, Derek Haase, Sven-Hendrik Haase, John Haddon, Daniel
Heckenberg, Ronan Keryell, Elvic Liang, Max Liani, Bastien Montagne, Erich
Ocean, Mikko Ohtamaa, Alex Schworer, Sergey Sharybin, Stephan Steinbach,
Esteban Tovagliari, Alexander von Knorring, Roman Zulak. (Listed
alphabetically; if we've left anybody out, please let us know.)
We cannot possibly express sufficient gratitude to the managers at Sony
Pictures Imageworks who allowed this project to proceed, supported it
wholeheartedly, and permitted us to release the source, especially Rob
Bredow, Brian Keeney, Barbara Ford, Rene Limberger, and Erik Strauss.
Huge thanks also go to the crack shading team at SPI, and the brave
lookdev TDs and CG supes willing to use OSL on their shows. They served
as our guinea pigs, inspiration, testers, and a fantastic source of
feedback. Thank you, and we hope we've been responsive to your needs.
OSL was not developed in isolation. We owe a debt to the individuals
and studios who patiently read early drafts of the language
specification and gave us very helpful feedback and additional ideas,
and especially to those at other companies who have taken the risk of
incorporating OSL into their products and pipelines.
The open source OSL implementation incorporates or depends upon several
other open source packages:
- **OpenImageIO** Copyright Contributors to OpenImageIO.
http://openimageio.org
- **Imath** Copyright Contributors to Imath.
http://www.openexr.com
- **Boost** Copyright various authors. http://www.boost.org
- **LLVM** Copyright 2003-2010 University of Illinois at
Urbana-Champaign. http://llvm.org
These other packages are all distributed under licenses that allow them
to be used by and distributed with OSL.
+827 -126
View File
File diff suppressed because it is too large Load Diff
+122
View File
@@ -0,0 +1,122 @@
# Lexical structure
## Characters
Source code for OSL consists of ASCII or UTF-8 characters.
The characters for space, tab, carriage return, and linefeed are
collectively referred to as *whitespace*. Whitespace characters
delimit identifiers, keywords, or other symbols, but other than that
have no syntactic meaning. Multiple whitespace characters in a row
are equivalent to a single whitespace character.
Source code may be split into multiple lines, separated by end-of-line
markers (carriage return and/or linefeed). Lines may be of any length
and end-of-line markers carry no significant difference from other
whitespace, except that they terminate `//` comments and delimit
preprocessor directives.
## Identifiers
*Identifiers* are the names of variables, parameters, functions, and shaders.
In OSL, identifiers consist of one or more characters. The first character
may be a letter (`A`-`Z` or `a`-`z`) or underscore (`_`), and subsequent
characters may be letters, underscore, or numerals (`0`-`9`). Examples of
valid and invalid identifiers are:
```
opacity // valid
Long_name42 // valid - letters, underscores, numbers are ok
_foo // valid - ok to start with an underscore
2smart // invalid - starts with a numeral
bigbuck$ // invalid - $ is an illegal character
```
## Comments
*Comments* are text that are for the human reader of programs, and
are ignored entirely by the OSL compiler. Just like in C++, there
are two ways to designate comments in OSL:
1. Any text enclosed by `/*` and `*/` will be considered a comment, even if
the comment spans several lines.
```
/* this is a comment */
/* this is also
a comment, spanning
several lines */
```
2. Any text following `//`, up to the end of the current line, will be
considered a comment.
```
// This is a comment
a = 3; // another comment
```
## Keywords and reserved words
There are two sets of names that you may not use as identifiers:
keywords and reserved words.
The following are *keywords* that have special meaning in OSL:
and break closure color continue do else emit float for if illuminance
illuminate int matrix normal not or output point public return string
struct vector void while
The following are *reserved words* that currently have no special meaning in
OSL, but we reserve them for possible future use, or because they are
confusingly similar to keywords in related programming languages:
bool case catch char class const delete default double
enum extern false friend
goto inline long new operator private protected
short signed sizeof static
switch template this throw true try typedef
uniform union unsigned varying virtual volatile
## Preprocessor
Shader source code is passed through a standard C preprocessor as a
first step in parsing.
Preprocessor directives are designated by a hash mark `#` as the first
character on a line, followed by a preprocessor directive name. Whitespace may
optionally appear between the hash and the directive name.
OSL compilers support the full complement of C/C++ preprocessing directives,
including:
```
#define
#undef
#if
#ifdef
#ifndef
#elif
#else
#endif
#include
#pragma error "message"
#pragma once
#pragma osl ...
#pragma warning "message"
```
Additionally, the following preprocessor symbols will already be
defined by the compiler:
| | |
| ------ | :------- |
| `OSL_VERSION_MAJOR` | Major version (e.g., 1) |
| `OSL_VERSION_MINOR` | Minor version (e.g., 9) |
| `OSL_VERSION_PATCH` | Patch version (e.g., 3) |
| `OSL_VERSION` | Combined version number = `10000*major + 100*minor + patch` (e.g., 10903 for version 1.9.3) |

Some files were not shown because too many files have changed in this diff Show More