Compare commits

..
Author SHA1 Message Date
Larry Gritz f8b8689a9f CHANGES and docs touchups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-07 18:36:45 -08:00
Larry Gritz 1150400339 Rebuild docs
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-07 18:36:45 -08:00
Larry Gritz 96aea948c6 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-28 15:02:34 -08:00
Larry Gritz d77389c076 Update films and product list
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-12 15:34:46 -08:00
Larry Gritz 7f850e3f83 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-03 14:54:17 -08:00
Larry Gritz 51350fcd6a 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-03 13:56:55 -08:00
Larry Gritz de287acce5 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 16:07:07 -08:00
Larry Gritz 719ba879a8 Fix minor CI issues (#1439)
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 10:42:44 -08:00
Larry Gritz ef4e5de217 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-24 10:17:53 -08:00
Larry Gritz 5064bcac1a 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:28:57 -08:00
Larry Gritz d2059a76ad 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:28:57 -08:00
Larry Gritz a37d680997 CI: OCIO renamed their master branch to main (#1429)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:28:57 -08:00
Larry Gritz 64773dd26f Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:28:57 -08:00
Larry Gritz 48be5bd710 CHANGES for 1.11.16.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-01 16:48:32 -07:00
Larry Gritz 1d436e3bb3 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:49:46 -07:00
Luya Tshimbalanga eb67611896 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-10-24 15:49:46 -07:00
Larry Gritz b37cd9ce26 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:33:04 -07:00
Larry Gritz 1602f4c577 Bump some CI versions and prepare release 1.11.15.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-09-01 00:26:06 -07:00
Larry Gritz c3d0283c96 CI set touch-ups to latest versions
Proper test against VFX Platform 2022 using the latest ASWF docker
container. This includes Python 3.9.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-28 23:08:16 -07:00
Larry Gritz 5a38e3f820 Give Symbol virtual destructor to fix UB because of derived classes. (#1397)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-24 10:59:35 -07:00
Larry Gritz 85ba4de8b0 Move from some long-deprecated OIIO things to modern equivalents (#1388)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-04 20:37:17 -07:00
Larry Gritz 769b81ad69 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 14:35:48 -07:00
Larry Gritz d4aec84493 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-04 14:35:22 -07:00
Larry Gritz 78bbac517c Prep for release 1.1.13.2
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-01 23:04:38 -07:00
Larry Gritz bc66e85636 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 11:38:54 -07:00
Larry Gritz 8e65cd93dc 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:33:40 -07:00
Larry Gritz d009183a38 CI: have a clang11 test (#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:32:31 -07:00
Larry Gritz fa00aadcf3 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-01 12:44:52 -07:00
Larry Gritz d94cd2f90d CHANGES and set version for 1.11.14.1 patch release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-01 12:44:18 -07:00
Larry Gritz 98dd811d8c 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-26 13:08:49 -07:00
Larry Gritz 91d22ebe2f CI: Change our clang-format standard to clang11 (#1372)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-26 11:48:23 -07:00
Larry Gritz 58abcf917a Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-11 20:55:29 -07:00
Larry Gritz b1ee46279d CHANGES & docs fixes for release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 15:47:57 -07:00
Larry Gritz 4b0b8e2170 CI script typo kept mac from recognizing ARCH properly
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 11:44:33 -07:00
Larry Gritz 0befcc5bcf CI: fix OpenEXR version
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 11:44:33 -07:00
Euan Haahr ea95ba08e2 Various fixes for LLVM 12 compatibility (1351)
Removed use of options.PrintMachineCode since this has been removed as
of llvm 12. Converted uses of DebugLoc::get to DILocation::get since
it has been deprecated and removed as of llvm 12.

PrintMachine code will only be used if llvm is lower than version 12.
TODO: Needs to be re-added in the new way for LLVM12. (LG just doesn't
have time to figure this out right now.)

Pass adjustment as various things have been deprecated or changed
names. (LG)

Signed-off-by: Euan Haahr <euanhaahrmail2@gmail.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 11:44:33 -07:00
Larry Gritz b650340b8b Deal with possibly C++14 OIIO
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 11:44:33 -07:00
Larry Gritz 17378ae351 CI Mac fix: this was no longer necessary, and seemed to be problematic (#1366)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 11:44:33 -07:00
Larry Gritz c8727203d0 Use OpenImageIO targets
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 11:44:33 -07:00
Brecht Van Lommel ac4673868c 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:17:38 -07:00
John Haddon a2b97d056e OSLCompiler : Check for write errors (#1360)
Fixes #1352

Signed-off-by: John Haddon <jhaddon@cinesite.com>
2021-04-22 09:17:26 -07:00
Larry Gritz e13f3cd10f 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.

Fix wrong oiio used for oldest tests.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-19 15:44:06 -07:00
Larry Gritz 9ea03296a1 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:56:48 -07:00
Larry Gritz 30b2f90207 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-01 19:41:23 -07:00
Larry Gritz 301ca92cf2 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-01 19:38:51 -07:00
Larry Gritz 976f865ff4 CMake 3.20 compatibility (#1349)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-27 22:27:01 -07:00
Mads Drøschler e7326b3815 Updated vector2.h with a mod fuction: mod(vector2,vector2); (#1312)
This is useful when working with vec2 concepts through out shaders like UV data for example.
2021-03-22 15:11:55 -07:00
sandipshukla 571ac807d7 Fix unnecessary error messages to stderr for broken point clouds (#1333)
Signed-off-by: sandipshukla <>
2021-03-22 15:11:25 -07:00
Larry Gritz 91b223774b Update old Strutil::format to new fmt conventions (#1342, #1347)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-12 15:17:46 -08:00
Larry Gritz 91e95723fe Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-02 00:33:22 -08:00
Larry Gritz 4101b947f2 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-02 00:31:47 -08:00
Larry Gritz d1231ef0d6 Minor change for smooth build against upcoming Imath 3.0 (#1341)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-02 00:29:48 -08:00
Larry Gritz db350bdc75 Update CI idioms (#1338)
* Separate the CI stages into separate steps. (As was prototyped in OIIO)

* Combine the dependency-building scripts for CentOS and Ubuntu into a
  single script.

* Get rid of cruft related to the CI systems we no longer use (Appveyor,
  Travis, CircleCI).

* Get rid of some needless CI verbosity

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-02 00:29:48 -08:00
Clark Chen 424b8c37ae Fix incorrect hyperlink for boost (#1339)
Signed-off-by: Clark Chen <9372896+clarkchentw@users.noreply.github.com>
2021-02-28 11:45:41 -08:00
Larry Gritz deb4d4cbaf Typo prevented visibility hiding from happening properly (#1337)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-18 08:46:01 -08:00
Larry Gritz 0f943b2b68 CI: Use ccache + GitHub 'cache' action to greatly speed up CI runs (#1335)
This speeds up CI builds by 50% or more, for PRs that are minor
changes by reusing the compiled results from previous runs.  Most of
the remaining time cannot be squeezed down -- it's the instantiation
of docker containers and running the testsuite itself. But the build
(including of dependencies we build from scratch) is dramatically
faster.

At the same time, remove some commented-out test matrix cases. When/if
we re-enable those tests, we can add those back.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-10 15:47:16 -08:00
Larry Gritz 95d496296e Expunge Travis (#1334)
Kill the old travis CI

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-10 15:47:09 -08:00
Larry Gritz af885d09b8 Imath 3 support: ImathLimits.h no longer exists (#1332)
Also change some refs to std::abs rather than deprecated Imath functions.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-09 09:21:31 -08:00
Larry Gritz 9686ba2280 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-01 22:01:34 -08:00
Larry Gritz aecf26fbb9 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-01 17:50:19 -08:00
Larry Gritz cfee61a908 Remove unused variable that was warning (#1325) 2021-02-01 17:50:19 -08:00
Larry Gritz bfdc9635eb Transitioning repository to ASWF (#1329)
* Rename CLA files so they no longer say "draft."

* Change CONTRIBUTING.md to correctly describe the new CLA process,
  remove language related to the old SPI CLAs. Also some touchups to
  README.md.

* Update the project_intake.md to check of various things that we've
  completed.

* Change all references to the old imageworks GitHub URLs to the new
  ASWF ones. (This touches comments at the start of basically every file.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-01 17:50:19 -08:00
Larry Gritz d892268952 Touch up OpenEXR include finding 2020-12-27 20:11:44 -08:00
Larry Gritz 5ff2a58401 Switch from deprecated to current version of OIIO parallel_image call (#1317)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-27 17:02:58 -08:00
Larry Gritz c4cff77947 CI Mac: the uninstall of openssl no longer needed, now causes problems (#1315)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-20 14:09:09 -08:00
Larry Gritz b921acb284 Amend GOVERNANCE to list new member and changing affiliations (#1314)
* Nicolas Guiard is a new TSC member representing Isotropix

* Chris Kulla has had a new affiliation for a while now

* Clean up a bit of language left over from when this document was
  just a proposal.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-14 22:38:00 -08:00
Larry Gritz bbbf4249e7 Embed sizzle reel video in main README (#1307)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-10 21:52:19 -08:00
Larry Gritz 286335bb99 New ASWF preferred CLAs, based on Apache 2.0 CLAs (#1240)
* Replace CLA drafts with ASWF CLA 2.1

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-10 21:52:12 -08:00
John Mertic 5bd0240c4f Added mission statement in the charter, pulled from README (#1308)
Approved by the TSC by vote on 2020-12-10

Signed-off-by: John Mertic <jmertic@linuxfoundation.org>
2020-12-10 21:52:06 -08:00
Larry Gritz 89c6e67a32 CMake refactoring and subproject friendliness (#1304)
Modeled after recent similar changes in OIIO.

* Detect if OSL is being built as a subproject, and if so, set
  `OSL_IS_SUBPROJECT` (a.k.a. `${PROJECT_NAME}_IS_SUBPROJECT`).

* Move all the testing logic out of the main CMakeLists.txt (and a few
  testing-related macros from oiio_macros.cmake) and into a new
  src/cmake/testing.cmake.

* Move all of the packaging logic out of the main CMakeLists.txt and
  into a new src/cmake/packaging.cmake.

* Make all the testing and packaging inactive if this is being built
  as a subproject. Also disable the clang-format target for subprojects.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-03 11:00:12 -08:00
Larry Gritz 87dd733679 Bump version after release 2020-12-01 11:37:55 -08:00
Larry Gritz a7fd523488 CHANGES 2020-12-01 11:37:15 -08:00
Larry Gritz 3fc5c85d4b Extend checked_find_package with VERSION_MIN and VERSION_MAX (#1303)
Upon reading cmake docs mre carefully, it's clear that when you pass a
version to find_package (which does much of the heavy lifting inside
checked_find_package), it DOESN'T MEAN you want that version or
later. It means you want to find a version that is "compatible" with
the named version. The meaning of "compatible" is up to the package.
Some packages define it as being >= the requested version. Others
define it as being the same major release, or same major AND minor
release, or exact.

But generally speaking, we only care about the minimum version (e.g.,
"I want FooBar 8.0 or later"). And it's not guaranteed that is what
the package's compatibility will do. In fact, FooBar may be using
compatibility mode "SameMajorVersion", which will make our find of
FooBar succeed for 8.0, 8.1, 8.2, but if a user encounters FooBar 9.0,
our build will reject it, even though it's probably fine.

So I augmented our checked_find_package wrapper to take optional
VERSION_MIN to give the real minimum version, when that's the semantic
we really want (in which case we would omit the ordinary version
number used for the compatibility check and let VERSION_MIN do all the
work). There's also an optional (and usually omitted) VERSION_MAX that
you can use if you are sure that we must be less than a certain
version (the max is exclusive, you must be <, not <=, whereas the min
is inclusive >=).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-27 12:34:00 -08:00
Larry Gritz 62d1428b2b Various fixes to CI
* Backport CI and build script fixes from master

* Fix optix build test

* Use OIIO 2.0 for oldest test

* Set CMAKE_PREFIX_PATH for so we can find OIIO in the deformer test

* Correct includes on liboslnoise

* Skip deformer test for OIIO 2.0 -- I'm too lazy to make it work for
  OIIO version too old to have a proper exported cmake config

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-20 15:00:21 -08:00
Larry Gritz be00d9fab5 Build against OpenEXR 3.0 + Imath 3.0 (#1299)
As OpenEXR works toward their 3.0 release, which includes splitting
Imath (the vector, matrix, math, and 'half' stuff) out into a separate
repo, their top of tree master finally breaks our "bleeding edge"
build.

This is a little tricky, because now our support of this dependency is
attempting to span 3 eras: 3.0 with the full split of openexr from
imath, recent openexr+ilmbase 2.x that supplies reliable exported
cmake configs, and older 2.x that predates cmake configs. Eventually
we'll phase out older versions and clean up.

Fixes in this patch generally include:

* Add a new CI test of VFX2021 + openexr/imath master. (This will go away
  when 3.0 is released and that's what we use for the main 2021 case.)

* For new enough versions of OpenEXR, use the exported config file and
  targets, rather than the old style OPENEXR_LIBRARIES style variables.
  We have kind of a mixed idiom use because we're still supporting older
  versions that predate use of the config files.

* Deal with the fact that the Imath headers now live inside
  `<Imath/ImathBlah.h>` rather than `<OpenEXR/ImathBlah.h>`. But of
  course, you need to start including things just to find out the
  version. It's tricky.  The logic is to look at
  `<OpenEXR/OpenEXRConfig.h>` to determine the version we're dealing
  with, then include Imath stuff from one or the other depending on
  what we found. I rearranged quite a few includes to ensure that all
  this logic only happens in a couple spots and the rest gets included
  transitively. As it turns out, quite a few of our `#include`s of
  Imath headers were redundant.

* OSL's exported config needs to look for OpenEXR.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-19 10:04:11 -08:00
Larry Gritz 688abe475a Minor fixes to CI homebrew -- fix Mac failure, sync with OIIO
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-18 22:26:32 -08:00
Larry Gritz d3fea168e9 LoadMemoryCompiledShader: ensure return false on parse failure (#1302)
Most failures in this function returned false, but if it got as far as
parsing but failed that stage, it ended up returning true (success),
which is clearly wrong.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-18 17:25:34 -08:00
Larry Gritz 1f51b27e0a Fix compability break with OIIO 2.0 (from change 1295)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-10 14:44:55 -08:00
Larry Gritz 663ac3641c Bug fix: optimizer interaction with output param that also is userdata (#1295)
* Bug fix: optimizer interaction output param that also is userdata

There's a "pass-through parameter" idiom, where an output param gets
its initial value from an input, it gets modified by the shader, but
it's also an output.

If the modification is optimized away -- say, if it was originally
`theparam *= scale` and scale is 1 -- then it may be that you end up
with no ops in the shader that read from the parameter. If the
parameter was hooked up to userdata, then get_userdata will never be
called to retrieve the value (because it's usually lazy, only doing
the callback the first time it's needed), and so the output value of
parameter will be its parameter default value in the shader, NOT the
value of the interpolatd variable, which was never retrieved and
copied into it, and also that a shader consisting of *only* that
particular flavor of useparam is not marked as "does nothing" (thus
skipping any code generation at all).

This patch adjusts the logic somewhat so that if that output parameter
is connected downstream or is a renderer output, then we definitely
initialize it with a useparam op, even if it is otherwise apparently
not read from within the shader.

Added a new test for this specific case.

Also necessitated update to reference output of debug_uninit test,
only because the extra useparam op caused some of the instruction
numbering to change.

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

* testshade: allow arbitrary command line-specificed userdata

To ease testing, add `--userdata` command line option to testshade,
which constructs a ParamValueList that will be used to look up
"userdata" from the shader.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-09 17:35:46 -08:00
Larry Gritz 39e4e54d95 CI/Mac: fix broken tests involving oslquery (#1289)
The specific combination of Mac + Python 3.8/3.9 + the lastest
pybind11 release causes a crash in the testsuite/python-oslquery
test. It works on other platforms and with older versions of pybind11.

I've tried to understand exactly what's going wrong, and have come up
empty and can't justify spending more time on it. It's suspiciously
similar to several recently "fixed" pybind11+python interaction bugs,
I suspect there are a couple edge cases they missed and that it will
be fixed eventually in a future pybind11 release (or possibly a future
python patch, there does seem to be a problem that pybind11 uncovered
in the cpython code).

In the mean time, a slight rewrite of the loop avoids the problem for
the purposes of our CI tests.

Also a few adjustments to switch back to python 3.9 after some recent
Homebrew fixes that had made us revert back to 3.8 for a while.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-05 10:31:30 -08:00
Larry Gritz 229959f4f3 CI: build_opencolorio.bash: don't build gpu tests (#1288)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-05 10:31:24 -08:00
Larry Gritz 76b5614560 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 22:18:46 -08:00
Larry Gritz d922192fd4 CHANGES and docs for release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 12:21:57 -08:00
Larry Gritz f4f8322a80 Build: Require exact version if PYTHON_VERSION is specified (#1286)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 11:46:54 -08:00
Larry Gritz 5b9da095dc Let Mac CI use llvm 11 (#1287)
Also make the error artifact include CMake log files.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 11:42:19 -08:00
Larry Gritz 86687ea518 Fix OSL::assume_aligned for broken MSVS clause (#1285)
Bad cut and paste made this all wrong. Fix.

Also rename the template's AlignmentT -> Alignment to help reduce
confusion because we usually use the T end to indicate a template
parameter that's a type.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-31 15:05:34 -07:00
Larry Gritz d206a1f8b7 Adjust for recent OIIO master change -- ImageInput no longer has m_mutex (#1281)
While we're in there, get rid of some cruft that only applied to
OIIO 1.x.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-26 19:49:44 -07:00
Larry Gritz 83ad298c39 CI: Lock down on clang-format 10 for CI format check (#1278)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-23 10:33:22 -07:00
Larry Gritz a0683cf7e5 Work around GHCI Mac problem with homebrew openssl (#1277)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-23 10:33:15 -07:00
Declan RussellandDeclan Russell 72af1720a8 Add __CUDADEVRT_INTERNAL__ define to bitcode generation, needed to avoid duplicate cudaMalloc symbols with CUDA9+ (#1271)
Co-authored-by: Declan Russell <Declan.Russell@autodesk.com>
2020-10-19 18:10:13 -07:00
Larry Gritz 000534f74b Update ref output after recent OIIO change (#1273)
A change in OIIO master eliminated some spurious newlines in certain
error messages.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-17 16:04:18 -07:00
Larry Gritz 00c895fc64 Turn on clang-format for cpp files in testsuite (#1269) 2020-10-15 10:15:01 -07:00
Larry Gritz 4699b3dcdf Use 'final' liberally (#1260)
This is good for optimization, allowing "de-virtualization" of function
calls in cases when the compiler can be sure that there can be no further
subclassing.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-14 15:35:57 -07:00
Alex M. Wells d27b779b30 Optimization: Skip copying of output params to used layers. (1253)
Work by Alex Wells.

When generating the code to copy one layer's outputs to a downstream
layer's inputs, we can skip the copy entirely if we already know that
the downstream layer will not be run.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2020-10-14 15:35:57 -07:00
Larry Gritz 8f0dbac9cb Fix typo in example-deformer/CMakeLists.txt (#1268)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-14 15:35:57 -07:00
Alex M. Wells 3ba0f3bf83 Fix false positive in uninit test involving do-while loops (1252)
Work of Alex Wells.

Like we do already for "for" loops, when generating extra ops to test for
uninitialized values, "do-while" loops also need to skip testing of their
condition variable (which we know has not been written yet, under most
circumstances).

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2020-10-12 20:42:57 -07:00
Larry Gritz 854c95feb9 Bug fix: is_nonzero was only considering the first element (#1266)
No symptoms ever reported, but surely this is a typo bug.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-12 20:42:57 -07:00
Larry Gritz 06e8d24ebc Fix CI break (#2741) (#1265)
Repeat of https://github.com/OpenImageIO/oiio/pull/2741

One of our CI matrix entries recently started failing due to changes
in somethign on GHCI's Ubuntu image. Fix by switching this matrix
to use the appropriate ASWF docker image.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-12 13:41:16 -07:00
Larry Gritz 1215128c3d Fix status message I meant to remove earlier
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-12 10:49:21 -07:00
Larry Gritz 81bec68ca9 pugixml build fixes (#1262)
* Bring back the idea of a Findpugixml.cmake file because it turns out
  that (for pugixml <= 1.10) the exported config files are not reliable.

* Fix CI scripts to build PugiXML (with a few different versions). We
  previously were relying on the embedded version for all CI tests, which
  masked problems associated with using an external PugiXML.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-10 16:57:21 -07:00
Larry Gritz c77141ca6f Build system and CI touchups (#1247)
Periodic comparison of analogous build scripts in OIIO & OSL and
synchronize to ensure that my current most favored idioms are in both.

Split checked_find_package into separate file for easier
synchronization between projects.

Bumped OpenEXR versions to latest patches.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-10 16:48:14 -07:00
debaetsdandDieter De Baets 7ca797f3a5 Windows compile fixes (#1263)
* Added OSLEXECPUBLIC attributes to inner classes of LLVM_Util to fix
linker errors on MSVC

* do not include cxxabi.h on non GNUC platforms

* fixed windows linker issues

- Link with Version.lib (system lib) to prevent missing symbols in
  ClangDriver.lib
- Do not define OSL_EXPORTS for oslcomp/oslquery as they should import
  (not export)

Co-authored-by: Dieter De Baets <dieter.baets@unity3d.com>
2020-10-09 14:34:21 -07:00
marsupialandrzulak fa4f1c8479 Build against Cuda-11.0.1 and Optix 7.1 (#1232)
Co-authored-by: rzulak <rzulak@imageworks.com>
2020-10-05 16:05:02 -07:00
Larry Gritz 1f3a810554 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-01 20:48:04 -07:00
Larry Gritz ebc98bf5be CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-01 09:50:06 -07:00
Larry Gritz 1d744e5b54 Print more build/runtime info in stats and help message (#1258)
testshade --help or --runstats now print additional info about the
dependency versions, hardware capabilities enabled at build time, and
hardware capabilities detected at runtime. This should help debugging
of user experiences as an easy way to find out what OSL thinks it's
working with in terms of its environment.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-29 15:56:33 -07:00
Larry Gritz a7bfaf09d0 Fix typo in version string (#1257)
Extra char prevented the "release type" from being amended onto the
version string.

Also, change the OSL_INTRO_STRING to use the preferred convention
of "Open Shading Language" rather than "OpenShadingLanguage".

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-29 14:47:25 -07:00
timgrantandTim Grant 7802ac31f7 Explicitly set the OptiX pipeline stack size. (#1254)
Co-authored-by: Tim Grant <tgrant@nvidia.com>
2020-09-23 15:12:00 -07:00
Larry Gritz 9efefc74b9 python cleanup (#1249)
Switch from old cmake macros that were marked obsolete in cmake 3.12 to
the new FindPython.cmake module.

Instead of defaulting to python 2.7, default to whatever is found.
But user can still set PYTHON_VERSION variable to request a specific
one in case there are multiple.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-21 09:44:01 -07:00
Larry Gritz f6c4430870 Fix derivatives of texture calls when only Dalpha is needed (#1251)
Luke Emrose noticed that for texture calls that retrieved alpha, if
derivatives were later taken *only* of the alpha but not the main
color result of the texture call, those derivs would always end up 0,
the texture call not noticing that it needed to call the version of
texture that returns derivatives.

This patch provides a fix. It was a simple matter of it testing only
whether main result derivs were needed, when determining which variety
of texture must be called.

Curiously, this was already done correctly for texture3d!

Added testsuite/texture-alpha-derivs to test this specific situation.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-19 20:18:51 -07:00
Larry Gritz 3206f48898 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-01 12:08:10 -07:00
Larry Gritz 88c37b53fe Release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-01 11:22:21 -07:00
Larry Gritz 1907e0f062 CHANGES, prep for RC
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-29 15:13:57 -07:00
Larry Gritz bcd2162311 License file renames for uniformity and correct autodetection (#1246)
Rename LICENSE -> LICENSE.md for uniformity with other projects
and our own documentation.

Rename LICENSE-THIRD-PARTY.md -> THIRD-PARTY.md because it was
confusing GitHub's autodetection of the license (this makes many
tools, including third part such as the ASWF's landscape fail to
correctly categorize this project as BSD-3-Clause).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-27 13:06:34 -07:00
Larry Gritz 1afa2caeae Fix CI build break on Mac with LLVM 10.0.1 (#1245)
There's a bug in the current Homebrew llvm 10.0.1 where
it fails to link because of missing libxml2.tbd. It's fixed
upstream in LLVM, but not yet fixed in Homebrew. Hopefully
a subsequent 10.0.x or 11.x will fix it, but for now, just
fall back to llvm@9.

Also issue a warning in the build scripts if this condition
is detected, so if a user encounters it on their system, they
have a hint about how to address it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-26 10:14:05 -07:00
Larry Gritz c5b2afa46d Fix typos in comments (#1243)
Ran a spell checker on our comments. So many fixes.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-25 11:41:58 -07:00
Larry Gritz 991c2247c5 Use .git-blame-ignore-revs (#1244)
This new file contains the hashes of commits whose only function was
to reformat large amounts of code.

Ordinarily, this would make for confusing 'git blame' output, by
making old code written by author A appear to have a new modification
date and authorship by B, when in fact we know that B just did some
reformatting. This can make it especially hard to discern code history
after after commits that establish the use of "clang-format".

A new git feature (requiring git >= 2.23) allows pointing to a file
containing hashes of commits to be ignored by git blame:

    git blame --ignore-revs-file .git-blame-ignore-revs

To avoid having to remember this all the time, consider adding this to
your git config:

    git config blame.ignoreRevsFile .git-blame-ignore-revs

Note that git supports this feature but does not dictate the name of
the file. I'm just following the convention I'm seeing pop up in other
projects of calling it ".git-blame-ignore-revs".

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-25 11:41:49 -07:00
Larry Gritz 0dc6f76d2f Bump version tweak for next release candidate
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-22 15:11:05 -07:00
Larry Gritz 709f6e9c66 Ready release candidate
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 22:18:29 -07:00
Larry Gritz 9cc760aeb9 Rebuild docs for release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 22:18:29 -07:00
Larry Gritz 1496406616 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 21:43:02 -07:00
Larry Gritz 46a6157613 Fix capitalization in new testshade options
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 21:35:05 -07:00
Larry Gritz c629e52bff Docs: Fix longstanding error in description of spline()
The implementation was always correct, but the description here was
super unclear and wrong.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-14 16:26:52 -07:00
Larry Gritz 1f8950d056 Fix fmt vs Cuda incompatibility (#1242)
We used to disable fmt and fall back to tinyformat, when using Cuda.
The new OIIO 2.2 removes tinyformat and the OIIO_USE_FMT preprocessor
symbol. So make sure that we also tell fmt to avoid using the int128
type, not supported by Cuda. That seems to be enough to let it use
the rest of fmt without trouble.
2020-08-14 16:25:29 -07:00
Alex M. Wells c4cd20ce70 split the opt and jit functionality of optimize_group (1226)
Work by Alex Wells.

Separate OSL optimization from JIT by adding optional parameter
`bool do_jit = true` to all optimize_group* methods. This will allow
optimization without JIT'ing for the host, or optimizing once but
JIT'ing for multiple back ends. It will be necessary if one will be
JIT'ing only for batched execution, we would not want to pay the cost
of JIT'ing a scalar version as well (but still could if we wanted both
scalar and batched versions simultaneously).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-11 22:10:43 -07:00
Larry Gritz d141efa55d More flexible find of llvm-config with suffixed with '-64' (#1238)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-11 11:10:27 -07:00
etheory 9d37207658 Remove null check from symbol_address for performance (#1237) 2020-08-02 21:33:15 -07:00
Alex M. Wells 93cf9fc383 testshade: make a way to force varying derivatives for testing (1227)
Work by Alex Wells

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-02 21:32:22 -07:00
Larry Gritz c0d873bc38 Fix changes typos
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 17:48:12 -07:00
Larry Gritz 2835538c70 Bump version after tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 17:48:12 -07:00
Larry Gritz d5d0e5e003 Branch for 1.11 beta
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 14:36:44 -07:00
Larry Gritz fb2ab3c8f2 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 14:36:20 -07:00
Larry Gritz ddfb7bd850 Rename workflow file, add status badge
Remove badges for Travis and Appveyor, since we are relying on GHA now.

Rename the ci workflow definition file from workflow.yml to ci.yml, to
support other workflows later.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 13:09:44 -07:00
Larry Gritz 6d8c2da928 Docs touch-up
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 13:09:44 -07:00
Larry Gritz 7fac82d319 Touch up readme
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 10:49:58 -07:00
Larry Gritz c40d3bd08d GHCI: adjust OIIO versions after OIIO 2.2 beta
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 09:52:12 -07:00
Larry Gritz 66d66fa563 Comment typo fix
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 09:51:06 -07:00
etheory 9b3bd6fbc5 Fix spelling errors (#1235) 2020-08-01 08:08:31 -07:00
marsupialandrzulak 9d4e290e0b Changes for LLVM-11. (#1234)
Co-authored-by: rzulak <rzulak@imageworks.com>
2020-07-30 11:05:08 -07:00
marsupialandrzulak 764b7cfb19 Bump SPI Partio version. (#1233)
Co-authored-by: rzulak <rzulak@imageworks.com>
2020-07-29 21:15:04 -07:00
Larry Gritz 4bc80a488e Switch to the newer name of this OIIO function (#1231)
Keep up with the long term fmt-related transition on the OIIO side.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-28 14:37:54 -07:00
Larry Gritz 46443af7ae Expect external PugiXML (#1229)
To be less reliant on a version embedded in OIIO, provide a handy
build_pugixml.bash script. And change to relying on PugiXML's exported
cmake configuration files, no more need for our FindPugiXML.cmake.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-27 10:49:47 -07:00
etheory 3be75ac573 Fix spelling errors (#1230) 2020-07-26 20:33:00 -07:00
Larry Gritz bf366d7a90 More clang-format: liboslquery, oslinfo, oslc, osl.imageio, osltoy (#1220)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-24 09:17:07 -07:00
Alex M. Wells d31f4a1adc Option to generate full debugging and profiling info. (1221)
Work from Alex Wells:

Add support for generating debug information to track function call
stack, source file, and line number inside generated LLVM module.
When enabled, can debug with source and line numbers.  Also Intel(r)
VTune(tm) Profiler associated assembly to shader source and line
number.

The big upshot here is that when this debugging is enabled,

  * gdb/lldb can debug a renderer app, all the way down to inside JITed
    shaders.

  * Stack dumps upon a crash will show you the full stack trace
    including where you were in a shader.

  * Profilers such as vtune can be used to accurately profile shaders.

The profiling only works if your LLVM was built with the option
`-DLLVM_USE_INTEL_JITEVENTS=ON`.

Due to some ABI changes on the LLVM side, the debugging symbols only
work properly if you are using LLVM >= 7.1.

Some other specifics that got rolled into this:

New ShadingSystem attributes to control this: `llvm_debugging_symbols`
and `llvm_profiling_events`. Both default to 0 ordinarily, a renderer
needs to enable them, which we only recommend doing if the renderer
itself is compiled for debugging or profiling.  The testshade and
testrender program automatically enable these options.

Debugging features to dump struct layouts and validate LLVM struct
representation based off expected offsets populated from host versions
of the data structures:

    void dump_struct_data_layout(llvm::Type *Ty);
    void validate_struct_data_layout(llvm::Type *Ty,
    const vector & expected_offset_by_index);

Added op_functioncall_nr to as a noop with the name of the function
that was inlined. Previously constfolding would eliminate a
op_functioncall if it had no return value.  Now we transmute into a
op_functioncall_nr. There should be no real shader execution cost to
this, but now can debug through nested OSL shader level function
calls. We needed the op_functioncall_nr to trigger the creation of
debug info for an inlined function call.

When not debugging, don't waste by naming basic blocks.

Note that for now, we disable debugging symbols for PTX mode. At some
point we will have to do some refactoring to re-enable this, if/when
there is a use for it for PTX debugging.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-24 09:09:54 -07:00
Alex M. Wells dd74962a77 Added ability to reuse allocas accross a function body.
Avoid emitting any alloca instructions inside loops and reuse
temporaries across the body of a function, which means we should not
emit them in conditional branches either.  So always place alloca at
the very beginning of a function.  To do that, we save the current
insertion point, change it to the beginning of the function, emit the
alloca, then restore the insertion point to where it was previously.

Work by Alex Wells.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-23 09:51:19 -07:00
Alex M. Wells 0a178b5dc6 Refactor jit mem manager and perthread to prevent leaks
Work by Alex Wells.

Leaks are prevented now, though at the cost of a bit more housekeeping
on the part of the user of LLVM_Util.  Each thread must have its own
LLVM_Util::PerThreadInfo, which must outlive any LLVM_Util (and which
must be passed a reference of the PerThreadInfo). Also, there must
somewhere in the app exist a ScopedJitMemoryUser that must outlive all
of the LLVM_Utils.

Expose LLVM_Util::PerThreadInfo (separate from its implementation so
it can be embedded in OSL::PerThreadInfo vs. managed separately.

Improve memory cleanup for JIT'd code by adding
LLVM_Util::ScopedJitMemoryUser. JIT'd code needs to exist with a
longer lifetime than the LLVM_Util object.  To enable better cleanup
at shutdown, the lifetime of all JIT'd code is controlled by the the
existence of ScopedJitMemoryUser objects. When the last
ScopedJitMemoryUser goes out of scope or is deleted, then the
underlying memory managers will be deleted.  Each ShadyingSystem
instance has a ScopedJitMemoryUser.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-22 20:42:39 -07:00
Larry Gritz 9d08f1a4ea Adjust include (#1222)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-22 09:40:01 -07:00
Larry Gritz 1c1d80763b Fix docs typo in cbrt
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-21 10:44:24 -07:00
Larry Gritz 5fd4674e1b Fix confusing wording of spec about matrix constructor
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-21 10:42:32 -07:00
Larry Gritz 3e2d9a0202 SPI find pybind11 in the right place 2020-07-15 16:29:39 -07:00
Larry Gritz d88ac8c5bc Make sure to test against latest fmtlib (#1219)
And add workaround for some recent weirdness on their end (see the
related recent PR in OIIO).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-14 16:16:54 -07:00
Larry Gritz bdb473cbdb More clang-format (#1218)
Reformat the contents of src/liboslcomp

Some adjustment of .clang-format to match my taste.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-14 15:23:23 -07:00
Larry Gritz 2ab21373fe Python touch-ups (#1217)
* Fix template casting reference to work properly with the latest
  pybind11 master.

* Mac CI: use Python 3.8.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-14 15:13:11 -07:00
Larry Gritz 630b4c042d Start using clang-format on OSL code base (#1215)
This fully enables the mechanism and reformat the first batch of files.

For now, we will continue to exclude the llvm-related code and
OptiX-related code from the reformatting, since changing those at this
time will make merging difficult for work that is in progress. We'll
add those after they have fully settled down. But in the mean time, we
can start by reformatting the more stable parts of the code base.

The reformatting will be staged in reasonable batches over a series of
PRs.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-10 16:36:32 -07:00
marsupialandrzulak d13efb1a4d [CMake] Move PUGIXML_LIBRARY outside PUGIXML_INCLUDE_DIR check. (#1216)
(CMake seems to cache PUGIXML_INCLUDE_DIR and so on a reconfigure PUGIXML_LIBRARY may never be set).

Co-authored-by: rzulak <rzulak@imageworks.com>
2020-07-10 16:35:54 -07:00
Larry GritzandAlex M. Wells c58f1c2b5a Add ISA-specific targeting and additional JIT control options (#1214)
* Add ISA-specific targeting and additional JIT control options

ISA means "instruction set architecture", by the way.

Heavy lifting by Alex Wells, some refactoring and adding options by LG.

A number of additional controls over the JIT process are added to the
ShadingSystem:

- "llvm_jit_target" Can be set to the name of an architecture ("none",
  "x64", "SSE4.2", "AVX2", "AVX2_noFMA", "AVX512", "AVX512_noFMA") to
  request that the JIT choose instructions for a specific machine ISA.
  Also "host" means to select whatever the host natively supports.
  It checks if the host CPU supports the requested architecture and
  will automatically restrict it to a choice your machine supports.
  The default is "none" meaning not to generate code for anything beyond
  the default Intel target. There seems to be little benefit to using
  this at this time for single-point shading, but we anticipate that
  it will be important to the forthcoming batch shading mode.

- "vector_width" Can set the vector width for SIMD instructions,
  independently of the JIT target (for example, you could JIT for
  AVX512 but still only make 8-wide SIMD instructions). The current
  default is 4, meaning it will not generate 8-wide or 16-wide
  vector ops, even when targeting and running on AVX512. We have found
  significant performance penalties when running single point shading
  mode on AVX512 hardware, unless we use this restriction (but no such
  slowdown on AVX2 hardware).

- "llvm_jit_fma" Enables use of fused multiply-add instructions on
  architectures that support them.  When enabled, resulting code is
  slightly faster and improves rounding accuracy for some
  computations.  But the default is 0, because enabling it can make
  results differ slightly on machines with different architetures (bad
  for testing, and maybe leading to problems if you have machines with
  differing architectures working on different frames of the same
  shot).

- "llvm_jit_aggressive" Enables the "aggressive" JIT option, whatever
  that means. Currently defaulted to 0.

- "llvm_dumpasm" a debugging mode that lets developers see the actual
  JIT code as assembly language.

The bottom line here is that the defaults are carefully chosen to be
performance-neutral on all architectures. We do not currently advise
adjusting these settings for single-point shading mode. When we add
batch-shading mode, we will probably have different defaults or
guidance to offer when using that mode (and the specific advice may
depend on the specific architecture you are running on).

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

* Fixes from review suggestions

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-07-09 22:51:57 -07:00
Larry Gritz 36dbb6d1db Python bindings for OSLQuery (#1212)
Using pybind11. See testsuite/python-oslquery/test_oslquery.py for a
full example of how to use it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-09 12:18:48 -07:00
Larry Gritz 9bcf490363 Fix Mac GH CI: freetype already installed
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-30 10:30:10 -07:00
Christopher Kulla a514421f92 Fix memory leak when using the JIT Event listener (#1213)
The execution engine does not take ownership of this object, so we
need to be cleaning it up ourselves.
2020-06-30 09:39:35 -07:00
Larry Gritz 9e64b14a35 Re-enable RTTI (#1211)
We had disabled RTTI throughout the OSL code base to avoid linkage
problems against LLVM, which builds with RTTI disabled by default.

But it's actually ok to mix code modules with differing RTTI status --
that's fine. It's just that you can't mix RTTI status within a class
inheritance hierarchy.

We observe that

  * The only classes we inherit from RTTI-free LLVM are solely defined
    and used within llvm_util.cpp.

  * The only classes exposed in llvm_util.h have no virtual functions
    and aren't designed to be subclassed.

So in fact, it appears that we can get by with only using no-rtti when
compiling that one module, and don't need to mess with rtti anywhere
else (including downstream users). This is an important step to
supporting python bindings, since pybind11 requires RTTI.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-22 17:57:05 -07:00
Larry Gritz 3e9445129a GH CI: Failed tests save artifacts of all test output for debug (#1207)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-16 23:10:07 -07:00
Alex M. Wells fd6a9b1aee Add LLVM_Util methods to detect appropriate ISA for the host CPU. (#1208)
We don't use this quite yet, but are staging it for easy review.

Work by Alex Wells. Some refactoring and minor edits by LG.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-16 15:29:33 -07:00
Alex M. Wells 27e8d23f7c Change some data to static visibility (#1210)
From Alex Wells

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-16 09:10:42 -07:00
Larry GritzandAlex M. Wells 8668634be4 Add override to the MemoryManager class. (#1209)
Work by Alex Wells.

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-06-16 09:09:49 -07:00
Larry Gritz 29cdfa8076 Bump version developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-15 22:15:29 -07:00
Larry Gritz 69a8ed2bff CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-15 10:29:54 -07:00
Larry Gritz f39aa92589 Add a clearer and more prescriptive message for LLVM 10 error (#1206)
Spell out the exact requirements when building against LLVM 10,
which option to set to bump to C++14, which compiler versions are
necessary.

Closes #1205

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-13 13:45:55 -07:00
Declan RussellandDeclan Russell cd7b411632 "error: 'ListT': parameter pack must be expanded in this context" on windows (#1201)
Remove variadic inthash

Co-authored-by: Declan Russell <Declan.Russell@autodesk.com>
2020-06-13 13:45:21 -07:00
Larry Gritz dd0756ea04 Allow output params with lockgeom=0 to have auto userdata binding (#1200)
Shader params declared with lockgeom=0

    surface foo (float bar = 0 [[ int lockgeom=0 ]]) { }

will generate code making underlying calls to RendererServices->get_userdata
to automatically bind userdata (a.k.a. interpolated "primitive variables")
that share the same name.

But, oddly, this was not true for output parameters:

    surface foo (output float bar = 0 [[ int lockgeom=0 ]]) { }

This was tripping some people up, and in retrospect seems strange.

This patch removes this restriction, allowing both input and output
parameters tagged with lockgeom=0 to attempt to retrieve userdata to get
their initial values.

Add test of userdata retrieval to make sure this works.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-11 18:18:14 -07:00
Christopher Kulla a9cd1a7cb6 Add progressive sampler to testrender (#1202)
I tried to keep the code simple rather than optimize it heavily, so it runs slower than the previous code. On the plus side, its shorter and doesn't have any dependency on OIIO hashes.

Signed-off-by: Christopher Kulla <ckulla@gmail.com>
2020-06-11 18:18:14 -07:00
Larry Gritz 6657ea218b lazyerror option (#1191)
By default, shader group layers execute lazily, meaning the node will
not execute until/unless one of its outputs is needed by a downstream
layer, and if in the course of optimization all of its outgoing
connections are eliminated, then the entire node will be pruned from
the shader graph. But if the node contained error() calls (say, to do
sanity check on parameters or other conditions), those error calls
will never be issued, possibly masking a problem.

This patch introduces a new ShadingSystem option:

"lazyerror" (default: 1) -- when set to 0, it means that the presence
in a shader layer of an error() call that *can't* be constant-folded
away will make the layer will execute unconditionally, thereby making
the error() call run even if the layer's outputs are never "pulled" by
any downstream layer.

Furthermore, if lazyerror=0, if you have shaders that after
optimization still have error calls (and thus will run the layer
unditionally), then if option "opt_warnings" is nonzero, you will get
a warning about the presence of a not-optimized-away error call (you
may want to know about this for performance reasons, if your intent
was that all error calls should be resolveable by the optimizer).

Along the way I also added a few more optimization-debugging logging
messages, including understanding exactly when and why unused connections
are pruned.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-11 18:17:33 -07:00
timgrantandTim Grant 9bf79896d4 O7 Strings Update (#1203)
* Refine O7 string handling. Avoid initializing string variables in the module PTX.

* Replace '.' with '_' when constructing PTX variables from symbol names.

* Remove the now-unnecessary DummyFunction from rend_lib.cu.

* Change the dimension check for issuing a 'missing output' warning in testrender/testshade.

Co-authored-by: Tim Grant <tgrant@nvidia.com>
2020-06-11 18:17:22 -07:00
Larry Gritz 4412863ad2 Remove unused (and also deprecated) retrieval of pixmap (#1204)
Critical fix to compile cleanly with Qt 5.15

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-11 18:17:10 -07:00
Declan RussellandDeclan Russell f9760fd650 static_foreach does not compile in GPU code (#1198)
* Enable static_foreach to run in device code

Co-authored-by: Declan Russell <Declan.Russell@autodesk.com>
2020-06-10 09:21:11 -07:00
Larry Gritz 53e59293b0 Example of using OSL as a deformer (#1199)
Many times, people can ask how they can use OSL to make more general
computational engines (not a classic renderer), and one use case that
comes up frequently is to use it to control deformations. This patch
includes a new testsuite example that does exactly this, for a test
case -- setting up a small shader network that operates on a series
of points.

It's a completely self-contained example of how to do this. There is a
lot of boilerplate for such a simple task, but I was really trying to
make sure to provide examples of all the little pieces you'd need to
do a more complex use use.

To make sure it builds, I added it to the testsuite itself, as
testsuite/example-deformer.

Interestingly, it is our first testsuite entry that needs compilation
and linking with OSL -- and not using OSL's own build system! So not
only does it test the code functionality itself, but it also serves as
a test for our exported CMake config.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-09 20:19:23 -07:00
Declan RussellandDeclan Russell 75fad5a91b Fix ICC remark #82: storage class is not first (#1197)
Co-authored-by: Declan Russell <Declan.Russell@autodesk.com>
2020-06-09 15:34:25 -07:00
Larry Gritz 302cb1edfa testshade -o: make 'null' as filename not produce any output (#1193)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-09 15:04:57 -07:00
Larry Gritz 49f61bc980 Propagate rtti compile options to exported cmake config (#1194)
People linking against oslexec needed to know to use -fno-rtti when
building their apps. Very brittle. This correctly adds the flag as
an interface compile flag in our exported CMake config files.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-09 15:02:20 -07:00
Larry Gritz 6f7313ec83 Fix new Parameter call -- didn't call the group-specific version (#1196)
Amendment to #1195, I called the wrong/deprecated version of Parameter.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-09 10:23:07 -07:00
Larry Gritz 25bbfda1fe Helper Parameter and ReParameter varieties for common types (#1195)
For attribute and getattribute, we had some specializations that make
it extra easy to do the common cases of a single float, int, string.
This is just adding the same kind of convenience functions for
Parameter() and ReParameter().

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-08 10:51:53 -07:00
Larry Gritz bdb6aadb87 Add gcc9 and gcc10 tests to CI matrix (#1192)
* Use the new ASWF VFX Platform 2021 docker image for gcc9/py37/llvm10/C++17

* Alter the "bleeding edge" CI test to use gcc10

* Fix some new warnings that pop up with gcc9 and gcc10

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-05 17:12:44 -07:00
cmstein a488bf1ca7 adding OIIO namespace to Strutil uses (#1190) 2020-06-03 10:57:53 -07:00
Larry Gritz 743a40f3dc Change all bare std::ofstream/ifstream to OIIO::ofstream/ifstream (#1188)
Because they are UTF-8 safe and work properly on MinGW.

Simplified a bit more as I went -- some reading idioms could be
replaced by a single call to Filesystem::read_text_file, some close()
calls were redundant because streams close upon destruction / scope
exit, some open flags unnecessary because the default write mode
already will truncate an existing file.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-01 15:04:43 -07:00
Larry Gritz e000c81952 Modernize loop (#1189)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-01 12:02:41 -07:00
Larry Gritz 2f2a40da84 Fix bug in understanding regex_search & regex_match parameter writes (#1186)
There was an oslc bug a long time ago (prior to OSL 1.10) in which the
3-argument versions of regex_search and regex_match failed to mark
their 'results' parameter as write-only in the oso.

In addition to fixing the bug in oslc so that subsequently-produced
oso files are correct, in order to properly interpret these
historically-compiled oso's, we also look for this particular case
upon reading the oso, in loadshader.cpp, and mark it correctly. This
was PR #922.

Except...

1) We neglected to distinguish the 2-arg version from the 3-arg version,
only the latter of which should be so marked.

2) We tested for regex_search twice (!) instead of testing for
regex_search and also regex_match.

Apologies! Here is the fix.

Thanks to Alex Wells for identifying the problem.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-29 14:03:49 -07:00
Alex M. Wells 23722baa7f Make the strings of <OSL/strdecls.h> into public symbols. (#1184)
It's not officially part of the public API, but making the symbols
public is necessary for some upcoming work where Alex has separate DLLs
for different CPU/SIMD implementation modules and the symbols will need
to be visible to the contents of those DLLs.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-28 21:10:46 -07:00
Alex M. Wells e4dabca271 Fix normalize() sqrt call to be sure it's using floats (#1185)
By Alex Wells

Also added OSL_LIKELY

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-28 20:55:58 -07:00
Alex M. Wells f9bab2b54b Added various OSL_MAYBE_UNUSED to make compiler builds happy. (#1183)
Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-27 14:26:35 -07:00
Larry GritzandAlex M. Wells 0c80502221 JIT code for the specific host target (#1182)
We aren't saving object files like an offline C compiler; we are
JITing and immediately executing on a specific machine, so we may as
well have LLVM optimize for that very chip. This patch from Alex Wells
adds optimization passes that do so.

LG amended it to make it a shading system option "llvm_target_host"
(defaulting to true).  And we force it to off when compiling for
OptiX, since obviously the GPU is not the host architecture.

Production benchmarks do not show a noticeable speed gain in scalar
code. (Nor does it slow down.) There is no harm in targeting the
specific host CPU, and it may be more helpful when we are dealing with
vectorized code down the road.

Alex also added a developer only macro OSL_DEV_ONLY(STUFF) to leave
developer debugging/tracing code around and only have it active if
compiled with -DOSL_DEV

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-27 13:18:35 -07:00
Larry Gritz d3f5048582 Remove stlfree -- not used (#1178)
Obsolete since C++11, where vector::shrink_to_fit() does the same thing.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-27 10:57:32 -07:00
Larry GritzandAlex M. Wells 7443d28e5a Expose packed flag to LLVM_Util::type_struct() (#1180)
Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-27 10:57:08 -07:00
Larry Gritz 01ced4a67a Fix confusing TypeSpec::is_float_based vs is_floatbased (#1176)
I'm not sure how this happened, but TypeSpec had `is_float_based` and
`is_floatbased` methods, and they were subtly different (the latter is
false for float-based arrays). This has led to at least one bug.

A careful examination reveals that the vast majority of uses of
`is_floatbased` really intended `is_float_based`, so I changed all
references to this.

For the few where excluding arrays is the right logic, I added a
separate test for arrayness.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-26 23:30:15 -07:00
Larry Gritz 59fd03f3fd Demangle symbol names for certain runtime error messages. (#1179)
In the compiler, symbol.name() is the human-readable name and
symbol.mangled() is a mangled symbol that keeps identical names in
different scopes from clashing. We use mangled() in the oso file but
name() in error messages.

However... at runtime, it reads the pre-mangled name from the oso, and
doesn't know the original name, so name() and mangled() are identical
and are both the mangled version. That's fine for almost everything,
but there are just a few runtime errors that involve the symbol name,
and we would prefer that these be the unmangled version, for the sake
of clarity when communicating errors to the user.

So we add a Symbol::unmangled() that trims the mangling from the front
of a mangled symbol, and in runtime error messages we use this to strip
the mangling.

I also modified Symbol::mangled() slightly, to make sure NVRO is used.
The observed behavior doesn't change, only the idiom.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-26 23:01:00 -07:00
Larry GritzandAlex M. Wells 27d3e56d0f LLVM_Util::prune_and_internalize_module (#1172)
Previously, we had `LLVM_Util::internalize_module_functions` that
reduced the LLVM optimize + JIT work by finding function symbols in an
IR module that started with "osl_" and were not our known entry points
and marking them with "internal" visibility. This lets LLVM recognize
them, if they are not called internally to the module, as dead code
and discard them before spending any time optimizing or jitting those
functions.

This patch from Alex Wells adds an additional method,
`prune_and_internalize_module`, that is even more aggressive, pruning
all symbols that we don't think can be reached with our generated code
(are not "materialized", in LLVM parlance), and then marking
everything that is not a known entry point as "internal".

N.B. Some care is needed not to mark as internal a few symbols that
Cuda adds and which if removed will cause the OptiX shader to
fail. These seem to all contain the substring "rti_internal_".

This is indeed slightly better, and in extensive benchmarks of
production shaders, we're seeing about a 10% average reduction in LLVM
opt+jit time.  This is a tiny portion of a fully rendered scene, but
for interactive renders where you care about "time to first pixel", it
is more significant to reduce this compilation overhead as much as
possible.

I (LG) am a little hesitant to deprecate the old method right away, in
case any as-yet undiscovered flaw is found or just to aid
benchmarking. So I added a ShadingSystem string attribute
"llvm_prune_ir_strategy" that can take on any of the values "prune"
(default, the new way, full prune and aggressively internalize),
"internalize" (old way, just internalize function symbols that aren't
entry points), and "none" (don't do either -- just for benchmarking or
debugging).

I also benchmarked the "none" strategy, and it spends an average of over
2x longer in LLVM opt+jit than our old "internalize." So either strategy
helps substantially cut down on opt+jit time, though "prune" seems the
fastest, and is thus the new default. As we gain more confidence in it
in production, we may eventually deprecate and remove the "internalize"
strategy, leaving only "prune."

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-26 22:54:14 -07:00
Larry GritzandAlex M. Wells 576b2187a2 Add several wide data types and wide operations to LLVM_Util. (#1175)
These aren't used anywhere in OSL's codebase yet. But they will be.

By Alex Wells.

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-26 18:53:10 -07:00
Larry GritzandAlex M. Wells 249cabc065 Make debug_nan and debug_uninit work more accurately for matrices (#1173)
Both were plagued by checking the entirety of the matrix, when in fact
only one element needs to be checked. This is wasteful because it
checks elements that aren't read or written by the op we are checking,
and it can also lead to "false positives", errors about elements that
are not touched by the present op.

Refinement of the debug_nan and debug_uninit cases was by Alex Wells.
LG added comments to clarify the implementation of these functions.

LG also amended the testsuite/debug-uninit to specifically test
arrays, triples, and matrices (checking for true positives and check
against false positives). In the process, he noticed another bug (!)
where float-based arrays were not being correctly initialized with
their uninitialized value sentinels, and thus were not detecting use
of uninitialized values therein, because instead of calling
is_float_based, we called is_floatbased, which excludes arrays.
(The similar names are yet ANOTHER bug, or at least unintended to be
so confusing, and this will be addressed in a separate PR).

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-26 17:31:22 -07:00
Larry Gritz 206987a4ec SPI build touch-ups for finding optix7 2020-05-26 17:26:03 -07:00
Larry GritzandAlex M. Wells 61277ef168 Only range check matrix component access when necessary (#1174)
Point/color and array accesses were range checked at runtime EXCEPT
when the indices were constant and known to be within legal range.

But matrix component access (m[r][c] = x, x = m[r][c]) were always
range checked.

This patch from Alex Wells (and then enhanced by LG) skips the range
checking on the row or column indices, or both, when they are constant
and >= 0 and < 4, which is probably a lot of the time, thus speeding
up matrix component access a little by skipping the range checking
when it's safe to do so.

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

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-05-26 16:53:00 -07:00
cmstein 94645220c0 Adding support for OptiX 7 (#1111)
* Adding experimental support for OptiX 7.  The testsuite is mostly passing.  This specific functionality requires llvm >= 9.0.
2020-05-19 14:40:49 -07:00
StefanBruens 74616c3707 Use single shared clang-cpp library starting with LLVM 9 (#1171)
Since 9.0 LLVM defaults to building a single clang-cpp library for
non-developer builds.

As this is just the default, and some distributions enable it only with
LLVM 10 (e.g. Fedora), make the clang-cpp search dependent on the build
mode.
2020-05-13 13:48:38 -07:00
Larry Gritz d830562c2c Switch containers from aswftesting to aswf
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-10 22:18:33 -07:00
Larry Gritz 38413a86dc Fix typo in the .pc.in files that botched the version (#1168)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-09 12:48:09 -07:00
Larry Gritz e03055bc3f CI: use ASWF docker images (#1169)
Modify the CI test matrix to include several tests using the ASWF docker
images to test exactly the VFX Platform configurations for 2019 and 2020.

Additionally:

* Some other minor juggling of GitHub CI configuration and dependency
  versions used for each test.

* Have the "2021-ish" test bump OpenEXR dependency to the newly
  released 2.5.

* Alter teh build_openimageio.bash helper script to use strictly the
  cmake build system, not the Makefile wrapper.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-09 12:28:25 -07:00
Larry Gritz 505b6aec10 Update all references to the osl-dev mail list (#1167)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-09 09:07:40 -07:00
Christopher Kulla 7e66fa08a9 Fix cube root derivative sign (#1166)
I had noticed the comment didn't match the code and updated the code not realizing it was the comment that was wrong ...

Signed-off-by: Christopher Kulla <ckulla@gmail.com>
2020-05-07 13:12:50 -07:00
Larry Gritz 0d198ef2bb Fix compiler warning about signed/unsigned (#1165)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-07 09:27:20 -07:00
Christopher Kulla 7547a89af0 Add cube root function to the language (#1164)
Also added a special case to allow pow(x,1.0/3.0) to be automatically turned into cbrt during runtime optimziation.
2020-05-07 09:03:17 -07:00
Larry Gritz 0d5bc28867 Make build area more closely resemble dist area (#1161)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-02 10:39:16 -07:00
Larry Gritz 0961da8a60 Fix include path bugs from libclang on OSX with llvm 10 (#1162)
On OSX, with LLVM 10, it seems that there can be a double linkage of
the libc++ that is built with llvm and the one in /usr/lib.

This leads to a very subtle problem where oslc's use of libclang for
preprocessing is unable to find included files when there are multiple
include search paths (!), unless you have the llvm lib directory first
in your DYLD_LIBRARY_PATH. That is obviously too brittle a fix.

Solve by forcing use of statically linked llvm/clang libraries when
on OSX and using LLVM+clang 10+, even if the user did not explicitly
request that.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-29 16:31:57 -07:00
Larry Gritz 537b492fcc Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-28 11:43:16 -07:00
Larry Gritz 4de31bdc8c CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-27 13:00:37 -07:00
Larry Gritz 604f8f4ab0 CI on GitHub Actions improvements (#1160)
* Fix newly broken Mac CI -- GHA's default homebrew now has llvm 10, which
  requires C++14.

* Schedule a nightly cron job for CI.

* Do not launch full builds and tests for pushes that only change
  documentation (md, rst, and tex files).
2020-04-25 16:56:42 -07:00
Larry Gritz 95bf159f50 Make sure the shader execution heap is cache aligned (#1159) 2020-04-24 10:48:59 -07:00
Larry Gritz af601c1eca Remove stray debugging print from last commit 2020-04-22 11:37:58 -07:00
Larry Gritz 92ac514a33 Support partio string attributes on particles (#1157)
We previously did not support indexed strings (only int, float, vector).

Also some SPI adjustments to partio finding, the rest of you can
ignore that part.
2020-04-21 17:06:41 -07:00
Christopher Kulla 265bd0d6b6 Fix for fmtlib not allowing printf syntax %p with non-void pointers (#1156) 2020-04-21 14:47:03 -07:00
John Mertic aca937412b Project intake checklist
Signed-off-by: John Mertic <jmertic@linuxfoundation.org>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-17 15:02:09 -07:00
Larry Gritz 0f5c2509c5 Fix accidental double SPDX cut/paste (#1154) 2020-04-17 15:00:47 -07:00
Larry Gritz f099602007 Bump LLVM minimum to 7 (#1152) 2020-04-17 11:35:31 -07:00
Larry Gritz 80ab6c9063 Documents to be added as part of ASWF transfer (#1137)
* Technical Charter, governance documents, Code of Conduct (approved by TSC)

* Draft copies of the proposed new CLAs.

These are as identical as possible to the corresponding documents of
OCIO (differing only for name changes and the like, and in just one or
two places, substituting an equivalent but slightly more clearly
worded version of some piece from OpenEXR). None of the important
legal stuff like CLAs or licenses have been altered from the OCIO and
ASWF standard template as they were approved (by my organization) for
that project.

The license remains the 3-clause BSD we have always used, so there is
no reason to contact prior authors for re-licensing. But when we get
around to moving the repo from the Imageworks GitHub account to the
ASWF one, the new CLAs will take effect and subsequent contributors
will need to sign them (even if they had previously signed the Sony
ones).
2020-04-16 17:13:27 -07:00
Larry Gritz ffc5303dcf Big copyright and license cleanup to follow ASWF conventions (#1145)
This brings us into conformance with ASWF standards for license text
and how the copyright notices read. (And was cleared by Sony and Linux
Foundation.) This is the same set of changes made to all the other
projects coming into the foundation, including OpenColorIO.

Please note that none of the licenses are changing -- it's the same
3-clause BSD license we have always used. Also, this doesn't change
any of the copyright holders -- it has always been the case that the
authors of each patch retain the copyright to their specific additions
or changes. OSL has never required copyright assignment for
contributions.

* Add a LICENSE-THIRD-PARTY.md file that documents imported software.

* Update documentation license to CC-BY-4.0 (from 3.0).

* Fully reproduce the Qt license in the two files derived from Qt
  example code.

* Change copyright notice to the new wording of 'Contributors to the
  Open Shading Language project', per ASWF convention.

* Replace lengthy per-file copyright boilerplate with SPDX short form.
  (This is more readable and is easily scanned by automated software to
  detect which licenses are used.)

* For any files lacking a copyright notice, license text, or SPDX
  identifier, add them.

* Fix test output for many unit tests where line numbers changed after
  license info was added to .osl files in the testsuite.
2020-04-16 16:55:29 -07:00
JN 7f6507781e Update blender docs link in README (#1151) 2020-04-16 10:40:21 -07:00
Larry GritzandAlex M. Wells 874efa244b Fix warnings about unused varables (#1150)
They aren't used in release builds, and some compilers will warn about
that.

Co-authored-by: Alex M. Wells <alex.m.wells@intel.com>
2020-04-16 01:00:08 -07:00
Alex M. Wells d2b754f250 Straighten out comments and simplify conditional compile for OSL_INDEX_LOOP 2020-04-15 13:43:23 -07:00
Alex M. Wells b11e2a474b Matrix function naming cleanup
Some of the internal matrix ops didn't use the usual naming
convention.  Fix. Also remove at least one that is never used because
it's a combination that oslc will never output.
2020-04-14 16:54:40 -07:00
Larry Gritz 3b3b5d7e4b Add missing oslc and oslinfo to exported targets in config (#1143) 2020-04-09 12:02:53 -07:00
Larry Gritz bf9be18d3b Make oslconfig.h be the result of a cmake configure_file step. (#1144)
This is much like how oslversion.h is generated from oslversion.h.in,
which allows things to be "baked in" from cmake control (version
numbers and namespaces, for example, in the case of oslversion.h).

Now with this patch, oslconfig.h is generated in a similar manner. I
don't actually have any build-time changes as part of this patch, but
some are coming in future planned patches, so I wanted this in place
first.
2020-04-09 10:12:51 -07:00
Alex M. Wells 6af3a7b696 Change Vec3 [] to .xyz (1141)
Avoid potential aliasing issues by avoiding use of Vec3::operator[]
which does a reinterpret_cast and instead explicitly use data member
names .x, .y, .z.

This doesn't matter much for scalar code, but when loops are
explicitly or automatically vectorized, using myvec[0] can confuse the
compiler enough to inhibit vectorization, whereas myvec.x does not.
2020-04-08 11:51:20 -07:00
Alex M. Wells 726af9c1bc Modernize some loops in LPE (#1142) 2020-04-08 11:48:37 -07:00
Alex M. Wells 4de3c81194 Fix typos (#1140) 2020-04-07 17:23:45 -07:00
Larry Gritz 9a9040edb9 SPI build adjustments 2020-04-05 18:00:04 -07:00
Larry Gritz 0862aa3bf0 TSC minutes 2020-04-02 (#1138) 2020-04-05 14:33:25 -07:00
Larry Gritz e95f8cc13b Change default OSL_BUILD_MATERIALX to OFF (#1136)
* I haven't been diligent about keeping these shaders in perfect sync with
  the MX spec.

* Because the MX shader spec changes with each MX version, it seems
  inherently confusing and error prone to have a version inside OSL,
  which is not versioned the same way or at the same times.

* Modern MX has all the reference OSL code and builds the shaders on its
  end, so soon (if not now), it will be completely redundant to have this
  here.

* Building the many hundreds of MX shaders is a significant portion of
  OSL build time (when using ccache at least), but most people don't need
  them.

So in light of these, we will eventually phase out and remove the MX
shader generation and compilation from the OSL package. Since I'm not
sure who that would break or inconvenience now, we'll slate the total
removal for some future major release (AFTER we are sure from the MX
folks that it serves no more value here at all).

But in the mean time, I think we should at least change the default to
not build it. Users who rely on it can always build with
`OSL_BUILD_MATERIALX=1` if they want.
2020-04-01 22:15:41 -07:00
Larry Gritz ca90dc60c0 Some SPI build fixes for finding the right llvm 2020-03-31 12:57:34 -07:00
Larry Gritz 5b7a792fa4 Update INSTALL, left out llvm9 in last edit 2020-03-31 12:56:49 -07:00
Larry Gritz 490c6bc470 Port recent fixes / improvements from OIIO cmake scripts here (#1132)
* build_foo scripts fail immediately upon error.

* Don't auto-download pybind11 (but do provide a script to do dl/build it)

* Developer snapshot builds from master should have so name include
  the patch number to help avoid linking incompatible shared libs.

* REQUIRED_DEPS and OPTIONAL_DEPS let you more easily turn off dependencies
  by name (beware unintended consequences!)

* Make the build area layout more closely resemble the dist area layout.
2020-03-31 08:49:17 -07:00
Larry Gritz 2683cfdc41 LLVM 10 odds and ends (#1135)
* Use llvm 10 in some CI tests

* build_llvm: New download location for llvm 10

* Build time check that LLVM 10+ requires C++ >= 14
2020-03-31 08:21:01 -07:00
Larry Gritz 192b5ec716 Fix some __CUDACC__ vs __CUDA_ARCH__, add clarifying comment (#1129) 2020-03-30 17:53:52 -07:00
Larry Gritz 70d939188d Update INSTALL to reflect support of LLVM 10 2020-03-30 16:16:20 -07:00
Larry Gritz 01b261986f Revise PARTIO_FOUND -> partio_FOUND 2020-03-25 21:40:45 -07:00
Larry Gritz b9a7526922 Overdue bump of version after those big header changes (but this isn't the release) 2020-03-24 09:46:48 -07:00
Larry Gritz 8740389dc4 Avoid compilation error -- can't use always_inline with USE_LLVM_BITCODE=0 (#1130)
Fix function that should not be marked as always inline
2020-03-24 09:18:04 -07:00
Larry Gritz 31273227ea Refactor of sfmath.h and movement of most back into OIIO fmath.h (#1124)
There was a huge amount of duplication between sfmath.h and OIIO's
fmath.h, with the ones here having only very minor modifications. With
almost no exceptions, I was able to port the fixes here back to
fmath. This now eliminates the redundant copies on the OSL side.

* Remove sfm::ifloor in favor of OIIO::ifloor
* Remove sfm::clamp in favor of improved OIIO::clamp
* Remove sfm::madd in favor of the improved OIIO::madd
* Remove sfm::lerp, bilerp, trilerp in favor of the fixed OIIO fmath version.
* Remove sfm::bit-cast in favor of the improved OIIO fmath version
* Remove sfm::negate in favor of OIIO fast_neg, add Dual fst_neg
* Remove sfm:log functions in favor of improved OIIO fmath.
* Remove unnecessary sfm::absi
* Eliminate most svm transcendentals, use improved OIIO ones instead
* Rearrange safe_fmod
* Remove sfm::absf which did nothing but call std::abs
* Keep sfm::isinf, but only for Intel

The requisite changes should be in both OIIO master ("2.2.2-dev" and later)
and the current release branch 2.1.12 and later. It should also build against
earlier versions of OIIO, but they won't have all the performance additions
for the vectorized loops.
2020-03-18 20:30:45 -07:00
Christopher Kulla b62c2df2d3 Allow OSL to compile with LLVM 10.x (#1128) 2020-03-12 13:16:19 -07:00
Larry Gritz 4e9ed63eb7 Fix GH CI build of oiio so it's not happening in the source tree 2020-03-11 21:20:02 -07:00
Larry Gritz 36ff4fdd0a Also add OIIO include deps to generated cmake config file 2020-03-11 14:35:15 -07:00
Larry Gritz 7cfbd36c43 Fix broken exported cmake configs that omitted public include dirs (#1126)
* Fix broken exported cmake configs that omitted public include dirs

* fix more config includes

* Fix CMake errors about exported deps being in the source tree
2020-03-11 12:58:54 -07:00
Larry Gritz 4405871acd Partio finding fixes (#1125)
A little black magic to ensure that a true cmake config file with
imported targets is preferred over my home grown partio finding module.

Rename FindPartio.cmake -> Findpartio.cmake to match the project naming.

Modify Findpartio.cmake to set up partio::partio target, use it properly.

This all paves the way for an eventual future in which Partio correctly
exports its targets.
2020-03-10 16:15:59 -07:00
Larry Gritz a26971dd71 Overdue bump of dev snapshot version (also update CHANGES) 2020-03-06 22:38:57 -08:00
Larry Gritz 489a918b68 Fix mistake in recent-added operator-(Dual,T). (#1123)
Thanks, Xavier Bec, for spotting this.
2020-03-05 10:49:01 -08:00
Larry Gritz ac1b692100 Make sure pybind11 is installed in homebrew for CI 2020-03-05 08:28:01 -08:00
Christopher Kulla 212e2e1c33 Add code to actually run the LLVM function passes on the module (#1121) 2020-02-27 14:07:17 -08:00
Christopher Kulla 9068359c7a Improve shader performance with always_inline (#1114)
* Make sure that LLVM ops are marked as always_inline

This allows LLVM to truly inline the functions when the optimization level is set to 1 or higher

* Small improvements to llvm_output_bitcode feature

This patches uses underscores instead of dots in the filename to avoid the file from being "hidden" if it started with a "/". Also handle the ":" character which shows up in some material naming conventions and would likely be problematic on windows.

Also add a message to indicate when the bitcode files are written, and make sure the message shows up immediately instead of being deferred.

* Change default LLVM JIT optimization level to 1

The default set of optimization passes produces better code than our previous hand-picked set of passes when combined with the always_inline annotation. Surprisingly, it even reduces the total JIT time as well.

Also fix an alignment issue in llvm_gen_print on the GPU revealed by moving to the more complete set of LLVM optimization passes
2020-02-26 12:06:34 -08:00
Larry Gritz f70b8b9167 Move Imath replicated headers into include/OSL/Imathx (#1118)
* Rename them also, take away the `_cuda` suffix because they contain more than
  just Cuda decorations, restore their original names.

* Copy a bit of updated material from the openexr versions (as of 2.4)
  back into ours, to make a someday reconciliation an easier merge.

* This is all more clearly indicating the semantics of what we intend here:
  these are Imath functions that we had to modify (for whatever reason) but that
  we intend to push back to OpenEXR and then eventually they can disappear
  here once our minimum OpenEXR version requirements are known to include the
  fixes.
2020-02-25 23:31:37 -08:00
Larry Gritz 5f8b42a4b2 Allow testsuite to run in parallel (#1119)
The tricky bit was that we have variants of tests: mytest, mytest.opt,
and when using OptiX, also mytest.optix and mytest.optix.opt.

Those previously all ran from the same working directory, which was
fine if run in serial. When they run at the same time, they will
clobber each other's outputs. So the testsuite logic had to be changed
so that each of the variants runs in its own special test directory.

More substantial overhaul/simplification of testsuite setup.
Including explaining to ctest which tests need to allocate a few cores.

On my workstation at work, this makes running the whole testsuite
(including all the optix tests) go from 5 mins to 30 seconds.  Woo!
2020-02-25 16:06:56 -08:00
Larry Gritz abb67e1563 Minor ref image tweaks after OIIO change to fmath clamp() 2020-02-19 12:50:26 -08:00
Larry Gritz d08cf0efa5 Minor Dual fixes (#1117)
* Fix `<<` stream output that broke its pretty formatting in a recent
  overhaul.

* Supply missing Dual/float comparison operators: for example, we had
  Dual<float, but not float<Dual.

* Add equalAll that is like equalVal, but also compares whether the
  derivs are equal (when both items being compared have derivatives).
2020-02-19 11:36:41 -08:00
Larry Gritz 72ec80aec2 Disentangle namespace declaration from use to avoid double decl. (#1115)
For some reason, the namespace declaration was attached to the end of
OSL_NAMESPACE_EXIT. Which would make an error in any source module that
had multiple OSL_NAMESPACE_ENTER/EXIT blocks.
2020-02-19 10:07:05 -08:00
Larry Gritz dbb11c6b55 Cleanup of platform.h (#1116)
* Move OSL_NODISCARD by porting OIIO's OIIO_DISCARD.

* Also port OIIO_FALLTHROUGH.

* Move osl_assume_aligned to the end so it can be inside the usual
  namespace. Also rename it assume_aligned to match C++20 and use a
  `using` so that for C++20 it just aliases to the std one.
2020-02-18 17:48:43 -08:00
Alex Wells e26cee88ef SIMD Friendly Math and Noise refinements to work inside SIMD loops (#1108)
* Introduce sfm (SIMD Friend Math) namespace with versions of math functions friendly to use inside SIMD loops.
Introduce IntHashBasedNoise to serve as base for HashNoise & CellNoise.
Reimplemented PeriodicHashNoise and PeriodicCellNose to use an adapter to wrap their input values and reuse existing HashNoise & CellNoise implementations.
Introduce code generation policies for Perlin based based functions and Noise objects in order to resuse the same perlin noise functions with or without SIMD intrinsics.  Using a "scalar"(non-intrinsic) version of the algorithm is required when calling from inside a SIMD loop.
Defined Scalar versions of any Noise objects that used SIMD intrinsics internally.
Provide optimized inthash, sfm_simplexnoise, sfm_gabornoise implementations suitable for use inside SIMD loops.
Introduce wide.h with Block<T, int Width> to store data as structure of arrays internally, more Wide and Masked wrappers to Block<T> be added in future.
Added osl::conjunction and osl::enable_if_type for compatibility with older C++ versions that do not have their equivalents defined in std::
Added OSL_NON_INTEL_CLANG = [0 | 1] to identify when compiler is a truely clang, as OSX still has __clang__ defined when using Intel compiler.
Added OSL_NODISCARD
Added OSL_OMP_PRAGMA(unquoted_text) that will only be emitted when -DOSL_OPENMP_SIMD and -DNDEBUG (disabled in debug builds)
Added OSL_FORCEINLINE_BLOCK on supported compilers will recursively inline the following statement
Split common portions of gabornoise.cpp into gabornoise.h that can be shared with sfm_gabornoise.h (the SIMD friendly version of gabornoise).

* Fixed warning error: suggest parentheses around comparison in operand of & [-Werror=parentheses] in sfmath.h

* Fixed typo bug when using C++17

* Added missing OSL_HOSTDEVICE to many noise and sfm functions to enable successful nvcc builds
2020-02-14 13:29:50 -08:00
Christopher Kulla 3d0a284e99 Add shader level annotation to disable range checking (#1112)
We now recognize the metadata annotation "int range_checking=0" on a shader to mean that the shader author is certain that range checks can be safely omitted for this particular shader. This can help speedup particularly expensive shaders without needing to globally disable the checks in other shaders.
2020-02-12 14:25:18 -08:00
Larry Gritz ba520cfb8f Update INSTALL to match the correct current minimum build requirements 2020-02-11 15:17:18 -08:00
Patrick Scheibe fba51a41cf Include link for compilation on macOS Catalina (#1110) 2020-02-05 11:04:52 -08:00
Christopher Kulla 917ec395bc Remove the failed attribute query cache (#1109)
This caching layer was added a long time ago when the renderer at SPI took a long time to find
out that an attribute query failed. This is no longer the case, and our usage of attribute lookups
has changed enough as to make the caching no longer helpful (and sometimes hurtful, such as
when a shader performs many successful queries). Renderers that need the caching behavior
can re-implement it internally to their RendererServices class.
2020-02-04 16:58:12 -08:00
Larry Gritz be67e3d9af bump version after tag 2020-02-04 16:50:56 -08:00
Larry Gritz 8ef7bebba4 SPI internal build updates 2020-01-29 15:14:04 -08:00
Larry Gritz de420f435b oslc: add -MT option (#1107)
Completing the recent dependency generation feature, -MT lets you
customize the name of the dependency target.

Also, to match the C/C++ compilers, we now accept both

    -MF<filename>       # all as one arg
    -MT<target>

    -MF <filename>      # two args
    -MT <target>
2020-01-29 10:37:56 -08:00
Larry Gritz 66f8c3ab83 changes 2020-01-28 15:55:59 -08:00
Larry Gritz 1159d140cf Address strict warnings about unused parameters to functions (#1106)
Fool around with -Wextra (optional, off by default for now), see what
turns up.
2020-01-28 13:38:07 -08:00
Larry Gritz 5215df6603 Refactor oslconfig.h, split parts to platform.h (#1102)
oslconfig.h was getting a little jumbled. Split off all the compiler,
language, and platform detection and macros that need to vary based on
those, put in a new platform.h.

Both in platform.h and what remains in oslconfig.h, reorder for clarity
and to group similar things together. Almost no actual code has changed.

One of the few changes is that I beefed up the pragma macros (now in
platform.h) to inclulde a few more items.
2020-01-28 10:27:33 -08:00
Larry Gritz 18bd46aaf7 Fix bug in recent string patch 1104 (#1105) 2020-01-27 21:09:52 -08:00
Larry Gritz c2eee5e285 Windows fix to escape stdosl path (#1101)
You see, we are taking a file path, which on Windows might look like
"c:\path\to\new\osl" (the Windows design mistake we will all live with
forever), and then injecting that into the osl source parse string as
a double quoted string, it will be unescaped and turn into
"c:\path<tab>o<newline>ew\osl", which of course is wrong.

This leads to hilarious bugs on Windows if OSL is installed someplace
where one of the directories in the sequence starts with an "n", as
above.
2020-01-27 12:01:34 -08:00
Christopher Kulla 0dca86bc09 Speedup string concat op (#1104)
The string concatenation op was going through sprintf which forced at least one
memory allocation to happen, in addition to the expense of going through the parsing logic, etc ... This was roughly doubling the cost of this (already expensive) operation. This commit implements a more direct concatenation via memcpy, and uses a small stack buffer in most cases.
2020-01-27 11:57:33 -08:00
Derek Haase e886d52884 Don't merge a layer if it's an entry layer (#1103)
Don't merge a layer if it's an entry layer
Add test case for merging duplicate layers that are also entry layers.
2020-01-27 11:31:30 -08:00
Larry Gritz 07509b764d Oh no, Alex wasn't in the credits 2020-01-23 18:08:00 -08:00
Larry Gritz 951f32880f Fix CI problems on GI, need OpenEXR 2.3+ (#1100)
Not sure why, but something changed recently on GitHub CI that is
causing our CI tests to fail... but not on the OIIO built itself, only
on the OpenEXR dependency build, and only when using OpenEXR 2.2.

I don't have time for this nonsense, so just adjust all the GH CI
tests to use OpenEXR >= 2.3. Adjust some of the TravisCI tests to use
OpenEXR 2.2 so we still have some proper test coverage of it.
2020-01-23 16:44:06 -08:00
Larry Gritz 026f36215c Fix incorrect OSL_DEBUG definition (#1099) 2020-01-23 10:58:35 -08:00
Larry Gritz 9a1c0db20e CI: Add Linux+clang test case, and other cleanup (#1098) 2020-01-20 09:52:37 -08:00
Larry Gritz 21669bc2da CI: On Linux, preinstall libsquish & qt5 (#1097)
libsquish saves a little OIIO build time by not having to build the
embedded version.

qt5 lets the CI build osltoy (doesn't run it, but makes sure there's a
clean build).. and sure enough, there wasn't a clean build on gcc8, so
I have a fix for a picky warning.
2020-01-20 09:52:02 -08:00
Larry Gritz 4a0693a242 Slight revision of detection of C++ version (#1095)
The main change is recognizing which MSVS version is C++14 compliant.
Also fixed some comment typos, and initial support for C++20 detection.
2020-01-20 09:51:34 -08:00
Alex Wells a54b44ba05 Math and aliasing improvements (#1096)
* Math and aliasing improvements:
Move inclusion of Imath*cuda.h from Imathx.h to oslconfig.h
Avoid aliasing in helper math functions by not using Vec3::operator [] and instead accessing .x, .y, .z data members directly.  Likewise for Vec2.
Avoid aliasing in helper math functions by not calling Matrix44::operator [] which returns a float *.  Instead use the x[4][4] datamember directly which keeps it type safe and avoids casting down to a float *.
Made math helper functions static OSL_FORCELINE where possible to avoid any collisions with other translation units who might be compiled with different compiler flags (like target ISA).
To make some of the aliasing avoidance changes, needed to introduce some free functions to be called instead of existing base class methods (which exist in a different open source project).
Partitioned general purpose inverse of Matrix44 into:
  test_if_affine
  affineInverse - fast path that is SIMD friendly
   nonAffineInverse - slow path to be used outside SIMD loop to
                      handle any non-affine matrices
Changed math helpers declared in OSL namespace to work on OSL::Matrix44, OSL::Vec3, etc. instead of Imath::Matrix44<T> as the helpers would not have function should OSL::Matrix44 be defined as anything other than Imath::Matrix44<T>.
Updated Matrix22 to avoid taking addresses with memset and memcpy that could prevent compiler Scalar Replacement of Aggregates optimizations.
Avoid aliasing issues in Matrix22 implementation by removing Matrix22::operator[] and using .x[2][2] directly and avoiding Vec2::operator[].
Removed default parameter to Matrix22::inverse(bool singExc) and added Matrix22::inverse() const noexcept, to allow for improved execution within SIMD loops.
Unrolled small loops in math helpers to avoid introducing control flow and dependencies during execution.
Updated opmatrix.cpp to call free function versions of transpose and multDirMatrix to utilized the versions added to Imathx.h
Added OSL_PRAGMA(unquoted) as a cross platform means of declaring a pragma
Added OSL_INTEL_PRAGMA to emit pragmas that are specific to ICC
Added OSL_CLANG_PRAGMA to emit pragmas that are specific to Clang
Added OSL_CLANG_ATTRIBUTE to emit attributes that are specific to Clang

* Fixed compiler warning error: suggest parentheses around comparison in operand of | [-Werror=parentheses]

* Fix error: OSL_v1_11::Matrix44 OSL_v1_11::nonAffineInverse(const Matrix44&) defined but not used [-Werror=unused-function
2020-01-20 09:50:52 -08:00
Larry Gritz e0ef30ce11 Add generation of cmake config files for export (#1092)
This lets projects directly use OSL as imported targets without any
"FindOSL.cmake" file.
2020-01-12 20:21:57 -08:00
Larry Gritz ae303bc0d4 Document in CHANGES that we renamed the ENABLERTTI build option 2020-01-09 12:18:38 -08:00
Larry Gritz e7a36e906a Add missing pugi libs to testrender linkage (#1094) 2020-01-09 12:03:52 -08:00
Larry Gritz 84764f823b Some stylistic touch-ups on compiler related macros (#1093)
* Port a bunch of compiler identification and manipulation macros from
  OIIO's platform.h to OSL's oslconfig.h. (Renaming OIIO_blah -> OSL_blah
  obviously.)

* Rename the recently-added OSL_INLINE -> OSL_FORCEINLINE to match the
  similar macro from OIIO and use OIIO's definition which is is more
  robust to a wider range of compilers. Rename many places where we
  previously used OIIO_FORCEINLINE to the OSL name.

* Rename the recently-added OSL_EXPECT_TRUE and OSL_EXPECT_FALSE ->
  OSL_LIKELY and OSL_UNLIKELY, porting and matching the similar macro
  that we already used extensively from OIIO. Rename all the places
  where we used it with the OIIO name.

* Change bare references to `__cplusplus >= 201402L` into
  `OSL_CPLUSPUS_VERSION >= 14`.

* Change stray OIIO_CONSTEXPR to OSL_CONSTEXPR which we have had for
  a while now.
2020-01-08 15:04:06 -08:00
marsupial be720a31ea Fix up some build issues. (#1091) 2020-01-06 15:55:38 -08:00
Larry Gritz 21716fd744 Compensate for CI machine changs for python install (#2445)
Something changed about homebrew versons, I guess, and the combination
of python + cmake on both GitHub CI and TravisCI broke OSX. Modifying
install_homebrew_deps.bash to be sure it upgraded to the latest
version of both packages seems to solve the problem.

Ported from OIIO, recently fixed here.
2020-01-03 17:35:17 -08:00
Alex Wells f682b75bb0 Refactor implementation of template<class T, int PARTIALS> Dual (#1088)
* Refactor implementation of template<class T, int PARTIALS> dual to not use array based data members and avoid any control flow loops for operations on it.  The change better enables compilers to keep values in registers via SROA (Scalar Replacement of Aggregates) optimizations as well as enable more efficient SIMD vectorization of loops using dual types.
Update opcolor implementation to avoid subscript operators [0],[1],[2] and use named data members .x, .y. z to avoid pointer aliasing issues.
Update opcolor implementation to avoid mat[?][?] operators that loose multidimensional C array data type  and access the underlying c array directly mat.x[?][?]

* To address internal compiler error issue with gcc8 & c++14 changed static loop unrolling strategy for __GNUC__.
Removed use of a local variable partial_count that was erronously being marked as unused by a compiler.

* When compiled with USE_OPTIX=1, there were some missing OSL_HOSTDEVICE decorations on the constructors for the Dual specializations
2020-01-03 14:53:27 -08:00
Larry Gritz 8c5898a184 Remove pointless ternary (#1090) 2019-12-18 16:37:58 -08:00
Larry Gritz f4ec638e6b Excise support for Boost Wave (#1089)
We don't need it anymore, we use clang library preprocessor on all
configurations now.
2019-12-18 15:38:48 -08:00
Larry Gritz 2252e1ab64 Replace ASSERT -> OSL_ASSERT and DASSERT -> OSL_DASSERT. (#1087)
The old macros were from OIIO, namespace polluting, and ASSERT always
aborted the process. The new macros won't conflict with other apps,
and OSL_ASSERT prints error always but only aborts for debug mode,
which discussion concluded was the preferred behavior.

I also policed up the whole set of assertions, and there were many
instances of:

* ASSERT that I deemed downgradable to DASSERT.

* ASSERT/DASSERT that I deemed entirely unnecessary and deleted.

* A few asserts that should always have been OIIO_CHECK_* unit test
  macros.
2019-12-18 10:40:19 -08:00
Larry Gritz e2c3743a3d oslc can generate dependency files (#1085)
This patch adds support for `-M`, `-MM`, `-MD`, `-MMD`, `-MF` flags,
akin to how they are used in gcc or clang, to generate dependency
files that can be used by make, ninja, etc., to express header
dependencies of osl files.  For example, output might look like:

    $ oslc -MMD test.osl
    Compiled test.osl -> test.oso
    $ cat test.d
    test.oso: test.osl \
      dist/macosx/share/OSL/shaders/color2.h \
      dist/macosx/share/OSL/shaders/stdosl.h

`-MD` and `-MMD` output a dependency file (all headers for `-MD`, just
user headers for `-MMD`), by default to `<inputbasename>.d`, but
overrideable by `-MF<filename>`.

`-M` and `-MM` are versions of `-MD` and `-MMD` but that print the
resulting dependency list to stdout.

We also adjust the printing of "Compiled foo.osl -> foo.oso" so that
it does not happen in the case of `-E`, `-M`, and `-MM` when other
specific output is expected to comprise the whole of stdout.

Also, I *think* that we now no longer use Boost Wave at all on any
platforms, so I put in an `#error` compiler directive to verify. If
nobody complains, I'll soon excise all of the Boost Wave specific
code.
2019-12-18 10:39:22 -08:00
Larry Gritz 9162a30915 Raise minimum LLVM to 6.0, drop LLVM 5 (#1046)
LLVM 9 is about to branch... supporting 6,7,8,9 is more than enough, we don't
need to support 5 versions back.

Also, LLVM 6 is the minimum that can be used with the new OptiX work.
2019-12-16 09:10:03 -08:00
Larry Gritz 5b7998e64f alloca cleanup (#1086) 2019-12-16 09:08:04 -08:00
Larry Gritz 0f0ff37d3c Adjust GH CI tests to include vs OIIO 2.1 2019-12-13 23:13:26 -08:00
Larry Gritz 25afa98528 osl internals: be clear about printf style formatting (#1082)
Found a couple more internals to change the names to be extra sure we
keep straight which ones are "printf-style" formatting ("%6.2f"), versus
future C++ converstion of std::format (Python-like: "{:6.2}"). Currently
we use exclusively printf-style, but some day there may be a mix, so I'm
removing ambiguity in the names. This is strictly internal, does not
change any public APIs.
2019-12-13 10:48:29 -08:00
Larry Gritz 710cc62f50 Missing quote broke 'make help', oops. (#1084) 2019-12-12 08:17:53 -08:00
Larry Gritz fc08ab5d21 Work around Cuda problem with the {fmt} lib that OIIO bundles (#1083)
Just disable it when compiling Cuda code -- which doesn't need this
functionality anyway. That skips the headers that Cuda is complaining
about.
2019-12-04 14:45:26 -08:00
Larry Gritz de4efd000b changes 2019-12-03 16:38:13 -08:00
Larry Gritz 3aba693fb5 oslc --embed-source : embed preprocessed source at end of oso file (#1081)
This can be useful in debugging situations, since the oso file would
completly contain a readable (though preprocessed) and recompilable
version of the source.

In the oso file, this is signified by the hint `%preprocessed_source`,
and following that the remainder of the file is assumed to be source
code or comments and will be ignored by the oso parser.
2019-12-02 15:31:16 -08:00
Larry Gritz 1e6869039a Assertion overhaul (#1080)
New macros:

* OSL_ASSERT / OSL_ASSERT_MSG -- always test, always print error if the
  test fails, abort only in debug build.

* OSL_DASSERT / OSL_DASSERT_MSG -- debug mode only test, print, abort.
  Does nothing for release build.

Eschew the old OIIO macros ASSERT/DASSERT, since it is perferable to not
purposely abort when in release mode.

Ported over from OIIO copies of a few other related macros.

This patch just adds definitions, we will change the existing macros
in subsequent PRs.
2019-11-27 12:43:02 -08:00
Larry Gritz edc52c053b Better logic about whether OIIO plugin must be module or shared lib (#1078)
OIIO master/2.1 on OSX changed the extension used for imageio plugins.
Make us do the right thing here. OSX problem only, and only when
straddling the OIIO 2.0/2.1 boundary.
2019-11-22 17:47:39 -08:00
Larry Gritz 0014b64aec Remove pointless assertions in TypeSpec class (#1079) 2019-11-22 15:53:49 -08:00
Larry Gritz f8bcfcf255 Be more explicit about which string formatting convention we use (#1076)
With OIIO 2.0 as our minimum, change all the internal error reporting
functions taking printf-style arguments to use the errorf() convention,
thus reserving the name error() for an eventual future where we use
C++20 format conventions.

Also make sure that we are consistently using the right OIIO functions
themselves -- sprintf, not format, for example.

This doesn't affect any of OSL's public APIs, this is all strictly
internal and does not break public API compatibility.
2019-11-20 23:14:33 -08:00
Larry Gritz c76d6bac7e Bump version after dev preview release 2019-11-20 16:58:07 -08:00
Larry Gritz fe411bd1df changes 2019-11-20 16:58:07 -08:00
Larry Gritz cdf5c79d0d Bump version for internal dev snapshot 2019-11-19 17:32:55 -08:00
Larry Gritz ffcf0c308c Fix bug in finding PugiXML when it comes with OIIO (#1077) 2019-11-19 17:32:24 -08:00
Larry Gritz 7b12e92eb9 Ensure locale independence (#1075)
* Allow testshade to override global locale for testing. Either with --locale command line arg or TESTSHADE_LOCALE env variable.

* Ensure locale independence: I found several additional places where we were not being  locale independent, so if run in a locale with "," as the decimal separators, output would change or bad things would happen.
2019-11-18 10:10:28 -08:00
Larry Gritz 6b242c6c29 Work around llvm download problem
The llvm download for 6.0.1 seems to be broken. Unstick our CI by using
6.0.0 instead.
2019-11-16 23:20:16 -08:00
Larry Gritz 7f75aae70d SPI: Bump Partio spcomp2 release 2019-11-14 14:26:28 -08:00
aconty 089ae7ea29 Uncomment old lines to fix rpath on macosx (#1074)
Build stopped working with rpath after latest overhaul. This seems to fix it.
2019-11-12 08:26:23 -08:00
Larry Gritz 220b05cb43 Bump GH CI Mac image to latest 2019-11-08 15:13:20 -08:00
Larry Gritz 3a06e88f6f Handle escaped string literals (like "\tfoo\n") more correctly. (#1073)
"Unescape" all string literals in .osl and .oso as they are parsed,
then "escape" them properly for output.  We weren't being careful and
consistent before. This led to at least two subtle behavioral errors:

1. oslinfo would appear to add an extra set of escape characters to
   metadata values that contained escape codes.

2. If s = "\n", then strlen(s) was 1 if s was a local variable, but was
   incorrectly 2 (wowza!) if s was a parameter!

* Add fixed version of parse_string (https://github.com/OpenImageIO/oiio/pull/2386)
2019-11-07 10:30:49 -08:00
Larry Gritz d3206b99eb CMake and CI overhaul (#1072)
I prototyped all this stuff in OIIO over the last month, and now am
finally porting the methodology to OSL. Major changes:

* Bump CMake minimum to 3.12

* Massive refactor of cmake files to move to modern idioms and best
  practices. Beware some changed conventions for controlling the build:
    - CMAKE_CXX_STANDARD instead of USE_CPP
    - CXX_VISIBILITY_PRESET instead of HIDESYMBOLS
    - BUILD_SHARED_LIBS instead of BUILDSTATIC
    - Package_ROOT to hint where to find dependencies, instead of
      some random selection of PACKAGEHOME, PACKAGE_ROOT_DIR, etc.

* Start using GitHub CI.
2019-11-07 00:01:15 -08:00
Larry Gritz c042d24cfd Fix how we ask for LLVM static libs (#1070) 2019-10-29 23:13:20 -07:00
Larry Gritz f545b6c571 Python3 safety (#1071) 2019-10-29 17:44:22 -07:00
Larry Gritz daffabf08c Update INSTALL
[ ci skip ]
2019-10-25 19:16:30 -07:00
Christopher Kulla 30f64c07c2 Make ShaderGroupBegin re-entrant when parsing a description from a pickled representation (#1067) 2019-10-16 17:07:37 -07:00
Larry Gritz 47ff9ec2e8 Changes
[ci skip]
2019-10-07 11:55:09 -07:00
Christopher Kulla 02d364e7cb Fix dual implementation of division so that the value is consistent with regular division (#1066) 2019-10-03 15:09:10 -07:00
Larry Gritz 55bd37b098 Ensure a new enough cmake for OIIO master (#1065)
Recent changes in OIIO master's build scripts require CMake 3.12+.
Also update openexr build script to handle OpenEXR 2.4 (copied from OIIO).
2019-10-01 18:41:39 -07:00
Larry Gritz 912633af99 SPI build cleanup (#1062)
Make it match things recently done to OIIO.

Prep for a Rez release.
2019-09-20 09:56:19 -07:00
timgrant af3024bf0c OptiX string closure params fix (#1064)
* Make following DeviceString variables to the underlying char* conditional.

* Update the string example code for the microfacet ID in the CUDA wrapper.

* Add an OptiX test for string closure params using the microfacet distribution.
2019-09-18 16:03:36 -07:00
timgrant 2b6e65b1a4 Overhaul OptiX variable creation (#1061)
* Overhaul how OptiX variables are created.

* Use the sym TypeDesc instead of c_str() when mapping to an OptiX type.

* Prefer TypeDesc over std::string for communicating types when creating CUDA variables. Remove redundant call to createOptixMetadata().
2019-09-17 16:00:35 -07:00
timgrant e4b59038ad Make rend_get_userdata behave more like the host version. (#1060) 2019-09-13 10:22:56 -07:00
Larry Gritz 530990b476 Mark more tests as passing OptiX mode
Also bump the default optix in my makefile wrapper for SPI, don't know
why that was so old.
2019-09-13 10:22:35 -07:00
Tim Grant f4cf6a63c2 Allow init ops in the OptiX path. Check for init ops first in llvm_assign_initial_value to make subsequent clauses slightly less awkward. 2019-09-12 16:03:15 -07:00
Tim Grant b4d4630fb8 Relax the alignment check when creating OptiX/CUDA variables. 2019-09-12 16:03:15 -07:00
Larry Gritz 00984c339f LLVM 9 / clang 9 compatibility (#1058) 2019-09-12 13:11:27 -07:00
marsupial f0a0039ca9 Fix private header inclusion of opcolor.h (#1053)
* Extend ShadingSystem::getattribute of type pointer's to also return the size of the pointer.
Add "colorsystem:colorspace" to ShadingSystem::getattribute.
Remove private include of opcolor.h.

* Be a little less hackey about the whole thing

* Have gettatrr return size and number of strings for a more general pattern.
2019-09-06 14:05:19 -07:00
Declan Russell 9c8dd33483 Add remaining matrix ops to optix (#1054)
* Add remaining matrix ops to optix

* Fix compilation fail

* Make llvm_load_value string-aware
2019-09-05 18:08:25 -07:00
Larry Gritz 473e1f6e2d Documentation touch-ups
Includes slight reformatting of the license text to make it correctly
be auto-recognized by GitHub and have the license displayed. The content
hasn't changed, it's still the 3-clause BSD, but it's *exactly* copied
from what GitHub wants to match against.
2019-08-16 12:44:14 -07:00
Larry Gritz 8f4b755e2a Bump version after dev tag 2019-08-15 15:09:26 -07:00
marsupial 5ee8f866e2 Fix exit not being recognized as basic block end (#1051)
Stale assignment elision was broken in the presence of `exit`.

In general

    a = 10;
    ... stuff not involving `a`...
    a = 20;

sees two assignments within the same basic block, and because `a` is not used between the two assignments, the first one can be eliminated.

But this optimization ("stale assignment elision") was wrong for this modified code:

    a = 10;
    return;  // note: `return` in the main shader body is the same as `exit()`
    a = 20;

because the `return` changes things -- the second assignment won't be executed, and therefore should not retroactively eliminate the earlier assignment. The correct final value of a is indeed 10.

The problem boiled down to a bug in OSOProcessorBase::find_basic_blocks, where the `exit` op was simply not recognized as terminating its basic block (since it is a jump).
2019-08-15 15:06:07 -07:00
Larry Gritz 3635cd0e7e docs for tag 2019-08-09 11:23:16 -07:00
Larry Gritz b6400e2b33 Allow aggregate component access with .[xyzrgb] (#1049)
Spatial geometry triples (point, vector, normal) now support A.x, A.y,
A.z as synonyms for A[0], A[1], A[2], respectively. It's not the
notation I prefer (obviously, or I would have done it 25 years ago),
but other people really dig it, so fine by me.

Colors now support A.r, A.g, A.b as synonyms for A[0], A[1], A[2],
respectively.  To be honest, this worries me a little because I fear
we will regret it if we ever shift to supporting spectral rendering
(and the components will not necessarily represent red, green, and
blue, and may have arbitrary number). But again, people really seem to
like this, so fine, but don't come complaining to me in a few years
when your shaders all need rewriting for your new spectral renderer.

In both cases, it's for direct reference to lvalues (variables, including
references passed as arguments to functions):

    val = P.x;   // yes
    P.y = val;   // yes
    function_with_float_param (P.z);   // yes

But you can't use this notations on arbitrary expressions:

    val = function_returning_color().r;   // no
    val = (P + N).y;                      // no, double ick

We are also NOT supporting "swizzling."

Note that this is strictly an oslc-side change, underneath C.r compiles
to the same ops as C[0] always did, so newly compiled shader using this
new syntax can be executed with old renderers/shading engines.
2019-08-09 11:22:40 -07:00
Larry Gritz f6a00194b2 texture "missingalpha" optinal param generated the wrong IR and crashed. (#1044) 2019-08-09 10:36:07 -07:00
Алексей 3f7a13ba5e Fix using macroses for Windows targets (#1048) 2019-08-05 07:55:56 -07:00
Алексей 5ddfae7da6 Some fixes for mingw compiler (#1047)
* Fix find pugixml 1.9

* Allow to properly export symbols by mingw compiler

* Fix linking osltoy with liboslexec
2019-08-02 11:04:31 -07:00
Larry Gritz 0245f94590 Fix typo in cmake message 2019-07-28 22:29:09 -07:00
Larry Gritz 78c15321aa Added movies 2019-07-23 22:44:38 -07:00
Larry Gritz b6829608cf Fix docs use of quotation marks 2019-07-23 22:10:01 -05:00
Larry Gritz 60d17dfd07 QFontMetrics.width() is marked as deprecated in new Qt. (#1043)
Keep warnings about marked-as-deprecated methods from breaking the OSL build.

On OSX, Homebrew just upgraded to a new enough Qt to see this breakage.

Also fix install_homebrew_deps to make sure Travis OSX test can find
Qt so it builds osltoy. (It wasn't before, so this build break would
not have been found by Travis-CI.)
2019-07-23 19:01:22 -07:00
Declan Russell 6e0deefa84 Fix crash in optimize_group when compiling transform command for OptiX and added OptiX support for a subset of matrix ops #1041 (#1042) 2019-07-23 10:44:40 -07:00
marsupial 3b034a4fa3 Define FMT_DEPRECATED for CUDA, as NVCC doesn't like deprecated attributes (#1039) 2019-07-15 22:18:04 -07:00
Larry Gritz 1fd6847ca9 Bump minimum OIIO version to 2.0 (#1038) 2019-07-08 10:41:00 -07:00
Christopher Kulla ae65c115b3 Avoid creating tiny std::vectors during LLVM code generation where possible
Refactor call_function methods to use a span instead of raw pointers to unify disparate idioms

Simplify llvm_call_function to use a short vector as it is never used on very long arrays
2019-07-08 10:35:33 -07:00
marsupial 1cbec0627b Fix sign/unsigned comparsison warning/error (#1037) 2019-07-04 10:11:29 -07:00
Christopher Kulla bfb937878e Constant fold array access even if they are out-of-bounds 2019-07-03 17:17:02 -07:00
Christopher Kulla 22fb810ee1 Avoid creating tiny std::vectors during constant folding where possible
Refactor insert_code method to use a span instead of a vector to facilitate the more efficient idiom
2019-07-03 15:36:14 -07:00
Christopher Kulla a5d8381afb Change the API of RendererServices::get_texture_handle to also provide a texture_thread_info handle (#1033)
Remove get_texture_perthread from RendererServices to reduce confusion

If a texture_handle is not provided to the texture related calls, attempt to get one and then always use the texture_handle version of the call since it also accepts a texture_thread_info

Always fetch a texture_handle before trying to make a call into the OIIO texture system so that texture_thread_info can be consistently used

Constant fold gettextureinfo even if the call would fail (and generate an error message to maintain runtime behavior)

Constant fold gettextureinfo even for arrays (did not require extra code)
2019-07-02 15:20:32 -07:00
marsupial cb2f7b8cdc Respect lockgeom default when building from commands. Remove ASSERT during ReParameter (#1032) 2019-06-28 11:58:46 -07:00
Larry Gritz dc94e1317d ASTNode: Make long chains of nodes (though m_next) free serially, not recursively. (#1031)
Avoids stack overflow for hideously complicated parse trees.
2019-06-19 10:53:33 -07:00
marsupial 3f936e280d Fix OSLQuery::init return value (#1030) 2019-06-17 21:02:18 -07:00
timgrant dfa26a5c53 OptiX closure param fix (#1029)
* Add OSL namespace to optix::Exception to fix compile error.

* Fix illegal closure param type check when assigning initial values to OptiX params.
2019-06-14 15:51:01 -07:00
Declan Russell 2dcd109094 Add support for native OSL closures in OptiX (#1028)
The current implementation of the OptiX run time defines its own closure structures that replicate that of the native OSL closure structures. This is likely just legacy code as it was easier to use OptiX types like float3 than add support the native OSL types. Removing this duplication and using the native OSL closures improves the maintainability of the code as you will no longer need duplicate logic if the structures ever change.

* Add support for native OSL closures in OptiX

* Ensure Imathx.h is included before OpenImageIo headers in device code

* Add more intelligent memory alignment logic

* Remove unnecessary ustring.h include
2019-06-13 11:39:53 -07:00
Larry Gritz 2fa42516b9 Allow shader params with empty brace inits: (#967)
Allow shader params with empty brace inits:

    type myarray[] = {},
    mystruct S = {}

Un-lengthed arrays, if they aren't connected or given a concrete
instance value, still default to length 1 (we don't allow 0-length
arrays, that's a whole other can of worms), but this is now treated as
equivalent to `= { default_value }` (0 for int or float, "" for string).

And it works for structs, too, just means to initialize all the elements
to is obvious (0, "") default values.

It's syntactic sugar, but it removes some clutter for people who want to
have shader parameters that are arrays of undetermined length (and thus
are probably expected to have a runtime-assigned instance value or be
conntected to an output of an earlier layer within the shader group),
removes the requirement for spelling out an initializing value that
won't be used anyway.
2019-05-24 09:37:55 -07:00
Larry Gritz 9d867289f7 Improve errors for badly formed serialized shaders (#1026)
When using the variety of ShaderGroupBegin that takes a serialized
description of the group, errors in the individual 'shader', 'param',
or 'connect' commands were not bubbled up into a proper error message
for the ShaderGroupBegin call itself, nor caused it to return null
as the group.

Be more diligent about printing the group name with all group setup
errors. This includes in testshade, no longer accidentally clearing the
group name.
2019-05-24 09:21:57 -07:00
Larry Gritz 7b72d2f47d Port FindOpenEXR.cmake fixes from OIIO (#1022) 2019-05-22 12:13:39 -07:00
Larry Gritz 9766aedb79 Install crash handlers with stack trace dump (#1019)
Recently, OIIO sysutil.h added a way to set up a stack trace dump in
case of crash. Use those in OSL binary commands (it does not
automatically happen from the library). This only work with a new
enough version of OIIO, and only if that OIIO was compiled with a new
enough boost to contain boost's stack trace library (>= 1.65).

This is primarily to help developers figure out what's going on with
CI tests fail on remote machines -- you can't catch it in the
debugger, but maybe the stack trace will give you the clue you need as
to what's going on. I definitely don't expect it to be very helpful if
the crash happens in the JITed shader. But if the crash is in our code,
maybe it will help the detective work.

To that end, we also change the testsuite runtest.py so that when a
command fails entirely, print its console output.

And bump appveyor boost to 1.69, so that it's new enough to support
the stack trace library.
2019-05-14 14:02:34 -07:00
Larry Gritz 5b4998764e Enable OptiX on many tests (#1018)
Add 'OPTIX' label files to a whole bunch of testsuite tests to force
them to run in OptiX mode also.

Make sure optix tests run both optimized and unoptimized.

Moany tests still ran 'testsuite -g 2 2' to run at 4 points as if on a
grid. This was an artifact from the early days when we had a "batched
shader bytecode interpreter" that handled "varying" specially and
needed to run on multiple points at once to ensure that they were
shading entire grids properly. But once we switched to LLVM JIT and a
"single point shading model", that was no longer necessary. But never
had a good reason to change them before.

Lots of tests "failed" OptiX mode just because printf wasn't working
correctly for multiple points. That's silly, we can test printf interleaving
separately and with one test. No need to make passing dozens or hundreds
of others contingent on that one problem, rather than hinging on whether
OptiX path can really implement the feature that the test was designed
to demonstrate.

So for a bunch of tests, I changed them from running 'testsuite -g 2 2' to
just running on one point, and enabled OptiX mode to get a pass.

All in all now, I believe we pass 37 tests in OptiX mode (both optimized
and not optimized). We will try to grow this week by week.
2019-05-13 15:55:04 -07:00
Declan Russell 184ae4fbf0 Windows build (#1020)
* Allow OSL to build with USE_LLVM_BITCODE enabled on windows

* Explicitly call python script from cmake python

* Added NOMINMAX define required before including optix_world.h on windows
2019-05-13 12:13:04 -07:00
marsupial 022eefb3e6 CPU & Optix "rgb" <=> "sRGB" color transformation (#1013)
* Add sRGB <-> linear routines

* Remove typed overrides for RGB <-> XYZ

* Update transformc test

* Add linear to rgb clauses
2019-05-10 17:11:58 -07:00
ThiagoIze 7d3f581a93 __attribute__((aligned())) does not work on Windows (no error is given even though alignment never happens). Use C++11 alignas for cross-platform compatibility. (#1017) 2019-05-10 10:28:13 -07:00
Larry Gritz 9956898e99 CHANGES 2019-05-06 12:52:31 -07:00
marsupial 92f25382f1 Optix compilation of opcolor.cpp (#1012)
* Add flipv parameter to grid-renderer.

* Fix shutdown problem

* Refactor opcolor for GPU devices.

* Explicit instantiation for transformc
2019-05-03 17:43:48 -07:00
marsupial 9ee13e259d Optix simplification / cleanup (#1011)
* Send bitcode as an array: avoids a temporary allocation and passing a std::vector.

* Add OSL_CONSTANT_DATA decorator, and remove the CPU->GPU transfer of pvt::Spline::gBasisSet.

* Add BackendLLVM::llvm_load_string

* Remove unused optix calls.
2019-05-02 14:41:17 -07:00
Larry Gritz 66459c4d29 Warn about missed optimizations (#1010)
* Warn about missed optimizations

* Properly track gettextureinfo handle use in the stats.

* New ShadingSystem option: "opt_warnings" enables warnings about
  things that couldn't be optimized and may be performance issues.

* New ShadingSystem option: "gpu_opt_error" enables full error status
  of the subset of those warnings that are also hard no-go's when
  executing on GPUs.

As an example, the first such warning/error is for texture calls where
the name of the texture cannot be fully resolved to a known string
constant during the course of runtime optimization. We will add other
warnings/errors over time.

The warnings/errors are sent back to the renderer's ErrorHandler,
and as an example they look like this:

    Optimization warning:
      group:  bumpy_material_14
      layer:  disp_texture_2
      source: shaders/tex.osl:58
      issue:  texture(): texture name cannot be reduced to a constant.
2019-05-01 18:34:01 -07:00
marsupial 652bd8dbea Optix: support array and va_args printing (#1007)
* Optix: support array and va_args printing

* Adresss issues raised.

* Remove thread-testing from osl_printf for Optix (this should be handled by the test-runner).
2019-05-01 18:31:32 -07:00
Larry Gritz 7e57304373 testsuite runtest.py cleanup (#1009)
* Fix bug from PR 1001, default value for missing OSL_SOURCE_DIR env
  variable should not have included the testsuite directory itself.

* Be sure to correctly redirect all stderr to the same saved file as
  stdout. This makes it easier to have testsuite entries that test
  warning or error output.
2019-04-30 22:59:45 -07:00
marsupial fae0ef0cad Optix opcolor (start) (#1002)
* Add additional more Imath_cuda types and overrides, but try to consolidate their inclusion (or maybe use the pragma in Imathx.h).

* Remove unused include.

* Fix an issue with OSL::ShadingSystemImpl and it's colorspace.

* Add colorspace strings to Device.
2019-04-30 14:03:17 -07:00
Chris Kulla ced815834b When specifying a parameter value for an unbounded array, supplying a scalar parameter would lead to a failed assert 2019-04-25 11:20:06 -07:00
Declan Russell f63818681d Allow OSL to build with USE_LLVM_BITCODE enabled on windows (#998) 2019-04-24 22:07:52 -07:00
Declan Russell e73f8ab40d Improve FindOptiX.cmake logic (#997) 2019-04-24 22:07:15 -07:00
Larry Gritz 1a5dc143f5 SPI only: bump the version of partio we use internally (#1005) 2019-04-24 22:06:30 -07:00
Larry Gritz d354337843 Modify testsuite to run optix tests (#1004)
We previously had each test run twice: once with -O0 and again with
-O2. Because one tests the actual literal code specified in the shader
(without the possibility of being optimized away) and the other tests
the optimization to make sure it still matches.

This patch extends the logic to allow the possibility of every test
running in optix mode as well, if the code base is built with
USE_OPTIX=1.

For now, it only runs optix mode if the individual test has "optix"
in its name, or if the test directory has a file called "OPTIX" present.
Also, if environment variable TESTSUITE_OPTIX=1, it will try to run
*all* tests with optix mode (that's just for me... most of them fail
at the moment).

The eventual goal is for these conditions to change, so that in a
USE_OPTIX=1 build, *all* tests run optix flavors unless not marked
with a NOOPTIX file in their directory.

At the moment, *6* tests pass for me in OptiX mode. Now we can start
attacking the features to get more and more tests to pass identically
on CPU and GPU.

I realized that there were many tests that are only trying to test
that oslc issues the right error or warning for various malformed
code, or that are only compiling the shader to test oslinfo, or a few
other such cases that run oslc only and never try to execute their
shaders. So I also liberally sprinkled NOOPTIX as well as NOOPTIMIZE
marker files in those test directories, to skip optix tests, and also
skip a second "optimized" run of the same test (which was pointless,
because it wasn't executing at all).
2019-04-24 22:06:11 -07:00
Larry Gritz 958272eac2 Refactor testshade argument parsing (#1003)
We had a weird chicken-and-egg problem after a recent testshade
refactor, where getargs parsing made the individual shadingsystem
calls to set up the group, but also set other options we wished had
been established before this parsing starts.

The solution is change the main getargs to NOT fully set up the shader
group, but instead to just stash away the group setup args for later
processing. Then after the renderer and SS are fully set up
considering all the other options, we re-parse the stashed options and
set up the shader group.

This fixes some embarrassing reliance on the TESTSHADE_OPTIX environment
variable during tests.
2019-04-22 20:11:42 -07:00
marsupial 4b437777ce Testsuite and optix fixes (#1001)
* Allow testsuite to run (and hopefully pass) when built outside the source tree.

* Search for PTX files next to binary before PTX_PATH (installed path).
Fixes an issue when rebuilding with changes to PTX, that build would have to be installed to be tested.

* Add OSL::optix::Exception and catch the real optix::Exceptions in testshade.

* Make OptixGridRenderer::load_ptx_file without Optix a compile error

* Use OIIO to get the program directory and change OSL_USE_OPTIX guard

* Make optix_compat a private include & not installed.
  Explicitly include stdlib.h for malloc and free.
2019-04-22 16:44:37 -07:00
Larry Gritz 673cb79d35 Fix inadvertently missing SS::Parameter() implementation (#1000)
The implementation of #984 inadvertently lost one of the old
variants of the SS::Parameter() call. There was a 3-param version
and a 4-param version separately declared, but somehow in the code
that was merged, only the 4-param version has an implementation.
Fix by merging the declarations so that it's a 4-param method with
a default value for the last argument (which I think was my intent
all along).
2019-04-22 14:39:55 -07:00
Larry Gritz cbf687f9ac Print output of failed diffs when testing 2019-04-19 09:42:00 -07:00
Larry Gritz 35e1b04834 testshade --optix (#996)
Works for simple cases. Use with caution, there is a LOT that doesn't
work in the OptiX path. Embarrassingly so. But this refactor makes it so
that the last of the old "testoptix" oriented tests now work using
"testshade --optix".

It also requires that environment variable TESTSHADE_OPTIX=1 must be
set.  This is for weird reasons that have to do with argument orders,
and will go away in the next refactor of testshade, so I don't even
want to bother explaining. It's about to get fixed.

There is a lot that doesn't work properly. Frankly, I would encourage
onlookers to wait for another couple of checkins from me before wasting
any time on this. The most embarrassing parts will be fixed soon.
2019-04-18 23:22:15 -07:00
Larry Gritz 78b6e883bd Add build-time option to set gcc C++ ABI (ported from OIIO) (#995) 2019-04-15 23:00:35 -07:00
Larry Gritz 7c89fc6052 Extend linearstep and smooth_linearstep to color/point/vector/normal (#994) 2019-04-15 12:40:28 -07:00
Larry Gritz d710e39fab Revise shader install path and stdosl.h search (#956)
* Revise shader install path and stdosl.h search

Issue #955 points out that we install the example shaders (and stdosl.h)
in PREFIX/shaders. That may be fine for a totally custom directory, but
it's nonstandard and rightly frowned upon if the prefix is a system-wide
place like /usr. Just like docs go in PREFIX/share/doc, probably the
shaders ought to go in PREFIX/share/shaders.

So this patch makes that change. Does anybody think that will be
extremely disruptive?

Modify oslc/liboslcomp to search in the new location (as well as
the old), and while we're at it, I was able to significantly clean up
and compress find_stdoslpath(). Also adjusted what in retrospect was
a logical error in how we search for stdosl: I now think that the
user-supplied include paths (for example, `oslc -Ifoo -Ibar`)
probably ought to be the first places searched, not the last (as it was
before).

Fixes #955

* Move shaders to .../shared/OSL/shaders

* Allow option to control shader install dir
2019-04-12 11:23:01 -07:00
Larry Gritz 79954a3916 oslc: slight adjustment to assignment typechecking (#993)
Consider int=float to be a warning, not an error.
This is partly because C allows it and we ran accross some
examples where it seems more strict than necessary.
(Of course it works without warning if you use a cast, showing
that any trucation is intentional.)
2019-04-10 12:06:32 -07:00
Larry Gritz fd5677342b Fix up testrender error handling: use an ErrorHandler properly, not stderr (#992) 2019-04-08 08:59:09 -07:00
Larry Gritz 3318375f31 Improve oslc type error detection for variable declaration with init (#991)
Turns out that some of the various type checking we do for simple
assignment,

    x = y

was not being checked at all for variable declaration with initialization,

    Type x = y

So this patch adds the necessary checks. And also goes back and improves
the error messages for regular variable assignment, changing from messages
like

    Cannot assign 'float' to 'int'

to the more clear (I think, because it names the variable, and looks
more like the grammatical construct being complained about)

    Cannot assign int i = float
2019-04-05 16:43:45 -07:00
Larry Gritz e51663adb0 Change remaining refs to array_view to cspan (#990) 2019-04-05 12:14:50 -07:00
Larry Gritz dcbea18e7f testoptix is dead. Long live testrender! (#989)
This extensive refactor fully merges all remaining testoptix
functionality into testrender, and deletes the remnants of testoptix.

There's still lots of refactoring I intend to do moving forward,
especially as I made an optix mode to 'testshade' as well. But this
is a good checkpoint to merge.
2019-04-04 17:17:33 -07:00
Larry Gritz 8b50e69a43 Add all testoptix functionality to testrender
This attempts to merge them. In the process, it's a pretty big overhaul
of the internal organization of testrender, a lot of stuff moves around
between files and classes are refactored significantly.

N.B. render-veachmis changes slighty, only on osx, and I don't know why.
Return to investigate later.

Revise to bring in line with Roman's changes

I made a bunch of changes to testoptix, not altering any functionality
but just mashing things around to make it more symmetric to testrender
and make diffing between them easier.

Several file have been removed from testoptix, which now gets them
from the copies in testrender (so at least there's only one copy now):
all the .cu files, testoptix stringtable.{cpp,h},
shading.{cpp,h}, raytracer.h.

All that's left now in testoptix is testoptix.cpp, optixrend.h,
optirend.cpp. In a subsequent PR I will complete this process by
replicating all remaining testoptix functionality in testrender and
then getting rid of the remainder of testoptix.
2019-04-01 13:48:21 -07:00
Larry Gritz 6d02dd72b5 Revert "Add all testoptix functionality to testrender (#987)"
This reverts commit 3e1857fac5.
2019-04-01 12:37:28 -07:00
Larry Gritz c7480efbd5 CHANGES 2019-04-01 11:03:17 -07:00
Larry Gritz 3e1857fac5 Add all testoptix functionality to testrender (#987)
This attempts to merge them. In the process, it's a pretty big overhaul
of the internal organization of testrender, a lot of stuff moves around
between files and classes are refactored significantly.

N.B. render-veachmis changes slighty, only on osx, and I don't know why.
Return to investigate later.

Revise to bring in line with Roman's changes.

I made a bunch of changes to testoptix, not altering any functionality
but just mashing things around to make it more symmetric to testrender
and make diffing between them easier.

Several file have been removed from testoptix, which now gets them
from the copies in testrender (so at least there's only one copy now):
all the .cu files, testoptix stringtable.{cpp,h},
shading.{cpp,h}, raytracer.h.

All that's left now in testoptix is testoptix.cpp, optixrend.h,
optirend.cpp. In a subsequent PR I will complete this process by
replicating all remaining testoptix functionality in testrender and
then getting rid of the remainder of testoptix.
2019-04-01 10:58:55 -07:00
Larry Gritz e281f49f89 Fix oslc assertion on type constructor for unknown struct (#988)
The assertion was not needed, errors issue before this code is reached.
2019-03-30 11:07:22 -07:00
rzulak cf17ea5a0d Add texture lookup and 'texture-space' rendering to testoptix (974)
And a few more spline touch-ups.
2019-03-23 14:57:50 -07:00
Roman Zulak 99006ad468 Add spline functions to Optix. (974)
Fix osl_spline_xxx signatures for Optix.
2019-03-23 14:49:50 -07:00
rzulak b32a259bbb Synchronize CPU & GPU device strings. (974)
Fix Optix namespacing issues.
2019-03-23 13:36:05 -07:00
Roman Zulak f2cb33543b Fix Optix compilation problems for Dual<float3> (974) 2019-03-23 13:21:45 -07:00
rzulak 76e6452708 Refactor CPU spline code (974) 2019-03-23 13:17:02 -07:00
Larry Gritz 6fdfc41fa4 Update docs to reflect that LLVM 8 / clang 8 work fine 2019-03-23 09:57:40 -07:00
Larry Gritz cda5f6541e Fix related to thread-safe shader specification (#986)
PR #984 had a typo, which my unit tests didn't catch because it was
inside code that only is compiled when building OptiX support.
2019-03-22 10:33:04 -07:00
Christopher Kulla b3edc8ab3c Make sure recursive invocations of ConnectShaders operate on the same group (#985) 2019-03-21 16:30:02 -07:00
Larry Gritz 11d52bac68 ShadingSystem: allow for thread-safe/reentrant shader specification (#984)
The ShaderGroupBegin / ShaderGroupEnd (with interspersed Parameter,
Shader, and ConnectShaders calls between them) relied on hidden state
indicating which shader group was the single one undergoing
specification.  This made the shader declaration process unable to
occur concurrenty for different shaders by different threads.

This patch introduces new versions of Parameter(), Shader(), and
ConnectShaders() that take an explicit `ShaderGroup&` parameter and
don't depend on any saved state. Remember that ShaderGroupBegin
returns a ShaderGroupRef, it's this dereferenced object that is passed
to the other functions that help specify the contents of the group.
This allows multithreaded apps to be building the scene, including
shader specification, from many threads concurrently.

The old stateful versions remain, and are fine to continue using for
any apps that are sure that all shader declaration will be done
serially (though we will perhaps mull over whether to eventually
deprecate it entirely).  Though internally, the amount of saved state
is now reduced to merely the one shared pointer that designates which
is the single active group being specified, the other former bits of
state either being entirely redundant or moving to be local to the
group itself.
2019-03-20 18:00:27 -07:00
Larry Gritz d54022fa2f Fix oslc assertion when passing init-lists to array parameters (#983)
It's easiest to explain the situation by example:

    void receive_array_3 (float array[3]) { }
    void receive_array_any (float array[]) { }

    receive_array_3 ({1.0, 2.0, 3.0});
    receive_array_any ({1.0, 2.0, 3.0});

Both of these would fail/crash by hitting an assertion in oslc.  The
general pattern is when passing an initializer-list (like just saying
`{ a, b, c }`) to a user function formal parameter that's an array.
They failed for somewhat different reasons if the formal parameter
was a concretely-sized array or if it was an unsized array.

A little bit of typecheck-fu handles this case.
2019-03-20 13:26:33 -07:00
Larry Gritz 493eccd5d5 testoptix enhancements to make more analogous to testrender (#982)
* Change -r to -res to match testrender (and for that matter, make -res
  work for testshade, not -g). (In both cases, the old oddballs are
  silent synonyms.)

* Respond to several additional OSL options, and set them the same
  was as testrender

* Allow --iters (much like it works in testshade) to make it easy to
  run all the rays many times to make accurate timing easier.

Also do a little bit of synchronizing of near-identical code between
testshade, testrender, and testoptix. And synchronize some of the
analogous command line arguments (e.g., -res for everybody, not -res
for testrender and -r for testoptix and -g for testsahde).
2019-03-14 10:53:03 -07:00
Larry Gritz 5d0ea34369 Improve warnings about ill-advised use of comma operator (#978)
We previously had warnings that attempted to catch mistakes in using
the "comma operator" when the user intended an "aggregate type
constructor", for example:

    color x = (a, b, c);    // comma operator! equivalent to: x = c;
    color x = color(a,b,c); // this is what they probably meant

However, the way we implemented the warning was specific to assignment:

    x = (a, b, c);

and variable declaration with initialization:

    color x = (a, b, c);

But it missed similar bugs in other constructs, for example

    color x = Cdiffuse * (a, b, c);

Here the user surely intends to multiply Cdiffuse channel-by-channel
with color(a,b,c), but what they will actually get is Cfiffuse scaled
by float c.

This patch changes the strategy for this warning, no longer tied to
variable declaration or assignment, but more generally any time the
comma operator is used inside expression parentheses, it will give a
warning.
2019-03-14 10:44:18 -07:00
Larry Gritz 661e0810a7 Simplify flex/bison handling (#977)
Rely on CMake's own finding of flex/bison, simplifying our code to
just the helpful shortcut macro. Also make finding these REQUIRED,
which makes an easier-to-interpret error message than simply not
defining the macro.
2019-03-13 10:07:12 -07:00
Larry Gritz 2bee9957f7 Raise LLVM floor to 5.0, drop support for llvm 4 (#981)
* Raise LLVM floor to 5.0, drop support for llvm 4

* Bump appveyor llvm release (and use pre-installed LLVM rather than building)
2019-03-12 15:36:22 -07:00
Larry Gritz fdfc21ab22 SPI: make it easier to override using ninja 2019-03-12 10:03:06 -07:00
timgrant b1b3ab8cf1 OptiX path: Device noise update (#980)
* Factor out the CUDA-to-LLVM compilation shared between liboslexec and testoptix.

* Add some decorators and typedefs to allow math headers to be used for device code.

* Add device support for Gabor noise and generic noise. Add NoiseOptCUDA and a faux ShadingContext to use in device code.

* Rejigger the OSL DeviceStrings namespace.

* Add a test for Gabor and generic noise in testoptix-noise.

* Update DeviceString example code in wrapper.cu.

* Destroy the OptiX Context before exiting testoptix.
2019-03-08 18:13:49 -08:00
Larry Gritz 7f3b668c7f OptiX: always seem to need --cuda-path flag, even for cuda 9 (#979) 2019-03-06 14:47:57 -08:00
Larry Gritz 86db5b6cce FindLLVM: Make more robust to library configuration of llvm (#976)
In particular, some system distributions bundle everything in one
libLLVM, without a separate libLLVMMCJIT.
2019-03-05 14:43:27 -08:00
Larry Gritz 5d0668e55c SPI: make sure to use the right optix lib 2019-03-01 17:53:49 -08:00
timgrant c4f19c69ac OptiX path device string update (#973)
* Refine DevieString handling. Improve handling of userdata params when running in OptiX.

* Bring testoptix up to date.

* Use a more consistent namespace for DeivceStrings.

* Use ustring::format instead of sprintf when constructing CUDA variable names.

* Use a std::string instead of a ustring when constructing the CUDA variable name. Guard the ustring::sprintf use when constructing the userdata param name.

* Replace hash noise with simplex in the OptiX noise test (hash is unstable if ray hit points change ever so slightly as OptiX evolves).
2019-03-01 17:51:25 -08:00
Tim Grant 704d1a79b8 Pass a nullptr to optimize_group, in place of a ShadingContext pointer. 2019-03-01 17:39:12 -08:00
aconty d3da6d12d4 Forbid LPE repetitions inside groups (#972)
This is not useful in practice and we've seen a case of exponential DFA
state blowup in issue #971 because of its accidental use. This does not
make LPEs totally robust to ReDoS but prevents this particular mistake.
2019-02-19 10:26:23 -08:00
Larry Gritz 2ecbb4cb90 CHANGES 2019-02-01 15:06:33 -08:00
Larry Gritz 0c778aa477 Fix comment in makefile 2019-02-01 15:06:33 -08:00
Larry Gritz a52899642a SPI: modify site build scripts to allow it to build for spcomp2 2019-01-31 16:20:52 -08:00
Christopher Kulla 17f53d53da Fix bad copy/paste in recent library suffix addition 2019-01-17 10:08:17 -08:00
Larry Gritz 2933d47842 Allow optional library name suffix (#970)
This patch allows an optional suffix to be specified that will let you
produce something like liboslexec_spi.so or whatever. Use with caution,
or preferably not at all, if you don't absolutely need it).

Example of how it's used: Suppose you're at a facility that needs (don't
ask why) multiple versions of OSL to be built. And namespacing is not
enough, because if you have two copies of liboslexec.so, you can't
separately rpath them.
2019-01-16 15:19:05 -08:00
Larry Gritz 2713e05c58 Suppress warning about uninitialized variable (#968) 2019-01-16 15:18:46 -08:00
Larry Gritz a32d05612f Deprecate the auto-allocation of contexts and per-thread-info (#958)
There were a variety of places that took a Context* that defaulted
to null, where passing null means to let the called funtion allocate
a context.

This relies on a boost::thread_specific_pointer which could be easily
mishandled and lead to problems.

So with this patch, we move toward requiring the app to allocate and
own the contexts and PerThreadInfo objects.

* No more default null parameter value on contexts or threadinfo.

* Explicitly passing nullptr will still work (use with caution!) on
  2.0 with a warning, but will be a full error in 2.1 as that functionality
  is totally removed.

* execute() takes a ShadingContext& instead of ShadingConext*, to emphasize
  that it must not be null. (For 2.0, the pointer one will still exist
  and work, but is slated for deprecation.)

* Fixed comments that document "it's advised o pass a contexts, but simple
  apps can choose not to" to now imply that it's required.

* A bit of reorganization of SS::getattribute -- some group attrib
  queries required the group to already be optimized, and there were many
  calls to optimze_group that all had the implicit null context. These
  are all coalesced now, and it allocates a temporary context.

Fixes #691
2019-01-14 11:09:52 -08:00
Larry Gritz 9da2eab1b2 Improve thread safety of OSLCompiler (#953)
Fixes #654.

There's a problem with the lock we use to protect the global
`oslcompiler` pointer -- it's locked for the duration `osl_parse_buffer`
(where it's assigned), but it is used and also cleared to NULL after the
lock is released (in particular, the clearing that happens in compile()
and compile_buffer().

The solution is to move the lock itself to compile/compile_buffer, and
do all of the assignment, use, and clear within the scope of that lock.

I think this went unnoticed for so long because most of us highly
multithread the shader execution (and runtime optimization), but not the
initial compilation -- except for Issue #654, and my sincere apologies for
letting that slip through the cracks.
2019-01-12 09:07:56 -08:00
Larry Gritz 0316d8bc9c Change all calls to Strutil::format to Strutil::sprintf (#946)
In oslconfig.h, if the version of OSL is too old to have sprintf,
define it as a synonym for format.
2019-01-12 09:04:38 -08:00
Larry Gritz 144ad7ce55 Some C++ definition and other touch-ups (#950)
Some C++ definition and other touch-ups
Partly ported from equivalent changes in OIIO recently.
2019-01-11 14:17:03 -08:00
Larry Gritz 954d345b35 Remove long-deprecated methods (#945) 2019-01-11 14:16:03 -08:00
Larry Gritz d9a1c45d94 Fix custom namespace vs symbol hiding clash (#962)
I guess everbody who builds with NAMESPACE=... to customize OSL's namespace
must (like we do) pick a name that include the substring "OSL".
Because if they don't... a bunch of public API symbols will be improperly
hidden!

Oops. Seems like the most foolproof solution is that if a custom namespace
is supplied that doesn't include the substring "OSL", have the build
script prepend "OSL_". Then the symbol hiding regex will work.

(You may object: "But then you're not using exactly what they asked for!"
Correct, but remember we are already overriding their literal choice by
automatically appending the OSL version number as well.)

While there, also take care to hide symbols containing "pvt", which I
think should not be exposed, despite the fact that they're in the main
OSL namespace.
2019-01-11 14:10:29 -08:00
marsupial f7d53d9f21 [SPI] Update to latest partio version. (#961) 2019-01-08 16:31:36 -08:00
Larry Gritz 987f585576 Get rid of suspicious spurious reference (#959) 2019-01-04 16:35:30 -08:00
Larry Gritz 93833a6ef9 Fix transformc with derivs when using OCIO (#960)
I have no idea how this ever worked. In fact, it must never have, because
our checked-in reference output was wrong. But it kept matching the same
wrong until it didn't, and became a different kind of wrong on at least
one machine.

When doing transformc, where the space names necessitated using OCIO for
the transformation math, and only for the derivative case (the non-deriv
was fine all along), we were simply passing the wrong stride parameters
to the colorproc->apply() call.

Also, I noticed that we were trying to save a per-context "last
transformation" to avoid the lookup when doing repeats of needing the
same colorproc (basically, a 1-item LRU cached lookup of the
colorproc). But we never saved the space name, so the cache was not
operating.
2019-01-04 16:16:35 -08:00
Larry Gritz a29dc0fd94 Reword error with less yelling (#952)
Fixes #811
2019-01-04 10:41:28 -08:00
Larry Gritz 7521c385ff Fix bug with inverse spline (#954)
We were clipping the range incorrectly for bezier, where it needs
to step by 3 CVs for each span. Worked ok for the other spline
types, which step by 1.

Add a test that verify that a spline designed to give a f(x)=x response
does so, and also that its inverse is perfect.

Fixes #778
2019-01-04 10:40:36 -08:00
Larry Gritz df0d343e2a Fix bug in oslc loop code generation (#947)
The problem was specific to using an integer variable directly as the
loop test, rather than a comparison. So for example, this would work
fine:

    i = 3;
    while (i > 0) {
        --i;
    }

But this would loop forever:

    i = 3;
    while (i) {
        --i;
    }

Because of a hilarious chain of events, this would eventually lead to
the optimizer thinking that since the value of i was nonzero at the
beginning of the loop, it must be equivalent to while(1). There was a
subtle assumption that the scope of the loop control variable would be
entirey inside the condition code. That was true of the the temporary
created to hold the result of "i > 0", but not true of the direct use of
i itself.  The solution is to force it to create a bool comparison
(which turns into the same machine code later anyway, so there is no
efficiency issue here).

Fixes #776
2019-01-04 10:39:35 -08:00
Larry Gritz 424f1ee32e oslc: Fix crash when encountering for (;;) (#951)
An empty conditional clause of a `for` statement was leading to bad
things. It's understood that `for (;;)` means `for (;1;)`, so just
make sure that happens when parsing.

Fixes #688
2019-01-04 10:36:50 -08:00
Larry Gritz bcb0de1925 Fix group_name, group_init_name, group_entry_name (#957)
I didn't notice this in Tim's code before today, but he made the
retrieval of these group attributes more complex than they needed to be.
Instead of messing with pointers (which we avoid), you can just directly
getattribute(name,string&). So now we use that. Also eliminate group_name
entirely, since it's redundant with the existing groupname.
2019-01-04 08:21:17 -08:00
Larry Gritz 7b6beb9117 Change %.8g formatting to %.9g (#949)
%.9g is needed to totally guarantee full precision preservation for all
possible float32 values.
2019-01-03 10:49:59 -08:00
Alejandro Conty fb338337df Fix comment flagged in issue 527 2019-01-02 10:00:43 +01:00
Larry Gritz d54ab5181c Tweaks to pdf docs building 2018-12-23 13:19:54 -08:00
marsupial aedc0ee33a Fix array initialization counter (#948) 2018-12-18 23:06:51 -08:00
Larry Gritz 30838077b7 Docs update after release 2018-12-13 13:41:05 -08:00
Larry Gritz 3009615c31 Demote writing to non-output function parameters to be a warning. (#944)
It was never supposed to be allowed. It used to be ignored in most
cases, error neither detected nor issued. PR #878 "fixed" it to detect
the error. But there were too many shaders that did it, users are
confused and it breaks things.

So this patch downgrades it from an error to a warning. If you ignore
the warning, you get what you deserve (which is probably not
bad... people lived with it for years). Anybody who wants it to be fully
illegal can always compile with -Werror to turn warnings in to full
errors.

I also "uniformized" two separate error messages on the same general
topic, so they look the same.
2018-12-13 09:14:37 -08:00
Larry Gritz 971916f23e Extremely minor docs source fix 2018-12-05 11:51:16 -08:00
Larry Gritz ce50efa951 Docs typo fix
[ci skip]
2018-11-30 11:53:26 -08:00
marsupial a9dc8886c1 Use memmove as dst & src may overlap (#941) 2018-11-29 17:41:52 -08:00
Larry Gritz 745a6c7ced Bump version to diverge from RB-1.10 2018-11-27 23:55:19 -08:00
marsupial ed76348c89 Allow type conversion to float[4] in ShadingSystem::convert_value (#940) 2018-11-27 17:19:35 -08:00
Larry Gritz eda9e0f290 testshade: check that no leftover errors are in the TS or IC (#939) 2018-11-26 16:42:38 -08:00
Larry Gritz 7363c10a27 Improve oso output efficiency with less redundant work on retrieve_source (#938)
To make debugging easier and be more human-readable, oso files are
littered with comment lines reproducing the source code, so that you can
see which source corresponds to which "oso assembly".

The workhorse here is the retrieve_source(filename,line) function. But
it was unspeakably inefficient, reading the entire source file every
time an op needed a different source file than the previous op, and
scanning the file to find the n-th line *every* time. This seems like
the lookup is O(n^2) and also that we're rereading source files
potentially thousands of times.

Theory: If we cache all the files we read, so we never read each source
file more than once, and also remember which line we used last (we tend
to go in increasing order in a source file) and resume the search from
there, backtracking only when the line is less than the last one needed,
it ought to be blazingly fast!

Practice: It barely makes any difference.  Compiling all 600 MaterialX
source osl files takes 30 seconds on my laptop, and this fix saves maybe
a second or two at most.

Oh well. But I already made the change, so may as well keep the more
efficient algorithm. Perhaps there are other cases where it gives a
bigger advantage.
2018-11-26 14:26:23 -08:00
Larry Gritz 2332f60ec5 Improve error reporting when compiling from memory buffer (#937)
The `OSLCompiler::compile_buffer()` method, which is used to compile
osl source code from a memory buffer, had unhelpful error messages
such as:

    <buffer>:11: error: Unknown struct name: x

because of course, there was no filename, just a memory buffer. This
is ugly and confusing to users.

This patch adds an optional parameter to compile_buffer() that lets you
supply a "filename" to use for error reporting of the mem-buffer-compiled
shader. This makes pretty error messages if you supply a good name:

    zap.osl:11: error: Unknown struct name: x

An application of this is shown with the changes in osltoy.

For my own debugging purposes, I also implemented a `-buffer` option to
oslc, which just forces a file read, compile-from-buffer, and then file
write, so that it's easier for me to exercise the buffer code path.
2018-11-26 14:26:06 -08:00
Larry Gritz 31e1f4c6b3 SS::optimize_group: add optional ctx pointer (#936)
If supplied, it uses the passed context if needed, rather than allocating
a temporary one.
2018-11-26 14:25:46 -08:00
Larry Gritz e20730af4e Bump version after tag 2018-11-20 16:11:42 -08:00
Larry Gritz f51907c205 Docs and other touch-ups for 1.10 beta 2018-11-20 11:47:12 -08:00
Larry Gritz 5b246b0d3e Fix crash with struct parameter assignment from function call. (#934)
Edge case that triggered an assert.
2018-11-20 10:49:06 -08:00
Larry Gritz ccc6d5015b Add options to skip compiling of shaders or MX shaders (#935) 2018-11-19 14:07:03 -08:00
darkhorse64 b33262f50d Export struct OSLQuery::Parameter for Windows (#933) 2018-11-18 11:12:26 -08:00
Christopher Kulla 74eb73a0c8 Fix texture3d lookups with derivatives (#932)
One side was trying to make use of dresultdz while the llvm codegen was always providing nullptr. Since the shading system only supports Dual2 at the moment for derivative lookups, it seems more consistent to forget about trying to come up with a meaningful Z derivative for the time being.
2018-11-08 10:28:58 -08:00
Larry Gritz fd3bba1e13 oslc: Fix type constructor dealing with ambiguity in function return types (#931)
If you have a function that is polymorphic based on return type --
like cellnoise, which could return a float or a color -- you will get
a warning about the ambiguity in certain situations which you can resolve
with an explicit type cast:

    (float) cellnoise (u, v)    // the cast disambiguates which you want

But Thiago found that the similar idiom using a type constructor (rather
than a cast) like this:

    float (cellnoise (u, v))    // fails to disambiguate cellnoise?

fails to disambiguate and gives a warning about ambiguous types (it will
choose the float-returning kind, but will warn about the ambiguity, which
will be an error if you compile with `-Wall`).

This patch fixes the problem by making ASTtype_constructor::typecheck()
aware that float(expr) ought to expect expr to be a float if possible,
and also triple(expr,expr,expr) should expect all three of the channel
expressions to disambiguate to float. It previously made no such inference
in those cases. Note, however, that triple(expr) did previously know that
the expression ought to prefer to disambiguate to the same triple type.

While investigating, I also saw that the oso generated by that same
constructor sometimes did an extra unnecessary temporary assignment, so
while I was ast it I also fixed that with the changes you see to
ASTtype_constructor::codegen (in fact, these changes altered more code
than the type checking part).

Fixes #930
2018-11-06 15:26:17 -08:00
Larry Gritz 93839e1c42 Bump dev version 2018-11-01 14:46:32 -07:00
Larry Gritz 158efc4d6c Rebuild docs
[ci skip]
2018-11-01 14:44:32 -07:00
Larry Gritz 9d64eb55f5 CHANGES/docs
[ci skip]
2018-11-01 14:39:06 -07:00
Larry Gritz d25f8d6435 Wean ourselves off of 'operator int' of ustring, and bug fixes (#929)
OIIO's ustring has an "operator int()" that is possibly ill-advised, as
claimed by Thiago Ize and John Haddon from an oiio-dev thread from back
in 2015 (I'm doing some old thread necromancy). They claimed that an
operator int (or for that matter bool) could result in subtle bugs from
type conversions you don't expect to happen.  The fact that there's no
equivalent operator int/bool for std::string or std::string_view
bolsters their argument.

I started off just trying to eliminate all OSL uses that assume this
operator would work (the proper idiom is simply `!str.empty()`). Along the
way, I found *TWO* bugs related to this -- one in osltoy and one
when constant folding "wrap" arguments to texture functions! So Thiago
and John were surely right, and I am appropriately chastened and
belatedly trying to find a way to get rid of the troublesome operator.
2018-10-29 11:40:20 -07:00
Larry Gritz 7d8b0b2540 CMake refactor (#928)
* Use the "official" FindOpenImageIO.cmake from OIIO (recently
  added). This necessitates some renaming, for example standard use of
  OPENIMAGEIO_ROOT_DIR.

* Change inconsistent naming of OSLHOME (and OSL_HOME) to the more
  standard OSL_ROOT_DIR.

* Copy updated FindOpenEXR.cmake from recent OIIO (and related changes).

* Eliminate all of testsuite/MaterialX, which was not used, never fully
  worked, and was certainly out of date with our MX support. If we want
  to add unit tests for MX shaders, I think I will take a completely
  different approach. So for now, just eliminate the clutter.

* Eliminate site/pixar/Makefile-bits, which they say they no longer use
  (some of those customizations were the very last uses of some weird
  custom stuff in our older FindOpenEXR.cmake, now eliminated).
2018-10-26 14:27:37 -07:00
marsupial ab44f553ca SPI: Default to use vanilla boost (#927) 2018-10-24 18:00:17 -07:00
Larry Gritz 637fe3e833 Fix typos in docs & comments
[ci skip]
2018-10-22 15:56:28 -07:00
Larry Gritz d76bfeec4b Fixes to make recent osltoy changes not break against OIIO 1.8 (#926)
Recent changes used a new ImageBufAlgo convention only present in current
OIIO master, not older 1.8 that we still promise compatibility with.

Didn't catch this before because the Travis tests don't install qt and
therefore don't build osltoy at all. Add qt to the Mac travis setup so
that it at least builds to prevent this from happening.
2018-10-15 12:44:05 -07:00
Larry Gritz 524ffe306a Change to search path rules for .oso files (#925)
New rules:

* If NO "searchpath:shader" attribute is specified to the ShadingSystem,
  the current working directory (".") will be searched.

* If a searchpath is specified, it will look ONLY in those directories,
  in order. The current working directory will only be searched if
  it is listed among the paths.
2018-10-12 17:02:21 -07:00
Larry Gritz 27266344fb Rewrite OSOReaderToMaster::hint (#923)
Zap is seeing sporadic (but frustraingly impossible to reproduce) crash
reports from inside this function, specifically in the part that parses
%argrw hints.

There was a longstanding comment:   // FIXME -- use string_view ops here

So, sure, rewrite the whole thing using string_view and Strutil::parse
functions, and remove the assertions, and put extra guards to make sure
we aren't acessing a symbol or op (via blah.back()) if there aren't any
in the vector yet, and pretty much just let it ignore or be robust to any
malformed hints.

I've never seen a repro case, so I don't know that this will fix it, but
it's programmed a lot more defensively now, so hopefully there will be
no further crashes (after I backport this to whatever version Zap is
using).  I even put in an error message for a certain way to malform
%argrw, in the hopes that it might give us a clue, but even that is just
a guess.
2018-10-12 15:13:57 -07:00
Larry Gritz c0a4cdea9d Update MaterialX README
[ci skip]
2018-10-12 10:22:11 -07:00
Larry Gritz 5e839afa52 Fix docs typo about matrix construction 2018-10-11 14:28:36 -07:00
Larry Gritz 157e4657fa Fix oslc read/write error for regex_search/regex_match (#922)
For these functions, oslc failed to mark the results output param as
write only.

Fix the bug in oslc, and also put in a provision in loadshader that will
correct the old already-compiled incorrect files.

Thanks to Steena Monteiro from Intel for pointing this out!
2018-10-05 15:50:32 -07:00
Larry Gritz c66ccb6fb5 Test against llvm7 and gcc8, several gcc8-related warning fixes (#921) 2018-10-01 11:27:48 -07:00
Christopher Kulla f865b5b252 Fix compile errors inside LLVM 7 on CentOS 7.3 from buggy system inttypes.h header 2018-09-27 15:23:31 -07:00
marsupial 3a080f70b0 Add Pixel magnifier to osltoy when alt is held down (#918) 2018-09-26 13:04:58 -07:00
Jino Park 66f52f8644 Remove useless nullptr check (#920) 2018-09-26 10:40:53 -07:00
Larry Gritz 64dadf9b8f Minor changes to build with clang 7. (#917)
The changes in oslcomp.cpp seem only to be necessary with particular
combinations of clang7 and older llvm. Which we don't recommend!  Better
to use the same generation of clang and llvm. But in any case, may as
well make set those options explicitly.

Also switch SPI to build with clang7/llvm7 by default.
2018-09-19 16:25:55 -07:00
Larry Gritz d6c375bc29 Travis: add test entry against LLVM 6.0 2018-09-14 22:51:11 -07:00
Larry Gritz 0169ab732e Fix testrender bug with undefined order of operations (#916)
A suspicious line in testrender seems to depend on undefined behavior
regarding the specific order of evaluation of quantities in a math expression.
It has been there forever, but only seems to fail on certain builds of gcc 5
and possibly clang 7.

It's just a one-line fix to remove the order-of-evaluation ambiguity.

Thanks, Tim Grant, for pointing this out!
2018-09-14 22:41:58 -07:00
Larry Gritz ffc58557a3 osltoy: add 'pause' and 'reset' buttons (#914)
'Pause' (which changes its label to 'continue' when paused) stops the
clock and continued execution of the shader, until 'continue' is hit.

'Reset' sets the time counter back to 0.0 again.

It starts in a paused state, and starts the clock the first time you
successfully compile a shader.
2018-09-14 18:05:20 -07:00
Shane Ambler e9191e2440 Remove use of a fixed path to call bash (#915)
* use a less rigid path to call bash
2018-09-14 10:30:34 -07:00
Larry Gritz 5ec807c081 Replace quick_floor with ifloor (912) 2018-09-05 09:55:33 -07:00
Larry Gritz b4843323b0 Fix cellnoise bug (912)
WARNING: possible visible change in procedural patterns

It's expected that cellnoise(x) == cellnoise(floor(x)), but we found an
ugly bug wherein cellnoise internally used a helper function
quick_floor, which is supposed to take the floor of a float argument and
return its integer equivalent. But unfortunately it had a really odd
error: when x was an exact negative integer, it gave the value for the
next smaller integer.

    quick_floor( 1.00) ==  1
    quick_floor( 0.01) ==  0
    quick_floor( 0.00) ==  0
    quick_floor(-0.01) == -1
    quick_floor(-0.99) == -1
    quick_floor(-1.00) == -2    // WRONG!!! Should be -1
    quick_floor(-1.01) == -2

This in turn caused cellnoise lookups of exact negative integer values
to be incorrect lookups of the next lower-numbered cell, i.e.,
cellnoise(i) having the same value as cellnoise(i-epsilon), but again,
only for i<0 and i==floor(i) exact integer values.

Now, if your shader made a visual representation of callnoise(x,y), it
would look just fine, unless a particular x,y fell *exactly* on integer
coordinates, in which case it would be ever so slightly off (by being
the color of the square immedately to the left instead of to the right,
as it should be, say).  Nobody would ever notice that.

Also, if your shader took the floor before passing to cellnoise, like:
cellnoise(floor(x),floor(y)), it would also *look* correct, though the
negative values would be wrong, since cellnoise(-1,-1) would have
returned the value that should have been cellnoise(-2,-2), etc., but
you never would have noticed that.

But... there were some possible uses of cellnoise where it was behaving
very strangely, and the main place you would notice this is certain
types of "voronoi" noises where you are lookup up cellnoise values while
looping over adjacent lattice points. (Thanks, Zap, for noticing this,
and so sorry that there was a legit bug here!)

It was a very slight possible problem for perlin style noise as well,
but since those noises are "continuous" and defined by gradients, you
really, really, would not have known that the occasional pixel had noise
results that were ever so slightly off in its derivatives only at those
isolated integer lattice points. I think no visible artifacts were
discernable under real-world conditions.

The solution is to bite the bullet and replace the clever (but extremely
minor) speedup for computing floor, with a legit floor call.  It's ever
so slightly more expensive if you isolate the cost of just raw cellnoise
calls, but in the context of a real render I don't think you'll be able
to measure it.

WARNING: This may change the appearance of certain "Voronoi" patterns,
or possibly other uses of cellnoise as random number sequences. It also
changes the appearance of "Gabor" noise, which internally also used the
faulty quick_floor in such a way that it affects the whole pattern.

Note that this should NOT change the appearance of any of the
perlin-style noises, and you may not notice any change for most ordinary
uses of cellnoise, either.

I changed the oslnoise unit tests to check that this is working
properly, and updated all of the noise unit tests that generate images
to "center" the patterns so that they visibly display the negative
regions of the noise domain (they had all shown only positive domain,
which is probably inviting trouble if there was ever a noise bug that
only affects what happens for negative values or right on the axes).
This caused a lot of the reference images to change, even for the tests
of noise patterns that were unaffected. Also, I took the chance to merge
a few of the signed/unsigned tests for less repetition.

I'm very sorry about this; changing the appearance of noise functions is
not something we take lightly, we do it only as a last resort. It was
clearly wrong before and had some very unexpected failure modes. But I'm
only making this fix in master, which is destined to be "OSL 2.0", so I
figure it's as good a time as any to make a change that could possibly
make visible changes in some shaders.

If you see this as some kind of major betrayal that will screw up your
productions, let me know and if pressed I can perhaps make some kind of
emulation of the old buggy behavior for people who need to preserve it.
But I'd rather not do that if it's not absolutely necessary.
2018-09-05 09:55:29 -07:00
Larry Gritz f0bc9a91f3 LLVM 7.0 and clang 7 compiles (#910)
* Modernize the way we generate memset and memcpy ops -- we still had
  some artifacts of LLVM 3.x; since LLVM 4+, there has been a more
  direct way to generate the equivalent of memset/memcpy (and be
  careful, the API changes slightly for LLVM 7.0).

* Some header file changes with llvm 7.

* Minor ref-vs-ptr miscellany for WriteBitcodeToFile and CloneModule.

* Slight change to addPassesToEmitFile call signature.
2018-08-17 21:21:06 -07:00
Larry Gritz d78dfc146e MaterialX build strategy overhaul (#909)
* Radically simplify build_materialX_osl.py -- It previously had a whole
lot of unused complexity by being able to build multiple template
expansions at once, and to do ALL template expansions without the cmake
system. But we never used it that way. So simplify it to handle a single
shader and type at a time, which is how it's called from our cmake
scripts. This makes it easier to maintain and removes a lot of redundant
logic that was duplicated (possibly incorrectly) between cmake and
python.

* Modify MaterialX build process to handle "OTHERTYPE" so we can get a
templated cross-product of two type lists (though by default, OTHERTYPE
is "none", so it's just a linear list of types we expand to). OTHERTYPE
is also allowed to be "same" which means it's the same as the first TYPE.
This makes it easy to make a templated node where for a bunch of types T,
it has a T,T version, and also a T,float version.

* Implement MX "convert" node, which utilizes the ability to have two
templated types.

* Clean-up of lots of nodes where we special cased the vecN/colN versus
itself, versus vecN/colN versus float. Now that we can template on two
types, these all simplify to one template for the "same" case and the
"float" case.

* File/node naming convention: for all nodes that can be templated on
a single type, we continue to call the OSL shader mx_thefunction_thetype.osl
(and .oso). But for all nodes that can be templated on two types,
(add, smoothstep, etc.), they will be named mx_thefunction_type1_type2.osl.
2018-08-09 12:00:14 -07:00
Larry Gritz 0e4296de4b MaterialX cleanup: ramp4, texture mapping, matrix math (#907)
* MaterialX: fix definition of ramp4 top vs bottom

In recent times, it's been decided that "top" always refers to v=1 and
"bottom" refers to v=0.

* MaterialX: various clean ups to texture mapping nodes

* image node: wasn't honoring addressmode or filtertype params.

* Fixes to triplanarprojection: wasn't properly normalizing by the
  combined weight of the three views, wasn't honoring filtertype param,
  wasn't forcing periodic wrap.

* Implement the new "tiledimage" node.

* MaterialX: extend add/sub/mul/div to include matrices per 1.36 spec
2018-08-06 18:40:34 -04:00
Larry Gritz 22443fc4e9 Whitespace cleanup
[ci skip]
2018-07-28 12:33:25 -07:00
Larry Gritz 3e3b528c73 MaterialX 1.36 additions: rotate, transforms, rgb/hsv, extract, separate (#905)
* Add a variant of rotate() that just takes an axis, rotate about the origin.

* MaterialX: add rotate node (new with MaterialX 1.36)

* rotate2d note is kept for back-compatibility, but considered deprecated, since it was dropped from 1.36.

* MaterialX: implement new transformpoint, transformvector, transformnormal nodes

* MaterialX: add new nodes rgbtohsv, hsvtorgb

* MaterialX: add new 1.36 node 'hsvadjust', deprecate 'hueshift'

* MatrialX: Add new 1.36 nodes: extract, separate
2018-07-28 08:45:03 -07:00
Larry Gritz 7a56abdfb0 SPI specific touch-ups for OptiX support 2018-07-25 18:10:04 -07:00
timgrant 99ed27a535 More OSL+OptiX progress: support for strings (#902)
* Add a device_string type for representing static strings on CUDA devices. Update LLVM codegen to generate and handle device_strings. Add mechanisms to register and query integer IDs associated with device_strings.

* Move the DEVICE_STRING_PARAM macro.

* Remove some redundant calls in addGlobalVariable.

* Remove OptiX exceptions, since they are not well supported.

* Unify the OptiX and non-OptiX path for passing the noise name.

* Re-add osl_printf to rend_lib.cu.

* Add a very basic print test for testoptix.

* Make the warmup launch in testoptix optional. Fix minor indentation problem in rend_lib.cu.

* De-unify the OptiX and non-OptiX path for passing the noise name. Fix some formatting issues with rend_lib.cu.

* Simplify test_print.osl.

* Add ASSERTs to certain OptiX-only functions as a sanity check.

* Add detailed comment to device_string.h.

* Slightly rework device_string example in wrapper.cu.

* Add some macros to make registering device_strings less painful.

* Pulled more of the 'standard' strings into strdecls.h. Added DeviceStrings namespace. Using the STRDECLs in setup_string_tags.

* Update the comment in device_string.h with usage notes for the STRDECLs.

* Changes to compile and link device_strings.cpp separately.

* Working on a device memory string table.

G# ot string assignment seemingly working.

Cleanup.

* Simplify StringTable a little.

* Pack the string length and hash value into the string table, and add strlen and hash functions to rend_lib.cu.

* Replace vector with map in StringTable.

* Handle OptiX printf with wrong args by printing warning and ignoring print call.

* Add rudimentary check for collisions between global variable names.

Fix a bug in the offset alignment logic for the string table.

Add getchar. Add StrRep type for casting raw DeviceString pointers to make accessing hash and len more convenient.

Modified ustring to use cudaMallocManaged. Modified StringTable to use the ustring pointers instead of a separate table. Not working with varying strings.

* Use regular device memory instead of Unified Memory for string table. Add assert to limit active devices to 1. Miscellaenous comments and refactoring.

* Added better re-casting macro for DeviceString. Added comments. Added test for string ops. Misc. small fixes.

* Update OptiX version-finding logic in CMake.

* Rename the CUDA-specific GlobalVariable functions. Use string format when constructing the mangled variable names.

* Add TODO comments about string arrays in CUDA/OptiX.

* Add license to stringtable.cpp.
2018-07-25 18:07:35 -07:00
Larry Gritz 3c8f214461 Add sign() and log() to vector struct types. (#904)
Ass missing `sign` node to MaterialX.
Change MaterialX `ln` implementation from log2 to correct log.
2018-07-25 17:55:05 -07:00
Derek Haase 4d3d0c4804 Add lots of new MaterialX 1.36 support
Add sin, cos, tan, atan2, ceil, sqrt, exp, determinent, ln, and
transpose operators

Rename exponent operator to power

Rename pack to combine

add extract operator

Add conversion operators:
color2->vector2
color->vector
color4->vector4
vector2->color2
vector->color
vector4->color4

Matrix inversion operator.
2018-07-21 09:40:11 -07:00
Derek Haase de63270a19 Add more functions to color2, color4, vector2, vector4
ceil, sqrt, exp, log2, sin, cos, tan, asin, acos, atan2
2018-07-21 09:40:11 -07:00
Larry Gritz 585e3dcfba Speed up parsing of long initializer lists. (#901)
If you have something like

    float table[65536] = { 0.1, 0.35, -0.72, ... }

This might take TENS of seconds for oslc to parse, because the mechanics
of how that long list of values is parsed -- it involves a singly-linked
list of ASTNodes, and with each new one, we are appending to the far end
of the linked list. This leads to an O(n^2) parsing time, where n is the
length of the list.

The straightforward (but wrong!) way to fix it is to change the Bison
grammar for init_expression_list from "left-recursive" to "right-recursive".
That makes it natural to prepend items (O(1)) to the accumulating list,
but it's very inefficient for Bison and can overrun Bison's fixed-size
parsing stack. Bison docs discurage use of right-recursion in grammars,
since left-recursion grammar can parse arbitrarily deep recursive
structures in a fixed memory size.

OK, so how do we fix this? Trickery! Keep left recursion, but accumulate
in the reverse order (i.e., prepend, not append), and then do a single
reverse of the backwards list at the very end. That makes the whole
parsing affair O(n) instead of O(n^2).

Sounds good, but one final wrinkle is that the list we need to reverse
is is a raw pointer to the head, followed by ref-counted pointers to
each subsequent element. In order to keep from accidentally freeing
things if the ref counts reach zero, we have our fancy reverse()
function rely on a brand spanking new feature of OIIO's intrusive_ptr<>
to add a release() method (https://github.com/OpenImageIO/oiio/pull/1986).
But since that doesn't exist in older OIIO, to avoid a compatibility
break, we only do our special left recursion + backwards list + reversal
trick if the OIIO version we build against has that new feature.
Otherwise, it's #ifdef'ed out and we just do it the old slow way.

This fixes OSL issue #723, and for the pathological test case presented
in that issue, it improves compile time (on my laptop) from ~26 seconds
to 0.4 seconds.

I also checked that this funny business with the reversal doesn't slow
down the simple cases for ordinary shader. Compiling the whole
collection of 500+ MaterialX shaders took about 20.5 seconds, and with
the new parsing code is exactly the same, or at least, too close to
accurately discern in the time trials.
2018-07-19 18:13:50 -07:00
Christopher Kulla addb70fa65 Fix incorrect array length on unbounded arrays specified via relaxed parameter type checking (#900) 2018-07-18 13:51:58 -07:00
Larry Gritz 18893a8484 docs
[ci skip]
2018-07-16 22:33:59 -07:00
Larry Gritz fb3e125063 ShaderType/ShaderUse refactoring (#899)
Deprecate the use of shader "types" (surface, displacement, etc.)
designated in OSL source code. Those words will still be accepted for
backward-compatibility, but they are no longer required or encouraged.
Generic "shader" type is the only one we will talk about as we move
forward.

Excise the ShaderUse enum. Renderers (or non-renderers using OSL for
programmability) are allowed to determine and document whatever type of
shader "uses" they want to support. The only enforcement from the
liboslexec side is that all the shader nodes within one group must be
tagged with the same "use" string.

The "use" parameter to ShadingSystem::Shader() is intended to be removed
entirely, eventually. However, that's the first of three (optional)
parameters to Shader(), so it's a subtle change that can break renderers
in annoying and confusing ways if we do it all at once, so we'll do it
in stages: For this major release, we will make all three parameters to
Shader() be required (no optional params), which even if it generates a
compile-time error for a renderer, is a very obvious one to fix. Then in
a later major release (2.1?), after we know that all renderer code is
making 3-argument calls to Shader(), we will introduce a 2-argument
version that lacks a "use" parameter (can't break renderer code) and
deprecate the 3-argument call that has the useless "use" parameter, and
then in a later release, we can remove the 3-argument version once and
for all.

Add new queries for shader groups: "globals_read" and "globals_write",
which return a bit field of which shaderglobals fields will be read or
written, respectively, by the shader group after it's optimized.
The bitfield meanings are given by the new enum class SGBits, defined
in shaderglobals.h. This is easier to query (as an `int`) than to sort
through the list of strings you'd get with "globals_needed", and allows
renderers (if they so desire) to (a) verify that shaders don't use or
modify globals they aren't supposed to, for the type of shader use they
are being used for; (b) potentially to avoid any expensive computations
that would need to be performed to prepare certain shaderglobals fields,
for shader groups that won't end up using them.

Also make the `I` global variable be writeable and clarify that if a
global is writeable, it's writeable from any shader type, and we don't
intend to do differing checks based on shader type.
2018-07-12 18:23:55 -07:00
Larry Gritz 9d6d30b13c Fix compiler error on MSVC -- suspicious static_assert (#898)
In dual.h, we static_assert involving std::initializer_list<T>::size(),
which is constexpr only for C++14 and on. This seemed to work for clang
and gcc, but MSVC 15 doesn't like it. Guard it so that it only applies
for C++ >= 14, in which the constexpr makes it more certainly legal for
static_assert to reference initializer_list::size().

Fixes #897
2018-07-09 10:24:52 -07:00
Larry Gritz 388f0370c7 Warning fixes on gcc6 (#896)
For some reason, this built ok on TravisCI, but not on the partciular
gcc6 version I had at work. Minor fix.
2018-07-03 16:46:41 -07:00
Larry Gritz 182c02b28a Fix test output to not fail on Windows 2018-06-15 10:27:06 -07:00
Larry Gritz 6fb409d6eb Fix MSVS potential build problem with iso646.h macros (#892) 2018-06-14 15:13:11 -07:00
Larry Gritz ae64eadf48 Update trig ref output after recent OIIO change 2018-06-14 14:27:14 -07:00
Larry Gritz 4afb8d4cf0 Fix build break after recent OIIO changes 2018-06-14 14:13:21 -07:00
Alex Fuller 7db5293d96 Flex/bison wincompat patch (#891) 2018-06-04 14:10:22 -07:00
Christopher Kulla d595393728 Specify gcc-toolchain for clang explicitly for SPI builds 2018-05-30 16:02:32 -07:00
Larry Gritz f4b5846c28 Update test ref output after recent OIIO fmath.hchanges 2018-05-18 14:39:31 -07:00
Larry Gritz 0766be6328 Fixes for OIIO change to imageio create function signature (#889) 2018-05-18 14:34:20 -07:00
McHox d8c755bf5a fixed typo (#886) 2018-05-07 23:09:32 -07:00
Larry Gritz d02cbb9b7c RendererServices: make non-abstract (#885)
Allowing the base class to be used as a trivial RendererServices, can
be helpful for certain applications where not much renderer functionality
is needed.
2018-05-04 18:10:47 -07:00
Larry Gritz ad3d40c8df changes
[ci skip]
2018-04-29 18:16:10 -07:00
Larry Gritz 3b72f78f66 Updates to handle OIIO ImageInput refactor. (#882) 2018-04-27 16:59:41 -07:00
Larry Gritz 61fd99d06e Fix error_repeats: clearing happened for getattribute instead of attribute (#883) 2018-04-26 10:08:57 -07:00
timgrant a39f965544 OptiX noise functions (#877)
* Changes to compile OSL noise functions for CUDA: Add CUDA-compatible variant of ImathMatrix.h; add HOSTDEVICE macro to noise functions; modify CMake build for liboslexec to compile and link multiple shadeops sources when compiling for CUDA; change Module link order when compiling to PTX; bump minimum CUDA version to 8.0; set CUDA path for clang according to CUDA version; add CUDA_TARGET_ARCH CMake variable.

* Add testoptix-noise to testsuite.

* Fix up the CMake build flags in liboslexec. Remove the HOST_DEVICE macro from some hash functions in opnoise.cpp. Clean up a few unneeded preprocessor macros.

* Change a few hash function signatures to take void* instead of float*, and cast as appropriate.
2018-04-11 20:17:22 -07:00
Larry Gritz edf7d842f7 Reduce extreme cost of oslnoise_test on CI and DEBUG runs 2018-04-09 16:40:54 -07:00
Larry Gritz 98d71786f8 SS attrib "error_repeats" controls suppression of repeat errors & warnings (880)
Previously, exactly identical error and warning messages (including from
shaders themselves) printed the first time and suppressed the duplicates.
The rationale is that an error in a shader could easily turn into thousands
of error messages if duplicates weren't suppressed.
There wasn't a way to turn this behavior off.

Now it's controlled by ShadingSystem attribute "error_repeats", an int,
which has default value 0 (do not issue repeated errors). If changed
to 1, repeated errors and warnings will be allowed to pass to the error
handler, without suppression in the ShadingSystem.

Furthermore, the act of setting the attribute (to either 0 or 1) has the
side effect of clearing the list of remembered errors. This means that
even if you want error suppression, poking it in this way will reset the
counters, which might be a handy thing to do at the start of each frame
(if you are using a single ShadingSystem to render multiple frames) so
that you start the counts fresh for each render, rather than for each
ShadingSystem.
2018-04-09 15:45:58 -07:00
Larry Gritz 0efbf04f5c CHANGES 2018-04-05 09:14:03 -07:00
Larry Gritz 1e336440d9 Fix redundant command line flag entry 2018-04-05 09:09:41 -07:00
Larry Gritz 379107eab3 Errors for writing to read-only function parameters or globals (#878)
It has been a longstanding problem that oslc did not properly flag
attempts to write to function paramseters that were not marked as
'output'.

I've rigged this so that in the current master (and any past releases,
assuming we backport this to release branches), it will just be a
warning. In future versions, it will be a full error. That should give
people some advanced warning (no pun intended) to fix any problems that
this catches that previously went unnoticed.
2018-04-05 09:08:35 -07:00
Larry Gritz 36c714000f CHANGES and docs 2018-03-31 14:49:05 -07:00
Larry Gritz 9a301e8153 Add forgotten -Werror to oslc help message (#879) 2018-03-28 10:23:25 -07:00
Larry Gritz d67b469898 Fix confusing argument order issue for testshade (#875)
Testshade set certain command line options as a by-product of certain
other ones, and that introduced a weird order dependency to the arguments
that was confusing. In particular,

    testshade -O0 myshader

worked as expected, but

    testshade myshader -O0

set the options (including optimization level) when parsing myshader,
before it got to the -O0.

So this patch simply makes sure that the shader options are
re-established after all arguments are parsed.
2018-03-27 13:38:23 -07:00
Larry Gritz ca1d377056 Fix OptiX build for SPI 2018-03-26 16:07:39 -07:00
Matt Johnson 75aeade555 specify the VERSION and SOVERSION when building library shared objects (#876)
In this change, we specify the VERSION and SOVERSION properties of library
shared objects so that the SONAME in the shared object contains the OSL version
number suffix (major.minor). This also results in the build creating versioned
symlinks back to the installed shared objects. Code that links against the
libraries can then link against a specific version of OSL such that the correct
version can be dynamically linked at runtime.

This follows a similar pattern to the one used in OpenImageIO.
2018-03-26 15:36:50 -07:00
Larry Gritz 4d5eb61328 Bump LLVM minimum to 4.0, drop support for 3.9 (#874) 2018-03-19 11:33:18 -07:00
timgrant 6f611fc009 OSL-to-PTX compilation (#868)
* Apply initial round of changes to liboslexec to support PTX generation. Add function decorators to shadeops in llvm_ops.cpp and to functions in dual.h to support device compilation. Depends on modified version of fmath.h from OIIO, and includes a local version of ImathVec.h from OpenEXR that has been modified to support CUDA compilation.

* Update testoptix to reflect changes to liboslexec. testoptix now loads scenes from the testsuite, compiles the ShaderGroups to PTX, and attempts to render the scene using flat shading. The implementation is limited and very experimental.

* Update the testsuite to reflect the current state of testoptix.

* Get rid of the 'native_target' flag and initialize all LLVM targets in all cases.

* Use ustring::format to construct OptiX variable names, instead of std::string concatenation.

* Don't delete m_const_map entries in destructor, since they are owned by the LLVM Module.

* Cache whether or not the renderer supports OptiX.

* Use the serialization script from liboslexec for testoptix.

* Fix wrong header include.

* Add OPTIX_EXTRA_LIBS CMake variable. Add include path for ILMBase. Specify CUDA path when compiling with clang.

* Refactor ptx_compile_group: replace deprecated default CodeModel option, simplify target/layout option, reword some assert messages.

* Add virtual destructor to Primitive struct in testoptix to appease pedantic compilers.

* Add check for NVPTX target to CMake build.

* Add guard against redefinition of HOSTDEVICE macro. Rename HOSTDEVICE IMATH_HOSTDEVICE. Add decorators to Imath::Vec4 types. General reformatting of ImathVec_cuda.h.

* Move OSL_HOSTDEVICE definition into oslconfig.h, and update includes accordingly.
2018-03-16 18:15:41 -07:00
Larry Gritz 539a5c4f7b Make runtest.py be python 2/3 agnostic (#873) 2018-03-06 15:56:37 -08:00
Larry Gritz 49add4953c Fix docs typos (#871)
Fixes #869
Fixes #870

[ci skip]
2018-03-05 16:32:39 -08:00
Larry Gritz 75012eb38e docdeep 2018-03-05 15:06:54 -08:00
Larry Gritz 634c1d30d8 Improve oslc error reporting (#867)
For many grammatical constructs, the "source line" recorded in the AST
node is where the grammatical case ENDS. As an example,

    1:  shader foo (int holdout
    2:                    =
    3:                    1)
    4:  { }

There is a warning because 'holdout' masks another symbol at the same
scope. You would think the warning should be reported as occurring on
line 1, but it is reported for line 3, because that's where the clause
ends.

This will tend to happen for grammatical constructs that look like

     ANCHOR potentially-long-expression-that-may-span-lines

where any sensible person would want the warning associated this to be
on the line of the anchor, not wherever the long expression happens to
end.

In this patch, I carefully fix a whole lot of these grammatical
constructs to patch the 'sourceline' of the AST node they create with
the line that a particular anchor symbol is on.

There's a bit of extra work for ASTvariable_declaration, because there
are some errors (for duplicate symbols, etc.) that happen in the
constructor itself, so it's too late to return from the constructor and
then reset the source line; the misleading error has already been
issued.  So in that case, I added a line override parameter to the ctr
itself, mimicking the solution I implemented some time back for a
similar situation with function declarations.
2018-03-05 09:44:08 -08:00
Larry Gritz 803713303a SPI changes to find Cuda and OptiX 2018-02-27 13:36:52 -08:00
timgrant 89faf72cd0 OptiX integration (#861)
First checkin of effort to make OSL for OptiX/Cuda.

* Add (optional) OptiX and CUDA dependencies to the build system. None of this comes into play unless you build with the optional USE_OPTIX=1

* Add testoptix project to verify basic OptiX functionality. This is similar in spirit to the existing "testrender", but using OptiX to do all the heavy lifting. It does not currently shade with OSL... just laying the groundwork for a test harness.

* Add testoptix to the testsuite.

* Use NVCC for offline PTX generation rather than using NVRTC. Use CUDA_TOOLKIT_ROOT_DIR instead of CUDAHOME in CMake build.
2018-02-27 13:35:17 -08:00
Larry Gritz eac82a0087 #pragma osl nowarn suppresses warning on the following source line. (#864)
This sets the precedent that all future osl pragmas will start with
`#pragma osl`, and that any other token after the `#pragma` will be
ignored.
2018-02-16 10:44:49 -08:00
Larry Gritz 020214b582 Warning fixes and general cleanup to recently added typecheck code (#863)
The most important change here is to modify the practice making
multi-line warnings/errors by issuing a warning/error for the first line
followed by message() calls for the subsequent line.  Instead, we
generate those line-by-line messages as strings, and at the very end
issue a single warning or error call.

Also, directly call m_compiler->warning or error, don't bypass the
compiler by calling the app's error handler.

The reason both of those are important is that I have a separate change
I am ready to submit that is about giving a `#pragma nowarn` that can be
used to suppress warnings on the following line. This is totally borked
by warnings that span multiple calls and where most of their output is
in the form of message() and thus aren't easily recognized as part of
the warning.

This includes some general stylistic cleanup also in a few spots, some
preferences I have but but did not feel was worth nit picking line by
line in the original PRs.
2018-02-15 16:19:09 -08:00
Christopher Kulla f19ab7ced8 Upgrade SPI makefiles to Clang 5.0.1 final 2018-02-15 08:25:14 -08:00
marsupial 0afc301019 C++11 style Initializer lists (#838)
This lets you have constructs like

    // pass a {} list as a triple, matrix, or struct
    void func (point p);
    func ({x, y, z});

    // Assign {} to a struct if the types match up
    struct vec2 { float x, y; };
    vec2 v = {a,b};
    
    // Compact 'return' notation, it knows to construct the return type
    vec2 func (float a, float b)
    {
        return {a, b};
    }

Along the way, a number of steps:

* Initialize struct array elements without going through a temporary.

* Refactor codegen of aassign into single method.

* Allow float <=> int conversions using "aassign" without going through a temporary.

* Allow initializer lists as return types.

* Allow initializer lists as function/constructor arguments.

* C++11 style initializer lists.

* Complete ASTcompound_initializer type check/binding.

* Remove ASTNode typecheck_initlist & typecheck_struct_initializers.
Everything now flows properly through ASTcompound_initializer.

* Adapt to recent function-overload changes.
Hide some implementation details that don't need to be public.

* Error on ambiguity of arguments using init-lists.

* Make warnings & errors involving initializer list arguments more obvious.
2018-02-14 23:05:01 -08:00
Larry Gritz db85b9af61 oslc -Werror (#862)
This flag to oslc will treat all warnings issued as if they were errors.
2018-02-14 11:18:33 -08:00
Chris Kulla b036b11055 Fix LLVM memory manager for LLVM 6.0 and higher
Refactor code to avoid unecessary casts
2018-02-14 09:40:34 -08:00
Chris Kulla 3fb1ca5eaf Add support for Clang 6.0.0rc2 in SPI makefiles 2018-02-14 09:40:34 -08:00
marsupial 15b8664336 Fix remaining undefined behavior from functions ambiguous by return type. (#858)
Adds color closures, structs, and void to the defined precedence order of resolving via return type.
Errors when disambiguating via return type and more than one user struct is a match.
2018-02-14 00:25:05 -08:00
Larry Gritz 8a3242c1d5 Tweak OIIO related deprecations (#859)
For some time, the current master had advertised that it requires OIIO
>= 1.8. This patch simplify code by removing #if clauses related to OIIO
versions older than that.
2018-02-13 15:39:13 -08:00
Larry Gritz b1ed8cc599 CHANGES 2018-02-11 15:51:54 -08:00
Larry Gritz a271bfc786 Shader parameter metadata [[ int allowconnect = 0 ]] (#857)
If a shader input parameter has this metadata present and set to
nonzero, no incoming connections via ConnectShaders() will be accepted,
resulting in a runtime error if it is attempted.
2018-02-07 14:03:14 -08:00
marsupial a157358717 Minor fixes to recent changes. (#856)
* Windows: Fix strcasecmp usage.
* Fix renamed test which got borked in merge.
2018-02-07 10:59:47 -08:00
marsupial 4d928f6623 Function redefinitions (#853)
* Error on redefinition of functions in same scope with matching signatures.

* Move function redefinition in same scope to back to a warning.

* Call ASTNode::warning with a fully formed string instead of piecemealing formatting.

* Swap order of scope and argument comparison to avoid unnecessary string comparisons.
2018-02-06 11:39:11 -08:00
marsupial 926e98b408 Fix poorly defined behavior when choosing certain function overloads. (#844)
For function overloading in ambiguous cases, we were (a) doing some weird things; and (b) had the resolution dependent on the order the functions were declared, which seems bad.

This set of changes introduces a new polymorphic ranking system that is better documented, consistent, and not declaration-order-dependent.

For now, if the OSL_LEGACY_FUNCTION_RESOLUTION env variable is set, it should revert to old behavior.

We also fix a bug where type casts (like `(vector)foo()`) would properly pass the desired type hint down to the type checking and selection of foo, but type constructors (like `vector(foo())`) would not. This was an error, and is now also fixed. This may change behavior in some cases.

Better ambiguity error messages overall.
2018-02-06 11:00:37 -08:00
marsupial 83159c81b9 Appveyor (#855)
* Appveyor: Fix FreeType discovery for building OIIO and testing OSL.

* Appveyor: Fix passing CMake wrong directory to OpenImageIO.
Always create the download directory and skip Appveyor’s test discovery step.
2018-02-06 09:53:15 -08:00
Larry Gritz 5a5766f85a Add missing info and message reporting methods to ASTNode and OSLCompileImp. (#854) 2018-02-05 13:48:05 -08:00
marsupial e410f16a05 Skip OSL tests on Appveyor when updating the dependency cache. (#852)
Always build OIIO from master instead of caching it.
Limit MSBuild output to interesting notes only.
2018-02-05 10:25:06 -08:00
Larry Gritz 4cc1f66294 Document changes to connection rules 2018-02-01 12:14:46 -08:00
Larry Gritz ca0738de90 CHANGES / docs 2018-02-01 12:00:16 -08:00
marsupial 2398438c0c Allow individual components of aggregate types to be connected. (#801)
Connecting only the r,g, or b channels into another color is common in a lot shader networks.

* Support connections between Symbol components.

* Add component connection tests.

* Debug aid: human readable Connection

* Avoid errors for component connections when optimizing.

* Remove init ops for any fully connected destination param.
2018-02-01 11:59:21 -08:00
Larry Gritz 7a0f6c3ddc Force -Wall on Travis builds (#850) 2018-02-01 11:11:58 -08:00
Larry Gritz 778624d9fb Appveyor: tweak which branches will run, run tests with --output-on-failure 2018-01-31 13:39:43 -08:00
Frederich Munch e99fad5c45 Appveyor 2018-01-30 17:01:32 -08:00
Frederich Munch 62c1c3da0c CMake: Fix LLVM_SYSTEM_LIBRARIES on Windows. 2018-01-30 17:01:32 -08:00
Frederich Munch 6074cd0347 Fix problems running test suite on Windows. 2018-01-30 17:01:32 -08:00
Frederich Munch b0a680ff4e Add Windows export for liboslnoise. 2018-01-30 17:01:32 -08:00
Frederich Munch caef3c954a Work around boost::wave’s preprocessing escaping Windows path separators. 2018-01-30 17:01:32 -08:00
Frederich Munch 320e82ab37 Fix bug/undefined behavior trying to format/printf a struct value. 2018-01-30 17:01:32 -08:00
marsupial cf58c7343d Minor fixes - boost::wave whitespace issue and uninitialized variable (#840)
* Turn off Turn off whitespace insertion when using boost::wave.

* Fix  un-initialized members of ASTfunction_call.
Move all initialization into constructor so some compilers can error on regression.
2018-01-30 15:46:44 -08:00
Larry Gritz c505420eb6 Improve install instructions 2018-01-29 23:20:31 -08:00
Larry Gritz b4c8d2850f Fix compiler warning about possibly uninitialized variable (false positive) (#847)
Fixes #846
2018-01-25 16:29:18 -08:00
Larry Gritz ca0c6df4e0 Fix slightly broken overload resolution (#845) 2018-01-23 14:27:53 -08:00
Larry Gritz 967960dc54 Revert "Fix poorly defined behavior when choosing certain function overloads. (#837)"
This reverts commit 597b6b17e2.
2018-01-20 14:47:29 -08:00
Larry Gritz 2e2e2feb7c oslc: Add warning for detection of duplicate functions in the same scope. (#746)
Previously, if you for some reason defined two identical functions in
the same scope (including redefining a "built-in" function exactly in
the outermost scope), it would just silently accept it, and then you
wouldn't be sure which one would actually end up getting called.

For now it's a warning. After people have had a chance to scrub their
code bases, perhaps we will upgrade this to a full error in a future
release.
2018-01-18 13:56:41 -08:00
Larry Gritz d0f158a7cd Docs: Clarify function overloading 2018-01-17 10:51:17 -08:00
marsupial 597b6b17e2 Fix poorly defined behavior when choosing certain function overloads. (#837)
Previously the order of overload declarations would affect which was chosen.

This attempts to define how overloads are chosen in a more concrete way by scoring:

1. all arguments match without conversion
2. prefer promotion of int -> float over float -> int
3. use return type to resolve any possible ambiguities
2018-01-17 10:04:26 -08:00
Larry Gritz b52b3e673d docdeep (#842)
Why write documentation when you could make yet another documentation
generator?

I like the *idea* of Doxygen -- generate documentation by extracting the
comments in code, particularly those explaining the individual functions
or methods that are part of an API. But Doxygen, ick. Its markup
conventions make the code comments themselves hard to read, and the
output HTML is...  not very aesthetically pleasing (to me, at
least). And it's really a kitchen sink package, a lot of baggage to
carry along for the 2% of it that I really want.

On the other hand, I just love Morgan McGuire's awesome Markdeep
package (https://casual-effects.com/markdeep/), which is an extension
of Markdown but adds a crap ton of neato features that are great for
code, math, and diagrams.

So I tried my hand at doing something really small and "good enough" to
let you mark up your code comments -- but MINIMALLY, so subtly that the
casual observer might not even notice, and using markdeep for anything
fancy -- and then extract that material to generate Markdeep-based
documentation pages that look beautiful.

So here is the prototype. The entire implementation is just one Python
script, src/build-scripts/docdeep. In addition to documenting itself,
I also used oslquery.h to test the idea, so you can see both how the
docdeep markup looks in code, and as well, now we finally have OSLQuery
class documentation, which we never had before. Ha! Those two pieces
of documentation are generated automatically as part of the OSL build, so
you can see what we did on the CMake side to make that happen.

To see how you use it in source, look at oslquery.h.
(Better to just look at the new oslquery in toto, rather than trying to
understand just the diffs of this patch.)

To see what the resulting docs look like, build OSL and look at the
resulting share/doc/OSL/OSLQuery.md.html in your browser.

This is still experimental. I expect it to undergo a lot of revision.
When it settles down, if this looks useful to people and there is
demand, I might split this off into a separate open source project (just
the docdeep script) so that people can use it for other projects without
the overhead of downloading and building OSL. Let's see how it goes.

Feedback appreciated.
2018-01-16 12:39:59 -08:00
Alexis Oblet 714db4adb7 oslc: handle args if the shader file is not the last argument (#841) 2018-01-13 17:17:44 -08:00
Larry Gritz 75461a12ae Change URL for LLVM source after it moved 2018-01-12 19:11:51 -08:00
marsupial df98828efd Fix oslc crash with invalid field selection. (#835) 2017-12-19 00:47:15 -08:00
Larry Gritz cb9935cdf5 Fixes to group names and debug bitcode output (#833)
* Better guaranteed unique naming of missing names.

* When dumping ll/bc files for debugging to filenames derived from the
  group name, beware group names that have slashes in them! Also,
  sheesh, watch out for group names that are so long that they exceed
  the longest filename allowed (256 chars for most modern filesystems).

* Decided only the ll files are useful for debugging, I don't think we
  need the binary bc files.

* Simplify ShaderGroup ctr by using C++11 data member defaults and
  delegating constructors.
2017-12-12 10:19:41 -08:00
Larry Gritz 0729cca05b Adjust deprecations (#832)
Remove a method that has been deprecated since OSL 1.6, and mark some
methods that were deprecated since 1.8 with the OSL_DEPRECATED warning.
2017-12-08 21:06:12 -08:00
Larry Gritz 5f99b5c93d Enable symbols in the JIT for the Intel Vtune profiler (#830)
* Enable helpful symbols in the JIT for Intel Vtune profiler

* Bump which compiler SPI uses
2017-12-08 14:22:39 -08:00
Larry Gritz 5fe0c5bd9a Some bitcode and symbol debugging aids (#831)
* Add a new shadingsys option "llvm_optput_bitcode" that will dump the
bitcode for each group, even if the other debug options aren't turned all
the way on.

* bitcode now dumps in text as well as binary. (It saves a step of running
"llvm-dis" if your goal is just ot see the text in the first place, and also
it helps the llvm bug where sometimes it refuses to work because of mismatched
version strings.)

* Make sure that both in the bitcode output and other debug symbols,
we are more careful about being sure the shader group name is included,
not just the layer name, and also if a layer name is not specified to
ss->Shader(), make one up based on the shader master name and the
layer number.
2017-12-08 13:17:32 -08:00
Chris Kulla 5ea1cceb8c Pass the context's texture_thread_info to the render services texture callbacks instead of always passing NULL 2017-12-06 09:54:38 -08:00
Larry Gritz cd6081e609 CHANGES 2017-12-04 22:30:45 -08:00
Larry Gritz 7f9372f7a2 osltoy (#824)
osltoy is a GUI app that lets you interactively edit a pattern shader
and adjust its parameters, seeing the updated rendered results in
real time.

It's the OSL equivalent https://www.shadertoy.com/

The GUI uses Qt5. If that's not on your system (or if you purposely
disable it with the build-time option USE_QT=0), osltoy will not be
built (but the rest of OSL will).

A few other changes that come along with the ride:

* The `shade_image` utility function has changed its API slightly: the
  last (optional) parameter that used to be a simple thread count is now
  a `parallel_image_options` struct. But this struct can be implicitly
  constructed from an int (which is, in fact, the thread count), so any
  source code that calls shade_image should not need to be altered.

* New mandelbrot.osl shader has been added. It computes Julia sets, too.
  Enjoy!
2017-12-04 15:09:17 -08:00
Larry Gritz 897c20dce6 Add missing OSLQuery::Parameter correct assignment operator (#827) 2017-12-01 14:46:37 -08:00
Mark Final 416d443f82 Fixes compiler error (AppleClang,Gcc) in using std::atomic values as printf arguments (#826)
Compiler error in AppleClang (Xcode8) is

/Users/mark/dev/Thirdparty/OSL-1.9/src/liboslcomp/ast.cpp:76:33: error: call to implicitly-deleted copy constructor of 'std::atomic<int>'
                             i, node_counts[i], node_counts_peak[i]);
                                ^~~~~~~~~~~~~~

Compiler error in Gcc (4.8) is

/home/mark/dev/Thirdparty/OSL-1.9/src/liboslcomp/ast.cpp:76:68: error: use of deleted function ‘std::atomic<int>::atomic(const std::atomic<int>&)’
                              i, node_counts[i], node_counts_peak[i]);
                                                                    ^
Believe this is a problem because printf accepts arguments by value, whereas OIIO 1.8's Strutil::printf takes by reference, and you can't copy a std::atomic.
2017-12-01 11:43:20 -08:00
Larry Gritz 848aa8e6d7 Update Markdeep version and break our style add-ons into separate docs.css. 2017-11-28 15:48:47 -08:00
Larry Gritz 18c3a0c620 Bump minimum OIIO dependency to 1.8 (master only) (#817) 2017-11-27 21:11:01 -08:00
Mark Final d27879a7db Fix to compile OSL debug against OIIO-1.7.x. Previously assumed OIIO 1.8 going by required headers and the new Strutil::printf function (#822) 2017-11-27 16:44:53 -08:00
Larry Gritz bd28ff18c5 OSLQuery improvements (#821)
* OSLQuery::Parameter -- add copy/move constructors

* Make the ShadingSystem side of OSLQuery correctly report default vals.
2017-11-27 16:44:01 -08:00
Mark Final 84e9205b5e VisualStudio 2015 x64 compilation fixes for 1.9.x (#820)
* VisualStudio 2015 x64 build fix

include/OSL/dual.h(64): error C2476: 'constexpr' constructor does not
initialize all members

According to http://en.cppreference.com/w/cpp/language/constexpr, this
is an expected error for C++11, but not for C++14 and beyond.

* VisualStudio 2015 x64 build fix

Using SimplePool in the member variables in ShadingContext is causing an
'attempting to reference a deleted function' error for the
std::unique_ptr<char>s.

Applying the rule of 5, to disallow copying or moving a SimplePool.
2017-11-26 21:18:41 -08:00
Larry Gritz 61bb74ee65 Trim verbose build output of clutter 2017-11-16 17:36:08 -08:00
Brecht Van Lommel 01167e2a73 Fix ClosureComponent to work with SSE alignment requirements. (#810) 2017-11-16 14:33:06 -08:00
Larry Gritz 1bd2d67d88 FindPugiXML.cmake touchup -- make robust to re-builds (#814)
Without this, certain build-change cmake-rebuild cycles could give
cmake errors instead of correctly re-finding the pugi files.
2017-11-16 13:23:57 -08:00
Larry Gritz f1ae57c75f ShadingSys option "allow_shader_replacement" (#816)
Default is 0, for old behavior in which it's an error for
LoadMemoryCompiledShader to try to load the same named shader more than
once.

If set to nonzero, this is allowed, replacing the old shader master.
This does not change any already declared shader groups, which
will continue to use the original definition at the time of their
declaration. But subsequent groups that reference the master will get
the latest one.
2017-11-16 12:37:30 -08:00
Larry Gritz 3bf2494b28 Allow stats to print if shaders were declared, even if not requested (#815) 2017-11-16 12:05:43 -08:00
Larry Gritz 43445591e4 oslc internals: Police up some uses of stderr -- use the error handler (#813)
Doesn't matter much from the command line, but when compiling in memory
with OSLCompiler, you don't want the errors leaking into stderr.
2017-11-16 10:16:46 -08:00
Larry Gritz 9568e93d59 whitespace 2017-11-15 16:10:12 -08:00
Larry Gritz 0647312733 oslc: Fix param write analysis bug for token/value optional arguments (#812)
Functions that take optional argument lists in token/value form, like
`texture` or `pointcloud_search` needed to mark just those value
references as "writeable" that are (for example, the one following
"alpha" for texture calls, but all of the optional value slots for
pointcloud_search).

The logic on the oslc side here was broken -- it worked when the token
was a string literal, but when it was a variable whose value wouldn't be
known until runtime, it was failing to mark it as writeable, whereas the
correct thing to do is to conservatively conclude that it *might* be
written to (we don't know yet) and mark it as such.

The cascade of errors could lead to incorrect runtime optimization, if
the only used output of the function call was one of these parameters
that failed to be marked as an output, so so the whole function call
might be subject to the "useless op elision" optimization wherein ops
whose writes are never subsequently read can be eliminated entirely.
2017-11-15 13:18:27 -08:00
Larry Gritz c3d062b0ca Bump LLVM minimum from 3.5 to 3.9. (#806)
This cleans up a lot of #if cases where we were trying to support a very
wide range of LLVM releases in the face of changing APIs. With 3.5 gone,
so too is the "old" JIT (it's all MCJIT now).

By the time we get around to the next major release, we may further
reduce the complexity by dropping support for 3.9 (i.e., minimum LLVM >=
4.0), but I'll leave that for a later review.

Also tweak the Travis settings to assure we test against all the supported
LLVM releases.
2017-11-14 11:10:35 -08:00
Larry Gritz 9c83485a4a Travis reduce package install cost
1. Instead of installing libboost1.55-all-dev, which truly is everything
boost, just install the boost headers and the library components for the
very small number of non-header things we want.

2. Move the Linux package installation to be per-matrix-entry, this
allows us to customize by only installing the specific g++ version we
need, and exclude some boost components (using gcc >= 4.9 removes the
need for boost regex, for example).

This shaves several MINUTES of time from each test matrix entry, which
had been needlessly downloading and installing unneeded packages.
2017-11-10 00:07:11 -08:00
Larry Gritz d541d1a113 pugi tweak 2017-11-10 00:06:15 -08:00
Larry Gritz 0d058c798e Simplify the PugiXML logic. (#809)
By default, look for a system install. If that's not found, check
the OIIO distribution, where another header-only copy can also usually
be found. Eliminate the USE_EXTERNAL_PUGIXML, I don't think anybody
depends on that as long as the default is to check system libs first.

The only thing this doesn't do well is to have a system PugiXML but
*force* us to use the one from OIIO (whose only possible advantage is that
it's namespaced). If this is a problem in practice, we can return to make
that possible.
2017-11-09 22:19:56 -08:00
Larry Gritz 86af7c880f Restore support for OIIO 1.7 (#808) 2017-11-09 17:05:53 -08:00
Larry Gritz 99b0db748e Suppress gcc7 warning about signed vs unsigned compare. (#807)
We can't fix the code -- it's not "our" code, it it's the stuff
generated as part of the build process by flex itself. The expedient
thing is to just suppress the warning in the flex-generated module.
2017-11-09 14:55:03 -08:00
Larry Gritz dcb810a109 Fix incorrect Linux pre-build LLVM for 4.0, 5.0 2017-11-02 10:54:44 -07:00
Larry Gritz 03b10d0d66 Bump version numbers after branch of OSL 1.9 2017-10-30 14:01:36 -07:00
Larry Gritz 806e399c3f CHANGES
[ci skip]
2017-10-30 13:52:39 -07:00
Larry Gritz 0f339174f2 Sort out locales for OSL (#795)
I got quite the education this week, realizing just how much of C++'s
I/O functionality implicitly takes the system's "locale" into
consideration.  Of particular concern is the conversion of text to
floating point numeric values and vice versa, for which much C++
functionality will happily swap the role of '.' and, say, ',' (comma)
for the decimal mark, depending on the user's country and whether they
are savvy enough to set their locale to the classic "C" (essentially
US-style) version. On the other hand, who can blame somebody for not
blindly accepting US hegemony these days?

But dammit, OSL is a programming language, and so '.' has a specific
role in numeric constants and ',' does something quite different (comma
operator!), and if you start mixing up the two when parsing programs,
it will all end in tears. All other major programming languages just
adopt this convention as well.

Now, if you were writing a full app, you could set the locale to the
classic one globally (to that process) upon startup, and then never
worry about it. Which we can do for oslc itself. But much of OSL is
actually a library that can be embedded into other libraries or apps,
so globally setting the locale can mess up UI internationalization or
the intentional localization of other app I/O. So we have to handle
this deftly throughout.

The fix comes in three parts:

1. I've submitted a separate review to OIIO here:
https://github.com/OpenImageIO/oiio/pull/1785 which tries to straighten
up that library, and in particular the various Strutil and ustring
utilities that we liberally use throughout OSL. And patrol some of the
places where we directly call the locale-sensitive C++ functions like
atof and strtod, and replace them with the now-safe OIIO::Strutil
equivalents. We'll be able to count on all this working for OIIO >= 1.8.6.

2. In a variety of places that don't rely on OIIO (for example, various
outputs via std::ostringstream), we need to take care to explicitly set
the stream's locale to produce the output we expect.

3. For people building OSL against a too-old version of OIIO to contain
the fixes described above, when compiling a buffer of OSL source code,
do the gross but necessary safeguard of saving the prior locale,
globally changing to "C" locale while we compile the OSL, then restoring
the locale.  And *HOPE* that the surrounding application isn't
simultaneously counting on the original locale-based
internationalization still being in effect for something it is doing in
another thread that's unaware that we've temporarily altered a global
setting. That's inherently unsafe, but remember it only affects OSL builds
against pre-1.8 OIIO (once that patch is applied on the OIIO side), and
only will be symptomatic for systems using a non-. locale (which is,
empirically speaking, rare enough that nobody noticed this issue until
this week).
2017-10-27 20:08:39 -07:00
Larry Gritz f785cc28e0 Fixes to ShadingSystemImpl::decode_connected_param (#805)
@marsupial correctly points out that we are unsafely passing
a string_view.data() into both atoi and strchr, which is unsafe because
there's no guarantee that a string_view is null-terminated. Ugh!

He proposed a fix here: https://github.com/imageworks/OpenShadingLanguage/pull/800
and there's nothing wrong with it per se, but I suspected it could be done
more simply, so this PR is my stab at it, using the `OIIO::Strutil::parse_*`
functions.
2017-10-27 13:48:19 -07:00
Larry Gritz 0c6e557158 Dual refactor and generalization (#803)
In this patch, I completely overhaul the main class that implements our
dual arithmetic-based automatic differentiation. No more Dual2, with
hard-coded x and y partials. Now we have Dual<T,P>, templated on the
number of partial dimensions P. Now Dual2<T> is just a templated typedef
that specilizes to 2 dimensions.

In addition to general cleanup, this leads to several benefits:

1. It is now trivial to extend to 3 dimensions (dx, dy, dz) if we wanted
to use Dual for automatic differentiation of volumetric functions.

2. Dual<T,1> can be used for automatic differentiation of 1-D functions,
which doesn't have any applications within OSL that I'm aware of, but
makes it a whole lot more convenient to re-use outside of OSL, any time
you want to use A.D. with these techniques.

3. It sets us up for a potential future distribution of the Dual stuff
as a separate library, if it seems useful.  It's not 100% free of other
dependencies from OSL (& OIIO), but it's fairly close and would not be
hard to make it entirely self-contained (and header only). I don't need
to do that this week, but it's something I'd like to work toward.

I did double check this by benchmarking full renders, and have confirmed
that it doesn't affect performance at all.
2017-10-24 14:30:24 -07:00
Larry Gritz 33bfadcf80 Make sure that changed headers properly rebuild llvm_ops.cpp bitcode (#802) 2017-10-23 16:22:50 -07:00
Larry Gritz 4c8cb6fc10 Fix typo -- equalVal ought to return bool, not T (#799) 2017-10-19 10:31:01 -07:00
Larry Gritz 01b87c4ead ctransform full derivative support.
Using Dual2 for exact derivs of the hard-coded color transformations.
Use finite differences to numerically differentiate the OCIO color
transformations.
2017-10-18 09:19:56 -07:00
Larry Gritz 027629b782 Dual additions and touch-ups
* templated equalVal() compares the value only (not derivs), overloaded
  for duals and scalars.

* floor and ifloor for duals.

* Some items to make sure Dual2<Color3> works in addition to Dual2<Vec3>.

* multiplication of Dual2<Vec3> * Matrix33
2017-10-18 09:19:56 -07:00
Larry Gritz f9c6f95710 Fix reference output for too-old OIIO 2017-10-18 09:19:56 -07:00
Larry Gritz 1233c398fa transformc overhaul (#796)
Convert transformc() from strosl.h-implemented to C++.

Rather than have it aware of just a few color hard-coded color space
names, allow it to fall back on OpenColorIO (via ColorConfig/ColorProcessor
functionality exposed by OIIO).

This requires OIIO 1.9 and some recent changes in order to be fully
functional. The corresponding OIIO patch is here:
https://github.com/OpenImageIO/pull/1788

Currently, this does not compute derivatives correctly for transformc()
results. I want to go back to this, but it's not trivial because OCIO
doesn't have entry points that return partial derivatives. I don't think
it's an emergency for any practical cases -- you would only notice if you
used the *results* of a transformc call as texture coordinates.
2017-10-17 09:56:20 -07:00
Larry Gritz 5fa7a54a8d Another fixup to make sure older oiio doesn't think Travis is SPI 2017-10-16 22:22:04 -07:00
Chris Kulla 4c4996f96b Support the equivalence between int and int[1] in relaxed type checking 2017-10-16 16:57:58 -07:00
Chris Kulla f260a5b30a Make relaxed parameter type checking less strict
We previously allowed float to vec3 conversions, and it turns out some workflows at SPI could lead to float parameters being passed in as int which we need to perserve.

However, we don't want to get too much more relaxed that this, so make all other cases errors because other mismatches should be flagged as bigger problems and not silently make the wrong picture.
2017-10-16 14:42:42 -07:00
Larry Gritz 2dd1476092 Travis touch up: make the site recognition use the full name
Because, haha, the "imageworks" Travis account is still Travis, its not
the SPI internal machine configuration. So searching 'uname -n' for
"imageworks" is misleading! But searching for "imageworks.com" is ok.
2017-10-16 00:00:16 -07:00
Chris Kulla 58a5935e05 Fix relaxed parameter type check
The meaning of valuetype and paramtype were flipped incorrectly. This only impacted the unsized array case, because the other cases are symmetric
2017-10-05 15:37:47 -07:00
Chris Kulla e5536efe59 Allow an (optional) slightly more relaxed policy when declaring parameters
This allows a color to be declared as float[3] for example. This may be useful when declaring shaders from systems that do not explicitly keep track of the source data type.
2017-10-05 09:54:46 -07:00
Larry Gritz f37150ed0c Fixup for SPI to put the libs in our usual place 2017-09-25 10:55:16 -07:00
Jonathan Scruggs 6b9b167a8f OpenShadingLanguage/master: Change to GNUInstallDirs for install paths (#788)
The variables: BIN_INSTALL_DIR, LIB_INSTALL_DIR, INCLUDE_INSTALL_DIR,
DOC_INSTALL_DIR, and MAN_INSTALL_DIR are defined but never used.
Instead, hard coded paths to lib, include, and bin were used. This
will cause difficulty on multi-lib systems or in cases where they
are named differently. The existing variables were replaced by the
GNUInstallDirs variables, which is compatible on all systems.

There were two instances of the install_targets macro defined, so
removed one and upgraded the other to use GNUInstallDirs. Also, it
was never used in code, so all library installs were changed to use
it.

INSTALL_DOCS variable is defined, so it's now controlling if
the documentation is being installed.

Signed-off by: Jonathan Scruggs <j.scruggs@gmail.com>
2017-09-23 18:47:39 -07:00
Larry Gritz c0db3d7135 CHANGES 2017-09-19 17:11:15 -07:00
Christopher Kulla 3082a7cdd8 Upgrade spi builds to use clang 5 2017-09-19 14:13:28 -07:00
Larry Gritz a734438111 Formalize OpenEXR 2.0 minimum (#793) 2017-08-29 21:34:36 -07:00
Larry Gritz 9f575a9d24 Remove support for LLVM 3.4 (#792) 2017-08-29 21:33:59 -07:00
Larry Gritz 442db05908 Revise constant fold for mod -- eliminate assertion (#791)
Turns out that old shaders that were compiled before we moved float mod()
into stdosl.h, could hit this code. Removing the assertion is the best
way forward. We don't have to explicitly handle the constant folding cases
because they can't happen with newly compiled shaders.
2017-08-29 14:20:48 -07:00
Larry Gritz e061012a9a Update ref output for improved OIIO error message 2017-08-28 13:29:01 -07:00
Larry Gritz bbd90dcb62 OSL runtime constant folding of % (modulus) (#790) 2017-08-23 12:46:34 -07:00
Larry Gritz 104bd26e71 Make OSL work with clang5/llvm5 (#787) 2017-08-18 12:40:45 -07:00
Larry Gritz 5328e3c2d3 Replace many loops with range-for (#785)
As suggested by clang-tidy
2017-08-17 14:48:21 -07:00
Larry Gritz 1bb2b54366 Remove dynamic exception that is deprecated in C++11 and illegial in C++17 2017-08-17 14:47:54 -07:00
Larry Gritz 3831f11df7 SPI: Adjustments to select clang 4.0 on Mac 2017-08-17 14:47:54 -07:00
Larry Gritz c74d13b40c Travis: upgrade to Trusty linux image, test against gcc7 2017-08-17 14:47:54 -07:00
amartinez-cg 8950cc5407 fixes var types not substituting properly (#784) 2017-08-11 23:51:24 -07:00
Larry Gritz 3a09775632 Docs 2017-07-30 09:13:06 -07:00
Larry Gritz cb6f28c447 CHANGES 2017-07-30 00:06:17 -07:00
Larry Gritz e9e55306ea MaterialX build process: Change all type names to lowercase (#783) 2017-07-19 17:25:44 -07:00
Larry Gritz fb69b916d9 Overhaul MX shader generation to produce the actual osl files (#782)
Previously, the mx templates used tricky #define techniques to do
the type specialization. But now we do some string substitution
to generate the actual .osl for every type flavor of every mx shader,
then just directly oslc that.

In the process, mx_types goes away because there's nothing left in it
that was necessary. And I merged swizzle.h into mx_funcs.h, and also
needed to expand the various typed swizzling operations.
2017-07-19 09:34:15 -07:00
Larry Gritz 3f271958ec Implement fprintf (#780)
Has always been in the docs. I swear I had this working at one point.
But it seems to be MIA.
2017-07-15 14:50:04 -07:00
Larry Gritz d358b63cc9 Rename long-deprecated mask4 -> bool4 (#779) 2017-07-15 14:49:09 -07:00
Larry Gritz eca73bde3c Fix dependency problem with the mx shaders (#781)
There were a number of subtle problems with how the shaders compiled and
the dependencies thereof (especially with respect to the copying of the
headers). This resulted in some things happening in the wrong order, which
for certain build thread counts could make build breakages.

It was really subtle, and in the end, I rewrote most of the CMake
scrips for both the OSL and MaterialX shader directories. But hopefully
everybody will be pleased with the results, it's cleaner now.
2017-07-15 09:34:33 -07:00
Adam Martinez 98aa2ac11b MaterialX -- OSL shaders for everything described in MX.
By Adam Martinez & Derek Haase

Because MX shaders come in a huge variety of flavors for every type, the
bulk of the shader logic is in "template" files such as
src/shaders/MaterialX/mx_add.mx.

The build system will compile this several times, once for each type,
using preprocessor tricks to specialize the types, resulting in a
collection of type-specific shaders:
    dist/macosx/shaders/MaterialX/mx_add_color.oso
    dist/macosx/shaders/MaterialX/mx_add_color2.oso
    dist/macosx/shaders/MaterialX/mx_add_color4.oso
    dist/macosx/shaders/MaterialX/mx_add_float.oso
    dist/macosx/shaders/MaterialX/mx_add_vector.oso
    dist/macosx/shaders/MaterialX/mx_add_vector2.oso
    dist/macosx/shaders/MaterialX/mx_add_vector4.oso

The testsuite additions to thoroughly unit test everything is still
a work in progress and will be submitted as separate PRs soon.
2017-07-11 17:51:18 -07:00
Adam Martinez 1ba9fd5816 Contributed helper headers for color2, color4, vector2, vector4
By Adam Martinez & Derek Haase

These headers define new struct-based types, plus operator overloading,
and extensions of many stdosl functions:

vector2 -- like vector, but with 2 components (x, y)
vector4 -- like vector, but with 4 components (x, y, z, w)
color2 -- a float (single color channel) + alpha
color4 -- a color (RGB) + alpha

These are not officially part of the OSL core language and are not
described in the OSL Language Specification. But the are sometimes handy
when building shader libraries, so we will call them contributed headers
that are distributed along with the OSL library implementation.
2017-07-11 17:51:18 -07:00
Larry Gritz 43e65c2d54 Bump version after tag 2017-07-03 17:26:47 -07:00
Larry Gritz 76c3bdb8b2 Update PDF docs 2017-06-30 11:47:14 -07:00
Larry Gritz 93a8ec0102 CHANGES/docs 2017-06-30 11:25:23 -07:00
Larry Gritz 2b59ea9a8c hash() of numeric types, and hashnoise() (#775)
int hash(T) extends the existing integer-valued hash that we have for
strings, to accept arguments of float, 2 floats, triple, triple+float,
int.

float_or_triple hashnoise(...) is like cellnoise, but is discontinuous
everywhere (i.e., returns a different uncorrelated value for every
distinct real-valued input).
2017-06-20 10:14:10 -07:00
Larry Gritz e6912d0a64 Fix bug in transitive assignment of indexed arrays. (#774)
This worked:

    float x, y, z;
    x = y = z;

for non-array values. But this hit an assertion:

    float f[3];
    f[0] = f[1] = f[2];
2017-06-19 09:26:44 -07:00
Larry Gritz 4c790a0800 testshade: proper error for common mistake with order of --param vs shader (#773)
Example:

    $ testshade -param x 1.0 test
    x=1.0

    $ testshade test -param x 1.0
    ERROR: Pending parameters without a shader: x
    Did you mistakenly put --param after the shader declaration?
2017-06-12 13:27:41 -07:00
Larry Gritz 6dc17faec9 Docs 2017-06-12 13:26:50 -07:00
Larry Gritz 1e20f6c300 Fix minor numerical precision problem with inversespline (772)
We were having some troubles right at the boundary, which was easily
fixed if we changed the tests for trivial cases to be <= and >= instead
of < and > the boundary value.

Required also implementing <= and >= for Dual types.
2017-06-12 13:25:36 -07:00
Larry Gritz 993e4eb294 Define <= and >= for Dual types (771) 2017-06-12 13:25:36 -07:00
Larry Gritz 14aaf9ed7b testshade docs
[ci skip]
2017-06-06 22:48:01 -07:00
Brecht Van Lommel 0aeff68c12 Fix Windows build to not force enable /MT, it is not need for BUILDSTATIC. (#769) 2017-06-06 14:04:13 -07:00
Brecht Van Lommel 1a2db9e892 Fix osl_range_check not found error with USE_LLVM_BITCODE=OFF. (#767) 2017-06-06 14:01:41 -07:00
Brecht Van Lommel b55af05cc4 Fix Ilmbase linker warning with LINKSTATIC on Windows. (#768) 2017-06-06 13:59:06 -07:00
Larry Gritz 3df9b1b9ef Add mix() for color closures (#766)
The mixing factor may be either a float or a color, and it blends the
color closures in the obvious way.
2017-06-05 15:25:37 -07:00
Larry Gritz b5724e1072 Add color/vector-valued version of smoothstep (#765) 2017-06-05 14:36:57 -07:00
Larry Gritz e09dd0aed1 docs 2017-06-05 11:01:30 -07:00
Larry Gritz f7292fc024 CHANGES
[ci skip]
2017-06-05 10:53:09 -07:00
Larry Gritz 41dbdae78c Add logo image 2017-06-05 10:53:09 -07:00
Larry Gritz 81ad4e78cd Install README and similar docs in the doc directory 2017-06-02 16:11:15 -07:00
Larry Gritz 07b2406832 testshade --shader <shadername> <layername> (#763)
`--shader` is like a combination of --layer, and then naming the shader
to create an instance of it.

The reason I prefer --shader is that when you use it, the command
line is almost identical to the shader group serialization. So much nicer!

For example:

```
$ testshade -param texturename "grid.tx" \
            -shader texturemap tex1 \
            -param frequency 4.0 \
            -shader noisy noise1 \
            -param scale 1.0 \
            -shader contrast cont1 \
            -shader umixer mix1 \
            -connect tex1 out cont1 in \
            -connect cont1 out mix1 left \
            -connect noise1 out mix1 right \
            -g 256 256 -o out noisetex.jpg
```

corresponds very symmetrically to the shader group

```
param string texturename "grid.tx" ;
shader texturemap tex1 ;
param float frequency 4.0 ;
shader noisy noise1 ;
param float scale 1.0 ;
shader contrast cont1 ;
shader umixer mix1 ;
connect tex1.out cont1.in ;
connect cont1.out mix1.left ;
connect noise1.out mix1.right ;
```

whereas, in comparison, using the old --layer notation works, but is
a less direct mapping to the serialization format:

```
$ testshade -layer tex1 -param texturename "grid.tx" texturemap \
            -layer noise1 -param frequency 4.0 noisy \
            -layer cont1 -param scale 1.0 contrast \
            -layer mix1 umixer \
            -connect tex1 out cont1 in \
            -connect cont1 out mix1 left \
            -connect noise1 out mix1 right \
            -g 256 256 -o out noisetex.jpg
```
2017-06-02 16:00:42 -07:00
Larry Gritz e6f921aec4 Fix oslc assertion when passing stucts with operator overloading. (762)
The recent patch that allows users to specify operator overloading
for structs means that, in this particular spot, the AST node type
that might be passed as the argument to a function might be a binary
or unary expression -- those could never have returned a struct before,
so were not enumerated in the list of nodes of this conditional, causing
an assertion to hit.
2017-06-01 17:15:08 -07:00
Larry Gritz eb7b872166 Refine structure type comparison (760)
The prior method of comparing structures by examining them for identical
layout failed if you wanted to have two structures that purposely had
the same layout but wanted their semantics to be different (for example,
by having a function that would work on only one of them).

Change the struct type checking comparisons to check NAME as well as
struct layout. Also need to no longer mangle the name when reading in
oso.

While I was there, and adding a new test for this, I renamed a test
I added recently, to more closely match other related ones.
2017-06-01 16:47:15 -07:00
Larry Gritz 3f6a926825 Improve type checking errors with structs (#761)
Change the implementation of TypeSpec::string(), which returns the text
representation of a TypeSpec, so that it prints the name of the struct
rather than just its numerical designation.

An example of the old behavior, as applied to a type checking error
message:

    test.osl:10: error: No matching function call to 'max (struct 1, struct 1)'
        Candidates are:
            int max (int, int)
            float max (float, float)
            ...

And the new behavior:

    test.osl:10: error: No matching function call to 'max (struct vector4, struct vector4)'
2017-06-01 14:49:41 -07:00
Brecht Van Lommel b8f8b2bfd5 Fix missing faceforward() implementation. (#759) 2017-06-01 13:39:13 -07:00
Larry Gritz c8ad35db7d testrender: output jpg/gif/png in sRGB (#758)
Just like we recently did for testshade.
2017-05-31 14:32:55 -07:00
Larry Gritz d19ce99d76 Merge pull request #757 from lgritz/lg-testshade
testshade improvements
2017-05-30 21:15:57 -07:00
Larry Gritz 20331f7c6e testshade: change -od to -d to match oiiotool and txmake. 2017-05-30 12:11:15 -07:00
Larry Gritz d671d259be testshade -runstats: be more careful about timing
Make sure the main timer doesn't count writing output files to disk.
2017-05-30 12:11:15 -07:00
Larry Gritz 8e2caa5ecd testshade: automatically convert to sRGB when outputting jpg, gif, or png.
Makes it easier to output directly to web-friendly formats, without
a second oiiotool step to apply the right color spaces.
2017-05-30 12:11:15 -07:00
Larry Gritz e9063df3fe testshade --print sends to the console the value of all saved outputs.
This is useful if you are trying to unit-test or directly inspect
the outputs of a shader, without needing 'printf' calls in the shader.

It's probably not helpful to do this when using -g to produce big
output images -- too much console output to be useful.
2017-05-30 12:11:15 -07:00
Larry Gritz b1c6522d50 testshade: rename --scalest/--offsetst -> --scaleuv/--offsetuv
Because it modifies the u and v range. There is no s and t.
2017-05-30 12:11:15 -07:00
Larry Gritz 54e54344da Fix bug comparing structure types with equivalent() -- false positive (#755)
It was incorrectly saying that two different structs matched! The
problem was a subtle issue of the ordering of clauses in a complex
comparison -- we need to test the structure case first, because the
other clause makes the assumption that the types are simple and not
structures and will have a false positive in that case. An important way
this could manifest is that if you had two overloaded functions whose
arguments were structs, say foo(structA) and foo(structB), it was not
able to correctly distinguish between them for type checking.
2017-05-30 11:20:39 -07:00
Larry Gritz 96bb3dea94 Move TypeSpec::string and c_str from symtab.cpp to typespec.cpp (#756) 2017-05-30 08:02:57 -07:00
Larry Gritz db18399e4b ShadingSystem::convert_value, allow float[3] <--> triple conversion. (#754)
This utility is used by renderers for getattribute and other
renderer-to-OSL data copying, and is meant to facilitate the
obvious set of copy conversions between slightly mismatched yet
sensible types.

Adding a clause that lets you retrieve a triple (point, color, etc.)
even if it was declared on the renderer side as float[3], and vice
versa.
2017-05-19 19:48:36 -07:00
Larry Gritz 45a4d78876 Operator overloading (#753)
This patch allows you to implement operator overloading in OSL -- for
example, if you define a type like

    struct vector4 {
        float x, y, z, w;
    };

you can also define math operators in the following manner:

    vector4 __operator__add__ (vector4 a, vector4 b) {
        return vector4 (a.x+b.x a.y+b.y, a.z+b.z, a.w+b.w);
    }

and then use plain old `+` as you would for any built-in types:

    vector4 a, b, c;
    c = a + b;    // automatically calls __operator__add__(vector4,vector4)

It's fairly straightforward: for any of the usual unary and binary
operators, if a function called __operator__NAME__ is visible from
the current scope and the types match, it is understood that the
operator really means a function call to that special function.
The valid NAME choices are add, sub, mul, div, neg, and so on. See
the docs for full list, but it's pretty obvious.

With great power comes great responsibility! Use this wisely -- that is,
sparingly, and only when the operator is exactly analogous to how it
works with the built-in types. Same general guidance about using it in
C++.
2017-05-18 17:35:54 -07:00
Larry Gritz 01615adbc8 Struct constructors work like built-in type constructors. (#751)
You know how you can have an expression for a built-in type like color?

    foo = color(1,1,1)

or

    void func (color c) { ...}
    func (color(1,1,1);

It was really awkward to do this with structs.

So with this patch, for every struct, you can construct it by name
with a function-call-like syntax, where the arguments must be the same
types as the data members of the struct, in order.

For example:

    struct RGBA {
        color rgb;
        float a;
    };

    RGBA x = RGBA(color(1,1,1), 1);

    void func (RGBA x) { ... }
    func (RGBA(Cblah,alpha));

You don't need to explicitly declare the constructor like in C++, it
just exists.
2017-05-17 14:25:08 -07:00
Larry Gritz ef44fddc2f Docs: improve appearance of tilde and caret operator symbols 2017-05-16 15:47:03 -07:00
Larry Gritz 5a8f7d5a50 More flexibility in pointcloud_search/get retrieval (#752)
In the default RendererServices implementation of retrieving data from
point clouds via Partio, there had to be an exact match between the
attribute type of the point cloud file (as understood by Partio) and the
element type of the OSL array used to store the retrieved data.

Because OSL doesn't support 2D arrays, that means that you could retrieve
only data of the main non-array OSL types: int, float, 3-float (color,
point, vector, normal etc.).

But we had somebody create a point cloud that stored float[4] to store
quaternions (don't ask), and then was unable to retrieve it from OSL,
because there is no float[4] type.

So the solution is that we are loosening the type matching tests.
Simply stated, it's willing to match either a float or a float[n] in the
point cloud, when retrieving into a float array in OSL. If it's a
float[n], it will just pack them contiguously into the OSL array of
floats, and it's up to the shader to know what's expected and to unpack
and interpret it properly. An error will be reported if there is not
enough room in the array provided.
2017-05-15 16:40:43 -07:00
Larry Gritz 75b475c4ca Fix namespace clash after recent OIIO pugi overhaul 2017-05-10 15:15:43 -07:00
Larry Gritz 13b04065ce Relax the strict typing of ShadingSystem::Parameter() (#750)
SS::Parameter(), which is used to pass parameter instance values,
is very strict about the types matching exactly. I'm loosening it
somewhat -- by allowing the user to pass a float as the
instance value of a triple (color, point, etc.), and to pass one triple
when a different was the declared parameter. This makes it have similar
flexibility to that afforded by ConnectParameters, and I can't think of
a good reason why one should be any stricter than the other.
2017-05-08 11:02:14 -07:00
Larry Gritz 1a02d84287 Document version preprocessor syms 2017-05-07 17:18:15 -07:00
Larry Gritz a90aa5b9f9 Get rid of html style 2017-05-07 17:18:15 -07:00
Larry Gritz c554ee6e45 Improve efficiency for texture (..., "subimage", "") (#749)
When we can detect that the user is passing the empty string as subimage
name to a texture call, there's no need to have the useless call to
osl_texture_set_subimagename.
2017-05-07 17:15:15 -07:00
Larry Gritz ee296dfe64 Add ways to test OSL version: (747)
* C++: define OSL_VERSION (10900 for 1.9.0), OSL_VERSION_MAJOR,
  OSL_VERSION_MINOR, OSL_VERSION_PATCH.

* osl source at compile time: oslc now pre-defines OSL_VERSION,
  OSL_VERSION_MAJOR, OSL_VERSION_MINOR, OSL_VERSION_PATCH.

* osl runtime now supports getattribute("osl:version"), which also
  get properly constant folded.

Note that this means that renderers ought to make sure their
implementation of RendererServices::get_attribute detects requests for
"osl:version" and in that case retrieve the integer value of
OSL_VERSION. But in practice, you will only notice a renderer's failure
to do this if you turn off runtime optimization and the constant folding
of the attribute doesn't occur.
2017-04-29 23:39:45 -07:00
Larry Gritz 1055d07bf4 More robust to new placement of external pugixml in Homebrew 2017-04-24 17:09:40 -07:00
Larry Gritz 3c3d6e4c0c testshade: fix to accept array of strings as parameter value (#745)
I discovered that while you can pass a parameter that's an int array,
float array, etc., string arrays didn't quite work, they were treated as
single strings.
2017-04-24 16:53:34 -07:00
Larry Gritz ded2c5d7d4 Add testshade arg to directly set any TextureSystem options 2017-04-21 14:03:29 -07:00
Larry Gritz f406577eda Minor formatting revision of PR and Issue templates
[ci skip]
2017-04-21 10:35:30 -07:00
Larry Gritz 5c0ac2e490 Fix memory leak of ASTNode's in osl compiler. (#743)
Chris discovered that oslc was leaking ASTNode allocations, which was
interfering with some of his sanitizer runs.

Function declarations had the raw pointers squirreled away in the symbol
table without ever keeping a ref-counted version, so they were never
freed. So now we keep a vector of the ref-counted pointers for
ASTfunction_declaration in the OSLCompilerImpl, which all get freed when
the compiler destructs.

Quite independently, we were leaking the nodes associated with certain
metadata, they were just dropped on the floor by the add_meta() method,
which walked through what it was handed and used it to adjust things,
but never freed the pointers. This is fixed by changing add_meta to
force the raw pointers to be converted to ref-counted.

I added some code that for DEBUG builds only will track the construction
and destruction of ASTNodes, and upon program termination will print
messages if more nodes were created than destroyed.
2017-04-20 13:11:24 -07:00
Larry Gritz 73d83836e1 Docs for PR, Issue, Contributing
[ci skip]
2017-04-19 15:58:10 -07:00
Larry Gritz aa367aa08e Fix OSX build problems on TravisCI, support make INSTALL_PREFIX (742)
Our TravisCI builds on OSX have been failing for a while and I finally
got a chance to track down the issues.

1. Slight adjustment to ensure that on OSX the rpath is set correctly.
(At least I think it's more "correct" now. Seems to fix some things.)

2. Make sure that on Travis we install the homebrew freetype package,
which is needed for the texture-udim test.

3. Make sure OIIO_LIBRARY_PATH is set to help the osl-imageio test, which
needs to find the osl plugin for OIIO.

4. Also simultaneously depends on a change to OIIO (analogous to the first
item here) to adjust its RPATH behavior slightly on OSX.

None of these things should affect non-OSX builds.

Also, as was recently done to OIIO, add to the wrapper Makefile the
ability to set INSTALL_PREFIX, which is passed along to cmake as
CMAKE_INSTALL_PREFIX. It defaults to the usual of ./dist/PLATFORM, but
this lets you override to, for example, instruct the build to put the
full installed files in another location. You could always do this if
invoking cmake directly, but it was tricky for those who preferred to
use the make wrapper.
2017-04-19 09:46:09 -07:00
Larry Gritz e0629074a3 Allow shaders to be accidentally specified with trailing .oso (#741) 2017-04-18 11:07:52 -07:00
Chris Kulla a0fde55e1b Fix the handling of alignment for closure structs 2017-04-17 09:17:29 -07:00
Larry Gritz a9c21bdf1d Streamline range checking (#739)
We noticed some cases where the range checking overhead was measurable.
The overhead can be cut roughly in half by making osl_range_check inline
in llvm_ops.cpp so that there is no function call involved in the check
itself, only in the uncommon case of when an error is detected does it
call osl_range_check_err which lives elsewhere.
2017-04-13 16:53:55 -07:00
Larry Gritz 0af8bb046b More robust finding of stdosl.h (#737)
There was a discrepancy in how stdosl.h is searched for, among the
different ways that compiles are triggered (osl from command line,
versus OSLCompiler from file, versus OSLCompiler from buffer). This
patch unifies them, and expands with additional heuristics for finding
the file.

Also falling out of this is that the build and test scripts are now much
more robust to the user not setting $OSLHOME -- a top-level 'make test'
will find it all in the build itself. Also, it fixes some cases where
osl.imageio.so can't find stdosl.h, and thus would appear inexplicably
broken.
2017-04-13 09:53:54 -07:00
Chris Kulla 0375b27f53 Move matrix transform shadeops out of llvm_ops and into opmatrix
This has the side benefit of avoiding the Imath exception handling in matrix inverse from making it into the bit code LLVM needs to process, reducing the amount of runtime symbol resolution required
2017-04-12 12:27:48 -07:00
Larry Gritz 6a1fb96457 Eliminate varargs from OSLCompilerImpl and ASTNode (#735)
Use variadic templates instead.

Depends on having a sufficiently new OIIO, so there are a couple `#if`s
for now, but eventually the old path can be removed.
2017-04-11 23:56:51 -07:00
Larry Gritz 3e5fffe938 Fix unclear/wrong docs about nested structs and arrays 2017-04-11 16:43:06 -07:00
Larry Gritz 2d5e1b14a7 Slight revision to namespace (conceptual, doesn't change the name for OSL) 2017-04-11 16:43:06 -07:00
Larry Gritz 87c72dffa6 Hide symbol visibility for the extern "C" osl_* functions LLVM needs. (732)
We never previously mangled or hid the many functions OSL needs to call
by address, which it figures out with dlsym calls, and therefore those
functions needed "C" linkage (no C++ mangling) and external visibility.
But that was the weak point for completely hiding the library symbols
to avoid clashes between versions or multiple OSL copies.

In this patch, we change the visibility of all those symbols to local
(which we also ensure is hidden by default) and since that would make
the dlsym fail, we explicitly make LLVM aware of the mapping from
llvm::Function* to callable address.
2017-04-11 10:27:07 -07:00
Larry Gritz bc44f40b6d Revise namespace. (732)
Instead of a nested namespace (like OSL_custom::OSL), only have one,
which now incorporates the major and minor version (not automatically
folding the version in was an oversight I wish to correct now). So, for
example namespace OSL_v1_9. The base name (the OSL part of it) is
customizeable by the OSL_NAMESPACE cmake variable, which defaults to
OSL. Individual sites or products may override, and are advised to if
they do anything nonstandard to their OSL build. Just like before, there
is a namespace OSL = the wrapped namespace, so client applications can
just say OSL::foo, and it's really referring to the full versioned
and/or customized name that the linker sees.

Also got rid of several pointless variables and defines.
2017-04-11 10:27:07 -07:00
Chris Kulla 3e1c297618 Add an API call to define the raytypes_on and raytypes_off assumptions that will be used during optimize_group
This makes it possible to use this feature of the optimizer even when relying on lazy JIT of shader groups
2017-04-10 16:51:46 -07:00
Larry Gritz f9498d3bd7 Fix missing include after oiio update
A recent oiio master update changed errorhandler.h to no longer include
<cstdarg>, but we depended on it here.
2017-04-09 10:32:40 -07:00
Larry Gritz 584979c835 Use C++11 vector::emplace_back() where appropriate. (#729)
Now that we have C++11 as a minimum, we can use this handy feature that
grows a vector by one slot (uninitialized) and the constructs a new
object in that location. In contrast, push_back() constructs the object
first, then grows the vector with a default constructed object, they
copies (or if you're lucky moves) the new object into the vector
position. Maybe the compiler will figure it all out, maybe not.  Using
emplace_back guarantees that there are no needless copies, moves, or
pointless constructions.

Thanks, clang-tidy, for making this a 5-minute change!
2017-04-03 14:33:49 -07:00
Larry Gritz d9afc5377f CHANGES
[ci skip]
2017-04-01 19:53:18 -07:00
Larry Gritz 7aa8d05005 Fix cmake typo 2017-04-01 14:48:15 -07:00
Larry Gritz 6708788928 Fix deprecated C header includes, change to proper C++ 2017-03-31 15:01:00 -07:00
Larry Gritz cfe492cff7 Fix up and make uniform all our internal #include directives
Use <OSL/foo.h> for all public header includes, not "OSL/foo.h"
and definitely not just "foo.h".
2017-03-31 14:49:22 -07:00
Larry Gritz 0945e25b65 clang-tidy support (ported from similar change to OIIO) 2017-03-31 14:38:35 -07:00
Larry Gritz 4d496f6699 Add a way to instrust install_homebrew_deps to select a LLVM version 2017-03-24 12:16:48 -07:00
Larry Gritz dd4ed72897 Fix linkage problem with some tests unnecessarily linking liboslcomp (#727)
liboslexec contains all the functionality of oslcomp. You never need
both. It used to be harmless to link against both, though, until we
included clang C preprocessing functionality. Clang has some components
that cause trouble if linked twice, and so we run into that both
liboslexec and liboslcomp contain statically linked clang components.
2017-03-23 16:35:44 -07:00
Christopher Kulla 4bafbffea3 Upgrade compiler path and LLVM version for SPI Arnold builds 2017-03-23 09:44:34 -07:00
Larry Gritz e4f369b622 Synchronize some build scripts between OIIO and OSL.
They are very similar. From time to time I do two-directional transfers
to migrate the best practices of each to the other.

I also try to nudge them even closer in various ways, such as using
${PROJECT_NAME}_BLAH in both instead of OSL_BLAH in one and
OpenImageIO_BLAH in the other.
2017-03-22 21:39:07 -07:00
Christopher Kulla 250ce429bd Avoid searching for render outputs when none are registered to avoid the cost of the string formats 2017-03-22 17:44:55 -07:00
Larry Gritz e24fff898b Improve detection of std::regex (ported from OIIO) 2017-03-21 12:49:25 -07:00
Larry Gritz 0f38d7e372 Synchronize testsuite/runtest.py code with the analogous OIIO code 2017-03-21 11:43:03 -07:00
Larry Gritz 4f5999d598 More robust handling of exceptions to "useless op elision." (#722)
OSL's runtime optimizer tries to eliminate operations whose results
are never used (people don't write shaders like this, but as we optimize
and rewrite the shader's ops, many ops may reveal themselves as having
no effect).

But, we don't do this with built-ins that have no written arguments
at all (such as printf or setmessage), because it figures that having
no immediate outputs means it's there purely for the side effects.

But -- OH NO! -- it turns out that trace() is an exception to the rule.
It has a writeable output (the return value), but it ALSO has an
important side effect (it sets up trade state that may later be queried
by getmessage("trace")). So if you wrote a trace call and did not assign
its return value to something that got used, the trace call might be
eliminated entirely, which would totally bork your later getmessage
queries about that traced probe ray.

So sorry.

This fix formalizes the notion that certain ops have important stateful
side effects, and it will not apply the "useless op elision" optimization
to those instructions.
2017-03-10 16:54:27 -08:00
Larry Gritz 9724cfd981 Fix clang assertion / linkage error (#721)
On some systems, sometimes, when linking against LLVM <= 3.5 and using
clang internals for C preprocessing, we've seen assertions coming from
llvm::cl::OptionCategory::registerCategory, which we aren't even
intentionally using.

This email explains the issue:

 http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140203/203968.html

Seems pointless to fight what appears to be an awkward mis-design in
older LLVM. The problem was fixed some time between 3.5 and 3.9.

So let's sweep it under the rug by falling back to boost wave when using
older LLVM.

Also includes a slight refactor to make clang cpp logic work for custom boost.
2017-03-09 17:24:57 -08:00
Larry Gritz 591ca7fd88 SPI: Temporary bug fix, having problems with clang cpp, revert to Boost wave 2017-03-09 10:02:46 -08:00
Larry Gritz 77586e863c SPI: use system install of ninja, not custom path 2017-03-09 09:57:31 -08:00
Larry Gritz acbba648c2 Update ref output for minor numerical changes from #720 2017-03-09 09:50:04 -08:00
Chris Kulla 5f48c34441 Fix inconsistency in normalize between Dual and float versions
This could lead to NaNs or Infs on very small arguments.
2017-03-09 09:18:11 -08:00
Larry Gritz 76377f1879 oslc with clang cpp: capture preprocessor errors properly (#719)
We were not setting up "diagnostics" properly, which led shaders
with certain errors in their use of the C preprocessing to hit
assertions in the clang code.
2017-03-08 14:20:20 -08:00
Larry Gritz 4950d4caf2 Movies 2017-03-01 21:46:24 -08:00
Larry Gritz 5433a71a20 CHANGES 2017-03-01 21:33:20 -08:00
Larry Gritz f6db0d5478 Simplify how we put raw source code into .oso comments (#717)
Use OIIO::Filesystem::read_text_file to read the whole file at once
instead of doing piecemeal file reads.

This eliminates an occasional buffer overrun as well.
2017-03-01 21:30:48 -08:00
Larry Gritz 130860aec8 Fix subtle use-after-free error in Dictionary::dict_find (#718)
It was incorrect to take a reference to an element of the vector
m_nodes, and then to keep using the reference inside the loop in
which the vector is grown (thus possibly invalidating the memory
that the reference points to).

Found by address sanitizer!
2017-02-28 13:13:52 -08:00
Larry Gritz 5fcf4810a1 Suppress leak sanitizer where necessary 2017-02-28 12:23:56 -08:00
Larry Gritz d771ee8606 Move compiler and installation logic to compiler.cmake, install.cmake (#716)
This mimics a cmake refactor we did recently in OIIO master.

In the process, this enables sanitizer modes.
2017-02-28 12:21:58 -08:00
Larry Gritz 7b4de29116 More films
[ci skip]
2017-02-24 16:28:00 -08:00
Larry Gritz 316c99f05f Document minimum cmake in the INSTALL.mk file 2017-02-24 16:27:11 -08:00
Larry Gritz 128e4c315a Try to speed up Travis builds by skipping unneeded portions of OIIO build 2017-02-24 12:17:17 -08:00
Larry Gritz da9a846a8a Remove unnecessary define OIIO_STATIC_BUILD 2017-02-24 12:17:10 -08:00
Larry Gritz 53a71ff617 Minor tweaks to FindOpenImageIO.cmake
* Fix verbose status print
* Set OPENIMAGEIO_LIBRARY_DIRS
2017-02-24 10:30:02 -08:00
Larry Gritz 979dc05e23 Use clang's C preprocessor as alternative to Boost Wave (#715)
Boost Wave is a bit of a pain, in particular it can have problems if
compiling OSL with C++11 (as is mandatory now in master) but link
against a Boost that was compiled without the C++11 options.

At Chris Kulla's suggestion, we can switch to using the C preprocessing
faciliies from clang's internals. Ordinarily, LLVM/clang would be much
to painful to add just for this, but since we're already tied to LLVM as
a dependency, it's really no additional burden.

So here we are. There's a build time cmake option USE_BOOST_WAVE, which
defaults to off, but if problems are discovered with the clang cpp, that
gives is a Plan B. Eventually, when we're completely confident in the
way I've done it with clang, we may remove the Wave option entirely.

This is not 100% working. It seems to work fine if you are using clang
as your compiler, or if you are using gcc 4.8.x, or if you are building
against LLVM 3.4/3.5.  But the combination of using gcc >= 4.9 to
compile and linking against LLVM >= 3.9 is resulting in crashes with
complaints about double-freeing something. Surely it's our error, making
a mistake about who owns what allocation or something, but I'm not sure
what's wrong and I'm tired of holding up this patch for all the people
and cases that it can help. So for now, for the combinations that don't
run properly, it automatically falls back to using Boost Wave. We will
remove this special case as soon as we figure out why it's failing in
that case. (As stated earlier, you can also force use of boost wave with
USE_BOOST_WAVE=1.)

Also made some changes to the Travis build matrix to cover various cases
of combinations of compiler and LLVM version.
2017-02-24 10:14:09 -08:00
Larry Gritz ef732a54c5 Use std::regex any time it is available. (#714)
On the currently supported compilers, we believe the only time we
need to fall back to boost::regex is for g++ 4.8.x.

Also change the ShadingContext::m_regex_map to use unique_ptr<>
so that the allocated regexes free upon destruction without needing
an explicit loop and delete calls.
2017-02-22 22:00:08 -08:00
Larry Gritz 1e9bf2870d Remove direct reference to tinyformat in lieu of C++11 variadic templates. (#713)
All protected by #if's for now, so it works right with older OIIO before
the change on that side. Eventually those will be deleted.
2017-02-22 13:41:48 -08:00
Larry Gritz 35cbb0dccf Change TravisCI builds on Linux to build primarily against LLVM 3.9. (#712)
Also one test against 3.5, while we still support it, to be sure it
doesn't break.

The real trick here is that I couldn't find a proper apt package for the
somewhat older flavor of Ubunu ("precise") that's on the Travis servers,
for any LLVM newer than 3.4. The solution, at least for now, is to use
wget to download the handy per-build packages available from llvm.org
and use those directly.
2017-02-15 21:37:39 -08:00
Larry Gritz bb64bebe4e Refactor finding of LLVM (#711)
Split into a proper FindLLVM.cmake, make it more robust, require
at least 3.4 (for now).
2017-02-15 15:47:04 -08:00
Christopher Kulla d2891ba748 Avoid division by 0 when computing derivatives in pointcloud_search (#710) 2017-02-09 15:59:27 -08:00
Larry Gritz e069245f21 boost::thread -> std::thread and OIIO::thread utils 2017-02-09 15:47:29 -08:00
Larry Gritz c9daf35fde boost::intrusive_ptr -> OIIO::intrusive_ptr 2017-02-09 15:47:29 -08:00
Larry Gritz 9159ddc4e4 OIIO dependency fixes (#708)
* Fancy new FindOpenImageIO.cmake, and related cleanup
* Bump OIIO minimum to 1.7
* Remove old #if's related to older OIIO versions
2017-02-08 16:59:59 -08:00
Larry Gritz 1a3debc4f0 Merge pull request #707 from lgritz/lg-cpp11
C++11 and Boost changes

I've waited a long time for this flurry of adjustments to 'master', now that we are safely assuming a base of C++11 minimum, Boost minimum 1.55 per VFXPlatform's guidelines (as far back as CY2015), and also our stated intention for OSL master/1.9 to require a minimum OpenImageIO version of 1.7 (which is the current supported release, so seems safe).

In the process, a whole bunch of our Boost use disappears, in favor of C++11 std and modern OIIO wrappers:

* BOOST_FOREACH -> C++11 "range for"
* boost::unordered_map and unordered_set -> std
* boost string algorithms -> OIIO Strutil utilities
* boost::bind and ref -> std
* boost::filesystem -> OIIO Filesystem utilities
2017-02-08 16:34:36 -08:00
Larry Gritz 06e0b2695e boost::random -> std::random 2017-02-08 15:05:03 -08:00
Larry Gritz 59dce1bb9c Remove unneeded reference to boost/scoped_ptr.hpp 2017-02-08 15:05:03 -08:00
Larry Gritz 300e3d4a3d Get rid of boost filesystem in favor of OIIO::Filesystem 2017-02-08 15:05:03 -08:00
Larry Gritz d46bd9df18 Get rid of boost::bind and boost::ref in favor of std 2017-02-08 15:05:03 -08:00
Larry Gritz e37603383f Get rid of boost string algorithms 2017-02-08 15:05:02 -08:00
Larry Gritz 2ee362604c Change boost unordered_map and set to C++11 std versions 2017-02-08 15:05:02 -08:00
Larry Gritz e930845606 Banish BOOST_FOREACH in favor of C++11 "range for" 2017-02-08 15:05:02 -08:00
Larry Gritz 474fd0afc6 Raise boost requirement to 1.55 (per VFXPlatform) 2017-02-08 15:05:02 -08:00
Larry Gritz 77765fc07f Use std::shared_ptr
Now that we are C++11 minimum, we can use std::shared_ptr directly without
needing to "wrap" it. A previous commit removed the clause of an #if
that alternately defined it using boost::shared_ptr for C++03, so all
that was left was pointless use of the wrapper.
2017-02-08 15:03:22 -08:00
Larry Gritz 7899a5f218 C++11: switch to C++11 baseline, also require CMake >= 3.2.2 (#704) 2017-02-07 23:22:13 -08:00
Larry Gritz d0ea3579bd Fix recent breakage against LLVM 3.5 (#705)
The last couple checkins botched some stuff, was leading to crashes
on real frames even though testsuite had passed. For the LLVM 3.5
case, it wasn't right.

1. The call to materializeAll() in do_optimize seems suspicious
for LLVM 3.5, taking it away solves crashes, so at Chris Kulla's
suggestion we're changing from #if OSL_LLVM_VERSION >= 35 to
> 35, so it only does the materializeAll for MCJIT cases.

2. LLVM_Util::module_from_bitcode was a mess. Impossible to follow.
Instead of a line-by-line #ifdef madness, I refactored it into a
much simpler <= 3.5 section and a >= 3.6 section, even if there was
some code repetition between the two. Also, I hereby declare that
we will not support LLVM 3.6, which further simplifies the logic.

3. As a result of that refactor, it was more obvious that another change,
the call to buf.release() was never there before and probably represents
some kind of double free. The older (pre-Marsupial) code for 3.4 & 3.5
in fact had a comment stating "don't delete buf, the module has taken
ownership of it."
2017-02-07 17:50:49 -08:00
Larry Gritz bc3516b411 Post-branch of 1.8, new world 2017-02-06 16:17:28 -08:00
Larry Gritz 92d9eaefc6 Rebuild PDF docs 2017-02-06 15:53:40 -08:00
Larry Gritz 45a7e2ec02 Docs 2017-02-06 15:53:29 -08:00
Roman Zulak 91bbf453bc Add #ifdef for changes in c8e38df to allow building on LLVM > 3.5 again. (703)
Fix possible leak if getLazyBitcodeModule had an error on 3.5
2017-02-06 14:11:22 -08:00
Christopher Kulla 442312d4cd Upgrade SPI builds to use clang 4.0 2017-02-06 10:33:39 -08:00
Christopher Kulla c8e38dfd63 Fix build issues against LLVM 3.5 from recent refactors 2017-02-06 09:34:11 -08:00
Larry Gritz 7802882b36 Fix compiler warnings and C++03 build breaks from recent changes 2017-02-03 19:59:52 -08:00
Roman Zulak a7dcb41ddf Use llvm::getLazyBitcodeModule in newer LLVM.
Try to make LLVM_Util::module_from_bitcode a more legible nightmare!
2017-02-02 17:31:03 -08:00
Larry Gritz 213e500a54 SPI: support for building with clang 4.0 2017-02-02 17:30:45 -08:00
Larry Gritz a5968de0b0 Skip LLVM JIT for empty shaders.
A good optimization in any case, but some of the new code triggered
assertions in LLVM that only seemed to happen for empty shaders.
2017-02-02 16:56:38 -08:00
Roman Zulak c87da2afec Fixes to build with modern LLVM 3.9.
With this patch, OSL is known to build properly against LLVM 3.4 (with
C++03), 3.5 (with C++11), or 3.9 (with C++11).

It's possible that it also builds properly with some of the intermediate
releases, but we're not officially supporting them.

It is important to remember that if you're not ready to upgrade your
LLVM, this patch still works just fine with the LLVM you were previously
using (3.4 or 3.5), but the NEXT major release of OSL may upgrade the
minimum LLVM requirement substantially.

When using LLVM 3.9, it uses "MCJIT", since the "old JIT" is gone as of
LLVM >= 3.6. This has somewhat different performance characteristics.
MCJIT is slower, so the overhead to optimize and jit your shaders is
about 2x what it was before. This may be quite noticeable for short,
low-quality, or interactive renders that have lots of complex
shaders. (If this is a problem, just stay on 3.4/3.5 while we
investigate fixes and improvements.) But the code it generates seems to
run a bit faster, so for long-rendering, high-quality production frames,
we are seeing an overall speedup of around 2-3%.
2017-01-31 17:09:20 -08:00
Larry Gritz 0385494ddc Adjust Travis builds 2017-01-31 16:19:44 -08:00
Larry Gritz 93e1b32a5f More robust finding of LLVM by cmake.
Identify LLVM version at build time and in ShadingSystem statistics output.
2017-01-31 16:18:02 -08:00
Larry Gritz 1d07a270cc New OSL built-in: select(a,b,cond) (#696)
This is like `mix(a,b,x)`, except that cond is treated like a boolean,
so the components of `result` are always either exactly the
corresponding components of `a` or `b`, never anything in between.

select(a,b,cond) is equivalent to per-component `(cond?a:b)`
or equivalently `mix (a, b, step(0,abs(cond)))`
but the underlying implementation does not need conditionals or multiplies.
2017-01-31 15:27:41 -08:00
Larry Gritz ad3f10d6dc Make BackendLLVM::llvm_debug_printf/gen_warning/gen_error take string_view (#694) 2017-01-23 12:24:24 -08:00
Larry Gritz c7ad6768fd Less cluttered listing of tests when setting up cmake files verbosely 2017-01-19 15:28:14 -08:00
Larry Gritz cf1b11695b Debugging option 'llvm_debug_ops' adds a printf before running each op 2016-12-15 14:37:32 -08:00
Christopher Kulla 2cd3113bd9 Fix build breaking against OIIO trunk due to new debug symbol 2016-12-12 10:06:48 -08:00
Larry Gritz 081c489264 testsuite/gettextureinfo: update test to check return values when
querying "displaywindow" and "datawindow" -- regression check for
bug fix on the OIIO side.

See https://github.com/OpenImageIO/oiio/pull/1574
2016-11-29 21:58:07 -08:00
Larry Gritz a6a3b5c24a Change partio search (#689)
* Everybody: break partio finding into separate FindPartio.cmake
* SPI only: change Partio version/location
2016-11-23 15:19:14 -08:00
Larry Gritz f06bd83036 Minor fixes for C++11 and use of std::atomic 2016-11-08 10:08:41 -08:00
Larry Gritz 89702bdcf9 Travis: change to precise linux, we don't trust trusty 2016-11-08 00:18:13 -08:00
Larry Gritz 8e0fce5a92 Bump version 2016-11-07 21:54:06 -08:00
Larry Gritz 32bb890f53 CHANGES 2016-10-31 16:14:09 -07:00
Larry Gritz df00e527e8 Touch-up of SPI OSX case 2016-10-27 11:09:20 -07:00
Larry Gritz 6390c1d52a SPI - Options to run other compilers (#687)
* Change default to use llvm & clang 3.5 rather than 3.4.
* More flexibility for overriding which compiler version.
* Some refactoring to regularize the OIIO and OSL cmake files that overlap.

This doesn't affect non-SPI sites.
2016-10-27 10:08:30 -07:00
Larry Gritz 56a55fb02f UDIM test 2016-10-17 14:19:55 -07:00
Larry Gritz 9d90766cf3 Add optional "errormessage" parameter to texture lookup functions. (#686)
OSL's texture(), texture3d(), and environment() functions now take a new
optional argument, "errormessage", followed by string variable
reference. A successful texture lookup will result in storing the empty
string ("") in the variable.

When this option is employed, a failed lookup or other error, such as a
missing texture, will store a non-empty string in the errormessage
variable (usually a descriptive error message, but will be "unknown" if
no message is forthcoming from the TextureSystem, as may be the case if
it's suppressing duplicate error messages from the same file). If the
"errormessage" option is passed, this will be the ONLY way an error is
handled for this call; it will not also forward any errors to the
renderer, assuming that if the shader asks for the message, the shader
intends to fully handle the situation.

If no "errormessage" optional param is passed, behavior is as it always
was: a texture lookup error will be passed to the renderer through the
usual error reporting mechanisms.

The reason for this change is UDIM -- a UDIM set may be sparse, with
some sections of uv space not having concrete texture files that exist.
We don't want those to spew error messages, and our typical way of
checking by doing a query like gettextureinfo(texname,"channels",chans)
is not reliable because it will return the channels for ANY match, doesn't
help you for particular uv ranges.

With this, you can imagine a shader gracefully (and more or less
efficiently) handling a sparse UDIM set with logic that looks like:

    int channels;
    if (gettextureinfo (texturefile, "channels", channels)) {
        string err;
        C = texture (texturefile, u, v, "errormessage", err);
        if (err != "") {
            // texture set exists, but no file for this UDIM section!
            C = missing_udim_color;
        }
    } else {
        // truly nonexistant texture set
        C = error_color;
    }

Unfortunately, this breaks some compatibility with the RendererServices
API. (That's ok, this is for master only, and will not be backported
to release branches because I just can't figure out how to do it without
an API change.) Renderers integrating OSL will need to add new
RendererServices methods texture(), environment(), and texture3d(), which
have an additional ustring* parameter for the error message destination.
Eventually, we'll get rid of the old versions. Allowing both for now will
limit the number of immediate breakages until the renderer authors get
the new calls squared away.
2016-10-17 10:18:00 -07:00
Larry Gritz 4f857898d2 Opt: triple(space,const,const,const) can get fully folded to a constant (#685)
if the space name is known to be equivalent to "common".
2016-10-14 14:19:20 -07:00
Larry Gritz 7ce7beb8a0 oslc better err reporting for use of non-function symbol as function. (#684)
See the new testsuite example. This crashed oslc before!
Fix it up to not crash (by marking the unfound function's symbol as NULL),
and also improve the resulting error message.

Fixes #681
2016-10-13 09:41:40 -07:00
Larry Gritz fe6dcd0db4 Suppress clang 3.9 warnings (#683) 2016-10-13 09:32:59 -07:00
Larry Gritz 5caa937dc3 Constant folding of bitwise and, or, xor, compl 2016-10-11 15:23:09 -07:00
Larry Gritz 948de98802 Some utillties. Set up for code that was discarded, but I want them anyway. 2016-10-11 15:23:09 -07:00
Larry Gritz e3f49bbaae Improve aliasing of params with simple init ops. (#679)
Params that needed init ops, but the initialization was just a single
assignment, could be "aliased" to the thing they were assigned to (a
constant or a global or another param). It was identifying this by
basically asking "does this param's init ops consist of just one op,
and is it 'assign'?"

But... maybe the initialization started out as several ops, and runtime
optimization whittled it down to just one assignment -- it might look
like multiple ops, but all but one are 'nop'.

So now we "trim" the init ops of any leading or trailing nop
instructions, before doing this test. And it catches some more cases
that can be simplified!

As a real-world example, consider:

    param s = u * scale + offset

Where scale and offset are also parameters.  This initially compiled to:

    tmp1 = u * scale
    s = tmp1 + offset

If at runtime, parameter scale==1 and offset==0, this will get optimized
to

    nop
    s = u

which is really just saying s is an alias for u, but this is the case
that fails because the test on the untrimmed ops will say "it's 2 ops,
forget it".
2016-10-11 15:08:57 -07:00
Larry Gritz 5c8c97334e Better runtime optimization of some matrix constructors. (#676)
matrix(spaceA,spaceB) already optimized to a constant matrix if
spaceA and spaceB were both constant names and did not refer to
motion-blurred transformations.

New case: if spaceA and spaceB alias to the same symbol, then we know
this is the identiy matrix, even if they are not known constant values,
and even if they refer to a motion-blurred space.

matrix(float0, float1, ... float15) already turned into a constant
matrix if all the values were constant.

New case: matrix(float0) can be turned into a constant matrix if its
value is constant (it's usually 1, but it doesn't have to be).
2016-10-07 14:23:16 -07:00
Brecht Van Lommel 17f821a80c Fix oslnoise link errors when building static OSL libraries. (#678) 2016-10-07 09:40:13 -07:00
Larry Gritz fab9aa81f9 SPI: stop building for old OS (#677) 2016-10-06 17:06:44 -07:00
Larry Gritz 6cc91b7354 Travis bumped their default OSX image, but we aren't ready to upgrade 2016-10-05 17:23:56 -07:00
Larry Gritz 1f26b183ea Be sure to propagate C++ standard flags to the compilation of llvm_ops.cpp (#674)
We weren't properly transferring --std=c++11 from the directives to
compile OSL's implementation, to the command line that compiles
the llvm bitcode from llvm_ops.cpp. They should match.
2016-10-04 10:21:47 -07:00
Larry Gritz 67fad2b960 Fix warning from last checkin 2016-10-03 13:54:59 -07:00
Larry Gritz fd58c96dd6 Bug fix: matrix param initialized with matrix(space,1) left out init ops (#675)
When generating the static construction values, it needed to recognize
that case and set the "completed" flag to false, so that it would know
that it couldn't be constructed statically and needed init ops emitted
for that paramter.
2016-10-03 12:12:03 -07:00
Larry Gritz 42c3902892 Fix compiler warning 2016-09-29 14:46:09 -07:00
Larry Gritz 1b6b7f527a New getattribute queries for shader, layer, and group name. (#673)
getattribute ("shader:shadername", dst)
    getattribute ("shader:layername", dst)
    getattribute ("shader:groupname", dst)

And of course they constant fold, so there is no runtime cost.

Beware: the layer names could be screwy if you are using the duplicate
instance merging optimization. If you are depending on layer names for
debugging, you may want to turn off just that optimization (set
ShadingSystem attribute "opt_merge_instances" to 0) while debugging.
2016-09-29 12:28:44 -07:00
Larry Gritz 4540bf9a63 Bug fix: incorrect dropping of optional texture arguments.
There was a well-meaning optimization: dropping the setting of TextureOpt
fields when the value was known to overwrite the field with the default
value. But of course this should only happen when the value is CONSTANT,
it shouldn't happen just because the value passed is a param and the
parameter's default value is the option default value -- because the
param may be connected to an earlier layer that passes a different
value.

The test is fixed now, the optimization only kicks in when the value
passed is definitely a constant. (Unconnected params should have been
turned into consts before this code is encountered, so it should still
provide the optimization all the places where it was originally intended
to work.)

Fixes #670.
2016-09-27 15:38:00 -07:00
Larry Gritz 52e5f3f267 Fix build break for older OIIO 2016-09-21 09:20:06 -07:00
Christopher Kulla 1672ed597c Add missing libraries to oslnoise_test 2016-09-14 14:48:28 -07:00
Larry Gritz ee7af7d8ac liboslnoise -- C++ library with noises that match OSL (#669)
This patch makes a new library, liboslnoise (with corresponding
oslnoise.h), that just contains the various noise functions from OSL,
exposed in a way that can be easily called from other applications.

For our first stab at this, only the perlin noises (signed and unsigned)
and cellnoise are exposed. We have varieties that take 1-, 2-, 3-, and 4-D
domain coordinates, and return either float or vector (3D) noise values.

At this point, we DO NOT expose the varieties that take derivatives, nor
the periodic perlin noises, nor the gabor and simplex noise varieties,
or varieties that directly take or return our simd types.  We may add
some or all of these in the future, but I thought that we should gague
reaction to what we have so far and make sure we're on the right track.

Although we produce a liboslnoise.so, the fact is that it only contains
the implementations of the gabor and simplex noises, so for now at
least, for the sake of using just the perlin and cell varieties, you can
treat this as a header-only library, it's not necessary to link to
liboslnoise.

Added a unit test oslnoise_test, that verifies correct functionality,
that the liboslnoise works without the rest of oslexec, and does timing
benchmarks on the noise functions.
2016-09-12 15:16:33 -07:00
Larry Gritz 2b1ebba655 Allow optimization of shader groups with known raytype bits. (#668)
A new ShadingSystem::optimize_group() method takes bit fields describing
which ray types are known to be true and known to be false (not being
specified in either means it's indeterminite at optimize time, will only
be known at execution time).

When compiled in this manner, the runtime optimizer will constant-fold
calls to raytype(name) when the name matches those in the "in" and "out"
lists you have supplied.

This allows an app to specialize a shader for particular ray types (such
as a highly optimized version just for shadow rays).

There is also a new group attribute query "raytype_queries", which reveals
the bit pattern of any raytype() calls mde by any of the shaders within
the group.

As an example, the basic logic for specializing shadow shades and non-shadow
shades looks like this:

    // Make the shader group, however you want
    ShaderGroupRef group = shadingsys->ShaderGroupBegin ("groupname", ...);
    ...
    ShaderGroupEnd ();

    // A second reference-counted shader group starts just referring to the
    // same group.
    ShaderGroupRef group_shad = group;

    // Figure out if the shader group contains any raytype("shadow") queries.
    int rayqueries = 0;
    shadingsys->getattribute (group.get(), "raytype_queries", rayqueries);

    std::string serialized;
    int shadowbit = raytypebit(ustring("shadow"));
    if (rayqueries & shadowbit) {
        // The shader group asks (or might ask) for raytype("shadow"). Let's
        // assume it has different behavior for shadow rays and specialize.
        // First, make another group from the same serialized description.
        shadingsys->getattribute (group.get(), "pickle", serialized);
        group_shad = shadingsys->ShaderGroupBegin ("groupname", "surface", serialized);
        ShaderGroupEnd ();
        // Now specialize the shadow-specific group for shadow rays only:
        shadingsys->optimize_group (group_shad.get(),
                                    shadowbit,   /* ray types on: shadow */
                                    ~shadowbit); /* ray types off: everything else */
        // And specialize the original group for anything but shadow rays:
        shadingsys->optimize_group (group_shad.get(),
                                    0,           /* ray types on -- anything */
                                    shadowbit);  /* ray types off -- shadow */
    } else {
        // The shader group definitely does not check for raytype("shadow"), so
        // there's no point in specializing. Just stick to one version of the
        // shader. It will compile automatically in a generic way whenever we
        // first call shadingsys->execute () with that group. We don't need to
        // do anything special.
    }

    ... shading time: ...
    if (it's a shadow ray)
        shadingsys->execute (context, *group_shad, shaderglobals);
    else /* not a shadow ray */
        shadingsys->execute (context, *group, shaderglobals);

The bad news is that it takes a bit more memory (you're making extra
shader groups) and more time to compile (you're optimizing twice for
many shaders). Nonetheless, I'm finding that I come out ahead.

On my production tests, I'm seeing between 2% and 15% speedup -- very
dependent on the scene, as well as the structure of your shaders. YMMV.

The whole scheme assumes that your shaders take significant shortcuts for
shadow rays, based on explicitly using "if (raytype("shadow")) ...".
2016-09-06 16:07:52 -07:00
Larry Gritz 0ea950efb9 Fix variant of spline() that didn't compute derivatives properly. (#666)
Specifically, the case where the knots are colors (without derivs), the
abscissa float with derivs.
2016-08-23 09:39:33 -07:00
Larry Gritz 4203b539d6 Add ability to have derivs computed everywhere. (#667)
New SS attribute "force_derivs", when nonzero, will store and compute
derivatives for all float-based symbols, even if dependency analysis shows
they are not needed.

This is handy for quantifying how good we are at recognizing when we need
derivs (answer: very good, only a small percentage of post-optimized syms
end up with derivs) and also for debugging suspected derivative problems
(by essentially forcing derivs on almost everywhere).

Also amend stats report how many symbols carry derivatives.
2016-08-23 09:37:13 -07:00
Larry Gritz a03b2f8e25 Left a couple options out of the stats output. 2016-08-19 17:57:54 -07:00
Larry Gritz 172f4e6b6e Implement pow(triple,triple) (#665)
Previously we had pow(float,float) and pow(triple,float).

The docs certainly implied that the second argument could be a triple
if the first argument was a triple.
2016-08-16 15:58:13 -07:00
Larry Gritz f5f2c12e16 SS and group options "exec_repeat" can cause shader execution to repeat. (#659)
The default is 1, which is the old behavior: each call to
ShadingSystem::execute() will run the shader group once.

How is this useful? Suppose you have a very complicated app like a
renderer, and you're curious how much total time is attributable to the
actual execution of the shader. Each individual shader execution may be
so quick that putting timers around the calls may throw off the overall
time of the app (it takes time to retrieve the time, so by measuring
you are changing the timing characteristics; Heisenberg would
be proud).

So you set exec_repeat to 2, running each shader TWICE per call to
execute(). If you time this and compare it to shading the usual 1 time
per execution, the difference should be the total time spent shading for
an ordinary run. (But NOT including texture I/O time, since the "first
shade" will include any I/O that is triggered by needing non-resident
tiles, which will then already be resident for the "second shade." But
the OIIO TextureSystem stats should also tell you the amount of I/O
time).

Setting exec_repeat=0 will skip texture execution. I'm not sure how that's
helpful, since it changes appearance, duh.

You can set the exec_repeat for the whole ShadingSystem, and also override
it for individual groups.

Beware that a few things with side effects (printf, error calls, and
pointcloud_write) may change overall rendering behavior by doing them
multiple times. But everything else should be safe and yield the same
rendered results, if I've done this all correctly.
2016-08-05 10:23:19 -07:00
Larry Gritz 3ea8957809 Typo bug transpose() vs transposed(). (#662)
Imath::M44f.transpose() transposes in place and returns the ref,
whereas transposed() returns the transpose without altering the original.

Not a symptomatic bug because we only did this on the result of an
inverse(), which was a temporary, so didn't hurt to mess with it in place.
But better to correct this code to properly reflect our intent.
2016-08-04 16:32:56 -07:00
Brecht Van Lommel 4781aeb9e5 Fix OSL compiler assert when indexing into closure type. (#663) 2016-08-04 16:29:52 -07:00
Larry Gritz 4299503900 post-release version bump 2016-08-01 17:58:21 -07:00
1197 changed files with 71266 additions and 23148 deletions
+139
View File
@@ -0,0 +1,139 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
Language: Cpp
BasedOnStyle: WebKit
SpaceBeforeParens: ControlStatements
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: WebKit
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '<[[:alnum:].]+>'
Priority: 4
- Regex: '"[[:alnum:].]+"'
Priority: 5
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 3
NamespaceIndentation: None
#NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 40
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 75
PenaltyReturnTypeOnItsOwnLine: 50
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++14
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
#...
+8
View File
@@ -0,0 +1,8 @@
# Start using clang-format on OSL code base (#1215)
630b4c042d696c94ec9b2a1b6f5adc250bd61e05
# More clang-format (#1218)
bdb473cbdb119f3d9060d48f75f965cbd45f6d7a
# More clang-format: liboslquery, oslinfo, oslc, osl.imageio, osltoy (#1220)
bf366d7a90c46599b82071dac6dbef7c5e3ca157
+40
View File
@@ -0,0 +1,40 @@
<!--
Please ask questions ("how do I...?" "why doesn't this work?") on the [osl-dev mail list](https://lists.aswf.io/g/osl-dev), not by filing issues.
Make concrete suggestions for fixing the code ("here is a patch") by filing
a pull request, not an issue.
-->
### Problem
<!-- Describe the problem or suggestion here.] -->
**Expected behavior:** <!-- What you expected to happen -->
**Actual behavior:** <!-- What actually happened -->
<!-- If your problem is a broken build, please create a -->
<!-- [gist](https://gist.github.com) that contains the _full_ verbose -->
<!-- build log, which you can create like this: -->
<!-- ```make clean ; make VERBOSE=1 > build.log``` -->
<!-- If you are reporting a problem about a release branch, have you -->
<!-- already tried the current head of `master` to see if the problem -->
<!-- has been fixed? -->
### Steps to Reproduce
1. [First Step]
2. [Second Step]
3. [and so on...]
### Versions
* OSL branch/version:
* OS:
* C++ compiler:
* LLVM version:
* OIIO version:
+22
View File
@@ -0,0 +1,22 @@
## Description
<!-- Please provide a description of what this PR is meant to fix, and -->
<!-- how it works (if it's not going to be very clear from the code). -->
## Tests
<!-- Did you / should you add a testsuite case (new test, or add to an -->
<!-- existing test) to verify that this works? -->
## Checklist:
<!-- 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.
+708
View File
@@ -0,0 +1,708 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# GitHub Actions workflow file for CI
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: CI
on:
push:
# Skip jobs when only documentation files are changed
paths-ignore:
- '**.md'
- '**.rst'
- '**.tex'
pull_request:
paths-ignore:
- '**.md'
- '**.rst'
- '**.tex'
schedule:
# Full nightly build
- cron: "0 8 * * *"
jobs:
vfxplatform-2019:
name: "Linux VFXP-2019: gcc6 C++11 llvm7 py2.7 boost-1.66 exr-2.3 OIIO-2.0 sse2"
runs-on: ubuntu-latest
container:
image: aswf/ci-osl:2019-clang7
env:
CXX: g++
CC: gcc
CMAKE_CXX_STANDARD: 11
PYTHON_VERSION: 2.7
USE_PYTHON: 0
OPENIMAGEIO_VERSION: Release-2.0.14
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
# Remove pesky wrong installed OIIO version
rm -rf /usr/local/include/OpenImageIO
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
vfxplatform-2020:
name: "Linux VFXP-2020 gcc6/C++14 llvm7 py3.7 boost-1.70 exr-2.4 OIIO-2.1 sse4"
runs-on: ubuntu-latest
container:
image: aswf/ci-osl:2020
env:
CXX: g++
CC: gcc
CMAKE_CXX_STANDARD: 14
PYTHON_VERSION: 3.7
USE_SIMD: sse4.2
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
vfxplatform-2021:
name: "Linux VFXP-2021 gcc9/C++17 llvm10 py3.7 boost-1.73 exr-2.5 OIIO-2.2 avx2"
runs-on: ubuntu-latest
container:
image: aswf/ci-osl:2021
env:
CXX: g++
CC: gcc
CMAKE_CXX_STANDARD: 17
PYTHON_VERSION: 3.7
USE_SIMD: avx2,f16c
OPENEXR_VERSION: v2.5.5
OPENIMAGEIO_VERSION: RB-2.2
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
vfxplatform-2022:
name: "Linux VFXP-2022 gcc9/C++17 llvm11 py3.9 boost-1.75 exr-3.1 OIIO-2.3 avx2"
runs-on: ubuntu-latest
container:
image: aswf/ci-osl:2022-clang11
env:
CXX: g++
CC: gcc
CMAKE_CXX_STANDARD: 17
PYTHON_VERSION: 3.9
USE_SIMD: avx2,f16c
OPENCOLORIO_VERSION: v2.1.0
OPENEXR_VERSION: v3.1.1
OPENIMAGEIO_VERSION: release
PYBIND11_VERSION: v2.7.1
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
rm -rf /usr/local/include/OpenImageIO /usr/local/lib/cmake/OpenImageIO
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
# Build for OptiX, but don't run tests (will need a GPU instance for that)
gpu-optix7-2019:
name: "Linux GPU VFXP-2019 Cuda10 gcc6/C++14 llvm10 py2.7 boost-1.70 exr-2.4 OIIO-master avx2"
runs-on: ubuntu-latest
container:
image: aswftesting/ci-osl:2019-clang10
env:
CXX: g++
CC: gcc
CMAKE_CXX_STANDARD: 14
PYTHON_VERSION: 2.7
USE_SIMD: avx2,f16c
OPENIMAGEIO_VERSION: master
OSL_CMAKE_FLAGS: -DUSE_OPTIX=1
OPTIX_VERSION: "7.0"
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
rm -rf /usr/local/include/OpenImageIO
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
# Testsuite disabled until we have GPU hardware to run on
#- name: Testsuite
# run: |
# src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
optix.h
linux-debug-gcc7-llvm8:
name: "Linux Debug gcc7, C++14, llvm8, OIIO release, py2.7, boost1.65, sse4, exr2.4"
runs-on: ubuntu-18.04
env:
CXX: g++-7
CMAKE_BUILD_TYPE: Debug
USE_CPP: 14
CMAKE_CXX_STANDARD: 14
# Debug build makes some tests run very slowly, increase timeout
CTEST_TEST_TIMEOUT: 240
LLVM_VERSION: 8.0.0
OPENEXR_VERSION: v2.4.1
OPENIMAGEIO_VERSION: release
USE_SIMD: sse4.2
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
linux-clang9-llvm9:
name: "Linux clang9, C++14, llvm9, oiio release, boost1.66, avx2, exr2.3, py2.7"
runs-on: ubuntu-18.04
container:
image: aswf/ci-osl:2019-clang9
env:
CXX: clang++
CMAKE_CXX_STANDARD: 14
USE_SIMD: avx
OPENIMAGEIO_VERSION: release
PYTHON_VERSION: 2.7
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
# Remove pesky wrong installed OIIO version
rm -rf /usr/local/include/OpenImageIO
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
linux-clang11-llvm11:
name: "Linux clang11/C++17 llvm-11 oiio-master avx2 exr3.0 py3.7 boost1.73"
runs-on: ubuntu-latest
container:
image: aswf/ci-osl:2021-clang11
env:
CXX: clang++
CC: clang
CMAKE_CXX_STANDARD: 17
PYTHON_VERSION: 3.7
USE_SIMD: avx2,f16c
OPENEXR_VERSION: v3.0.4
OPENIMAGEIO_VERSION: master
PYBIND11_VERSION: v2.6.2
USE_OPENVDB: 0
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
sudo rm -rf /usr/local/include/OpenEXR
sudo rm -rf /usr/local/lib64/cmake/{IlmBase,OpenEXR}
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
linux-2021ish-gcc8-llvm10:
name: "Linux gcc8, C++17, llvm10, oiio master, avx2, exr2.5, boost1.65, avx2"
runs-on: ubuntu-18.04
env:
CXX: g++-8
CMAKE_CXX_STANDARD: 17
LLVM_VERSION: 10.0.0
USE_SIMD: avx2,f16c
OPENEXR_VERSION: v2.5.5
OPENIMAGEIO_VERSION: master
OPENIMAGEIO_CMAKE_FLAGS: -DBUILD_FMT_VERSION=7.0.1
PUGIXML_VERSION: v1.10
PYBIND11_VERSION: v2.5.0
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
linux-latest-release:
# Test against development master for relevant dependencies, latest
# supported releases of everything else.
name: "Linux latest releases: gcc10/C++17, llvm12, oiio-2.3, py3.8, boost1.71, exr3.1, ocio2.1, avx2"
runs-on: ubuntu-20.04
env:
CXX: g++-10
USE_CPP: 17
CMAKE_CXX_STANDARD: 17
LLVM_VERSION: 12.0.0
LLVM_DISTRO_NAME: ubuntu-20.04
USE_SIMD: avx2,f16c
OPENEXR_VERSION: v3.1.0
OPENIMAGEIO_VERSION: release
OPENIMAGEIO_CMAKE_FLAGS: -DBUILD_FMT_VERSION=8.0.0
OPENCOLORIO_VERSION: v2.1.0
PUGIXML_VERSION: v1.11.4
PYBIND11_VERSION: v2.7.1
PYTHON_VERSION: 3.8
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
linux-bleeding-edge:
# Test against development master for relevant dependencies, latest
# supported releases of everything else.
name: "Linux bleeding edge: gcc11, C++17, llvm12, oiio/ocio/exr/pybind-master, py3.8, avx2"
runs-on: ubuntu-20.04
env:
CXX: g++-11
USE_CPP: 17
CMAKE_CXX_STANDARD: 17
LLVM_VERSION: 12.0.0
LLVM_DISTRO_NAME: ubuntu-20.04
USE_SIMD: avx2,f16c
OPENEXR_VERSION: master
OPENIMAGEIO_VERSION: master
OPENIMAGEIO_CMAKE_FLAGS: -DBUILD_FMT_VERSION=master
OPENCOLORIO_VERSION: main
PUGIXML_VERSION: master
PYBIND11_VERSION: master
PYTHON_VERSION: 3.8
OSL_BUILD_MATERIALX: 1
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
linux-oldest:
# Oldest versions of the dependencies that we can muster, and various
# things disabled.
name: "Linux oldest everything: gcc6/C++11 llvm7 py-no boost-1.66 oiio-2.0 no-simd exr2.3"
runs-on: ubuntu-latest
container:
image: aswf/ci-osl:2019-clang7
env:
CXX: g++
CC: gcc
CMAKE_CXX_STANDARD: 11
PYTHON_VERSION: 2.7
USE_SIMD: 0
USE_PYTHON: 0
OPENIMAGEIO_VERSION: Release-2.0.14
PUGIXML_VERSION: v1.8
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /tmp/ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
rm -rf /usr/local/include/OpenImageIO
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
macos-py39:
name: "Mac py39"
runs-on: macOS-latest
env:
CXX: clang++
USE_CPP: 14
CMAKE_CXX_STANDARD: 14
PYTHON_VERSION: 3.9
steps:
- uses: actions/checkout@v2
- name: Prepare ccache timestamp
id: ccache_cache_keys
shell: bash
run: |
echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@v2
with:
path: /Users/runner/.ccache
key: ${{ github.job }}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: |
${{ github.job }}-
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
source src/build-scripts/install_homebrew_deps.bash
# OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0"
# source src/build-scripts/build_openimageio.bash
brew install --display-times -q openimageio
PYTHONPATH=$PYTHONPATH:/usr/local/python${PYTHON_VERSION}/site-packages
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: |
src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: |
build/*/testsuite/*/*.*
build/*/CMake*.{txt,log}
clang-format:
# Test formatting. This test entry doesn't do a full build, it just runs
# clang-format on everything, and passes if nothing is misformatted.
# Upon failure, the build artifact will be the full source code with the
# formatting fixed (diffs will also appear in the console output).
name: "clang-format verification"
runs-on: ubuntu-18.04
container:
image: aswf/ci-osl:2021-clang11
env:
BUILDTARGET: clang-format
CMAKE_CXX_STANDARD: 17
PYTHON_VERSION: 3.7
steps:
- uses: actions/checkout@v2
- name: Build setup
run: |
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ github.job }}
path: src/*/*.{cpp,h}
+4
View File
@@ -1,3 +1,7 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
dist
build
*~
-156
View File
@@ -1,156 +0,0 @@
# .travis.yml for OSL
language: cpp
sudo: false
compiler:
- clang
- gcc
os:
- linux
- osx
#osx_image: xcode7.3
dist: trusty
env:
matrix:
- USE_CPP11=1
- DEBUG=1
# Add-ons: specify apt packages for Linux
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- gcc-5
- g++-5
- gcc-6
- g++-6
- libboost1.55-all-dev
- libtiff4-dev
- llvm-3.4-dev
- clang-3.4
cache:
ccache: true
apt: true
directories:
- $HOME/.ccache
before_install:
- if [ "$WHICHGCC" == "" ]; then export WHICHGCC="4.8" ; fi
- if [ $TRAVIS_OS_NAME == osx ] ; then
export PLATFORM=macosx ;
sysctl machdep.cpu.features ;
elif [ $TRAVIS_OS_NAME == linux ] ; then
export PLATFORM=linux64 ;
cat /proc/cpuinfo ;
fi
- export OIIOPLATFORM=$PLATFORM
- if [ "$DEBUG" == 1 ] ; then export PLATFORM=${PLATFORM}.debug ; fi
- echo "Build platform name is $PLATFORM"
install:
- if [ "$CXX" == "g++" ]; then export CXX="g++-${WHICHGCC}" ; fi
- export USE_CCACHE=1
- export CCACHE_CPP2=1
- if [ $TRAVIS_OS_NAME == osx ] ; then
src/build-scripts/install_homebrew_deps.bash ;
export LLVM_DIRECTORY=/usr/local/Cellar/llvm34/3.4.2/lib/llvm-3.4 ;
elif [ $TRAVIS_OS_NAME == linux ] ; then
CXX="ccache $CXX" CCACHE_CPP2=1 src/build-scripts/build_openexr.bash ;
export ILMBASE_HOME=$PWD/openexr-install ;
export OPENEXR_HOME=$PWD/openexr-install ;
fi
- export OIIOMAKEFLAGS="$OIIOMAKEFLAGS -j2 DEBUG= "
- src/build-scripts/build_openimageio.bash
- export OPENIMAGEIOHOME=$PWD/OpenImageIO/dist/$OIIOPLATFORM
- export DYLD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$DYLD_LIBRARY_PATH
- export LD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$LD_LIBRARY_PATH
- export PATH=$OPENIMAGEIOHOME/bin:$PATH
- if [ $TRAVIS_OS_NAME == linux ] ; then
export BUILD_FLAGS="$BUILD_FLAGS LLVM_STATIC=1" ;
export TEST_FLAGS="-E broken\|render-cornell\|render-oren-nayar\|render-veachmis\|render-ward" ;
fi
# ^^^ Linux only, can't make these test work. Exclude for now and return later. ;
# before_script:
script:
- make VERBOSE=1 $BUILD_FLAGS cmakesetup
- make -j2 $BUILD_FLAGS
- export OSLHOME=$PWD/dist/$PLATFORM
- export DYLD_LIBRARY_PATH=$OSLHOME/lib:$DYLD_LIBRARY_PATH
- export LD_LIBRARY_PATH=$OSLHOME/lib:$LD_LIBRARY_PATH
- export PYTHONPATH=$OSLHOME/python:$OPENIMAGEIOHOME/python:$PYTHONPATH
- make $BUILD_FLAGS test
after_success:
- if [ "$CODECOV" == 1 ]; then bash <(curl -s https://codecov.io/bash) ; fi
after_failure:
# FIXME: find failed logs, stash them or send them to lg?
branches:
only:
- master
- /RB-/
- /lg-/
matrix:
fast_finish: true
exclude:
- os: osx
compiler: gcc
- os: linux
compiler: clang
include:
# Make sure we can still build C++03, both platforms
- os: linux
dist: trusty
compiler: gcc
env: USE_CPP11=0
- os: osx
compiler: clang
env: USE_CPP11=0
# Test against the older release branch of OIIO (all the other tests
# are against OIIO master)
- os: linux
dist: trusty
compiler: gcc
env: OIIOBRANCH=release USE_CPP11=1
- os: osx
compiler: clang
env: OIIOBRANCH=release USE_CPP11=1
# Linux only: test gcc 6 (catch new warnings hot off the presses) and
# also use a higher SIMD level, avx and f16c, to make sure all is well.
# TravisCI's OSX images don't yet support avx/f16c, so we only do this
# on Linux for now, but eventually we'll want to separate these concerns
# into separate tests.
- os: linux
dist: trusty
compiler: gcc
env: WHICHGCC=6 USE_SIMD=avx,f16c
# Linux only: test gcc 5
- os: linux
dist: trusty
compiler: gcc
env: WHICHGCC=5
# One more, just for the heck of it, turn all SIMD off. I guess this
# should/could be both platforms, but in the interest of making the
# tests go faster, don't bother doing it on OSX.
- os: linux
dist: trusty
compiler: gcc
env: USE_SIMD=0
notifications:
email:
# recipients:
# -
on_success: change
on_failure: always
+149
View File
@@ -0,0 +1,149 @@
Project Name: Open Shading Language
Project Entity: Open Shading Language Project a Series of LF Projects, LLC
If emailing signed PDF, send to: manager@lfprojects.org
**Software Grant and Corporate Contributor License Agreement ("Agreement") v2.1**
Thank you for your interest in the project specified above (the “Project”). In
order to clarify the intellectual property license granted with Contributions
from any person or entity, the Project must have a Contributor License Agreement
(CLA) on file that has been signed by each Contributor, indicating agreement to
the license terms below. This license is for your protection as a Contributor as
well as the protection of the Project and its users; it does not change your
rights to use your own Contributions for any other purpose.
This version of the Agreement allows an entity (the “Corporation”) to submit
Contributions to the Project, to authorize Contributions submitted by its
designated employees to the Project, and to grant copyright and patent licenses
thereto.
If you have not already done so, please complete and sign this Agreement using
the electronic signature portal made available to you by the Project or its
third-party service providers, or email a PDF of the signed agreement to the
email address specified above. Please read this document carefully before
signing and keep a copy for your records.
You accept and agree to the following terms and conditions for Your present and
future Contributions submitted to the Project. In return, the Project shall not
use Your Contributions in a way that is contrary to the public benefit or
inconsistent with its charter at the time of the Contribution. Except for the
license granted herein to the Project and recipients of software distributed by
the Project, You reserve all right, title, and interest in and to Your
Contributions.
1. Definitions.
“You” (or “Your”) shall mean the copyright owner or legal entity authorized by
the copyright owner that is making this Agreement with the Project. For legal
entities, the entity making a Contribution and all other entities that
control, are controlled by, or are under common control with that entity are
considered to be a single Contributor. For the purposes of this definition,
“control” means (i) the power, direct or indirect, to cause the direction or
management of such entity, whether by contract or otherwise, or (ii) ownership
of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
ownership of such entity.
“Contribution” shall mean the code, documentation or other original works of
authorship, including any modifications or additions to an existing work, that
is intentionally submitted by You to the Project for inclusion in, or
documentation of, any of the products owned or managed by the Project (the
“Work”). For the purposes of this definition, “submitted” means any form
of electronic, verbal, or written communication sent to the Project or its
representatives, including but not limited to communication on electronic
mailing lists, source code control systems, and issue tracking systems that
are managed by, or on behalf of, the Project for the purpose of discussing and
improving the Work, but excluding communication that is conspicuously marked
or otherwise designated in writing by You as “Not a Contribution.”
2. Grant of Copyright License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, publicly perform, sublicense,
and distribute Your Contributions and such derivative works.
3. Grant of Patent License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent
license to make, have made, use, offer to sell, sell, import, and
otherwise transfer the Work, where such license applies only to
those patent claims licensable by You that are necessarily infringed
by Your Contribution(s) alone or by combination of Your
Contribution(s) with the Work to which such Contribution(s) were
submitted. If any entity institutes patent litigation against You or
any other entity (including a cross-claim or counterclaim in a
lawsuit) alleging that your Contribution, or the Work to which
you have contributed, constitutes direct or contributory patent
infringement, then any patent licenses granted to that entity under
this Agreement for that Contribution or Work shall terminate as of
the date such litigation is filed.
4. You represent that You are legally entitled to grant the above license. You
represent further that the employee of the Corporation designated as the Initial
CLA Manager below (and each who is designated in a subsequent written
modification to the list of CLA Managers) (each, a “CLA Manager”) is
authorized to maintain with the Project (1) the list of employees of the
Corporation who are authorized to submit Contributions on behalf of the
Corporation, and (2) the list of CLA Managers.
5. You represent that each of Your Contributions is Your original creation (see
section 7 for submissions on behalf of others).
6. You are not expected to provide support for Your Contributions, except to the
extent You desire to provide support. You may provide support for free, for a
fee, or not at all. Unless required by applicable law or agreed to in writing,
You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied, including, without
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
7. Should You wish to submit work that is not Your original creation, You may
submit it to the Project separately from any Contribution, identifying the
complete details of its source and of any license or other restriction
(including, but not limited to, related patents, trademarks, and license
agreements) of which you are personally aware, and conspicuously marking the
work as “Submitted on behalf of a third-party: [named here]”.
8. It is your responsibility to notify the Project when any change is required
to the list of designated employees authorized to submit Contributions on behalf
of the Corporation, or to the list of the CLA Managers.
\[Please complete and sign on the next page.\]
::: {style="page-break-after: always; visibility: hidden"}
```{=tex}
\pagebreak
```
:::
Please sign:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Date:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Signatory Name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Signatory E-mail:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Signatory Title:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Corporation Name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Corporation Address:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Initial CLA Manager Name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Initial CLA Manager E-Mail:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
+137
View File
@@ -0,0 +1,137 @@
Project Name: Open Shading Language
Project Entity: Open Shading Language Project a Series of LF Projects, LLC
If emailing signed PDF, send to: manager@lfprojects.org
**Individual Contributor License Agreement ("Agreement") v2.1**
Thank you for your interest in the project specified above (the “Project”). In
order to clarify the intellectual property license granted with Contributions
from any person or entity, the Project must have a Contributor License Agreement
(CLA) on file that has been signed by each Contributor, indicating agreement to
the license terms below. This license is for your protection as a Contributor as
well as the protection of the Project and its users; it does not change your
rights to use your own Contributions for any other purpose.
If you have not already done so, please complete and sign this Agreement using
the electronic signature portal made available to you by the Project or its
third-party service providers, or email a PDF of the signed agreement to the
email address specified above. Please read this document carefully before
signing and keep a copy for your records.
You accept and agree to the following terms and conditions for Your present and
future Contributions submitted to the Project. In return, the Project shall not
use Your Contributions in a way that is contrary to the public benefit or
inconsistent with its charter at the time of the Contribution. Except for the
license granted herein to the Project and recipients of software distributed by
the Project, You reserve all right, title, and interest in and to Your
Contributions.
1. Definitions.
“You” (or “Your”) shall mean the copyright owner or legal entity authorized by
the copyright owner that is making this Agreement with the Project. For legal
entities, the entity making a Contribution and all other entities that control,
are controlled by, or are under common control with that entity are considered
to be a single Contributor. For the purposes of this definition, “control”
means (i) the power, direct or indirect, to cause the direction or management
of such entity, whether by contract or otherwise, or (ii) ownership of fifty
percent (50%) or more of the outstanding shares, or (iii) beneficial ownership
of such entity.
“Contribution” shall mean the code, documentation or other original works of
authorship, including any modifications or additions to an existing work, that
is intentionally submitted by You to the Project for inclusion in, or
documentation of, any of the products owned or managed by the Project (the
“Work”). For the purposes of this definition, “submitted” means any form of
electronic, verbal, or written communication sent to the Project or its
representatives, including but not limited to communication on electronic
mailing lists, source code control systems, and issue tracking systems that are
managed by, or on behalf of, the Project for the purpose of discussing and
improving the Work, but excluding communication that is conspicuously marked or
otherwise designated in writing by You as “Not a Contribution.”
2. Grant of Copyright License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, publicly perform, sublicense,
and distribute Your Contributions and such derivative works.
3. Grant of Patent License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent
license to make, have made, use, offer to sell, sell, import, and
otherwise transfer the Work, where such license applies only to
those patent claims licensable by You that are necessarily infringed
by Your Contribution(s) alone or by combination of Your
Contribution(s) with the Work to which such Contribution(s) were
submitted. If any entity institutes patent litigation against You or
any other entity (including a cross-claim or counterclaim in a
lawsuit) alleging that your Contribution, or the Work to which
you have contributed, constitutes direct or contributory patent
infringement, then any patent licenses granted to that entity under
this Agreement for that Contribution or Work shall terminate as of
the date such litigation is filed.
4. You represent that you are legally entitled to grant the above license. If
your employer(s) has rights to intellectual property that you create that
includes your Contributions, you represent that you have received permission to
make Contributions on behalf of that employer, that your employer has waived
such rights for your Contributions to the Project, or that your employer has
executed a separate Corporate CLA with the Project.
5. You represent that each of Your Contributions is Your original creation (see
section 7 for submissions on behalf of others). You represent that Your
Contribution submissions include complete details of any third-party license or
other restriction (including, but not limited to, related patents and
trademarks) of which you are personally aware and which are associated with
any part of Your Contributions.
6. You are not expected to provide support for Your Contributions, except to the
extent You desire to provide support. You may provide support for free, for a
fee, or not at all. Unless required by applicable law or agreed to in writing,
You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied, including, without
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
7. Should You wish to submit work that is not Your original creation, You may
submit it to the Project separately from any Contribution, identifying the
complete details of its source and of any license or other restriction
(including, but not limited to, related patents, trademarks, and license
agreements) of which you are personally aware, and conspicuously marking the
work as “Submitted on behalf of a third-party: [named here]”.
8. You agree to notify the Project of any facts or circumstances of which you
become aware that would make these representations inaccurate in any respect.
\[Please complete and sign on the next page.\]
::: {style="page-break-after: always; visibility: hidden"}
```{=tex}
\pagebreak
```
:::
Please sign:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Date: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Full name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Mailing Address:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
------------------------------------------------------------------------
------------------------------------------------------------------------
Country:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
E-Mail:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
+253
View File
@@ -0,0 +1,253 @@
# Technical Charter (the "Charter") for Open Shading Language a Series of LF Projects, LLC
This charter (the "Charter") sets forth the responsibilities and procedures
for technical contribution to, and oversight of, the Open Shading Language
project, which has been established as Open Shading Language a Series of LF
Projects, LLC (the "Project"). LF Projects, LLC ("LF Projects") is a
Delaware series limited liability company. All Contributors to the Project
must comply with the terms of this Charter.
### 1. Mission and Scope of the Project
* **a.** The mission of the Project is to develop an open source project
for programmable shading in advanced renderers and other applications,
ideal for describing materials, lights, displacement, and pattern
generation.
* **b.** The scope of the Project includes software development under an
OSI-approved open source license supporting the mission, including
documentation, testing, integration and the creation of other artifacts
that aid the development, deployment, operation or adoption of the open
source software project.
### 2. Technical Steering Committee
* **a.** The Technical Steering Committee (the "TSC") will be responsible
for all technical oversight of the open source Project.
* **b.** The TSC voting members are initially the Project's Committers. At
the inception of the project, the Committers of the Project will be as
set forth within the "GOVERNANCE" file within the Project's code
repository. The TSC may choose an alternative approach for determining
the voting members of the TSC, and any such alternative approach will be
documented in the GOVERNANCE file. Any meetings of the Technical
Steering Committee are intended to be open to the public, and can be
conducted electronically, via teleconference, or in person.
* **c.** TSC projects generally will involve Contributors and Committers.
The TSC may adopt or modify roles so long as the roles are documented in
the GOVERNANCE file. Unless otherwise documented:
- **i.** Contributors include anyone in the technical community that
contributes code, documentation, or other technical artifacts to the
Project;
- **ii.** Committers are Contributors who have earned the ability to
modify ("commit") source code, documentation or other technical
artifacts in a project's repository; and
- **iii.** A Contributor may become a Committer by a majority approval
of the existing Committers or at the discretion of the TSC. A
Committer may be removed by a majority approval of the other existing
Committers, or at the discretion of the TSC.
* **d.** Participation in the Project through becoming a Contributor and
Committer is open to anyone so long as they abide by the terms of this
Charter.
* **e.** The TSC may (1) establish workflow procedures for the submission,
approval, and closure/archiving of projects, (2) set requirements for
the promotion of Contributors to Committer status, as applicable, and
(3) amend, adjust, refine and/or eliminate the roles of Contributors,
and Committers, and create new roles, and publicly document any TSC
roles, as it sees fit.
* **f.** The TSC may elect a TSC Chair, who will preside over meetings of
the TSC and will serve until his or her resignation or replacement by
the TSC. The TSC Chair, or any other TSC member so designated by the
TSC, will serve as the primary communication contact between the Project
and the Academy Software Foundation Fund of The Linux Foundation.
* **g.** Responsibilities: The TSC will be responsible for all aspects of
oversight relating to the Project, which may include:
- **i.** coordinating the technical direction of the Project;
- **ii.** approving project or system proposals (including, but not
limited to, incubation, deprecation, and changes to a sub-project's
scope);
- **iii.** organizing sub-projects and removing projects;
- **iv.** creating sub-committees or working groups to focus on
cross-project technical issues and requirements;
- **v.** appointing representatives to work with other open source or
open standards communities;
- **vi.** establishing community norms, workflows, issuing releases, and
security issue reporting policies;
- **vii.** approving and implementing policies and processes for
contributing (to be published in the CONTRIBUTING file) and
coordinating with the Series Manager to resolve matters or concerns
that may arise as set forth in Section 7 of this Charter;
- **viii.** discussions, seeking consensus, and where necessary, voting
on technical matters relating to the code base that affect multiple
projects; and
- **ix.** coordinating any marketing, events, or communications
regarding the Project with the LF Projects Manager or their designee.
### 3. TSC Voting
* **a.** While the Project aims to operate as a consensus based community,
if any TSC decision requires a vote to move the Project forward, the
voting members of the TSC will vote on a one vote per voting member
basis.
* **b.** At least fifty percent of all voting members of the TSC must be
present at a TSC meeting in order to establish a quorum. The TSC may
continue to meet if a quorum is not met, but will be prevented from
making any decisions at such meeting.
* **c.** Except as provided in Section 7.c. and 8.a, decisions by vote at
a meeting require a majority vote of those in attendance, provided
quorum is met. Decisions made by electronic vote without a meeting
require a majority vote of all voting members of the TSC.
* **d.** In the event a vote cannot be resolved by the TSC, any voting
member of the TSC may refer the matter to the Series Manager or its
designee for assistance in reaching a resolution.
### 4. Compliance with Policies
* **a.** This Charter is subject to the Series Agreement for the Project
and the Operating Agreement of LF Projects. Contributors will comply
with the policies of LF Projects as may be adopted and amended by LF
Projects, including, without limitation the policies listed at
https://lfprojects.org/policies/.
* **b.** The TSC may adopt a code of conduct ("CoC") for the Project,
which is subject to approval by the Series Manager. Contributors to the
Project will comply with the CoC or, in the event that a
Project-specific CoC has not been approved, the LF Projects Code of
Conduct listed at https://lfprojects.org/policies/.
* **c.** When amending or adopting any policy applicable to the Project,
LF Projects will publish such policy, as to be amended or adopted, on
its web site at least 30 days prior to such policy taking effect;
provided, however, that in the case of any amendment of the Trademark
Policy or Terms of Use of LF Projects, any such amendment is effective
upon publication on LF Project's web site.
* **d.** All participants must allow open participation from any
individual or organization meeting the requirements for contributing
under this Charter and any policies adopted for all participants by the
TSC, regardless of competitive interests. Put another way, the Project
community must not seek to exclude any participant based on any
criteria, requirement, or reason other than those that are reasonable
and applied on a non-discriminatory basis to all participants in the
Project community.
* **e.** The Project will operate in a transparent, open, collaborative,
and ethical manner at all times. The output of all Project discussions,
proposals, timelines, decisions, and status should be made open and
easily visible to all. Any potential violations of this requirement
should be reported immediately to the LF Projects Manager.
### 5. Community Assets
* **a.** LF Projects will hold title to all trade or service marks used by
the Project ("Project Trademarks"), whether based on common law or
registered rights. Project Trademarks will be transferred and assigned
to LF Projects to hold on behalf of the Project. Any use of any Project
Trademarks by participants in the Project will be in accordance with the
license from LF Projects and inure to the benefit of LF Projects.
* **b.** The Project shall, as permitted and in accordance with such
license from LF Projects, develop and own all Project GitHub and social
media accounts, and domain name registrations created by the Project
community.
* **c.** Under no circumstances will LF Projects be expected or required
to undertake any action on behalf of the Project that is inconsistent
with the tax-exempt status or purpose, as applicable, of LFP, Inc. or LF
Projects, LLC.
### 6. General Rules and Operations.
* **a.** The Project will:
- **i.** engage in the work of the project in a professional manner
consistent with maintaining a cohesive community, while also
maintaining the goodwill and esteem of LF Projects, LFP, Inc. and
other partner organizations in the open source software community; and
- **ii.** respect the rights of all trademark owners, including any
branding and trademark usage guidelines.
### 7. Intellectual Property Policy
* **a.** Participants acknowledge that the copyright in all new
contributions shall be retained by the copyright holder as independent
works of authorship and that no contributor or copyright holder will be
required to assign copyrights to the Project.
* **b.** Except as described in Section 7.c., all code contributions to
the Project are subject to the following:
- **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/main/LICENSE.md)
(the "Project License").
- **ii.** All new inbound code contributions must:
o **a.** be made pursuant to a binding Project Contribution License
Agreement (the "CLA") available on the Project's web site; and
o **b.** be accompanied by a Developer Certificate of Origin
(http://developercertificate.org) sign-off in the source code system
that is submitted through a TSC-approved contribution process which
will bind the authorized contributor and, if not self-employed,
their employer to the applicable license;
- **iii.** All outbound code will be made available under the Project
License.
- **iv.** Documentation will be received and made available by the
Project under the Creative Commons Attribution 4.0 International
License (available at http://creativecommons.org/licenses/by/4.0/).
- **v.** The Project may seek to integrate and contribute back to other
open source projects ("Upstream Projects"). In such cases, the Project
will conform to all license requirements of the Upstream Projects,
including dependencies, leveraged by the Project. Upstream Project
code contributions not stored within the Project's main code
repository shall comply with the contribution process and license
terms for the applicable Upstream Project.
* **c.** If an alternative inbound or outbound license is required for
compliance with the license for a leveraged open source project or is
otherwise required to achieve the Project's mission, the Governing Board
of the Academy Software Foundation Fund of the Linux Foundation
("Governing Board"), or the Governing Board's representatives designated
for such purpose, may approve the use of an alternative license for
specific inbound or outbound contributions on an exception basis. Any
exceptions must be approved by a vote of the Governing Board and must be
limited in scope to what is required for such a purpose. To request an
exception, please describe the contribution, the alternative open source
license(s), and the justification for using an alternative open source
license for the Project.
* **d.** Contributed files should contain license information, such as
SPDX short form identifiers, indicating the open source license or
licenses pertaining to the file.
### 8. Amendments
* **a.** This charter may be amended by a two-thirds vote of the entire
TSC, subject to reasonable approval by LF Projects.
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

+105
View File
@@ -0,0 +1,105 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
# TSC meeting 2020-04-02 (first TSC meeting!)
Host: John Mertic
### Attendees:
Meeting chair pro tem: John Mertic, Linux Foundation
TSC members:
* [x] Luke Emrose, Animal Logic
* [x] Eric Enderton, NVIDIA
* [x] Stephen Friedman, Pixar
* [x] Larry Gritz, Sony Pictures Imageworks
* [x] Derek Haase, DNEG
* [x] Adrien Herubel, Autodesk
* [x] Lee Kerley, Sony Pictures Imageworks
* [x] Chris Kulla, Sony Pictures Imageworks
* [x] Mitch Prater, Laika
* [x] Brecht Van Lommel, Blender
Additional attendees:
* [x] Max Liani, Pixar
* [x] Zap Anderson, Autodesk
* [x] Pete Segal, Foundry
* [x] JT Nelson, Pasadena Open Source
* [x] Amir Shachar, DNEG
* [x] Alex Wells, Intel
### Agenda / Meeting notes
* Charter / legalities
- All the proposed documents are in this PR:
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1137
- **Action**: Everybody please look over the charter, etc., give a +1,
raise any objections or ask questions.
- **Action**: Look at the CLA, show to your legal depts if they care. It's
identical to the other ASWF projects, so the bar to alter it will be
extremely high, please resist the temptation.
- Aim to vote on approval by the next TSC meeting
* TSC membership
- As above, per pre-meeting correspondence and opportunities to
volunteer.
- **Action**: suggest any edits to TSC voting members
- People or orgs not on the list who want to be members and can commit
a high level of involvement.
- Swapping, adding, or subtracting people in the future is easy as
circumstances changes, so don't overthink it.
* Office elections
- LG nominated himself as chief architect, Chris Kulla for chair.
- Both passed by voice vote without objections.
- Welcome to the ASWF TAC, Chris!
- Elections (and/or ratification of people staying in their current roles)
will be annual.
* John went over the infrastructure checklist as we transition the project:
- Where does the code live, issues, etc: we're already on GitHub, nothing
to do there
- CI: we are already using GitHub Actions CI
- short term, nothing to do
- long term, we will want to enhance our lack of good Windows CI and
ability to CI test both the GPU path and the CPU "wide SIMD" batch
shading mode.
- **Action**: look at the CLA, +1 it
- When we set up the new EasyCLA system, even orgs who previously signed
the old Sony CLA will need to sign the new LF one. We will want to have
everybody do this before we move the repository.
- **Action**: LG to turn over the openshadinglanguage.org domain to LF
(right now it's just a redirect to our GitHub repo)
- **Action**: LF/Steve Winslow will do the code scan, make sure licenses
are in order, etc., as another prerequisite to moving the repo from
imageworks GH account to ASWF GH account.
- Mail list:
- **Action**: John Mertic will set up osl-dev@lists.aswf.io (and a
second osl-tsc-private for the occasional topics among TSC members
that can't be public, like security or code of conduct issues)
- **Action**: LG will let people know about the new list. You will need
to sign up even if you were signed up to the old list.
- **Action**: John will figure out how to transfer the archives of the
old osl-dev so they are not lost.
- Future action: in a few weeks, after everybody is signed up for the
new list, we will throw the switch and stop using the old one.
- Social media: there are no other accounts to transfer.
- Trademarks: SPI never registered any.
- Slack channel: John already set up on ASWF slack.
* Meeting cadence
- Let's keep the Thursday 2pm PT time for now. (No objections.)
- LG suggests that we meet every 2nd week -- because this project is
starting with so much more already completed compared to the other
projects when they joined (already have CI, documents are same as were
approved by the orgs before, etc.), we probably don't need every week.
Can adjust later.
- Hopefully will get this administrivia done soon and can spend all our
time on tech stuff.
* Items for next TSC meeting agenda:
- Ratify charter, governance, CLAs
+51
View File
@@ -0,0 +1,51 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
# OSL TSC meeting DATE
[Video link](https://zoom.us/j/100511909)
[Agenda link](https://docs.google.com/document/d/1yf0bG6eoE2EvKZBNZX3nskdTvu99ADTDTNOknCDJd1I/)
### Attendees:
TSC voting members:
* [ ] Luke Emrose, Animal Logic
* [ ] Eric Enderton, NVIDIA
* [ ] Stephen Friedman, Pixar
* [ ] Larry Gritz (_Chief Architect_), Sony Pictures Imageworks
* [ ] Derek Haase, DNEG
* [ ] Adrien Herubel, Autodesk
* [ ] Lee Kerley, Sony Pictures Imageworks
* [ ] Chris Kulla (_TSC Chair_), Sony Pictures Imageworks
* [ ] Mitch Prater, Laika
* [ ] Brecht Van Lommel, Blender
Additional attendees:
* [ ] Name - Org
* ...others...
### Agenda / Meeting notes
* Status on last meeting's action items:
- info
- info
* Topic 1
- info
- info
* Topic 2
- info
- info
### Next steps
* New action items:
-
-
* Items for next TSC meeting agenda:
- xxx
+53
View File
@@ -0,0 +1,53 @@
# Project Intake checklist
This is a checklist for TSC's to review as part of the intake process. The TSC should review this entire list during the kickoff meeting. For anything outstanding, create an [issue](../issues) to track and link to it in the list
- 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] )
- 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) )
- New Project Governance
- [X] TSC members identified
- [X] First TSC meeting held
- [X] TSC meeting cadence set and added to project calendar
- [X] CLA Approved ( if used ) ( [CCLA](CLA-corporate.md) and [ICLA](CLA-individual.md) )
- Project charter ( [charter.md](charter.md) )
- [X] Approved by TSC
- Closed by https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1137
- [X] Filed ( create pull request against [foundation repo](https://github.com/AcademySoftwareFoundation/foundation) )
- Current tools
- [X] Source Control ( https://github.com/AcademySoftwareFoundation/OpenShadingLanguage )
- [X] Issue/feature tracker ( https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues )
- Collaboration tools
- [X] Mailing lists (old: http://groups.google.com/group/osl-dev )
- [X] Move to groups.io ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new ) to setup/transfer
- [X] Slack or IRC ( #openshadinglanguage )
- [ ] CI/build environment
- Already using GitHub Actions CI
- [ ] Needs work on Windows
- [X] Needs to use ASWF docker images for more complete VFXPlatform coverage
- [ ] Longer term: needs GPU tests
- Project assets
- [X] Domain name
- [X] Logo(s) ( https://github.com/AcademySoftwareFoundation/artwork/blob/master/examples/incubating.md#open-shading-language-logos )
- [X] Trademarks/mark ownership rights
- Outreach
- [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
- [ ] Committer Diversity established
- [ ] Commit/Contribution growth during incubation
- [ ] Committers defined in the project ( [COMMITTERS.csv](COMMITTERS.csv) or [COMMITTERS.yml](COMMITTERS.yml) )
- [X] TAC representative appointed
- Chris Kulla, TSC chair, is our TAC rep for the project
- [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.
+1399 -27
View File
File diff suppressed because it is too large Load Diff
+205 -561
View File
@@ -1,634 +1,278 @@
project (OSL)
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Release version of the library
set (OSL_LIBRARY_VERSION_MAJOR 1)
set (OSL_LIBRARY_VERSION_MINOR 8)
set (OSL_LIBRARY_VERSION_PATCH 1)
set (OSL_LIBRARY_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
# Version of the OSO file format and instruction set
set (OSO_FILE_VERSION_MAJOR 1)
set (OSO_FILE_VERSION_MINOR 0)
cmake_minimum_required (VERSION 2.6)
if (NOT CMAKE_VERSION VERSION_LESS 2.8.4)
cmake_policy (SET CMP0017 NEW)
cmake_minimum_required (VERSION 3.12)
project (OSL VERSION 1.11.17.0
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 "" 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_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 ()
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy (SET CMP0025 NEW) # Detect AppleClang for new CMake
endif ()
if (NOT CMAKE_VERSION VERSION_LESS 3.2.2)
cmake_policy (SET CMP0042 OLD)
cmake_policy (SET CMP0046 OLD)
endif ()
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
if (VERBOSE)
message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
endif ()
message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message (FATAL_ERROR "Not allowed to run in-source build!")
# 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 (CMAKE_BUILD_TYPE STREQUAL "Debug")
set (DEBUGMODE ON)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# cmake bug workaround -- on some platforms, cmake doesn't set
# NDEBUG for RelWithDebInfo mode
add_definitions ("-DNDEBUG")
# 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}")
message (STATUS "CMake system name = ${CMAKE_SYSTEM_NAME}")
message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
message (STATUS "Project install prefix = ${CMAKE_INSTALL_PREFIX}")
message (STATUS "Configuration types = ${CMAKE_CONFIGURATION_TYPES}")
message (STATUS "Build type = ${CMAKE_BUILD_TYPE}")
# Make the build area layout look a bit more like the final dist layout
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message (FATAL_ERROR "Not allowed to run in-source build!")
endif ()
option (CMAKE_USE_FOLDERS "Use the FOLDER target property to organize targets into folders." ON)
mark_as_advanced (CMAKE_USE_FOLDERS)
if (CMAKE_USE_FOLDERS)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
endif ()
## turn on more detailed warnings and consider warnings as errors
set (STOP_ON_WARNING ON CACHE BOOL "Stop building if there are any compiler warnings")
if (NOT MSVC)
add_definitions ("-Wall")
if (STOP_ON_WARNING)
add_definitions ("-Werror")
endif ()
endif ()
message (STATUS "CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_COMPILER_ID is ${CMAKE_CXX_COMPILER_ID}")
# Figure out which compiler we're using
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 ()
endif ()
# Figure out which compiler we're using, for tricky cases
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang")
# 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
# CLANG_VERSION_STRING.
set (CMAKE_COMPILER_IS_CLANG 1)
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
if (clang_full_version_string MATCHES "Apple")
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 ()
else ()
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 ()
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set (CMAKE_COMPILER_IS_INTEL 1)
if (VERBOSE)
message (STATUS "Using Intel as the compiler")
endif ()
endif ()
# Options common to gcc and clang
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
# CMake doesn't automatically know what do do with
# include_directories(SYSTEM...) when using clang or gcc.
set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
# Ensure this macro is set for stdint.h
add_definitions ("-D__STDC_LIMIT_MACROS")
# this allows native instructions to be used for sqrtf instead of a function call
add_definitions ("-fno-math-errno")
if (HIDE_SYMBOLS AND NOT DEBUGMODE)
# Turn default symbol visibility to hidden
set (VISIBILITY_COMMAND "-fvisibility=hidden -fvisibility-inlines-hidden")
add_definitions (${VISIBILITY_COMMAND})
if (CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU")
# Linux/FreeBSD/Hurd: also hide all the symbols of dependent
# libraries to prevent clashes if an app using this library is
# linked against other verions of our dependencies.
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/libOpenImageIO/libOpenImageIO.map")
endif ()
endif ()
if (LLVM_STATIC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT DEBUGMODE)
# Linux: When linking against LLVM statically, we can also hide
# all its symbols to prevent clashes if OSL is linked against an
# app that also embeds LLVM.
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/liboslexec/liboslexec.map")
endif ()
endif ()
# Clang-specific options
if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
# Disable some warnings for Clang, for some things that are too awkward
# to change just for the sake of having no warnings.
add_definitions ("-Wno-unused-function")
add_definitions ("-Wno-overloaded-virtual")
add_definitions ("-Wno-unneeded-internal-declaration")
add_definitions ("-Wno-unused-private-field")
add_definitions ("-Wno-tautological-compare")
# disable warning about unused command line arguments
add_definitions ("-Qunused-arguments")
# Don't warn if we ask it not to warn about warnings it doesn't know
add_definitions ("-Wunknown-warning-option")
add_definitions ("-Wno-unknown-pragmas")
# disable warning in flex-generated code
add_definitions ("-Wno-null-conversion")
add_definitions ("-Wno-error=strict-overflow")
if (DEBUGMODE)
add_definitions ("-Wno-unused-function -Wno-unused-variable")
endif ()
if (CLANG_VERSION_STRING VERSION_GREATER 3.5 OR
APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
add_definitions ("-Wno-unused-local-typedefs")
endif ()
endif ()
# gcc specific options
if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG))
if (NOT ${GCC_VERSION} VERSION_LESS 4.8)
add_definitions ("-Wno-error=strict-overflow")
# suppress a warning that Boost::Python hits in g++ 4.8
add_definitions ("-Wno-error=unused-local-typedefs")
add_definitions ("-Wno-unused-local-typedefs")
endif ()
if (NOT ${GCC_VERSION} VERSION_LESS 4.5)
add_definitions ("-Wno-unused-result")
endif ()
endif ()
# Version of the OSO file format and instruction set
set (OSO_FILE_VERSION_MAJOR 1)
set (OSO_FILE_VERSION_MINOR 0)
## enable RTTI
## NOTE: LLVM builds without RTTI by default so beware
## if you find the need to turn this on, to use OSL in a
## project that requires RTTI for example, you need to build
## LLVM with RRTI, otherwise OSL classes extending LLVM ones
## will cause linker errors.
set (ENABLERTTI OFF CACHE BOOL "Build with RTTI. Requires a LLVM build with RTTI enabled.")
if (NOT ENABLERTTI)
if (MSVC)
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-" )
else ()
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
endif()
# For gcc < 4.3, Boost needs some extra help detecting that we've
# disabled RTTI.
if ((CMAKE_COMPILER_IS_GNUCC AND GCC_VERSION VERSION_LESS 4.3)
OR CMAKE_COMPILER_IS_CLANG)
add_definitions ("-DBOOST_NO_RTTI")
add_definitions ("-DBOOST_NO_TYPEID")
endif ()
endif()
# Needed for static boost libraries on Windows
if (WIN32 AND Boost_USE_STATIC_LIBS)
add_definitions ("-DBOOST_ALL_NO_LIB")
add_definitions ("-DBOOST_THREAD_USE_LIB")
endif ()
# Needed to disable dllimport/dllexport for static library
if (BUILDSTATIC)
add_definitions ("-DOSL_STATIC_LIBRARY")
endif()
set (USE_fPIC OFF CACHE BOOL "Build with -fPIC")
if (USE_fPIC)
add_definitions ("-fPIC")
endif ()
# Try to detect if this is an OSX distro new enough that the system library
# is libc++.
if (EXISTS "/usr/lib/libc++.dylib")
set (OSL_SYSTEM_HAS_LIBCPP ON)
endif ()
# This needs to be early, for CMAKE_INSTALL_FULL_DATADIR
include (GNUInstallDirs)
set (VERBOSE OFF CACHE BOOL "Print lots of messages while compiling")
set (OSL_BUILD_TESTS ON CACHE BOOL "Build the unit tests, testshade, testrender")
set (BUILDSTATIC OFF CACHE BOOL "Build static library instead of shared")
set (HIDE_SYMBOLS OFF CACHE BOOL "Hide symbols not in the public API")
set (USE_EXTERNAL_PUGIXML OFF CACHE BOOL
"Use an externally built shared library version of the pugixml library")
set (PUGIXML_HOME "" CACHE STRING "Hint about where to find external PugiXML library")
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")
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)
if (WIN32)
set (USE_LLVM_BITCODE OFF CACHE BOOL "Generate embedded LLVM bitcode")
option (USE_LLVM_BITCODE "Generate embedded LLVM bitcode" OFF)
else ()
set (USE_LLVM_BITCODE ON CACHE BOOL "Generated embedded LLVM bitcode")
option (USE_LLVM_BITCODE "Generate embedded LLVM bitcode" ON)
endif ()
set (USE_PARTIO ON CACHE BOOL "Use Partio if found")
set (USE_FAST_MATH ON CACHE BOOL "Use fast math approximations (if no, then use system math library)")
set (USE_CPP11 ON CACHE BOOL "Compile in C++11 mode")
set (USE_CPP14 OFF CACHE BOOL "Compile in C++14 mode")
set (USE_LIBCPLUSPLUS OFF CACHE BOOL "Compile with clang libc++")
set (EXTRA_CPP_ARGS "" CACHE STRING "Extra C++ command line definitions")
set (USE_SIMD "" CACHE STRING "Use SIMD directives (0, sse2, sse3, sse4.1, sse4.2)")
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)
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_35" CACHE STRING "CUDA GPU architecture (e.g. sm_35)")
set (OSL_SHADER_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/shaders"
CACHE STRING "Directory where shaders will be installed")
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')")
set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::TextureSystem")
set (OSL_BUILD_PLUGINS ON CACHE BOOL "Bool OSL plugins, for example OIIO plugin")
set (USE_CCACHE ON CACHE BOOL "Use ccache if found")
set (CODECOV OFF CACHE BOOL "Build code coverage tests")
# Use ccache if found
find_program (CCACHE_FOUND ccache)
if (CCACHE_FOUND AND USE_CCACHE)
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif ()
if (LLVM_NAMESPACE)
add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}")
endif ()
if (USE_EXTERNAL_PUGIXML)
add_definitions ("-DUSE_EXTERNAL_PUGIXML")
endif ()
if (USE_FAST_MATH)
add_definitions ("-DOSL_FAST_MATH=1")
else ()
add_definitions ("-DOSL_FAST_MATH=0")
endif ()
set (USE_OIIO_STATIC ON CACHE BOOL "If OIIO is built static")
if (USE_OIIO_STATIC)
add_definitions ("-DOIIO_STATIC_BUILD=1")
endif ()
if (OSL_NO_DEFAULT_TEXTURESYSTEM)
add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1")
endif ()
if (EXTRA_CPP_ARGS)
message (STATUS "Extra C++ args: ${EXTRA_CPP_ARGS}")
add_definitions ("${EXTRA_CPP_ARGS}")
endif()
if (USE_CPP11 OR USE_CPP14)
if (USE_CPP14)
message (STATUS "Building for C++14")
add_definitions ("-std=c++14")
elseif (USE_CPP11)
message (STATUS "Building for C++11")
add_definitions ("-std=c++11")
endif ()
if (CMAKE_COMPILER_IS_CLANG)
# C++ >= 11 doesn't like 'register' keyword, which is in Qt headers
add_definitions ("-Wno-deprecated-register")
endif ()
option (USE_FAST_MATH "Use fast math approximations (if no, then use system math library)" ON)
if (USE_FAST_MATH)
add_definitions ("-DOSL_FAST_MATH=1")
else ()
message (STATUS "Building for C++98!")
add_definitions ("-DOSL_FAST_MATH=0")
endif ()
if (USE_LIBCPLUSPLUS AND CMAKE_COMPILER_IS_CLANG)
message (STATUS "Using libc++")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
option (OIIO_FMATH_SIMD_FRIENDLY "Make sure OIIO fmath functions are SIMD-friendly" OFF)
if (OIIO_FMATH_SIMD_FRIENDLY)
add_definitions (-DOIIO_FMATH_SIMD_FRIENDLY=1)
endif ()
# Options common to gcc and clang
if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
message (STATUS "Compiling for code coverage analysis")
add_definitions ("-ftest-coverage -fprofile-arcs -O0 -DOSL_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")
if (USE_OPTIX)
add_definitions ("-DOSL_USE_OPTIX=1")
endif ()
if (DEFINED ENV{TRAVIS})
add_definitions ("-DOSL_TRAVIS=1")
# Set the default namespace. For symbol hiding reasons, it's important that
# the project name is a subset of the namespace name.
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 (OSL_SIMD_FLAGS "")
if (NOT USE_SIMD STREQUAL "")
message (STATUS "Compiling with SIMD level ${USE_SIMD}")
if (USE_SIMD STREQUAL "0")
add_definitions ("-DOIIO_NO_SSE=1")
else ()
string (REPLACE "," ";" SIMD_FEATURE_LIST ${USE_SIMD})
foreach (feature ${SIMD_FEATURE_LIST})
if (VERBOSE)
message (STATUS "SIMD feature: ${feature}")
endif ()
if (MSVC OR CMAKE_COMPILER_IS_INTEL)
add_definitions ("/arch:${feature}")
set (OSL_SIMD_FLAGS ${OSL_SIMD_FLAGS} "/arch:${feature}")
else ()
add_definitions ("-m${feature}")
set (OSL_SIMD_FLAGS ${OSL_SIMD_FLAGS} "-m${feature}")
endif ()
endforeach()
endif ()
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE}_v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}")
if (OIIO_NAMESPACE_INCLUDE_PATCH)
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE_V}_${PROJECT_VERSION_PATCH}")
endif ()
message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
# Set the default namespace
if (OSL_NAMESPACE)
add_definitions ("-DOSL_NAMESPACE=${OSL_NAMESPACE}")
endif ()
message(STATUS "Setting Namespace to: ${OSL_NAMESPACE}")
set (CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")
list (APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")
# Helpful functions and macros for our project
include (colors)
include (check_is_enabled)
include (checked_find_package)
# All the C++ and compiler related options and adjustments
include (compiler)
# Utilities and options related to finding python and making python bindings
include (pythonutils)
include (util_macros)
include (platform)
include (externalpackages)
include (oiio)
include (flexbison)
include (cuda_macros)
# Include all our testing apparatus and utils, but not if it's a subproject
if (${PROJECT_NAME}_BUILD_TESTS AND PROJECT_IS_TOP_LEVEL)
include (testing)
endif ()
include_directories (
BEFORE
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_BINARY_DIR}/include/OSL"
"${OPENIMAGEIO_INCLUDES}"
"${CMAKE_BINARY_DIR}/src/include"
"${CMAKE_BINARY_DIR}/include"
)
###########################################################################
# Paths for install tree customization. Note that relative paths are relative
# to CMAKE_INSTALL_PREFIX.
set (DEFAULT_BIN_INSTALL_DIR "bin")
set (DEFAULT_LIB_INSTALL_DIR "lib")
set (DEFAULT_INCLUDE_INSTALL_DIR "include/OSL")
if (UNIX AND NOT SELF_CONTAINED_INSTALL_TREE)
# Try to be well-behaved and install into reasonable places according to
# the "standard" unix directory heirarchy
# TODO: Figure out how to get the correct python directory
set (DEFAULT_PYLIB_INSTALL_DIR "lib/python/site-packages")
set (DEFAULT_PYLIB3_INSTALL_DIR "lib/python3/site-packages")
set (DEFAULT_DOC_INSTALL_DIR "share/doc/OSL")
set (DEFAULT_MAN_INSTALL_DIR "share/man/man1")
else ()
# Here is the "self-contained install tree" case: the expectation here is
# that everything OSL related will go into its own directory, not into
# some standard system heirarchy.
set (DEFAULT_PYLIB_INSTALL_DIR "python")
set (DEFAULT_PYLIB3_INSTALL_DIR "python3")
set (DEFAULT_DOC_INSTALL_DIR "doc")
set (DEFAULT_MAN_INSTALL_DIR "doc/man")
endif ()
if (EXEC_INSTALL_PREFIX)
# Tack on an extra prefix to support multi-arch builds.
set (DEFAULT_BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_BIN_INSTALL_DIR}")
set (DEFAULT_LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_LIB_INSTALL_DIR}")
set (DEFAULT_PYLIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_PYLIB_INSTALL_DIR}")
set (DEFAULT_PYLIB3_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_PYLIB3_INSTALL_DIR}")
endif ()
# Set up cmake cache variables corresponding to the defaults deduced above, so
# that the user can override them as desired:
set (BIN_INSTALL_DIR ${DEFAULT_BIN_INSTALL_DIR} CACHE STRING
"Install location for binaries (relative to CMAKE_INSTALL_PREFIX or absolute)")
set (LIB_INSTALL_DIR ${DEFAULT_LIB_INSTALL_DIR} CACHE STRING
"Install location for libraries (relative to CMAKE_INSTALL_PREFIX or absolute)")
set (PYLIB_INSTALL_DIR ${DEFAULT_PYLIB_INSTALL_DIR} CACHE STRING
"Install location for python libraries (relative to CMAKE_INSTALL_PREFIX or absolute)")
set (PYLIB3_INSTALL_DIR ${DEFAULT_PYLIB3_INSTALL_DIR} CACHE STRING
"Install location for python3 libraries (relative to CMAKE_INSTALL_PREFIX or absolute)")
set (INCLUDE_INSTALL_DIR ${DEFAULT_INCLUDE_INSTALL_DIR} CACHE STRING
"Install location of header files (relative to CMAKE_INSTALL_PREFIX or absolute)")
set (DOC_INSTALL_DIR ${DEFAULT_DOC_INSTALL_DIR} CACHE STRING
"Install location for documentation (relative to CMAKE_INSTALL_PREFIX or absolute)")
if (UNIX)
set (MAN_INSTALL_DIR ${DEFAULT_MAN_INSTALL_DIR} CACHE STRING
"Install location for manual pages (relative to CMAKE_INSTALL_PREFIX or absolute)")
endif()
set (PLUGIN_SEARCH_PATH "" CACHE STRING "Default plugin search path")
set (INSTALL_DOCS ON CACHE BOOL "Install documentation")
if (APPLE)
set (MACOSX_RPATH ON)
endif ()
# use, i.e. don't skip the full RPATH for the build tree
set (CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# the RPATH to be used when installing
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
message (STATUS "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_RPATH}")
###########################################################################
if (MSVC)
add_definitions (-D_CRT_SECURE_NO_DEPRECATE)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
add_definitions (-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions (-D_SCL_SECURE_NO_WARNINGS)
if(NOT LINKSTATIC)
add_definitions (-DBOOST_ALL_DYN_LINK)
add_definitions (-DOPENEXR_DLL)
endif ()
endif (MSVC)
# We want CTest for testing
# N.B. This needs to be added before any of the subdirectories, or
# their add_test commands will not register.
include (CTest)
# Tell CMake to process the sub-directories
add_subdirectory (src/include)
add_subdirectory (src/liboslcomp)
add_subdirectory (src/liboslquery)
add_subdirectory (src/liboslexec)
add_subdirectory (src/liboslnoise)
add_subdirectory (src/oslc)
add_subdirectory (src/shaders)
add_subdirectory (src/oslinfo)
if (OSL_BUILD_TESTS)
add_subdirectory (src/testshade)
add_subdirectory (src/testrender)
add_subdirectory (src/testshade)
add_subdirectory (src/testrender)
endif ()
if (OSL_BUILD_PLUGINS)
add_subdirectory (src/osl.imageio)
add_subdirectory (src/osl.imageio)
endif ()
add_subdirectory (src/include)
add_subdirectory (src/doc)
if (USE_QT AND Qt5_FOUND)
add_subdirectory (src/osltoy)
endif ()
#########################################################################
# Testing
# Make a build/platform/testsuite directory, and copy the master runtest.py
# there. The rest is up to the tests themselves.
file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testsuite")
add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/testsuite/runtest.py"
"${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" )
macro ( TESTSUITE )
parse_arguments (_ats "LABEL" "" ${ARGN})
# If there was a FOUNDVAR param specified and that variable name is
# not defined, mark the test as broken.
if (_ats_FOUNDVAR AND NOT ${_ats_FOUNDVAR})
set (_ats_LABEL "broken")
if (OSL_BUILD_SHADERS)
add_subdirectory (src/shaders)
if (OSL_BUILD_MATERIALX)
add_subdirectory (src/shaders/MaterialX)
endif ()
# Add the tests if all is well.
foreach (_testname ${_ats_DEFAULT_ARGS})
set (_testsrcdir "${CMAKE_SOURCE_DIR}/testsuite/${_testname}")
set (_testdir "${CMAKE_BINARY_DIR}/testsuite/${_testname}")
if (_ats_LABEL MATCHES "broken")
set (_testname "${_testname}-broken")
endif ()
set (_runtest python "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
${_testdir} ${_extra_test_args})
if (MSVC_IDE)
set (_runtest ${_runtest} --devenv-config $<CONFIGURATION>
--solution-path "${CMAKE_BINARY_DIR}" )
endif ()
endif ()
if (VERBOSE)
message (STATUS "TEST ${_testname}: ${CMAKE_BINARY_DIR}/testsuite/runtest.py ${_testdir} ${_extra_test_args}")
endif ()
option (INSTALL_DOCS "Install documentation" ON)
if (INSTALL_DOCS)
add_subdirectory (src/doc)
endif ()
file (MAKE_DIRECTORY "${_testdir}")
# Last minute site-specific instructions, if they exist
if (OSL_SITE AND EXISTS "${PROJECT_SOURCE_DIR}/site/${OSL_SITE}/cmake/sitecustom.cmake")
include ("${PROJECT_SOURCE_DIR}/site/${OSL_SITE}/cmake/sitecustom.cmake")
endif ()
# Run the test unoptimized, unless it's a "render_*" or "oslinfo_*"
# test, which we don't bother testing unoptimized.
if (NOT _testname MATCHES "^render" AND
NOT _testname MATCHES "^oslinfo" AND
NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
set (_env TESTSHADE_OPT=0 OPENIMAGEIOHOME=${OPENIMAGEIOHOME})
add_test ( NAME ${_testname}
COMMAND env ${_env} ${_runtest} )
endif ()
# Run the same test again with aggressive -O2 runtime
# optimization, triggered by setting TESTSHADE_OPT env variable
set (_env TESTSHADE_OPT=2 OPENIMAGEIOHOME=${OPENIMAGEIOHOME})
add_test ( NAME ${_testname}.opt
COMMAND env ${_env} ${_runtest} )
endforeach ()
endmacro ()
if (OSL_BUILD_TESTS)
# List all the individual testsuite tests here, except those that need
# special installed tests.
TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
blackbody blendmath breakcont
bug-array-heapoffsets
bug-locallifetime bug-outputinit bug-param-duplicate bug-peep
cellnoise closure closure-array color comparison
compile-buffer
component-range const-array-params const-array-fill
debugnan debug-uninit
derivs derivs-muldiv-clobber
draw_string
error-dupes exit exponential
function-earlyreturn function-simple function-outputelem
geomath getattribute-camera getsymbol-nonheap gettextureinfo
group-outputs groupstring
hex hyperb
ieee_fp if incdec initops intbits isconnected isconstant
layers layers-Ciassign layers-entry layers-lazy
layers-nonlazycopy layers-repeatedoutputs
linearstep
logic loop matrix message
mergeinstances-nouserdata mergeinstances-vararray
metadata-braces miscmath missing-shader
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
noise-perlin noise-uperlin noise-simplex noise-usimplex
pnoise pnoise-cell pnoise-gabor pnoise-perlin pnoise-uperlin
oslc-comma oslc-D
oslc-err-arrayindex oslc-err-closuremul
oslc-err-format oslc-err-intoverflow
oslc-err-noreturn oslc-err-outputparamvararray oslc-err-paramdefault
oslc-err-struct-array-init oslc-err-struct-dup
oslc-warn-commainit
oslc-variadic-macro
oslinfo-arrayparams oslinfo-colorctrfloat
oslinfo-metadata oslinfo-noparams
osl-imageio
printf-whole-array
raytype reparam
render-background render-bumptest
render-cornell render-furnace-diffuse
render-microfacet render-oren-nayar render-veachmis render-ward
shortcircuit spline splineinverse string
struct struct-array struct-array-mixture
struct-err struct-init-copy struct-layers
struct-return struct-with-array
struct-nested struct-nested-assign struct-nested-deep
ternary
testshade-expr
texture-alpha texture-blur texture-derivs
texture-firstchannel texture-interp
texture-missingcolor texture-simple
texture-smallderivs texture-swirl
texture-width texture-withderivs texture-wrap
trailing-commas transform transformc trig typecast
unknown-instruction
vararray-connect vararray-default
vararray-deserialize vararray-param
vecctr vector
wavelength_color xml )
# Only run field3d-related tests if the local OIIO was built with f3d support.
EXECUTE_PROCESS ( COMMAND ${OPENIMAGEIO_BIN}/oiiotool --help
OUTPUT_VARIABLE oiiotool_help )
if (oiiotool_help MATCHES "field3d")
TESTSUITE ( texture-field3d )
# install pkgconfig files
if ( NOT MSVC )
configure_file(src/build-scripts/oslexec.pc.in "${CMAKE_BINARY_DIR}/oslexec.pc" @ONLY)
configure_file(src/build-scripts/oslcomp.pc.in "${CMAKE_BINARY_DIR}/oslcomp.pc" @ONLY)
configure_file(src/build-scripts/oslquery.pc.in "${CMAKE_BINARY_DIR}/oslquery.pc" @ONLY)
install (FILES "${CMAKE_BINARY_DIR}/oslexec.pc"
"${CMAKE_BINARY_DIR}/oslcomp.pc"
"${CMAKE_BINARY_DIR}/oslquery.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT developer)
endif()
# Only run pointcloud tests if Partio is found
if (PARTIO_FOUND)
TESTSUITE ( pointcloud pointcloud-fold )
endif ()
endif (OSL_BUILD_TESTS)
#########################################################################
# Packaging
set (CPACK_PACKAGE_VERSION_MAJOR ${OSL_LIBRARY_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${OSL_LIBRARY_VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${OSL_LIBRARY_VERSION_PATCH})
# "Vendor" is only used in copyright notices, so we use the same thing that
# the rest of the copyright notices say.
set (CPACK_PACKAGE_VENDOR "Sony Pictures Imageworks")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenShadingLanguage is...")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/src/doc/Description.txt")
set (CPACK_PACKAGE_FILE_NAME OSL-${OSL_LIBRARY_VERSION_MAJOR}.${OSL_LIBRARY_VERSION_MINOR}.${OSL_LIBRARY_VERSION_PATCH}-${platform})
file (COPY "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_BINARY_DIR}")
file (RENAME "${CMAKE_BINARY_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/License.txt")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/License.txt")
file (COPY "${PROJECT_SOURCE_DIR}/README.md" DESTINATION "${CMAKE_BINARY_DIR}")
file (RENAME "${CMAKE_BINARY_DIR}/README.md" "${CMAKE_BINARY_DIR}/Readme.txt")
set (CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/Readme.txt")
set (CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/src/doc/Welcome.txt")
#set (CPACK_PACKAGE_EXECUTABLES I'm not sure what this is for)
#set (CPACK_STRIP_FILES Do we need this?)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (CPACK_GENERATOR "TGZ;STGZ;RPM;DEB")
set (CPACK_SOURCE_GENERATOR "TGZ")
# Export the configuration files. There are also library-specific config
# exports in the CMakeLists.txt of libOpenImageIO.
include (CMakePackageConfigHelpers)
# the file containing the exported targets
set (OSL_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets.cmake")
# the version file
set (OSL_VERSION_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
# the config file that is actually looked for by find_package
set (OSL_PROJECT_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
# where all these files will be installed
set (OSL_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
# first generate the version file in the binary dir
write_basic_package_version_file (
${OSL_VERSION_CONFIG}
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
# generate the Targets file in the binary dir using the targets collected in
# OSL_EXPORTED_TARGETS each target is added to OSL_EXPORTED_TARGETS through
# the macro install_target().
export (EXPORT OSL_EXPORTED_TARGETS FILE "${CMAKE_BINARY_DIR}/${OSL_TARGETS_EXPORT_NAME}")
# generate the config file from the template in the binary dir
configure_package_config_file ("${PROJECT_SOURCE_DIR}/src/cmake/Config.cmake.in"
"${OSL_PROJECT_CONFIG}"
INSTALL_DESTINATION "${OSL_CONFIG_INSTALL_DIR}")
# generate the config file from the template in the binary dir
install (FILES "${OSL_PROJECT_CONFIG}" "${OSL_VERSION_CONFIG}"
DESTINATION "${OSL_CONFIG_INSTALL_DIR}")
# 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 PROJECT_IS_TOP_LEVEL)
osl_add_all_tests()
endif ()
if (APPLE)
set (CPACK_GENERATOR "TGZ;STGZ;PackageMaker")
set (CPACK_SOURCE_GENERATOR "TGZ")
if (PROJECT_IS_TOP_LEVEL)
include (packaging)
endif ()
set (CPACK_SOURCE_PACKAGE_FILE_NAME OSL-${OSL_LIBRARY_VERSION_MAJOR}.${OSL_LIBRARY_VERSION_MINOR}.${OSL_LIBRARY_VERSION_PATCH}-source)
#set (CPACK_SOURCE_STRIP_FILES ...FIXME...)
set (CPACK_SOURCE_IGNORE_FILES ".*~")
include (CPack)
+8
View File
@@ -0,0 +1,8 @@
# Code of Conduct
The Open Shading Language project abides by Linux Foundation's code of
conduct, which you can read in full
[here](https://lfprojects.org/policies/code-of-conduct).
To report incidents or to appeal reports of incidents, send email to
the Manager of LF Projects at manager@lfprojects.org.
+354
View File
@@ -0,0 +1,354 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Contributing to OSL
===========================
Code contributions to OSL are always welcome. That's a big part of
why it's an open source project. Please review this document to get a
briefing on our process.
Mail List and Slack
-------------------
Contributors should be reading the osl-dev mail list:
* [osl-dev](https://lists.aswf.io/g/osl-dev)
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.
Bug Reports and Issue Tracking
------------------------------
We use GitHub's issue tracking system for reporting bugs and requesting
enhancements:
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues
**If you are merely asking a question ("how do I...")**, please do not file an
issue, but instead ask the question on the [OSL developer mail
list](https://lists.aswf.io/g/osl-dev).
If you are submitting a bug report, please be sure to note which version of
OSL you are using, on what platform (OS/version, which compiler you used,
and any special build flags or other unusual environmental issues). Please
give an account of
* what you tried
* what happened
* what you expected to happen instead
with enough detail that others can reproduce the problem.
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)
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.
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
the executed copy to manager@lfprojects.org.
The CLA allows a company to name a "CLA Manager" (who does not need
signatory power) who has the ability to use the online system to add or
delete individual employees of the company who are authorized to submit pull
requests, without needing to get an executive to amend and sign the
agreement each time.
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
ASWF requires the use of the [Developer’s Certificate of Origin 1.1
(DCO)](https://developercertificate.org/), which is the same mechanism that
the [Linux®
Kernel](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n416)
and many other communities use to manage code contributions. The DCO is
considered one of the simplest tools for sign offs from contributors as the
representations are meant to be easy to read and indicating signoff is done
as a part of the commit message.
Here is an example Signed-off-by line, which indicates that the submitter
accepts the DCO:
`Signed-off-by: John Doe <john.doe@example.com>`
You can include this automatically when you commit a change to your local
git repository using <code>git commit -s</code>. You might also want to
leverage this [command line tool](https://github.com/coderanger/dco) for
automatically adding the signoff message on commits.
Pull Requests and Code Review
-----------------------------
The best way to submit changes is via GitHub Pull Request. GitHub has a
[Pull Request Howto](https://help.github.com/articles/using-pull-requests/).
All code must be formally reviewed before being merged into the official
repository. The protocol is like this:
1. Get a GitHub account, fork AcademySoftwareFoundation/OpenShadingLanguage to create your
own repository on GitHub, and then clone it to get a repository on your
local machine.
2. Edit, compile, and test your changes.
3. Push your changes to your fork (each unrelated pull request to a separate
"topic branch", please).
4. Make a "pull request" on GitHub for your patch.
5. If your patch will induce a major compatibility break, or has a design
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,
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
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`.
All headers should contain
#pragma once
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:
* 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.
* 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.
#### 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.
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.
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:
(setq c-default-style "bsd")
(setq-default indent-tabs-mode nil)
Opening brace on the same line as the condition or loop.
One statement per line, except in rare cases where violating this rule makes
the code more clear.
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 if, for, while, etc., put a space before the paren, but NOT inside the parens. For example:
if (foo) // Yes
if(foo) // No
if ( foo ) // No
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.
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
use their naming conventions. For example, very general utility classes and
templates (the kind of thing you would normally find in std or boost) should
be lower case with underscores separating words, as they would be if they
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.
#### Class structure
Try to avoid public data members, although there are some classes that serve
a role similar to a simple C struct -- a very straightforward collection of
data members. In these, it's fine to make the data members public and have
clients set and get them directly.
Private member data should be named m_foo (alternately, it's ok to use the
common practice of member data foo_, but don't mix the conventions within a
class).
Private member data that needs public accessors should use the convention:
void foo (const T& newfoo) { m_foo = newfoo; }
const T& foo () const { return m_foo; }
Avoid multiple inheritance.
Namespaces: yes, use them!
#### Third-party libraries
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
internals (provided those features are present in the minimum version of
that library that we support).
Please do not add any NEW dependencies without debate on osl-dev and
approval of the project leader.
Use these libraries for OSL internals, but please DO NOT let them infect any
of our public APIs unless it's been thoroughly discussed and approved by the
group. (Exceptions: it's ok to use OIIO and Imath classes in our public
APIs.)
#### Comments and Doxygen
Comment philosophy: try to be clear, try to help teach the reader what's
going on in your code.
Prefer C++ comments (starting line with `//`) rather than C comments (`/* ... */`).
For any function that may be used by other programmers (e.g., public or
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
}
If you know Doxygen well, please feel free to use the various other markups.
But don't go so crazy with Doxygen markups that the comment itself, in an
ordinary editor, is not as readable as possible. The Doxygen-generated pages
are nice, but the place that needs to be most readable is in the code.
#### Miscellaneous
Macros should be used only rarely -- prefer inline functions, templates,
enums, or "const" values wherever possible.
#### Bottom Line
When in doubt, look elsewhere in the code base for examples of similar
structures and try to format your code in the same manner.
+209
View File
@@ -0,0 +1,209 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
# OSL Project Governance
OSL is a project of the Academy Software Foundation and relies on the ASWF
governance policies, supported by the Linux Foundation.
There are three primary project roles: Contributors submit code to the
project; Committers approve code to be included into the project; and the
Technical Steering Committee (TSC) provides overall high-level project
guidance.
* [Contributors](#Contributors)
* [Committers](#Committers)
* [Technical Steering Committee](#Technical-Steering-Committee)
## Contributors
The OSL project grows and thrives from assistance from Contributors.
Contributors include anyone in the community who contributes code,
documentation, or other technical artifacts that have been incorporated into
the projects repository.
Anyone can be a Contributor. You need no formal approval from the project,
beyond the legal forms.
### How to Become a Contributor
* Review the coding standards to ensure your contribution is in line
with the project's coding and styling guidelines.
* Sign the Individual CLA, or if you are employed by an organization that
might have any claim to IP you create, have your organization sign the
Corporate CLA.
* Submit your code as a PR with the appropriate DCO sign-off.
## Committers
Project Committers have merge access on the OSL GitHub repository
and are responsible for approving submissions by Contributors.
### Committer Responsibilities
Typical activities of a Committer include:
* Helping users and novice contributors.
* Ensuring a response to questions posted to the
[osl-dev developer mail list](https://lists.aswf.io/g/osl-dev)
* Contributing code and documentation changes that improve the project.
* Reviewing and commenting on issues and pull requests.
* Ensuring that changes and new code meet acceptable standards and are in
the long-term interest of the project.
* Participation in working groups.
* Merging pull requests.
### How to Become a Committer
Any member of the OSL community (though typically an existing Committer or
TSC member) may nominate an individual making significant and valuable
contributions to the OSL project to become a new Committer. To nominate a
new Committer, open an issue in the OSL repository, send mail to the TSC
mail list, or raise the issue at a TSC meeting.
The TSC may periodically review the Committer list to identify inactive
Committers. Past Committers are typically given Emeritus status. Emeriti may
request that the TSC restore them to active Committer status.
## Technical Steering Committee
The Technical Steering Committee (TSC) has final authority over this
project. As defined in the project charter, TSC responsibilities include,
but are not limited to:
* Coordinating technical direction of the Project.
* Project governance and contribution policy.
* GitHub repository administration.
* Maintaining the list of additional Committers
* Appointing representatives to work with other open source or open
standards communities.
* Discussions, seeking consensus, and where necessary, voting on technical
matters relating to the code base that affect multiple projects.
* Coordinating any marketing, events, or communications regarding the
project.
Within the TSC are two elected leadership roles to be held by its members
and voted on annually. Any TSC member can express interest in serving in a
role, or nominate another member to serve. There are no term limits, and one
person may hold multiple roles simultaneously. Should a TSC member resign
from a leadership role before their term is complete, a successor shall be
elected through the standard nomination and voting process to complete the
remainder of the term. The leadership roles are:
* **Chair**: This position acts as the project manager, organizing meetings
and providing oversight to project administration.
* **Chief Architect**: This position makes all the final calls on design and
technical decisions, and is responsible for avoiding "design by committee"
pitfalls.
The chair role is assumed to rotate annually (though there are no term
limits, so the TSC may reelect an existing chair). The chief architect
position should be a source of stability and coherent design vision, so the
TSC is encouraged to choose an architect who can serve for many years and
only change architects when it is necessary for the health of the project
and its community.
At the time of election, the TSC will also agree upon which of these two
leaders will serve as the OSL ASWF (Academy Software Foundation) TAC
(Technical Advisory Council) representative for the term. This member
represents the project at all ASWF TAC meetings.
### TSC Members
Current voting members of the TSC are:
* **Chair and TAC representative**: Chris Kulla - Epic Games
* **Chief Architect**: Larry Gritz - Sony Pictures Imageworks
* Luke Emrose - Animal Logic
* Eric Enderton - NVIDIA
* Stephen Friedman - Pixar
* Nicolas Guiard - Isotropix
* Derek Haase - DNEG
* Adrien Herubel - Autodesk
* Lee Kerley - Sony Pictures Imageworks
* Mitch Prater - Laika
* Brecht Van Lommel - Blender
### TSC Nomination and Succession
Any proposal for additional members of the TSC may be submitted by
Committers, TSC members, or other major stakeholders of the OSL community by
opening an issue outlining their case or raising the issue at a TSC meeting.
New TSC members are accepted or rejected by majority vote of the TSC.
If a TSC member is for an extended period not regularly participating or
performing the responsibilities expected of TSC members, the TSC may by
majority vote request an alternate TSC member be submitted by that
organization, or remove the inactive member from the TSC.
A voting member of the TSC may nominate a successor in the event that such
voting member decides to leave the TSC, and the TSC, including the departing
member, shall confirm or reject such nomination by a vote. In the event that
the departing member's nomination for successor is rejected by vote of the
TSC, the departing member shall be entitled to continue nominating
successors until one such successor is confirmed by vote of the TSC. If the
departing member fails or is unable to nominate a successor, the TSC may
nominate one on the departing member's behalf.
TSC membership is presumed to be retained by the individual even if they
change employers. The TSC may take action to ensure that organizational
stakeholder representation not become severely disproportionate, for example
by urging an organization that loses its sole TSC representative to nominate
a new member, or to limit the total number of voting members from any one
organization if too many members all move to the same organization.
### TSC Meetings
Any meetings of the TSC are intended to be open to the public, except where
there is a reasonable need for privacy. The TSC meets regularly in a voice
conference call, at a cadence deemed appropriate by the TSC. The TSC Chair
moderates the meeting, or appoints another TSC member to moderate in his or
her absence. Meetings may also be streamed online where appropriate;
connection details will be posted to the osl-dev mail list in advance of the
scheduled meeting.
Items are added to the TSC agenda which are considered contentious or are
modifications of governance, contribution policy, TSC membership, or release
process, in addition to topics involving the high-level technical direction
of the project.
The intention of the agenda is not to approve or review all patches. That
should happen continuously on GitHub and be handled by the larger group of
Committers.
Any community member or Contributor can ask that something be reviewed by
the TSC at the meeting by logging a GitHub issue. Any Committer, TSC member,
or the meeting chair can bring the issue to the TSC's attention by applying
the `TSC` label.
Prior to each TSC meeting, the meeting chair will share the agenda with
members of the TSC. TSC members can also add items to the agenda at the
beginning of each meeting. The meeting chair and the TSC cannot veto or
remove items.
The TSC may invite additional persons to participate in a non-voting
capacity.
The meeting chair is responsible for ensuring that minutes are taken and
archived in the project repository.
Due to the challenges of scheduling a global meeting with participants in
several time zones, the TSC will seek to resolve as many agenda items as
possible outside of meetings on the public mailing list.
+86 -31
View File
@@ -1,42 +1,91 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Building OSL
============
OSL currently compiles and runs cleanly on Linux and Mac OS X. We have
not yet compiled it for Windows, but we believe we it should be very
portable (we have done almost nothing platform-specific).
OSL currently compiles and runs cleanly on Linux, Mac OS X, and Windows.
OSL makes very heavy use of the OpenImageIO project
(http://openimageio.org), both for its texture mapping functionality as
well as numerous utility classes. If you are integrating OSL into an
existing renderer, you may use your own favorite texturing system rather
than OpenImageIO with a little minor surgery. There are only a few
places where OIIO (OpenImageIO) texturing calls are made, and they could
easily be bypassed. But it is probably not possible to remove OIIO
completely as a dependency, since we so heavily rely on a number of
other utility classes that it provides (for which there was no point
reinventing redundantly for OSL).
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.21)
* A suitable C++11 compiler to build OSL itself, which may be any of:
- GCC 4.8.5 or newer (tested through gcc 11.2)
- Clang 3.4 or newer (tested through clang 13)
- Microsoft Visual Studio 2015 or newer
- Intel C++ compiler icc version 13 (?) 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.0 or newer** (tested through 2.3)
OSL uses OIIO both for its texture mapping functionality as well as
numerous utility classes. If you are integrating OSL into an existing
renderer, you may use your own favorite texturing system rather than
OpenImageIO with a little minor surgery. There are only a few places
where OIIO texturing calls are made, and they could easily be bypassed.
But it is probably not possible to remove OIIO completely as a
dependency, since we so heavily rely on a number of other utility classes
that it provides (for which there was no point reinventing redundantly
for OSL).
After building OpenImageIO, if you don't have it installed in a
"standard" place (like /usr/include), you should set the environment
variable $OPENIMAGEIOHOME to point to the compiled distribution, as
well as for $OPENIMAGEIOHOME/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X) and then OSL's build scripts will be able
to find it.
* **[LLVM](http://www.llvm.org) 7, 8, 9, 10, 11, 12, or 13**, 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.
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.76)
* [Ilmbase or Imath](http://openexr.com/downloads.html) 2.0 or newer (tested through 3.1)
* [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/)
* (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, 3.9)
* pybind11 >= 2.4.2 (Tested through 2.7).
* NumPy
* (optional) Qt >= 5.6 (tested through 5.15). If not found at build time,
the `osltoy` application will be disabled.
Build process
-------------
Here are the steps to check out, build, and test the OSL distribution:
0. Install and build dependencies. You will need Boost (www.boost.org),
Imath (http://openexr.com/downloads.html), and OpenImageIO
(http://openimageio.org).
After building OpenImageIO, if you don't have it installed in a
"standard" place (like /usr/include), you should set the environment
variable $OPENIMAGEIOHOME to point to the compiled distribution, as
well as for $OPENIMAGEIOHOME/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X) and then OSL's build scripts will be able
to find it.
0. Install and build dependencies.
1. Check out a copy of the source code from the Git repository:
git clone https://github.com/imageworks/OpenShadingLanguage.git osl
git clone https://github.com/AcademySoftwareFoundation/OpenShadingLanguage.git osl
2. Change to the distribution directory and 'make'
cd osl
make
cd osl
make
Note: OSL uses 'CMake' for its cross-platform build system. But for
simplicity, we have made a "make wrapper" around it, so that by just
@@ -44,6 +93,11 @@ 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
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".
@@ -57,13 +111,14 @@ Here are the steps to check out, build, and test the OSL distribution:
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/doc".
in "dist/ARCH/share/doc".
5. After building (and setting your library path), you can run the
test suite with:
make test
make test
Troubleshooting
----------------
(Note: currently all tests pass on OS X but a few tests fail on Linux
strictly for floating point precision reasons, not because anything
is really broken. We're working on a fix for this.)
- [Build issues on macOS Catalina (fatal error: 'wchar.h' file not found)](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues/1055#issuecomment-581920327)
-27
View File
@@ -1,27 +0,0 @@
Copyright (c) 2009-2016 Sony Pictures Imageworks Inc., et al.
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Sony Pictures Imageworks nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 2009-present Contributors to the Open Shading Language project.
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+181 -129
View File
@@ -1,8 +1,14 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#########################################################################
#
# This is the master makefile.
# Here we put all the top-level make targets, platform-independent
# rules, etc.
# rules, etc. This is just a fancy wrapper around cmake, but for many
# people, it's a lot simpler to just type "make" and have everything
# happen automatically.
#
# Run 'make help' to list helpful targets.
#
@@ -12,7 +18,6 @@
.PHONY: all debug profile clean realclean nuke
working_dir := ${shell pwd}
INSTALLDIR =${working_dir}
# Figure out which architecture we're on
include ${working_dir}/src/make/detectplatform.mk
@@ -28,30 +33,26 @@ endif
MY_MAKE_FLAGS ?=
MY_NINJA_FLAGS ?=
MY_CMAKE_FLAGS ?=
#-g3
#-DSELF_CONTAINED_INSTALL_TREE:BOOL=TRUE
MY_CMAKE_FLAGS ?=
BUILDSENTINEL ?= Makefile
NINJA ?= ninja
CMAKE ?= cmake
CMAKE_BUILD_TYPE ?= Release
# Site-specific build instructions
ifndef OSL_SITE
OSL_SITE := ${shell uname -n}
endif
ifneq (${shell echo ${OSL_SITE} | grep imageworks},)
OSL_SITE ?= ${shell uname -n}
ifneq (${shell echo ${OSL_SITE} | grep imageworks.com},)
include ${working_dir}/site/spi/Makefile-bits
endif
ifneq (${shell echo ${OSL_SITE} | grep pixar},)
include ${working_dir}/site/pixar/Makefile-bits
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}
top_build_dir ?= build
build_dir ?= ${top_build_dir}/${platform}${variant}
top_dist_dir ?= dist
dist_dir ?= ${top_dist_dir}/${platform}${variant}
INSTALL_PREFIX ?= ${working_dir}/${dist_dir}
VERBOSE ?= ${SHOWCOMMANDS}
ifneq (${VERBOSE},)
@@ -63,11 +64,16 @@ ifneq (${VERBOSE},0)
endif
$(info OSL_SITE = ${OSL_SITE})
$(info dist_dir = ${dist_dir})
$(info INSTALLDIR = ${INSTALLDIR})
$(info INSTALL_PREFIX = ${INSTALL_PREFIX})
endif
ifneq (${NAMESPACE},)
MY_CMAKE_FLAGS += -DOSL_NAMESPACE:STRING=${NAMESPACE}
endif
ifneq (${LLVM_DIRECTORY},)
MY_CMAKE_FLAGS += -DLLVM_DIRECTORY:STRING=${LLVM_DIRECTORY}
MY_CMAKE_FLAGS += -DLLVM_ROOT:STRING=${LLVM_DIRECTORY}
endif
ifneq (${LLVM_VERSION},)
@@ -86,64 +92,52 @@ ifneq (${USE_LLVM_BITCODE},)
MY_CMAKE_FLAGS += -DUSE_LLVM_BITCODE:BOOL=${USE_LLVM_BITCODE}
endif
ifneq (${NAMESPACE},)
MY_CMAKE_FLAGS += -DOSL_NAMESPACE:STRING=${NAMESPACE}
endif
ifneq (${HIDE_SYMBOLS},)
MY_CMAKE_FLAGS += -DHIDE_SYMBOLS:BOOL=${HIDE_SYMBOLS}
endif
ifneq (${USE_FAST_MATH},)
MY_CMAKE_FLAGS += -DUSE_FAST_MATH:BOOL=${USE_FAST_MATH}
endif
ifneq (${OPENEXR_HOME},)
MY_CMAKE_FLAGS += -DOPENEXR_HOME:STRING=${OPENEXR_HOME}
endif
ifneq (${ILMBASE_HOME},)
MY_CMAKE_FLAGS += -DILMBASE_HOME:STRING=${ILMBASE_HOME}
endif
ifneq (${USE_PARTIO},)
MY_CMAKE_FLAGS += -DUSE_PARTIO:BOOL=${USE_PARTIO}
endif
ifneq (${PARTIO_HOME},)
MY_CMAKE_FLAGS += -DPARTIO_HOME:BOOL=${PARTIO_HOME} -DUSE_PARTIO:BOOL=1
endif
ifneq (${BOOST_HOME},)
MY_CMAKE_FLAGS += -DBOOST_ROOT:STRING=${BOOST_HOME}
endif
ifneq (${STOP_ON_WARNING},)
MY_CMAKE_FLAGS += -DSTOP_ON_WARNING:BOOL=${STOP_ON_WARNING}
endif
ifneq (${BUILDSTATIC},)
MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=${BUILDSTATIC}
ifneq (${BUILD_SHARED_LIBS},)
MY_CMAKE_FLAGS += -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
endif
ifneq (${LINKSTATIC},)
MY_CMAKE_FLAGS += -DLINKSTATIC:BOOL=${LINKSTATIC}
endif
ifneq (${SOVERSION},)
MY_CMAKE_FLAGS += -DSOVERSION:STRING=${SOVERSION}
endif
ifneq (${OSL_LIBNAME_SUFFIX},)
MY_CMAKE_FLAGS += -DOSL_LIBNAME_SUFFIX:STRING=${OSL_LIBNAME_SUFFIX}
endif
ifneq (${OIIO_LIBNAME_SUFFIX},)
MY_CMAKE_FLAGS += -DOIIO_LIBNAME_SUFFIX:STRING=${OIIO_LIBNAME_SUFFIX}
endif
ifneq (${OSL_BUILD_TESTS},)
MY_CMAKE_FLAGS += -DOSL_BUILD_TESTS:BOOL=${OSL_BUILD_TESTS}
endif
ifneq (${USE_EXTERNAL_PUGIXML},)
MY_CMAKE_FLAGS += -DUSE_EXTERNAL_PUGIXML:BOOL=${USE_EXTERNAL_PUGIXML} -DPUGIXML_HOME=${PUGIXML_HOME}
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
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug
CMAKE_BUILD_TYPE=Debug
endif
ifdef PROFILE
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
CMAKE_BUILD_TYPE=RelWithDebInfo
endif
ifneq (${MYCC},)
@@ -153,18 +147,22 @@ ifneq (${MYCXX},)
MY_CMAKE_FLAGS += -DCMAKE_CXX_COMPILER:STRING="${MYCXX}"
endif
ifneq (${USE_CPP11},)
MY_CMAKE_FLAGS += -DUSE_CPP11:BOOL=${USE_CPP11}
ifneq (${USE_CPP},)
MY_CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=${USE_CPP}
endif
ifneq (${USE_CPP14},)
MY_CMAKE_FLAGS += -DUSE_CPP14:BOOL=${USE_CPP14}
ifneq (${CMAKE_CXX_STANDARD},)
MY_CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
endif
ifneq (${USE_LIBCPLUSPLUS},)
MY_CMAKE_FLAGS += -DUSE_LIBCPLUSPLUS:BOOL=${USE_LIBCPLUSPLUS}
endif
ifneq (${GLIBCXX_USE_CXX11_ABI},)
MY_CMAKE_FLAGS += -DGLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}
endif
ifneq (${EXTRA_CPP_ARGS},)
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="${EXTRA_CPP_ARGS}"
endif
@@ -186,10 +184,62 @@ MY_CMAKE_FLAGS += -G Ninja
BUILDSENTINEL := build.ninja
endif
ifneq (${CODECOV},)
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug -DCODECOV:BOOL=${CODECOV}
ifeq (${CODECOV},1)
CMAKE_BUILD_TYPE=Debug
MY_CMAKE_FLAGS += -DCODECOV:BOOL=${CODECOV}
endif
ifneq (${SANITIZE},)
MY_CMAKE_FLAGS += -DSANITIZE=${SANITIZE}
endif
ifneq (${CLANG_TIDY},)
MY_CMAKE_FLAGS += -DCLANG_TIDY:BOOL=1
endif
ifneq (${CLANG_TIDY_CHECKS},)
MY_CMAKE_FLAGS += -DCLANG_TIDY_CHECKS:STRING=${CLANG_TIDY_CHECKS}
endif
ifneq (${CLANG_TIDY_ARGS},)
MY_CMAKE_FLAGS += -DCLANG_TIDY_ARGS:STRING=${CLANG_TIDY_ARGS}
endif
ifneq (${CLANG_TIDY_FIX},)
MY_CMAKE_FLAGS += -DCLANG_TIDY_FIX:BOOL=${CLANG_TIDY_FIX}
MY_NINJA_FLAGS += -j 1
# N.B. when fixing, you don't want parallel jobs!
endif
ifneq (${CLANG_FORMAT_INCLUDES},)
MY_CMAKE_FLAGS += -DCLANG_FORMAT_INCLUDES:STRING=${CLANG_FORMAT_INCLUDES}
endif
ifneq (${CLANG_FORMAT_EXCLUDES},)
MY_CMAKE_FLAGS += -DCLANG_FORMAT_EXCLUDES:STRING=${CLANG_FORMAT_EXCLUDES}
endif
ifneq (${BUILD_MISSING_DEPS},)
MY_CMAKE_FLAGS += -DBUILD_MISSING_DEPS:BOOL=${BUILD_MISSING_DEPS}
endif
ifneq (${USE_OPTIX},)
MY_CMAKE_FLAGS += -DUSE_OPTIX:BOOL=${USE_OPTIX}
endif
ifneq (${USE_PYTHON},)
MY_CMAKE_FLAGS += -DUSE_PYTHON:BOOL=${USE_PYTHON}
endif
ifneq (${PYTHON_VERSION},)
MY_CMAKE_FLAGS += -DPYTHON_VERSION:STRING=${PYTHON_VERSION}
endif
ifneq (${PYLIB_LIB_PREFIX},)
MY_CMAKE_FLAGS += -DPYLIB_LIB_PREFIX:BOOL=${PYLIB_LIB_PREFIX}
endif
ifneq (${PYLIB_INCLUDE_SONAME},)
MY_CMAKE_FLAGS += -DPYLIB_INCLUDE_SONAME:BOOL=${PYLIB_INCLUDE_SONAME}
endif
#$(info MY_CMAKE_FLAGS = ${MY_CMAKE_FLAGS})
#$(info MY_MAKE_FLAGS = ${MY_MAKE_FLAGS})
@@ -211,86 +261,78 @@ debug:
profile:
${MAKE} PROFILE=1 --no-print-directory
# 'make cmakesetup' constructs the build directory and runs 'cmake' there,
# 'make config' constructs the build directory and runs 'cmake' there,
# generating makefiles to build the project. For speed, it only does this when
# ${build_dir}/Makefile doesn't already exist, in which case we rely on the
# cmake generated makefiles to regenerate themselves when necessary.
cmakesetup:
config:
@ (if [ ! -e ${build_dir}/${BUILDSENTINEL} ] ; then \
${CMAKE} -E make_directory ${build_dir} ; \
cd ${build_dir} ; \
${CMAKE} -DCMAKE_INSTALL_PREFIX=${INSTALLDIR}/${dist_dir} \
${MY_CMAKE_FLAGS} -DBOOST_ROOT=${BOOST_HOME} \
../.. ; \
${CMAKE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${MY_CMAKE_FLAGS} ../.. ; \
fi)
ifeq (${USE_NINJA},1)
# 'make cmake' does a basic build (after first setting it up)
cmake: cmakesetup
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} )
# 'make build' does a basic build (after first setting it up)
build: config
@ ( cd ${build_dir} ; \
${CMAKE} --build . --config ${CMAKE_BUILD_TYPE} \
)
# 'make cmakeinstall' builds everthing and installs it in 'dist'.
# 'make install' builds everthing and installs it in 'dist'.
# Suppress pointless output from docs installation.
cmakeinstall: cmake
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} install | grep -v '^-- \(Installing\|Up-to-date\|Set runtime path\)' )
install: build
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target install --config ${CMAKE_BUILD_TYPE} | grep -v '^-- \(Installing\|Up-to-date\|Set runtime path\)' \
)
# 'make package' builds everything and then makes an installable package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package: cmakeinstall
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} package )
package: install
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target package --config ${CMAKE_BUILD_TYPE} \
)
# 'make package_source' makes an installable source package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package_source: cmakeinstall
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} package_source )
package_source: install
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target package_source --config ${CMAKE_BUILD_TYPE} \
)
else
# 'make clang-format' runs clang-format on all source files (if it's installed)
clang-format: config
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target clang-format --config ${CMAKE_BUILD_TYPE} \
)
# 'make cmake' does a basic build (after first setting it up)
cmake: cmakesetup
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} )
# 'make cmakeinstall' builds everthing and installs it in 'dist'.
# Suppress pointless output from docs installation.
cmakeinstall: cmake
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} install | grep -v '^-- \(Installing\|Up-to-date\|Set runtime path\)' )
# 'make package' builds everything and then makes an installable package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package: cmakeinstall
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} package )
# 'make package_source' makes an installable source package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package_source: cmakeinstall
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} package_source )
endif
# 'make dist' is just a synonym for 'make cmakeinstall'
dist : cmakeinstall
# 'make dist' is just a synonym for 'make install'
dist : install
TEST_FLAGS += --force-new-ctest-process --output-on-failure
# 'make test' does a full build and then runs all tests
test: cmake
test: build
@ ${CMAKE} -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests ${TEST_FLAGS}..."
@ # if [ "${CODECOV}" == "1" ] ; then lcov -b ${build_dir} -d ${build_dir} -z ; rm -rf ${build_dir}/cov ; fi
@ ( cd ${build_dir} ; PYTHONPATH=${PWD}/${build_dir}/src/python ctest -E broken ${TEST_FLAGS} )
@ ( if [ "${CODECOV}" == "1" ] ; then \
@ ( cd ${build_dir} ; \
OSL_ROOT_DIR=${INSTALL_PREFIX} \
OSL_ROOT=${INSTALL_PREFIX} \
LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:${LD_LIBRARY_PATH} \
DYLD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:${DYLD_LIBRARY_PATH} \
OIIO_LIBRARY_PATH=${INSTALL_PREFIX}/lib:${OIIO_LIBRARY_PATH} \
PYTHONPATH=${working_dir}/${build_dir}/lib/python/site-packages:${PYTHONPATH} \
ctest -E broken ${TEST_FLAGS} \
)
@ ( if [[ "${CODECOV}" == "1" ]] ; then \
cd ${build_dir} ; \
lcov -b . -d . -c -o cov.info ; \
lcov --remove cov.info "/usr*" -o cov.info ; \
genhtml -o ./cov -t "OSL test coverage" --num-spaces 4 cov.info ; \
genhtml -o ./cov -t "Test coverage" --num-spaces 4 cov.info ; \
fi )
# 'make testall' does a full build and then runs all tests (even the ones
# that are expected to fail on some platforms)
testall: cmake
${CMAKE} -E cmake_echo_color --switch=$(COLOR) --cyan "Running all tests ${TEST_FLAGS}..."
( cd ${build_dir} ; PYTHONPATH=${PWD}/${build_dir}/src/python ctest ${TEST_FLAGS} )
# 'make clean' clears out the build directory for this platform
clean:
${CMAKE} -E remove_directory ${build_dir}
@@ -311,17 +353,18 @@ nuke:
# 'make help' prints important make targets
help:
@echo "Targets:"
@echo " make Build optimized binaries and libraries in ${dist_dir},"
@echo " temporary build files in ${build_dir}"
@echo " make debug Build unoptimized with symbols in ${dist_dir}.debug,"
@echo " temporary build files in ${build_dir}.debug"
@echo " make profile Build for profiling in ${dist_dir}.profile,"
@echo " temporary build files in ${build_dir}.profile"
@echo " make Build and install optimized binaries and libraries"
@echo " make install Build and install optimized binaries and libraries"
@echo " make build Build only (no install) optimized binaries and libraries"
@echo " make config Just configure cmake, don't build"
@echo " make debug Build and install unoptimized with symbols"
@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"
@echo ""
@echo "Helpful modifiers:"
@echo " C++ compiler and build process:"
@@ -329,36 +372,45 @@ 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 " USE_CPP11=0 Compile in C++11 mode (=0 means use CPP03!)"
@echo " USE_CPP14=1 Compile in C++14 mode"
@echo " USE_LIBCPLUSPLUS=1 Use clang libc++"
@echo " CMAKE_CXX_STANDARD=14 Compile in C++14 mode (default is C++11)"
@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"
@echo " USE_NINJA=1 Set up Ninja build (instead of make)"
@echo " USE_CCACHE=0 Disable ccache (even if available)"
@echo " CODECOV=1 Enable code coverage tests"
@echo " SANITIZE=name1,... Enable sanitizers (address, leak, thread)"
@echo " CLANG_TIDY=1 Run clang-tidy on all source (can be modified"
@echo " by CLANG_TIDY_ARGS=... and CLANG_TIDY_FIX=1"
@echo " CLANG_FORMAT_INCLUDES=... CLANG_FORMAT_EXCLUDES=..."
@echo " Customize files for 'make clang-format'"
@echo " Linking and libraries:"
@echo " HIDE_SYMBOLS=1 Hide symbols not in the public API"
@echo " BUILDSTATIC=1 Build static library instead of shared"
@echo " BUILD_SHARED_LIBS=0 Build static library instead of shared"
@echo " LINKSTATIC=1 Link with static external libs when possible"
@echo " Dependency hints:"
@echo " For each dependeny Foo, defining ENABLE_Foo=0 disables it, even"
@echo " if found. And you can hint where to find it with Foo_ROOT=path"
@echo " Note that it is case sensitive!"
@echo " Finding and Using Dependencies:"
@echo " BOOST_HOME=path Custom Boost installation"
@echo " OPENEXR_HOME=path Custom OpenEXR installation"
@echo " ILMBASE_HOME=path Custom Ilmbase installation"
@echo " PARTIO_HOME= Use Partio from the given location"
@echo " USE_EXTERNAL_PUGIXML=1 Use the system PugiXML, not the one in OIIO"
@echo " BOOST_ROOT=path Custom Boost installation"
@echo " USE_QT=0 Skip anything that needs Qt"
@echo " LLVM-related options:"
@echo " LLVM_VERSION=3.4 Specify which LLVM version to use"
@echo " LLVM_VERSION=7.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"
@echo " USE_LLVM_BITCODE=0 Don't generate embedded LLVM bitcode"
@echo " OSL build-time options:"
@echo " NAMESPACE=name Wrap OSL APIs in another namespace"
@echo " INSTALL_PREFIX=path Set installation prefix (default: ${INSTALL_PREFIX})"
@echo " NAMESPACE=name Override namespace base name (default: OSL)"
@echo " USE_FAST_MATH=1 Use faster, but less accurate math (set to 0 for libm defaults)"
@echo " OSL_BUILD_TESTS=0 Skip building the unit tests, testshade, testrender"
@echo " USE_SIMD=arch Build with SIMD support (choices: 0, sse2, sse3,"
@echo " ssse3, sse4.1, sse4.2, f16c,"
@echo " comma-separated ok)"
@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 " make test, extra options:"
@echo " TEST=regex Run only tests matching the regex"
@echo ""
+295 -146
View File
@@ -1,20 +1,15 @@
README for Open Shading Language
================================
<div align="center">
<img src="https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/doc/Figures/osl-short.png" width=256 height=128>
Build status:
<H1>Open Shading Language</H1>
</div>
[![Build Status](https://travis-ci.org/imageworks/OpenShadingLanguage.svg?branch=master)](https://travis-ci.org/imageworks/OpenShadingLanguage)
[![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")
Table of contents
------------------
[![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)
* [Introduction](#introduction)
* [How OSL is different](#how-osl-is-different)
* [What OSL consists of](#what-osl-consists-of)
* [Building OSL](#building-osl)
* [Current state of the project and road map](#current-state-of-the-project-and-road-map)
* [Contacts](#contacts)
* [Credits](#credits)
Introduction
@@ -26,27 +21,28 @@ 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 was originally developed by Sony Pictures Imageworks for use in its in-
house renderer used for feature film animation and visual effects, released
as open source so it could be used by other visual effects and animation
studios and rendering software vendors. Now it's the de facto standard
shading language for VFX and animated features, used across the industry in
many commercial and studio- proprietary renderers. Because of this, the work
on OSL received an Academy Award for Technical Achievement in 2017.
OSL is robust and production-proven, and was the exclusive shading
system for work on big VFX films such as "Men in Black 3", "The Amazing
Spider-Man," "Oz the Great and Powerful," and "Edge of Tomorrow," as
well as animated features such as "Hotel Transylvania" and "Cloudy With
a Chance of Meatballs 2", and many other films completed or currently in
production.
OSL is robust and production-proven, and has been used in films as diverse
as "The Amazing Spider-Man," "Hotel Transylvania," "Edge of Tomorrow", "Ant
Man", "Finding Dory," and many more. OSL support is in most leading
renderers used for high-end VFX and animation work. For a full list of films
and products, see the [filmography](#where-osl-has-been-used).
The OSL code is distributed under the "New BSD" license (see the
"LICENSE" file that comes with the distribution), and the documentation
under the Creative Commons Attribution 3.0 Unported License
(http://creativecommons.org/licenses/by/3.0/). In short, you are free
to use OSL in your own applications, whether they are free or
The OSL code is distributed under the
["New/3-clause BSD" license](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/LICENSE.md),
and the documentation under the [Creative Commons Attribution 4.0 International
License](https://creativecommons.org/licenses/by/4.0/). In short, you are
free to use OSL in your own applications, whether they are free or
commercial, open or proprietary, as well as to modify the OSL code and
documentation as you desire, provided that you retain the original
copyright notices as described in the license.
documentation as you desire, provided that you retain the original copyright
notices as described in the license.
How OSL is different
@@ -215,147 +211,300 @@ The OSL open source distribution consists of the following components:
Building OSL
Where OSL has been used
-----------------------
*This list only contains films or products whose OSL use is stated or can be
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
* [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: Angie](http://www.isotropix.com/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/)
* [Image Engine: Gaffer](http://www.gafferhq.org/) (for expressions and deformers)
* [DNA Research: 3Delight](http://www.3delight.com/)
* 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)
Films using OSL (grouped by year of release date):
* **(2012)**
Men in Black 3, The Amazing Spider-Man, Hotel Transylvania
* **(2013)**
Oz the Great and Powerful, Smurfs 2, Cloudy With a Chance of Meatballs 2
* **(2014)**
The Amazing Spider-Man 2, Blended, Edge of Tomorrow, 22 Jump Street,
Guardians of the Galaxy, Fury,
The Hunger Games: Mockingjay - Part 1, Exodus: Gods and Kings,
The Interview
* **(2015)**
American Sniper,
Insurgent,
Avengers Age of Ultron,
Ant Man,
Pixels,
Mission Impossible: Rogue Nation,
Hotel Transylvania 2,
Bridge of Spies,
James Bond: Spectre,
The Hunger Games: Mockingjay - Part 2,
Concussion
* **(2016)**
Allegiant,
Batman vs Superman: Dawn of Justice,
The Huntsman,
Angry Birds Movie,
Alice Through the Looking Glass,
Captain America: Civil War,
Finding Dory,
Piper,
Independence Day: Resurgence,
Ghostbusters,
Star Trek Beyond,
Suicide Squad,
Kingsglaive: Final Fantasy XV,
Storks,
Miss Peregrine's Home for Peculiar Children,
Fantastic Beasts and Where to Find Them,
Assassin's Creed
* **(2017)**
Lego Batman,
The Great Wall,
A Cure for Wellness,
Logan,
Power Rangers,
Life,
Smurfs: The Lost Village,
The Fate of the Furious,
Alien Covenant,
Guardians of the Galaxy 2,
The Mummy,
Wonder Woman,
Cars 3,
Baby Driver,
Spider-Man: Homecoming,
Dunkirk,
The Emoji Movie,
Detroit,
Kingsman: The Golden Circle,
Lego Ninjago Movie,
Blade Runner 2049,
Geostorm,
Coco,
Justice League,
Thor: Ragnarok
* **(2018)**
Peter Rabbit,
Black Panther,
Annnihilation,
Red Sparrow,
Pacific Rim Uprising,
Avengers Infinity War,
Deadpool 2,
Incredibles 2,
Jurassic World: Fallen Kingdom,
Hotel Transylvania 3: Summer Vacation,
Ant Man and the Wasp,
Skyscraper,
Mission Impossible: Fallout,
The Meg,
Kin,
Smallfoot,
Alpha,
Venom,
First Man,
Bad Times at the El Royale,
Fantastic Beasts: The Crimes of Grindelwald,
Bohemian Rhapsody,
Holmes and Watson,
Spider-Man: Into the Spider-Verse
* **(2019)**
The Kid Who Would Be King,
Alita: Battle Angel,
Lego Movie 2,
Lucky 13 (Love, Death, and Robots),
Captain Marvel,
Triple Frontier,
Avengers: Endgame,
Pokémon Detective Pikachu,
Godzilla: King of Monsters,
Rim of the World,
John Wick 3 Parabellum,
Men in Black International,
Toy Story 4,
Spider-Man: Far From Home,
Hobbs & Shaw,
Angry Birds 2,
The Art of Racing in the Rain,
Secret Life of Pets,
The Mandalorian (S1),
The Dark Crystal: Age of Resistance,
The King,
Jumanji: The Next Level,
Richard Jewell,
Game of Thrones (S8),
Lost in Space (S1),
Togo
* **(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)
* **(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,
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
* **(2022 / upcoming)**
Hotel Transylvania 4: Transformania,
...
Building and Installation
-------------------------
Please read the [INSTALL.md](INSTALL.md) file for detailed instructions on
how to build and install OSL.
Documentation
-------------
The OSL language specification can be found at
[src/doc/osl-languagespec.pdf](src/doc/osl-languagespec.pdf) (in a source
distribution) or in the share/doc/OSL/osl-languagespec.pdf file of an
installed binary distribution.
Contact & reporting problems
----------------------------
Simple "how do I...", "I'm having trouble", or "is this a bug" questions are
best asked on the [osl-dev developer mail
list](https://lists.aswf.io/g/osl-dev).
That's where the most people will see it and potentially be able to answer
your question quickly (more so than a GH "issue").
Bugs, build problems, and discovered vulnerabilities that you are relatively
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.
Contributing
------------
Please see the "INSTALL" file in the OSL distribution for instructions
for building the OSL source code.
OSL welcomes code contributions, and nearly 50 people have done so over the
years. We take code contributions via the usual GitHub pull request (PR)
mechanism. Please see [CONTRIBUTING](CONTRIBUTING.md) for detailed
instructions.
Contacts, Links, and References
-------------------------------
Current state of the project and road map
-----------------------------------------
[OSL GitHub page](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage)
At Sony Pictures Imageworks, we are exclusively using OSL in our
proprietary renderer, "Arnold." Completed productions that used OSL for
shading have included:
[Read or subscribe to the OSL development mail list](https://lists.aswf.io/g/osl-dev)
Men in Black 3
The Amazing Spider-Man
Hotel Transylvania
Oz the Great and Powerful
Smurfs 2
Cloudy With a Chance of Meatballs 2
Amazing Spider-Man 2
Edge of Tomorrow
Blended
22 Jump Street
Guardians of the Galaxy
The Interview
Fury
American Sniper
Pixels
Hotel Transylvania 2
Concussion
Alice in Wonderland: Through the Looking Glass
And more are currently in production. Our shader-writing team works
entirely in OSL, all productions use OSL, and we've even removed all the
code from the renderer that allows people to write the old-style "C"
shaders. At the time we removed the old shader facility, the OSL
shaders were consistently outperforming their equivalent old compiled C
shaders in the old system.
In the longer term, there are a number of projects we hope to get to
leading to a 2.x or 3.x cut of the language and library. Among our
long-term goals:
* More documentation, in particular the "Integration Guide" that
documents all the public APIs of the OSL libraries that you use when
integrating into a renderer. Currently, the source code to
"testrender" is the best/only example of how to integrate OSL into a
renderer.
* Our set of sample shaders is quite anemic. We will eventually have a
more extensive set of useful, production-quality shaders and utility
functions you can call from your shaders.
* Currently "closure primitives" are implemented in C++ in the OSL
library or in the renderer, but we would like a future spec of the
language to allow new closure primitives to be implemented in OSL
itself.
* Similarly, integrators are now implemented in the renderer, but we
want a future OSL release to allow new integrators to be implemented
in OSL itself.
* We would like to implement alternate "back ends" that would allow
translation of OSL shaders (and shader networks) into code that can
run on GPUs or other exotic hardware (at least for the biggest subset
of OSL that can be expressed on such hardware). This would, for
example, allow you to view close approximations to your OSL shaders in
realtime preview windows in a modeling system or lighting tool.
We (the renderer development team at Sony Pictures Imageworks) probably
can't do these all right away (in fact, probably can't do ALL of them in
any time range). But we hope that as an open source project, other
users and developers will step up to help us explore more future
development avenues for OSL than we would be able to do alone.
Contacts
--------
[OSL GitHub page](https://github.com/imageworks/OpenShadingLanguage)
[Read or subscribe to the OSL development mail list](http://groups.google.com/group/osl-dev)
Email the lead architect: lg AT imageworks DOT com
[Most recent PDF of the OSL language specification](https://github.com/imageworks/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://opensource.imageworks.com/?p=osl)
[OSL home page](http://openshadinglanguage.org)
[Sony Pictures Imageworks main open source page](http://opensource.imageworks.com)
If you want to contribute code back to the project, you'll need to
sign [a Contributor License Agreement](http://opensource.imageworks.com/cla/).
Credits
-------
The original designer and open source administrator of OSL is Larry Gritz.
The current project leadership is documented in the
[Governance](GOVERNANCE.md) file.
The main/early developers of OSL are (in order of joining the project):
Larry Gritz, 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
small changes: Steve Agland, Shane Ambler, Martijn Berger, Nicholas Bishop,
Matthaus G. Chajdas, Thomas Dinges, Henri Fousse, Syoyo Fujita, Derek Haase,
Sven-Hendrik Haase, John Haddon, Daniel Heckenberg, Ronan Keryell, Max
Liani, Bastien Montagne, Erich Ocean, Mikko Ohtamaa, Alex Schworer, Sergey
Sharybin, Stephan Steinbach, Esteban Tovagliari, Alexander von Knorring.
(Listed alphabetically; if we've left anybody out, please let us know.)
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, Clark Chen, Alejandro Conty, Thomas Dinges, Mads
Drøschler, Luke Emrose, Louis Feng, Mark Final, Henri Fousse, Syoyo Fujita,
Tim Grant, Larry Gritz, Nicolas Guiard, Euan Haahr, Derek Haase, Sven-Hendrik
Haase, John Haddon, Niklas Harrysson, 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, Benoit Ruiz, Declan
Russell, Patrick Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin,
Sandip Shukla, Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, 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.)
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.
Bredow, Brian Keeney, Barbara Ford, Rene Limberger, Erik Strauss, and Mike
Ford.
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.
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. And
of course, the many engineers, TDs, and artists elsewhere who incorporated
OSL into their products and pipelines, especially the early risk-takers at
Chaos Group, Double Negative, Pixar, DNA, Isotropix, and Animal Logic. 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.
(I hope to mention them by name after we get permission of the people
and studios involved.)
specification and gave us very helpful feedback and additional ideas,
as well as to the continuing contributions and feedback of its current
developers and users at other VFX and animation studios.
The OSL implementation incorporates or depends upon several other open
source packages:
[OpenImageIO (c) Larry Gritz, et al](http://www.openimageio.org)
[Boost - various authors](http://www.boost.org)
[IlmBase (c) Industrial Light & Magic](http://www.openexr.com)
[LLVM Compiler Infrastructure](http://llvm.org)
The OSL implementation depends upon several other open source packages,
all with compatible licenses:
* [OpenImageIO](http://www.openimageio.org)
* [Boost](http://www.boost.org)
* [IlmBase](http://www.openexr.com)
* [LLVM Compiler Infrastructure](http://llvm.org)
OSL's documentation incorporates parts of [Markdeep](https://casual-effects.com/markdeep/)
(c) 2015-2016, Morgan McGuire, and [highlight.js](https://highlightjs.org/)
(c) 2006, Ivan Sagalaev, both distributed under BSD licenses.
+113
View File
@@ -0,0 +1,113 @@
See [LICENSE.md](LICENSE.md) for the main open source license of original
code written for the Open Shading Language project.
The remainder of this file reproduces the open source licensing details
of other projects that have been imported, incorporated into, or derived
into parts of OSL.
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
OSL replicates and modifies several files from the "Imath" portion of
OpenEXR. These are all found in src/include/OSL/Imathx.
* Qt, Copyright (c) The Qt Company Ltd.
http://doc.qt.io/
Some widget code in src/osltoy is copied and/or derived from example code
for Qt.
* Highlight.js
https://github.com/highlightjs/highlight.js/
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
SPDX-License-Identifier: BSD-2-Clause
* Markdeep
https://casual-effects.com/markdeep
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------
Public domain
* The simplex noise implementation is Copyright (c) Stefan Gustavson.
It bears the following notice:
This library is public domain software, released by the author
into the public domain in February 2011. You may do anything
you like with it. You may even remove all attributions,
but of course I'd appreciate it if you kept my name somewhere.
-------------------------------------------------------------------------
If we have left anything out, it is unintentional. Please let us know.
-27
View File
@@ -1,27 +0,0 @@
# Pixar-specific settings
ifneq (${VERBOSE},)
$(info Including pixar/Makefile-bits)
endif
MY_CMAKE_FLAGS += -DUSE_fPIC:BOOL=1
MY_CMAKE_FLAGS += -DENABLERTTI:BOOL=1
MY_CMAKE_FLAGS += -DSTOP_ON_WARNING:BOOL=0
MY_CMAKE_FLAGS += -DHIDE_SYMBOLS:BOOL=1
MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=1
MY_CMAKE_FLAGS += -DLINKSTATIC:BOOL=1
MY_CMAKE_FLAGS += -DUSE_FAST_MATH:BOOL=1
MY_CMAKE_FLAGS += -DOPENEXR_CUSTOM_LIB_DIR:STRING=${ILMBASE_HOME}/lib/linux-ix86-64/gcc4.1
MY_CMAKE_FLAGS += -DOPENEXR_CUSTOM_LIB_SUFFIX:STRING="-fPIC"
# Don't build testshade or testrender (mostly because they require the
# image-handling parts of OIIO, which Pixar doesn't build)
MY_CMAKE_FLAGS += -DOSL_BUILD_TESTS:BOOL=0
# Don't let OSL create a default OIIO::TextureSystem. If the renderer
# doesn't pass in whatever proxy it wants, it will assert.
MY_CMAKE_FLAGS += -DOSL_NO_DEFAULT_TEXTURESYSTEM:BOOL=1
ifneq (${VERBOSE},)
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
endif
+483 -171
View File
@@ -1,204 +1,516 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# SPI-specific settings
OSL_NAMESPACE ?= 'OSL_Arnold'
OPENIMAGEIO_NAMESPACE ?= 'OpenImageIO_Arnold'
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS="-DOSL_SPI=1"
## Generic OSX machines (including LG's laptop)
ifeq (${platform}, macosx)
MY_CMAKE_FLAGS += \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
ifeq (${COMPILER}, clang)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
endif
# All our Mac laptops seem to be at least SSE 4.2
USE_SIMD = sse4.2
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.
## Spinux (current)
ifeq ($(SP_OS), spinux1)
platform=spinux1
USE_CPP11 ?= 0
USE_NINJA := 1
NINJA := /net/soft_scratch/apps/arnold/tools/spinux1/bin/ninja
CMAKE := /net/soft_scratch/apps/arnold/tools/spinux1/bin/cmake
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
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}
## If not overridden, here is our preferred LLVM installation
## (may be changed as new versions are rolled out to the facility)
ifeq (${LLVM_DIRECTORY},)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/spinux1/llvm_3.4.2
endif
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 MAKECMDGOALS = $(MAKECMDGOALS))
# default compiler is clang, taken from the LLVM directory
ifeq (${COMPILER},)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
# requesting 'clang' or 'gcc' (no version) means the first clang or
# gcc in your path
ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
endif
ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_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
CMAKE_CXX_STANDARD ?= 14
endif
SP_PLATFORM ?= linux
SP_PROC ?= x86_64
SP_REZ_OS ?= CentOS-7
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}
# 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}, clang341)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.1/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.1/bin/clang++
endif
ifeq (${COMPILER}, clang342)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang++
endif
ifeq (${COMPILER}, gcc463)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.6.3-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.6.3-test/bin/g++
endif
ifeq (${COMPILER}, gcc470)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.0-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.0-test/bin/g++
endif
ifeq (${COMPILER}, gcc472)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/g++
endif
ifeq (${COMPILER}, gcc490)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/g++
endif
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 += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOSL_SPI=1" -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
SPCOMP2_ROOT ?= /shots/spi/home/lib/SpComp2
# Our minimal architecture for workstations and farm supports SSE 4.1
USE_SIMD = sse4.1
MY_CMAKE_FLAGS += \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libpthread.so" \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libcurses.so" \
-DLLVM_CUSTOM=1 \
-DLLVM_STATIC=1 \
-DLLVM_VERSION=${LLVM_VERSION} \
-DLLVM_DIRECTORY=${LLVM_DIRECTORY}
ifneq (${SPCOMP2_USE_BOOSTVERS}, 1)
BOOSTVERS=1.51
endif
BOOSTVERS_SUFFIX = -${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
CONSTRUCTED_BOOSTVERS = ${shell echo ${BOOSTVERS} | sed "s/\\./0/"}00
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${CONSTRUCTED_BOOSTVERS} \
-DBoost_INCLUDE_DIRS=/usr/include/boost_${BOOSTVERS} \
-DBoost_LIBRARY_DIRS=/usr/lib64/boost_${BOOSTVERS} \
-DBoost_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERS}/libboost_filesystem-gcc44-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERS}/libboost_filesystem-gcc44-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERS}/libboost_regex-gcc44-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERS}/libboost_system-gcc44-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERS}/libboost_thread-gcc44-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERS}/libboost_wave-gcc44-mt${BOOSTVERS_SUFFIX}.so"
endif # endif spinux1
## Rhel7 (current)
ifeq ($(SP_OS), rhel7)
platform=rhel7
USE_CPP11 ?= 1
USE_NINJA := 1
NINJA := /net/soft_scratch/apps/arnold/tools/spinux1/bin/ninja
CMAKE := /net/soft_scratch/apps/arnold/tools/spinux1/bin/cmake
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
## If not overridden, here is our preferred LLVM installation
## (may be changed as new versions are rolled out to the facility)
ifeq (${LLVM_DIRECTORY},)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/spinux1/llvm_3.4.2
ifeq (${SP_OS}, rhel7)
PYTHON_VERSION ?= 2.7
USE_SIMD ?= sse4.1,aes
CMAKE ?= cmake
USE_NINJA ?= 1
NINJA ?= ninja
ifeq ($(USE_NINJA),1)
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
endif
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)
OIIO_LIBNAME_SUFFIX ?= _Arnold
OSL_LIBNAME_SUFFIX ?= _Arnold
endif
# default compiler is clang, taken from the LLVM directory
ifeq (${COMPILER},)
#
# 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/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++
else ifeq (${COMPILER},clang10)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/10.0.0-1/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang11)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/11.0.0-rc1/${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)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/g++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
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++
endif
# requesting 'clang' or 'gcc' (no version) means the first clang or
# gcc in your path
ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
endif
ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
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
# 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}, clang342)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang++
endif
ifeq (${COMPILER}, gcc472)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/g++
endif
ifeq (${COMPILER}, gcc490)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/g++
endif
# Our minimal architecture for workstations and farm supports SSE 4.1
USE_SIMD = sse4.1
MY_CMAKE_FLAGS += \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libpthread.so" \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libcurses.so" \
-DLLVM_CUSTOM=1 \
-DLLVM_STATIC=1 \
MY_CMAKE_FLAGS +=
-DLLVM_STATIC=1 \
-DLLVM_VERSION=${LLVM_VERSION} \
-DLLVM_DIRECTORY=${LLVM_DIRECTORY}
ifneq (${SPCOMP2_USE_BOOSTVERS}, 1)
BOOSTVERS=1.55
#
# 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
#
# Python
#
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)
# 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
else ifeq (${PYTHON_VERSION},2.7)
# Special sauce for Python 2.7
Python_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}
Python_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
endif
BOOSTVERSSP=${BOOSTVERS}sp
BOOSTVERS_SUFFIX = -${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
BOOSTVERS_PREFIX = ${shell echo ${BOOSTVERS} | sed "s/\\./_/"}_0
CONSTRUCTED_BOOSTVERS = ${shell echo ${BOOSTVERS} | sed "s/\\./0/"}00
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${CONSTRUCTED_BOOSTVERS} \
-DBoost_INCLUDE_DIRS=/usr/include/boost_${BOOSTVERSSP} \
-DBoost_LIBRARY_DIRS=/usr/lib64/boost_${BOOSTVERS} \
-DBoost_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_regex-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_system-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_thread-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_wave-gcc48-mt${BOOSTVERS_SUFFIX}.so"
-DPython_INCLUDE_DIR:STRING=${Python_INCLUDE_DIR} \
-DPython_LIBRARY:STRING=${Python_LIBRARY} \
-Dpybind11_ROOT:STRING=${REZ_PACKAGE_ROOT}/pybind11/2.4.3/python-${PYTHON_VERSION}
endif # endif rhel7
# set up OpenImageIO distribution environment
ifeq (${OPENIMAGEIOHOME},)
MY_CMAKE_FLAGS += -DOPENIMAGEIOHOME:STRING=${working_dir}/../OpenImageIO_local/dist/${platform}${variant}/ \
-DOSL_NAMESPACE:STRING=${OSL_NAMESPACE}
# 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
Partio_VERSION ?= 1.10.6
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
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
CUDA_VERSION ?= 11.0.1
OPTIX_VERSION ?= 7.1.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}
CUDA_EXTRA_LIBS ?= ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libnvrtc.so
OptiX_ROOT ?= /shots/spi/home/lib/arnold/rhel7/optix_${OPTIX_VERSION}
OPTIXHOME = ${OptiX_ROOT}
MY_CMAKE_FLAGS += -DUSE_OPTIX=${USE_OPTIX} \
-DCUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR} \
-DCUDA_EXTRA_LIBS=${CUDA_EXTRA_LIBS} \
-DOPTIXHOME=${OPTIXHOME} -DOPTIX_EXTRA_LIBS=lzma
# end rhel7
## Generic OSX machines (including LG's laptop)
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"
BOOSTVERSSP=${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)
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)
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)
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)
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++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
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++
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++
endif
# end generic OSX
else
MY_CMAKE_FLAGS += -DOPENIMAGEIOHOME:STRING=${IMAGEIOHOME} \
-DOSL_NAMESPACE:STRING=${OSL_NAMESPACE}
$(error Unknown SP_OS=${SP_OS} platform=${platform})
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))
$(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
@@ -0,0 +1,72 @@
<!-- 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.
+6
View File
@@ -0,0 +1,6 @@
<cfg>
<version>@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@</version>
<appdir architecture="@SP_OS@">@OSL_REZ_INSTALL_PATH@</appdir>
<launchprogram></launchprogram>
<setup></setup>
</cfg>
+20
View File
@@ -0,0 +1,20 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# 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 ()
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# This helper script takes a major.minor.patch semantic version string
# ("2.1.1") and reformats it into the dot-less zero-padded version like
# "20101". This is necessary to turn external release designations into
# integer SpComp2 version numbers.
from __future__ import print_function
import sys
if len(sys.argv) != 2 :
print('Need 1 argument: version number with dots')
exit(1)
vers = sys.argv[1]
parts = vers.split('.')
print ('{:d}{:02d}{:02d}'.format(int(parts[0]), int(parts[1]), int(parts[2])))
+31
View File
@@ -0,0 +1,31 @@
# 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
@@ -0,0 +1,59 @@
# -*- 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
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Utility script to download and build cmake
#
# 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
echo "Building cmake"
uname
CMAKE_VERSION=${CMAKE_VERSION:=3.12.4}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
CMAKE_INSTALL_DIR=${CMAKE_INSTALL_DIR:=${LOCAL_DEPS_DIR}/cmake}
if [[ `uname` == "Linux" && `uname -m` == "x86_64" ]] ; then
mkdir -p ${CMAKE_INSTALL_DIR} || true
curl --location "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh" -o "cmake.sh"
sh cmake.sh --skip-license --prefix=${CMAKE_INSTALL_DIR}
export PATH=${CMAKE_INSTALL_DIR}/bin:$PATH
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 -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:
# curl --location "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz" -o cmake.tar.gz
# tar xzf cmake.tar.gz
# pushd cmake-${CMAKE_VERSION}
# CXX="ccache $CXX" ./bootstrap --parallel=${PARALLEL:=4} --enable-ccache
# CXX="ccache $CXX" timeout 2100 time make ${PAR_MAKEFAGS} || true
# export PATH=${CMAKE_INSTALL_DIR}/bin:$PWD/bin:$PATH
# popd
fi
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Utility script to download and build LLVM & clang
#
# 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
echo "Building LLVM"
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
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" ]] || [[ "$LLVM_VERSION" == "11.1.0" ]] || [[ "$LLVM_VERSION" == "12.0.0" ]] ; then
# 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
rm -f $LLVMTAR
echo "Installed ${LLVM_VERSION} in ${LLVM_INSTALL_DIR}"
mkdir -p $LLVM_INSTALL_DIR && true
mv clang+llvm*/* $LLVM_INSTALL_DIR
export LLVM_DIRECTORY=$LLVM_INSTALL_DIR
export PATH=${LLVM_INSTALL_DIR}/bin:$PATH
# ls -a $LLVM_DIRECTORY
fi
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Utility script to download and build OpenColorIO
# Exit the whole script if any command fails.
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}
# 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_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build}
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
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 \
-DOCIO_BUILD_DOCS=OFF -DOCIO_BUILD_TESTS=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}"
BASEDIR=`pwd`
pwd
echo "OpenColorIO install dir will be: ${OPENCOLORIO_INSTALL_DIR}"
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
fi
cd OpenColorIO
echo "git checkout ${OPENCOLORIO_VERSION} --force"
git checkout ${OPENCOLORIO_VERSION} --force
mkdir -p build
cd build
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS} ..
time cmake --build . --config Release --target install
popd
# ls -R ${OPENCOLORIO_INSTALL_DIR}
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export OpenColorIO_ROOT=$OPENCOLORIO_INSTALL_DIR
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENCOLORIO_INSTALL_DIR}/lib
+100 -32
View File
@@ -1,48 +1,116 @@
#!/bin/bash
#!/usr/bin/env bash
# The Linux VM used by Travis has OpenEXR 1.x. We really want 2.x.
# Utility script to download and build OpenEXR & IlmBase
#
# 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
# 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}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
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
EXRINSTALLDIR=${EXRINSTALLDIR:=${PWD}/openexr-install}
EXRVERSION=${EXRVERSION:=2.2.0}
BASEDIR=`pwd`
pwd
echo "EXR install dir will be: ${EXRINSTALLDIR}"
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 [ ! -e ${EXRINSTALLDIR} ] ; then
mkdir ${EXRINSTALLDIR}
if [[ "$CMAKE_GENERATOR" == "" ]] ; then
OPENEXR_GENERATOR_CMD="-G \"$CMAKE_GENERATOR\""
fi
# Clone OpenEXR project (including IlmBase) from GitHub and build
if [ ! -e ./openexr ] ; then
git clone -b v${EXRVERSION} https://github.com/openexr/openexr.git ./openexr
if [[ ! -e ${OPENEXR_SOURCE_DIR} ]] ; then
echo "git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}"
git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}
fi
flags=
mkdir -p ${OPENEXR_INSTALL_DIR} && true
mkdir -p ${OPENEXR_BUILD_DIR} && true
if [ ${LINKSTATIC:=0} == 1 ] ; then
flags=${flags} --enable-static --enable-shared=no --with-pic
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force
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 -DCMAKE_BUILD_TYPE=${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 -DCMAKE_BUILD_TYPE=${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 -DCMAKE_BUILD_TYPE=${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 -DCMAKE_BUILD_TYPE=${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 \
-DINSTALL_OPENEXR_EXAMPLES=0 \
-DOPENEXR_INSTALL_EXAMPLES=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
pushd ./openexr
git checkout v${EXRVERSION} --force
cd IlmBase
mkdir build
cd build
cmake --config Release -DCMAKE_INSTALL_PREFIX=${EXRINSTALLDIR} .. && make clean && make -j 4 && make install
cd ..
cd ../OpenEXR
cp ${BASEDIR}/src/build-scripts/OpenEXR-CMakeLists.txt CMakeLists.txt
cp ${BASEDIR}/src/build-scripts/OpenEXR-IlmImf-CMakeLists.txt IlmImf/CMakeLists.txt
mkdir build
mkdir build/IlmImf
cd build
unzip -d IlmImf ${BASEDIR}/src/build-scripts/b44ExpLogTable.h.zip
unzip -d IlmImf ${BASEDIR}/src/build-scripts/dwaLookups.h.zip
cmake --config Release -DCMAKE_INSTALL_PREFIX=${EXRINSTALLDIR} -DILMBASE_PACKAGE_PREFIX=${EXRINSTALLDIR} -DBUILD_UTILS=0 -DBUILD_TESTS=0 .. && make clean && make -j 4 && make install
popd
ls -R ${EXRINSTALLDIR}
#ls -R ${OPENEXR_INSTALL_DIR}
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export ILMBASE_ROOT=$OPENEXR_INSTALL_DIR
export OPENEXR_ROOT=$OPENEXR_INSTALL_DIR
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
+59 -9
View File
@@ -1,17 +1,67 @@
#!/bin/bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Install OpenImageIO
OIIOBRANCH=${OIIOBRANCH:=master}
OIIOINSTALLDIR=${OIIOINSTALLDIR:=${PWD}/OpenImageIO}
# Exit the whole script if any command fails.
set -ex
if [ ! -e $OIIOINSTALLDIR ] ; then
git clone https://github.com/OpenImageIO/oiio.git $OIIOINSTALLDIR
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=OpenImageIO/oiio}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=master}
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_INSTALLDIR=${OPENIMAGEIO_INSTALLDIR:=${LOCAL_DEPS_DIR}/dist}
OPENIMAGEIO_CMAKE_FLAGS=${OPENIMAGEIO_CMAKE_FLAGS:=""}
OPENIMAGEIO_BUILD_TYPE=${OPENIMAGEIO_BUILD_TYPE:=Release}
OPENIMAGEIO_CXXFLAGS=${OPENIMAGEIO_CXXFLAGS:=""}
BASEDIR=$PWD
CMAKE_GENERATOR=${CMAKE_GENERATOR:="Unix Makefiles"}
if [ ! -e $OPENIMAGEIO_SRCDIR ] ; then
git clone https://github.com/${OPENIMAGEIO_REPO} $OPENIMAGEIO_SRCDIR
fi
( cd $OIIOINSTALLDIR ; git fetch --all -p && git checkout $OIIOBRANCH --force ; make nuke )
( cd $OIIOINSTALLDIR ; make ${OIIOMAKEFLAGS} VERBOSE=1 cmakesetup )
( cd $OIIOINSTALLDIR ; make ${OIIOMAKEFLAGS} )
echo "OIIOINSTALLDIR $OIIOINSTALLDIR"
ls -R $OIIOINSTALLDIR/dist
mkdir -p ${OPENIMAGEIO_INSTALLDIR} && true
mkdir -p ${OPENIMAGEIO_BUILD_DIR} && true
pushd $OPENIMAGEIO_SRCDIR
git fetch --all -p
git checkout $OPENIMAGEIO_VERSION --force
if [[ "$USE_SIMD" != "" ]] ; then
OPENIMAGEIO_CMAKE_FLAGS="$OPENIMAGEIO_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
fi
if [[ "$DEBUG" == "1" ]] ; then
OPENIMAGEIO_CMAKE_FLAGS="$OPENIMAGEIO_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug"
fi
# if [[ "$ARCH" == "windows64" ]] ; then
pushd ${OPENIMAGEIO_BUILD_DIR}
cmake ../.. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="$OPENIMAGEIO_BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX="$OPENIMAGEIO_INSTALLDIR" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
-DCMAKE_INSTALL_LIBDIR="$OPENIMAGEIO_INSTALLDIR/lib" \
-DCMAKE_CXX_STANDARD="$CMAKE_CXX_STANDARD" \
$OPENIMAGEIO_CMAKE_FLAGS -DVERBOSE=1
echo "Parallel build $CMAKE_BUILD_PARALLEL_LEVEL"
time cmake --build . --target install --config ${OPENIMAGEIO_BUILD_TYPE}
popd
popd
export OpenImageIO_ROOT=$OPENIMAGEIO_INSTALLDIR
export PATH=$OpenImageIO_ROOT/bin:$PATH
export DYLD_LIBRARY_PATH=$OpenImageIO_ROOT/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$OpenImageIO_ROOT/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
echo "DYLD_LIBRARY_PATH = $DYLD_LIBRARY_PATH"
echo "LD_LIBRARY_PATH = $LD_LIBRARY_PATH"
echo "OpenImageIO_ROOT $OpenImageIO_ROOT"
# ls -R $OpenImageIO_ROOT
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Utility script to download and build pugixml
#
# 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
# 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}
# Where to put pugixml repo source (default to the ext area)
PUGIXML_SRC_DIR=${PUGIXML_SRC_DIR:=${PWD}/ext/pugixml}
# Temp build area (default to a build/ subdir under source)
PUGIXML_BUILD_DIR=${PUGIXML_BUILD_DIR:=${PUGIXML_SRC_DIR}/build}
# Install area for pugixml (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
PUGIXML_INSTALL_DIR=${PUGIXML_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
#PUGIXML_BUILD_OPTS=${PUGIXML_BUILD_OPTS:=}
pwd
echo "pugixml install dir will be: ${PUGIXML_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone pugixml project from GitHub and build
if [[ ! -e ${PUGIXML_SRC_DIR} ]] ; then
echo "git clone ${PUGIXML_REPO} ${PUGIXML_SRC_DIR}"
git clone ${PUGIXML_REPO} ${PUGIXML_SRC_DIR}
fi
cd ${PUGIXML_SRC_DIR}
echo "git checkout ${PUGIXML_VERSION} --force"
git checkout ${PUGIXML_VERSION} --force
mkdir -p ${PUGIXML_BUILD_DIR}
cd ${PUGIXML_BUILD_DIR}
time cmake -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
# ls -R ${PUGIXML_INSTALL_DIR}
popd
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export pugixml_ROOT=$PUGIXML_INSTALL_DIR
export LD_LIBRARY_PATH=$pugixml_ROOT/lib:$pugixml_ROOT/lib64:$LD_LIBRARY_PATH
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
# Utility script to download and build pybind11
#
# 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
# 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}
# Where to put pybind11 repo source (default to the ext area)
PYBIND11_SRC_DIR=${PYBIND11_SRC_DIR:=${PWD}/ext/pybind11}
# Temp build area (default to a build/ subdir under source)
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:=}
if [[ "${PYTHON_VERSION}" != "" ]] ; then
PYBIND11_BUILD_OPTS+=" -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION}"
fi
pwd
echo "pybind11 install dir will be: ${PYBIND11_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone pybind11 project from GitHub and build
if [[ ! -e ${PYBIND11_SRC_DIR} ]] ; then
echo "git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}"
git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}
fi
cd ${PYBIND11_SRC_DIR}
echo "git checkout ${PYBIND11_VERSION} --force"
git checkout ${PYBIND11_VERSION} --force
mkdir -p ${PYBIND11_BUILD_DIR}
cd ${PYBIND11_BUILD_DIR}
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
-DPYBIND11_TEST=OFF \
${PYBIND11_BUILD_OPTS} ..
time cmake --build . --config Release --target install
# ls -R ${PYBIND11_INSTALL_DIR}
popd
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export pybind11_ROOT=$PYBIND11_INSTALL_DIR
+43
View File
@@ -0,0 +1,43 @@
#!/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 -ex
if [[ "$USE_SIMD" != "" ]] ; then
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
fi
pushd build/$PLATFORM
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" \
-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}
popd
if [[ "${DEBUG_CI:=0}" != "0" ]] ; then
echo "PATH=$PATH"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
echo "PYTHONPATH=$PYTHONPATH"
echo "ldd testshade"
ldd $OSL_ROOT/bin/testshade
fi
if [[ "$BUILDTARGET" == clang-format ]] ; then
git diff --color
THEDIFF=`git diff`
if [[ "$THEDIFF" != "" ]] ; then
echo "git diff was not empty. Failing clang-format or clang-tidy check."
exit 1
fi
fi
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# This script is run when CI system first starts up.
# 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
exit -1
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}
export CCACHE_CPP2=1
export CCACHE_DIR=/tmp/ccache
if [[ "${RUNNER_OS}" == "macOS" ]] ; then
export CCACHE_DIR=$HOME/.ccache
fi
mkdir -p $CCACHE_DIR
export OSL_ROOT=$PWD/dist/$PLATFORM
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 USE_PYTHON=${USE_PYTHON:=1}
export PYTHON_VERSION=${PYTHON_VERSION:="2.7"}
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
export PYTHONPATH=/usr/local/lib64/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
export PYTHONPATH=$OSL_ROOT/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
export BUILD_MISSING_DEPS=${BUILD_MISSING_DEPS:=1}
export COMPILER=${COMPILER:=gcc}
export CXX=${CXX:=g++}
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
export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib64:$LD_LIBRARY_PATH
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
echo "HOME = $HOME"
echo "PWD = $PWD"
echo "LOCAL_DEPS_DIR = $LOCAL_DEPS_DIR"
echo "uname -a: " `uname -a`
echo "uname -m: " `uname -m`
echo "uname -s: " `uname -s`
echo "uname -n: " `uname -n`
pwd
ls
env | sort
if [[ `uname -s` == "Linux" ]] ; then
head -40 /proc/cpuinfo
elif [[ $ARCH == macosx ]] ; then
sysctl machdep.cpu.features
fi
# Save the env for use by other stages
src/build-scripts/save-env.bash
+22
View File
@@ -0,0 +1,22 @@
#!/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 -ex
$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}
popd
# if [[ "$CODECOV" == 1 ]] ; then
# bash <(curl -s https://codecov.io/bash)
# fi
+442
View File
@@ -0,0 +1,442 @@
#!/usr/bin/env python
from __future__ import print_function, absolute_import
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# ----------------------------------------------------------------------
# To generate docdeep for docdeep, run this:
# python3 docdeep.py -d docdeep docdeep.py > docdeep.md.html
# ----------------------------------------------------------------------
### <doc docdeep>
###
### **docdeep**
###
### Introduction
### ============
###
### `docdeep` is a utility that extracts documentation from source code and
### turns them into beautiful Markdeep documents.
###
### [Markdeep](https://casual-effects.com/markdeep) is a package by Morgan
### McGuire, an extension of Markdown with a whole bunch of nice features
### that make it extra nice for code, math, and diagrams. Read the Markdeep
### web page and look at the examples for details.
###
### `docdeep` is a little like `Doxygen`. A poor person's Doxygen. A very
### poor person. But without Doxygen's awkward syntax -- you just write
### the comments in Markdeep. And the output is very aesthetically pleasing.
### But it doesn't have any bells and whistles, like cross-referencing.
###
###
###
### Markup controls
### ===============
###
### ## Documentation lines.
###
### A line whose first three non-whitespace characters are either `///` or
### `###` is called a *doc-line*. Any other line is a *non-doc-line*.
###
### The `///` or `###` is the *doc-symbol*. Generally speaking, the `///`
### doc-symbol is used when doc-marking C or C++, and `###` when doc-marking
### Python, shell scripts, or other programs in languages where `#` is the
### comment character. For simplicity, in the rest of this document, we will
### always use `///` in our examples.
###
### ## Doc regions
###
### Doc-lines by themeslves don't do much, unless they are within a
### *doc-region*. The beginning of a doc-region is denoted by a doc-line
### whose first characters after the doc-symbol is
###
### <code>
### /// <doc region-name>
### </code>
###
### A doc region is ended one of three ways:
###
### 1. `&lt;/doc>` ends the active region.
### 2. `&lt;doc newname>` setting a new region name.
### 3. The end of the source file.
###
### When there is an active named region, any other doc lines will be
### appended (after stripping off the doc symbol itself) to the current
### doc region text.
###
### You can have multiple regions with the same name, in entirely separate
### parts of your source code. They will just be concatenated.
###
### 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.
###
### However, one doc-region may *include* the text of another doc-region
### as follows:
###
### <code>
### /// <inc region-name>
### </code>
###
### ## Doc continuations and code regions
###
### If three dots follow the `doc` directive, like this:
###
### <code>
### /// <doc... region-name>
### </code>
###
### This causes *all* lines (until the end of the doc region) to be
### interpreted as Markdeep documentation, even it if doesn't start with
### the doc-symbol.
###
### Furthermore, denoting any region thusly:
### <code>
### /// <code>
### ...
### /// </code>
### </code>
###
### will designate the contents not only as a doc continuation, but also
### to be formatted as source code (mono space, syntax highlighted).
###
### ## API Explanations
###
### There is a special syntax for a common case: call-by-call explanations
### of API methods and their explanations. Of course, this may constitute
### the bulk of your auto-generated documentation. The two cases we are
### concerned about is *pre-code comments* and *post-code comments*.
###
### 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
### 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.
###
### This is perhaps best explained by example:
###
### <code>
### ///> Do the foo operation. Everybody knows what this is. You can write
### /// any comment you want, with full markdeep formatting! It applies
### /// to the declaration that will immediately follow this comment.
### float foo (float x, float y);
###
### void bar (int n);
### ///< The bar procedure. Note that with post-comments, you explain the
### /// function or method *after* the declaration itself.
### </code>
###
### This will generate the following output:
###
### <code>
### float foo (float x, float y);
### </code>
### Do the foo operation. Everybody knows what this is. You can write
### any comment you want, with full markdeep formatting! It applies
### to the declaration that will immediately follow this comment.
###
### <code>
### void bar (int n);
### </code>
### The bar procedure. Note that with post-comments, you explain the
### function or method *after* the declaration itself.
###
### -----------------------
###
### It is important to keep in mind that **this API explanation is extremely
### stupid**. The comment documentation is just a series of doc-lines with
### no break between them, whose *first* line starts with `///>' or `///>`
### (for pre-code and post-code docs, respectively). And the code that it
### documents is just the immediately preceding or following set of non-doc
### lines that contain *no* whitespace-only lines. There is no syntax
### parsing going on here -- it just takes those non-blank, non-doc lines,
### strips off any semicolons and any characters following the semicolon
### from each line in the block, and deletes anything in the whole block
### at or after the first opening brace (`{`) found in the block. Strangely
### enough, this is almost exactly what I want to document.
###
###
### Command line arguments
### ======================
###
### Run from the command line as follows:
###
### `$ python docdeep.py -d` *region* `-s` *style.css* `input1.h input2.cpp [...] > output.md.html`
###
### Arguments:
###
### `-d` *region*
### : Specifies the name of the doc-region to generate output for. This is
### required.
### `-s` *stylesheet*
### : This optional argument will specify which CSS style sheet to include a
### reference to.
###
### Any number of filenames may be specified. They will be processed in the
### order that they appear on the command line.
###
import sys
import re
import argparse
# pattern for beginning of special comment
docline_pattern = re.compile ('(^[ \t]*)((///)|(###))[<>]?([ \t]|$)(.*)')
doc_begin_pattern = re.compile ('(^[ \t]*)((///)|(###))[ ]*<doc(\.\.\.)?[ ]*(\w*)[ ]*>')
docendpattern = re.compile ('(^[ \t]*)((///)|(###))[ ]*</doc>')
api_precomment_pattern = re.compile ('(^[ \t]*)((///)|(###))>( )+( )?(.*)')
api_postcomment_pattern = re.compile ('(^[ \t]*)((///)|(###))<( )+( )?(.*)')
inc_pattern = re.compile ('(^[ \t]*)<inc[ ]+([^>]+)>')
code_pattern = re.compile ('(^[ \t]*)((///)|(###))[ ]*<code>')
codeend_pattern = re.compile ('(^[ \t]*)((///)|(###))[ ]*</code>')
trimbrace_pattern = re.compile ("([^{]*)")
trimsemi_pattern = re.compile ("([^;]*)")
blankline_pattern = re.compile ("^[ \t]*$")
region_name = '_'
alldocs = { '_' : '' }
DEBUG = False
# Utility: blob is a string (possibly containing many "lines" separated by
# '\n'). For each line of text in the blob, shave off the first `indent`
# characters. Then reassemble and return.
def shave_each_line (blob, indent) :
r = ''
lines = blob.split ('\n')
for line in lines :
r += line[indent:] + '\n'
# strip trailing newline unless the original blob had a trailing newline
if len(r) and r[-1] == '\n' and blob[-1] != '\n':
r = r[:-1]
return r
# Enumerated type for the state machine.
class LineType :
BLANK = 0
DOC = 2
NONDOC = 3
# Append this doc blob to the current region, and clear the blob
def flush_doc_blob (doc_blob) :
global alldocs, region_name
if len(doc_blob) :
alldocs[region_name] += doc_blob + '\n'
doc_blob = ''
def read_input (filename, file) :
global region_name, alldocs
doc_cont_mode = False
post_api_mode = False
pre_api_mode = False
indent = 0 # Amount of indentation we saw on the liast doc line
lines = file.read().splitlines()
code_blob = '' # Running set of contiguous non-doc, non-blank lines
doc_blob = '' # Running set of contiguous doc lines
# state machine
line_type = LineType.BLANK
last_line_type = LineType.BLANK
for line in lines :
# Figure out what type of line we're on, and remember what type
# of line we saw last.
last_line_type = line_type
if blankline_pattern.match(line) :
line_type = LineType.BLANK
elif docline_pattern.match(line) :
line_type = LineType.DOC
else :
line_type = LineType.NONDOC
# print ('<!-- LINE----- ', line_type, line, ' -->\n')
# Not a doc line, but we're in "continuation mode": append
# (unindented) to the doc blob.
if line_type != LineType.DOC and doc_cont_mode :
doc_blob += line[indent:] + '\n'
if DEBUG :
alldocs[region_name] += '<!-- CONT ' + line[:35] + ' -->\n'
continue
# Blank line, not in continuation mode
if line_type == LineType.BLANK :
if DEBUG and last_line_type != LineType.BLANK :
alldocs[region_name] += '<!-- BLANK -->\n'
# FIXME: does this end a post-declaration API doc?
if pre_api_mode : # this blank ends a pre-api comment
continue # ...keep reading
# If this line ends a post-api comment, output the code blob
if post_api_mode :
if DEBUG :
alldocs[region_name] += ' <!-- blank ended post-api -->\n'
# Trim everything past the first ; or { from the code blob
alllines = code_blob.split('\n')
# code_blob = ''
new_code_blob = ''
for oneline in alllines :
m = trimsemi_pattern.search (oneline)
oneline = m.group(1)
new_code_blob += oneline + '\n'
new_code_blob = new_code_blob.rstrip(' \n\r')
m = trimbrace_pattern.match(new_code_blob)
alldocs[region_name] += ('~~~C\n' +
shave_each_line(m.group(1),indent) +
'\n~~~\n')
post_api_mode = False
# If this line ends a doc blob, output it
if len(doc_blob) :
alldocs[region_name] += doc_blob + '\n'
doc_blob = ''
# Blank lines clear the code blob
code_blob = ''
continue
# Non-blank, non-doc line: append to code blob and move on.
if line_type == LineType.NONDOC :
if DEBUG :
alldocs[region_name] += '<!-- NONDOC ' + line[:35] + ' -->\n'
code_blob += line + '\n'
continue
# Remaining cases are all doc lines!
# Any doc line resets the pre-doc-symbol indentation level
m = docline_pattern.match(line)
indent = len(m.group(1))
# Handle <doc> and <doc...> : start of new doc section
m = doc_begin_pattern.match(line)
if m :
flush_doc_blob (doc_blob)
doc_blob = ''
# If it led with <doc...> it also starts continuation mode
doc_cont_mode = (m.group(5) == '...')
# The <doc> directive gave the region name.
r = m.group(6)
r.strip()
if r == '' :
r = '_'
if DEBUG :
alldocs[region_name] += '<!-- DOCBEGIN ' + r + ' -->\n'
region_name = r
if not (region_name in alldocs) :
alldocs[region_name] = ''
continue
#
# Handle </doc>
m = docendpattern.match(line)
if m :
if DEBUG :
alldocs[region_name] += '<!-- DOCEND ' + region_name + '-->\n'
flush_doc_blob (doc_blob)
doc_blob = ''
doc_cont_mode = False
region_name = '_'
continue
#
# Handle start of post-declaration API comment
m = api_postcomment_pattern.match(line)
if m :
if DEBUG :
alldocs[region_name] += '<!-- start post-decl api ' + line[:35] + '-->\n'
flush_doc_blob (doc_blob)
doc_blob = ''
# Deduce indentation level
indent = len(m.group(1))
post_api_mode = True
remainder = m.group(7)
doc_blob += remainder + '\n'
continue
#
# Handle start of pre-declaration API comment
m = api_precomment_pattern.match(line)
if m :
flush_doc_blob (doc_blob)
doc_blob = ''
indent = len(m.group(1))
post_api_mode = True
remainder = m.group(7)
doc_blob += remainder + '\n'
continue
#
# Handle code section <code> ... </code>
m = code_pattern.match(line)
if m :
flush_doc_blob (doc_blob)
doc_blob = ''
if DEBUG :
doc_blob += '<!-- start code in '+ region_name+ '-->\n'
indent = len(m.group(1))
doc_blob += '<script type="preformatted">\n~~~C\n'
doc_cont_mode = True
continue
if codeend_pattern.match(line) :
doc_cont_mode = False
doc_blob += '~~~\n</script>\n'
if DEBUG :
doc_blob += '<!-- end code in '+ region_name+ '-->\n'
flush_doc_blob (doc_blob)
doc_blob = ''
continue
#
# Last case: just a continuing doc line
m = docline_pattern.match (line)
if m :
if DEBUG :
alldocs[region_name] += '<!-- doc cont ' + line[:35] + ' -->\n'
contents = m.group(6)
doc_blob += contents + '\n'
continue
print ('<!-- REMAINING CASE:', line, '-->\n')
flush_doc_blob (doc_blob)
region_name = '_'
def output_blob (blob) :
for line in blob.splitlines() :
m = inc_pattern.match (line)
if m and (m.group(2) in alldocs) :
# print ('Want to include', m.group(2))
output_blob (alldocs[m.group(2)])
else :
print (line)
parser = argparse.ArgumentParser (prog='docdeep',
description='Turn source comments into markdeep document')
parser.add_argument ('-d', dest='docname', default='main',
help='Name of documentation (default: "main")')
parser.add_argument ('-s', dest='stylesheet', default='',
help='Name of style sheet (default: "")')
parser.add_argument ('--debug', dest='DEBUG', action='store_const',
const=True, default=False)
parser.add_argument ('filenames', nargs='+')
# parser.add_argument ('-o', dest='output_filename', nargs=1,
# help='Output filename (default: stdout)')
args = parser.parse_args()
DEBUG = args.DEBUG
for filename in args.filenames :
with open(filename) as file:
read_input (filename, file)
print ('<meta charset="utf-8">\n')
if args.docname in alldocs :
output_blob (alldocs[args.docname])
else :
print ("Ick! could not find docs for", args.docname)
print ('<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js"></script><script src="https://casual-effects.com/markdeep/latest/markdeep.min.js?"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>')
if args.stylesheet :
print ('<link rel="stylesheet" href="{}">'.format (args.stylesheet))
+116
View File
@@ -0,0 +1,116 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
set -ex
#
# Install system packages when those are acceptable for dependencies.
#
if [[ "$ASWF_ORG" != "" ]] ; then
# Using ASWF CentOS 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
else
# Using native Ubuntu runner
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 \
libilmbase-dev libopenexr-dev \
python-dev python-numpy \
libtiff-dev libgif-dev libpng-dev \
flex bison libbison-dev \
libpugixml-dev \
libopencolorio-dev \
qt5-default
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
time sudo apt-get install -y g++-6
elif [[ "$CXX" == "g++-7" ]] ; then
time sudo apt-get install -y g++-7
elif [[ "$CXX" == "g++-8" ]] ; then
time sudo apt-get install -y g++-8
elif [[ "$CXX" == "g++-9" ]] ; then
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
fi
source src/build-scripts/build_llvm.bash
fi
if [[ "$OPTIX_VERSION" != "" ]] ; then
echo "Requested OPTIX_VERSION = '${OPTIX_VERSION}'"
mkdir -p $LOCAL_DEPS_DIR/dist/include/internal
OPTIXLOC=https://developer.download.nvidia.com/redist/optix/v${OPTIX_VERSION}
for f in optix.h optix_device.h optix_function_table.h \
optix_function_table_definition.h optix_host.h \
optix_stack_size.h optix_stubs.h optix_types.h optix_7_device.h \
optix_7_host.h optix_7_types.h \
internal/optix_7_device_impl.h \
internal/optix_7_device_impl_exception.h \
internal/optix_7_device_impl_transformations.h
do
curl --retry 100 -m 120 --connect-timeout 30 \
$OPTIXLOC/include/$f > $LOCAL_DEPS_DIR/dist/include/$f
done
export OptiX_ROOT=$LOCAL_DEPS_DIR/dist
fi
source src/build-scripts/build_pybind11.bash
if [[ "$OPENEXR_VERSION" != "" ]] ; then
source src/build-scripts/build_openexr.bash
fi
# if [[ "$PUGIXML_VERSION" != "" ]] ; then
source src/build-scripts/build_pugixml.bash
export MY_CMAKE_FLAGS+=" -DUSE_EXTERNAL_PUGIXML=1 "
# 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
export ENABLE_iinfo=0 ENABLE_iv=0 ENABLE_igrep=0
export ENABLE_iconvert=0 ENABLE_testtex=0
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_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0"
source src/build-scripts/build_openimageio.bash
fi
# Save the env for use by other stages
src/build-scripts/save-env.bash
+157
View File
@@ -0,0 +1,157 @@
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# DEP_DIR="$PWD/ext/dist"
DEP_DIR="$PWD/dist/$PLATFORM"
mkdir -p "$DEP_DIR"
INT_DIR="build/$PLATFORM"
VCPKG_INSTALLATION_ROOT=/c/vcpkg
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:=.}
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$DEP_DIR"
export BOOST_ROOT=${BOOST_ROOT_1_72_0}
BOOST_UNIX_PATH=$(echo "/$BOOST_ROOT" | sed -e 's/\\/\//g' -e 's/://')
echo "BOOST_UNIX_PATH=$BOOST_UNIX_PATH"
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$BOOST_ROOT"
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
export PATH="$PATH:$DEP_DIR/bin:$DEP_DIR/lib:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin:/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/lib:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# export OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
# export OPENEXR_CMAKE_FLAGS="$OPENEXR_CMAKE_FLAGS -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
#ls -l "C:/Program Files (x86)/Microsoft Visual Studio/*/Enterprise/VC/Tools/MSVC" && true
#ls -l "C:/Program Files (x86)/Microsoft Visual Studio" && true
if [[ "$PYTHON_VERSION" == "3.6" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.6.8/x64"
else
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.7.9/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.7.9/x64/python.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
fi
pip install numpy
########################################################################
# Dependency method #1: Use vcpkg (disabled)
#
# Currently we are not using this, but here it is for reference:
#
echo "All pre-installed VCPkg installs:"
vcpkg list
echo "---------------"
# vcpkg update
#
# # vcpkg install zlib:x64-windows
vcpkg install tiff:x64-windows
vcpkg install libpng:x64-windows
#vcpkg install giflib:x64-windows
#vcpkg install freetype:x64-windows
# vcpkg install openexr:x64-windows
# vcpkg install libjpeg-turbo:x64-windows
# vcpkg install libraw:x64-windows
# vcpkg install openjpeg:x64-windows
# vcpkg install ffmpeg:x64-windows # takes FOREVER!
# vcpkg install webp:x64-windows # No such vcpkg package?a
# echo "$VCPKG_INSTALLATION_ROOT"
# ls "$VCPKG_INSTALLATION_ROOT"
# echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
# ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
# echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
# ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
echo "All VCPkg installs:"
vcpkg list
#
########################################################################
########################################################################
# Dependency method #2: Build from source ourselves
#
#
src/build-scripts/build_zlib.bash
export ZLIB_ROOT=$PWD/ext/dist
src/build-scripts/build_libpng.bash
export PNG_ROOT=$PWD/ext/dist
# We're currently getting libtiff from vcpkg
#src/build-scripts/build_libtiff.bash
#export TIFF_ROOT=$PWD/ext/dist
# We're currently getting jpeg from vcpkg
# LIBJPEGTURBO_CONFIG_OPTS=-DWITH_SIMD=OFF
# # ^^ because we're too lazy to build nasm
# src/build-scripts/build_libjpeg-turbo.bash
# export JPEGTurbo_ROOT=$PWD/ext/dist
source src/build-scripts/build_pybind11.bash
#export pybind11_ROOT=$PWD/ext/dist
# curl --location https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.1-win64-dev.zip -o ffmpeg-dev.zip
# unzip ffmpeg-dev.zip
# FFmpeg_ROOT=$PWD/ffmpeg-4.2.1-win64-dev
echo "CMAKE_PREFIX_PATH = $CMAKE_PREFIX_PATH"
OPENEXR_CXX_FLAGS=" /W1 /EHsc /DWIN32=1 "
#OPENEXR_BUILD_TYPE=$CMAKE_BUILD_TYPE
OPENEXR_INSTALL_DIR=$DEP_DIR
source src/build-scripts/build_openexr.bash
export PATH="$OPENEXR_INSTALL_DIR/bin:$OPENEXR_INSTALL_DIR/lib:$PATH"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PATH
# the above line is admittedly sketchy
cp $DEP_DIR/lib/*.lib $DEP_DIR/bin
cp $DEP_DIR/bin/*.dll $DEP_DIR/lib
#OPENIMAGEIO_BRANCH=lg-cmake312
OPENIMAGEIO_INSTALLDIR=$DEP_DIR
OPENIMAGEIO_CMAKE_FLAGS+=" -DOIIO_BUILD_TESTS=0 -DOIIO_BUILD_TOOLS=0"
OPENIMAGEIO_CMAKE_FLAGS+=" -DUSE_OPENGL=0 -DUSE_GENERATED_EXPORT_HEADER=1"
OPENIMAGEIO_CMAKE_FLAGS+=" -DENABLE_DPX=0 -DENABLE_CINEON=0 -DENABLE_DDS=0"
OPENIMAGEIO_CMAKE_FLAGS+=" -DENABLE_IFF=0 -DENABLE_ICO=0 -DENABLE_PSD=0"
OPENIMAGEIO_CMAKE_FLAGS+=" -DENABLE_PNM=0 -DENABLE_ZFILE=0 -DENABLE_SOFTIMAGE=0"
OPENIMAGEIO_CMAKE_FLAGS+=" -DLINKSTATIC=1 -DBUILD_SHARED_LIBS=0"
export OPENIMAGEIO_CMAKE_FLAGS
source src/build-scripts/build_openimageio.bash
cp $DEP_DIR/lib/*.lib $DEP_DIR/bin
cp $DEP_DIR/bin/*.dll $DEP_DIR/lib
echo "after OIIO install, DEP_DIR $DEP_DIR :"
ls -R -l "$DEP_DIR"
# export PATH="$PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
export PATH="$DEP_DIR/lib:$DEP_DIR/bin:$PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib:$DEP_DIR/lib:$DEP_DIR/bin"
# source src/build-scripts/build_openexr.bash
# export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$ILMBASE_ROOT;$OPENEXR_ROOT"
# source src/build-scripts/build_opencolorio.bash
# For CI on Windows, prefer to pick up static libs where possible
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DLINKSTATIC=1 -DBUILD_SHARED_LIBS=0"
# Save the env for use by other stages
src/build-scripts/save-env.bash
+4
View File
@@ -0,0 +1,4 @@
{
global: *OSL*; test_shade; *osl*imageio*; *osl_input_extensions;
local: osl_*; *pvt*; *;
};
+47 -14
View File
@@ -1,33 +1,66 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# This script, which assumes it is runnign on a Mac OSX with Homebrew
# installed, does a "brew install" in all packages reasonably needed by
# OIIO.
# OSL and its dependencies.
if [ `uname` != "Darwin" ] ; then
if [[ `uname` != "Darwin" ]] ; then
echo "Don't run this script unless you are on Mac OSX"
exit 1
fi
if [ `which brew` == "" ] ; then
if [[ `which brew` == "" ]] ; then
echo "You need to install Homebrew before running this script."
echo "See http://brew.sh"
exit 1
fi
brew update >/dev/null
#brew update >/dev/null
echo ""
echo "Before my brew installs:"
brew list --versions
brew install ccache
brew install flex bison
brew install ilmbase openexr
brew install boost-python
brew install opencolorio partio
brew install freetype libraw libpng webp
brew install llvm34
#brew install homebrew/science/hdf5 --with-threadsafe
#brew install field3d webp ffmpeg openjpeg opencv
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 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 install --display-times -q pybind11 numpy || true
brew install --display-times -q tbb || true
brew install --display-times -q flex bison
brew install --display-times -q llvm${LLVMBREWVER}
brew install --display-times -q qt
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
# 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
# Save the env for use by other stages
src/build-scripts/save-env.bash
+5
View File
@@ -0,0 +1,5 @@
leak:Imf_2_2
leak:Imf_2_3
leak:Imf_2_4
leak:libIlmImf
leak:oslgram.y
+11
View File
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include
Name: oslcomp
Description: oslcomp Compile OSL shaders from source
URL: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
Libs: -L${libdir} -loslcomp
Cflags: -I${includedir}
+11
View File
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include
Name: oslexec
Description: oslexec Execute compiled OSL shaders
URL: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
Libs: -L${libdir} -loslexec
Cflags: -I${includedir}
+11
View File
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include
Name: oslquery
Description: oslquery Query parameters of OSL compiled shaders
URL: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
Libs: -L${libdir} -loslquery
Cflags: -I${includedir}
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Save the env for use by other stages. Exclude things that we know aren't
# needed.
printenv \
| sort \
| grep -v ASWF_ \
| grep -v GITHUB_ \
| grep -v NVIDIA_ \
| grep -v RUNNER_ \
| grep -v _= \
| fgrep -v "\*" \
>> $GITHUB_ENV
echo "save-env: GITHUB_ENV=${GITHUB_ENV}"
cat $GITHUB_ENV
echo "---------"
+31
View File
@@ -0,0 +1,31 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
# add here all the find_dependency() whenever switching to config based dependencies
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 3.0)
find_dependency(Imath @OpenEXR_VERSION@)
elseif (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.4 AND @FOUND_OPENEXR_WITH_CONFIG@)
find_dependency(IlmBase @OpenEXR_VERSION@)
find_dependency(OpenEXR @OpenEXR_VERSION@)
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@")
#...logic to determine installedPrefix from the own location...
#set (@PROJECT_NAME@_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@")
include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components ("@PROJECT_NAME@")
+28
View File
@@ -0,0 +1,28 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# 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
# ENABLE_PKGNAME) exists as either a CMake or environment variable, is
# nonempty by contains a non-true/nonzero value, store false in the
# variable named by <enablevar>, otherwise store true.
function (check_is_enabled pkgname enablevar)
string (TOUPPER ${pkgname} pkgname_upper)
set (${enablevar} true PARENT_SCOPE)
if (
(NOT "${USE_${pkgname}}" STREQUAL "" AND NOT "${USE_${pkgname}}") OR
(NOT "${USE_${pkgname_upper}}" STREQUAL "" AND NOT "${USE_${pkgname_upper}}") OR
(NOT "$ENV{USE_${pkgname}}" STREQUAL "" AND NOT "$ENV{USE_${pkgname}}") OR
(NOT "$ENV{USE_${pkgname_upper}}" STREQUAL "" AND NOT "$ENV{USE_${pkgname_upper}}") OR
(NOT "${ENABLE_${pkgname}}" STREQUAL "" AND NOT "${ENABLE_${pkgname}}") OR
(NOT "${ENABLE_${pkgname_upper}}" STREQUAL "" AND NOT "${ENABLE_${pkgname_upper}}") OR
(NOT "$ENV{ENABLE_${pkgname}}" STREQUAL "" AND NOT "$ENV{ENABLE_${pkgname}}") OR
(NOT "$ENV{ENABLE_${pkgname_upper}}" STREQUAL "" AND NOT "$ENV{ENABLE_${pkgname_upper}}") OR
(DISABLE_${pkgname} OR DISABLE_${pkgname_upper} OR
"$ENV{DISABLE_${pkgname}}" OR "$ENV{DISABLE_${pkgname_upper}}") OR
(NOT "${_pkg_ENABLE}" STREQUAL "" AND NOT "${_pkg_ENABLE}")
)
set (${enablevar} false PARENT_SCOPE)
endif ()
endfunction ()
+157
View File
@@ -0,0 +1,157 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
set (REQUIED_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)")
# checked_find_package(Pkgname ...) is a wrapper for find_package, with the
# following extra features:
# * If either `USE_Pkgname` or the all-uppercase `USE_PKGNAME` (or
# `ENABLE_Pkgname` or `ENABLE_PKGNAME`) exists as either a CMake or
# environment variable, is nonempty by contains a non-true/nonzero
# value, do not search for or use the package. The optional ENABLE <var>
# arguments allow you to override the name of the enabling variable. In
# other words, support for the dependency is presumed to be ON, unless
# 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
# package is 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
# dep_FOUND is not true, disable this package with an error message.
# * Optional ISDEPOF <downstream> names another package for which the
# present package is only needed because it's a dependency, and
# therefore if <downstream> is disabled, we don't bother with this
# package either.
# * Optional VERSION_MIN and VERSION_MAX, if supplied, give minimum and
# maximum versions that will be accepted. The min is inclusive, the max
# is exclusive (i.e., check for min <= version < max). Note that this is
# not the same as providing a version number to find_package, which
# checks compatibility, not minimum. Sometimes we really do just want to
# say a minimum or a range. (N.B. When our minimum CMake >= 3.19, the
# built-in way to do this is with version ranges passed to
# find_package.)
# * Optional RECOMMEND_MIN, if supplied, gives a minimum recommended
# 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.
#
# 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,
# not merely the scope for this function.
macro (checked_find_package pkgname)
cmake_parse_arguments(_pkg # prefix
# noValueKeywords:
"REQUIRED"
# singleValueKeywords:
"ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON"
# multiValueKeywords:
"DEFINITIONS;PRINT;DEPS"
# argsToParse:
${ARGN})
string (TOLOWER ${pkgname} pkgname_lower)
string (TOUPPER ${pkgname} pkgname_upper)
if (NOT VERBOSE)
set (${pkgname}_FIND_QUIETLY true)
set (${pkgname_upper}_FIND_QUIETLY true)
endif ()
if ("${pkgname}" IN_LIST REQUIRED_DEPS OR "ALL" IN_LIST REQUIRED_DEPS)
set (_pkg_REQUIRED 1)
endif ()
if ("${pkgname}" IN_LIST OPTIONAL_DEPS OR "ALL" IN_LIST OPTIONAL_DEPS)
set (_pkg_REQUIRED 0)
endif ()
set (_quietskip false)
check_is_enabled (${pkgname} _enable)
set (_disablereason "")
foreach (_dep ${_pkg_DEPS})
if (_enable AND NOT ${_dep}_FOUND)
set (_enable false)
set (ENABLE_${pkgname} OFF PARENT_SCOPE)
set (_disablereason "(because ${_dep} was not found)")
endif ()
endforeach ()
if (_pkg_ISDEPOF)
check_is_enabled (${_pkg_ISDEPOF} _dep_enabled)
if (NOT _dep_enabled)
set (_enable false)
set (_quietskip true)
endif ()
endif ()
if (_enable OR _pkg_REQUIRED)
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
AND ${pkgname}_VERSION
AND (_pkg_VERSION_MIN OR _pkg_VERSION_MAX))
if ((_pkg_VERSION_MIN AND ${pkgname}_VERSION VERSION_LESS _pkg_VERSION_MIN)
OR (_pkg_VERSION_MAX AND ${pkgname}_VERSION VERSION_GREATER _pkg_VERSION_MAX))
message (STATUS "${ColorRed}${pkgname} ${${pkgname}_VERSION} is outside the required range ${_pkg_VERSION_MIN}...${_pkg_VERSION_MAX} ${ColorReset}")
unset (${pkgname}_FOUND)
unset (${pkgname}_VERSION)
unset (${pkgname_upper}_FOUND)
unset (${pkgname_upper}_VERSION)
endif ()
endif ()
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
foreach (_vervar ${pkgname_upper}_VERSION ${pkgname}_VERSION_STRING
${pkgname_upper}_VERSION_STRING)
if (NOT ${pkgname}_VERSION AND ${_vervar})
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 ()
add_definitions (${_pkg_DEFINITIONS})
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}")
endif ()
endif ()
else ()
message (STATUS "${ColorRed}${pkgname} library not found ${ColorReset}")
if (${pkgname}_ROOT)
message (STATUS "${ColorRed} ${pkgname}_ROOT was: ${${pkgname}_ROOT} ${ColorReset}")
elseif ($ENV{${pkgname}_ROOT})
message (STATUS "${ColorRed} ENV ${pkgname}_ROOT was: ${${pkgname}_ROOT} ${ColorReset}")
else ()
message (STATUS "${ColorRed} Try setting ${pkgname}_ROOT ? ${ColorReset}")
endif ()
if (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname}.bash")
message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_${pkgname}.bash ${ColorReset}")
elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname_upper}.bash")
message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_${pkgname_upper}.bash ${ColorReset}")
elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_${pkgname_lower}.bash")
message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_${pkgname_lower}.bash ${ColorReset}")
elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/build-scripts/build_lib${pkgname_lower}.bash")
message (STATUS "${ColorRed} Maybe this will help: src/build-scripts/build_lib${pkgname_lower}.bash ${ColorReset}")
endif ()
if (_pkg_REQUIRED)
message (FATAL_ERROR "${ColorRed}${pkgname} is required, aborting.${ColorReset}")
endif ()
endif()
else ()
if (NOT _quietskip)
message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}")
endif ()
endif ()
endmacro()
+12
View File
@@ -0,0 +1,12 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Define color codes for pretty terminal output
string (ASCII 27 ColorEsc)
set (ColorReset "${ColorEsc}[m")
set (ColorRed "${ColorEsc}[31m")
set (ColorGreen "${ColorEsc}[32m")
set (ColorYellow "${ColorEsc}[33m")
set (ColorBoldWhite "${ColorEsc}[1;37m")
+619
View File
@@ -0,0 +1,619 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
###########################################################################
#
# This file contains compiler-related detection, options, and actions.
#
# Each option declaration is kept close to the related logic for that
# option.
#
###########################################################################
###########################################################################
# 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}")
###########################################################################
# C++ language standard
#
set (CMAKE_CXX_STANDARD 11 CACHE STRING
"C++ standard to prefer (11, 14, 17, 20, etc.)")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
message (STATUS "Building for C++${CMAKE_CXX_STANDARD}")
###########################################################################
# Figure out which compiler we're using
#
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 ()
else ()
set (GCC_VERSION 0)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang")
# 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
# CLANG_VERSION_STRING.
set (CMAKE_COMPILER_IS_CLANG 1)
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
if (clang_full_version_string MATCHES "Apple")
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 ()
else ()
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 ()
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set (CMAKE_COMPILER_IS_INTEL 1)
if (VERBOSE)
message (STATUS "Using Intel as the compiler")
endif ()
endif ()
###########################################################################
# Turn on more detailed warnings and optionally consider warnings as errors
#
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" OFF)
else ()
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
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{${PROJECT_NAME}_CI})
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 ()
###########################################################################
# Control symbol visibility
#
# We try hard to make default symbol visibility be "hidden", except for
# symbols that are part of the public API, which should be marked in the
# source code with a special decorator, OSL_API.
#
# Additionally, there is a hidesymbols.map file that on some platforms may
# 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")
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
(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
# to prevent clashes if an app using this project is linked against
# other versions of our dependencies.
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${VISIBILITY_MAP_FILE}")
endif ()
###########################################################################
# Compiler-specific and platform-specific options.
#
# Here is where we add a whole bunch of options for specific compilers or
# platforms. Usually this is to suppress false-positive compiler warnings.
#
if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
# Clang-specific options
add_compile_options ("-Wno-unused-function")
add_compile_options ("-Wno-overloaded-virtual")
add_compile_options ("-Wno-unneeded-internal-declaration")
add_compile_options ("-Wno-unused-private-field")
add_compile_options ("-Wno-tautological-compare")
add_compile_options ("-Wno-unknown-pragmas")
# disable warning about unused command line arguments
add_compile_options ("-Qunused-arguments")
# Don't warn if we ask it not to warn about warnings it doesn't know
add_compile_options ("-Wunknown-warning-option")
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.6 OR
APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
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
add_compile_options ("-Wno-expansion-to-defined")
endif ()
# disable warning in flex-generated code
add_compile_options ("-Wno-null-conversion")
add_compile_options ("-Wno-error=strict-overflow")
if ($<CONFIG:Debug>)
add_compile_options ("-Wno-unused-function -Wno-unused-variable")
endif ()
endif ()
if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG))
add_compile_options ("-Wno-error=strict-overflow")
add_compile_options ("-Wno-unused-local-typedefs")
add_compile_options ("-Wno-unused-result")
if (NOT ${GCC_VERSION} VERSION_LESS 6.0)
add_compile_options ("-Wno-error=misleading-indentation")
endif ()
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
# Options common to gcc and clang
# Ensure this macro is set for stdint.h
add_definitions ("-D__STDC_LIMIT_MACROS")
add_definitions ("-D__STDC_CONSTANT_MACROS")
# this allows native instructions to be used for sqrtf instead of a function call
add_compile_options ("-fno-math-errno")
endif ()
if (MSVC)
# Microsoft specific options
add_compile_options (/W1)
add_definitions (-D_CRT_SECURE_NO_DEPRECATE)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
add_definitions (-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions (-D_SCL_SECURE_NO_WARNINGS)
add_definitions (-DJAS_WIN_MSVC_BUILD)
endif (MSVC)
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
# For FreeBSD, minimum arch of i586 is needed for atomic cpu instructions
add_compile_options (-march=i586)
endif ()
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}")
endif ()
###########################################################################
# Use ccache if found
#
# This can really speed up compilation by caching object files that have
# been compiled previously with identical arguments and inputs. Putting this
# logic here makes it work even if the user is unaware of ccache. If it's
# not found on the system, it will simply be silently not used.
option (USE_CCACHE "Use ccache if found" ON)
find_program (CCACHE_FOUND ccache)
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 (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
# compiler. Maybe it would also work for g++? Investigate.
option (USE_LIBCPLUSPLUS "Compile with clang libc++" OFF)
if (USE_LIBCPLUSPLUS AND CMAKE_COMPILER_IS_CLANG)
message (STATUS "Using libc++")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
###########################################################################
# For gcc >= 5, allow an option to force which version of the C++ ABI to
# use (mostly this affects the implementation of std::string).
#
# FIXME: In theory, this should also be needed for clang, if compiling with
# the gcc libstdc++ toolchain. In practice, I could not get things to build
# with clang properly when using this option, and I haven't yet seen a case
# where it's needed. We can return to this and fix for clang if it becomes a
# legit problem later.
#
set (GLIBCXX_USE_CXX11_ABI "" CACHE STRING "For gcc, use the new C++11 library ABI (0|1)")
if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 5.0)
if (NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "")
add_definitions ("-D_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}")
endif ()
endif ()
###########################################################################
# SIMD and machine architecture options.
#
# The USE_SIMD option may be set to a comma-separated list of machine /
# instruction set options, such as "avx3,f16c". The list will be parsed and
# the proper compiler directives added to generate code for those ISA
# capabilities.
#
set (USE_SIMD "" CACHE STRING "Use SIMD directives (0, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512f, f16c, aes)")
set (SIMD_COMPILE_FLAGS "")
if (NOT USE_SIMD STREQUAL "")
message (STATUS "Compiling with SIMD level ${USE_SIMD}")
if (USE_SIMD STREQUAL "0")
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-DOIIO_NO_SSE=1")
else ()
string (REPLACE "," ";" SIMD_FEATURE_LIST ${USE_SIMD})
foreach (feature ${SIMD_FEATURE_LIST})
if (VERBOSE)
message (STATUS "SIMD feature: ${feature}")
endif ()
if (MSVC OR CMAKE_COMPILER_IS_INTEL)
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "/arch:${feature}")
else ()
set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-m${feature}")
endif ()
if (feature STREQUAL "fma" AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
# If fma is requested, for numerical accuracy sake, turn it
# off by default except when we explicitly use madd. At some
# future time, we should look at this again carefully and
# see if we want to use it more widely by ffp-contract=fast.
add_compile_options ("-ffp-contract=off")
endif ()
endforeach()
endif ()
add_compile_options (${SIMD_COMPILE_FLAGS})
endif ()
###########################################################################
# Preparation to test for compiler/language features
if (NOT VERBOSE)
set (CMAKE_REQUIRED_QUIET 1)
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
#
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_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")
endif ()
###########################################################################
# Sanitizer options
#
set (SANITIZE "" CACHE STRING "Build code using sanitizer (address, thread)")
if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
message (STATUS "Compiling for sanitizer=${SANITIZE}")
string (REPLACE "," ";" SANITIZE_FEATURE_LIST ${SANITIZE})
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}")
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")
endif ()
add_definitions ("-D${PROJECT_NAME}_SANITIZE=1")
endif ()
###########################################################################
# clang-tidy options
#
# clang-tidy is a static analyzer that is part of the LLVM tools. It has a
# variety of the usual bug and security tests, linting, and also tests for
# things like finding (and correcting!) use of older language constructs.
#
# If clang-tidy is found and enabled, a "clang-tidy" build target will be
# enabled. The set of tests can be customized both here and through
# the .clang-tidy file that is part of this project.
#
option (CLANG_TIDY "Enable clang-tidy" OFF)
set (CLANG_TIDY_CHECKS "-*" CACHE STRING "clang-tidy checks to perform (none='-*')")
set (CLANG_TIDY_ARGS "" CACHE STRING "clang-tidy args")
option (CLANG_TIDY_FIX "Have clang-tidy fix source" OFF)
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)
set (CMAKE_CXX_CLANG_TIDY
"${CLANG_TIDY_EXE}"
)
if (CLANG_TIDY_ARGS)
list (APPEND CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_ARGS})
endif ()
if (CLANG_TIDY_CHECKS)
list (APPEND CMAKE_CXX_CLANG_TIDY -checks="${CLANG_TIDY_CHECKS}")
endif ()
set (CMAKE_CXX_CLANG_TIDY "-header-filter=(${PROJECT_NAME})|(${PROJ_NAME})|(${PROJ_NAME_LOWER})|(_pvt.h)")
execute_process (COMMAND ${CMAKE_CXX_CLANG_TIDY} -list-checks
OUTPUT_VARIABLE tidy_checks
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CLANG_TIDY_FIX)
list (APPEND CMAKE_CXX_CLANG_TIDY "-fix")
endif ()
message (STATUS "clang-tidy command line is: ${CMAKE_CXX_CLANG_TIDY}")
message (STATUS "${tidy_checks}")
else ()
message (STATUS "Cannot run clang-tidy as requested")
endif ()
# Hint: run with CLANG_TIDY_ARGS=-list-checks to list all the checks
endif ()
###########################################################################
# clang-format options
#
# clang-format is a source code reformatter that is part of the LLVM tools.
# It can be used to check adherence to project code formatting rules and
# correct any deviations. If clang-format is found on the system, a
# "clang-format" build target will trigger a reformatting.
#
# 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/*.h" "src/*.cpp"
"src/include/*.h"
"src/liboslcomp/*.cpp"
"src/liboslcomp/*.h"
"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.")
endif ()
endif ()
###########################################################################
# Another way to sneak in custom compiler and DSO linking flags.
#
set (EXTRA_CPP_ARGS "" CACHE STRING "Extra C++ command line definitions")
if (EXTRA_CPP_ARGS)
message (STATUS "Extra C++ args: ${EXTRA_CPP_ARGS}")
add_compile_options ("${EXTRA_CPP_ARGS}")
endif()
set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when building DSOs")
###########################################################################
# Set the versioning for shared libraries.
#
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
# Supported releases guarantee ABI back-compatibility within the release
# family, so SO versioning is major.minor.
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
CACHE STRING "Set the SO version for dynamic libraries")
else ()
# Development master makes no ABI stability guarantee, so we make the
# SO naming capture down to the major.minor.patch level.
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 ()
###########################################################################
# BUILD_SHARED_LIBS, if turned off, will disable building of .so/.dll
# dynamic libraries and instead only build static libraries.
#
option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON)
if (NOT BUILD_SHARED_LIBS)
add_definitions (-D${PROJECT_NAME}_STATIC_DEFINE=1)
endif ()
###########################################################################
# LINKSTATIC, if enabled, will cause us to favor linking static versions
# of library dependencies, if they are available.
#
option (LINKSTATIC "Link with static external libraries when possible" OFF)
if (LINKSTATIC)
#set (_orig_link_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
message (STATUS "Statically linking external libraries when possible")
if (WIN32)
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else ()
set (CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif ()
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{${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.
set(CMAKE_FIND_FRAMEWORK LAST)
endif ()
endif ()
###########################################################################
# Rpath handling at the install step
#
set (MACOSX_RPATH ON)
if (CMAKE_SKIP_RPATH)
# We need to disallow the user from truly setting CMAKE_SKIP_RPATH, since
# we want to run the generated executables from the build tree in order to
# generate the manual page documentation. However, we make sure the
# install rpath is unset so that the install tree is still free of rpaths
# for linux packaging purposes.
set (CMAKE_SKIP_RPATH FALSE)
unset (CMAKE_INSTALL_RPATH)
else ()
if (NOT CMAKE_INSTALL_RPATH)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif ()
# 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 ()
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
set (CMAKE_SKIP_BUILD_RPATH FALSE)
# When building, don't use the install RPATH already (but later on when installing)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
###########################################################################
# Macro to install targets to the appropriate locations. Use this instead
# of the install(TARGETS ...) signature. Note that it adds it to the
# export targets list for when we generate config files.
#
# Usage:
#
# install_targets (target1 [target2 ...])
#
macro (install_targets)
install (TARGETS ${ARGN}
EXPORT ${PROJ_NAME}_EXPORTED_TARGETS
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT user
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT user
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT developer)
endmacro()
+133
View File
@@ -0,0 +1,133 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Compile a CUDA file to PTX using NVCC
function ( NVCC_COMPILE cuda_src 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 (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 ${cuda_ptx}
COMMAND ${CUDA_NVCC_EXECUTABLE}
"-I${OPTIX_INCLUDES}"
"-I${CUDA_INCLUDES}"
"-I${CMAKE_CURRENT_SOURCE_DIR}"
"-I${CMAKE_BINARY_DIR}/include"
"-I${PROJECT_SOURCE_DIR}/src/include"
"-I${PROJECT_SOURCE_DIR}/src/cuda_common"
${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++${CMAKE_CXX_STANDARD} -dc -O3 --use_fast_math --expt-relaxed-constexpr
${extra_nvcc_args}
${cuda_src} -o ${cuda_ptx}
MAIN_DEPENDENCY ${cuda_src}
DEPENDS ${cuda_src} ${cuda_headers} oslexec
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
# Function to compile a C++ source file to CUDA-compatible LLVM bitcode
function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
get_filename_component ( src_we ${src} NAME_WE )
set (asm_cuda "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.s" )
set (bc_cuda "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.bc" )
set (${generated_bc} ${bc_cuda} PARENT_SCOPE )
# Setup the compile flags
get_property (CURRENT_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
if (VERBOSE)
message (STATUS "Current #defines are ${CURRENT_DEFINITIONS}")
endif ()
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})
# Setup the bitcode generator
if (NOT LLVM_BC_GENERATOR)
FIND_PROGRAM(LLVM_BC_GENERATOR NAMES "clang++" PATHS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH)
endif ()
# If that didn't work, look anywhere
if (NOT LLVM_BC_GENERATOR)
# Wasn't in their build, look anywhere
FIND_PROGRAM(LLVM_BC_GENERATOR NAMES clang++ llvm-g++)
endif ()
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()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# fix compilation error when using MSVC
set (CLANG_MSVC_FIX "-DBOOST_CONFIG_REQUIRES_THREADS_HPP")
# these are warnings triggered by the dllimport/export attributes not being supported when
# compiling for Cuda. When all 3rd parties have their export macro fixed these warnings
# can be restored.
set (CLANG_MSVC_FIX "${CLANG_MSVC_FIX} -Wno-ignored-attributes -Wno-unknown-attributes")
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_BINARY_DIR}/include"
"-I${PROJECT_SOURCE_DIR}/src/include"
"-I${PROJECT_SOURCE_DIR}/src/cuda_common"
${ALL_OpenImageIO_INCLUDES}
${ALL_IMATH_INCLUDES}
${ALL_OPENEXR_INCLUDES}
"-I${Boost_INCLUDE_DIRS}"
${LLVM_COMPILE_FLAGS} ${CUDA_LIB_FLAGS}
-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}
${src} -o ${asm_cuda}
COMMAND "${LLVM_DIRECTORY}/bin/llvm-as" -f -o ${bc_cuda} ${asm_cuda}
DEPENDS ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
# Compile a CUDA source file to LLVM bitcode, and then serialize the bitcode to
# a C++ file to be compiled into the target executable.
function ( LLVM_COMPILE_CUDA llvm_src headers prefix llvm_bc_cpp_generated extra_clang_args )
get_filename_component (llvmsrc_we ${llvm_src} NAME_WE)
set (llvm_bc_cpp "${CMAKE_CURRENT_BINARY_DIR}/${llvmsrc_we}.bc.cpp")
set (${llvm_bc_cpp_generated} ${llvm_bc_cpp} PARENT_SCOPE)
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}
MAIN_DEPENDENCY ${llvm_src}
DEPENDS "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
+195 -214
View File
@@ -1,120 +1,77 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
###########################################################################
# Find external dependencies
###########################################################################
# Find libraries
# When not in VERBOSE mode, try to make things as quiet as possible
if (NOT VERBOSE)
set (Bison_FIND_QUIETLY true)
set (Boost_FIND_QUIETLY true)
set (Flex_FIND_QUIETLY true)
set (LLVM_FIND_QUIETLY true)
set (OpenEXR_FIND_QUIETLY true)
set (OpenImageIO_FIND_QUIETLY true)
set (Partio_FIND_QUIETLY true)
set (PkgConfig_FIND_QUIETLY true)
set (PugiXML_FIND_QUIETLY TRUE)
set (PythonInterp_FIND_QUIETLY true)
set (PythonLibs_FIND_QUIETLY true)
set (Threads_FIND_QUIETLY true)
set (ZLIB_FIND_QUIETLY true)
endif ()
message (STATUS "${ColorBoldWhite}")
message (STATUS "* Checking for dependencies...")
message (STATUS "* - Missing a dependency 'Package'?")
message (STATUS "* Try cmake -DPackage_ROOT=path or set environment var Package_ROOT=path")
message (STATUS "* For many dependencies, we supply src/build-scripts/build_Package.bash")
message (STATUS "* - To exclude an optional dependency (even if found),")
message (STATUS "* -DUSE_Package=OFF or set environment var USE_Package=OFF ")
message (STATUS "${ColorReset}")
setup_path (THIRD_PARTY_TOOLS_HOME
"unknown"
"Location of third party libraries in the external project")
# Add all third party tool directories to the include and library paths so
# that they'll be correctly found by the various FIND_PACKAGE() invocations.
if (THIRD_PARTY_TOOLS_HOME AND EXISTS "${THIRD_PARTY_TOOLS_HOME}")
set (CMAKE_INCLUDE_PATH "${THIRD_PARTY_TOOLS_HOME}/include" "${CMAKE_INCLUDE_PATH}")
# Detect third party tools which have been successfully built using the
# lock files which are placed there by the external project Makefile.
file (GLOB _external_dir_lockfiles "${THIRD_PARTY_TOOLS_HOME}/*.d")
foreach (_dir_lockfile ${_external_dir_lockfiles})
# Grab the tool directory_name.d
get_filename_component (_ext_dirname ${_dir_lockfile} NAME)
# Strip off the .d extension
string (REGEX REPLACE "\\.d$" "" _ext_dirname ${_ext_dirname})
set (CMAKE_INCLUDE_PATH "${THIRD_PARTY_TOOLS_HOME}/include/${_ext_dirname}" ${CMAKE_INCLUDE_PATH})
set (CMAKE_LIBRARY_PATH "${THIRD_PARTY_TOOLS_HOME}/lib/${_ext_dirname}" ${CMAKE_LIBRARY_PATH})
endforeach ()
endif ()
# Place where locally built (by src/build-scripts/*) dependencies go.
# Put it first in the prefix path.
set (OSL_LOCAL_DEPS_DIR "${CMAKE_SOURCE_DIR}/ext/dist" CACHE STRING
"Local area for dependencies added to CMAKE_PREFIX_PATH")
list (INSERT CMAKE_PREFIX_PATH 0 ${OSL_LOCAL_DEPS_DIR})
message (STATUS "CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
setup_string (SPECIAL_COMPILE_FLAGS ""
"Custom compilation flags")
if (SPECIAL_COMPILE_FLAGS)
add_definitions (${SPECIAL_COMPILE_FLAGS})
endif ()
include (ExternalProject)
###########################################################################
# IlmBase setup
find_package (OpenEXR REQUIRED)
#OpenEXR 2.2 still has problems with importing ImathInt64.h unqualified
#thus need for ilmbase/OpenEXR
include_directories ("${OPENEXR_INCLUDE_DIR}"
"${ILMBASE_INCLUDE_DIR}"
"${ILMBASE_INCLUDE_DIR}/OpenEXR")
if (${OPENEXR_VERSION} VERSION_LESS 2.0.0)
# OpenEXR 1.x had weird #include dirctives, this is also necessary:
include_directories ("${OPENEXR_INCLUDE_DIR}/OpenEXR")
else ()
add_definitions (-DUSE_OPENEXR_VERSION2=1)
endif ()
if (NOT OpenEXR_FIND_QUIETLY)
message (STATUS "ILMBASE_INCLUDE_DIR = ${ILMBASE_INCLUDE_DIR}")
message (STATUS "ILMBASE_LIBRARIES = ${ILMBASE_LIBRARIES}")
endif ()
# end IlmBase setup
###########################################################################
option (BUILD_MISSING_DEPS "Try to download and build any missing dependencies" OFF)
###########################################################################
# Boost setup
if (NOT Boost_FIND_QUIETLY)
message (STATUS "BOOST_ROOT ${BOOST_ROOT}")
endif ()
if (NOT DEFINED Boost_ADDITIONAL_VERSIONS)
set (Boost_ADDITIONAL_VERSIONS "1.60" "1.59" "1.58" "1.57" "1.56"
"1.55" "1.54" "1.53" "1.52" "1.51" "1.50"
"1.49" "1.48" "1.47" "1.46" "1.45" "1.44"
"1.43" "1.43.0" "1.42" "1.42.0")
endif ()
if (LINKSTATIC)
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_STATIC_LIBS ON)
else ()
if (MSVC)
add_definitions (-DBOOST_ALL_DYN_LINK=1)
endif ()
endif ()
set (Boost_USE_MULTITHREADED ON)
if (BOOST_CUSTOM)
set (Boost_FOUND true)
# N.B. For a custom version, the caller had better set up the variables
# Boost_VERSION, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES.
else ()
set (Boost_COMPONENTS filesystem regex system thread wave)
find_package (Boost 1.42 REQUIRED
COMPONENTS ${Boost_COMPONENTS}
)
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)
checked_find_package (Boost REQUIRED
VERSION_MIN 1.55
COMPONENTS ${Boost_COMPONENTS}
RECOMMEND_MIN 1.66
RECOMMEND_MIN_REASON "Boost 1.66 is the oldest version our CI tests against"
PRINT Boost_INCLUDE_DIRS Boost_LIBRARIES
)
endif ()
# On Linux, Boost 1.55 and higher seems to need to link against -lrt
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND ${Boost_VERSION} GREATER 105499)
if (CMAKE_SYSTEM_NAME MATCHES "Linux"
AND ${Boost_VERSION} VERSION_GREATER_EQUAL 105500)
list (APPEND Boost_LIBRARIES "rt")
endif ()
if (NOT Boost_FIND_QUIETLY)
message (STATUS "BOOST_ROOT ${BOOST_ROOT}")
message (STATUS "Boost found ${Boost_FOUND} ")
message (STATUS "Boost version ${Boost_VERSION}")
message (STATUS "Boost include dirs ${Boost_INCLUDE_DIRS}")
message (STATUS "Boost library dirs ${Boost_LIBRARY_DIRS}")
message (STATUS "Boost libraries ${Boost_LIBRARIES}")
endif ()
include_directories (SYSTEM "${Boost_INCLUDE_DIRS}")
link_directories ("${Boost_LIBRARY_DIRS}")
@@ -122,145 +79,169 @@ link_directories ("${Boost_LIBRARY_DIRS}")
###########################################################################
###########################################################################
# Partio
checked_find_package (ZLIB REQUIRED) # Needed by several packages
find_package (ZLIB)
if (USE_PARTIO)
find_library (PARTIO_LIBRARIES
NAMES partio
PATHS "${PARTIO_HOME}/lib")
find_path (PARTIO_INCLUDE_DIR
NAMES Partio.h
PATHS "${PARTIO_HOME}/include")
if (PARTIO_INCLUDE_DIR AND PARTIO_LIBRARIES)
set (PARTIO_FOUND TRUE)
add_definitions ("-DUSE_PARTIO=1")
include_directories ("${PARTIO_INCLUDE_DIR}")
if (NOT Partio_FIND_QUIETLY)
message (STATUS "Partio include = ${PARTIO_INCLUDE_DIR}")
message (STATUS "Partio library = ${PARTIO_LIBRARIES}")
endif ()
else ()
add_definitions ("-DUSE_PARTIO=0")
set (PARTIO_FOUND FALSE)
set (PARTIO_LIBRARIES "")
message (STATUS "Partio not found")
endif ()
# IlmBase & OpenEXR
checked_find_package (OpenEXR REQUIRED
VERSION_MIN 2.0
RECOMMEND_MIN 2.2
RECOMMEND_MIN_REASON
"OpenEXR 2.2 is the oldest version our CI tests against, and the minimum that supports DWA compression"
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
# 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 (PARTIO_FOUND FALSE)
set (PARTIO_LIBRARIES "")
endif (USE_PARTIO)
# end GL Extension Wrangler library setup
###########################################################################
set (OSL_USING_IMATH 2)
endif ()
###########################################################################
# Pugixml setup. Normally we just use the version bundled with oiio, but
# some linux distros are quite particular about having separate packages so we
# allow this to be overridden to use the distro-provided package if desired.
if (USE_EXTERNAL_PUGIXML)
find_package (PugiXML REQUIRED)
# insert include path to pugixml first, to ensure that the external
# pugixml is found, and not the one in OIIO's include directory.
include_directories (BEFORE "${PUGIXML_INCLUDE_DIR}")
endif()
# end Pugixml setup
###########################################################################
# OpenImageIO
set (OIIO_LIBNAME_SUFFIX "" CACHE STRING
"Optional name appended to OIIO libraries that are built")
checked_find_package (OpenImageIO REQUIRED
VERSION_MIN 2.0
PRINT OIIOTOOL_BIN)
if (OPENIMAGEIO_FOUND)
include_directories ("${OPENIMAGEIO_INCLUDES}")
endif ()
checked_find_package (pugixml REQUIRED
VERSION_MIN 1.8)
###########################################################################
# LLVM library setup
# try to find llvm-config, with a specific version if specified
if(LLVM_DIRECTORY)
FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH)
if(NOT LLVM_CONFIG)
FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH)
endif()
else()
FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})
if(NOT LLVM_CONFIG)
FIND_PROGRAM(LLVM_CONFIG llvm-config)
endif()
endif()
if(NOT LLVM_DIRECTORY OR EXISTS ${LLVM_CONFIG})
execute_process (COMMAND ${LLVM_CONFIG} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --libdir
OUTPUT_VARIABLE LLVM_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if (LLVM_VERSION VERSION_GREATER 3.4.9 AND (NOT USE_CPP11 AND NOT USE_CPP14))
message (FATAL_ERROR "LLVM ${LLVM_VERSION} requires C++11. You must build with USE_CPP11=1 or USE_CPP14=1.")
checked_find_package (LLVM REQUIRED
VERSION_MIN 7.0
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
link_directories ("${LLVM_LIB_DIR}")
# Extract and concatenate major & minor, remove wayward patches,
# dots, and "svn" or other suffixes.
string (REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1\\2" OSL_LLVM_VERSION ${LLVM_VERSION})
add_definitions (-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION})
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 "
"${ColorReset}\n")
endif ()
find_library ( LLVM_LIBRARY
NAMES LLVM-${LLVM_VERSION}
PATHS ${LLVM_LIB_DIR})
find_library ( LLVM_MCJIT_LIBRARY
NAMES LLVMMCJIT
PATHS ${LLVM_LIB_DIR})
execute_process (COMMAND ${LLVM_CONFIG} --ldflags
OUTPUT_VARIABLE LLVM_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
checked_find_package (partio)
# if (NOT LLVM_LIBRARY)
# execute_process (COMMAND ${LLVM_CONFIG} --libfiles engine
# OUTPUT_VARIABLE LLVM_LIBRARIES
# OUTPUT_STRIP_TRAILING_WHITESPACE)
# endif ()
if (NOT LLVM_FIND_QUIETLY)
message (STATUS "LLVM version = ${LLVM_VERSION}")
message (STATUS "LLVM dir = ${LLVM_DIRECTORY}")
message (STATUS "LLVM includes = ${LLVM_INCLUDES}")
message (STATUS "LLVM library = ${LLVM_LIBRARY}")
message (STATUS "LLVM MCJIT library = ${LLVM_MCJIT_LIBRARY}")
message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
message (STATUS "LLVM libraries = ${LLVM_LIBRARIES}")
# From pythonutils.cmake
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")
endif ()
# shared llvm library may not be available, this is not an error if we use LLVM_STATIC.
if ((LLVM_LIBRARY OR LLVM_STATIC) AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE "${LLVM_INCLUDES}")
if (NOT OSL_LLVM_VERSION)
# Extract and concatenate major & minor, remove wayward patches,
# dots, and "svn" or other suffixes.
string (REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1\\2" OSL_LLVM_VERSION ${LLVM_VERSION})
endif ()
add_definitions ("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}")
if (LLVM_STATIC)
# if static LLVM libraries were requested, use llvm-config to generate
# the list of what libraries we need, and substitute that in the right
# way for LLVM_LIBRARY.
execute_process (COMMAND ${LLVM_CONFIG} --libfiles
OUTPUT_VARIABLE LLVM_LIBRARY
OUTPUT_STRIP_TRAILING_WHITESPACE)
string (REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
endif ()
if (NOT LLVM_FIND_QUIETLY)
message (STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
message (STATUS "LLVM library = ${LLVM_LIBRARY}")
endif ()
if (NOT LLVM_LIBRARY)
message (FATAL_ERROR "LLVM library not found.")
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 (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}")
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()
if (${CUDA_VERSION} VERSION_GREATER 8 AND ${LLVM_VERSION} VERSION_LESS 6)
message (FATAL_ERROR "CUDA ${CUDA_VERSION} requires LLVM 6.0 or greater")
endif ()
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})
# 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})
set(CUDA_EXTRA_LIBS ${CUDA_EXTRA_LIBS} dl)
endif()
# OptiX setup
if (USE_OPTIX)
checked_find_package (OptiX REQUIRED
VERSION_MIN 5.1)
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")
endif ()
endif ()
function (osl_optix_target TARGET)
target_include_directories (${TARGET} BEFORE PRIVATE ${CUDA_INCLUDES} ${OPTIX_INCLUDES})
## XXX: Should -DPTX_PATH point to (or include) CMAKE_CURRENT_BINARY_DIR so tests can run before installation ?
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 ()
message (FATAL_ERROR "LLVM not found.")
function (osl_optix_target TARGET)
endfunction()
endif ()
# end LLVM library setup
###########################################################################
+55
View File
@@ -0,0 +1,55 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Macro to add an executable build target. The executable name can be
# specified with NAME, otherwise is inferred from the subdirectory name. The
# source files of the binary can be specified with SRC, otherwise are
# inferred to be all the .cpp files within the subdirectory. Optional
# compile DEFINITIONS, private INCLUDE_DIRS, and private LINK_LIBRARIES may
# also be specified.
#
# The executable may be disabled individually using any of the usual
# check_is_enabled() conventions (e.g. -DENABLE_<executable>=OFF).
#
# Usage:
#
# fancy_add_executable ([ NAME targetname ... ]
# [ SRC source1 ... ]
# [ INCLUDE_DIRS include_dir1 ... ]
# [ DEFINITIONS -DFOO=bar ... ])
# [ LINK_LIBRARIES external_lib1 ... ]
#
macro (fancy_add_executable)
cmake_parse_arguments (_target "" "NAME" "SRC;INCLUDE_DIRS;SYSTEM_INCLUDE_DIRS;LINK_LIBRARIES;DEFINITIONS" ${ARGN})
# Arguments: <prefix> <options> <one_value_keywords> <multi_value_keywords> args...
if (NOT _target_NAME)
# If NAME is not supplied, infer target name (and therefore the
# executable name) from the directory name.
get_filename_component (_target_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
endif ()
if (NOT _target_SRC)
# If SRC is not supplied, assume local cpp files are its source.
file (GLOB _target_SRC *.cpp)
endif ()
check_is_enabled (${_target_NAME} _target_NAME_enabled)
if (_target_NAME_enabled)
add_executable (${_target_NAME} ${_target_SRC})
if (_target_INCLUDE_DIRS)
target_include_directories (${_target_NAME} PRIVATE ${_target_INCLUDE_DIRS})
endif ()
if (_target_SYSTEM_INCLUDE_DIRS)
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
endif ()
if (_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})
else ()
message (STATUS "${ColorRed}Disabling ${_target_NAME} ${ColorReset}")
endif ()
endmacro ()
+35 -56
View File
@@ -1,8 +1,11 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# LG's macros for using flex and bison.
# Merely including this file will set FLEX_EXECUTABLE and BISON_EXECUTABLE
# to the locations of 'flex' and 'bison' on the system, and leave them
# undefined if those programs were not found.
# If both are found, there will also be a macro defined:
# Merely including this file will require flex and bison to be found.
#
# The main purpose is to define the macro FLEX_BISON:
# FLEX_BISON ( flexsrc bisonsrc srclist compiler_headers )
# where
# flexsrc = the name of the .l file
@@ -14,72 +17,48 @@
# for the .y and .l files.
IF (NOT FLEX_EXECUTABLE)
if (NOT Flex_FIND_QUIETLY)
MESSAGE (STATUS "Looking for flex")
endif ()
FIND_PROGRAM (FLEX_EXECUTABLE flex)
IF (FLEX_EXECUTABLE)
if (NOT Flex_FIND_QUIETLY)
MESSAGE (STATUS "Looking for flex -- ${FLEX_EXECUTABLE}")
endif ()
ENDIF (FLEX_EXECUTABLE)
ENDIF (NOT FLEX_EXECUTABLE)
checked_find_package (BISON REQUIRED)
checked_find_package (FLEX REQUIRED)
IF (NOT BISON_EXECUTABLE)
if (NOT Bison_FIND_QUIETLY)
MESSAGE (STATUS "Looking for bison")
endif ()
FIND_PROGRAM (BISON_EXECUTABLE bison)
IF (BISON_EXECUTABLE)
if (NOT Bison_FIND_QUIETLY)
MESSAGE (STATUS "Looking for bison -- ${BISON_EXECUTABLE}")
endif ()
ENDIF (BISON_EXECUTABLE)
ENDIF (NOT BISON_EXECUTABLE)
IF ( FLEX_EXECUTABLE AND BISON_EXECUTABLE )
MACRO ( FLEX_BISON flexsrc bisonsrc prefix srclist compiler_headers )
if ( FLEX_EXECUTABLE AND BISON_EXECUTABLE )
macro ( FLEX_BISON flexsrc bisonsrc prefix srclist compiler_headers )
if (VERBOSE)
MESSAGE (STATUS "FLEX_BISON flex=${flexsrc} bison=${bisonsrc} prefix=${prefix}")
message (STATUS "FLEX_BISON flex=${flexsrc} bison=${bisonsrc} prefix=${prefix}")
endif ()
#MESSAGE (STATUS " src ${CMAKE_CURRENT_SOURCE_DIR}")
#MESSAGE (STATUS " bin ${CMAKE_CURRENT_BINARY_DIR}")
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" )
# MESSAGE (STATUS " bison output ${bisonoutputcxx} ${bisonoutputh}")
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" )
GET_FILENAME_COMPONENT ( flexsrc_we ${flexsrc} NAME_WE )
SET ( flexoutputcxx "${CMAKE_CURRENT_BINARY_DIR}/${flexsrc_we}.cpp" )
# MESSAGE (STATUS " flex output ${flexoutputcxx}")
SET ( ${srclist} ${${srclist}} ${bisonoutputcxx} ${flexoutputcxx} )
# MESSAGE (STATUS " src list now ${${srclist}}")
# MESSAGE (STATUS " compiler headers = ${${compiler_headers}}")
get_filename_component ( flexsrc_we ${flexsrc} NAME_WE )
set ( flexoutputcxx "${CMAKE_CURRENT_BINARY_DIR}/${flexsrc_we}.cpp" )
set ( ${srclist} ${${srclist}} ${bisonoutputcxx} ${flexoutputcxx} )
# Be really sure that we prefer the FlexLexer.h that comes with
# the flex binary we're using, not some other one in the system.
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" )
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}")
message (STATUS "Flex include dir = ${FLEX_INCLUDE_DIR}")
endif ()
INCLUDE_DIRECTORIES ( ${FLEX_INCLUDE_DIR} )
include_directories ( ${FLEX_INCLUDE_DIR} )
INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR} )
INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_SOURCE_DIR} )
ADD_CUSTOM_COMMAND ( OUTPUT ${bisonoutputcxx}
# include_directories ( ${CMAKE_CURRENT_BINARY_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
add_custom_command ( OUTPUT ${bisonoutputcxx}
COMMAND ${BISON_EXECUTABLE} -dv -p ${prefix} -o ${bisonoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${bisonsrc}"
MAIN_DEPENDENCY ${bisonsrc}
DEPENDS ${${compiler_headers}}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
ADD_CUSTOM_COMMAND ( OUTPUT ${flexoutputcxx}
COMMAND ${FLEX_EXECUTABLE} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
if ( WINDOWS )
set ( FB_WINCOMPAT --wincompat )
else ()
set ( FB_WINCOMPAT )
endif ()
add_custom_command ( OUTPUT ${flexoutputcxx}
COMMAND ${FLEX_EXECUTABLE} ${FB_WINCOMPAT} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
MAIN_DEPENDENCY ${flexsrc}
DEPENDS ${${compiler_headers}}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
ENDMACRO ()
ENDIF ()
endmacro ()
endif ()
+159
View File
@@ -0,0 +1,159 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Module to find LLVM
#
# This module defines the following variables:
# LLVM_FOUND - True if llvm found.
# LLVM_VERSION - Full LLVM version
# LLVM_INCLUDES - where to find llvm headers
# LLVM_LIBRARIES - List of LLVM libraries to link against
# LLVM_SYSTEM_LIBRARIES - additional libraries needed by LLVM
# LLVM_DIRECTORY - If not already set, the root of the LLVM install
# LLVM_LIB_DIR - where to find llvm libs
# LLVM_TARGETS - List of available LLVM targets
# CLANG_LIBRARIES - list of libraries for clang components (optional,
# those may not be found)
#
# The following input symbols may be used to help guide the search:
# LLVM_DIRECTORY - the root of the LLVM installation (if custom)
# LLVM_FIND_QUIETLY - if true, will suppress most console output
# LLVM_STATIC - if true, will prefer static LLVM libs to dynamic
# try to find llvm-config, with a specific version if specified
if (LLVM_DIRECTORY)
set (LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
endif ()
list (APPEND LLVM_CONFIG_PATH_HINTS
"/usr/local/opt/llvm/${LLVM_VERSION}/bin/"
"/usr/local/opt/llvm/bin/")
find_program (LLVM_CONFIG
NAMES llvm-config-${LLVM_VERSION} llvm-config
llvm-config-64-${LLVM_VERSION} llvm-config-64
HINTS ${LLVM_CONFIG_PATH_HINTS} NO_DEFAULT_PATH)
find_program (LLVM_CONFIG
NAMES llvm-config-${LLVM_VERSION} llvm-config
llvm-config-64-${LLVM_VERSION} llvm-config-64
HINTS ${LLVM_CONFIG_PATH_HINTS})
if (NOT LLVM_FIND_QUIETLY)
message (STATUS "Found llvm-config '${LLVM_CONFIG}'")
endif ()
if (NOT LLVM_DIRECTORY)
execute_process (COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
execute_process (COMMAND ${LLVM_CONFIG} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --libdir
OUTPUT_VARIABLE LLVM_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --targets-built
OUTPUT_VARIABLE LLVM_TARGETS
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
NAMES LLVM-${LLVM_VERSION} LLVM
PATHS ${LLVM_LIB_DIR})
find_library ( LLVM_MCJIT_LIBRARY
NAMES LLVMMCJIT
PATHS ${LLVM_LIB_DIR})
if (NOT LLVM_LIBRARY)
# if no single library was found, use llvm-config to generate the list
# of what libraries we need, and substitute that in the right way for
# LLVM_LIBRARY.
execute_process (COMMAND ${LLVM_CONFIG} --libfiles
OUTPUT_VARIABLE LLVM_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
string (REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
set (LLVM_LIBRARY "${LLVM_LIBRARIES}")
endif ()
execute_process (COMMAND ${LLVM_CONFIG} --shared-mode
OUTPUT_VARIABLE LLVM_SHARED_MODE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (LLVM_VERSION VERSION_GREATER_EQUAL 9.0 AND (LLVM_SHARED_MODE STREQUAL "shared"))
find_library ( _CLANG_CPP_LIBRARY
NAMES "clang-cpp"
PATHS ${LLVM_LIB_DIR})
if (_CLANG_CPP_LIBRARY)
list (APPEND CLANG_LIBRARIES ${_CLANG_CPP_LIBRARY})
endif ()
endif ()
foreach (COMPONENT clangFrontend clangDriver clangSerialization
clangParse clangSema clangAnalysis clangAST clangBasic
clangEdit clangLex)
find_library ( _CLANG_${COMPONENT}_LIBRARY
NAMES ${COMPONENT}
PATHS ${LLVM_LIB_DIR})
if (_CLANG_${COMPONENT}_LIBRARY)
list (APPEND CLANG_LIBRARIES ${_CLANG_${COMPONENT}_LIBRARY})
endif ()
endforeach ()
# 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)
# if static LLVM libraries were requested, use llvm-config to generate
# the list of what libraries we need, and substitute that in the right
# way for LLVM_LIBRARY.
execute_process (COMMAND ${LLVM_CONFIG} --libfiles --link-static
OUTPUT_VARIABLE LLVM_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (LLVM_LIBRARIES)
string (REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
set (LLVM_LIBRARY "")
endif ()
else ()
set (LLVM_LIBRARIES "${LLVM_LIBRARY}")
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args (LLVM
REQUIRED_VARS
LLVM_INCLUDES
LLVM_LIBRARIES
VERSION_VAR LLVM_VERSION
)
+178 -67
View File
@@ -1,21 +1,123 @@
# Module to find OpenEXR.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Module to find OpenEXR and Imath.
#
# 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
# targets:
#
# Imath::Imath
# Imath::Half
# OpenEXR::OpenEXR
# OpenEXR::Iex
# OpenEXR::IlmThread
#
# For OpenEXR 2.4 & 2.5, it will establish the following imported targets:
#
# IlmBase::Imath
# IlmBase::Half
# IlmBase::Iex
# IlmBase::IlmThread
# OpenEXR::IlmImf
#
# For all versions -- but for OpenEXR < 2.4 the only thing this sets --
# are the following CMake variables:
#
# This module will set
# OPENEXR_FOUND true, if found
# OPENEXR_INCLUDE_DIR directory where headers are found
# OPENEXR_INCLUDES directory where OpenEXR headers are found
# OPENEXR_LIBRARIES libraries for OpenEXR + IlmBase
# ILMBASE_LIBRARIES libraries just IlmBase
# OPENEXR_VERSION OpenEXR version (accurate for >= 2.0.0,
# otherwise will just guess 1.6.1)
# IMATH_INCLUDES directory where Imath headers are found
# ILMBASE_INCLUDES directory where IlmBase headers are found
# ILMBASE_LIBRARIES libraries just IlmBase
#
# Special inputs:
# OPENEXR_CUSTOM_INCLUDE_DIR - custom location of headers
# OPENEXR_CUSTOM_LIB_DIR - custom location of libraries
# OPENEXR_CUSTOM_LIB_PREFIX - special snowflake library prefix
# OPENEXR_CUSTOM_LIB_SUFFIX - special snowflake library suffix
#
# Other standarnd issue macros
# First, try to fine just the right config files
find_package(Imath CONFIG)
if (NOT TARGET Imath::Imath)
# Couldn't find Imath::Imath, maybe it's older and has IlmBase?
find_package(IlmBase CONFIG)
endif ()
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})")
endif ()
# Mimic old style variables
set (OPENEXR_VERSION ${OpenEXR_VERSION})
get_target_property(IMATH_INCLUDES Imath::Imath INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(ILMBASE_INCLUDES Imath::Imath INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(ILMBASE_IMATH_LIBRARY Imath::Imath INTERFACE_LINK_LIBRARIES)
get_target_property(IMATH_LIBRARY Imath::Imath INTERFACE_LINK_LIBRARIES)
get_target_property(OPENEXR_IEX_LIBRARY OpenEXR::Iex INTERFACE_LINK_LIBRARIES)
get_target_property(OPENEXR_ILMTHREAD_LIBRARY OpenEXR::IlmThread INTERFACE_LINK_LIBRARIES)
set (ILMBASE_LIBRARIES ${ILMBASE_IMATH_LIBRARY})
set (ILMBASE_FOUND true)
get_target_property(OPENEXR_INCLUDES OpenEXR::OpenEXR INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(OPENEXR_ILMIMF_LIBRARY OpenEXR::OpenEXR INTERFACE_LINK_LIBRARIES)
set (OPENEXR_LIBRARIES ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ILMBASE_LIBRARIES})
set (OPENEXR_FOUND true)
# Link with pthreads if required
find_package (Threads)
if (CMAKE_USE_PTHREADS_INIT)
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 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})")
endif ()
# Mimic old style variables
get_target_property(ILMBASE_INCLUDES IlmBase::IlmBaseConfig INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(IMATH_INCLUDES IlmBase::IlmBaseConfig INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(ILMBASE_Imath_LIBRARY IlmBase::Imath INTERFACE_LINK_LIBRARIES)
get_target_property(ILMBASE_IMATH_LIBRARY IlmBase::Imath INTERFACE_LINK_LIBRARIES)
get_target_property(ILMBASE_HALF_LIBRARY IlmBase::Half INTERFACE_LINK_LIBRARIES)
get_target_property(OPENEXR_IEX_LIBRARY IlmBase::Iex INTERFACE_LINK_LIBRARIES)
get_target_property(OPENEXR_ILMTHREAD_LIBRARY IlmBase::IlmThread INTERFACE_LINK_LIBRARIES)
set (ILMBASE_LIBRARIES ${ILMBASE_IMATH_LIBRARY} ${ILMBASE_HALF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY})
set (ILMBASE_FOUND true)
get_target_property(OPENEXR_INCLUDES OpenEXR::IlmImfConfig INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(OPENEXR_ILMIMF_LIBRARY OpenEXR::IlmImf INTERFACE_LINK_LIBRARIES)
set (OPENEXR_LIBRARIES ${OPENEXR_ILMIMF_LIBRARY} ${ILMBASE_LIBRARIES})
set (OPENEXR_FOUND true)
# Link with pthreads if required
find_package (Threads)
if (CMAKE_USE_PTHREADS_INIT)
list (APPEND ILMBASE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif ()
# 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}")
else ()
# OpenEXR 2.x older versions without a config or whose configs we don't
# trust.
set (FOUND_OPENEXR_WITH_CONFIG 0)
# Other standard issue macros
include (FindPackageHandleStandardArgs)
include (SelectLibraryConfigurations)
@@ -27,33 +129,50 @@ 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_CUSTOM_INCLUDE_DIR and ${OPENEXR_HOME}/include.
# ${OPENEXR_ROOT}/include.
# ILMBASE is needed in case ilmbase an openexr are installed in separate
# directories, like NixOS does
set (GENERIC_INCLUDE_PATHS
${OPENEXR_CUSTOM_INCLUDE_DIR}
${OPENEXR_HOME}/include
${ILMBASE_HOME}/include
${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}
/usr/local/include
/sw/include
/opt/local/include )
# Find the include file locations. We call find_path twice -- first using
# only the custom paths, then if that fails, try the default paths only.
# This seems to be the most robust way I can find to not get confused when
# both system and custom libraries are present.
# Find the include file locations.
find_path (ILMBASE_INCLUDE_PATH OpenEXR/IlmBaseConfig.h
PATHS ${GENERIC_INCLUDE_PATHS} NO_DEFAULT_PATH)
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
PATHS ${GENERIC_INCLUDE_PATHS} NO_DEFAULT_PATH)
find_path (OPENEXR_INCLUDE_PATH OpenEXR/OpenEXRConfig.h)
HINTS ${OPENEXR_INCLUDE_DIR}
${GENERIC_INCLUDE_PATHS} )
# Try to figure out version number
if (EXISTS "${OPENEXR_INCLUDE_PATH}/OpenEXR/ImfMultiPartInputFile.h")
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})
@@ -70,21 +189,24 @@ endif ()
# List of likely places to find the libraries -- note priority override of
# OPENEXR_CUSTOM_LIB_DIR and ${OPENEXR_HOME}/lib.
set (GENERIC_LIBRARY_PATHS
${OPENEXR_CUSTOM_LIB_DIR}
${OPENEXR_HOME}/lib
${ILMBASE_HOME}/lib
# ${OPENEXR_ROOT}/lib.
set (GENERIC_LIBRARY_PATHS
${OPENEXR_ROOT}/lib
${ILMBASE_ROOT}/lib
${OPENEXR_INCLUDE_PATH}/../lib
${ILMBASE_INCLUDE_PATH}/../lib
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
${_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})
@@ -96,56 +218,43 @@ if (OpenEXR_USE_STATIC_LIBS)
endif ()
endif ()
# Look for the libraries themselves, for all the components. Like with the
# headers, we do two finds -- first for custom locations, then for default.
# 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
set (FULL_COMPONENT_NAME ${OPENEXR_CUSTOM_LIB_PREFIX}${COMPONENT}-${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}${OPENEXR_CUSTOM_LIB_SUFFIX})
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY ${FULL_COMPONENT_NAME}
PATHS ${GENERIC_LIBRARY_PATHS} NO_DEFAULT_PATH)
# Again, with no directory restrictions
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY ${FULL_COMPONENT_NAME})
# Try again without the version
set (FULL_COMPONENT_NAME ${OPENEXR_CUSTOM_LIB_PREFIX}${COMPONENT}${OPENEXR_CUSTOM_LIB_SUFFIX})
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY ${FULL_COMPONENT_NAME}
PATHS ${GENERIC_LIBRARY_PATHS} NO_DEFAULT_PATH)
# One more time, with no restrictions
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY ${FULL_COMPONENT_NAME})
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 ()
#Half usually has no suffix
find_library (OPENEXR_HALF_LIBRARY ${OPENEXR_CUSTOM_LIB_PREFIX}Half
PATHS ${GENERIC_LIBRARY_PATHS} NO_DEFAULT_PATH)
find_library (OPENEXR_HALF_LIBRARY ${OPENEXR_CUSTOM_LIB_PREFIX}Half)
# Set the FOUND, INCLUDE_DIR, and LIBRARIES variables.
if (ILMBASE_INCLUDE_PATH AND OPENEXR_INCLUDE_PATH AND
OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND
OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
set (OPENEXR_FOUND TRUE)
set (ILMBASE_FOUND TRUE)
set (ILMBASE_INCLUDE_DIR ${ILMBASE_INCLUDE_PATH} CACHE STRING "The include paths needed to use IlmBase")
set (OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDE_PATH} CACHE STRING "The include paths needed to use OpenEXR")
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")
endif ()
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
VERSION_VAR OPENEXR_VERSION
)
MARK_AS_ADVANCED(
ILMBASE_INCLUDE_DIR
OPENEXR_INCLUDE_DIR
ILMBASE_LIBRARIES
OPENEXR_LIBRARIES
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
@@ -154,3 +263,5 @@ MARK_AS_ADVANCED(
# Restore the original CMAKE_FIND_LIBRARY_SUFFIXES
set (CMAKE_FIND_LIBRARY_SUFFIXES ${_openexr_orig_suffixes})
endif ()
+136
View File
@@ -0,0 +1,136 @@
###########################################################################
# OpenImageIO https://www.openimageio.org
# Copyright 2008-present Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
#
# For an up-to-date version of this file, see:
# https://github.com/OpenImageIO/oiio/blob/master/src/cmake/Modules/FindOpenImageIO.cmake
#
###########################################################################
#
# CMake module to find OpenImageIO
#
# This module will set
# OPENIMAGEIO_FOUND True, if found
# OPENIMAGEIO_INCLUDES directory where headers are found
# OPENIMAGEIO_LIBRARIES libraries for OIIO
# OPENIMAGEIO_LIBRARY_DIRS library dirs for OIIO
# OPENIMAGEIO_VERSION Version ("major.minor.patch.tweak")
# OPENIMAGEIO_VERSION_MAJOR Version major number
# OPENIMAGEIO_VERSION_MINOR Version minor number
# OPENIMAGEIO_VERSION_PATCH Version minor patch
# OPENIMAGEIO_VERSION_TWEAK Version minor tweak
# OIIOTOOL_BIN Path to oiiotool executable
#
# Imported targets:
# OpenImageIO::OpenImageIO The libOpenImageIO library.
# OpenImageIO::oiiotool The oiiotool executable.
#
# Special inputs:
# OpenImageIO_ROOT - if using CMake >= 3.12, will automatically search
# this area for OIIO components.
# OPENIMAGEIO_ROOT_DIR - custom "prefix" location of OIIO installation
# (expecting bin, lib, include subdirectories)
# This is deprecated, but will work for a while.
# OpenImageIO_FIND_QUIETLY - if set, print minimal console output
# OIIO_LIBNAME_SUFFIX - if set, optional nonstandard library suffix
#
###########################################################################
#
# NOTE: This file is deprecated.
#
# In OIIO 2.1+, we generate OpenImageIOConfig.cmake files that are now the
# preferred way for downstream projects to find an installed OIIO. There
# should be no need to copy this FindOpenImageIO.cmake file into downstream
# projects, *unless* they need to work with a range of OIIO versions that
# may include <2.1, which would lack the generated config files.
#
###########################################################################
# Prefer an OpenImageIO cmake config file if it can be found
find_package(OpenImageIO CONFIG)
if (TARGET OpenImageIO::OpenImageIO)
set (OPENIMAGEIO_VERSION ${OpenImageIO_VERSION})
else ()
# If 'OPENIMAGE_HOME' not set, use the env variable of that name if available
if (NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "")
set (OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR})
endif ()
find_library ( OPENIMAGEIO_LIBRARY
NAMES OpenImageIO${OIIO_LIBNAME_SUFFIX}
HINTS ${OPENIMAGEIO_ROOT_DIR}
PATH_SUFFIXES lib64 lib )
find_path ( OPENIMAGEIO_INCLUDE_DIR
NAMES OpenImageIO/imageio.h
HINTS ${OPENIMAGEIO_ROOT_DIR} )
find_program ( OIIOTOOL_BIN
NAMES oiiotool
HINTS ${OPENIMAGEIO_ROOT_DIR} )
# Try to figure out version number
set (OIIO_VERSION_HEADER "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h")
if (EXISTS "${OIIO_VERSION_HEADER}")
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MAJOR .*$")
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MAJOR ${TMP})
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MINOR .*$")
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MINOR ${TMP})
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_PATCH .*$")
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_PATCH ${TMP})
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_TWEAK .*$")
if (TMP)
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_TWEAK ${TMP})
else ()
set (OPENIMAGEIO_VERSION_TWEAK 0)
endif ()
set (OPENIMAGEIO_VERSION "${OPENIMAGEIO_VERSION_MAJOR}.${OPENIMAGEIO_VERSION_MINOR}.${OPENIMAGEIO_VERSION_PATCH}.${OPENIMAGEIO_VERSION_TWEAK}")
endif ()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (OpenImageIO
FOUND_VAR OPENIMAGEIO_FOUND
REQUIRED_VARS OPENIMAGEIO_INCLUDE_DIR OPENIMAGEIO_LIBRARY
OPENIMAGEIO_VERSION
VERSION_VAR OPENIMAGEIO_VERSION
)
if (OPENIMAGEIO_FOUND)
set (OpenImageIO_VERSION ${OPENIMAGEIO_VERSION})
set (OPENIMAGEIO_INCLUDES ${OPENIMAGEIO_INCLUDE_DIR})
set (OpenImageIO_INCLUDES ${OPENIMAGEIO_INCLUDE_DIR})
set (OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
get_filename_component (OPENIMAGEIO_LIBRARY_DIRS "${OPENIMAGEIO_LIBRARY}" DIRECTORY)
if (NOT OpenImageIO_FIND_QUIETLY)
message ( STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDE_DIR}" )
message ( STATUS "OpenImageIO libraries = ${OPENIMAGEIO_LIBRARIES}" )
message ( STATUS "OpenImageIO library_dirs = ${OPENIMAGEIO_LIBRARY_DIRS}" )
message ( STATUS "OpenImageIO oiiotool = ${OIIOTOOL_BIN}" )
endif ()
if (NOT TARGET OpenImageIO::OpenImageIO)
add_library(OpenImageIO::OpenImageIO UNKNOWN IMPORTED)
set_target_properties(OpenImageIO::OpenImageIO PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENIMAGEIO_INCLUDES}")
set_property(TARGET OpenImageIO::OpenImageIO APPEND PROPERTY
IMPORTED_LOCATION "${OPENIMAGEIO_LIBRARIES}")
endif ()
if (NOT TARGET OpenImageIO::oiiotool AND EXISTS "${OIIOTOOL_BIN}")
add_executable(OpenImageIO::oiiotool IMPORTED)
set_target_properties(OpenImageIO::oiiotool PROPERTIES
IMPORTED_LOCATION "${OIIOTOOL_BIN}")
endif ()
endif ()
mark_as_advanced (
OPENIMAGEIO_INCLUDE_DIR
OPENIMAGEIO_LIBRARY
)
endif ()
+98
View File
@@ -0,0 +1,98 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
###########################################################################
# CMake module to find OptiX
#
# This module will set
# OPTIX_FOUND True, if OptiX is found
# OPTIX_INCLUDES directory where OptiX headers are found
# OPTIX_LIBRARIES libraries for OptiX
#
# Special inputs:
# OPTIXHOME - custom "prefix" location of OptiX installation
# (expecting bin, lib, include subdirectories)
# If 'OPTIXHOME' not set, use the env variable of that name if available
if (NOT OPTIXHOME)
if (NOT $ENV{OPTIXHOME} STREQUAL "")
set (OPTIXHOME $ENV{OPTIXHOME})
elseif (NOT $ENV{OPTIX_INSTALL_DIR} STREQUAL "")
set (OPTIXHOME $ENV{OPTIX_INSTALL_DIR})
endif ()
endif ()
if (NOT OptiX_FIND_QUIETLY)
message (STATUS "OPTIXHOME = ${OPTIXHOME}")
endif ()
find_path (OPTIX_INCLUDE_DIR
NAMES optix.h
HINTS ${OPTIXHOME}/include
PATH_SUFFIXES include )
# Macro adapted from https://github.com/nvpro-samples/optix_advanced_samples
macro(OPTIX_find_api_library name version)
find_library(${name}_LIBRARY
NAMES ${name}.${version} ${name}
PATHS "${OPTIXHOME}/lib64"
NO_DEFAULT_PATH
)
find_library(${name}_LIBRARY
NAMES ${name}.${version} ${name}
)
if (${name}_LIBRARY STREQUAL "${name}_LIBRARY-NOTFOUND")
if (WIN32)
set (${name}_LIBRARY "${OPTIXHOME}/lib64/${name}.${version}.lib")
else ()
set (${name}_LIBRARY "${OPTIXHOME}/lib64/lib${name}.so")
endif ()
endif()
endmacro()
if (OPTIX_INCLUDE_DIR)
# Pull out the API version from optix.h
file(STRINGS ${OPTIX_INCLUDE_DIR}/optix.h OPTIX_VERSION_LINE LIMIT_COUNT 1 REGEX "define OPTIX_VERSION")
string(REGEX MATCH "([0-9]+)" OPTIX_VERSION_STRING "${OPTIX_VERSION_LINE}")
math(EXPR OPTIX_VERSION_MAJOR "${OPTIX_VERSION_STRING}/10000")
math(EXPR OPTIX_VERSION_MINOR "(${OPTIX_VERSION_STRING}%10000)/100")
math(EXPR OPTIX_VERSION_MICRO "${OPTIX_VERSION_STRING}%100")
set(OPTIX_VERSION "${OPTIX_VERSION_MAJOR}.${OPTIX_VERSION_MINOR}.${OPTIX_VERSION_MICRO}")
endif ()
# OptiX 7 doesn't link to any libraries
if (OPTIX_VERSION VERSION_LESS 7)
OPTIX_find_api_library(optix ${OPTIX_VERSION})
OPTIX_find_api_library(optixu ${OPTIX_VERSION})
OPTIX_find_api_library(optix_prime ${OPTIX_VERSION})
set (OPTIX_LIBRARIES ${optix_LIBRARY})
endif ()
mark_as_advanced (
OPTIX_INCLUDE_DIR
OPTIX_LIBRARIES
OPTIX_VERSION
)
include (FindPackageHandleStandardArgs)
if (${OPTIX_VERSION_MAJOR} LESS 7)
find_package_handle_standard_args (OptiX
FOUND_VAR OPTIX_FOUND
REQUIRED_VARS OPTIX_INCLUDE_DIR OPTIX_LIBRARIES OPTIX_VERSION
VERSION_VAR OPTIX_VERSION
)
else ()
find_package_handle_standard_args (OptiX
FOUND_VAR OPTIX_FOUND
REQUIRED_VARS OPTIX_INCLUDE_DIR OPTIX_VERSION
VERSION_VAR OPTIX_VERSION
)
endif()
if (OPTIX_FOUND)
set (OPTIX_INCLUDES ${OPTIX_INCLUDE_DIR})
endif ()
-31
View File
@@ -1,31 +0,0 @@
# Find the pugixml XML parsing library.
#
# Sets the usual variables expected for find_package scripts:
#
# PUGIXML_INCLUDE_DIR - header location
# PUGIXML_LIBRARIES - library to link against
# PUGIXML_FOUND - true if pugixml was found.
find_path (PUGIXML_INCLUDE_DIR
NAMES pugixml.hpp
PATHS ${PUGIXML_HOME}/include)
find_library (PUGIXML_LIBRARY
NAMES pugixml
PATHS ${PUGIXML_HOME}/lib)
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (PugiXML DEFAULT_MSG PUGIXML_LIBRARY
PUGIXML_INCLUDE_DIR)
if (PUGIXML_FOUND)
set (PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
if (NOT PugiXML_FIND_QUIETLY)
message (STATUS "PugiXML include = ${PUGIXML_INCLUDE_DIR}")
message (STATUS "PugiXML library = ${PUGIXML_LIBRARY}")
endif ()
else ()
message (STATUS "No PugiXML found")
endif()
mark_as_advanced (PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
+47
View File
@@ -0,0 +1,47 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Find the Partio library.
#
# Sets the usual variables expected for find_package scripts:
#
# PARTIO_INCLUDE_DIR - header location
# PARTIO_LIBRARIES - library to link against
# PARTIO_FOUND - true if Partio was found.
# Hack! perfer 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 ()
else ()
if (VERBOSE)
message (STATUS "partio falling back to FindPartio.cmake")
endif ()
find_path (PARTIO_INCLUDE_DIR NAMES Partio.h)
find_library (PARTIO_LIBRARY NAMES partio)
# Support the REQUIRED and QUIET arguments, and set PARTIO_FOUND if found.
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (partio DEFAULT_MSG PARTIO_LIBRARY
PARTIO_INCLUDE_DIR)
if (PARTIO_FOUND)
set (partio_FOUND ${PARTIO_FOUND})
set (PARTIO_INCLUDES ${PARTIO_INCLUDE_DIR})
set (PARTIO_LIBRARIES ${PARTIO_LIBRARY})
if (NOT TARGET partio::partio)
add_library (partio::partio UNKNOWN IMPORTED)
set_target_properties (partio::partio PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PARTIO_INCLUDE_DIR}")
set_property (TARGET partio::partio APPEND PROPERTY
IMPORTED_LOCATION "${PARTIO_LIBRARY}")
endif ()
endif()
endif ()
+79
View File
@@ -0,0 +1,79 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Find the pugixml XML parsing library.
#
# Sets the usual variables expected for find_package scripts:
#
# PUGIXML_INCLUDES - header location
# PUGIXML_LIBRARIES - library to link against
# PUGIXML_FOUND - true if pugixml was found.
# First try the config files and hope they're good enough
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)")
set (PUGIXML_FOUND true)
set (pugixml_FOUND true)
get_target_property(PUGIXML_INCLUDES pugixml::pugixml INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(PUGIXML_LIBRARIES pugixml::pugixml INTERFACE_LINK_LIBRARIES)
# elseif (TARGET pugixml)
# # But older pugixml (<= 1.10) has mediocre config files that are not
# # reliable in practice. They also only define a "pugixml" target but
# # not "pugixml::pugixml". So just fall through to the "no config" case
# # below, and figure everything out by hand.
else ()
# If no config file is found for PugiXML, do it the old fashioned way.
find_path (PUGIXML_INCLUDE_DIR
NAMES pugixml.hpp
#HINTS ${OpenImageIO_INCLUDE_DIR}/detail/pugixml
PATH_SUFFIXES pugixml-1.8 pugixml-1.9 pugixml-1.10)
set (pugixml_required_vars PUGIXML_INCLUDE_DIR)
find_library (PUGIXML_LIBRARY
NAMES pugixml
PATH_SUFFIXES pugixml-1.8 pugixml-1.9 pugixml-1.10)
if (PUGIXML_INCLUDE_DIR)
file (STRINGS "${PUGIXML_INCLUDE_DIR}/pugixml.hpp" TMP REGEX "define PUGIXML_VERSION .*$")
string (REGEX MATCHALL "[0-9]+" PUGIXML_CODED_VERSION ${TMP})
if (PUGIXML_CODED_VERSION VERSION_GREATER_EQUAL 1000)
math (EXPR PUGIXML_VERSION_MAJOR "${PUGIXML_CODED_VERSION} / 1000")
math (EXPR PUGIXML_VERSION_MINOR "(${PUGIXML_CODED_VERSION} % 1000) / 10")
else ()
math (EXPR PUGIXML_VERSION_MAJOR "${PUGIXML_CODED_VERSION} / 100")
math (EXPR PUGIXML_VERSION_MINOR "(${PUGIXML_CODED_VERSION} % 100) / 10")
endif ()
set (PUGIXML_VERSION ${PUGIXML_VERSION_MAJOR}.${PUGIXML_VERSION_MINOR})
endif ()
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (pugixml DEFAULT_MSG
#PUGIXML_LIBRARY
PUGIXML_INCLUDE_DIR)
if (PUGIXML_FOUND OR pugixml_FOUND)
set (PUGIXML_INCLUDES ${PUGIXML_INCLUDE_DIR})
set (PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
if (NOT TARGET pugixml::pugixml)
add_library(pugixml::pugixml UNKNOWN IMPORTED)
set_target_properties(pugixml::pugixml PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PUGIXML_INCLUDES}")
if (PUGIXML_LIBRARIES)
set_property(TARGET pugixml::pugixml APPEND PROPERTY
IMPORTED_LOCATION "${PUGIXML_LIBRARIES}")
endif ()
endif ()
endif ()
mark_as_advanced (PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
endif()
-42
View File
@@ -1,42 +0,0 @@
###########################################################################
# OpenImageIO
# If 'OPENIMAGEHOME' not set, use the env variable of that name if available
if (NOT OPENIMAGEIOHOME)
if (NOT $ENV{OPENIMAGEIOHOME} STREQUAL "")
set (OPENIMAGEIOHOME $ENV{OPENIMAGEIOHOME})
endif ()
endif ()
if (NOT OpenImageIO_FIND_QUIETLY)
MESSAGE ( STATUS "OPENIMAGEIOHOME = ${OPENIMAGEIOHOME}" )
endif ()
find_library ( OPENIMAGEIO_LIBRARY
NAMES OpenImageIO
HINTS ${OPENIMAGEIOHOME}
PATH_SUFFIXES lib64 lib
PATHS "${OPENIMAGEIOHOME}/lib" )
find_path ( OPENIMAGEIO_INCLUDES
NAMES OpenImageIO/imageio.h
HINTS ${OPENIMAGEIOHOME}
PATH_SUFFIXES include )
find_program ( OPENIMAGEIO_BIN
NAMES oiiotool
HINTS ${OPENIMAGEIOHOME}
PATH_SUFFIXES bin )
if (NOT OpenImageIO_FIND_QUIETLY)
MESSAGE ( STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDES}" )
MESSAGE ( STATUS "OpenImageIO library = ${OPENIMAGEIO_LIBRARY}" )
MESSAGE ( STATUS "OpenImageIO bin = ${OPENIMAGEIO_BIN}" )
endif ()
IF ( OPENIMAGEIO_INCLUDES AND OPENIMAGEIO_LIBRARY )
SET ( OPENIMAGEIO_FOUND TRUE )
ELSE ()
MESSAGE ( FATAL_ERROR "OpenImageIO not found" )
ENDIF ()
# end OpenImageIO setup
###########################################################################
+34
View File
@@ -0,0 +1,34 @@
# Copyright Contributors to the Open Shading Languge project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
#########################################################################
# Packaging
set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
# "Vendor" is only used in copyright notices, so we use the same thing that
# the rest of the copyright notices say.
set (CPACK_PACKAGE_VENDOR ${PROJECT_AUTHORS})
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Shading Language is the de facto standard for shading in modern path tracers used in film VFX and animation")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/src/doc/Description.txt")
set (CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-${platform})
file (COPY "${PROJECT_SOURCE_DIR}/LICENSE.md" DESTINATION "${CMAKE_BINARY_DIR}")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.md")
file (COPY "${PROJECT_SOURCE_DIR}/README.md" DESTINATION "${CMAKE_BINARY_DIR}")
set (CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.md")
set (CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/src/doc/Welcome.txt")
#set (CPACK_PACKAGE_EXECUTABLES I'm not sure what this is for)
#set (CPACK_STRIP_FILES Do we need this?)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (CPACK_GENERATOR "TGZ;STGZ;RPM;DEB")
set (CPACK_SOURCE_GENERATOR "TGZ")
endif ()
if (APPLE)
set (CPACK_GENERATOR "TGZ;STGZ;PackageMaker")
set (CPACK_SOURCE_GENERATOR "TGZ")
endif ()
set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-source)
#set (CPACK_SOURCE_STRIP_FILES ...FIXME...)
set (CPACK_SOURCE_IGNORE_FILES ".*~")
include (CPack)
-54
View File
@@ -1,54 +0,0 @@
###########################################################################
# Figure out what platform we're on, and set some variables appropriately
# CMAKE_SYSTEM_PROCESSOR should not be used because it indicates the platform
# we are building on, but when cross compiling or using a chroot this is not
# what we want to use
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set (SYSTEM_PROCESSOR "x86_64")
else()
set (SYSTEM_PROCESSOR "i686")
endif()
if (VERBOSE)
message (STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message (STATUS "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}")
message (STATUS "SYSTEM_PROCESSOR = ${SYSTEM_PROCESSOR}")
endif ()
if (UNIX)
if (VERBOSE)
message (STATUS "Unix! ${CMAKE_SYSTEM_NAME}")
endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (platform "linux")
set (CXXFLAGS "${CXXFLAGS} -DLINUX")
if (${SYSTEM_PROCESSOR} STREQUAL "x86_64")
set (platform "linux64")
set (CXXFLAGS "${CXXFLAGS} -DLINUX64")
endif ()
elseif (APPLE)
set (platform "macosx")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set (platform "FreeBSD")
set (CXXFLAGS "${CXXFLAGS} -DFREEBSD")
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
# minimum arch of i586 is needed for atomic cpu instructions
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i586")
endif()
else ()
string (TOLOWER ${CMAKE_SYSTEM_NAME} platform)
endif ()
endif ()
if (WIN32)
set (platform "windows")
endif ()
if (platform)
message (STATUS "platform = ${platform}")
else ()
message (FATAL_ERROR "'platform' not defined")
endif ()
unset(SYSTEM_PROCESSOR)
+128
View File
@@ -0,0 +1,128 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Python-related options.
option (USE_PYTHON "Build the Python bindings" ON)
set (PYTHON_VERSION "" CACHE STRING "Target version of python to try to find")
option (PYLIB_INCLUDE_SONAME "If ON, soname/soversion will be set for Python module library" OFF)
option (PYLIB_LIB_PREFIX "If ON, prefix the Python module with 'lib'" OFF)
set (PYMODULE_SUFFIX "" CACHE STRING "Suffix to add to Python module init namespace")
# Find Python. This macro should only be called if python is required. If
# Python cannot be found, it will be a fatal error.
macro (find_python)
if (NOT VERBOSE)
set (PythonInterp_FIND_QUIETLY true)
set (PythonLibs_FIND_QUIETLY true)
endif ()
# 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 ()
endif ()
checked_find_package (Python ${PYTHON_VERSION}
${_req}
COMPONENTS Interpreter Development
PRINT Python_Development_FOUND Python_VERSION
Python_EXECUTABLE Python_LIBRARIES
Python_Development_FOUND Python_Interpreter_FOUND)
# The version that was found may not be the default or user
# defined one.
set (PYTHON_VERSION_FOUND ${Python_VERSION_MAJOR}.${Python_VERSION_MINOR})
# Give hints to subsequent pybind11 searching to ensure that it finds
# exactly the same version that we found.
set (PythonInterp_FIND_VERSION PYTHON_VERSION_FOUND)
set (PythonInterp_FIND_VERSION_MAJOR ${Python_VERSION_MAJOR})
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 ()
endmacro()
###########################################################################
# pybind11
macro (setup_python_module)
cmake_parse_arguments (lib "" "TARGET;MODULE;LIBS" "SOURCES" ${ARGN})
# Arguments: <prefix> <options> <one_value_keywords> <multi_value_keywords> args...
set (target_name ${lib_TARGET})
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# 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 ()
# Add the library itself
add_library (${target_name} MODULE ${lib_SOURCES})
# Declare the libraries it should link against
target_link_libraries (${target_name}
PRIVATE
pybind11::pybind11
Python::Python
${lib_LIBS} ${SANITIZE_LIBRARIES})
if (APPLE)
set_target_properties (${target_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif ()
# Exclude the 'lib' prefix from the name
if (NOT PYLIB_LIB_PREFIX)
target_compile_definitions(${target_name}
PRIVATE "PYMODULE_NAME=${lib_MODULE}")
set_target_properties (${target_name} PROPERTIES
OUTPUT_NAME ${lib_MODULE}
PREFIX "")
else ()
target_compile_definitions(${target_name}
PRIVATE "PYMODULE_NAME=Py${lib_MODULE}")
set_target_properties (${target_name} PROPERTIES
OUTPUT_NAME Py${lib_MODULE}
PREFIX lib)
endif ()
if (PYLIB_INCLUDE_SONAME)
if (VERBOSE)
message(STATUS "Setting Py${lib_MODULE} SOVERSION to: ${SOVERSION}")
endif ()
set_target_properties(${target_name} PROPERTIES
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
SOVERSION ${SOVERSION} )
endif()
if (WIN32)
set_target_properties (${target_name} PROPERTIES
DEBUG_POSTFIX "_d"
SUFFIX ".pyd")
endif()
# In the build area, put it in lib/python so it doesn't clash with the
# non-python libraries of the same name (which aren't prefixed by "lib"
# on Windows).
set_target_properties (${target_name} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python/site-packages
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python/site-packages
)
install (TARGETS ${target_name}
RUNTIME DESTINATION ${PYTHON_SITE_DIR} COMPONENT user
LIBRARY DESTINATION ${PYTHON_SITE_DIR} COMPONENT user)
endmacro ()
+264
View File
@@ -0,0 +1,264 @@
# Copyright Contributors to the Open Shading Languge project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
include (CTest)
# Make a build/platform/testsuite directory, and copy the master runtest.py
# there. The rest is up to the tests themselves.
file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testsuite")
file (COPY "${CMAKE_CURRENT_SOURCE_DIR}/testsuite/common"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/testsuite")
add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/testsuite/runtest.py"
"${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" )
# add_one_testsuite() - set up one testsuite entry
#
# Usage:
# add_one_testsuite ( testname
# testsrcdir - Current test directory in ${CMAKE_SOURCE_DIR}
# testdir - Current test sandbox in ${CMAKE_BINARY_DIR}
# [ENV env1=val1 env2=val2 ... ] - env vars to set
# [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}")
if (NOT _tst_COMMAND)
set (_tst_COMMAND ${Python_EXECUTABLE} "${testsuite}/runtest.py" ${testdir})
if (MSVC_IDE)
list (APPEND _tst_COMMAND --devenv-config $<CONFIGURATION>
--solution-path "${CMAKE_BINARY_DIR}" )
endif ()
endif ()
list (APPEND _tst_ENV
OpenImageIO_ROOT=${OpenImageIO_ROOT}
OSL_SOURCE_DIR=${CMAKE_SOURCE_DIR}
OSL_BUILD_DIR=${CMAKE_BINARY_DIR}
OSL_TESTSUITE_ROOT=${testsuite}
OSL_TESTSUITE_SRC=${testsrcdir}
OSL_TESTSUITE_CUR=${testdir}
)
file (MAKE_DIRECTORY "${testdir}")
add_test ( NAME ${testname} COMMAND ${_tst_COMMAND} )
# message ("Test -- env ${_tst_ENV} cmd ${_tst_COMMAND}")
set_tests_properties (${testname} PROPERTIES ENVIRONMENT "${_tst_ENV}" )
# Certain tests are already internally multi-threaded, so to keep them
# from piling up together, allocate a few cores each.
if (${testname} MATCHES "^render-")
set_tests_properties (${testname} PROPERTIES LABELS render
PROCESSORS 4 COST 10)
endif ()
# Some labeling for fun
if (${testname} MATCHES "^texture-")
set_tests_properties (${testname} PROPERTIES LABELS texture
PROCESSORS 2 COST 4)
endif ()
if (${testname} MATCHES "noise")
set_tests_properties (${testname} PROPERTIES LABELS noise
PROCESSORS 2 COST 4)
endif ()
if (${testname} MATCHES "optix")
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)
endif()
endif ()
endmacro ()
macro ( TESTSUITE )
cmake_parse_arguments (_ats "" "LABEL;FOUNDVAR;TESTNAME" "" ${ARGN})
# If there was a FOUNDVAR param specified and that variable name is
# not defined, mark the test as broken.
if (_ats_FOUNDVAR AND NOT ${_ats_FOUNDVAR})
set (_ats_LABEL "broken")
endif ()
set (test_all_optix $ENV{TESTSUITE_OPTIX})
# Add the tests if all is well.
set (ALL_TEST_LIST "")
set (_testsuite "${CMAKE_SOURCE_DIR}/testsuite")
foreach (_testname ${_ats_UNPARSED_ARGUMENTS})
set (_testsrcdir "${_testsuite}/${_testname}")
if (_ats_TESTNAME)
set (_testname "${_ats_TESTNAME}")
endif ()
if (_ats_LABEL MATCHES "broken")
set (_testname "${_testname}-broken")
endif ()
set (ALL_TEST_LIST "${ALL_TEST_LIST} ${_testname}")
# 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")
add_one_testsuite ("${_testname}" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 )
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}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 )
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
AND (EXISTS "${_testsrcdir}/OPTIX" OR test_all_optix OR _testname MATCHES "optix")
AND NOT EXISTS "${_testsrcdir}/NOOPTIX"
AND NOT EXISTS "${_testsrcdir}/NOOPTIX-FIXME")
# Unoptimized
if (NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}.optix" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 TESTSHADE_OPTIX=1 )
endif ()
# and optimized
add_one_testsuite ("${_testname}.optix.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_OPTIX=1 )
endif ()
endforeach ()
if (VERBOSE)
message (STATUS "Added tests: ${ALL_TEST_LIST}")
endif ()
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
bug-array-heapoffsets bug-locallifetime bug-outputinit
bug-param-duplicate bug-peep bug-return
cellnoise closure closure-array color comparison
compile-buffer
component-range
connect-components
const-array-params const-array-fill
debugnan debug-uninit
derivs derivs-muldiv-clobber
draw_string
error-dupes error-serialized
exit exponential
fprintf
function-earlyreturn function-simple function-outputelem
function-overloads function-redef
geomath getattribute-camera getattribute-shader
getsymbol-nonheap gettextureinfo
group-outputs groupstring
hash hashnoise hex hyperb
ieee_fp if incdec initlist initops intbits isconnected isconstant
layers layers-Ciassign layers-entry layers-lazy layers-lazyerror
layers-nonlazycopy layers-repeatedoutputs
linearstep
logic loop matrix message
mergeinstances-duplicate-entrylayers
mergeinstances-nouserdata mergeinstances-vararray
metadata-braces miscmath missing-shader
named-components
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
noise-perlin noise-simplex
pnoise pnoise-cell pnoise-gabor pnoise-perlin
operator-overloading
opt-warnings
oslc-comma oslc-D oslc-M
oslc-err-arrayindex oslc-err-assignmenttypes
oslc-err-closuremul oslc-err-field
oslc-err-format oslc-err-funcoverload
oslc-err-intoverflow oslc-err-write-nonoutput
oslc-err-noreturn oslc-err-notfunc
oslc-err-initlist-args oslc-err-initlist-return
oslc-err-named-components
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-unknown-ctr
# oslc-pragma-warnerr
oslc-warn-commainit
oslc-variadic-macro
oslc-version
oslinfo-arrayparams oslinfo-colorctrfloat
oslinfo-metadata oslinfo-noparams
osl-imageio
paramval-floatpromotion
pragma-nowarn
printf-whole-array
raytype raytype-specialized 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
spline-boundarybug spline-derivbug
string
struct struct-array struct-array-mixture
struct-err struct-init-copy
struct-isomorphic-overload struct-layers
struct-operator-overload struct-return struct-with-array
struct-nested struct-nested-assign struct-nested-deep
ternary
testshade-expr
texture-alpha texture-alpha-derivs
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
trailing-commas
transitive-assign
transform transformc trig typecast
unknown-instruction
userdata userdata-passthrough
vararray-connect vararray-default
vararray-deserialize vararray-param
vecctr vector
wavelength_color Werror xml )
if (OPENIMAGEIO_VERSION VERSION_GREATER_EQUAL 2.1)
# I'm too lazy to set this test up to work with OIIO versions too
# old to have proper exported cmake config files. So just skip it
# for OIIO 2.0.
TESTSUITE (example-deformer)
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
# libraries to run correctly.
if (USE_PYTHON AND NOT SANITIZE_ON_LINUX)
TESTSUITE ( python-oslquery )
endif ()
# 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 "openvdb")
TESTSUITE ( texture3d )
endif()
# Only run pointcloud tests if Partio is found
if (PARTIO_FOUND)
TESTSUITE ( pointcloud pointcloud-fold )
endif ()
# Only run the OptiX tests if OptiX and CUDA are found
if (OPTIX_FOUND AND CUDA_FOUND)
TESTSUITE ( testoptix testoptix-noise example-cuda)
endif ()
endmacro()
-112
View File
@@ -1,112 +0,0 @@
# The PARSE_ARGUMENTS macro will take the arguments of another macro and define
# several variables. The first argument to PARSE_ARGUMENTS is a prefix to put
# on all variables it creates. The second argument is a list of names, and the
# third argument is a list of options. Both of these lists should be quoted.
# The rest of the PARSE_ARGUMENTS args are arguments from another macro to be
# parsed.
#
# PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...)
#
# For each item in options, PARSE_ARGUMENTS will create a variable with that
# name, prefixed with prefix_. So, for example, if prefix is MY_MACRO and
# options is OPTION1;OPTION2, then PARSE_ARGUMENTS will create the variables
# MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These variables will be set to true if
# the option exists in the command line or false otherwise.
#
# For each item in arg_names, PARSE_ARGUMENTS will create a variable with that
# name, prefixed with prefix_. Each variable will be filled with the arguments
# that occur after the given arg_name is encountered up to the next arg_name or
# the end of the arguments. All options are removed from these lists.
# PARSE_ARGUMENTS also creates a prefix_DEFAULT_ARGS variable containing the
# list of all arguments up to the first arg_name encountered.
#
# Downloaded from: http://www.itk.org/Wiki/CMakeMacroParseArguments
#
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
# Macro to set a variable with our funny overrides:
# If the variable is already set (by -D on the command line), leave it alone.
# If an environment variable of the same name is set, use that value
# (making it super easy for sites to override external tool locations).
# If neither of those, then use the default passed.
macro (setup_string name defaultval explanation)
# If the named variable already has a value (was set by -D...), leave
# it alone. But if it's not yet set...
if ("${${name}}" STREQUAL "")
# If there's an environment variable of the same name that's
# nonempty, use the env variable. Otherwise, use the default.
if (NOT $ENV{${name}} STREQUAL "")
set (${name} $ENV{${name}})
# CACHE STRING ${explanation})
else ()
set (${name} ${defaultval})
# CACHE STRING ${explanation})
endif ()
endif ()
if (VERBOSE)
message (STATUS "${name} = ${${name}}")
endif ()
endmacro ()
macro (setup_path name defaultval explanation)
# If the named variable already has a value (was set by -D...), leave
# it alone. But if it's not yet set...
if ("${${name}}" STREQUAL "")
# If there's an environment variable of the same name that's
# nonempty, use the env variable. Otherwise, use the default.
if (NOT $ENV{${name}} STREQUAL "")
set (${name} $ENV{${name}})
# CACHE PATH ${explanation})
else ()
set (${name} ${defaultval})
# CACHE PATH ${explanation})
endif ()
endif ()
if (VERBOSE)
message (STATUS "${name} = ${${name}}")
endif ()
endmacro ()
# Macro to install targets to the appropriate locations. Use this instead of
# the install(TARGETS ...) signature.
#
# Usage:
#
# install_targets (target1 [target2 ...])
#
macro (install_targets)
install (TARGETS ${ARGN} RUNTIME DESTINATION bin
LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
endmacro()
+80 -5
View File
@@ -1,10 +1,85 @@
set (public_docs osl-languagespec.pdf)
# Some day: CLA-INDIVIDUAL CLA-CORPORATE
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
install (FILES ${public_docs} DESTINATION doc COMPONENT documentation)
set (public_docs osl-languagespec.pdf
testshade.md.html
osltoy.md.html
markdeep.min.js
docs.css
)
install ( FILES "${PROJECT_SOURCE_DIR}/LICENSE"
install (FILES ${public_docs} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT documentation)
install ( FILES "${PROJECT_SOURCE_DIR}/LICENSE.md"
"${PROJECT_SOURCE_DIR}/INSTALL.md"
"${PROJECT_SOURCE_DIR}/CHANGES.md"
"${PROJECT_SOURCE_DIR}/README.md"
DESTINATION . )
DESTINATION ${CMAKE_INSTALL_DOCDIR} )
file (GLOB testshade_figures "Figures/testshade/*.jpg")
install (FILES ${testshade_figures}
DESTINATION ${CMAKE_INSTALL_DOCDIR}/Figures/testshade )
file (GLOB osltoy_figures "Figures/osltoy/*.jpg")
install (FILES ${osltoy_figures}
DESTINATION ${CMAKE_INSTALL_DOCDIR}/Figures/osltoy )
# Macro to compile a shader with oslc. Syntax is:
# docdeep_generate (SOURCE osl_source_file
# [ NAME doc_name ]
# [ DOC_LIST list_to_append_doc_filename ] )
# [ SRC_LIST list_to_append_src_filename ] )
macro (docdeep_generate)
cmake_parse_arguments (_docdeep "" "NAME;DOC_LIST;SRC_LIST" "SOURCE" ${ARGN})
# ^^ 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 ()
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
${_docdeep_SOURCE} > "${CMAKE_CURRENT_BINARY_DIR}/${mdfile}"
MAIN_DEPENDENCY ${docdeep_program}
DEPENDS ${_docdeep_SOURCE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "docdeep ${_docdeep_NAME}"
)
if (_docdeep_DOC_LIST)
list (APPEND ${_docdeep_DOC_LIST} "${CMAKE_CURRENT_BINARY_DIR}/${mdfile}")
endif ()
if (_docdeep_SRC_LIST)
list (APPEND ${_docdeep_SRC_LIST} ${_docdeep_SOURCE})
endif ()
endmacro ()
set (all_docdeep_docs "")
set (all_docdeep_srcs "")
docdeep_generate (NAME OSLQuery
SOURCE ${PROJECT_SOURCE_DIR}/src/include/OSL/oslquery.h
${PROJECT_SOURCE_DIR}/src/oslinfo/oslinfo.cpp
DOC_LIST all_docdeep_docs
SRC_LIST all_docdeep_srcs)
docdeep_generate (NAME docdeep
SOURCE ${PROJECT_SOURCE_DIR}/src/build-scripts/docdeep.py
DOC_LIST all_docdeep_docs
SRC_LIST all_docdeep_srcs)
add_custom_target (generated_docs ALL
DEPENDS ${all_docdeep_docs} ${all_docdeep_srcs}
SOURCES ${all_docdeep_srcs}
)
message (STATUS "All docdeep docs = ${all_docdeep_docs}")
install (FILES ${all_docdeep_docs}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation
)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

+13 -3
View File
@@ -1,3 +1,7 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
PDFLATEX_FLAGS = -interaction=errorstopmode ### "--shell-escape"
@@ -6,7 +10,7 @@ all: languagespec.pdf
# document making rule: use pdflatex
languagespec.pdf: *.tex languagespec.aux macros.aux Figures/*.pdf Figures/*png
languagespec.pdf: *.tex Figures/*.pdf Figures/*png
pdflatex ${PDFLATEX_FLAGS} languagespec.tex
@@ -15,8 +19,14 @@ languagespec.pdf: *.tex languagespec.aux macros.aux Figures/*.pdf Figures/*png
index: languagespec_index
languagespec_index:
pdflatex ${PDFLATEX_FLAGS} languagespec.tex
pdflatex ${PDFLATEX_FLAGS} languagespec.tex
makeindex languagespec
pdflatex ${PDFLATEX_FLAGS} languagespec.tex
pdflatex ${PDFLATEX_FLAGS} languagespec.tex languagespec.aux macros.aux
pdflatex ${PDFLATEX_FLAGS} languagespec.tex languagespec.aux macros.aux languagespec.toc
clean:
rm -f languagespec.aux languagespec.idx languagespec.ilg languagespec.ind languagespec.log
rm -f languagespec.out languagespec.pdf languagespec.toc macros.aux
.PHONY: clean
+165
View File
@@ -0,0 +1,165 @@
/* Custom stylesheet.
* Bits copied from many sources, including those that come with Markdeep.
*/
/* Custom stylesheet for API documentation by Aras Pranckevičius, http://aras-p.info/
and tweaked by Morgan McGuire.
Licensed as public domain or BSD 2-clause, whichever is more convenient for you.
Originally from https://github.com/aras-p/markdeep-docs-style */
/* Some modifications by Larry Gritz */
body {
max-width: 50em;
/* font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; */
text-align: left;
margin: 1.5em;
padding: 0 1em;
}
/* if screen is wide enough, put table of contents on the right side */
@media screen and (min-width: 64em) {
.md .longTOC, .md .mediumTOC, .md .shortTOC {
position: fixed;
max-width: 20em;
left: 54em;
display:block;
}
}
/* for narrow screens or print, hide table of contents */
@media screen and (max-width: 64em) {
.md .longTOC, .md .mediumTOC, .md .shortTOC { display: none; }
}
@media print {
.md .longTOC, .md .mediumTOC, .md .shortTOC { display: none; }
body { max-width: 100%; }
}
/* reset heading/link fonts to that of body */
.md a,
.md div.title, contents, .md .tocHeader,
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6,
.md .nonumberh1, .md .nonumberh2, .md .nonumberh3, .md .nonumberh4, .md .nonumberh5, .md .nonumberh6,
.md .shortTOC, .md .mediumTOC, .md .longTOC {
font-family: inherit;
}
.md div.title {
/*orig margin: 0.4em 0 0 0; */
margin: 0.4em 0 2em 0; /* LG */
padding: 0;
/*orig text-align: inherit; */
text-align: center; /* LG */
text-decoration: underline; /* LG */
}
.md div.subtitle {
/* orig text-align: inherit; */
text-align: center; /* LG */
}
/* faint border below headings */
.md h1, .md h2, .md h3, .md h4,
.md .nonumberh1, .md .nonumberh2, .md .nonumberh3, .md .nonumberh4 {
border-bottom: 1px solid rgba(0,0,0,.1);
}
/* heading font styles */
.md h1, .md .nonumberh1, .md div.title {
font-size: 150%;
font-weight: 600;
color: rgba(0,0,0,.7);
}
.md h2, .md .nonumberh2 {
font-size: 120%;
font-weight: 400;
color: rgba(0,0,0,.9);
}
.md h3, .md .nonumberh3 {
font-size: 110%;
font-weight: 400;
color: rgba(0,0,0,.7);
}
/* no numbering of headings */
/*.md h1:before, .md h2:before, .md h3:before, .md h4:before { content: none; }*/
/* link styling */
.md a:link, .md a:visited {
color: #3f51b5;
}
/* inline and block code */
.md code, .md pre.listing {
background-color: rgba(0,0,0,.03);
padding: 0.1em 0.2em;
border-radius: 0.15em;
}
.md pre.listing code {
background-color: transparent;
padding: 0;
border: none;
}
/* table of contents styling; make all 3 forms of it look the same */
.md .longTOC, .md .mediumTOC, .md .shortTOC {
font-size: inherit;
line-height: 120%;
margin: 1em 0;
padding: .4rem;
border-left: .1rem solid #3f51b5;
}
.md .tocHeader {
margin: 0;
padding: 0;
border: none;
font-size: inherit;
}
.md .tocNumber {
display: none;
}
.md .longTOC .level1, .md .mediumTOC .level1, .md .shortTOC .level1 {
font-weight: inherit;
padding: 0;
margin: 0;
}
.md .longTOC p, .md .mediumTOC p, .md .shortTOC p {
overflow: hidden;
text-overflow: ellipsis;
}
.md .longTOC center, .md .mediumTOC center, .md .shortTOC center {
text-align: left;
}
.md .longTOC b, .md .mediumTOC b, .md .shortTOC b {
font-weight: 400;
}
.md .longTOC a, .md .mediumTOC a, .md .shortTOC a {
color: black;
}
.md .longTOC .level1, .md .mediumTOC .level1, .md .shortTOC .level1,
.md .longTOC .level2, .md .mediumTOC .level2, .md .shortTOC .level2,
.md .longTOC .level3, .md .mediumTOC .level3, .md .shortTOC .level3 {
white-space: nowrap;
margin: 0;
padding: 0;
font-size: 90%;
}
/* tables; use fainter colors than regular markdeep style */
.md table.table {
font-size: 90%;
}
.md table.table th {
border: none;
background-color: #ccc;
color: rgba(0,0,0,.6);
}
.md table.table tr, .md table.table td {
border-color: #eee;
}
.md table.table tr:nth-child(even) {
background-color: #f4f4f4;
}
+411 -164
View File
@@ -1,3 +1,8 @@
% Copyright 2009-present Contributors to the Open Shading Language project.
% SPDX-License-Identifier: CC-BY-4.0
% SPDX-License-Identifier: BSD-3-Clause
% https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
\documentclass[11pt,letterpaper]{book}
\setlength{\oddsidemargin}{0.5in}
\setlength{\topmargin}{0in}
@@ -21,7 +26,7 @@
\usepackage{xspace}
%\usepackage{multicol}
%\usepackage{color}
\usepackage{html}
\usepackage{hyperref}
%\usepackage{version}
\usepackage{makeidx}
\usepackage[chapter]{algorithm}
@@ -43,31 +48,31 @@
\def\langname{Open Shading Language\xspace}
\def\product{{\sffamily Open Shading Language}\xspace}
\def\versionnumber{1.7}
\def\versionnumber{1.11}
\def\productver{\product\ {\sffamily \versionnumber}\xspace}
\title{
\title{
{\Huge{\bf \product}
%\textregistered\
{\bf\sffamily \versionnumber} \medskip \\ \huge
%\textregistered\
{\bf\sffamily \versionnumber} \medskip \\ \huge
Language Specification
%\\ \large (CONFIDENTIAL --- draft in progress)
} \bigskip }
\author{
\copyright\ Copyright 2009-2016 Sony Pictures Imageworks Inc., et al. All rights reserved.
\copyright\ Copyright 2009-present Contributors to the Open Shading Language project. \\
All rights reserved.
\bigskip \\
\vspace{1in} \\
Editor: Larry Gritz \\
\emph{lg@imageworks.com}
}
\date{{\large Date: 14 Jan, 2016 \\
(with corrections, 5 Jul 2016)
\date{{\large Date: 11 Aug 2020 \\
(with corrections, 24 Nov 2021)
}
\bigskip
\bigskip
\bigskip
\bigskip
\bigskip
}
@@ -103,6 +108,7 @@ Editor: Larry Gritz \\
\def\pnoise{{\cf pnoise()}\xspace}
\def\psnoise{{\cf psnoise()}\xspace}
\def\cellnoise{{\cf cellnoise()}\xspace}
\def\hashnoise{{\cf hashnoise()}\xspace}
\def\illuminance{{\cf illuminance}\xspace}
\def\illuminate{{\cf illuminate}\xspace}
@@ -129,8 +135,8 @@ documentation are:
\vspace*{0.2in}
Copyright (c) 2009-2016 Sony Pictures Imageworks Inc., et al.
All Rights Reserved.
Copyright \textcopyright\ 2009-present, Contributors to the Open Shading
Language project. All Rights Reserved.
\vspace{0.5in}
@@ -149,7 +155,7 @@ met:
\item Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
\item Neither the name of Sony Pictures Imageworks nor the names of its
\item Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
\end{itemize}
@@ -170,12 +176,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\vspace{0.5in}
This specification and other text documentation about Open Shading
Language is licensed under a the Creative Commons Attribution 3.0
Language is licensed under a the Creative Commons Attribution 4.0
Unported License. \\
\smallskip
\spc \includegraphics[width=0.85in]{Figures/CC-30BY.png}
\spc http://creativecommons.org/licenses/by/3.0/
\spc \includegraphics[width=0.85in]{Figures/CC-BY.png}
\spc http://creativecommons.org/licenses/by/4.0/
\bigskip
@@ -233,7 +239,7 @@ find are different in OSL compared to other languages:
\subsubsection*{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
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.
@@ -242,7 +248,7 @@ find are different in OSL compared to other languages:
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
``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
@@ -251,17 +257,17 @@ find are different in OSL compared to other languages:
\subsubsection*{Surface and volume shaders do not loop over lights or shoot rays.}
There are no "light loops" or explicitly traced rays in OSL surface
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
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 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
@@ -284,7 +290,7 @@ find are different in OSL compared to other languages:
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
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
@@ -303,7 +309,7 @@ find are different in OSL compared to other languages:
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
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).
@@ -329,7 +335,7 @@ find are different in OSL compared to other languages:
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
points, but rather by ``automatic differentiation,'' computing partial
differentials for the variables that lead to derivatives, without any
intervention required by the shader writer.
@@ -339,27 +345,19 @@ find are different in OSL compared to other languages:
\section*{Acknowledgments}
The main developers of OSL are (in order of joining the project):
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.
\vspace*{0.2in}
Larry Gritz
Cliff Stein
Chris Kulla
Alejandro Conty
Jay Reynolds
Solomon Boulos
Adam Martinez
Brecht Van Lommel
\vspace*{0.2in}
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
@@ -373,22 +371,22 @@ 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.
(I hope to mention them by name after we get permission of the people
and studios involved.)
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.
\bigskip
\bigskip
The open source OSL implementation incorporates or depends upon several
other open source packages:
\begin{itemize}
\item {\cf OpenImageIO} \copyright\ 2008 Larry Gritz et al.
{\cf http://openimageio.org}
\url{http://openimageio.org}
\item Ilmbase \copyright\ 2006, Industrial Light \& Magic.
{\cf http://www.openexr.com}
\item Boost \copyright\ various authors. {\cf http://www.boost.org}
\url{http://www.openexr.com}
\item Boost \copyright\ various authors. \url{http://www.boost.org}
\item LLVM \copyright\ 2003-2010 University of Illinois at
Urbana-Champaign. {\cf http://llvm.org}
Urbana-Champaign. \url{http://llvm.org}
\end{itemize}
These other packages are all distributed under licenses that allow them
@@ -546,6 +544,8 @@ source code:
\item {\cf source} is a {\cf float} or {\cf int} and {\cf dest} is a
\emph{triple} (the scalar value will be replicated for all three components
of the triple).
\item {\cf source} is a single component of an aggregate type (e.g. one
channel of a {\cf color}) and {\cf dest} is a {\cf float} (or vice versa).
\end{itemize}
\subsection*{Geometric primitives}
@@ -593,13 +593,6 @@ 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.
%\subsection*{Shader types}
%
%There are several types of shaders: surface, displacement, light,
%volume. The type of shader determines what it's allowed to do (for
%example, only displacement shaders can alter the surface position).
%There is also a generic kind of shader that can be used for any of the
%shader uses.
\subsection*{Shader execution state: parameter binding and global variables}
@@ -621,7 +614,7 @@ information about the renderer as a whole (rendering options, etc.).
Surface shaders (and volume shaders) do not by themselves compute the
final color of light emanating from the surface (or along a volume).
Rather, the compute a \emph{closure}, which is a symbolic representation
Rather, they compute a \emph{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
@@ -722,7 +715,7 @@ 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 \qkw{cm}, \qkw{in}, \qkw{km}",
It knows all the standard names like \qkw{cm}, \qkw{in}, \qkw{km},
etc., and can convert among any of those, as well as between named
coordinate systems. For example,
@@ -880,9 +873,21 @@ directives, including:
#pragma once
\end{code}
\noindent Additionally, the following preprocessor symbols will already be
defined by the compiler:
\smallskip
\begin{tabular}{p{1.5in} p{3.5in}}
{\cf OSL_VERSION_MAJOR} & Major version (e.g., 1) \\[0.5ex]
{\cf OSL_VERSION_MINOR} & Minor version (e.g., 9) \\[0.5ex]
{\cf OSL_VERSION_PATCH} & Patch version (e.g., 3) \\[0.5ex]
{\cf OSL_VERSION} & Combined version number = 10000*major + 100*minor + patch
(e.g., 10903 for version 1.9.3)
\end{tabular}
\chapter{Gross syntax, shader types, parameters, functions}
\chapter{Gross syntax, shader types, parameters}
\label{chap:grosssyntax}
The overall structure of a shader is as follows:
@@ -974,7 +979,7 @@ different behaviors or appearances when used on different objects.
Shader parameters are specified in the shader declaration, in
parentheses after the shader's name. This is much like the parameters
to a \languagename function (or a function in C or similar languages),
to an OSL function (or a function in C or similar languages),
except that shader parameters must have an \emph{initializer}, giving a
default value for the parameter. Shader parameter default initializers
may be expressions (i.e., may be computed rather than restricted to
@@ -1239,7 +1244,7 @@ numbers, 0 and 1 are used.
\apiitem{"checkBox"}
\vspace{12pt}
A boolean widget displayed as a checkbox. Works on strings or
numbers. With strings, "Yes" and "No" values are used, with numbers,
numbers. With strings, ``Yes'' and ``No'' values are used, with numbers,
0 and 1 are used.
\apiend
\vspace{-12pt}
@@ -1332,48 +1337,6 @@ if a \qkw{degrees} variable is passed as the argument to {\cf cos}).
\newpage
\section{Functions}
\label{sec:functions}
\index{functions!declarations}
You may define functions much like in C or C++.
\begin{quote}
\em
return-type ~ function-name ~ {\rm\cf (} optional-parameters {\rm\cf )} \\
\rm
{\cf \{ } \\
\em
\spc statements
{\cf \} }
\end{quote}
Parameters to functions are similar to shader parameters, except that
they do not permit initializers. A function call must pass values for
all formal parameters. Function parameters in \langname are all
\emph{passed by reference}, and are read-only within the body of the
function unless they are also designated as {\cf output} (in the same
manner as output shader parameters).
Like for shaders, statements inside functions may be actual executions
(assignments, function call, etc.), local variable declarations (visible
only from within the body of the function), or local function
declarations (callable only from within the body of the function).
The return type may be any simple data type, a {\cf struct}, or a {\cf
closure}. Functions may not return arrays. The return type may be
{\cf void}, indicating that the function does not return a value (and
should not contain a {\cf return} statement). A {\cf return} statement
inside the body of the function will halt execution of the function at
that point, and designates the value that will be returned (if not a
{\cf void} function).
Functions may be \emph{overloaded}. That is, multiple functions may be
defined to have the same name, as long as they have differently-typed
parameters, so that when the function is called the list of arguments
can disambiguate which version of the function is desired.
\section{Public methods}
\label{sec:publicmethods}
\indexapi{public}
@@ -1486,7 +1449,7 @@ operation & result & ~ \\
{\ce ++} \inttype & \inttype & pre-increment by 1 \\[0.5ex]
{\ce --} \inttype & \inttype & pre-decrement by 1 \\[0.5ex]
{\cf {\bfseries -} int} & \inttype & unary negation \\[0.5ex]
\verb|~| {\cf int} & \inttype & bitwise complement (1 and 0 bits flipped) \\[0.5ex]
{\ce \textasciitilde} {\cf int} & \inttype & bitwise complement (1 and 0 bits flipped) \\[0.5ex]
{\cf {\bfseries !} int} & \inttype & boolean `not' (1 if operand is zero, otherwise 0) \\[0.5ex]
\hline
{\cf int {\bfseries *} int} & \inttype & multiplication \\[0.5ex]
@@ -1515,7 +1478,7 @@ else 0 \\[0.5ex]
\hline
{\cf int {\bfseries \&} int} & \inttype & bitwise and \\[0.5ex]
\hline
{\cf int {\bfseries \verb|^|} int} & \inttype & bitwise exclusive or \\[0.5ex]
{\cf int {\bfseries \textasciicircum} int} & \inttype & bitwise exclusive or \\[0.5ex]
\hline
{\cf int {\bfseries |} int} & \inttype & bitwise or \\[0.5ex]
\hline
@@ -1663,6 +1626,16 @@ Colors can have their individual components examined and set using the
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
{\cf r}, {\cf g}, and {\cf b}, as synonyms for {\cf [0]}, {\cf [1]}, and
{\cf [2]}, respectively:
\begin{code}
float green = C.g; // get the green component
C.r = 0.5; // set the red component
\end{code}
The following operators may be used with \color values (in order of
decreasing precedence, with each box holding operators of the same
precedence):
@@ -1824,6 +1797,16 @@ the {\cf []} array access notation. For example:
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
{\cf x}, {\cf y}, and {\cf z}, as synonyms for {\cf [0]}, {\cf [1]}, and
{\cf [2]}, respectively:
\begin{code}
float yval = P.y; // get the [1] or y component
P.x = 0.5; // set the [0] or x component
\end{code}
The following operators may be used with point-like values (in order of
decreasing precedence, with each box holding operators of the same
precedence):
@@ -1902,8 +1885,8 @@ reference to a named space:
\end{code}
\noindent The first form creates the matrix that transforms points from
\commonspace to \shaderspace. Transforming points by this matrix
is identical to calling {\cf transform("shader",...)}.
\shaderspace to \commonspace. Transforming points by this matrix
is identical to calling {\cf 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 {\cf "shader"} and {\cf "world"}
@@ -2064,35 +2047,71 @@ using the `dot' operator. The syntax for declaring and using structures
is similar to C or C++:
\begin{code}
struct ray { // Define a structure type
point pos;
vector dir;
struct RGBA { // Define a structure type
color rgb;
float alpha;
};
ray r; // Declare a structure
r.pos = point (1, 0, 0); // Assign to one field
point p = r.pos; // Read from a structure field
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
\end{code}
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 permitted for one
structure to have a field that is another structure. For example:
You can use ``constructor expressions'' for a your struct types much like
you can construct built-in types like \color or \point:
\vspace{10pt}
\hspace{0.25in} \emph{struct\_name ( first\_member\_value, ... )}
\vspace{10pt}
\noindent For example,
\begin{code}
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));
\end{code}
You may also use the \emph{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:
\begin{code}
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
\end{code}
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).
\begin{code}
struct A {
color a;
float b[4]; // struct may contain an array
float b[4]; // Ok: struct may contain an array
};
A d[5]; // Array of structures
color e = d[0].a; // Field of one element of array of struct
d[2].b[4] = 0.25; // Element of a field of a struct in an array
RGBA vals[4]; // Ok: Array of structures
vals[0].a = 0;
A d[5]; // NO: Array of structures that contain arrays
\end{code}
%\begin{annotate}
%\QUESTION Is this restriction (no ``structure recursion'') acceptable?
%It certainly makes the implementation of the language easier.
%\end{annotate}
\index{types|)} % end of chapter
@@ -2121,7 +2140,7 @@ At present, the only type of \closure supported by \langname is the
form a linear combination of \colorclosure's. Additional closure types
and operations are reserved for future use.
Allowable operations on \colorclosure's include:
Allowable operations on \colorclosure include:
\medskip
\noindent \begin{tabular}{|p{2.25in}|p{1.25in}|p{1.75in}|}
@@ -2364,7 +2383,7 @@ variable, then return the new value.
\begin{tabbing}
\hspace{0.25in} {\cf -} \emph{expr} \hspace{1in} \= (negation) \\
\hspace{0.25in} \verb|~| \emph{expr} \> (bitwise complement) \\
\hspace{0.25in} {\cf \textasciitilde} \emph{expr} \> (bitwise complement) \\
\hspace{0.25in} \emph{expr} {\cf *} \emph{expr} \> (multiplication) \\
\hspace{0.25in} \emph{expr} {\cf /} \emph{expr} \> (division) \\
\hspace{0.25in} \emph{expr} {\cf +} \emph{expr} \> (addition) \\
@@ -2374,7 +2393,7 @@ variable, then return the new value.
\hspace{0.25in} \emph{expr} {\cf >>} \emph{expr} \> (integer shift right) \\
\hspace{0.25in} \emph{expr} {\cf \&} \emph{expr} \> (bitwise and) \\
\hspace{0.25in} \emph{expr} {\cf |} \emph{expr} \> (bitwise or) \\
\hspace{0.25in} \emph{expr} \verb|^| \emph{expr} \> (bitwise exclusive or) \\
\hspace{0.25in} \emph{expr} {\cf \textasciicircum} \emph{expr} \> (bitwise exclusive or) \\
\end{tabbing}
The operators {\cf +}, {\cf -}, {\cf *}, {\cf /}, and the unary {\cf -}
@@ -2387,7 +2406,7 @@ multiplication and matrix multiplication by the inverse of another
matrix.
The integer and bit-wise operators {\cf \%}, {\cf <<}, {\cf >>},
{\cf \&}, {\cf |}, {\cf \verb|^|}, and {\cf \verb|~|} may only be
{\cf \&}, {\cf |}, {\cf \textasciicircum}, and {\cf \textasciitilde} may only be
used with expressions of type \inttype.
For details on which operators are allowed, please consult the operator
@@ -2607,7 +2626,10 @@ altogether, and the {\cf continue} statement skip to the end of the body
and proceeds to the next iteration of the loop.
\section{Functions}
\label{sec:syntax:functions}
\label{sec:functions}
\subsection{Function calls}
\label{sec:syntax:functioncalls}
\index{function calls}
Function calls are very similar to C and related programming languages:
@@ -2626,8 +2648,115 @@ will not be noticeably different from C-style ``pass by value''
semantics, except if you pass the same variable as two separate
arguments to a function that modifies an argument's value.
Function definitions are described in detail in Section~\ref{sec:functions}.
\subsection{Function definitions}
\label{sec:syntax:functiondefinitions}
\index{functions!definitions}
You may define functions much like in C or C++.
\begin{quote}
\em
return-type ~ function-name ~ {\rm\cf (} optional-parameters {\rm\cf )} \\
\rm
{\cf \{ } \\
\em
\spc statements
{\cf \} }
\end{quote}
Parameters to functions are similar to shader parameters, except that
they do not permit initializers. A function call must pass values for
all formal parameters. Function parameters in \langname are all
\emph{passed by reference}, and are read-only within the body of the
function unless they are also designated as {\cf output} (in the same
manner as output shader parameters).
Like for shaders, statements inside functions may be actual executions
(assignments, function call, etc.), local variable declarations (visible
only from within the body of the function), or local function
declarations (callable only from within the body of the function).
The return type may be any simple data type, a {\cf struct}, or a {\cf
closure}. Functions may not return arrays. The return type may be
{\cf void}, indicating that the function does not return a value (and
should not contain a {\cf return} statement). A {\cf return} statement
inside the body of the function will halt execution of the function at
that point, and designates the value that will be returned (if not a
{\cf void} function).
Functions may be \emph{overloaded}. That is, multiple functions may be
defined to have the same name, as long as they have differently-typed
parameters, so that when the function is called the list of arguments can
select which version of the function is desired. When there are multiple
potential matches, function versions whose argument types match exactly are
favored, followed by those that match with type coercion (for example,
passing an {\cf int} when the function expects a {\cf float}, or passing a
{\cf float} when the function expects a \color), and finally by trying to
match the return value to the type of variable the result is assigned to.
\subsection{Operator overloading}
\label{sec:syntax:operatoroverloading}
\index{operator overloading}
OSL permits \emph{operator overloading}, which is the practice of providing
a function that will be called when you use an operator like {\cf +} or
{\cf *}. This is especially handy when you use {\cf struct} to define
mathematical types and wish for the usual math operators to work with them.
Here is a typical example, which also shows the special naming convention
that allows operator overloading:
\begin{code}
struct vector4 {
float x, y, z, w;
};
vector4 __operator__add__ (vector4 a, vector4 b) {
return vector4 (a.x+b.x, a.y+b.y, a.z+b.z, a.w+b.w);
}
shader test ()
{
vector4 a = vector4 (.2, .3, .4, .5);
vector4 b = vector4 (1, 2, 3, 4);
vector4 c = a + b; // Will call __operator__add__(vector4,vector4)
printf ("a+b = %g %g %g %g\n", c.x, c.y, c.z, c.w);
}
\end{code}
\noindent The full list of these special function names is as follows (in
order of decreasing operator precedence):
\smallskip
\begin{tabular}{ p{0.5in} p{2in} p{1.75in}}
%op & overload function name & ~ \\
%\hline
{\cf \bfseries -} & {\cf __operator__neg__} & unary negation \\
{\cf \bfseries \textasciitilde} & {\cf __operator__compl__} & unary bitwise complement \\
{\cf \bfseries !} & {\cf __operator__not__} & unary boolean `not' \\[1.5ex]
{\cf \bfseries *} & {\cf __operator__mul__} & \\
{\cf \bfseries /} & {\cf __operator__div__} & \\
{\cf \bfseries \%} & {\cf __operator__mod__} & \\
{\cf \bfseries +} & {\cf __operator__add__} & \\
{\cf \bfseries -} & {\cf __operator__sub__} & \\[1.5ex]
{\cf \bfseries <<} & {\cf __operator__shl__} & \\
{\cf \bfseries >>} & {\cf __operator__shr__} & \\[1.5ex]
{\cf \bfseries <} & {\cf __operator__lt__} & \\
{\cf \bfseries <=} & {\cf __operator__le__} & \\
{\cf \bfseries >} & {\cf __operator__gt__} & \\
{\cf \bfseries >=} & {\cf __operator__ge__} & \\
{\cf \bfseries ==} & {\cf __operator__eq__} & \\
{\cf \bfseries !=} & {\cf __operator__ne__} & \\[1.5ex]
{\cf \bfseries \&} & {\cf __operator__bitand__} & \\
{\cf \bfseries \textasciicircum} & {\cf __operator__xor__} & \\
{\cf \bfseries |} & {\cf __operator__bitor__} & \\
%{\cf \bfseries \&\&} & {\cf __operator__and__} & boolean and \\
%{\cf \bfseries ||} & {\cf __operator__or__} & boolean or \\
%\hline
\end{tabular}
\section{Global variables}
@@ -2901,6 +3030,11 @@ Returns the exponent of x, as a floating-point number.
Computes $\sqrt{x}$ and $1/\sqrt{x}$. Returns 0 if $x<0$.
\apiend
\apiitem{\emph{type} {\ce cbrt} (\emph{type} x)}
\indexapi{cbrt()}
Computes $\sqrt[3]{x}$. The sign of the return value will match $x$.
\apiend
\apiitem{float {\ce hypot} (float x, float y) \\
float {\ce hypot} (float x, float y, float z)}
\indexapi{hypot()}
@@ -2930,7 +3064,7 @@ Returns 1 if $x>0$, -1 if $x<0$, 0 if $x=0$.
\emph{type} {\ce trunc} (\emph{type} x) }
\indexapi{floor()} \indexapi{ceil()} \indexapi{round()} \indexapi{trunc()}
Various rouinding methods: {\cf floor} returns the largest integer less
Various rounding methods: {\cf floor} returns the largest integer less
than or equal to $x$; {\cf ceil} returns the smallest integer greater than
or equal to $x$; {\cf round} returns the closest integer to $x$, in
either direction; and {\cf trunc} returns the integral part of $x$
@@ -2977,6 +3111,18 @@ The {\cf mix} function returns a linear blending :
$ x*(1-\alpha) + y*(\alpha) $
\apiend
\apiitem{\emph{type} {\ce select} (\emph{type} x, \emph{type} y, \emph{type} cond) \\
\emph{type} {\ce select} (\emph{type} x, \emph{type} y, float cond) \\
\emph{type} {\ce select} (\emph{type} x, \emph{type} y, int cond)}
\indexapi{mix()}
The {\cf select} function returns {\cf x} if {\cf cond} is zero, or {\cf y}
if {\cf cond} is nonzero. This is roughly equivalent to {\cf (cond ? y : x)},
except that if {\cf cond} is a component-based type (such as {\cf color}),
the selection happens on a component-by-component basis. It is presumed
that the underlying implementation is not a true conditional and will not
incur any branching penalty.
\apiend
\apiitem{int {\ce isnan} (float x) \\
int {\ce isinf} (float x) \\
int {\ce isfinite} (float x)}
@@ -3130,10 +3276,12 @@ and {\cf eta} is the ratio of refractive index of the medium
containing {\cf I} to that on the opposite side of the surface.
\apiend
\apiitem{point {\ce rotate} (point Q, float angle, point P0, point P1)}
\apiitem{point {\ce rotate} (point Q, float angle, point P0, point P1) \\
point {\ce rotate} (point Q, float angle, vector axis)}
\indexapi{rotate()}
Returns the point computed by rotating point {\cf Q} by {\cf angle}
radians about the axis that passes from point {\cf P0} to {\cf P1}.
Returns the point computed by rotating point {\cf Q} by {\cf angle}
radians about the axis that passes from point {\cf P0} to {\cf P1},
or about the {\cf axis} vector centered on the origin.
\apiend
\apiitem{\emph{ptype} {\ce transform} (string tospace, \emph{ptype} p) \\
@@ -3329,23 +3477,33 @@ The \emph{type} may be any of of \float, \color, \point, \vector, or
performed component-by-component (separately for $x$, $y$, and $z$).
\apiend
\apiitem{float {\ce linearstep} (float edge0, float edge1, float x)}
\apiitem{float {\ce linearstep} (float edge0, float edge1, float x) \\
\emph{type} {\ce linearstep} (\emph{type} edge0, \emph{type} edge1, \emph{type} x)}
\indexapi{linearstep()}
Returns 0 if $x \le {\mathit edge0}$, and 1 if $x \ge {\mathit edge1}$,
and performs a linear
interpolation between 0 and 1 when ${\mathit edge0} < x < {\mathit edge1}$.
This is equivalent to {\cf step(edge0, x)} when {\cf edge0 == edge1}.
For \color and \point-like types, the computations are
performed component-by-component (separately for $x$, $y$, and $z$).
\apiend
\apiitem{float {\ce smoothstep} (float edge0, float edge1, float x)}
\apiitem{float {\ce smoothstep} (float edge0, float edge1, float x) \\
\emph{type} {\ce smoothstep} (\emph{type} edge0, \emph{type} edge1, \emph{type} x)}
\indexapi{smoothstep()}
Returns 0 if $x \le {\mathit edge0}$, and 1 if $x \ge {\mathit edge1}$,
and performs a smooth Hermite
interpolation between 0 and 1 when ${\mathit edge0} < x < {\mathit edge1}$.
This is useful in cases where you would want a thresholding function
with a smooth transition.
The \emph{type} may be any of of \float, \color, \point, \vector, or
\normal. For \color and \point-like types, the computations are
performed component-by-component.
\apiend
\apiitem{float {\ce smooth_linearstep} (float edge0, float edge1, float x, float eps)}
\apiitem{float {\ce smooth_linearstep} (float edge0, float edge1, float x, float eps) \\
\emph{type} {\ce smooth_linearstep} (\emph{type} edge0, \emph{type} edge1, \emph{type} x, \emph{type} eps)}
\indexapi{smooth_linearstep()}
This function is strictly linear between ${\mathit edge0}+{\mathit eps}$ and ${\mathit edge1}-{\mathit eps}$
but smoothly ramps to 0 between ${\mathit edge0}-{\mathit eps}$ and ${\mathit edge0}+{\mathit eps}$
@@ -3353,6 +3511,8 @@ and smoothly ramps to 1 between ${\mathit edge1}-{\mathit eps}$ and ${\mathit ed
It is 0 when $x \le {\mathit edge0}-{\mathit eps}$, and 1 if $x \ge {\mathit edge1}+{\mathit eps}$,
and performs a linear
interpolation between 0 and 1 when ${\mathit edge0} < x < {\mathit edge1}$.
For \color and \point-like types, the computations are
performed component-by-component.
\apiend
@@ -3404,6 +3564,14 @@ large-scale average is 0.5, and its values are evenly distributed over
$[0,1]$.
\apiend
\apiitem{"hash"}
\vspace{12pt}
A function that returns a different, uncorrelated (but deterministic and
repeatable) value at every real input coordinate. The range is $[0,1]$, its
large-scale average is 0.5, and its values are evenly distributed over
$[0,1]$.
\apiend
\apiitem{"simplex"}
\vspace{12pt}
A signed simplex noise with an output range of $[-1,1]$,
@@ -3544,29 +3712,29 @@ The old {\cf cellnoise(...coords...)} function is equivalent to
{\cf noise("cell",...coords...)}.
\apiend
\begin{comment} % couldn't find a use for this
\apiitem{\emph{type} {\ce hash} (float u) \\
\emph{type} {\ce hash} (float u, float v) \\
\emph{type} {\ce hash} (point p) \\
\emph{type} {\ce hash} (point p, float t) \\
\emph{type} {\ce hash} (int i) \\
\emph{type} {\ce hash} (string s)}
\indexapi{hash()}
\apiitem{\emph{type} {\ce hashnoise} (float u) \\
\emph{type} {\ce hashnoise} (float u, float v) \\
\emph{type} {\ce hashnoise} (point p) \\
\emph{type} {\ce hashnoise} (point p, float t)}
\indexapi{hashnoise()}
Returns a deterministic, repeatable \emph{hash} of the 1-, 2-, 3-, or
4-D coordinates, integer, or string. The return values will be evenly
4-D coordinates. The return values will be evenly
distributed on $[0,1]$ and be completely repeatable when passed the same
coordinates again, yet will be uncorrellated to hashes of any other
positions (including nearby points). This is like having a random value
indexed spatially, but that will be repeatable from frame to frame of an
animation (provided its input is \emph{precisely} identical).
The return \emph{type} may be any of \float, \color, \point, \vector, or
\normal, depending on the type of the variable the result is assigned to
(or based on an explicit type cast). For multi-component return types
(e.g., \point), each component is an uncorrelated \float\ {\cf hash}
function.
\apiend
\end{comment}
\apiitem{int {\ce hash} (float u) \\
int {\ce hash} (float u, float v) \\
int {\ce hash} (point p) \\
int {\ce hash} (point p, float t) \\
int {\ce hash} (int i)}
\indexapi{hash()}
Returns a deterministic, repeatable integer \emph{hash} of the 1-, 2-, 3-,
or 4-D coordinates.
\apiend
\apiitem{\emph{type} {\ce spline} (string basis, float x, \emph{type} $\mathtt{y}_0$, \emph{type} $\mathtt{y}_1$, ... \emph{type} $\mathtt{y}_{n-1}$)\\
\emph{type} {\ce spline} (string basis, float x, \emph{type} y[]) \\
@@ -3588,8 +3756,10 @@ The type of interpolation is specified by the \emph{basis} name,
\qkw{bezier}, \qkw{bspline}, \qkw{hermite}, \qkw{linear}, or
\qkw{constant}. Some basis
types require particular numbers of knot values -- Bezier splines
require $4n+3$ values, Hermite splines require $4n+2$ values,
Catmull-Rom and linear splines may use any number of values $n\ge 4$.
require $3n+1$ values, Hermite splines require $2n+2$ values, and all of
Catmull-Rom, linear, and constant requires $3+n$, where in all cases,
$n \ge 1$ is the number of spline segments.
To maintain consistency with the other spline types, \qkw{linear} splines will
ignore the first and last data value; interpolating piecewise-linearly
between $y_1$ and $y_{n-2}$, and \qkw{constant} splines ignore the first
@@ -3904,7 +4074,7 @@ Identical to {\cf regex_search}, except that it must match the
Perform a texture lookup of an image file, indexed by 2D coordinates
$(s,t)$, antialiased over a region defined by the differentials
\emph{dsdx, dtdx, dsty} and \emph{dtdy} (which are computed
\emph{dsdx, dtdx, dsdy} and \emph{dtdy} (which are computed
automatically from $s$ and $t$, if not supplied). Whether the results
are assigned to a \float or a \color (or type cast to one of those)
determines whether the texture lookup is a single channel or three
@@ -3992,6 +4162,15 @@ variable specified. This allows for RGBA lookups in a single call to
\apiend
\vspace{-16pt}
\apiitem{"errormessage", <stringvariable>}
\vspace{12pt}
If this option is supplied, any error messages generated by the texture
system will be stored in the specified variable rather than issuing error
calls to the renderer, thus leaving it up to the shader to handle any
errors. The error message stored will be \qkw{} if no error occurred.
\apiend
\vspace{-16pt}
\apiitem{"interp", <string>}
\vspace{12pt}
Overrides the texture interpolation method: \qkw{smartcubic} (the
@@ -4068,6 +4247,14 @@ The first channel to look up from the texture map (default: 0).
\apiend
\vspace{-16pt}
\apiitem{"subimage", <int> \\
"subimage", <string>}
\vspace{12pt}
Specify the subimage (by numerical index, or name) of the subimage
within a multi-image texture file (default: subimage 0).
\apiend
\vspace{-16pt}
\apiitem{"fill", <float>}
\vspace{12pt}
The value to return for any channels that are requested,
@@ -4101,6 +4288,15 @@ variable specified. This allows for RGBA lookups in a single call to
\apiend
\vspace{-16pt}
\apiitem{"errormessage", <stringvariable>}
\vspace{12pt}
If this option is supplied, any error messages generated by the texture
system will be stored in the specified variable rather than issuing error
calls to the renderer, thus leaving it up to the shader to handle any
errors. The error message stored will be \qkw{} if no error occurred.
\apiend
\vspace{-16pt}
\apiend
\apiitem{\emph{type} \textbf{environment} (string filename, vector R, \pl) \\
@@ -4175,6 +4371,15 @@ variable specified. This allows for RGBA lookups in a single call to
\apiend
\vspace{-16pt}
\apiitem{"errormessage", <stringvariable>}
\vspace{12pt}
If this option is supplied, any error messages generated by the texture
system will be stored in the specified variable rather than issuing error
calls to the renderer, thus leaving it up to the shader to handle any
errors. The error message stored will be \qkw{} if no error occurred.
\apiend
\vspace{-16pt}
\apiend
@@ -4304,6 +4509,15 @@ Note that the named point cloud will be created, if it does not yet
exist in memory, and that it will be initialized by reading a point
cloud from disk, if there is one matching the name.
Generally, the element type of the data arrays must match exactly the type
of the point data attribute, or else you will get a runtime error. But there
are two exceptions: (1) ``triple'' types (\color, \point, \vector, \normal)
are considered interchangeable; and (2) it is legal to retrieve {\cf float}
arrays (e.g., a point cloud attribute that is {\cf float[4]}) into a regular
array of {\cf float}, and the results will simply be concatenated into the
larger array (which must still be big enough, in total, to hold {\cf
maxpoints} of the data type in the file).
\noindent Example:
\begin{code}
@@ -4337,10 +4551,20 @@ in the following example:
int indices[10];
int n = pointcloud_search ("particles.ptc", P, r, 10,
"index", indices);
float temp[10];
float temp[10]; // presumed to be "float" attribute
float quaternions[40]; // presumed to be "float[4]" attribute
int ok = pointcloud_get ("particles.ptc", indices, n,
"temperature", temp);
"temperature", temp,
"quat", quaternions);
\end{code}
As with {\cf pointcloud_search}, the element type of the data array must
either be equivalent to the point cloud attribute being retrieved, or else
when retrieving {\cf float} arrays (e.g., a point cloud attribute
that is {\cf float[4]}) into a regular array of {\cf float}, and the
results will simply be concatenated into the larger array (which must
still be big enough, in total, to hold {\cf maxpoints} of the data type
in the file).
\apiend
@@ -4510,7 +4734,7 @@ U, \\ \bigspc\bigspc float xalpha, float yalpha, float eta, int refract)}
\indexapi{microfacet()}
Returns a \colorclosure that represents scattering on the
surface using some microfacet distribution such as "beckmann" or "ggx" (as
surface using some microfacet distribution such as \qkw{beckmann} or \qkw{ggx} (as
described in Walter et al., ``Microfacet Models for Refraction through Rough
Surfaces,'' Eurographics Symposium on Rendering, 2007).
Both {\cf xalpha} and {\cf yalpha} control how rough the microstructure of the
@@ -4526,7 +4750,7 @@ refractive ({\cf 1}) or both at once ({\cf 2}). The implementation must not rely
The list of supported distributions will change from renderer to renderer, and
also the behavior when an unsupported distribution is requested. It is up to the
implementation to issue an error or to default to a supported one. Also it is
expected that the alias "default" must work as a distribution in any renderer.
expected that the alias \qkw{default} must work as a distribution in any renderer.
\apiend
@@ -4763,8 +4987,23 @@ Tables giving ``standardized'' names for different kinds of attributes may
be found below. All renderers are expected to use the same names for these
attributes, but are free to choose any names for additional attributes they
wish to make queryable.
\apiend
\begin{table}[htbp]
\caption{Names of standard attributes that may be retrieved.}\label{tab:stdattributes}
\begin{tabular}{|p{1.8in}|p{0.6in}|p{2.8in}|}
\hline
{\bf Name} & {\bf Type} & {\bf Description} \\
\hline
{\cf "osl:version"} & {\cf int} & Major*10000 + Minor*100 + patch. \\
{\cf "shader:shadername"} & {\cf string} & Name of the shader master. \\
{\cf "shader:layername"} & {\cf string} & Name of the layer instance. \\
{\cf "shader:groupname"} & {\cf string} & Name of the shader group. \\
\hline
\end{tabular}
\end{table}
\begin{table}[htbp]
\caption{Names of standard camera attributes that may be retrieved.
If the {\cf getattribute()} function specifies an {\cf objectname} parameter
@@ -4955,7 +5194,7 @@ int {\ce dict_find} (int nodeID, string query)}
of a file containing the dictionary. (The system can easily
distinguish between them.) XML dictionaries are currently
supported, and additional formats may be supported in the future.
The query is expressed in "XPath 1.0" syntax (or a reasonable subset
The query is expressed in ``XPath 1.0'' syntax (or a reasonable subset
therof).
The return value is a \emph{Node ID}, an opaque integer identifier
@@ -5265,6 +5504,7 @@ nothing (empty, no token).
\alt <ternary-expression>
\alt <typecast-expression>
\alt <variable-ref>
\alt <compound-initializer>
<compound-expression> ::= <expression> \{ "," <expression> \}
@@ -5274,6 +5514,13 @@ nothing (empty, no token).
<variable-ref> ::= <identifier> <array-deref-opt>
<array-deref> ::= "[" <expression> "]"
<component-deref> ::= "[" <expression> "]"
\alt "." <component-field>
<component-field> ::= "x" | "y" | "z" | "r" | "g" | "b"
<binary-op> ::= "*" | "/" | "\%"
\alt "+" | "-"
\alt "<<" | ">>"
+19 -14
View File
@@ -6,6 +6,11 @@
% Please use or modify this at will.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright Contributors to the Open Shading Language project.
% SPDX-License-Identifier: BSD-3-Clause
% https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
%
% Define typesetting commands for filenames and code
%
@@ -36,11 +41,11 @@
\newenvironment{smallcode}{\small \renewcommand{\baselinestretch}{0.8} \verbatimtab}{\endverbatimtab \renewcommand{\baselinestretch}{1}}
\newenvironment{tinycode}{\footnotesize \renewcommand{\baselinestretch}{0.75} \verbatimtab}{\endverbatimtab \renewcommand{\baselinestretch}{1}}
\begin{htmlonly}
\renewenvironment{code}{\begin{verbatim}}{\end{verbatim}}
\newenvironment{smallcode}{\begin{verbatim}}{\end{verbatim}}
\newenvironment{tinycode}{\begin{verbatim}}{\end{verbatim}}
\end{htmlonly}
% \begin{htmlonly}
% \renewenvironment{code}{\begin{verbatim}}{\end{verbatim}}
% \newenvironment{smallcode}{\begin{verbatim}}{\end{verbatim}}
% \newenvironment{tinycode}{\begin{verbatim}}{\end{verbatim}}
% \end{htmlonly}
\newcommand{\includedcode}[1]{{\small \verbatimtabinput{#1}}}
\newcommand{\smallincludedcode}[1]{{\small \renewcommand{\baselinestretch}{0.8} \verbatimtabinput{#1} \renewcommand{\baselinestretch}{1}}}
@@ -76,15 +81,15 @@
%end{latexonly}
\begin{htmlonly}
\newcommand{\apiitem}[1]{\medskip \noindent {\bf #1} \begin{quote}}
\newcommand{\apiend}{\end{quote}}
\def\halfspc{\begin{rawhtml} &nbsp; &nbsp; \end{rawhtml}}
\def\spc{\halfspc\halfspc}
\pagecolor[named]{White}
\def\chapwidthbegin{\begin{rawhtml}<p><table cellspacing=1><tr><td width=550>\end{rawhtml}}
\def\chapwidthend{\begin{rawhtml}</td></tr></table>\end{rawhtml}}
\end{htmlonly}
%\begin{htmlonly}
%\newcommand{\apiitem}[1]{\medskip \noindent {\bf #1} \begin{quote}}
%\newcommand{\apiend}{\end{quote}}
%\def\halfspc{\begin{rawhtml} &nbsp; &nbsp; \end{rawhtml}}
%\def\spc{\halfspc\halfspc}
%\pagecolor[named]{White}
%\def\chapwidthbegin{\begin{rawhtml}<p><table cellspacing=1><tr><td width=550>\end{rawhtml}}
%\def\chapwidthend{\begin{rawhtml}</td></tr></table>\end{rawhtml}}
%\end{htmlonly}
\newcommand{\apibinding}[3]{\apiitem{#1\\[1ex]#2\\[1ex]#3}}
+7
View File
File diff suppressed because one or more lines are too long
Binary file not shown.
+246
View File
@@ -0,0 +1,246 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
**osltoy**
revision date: 30 Nov 2017
_osltoy_ basics
==================================================
`osltoy` is an interactive editor and realtime visualizer for OSL shaders.
It is inspired by [Shadertoy](https://www.shadertoy.com/) by Inigo Quilez.
But it uses a real VFX shading language!
![osltoy](Figures/osltoy/osltoy-fbm.jpg width="400px")
The basic functionaity of `osltoy` is:
* Allow you to edit OSL shader source code.
* Live and continuous rendering of an "image" that is the result of running
your shader on each pixel of the image (pixel color is taken from the
shader's parameter `output color Cout`.)
## Command line
Launch `osltoy` from the command line:
`osltoy` [*options*]
Additional command line arguments:
`--help`
: Print command line options and other help.
`-v`
: Verbose mode. (Doesn't really do anything currently.)
`--res` *xres* *yres* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
: Specifies the resolution of the render window (default: 512 x 512).
`--threads` *n*
: Specifies the number of simultaneous threads to use for shading. If not
specified, it will use all your hardware cores.
*filename.osl*
: If one or more filenames of shader source code are specified, they will
be loaded into editor tabs upon startup.
## osltoy Basics
First, let's launch `osltoy`:
```
$ osltoy
```
![ ](Figures/osltoy/osltoy-start.jpg width="400px")
This will start up a new `osltoy` session.
On the right half of the GUI is a code editor window. Below the code editor
is an area that will show you any compilation errors. The left half of the
GUI will display the results of the shader (a checkerboard if no shader
has been compiled yet). Below that is an area that will hold widgets to
allow adjustment of shader parameter values.
At the very bottom of the app window is a status bar showing time, frames
per second, and other status messages. At the very top of the app window
(or, on MacOS, at the top of the screen) is a menu bar with the usual set of
common operations.
### Loading and saving shaders
You can load a shader one of three ways:
1. Specify the filename of an existing shader when you launch the app:
```
osltoy test.osl
```
2. From a blank window, load an existing shader by selecting the menu
bar choice `File` --> `Open`, or hitting the hotkey `Ctrl-O` (on MacOS,
⌘`-O`). This will present a file selection dialog.
3. Just start typing in the editor window.
You can save the edited shader with the menu bar `File` --> `Save`
or the hotkey `Ctrl-S` (⌘`-S` on MacOS). If the file does not yet
have a name, you will be presented with a file save dialog (as you will
if you use `File` --> `Save As`).
!!! Note
Every time we talk about a `Ctrl-`*key* combination, if you are on MacOS
(OSX), that hotkey will be ⌘`-`*key*. This document won't awkwardly
repeat this clarification for every command.
### Compiling shaders
When you have loaded or edited your OSL source code, you can compile the
shader with menu `Tools` --> `Recompile shaders`, or by clicking the
`Recompile` button below the source code editor widget, or by using the
hotkey `Ctrl-R`.
!!! Warning
`osltoy` won't compile a buffer that doesn't have a filename ending in
`.osl`, and if you started with a blank window, it won't have a name at
all until you save the first time.
In the compilation status window below the editor, you will either see
an `Ok` message if the compiler succeeded, or the error output from the
compiler, as illustrated here:
![Compilation error display.](Figures/osltoy/osltoy-error.jpg width="512px")
!!! Warning
`osltoy` appears to let you load or create multiple shaders, appearing
in a tabbed editor. We'll get this working eventually (so you can edit
whole shader groups and all the shaders that are in them), but currently
only the shader in the first tab will be compiled and executed, so don't
get confused by the non-functional parts of the interface.
### Executing shaders and interactive changes
Once you compile the shader successfully, it will execute and display the
results of shading a rectangle.
![osltoy has executed the shader](Figures/osltoy/osltoy-fbm.jpg)
As soon as you recompile, the shader will be executed as quickly as possible
and displayed as an image on the left, with shader parameter adjustment
widgets below it.
Evey time you change a parameter value through its widget, the shader will
automatically recompile and re-execute. If you edit the text of the shader,
clicking the `Recompile` button or using the hotkey `Ctrl-R` will recompile
and re-execute the shader.
Rules of the game
==================
## Shader inputs and state
The shader is executed on every pixel of an image (defaulting to a 512x512
square, but you can change the resolution via a command line flag).
The `float u` and `v` global variables vary from 0 to 1 along the rectangle.
The `point P` global variable will be set to `(x,y,0)`, where `x` is the pixel
horizontal coordinate (0 to xres-1 as it goes from left to right) and `y`
is the pixel vertical coordinate (0 to yres-1 as it goes from top to bottom
of the image).
The `float time` global variable contains the time (in seconds) since the
last time the shader was recompiled. Making your shader change its behavior
based on the `time` variable will make an animated shader.
## Shader outputs
The color displayed is taken from the shader output parameter that is
declared like this:
```
output color Cout = 0
```
Whatever you place in that output will be the color displayed at each pixel
of the output image.
!!! Note
Your shader does not need to set `Ci` or deal with closures. The
`osltoy` app is just for exploring pattern generation, not illumination.
It doesn't actually have any notion of 3D geometry or lights.
## Shader execution
If your shader does not reference the `time` variable in any way, it will
only be executed once each time it recompiles. But if `time` appears in your
shader, it will execute repeatedly, as quickly as possible, until you exit
or recompile.
Shader execution will by default use enough threads to keep all your cores
busy. The command line option `--threads` can be used to limit the number
of cores (or to "over-thread").
Caveats, limitations, and broken stuff
========================
These are current limitations or breakages that we will fix over time.
* The GUI seems to let you open multiple editor tabs, but currently, the
only one that will compile and execute is the *first* (farthest to the left
tab that was loaded or saved under a name that ends in `".osl"`.
* We intend to add "Pause" and "Reset" buttons to control time.
* I tried to make the parameter adjustment widgets be clever about how
quickly to modify the values, depending on their range. But I don't have
it quite right. It's still being refined.
* There isn't yet have a way to get the shader itself to get information about
external events such as mouse clicks or key presses, but that would be
fun.
* There isn't yet a way for the shader to have *state* that can be computed,
stored, then re-read when the shader executes on the next frame.
Things to try
=============
* Try this:
` osltoy ` *osl_install_directory*`/shaders/mandelbrot.osl`
* Use the global `time` variable to make animated patterns.
* Explore noise functions and other pattern generation interactively.
* Explore (by keeping an eye on the "FPS" reading at the bottom) what shader
operations are fast and what is slow.
* Don't forget that `texture()` calls work as expected in shadertoy!
* `osltoy` is a great tool for leaning or *teaching* OSL.
* The actual "geometry" is just a rectangle, but like with Shadertoy,
you can make patterns that *look like* by implementing a simple ray tracer
in the shader itself, or using other clever tricks.
* Look at the many examples on [Shadertoy](https://www.shadertoy.com/)
for inspiration!
* Make crazy stuff and post the shaders to the `osl-dev` mail list!
<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js"></script><script src="https://casual-effects.com/markdeep/latest/markdeep.min.js?"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>
<link rel="stylesheet" href="docs.css?">
+3
View File
@@ -1,3 +1,6 @@
% SPDX-License-Identifier: CC-BY-4.0
% Copyright Contributors to the Open Shading Language Project.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Style developed by Larry Gritz for various books and technical
% manuals. Please distribute freely, there's nothing special here.
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More