Compare commits

...
Author SHA1 Message Date
Larry Gritz 6b7e81fd43 Stage v1.13.2.4-dev 2023-04-14 10:24:57 -07:00
Larry Gritz edf079ce6d Temp fix for 1670 to be backported to this branch 2023-04-14 10:24:57 -07:00
cmstein 2754fa2a08 fix for ReParameterization corner case (#1670)
Take into account whether a parameter can change due to interactivity
when comparing parameters for "mergeability".

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

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

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

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2023-04-14 10:05:05 -07:00
Chris Hellmuth 56a6099de1 Apply recent run layer call optimization to batched execution (#1669)
Copy-paste the run layer call checks from #1665 into the batched execution mode.

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-04-14 10:04:48 -07:00
Larry Gritz 86050991c4 Clean up OptiX comments (#1666)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-14 10:04:33 -07:00
Chris Hellmuth 4478b290d1 Don't insert redundant run layer calls inside a basic block (#1665)
This patch is a very simple part one of work to optimize the number of conditional run layer calls that OSL makes, which take the form:

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

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

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

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

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

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

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

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

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-04-14 10:04:09 -07:00
Larry Gritz 26868c8493 Build: verify that OSL can build with clang16 (#1664)
But note: OSL does not yet work with LLVM 16.

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-04-14 10:03:57 -07:00
Larry Gritz 786e943b61 Build: Fix cuda compilation flags for LLVM 15 (#1659)
For LLVM 15+, we need to disable opaque pointers. We did this for
regular bitcode generation in llvm_macros.cmake, but neglected to make
the corresponding change for copmiling to ptx in cuda_macros.cmake.

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

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

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

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

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

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

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-04-14 10:02:25 -07:00
Larry Gritz 74be126d44 Be more careful about paths to look for llvm (1656)
In particular, `${LLVM_ROOT}/bin` will end up being (incorrectly!)
`/bin` if LLVM_ROOT is empty. That is bad if some other llvm-config
happens to be in /bin.

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

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

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

         int val = 3 + 1;

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-16 00:33:04 -07:00
Larry Gritz 4d9ef03d76 ci: Fix broken Mac CI (#1647)
Make sure LLVM_ROOT/bin (either as a cmake var or as an env var) end
up in the hints list when searching for llvm-config.

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 23:08:07 -07:00
Larry Gritz 3e2689db51 docs: Update credits
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 23:07:56 -07:00
Larry Gritz 9673b6faa2 Typo in test shaders (#1644)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-03-15 23:07:41 -07:00
Larry Gritz 9644456f0d fix: add missing fmod variants (#1643)
Apparently some varieties of fmod(triple,float) -- which were not
documented in the spec but were intended to work and did allow that
combination in oslc -- were not fully implemented in the runtime.

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-12 22:48:55 -08:00
Larry Gritz 8036e174fb Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-12 15:18:10 -08:00
danieldresser-ie b064b25721 Remove unnecessary setting of locale::global (#1636)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-12 15:14:14 -08:00
Larry Gritz 8d1d9f0cf6 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-03 17:02:40 -08:00
Larry Gritz 1c196d935c Temp workaround for botched aswftesting container yum (#1633)
It seems something in the latest builds of the aswftesting/ci-osl:2022
containers has changed, and explicitly running /usr/bin/yum (instead of
the broken /usr/local/bin/yum) fixes it for now. This was completely
breaking the icc & icx tests, which require yum to install the Intel
compilers.

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

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-16 13:39:32 -08:00
Patrick Mours fae61e699f Remove dependency on OptiX SDK for building core OSL with OptiX support (#1627)
Signed-off-by: Patrick Mours <pmours@nvidia.com>
2022-12-16 12:20:24 -08:00
Larry Gritz 7b6854823d CMake: Adjust how version overrides work (#1617)
Related to https://github.com/OpenImageIO/oiio/pull/3653

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

This patch changes the behavior as follows:

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

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

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

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

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

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

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

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

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

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

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

Nothing, it seems. So eliminate it.

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

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

Signed-off-by: Daniel Dresser <danield@image-engine.com>
2022-11-23 09:08:06 -08:00
Larry Gritz bd7fd4cf8c Checkpoint to phase 2 of the great ustringhash conversion (#1612)
Reminder: phase 1 changed the RendererServices APIs to be based
completely on ustringhash for public method calls, not ustring.

This PR starts along the path of phase 2.

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

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

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

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

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

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

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

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

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

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

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

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

* Fix ptx definitions of OSL_CONSTANT_DATA arrays

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

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

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

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

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

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

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

Some notes and guideposts:

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

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

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

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

Remove deprecated version of LLVM_Util::make_function.

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

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

get_alignment can also be OSL_DEV only as well as simplified

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

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

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

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

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

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

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

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

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

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

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

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

* Fixed LLVM representation to accommodate ShaderGlobals::shadingStateUniform.

* Added missing Copyright Contributors license to shading_state_uniform.h

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

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

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

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

Signed-off-by: Steena Monteiro <steena.monteiro@intel.com>
2022-10-06 15:29:55 -07:00
Larry Gritz bd491d025e Git rid of the last remnants of the Cuda string_table (#1600)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 14:59:13 -07:00
Alex Wells 6140c72aa6 CI: address regressions with new icx compiler (#1601)
Some explicit SIMD loops were technically illegal because each lane was not truly independent, fixed by adding "reduction" clause.  Some Mask objects had to be replaced with just "int" to allow it to be specified in the reduction clause.

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

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

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

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

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

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

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

* Exclude Imath duplicate headers from Sonar analysis.

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 18:23:09 -07:00
Larry Gritz e0a66c7bc6 Fix LPE leak in error condition (#1594)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-30 17:03:31 -07:00
Larry Gritz e4e5088ed6 LLVM 15.0 support (#1592)
* A variety of changes to get a clean build and passing tests when
  using LLVM 15.0.

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

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

IMPORTANT TO-DO / CAVEATS:

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-27 15:31:12 -07:00
Larry Gritz 4ba1678561 Fixes to compile with clang 15 (#1586)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-27 14:55:29 -07:00
Larry Gritz 8417f8eb04 CI: Move clang-format test to main section (#1588)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-27 11:24:39 -07:00
Larry Gritz 55029e388f Make testshade --help print texturesystem options and hardware info (#1584)
This was meant to work all along, which is why this patch is so small!

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

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

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

Signed-off-by: Mark Sisson <5761292+marksisson@users.noreply.github.com>
2022-09-20 15:59:32 -07:00
Larry Gritz 6588caafa6 CI: Set up a dynamic analysis test using address and leak sanitizers (#1581)
- There are a handful of tests we disable entirely with because they
  are irrelevant or just cannot be made to be clean (and that's ok).

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

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

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

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

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

    project (OSL VERSION 1.13.0.0 ...)

this patch decouples it

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

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

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

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

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

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

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

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

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

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

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

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

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

!!!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2022-08-30 10:56:55 -07:00
Larry Gritz ed5b5a2a0c Simplify clang-format call now that we include virtually everything (#1562)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 12:52:48 -07:00
Larry Gritz 37cbab5bad Sonar warning fixes and improvements (#1563)
* Minor changes to fix a couple more warnings given by SonarCloud
  static analysis.

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

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

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

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

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

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

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

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

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

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

Also slightly bump up the error tolerance for this test.

Also add one alternative that seems to frequently pop up.

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 22:23:16 -07:00
Larry Gritz c3e36affa8 CHANGES and other misc docs fixups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 17:16:11 -07:00
Larry Gritz e9a614ba53 Bump patch level 2022-08-19 19:10:20 -07:00
Larry Gritz d57a462462 GPU string fix -- needed missing cast (#1553)
Fix slightly incorrect code generation when getting a string address
for GPU.

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

Yay for static analysis!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Add test cases for dielectric, conductor and generalized schlick closures

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

* Implement refraction case in microfacet closures

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

* Update reference images

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

* Relax diff threshold on render tests

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

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

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

* Add support for sheen in the layer closure

Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-24 14:27:56 -07:00
Adrien Herubel e0d6a21438 Missing documentation for the exponent parameter in the generalized_schlick_bsdf, and missing storage for the parameter (#1539)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-24 11:29:40 -07:00
Christopher Kulla da794de6fd Implement MaterialX closure sheen_bsdf (#1537)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-20 14:12:46 -07:00
Christopher Kulla a1e941c43b Implement MaterialX closure burley_diffuse_bsdf (#1536)
Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-20 10:52:55 -07:00
Christopher Kulla 3bb41960fd Implement basic support for MaterialX closures in testrender (#1533)
* Extend the bsdf interface in testrender to use Color3 instead of float in preparation for MaterialX closures which are almost all tinted

  * Add stub parameters and IDs for all MaterialX closures

  * Register all MaterialX closure types

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

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

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

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

Update reference images for new sampler

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

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

Some details worth noting:

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

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

* A lot of clunky OptiX-only code disappears.

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

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

* Remove register_string entirely from RendererServices

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

* Remove more register_string remnants

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

* comment typo

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

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

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

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

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

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

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

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

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

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

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

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

So remove this confusing sentence.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Revise simd loop pragma for wide_transformc due to llvm14 regression

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

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

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

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

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

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

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

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

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

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

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

Added LLVM_Util::validate_global_mapping to identify unresolved globals.

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

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

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

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

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

Added better error checking for module_from_bitcode().

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

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

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

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

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

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

fancy_add_executable:

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

other:

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

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

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

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

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

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

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

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

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

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

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

* Improve support for CUDA osl_get_matrix.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Define OSL_INTEL_LLVM_COMPILER to hold an encoded Intel(r) LLVM Compiler version
(e.g. 20220000), or 0 if not an Intel(r) LLVM Compiler.
Define OSL_INTEL_CLANG_VERSION to hold the encoded Clang version the
Intel(r) LLVM Compiler is based on (e.g. 140000),
or 0 if not an Intel(r) LLVM compiler.

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

Added OSL_ANY_CLANG which is set for any clang based compiler.

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

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

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

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

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

* Added icx-vp2022 to CI plan.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* More changes to avoid non-determinism in pointcloud test results

* Add alternate reference images for point cloud results that were coming back slightly different for essentially identical distances.

* Fixed bug in llvm_gen for raytype where the wrong type was passed as a parameter for a string.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-02-19 10:17:35 -08:00
Larry Gritz 89207ef83a Fix testrender sphere tangents, per MaterialX suggestion (#1465)
Fix erroneous computation of sphere tangents

Add render-uv test to check

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-19 09:10:03 -08:00
Larry Gritz d34c3f584c Adapt to OpenEXR/Imath changing branch master -> main (#1463)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-14 14:34:57 -08:00
Larry Gritz 72d530702e CHANGES and bump version to dev snapshot v1.12.4.2
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-11 12:03:26 -08:00
Larry Gritz bf185d1245 CI and build miscellaneous fixes (#1461)
(many ported/replicated from various recent OIIO PRs)

* CI: bump to latest dependency releases

* Bugs fixed in build_opencolorio.bash, it botched some of the
  directory choices when customizing where to place and build
  it. Also, switch to the more standard BUILD_SHARED_LIBS cmake
  variable to control whether to build dynamic or static libraries.

* Correctly handle the cmake variable VISIBILITY_MAP_FILE being set to
  "" on the command line as a way to disable using the visibility map
  file entirely.

* On Linux, also set link flags `--exclude-libs ALL` to hide symbols
  from any embedded static library dependencies, to prevent clashes
  with other versions of those libraries that may be compiled into a
  DCC app.

* Some other minor touch-ups in compiler.cmake.

* Refresh build_openexr.bash with the latest changes from OIIO.

* CI workflow: revise failed build artifact storage to capture cmake
  files.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-11 12:00:30 -08:00
Larry Gritz 58a25f1bea Favor our choice of Imath includes over OIIO's. (#1460)
New OIIO guards the contents of its Imath.h with the
`OIIO_IMATH_H_INCLUDED` preprocessor symbol. This lets us in OSL
pre-define it to absolutely ensure that OSL headers are including
exactly the Imath headers they want, not accidentally getting the ones
that OIIO includes.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-02-11 11:05:22 -08:00
Larry Gritz b816c21b19 Wean ourselves off of OIIO::string_view::c_str() (#1458)
OIIO's string_view::c_str() was cute, but it's a little dicey and it's
not present in the C++20 std::string_view. We didn't use it in a ton
of places, so replace with other idioms so that in the future we are
better able to interchange with or switch to std::string_view (when
our minimum supported C++ standard is high enough).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-28 14:32:50 -08:00
Larry Gritz c476b4727d oslc: detect using type name as an variable identifier (#1457)
Here was the construct it was confused by:

    struct Data {
        float height;
    };

    Data foo(Data a, float b)
    {
        return Data;   // <----- what's this madness?
    }

Curiously, this revealed a source code error in one of our other tests,
oslc-err-struct-print, which had not been detected previously!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-27 16:56:21 -08:00
Alex Wells f7fccf6a3a Implement batched version userdata and output placement. (#1455)
Added Wide<const int, WidthT> wide_shadeindex, void* userdata_base_ptr, void* output_base_ptr to BatchedExecutor interface (and underlying implementation) that allows each data lane
of a batch to utilize a different shade index in combination with a uniform userdata and output base pointer.

Fixed bug in batched version of llvm_gen_compassign where index was being loaded as uniform value even when it was varying (really just caused assert/extra output in Release).
For scalar and batched, avoid generating code for init ops or default values when a sym_loc is found because unlike get_userdata, when supplied sym_loc can't fail.

Improved LLVM_Util::op_scatter to handle scalar destination data types, previously only wide destination were required but to handle scatter results from SOA wide data layout to AOS
output placement layout scalar destinations need to be supported.

Updated BatchedRendererServices to be less abstract replacing several pure virtual functions with default noop versions to better match behavior of RendererServices.

Changed testshade to utilize output placement by default in batched mode.
Added NOSCALAR option to testing framework to allow for batched only tests.

Added testsuite/example-batched-deformer to exercise userdata placement and simple example of utilizing batched interface.

Added alternate output for example-batched-deformer to account for some rounding differences.

Added comment to note that the batched implementation assumes that SymLocationDesc::offset is readable at point 0 (because we clamp masked off lanes to 0 vs. adding conditionals).
Renamed local variable wide_index_to_output to wide_index_for_userdata to more accurately describe how it is used.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-25 13:23:28 -08:00
Alex Wells 72acb7caf1 Implement batched versions of isnan, isinf, and isfinite. (#1456)
Implement batched versions of isnan, isinf, and isfinite.

Added batched regression testsuite ieee-fp-reg.

NOTE:  its really difficult to test isnan(value) == true,
as its unclear to actually generate a NAN in OSL because
most functions are "safe" and check/avoid NAN's

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-25 12:26:33 -08:00
Larry Gritz 40223e513b Bump version for developer preview build 2022-01-20 12:33:07 -08:00
Larry Gritz e71dfec941 CI: Bump OpenColorIO and fmt "latest" versions (#1452)
They have recently had new releases. Make our CI keep up.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-20 10:22:54 -08:00
Larry Gritz 0e4a7e6f90 Separate C++ that we build with from that we demand downstream (#1454)
We were passing along, in the exported cmake config files, a demand
for downstream clients to use a C++ standard version equal to that
which we used to build OSL itself. But that's not necessary. We may
choose to build with C++17 (for example), but all of our public APIs
are safe to use for C++14.

Split the build-time options to CMAKE_CXX_STANDARD for the standard we
build this project with, and DOWNSTREAM_CXX_STANDARD for the standard
we are declaring is the minimum to *use* the library.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-20 09:16:56 -08:00
Alex Wells 7baa2937b0 Odds and ends to enable BATCHED execution of most testsuite (#1453)
* Enable BATCHED execution of most testsuite entries that don't use closures or point cloud.

Added batched implementation of hash function.

Updated batched implementation to use the symbol.get_int(), symbol.get_float(), and symbol.get_string() methods vs. *(int*)symbol.data() approach.

Fixed bug in batched code gen where mangled symbol names were output as part of debug uninit warnings and range checking.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fixed reparameter in batched execution.
Updated batched behavior for unlocked geom shader output parameters to function like scalar version.
Fixed batched bug when non-entry layers are executed and execution masks are compared producing a <i1x16> instead of i1 for use in conditional operation.

Added more reparameter test cases to cover arrays and arrays of aggregate types.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Enabled command line assignable user data for batched execution in testshade, which fixes testsuite/userdata-passthrough
Changed print_outputs for batched execution to not use << operator which includes parenthesis, but instead output each componenet with spaces to match the non-batched print_outputs.

renamed MaskedData<...>::assign_from(void* ptr_wide_data) to assign_val_from(const void* ptr_wide_data) to better reflect that only the value is assigned, and Dx and Dy are NOT assigned.
Added MaskedData<...>::assign_all_from(const void* ptr_data) to take a scalar DataT and broadcast it to all lanes of the MaskedData, masked off lanes are NOT overwritten, and value, Dx, Dy are assigned.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Apply clang-format to wide.h
Add some paranetheses to conditional to avoid warning.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Wrapped all printf arguments with pretty() in testsuite/geomath/test.osl to avoid small floating point differences from affecting printed results in test.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Add testsuite/geomath/ref/out-alt.txt to allow for minute floating point differences with some compiler/platform combinations.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-13 15:38:43 -08:00
Larry Gritz c79e4a7a4b Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-10 14:59:39 -08:00
Larry Gritz 7f40f3687c Rebuild pdf language spec docs
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-10 13:01:34 -08:00
Larry Gritz 4c7c3922ea CHANGES and docs touchups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-10 13:00:21 -08:00
Dieter De Baets 6814224f0e windows compile fix (#1451)
Signed-off-by: Dieter De Baets <debaetsd@gmail.com>
2022-01-10 10:30:34 -08:00
Larry Gritz 0b8ddec6d9 Remove out of date MaterialX shaders (#1450)
We used to build MaterialX shaders on our end. Now it's all done in
the MaterialX project itself, and along the way, we failed to keep in
sync with them. (And even if we had "kept up", what does that even mean?
We want OSL to be independent of any particular MX release, but the MX
shaders may change from release to release. Better to be entirely on
their side of the fence.)

We turned off building these shaders by default a long
time ago, now let's finally remove the last remnants and urge everyone
to rely on the MaterialX project for this material.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-07 15:20:28 -08:00
Alex Wells 5c43516282 Add batched support for trace, setmessage, and getmessage (#1448)
Added MaskedData::assign_from(void *ptr_wide_data) to perform a masked copy of wide data at some address.
Added enum class RenderServices::TraceOpt::LLVMMemberIndex to correlate C++ data members with LLVM type generated by BatchedBackendLLVM::llvm_type_batched_trace_options()

Fixed bug in BatchedBackendLLVM::llvm_load_arg where array types where only properly broadcasting uniform to varying arguments for the 0th element of the array.

For batched implemented trace options as a LLVM type with direct code gen to alloca, init default values, and set optional values vs. callbacks.  Same code could be resused for non-batched impl.

Added BatchedMessageBuffer to context and BatchedMessageList to wide_opmessage.cpp to allow a shared buffer to be cleared by the ShadingSystem while allowing target specific compilation of SIMD import/export of message values into the list to compile in wide_opmessage.cpp.

Extended testshade's SimpleRenderer and BatchedSimpleRenderer to implement trace and getmessage to allow new tests to exercise some basic functionality.

Added new batched regression tests:
  message-reg
  trace-reg

Added new test:  message-no-closure which is a simplied version of message with no closures

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Temporarily disable simd compilation of message import and export data to test if that is cause of crash in bleeding edge CI workflow.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Temporarily disable more simd compilation of batched message test if that is cause of crash in bleeding edge CI workflow.
Temporarily run only message-reg test for bleeding edge CI workflow

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Temporarily run only message-reg.regress.batched.opt for bleeding edge CI workflow

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fix alignment of MessageBlock allocation so that reads/writes can be assumed aligned to Block<> data members

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Re-enable disabled simd statements from trouble shooting bleeding edge CI.
Re-neable all tests for bleeding edge workflow.
Applied clang-format to wide_opmessage.cpp

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-01-06 16:58:29 -08:00
Larry Gritz 450a9e37cf CI: pybind11 adjustments (#1449)
* pybind11 2.9.0 release -- bump the vfx2022 and "latest" CI tests to
  use it.
* Adjust other CI test pybind11 versions to get good coverage across all
  the pybind11 releases, and to synchronize the vfx platfom tests with
  the pybind11 release that was current for its respective year.
* Sync build_scripts/build_pybind11.bash with the latest in OIIO, including
  bumping the default pybind11 version we download to 2.8.1.
* Opportunistic touch-up of warnings about llvm version to bring
  into sync with our actual current requirements.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-01-05 13:00:20 -08:00
Larry Gritz 7e2bcbb122 RuntimeOptimizer: Fix messages & unknown_message_sent initialization (#1447)
Alex Wells pointed out that they were never explicitly initialized.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-14 18:21:46 -08:00
Larry Gritz 535b560b0d Update films and product list
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-12 15:28:29 -08:00
Larry Gritz eb35c6185a Bump LLVM minimum from 7 to 9 (#1441)
Among other cruft that existed to support versions 7 and 8, this lets
us completely get rid of PrePromoteLogicalOpsOnBitMasks custom pass,
which is only needed for LLVM < 8.

Also get rid of some cmake checks for LLVM versions that require
C++14 or higher -- not necessary now that C++14 is our minimum.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-09 12:58:38 -08:00
Alex Wells 4faeda1234 Add batched support for dict find, dict next, dict value. (#1445)
* Add batched support for dict find, dict next, dict value.
Implementation takes advantage of uniform values and only does lookup once and broadcasts results if necessary.
When nodeid is varying, it falls back to simple loop over active data lanes performing lookups.

* Added new regression test xml-reg.
Enabled BATCHED execution of existing xml test

* Add new wide_opdictionary.cpp missed in original commit

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-12-09 12:16:28 -08:00
Larry Gritz 15e0273eec Use a project-specific var for whether we're running in CI (#1446)
Maybe somebody else is building this as a subproject or has a variable
called "CI"?

* For our CI runs, set an env variable "OSL_CI" (not just generic "CI").

* Default STOP_ON_WARNING to be off for supported releases, only on by
  default for main branch where we're actively developing. Because you
  want downstream users who are building supported releases to not get
  tripped up when their compiler upgrades and there's a new warning.

* Make sure STOP_ON_WARNING is true for our CI runs, even for release
  branches -- but now check OSL_CI, not CI, in case somebody else has
  set that.

Fixes #1428

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-02 23:42:58 -08:00
Larry Gritz 5b775c7fc7 CMake tweaks (#1443)
* Make PROJECT_VERSION_RELEASE_TYPE be a cache string, so individual
  build configs or sites can override it.

* Make OSL_SUPPORTED_RELEASE be an overrideable option, and make
  OSL_DEV_RELEASE be driven by it, rather than (possibly incorrectly)
  independently set.

* Change OSL_IS_SUBPROJECT to PROJECT_IS_TOP_LEVEL (and with the opposite
  sense), to match CMake 21+ behavior. And no need to set it ourselves if
  using cmake 21+.

* All of the clang-format stuff should only apply if PROJECT_IS_TOP_LEVEL.

* Add a TIME_COMMANDS option to help debug performance of the build.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-12-01 12:20:57 -08:00
Alex WellsandLarry Gritz e7ca0926c9 Pr/batched texture (#1436)
* Add batched support for 2d texture calls, gettextureinfo.

To enable, added:
  bool RenderServices::is_udim (TextureHandle *texture_handle)
  TextureSystem::TextureHandle* BatchedRendererServices::resolve_udim_uniform(...,TextureSystem::TextureHandle*, float S, float T)
  void BatchedRendererServices::resolve_udim(...,TextureSystem::TextureHandle*,Wide<const float> wS, Wide<const float> wT, Masked<TextureSystem::TextureHandle*> wresult)

which allows batched code gen to resolve_udim's for varying S & T and bin the resulting TextureHandle* and make calls to get_texture_info_uniform with a single resolved udim texture handle, then broadcast the results to data lanes with matching TextureHandle *'s.

Added extensive new regression tests:
    gettextureinfo-reg
    gettextureinfo-udim-reg
    texture-opts-reg

Enabled BATCHED execution of existing tests:
    gettextureinfo-udim
    gettextureinfo
    texture-alpha-derivs
    texture-alpha
    texture-blur
    texture-connected-options
    texture-derivs
    texture-errormsg
    texture-firstchannel
    texture-interp
    texture-missingalpha
    texture-missingcolor
    texture-simple
    texture-smallderivs
    texture-swirl
    texture-udim
    texture-width
    texture-withderivs
    texture-wrap

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Removed some commented out includes

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Add conditional compilation dependent on OIIO version to enable RendererServices::is_udim

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fix clang-format issues

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fix bug in testing.cmake where non-existant OPENIMAGEIO_VERSION was being checked, when it should have been OpenImageIO_VERSION.

Added quiet option to oiio-tool calls in regression tests to allow produced out.txt to match between baseline and batched runs.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Added optional silent=False argument to oiiotool in test suite, allowing us to avoid generating warnings for file already exists that was causing differences when comparing baseline/out.txt and out.txt in regression tests

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Added missing batched texture option rnd for the llvm code gen representation

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Fixed compilations issues with OIIO 2.4 by enabling "rnd" batched texture option.
Fixed some other compilation issues when OSL_DEV is defined.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Cleared up some comments around populating rnd.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Add support for batched texture3d.

Discovered mismatch between documentation, llvm_gen implementation, and oslc when passing user derivatives to texture3d.
oslc and documentation expect optional parameters "vector dpdx, vector dpdy, vector dpdz",
however llvm_gen and optexture implementation only accept "vector dpdx, vector dpdy"
and use 0 for dpdz when calling into the texture subsystem.

This commit includes changes to oslc to make the compiler match the implementation of accepting only "vector dpdx, vector dpdy".

Enable BATCHED execution of testsuite/texture3d
Add new regression test textur3d-opts-reg

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Revert oslc to make the compiler match the documentation of accepting only user inputs that include dpdz:  "vector dpdx, vector dpdy, vector dpdz".
Fixed llvm_gen and optexture to properly extract user dpdz from texture3d options or initialize a Vec3(0) and pass through to texture subsystem.
Modified batched_llvm_gen and wide_optexture to properly extract user dpdz from texture3d options or initialize a Wide<Vec3>(0) and pass through to texture subsystem.
Updated texture3d-opts-reg test to pass dpdz for calls taking user derivatives.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Added batched support for environment.

Added BatchedRendererServices::environment virtual method

Added new test environment
Added new regression test environment-opt-reg

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* clang-format of batched_rendererservices.h

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Rename testsuite/environment-opts-reg to testsuite/texture-environment-opts-reg to line up with a different PR adding testsuite/texture-environment.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Removed some environment option test for "wrap" as that is an unsupported option for environment.
Added test and handling for "time" option to batched texture3d.  Current choice is to just silently ignore "time" as currently supported 3d formats do not support time.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Removed redundant environment test as texture-environment covers it.
Enabled BATCHED execution of texture-environment

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Extended test timouts further for arithmetic-reg.regress.batched.opt and transform-reg.regress.batched.opt which were causing spurious CI timeouts.
Reduced some multipliers of user supplied derivs to environment tests to reduce differences in results.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

Co-authored-by: Larry Gritz <lg@larrygritz.com>
2021-11-30 18:35:11 -08:00
Larry Gritz a33abee2ad Docs: fix missing "errormessage" explanation for environment and texture3d (#1442)
It was documnted for texture(), but not for the others, for which it
also has worked for many years.

Thanks for Alex Wells for pointing this out.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 15:57:40 -08:00
Larry Gritz 9d42d4a6f7 Testing: Adjust timeout strategy (#1440)
I recently bumped the ctest per-test timeout to 300s because one of the
batched shading regression tests was occasionally taking longer than the
prior limit of 240s.

But there is a better way: Individual tests can have their timeouts
set individually via set_tests_properties(TIMEOUT), so I raised the
timeout to 300s for all tests whose names contain "-reg", also kept it
rather long (the old 240s) for the long render tests that are all named
"render-". Then for everything else, we can actually lower the default
to 60s, since no other tests should be long-running.

(For the curious, the reason these batched regression tests are so
expensive is that they test a bunch of combinations, and they first
run the test in the non-batch scalar mode, then again in batched mode,
and compare the results to ensure that the batch code never deviates
from scalar. This makes them take at least twice as long as they
ordinarily would. But also remember that these are only run for the
few CI test matrix entries where we are specifically testing batch
shading.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 11:52:30 -08:00
Larry Gritz 81dacc2e3b Add testsuite coverage of environment() (#1438)
Can you believe we never had a test?

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 09:10:39 -08:00
Larry Gritz 1e84fc03ce Fix minor CI issues (#1439)
* Increase testing timeout, some of the batch shading regression tests
  seem to take longer than the prior 240s limit.

* Turn off OpenVDB when using the osl:2021 in combination with OpenEXR
  3.x -- the version of OpenVDB in the 2021 container is too old to
  understand OpenEXR 3.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-24 08:59:12 -08:00
Larry Gritz 5ec96f37a7 CI adjustments (#1434)
* Use LLVM 13 / clang 13 for the VFX Platform 2022 test.

* Add MacOS-11 test

* Poke around how to use arbitrary LLVM versions via Conan. (Works! But
  I have not yet enabled it.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-20 10:32:53 -08:00
Larry Gritz 748b895e05 Restore unit tests for texture3d (#1437)
OIIO master recently removed support for Field3D, which is rarely used
and the project is effectively unmaintained and isn't able to build
against the newer OpenEXR releases that we want to encourage people to
use.

So the primary purpose of this patch is to switch our unit test for
texture3d from using a field3d file (and thus would not run when using
newer OIIO) to a roughly equivalent test using openvdb (which is
supported, assuming OIIO is built in the presence of OpenVDB).

But, ha, I discovered two things, either one of which means that we
had actually not been unit testing texture3d at all lately: (1) To
discover whether the installed OIIO supported openvdb (and therefore
whether to bother running the test), we were relying on a totally
nonexistant OPENIMAGEIO_BIN cmake varaible. I don't know what that was
supposed to be (did I mean OIIOTOOL_BIN? but that also is not a
thing), but anyway, it caused it to always skip the test. (2) Oh boy,
the OIIO that we were relying on for may tests, provided by the ASWF
docker containers, was an OIIO that was not built in the presence of
OpenVDB (even though our OSL testing containers DO have OpenVDB), so
again it skipped the test because it needs that OIIO-side support for
texture3d() to know how to read openvdb files. Fix this by building
OIIO from scratch with openvdb support when doing the "VFX Platform
2022" test, rather than relying on the one in the container.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-19 23:42:37 -08:00
cmstein 1ff9aec2f1 osl_get_attribute() should use device strings when compiling for OptiX. (#1435)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-11-17 11:13:26 -08:00
Larry Gritz 47ddafda31 Raise OIIO minimum to 2.2 going forward (#1426)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 20:08:38 -08:00
Larry Gritz 0fedeb4212 CI: Update some of the 'latest' released versions we build against (#1433)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:24:54 -08:00
Larry Gritz 95def2d57b Banish the last of the sscanf calls (#1432)
Because they can fail with some locales. Replace with OIIO::Strutil
parsing functions that are locale-independent.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:24:34 -08:00
Larry Gritz 41f645902f Minor docs changes for changing master branch name to main (#1431)
Renaming the master branch to main is imminent. Here are the few
places where we refer directly to branch names that will no longer
exist.

While searching for "master/", I also noticed a couple files that
had the wrong project's copyright boilerplate on it (a lot of the
cmake scripts I write and submit to both projects simultaneously).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-07 15:22:09 -08:00
Larry Gritz 2120647911 Catch up to change in OIIO TextureOptBatch in development (#1430)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-04 23:29:54 -07:00
Larry Gritz 75d06a6c94 CI: OCIO renamed their master branch to main (#1429)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-03 16:27:13 -07:00
Larry Gritz ac544e8c9c CMake: use the more compact TARGET_NAME_IF_EXISTS to know if target exists (#1425)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-11-03 00:39:22 -07:00
Larry Gritz 6b6637e271 Fix one spot where we should have used OIIO::ofstream instead of std. (#1424)
This is primarily for the sake of mingw, but also is the proper kind
of stream to pass to OIIO::Filesystem::open.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:29:55 -07:00
Larry Gritz 0f44f46973 build: Be careful about default installation directory (#1421)
Use a cmake idiom so that you need an explicit -DCMAKE_INSTALL_PREFIX=
in order to write over /usr/local or any potentially sensitive area.
In the absence of this being set explicitly, it will configure the
cmake build so that an "install" ends up in ./dist (which is what the
Makefile wrapper did all along).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:29:31 -07:00
Larry Gritz bf02d4a98b Changes to work with LLVM 13 (#1420)
And a few places to let it compile with clang 13's new warnings.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-24 15:29:08 -07:00
Alex Wells 03a31f506e Implement spline and spline inverse for batched SIMD implementation (#1422)
Added
    template <int M00, int M01, int M02, int M03,
              int M10, int M11, int M12, int M13,
              int M20, int M21, int M22, int M23,
              int M30, int M31, int M32, int M33, int DivisorT>
    struct sfm::StaticMatrix44
to model a matrix whose elements are known at compile time.  Internally it utilizes proxys instead of floats in order to optimize for special cases of 0, 1, -1 elements and not even generate math when possible.  The StaticMatrix44 is used by wide_opspline.cpp to create specialized functions for each of the spline basis types.  A dispatch function routes the compile time optimized spline or spline inverse routine.

Altered splineimpl.h to provide "int basis_type_of(StringParam basis_name)" to allow the batched implementation to map a string to spline enum value used as an index in the dispatch function to functions optimized for each type of spline basis (instead of generic 4x4 matrix implementation)

Added "T sfm::select_val(bool cond, const T left, const T right)" as alternative to the ternary operator which appeared to possibly take address of its arguments which prevented privatization of those variables when compiled inside a SIMD loop.

Added note to BatchedAnalysis implementation identifying that local variables scope is lost between .osl and .oso and when a function is inlined multiple times, its local variables could be treated as varying when they could have been uniform if somehow identified as a local variable by the Analyzer.

Enable BATCHED testing of:
  spline-boundarybug
  spline-derivbug
  spline-nonuniformknots
  spline
  splineinverse-ident
  splineinverse

Added new BATCHED_REGRESSION tests:
  spline-reg
  splineinverse-knots-ascend-reg
  splineinverse-knots-descend-reg

Added sfm::Inverter to remove nested loop behavior of batched splineinverse as OIIO::invert has a loop which was called from inside the search interval loop, created a nested loop.  Under SIMD/SIMT the nested loop could execute incoherently.  Instead we choose to use the class sfm::Inverter to manage state between is_bracketed_by(min,max), meant to be called from the search interval loop, and bracketed_invert(min,max) meant to be called after exiting the search interval loop, avoiding a nested loop that could be executed at different interval's for each SIMD/SIMT lane/thread.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-10-18 22:13:51 -07:00
Larry Gritz 1d9eec69ab Rebuild docs and minor touchups
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-08 14:38:53 -07:00
Larry Gritz e26a597e3f CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-08 14:29:59 -07:00
Larry Gritz bee949cd3b Changes to OSL ownership of color systems (#1405)
Patrick Hodoul pointed out that we were forcing OpenColorIO to
initialize and read configs as soon as the ShadingSystem was
created. In this patch, we're changing to a lazy creation approach.

We remove the `OCIOColorSystem m_ocio_system` member and the
ocio_transform() method from ShadingSystem. Put them in the
ShadingContext instead. This allows lock-free access because each
context is used by only one thread at a time.

Within the OCIOColorSystem, make the `OIIO::ColorConfig` be a
shared_ptr rather than a member, so it can be created lazily.  If the
Context's OCIOColorSystem needs a config and doesn't have its own yet,
it asks the ShadingSystem, which allocates one the first time (and
only that one time).

So, in short, SS allocates *one* shared ColorConfig, the first time
any context asks for one. The Context only asks the SS for this once
per context (i.e., once per thread). Individual shades just use the
ColorConfig of their context, not needing to lock for it (except for
that brief lock the first time any context asks for the very first
ColorConfig that's needed).

Some things were guarded by `OIIO_HAS_COLORPROCESSOR`, which is silly
because we no longer support OIIO versions so old that it's not
defined.  But then OSL `undef`ed it for Cuda. I replaced these guards
by a more straightforward direct test of whether it was Cuda code.

I added a sample OCIO config to testsuite so we can use it for tests.
In particular, the new testsuite/ocio -- test using OCIO for color
transforms.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-05 13:45:11 -07:00
Larry Gritz 0d1d2de350 Fix oslc missing a write error on function parameter (#1417)
Fixes 1416

In OSL, function parameters must be marked as `output` or they are not
supposed to be writable. In issuing errors when a write is performed on
something not writable, we missed an interesting case:

```
void g(output float b) {
    b = 1;  // ok, since b is marked as output
}

void f(float a) {
    g(a);  // <--- should be disallowed, g is writing to f's non-output param
}

float x;
f(x);
```

This patch catches cases like these. The new error looks like this:

`test.osl:22: error: cannot write to non-output parameter "a", as passed to function g() as arg 1 (output parameter "b")`

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-10-05 13:42:46 -07:00
Alex Wells 54727f9dee More batched gen ops (#1413)
* Add batched SIMD implementation for all color operations.

Added batched llvm code gen for: llvm_gen_blackbody, llvm_gen_luminance, llvm_gen_transformc (including code gen of loop to identify unique "from" and "to" space combinations to call library function with).

Made ColorSystem const correct.
Pulled much of ColorSystem's implementation into src/liboslexec/opcolor_impl.h so it could be inlined in both opcolor.cpp and wide_opcolor.cpp.
To enable SIMD fast path for ColorSystem::blackbody_rgb added new methods to expose underlying lookup table optimization.
    bool can_lookup_blackbody(float T /*Kelvin*/) const;

    Color3 lookup_blackbody_rgb (float T /*Kelvin*/) const;

    Color3 compute_blackbody_rgb (float T /*Kelvin*/) const;
When can_lookup_blackbody() returns true
then lookup_blackbody_rgb can be safely called,
otherwise the expensive compute_blackbody_rgb is required.

Updated implementation of ColorSystem to succesfully vectorize on multiple compilers, optimized lookup table data types and indexed dereferences to generate prefered 32bit indexed gathers vs 64bit gathers which require multiple instructions and registers.

To improve code generation and less chances of aliasing issues, changed nested M[i][j] operator access to Matrix in ImathMatrix.h to directly access underlying 2d array M.x[i][j] also changed Vector operator V[i] to directly access V.x, V.y, V.z in OSL/IMathx/IMath*.h

Moved helper testIfAnyLaneIsNonZero from wide_opmatrix.cpp to be testIfAnyLaneIsNonZero in OSL/wide.h

Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

Enabled BATCHED execution of existing testsuites: blackbody, color, transformc, wavelength_color
Added new testsuite BATCHED regression tests:  blackbody-reg, color-reg, luminance-reg, transformc-reg, wavelength_color-reg
Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

* Adopt OIIO calls to fast_cbrt and fast_expm1 for blackbody computation.
Use single precision for bb_spectrum object/operator and manually implement std::pow(wlm,-5.0f) to better enable vectorization.
Reduced masked code generation for rgb_to_hsl.
Removed duplicated code by implementing ColorSystem::blackbody_rgb(T) in terms of ColorSystem::can_lookup_blackbody(T), ColorSystem::lookup_blackbody_rgb(T), and ColorSystem::compute_blackbody_rgb(T).  Removed some casting to uint16_t that was unnecessary.

Removed some test shaders that were not intended to be promoted.

* Implement batched llvm code generation for ops: andor, bitwise_binary_op, clamp, get_simple_SG_field, isconstant, select, unary_op, mix

Fixed bug in BatchedAnalysis where the complement operator was being treated as always having a boolean result.  In reality the result of complement or other bitwise operation would only be boolean if its input parameters were forced to be boolean (left TODO note for future improvement).

Fixed bug in printf where integer who is forced_llvm_bool() is formatted as a float was not converted to an integer first.

Enabled BATCHED for execution for tests:  and-or-not-synonyms, isconstant, logic, select.
Expanded testsuite/shaderglobals to exercise/access all shader global data members.

Add regression tests: andor-reg, bitwise-and-reg bitwise-or-reg bitwise-shl-reg
bitwise-shr-reg bitwise-xor-reg, complement-reg, mix-reg, select-reg

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-10-05 11:57:37 -07:00
Brendan P 1d7362b331 Added Redshift renderer to list of renderers/tools that support OSL. (#1419)
Signed-off-by: brendisurfs <brendan.prednis@protonmail.com>
2021-10-02 09:58:20 -07:00
cmstein 7b2cdacdea fixing return type (#1418)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-10-01 19:36:13 -07:00
Derek Haase ea550aa5c8 Changing DNEG board member from Derek to Clint (#1415)
Signed-off-by: Derek Haase <derekhaase@gmail.com>
2021-09-30 13:38:14 -07:00
Larry Gritz 4f169d8b38 Raise OpenEXR/Imath minimum to 2.3 (#1406)
Remember that our current 'master' is really aiming for a release in
late 2021 at the earliest, and thus will be a version primarily
intended to be used widely in 2022. Release branches never drop
supported dependencies, so the 1.11 branch will continue to support
OpenEXR all the way back to 2.0.

VFX Platform guidance is to support the current year, plus up to 3 years
prior, so that means that for 2022-ish software, we should support back
to 2019 dependency ecosystem.

For OpenEXR, 2019 state of the art was 2.3 -- that's still dreadfully
old, and is no longer getting even critical or security bug fixes. But
it still means that we can comfortably upgrade our advertised minimum
OpenEXR from 2.0+ to 2.3+ and eliminate some build and dependency
logic that was dedicated to dealing with 2.0..2.2.

We're also raising the OpenEXR/Imath "recommended minimum" (build-time
warning, but not rejection) to 2.4. Even that is shaky, but the fact
that it's still in wide use and was officially (though IMHO unwisely)
the VFX Platform 2021 recommendation, means we can't yell at people
too much about it.

It is possible that by the time we make a supported OSL 1.12 release,
we will bump even further to OpenEXR 2.4 as the minimum. We'll make
that decision later. It would depend on our being confident that even
though 2.3 is technically within the 3 year window we try to support,
we cannot discern that anybody is actually using it (who would also
need the most recent OSL in the same app).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-09-28 10:08:33 -07:00
Luya Tshimbalanga 8682211d0b Fix compatibility with LLVM 12 and up (#1412)
Upstream LLVM stopped using the compatibility
spellings of OF_{None,Text,Append} from version 12 and up.

https://reviews.llvm.org/D101650

Signed-off-by: Luya Tshimbalanga <luya@fedoraproject.org>
2021-09-28 10:08:01 -07:00
Alex Wells 15c81df232 Add batched SIMD implementation for all color operations. (#1408)
Added batched llvm code gen for: llvm_gen_blackbody, llvm_gen_luminance, llvm_gen_transformc (including code gen of loop to identify unique "from" and "to" space combinations to call library function with).

Made ColorSystem const correct.
Pulled much of ColorSystem's implementation into src/liboslexec/opcolor_impl.h so it could be inlined in both opcolor.cpp and wide_opcolor.cpp.
To enable SIMD fast path for ColorSystem::blackbody_rgb added new methods to expose underlying lookup table optimization.
    bool can_lookup_blackbody(float T /*Kelvin*/) const;

    Color3 lookup_blackbody_rgb (float T /*Kelvin*/) const;

    Color3 compute_blackbody_rgb (float T /*Kelvin*/) const;
When can_lookup_blackbody() returns true
then lookup_blackbody_rgb can be safely called,
otherwise the expensive compute_blackbody_rgb is required.

Updated implementation of ColorSystem to succesfully vectorize on multiple compilers, optimized lookup table data types and indexed dereferences to generate prefered 32bit indexed gathers vs 64bit gathers which require multiple instructions and registers.

To improve code generation and less chances of aliasing issues, changed nested M[i][j] operator access to Matrix in ImathMatrix.h to directly access underlying 2d array M.x[i][j] also changed Vector operator V[i] to directly access V.x, V.y, V.z in OSL/IMathx/IMath*.h

Moved helper testIfAnyLaneIsNonZero from wide_opmatrix.cpp to be testIfAnyLaneIsNonZero in OSL/wide.h

Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

Enabled BATCHED execution of existing testsuites: blackbody, color, transformc, wavelength_color
Added new testsuite BATCHED regression tests:  blackbody-reg, color-reg, luminance-reg, transformc-reg, wavelength_color-reg
Added sfm::min_val to provide an implementation of min which returns values not references to the original through a ternary (which can cause issues with vectorization).  Added Clang specific sfm::min_val and sfm::max_val implementations to assist in vectorization.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>

* Adopt OIIO calls to fast_cbrt and fast_expm1 for blackbody computation.
Use single precision for bb_spectrum object/operator and manually implement std::pow(wlm,-5.0f) to better enable vectorization.
Reduced masked code generation for rgb_to_hsl.
Removed duplicated code by implementing ColorSystem::blackbody_rgb(T) in terms of ColorSystem::can_lookup_blackbody(T), ColorSystem::lookup_blackbody_rgb(T), and ColorSystem::compute_blackbody_rgb(T).  Removed some casting to uint16_t that was unnecessary.

Removed some test shaders that were not intended to be promoted.

* Added additional test result for black body because the change from double to single precision caused a few results to differ slightly (max delta 0.0000534058)

* Incorporated changes from PR to "fix color conversion from RGB to xyY"

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-09-27 15:49:11 -07:00
cmstein 8f9206ab46 Removing race condition when compiling for OptiX 7 (#1411)
This change now requires renderers to manually link in the compiled rend_lib.cu
PTX code when using OptiX 7.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-09-27 10:53:46 -07:00
ix-bruiz 3f87e75821 Fix color conversion from RGB to xyY (#1410)
Signed-off-by: Benoit Ruiz <bruiz@isotropix.com>
2021-09-23 15:32:41 -07:00
ix-bruiz f471ab5e0c Fix missing hostdevice modifier on some matrix operators (#1409)
Signed-off-by: Benoit Ruiz <bruiz@isotropix.com>
2021-09-22 10:05:40 -07:00
Nicolas Guiard 22105d2982 Changed the prototype of osl_get_attribute callback in liboslexec (#1404)
Changed the prototype of osl_get_attribute callback in liboslexec in
order it takes a copy of the attribute TypeDesc casted into a long long
instead of taking a pointer to it. This allows to make it work properly
on GPU else we have an invalid pointer.

Signed-off-by: nicolas <nicolas@isotropix.com>
2021-09-13 23:56:55 -07:00
Larry Gritz 879545c359 CI minor version updates (#1403)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-09-12 21:13:36 -07:00
cmstein 1b05f9a6a0 Fix problem with unresolved symbols on GPU (#1401)
Fix problem with unresolved symbols when multiple shaders call certain (#1401)functions on the GPU (ie. osl_printf()).

This fixes a problem I was seeingon the GPU: if I had two shaders that contained a printf(), then the second shader group would report osl_printf as being an unresolved function (the first shader group was fine). If I looked at the PTX for the second shader group, osl_printf was tagged as a "weak" function. Removing the "weak" attribute resolves the problem.

I'm not sure why osl_printf and rend_get_userdata should be different from the other functions in rend_lib.cu.

This is easily reproduced in testsuite/testoptix by adding a printf() to checkerboard.osl and microfacet_test.osl.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-09-02 18:08:37 -07:00
Alex Wells cb3bdb4b4e Removed clang and gcc attributes that disabled optimizations for nonAffineInverse. (#1400)
Added clang pragma and gcc attribute to disable Fused Multiply Add for nonAffineInverse to allow offline compilers to produce results closer to those of LLVM IR compilation (which has FMA disabled by default) which produced the reference images of the testsuite.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-09-01 13:07:04 -07:00
Larry Gritz 692c9b4498 Position-specific gettextureinfo() for UDIM textures (#1398)
Newly added functionality in TextureSystem (only in OIIO >= 2.3.7)
allows us to add a new flavor of gettextureinfo that takes texture
coordinates, and in the case of UDIM textures, will retrieve the info
for the particular UDIM texture that will be used for the given
position:

    int gettextureinfo (string texturename, string paramname,
                        float s, float t, output TYPE destination)

NOTE: Use with caution, this will be more expensive than ordinary
calls to gettextureinfo that will tend to constant-fold effectively,
since the s,t coordinates are runtime-determined and won't be known
for runtime optimization.

If built against older versions of TextureSystem that lack support for
the new is_udim() and udim_resolve() methods, this new gettextureinfo
will simply use the old gettextureinfo() without coordinates, and thus
will not be able to retrieve position-specific texture info.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 09:12:11 -07:00
Larry Gritz e901657f81 Bump some CI dependency versions (#1399)
Most important: make sure we have a proper VFXPlatfom-2022 like test,
with Python 3.9 and OpenEXR/Imath 3.1.

Fix a few of the "name" entries for tests to match the set of versions
actually present on those images.

Remove apt-get install of libboost-regex-dev, since we use only
std::regex now that we're no longer using gcc4.8.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 09:11:50 -07:00
Larry Gritz 881c704d11 Build: collapse build and dist hierarchy (#1396)
Similar to a recent change in OIIO... For historical reasons, our
wrapper makefiles assume that we build in `build/ARCH[.variant]`, so
maybe build/linux64, build/linux64.debug, etc.

Get rid of this extra bit of hierarchy, it no longer serves us and
it's contrary to modern cmake practice.

Also used this as an excuse to remove some SPI build script
customization that we no longer use.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 09:11:09 -07:00
Larry Gritz df18d97283 Give Symbol virtual destructor to fix UB because of derived classes. (#1397)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-24 09:28:31 -07:00
Larry Gritz 30d2a4a089 Userdata input placement (#1391)
This is analogous to the "output placement" that we added recently, but
for input of userdata.

Reminder: "userdata" means shader parameters marked as lockgeom=0 that
are expected to be supplied on a per-shade basis, such as interpolated
vertex data on geometric primitives. The primitive data binds by name to
matching shader parameters.

This patch concerns how the shader gets this per-point data.

Old school: in the middle of the shader, when userdata is needed, the
shader calls osl_bind_interpolated_param(), which makes a callback to
RendererServices::get_userdata(), which... does something magical and
renderer-specific to retrieve the data by name.  This is expensive and
also challenging to implement on the GPU (which is why it remains
unimplemented).

This patch changes the methodology to the following, which is somewhat
analogous to how we did output placement:

0. It is assumed that there is an arena of memory where the userdata
   is going to be, and the pointer to its start is passed down to the
   shader via execute() (just like how the shaderglobals and output
   arena pointers are passed), along with an index of the current
   shade point.

1. The renderer pre-declares SymLocationDesc records for the userdata,
   which specifies the offsets and strides within the arena where the
   data can be found.

2. Prior to launching the shader execute(), the renderer is expected
   fill in those values in the userdata arena for the points to be
   shaded.

3. When JITing the part of the shader that initializes those userdata
   parameter values, we simply JIT a simple data copy directly from
   the computed position within the arena (offsetting the right amount
   for this data, at this shade index) -- just a couple of
   instructions per shade, no function calls, no RendererServices
   callbacks, no name lookups!

4. There is no 4. That's it.

See the changes to osldeformer.cpp for an example of how this looks from
the renderer side. It's really straightforward.

Currently, if there is no SymLocationDesc for a lockgeom=0 parameter
that needs initialization, it will fall back to the old callback. We
may fully deprecate the old way, but not for a while, so this is back
compatible for now.

This seems to work, passes all tests, doesn't break anything, and works
for the osldeformer example!

There is follow-up work to do: I think we can pretty easily do the
same thing for ShaderGlobals ("make your own SG struct"), named marix
retrieval, and other attributes. Will do those in subsequent PRs if
this meets everybody's approval.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-19 14:52:27 -07:00
Larry Gritz 06c9d0d1c7 Test: don't clobber LD_LIBRARY_PATH for optix tests (#1395)
Well intentioned attempt to ensure that Cuda runtime library was in
the library path when tests were run, but it clobbered the existing
LD_LIBRARY_PATH.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-18 16:26:21 -07:00
Alex Wells d4f54bc76a PR/BatchedNoise (#1394)
Add batched code gen to generate a loop to calls to OSL library noise functions with binning of varying noisetypes and options.  For example if half of a SIMD batch uses gabor option "bandwidth" of 10 and the other half default "bandwidth" of 1, then gabornoise will be called twice (once with bandwith option set to 10 and a mask with the 1st half of SIMD lanes enabled, then a 2nd time with bandwith option set to 1 and a mask with the 2nd half of SIMD lanes enabled.

Added batched OSL noise library functions which compile with outer loop explicit vectorization.  NOTE:  Perlin and some other noises have SIMD intrinsics that work on multiple data elements (block vectorization).  When the the active number of lanes in a batch is below a tunable threshold, the legacy block vectorization version is called.  This avoids the worst case scenarios of 1 active SIMD lane executing, and allows the 3-4 wide x,y,z data element version to run instead.

Add previosly omitted /Qopenmp-simd and -fopenmp compiler flags along with -DOSL_OPENMP_SIMD to cause OpenMP outer loop explicit SIMD vectorization of loops in batched OSL libraries.

Fix Mask::invoke_foreach to be OSL_NOINLINE, it was mistakenly set to OSL_FORCEINLINE

Update oslnoise.h to access target specific library sfm namespace

Improve compile time for 4d perlin noise with Dual arguments by using a 2 iteration loops to avoid repeating a large amount of code.

Changed ShadingSystemImpl::count_noise(void) to count_noise (int number=1) to allow batched version to update the call count with the number of active lanes in the current mask.

Fixed sfm::scalar_gabor3 and sfm::scalar_pgabor3 to not use the loop array index when storing partial results, when vectorizing an aliasing issue on the stack caused incorrect results.

Enabled BATCHED execution of all noise tests.
Added new tests: noise-generic, pnoise-generic
Added new BATCHED_REGRESSION tests:  noise-gabor-reg, noise-reg, pnoise-reg

Avoid issue with constant folding in hashnoise with different compilers causing slightly different results from sin & cos to cause massively different results due to aliasing in hashnoise.

* Add openmp-simd and target compiler flags when CMAKE_COMPILER_IS_GNUCC for batched target specific liboslexec libraries
Move filter_gabor_kernel_2d from gabornoise.h to .cpp to avoid unused function warning.

* Revert to reference 4d perlin noise for Clang vectorization.

* Utilize reference filter_gabor_kernel_2d which uses its own gabor_mul_m22_v2(const Matrix22& m, const Vec2& v) instead of relying on Imath version which differs in naming between OSL/matrix22.h and <Imath/ImathMatrix.h>
Move filter_gabor_kernel_2d back from gabornoise.cpp to .h to share it between gabornoise.cpp and sfm_gabornoise.h.
Disable Clang vectorization of strlen because resulting binary causes crashes in testsuite (TODO: investigate)

* To avoid "may be used uninitialized in this function [-Werror=maybe-uninitialized]" messages add extra (unnecessary) initialization, as its a unlikely fallback case shouldn't affect performance much.

* Disabled GCC optimizations for nonAffineInverse to allow results to match LLVM-IR version for Matrix44 inversion.
Implemented better optimization for transform normal when matrix is uniform.

* Mark nonAffineInverse definition as OSL_HOSTDEVICE to match its forward declaration.

* Added environment variable TESTSHADE_LLVM_JIT_FMA to force FMA generation for JIT'd code, needed to produce reference i mages for tests.

Fixed warning message that was accessing a null pointer when testshade requests FMA without specifiying a target.

Added out_LLVM_JIT_FMA.tif image for hashnoise tests whose results vastly differ for small changes in input values, so we need a 2nd test image to compare against when FMA is enabled for LLVM JIT.

* Rearranged local stack variables inside of sfm::simplexnoise4 to instantiate Vec4 locals closer where they are used.  This was necessary to get correct results with gcc (even with vectorization disabled), suspect issue with register overflow or stack stomping.

* Fix issue with impl_transform_normal_masked failing to vectorize when only the result is varying.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-08-18 15:31:32 -07:00
Larry Gritz 92a6055ab9 Add include to prepare for upcoming OIIO change (#1393)
OIIO 2.3 will rearrange some header files slightly. If you need to use
ImageCache, you must include imagecache.h (duh!). We were accidentally
relying on some leaked definitions in other header files, which will
soon be removed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-04 10:37:00 -07:00
Larry Gritz e3f40d764e CI: Bump some of the "latest" releases (#1392)
latest OpenEXR/Imath -> 3.1.0
latest pybind11 -> 2.7.0
latest fmt -> 8.0.0

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-03 08:05:51 -07:00
Larry Gritz 79cc3a3268 Convert some uses of temp vectors to span (#1390)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-08-03 08:05:29 -07:00
Larry Gritz 0406e48cef More string format convention modernization (#1389)
* OSLQuery::errorf (public)
* ShadingSysImpl::errorf, etc. (internals)
* Context::errorf (internals)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-22 22:58:17 -07:00
Larry Gritz 4bfdefdba5 Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-21 23:45:05 -07:00
Larry Gritz cd0fa5d7d7 CHANGES etc
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-20 20:45:24 -07:00
Larry Gritz 2f3c21ff7c Move from some long-deprecated OIIO things to modern equivalents (#1388)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-20 20:44:18 -07:00
Alex Wells 27cc863108 PR/BatchedMath -- algebraic, trig, transcendental (#1385)
Implement batched versions algebraic, trigonometric, and transcendental OSL library functions.
Add extensive regression tests to exercise binary and ternary operations with combinations of uniform, varying, and constant arguments.
Added some reusable xmacros for shaders in the testsuite/common/shader's directory to create unary, binary, and ternary test shaders.

Increase timeout of CI tests from 180 seconds to 240 seconds to allow comprehensive regression tests to complete.
Alternative is to break regression tests into separate test directories so the individually finish faster.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-07-08 11:38:44 -07:00
Larry Gritz d6ec4b828f Sanitize filenames when using "archive_groupname" (#1383)
This feature (used, very possibly, only by me, for debugging) lets me
force OSL to write an archive that contains the oso files and a
serialized version of the shader network.

If no explicit name is given (by the "archive_filename" attribute), it
picks a name based on the shader group name. But that may not be a
safe string for a valid filename. We already eliminated anything
before the last slash, but it turns out that a colon (':') and pipe ('|')
can also really mess things up. So this small change protects against that.

For the actual commands sent to system(), escape special characters
in the strings and enclose any arguments that come from the user in
double quotes. That prevents shenanigans like asking for an archive
filename called "; rm -r *". By enclosing in double quotes, we'll
end up with a badly named filename produced by tar, rather than
possibly an arbitrary command being executed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-01 23:08:15 -07:00
Larry Gritz 98e3aca1c9 Remove last calls to ambiguous OIIO format functions (#1382)
Background: OIIO now has errorf that are explicitly printf-like, and
errorfmt that are explicitly std::format-like, and also an old style
error() that is ambiguous.  The ambiguous calls are (at this moment)
aliases to the printf ones, but will be deprecated at some point (and
may, later when it seems safe, get reborn as the std::format compliant
behavior).

This roots out and removes the last few calls to the old ambiguous
ones from the OSL codebase.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-07-01 23:06:34 -07:00
Larry Gritz b0ed183b90 CI gcc and llvm testing changes (#1381)
* Update the "bleeding edge" CI test to gcc-11, and also LLVM 12,
  which we hadn't tested before.
* A "latest releases" CI test uses gcc10 and LLVM 11.
* Turns out that nothing else on the OSL side needed to be fixed to
  accommodate gcc 11 (though you need a very up-to-date OIIO if you
  want to compile it with gcc11 unless you turn warnings off).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-21 10:29:06 -07:00
Larry Gritz cfc679ad8b CI: speed up OIIO build for CI by not building its tests (#1380)
Was using the wrong notation before.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-21 10:28:30 -07:00
Larry Gritz b9ca59ea61 CI: have a clang11 test, also test batched shading with clang (#1379)
Along the way, discovered a couple clang-specific warnings when using
C++17.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-21 10:28:16 -07:00
Alex Wells 135b087017 PR/BatchedMatrix (#1378)
* Implement batched matrix ops, including transform, determinant, transpose, and construction and getmatrix with spaces, multiplication, division, negation.
Moved helpers det2x2, det3x3, and det4x4 from opmatrix.cpp to Imathx.h so they could be shared with the wide_opmatrix.cpp.
Enabled BATCHED testing for matrix and transform testsuites
Added new BATCHED_REGRESSION testsuites array-reg, matrix-arithmetic-reg, matrix-compref-reg, matrix-reg, transform-reg to more fully exercise combinations of uniform and varying data types and indexing variables.

* Removed #if 0 code block of determinant match that was moved to Imathx.h

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-06-15 18:31:56 -07:00
Larry Gritz 7f8a1a1702 Now that gcc minimum is gcc6, remove use of boost::regex (#1377)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-02 10:57:05 -07:00
Larry Gritz d755edf4f4 Bump minimum C++ to 14 and update compiler mins to match (#1369)
As discussed at the TSC meeting and on the mail list, I won't merge this
change until June 1. It will only be in master (future OSL 1.12), not
backported to any release branch.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-01 15:39:53 -07:00
Alex Wells 0c0e6d4b42 Batched control flow and string ops (#1373)
* Implement batched loop control flow (including, break, continue) along with early outs (return, exit).  Also add batched support for printf and other string operations.  Implement batched support for shadingsystem ops like bind_interpolated_param, get_userdata, rangecheck, uninitcheck_values, and nancheck.  Implement batched support for negate, min/max, arraycopy, compassign, mxcompref, mxcompassign, .Added BATCHED_REGRESSION tests to the suite to exercise control flow and string ops and compare scaler and batched results.  Enabled various tests to also execute in BATCHED mode.  Enable unoptimized BATCHED mode testing, as constfolding was avoiding any work in optimized mode for some tests.
Fixed bug in testshaded batched mode that inverted population of x and y shader global values, but only noticed in order of side effects like printf in shaders.
Added buffered file support to ShadingSystem to allow batched fprint to write out to files in the correct order.
Fixed bug in BatchedAnalysis which was not handling unlocked geom correctly by requiring unlocked input parameters be varying inorder to accept Wide results from BatchedRendererServices::get_userdata.

LLVM_Util had previously added support managing masks, and its strategy should
be reviewed before trying to understand this commit's changes:

    // Overview of masking strategy
    //
    // For if/then based on a conditional, the result of the conditional is
    // conditionals written to a symbol that is a wide boolean.  To handle
    // nesting we will keep a stack of conditional masks.  When a new
    // conditional mask is pushed, it is combined with the previous mask on
    // the top of the stack.  It is the top of the mask stack that is used
    // as the mask for any instructions requiring masking.  When a
    // conditional scope is exited, we just pop the top of the conditional
    // mask stack.
    //
    // Loops are handled by pushing their conditional result onto the
    // conditional mask stack, and popping it back off at the end of the
    // loop.
    //
    // Handling of early outs (exit, return, break, continue) is done by
    // storing a mask representing the lanes which are going to be
    // deactivated (or continue executing) to an allocated location in the
    // stack. We actually have to store these early out masks, so that we
    // can apply it to the conditional mask stack.  As that stack unwinds,
    // any early out masks are applied to the top of the conditional mask
    // stack.  As there are different types of early outs that apply to
    // different control flow scopes and multiple types can be present at
    // the same time for different data lanes, we must store these early
    // out masks at separate locations on the stack.
    //
    // To handle 'exit', we allocate a 'shader mask' that is initially
    // populated with a startMaskValue representing the active lanes in a
    // shader global batch.  For example perhaps only 7 of 16 data lanes
    // are populated, the startMaskValue would store that value and push it
    // onto the conditional mask stack.  We require a location on the stack
    // for this 'shader mask' in order for an 'exit' statement to modify it
    // and cause a subset of the lanes to be deactivated.  If an exit was
    // processed, the 'shader mask' is where it will be stored and pulled
    // from when applying to the unwinding conditional mask stack.
    //
    // To handle 'return', we allocate a 'function mask' that is initially
    // populated with a startMaskValue representing the active lanes when
    // an inlined function was called.  This startMaskValue should just be
    // value at the top of the conditional mask stack.  As function calls
    // can be nested, we maintain a stack of function masks.  We require a
    // location on the stack for each 'function mask' in order for a
    // 'return' statement to modify it and cause a subset of the lanes to
    // be deactivated.  If an return was processed, the 'return mask' is
    // where it will be stored and pulled from when applying to the
    // unwinding conditional mask stack. When a function scope is exited,
    // the function mask is popped so any return's processed would apply to
    // the outer function mask vs. the one just exited.
    //
    // To handle 'break', we use the condition symbol's location on the
    // stack to directly disable data lanes for the loop execution.  As we
    // already had a location to store the conditional symbol's mask, no
    // need to allocate or store a separate one.  However code will need to
    // reload the condition's value when a break 'could have been' called
    // vs. relying on a conditional result already in a register.
    //
    // To handle 'continue', we allocate a 'continue mask' that is
    // initially populated with a 0 representing the deactived lanes by
    // 'continue' operations. We require a location on the stack for each
    // 'continue mask' in order for a 'continue' statement to modify it and
    // cause a subset of the lanes to be deactivated.  If an continue was
    // processed, the 'continue mask' is where it will be stored and pulled
    // from when applying to the unwinding conditional mask stack. When a
    // loop's scope is exited, the continue mask is popped so it would't be
    // applied to an outer loop.
    //
    // The logic of when and how to actually apply these masks is handled
    // by the caller, tracking/storing the different stacks and masks is
    // handled here.  And queries exist to see how many early outs
    // operations have been processed, these counts can be used by the
    // caller to determine which to generate code to apply each of them.

In our case BatchedBackendLLVM is the caller and during code gen will be calling:
    push_shader_instance(llvm::Value* startMaskValue) and pop_shader_instance()
    push_function_mask(llvm::Value* startMaskValue) and pop_function_mask()
    push_masked_loop(llvm::Value* location_of_control_mask, llvm::Value* location_of_continue_mask) and pop_masked_loop()
And to handle if/then/else be calling
    push_mask(llvm::Value *mask, bool negate, bool absolute) and pop_mask()
By checking masked_exit_count(), masked_return_count(), masked_break_count(), and masked_continue_count()
before and after code gen of a function call, then block, else block, loop body, etc.
we can detect if a exit, return, break or continue existed in the generated scope
and then can call apply_exit_to_mask_stack(), apply_return_to_mask_stack(),
apply_break_to_mask_stack(), or apply_continue_to_mask_stack() when needed.

Add utility function "foreach_unique" to provide scalar execution of a Functor
for each unique value in the a Wide data block along with a mask identify which
data lanes match the unique value.

Add utility function "unproxy(const T &elem)" to extract value type from a proxied
element.  This is alternative to static_cast<ValueType>(elem), and better self documents.

Fixed compatibility bug where llvm 9+ asserted that bool was not a valid datatype for llvm::ConstantDataVector::getSplat.
Added LLVM_Util::test_mask_lane(llvm::Value *mask, llvm::Value * lane_index) to test a mask with a variable lane index.

* Updated OIIO::vformat calls to OIIO::sprintf.
Conditionally compile buffered_file_output_mutex to avoid unused variable warning when not building with USE_BATCHED.
Ran couple files through clang-format.

* Initialize local variable mask_slot to avoid maybe-uninitialized errors

* Fixed paths to additional oiiodiff that runs when a test fails to find a match to use the /baseline subdir when performing a BATCHED_REGRESSION test.
Improved control-flow-test to use 0.5 default value instead of 0 to tell difference between actual assignment and 0's on the heap.

* Changed some control-flow-reg tests to use non-zero default values to tell difference between uninitialized heap and setting of default values.
Changed order of parameters so that any initops that contain an "exit" are the final parameter so the exit doesn't skip assigning default values.  Otherwise those parameters would be uninitialized data and cause intermitent CI failures.

* Deleted extraneious cmakefile settings for clang

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-06-01 15:38:58 -07:00
Larry Gritz bc5b969a59 CMake fixes (#1376)
* "SOVERSION" option was set twice, oops!
* Stray "OIIO" in a name that should have been this project's name.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-26 09:23:01 -07:00
Larry Gritz ae2edaceb8 CI: Bump OpenEXR versions to the latest patches in each branch (#1374)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-25 22:55:34 -07:00
Niklas Harrysson 35c9ae7e22 Add declarations of MaterialX closures (#1371)
This PR adds closure declarations for the MaterialX PBS nodes. A discussion of their design has been ongoing in a thread at the MaterialX GitHub repo. The full history of this discussion can be found here: https://github.com/materialx/MaterialX/pull/614

Signed-off-by: Niklas Harrysson <niklas.harrysson@gmail.com>
2021-05-25 22:55:01 -07:00
Larry Gritz 908000e595 Fix SPI compilation (everybody else can ignore).
Mostly just getting rid of support for compilers and boost versions we
no longer use. But also some openexr version finding fixes.
2021-05-22 09:35:03 -07:00
Larry Gritz 11ba289f5f Build: llvm-config --system-libs needs --static for LLVM_STATIC (#1375)
This fixes CI in the Mac test. Something about the Homebrew upgrade to llvm 12.0.0_1 made this fix necessary to build.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-22 09:15:57 -07:00
Larry Gritz 9f91311c78 CI: Change our clang-format standard to clang11 (#1372)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-21 16:06:02 -07:00
Larry Gritz 1435e3a202 Output variable placement (#1328)
Up until now, client apps declare which output variables are "renderer
outputs" before shader groups are compiled, and also after a shader is
executed, it is up to the app to extract the individual output values
and do with them what it needs to do. Those outputs live on the shader
heap (the temp storage used to run the shader), and information about
where it lives on the heap can be retrieved via find_symbol() and
symbol_address().

New paradigm:

Various inputs and outputs of shaders live in different memory arenas,
and for those inputs/outputs, the app declares (prior to shader group
compilation) which arena it lives in, its offset within the arena, and
the stride between entries (for different shades, such as different
rays in flight, different points on a mesh, pixels in an image, etc.).
The shader JITs into code that automatically pull inputs from their
sources and copy outputs to their destinations with no need for client
app code to call find_symbol or symbol_address or do any extra data
copies.

This symbol location data is communicated to the shading system through
new calls to add_symlocs() passing a new struct called a SymLocationDesc,
which has the aformentioned arena, offset, stride, etc.

Right now, the only supported arena is Outputs, and the actual call
signature to execute(), and to the shader JIT code itself, includes
extra parameters for the base pointer to the output arena (this could
conceivably change from shade to shade) and the integer shade index of
this shade.

I've tried to set this up in a general way, so that additional arenas
will be added later -- places where ShaderGlobals can be customized,
UserData, etc. Also there are placeholders for being able to talk about
absolute addreses and offsets into the heap, though I don't use them
at the moment. Some of the flexibility may be later removed as we learn
more about how we want to use this.

To show it in action, I have modified the "osldeformer" example to use
this new method to place the outputs directly where we want them.
It's just storing results into an array. The output arena base pointer
is the start of the array, the offset of the single output is 0, and
the stride is the size of each array element (one 3-float point).

As a much more complex example, testshade also uses the new technique
(unless you use --no-output-placement, but I'm not sure how long I'll
keep that). This is a good example of storing to images. Testshade thinks
of itself as shading pixels in an image, so there is an ImageBuf for every
renderer output (think of it like an AOV). The output arena base pointer
is the address of the (0,0) pixel of the ImageBuf for the first AOV; the
"offset" of each output variable is the address difference between that
AOV's first ImageBuf pixel and the arena base pointer, the stride is the
pixel data size for each output, and the shadeindex is the pixel index of
that shade.

It all works. Crazy!

OK, not quite all. Here's what hasn't been done yet:

  * testrender does not yet use the new API (only testshade)
  * GPU (have only tried CPU so far)
  * Batch shading -- I don't want to mess with this while Alex is
    still integrating all his work. We'll go back and catch the batch
    shading up after he's all done.

These will come in subsequent PRs.

All the old calls should still work, so this ought not to be a source
compatibility break for renderers using OSL. Not at this point, anyway.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-13 13:25:11 -07:00
Larry Gritz f2d0668c93 CI: Fix which openexr version is used for vfxp 2021 test
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-13 11:30:41 -07:00
Larry Gritz 7f2c3a6c0e CI script typo kept mac from recognizing ARCH properly (#1370)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-11 20:45:40 -07:00
Larry Gritz 0a97b2a96e Some minor cmake touch-ups (#1368)
* Left out some imath targets in liboslnoise

* Conform a couple libraries to conventions of the ${local_lib} notation
  we use in the othe rlibraries.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-11 20:43:03 -07:00
Larry Gritz f94bb6df40 CHANGES & docs fixes
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-09 16:28:50 -07:00
Larry Gritz 1e77b38d23 CI: Make sure we have some test coverage for batched shading mode (#1367)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-07 22:51:50 -07:00
Larry Gritz 6882703746 CI Mac fix: this was no longer necessary, and seemed to be problematic (#1366)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-05 18:11:52 -07:00
Larry Gritz 444261a11e Bump the default C++ mode to 14 (#1362)
This leaves the minimum C++ at 11, but bumps the default (if not set by
the user via CMAKE_CXX_STANDARD) from 11 to 14.

This is meant to start identifying any problems people have switching
to 14. We anticipate a hard switch to 14 minimum before the next OSL
major release. This change is in master only (i.e. future OSL), we would
never change minimum or default C++ standard in the supported release
branches (currently OSL 1.11.x).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-05-04 14:02:08 -07:00
Alex Wells 4292cc9974 USE_BATCHED cmake option listing target library to build. New BATCHED_REGRESSION testing mode. (#1357)
* Introduce cmake option USE_BATCHED to enabling building batched SIMD shader execution for a comma separated list of batch sizes, ISA's, and noFMA: (0, b8_AVX, b8_AVX2, b8_AVX2_noFMA, b8_AVX512, b8_AVX512_noFMA, b16_AVX512, b16_AVX512_noFMA)
When USE_BATCHED is set, -DOSL_USE_BATCHED=1 will be passed allowing for source files to conditionally compile in batched execution support.
When USE_BATCHED is set, cmake variable BUILD_BATCHED=True and projects can conditionally add batched sources to be built.
Updated OSL source with #ifdef OSL_USE_BATCHED/#endif were needed.
Improved/streamlined liboslexec/CMakeLists.txt to iterate over targets in USE_BATCHED vs. hardcoding all variants.
Updated _OSL_SUPPORTS_* defines to match USE_BATCHED values simplying creating compiler definitions in Cmake.

Added new BATCHED_REGRESSION testing mode, when a file named BATCHED_REGRESSION exists in a testsuite folder, the run.py will be executed and its output files copied to "./baseline".  The same run.py is then run again but with environment variable TESTSHADE_BATCHED=1, which cause testshade to execute in batched mode.  Then the results/image comparison happens between the batched output files and those in "./baseline".  The "./ref" dir is never used in a regression test.
Presence of BATCHED_REGRESSION prevents non-regression tests from being created for a folder.

Converted arithmetic-cov to be a BATCHED_REGRESSION test.
Removed testsuite/arithmetic-cov/ref image files.

Renamed ShadingSystem::supports_batch_execution_at(int width) to ShadingSystem::configure_batch_execution_at(int width) to better identify its behavior:  based on currently set attributes for llvm_jit_target and llvm_jit_fma, test if current machine is capable of supporting batched execution at the specified width.  If no specific llvm_jit_target was requested, sets llvm_jit_target and llvm_jit_fma to the supported configuration for the requested width.  Returns true if supported, false otherwise

Fix bug in batched Matrix*Matrix code generation where the order of arguments were being reversed (swap was intended to transform float*Matrix to a Matrix*float function call, but accidentally happened for Matrix*Matrix)

* Moved define of OSL_USE_BATCHED to oslconfig.h.in
Fixed order of includes in batched*.cpp so oslconfig.h is higher

* Renamed testsuite/arithmetic-cov to testsuite/arithmetic-reg to better represent it is a regression test.
Changed #ifdef OSL_USE_BATCHED to #if OSL_USE_BATCHED and rely on it being set to 0 or 1 by <OSL/oslconfig.h>

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-04-29 21:04:21 -07:00
Brecht Van Lommel ab7107cf23 Fix crash generating closure functions calls with LLVM 11 (#1361)
Generating code for prepare_closure and gen_closure was crashing.
The code now matches the implementation of the removed LLVM function.

Signed-off-by: Brecht Van Lommel <brecht@blender.org>
2021-04-22 09:15:10 -07:00
Larry Gritz eccd335d78 Revert "SPI: Remove old cruft related to spcomp2, rez, and gcc-4.8"
This reverts commit 63026c7279.

I removed it prematurely and not carefully enough.
2021-04-20 09:12:12 -07:00
John Haddon 8dafa41262 OSLCompiler : Check for write errors (#1360)
Fixes #1352

Signed-off-by: John Haddon <jhaddon@cinesite.com>
2021-04-20 09:08:47 -07:00
Larry Gritz 58ca5c2f8d Build: be robust to certain OpenEXR 2.x config files (#1356)
Ever since adding OpenEXR 3.0 support, we had some cases where
installations that built the 2.x IlmBase and OpenEXR portions
separately and installing to separate areas, had trouble being found
properly.

Remove the need to include OpenEXR/OpenEXRConfig.h

Also make some minor changes to ci.yml to make sure we are documenting
the right openexr versions used for each test.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-19 13:53:29 -07:00
Larry Gritz e9d0dc3ec4 Update several stray references to the old repo URL (#1353)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-12 19:35:52 -07:00
Larry Gritz 7d6310d17c CMake 3.20 safety (#1354)
It seems that our liberal use of cmake argument `--config` should only
be used in conjunction with the `--build` flag, not for the initial
configuration step. Apparently this was just silently ignored for a
long time, but for CMake 3.20, it is an error and breaks a lot of our
CI cases and our build_blah.bash scripts.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-02 15:46:23 -07:00
Alex Wells 8727d61ec1 More work on batched shading -- ISA specific modules (#1345)
* Added building of ISA specific shared libraries lib_b16_AVX512_oslexec, lib_b8_AVX2_oslexec, lib_b8_AVX512_oslexec, lib_b8_AVX_oslexec to house precompiled OSL library functions that execute over batches of 8 or 16 in SIMD for the ISA.  Compiler flags for OpenMP simd code gen and ISA targets has been added for Intel(r) C++ Compiler (ICC) and CLang (newer versions of GCC 6+ might be possible, but untested).

Implement batched llvm code gen for:  generic function calls, useparam, compare ops,  addition, subtraction, multiplication, division, modulus, assignment, component reference, construct triple, construct color, derivative extraction.  Stubbed out all other code gen functions with TBD asserts.

Populate OpDescriptiors with valid wide version of llvm-generating routine

Added wide_opalgebraic.cpp which uses X-macros (instead of #define like llvm_ops.cpp) to define wide(batched) versions of OSL library functions:  sqrt, inversesqrt, floor, ceil, trunc, round, sign, abs, fabs, fmod, and step.
The X-macro wrappers follow a pattern of manufacturing a target specific library function name with enough parameter types embeded in its name to uniquely identify it (vs. other versions).  Then it declares local Wide<T> or Masked<T> wrappers that convert any void */char * parameters to references to Block<T,WidthT> data blocks of wide SOA data.  Then an explicit OpenMP simd loop iterates over the data lanes and extract a local scalar values from the Wide|Masked wrappers, then the scalar implementation of the library function is then inlined using the local scalar values.  Finally the result is writen back out to the data lane inside the Wide|Masked wrapper.  This paradigm allows scalar implementations to be resused inside simd loops and avoid having to use intrinsics or assembly.  It also allows the same implementation to be recompiled for different target ISA's and varius Widths (8|16).  The build system will create copy of each  wide_*.cpp to a target and batch size specific named b(8|16)_(AVX512|AVX2|AVX)_wide*.cpp and build it with different -D__OSL_TARGET_ISA and -D__OSL_WIDTH values which inturn will manufacture uniquie function names.  Sometimes scalar algorithms/functions can be refactored to provide better performance when executing inside a SIMD loop.  sfmath.h (SIMD friendly math) houses these alternative math functions, although many improvements have already been moved into OIIO as they benefit (or do no harm) to scalar code gen.

Made ShadingContext remember the ShaderGroup it just optimized.  This allows symbol queries without actually jitting or executing a shader.

Improved TestShade to not actually execute the shader during setup_output_images, but to instead explicitly JIT scalar or batched version of the ShaderGroup (primarily to make sure JIT happens during the "setup" stage vs. lazily later).
Fix TestShade to explicitly set the number of OIIO worker threads to avoid overhead (and debugging confusion) of OIIO thread pools being created even when "-t 1" was requested.

Modified ShadingSystem to only perform group_post_jit_cleanup (delete operations of shader group) only if both scalar and wide JIT's have occured or if RendererServices doesn't support batching.  Without this changed the operations were being deleted before a batched JIT could occur.

Extended testsuite framework to look for file named "BATCHED" which causes another run of the test with TESTSHADE_BATCHED=1
Added testsuite new tests with BATCHED enabled for passing tgh shaderglobal values, and increased coverage of arithmetic tests with reference images for float, color, point, vector, normal data types along with Dx Dy results.

Added utility macros  __OSL_CONCAT,  __OSL_CONCAT3, ...,  __OSL_CONCAT10 to be able to easily manufacture function names.
Added macro __OSL_WIDE_PVT to give each target specific library its own namespace avoiding collisions should multiple libraries be loaded.
Added sfm::negate(const T &x) with optimized implementation.

Disabled some unreferenced functions warnings for ICC and removed some unused functions from batched_analysis.cpp
Updated BatchedBackendLLVM to match behavior of BackendLLVM by configuring its LLVM_Util based on ShadingSystem attributes.

Disable clang format for X macro based building of initializer arrays to prevent clang format from reordering the #include files.
Fix control flow in factory function TargetLibraryHelper::build to not trigger assert unnecessarily.

Limit list of OSL library functions in builtindecl_wide_xmacro to just those we have implemented so far because all functions listed must exist in the target specific library for it to successfully be loaded and resolved.

Added LLVM_Util::op_zero_if(llvm::Value *cond, llvm::Value *v) which allows its implementation to work around an LLVM issue where expensive instructions to produce the value (div, sqrt, etc) are duplicated (once with a mask, once without).

Fix bug in ShadingSystem::supports_batch_execution_at where jit_fma was being accidentally negated causing rest of logic to fail.
Implement ShadingSystem::BatchedExecutor<WidthT>::jit_group

* In Cmake, changed ISA specific target libraries from SHARED to MODULE so that on OSX they will be named .so instead of .dylib.
Moved new arithmetic tests into their own subdirectory arithmetic-cov so that the existing arithmetic test can run in non-batched mode as it uses printf which is still TBD for the batched version.
Fixed bug where shader ops weren't being cleaned up unless batched jit had occured.
Fixed compilation issue with newer LLVM versions and LLVMUtil::zero_if

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-04-01 23:35:15 -07:00
Larry Gritz 63026c7279 SPI: Remove old cruft related to spcomp2, rez, and gcc-4.8
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-04-01 23:04:55 -07:00
Larry Gritz c32c1ed799 Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-29 21:46:35 -07:00
Larry Gritz 96249d0258 CHANGES 2021-03-29 20:32:18 -07:00
Larry Gritz 0ceb805deb SPI fixes 2021-03-29 13:38:54 -07:00
Euan Haahr f76ea6220a 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-03-29 12:28:46 -07:00
Larry Gritz b49f4d4819 CMake 3.20 compatibility (#1349)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-27 22:26:02 -07:00
Larry Gritz 1c10440bdf CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-22 15:09:49 -07:00
Larry Gritz 975e350cd3 Formatting adjustment
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-16 21:45:14 -07:00
Larry Gritz 2599a88b1d Fix oslquery link conflict (#1348)
In PR 1346, we overlooked the fact that OSLQuery::init() is defined
*differently* in liboslquery and the separate copy that used to be
in liboslexec.

In this patch, we remove the oslquery-side version (and in fact
coalesce it into the constructor, the only place it was used). So now
instead of being replicated differently in the two libraries, it only
exists in oslexec. That constructor, since it takes a ShaderGroup* as
an argument, only makes sense to call if you have a full ShadingSystem
nearby.

Add ShadingSystem::oslquery(), deprecate OSLQuery(ShaderGroup*).
This eliminates the weirdness of having this constructor undefined in
liboslquery, moves the functionality to the ShadingSystem.
Because of ABI compatibility issues, we have to merely deprecate (but
not remove) the OSLQuery functionality for now.

Avoid assertions for shaders with params that are arrays of indeterminite length

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-16 13:13:27 -07:00
Larry Gritz 7c60b5949a Fix guard so errorfmt is not used with too early an OIIO version (#1347)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-12 15:13:32 -08:00
Larry Gritz 9d070999b6 Fully split oslquery and oslnoise libraries from oslexec (#1346)
liboslquery and liboslnoise exist as separate libraries for apps that
only need to query shader parameters or use OSL's noise functions,
respectively, but dont want to pull in the rest of OSL and all its
heavy dependencies (including LLVM). But liboslexec also needs that
functionality and so separately put the individual modules inside.

This was causing some problems for a tricky use case, and I can't
think of a good reason for it to be done this way now. So in this
patch I remove the redundant modules and just make liboslquery and
liboslnoise into *link dependencies* of liboslexec. None of this
should affect downstream projects, I don't think; linking against
liboslexec ought to just automatically pull in those other libs.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-12 13:55:03 -08:00
cmstein 27d3bbbaf9 A number of changes with respect to OptiX 7: (#1309)
* strings are no longer copied to the GPU and are instead passed around
  as ustring hashes.  This means we no longer need to copy string pointers
  CUDA/PTX code.  This should result in faster compilations because
  strings are defined at "compile time" instead of "runtime".
* OSL's shaders' printf() output is now handled on the host/CPU
* testshade and testrender now use a separate optixLaunch() to set up
  global variables
* removal of runtime compilation of CUDA (libnvrtc dependency eliminated!)
  which was used to handle the setting of global variables in OptiX 7's
  CUDA programs.

Signed-off-by: Clifford Stein <cstein@imageworks.com>
2021-03-11 16:59:05 -08:00
Larry Gritz 8c6606ce3b Update old Strutil::format to new fmt conventions (#1342)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-03-11 12:13:24 -08:00
Larry Gritz 6669fa5942 Minor change for smooth build against upcoming Imath 3.0 (#1341)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-28 21:10:00 -08:00
Mads Drøschler feafbf1472 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-02-28 11:41:24 -08:00
Larry Gritz fe08e6c04c 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-02-28 11:39:31 -08:00
Clark Chen cbd1915658 Fix incorrect hyperlink for boost (#1339)
Signed-off-by: Clark Chen <9372896+clarkchentw@users.noreply.github.com>
2021-02-24 23:09:52 -08:00
Larry Gritz 5c95eceac8 Fix formatting
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-18 08:55:55 -08:00
Larry Gritz e5f26c0977 Typo prevented visibility hiding from happening properly (#1337)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-18 08:42:32 -08:00
Larry Gritz 5cd6b3ec3c Minor fixes/enhancements to TypeSpec & Symbol (OSL internal classes) (#1327)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-17 23:33:26 -08:00
Larry Gritz 64ccf25d4a 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 14:23:02 -08:00
Larry Gritz 536c2d3ef6 Expunge Travis (#1334)
Kill the old travis CI

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-10 14:22:48 -08:00
sandipshukla 73d8f53a95 Fix unnecessary error messages to stderr for broken point clouds (#1333)
Signed-off-by: sandipshukla <>
2021-02-09 15:52:05 -08:00
Alex Wells f9c6e6714d Add implementation for BatchedBackendLLVM (#1330)
* Add implementation for BatchedBackendLLVM.  BatchedBackendLLVM implements the same set of functionality as BackendLLVM does, except it's implementation and many of it's methods handle wide data type (for symbols identified as varying (is_uniform()==false).  Many methods exist for (re)use by batched_llvm_gen and batched_llvm_instance.cpp.  A common theme is additional "bool is_uniform" parameter to identify if the operation we are generated code for is uniform or not.  We cannot rely on the Symbol itself, as an operation will be varying if just 1 of its inputs is varying.  This means that when uniform symbols are loaded as arguments, they will need to be widened/broadcast to partcipate in the varying operation.  Additionally "bool index_is_uniform" is used to generate gather/scatters vs. a wide load when symbols are varying.  Please remember the underlying "wide" data types are Structure of Arrays (SOA) and all address calculations have been modified inside BatchedBackendLLVM to work with SOA's.
Introduce helper class FuncSpec to encapsulate building function names that include a batch width and target ISA along with uniform and varying parameters.
Introduce TargetLibraryHelper interface and factory method to construct a Concrete TargetLibraryHelper
that provides a prefex string that all function calls will be prefixed with
and correctly initialize a function map for the shading system with
the functions from the target ISA library. Intent is batch size and target ISA specific shared libaries will be built and the correct on be loaded based on host machine.
Introduce TempScope.  Any calls to getOrAllocateTemp during the lifetime of a TempScope
will be associated with the latest TempScope on the stack and
when that TempScope's lifetime ends, any temp allocations will
be marked unused and will be available for reuse by the next
call to getOrAllocateTemp.
Introduce liboslexec/wide/define_opname_macros.h to define macros to consistently build OSL library function names including batch width, target isa, 0 to 5 arguments, and optionally masking.
Added builtindecl_wide_xmacro.h which is the equivalent of builtindecl.h for identifying the function names and signatures of OSL library functions that exist in batch size and target ISA specific shared libraries.

* Added missing initialization of OpDescriptor::llvmgenwide
Added friend declaration for ConcreteTargetLibraryHelper to use private base class TargetLibraryHelper

* Replaced some older copyright notices with latest one.
Moved llvm::Value* arrind assignment in batched_backendllvm.cpp from innerloop.

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2021-02-09 15:29:48 -08:00
Larry Gritz 627c406d8a 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-08 23:32:21 -08:00
Larry Gritz f7c8a0bb7b CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-02-01 22:17:21 -08:00
Larry Gritz 04d331e439 Transitioning repository to ASWF (#1329)
* Rename CLA files so they no longer say "draft."

* Change CONTRIBUTING.mv 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-01-25 09:44:09 -08:00
Reza Aarabi 1e7d8f0ba8 Building OSL on Windows OS (#1326)
* readme and documentation for windows build is added

* some fixes

* remove pythonpath

* add .vscode

* windows installation document is added to new directory

* add windows build script to new doc folder

* remove .vscode folder by adding it to .gitignore

* remove .vscode manually

* update document format

* change the name of the documentation to Readme.md

* add relative image path

* image now is ok

* remove copyright problems

* remove my website name

* add appropriate copyright notices to all the files

* a little fix

* Pixar copyright is added to the python file

* Modified Apache 2.0 License is added to THIRD_PARTY.md

* remove my website from the doc

* revert changes on THIRD-PARTY.md

* Modified Apache 2.0 License is reproduced
2021-01-24 14:16:27 -08:00
Alex Wells 79c1a20ed3 BatchedAnalysis (#1322)
Introduce BatchedAnalysis which processes operations similar to code gen in order to build up relationships between operations and symbols controlling conditional control flow. Using these relationships and information on which shader globals are varing and which symbols renderer outputs, varying can be pushed down to just the symbols that will require it. Also analysis to determine which symbols can be forced in llvm to be boolean vs integers.

The idea is simple, but understanding & managing the relationships is complex, however it is entirely encapsulated in BatchedAnalysis.cpp. The main goal is to build up a multimap "m_symbols_dependent_upon" which maps a key symbol to all other symbols that due to operations, conditions, loops, function calls, early out control flow (break, continue, exit) would be forced to be varying if that key symbol where varying. We can use this map to recursively push varying of symbols down from shader globals, renderer outputs, and operations whose results are implicitly varying.
Several custom data/acceleration structures have been created to efficiently model these relations ships with their key feature being that their iterators are never invalidated as additional items are pushed and popped such that one can always iterate from a historical position back to the root:
DependencyTreeTracker, FunctionTreeTracker. Additonally LoopStack tracks loop nesting and aids in detecting cyclical reads.

Analysis is also performed to identify which symbols are read at a different conditional scope than they were written to and might require masking. Symbols written to and read from within the same (or deeper nesting) conditional scope do not require masking. A conditional scope is defined as the stack of of conditions evaluated to reach an operation and is managed by the DependencyTreeTracker.

When adding new ops, or when changing implementation or behavior of
existing ops, the following functions should be evaluated to see if
they need to be updated to handle to handle the new op or change:

    bool are_op_results_always_implicitly_varying(ustring opname);
    bool are_op_results_always_implicitly_uniform(ustring opname);
    bool does_op_implementation_require_masking(ustring opname);
    SymbolPtrVec * protected_shader_globals_op_implicitly_depends_on(ShaderInstance &inst, Opcode & opcode);

If there is a new or change in control flow op's are made,
a more detailed evaluation will be needed as their behavior
is hard coded vs. lookup based implementation of the
functions above.

RuntimeOptimizer uses BatchedAnalysis before it coalesces temporaries so that varying and uniform symbols do not get merged.
2021-01-19 15:43:15 -08:00
Larry Gritz 7fe87d1daa Remove unused variable that was warning (#1325) 2021-01-19 15:39:28 -08:00
Mitch Prater ac3eb59173 New doc files. 2021-01-13 03:43:21 -08:00
Alex Wells 9d8aaabb6d PR/OptBatchedAnalysis (#1318)
* Add ShadingSystem attribute "opt_batched_analysis"(defaults to false) which triggers additional analysis during runtime optimization to set Symbol::is_uniform, Symbol::forced_llvm_bool(), and Opcode::requires_masking.  Only coalesce_temps for symbols whose is_uniform() and forced_llvm_bool() values match.  Update testshade to set opt_batched_analysis when batched execution is requested.

* Initialize opt_batched_analysis to true when RendererServices provides a BatchedRendererServices for WidthOf<16> or WidthOf<8>.
Changed testshade from explicitly enabling opt_batched_analysis to explicitly disabling it when not in batched execution mode.
Removed test for opt_batched_analysis from coalesce symbols pass and just rely on a Symbol's is_uniform() and forced_llvm_bool() to be set correctly.
2021-01-05 15:22:17 -08:00
Larry Gritz b0d3eef7a9 Fix CI after OIIO branch markers disappeared (#1320)
OIIO removed "RB-2.1" branch marker because it's not expecting any
further development in the obsolete 2.1 branch. We still test against
it, though, so replace its designation in our CI with the specific
branch tag of the last OIIO 2.1 release.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-01-02 12:41:37 -08:00
debaetsd 14bd942f1b fixed cmake setup when tests are disabled (#1319) 2020-12-29 13:01:21 -08:00
Larry Gritz 1a122a6606 Switch from deprecated to current version of OIIO parallel_image call (#1317)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-27 17:00:23 -08:00
Alex Wells dce27cd024 Add storage to Symbol for analysis result bool forced_llvm_bool(). (#1316)
Add storage to Symbol for analysis result bool forced_llvm_bool().
Results of a compare_op and other ops with logically boolean
results under certain conditions could be forced to be represented
in llvm as a boolean <i1> vs. an integer <i32>.  This simplifies
code generation, and under batched execution is a requirement
to make efficient use of hardware masking registers by allowing a
vector of bools <16 x i1> vs. integers <16 x i32>.  However the
underlying OIIO::TypeDesc as well as OSL does not support bools,
therefore they need to be promoted to integers when interacting with
other integer op's.
The value of forced_llvm_bool() is currently only respected during
batched execution.  Forced bools should not be coalesced with regular
ints, only other forced bools.
2020-12-18 10:06:03 -08:00
Larry Gritz d311f3ef82 CI Mac: the uninstall of openssl no longer needed, now causes problems (#1315)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-17 15:13:03 -08:00
Larry Gritz abd5ffbf9d 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-12 12:21:18 -08:00
Larry Gritz 315d91ab92 Embed sizzle reel video in main README (#1307)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-12-10 17:54:57 -08:00
Larry Gritz 04df5730f4 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 17:54:34 -08:00
John Mertic 2bb303f705 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 17:53:15 -08:00
Alex Wells 5b32bd1a48 Add ShadingSystem attribute "searchpath:library" (similar to searchpa… (#1310)
Add ShadingSystem attribute "searchpath:library" (similar to searchpath:shader) that is used to identify directories where target ISA optimized OSL shared libraries may exist.

Remove testshade command line parameters of "path" and "librarypath" as they were never used and can still be specified with "options".
2020-12-08 22:49:10 -08:00
Alex Wells 3104c85457 Symbol and Opcode changes to support batched analysis (#1313)
During batched analysis we will be figuring out which symbols need to be varying and which can be uniform during batched execution, we will also be figuring out the minimum number of operations which require masking as well as storing/caching some other operation specific flags used later in batched code generation.  We choose to store these analysis results inside Symbol and Opcode directly so that they are efficiently accessible and stable under optimization passes than might invidate OpcodeVec.
2020-12-08 22:31:33 -08:00
Alex Wells fc3d17acba Added missing implementations for LLVM_Util::assume_ptr_is_aligned(llvm::Value* ptr, unsigned alignment) and LLVM_Util::module_string() (#1306) 2020-12-02 15:54:20 -08:00
Larry Gritz c9f4dc98af 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-01 17:52:40 -08:00
Larry Gritz d236f480e6 CHANGES 2020-12-01 14:51:19 -08:00
Larry Gritz 962cc73639 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:17:48 -08:00
Larry Gritz 6f024bd13a Bump version in development master 2020-11-26 23:24:16 -08:00
Larry Gritz 2f26e9ddf3 Fix bug introduced in 1267: botched constant folding. (#1305)
Some minor refactoring of the recently introduced get_vec3 introduced
a bug into the constant folding of + and - for mixed floats and
triples: the constant produced was of the type of the first operand,
instead of the result. This fixes.

Added handy helper to make vector constant (and disambiguate it from
the one that makes a color constant).
2020-11-26 23:11:34 -08:00
Alex Wells d2f74c6edd Add plumbing through ShadyingSystem into Context to support Batched Execution (#1301)
* Add Symbol::wide_dataoffset() to track offset in heap to wide version of symbol's data
Add flag to Context to track if last execution was batched
Add template<int WidthT> ShadingContext::Batched interface to group together batched versions of execute_init, execute_layer, and execute methods.
Instantiate ShadingCOntext::Batched<8> and ShadingContext::Batched<16>.
Refactor std::vector<std::pair<ErrorHandler::ErrCode, std::string> m_buffered_errors to use proper ErrorItem class with optional Mask to identify which data lanes the Error message applies to.
Added struct ErrorBatch and std::vector<ErrorBatch> m_buffered_error_batches to track which entries in m_buffered_errors came from batched execution as those ranges need to processed multiple times, once per active data lane.
Refactored ShadingContext::process_errors into a templated helper to correlate batched and not batched errors effectively serializing the message output up to the ShadingSy
stem.
Modify ShadingContext::symbol_data to use the symbol's wide_dataoffset() when last execution was batched.
Add RunLLVMGroupFuncWide to model a a function pointer to a batched verson of a JIT'd shader function that accepts batched shader globals and an integer representing the mask (active data lanes) to execute on.
Added ShadingSystemImpl::Batched<int WidthT> interface to group together batched methods jit_group, and jit_all_groups
Instantiate ShadingSystemImpl::Batched<8> and ShadingSystemImpl::Batched<16>
Added ShaderGroup::batch_jitted to track if a group had been jitted for batching (separately from scalar jit)
Added ShaderGroup::llvm_groupdata_wide_size to track amount of heap space needed for a wide version of the group data structure.
To hold onto wide versions of llvm functions side by side with scalar, added llvm_compiled_wide_version, llvm_compiled_wide_init, llvm_compiled_wide_layer.
Add plumbing through ShadyingSystem into Context to support Batched Execution.

* Removed ErrorBatch as it was deemed unnecessary (unreachable usage scenario), which simplifies processing buffered errors.
Changed bool m_execution_is_batched to int batch_size_executed, so we know exactly how many data lanes to process errors for.
Fixed some clang-format issues in osl_pvt.h
2020-11-22 23:35:15 -08:00
Larry Gritz c361228791 Don't merge layers that produce renderer outputs. (#1296)
After talking this over with Luke Emrose it seems unwise to allow
merging of layers that produce renderer outputs.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-19 21:45:39 -08:00
Larry Gritz 0af46f8b2e Simplify popcount and countr_zero implementations (#1294)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-19 12:21:51 -08:00
Larry Gritz 7e5d44f313 Minor fixes to CI homebrew -- fix Mac failure, sync with OIIO
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-18 22:25:28 -08:00
Larry Gritz 6a50ea0c91 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 16:43:58 -08:00
Larry Gritz 68fbb9b5fe 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-18 16:41:20 -08:00
Larry Gritz f791a3deef Add #pragma error and warning to OSL preprocessor (#1300)
Two new preprocessor directives that oslc will respond to:

    #pragma error "my message"

    #pragma warning "my message"

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-18 14:55:06 -08:00
Larry Gritz ff3220753a Emergency fix for Mac versus recent OIIO master changes
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-16 12:08:38 -08:00
Alex Wells ea3f571ee0 Batched testshade (#1298)
* Added 64bit specific popcount call for GCC/Clang in Mask<int WidthT>::count()

* Implement BatchedSimpleRenderer for TestShade

* Introduce template<int WidthT> struct BatchedShaderGlobals
to store upto WidthT instances of ShaderGlobal data.  The data for a batch is broken into underlying uniform and varying data structures.  Uniform contains a fixed set of shader global values that are shared between all instances.  Varying has Block<DataT, WidthT> members so each instance can hold a different value.  The Block data structure is specialized to hold the underlying data type in a SIMD friendly Structure of Arrays (SOA) data layout but provides an array subscript interface to a proxy that can import/export the DataT in its orignal data layout.

Introduce template<int WidthT> class ShadingSystem::BatchedExecutor as an interface to execute batches of shader globals through a shader network.  BatchedExecutor provides similar execute methods that accept a BatchedShaderGlobals and batchSize instead of individual ShaderGlobal(s). This is just the interface, batched backend implemention to follow in subsequent pull requests.

Introduce template<typename DataT, int WidthT> Wide to hold a reference to Block<DataT, WidthT> and provide access to the underlying SOA data layout.  Wide can handle array types and const correctness.  The Wide adapter is lightweight and can be copied by value, used as function parameter.

Once batched execution finishes, the resulting symbol address can be passed to a Wide<DataT, Width> to access the resulting data in a type safe manner.

Updated testshade with command line option "--batched" causing batched execution of 16 or 8 instances through the shader network and to extract the results.  A later pull request will add batched interface to renderer services.

* Add new file src/include/OSL/batched_shaderglobals.h

* Disambiguate fabs call to fabs(double) so it doesn't try OSL::fabs which has no overload for double

* clang-format of batched_shaderglobals.h

* Add BatchedRenderServices, Mask<int WidthT> to represent active lanes during SIMD execution, BatchedTextureOptions, Masked<typename DataT, int WidthT>

* Removed unnecessary .c_str(), changed call to ::fabs to std::fabs

* Removed BatchedRendererServicesBases in favor of simple virtual functions is_overriden_*().
Improved some comments for BatchedRendererServices.h
Workaround some QT macro issues.

* Add BatchedRendererServices implimentation which mainly asserts that its methods are never directly called.
Fixed up issues with OSL_USING_DATA_WIDTH(WIDTH) macro.

* Removed Dz Structure Of Arrays wrappers as OSL doesn't currently support Dz.

* clang-format of mask.h and wide.h

* Added GCC and MSVC specific intrinsics for Mask<int WidthT>::count() and ::first_on()
Moved documentation for Wide, Masked, and other classes in wide.h from top overview to be near class definition.
Fixed some typos.
2020-11-16 10:50:06 -08:00
Larry Gritz 376be8e2f4 Fix compability break with OIIO < 2.2 (from change 1295) (#1297)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-12 11:48:08 -08:00
Larry Gritz 4b1f7b7b23 Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-11 16:22:43 -08:00
Larry Gritz 8f911b47cf CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-10 13:49:41 -08:00
Damien Courtois b8ee545347 Windows build fixes related to Cuda compilation (#1293)
* [cmake] fixed a compilation error when generating bitcode for Cuda files.

Basically the problem is that Boost::thread does some compile time checks that rely (when compiling with MSVC) on the runtime lib being set (/MD switch for instance) And the command that generates the bitcode doesn't specify this, and is not compatible with the switch (clang++ doesn't support MSVC switches, clang-cl is the one that does, but clang-cl doesn't support -O3 and other switches ...)
The easiest solution is to just disable the compile checks from Boost::threads by defined the macro used to guard the checks header.

* [cmake] silenced a ton of warnings about dllimport attributes being ignored on Windows, when generating bitcodes

* [cmake] fixed MSVC's command line warning about overwriting a /W argument.

* better fix for the dllimport attribute not being supported when compiling for Cuda

- the OSL export macros now check for __CUDACC__
- added comments in the CMake to remember to restore the warnings when the 3rd parties' export macros are also fixed.

* clang-format fix in export.h
2020-11-10 09:49:31 -08:00
Larry Gritz 82292a52b9 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 16:04:55 -08:00
Anders Langlands 06ce3d0635 simple self-contained cuda example (#1280) 2020-11-06 09:25:48 -08:00
Larry Gritz 8b1098f3a1 Clean up Mask implementation of first_on (#1291)
The version of Mask::first_on turned out not to have all the necessary
clauses fleshed out, breaking on Windows. So I refactored to get it
right.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-06 08:54:31 -08:00
Larry Gritz c7d77d8508 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:27:10 -08:00
Larry Gritz 308f289822 CI: build_opencolorio.bash: don't build gpu tests (#1288)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-05 10:26:47 -08:00
Alex Wells c3cd439335 Pr/batched rs (#1276)
* Added 64bit specific popcount call for GCC/Clang in Mask<int WidthT>::count()

* Introduce template<int WidthT> struct BatchedShaderGlobals
to store upto WidthT instances of ShaderGlobal data.  The data for a batch is broken into underlying uniform and varying data structures.  Uniform contains a fixed set of shader global values that are shared between all instances.  Varying has Block<DataT, WidthT> members so each instance can hold a different value.  The Block data structure is specialized to hold the underlying data type in a SIMD friendly Structure of Arrays (SOA) data layout but provides an array subscript interface to a proxy that can import/export the DataT in its orignal data layout.

Introduce template<int WidthT> class ShadingSystem::BatchedExecutor as an interface to execute batches of shader globals through a shader network.  BatchedExecutor provides similar execute methods that accept a BatchedShaderGlobals and batchSize instead of individual ShaderGlobal(s). This is just the interface, batched backend implemention to follow in subsequent pull requests.

Introduce template<typename DataT, int WidthT> Wide to hold a reference to Block<DataT, WidthT> and provide access to the underlying SOA data layout.  Wide can handle array types and const correctness.  The Wide adapter is lightweight and can be copied by value, used as function parameter.

Once batched execution finishes, the resulting symbol address can be passed to a Wide<DataT, Width> to access the resulting data in a type safe manner.

Updated testshade with command line option "--batched" causing batched execution of 16 or 8 instances through the shader network and to extract the results.  A later pull request will add batched interface to renderer services.

* Add new file src/include/OSL/batched_shaderglobals.h

* Disambiguate fabs call to fabs(double) so it doesn't try OSL::fabs which has no overload for double

* clang-format of batched_shaderglobals.h

* Add BatchedRenderServices, Mask<int WidthT> to represent active lanes during SIMD execution, BatchedTextureOptions, Masked<typename DataT, int WidthT>

* Removed unnecessary .c_str(), changed call to ::fabs to std::fabs

* Removed BatchedRendererServicesBases in favor of simple virtual functions is_overriden_*().
Improved some comments for BatchedRendererServices.h
Workaround some QT macro issues.

* Add BatchedRendererServices implimentation which mainly asserts that its methods are never directly called.
Fixed up issues with OSL_USING_DATA_WIDTH(WIDTH) macro.

* Removed Dz Structure Of Arrays wrappers as OSL doesn't currently support Dz.

* clang-format of mask.h and wide.h

* Added GCC and MSVC specific intrinsics for Mask<int WidthT>::count() and ::first_on()
Moved documentation for Wide, Masked, and other classes in wide.h from top overview to be near class definition.
Fixed some typos.
2020-11-04 16:29:44 -08:00
Larry Gritz 79c3ba4159 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 22:35:58 -08:00
Larry Gritz c3e2101f19 Build: Require exact version if PYTHON_VERSION is specified (#1286)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 11:03:05 -08:00
Larry Gritz 8fa602d270 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:02:52 -08:00
Larry Gritz 8ff28a0e06 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:03:55 -07:00
Larry Gritz 4c3f28e10e Add GPU CI test to build with USE_OPTIX=1 (#1283)
It can't run the tests, because there is no GPU on the GHA
instance. But at least we can tell if a PR will breake the build
itself. Later we will find a way to execute these via ASWF's AWS
instances that are for this purpose.

Includes the following changes:

* Download optix headers when needed. The ASWF docker container we're
  running on already has Cuda.

* Use CUDA_TARGET_ARCH CMake variable instead of hard coding in
  llvm_util.cpp.

* Bump cuda target default to sm_60.

* Make CI failure artifacts include CMakeCache.txt for inspection.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-29 13:20:37 -07:00
Larry Gritz d988291851 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:48:34 -07:00
Larry Gritz f0b28094a8 Modifications to build against LLVM 11 (#1274)
Change bleeding edge CI test to use LLVM 11.

A variety of changes were necessary to the code in LLVM_Util:

* `#if` guards for differing calls related to VectorType::get(),
  CreateShuffleVector.

* constant-generating functions now return llvm::Constant* instead of
  llvm::Value*.

* New wide_constant(width,value) functions for when you want a width other
  than the default vector_width.

* Renamed llvmVectorGet -> llvm_vector_type to be more symmetric with
  other methds we have.

* Simplified places that could have made calls to constant(),
  constant_bool(), wide_constant(), llvm_vector_type(), and
  call_function(), but instead did more complex llvm calls by hand.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-26 17:41:59 -07:00
Larry Gritz 2571c5d878 CI: Lock down on clang-format 10 for CI format check (#1278)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-23 08:42:10 -07:00
Larry Gritz 5bc4160a6c Work around GHCI Mac problem with homebrew openssl (#1277)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-23 08:41:53 -07:00
Larry Gritz e0fb636086 Remove rendererservices.h and batched_shaderglobals.h from oslexec.h (#1275)
With just a few minor adjustments, we're able to eliminate these two
headers (and everything else they pull in) from every client of
oslexec.h.  For the purposes of oslexec.h's declarations, all uses are
either pointers or references, so we only need the names
forward-declared, but we don't need the implementations revealed to
everybody including oslexec.h.

In particular, this hides the RendererServices and BatchedShaderGlobals
from a lot of translation units, should cut down on compile time and
reduce exposure of certain semi-internals to only the modules that
need them.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-21 09:05:02 -07:00
Alex Wells ab3712811c Add interface to ShadingSystem for Batched Execution (#1272)
* Introduce template<int WidthT> struct BatchedShaderGlobals
to store up to WidthT instances of ShaderGlobal data.  The data for a batch is broken into underlying uniform and varying data structures.  Uniform contains a fixed set of shader global values that are shared between all instances.  Varying has Block<DataT, WidthT> members so each instance can hold a different value.  The Block data structure is specialized to hold the underlying data type in a SIMD friendly Structure of Arrays (SOA) data layout but provides an array subscript interface to a proxy that can import/export the DataT in its orignal data layout.

Introduce template<int WidthT> class ShadingSystem::BatchedExecutor as an interface to execute batches of shader globals through a shader network.  BatchedExecutor provides similar execute methods that accept a BatchedShaderGlobals and batchSize instead of individual ShaderGlobal(s). This is just the interface, batched backend implemention to follow in subsequent pull requests.

Introduce template<typename DataT, int WidthT> Wide to hold a reference to Block<DataT, WidthT> and provide access to the underlying SOA data layout.  Wide can handle array types and const correctness.  The Wide adapter is lightweight and can be copied by value, used as function parameter.

Once batched execution finishes, the resulting symbol address can be passed to a Wide<DataT, Width> to access the resulting data in a type safe manner.

Updated testshade with command line option "--batched" causing batched execution of 16 or 8 instances through the shader network and to extract the results.  A later pull request will add batched interface to renderer services.

* Add new file src/include/OSL/batched_shaderglobals.h

* Disambiguate fabs call to fabs(double) so it doesn't try OSL::fabs which has no overload for double

* clang-format of batched_shaderglobals.h

* Removed unnecessary .c_str(), changed call to ::fabs to std::fabs
2020-10-19 18:14:13 -07:00
Larry Gritz 441c783b76 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 11:06:29 -07:00
Declan RussellandDeclan Russell 00e56afe8a 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-15 23:17:37 -07:00
Larry Gritz 27152ad3eb Minor fixes/enhancements to TypeSpec & Symbol (OSL internal classes) (#1267)
* Simplify implementation of TypeSpec::is_triple, more efficient.

* Add TypeSpec::is_triple_based(), analogous to all the other
  is_X/is_X_based.

* Bug fix: Symbol::get_string()'s assertion was checking whether it was
  a string, but should have checked if it was string_based.

* Add Symbol::get_vec3(), analogous to get_int/float/string.

* Add Symbol::coerce_float and coerce_vec3, like get but with some type
  coercions.

* Add Symbol::dataptr() as synonym for data(). This is for "forward
  compatibility", a future PR will make more widespread use of this.

* Lots and lots of places were error-prone and verbose casts are replaced
  with the new methods, and some logic simplified.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-15 13:00:34 -07:00
Larry Gritz a9b1f07c0e Remove ustring::format references, they will change meaning someday (#1270)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-15 10:13:44 -07:00
Larry Gritz 5e848fb761 Turn on clang-format for cpp files in testsuite (#1269) 2020-10-15 10:13:25 -07:00
Larry Gritz 0411a71ec7 Fix typo in example-deformer/CMakeLists.txt (#1268)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-14 14:01:51 -07:00
Larry Gritz 3e7ee0241f 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 15:39:03 -07:00
Larry Gritz 3aae741b09 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:27:04 -07:00
Larry Gritz 304f172376 Fix status message I meant to remove earlier
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-12 10:49:47 -07:00
Larry Gritz 58c9d166c0 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 13:04:51 -07:00
debaetsdandDieter De Baets 6a303aa2bc 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 13:40:02 -07:00
marsupialandrzulak a3d8ebfbb6 Make OSL & OSO parsers re-entrant. (#969)
* OSO re-entrant parser.

* OSL re-entrant parser.

* Formatting

* Use homebrew flex & bison for OSX

* Remove old oslparse()/osoparse() extern declarations.

* Set minimum versions of Flex and Bison

Add logic to flexbison.cmake to prefer the Homebrew version if it's
found (and if no BISON_ROOT is set) because the system install in
/usr/bin is too old to properly build with the new reentrant parser
directives.

Co-authored-by: rzulak <rzulak@imageworks.com>
2020-10-05 21:04:27 -07:00
Larry Gritz 17a17191df 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-05 16:01:46 -07:00
marsupialandrzulak 925a36e46e Build against Cuda-11.0.1 and Optix 7.1 (#1232)
Co-authored-by: rzulak <rzulak@imageworks.com>
2020-10-05 11:40:28 -07:00
Larry Gritz 3f5dae3f07 Raise OIIO dependency minimum to 2.1 going forward (#1256)
This patch drops support for OIIO 2.0, making 2.1 the minimum as we
move forward on the way to OSL 1.12 (or 2.0?). The current public
supported release of OIIO is 2.2, so this means that we are still
supporting both the current and the previous year's OIIO major
releases, as is our usual policy (that is, for an OSL that won't
be an official release until some time in 2021).

This patch does not change the supported OIIO releases of prior OSL
releases. In particular, the current release family, OSL 1.11, will
continue to support OIIO 2.0. We never change minimum dependencies
during the course of a release series.

One way this becomes a big simplification is that OIIO 2.1 started
exporting cmake configurations directly, and thus we no longer need
our copy of FindOpenImageIO.cmake, and can jettison some old
conventions that it used for older OIIO releases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-04 12:54:42 -07:00
Larry Gritz d56d03e0c5 Add Cuda+OptiX dependency reporting to testshade (#1259)
Move things around -- add new SS::getattribute queries for the
dependencies, SIMD build flags and runtime capabilities, and
Cuda/OptiX versions.  Then use these queries as the implementation for
reporting them in the statistics output.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-02 19:01:03 -07:00
Larry Gritz 0f46d8d0e2 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:50:38 -07:00
Larry Gritz 8a47b386e7 Belatedly bump version after development preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-29 14:27:05 -07:00
Larry Gritz d09912a42b 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:15:59 -07:00
Larry Gritz 47381363b7 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-25 11:17:14 -07:00
Alex M. Wells acf6b29059 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-09-24 11:01:59 -07:00
Alex M. Wells ace9c64ab9 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-09-24 11:00:03 -07:00
marsupialandrzulak 4288d5747e Fix osoparse & osolex from two independent liboslexec.so (#1255)
* Mangle parse and lex C-functions.

* Reset osoreader to nullptr after parse.

Co-authored-by: rzulak <rzulak@imageworks.com>
2020-09-24 10:59:03 -07:00
timgrantandTim Grant ff599d134d Explicitly set the OptiX pipeline stack size. (#1254)
Co-authored-by: Tim Grant <tgrant@nvidia.com>
2020-09-23 15:11:07 -07:00
Alex M. Wells 3b57df4e33 Custom opt levels and passes (1250)
Work of Alex Wells, Intel.

Added custom optimization passes to improve AVX/AVX2 code generation
which are automatically added when targeting the host:

  * PrePromoteLogicalOpsOnBitMasks
  * PreventBitMasksFromBeingLiveinsToBasicBlocks

Added support for experimental llvm_optimize: 10,11,12,13.  Optlevels
10, 11, 12, 13 explicitly create optimization passes.  They are
stripped down versions of clang's -O0, -O1, -O2, -O3.  They try to
provide similar results with improved optimization time by removing
some expensive passes that were repeated many times and omitting other
passes that are not applicable or not profitable.  Useful for
debugging, optlevel 10 adds next to no additional passes.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-21 21:52:09 -07:00
Larry Gritz 71eb599211 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-20 22:38:15 -07:00
Larry Gritz 6226bee166 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:17:17 -07:00
Alex M. Wells 9a85e6fe4d LLVM_Util: add support for masked operations (1248)
Work by Alex Wells.

This will be used extensively by the SIMD batched shading.

* Added support for masked operations by managing a stack of masks
  that were created by conditionals or control flow. Detailed
  explanation of the Masking Strategy in llvm_util.h.

* Added support for logically masked functions (handling of masked
  return from inside OSL functions)

* Added support for masked loops (handling of masked break and or
  masked continue).

* Added support for masked exit (handling of masked exit from entire
  shader).

* Added support for management of when masking is required with a
  ScopedMasking object to allow nesting during code gen.

* op_store (and other store variations) respect the current masking
  requirement and current top of the mask stack (not just the top
  entry, but a combined view of the entire mask stack).

* Added support for results of conditional operations to remain
  boolean.  Most masking operations are expecting vector of bool
  values, not a vector of integers., e.g. when vector width is 16, for
  scalar or <16 x i1> for wide. When a conditional result is used by
  another operation a numerical value it is automatically converted to
  an integer.

* Added `llvm::Type *type_native_mask() const;` because different
  ISA's may have different representations of a mask from llvm's
  vector of bits that comparison operations emit.  And we need varying
  boolean symbols to have the correct data type (size) on the stack
  and in data structures.

* Added gather and scatter operations.

* Added helpers to convert from bool<->int, native_mask<->llvm_mask

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-09 20:25:39 -07:00
Larry Gritz a977bd7fe8 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-09-03 16:00:47 -07:00
Larry Gritz f99ab09096 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:05:04 -07:00
Larry Gritz 9929b39294 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 09:07:03 -07:00
Larry Gritz 9fdaf2cb1f 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:01 -07:00
Larry Gritz e254b50ff7 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 09:56:48 -07:00
Larry Gritz 708a99307c CMake: Remember to set ${PROJECT_NAME}_SUPPORTED_RELEASE
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 22:21:50 -07:00
Larry Gritz 8bc15b2dd4 Rebuild docs for release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 22:19:12 -07:00
Larry Gritz 85694d0b32 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 22:18:51 -07:00
Larry Gritz b205b1905a Fix capitalization in new testshade options
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 22:18:47 -07:00
Larry Gritz 8be28e2c5b Docs: Fix longstanding error in description of spline() (#1239)
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:27:57 -07:00
Larry Gritz 5aefa56d6c 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:22:00 -07:00
marsupialandrzulak b1c9fdf678 Move spi-bits to llvm-11.0.0 release. (#1241)
Co-authored-by: rzulak <rzulak@imageworks.com>
2020-08-12 20:25:47 -07:00
Alex M. Wells 3330f0a436 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 21:34:29 -07:00
Larry Gritz 5f69390515 More flexible find of llvm-config with suffixed with '-64' (#1238)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-11 11:09:26 -07:00
etheory d1ff4e5748 Remove null check from symbol_address for performance (#1237) 2020-08-02 21:15:49 -07:00
Alex M. Wells 164e834473 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-01 17:51:21 -07:00
Larry Gritz 440d8a9083 Fix changes typos
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 17:48:25 -07:00
Larry Gritz 8baad933c3 Branch, master is now dev area for 1.12
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 14:36:20 -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
3083 changed files with 259189 additions and 41751 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
#...
+45
View File
@@ -0,0 +1,45 @@
# 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
# Turn on clang-format for cpp files in testsuite (#1269)
00c895fc642eb89685797c292048bdff15d675e7
5e848fb761261521a3ee7cd8a4f6814f32fe4a47
# CI: Change our clang-format standard to clang11 (#1372)
91d22ebe2f65d4ed0599e421172a15d99fe0e1b4
# More clang-format (this time, testrender and liboslnoise) (#1511)
08706b7cbac781b6a9389780428016be985d9d89
# clang-format #1509
b4026fd1695c08532557b3ba1c2142323087ccf9
1f73b075c99861afa42fac44567b37f797bc72f2
7f2e83794e6fa63d5180653cffb77be2cc38b32b
28399fefc890442b5ac020e7a90cee0d5bf9f03c
e56851056d33233b0bb8324faac251907099961a
1c57fc61d8ab7c3f309be4335e4c71c26399edd4
46d451ce74d00e904874df476ebeca19bb119ea9
c1045f2c2845a98e661c7181932a031eb3c76063
# More clang-format (#1512)
8c6ffdd911b9eb7db4adf41ab88891360452d7c5
# style: more clang-format (#1515)
102430c83554fe7e328cd8c3317db00507bcfaba
# Revert some formatting (#1518)
21eac9d9215d071b0a7b9ce2c32f189ed0c62c4a
# Another round of clang-format (#1540)
38015b6be28643254aea530154b7860136cf5e15
89d5db2b5c5fda79184d8245d903e580fc6a4e9c
# clang-format: the very last piece of the puzzle (#1555)
4ee62cd2ef05543f818f4d95a19efc1d684a7381
5be7c6bd4e7bd2e560cb6be8c06f11985384a87a
+1 -1
View File
@@ -1,5 +1,5 @@
<!--
Please ask questions ("how do I...?" "why doesn't this work?") on the [osl-dev mail list](http://groups.google.com/group/osl-dev), not by filing issues.
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.
+130
View File
@@ -0,0 +1,130 @@
# Copyright 2008-present Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
name: Analysis
on:
schedule:
# Run nightly while we're still working our way through the warnings
- cron: "0 8 * * *"
# Run unconditionally once weekly
# - cron: "0 0 * * 0"
push:
branches:
- main
- '*analysis*'
# Allow manual kicking off of the workflow from github.com
workflow_dispatch:
permissions: read-all
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
aswf:
name: "SonarCloud Analysis"
if: |
github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
strategy:
fail-fast: false
matrix:
include:
- desc: sonar gcc9/C++14 llvm13 py3.9 boost1.76 exr3.1 oiio2.3 avx2
nametag: static-analysis-sonar
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang13
cxx_std: 14
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.9.0
simd: avx2,f16c
batched: b8_AVX2,b16_AVX512
coverage: 1
# skip_tests: 1
sonar: 1
setenvs: export SONAR_SCANNER_VERSION=4.7.0.2747
SONAR_SERVER_URL="https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR=bw_output
OSL_CMAKE_BUILD_WRAPPER="build-wrapper-linux-x86-64 --out-dir bw_output"
CMAKE_BUILD_TYPE=Debug
CMAKE_UNITY_BUILD=OFF
CODECOV=1
TESTRENDER_AA=1
OSL_TESTSUITE_SKIP_DIFF=1
CTEST_TEST_TIMEOUT=1200
OSL_CMAKE_FLAGS="-DOSL_TEST_BIG_TIMEOUT=1200 -DUSE_QT=0"
CTEST_EXCLUSIONS="broken|noise-reg.regress|noise-gabor-reg.regress"
runs-on: ${{ matrix.os }}
container:
image: aswf/ci-osl:${{matrix.vfxyear}}${{matrix.vfxsuffix}}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
OPENIMAGEIO_VERSION: ${{matrix.openimageio_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
USE_BATCHED: ${{matrix.batched}}
USE_SIMD: ${{matrix.simd}}
# DEBUG_CI: 1
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
fetch-depth: '0'
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Remove existing OIIO
if: matrix.openimageio_ver != ''
run: |
sudo rm -rf /usr/local/include/OpenImageIO
sudo rm -rf /usr/local/lib*/cmake/OpenImageIO
sudo rm -rf /usr/local/lib*/libOpenImageIO*
sudo rm -rf /usr/local/lib*/python3.9/site-packages/OpenImageIO*
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- name: Code coverage
if: matrix.coverage == '1'
run: src/build-scripts/ci-coverage.bash
- name: Sonar-scanner
if: matrix.sonar == 1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner -X --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="build/bw_output" --define sonar.cfamily.gcov.reportsPath="_coverage"
+495
View File
@@ -0,0 +1,495 @@
# 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, for the main project repo (not for forks)
- cron: "0 6 * * *"
if: github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
permissions: read-all
jobs:
aswf:
name: "VFX${{matrix.vfxyear}} ${{matrix.desc}}"
strategy:
fail-fast: false
matrix:
include:
- desc: gcc6/C++14 llvm9 py2.7 boost1.66 exr2.3 oiio2.2 sse2
nametag: linux-vfx2019
os: ubuntu-latest
vfxyear: 2019
vfxsuffix: -clang9
cxx_std: 14
openimageio_ver: v2.3.17.0
python_ver: 2.7
pybind11_ver: v2.4.2
- desc: clang9/C++14 llvm9 oiio-release boost1.66 avx2 exr2.3 py2.7
nametag: linux-clang9-llvm9
os: ubuntu-20.04
vfxyear: 2019
vfxsuffix: -clang9
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 14
openimageio_ver: release
python_ver: 2.7
# pybind11_ver: v2.9.0
simd: avx
- desc: GPU Cuda10 gcc6/C++14 llvm10 py2.7 boost-1.70 exr-2.3 OIIO-master avx2
nametag: linux-optix7-2019
os: ubuntu-latest
vfxyear: 2019
vfxsuffix: -clang10
cxx_std: 14
openimageio_ver: master
python_ver: 2.7
# pybind11_ver: v2.9.0
simd: avx2,f16c
skip_tests: 1
setenvs: export OSL_CMAKE_FLAGS="-DUSE_OPTIX=1" OPTIX_VERSION=7.0
OPENIMAGEIO_CMAKE_FLAGS=-DBUILD_FMT_VERSION=8.1.1
- desc: gcc6/C++14 llvm10 py3.7 boost1.70 exr2.4 oiio2.2 sse4
nametag: linux-vfx2020
os: ubuntu-latest
vfxyear: 2020
cxx_std: 14
openimageio_ver: v2.3.17.0
python_ver: 3.7
pybind11_ver: v2.5.0
simd: sse4.2
setenvs: export CONAN_LLVM_VERSION=10.0.1
- desc: gcc9/C++17 llvm11 py3.7 boost1.73 exr2.5 oiio2.2 avx2 batch-b8avx2
nametag: linux-vfx2021
os: ubuntu-latest
vfxyear: 2021
vfxsuffix: -clang11
cxx_std: 17
openimageio_ver: dev-2.3
python_ver: 3.7
pybind11_ver: v2.7.0
simd: avx2,f16c
batched: b8_AVX2_noFMA
- desc: gcc9/C++17 llvm13 py3.9 boost1.76 exr3.1 oiio2.3 avx2
nametag: linux-vfx2022
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang13
cxx_std: 17
openimageio_ver: release
python_ver: 3.9
pybind11_ver: v2.9.0
simd: avx2,f16c
batched: b8_AVX2
- desc: clang12/C++17 llvm12 oiio-master boost1.73 exr3.1 py3.9 avx2 batch-avx512
nametag: linux-clang12-llvm12-batch
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang12
cxx_std: 17
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.6.2
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: USE_OPENVDB=0
- desc: icc/C++17 llvm14 py3.9 boost1.76 exr3.1 oiio-master avx2
nametag: linux-icc
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang14
cc_compiler: icc
cxx_compiler: icpc
cxx_std: 17
fmt_ver: 7.1.3
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.9.0
# simd: avx2,f16c
batched: b8_AVX2_noFMA
setenvs: export OSL_CMAKE_FLAGS="-DSTOP_ON_WARNING=OFF -DEXTRA_CPP_ARGS=-fp-model=consistent"
OPENIMAGEIO_CMAKE_FLAGS=-DBUILD_FMT_VERSION=7.1.3
USE_OPENVDB=0
- desc: icx/C++17 llvm14 py3.9 boost1.76 exr3.1 oiio2.3 avx2
nametag: linux-icx
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang14
cc_compiler: icx
cxx_compiler: icpx
cxx_std: 17
fmt_ver: 7.1.3
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.9.0
simd: avx2,f16c
batched: b8_AVX2_noFMA
setenvs: export OSL_CMAKE_FLAGS="-DSTOP_ON_WARNING=OFF" USE_OPENVDB=0
- desc: oldest everything gcc6/C++14 llvm9 py2.7 boost1.66 oiio2.2 no-simd exr2.3
nametag: linux-oldest
os: ubuntu-latest
vfxyear: 2019
vfxsuffix: -clang9
cxx_std: 14
openimageio_ver: v2.3.17.0
python_ver: 2.7
pybind11_ver: v2.6.2
simd: 0
setenvs: export PUGIXML_VERSION=v1.8
# Address and leak sanitizers
- desc: sanitizers
nametag: sanitizer
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang13
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 17
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.9.0
simd: avx2,f16c
batched: b8_AVX2
setenvs: export OSL_CMAKE_FLAGS="-DSANITIZE=address -DOSL_TEST_BIG_TIMEOUT=1200"
CMAKE_BUILD_TYPE=Debug
CTEST_TEST_TIMEOUT=1200
CTEST_EXCLUSIONS="broken|noise-reg.regress|noise-gabor-reg.regress|example-.*deformer|spline-reg.regress.batched|osl-imageio"
OSL_OPTIONS=llvm_debugging_symbols=1
TESTRENDER_AA=1
OSL_TESTSUITE_SKIP_DIFF=1
# Sanitizer notes:
# - There are a handful of tests we disable entirely with
# CTEST_EXCLUSIONS because they are irrelevant or just cannot be
# made to be clean (and that's ok).
# - Tests with sanitizers run slow, so we increase timeouts, and
# also set AA to 1 for render tests to speed them up.
# OSL_TESTSUITE_SKIP_DIFF prevents making the AA=1 image result
# fail, but that's ok because every other CI test is checking
# the results; here we have no reason to believe results will
# differ from other tests, we just need to run with sanitizers
# turned on.
# - In testing.cmake, we rig texture tests to disable the leak
# sanitizer, because we can't eliminate some completely benign
# leaks from the texture system, and because they are called
# from JITed code, we don't get a clean stack trace of things
# that happen in OIIO and therefore we just can't enumerate the
# allowed exceptions. So we trust that OIIO itself tests the
# texture system adequately and is able to ignore the benign
# "leaks."
# 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).
- desc: "clang-format"
nametag: clang-format
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang14
cxx_std: 17
openimageio_ver: release
python_ver: 3.9
simd: avx2,f16c
batched: b8_AVX2
skip_tests: 1
setenvs: export BUILDTARGET=clang-format
OPENIMAGEIO_CMAKE_FLAGS=-DUSE_PYTHON=0
runs-on: ${{matrix.os}}
container:
image: aswftesting/ci-osl:${{matrix.vfxyear}}${{matrix.vfxsuffix}}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
OPENIMAGEIO_VERSION: ${{matrix.openimageio_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
USE_BATCHED: ${{matrix.batched}}
USE_SIMD: ${{matrix.simd}}
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-${{matrix.nametag}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Remove existing OIIO
if: matrix.openimageio_ver != ''
run: |
sudo rm -rf /usr/local/include/OpenImageIO
sudo rm -rf /usr/local/lib*/cmake/OpenImageIO
sudo rm -rf /usr/local/lib*/libOpenImageIO*
sudo rm -rf /usr/local/lib*/python3.9/site-packages/OpenImageIO*
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: osl-${{github.job}}-${{matrix.nametag}}
path: |
build/*.cmake
build/CMake*
build/testsuite/*/*.*
ubuntu:
name: "Ubuntu ${{matrix.desc}}"
strategy:
fail-fast: false
matrix:
include:
- desc: Debug gcc7/C++14 llvm9 py2.7 oiio2.3 exr2.4 sse4 boost1.65 exr2.4
nametag: linux-debug-gcc7-llvm9
os: ubuntu-20.04
cxx_compiler: g++-7
cxx_std: 14
openexr_ver: v2.4.3
openimageio_ver: dev-2.3
pybind11_ver: v2.6.2
python_ver: 2.7
simd: sse4.2
setenvs: export CMAKE_BUILD_TYPE=Debug
LLVM_VERSION=9.0.0
PUGIXML_VERSION=v1.9
CTEST_TEST_TIMEOUT=240
- desc: gcc10/C++17 llvm10 oiio-release boost1.65 exr2.5 avx2
nametag: linux-2021ish-gcc10-llvm10
os: ubuntu-20.04
cxx_compiler: g++-10
cxx_std: 17
fmt_ver: 7.0.1
openexr_ver: v2.5.6
openimageio_ver: release
pybind11_ver: v2.8.1
# python_ver: 2.7 FIXME
simd: avx2,f16c
setenvs: export LLVM_VERSION=10.0.0
OPENIMAGEIO_CMAKE_FLAGS="-DBUILD_FMT_VERSION=7.0.1"
PUGIXML_VERSION=v1.10
- desc: latest releases gcc11/C++17 llvm13 boost1.71 exr3.1 py3.9 avx2 batch-b16avx512
nametag: linux-latest-releases
os: ubuntu-20.04
cxx_compiler: g++-11
cxx_std: 17
fmt_ver: 9.1.0
openexr_ver: v3.1.6
openimageio_ver: master
pybind11_ver: v2.10.0
python_ver: 3.9
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: export LLVM_VERSION=13.0.0
LLVM_DISTRO_NAME=ubuntu-20.04
OPENCOLORIO_VERSION=v2.2.0
PUGIXML_VERSION=v1.13
- desc: bleeding edge gcc12/C++17 llvm14 oiio/ocio/exr/pybind-master boost1.71 py3.10 avx2 batch-b16avx512
nametag: linux-bleeding-edge
os: ubuntu-22.04
cxx_compiler: g++-12
cxx_std: 17
fmt_ver: master
openexr_ver: main
openimageio_ver: master
pybind11_ver: master
python_ver: "3.10"
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: export LLVM_VERSION=14.0.0
LLVM_DISTRO_NAME=ubuntu-18.04
OPENCOLORIO_VERSION=main
PUGIXML_VERSION=master
- desc: clang14/C++17 llvm14 boost1.71 exr3.1 py3.8 avx2 batch-b16avx512
nametag: linux-latest-releases-clang
os: ubuntu-20.04
cxx_compiler: clang++
cc_compiler: clang
cxx_std: 17
fmt_ver: 8.1.1
openexr_ver: v3.1.5
openimageio_ver: master
pybind11_ver: v2.9.2
python_ver: 3.8
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: export LLVM_VERSION=14.0.0
LLVM_DISTRO_NAME=ubuntu-18.04
OPENCOLORIO_VERSION=v2.1.2
PUGIXML_VERSION=v1.11.4
runs-on: ${{matrix.os}}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
OPENIMAGEIO_VERSION: ${{matrix.openimageio_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
USE_BATCHED: ${{matrix.batched}}
USE_SIMD: ${{matrix.simd}}
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-${{matrix.nametag}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: osl-${{github.job}}-${{matrix.nametag}}
path: |
build/*.cmake
build/CMake*
build/testsuite/*/*.*
macos:
name: "${{matrix.os}} appleclang${{matrix.aclang}}/C++${{matrix.cxx_std}} py${{matrix.python_ver}} ${{matrix.desc}}"
strategy:
fail-fast: false
matrix:
include:
- desc: MacOS-11
os: macos-11
nametag: macos11-py39
cc_compiler: /usr/local/opt/llvm@14/bin/clang
cxx_compiler: /usr/local/opt/llvm@14/bin/clang++
cxx_std: 17
python_ver: "3.10"
aclang: 13
setenvs: export LLVMBREWVER="@14" DO_BREW_UPDATE=1
OPENIMAGEIO_VERSION=release
- desc: MacOS-12
os: macos-12
nametag: macos11-p310
cc_compiler: /usr/local/opt/llvm@15/bin/clang
cxx_compiler: /usr/local/opt/llvm@15/bin/clang++
cxx_std: 17
python_ver: "3.10"
aclang: 13
setenvs: export LLVMBREWVER="@15" DO_BREW_UPDATE=1
OPENIMAGEIO_VERSION=master
runs-on: ${{matrix.os}}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
PYTHON_VERSION: ${{matrix.python_ver}}
OPENIMAGEIO_VERSION: ${{matrix.openimageio_ver}}
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /Users/runner/.ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-${{matrix.nametag}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
source src/build-scripts/install_homebrew_deps.bash
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then \
OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0" ; \
source src/build-scripts/build_openimageio.bash ; \
else \
brew install --display-times -q openimageio ; \
PYTHONPATH=$PYTHONPATH:/usr/local/python${PYTHON_VERSION}/site-packages ; \
fi
src/build-scripts/save-env.bash
- name: Build
run: |
src/build-scripts/ci-build.bash
- name: Testsuite
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: osl-${{github.job}}-${{matrix.nametag}}
path: |
build/*.cmake
build/CMake*
build/testsuite/*/*.*
+67
View File
@@ -0,0 +1,67 @@
name: Scorecards supply-chain security
on:
# Only the default branch is supported.
branch_protection_rule:
schedule:
- cron: '44 20 * * 6'
push:
branches: [ "main", "scorecard" ]
# Declare default permissions as read only.
permissions: read-all
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
analysis:
name: Scorecards analysis
if: |
github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Used to receive a badge. (Upcoming feature)
id-token: write
steps:
- name: "Checkout code"
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@3e15ea8318eee9b333819ec77a36aca8d39df13e # v1.1.1
with:
results_file: results.sarif
results_format: sarif
# (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results for public repositories to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with:
sarif_file: results.sarif
+7
View File
@@ -1,6 +1,13 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
dist
build
*~
\#*\#
*.pyc
*.log
.vscode
.envrc
-148
View File
@@ -1,148 +0,0 @@
# .travis.yml for OSL
language: cpp
sudo: false
osx_image: xcode7.3
dist: trusty
# Add-ons: specify apt packages for Linux
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- cmake
- cmake-data
- g++-4.8
- g++-5
- g++-6
- g++-7
- libboost1.55-all-dev
- libtiff4-dev
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 | head -26 ;
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
# Temporary fix: Use LG's private openexr branch, until the
# fixes are merged into the OpenEXR project that will address
# the warnings for gcc7 and C++17 compatibility.
- export EXRREPO=https://github.com/lgritz/openexr.git ;
- export EXRBRANCH=lg-cpp11 ;
- if [ $TRAVIS_OS_NAME == osx ] ; then
src/build-scripts/install_homebrew_deps.bash ;
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 ;
if [ "$LLVM_VERSION" == "" ]; then export LLVM_VERSION="3.9.0" ; fi ;
wget http://releases.llvm.org/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz ;
tar xf clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz ;
rm -f clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz ;
mv clang+llvm* llvm-install ;
export LLVM_DIRECTORY=$PWD/llvm-install ;
fi
- export OIIOMAKEFLAGS="$OIIOMAKEFLAGS -j2 DEBUG= USE_PYTHON=0 OIIO_BUILD_TESTS=0"
- export OPENIMAGEIO_SITE=travis
- export OSL_SITE=travis
- src/build-scripts/build_openimageio.bash
- export OPENIMAGEIOHOME=$PWD/OpenImageIO/dist/$OIIOPLATFORM
- export PATH=$OPENIMAGEIOHOME/bin:$PATH
- export DYLD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$DYLD_LIBRARY_PATH
- export LD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$LD_LIBRARY_PATH
- export PYTHONPATH=$OPENIMAGEIOHOME/python:$PYTHONPATH
- 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 LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt
- export OSLHOME=$PWD/dist/$PLATFORM
- export OIIO_LIBRARY_PATH=$OSLHOME/lib:${OIIO_LIBRARY_PATH}
- 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
include:
# Build with C++11, default compiler, optimized build, against OIIO master
- os: linux
compiler: gcc
- os: osx
compiler: clang
# Test against the older release branch of OIIO (all the other tests
# are against OIIO master).
- os: linux
compiler: gcc
env: OIIOBRANCH=release
# Test gcc 5, also against higher SSE level
- os: linux
compiler: gcc
env: WHICHGCC=5 USE_SIMD=sse4.2
# Test gcc6, and highest SIMD level supported by Travis.
- os: linux
compiler: gcc
env: WHICHGCC=6 USE_SIMD=avx,f16c
# Linux only: test gcc 7, also test C++14
- os: linux
compiler: gcc
env: WHICHGCC=7 USE_CPP=14
# Build with C++11, DEBUG build, against OIIO master
- os: linux
compiler: gcc
env: DEBUG=1
# Test against older LLVM
- os: linux
compiler: gcc
env: LLVM_VERSION=3.5.2
# One more, just for the heck of it, turn all SIMD off.
- os: linux
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
- [X] Developer Certificate of Origin post commit signoff done and DCO Probot enabled.
+1431 -30
View File
File diff suppressed because it is too large Load Diff
+219 -273
View File
@@ -1,357 +1,303 @@
cmake_minimum_required (VERSION 3.2.2)
cmake_policy (SET CMP0048 NEW) # Allow VERSION specifier in project()
project (OSL
VERSION 1.9.1
LANGUAGES CXX C)
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
cmake_minimum_required (VERSION 3.12)
set (OSL_VERSION "1.13.2.4")
set (OSL_VERSION_OVERRIDE "" CACHE STRING
"Version override (use with caution)!")
mark_as_advanced (OSL_VERSION_OVERRIDE)
if (OSL_VERSION_OVERRIDE)
set (OSL_VERSION ${OSL_VERSION_OVERRIDE})
endif ()
project (OSL VERSION ${OSL_VERSION}
LANGUAGES CXX C
HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/OpenShadingLanguage")
set (PROJ_NAME ${PROJECT_NAME}) # short name
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
set (PROJECT_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
set (PROJECT_VERSION_RELEASE_TYPE "dev" 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_COPYRIGHTYEARS "2008-2017")
set (PROJECT_AUTHORS "Sony Pictures Imageworks, et al")
set (PROJECT_URL "")
set (PROJECT_VERSION_MAJORMINOR
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
message (STATUS "Building ${PROJECT_NAME} ${PROJECT_VERSION}")
message (STATUS "CMake version is ${CMAKE_VERSION}")
cmake_policy (SET CMP0017 NEW) # Prefer files from the CMake module directory when including from there.
cmake_policy (SET CMP0025 NEW) # Detect AppleClang for new CMake
cmake_policy (SET CMP0046 OLD) # Don't error on non-existent dependency in add_dependencies.
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
# Deprecated names
set (OSL_LIBRARY_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set (OSL_LIBRARY_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set (OSL_LIBRARY_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set (OSL_LIBRARY_VERSION_RELEASE_TYPE ${PROJECT_VERSION_RELEASE_TYPE})
# Version of the OSO file format and instruction set
set (OSO_FILE_VERSION_MAJOR 1)
set (OSO_FILE_VERSION_MINOR 0)
if (VERBOSE)
message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
set (PROJECT_AUTHORS "Contributors to the Open Shading Language project")
option (${PROJECT_NAME}_SUPPORTED_RELEASE
"Set ON for supported release branch, OFF for master" OFF)
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
set (${PROJECT_NAME}_DEV_RELEASE OFF)
else ()
set (${PROJECT_NAME}_DEV_RELEASE ON)
endif ()
message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
message (STATUS "Project install dir = ${CMAKE_INSTALL_PREFIX}")
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)
# 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 ()
# Version of the OSO file format and instruction set
set (OSO_FILE_VERSION_MAJOR 1)
set (OSO_FILE_VERSION_MINOR 0)
# This needs to be early, for CMAKE_INSTALL_FULL_DATADIR
include (GNUInstallDirs)
set (CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")
include (platform)
include (compiler) # All the C++ and compiler related options live here
## 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()
endif()
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)")
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)
option (USE_LLVM_BITCODE "Generate embedded LLVM bitcode" OFF)
else ()
option (USE_LLVM_BITCODE "Generate embedded LLVM bitcode" ON)
endif ()
option (USE_PARTIO "Use Partio if found" ON)
set (PARTIO_HOME "" CACHE STRING "Search path for Partio components")
option (USE_EXTERNAL_PUGIXML "Use an externally built shared library version of the pugixml library" OFF)
set (PUGIXML_HOME "" CACHE STRING "Hint about where to find external PugiXML library")
option (USE_FAST_MATH "Use fast math approximations (if no, then use system math library)" ON)
option (OSL_BUILD_PLUGINS "Bool OSL plugins, for example OIIO plugin" ON)
option (USE_BOOST_WAVE "Use Boost Wave for C preprocessor (alternative is to use clang)" OFF)
option (OSL_BUILD_SHADERS "Build shaders" ON)
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_60" CACHE STRING "CUDA GPU architecture (e.g. sm_50)")
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')")
option (OSL_USTRINGREP_IS_HASH "Always use ustringhash for strings" OFF)
# set (USE_OIIO_STATIC ON CACHE BOOL "If OIIO is built static")
# if (USE_OIIO_STATIC)
# add_definitions ("-DOIIO_STATIC_BUILD=1")
# endif ()
set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::TextureSystem")
if (OSL_NO_DEFAULT_TEXTURESYSTEM)
add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1")
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 ()
add_definitions ("-DOSL_FAST_MATH=0")
endif ()
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 ()
# Set the default namespace
if (USE_OPTIX)
add_definitions ("-DOSL_USE_OPTIX=1")
endif ()
# Define OSL_INTERNAL symbol only when building OSL itself, will not be
# defined for downstream projects using OSL.
add_definitions (-DOSL_INTERNAL=1)
# Set the default namespace. For symbol hiding reasons, it's important that
# the project name is a subset of the namespace name.
set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING
"Customized outer namespace base name (version will be added)")
option (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH
"Should the inner namespace include the patch number" ${${PROJECT_NAME}_DEV_RELEASE})
set (PROJ_NAMESPACE "${${PROJ_NAME}_NAMESPACE}")
string(REGEX MATCH ${PROJECT_NAME} NAMESPACE_HAS_PROJECT_NAME ${PROJ_NAMESPACE})
if (NOT NAMESPACE_HAS_PROJECT_NAME)
set (PROJ_NAMESPACE ${PROJECT_NAME}_${PROJ_NAMESPACE})
endif ()
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE}_v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}")
if (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH)
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE_V}_${PROJECT_VERSION_PATCH}")
endif ()
message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
include (util_macros)
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 (externalpackages)
include (flexbison)
include (install) # installation options all implemented here
include (cuda_macros)
include (llvm_macros)
# Include all our testing apparatus and utils, but not if it's a subproject
if (${PROJECT_NAME}_BUILD_TESTS AND PROJECT_IS_TOP_LEVEL)
include (testing)
endif ()
include_directories (
BEFORE
"${OSL_LOCAL_DEPS_DIR}/include"
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_BINARY_DIR}/src/include"
"${CMAKE_BINARY_DIR}/include"
)
###########################################################################
# 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)
# Make sure our math calculations are consistent,
# especially division. Different compilers may have choose to use
# reciprocal division losing precision causing slightly different
# results which can lead to aliasing differences when running the testsuite
# Disable reciprocal division
if (CMAKE_COMPILER_IS_INTEL)
if (MSVC)
add_compile_options("/Qprec-div")
else ()
add_compile_options("-prec-div")
endif ()
elseif (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG OR CMAKE_COMPILER_IS_INTELCLANG)
add_compile_options("-fno-reciprocal-math")
endif ()
# Tell CMake to process the sub-directories
add_subdirectory (src/include)
add_subdirectory (src/liboslcomp)
add_subdirectory (src/liboslquery)
add_subdirectory (src/liboslexec)
add_subdirectory (src/liboslnoise)
add_subdirectory (src/oslc)
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/shaders)
add_subdirectory (src/shaders/MaterialX)
if (USE_QT AND Qt5_FOUND)
add_subdirectory (src/osltoy)
endif ()
if (OSL_BUILD_SHADERS)
add_subdirectory (src/shaders)
endif ()
option (INSTALL_DOCS "Install documentation" ON)
if (INSTALL_DOCS)
add_subdirectory (src/doc)
add_subdirectory (src/doc)
endif ()
# 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 ()
#########################################################################
# 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 )
cmake_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")
endif ()
# Add the tests if all is well.
set (ALL_TEST_LIST "")
foreach (_testname ${_ats_UNPARSED_ARGUMENTS})
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 ()
file (MAKE_DIRECTORY "${_testdir}")
# 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 _testname MATCHES "^getattribute-shader" 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})
set (ALL_TEST_LIST "${ALL_TEST_LIST} ${_testname}")
add_test ( NAME ${_testname}.opt
COMMAND env ${_env} ${_runtest} )
endforeach ()
if (VERBOSE)
message (STATUS "Added tests: ${ALL_TEST_LIST}")
endif ()
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
fprintf
function-earlyreturn function-simple function-outputelem
geomath getattribute-camera getattribute-shader
getsymbol-nonheap gettextureinfo
group-outputs groupstring
hash hashnoise 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
operator-overloading
oslc-comma oslc-D
oslc-err-arrayindex oslc-err-closuremul
oslc-err-format oslc-err-intoverflow
oslc-err-noreturn oslc-err-notfunc
oslc-err-outputparamvararray oslc-err-paramdefault
oslc-err-struct-array-init oslc-err-struct-ctr
oslc-err-struct-dup
oslc-warn-commainit
oslc-variadic-macro
oslc-version
oslinfo-arrayparams oslinfo-colorctrfloat
oslinfo-metadata oslinfo-noparams
osl-imageio
paramval-floatpromotion
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
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-blur texture-connected-options
texture-derivs texture-errormsg
texture-firstchannel texture-interp
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
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 ()
# FIXME: still working on MaterialX testsuite
# add_subdirectory(testsuite/MaterialX)
endif (OSL_BUILD_TESTS)
#########################################################################
# 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 "OpenShadingLanguage is...")
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" 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 ${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)
+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.
+74 -29
View File
@@ -1,3 +1,7 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Contributing to OSL
===========================
@@ -6,25 +10,32 @@ why it's an open source project. Please review this document to get a
briefing on our process.
Mail List
---------
Mail List and Slack
-------------------
Contributors should be reading the osl-dev mail list:
* [osl-dev](http://groups.google.com/group/osl-dev)
* [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 bugs and enhancements:
https://github.com/imageworks/OpenShadingLanguage/issues
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](http://groups.google.com/group/osl-dev).
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,
@@ -44,21 +55,51 @@ 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.
* 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, use the
[Individual CLA](http://opensource.imageworks.com/cla/pdf/Imageworks_Contributor_License_Agreement_Individual.pdf).
* [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.
* 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, then you should use the [Corporate
CLA](http://opensource.imageworks.com/cla/pdf/Imageworks_Contributor_License_Agreement_Corporate.pdf).
* [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.
Download the appropriate CLA from the links above, print, sign, and rescan
it (or just add a digital signature directly), and email it to:
opensource@imageworks.com
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.
Our CLA's are based on those used by Apache and many other open source
projects.
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
@@ -70,7 +111,7 @@ The best way to submit changes is via GitHub Pull Request. GitHub has a
All code must be formally reviewed before being merged into the official
repository. The protocol is like this:
1. Get a GitHub account, fork imageworks/OpenShadingLanguage to create your
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.
@@ -132,9 +173,16 @@ it really only applies to the particular file in which it appears.
#### Formatting
NEVER alter somebody else's code to reformat just because you found
something that violates the rules. Let the group/author/leader know, and
resist the temptation to change it yourself.
We use clang-format to enforce formatting rules for the vast majority of the
code base. It is automatically run during CI and is a CI failure if the code
does not conform. There are, however, parts of the code base that are not
clang-formatted, either because we have not yet put them under the
clang-format regime, or because individual modules were deemed to be less
clear with clang-format than with hand formatting.
For non-clang-format regions of code, NEVER alter somebody else's code to
reformat just because you found something that violates the rules. Let the
group/author/leader know, and resist the temptation to change it yourself.
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
@@ -176,13 +224,10 @@ 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); // Yes
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
@@ -192,7 +237,7 @@ 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)
function(int a, int b)
{
int x = a + b;
if (a == 0 || b == 0) {
@@ -203,7 +248,7 @@ Here is a short code fragment that shows some of these rules in action:
}
for (int i = 0; i < 3; ++i) {
x += a * i;
x *= foo (i); // function call
x *= foo(i); // function call
}
return x;
}
@@ -264,7 +309,7 @@ Namespaces: yes, use them!
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 libary already used as a dependency (such as OIIO,
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).
+210
View File
@@ -0,0 +1,210 @@
<!-- 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
* Clint Hanson - DNEG
* Adrien Herubel - Autodesk
* Lee Kerley - Sony Pictures Imageworks
* Mitch Prater - Laika
* Brecht Van Lommel - Blender
* Alex Wells - Intel
### TSC Nomination and Succession
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.
+60 -42
View File
@@ -1,3 +1,6 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Building OSL
============
@@ -9,18 +12,16 @@ Dependencies
OSL requires the following dependencies or tools.
NEW or CHANGED dependencies since the last major release are **bold**.
* Build system: **[CMake](https://cmake.org/) 3.2.2 or newer**
* Build system: [CMake](https://cmake.org/) 3.12 or newer (tested through 3.26)
* A suitable **C++11** compiler to build OSL itself, which may be any of:
- GCC 4.8.5 or newer
- Clang 3.4 or newer
- Microsoft Visual Studio 2015 or newer
- Intel C++ compiler icc version 13 (?) or newer
* A suitable C++14 or C++17 compiler to build OSL itself, which may be any of:
- GCC 6.1 or newer (tested through gcc 12.1)
- Clang 3.4 or newer (tested through clang 16)
- Microsoft Visual Studio 2017 or newer
- Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler
version 2022 or newer.
OSL should compile also properly with C++14 or C++17, but they are not
required.
* **[OpenImageIO](http://openimageio.org) 1.7 or newer**
* **[OpenImageIO](http://openimageio.org) 2.3 or newer** (tested through 2.4)
OSL uses OIIO both for its texture mapping functionality as well as
numerous utility classes. If you are integrating OSL into an existing
@@ -34,26 +35,38 @@ NEW or CHANGED dependencies since the last major release are **bold**.
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.
variable $OpenImageIO_ROOT to point to the compiled distribution, and
then OSL's build scripts will be able to find it. You should also have
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X).
* **[LLVM](http://www.llvm.org) 3.5, 3.9, 4.0, or 5.0**
* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, or 15, including
clang libraries. LLVM 16 doesn't work yet, we need to make changes
on the OSL side to be compatible.
Optionally, if Clang libraries are installed alongside LLVM, OSL will
in most circumstances use Clang's internals for C-style preprocessing of
OSL source. If not found, it will fall back on Boost Wave (but on many
platforms, that requires that Boost has been built in C++11 mode).
* (optional) For GPU rendering on NVIDIA GPUs:
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.
* [Cuda](https://developer.nvidia.com/cuda-downloads) 8.0 or higher.
* [Boost](www.boost.org) 1.55 or newer.
* **[Ilmbase/OpenEXR](http://openexr.com/downloads.html) 2.0 or newer**
* [Flex](https://github.com/westes/flex) and
[GNU Bison](https://www.gnu.org/software/bison/)
* [PugiXML](http://pugixml.org/)
* [Partio](https://www.disneyanimation.com/technology/partio.html) --
optional, but if it is not found at build time, the OSL `pointcloud`
functions will not be operative.
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.81)
* [Ilmbase or Imath](https://github.com/AcademySoftwareFoundation/openexr) 2.3
or newer (recommended: 2.4 or higher; 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/) >= 1.8 (we have tested through 1.13).
* (optional) [Partio](https://www.disneyanimation.com/technology/partio.html)
If it is not found at build time, the OSL `pointcloud` functions will not
be operative.
* (optional) Python: If you are building the Python bindings or running the
testsuite:
* Python >= 2.7 (tested against 2.7, 3.7, 3.8, 3.9, 3.10)
* pybind11 >= 2.4.2 (Tested through 2.10)
* NumPy
* (optional) Qt >= 5.6 (tested through 5.15). If not found at build time,
the `osltoy` application will be disabled.
@@ -62,13 +75,13 @@ Build process
Here are the steps to check out, build, and test the OSL distribution:
0. Install and build dependencies.
1. Install and build dependencies.
1. Check out a copy of the source code from the Git repository:
2. Check out a copy of the source code from the Git repository:
git clone https://github.com/imageworks/OpenShadingLanguage.git osl
git clone https://github.com/AcademySoftwareFoundation/OpenShadingLanguage.git osl
2. Change to the distribution directory and 'make'
3. Change to the distribution directory and 'make'
cd osl
make
@@ -79,22 +92,27 @@ 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.
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".
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.
Note: The default is to make an optimized "release" build. If
instead type 'make debug' at the top level, you will end up with
a debug build (no optimization, full symbols) in "dist/ARCH.debug".
4. After compilation, you'll end up with a full OSL distribution in
dist/
4. Add the "dist/ARCH/bin" to your $PATH, and "dist/ARCH/lib" to your
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on OS X), or copy the contents
5. Add the "dist/bin" to your $PATH, and "dist/lib" to your
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on MacOS), or copy the contents
of those files to appropriate directories. Public include files
(those needed when building applications that incorporate OSL)
can be found in "dist/ARCH/include", and documentation can be found
in "dist/ARCH/doc".
can be found in "dist/include", and documentation can be found
in "dist/share/doc".
5. After building (and setting your library path), you can run the
6. After building (and setting your library path), you can run the
test suite with:
make test
Troubleshooting
----------------
- [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-2017 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.
+159 -142
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.
#
@@ -16,49 +22,26 @@ working_dir := ${shell pwd}
# Figure out which architecture we're on
include ${working_dir}/src/make/detectplatform.mk
# Presence of make variables DEBUG and PROFILE cause us to make special
# builds, which we put in their own areas.
ifdef DEBUG
variant +=.debug
endif
ifdef PROFILE
variant +=.profile
endif
MY_MAKE_FLAGS ?=
MY_NINJA_FLAGS ?=
MY_CMAKE_FLAGS ?=
#-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
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.com},)
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}
OSLHOME ?= ${working_dir}/${dist_dir}
build_dir ?= build
dist_dir ?= dist
ifndef INSTALL_PREFIX
INSTALL_PREFIX := ${working_dir}/${dist_dir}
INSTALL_PREFIX_BRIEF := ${dist_dir}
else
INSTALL_PREFIX_BRIEF := ${INSTALL_PREFIX}
endif
INSTALL_PREFIX ?= ${working_dir}/${dist_dir}
VERBOSE ?= ${SHOWCOMMANDS}
ifneq (${VERBOSE},)
@@ -73,8 +56,13 @@ $(info dist_dir = ${dist_dir})
$(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},)
@@ -93,68 +81,44 @@ ifneq (${USE_LLVM_BITCODE},)
MY_CMAKE_FLAGS += -DUSE_LLVM_BITCODE:BOOL=${USE_LLVM_BITCODE}
endif
ifneq (${USE_BOOST_WAVE},)
MY_CMAKE_FLAGS += -DUSE_BOOST_WAVE:BOOL=${USE_BOOST_WAVE}
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 (${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
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},)
@@ -165,13 +129,21 @@ MY_CMAKE_FLAGS += -DCMAKE_CXX_COMPILER:STRING="${MYCXX}"
endif
ifneq (${USE_CPP},)
MY_CMAKE_FLAGS += -DUSE_CPP=${USE_CPP}
MY_CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=${USE_CPP}
endif
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
@@ -180,6 +152,14 @@ ifneq (${USE_SIMD},)
MY_CMAKE_FLAGS += -DUSE_SIMD:STRING="${USE_SIMD}"
endif
ifneq (${USE_BATCHED},)
MY_CMAKE_FLAGS += -DUSE_BATCHED:STRING="${USE_BATCHED}"
endif
ifneq (${VEC_REPORT},)
MY_CMAKE_FLAGS += -DVEC_REPORT:BOOL="${VEC_REPORT}"
endif
ifneq (${TEST},)
TEST_FLAGS += -R ${TEST}
endif
@@ -193,12 +173,13 @@ 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}
MY_CMAKE_FLAGS += -DSANITIZE=${SANITIZE}
endif
ifneq (${CLANG_TIDY},)
@@ -216,6 +197,38 @@ ifneq (${CLANG_TIDY_FIX},)
# 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})
@@ -227,7 +240,7 @@ endif
#########################################################################
# Top-level documented targets
all: dist
all: install
# 'make debug' is implemented via recursive make setting DEBUG
debug:
@@ -237,85 +250,76 @@ 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=${INSTALL_PREFIX} \
${MY_CMAKE_FLAGS} -DBOOST_ROOT=${BOOST_HOME} \
../.. ; \
${CMAKE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${MY_CMAKE_FLAGS} ${working_dir} ; \
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
# DEPRECATED: '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} ; \
OSLHOME=${OSLHOME} \
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}/src/python:${PYTHONPATH} \
ctest -E broken ${TEST_FLAGS} ;\
PYTHONPATH=${working_dir}/${build_dir}/lib/python/site-packages:${PYTHONPATH} \
ctest -E broken ${TEST_FLAGS} \
)
@ ( if [ "${CODECOV}" == "1" ] ; then \
@ ( 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 clean' clears out the build directory for this platform
@@ -326,10 +330,10 @@ clean:
realclean: clean
${CMAKE} -E remove_directory ${dist_dir}
# 'make nuke' blows away the build and dist areas for all platforms
# DEPRECATED: use 'make realclean'
nuke:
${CMAKE} -E remove_directory ${top_build_dir}
${CMAKE} -E remove_directory ${top_dist_dir}
${CMAKE} -E remove_directory ${build_dir}
${CMAKE} -E remove_directory ${dist_dir}
#########################################################################
@@ -338,13 +342,17 @@ nuke:
# 'make help' prints important make targets
help:
@echo "Targets:"
@echo " make Build optimized binaries and libraries"
@echo " make debug Build unoptimized with symbols"
@echo " make profile Build for profiling"
@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:"
@@ -352,40 +360,49 @@ 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_CPP=14 Compile in C++14 mode (default is C++11)"
@echo " USE_LIBCPLUSPLUS=1 Use clang libc++"
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)"
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"
@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,... Enablie sanitizers (address, leak, thread)"
@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=4.0 Specify which LLVM version to use"
@echo " LLVM_VERSION=12.0 Specify which LLVM version to use"
@echo " LLVM_DIRECTORY=xx Specify where LLVM lives"
@echo " LLVM_NAMESPACE=xx Specify custom LLVM namespace"
@echo " LLVM_STATIC=1 Use static LLVM libraries"
@echo " USE_LLVM_BITCODE=0 Don't generate embedded LLVM bitcode"
@echo " USE_BOOST_WAVE=1 Force boost wave rather than clang preprocessor"
@echo " OSL build-time options:"
@echo " INSTALL_PREFIX=path Set installation prefix (default: ./${INSTALL_PREFIX_BRIEF})"
@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 Don't build unit tests, testshade, testrender"
@echo " USE_SIMD=arch Build with SIMD support (choices: 0, sse2, sse3,"
@echo " ssse3, sse4.1, sse4.2, f16c, avx, avx2"
@echo " comma-separated ok)"
@echo " OSL_BUILD_SHADERS=0 Don't build any 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 " USE_BATCHED=targets Build batched SIMD execution of shaders for (comma-separated choices:"
@echo " 0, b8_AVX, b8_AVX2, b8_AVX2_noFMA,"
@echo " b8_AVX512, b8_AVX512_noFMA,"
@echo " b16_AVX512, b16_AVX512_noFMA)"
@echo " VEC_REPORT=0 Generate compiler vectorization reports"
@echo " make test, extra options:"
@echo " TEST=regex Run only tests matching the regex"
@echo ""
+212 -57
View File
@@ -1,24 +1,15 @@
<div align="center">
<img src="https://github.com/imageworks/OpenShadingLanguage/blob/master/src/doc/Figures/osl-short.png" width=256 height=128>
<img src="https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/blob/main/src/doc/Figures/osl-short.png" width=256 height=128>
<H1>Open Shading Language</H1>
</div>
[![Open Shading Language Reel 2020](http://img.youtube.com/vi/nmwMz1YnGPA/0.jpg)](https://www.youtube.com/watch?v=nmwMz1YnGPA "Open Shading Language Reel 2020")
Open Shading Language
=====================
[![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)
Build status:
[![Build Status](https://travis-ci.org/imageworks/OpenShadingLanguage.svg?branch=master)](https://travis-ci.org/imageworks/OpenShadingLanguage)
**Table of contents**
* [Introduction](#introduction)
* [How OSL is different](#how-osl-is-different)
* [What OSL consists of](#what-osl-consists-of)
* [Where OSL has been used](#where-osl-has-been-used)
* [Building OSL](#building-osl)
* [Contacts, Links, and References](#contacts-links-and-references)
* [Credits](#credits)
Introduction
@@ -45,9 +36,9 @@ 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](https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE),
and the documentation under the [Creative Commons Attribution 3.0 Unported
License](http://creativecommons.org/licenses/by/3.0/). In short, you are
["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
@@ -231,10 +222,10 @@ 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/cycles/nodes/osl.html)
* [Blender/Cycles](https://docs.blender.org/manual/en/dev/render/shader_nodes/osl.html)
* [Chaos Group: V-Ray](https://www.chaosgroup.com/)
* [Pixar: PhotoRealistic RenderMan RIS](https://renderman.pixar.com)
* [Isotropix: Clarisse](http://www.isotropix.com/clarisse)
* Isotropix: [Clarisse iFX](https://www.isotropix.com/products/clarisse/ifx) / [Clarisse BUiLDER](https://www.isotropix.com/products/clarisse/builder) / [Angie](https://www.isotropix.com/products/angie)
* [Autodesk Beast](http://www.autodesk.com/products/beast/overview)
* [Appleseed](http://appleseedhq.net)
* [Animal Logic: Glimpse renderer](https://www.fxguide.com/featured/a-glimpse-at-animal-logic/)
@@ -242,6 +233,8 @@ adding OSL support):
* [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)
* [Maxon: Redshift](https://www.maxon.net/en/redshift)
Films using OSL (grouped by year of release date):
* **(2012)**
@@ -255,8 +248,10 @@ Films using OSL (grouped by year of release date):
The Interview
* **(2015)**
American Sniper,
Insurgent, Avengers Age of Ultron,
Ant Man, Pixels,
Insurgent,
Avengers Age of Ultron,
Ant Man,
Pixels,
Mission Impossible: Rogue Nation,
Hotel Transylvania 2,
Bridge of Spies,
@@ -265,18 +260,23 @@ Films using OSL (grouped by year of release date):
Concussion
* **(2016)**
Allegiant,
Batman vs Superman: Dawn of Justice, The Huntsman,
Angry Birds Movie, Alice Through the Looking Glass,
Batman vs Superman: Dawn of Justice,
The Huntsman,
Angry Birds Movie,
Alice Through the Looking Glass,
Captain America: Civil War,
Finding Dory, Piper,
Finding Dory,
Piper,
Independence Day: Resurgence,
Ghostbusters,
Star Trek Beyond,
Suicide Squad,
Kingsglaive: Final Fantasy XV,
Storks,
Miss Peregrine's Home for Peculiar Children, Assassin's Creed
* **(2017) / upcoming**
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,
@@ -296,60 +296,215 @@ Films using OSL (grouped by year of release date):
The Emoji Movie,
Detroit,
Kingsman: The Golden Circle,
Lega Ninjago Movie,
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,
Sing 2
* **(2022)**
Hotel Transylvania 4: Transformania,
Death on the Nile,
Uncharted,
Turning Red,
The Adam Project,
Doctor Strange in the Multiverse of Madness,
Love, Death, and Robots: In Vaulted Halls Entombed,
Jurassic World: Dominion,
Lightyear,
Thor: Love and Thunder,
The Sea Beast,
DC League of Super Pets,
Minions: Rise of Gru,
Bullet Train,
Slumberland,
Glass Onion
* **(2023 / upcoming)**
Ant-Man and the Wasp: Quantumania,
...
Building OSL
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 you think you've found a potential vulnerability in OSL, please
confidentially report it by emailing the project administrators at
[security@openshadinglanguage.org](security@openshadinglanguage.org).
If any other issue requires confidentiality that precludes a public question
or issue, you may contact the project administrator privately at
[lg@larrygritz.com](lg@larrygritz.com).
Contributing
------------
Please see the [INSTALL.md](INSTALL.md) 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
-------------------------------
[OSL GitHub page](https://github.com/imageworks/OpenShadingLanguage)
[OSL GitHub page](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage)
[Read or subscribe to the OSL development mail list](http://groups.google.com/group/osl-dev)
[Read or subscribe to the OSL development mail list](https://lists.aswf.io/g/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 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.
The current project leadership is documented in the
[Governance](GOVERNANCE.md) file.
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.)
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, Damien Courtois, Dieter De
Baets, Thomas Dinges, Daniel Dresser, Mads Drøschler, Peter Ellerington, Luke
Emrose, Louis Feng, Mark Final, Henri Fousse, Stephen Friedman, Syoyo Fujita,
Tim Grant, Larry Gritz, Nicolas Guiard, Euan Haahr, Derek Haase, Sven-Hendrik
Haase, John Haddon, Niklas Harrysson, Daniel Heckenberg, Chris Hellmuth,
Adrien Herubel, Dan Horák, Thiago Ize, Matt Johnson, Ronan Keryell, Chris
Kulla, Elvic Liang, Max Liani, Adam Martinez, John Mertic, Bastien Montagne,
Steena Monteiro, Patrick Mours, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino
Park, Alexei Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick
Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip
Shukla, Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari,
Brecht Van Lommel, 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
@@ -368,9 +523,9 @@ developers and users at other VFX and animation studios.
The OSL implementation depends upon several other open source packages,
all with compatible licenses:
* [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)
* [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/)
+27
View File
@@ -0,0 +1,27 @@
# Security Policy
## Supported Versions
This gives guidance about which branches are supported with patches to
security vulnerabilities.
| Version / branch | Supported |
| --------- | ---------------------------------------------------- |
| main | :white_check_mark: :construction: ALL fixes immediately, but this is a branch under development with a frequently unstable ABI and occasionally unstable API. |
| 1.12.x | :white_check_mark: All fixes that can be backported without breaking ABI compatibility. New tagged releases monthly. |
| 1.11.x | :warning: Only the most critical fixes, only if they can be easily backported. |
| <= 1.10.x | :x: No longer receiving patches of any kind. |
## Reporting a Vulnerability
If you think you've found a potential vulnerability in OSL, please report it
by emailing the project administrators at
[security@openshadinglanguage.org](security@openshadinglanguage.org). Only the
project administrators have access to these messages. Include detailed steps to
reproduce the issue, and any other information that could aid an
investigation. Our policy is to respond to vulnerability reports within 14
days.
Our policy is to address critical security vulnerabilities rapidly and post
patches as quickly as possible.
+293
View File
@@ -0,0 +1,293 @@
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.
-------------------------------------------------------------------------
Modified Apache 2.0 License
Universal Scene Description
Copyright Pixar.
Portions of the build_osl.py were derived from scripts distributed with USD.
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. 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.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor 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
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You 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 the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You 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 such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor
and its affiliates, except as required to comply with Section 4(c) of
the License and to reproduce the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its 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. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
-------------------------------------------------------------------------
If we have left anything out, it is unintentional. Please let us know.
+27
View File
@@ -0,0 +1,27 @@
# Documentation
The OSL Documentation Project is a work in progress.
The plan is to adopt the OCIO Documentation Project's methodology for maintaining and building documentation of various kinds as it becomes the blueprint for the ASWF.
There is much work to be done here.
Of particular interest are these topics. Please consider adding any information you might have about any of these to the repo:
* Any material at all for people learning to write OSL shaders (beyond the formal language spec, which is not intended to be a tutorial or cookbook for writing shaders).
* Example .osl code and/or .h files that are:
1. Generally useful, but do not warrant inclusion into the OSL source itself.
2. Tutorial in nature.
* Robust installation or build instructions for Windows and macOS.
* Guide for how to integrate OSL into an application such as a renderer.
If you have some relevant content and you'd like to discuss its inclusion, please use the OSL Documentation discussion:
[OSL Documentation](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/discussions/1324)
or alternatively, you may post to:
https://lists.aswf.io/g/osl-dev/topics<br>
osl-dev@lists.aswf.io
You may also simply submit a PR.
+341
View File
@@ -0,0 +1,341 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
# Release Procedures for Open Shading Language
## Version nomenclature and release cadence
### The meaning of the version parts
Our release numbers are of the form `MAJOR.MINOR.PATCH.TWEAK`, and we follow
an almost-semantic-versioning scheme.
MAJOR changes are those that break backward-compatibility of the public APIs,
requiring existing application code to change their source code where it calls
OSL API functions in order to compile and work correctly.
MINOR changes guarantee API backward-compatibility with prior releases that
have the same major number, but can introduce ABI or link incompatibilities.
Applications using OSL need to be recompiled to move to a new minor release,
but should not need to change their source code. Minor releases are allowed
to drop support for sufficiently old compilers and dependencies.
PATCH changes guarantee both API and ABI/link backward-compatibility with
prior releases that have the same minor number. Features and new public API
calls may be added (thus deviating from strict semantic versioning), but only
if they preserve ABI/link compatibility. This means that standalone functions
or static methods may be added, but existing functions will not change their
parameters, and no new virtual methods or struct data layouts change for patch
releases (for classes in public header files). Application code can be
re-linked to a new patch release without needing to be recompiled. We also
guarantee that any compilers or dependencies supported for the first release
of a minor series will continue to be supported for all patches to that minor
series.
TWEAK changes are restricted to critical bug fixes or build breaks that do
not alter public APIs in any way.
### Cadence of releases
Major (arbitrarily incompatible) releases happen rarely, usually with multiple
years between them.
Minor (API backward-compatible) releases are scheduled annually, targeted at
late summer (SIGGRAPH time) to be in beta, and early autumn for a full
release.
Patch (API and ABI backward-compatible) releases are scheduled monthly,
usually aiming for the first day of each month.
Tweak (fully forward and backward compatible) releases are not regularly
scheduled, and only happen sporadically, when a critical fix is needed in
between scheduled patch releases.
### Things are different in "main"
The "main" branch is where ongoing development occurs without any
compatibility guarantees. We don't always know if the next year's release from
main will turn out to be major (API breaking) or minor (only ABI breaking).
Some studios or products need the most up-to-date enhancements, and thus tend
to build OSL from the "main" branch rather than using tagged releases. For
these users, we try to set version numbers and occasionally tag in main, to
send a signal about which points in main seem safe to rely on various
compatibility levels. However, the rules are slightly different than we use
for releases.
In the "main" branch:
- TWEAK changes within "main" only guarantee ABI back-compatibility, but may
have additions or non-bug-fix behavior changes (akin to patch releases
within a release branch).
- PATCH changes within "main" are allowed to break ABI or API (changes that
would require minor or major releases, if they were not in "main").
- Beware of unmarked breaks in compatibility of commits in main that are
in between developer preview tags.
---
## Branch and tag names
**Branches** are places where commits containing new development may be added
(and thus the branch markers will move over time). Branch names obey the
following conventions:
- `main` is the area for arbitrary changes intended for the next year's major
or minor release.
- `dev-1.2` are the areas for staging additions to the next month's patch
release for the designated minor version series.
- `release` is a special branch marker that is always set to the latest tag of
the currently supported, stable release family. People can count on
"release" always being the latest stable release, whatever that may be at
the time.
**Tags** indicate releases or developer previews, and once a commit is
tagged, it is permanent and will never be moved. Tag names obey the following
conventions:
- `v1.2.3.4` is a specific public stable release, corresponding to official
major, minor, public, or tweak releases.
- `v1.2.3.4-alpha`, `v1.2.3.4-beta`, or `v1.2.3.4-RC1` are pre-releases for an
upcoming public stable release, at the alpha, beta, or release candidate
stages, respectively.
- `v1.2.3.4-dev` is a "developer preview" within "main." It is not an official
supported release, and while the numbering may indicate compatibility versus
other recent developer previews, they should not be assumed to be compatible
with any prior official stable releases.
*Very* occasionally, other branch or tag names (with custom suffixes or
different naming schemes) may be used for special purposes by particular
developers or users, but should not be considered reliable or permanent, and
in general should be ignored by anyone who didn't make the tag or branch.
---
## Release Procedures
### Soft freeze for monthly tweak releases:
We freely backport *safe*, non-ABI-breaking changes by cherry-picking them
from main to the supported branch continually throughout most of the month.
In the seven days before the new month, we do a "soft freeze" where only
important bug fixes are backported. Hold on to any other patches you wish to
backport until after the monthly patch release (i.e., save them for the next
month's release so you never have a release that contains changes that are
only a few days old, and therefore not as well tested). You may, of course,
continue to backport fixes to documentation or other non-code parts of the
project during this soft freeze.
### Branching for annual major/minor releases
By mid-June (about 1-2 months before the beta of a new annual big release),
you should branch and mark it as an alpha.
At the tip of "main," create a new branch named `dev-MAJOR.MINOR` that will be
the staging area for the next release.
Customarily, at that point we add a commit to main (but not to the new
dev-MAJ.MIN branch) that bumps main's version to the next minor level, to
avoid any confusion between builds from main versus what will be the next
release branch. This starts the divergence between main and the release
branch, and henceforth, any big or compatibility-breaking changes will only be
committed to main and not backported to the release branch. (Though we are
loose about this rule during the alpha period and allow continued breaking
changes in the alpha, but by the time we call it beta, we allow no more
breaking changes.)
### Prior to a release
1. Update CI dependencies: Ensure that the "latest" CI test specifies the
current releases of the dependencies and compilers (check their home
pages), and that the [INSTALL.md](../INSTALL.md) file correctly documents
the version ranges that we expect to work and that we actively test.
2. Release notes: [CHANGES.md](../CHANGES.md) should be updated to reflect
all the new features and fixes. Looking at the notes from older releases
should provide a good example of what we're aiming for.
- Patch and tweak releases can be brief one-line descriptions (often the
first line of the commit messages involved), presented in a single
section in either chronological or any other order that seems right.
- Minor or major releases have a much more extensive, prose-based
description of all changes since the last minor release, broken into
sections (dependency changes, major new features, enhancements and fixes,
internals and developer goodies, testing/CI/ports, etc.) and ordered for
readability and relevance.
3. Ensure docs are up to date:
- Actually read the [README.md](../README.md), [INSTALL.md](../INSTALL.md),
and other repository docs and make sure all the information is up to
date. Check the "contributor credits" in the README against the recent
repo history to be sure new contributors are listed. Also check the
list of films and make sure it includes any recent productions that are
known to have used OSL.
- Skim the primary user documentation to look for any obvious errors,
especially the parts that describe new features. In the case of PDF docs
(such as osl-languagespec.pdf), make sure that a new PDF book is built if
the documentation source has been changed since the last release.
- If we are using any online docs (like readthedocs), make sure it is
building and looks correct on the web site.
4. Make sure the the top-level CMakeLists.txt file is updated:
- The version on the `project()` call should be correct.
- The `PROJECT_VERSION_RELEASE_TYPE` variable should be set to "alpha" or
"beta" if appropriate, "RC" for release candidate, or empty string `""`
for most supported releases, and "dev" only for the main branch or
developer previews.
- The `${PROJECT_NAME}_SUPPORTED_RELEASE` variable should be `ON` for any
release branch, `OFF` for main.
5. Make sure everything passes the usual CI workflow. Also check the daily or
weekly "analysis" workflows to make sure there aren't any important
warnings that should be fixed.
### Staging alpha / beta / release candidate (annual minor/major releases only)
For monthly patch releases, we don't have any formal alpha/beta/RC stages.
For the annual minor or major releases we have a staged release:
- `alpha` is everything after we have branched, in which we think all the big
new features have been added, and while we will make continued changes and
fixes, we are aiming for increased stability and to minimize additional
breaking changes prior to the release.
- `beta` should be about one month prior to the final release date. We create
a tag `v1.2.3.4-beta` and announce the beta (see below "Making the
release"). Once we tag a beta, we try very hard not to allow any further
changes that change the API or are not ABI-compatible (i.e., safe fixes
only).
- `RC` or release candidates around one week prior to the final release date.
This is a trial run, hopefully identical to the final release (except for
removing the RC label and making a new tag). The only changes allowed after
RC are fixes to the most critical bugs or build breaks that would be bad for
users to encounter. If critical problems are found with RC1, they should be
fixed and immediately re-tagged as RC2, etc. All other fixes should be
postponed until the next month's patch release.
### Making the release
A final release is made on the scheduled date, provided the latest RC has
survived for at least a few days of testing without finding any critical
problems. Don't make the release final until you are sure there are no
truly critical bugs or build breaks that users will encounter.
The following are the steps for making the release:
1. Edit the top-level CMakeLists.txt to remove any RC designation
(i.e., `PROJECT_VERSION_RELEASE_TYPE` should be set to `""`).
2. Edit CHANGES.md to reflect the correct date of the release and ensure it
includes any last-minute changes that were made during beta or release
candidate stages.
3. Push it to **your** GitHub, make sure it passes CI.
4. Tag the release: `git tag v1.2.3.4` (no more beta, RC, or dev suffix).
5. If this will now be the recommended stable release, move the `release`
branch marker to the same position.
6. Push it to GitHub: `git push aswf release --tags`
(This example assumes "aswf" is the name of the remote for the GitHub
`AcademySoftwareFoundation/OpenShadingLanguage` repo.)
7. Draft a release on GitHub: On
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/releases
select "Draft a new release." Choose the new tag you just pushed. Make the
release title "Open Shading Language v1.2.3.4" (and beta, etc., designation
if applicable). In the description, paste the release notes for this
release (from Changes.md). If this is a beta or release candidate, check
"this is a pre-release" box at the bottom.
8. Announce the release on the [osl-dev mail list](https://lists.aswf.io/g/osl-dev)
with the subject "Release: OSL v1.2.3.4" and using one of these templates
for the body of the email.
For a monthly patch release:
> We have tagged v1.2.3.4 as the latest production release and moved the
> "release" branch marker to that point. This is guaranteed to be API,
> ABI, and link back-compatible with prior 1.2 releases. Release notes
> are below.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
For an annual major/minor release:
> OSL version 1.2 has been released! Officially tagged as "v1.2.3.4", we
> have also moved the "release" branch tag to this position. Henceforth,
> 1.2 is the supported production release family. The API is now frozen --
> we promise that subsequent 1.2.x releases (which should happen monthly)
> will not break back-compatibility of API, ABI, or linkage, compared to
> this release. Please note that this release is *not* ABI or link
> compatible with 1.1 or older releases.
>
> Release notes for 1.2 outlining all the changes since last year's
> release are below.
>
> Please note that a few of the build and runtime dependencies have
> changed their minimum supported versions. (List here any important
> changes to dependencies, compilers, or C++ standard that users should be
> aware of.)
>
> (List here anything else that people should know about this release
> family that may be surprising if they haven't followed the last year of
> development closely, or that they must know even if they are too lazy to
> read the release notes. If this is a major release that is not
> backward-compatible with prior versions, warn about that here.)
>
> Enjoy, and please report any problems. We will continue to make patch
> releases to the 1.2 family roughly monthly, which will contain bug fixes
> and non-breaking enhancements.
>
> The older 1.1 series of releases is now considered obsolete. We will
> continue for now to make 1.1 patch releases, but over time, these will
> become less frequent and be reserved for only the most critical bug
> fixes.
>
> The "main" branch is now progressing toward an eventual 1.3 release next
> summer. As usual, you are welcome to use main for real work, but we do
> not make any compatibility guarantees and don't guarantee continuing API
> compatibility in main.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
For a beta leading up to the annual major/minor release:
> OSL version 1.2 is now in beta, tagged as "v1.2.3.4-beta". We
> will try very hard not to make any further API or ABI changes between
> now and the final release (unless it is absolutely necessary to fix
> an important problem identified during beta testing). The final 1.2
> release is scheduled for [DATE GOES HERE], so please try building and
> testing the beta so we are sure to find any problems.
>
> Release notes for 1.2 outlining all the changes since last year's
> release are below.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
### After the release
Odds and ends to do after the tag is pushed and the announcements are sent:
- Re-read RELEASING.md and ensure that the instructions match what you
have done. Update as necessary.
- For annual beta releases, post a short message to the "Open Shading
Language" channel of the ASWF slack. It can be a one-line announcement and
then just a link to the GitHub release page for this version.
+3
View File
@@ -0,0 +1,3 @@
# Application Integration
Contains content related to integrating OSL into a renderer, or any application for that matter, using the C API.
+21
View File
@@ -0,0 +1,21 @@
# Build and Install Instructions
---
#### Copyright Contributors to the Open Shading Language project.
#### SPDX-License-Identifier: CC-BY-4.0
---
Contains information about building and installing OSL.
## Windows
Method #1:
https://github.com/debaetsd/OSL_build
Method #2:
Go through `doc/build_install/windows/Readme.md` and using batch files to install OSL cleanly!
## macOS
+314
View File
@@ -0,0 +1,314 @@
## **Building, Using and Debugging OSL in Windows**
---
#### Copyright Contributors to the Open Shading Language project.
#### SPDX-License-Identifier: CC-BY-4.0
---
### **Contents**
1. Introduction
- Experimental
- My Setup
- Inspiration
2. Preparing Environment
- Cleaning Up the PATH
- Set-Up needed Environment Variables
- Set Flags based on your needs
3. Building (Release, Debug)
- Running the code based on your config
- Be Patient
- Errors
4. Running
5. Development in Windows
---
### **1. Introduction**
This document is prepared for those who have problem in building OSL in Windows OS, this is completely custom setup. And it is developing to make it compatible with all situations.
(`Disclaimer:` This Process is completely Experimental and it worked on my system, maybe you get error with changing some configs, during this process).
At a first glance it seems to be complicated, but it is very easy to do, bare with me.
So it would be great to share our experiences to reach to best way of building in Windows (and of course other Operating Systems) to save our time and energy to focus on OSL development and OSL Shader writing.
### **1.1 Experimental**
After a lot of efforts on manual building OSL on Windows, Finally I found a clean way to do that, I explained every steps I did, I hope it works for you too. This method is stricktly related to Environment Variables you create and Flags you set to the command and need patient and hard disk.
I've built OSL with minimal needed packages, for extra packages, they should be set as flag (**script is under development**)
### **1.2 My Setup**
This is my setup I have on my PC for building OSL, so you need to install some software before start.
My System and Setup Configuration:
**OS:** Windows 10 Home
**Compiler:** Microsoft Visual Studio 2019
**Git:** 2.28.0
**Python:** 3.7 tip: disable python App Installer in Manage `App Execution Aliases (Windows 10)`
**Cmake:** 3.18.4
**Qt:** 5.15.0
**NASM:** 2.15.05 for JPEG
**OpenShadingLanguage:** cloned from latest master branch
**Boost:** 1.70
**LLVM:** 11.0.0 C++ is set on C++14
**CLANG:** 11.0.0 C++ is set on C++14
**WinFlexBison:** 2.5.22
**Zlib:** 1.2.11
**JPEG:** 2.0.5
**TIFF:** 4.1.0
**PNG:** 1.6.35
**PyBind11:** 2.6.0
**LibRaw:** 0.20.2
**OpenImageIO:** 2.1.20
**OpenColorIO:** 1.1.0
**OpenEXR/**IlmBase: 2.5.3
**GLUT:** 3.2.1 freeglut on windows (this is needed for partio) (unfortunately Partio didn't build, it has a problem) (I’ve created a PR for it in Disney github repo)
**Disney Partio:** latest from master (zip file) (Skip this for now) (I didn't build OSL with Partio)
**PugiXML:** 1.10
---
### **1.3 Inspiration**
After lots of manual building dependencies one by one and fix errors and things I got inspired by `PIXAR USD INSTALLATION METHOD` and borrowed its structure to build OSL.
so I studied its python build script and found we can use same logic for installing OSL, fortunately after changing and adding OSL needed packages and some custom setup it worked fine
It still needs some other works to make it complete for all dependencies (optional).
We will keep Pixar name on it as inspiration code (or we can keep their copyright)
You can Run the installer from: `yourpath/OpenShadingLanguage/doc/build_install/windows/build_osl.bat`
---
### **21. Preparing Environment**
There are bunch od prerequisites for building OSL that I explained in following sections.
### **2.1 Cleaning Up the PATH**
Be sure you don't have any custom item added to PATH in your global Environment Variables of Windows
You can do it:
`Start Menu > Edit the system environmment variables > Environment Variables > User Variables/System Variables`
so you should not have any path that refer to previous osl installation folders
Recommendation: remove added path for cmake, git, python, Qt, llvm
it should be clean now.
### **2.2 Set-Up needed Environment Variables**
For running batch scripts without any problem I recommend to create some base environment variables.
**Needed Environment Variables: (Key/Value based on my installation folder)**
| Env Var | Path Example |
| --------------- | ---------------------------------------------------------------------------------- |
| BASE_LOCATION | D:\madoodia\sdks |
| PYTHON_LOCATION | D:\madoodia\sdks |
| QT_LOCATION | C:\Qt\5.15.0\msvc2019_64 |
| NASM_LOCATION | C:\NASM |
| GIT_LOCATION | "C:\Program Files\Git" |
| CMAKE_LOCATION | "C:\Program Files\CMake" |
| VCVARS_LOCATION | "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build" |
|
Open `doc/build_install/windows/osl_env_vars_setup.bat` in your editor and edit paths' values based on your installation folders.
### **2.3 Set Flags based on your needs**
The main build launcher is here `doc/build_install/windows/build_osl.bat`
For now we can not assign pre-installed llvm or boost so we have to build all together at once and put all of them in one directory.
I am working on it to see how we can use external llvm and boost installation without error.
**Table of flags we can assign to the command**
| Flag | State | Can Use |
| ------------- | --------------- | ------- |
| --osl | Implemented | Yes |
| --python | Implemented | Yes |
| --zlib | Implemented | Yes |
| --boost | Implemented | Yes |
| --llvm | Implemented | Yes |
| --clang | Implemented | Yes |
| --pugixml | Implemented | Yes |
| --openexr | Implemented | Yes |
| --tiff | Implemented | Yes |
| --jpeg | Implemented | Yes |
| --png | Implemented | Yes |
| --flex | Implemented | Yes |
| --bison | Implemented | Yes |
| --opencolorio | Implemented | Yes |
| --openimageio | Implemented | Yes |
| --libraw | Implemented | Yes |
| --pybind11 | Implemented | Yes |
| --Ptex | Implemented | No |
| --openvdb | Implemented | No |
| --partio | Implemented | No |
| --ffmpeg | Not-Implemented | No |
| --field3d | Not-Implemented | No |
| --opencv | Not-Implemented | No |
| --gif | Not-Implemented | No |
| --heif | Not-Implemented | No |
| --squish | Not-Implemented | No |
| --dcmtk | Not-Implemented | No |
| --webp | Not-Implemented | No |
---
### **3. Building (Release, Debug)**
We Prepared some batch files to do it for you automatically.
Based on Environment Variables you set in previous sections you can just call them and wait for it to be built and installed.
**My Method:**
- Open Powershell
- Go to: yourPath/OpenShadingLanguage/doc/build_install/windows
- Run build_osl.bat release
### **3.1 Running the code based on your config**
Based on the config (`Release` or `Debug`) that you send for installer it will create directory in `BASE_LOCATION` for you
`BASE_LOCATION/osl_release` for Release mode
`BASE_LOCATION/osl_debug` for Debug mode
**IMPORTANT:** `Good to know you can not have Release and Debug files in one directory at the same time, it makes conflict and give you weired errors. So keep them separate.`
### **3.2 Be Patient**
You should be patient because the whole process (based on your PC config) takes time between 30 minutes to 1 hour
And it takes:
**Release:** `~8Gb` of your hard disk (after installation) (Download size is `~350Mb`)
**Debug:** `~90Gb` of your hard disk (after installation) (Download size is `~400Mb`)
so please set a location to `BASE_LOCATION` that have enough space.
### **3.4 Errors**
If you got any error in any step of building process, you can remove the related package's build directory from `BASE_LOCATION/build` and run the installer again.
If you got any error please report to the forum of OSL.
---
### **4. Running**
We Prepared some batch files to do it for you automatically. Based on Environment Variables you set in previous sections you can just call it.
**Recommendation:** use `Powershell`
**TIP:** If you add your osl installation folders (both release and debug) in global Windows Environment Variable, you will get error.
So you can add release path or debug path in your global environment variables. Or create and use batch scripts.
For adding path you should add these two paths to your global env variables:
• PATH : `<osl install dir>\bin`;
• PATH : `<osl install dir>\lib`;
For example, you can open osltoy in releae mode with running `osltoy_release_launcher.bat`
if you have question, feel free to ask.
---
### **5. Development in Windows**
After editing your code, when you want to see your changes you should build osl again. But this time, it is so faster than before, (if you keep build folders) So just need to rebuild it in release mode.
**Release mode**:
- open powershell
- cd OpenShadingLanguage repo
- cd build_script
- run build_osl.bat release
- run osl_release_sln.bat
- example: set osltoy as default project
- run it in release x64 mode
**Debug mode**:
- open powershell
- cd OpenShadingLanguage repo
- cd build_script
- run build_osl.bat debug
- run osl_debug_sln.bat
- example: set osltoy as default project
- run it in debug x64 mode
If you open Visual Studio solution (sln) from release or debug, you can build it from inside it after your code editing
I recommend using: (in **powershell**)
- **osl_release_sln.bat** or **osl_debug_sln.bat**
now you can use Visual Studio for debugging.
---
**TIP about OSLToy:**
If you load a shader in `osltoy` and when hit Recompile, it is crashed and closed, probabely your output color attribute name is not `Cout`
It is mandatory to have at least one `Cout` output Variable in any shader, Otherwise osltoy will crash.
That's it
TIP: this process is getting better, I will update the document soon
**Conclusion:**
For easy installation you just need to setup your Environment Variables in `yourPath/OpenShadingLanguage/doc/build_install/windows/osl_env_vars_setup.bat` based on your paths
It is a custom setup, for example all dependencies are built before osl, because I had lots of issues on using external installation (like llvm)
and I tried this method on llvm 7, 8 and 9, all with error, so my current build setup is on llvm 11 and C++14, it can be changed in code. (I am trying to make it easy to use for changing configs with arguments)
Please take a look at docs and let me know my mistakes.
This method worked fine for me for release, debug and debugging in visual studio.
I am trying to build OSL on `Linux` with same method. If it worked fine I will Update the build system.
---
![osl_building_on_windows](./osl_building_on_windows.jpg)
+48
View File
@@ -0,0 +1,48 @@
@REM /* --------------------- */
@REM Copyright Contributors to the Open Shading Language project.
@REM SPDX-License-Identifier: BSD-3-Clause
@REM /* --------------------- */
@REM Main batch file for installing OSL
@echo off
call osl_env_vars_setup.bat
cls
set OSL_INPUT_CONFIG=%1
if "%OSL_INPUT_CONFIG%" equ "debug" (
set OSL_LOCATION_DIR=osl_debug
set OSL_BUILD_CONFIG=--debug
goto RUN
)
if "%OSL_INPUT_CONFIG%" equ "release" (
set OSL_LOCATION_DIR=osl_release
set OSL_BUILD_CONFIG=
goto RUN
)
if "%OSL_INPUT_CONFIG%" equ "" (
echo --= Enter debug or release as argument
exit
)
@REM if argument is not debug or release
if "%OSL_INPUT_CONFIG%" neq "" (
echo --= Enter debug or release as argument
exit
)
:RUN
set PATH=%CMAKE_LOCATION%/bin;GIT_LOCATION/cmd;%PYTHON_LOCATION%;%PYTHON_LOCATION%/Scripts;%QT_LOCATION%/bin;%QT_LOCATION%/lib;%NASM_LOCATION%;%PATH%
set PYTHONPATH=%PYTHON_LOCATION%/Lib/site-packages;
set Qt5_ROOT=%QT_LOCATION%/lib/cmake
call %VCVARS_LOCATION%/vcvarsall.bat x64
cls
python build_osl.py --generator "Visual Studio 16 2019" --osl --python %OSL_BUILD_CONFIG% --zlib --boost --llvm --clang --pugixml --openexr --tiff --jpeg --png --flex --bison --opencolorio --openimageio --libraw --pybind11 %BASE_LOCATION%/%OSL_LOCATION_DIR%
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

@@ -0,0 +1,19 @@
@REM /* --------------------- */
@REM Copyright Contributors to the Open Shading Language project.
@REM SPDX-License-Identifier: BSD-3-Clause
@REM /* --------------------- */
@REM Running Visual Studio 2019 in debug mode for editing and debugging OSL
@echo off
call osl_env_vars_setup.bat
cls
set PATH=%PYTHON_LOCATION%;%PYTHON_LOCATION%/Scripts;%QT_LOCATION%/bin;%QT_LOCATION%/lib;%BASE_LOCATION%/osl_debug/bin;%BASE_LOCATION%/osl_debug/lib;%PATH%
set PYTHONPATH=%PYTHON_LOCATION%/Lib/site-packages;
%BASE_LOCATION%\osl_debug\build\OpenShadingLanguage\OSL.sln
@@ -0,0 +1,33 @@
@REM /* --------------------- */
@REM Copyright Contributors to the Open Shading Language project.
@REM SPDX-License-Identifier: BSD-3-Clause
@REM /* --------------------- */
@REM Running Visual Studio 2019 in release mode for running OSL or editing code
@echo off
@REM TIP:
@REM for modifying env vars based on your paths
@REM if your path has space in it, put whole path between
@REM double quotation
set BASE_LOCATION=D:/madoodia/sdks
set PYTHON_LOCATION=C:/Python37
set QT_LOCATION=C:/Qt/5.15.0/msvc2019_64
set NASM_LOCATION=C:/NASM
set GIT_LOCATION="C:/Program Files/Git"
set CMAKE_LOCATION="C:/Program Files/CMake"
set VCVARS_LOCATION="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build"
echo --= -------------------------------------------- =--
echo --= Environmment Variables created successfully! =--
echo BASE_LOCATION : %BASE_LOCATION%
echo PYTHON_LOCATION : %PYTHON_LOCATION%
echo QT_LOCATION : %QT_LOCATION%
echo NASM_LOCATION : %NASM_LOCATION%
echo GIT_LOCATION : %GIT_LOCATION%
echo CMAKE_LOCATION : %CMAKE_LOCATION%
echo VCVARS_LOCATION : %VCVARS_LOCATION%
echo --= -------------------------------------------- =--
@@ -0,0 +1,18 @@
@REM /* --------------------- */
@REM Copyright Contributors to the Open Shading Language project.
@REM SPDX-License-Identifier: BSD-3-Clause
@REM /* --------------------- */
@REM Main batch file for installing OSL
@echo off
call osl_env_vars_setup.bat
cls
set PATH=%PYTHON_LOCATION%;%PYTHON_LOCATION%/Scripts;%QT_LOCATION%/bin;%QT_LOCATION%/lib;%BASE_LOCATION%/osl_release/bin;%BASE_LOCATION%/osl_release/lib;%PATH%
set PYTHONPATH=%PYTHON_LOCATION%/Lib/site-packages;
%BASE_LOCATION%\osl_release\build\OpenShadingLanguage\OSL.sln
@@ -0,0 +1,18 @@
@REM /* --------------------- */
@REM Copyright Contributors to the Open Shading Language project.
@REM SPDX-License-Identifier: BSD-3-Clause
@REM /* --------------------- */
@REM Running OSLToy in debug mode
@echo off
call osl_env_vars_setup.bat
cls
set PATH=%PYTHON_LOCATION%;%PYTHON_LOCATION%/Scripts;%QT_LOCATION%/bin;%QT_LOCATION%/lib;%BASE_LOCATION%/osl_debug/bin;%BASE_LOCATION%/osl_debug/lib;%PATH%
set PYTHONPATH=%PYTHON_LOCATION%/Lib/site-packages;
osltoy
@@ -0,0 +1,18 @@
@REM /* --------------------- */
@REM Copyright Contributors to the Open Shading Language project.
@REM SPDX-License-Identifier: BSD-3-Clause
@REM /* --------------------- */
@REM Running OSLToy in release mode
@echo off
call osl_env_vars_setup.bat
cls
set PATH=%PYTHON_LOCATION%;%PYTHON_LOCATION%/Scripts;%QT_LOCATION%/bin;%QT_LOCATION%/lib;%BASE_LOCATION%/osl_release/bin;%BASE_LOCATION%/osl_release/lib;%PATH%
set PYTHONPATH=%PYTHON_LOCATION%/Lib/site-packages;
osltoy
+3
View File
@@ -0,0 +1,3 @@
# Shader Writing in OSL
Contains OSL shader writing content.
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
# Web Site
Contains OSL web site content.
-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
+165 -68
View File
@@ -1,41 +1,89 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# SPI-specific settings
ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits)
endif
NAMESPACE ?= 'OSL_Arnold'
$(info Building generic OSL)
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
#$(info MAKECMDGOALS = $(MAKECMDGOALS))
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS="-DOSL_SPI=1"
## Detect which SPI platform and set $platform, $COMPILER,
## and PYTHON_VERSION. Lots of other decisions are based on these.
ifeq (${SP_OS}, rhel7)
# Rhel7 (current)
platform := rhel7
SPI_COMPILER_PLATFORM ?= gcc-6.3
ifeq (${SPI_COMPILER_PLATFORM},gcc-6.3)
CMAKE_CXX_STANDARD ?= 14
endif
LLVM_VERSION ?= 12.0.0
else ifeq (${platform}, macosx)
# Generic OSX machines (including LG's laptop)
COMPILER ?= clang
SP_OS ?= macosx
else
$(error Unknown SP_OS=${SP_OS} platform=${platform})
endif # endif ${SP_OS}
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS}
MY_CMAKE_FLAGS += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOSL_SPI=1" -DOSL_SITE:STRING=spi
MY_CMAKE_FLAGS += -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
MY_CMAKE_FLAGS += -DOSL_EXTRA_NVCC_ARGS="--compiler-bindir=/opt/rh/devtoolset-6/root/bin/gcc"
## Rhel7 (current)
ifeq ($(SP_OS), rhel7)
platform=rhel7
USE_CPP ?= 11
USE_SIMD = sse4.1
ifeq (${SP_OS}, rhel7)
PYTHON_VERSION ?= 2.7
USE_SIMD ?= sse4.1,aes
CMAKE ?= cmake
USE_NINJA := 1
NINJA := ninja
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
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"
## If not overridden, here is our preferred LLVM installation
## (may be changed as new versions are rolled out to the facility)
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_5.0.0
#
# 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.
ifeq (${COMPILER}, clang4)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_4.0_final/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_4.0_final/bin/clang++
else ifeq (${COMPILER}, clang5)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_5.0.0/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/rhel7/llvm_5.0.0/bin/clang++
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_12.0.0
LLVM_DIRECTORY ?= /shots/spi/home/software/packages/llvm/${LLVM_VERSION}/${SPI_COMPILER_PLATFORM}
ifeq (${COMPILER},clang9)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/9.0.1-1/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
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/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang12)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/12.0.0-final/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER}, 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++
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},)
@@ -45,54 +93,106 @@ ifeq ($(SP_OS), rhel7)
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
MY_CMAKE_FLAGS += \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DPARTIO_HOME="/shots/spi/home/lib/SpComp2/partio/rhel7-gcc48m64/v1" \
-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
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
#
# Boost
#
BOOSTVERS ?= 1.70
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}_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"
-DBOOST_INCLUDEDIR=/usr/include/boostroot/boost${BOOSTVERS}.0 \
-DBOOST_LIBRARYDIR=/usr/lib64/boostroot/boost${BOOSTVERS}.0
#
# 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.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
MY_CMAKE_FLAGS += \
-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}
# Set our preferred OpenEXR path, but allow env variable to override
# with custom/test version.
OPENEXR_VERSION ?= 2.4.1-2
OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}
$(info OpenEXR_ROOT = $(OpenEXR_ROOT))
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
Partio_VERSION ?= 1.10.6
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
MY_CMAKE_FLAGS += -Dpartio_ROOT="${partio_ROOT}"
pugixml_VERSION ?= 1.10.0
pugixml_ROOT ?= ${REZ_PACKAGE_ROOT}/pugixml/${pugixml_VERSION}/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -Dpugixml_ROOT="${pugixml_ROOT}"
ifneq ($(OpenImageIO_ROOT),)
MY_CMAKE_FLAGS += -DOpenImageIO_ROOT=${OpenImageIO_ROOT}
endif
# Cuda/OptiX
USE_OPTIX ?= 1
CUDA_VERSION ?= 11.1.1
OPTIX_VERSION ?= 7.2.0
# CUDA_TOOLKIT_ROOT_DIR = $(shell rez-env -b cuda-${CUDA_VERSION} ${SPI_COMPILER_PLATFORM} -c "echo '$CUDA_TOOLKIT_ROOT'")
CUDA_TOOLKIT_ROOT_DIR ?= /shots/spi/home/lib/arnold/rhel7/cuda_${CUDA_VERSION}
OptiX_ROOT ?= /shots/spi/home/lib/arnold/rhel7/optix_${OPTIX_VERSION}
OPTIXHOME = ${OptiX_ROOT}
MY_CMAKE_FLAGS += -DUSE_OPTIX=${USE_OPTIX} \
-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)
USE_CPP ?= 11
CMAKE_CXX_STANDARD ?= 14
USE_SIMD ?= sse4.2
MY_CMAKE_FLAGS += \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
MY_CMAKE_FLAGS += -DCMAKE_BUILD_WITH_INSTALL_RPATH=1
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/lib"
BOOSTVERS=${BOOSTVERS}${BOOSTSPSUFFIX}
LLVM_DIRECTORY ?= /usr/local/opt/llvm
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, gcc5)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc6)
ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER},clang35)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.5 -DCMAKE_CXX_COMPILER=clang++-3.5
else ifeq (${COMPILER},clang40)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@4/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@4/bin/clang++
else ifeq (${COMPILER}, gcc9)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER},clang14)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
else ifeq (${COMPILER},clang15)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++
else ifeq (${COMPILER},clang16)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@16/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@16/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
@@ -100,25 +200,22 @@ else ifeq (${platform}, macosx)
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_COMPILER=${LLVM_ROOT}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_ROOT}/bin/clang++
else ifeq (${COMPILER},llvm)
# "llvm" means "use the clang from our llvm"
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_ROOT}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_ROOT}/bin/clang++
endif
# end generic OSX
else
$(error Unknown SP_OS)
endif # endif $(SP_OS)
# set up OpenImageIO distribution environment
ifeq (${OPENIMAGEIOHOME},)
MY_CMAKE_FLAGS += -DOPENIMAGEIOHOME:STRING=${working_dir}/../OpenImageIO_local/dist/${platform}${variant}/
else
MY_CMAKE_FLAGS += -DOPENIMAGEIOHOME:STRING=${IMAGEIOHOME}
endif
$(error Unknown SP_OS=${SP_OS})
endif # endif ${SP_OS}
ifneq (${VERBOSE},)
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
endif
+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>
+9
View File
@@ -0,0 +1,9 @@
# 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)
if (${PROJ_NAME}_SPIREZ)
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}")
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])))
+28
View File
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the Open Shading Language Project.
sonar.host.url=https://sonarcloud.io
# Required metadata
sonar.organization=academysoftwarefoundation
sonar.projectName=OpenShadingLanguage
sonar.projectVersion=1.12
sonar.projectKey=AcademySoftwareFoundation_OpenShadingLanguage
# Project links
sonar.links.homepage=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
sonar.links.ci=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/actions
sonar.links.scm=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
sonar.links.issue=https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues
# Source properties
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.exclusions=src/include/OSL/Imath/*.h,src/build-scripts/*
# C/C++ analyzer properties
sonar.cfamily.build-wrapper-output=build/bw_output
sonar.cfamily.gcov.reportsPath=_coverage
sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=/tmp/sonarcache
-273
View File
@@ -1,273 +0,0 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT (openexr)
SET(OPENEXR_VERSION_MAJOR "2")
SET(OPENEXR_VERSION_MINOR "2")
SET(OPENEXR_VERSION_PATCH "0")
SET(OPENEXR_VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH})
SET(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
# enable the tests
ENABLE_TESTING()
# distro building
SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENEXR_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${OPENEXR_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${OPENEXR_VERSION_PATCH}")
SET(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${OPENEXR_VERSION}"
)
set(CPACK_SOURCE_IGNORE_FILES
"/.git*;/.cvs*;${CPACK_SOURCE_IGNORE_FILES}")
INCLUDE ( CPack )
# Allow the developer to select if Dynamic or Static libraries are built
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON)
OPTION (USE_ZLIB_WINAPI "Use ZLib Win API" OFF)
OPTION (NAMESPACE_VERSIONING "Use Namespace Versioning" ON)
OPTION (BUILD_UTILS "Build the binary/utility programs" ON)
OPTION (BUILD_TESTS "Build the tests" ON)
# Setup osx rpathing
SET (CMAKE_MACOSX_RPATH 1)
SET (BUILD_WITH_INSTALL_RPATH 1)
ADD_DEFINITIONS ( -DHAVE_CONFIG_H -DILM_IMF_TEST_IMAGEDIR="${CMAKE_SOURCE_DIR}/IlmImfTest/" )
INCLUDE_DIRECTORIES (
${CMAKE_CURRENT_BINARY_DIR}/config
IlmImf
IlmImfUtil
exrmaketiled
exrenvmap
exrmakepreview
exrmultiview
IlmImfFuzzTest
)
FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
IF (NOT WIN32)
SET ( PTHREAD_LIB pthread )
ENDIF()
INCLUDE_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/include/OpenEXR )
LINK_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/lib )
MESSAGE ( "ILMBASE_PACKAGE_PREFIX = " ${ILMBASE_PACKAGE_PREFIX})
SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
SET (LIB_TYPE SHARED)
IF (WIN32)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF ()
ENDIF ()
IF (USE_ZLIB_WINAPI)
ADD_DEFINITIONS(-DZLIB_WINAPI)
ENDIF ()
# Test for GCC-style inline asm support with AVX instructions
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES (
"
int main()
{
#if defined(__GNUC__) && defined(__SSE2__)
int n = 0;
int eax = 0;
int edx = 0;
__asm__(
\"xgetbv ;\"
\"vzeroupper \"
: \"=a\"(eax), \"=d\"(edx) : \"c\"(n) : );
#else
#error No GCC style inline asm supported for AVX instructions
#endif
}
" HAVE_GCC_INLINE_ASM_AVX)
# Check if sysconf(_SC_NPROCESSORS_ONLN) can be used for CPU count
CHECK_CXX_SOURCE_COMPILES (
"
#include <unistd.h>
int main()
{
sysconf(_SC_NPROCESSORS_ONLN);
}
" HAVE_SYSCONF_NPROCESSORS_ONLN)
##########################
# OpenEXRConfig.h generation
##########################
IF (WIN32)
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
ELSEIF (APPLE)
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_DARWIN 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#include <string.h>\n" )
ELSE ()
# Linux
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LINUX_PROCFS 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LARGE_STACK 1\n" )
ENDIF()
IF (NAMESPACE_VERSIONING)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1\n")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf_${OPENEXR_VERSION_API}\n\n" )
ELSE ()
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 0\n")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf\n\n" )
ENDIF ()
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_VERSION_STRING \"${OPENEXR_VERSION}\"\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_PACKAGE_STRING \"OpenEXR ${OPENEXR_VERSION}\"\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
#define OPENEXR_VERSION_MAJOR ${OPENEXR_VERSION_MAJOR}
#define OPENEXR_VERSION_MINOR ${OPENEXR_VERSION_MINOR}
#define OPENEXR_VERSION_PATCH ${OPENEXR_VERSION_PATCH}
")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
// Version as a single hex number, e.g. 0x01000300 == 1.0.3
#define OPENEXR_VERSION_HEX ((OPENEXR_VERSION_MAJOR << 24) | \\
(OPENEXR_VERSION_MINOR << 16) | \\
(OPENEXR_VERSION_PATCH << 8))\n
")
IF (HAVE_GCC_INLINE_ASM_AVX)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX 1\n" )
ENDIF()
IF (HAVE_SYSCONF_NPROCESSORS_ONLN)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN 1\n" )
ENDIF()
SET (OPENEXR_LIBSUFFIX "")
SET (ILMBASE_LIBSUFFIX "")
IF (NAMESPACE_VERSIONING)
SET ( OPENEXR_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
# assume same NAMESPACE_VERSION setting for IlmBase for now
SET ( ILMBASE_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
ENDIF ()
##########################
# IlmImf library
##########################
ADD_SUBDIRECTORY ( IlmImf )
SET_TARGET_PROPERTIES ( IlmImf
PROPERTIES
VERSION 22.0.0
SOVERSION 22
OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}"
)
##########################
# IlmImfUtil library
##########################
ADD_SUBDIRECTORY ( IlmImfUtil )
SET_TARGET_PROPERTIES ( IlmImfUtil
PROPERTIES
VERSION 22.0.0
SOVERSION 22
OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}"
)
##########################
# Example Code
##########################
ADD_SUBDIRECTORY ( IlmImfExamples )
##########################
# Tests
##########################
if (BUILD_TESTS)
ADD_SUBDIRECTORY ( IlmImfTest )
ADD_SUBDIRECTORY ( IlmImfUtilTest )
ADD_SUBDIRECTORY ( IlmImfFuzzTest )
endif ()
##########################
# Binaries / Utilities
##########################
if (BUILD_UTILS)
ADD_SUBDIRECTORY ( exrheader )
ADD_SUBDIRECTORY ( exrmaketiled )
ADD_SUBDIRECTORY ( exrstdattr )
ADD_SUBDIRECTORY ( exrmakepreview )
ADD_SUBDIRECTORY ( exrenvmap )
ADD_SUBDIRECTORY ( exrmultiview )
ADD_SUBDIRECTORY ( exrmultipart )
endif ()
##########################
# Installation
##########################
INSTALL ( FILES
${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
)
# Documentation
INSTALL ( FILES
doc/TechnicalIntroduction.pdf
doc/ReadingAndWritingImageFiles.pdf
doc/OpenEXRFileLayout.pdf
doc/MultiViewOpenEXR.pdf
doc/InterpretingDeepPixels.pdf
doc/TheoryDeepPixels.pdf
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}
)
# Examples
INSTALL ( FILES
IlmImfExamples/main.cpp
IlmImfExamples/drawImage.cpp
IlmImfExamples/rgbaInterfaceExamples.cpp
IlmImfExamples/rgbaInterfaceTiledExamples.cpp
IlmImfExamples/generalInterfaceExamples.cpp
IlmImfExamples/lowLevelIoExamples.cpp
IlmImfExamples/previewImageExamples.cpp
IlmImfExamples/generalInterfaceTiledExamples.cpp
IlmImfExamples/generalInterfaceTiledExamples.h
IlmImfExamples/drawImage.h
IlmImfExamples/rgbaInterfaceExamples.h
IlmImfExamples/generalInterfaceExamples.h
IlmImfExamples/rgbaInterfaceTiledExamples.h
IlmImfExamples/lowLevelIoExamples.h
IlmImfExamples/previewImageExamples.h
IlmImfExamples/namespaceAlias.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}/examples
)
# LG additions
if (DEFINED ENV{APPVEYOR})
add_definitions ("/W0")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /W0")
endif ()
@@ -1,273 +0,0 @@
# yue.nicholas@gmail.com
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h")
ADD_EXECUTABLE ( b44ExpLogTable
b44ExpLogTable.cpp
)
TARGET_LINK_LIBRARIES ( b44ExpLogTable
Half
Iex${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB}
)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/b44ExpLogTable > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
DEPENDS b44ExpLogTable
)
else ()
message (STATUS "Skipping build of b44ExpLogTable.h")
endif ()
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h")
ADD_EXECUTABLE ( dwaLookups
dwaLookups.cpp
)
TARGET_LINK_LIBRARIES ( dwaLookups
Half
Iex${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB}
)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/dwaLookups > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
DEPENDS dwaLookups
)
else ()
message (STATUS "Skipping build of dwaLookups.h")
endif ()
SET ( ILMIMF_SRCS
ImfAttribute.cpp
ImfBoxAttribute.cpp
ImfCRgbaFile.cpp
ImfChannelList.cpp
ImfChannelListAttribute.cpp
ImfFloatAttribute.cpp
ImfFrameBuffer.cpp
ImfHeader.cpp
ImfIO.cpp
ImfInputFile.cpp
ImfIntAttribute.cpp
ImfLineOrderAttribute.cpp
ImfMatrixAttribute.cpp
ImfOpaqueAttribute.cpp
ImfOutputFile.cpp
ImfRgbaFile.cpp
ImfStringAttribute.cpp
ImfVecAttribute.cpp
ImfHuf.cpp
ImfThreading.cpp
ImfWav.cpp
ImfLut.cpp
ImfCompressor.cpp
ImfRleCompressor.cpp
ImfZipCompressor.cpp
ImfPizCompressor.cpp
ImfB44Compressor.cpp
ImfDwaCompressor.cpp
ImfMisc.cpp
ImfCompressionAttribute.cpp
ImfDoubleAttribute.cpp
ImfConvert.cpp
ImfPreviewImage.cpp
ImfPreviewImageAttribute.cpp
ImfVersion.cpp
ImfChromaticities.cpp
ImfChromaticitiesAttribute.cpp
ImfKeyCode.cpp
ImfKeyCodeAttribute.cpp
ImfTimeCode.cpp
ImfTimeCodeAttribute.cpp
ImfRational.cpp
ImfRationalAttribute.cpp
ImfFramesPerSecond.cpp
ImfStandardAttributes.cpp
ImfStdIO.cpp
ImfEnvmap.cpp
ImfEnvmapAttribute.cpp
ImfScanLineInputFile.cpp
ImfTiledInputFile.cpp
ImfTiledMisc.cpp
ImfTiledOutputFile.cpp
ImfTiledRgbaFile.cpp
ImfTileDescriptionAttribute.cpp
ImfTileOffsets.cpp
ImfRgbaYca.cpp
ImfPxr24Compressor.cpp
ImfTestFile.cpp
ImfStringVectorAttribute.cpp
ImfMultiView.cpp
ImfAcesFile.cpp
ImfMultiPartOutputFile.cpp
ImfGenericOutputFile.cpp
ImfOutputPartData.cpp
ImfMultiPartInputFile.cpp
ImfGenericInputFile.cpp
ImfPartType.cpp
ImfInputPartData.cpp
ImfOutputPart.cpp
ImfTiledOutputPart.cpp
ImfInputPart.cpp
ImfTiledInputPart.cpp
ImfDeepScanLineInputPart.cpp
ImfDeepScanLineOutputPart.cpp
ImfDeepScanLineInputFile.cpp
ImfDeepScanLineOutputFile.cpp
ImfDeepTiledInputPart.cpp
ImfDeepTiledOutputPart.cpp
ImfDeepTiledInputFile.cpp
ImfDeepTiledOutputFile.cpp
ImfDeepFrameBuffer.cpp
ImfDeepCompositing.cpp
ImfCompositeDeepScanLine.cpp
ImfDeepImageStateAttribute.cpp
ImfFastHuf.cpp
ImfFloatVectorAttribute.cpp
ImfRle.cpp
ImfSystemSpecific.cpp
ImfZip.cpp
)
IF (BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DILMIMF_EXPORTS)
ENDIF()
ADD_LIBRARY ( IlmImf ${LIB_TYPE}
${ILMIMF_SRCS}
)
TARGET_LINK_LIBRARIES ( IlmImf
Half
Iex${ILMBASE_LIBSUFFIX}
Imath${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB} ${ZLIB_LIBRARIES}
)
ADD_DEPENDENCIES ( IlmImf b44ExpLogTable )
SET_SOURCE_FILES_PROPERTIES (
ImfB44Compressor.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
)
ADD_DEPENDENCIES ( IlmImf dwaLookups )
SET_SOURCE_FILES_PROPERTIES (
ImfDwaCompressor.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
)
# Libraries
INSTALL ( TARGETS
IlmImf
DESTINATION
${CMAKE_INSTALL_PREFIX}/lib
)
# Headers
INSTALL ( FILES
ImfForward.h
ImfExport.h
ImfAttribute.h
ImfBoxAttribute.h
ImfCRgbaFile.h
ImfChannelList.h
ImfChannelListAttribute.h
ImfCompressionAttribute.h
ImfDoubleAttribute.h
ImfFloatAttribute.h
ImfFrameBuffer.h
ImfHeader.h
ImfIO.h
ImfInputFile.h
ImfIntAttribute.h
ImfLineOrderAttribute.h
ImfMatrixAttribute.h
ImfOpaqueAttribute.h
ImfOutputFile.h
ImfRgbaFile.h
ImfStringAttribute.h
ImfVecAttribute.h
ImfHuf.h
ImfWav.h
ImfLut.h
ImfArray.h
ImfCompression.h
ImfLineOrder.h
ImfName.h
ImfPixelType.h
ImfVersion.h
ImfXdr.h
ImfConvert.h
ImfPreviewImage.h
ImfPreviewImageAttribute.h
ImfChromaticities.h
ImfChromaticitiesAttribute.h
ImfKeyCode.h
ImfKeyCodeAttribute.h
ImfTimeCode.h
ImfTimeCodeAttribute.h
ImfRational.h
ImfRationalAttribute.h
ImfFramesPerSecond.h
ImfStandardAttributes.h
ImfEnvmap.h
ImfEnvmapAttribute.h
ImfInt64.h
ImfRgba.h
ImfTileDescription.h
ImfTileDescriptionAttribute.h
ImfTiledInputFile.h
ImfTiledOutputFile.h
ImfTiledRgbaFile.h
ImfRgbaYca.h
ImfTestFile.h
ImfThreading.h
ImfB44Compressor.h
ImfStringVectorAttribute.h
ImfMultiView.h
ImfAcesFile.h
ImfMultiPartOutputFile.h
ImfGenericOutputFile.h
ImfMultiPartInputFile.h
ImfGenericInputFile.h
ImfPartType.h
ImfPartHelper.h
ImfOutputPart.h
ImfTiledOutputPart.h
ImfInputPart.h
ImfTiledInputPart.h
ImfDeepScanLineOutputFile.h
ImfDeepScanLineOutputPart.h
ImfDeepScanLineInputFile.h
ImfDeepScanLineInputPart.h
ImfDeepTiledInputFile.h
ImfDeepTiledInputPart.h
ImfDeepTiledOutputFile.h
ImfDeepTiledOutputPart.h
ImfDeepFrameBuffer.h
ImfDeepCompositing.h
ImfCompositeDeepScanLine.h
ImfNamespace.h
ImfMisc.h
ImfDeepImageState.h
ImfDeepImageStateAttribute.h
ImfFloatVectorAttribute.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
)
Binary file not shown.
+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
+50
View File
@@ -0,0 +1,50 @@
#!/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:=14.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" ]] \
|| [[ "$LLVM_VERSION" == "13.0.0" ]] || [[ "$LLVM_VERSION" == "14.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_SOURCE_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build}
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENCOLORIO_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 \
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"
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_SOURCE_DIR} ]] ; then
echo "git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}"
git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}
fi
cd ${OPENCOLORIO_SOURCE_DIR}
echo "git checkout ${OPENCOLORIO_VERSION} --force"
git checkout ${OPENCOLORIO_VERSION} --force
mkdir -p ${OPENCOLORIO_BUILD_DIR}
cd ${OPENCOLORIO_BUILD_DIR}
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS} ${OPENCOLORIO_SOURCE_DIR}
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
+77 -41
View File
@@ -1,52 +1,88 @@
#!/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/AcademySoftwareFoundation/openexr.git}
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.1.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}
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
BASEDIR=$PWD
EXRREPO=${EXRREPO:=https://github.com/openexr/openexr.git}
EXRINSTALLDIR=${EXRINSTALLDIR:=${PWD}/openexr-install}
EXRBRANCH=${EXRBRANCH:=v2.2.0}
EXRCXXFLAGS=${EXRCXXFLAGS:=""}
BASEDIR=`pwd`
pwd
echo "EXR install dir will be: ${EXRINSTALLDIR}"
if [ ! -e ${EXRINSTALLDIR} ] ; then
mkdir ${EXRINSTALLDIR}
fi
echo "Building OpenEXR ${OPENEXR_VERSION}"
echo "OpenEXR build dir will be: ${OPENEXR_BUILD_DIR}"
echo "OpenEXR install dir will be: ${OPENEXR_INSTALL_DIR}"
echo "OpenEXR Build type is ${OPENEXR_BUILD_TYPE}"
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
# Clone OpenEXR project (including IlmBase) from GitHub and build
if [ ! -e ./openexr ] ; then
echo "git clone ${EXRREPO} ./openexr"
git clone ${EXRREPO} ./openexr
if [[ ! -e ${OPENEXR_SOURCE_DIR} ]] ; then
echo "git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}"
git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}
fi
mkdir -p ${OPENEXR_INSTALL_DIR} && true
mkdir -p ${OPENEXR_BUILD_DIR} && true
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force
if [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
# Simplified setup for 2.3+
cd ${OPENEXR_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DOPENEXR_BUILD_UTILS=0 \
-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} \
-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
flags=
if [ ${LINKSTATIC:=0} == 1 ] ; then
flags=${flags} --enable-static --enable-shared=no --with-pic
fi
pushd ./openexr
echo "git checkout ${EXRBRANCH} --force"
git checkout ${EXRBRANCH} --force
cd IlmBase
mkdir build
cd build
cmake --config Release -DCMAKE_INSTALL_PREFIX=${EXRINSTALLDIR} -DCMAKE_CXX_FLAGS=${EXRCXXFLAGS} .. && 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 -DCMAKE_CXX_FLAGS=${EXRCXXFLAGS} .. && 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
+59 -13
View File
@@ -1,21 +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
OIIOREPO=${OIIOREPO:=OpenImageIO/oiio}
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/${OIIOREPO} $OIIOINSTALLDIR
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=OpenImageIO/oiio}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=release}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENIMAGEIO_SRCDIR=${OPENIMAGEIO_SRCDIR:=${LOCAL_DEPS_DIR}/OpenImageIO}
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build}
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
make ${OIIOMAKEFLAGS} VERBOSE=1 cmakesetup
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
+65
View File
@@ -0,0 +1,65 @@
#!/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.8.1}
# 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}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
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
fi
# 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
+57
View File
@@ -0,0 +1,57 @@
#!/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
if [[ -n "$CODECOV" ]] ; then
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DCODECOV=${CODECOV}"
fi
pushd build
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_INSTALL_PREFIX="$OSL_ROOT" \
-DUSE_PYTHON="${USE_PYTHON:=1}" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
-DUSE_BATCHED="${USE_BATCHED:=0}" \
-DCMAKE_INSTALL_LIBDIR="$OSL_ROOT/lib" \
-DCMAKE_CXX_STANDARD="$CMAKE_CXX_STANDARD" \
$OSL_CMAKE_FLAGS -DVERBOSE=1
# Save a copy of the generated files for debugging broken CI builds.
mkdir cmake-save || /bin/true
cp -r CMake* *.cmake cmake-save
: ${BUILDTARGET:=install}
if [[ "$BUILDTARGET" != "none" ]] ; then
echo "Parallel build ${CMAKE_BUILD_PARALLEL_LEVEL} of target ${BUILDTARGET}"
time ${OSL_CMAKE_BUILD_WRAPPER} cmake --build . --target ${BUILDTARGET} --config ${CMAKE_BUILD_TYPE}
fi
popd
if [[ "${DEBUG_CI:=0}" != "0" ]] ; then
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
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Run code coverage analysis
# This assumes that the build occurred with CODECOV=1 andtests have already
# fully run.
set -ex
echo "Performing code coverage analysis"
mkdir _coverage
pushd _coverage
ls -R ../build/src/
# Remove files or directories we want to exclude from code coverage analysis,
# generally because we don't expect to execute any of their code during our
# CI. (Because it's only used interactively, or is fallback code only used
# when certain dependencies are not found.) Including these when we know we
# won't be calling them during coverage gathering will just make our coverage
# percentage look artifically low.
rm -f ../build/src/osltoy/CMakeFiles/osltoy.dir/*.cpp.{gcno,gcda}
# The sed command below converts from:
# ../build/src/liboslexec/CMakeFiles/oslexec.dir/foo.gcno
# to:
# ../src/liboslexec/foo.cpp
for g in $(find ../build -name "*.gcno" -type f); do
echo "Processing $g"
echo "dirname $g = $(dirname $g) to " `$(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\.cpp\.cpp/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')`
gcov -l -p -o $(dirname "$g") $(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')
done
popd
+75
View File
@@ -0,0 +1,75 @@
#!/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.
# 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
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:detect_odr_violation=1
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 dist
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 [[ ${RUNNER_OS} == "macOS" ]] ; then
sysctl machdep.cpu.features
fi
# Save the env for use by other stages
src/build-scripts/save-env.bash
+36
View File
@@ -0,0 +1,36 @@
#!/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
: ${CTEST_EXCLUSIONS:="broken"}
: ${CTEST_TEST_TIMEOUT:=60}
$OSL_ROOT/bin/testshade --help
echo "Parallel test ${CTEST_PARALLEL_LEVEL}"
echo "Default timeout ${CTEST_TEST_TIMEOUT}"
echo "Test exclusions '${CTEST_EXCLUSIONS}'"
echo "CTEST_ARGS '${CTEST_ARGS}'"
pushd build
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process --output-on-failure \
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS} \
|| \
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process \
--rerun-failed --repeat until-pass:5 -R render --output-on-failure \
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS}
# The weird construct above allows the render-* tests to run multiple times
popd
# 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 documentation 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 documentation comments follows the code declaration, and this is
### designated by having its first line start with `///<`. I like to
### just remember that the `<` or `>` points in the direction of the code
### declaration that the comment applies to.
###
### 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))
Binary file not shown.
+184
View File
@@ -0,0 +1,184 @@
#!/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 /usr/bin/yum install -y giflib giflib-devel && true
# sudo /usr/bin/yum install -y ffmpeg ffmpeg-devel && true
if [[ "${CONAN_LLVM_VERSION}" != "" ]] ; then
mkdir conan
pushd conan
# Simple way to conan install just one package:
# conan install clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1 -g deploy -g virtualenv
# But the below method can accommodate multiple requirements:
echo "[imports]" >> conanfile.txt
echo "., * -> ." >> conanfile.txt
echo "[requires]" >> conanfile.txt
echo "clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1" >> conanfile.txt
time conan install .
echo "--ls--"
ls -R .
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
export LLVM_ROOT=$PWD
popd
fi
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d
sudo /usr/bin/yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2022.1.0-3768
# Because multiple (possibly newer) versions of oneAPI may be installed,
# use a config file to specify compiler and tbb versions
# NOTE: oneAPI components have independent version numbering.
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then
echo "Verifying installation of Intel(r) C++ Compiler:"
icpc --version
fi
if [[ "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
echo "Verifying installation of Intel(r) oneAPI DPC++/C++ Compiler:"
icpx --version
fi
fi
else
# 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 \
libilmbase-dev libopenexr-dev \
libtiff-dev libgif-dev libpng-dev \
flex bison libbison-dev \
libpugixml-dev \
libopencolorio-dev
time sudo apt-get -q install -y \
qt5-default || /bin/true
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH
# Nonstandard python versions
if [[ "${PYTHON_VERSION}" == "3.9" ]] ; then
time sudo apt-get -q install -y python3.9-dev python3-numpy
pip3 --version
pip3 install numpy
elif [[ "$PYTHON_VERSION" == "2.7" ]] ; then
time sudo apt-get -q install -y python-dev python-numpy
else
pip3 install numpy
fi
if [[ "$CXX" == "g++-6" ]] ; then
time sudo apt-get install -y g++-6
elif [[ "$CXX" == "g++-7" ]] ; then
time sudo apt-get install -y g++-7
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
elif [[ "$CXX" == "g++-12" ]] ; then
time sudo apt-get install -y g++-12
fi
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
time sudo apt-get update
time sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic=2022.1.0-3768
# Because multiple (possibly newer) versions of oneAPI may be installed,
# use a config file to specify compiler and tbb versions
# NOTE: oneAPI components have independent version numbering.
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
fi
source src/build-scripts/build_llvm.bash
fi
if [[ "$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
source src/build-scripts/build_opencolorio.bash
fi
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then
# There are many parts of OIIO we don't need to build for OSL's tests
export ENABLE_iinfo=0 ENABLE_iv=0 ENABLE_igrep=0
export ENABLE_iconvert=0 ENABLE_testtex=0
# For speed of compiling OIIO, disable the file formats that we don't
# need for OSL's tests
export ENABLE_BMP=0 ENABLE_cineon=0 ENABLE_DDS=0 ENABLE_DPX=0 ENABLE_FITS=0
export ENABLE_ICO=0 ENABLE_iff=0 ENABLE_jpeg2000=0 ENABLE_PNM=0 ENABLE_PSD=0
export ENABLE_RLA=0 ENABLE_SGI=0 ENABLE_SOCKET=0 ENABLE_SOFTIMAGE=0
export ENABLE_TARGA=0 ENABLE_WEBP=0
# We don't need to run OIIO's tests
export OPENIMAGEIO_CMAKE_FLAGS+=" -DOIIO_BUILD_TESTING=OFF -DOIIO_BUILD_TESTS=0"
# Don't let warnings in OIIO break OSL's CI run
export OPENIMAGEIO_CMAKE_FLAGS+=" -DSTOP_ON_WARNING=OFF"
export OPENIMAGEIO_CMAKE_FLAGS+=" -DUSE_OPENGL=0"
if [[ $OPENIMAGEIO_VERSION == master && "${OPENIMAGEIO_UNITY:-1}" != "0" ]] ; then
# Speed up the OIIO build by doing a "unity" build. (Note: this is
# only a savings in CI where there are only 1-2 cores available, and
# is only supported for OIIO 2.3.14 and later)
export OPENIMAGEIO_CMAKE_FLAGS+=" -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_MODE=BATCH"
fi
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"
mkdir -p "$DEP_DIR"
INT_DIR="build"
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
+1 -1
View File
@@ -1,4 +1,4 @@
{
global: *OSL*; test_shade; *osl*imageio*; *osl_input_extensions;
local: osl_*; *;
local: osl_*; *pvt*; *;
};
+54 -15
View File
@@ -1,33 +1,72 @@
#!/bin/bash
#!/usr/bin/env bash
# This script, which assumes it is runnign on a Mac OSX with Homebrew
# 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 running 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
set -ex
if [[ "$DO_BREW_UPDATE" != "" ]] ; then
brew update >/dev/null
fi
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 libpng
brew install llvm${LLVMBREWVER}
#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 install --display-times -q python@${PYTHON_VERSION} || true
# brew unlink python@2.7 || true
# brew unlink python@3.8 || true
# brew unlink python@3.9 || true
brew unlink python@3.10 || true
brew link --overwrite --force python@${PYTHON_VERSION} || true
brew upgrade --display-times -q cmake || true
brew install --display-times -q imath openexr
#brew install --display-times -q freetype
brew install --display-times -q --overwrite --force opencolorio || true
brew install --display-times -q 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
-3
View File
@@ -1,3 +0,0 @@
leak:Imf_2_2
leak:libIlmImf
leak:oslgram.y
+7
View File
@@ -0,0 +1,7 @@
[oneAPI]
name=Intel® oneAPI repository
baseurl=https://yum.repos.intel.com/oneapi
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
+3
View File
@@ -0,0 +1,3 @@
default=exclude
compiler=2022.1.0
tbb=2021.6.0
+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 "---------"
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Turn an LLVM-compiled bitfile into a C++ source file where the compiled
# bitcode is in a huge array.
from __future__ import print_function, absolute_import
import sys
in_name = sys.argv[1]
out_name = sys.argv[2]
prefix = sys.argv[3]
f_in = open(in_name, 'rb')
f_out = open(out_name, 'w')
f_out.write('#include <cstddef>\n')
f_out.write('unsigned char ' + prefix + '_block[] = {\n')
f_in.read
if (sys.version_info > (3, 0)):
for c in f_in.read():
f_out.write(hex(c) + ',\n')
else:
for c in f_in.read():
f_out.write('0x{},\n'.format(c.encode('hex')))
f_out.write('0x00 };\n')
f_out.write('int {}_size = sizeof({}_block)-1;\n'.format(prefix, prefix))
+38
View File
@@ -0,0 +1,38 @@
# 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 @Imath_VERSION@)
elseif (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.4 AND @FOUND_OPENEXR_WITH_CONFIG@)
find_dependency(IlmBase @OpenEXR_VERSION@)
find_dependency(OpenEXR @OpenEXR_VERSION@)
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)
# Compute the installation prefix relative to this file
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
# There's no guarantee that CMAKE_INSTALL_XXXDIR is a relative path so we extract the final component to handle absolute paths
get_filename_component(_INCLUDE_DIR_NAME "@CMAKE_INSTALL_INCLUDEDIR@" NAME)
get_filename_component(_LIB_DIR_NAME "@CMAKE_INSTALL_LIBDIR@" NAME)
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_INCLUDES "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_LIB_DIR "${_IMPORT_PREFIX}/${_LIB_DIR_NAME}")
#...logic to determine installedPrefix from the own location...
#set (@PROJECT_NAME@_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@")
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 ()
+202
View File
@@ -0,0 +1,202 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
set (REQUIRED_DEPS "" CACHE STRING
"Additional dependencies to consider required (semicolon-separated list, or ALL)")
set (OPTIONAL_DEPS "" CACHE STRING
"Additional dependencies to consider optional (semicolon-separated list, or ALL)")
option (ALWAYS_PREFER_CONFIG "Prefer a dependency's exported config file if it's available" OFF)
# Utility function to list the names and values of all variables matching
# the pattern (case-insensitive)
function (dump_matching_variables pattern)
string (TOLOWER ${pattern} _pattern_lower)
get_cmake_property(_allvars VARIABLES)
list (SORT _allvars)
foreach (_var IN LISTS _allvars)
string (TOLOWER ${_var} _var_lower)
if (_var_lower MATCHES ${_pattern_lower})
message (STATUS " ${_var} = ${${_var}}")
endif ()
endforeach ()
endfunction ()
# checked_find_package(Pkgname ...) is a wrapper for find_package, with the
# 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 SETVARIABLES <id>... is a list of CMake variables to set to
# TRUE if the package is found (they will not be set or changed if the
# package is not found).
# * Optional PRINT <list> is a list of variables that will be printed
# if the package is found, if VERBOSE is on.
# * Optional DEPS <list> is a list of hard dependencies; for each one, if
# 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.
# * Optional PREFER_CONFIG, if supplied, tries to use an exported config
# file from the package before using a FindPackage.cmake module.
# * Optional DEBUG turns on extra debugging information related to how
# this package is found.
#
# N.B. This needs to be a macro, not a function, because the find modules
# will set(blah val PARENT_SCOPE) and we need that to be the global scope,
# not merely the scope for this function.
macro (checked_find_package pkgname)
cmake_parse_arguments(_pkg # prefix
# noValueKeywords:
"REQUIRED;PREFER_CONFIG;DEBUG"
# singleValueKeywords:
"ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON"
# multiValueKeywords:
"DEFINITIONS;PRINT;DEPS;SETVARIABLES"
# argsToParse:
${ARGN})
string (TOLOWER ${pkgname} pkgname_lower)
string (TOUPPER ${pkgname} pkgname_upper)
set (_pkg_VERBOSE ${VERBOSE})
if (_pkg_DEBUG)
set (_pkg_VERBOSE ON)
endif ()
if (NOT _pkg_VERBOSE)
set (${pkgname}_FIND_QUIETLY true)
set (${pkgname_upper}_FIND_QUIETLY true)
endif ()
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 ()
set (_config_status "")
if (_enable OR _pkg_REQUIRED)
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
# was already found
elseif (_pkg_PREFER_CONFIG OR ALWAYS_PREFER_CONFIG)
find_package (${pkgname} CONFIG ${_pkg_UNPARSED_ARGUMENTS})
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
set (_config_status "from CONFIG")
endif ()
endif ()
if (NOT (${pkgname}_FOUND OR ${pkgname_upper}_FOUND))
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
endif()
if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
AND ${pkgname}_VERSION
AND (_pkg_VERSION_MIN OR _pkg_VERSION_MAX))
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} ${_config_status}${ColorReset}")
add_definitions (${_pkg_DEFINITIONS})
foreach (_v IN LISTS _pkg_SETVARIABLES)
set (${_v} TRUE)
endforeach ()
if (_pkg_RECOMMEND_MIN)
if (${${pkgname}_VERSION} VERSION_LESS ${_pkg_RECOMMEND_MIN})
message (STATUS "${ColorYellow}Recommend ${pkgname} >= ${_pkg_RECOMMEND_MIN} ${_pkg_RECOMMEND_MIN_REASON} ${ColorReset}")
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()
if (_pkg_VERBOSE AND (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_DEBUG))
if (_pkg_DEBUG)
dump_matching_variables (${pkgname})
endif ()
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
${_pkg_PRINT})
list (REMOVE_DUPLICATES _vars_to_print)
foreach (_v IN LISTS _vars_to_print)
if (NOT "${${_v}}" STREQUAL "")
message (STATUS " ${_v} = ${${_v}}")
endif ()
endforeach ()
endif ()
else ()
if (NOT _quietskip)
message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}")
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")
+463 -193
View File
@@ -1,29 +1,45 @@
# 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.
#
###########################################################################
# Compiler-related detection, options, and actions
message (STATUS "CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_COMPILER_ID is ${CMAKE_CXX_COMPILER_ID}")
set (USE_CPP 11 CACHE STRING "C++ standard to prefer (11, 14, etc.)")
option (USE_LIBCPLUSPLUS "Compile with clang libc++")
set (USE_SIMD "" CACHE STRING "Use SIMD directives (0, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512f, f16c)")
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
option (HIDE_SYMBOLS "Hide symbols not in the public API" ON)
option (USE_CCACHE "Use ccache if found" ON)
option (USE_fPIC "Build with -fPIC")
set (EXTRA_CPP_ARGS "" CACHE STRING "Extra C++ command line definitions")
set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when building DSOs")
option (BUILDSTATIC "Build static libraries instead of shared" OFF)
option (LINKSTATIC "Link with static external libraries when possible" OFF)
option (CODECOV "Build code coverage tests" OFF)
set (SANITIZE "" CACHE STRING "Build code using sanitizer (address, thread)")
option (CLANG_TIDY "Enable clang-tidy" OFF)
set (CLANG_TIDY_CHECKS "-*" CACHE STRING "clang-tidy checks to perform")
set (CLANG_TIDY_ARGS "" CACHE STRING "clang-tidy args")
option (CLANG_TIDY_FIX "Have clang-tidy fix source" OFF)
###########################################################################
# 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 14 CACHE STRING
"C++ standard to build with (14, 17, 20, etc.)")
set (DOWNSTREAM_CXX_STANDARD 14 CACHE STRING
"C++ minimum standard to impose on downstream clients")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
message (STATUS "Building with C++${CMAKE_CXX_STANDARD}, downstream minimum C++${DOWNSTREAM_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
@@ -31,10 +47,12 @@ if (CMAKE_COMPILER_IS_GNUCC)
if (VERBOSE)
message (STATUS "Using gcc ${GCC_VERSION} as the compiler")
endif ()
else ()
set (GCC_VERSION 0)
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 (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang"
OR CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
# If using any flavor of clang, set CMAKE_COMPILER_IS_CLANG. If it's
# Apple's variety, set CMAKE_COMPILER_IS_APPLECLANG and
# APPLECLANG_VERSION_STRING, otherwise for generic clang set
@@ -48,6 +66,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
if (VERBOSE)
message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
set (CMAKE_COMPILER_IS_INTELCLANG 1)
string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string})
if (VERBOSE)
message (STATUS "The compiler is Intel Clang: ${CMAKE_CXX_COMPILER_ID} version ${INTELCLANG_VERSION_STRING}")
endif ()
else ()
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
if (VERBOSE)
@@ -61,99 +85,125 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
endif ()
endif ()
# turn on more detailed warnings and consider warnings as errors
###########################################################################
# Turn on more detailed warnings and optionally consider warnings as errors
#
if (NOT ${PROJECT_NAME}_SUPPORTED_RELEASE OR DEFINED ENV{${PROJECT_NAME}_CI})
# For development branches (i.e., not a supported release), or when
# running CI, default to treating all warnings as errors.
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON)
else ()
# For release branches not doing a CI build default to just printing
# warnings but not letting them stop the build.
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" OFF)
endif()
option (EXTRA_WARNINGS "Enable lots of extra pedantic warnings" OFF)
if (NOT MSVC)
add_definitions ("-Wall")
add_compile_options ("-Wall")
if (EXTRA_WARNINGS)
add_compile_options ("-Wextra")
endif ()
if (STOP_ON_WARNING)
add_definitions ("-Werror")
add_compile_options ("-Werror")
endif ()
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# cmake bug workaround -- on some platforms, cmake doesn't set
# NDEBUG for RelWithDebInfo mode
add_definitions ("-DNDEBUG")
###########################################################################
# 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 VISIBILITY_MAP_FILE AND
(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND
(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU"))
# Linux/FreeBSD/Hurd: also hide all the symbols of dependent libraries
# 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")
add_compile_options ("-Wno-format-security")
# 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`
add_compile_options ("-Wno-expansion-to-defined")
endif ()
# Suppress warnings about our strategic use of bitwise operations in place
# of logical operators to produce branchless code in some places.
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0
OR INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0)
add_compile_options ("-Wno-bitwise-instead-of-logical")
endif ()
# disable warning in flex-generated code
add_compile_options ("-Wno-null-conversion")
add_compile_options ("-Wno-error=strict-overflow")
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 ()
# 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 ")
# 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_definitions ("-fno-math-errno")
add_compile_options ("-fno-math-errno")
endif ()
if (HIDE_SYMBOLS AND NOT DEBUGMODE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
# 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 OIIO is linked
# against other verions of our dependencies.
if (NOT VISIBILITY_MAP_FILE)
set (VISIBILITY_MAP_FILE "${PROJECT_SOURCE_DIR}/src/build-scripts/hidesymbols.map")
endif ()
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${VISIBILITY_MAP_FILE}")
if (VERBOSE)
message (STATUS "VISIBILITY_MAP_COMMAND = ${VISIBILITY_MAP_COMMAND}")
endif ()
endif ()
if (INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 2022.1.0)
# New versions of icx warn about changing certain floating point options
add_compile_options ("-Wno-overriding-t-option")
endif ()
# 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")
add_definitions ("-Wno-unknown-pragmas")
# 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")
if (CLANG_VERSION_STRING VERSION_GREATER 3.5 OR
APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
add_definitions ("-Wno-unused-local-typedefs")
endif ()
if (CLANG_VERSION_STRING VERSION_EQUAL 3.9 OR CLANG_VERSION_STRING VERSION_GREATER 3.9)
# Don't warn about using unknown preprocessor symbols in #if'set
add_definitions ("-Wno-expansion-to-defined")
endif ()
# 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 ()
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 ()
if (NOT ${GCC_VERSION} VERSION_LESS 6.0)
add_definitions ("-Wno-error=misleading-indentation")
endif ()
endif ()
# Microsoft specific options
if (MSVC)
add_definitions (/W1)
# Microsoft specific options
string (REGEX REPLACE "/W[1-4]" "/W1" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
add_definitions (-D_CRT_SECURE_NO_DEPRECATE)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
add_definitions (-D_CRT_NONSTDC_NO_WARNINGS)
@@ -161,40 +211,100 @@ if (MSVC)
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 ()
# Remember the -std flags we need will be used later for custom Cuda builds
set (CSTD_FLAGS "")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_INTEL)
set (CSTD_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
endif ()
# We will use this for ccache and timing
set (MY_RULE_LAUNCH "")
###########################################################################
# 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_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
set (MY_RULE_LAUNCH ccache)
endif ()
endif ()
set (CSTD_FLAGS "")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_INTEL)
if (USE_CPP VERSION_GREATER 11)
message (STATUS "Building for C++14")
set (CSTD_FLAGS "-std=c++14")
else ()
message (STATUS "Building for C++11")
set (CSTD_FLAGS "-std=c++11")
endif ()
add_definitions (${CSTD_FLAGS})
if (CMAKE_COMPILER_IS_CLANG)
# C++ >= 11 doesn't like 'register' keyword, which is in Qt headers
add_definitions ("-Wno-deprecated-register")
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 ()
# SIMD and machine architecture options
###########################################################################
# 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}")
@@ -216,132 +326,292 @@ if (NOT USE_SIMD STREQUAL "")
# 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_definitions ("-ffp-contract=off")
add_compile_options ("-ffp-contract=off")
endif ()
endforeach()
endif ()
add_definitions (${SIMD_COMPILE_FLAGS})
add_compile_options (${SIMD_COMPILE_FLAGS})
endif ()
if (USE_fPIC)
add_definitions ("-fPIC")
###########################################################################
# Batched SIMD shader execution options.
#
# The USE_BATCHED option may be set to indicate that support for batched
# SIMD shader execution be compiled along with targe specific libraries
set (USE_BATCHED "" CACHE STRING "Build batched SIMD shader execution for (0, b8_AVX, b8_AVX2, b8_AVX2_noFMA, b8_AVX512, b8_AVX512_noFMA, b16_AVX512, b16_AVX512_noFMA)")
option (VEC_REPORT "Enable compiler's reporting system for vectorization" OFF)
set (BATCHED_SUPPORT_DEFINES "")
set (BATCHED_TARGET_LIBS "")
set (BUILD_BATCHED False)
if (NOT USE_BATCHED STREQUAL "")
message (STATUS "Compiling with batched SIMD targets ${USE_BATCHED}")
if (NOT USE_BATCHED STREQUAL "0")
set (BUILD_BATCHED 1)
string (REPLACE "," ";" BATCHED_TARGET_LIST ${USE_BATCHED})
foreach (batched_target ${BATCHED_TARGET_LIST})
if (VERBOSE)
message (STATUS "BATCHED target: ${batched_target}")
endif ()
list (APPEND BATCHED_SUPPORT_DEFINES "__OSL_SUPPORTS_${batched_target}")
endforeach()
else ()
message (STATUS "Compiling with NO batched SIMD targets, USE_BATCHED=0")
endif ()
else ()
message (STATUS "Compiling with NO batched SIMD targets, USE_BATCHED is empty")
endif ()
# Test for features
###########################################################################
# Preparation to test for compiler/language features
if (NOT VERBOSE)
set (CMAKE_REQUIRED_QUIET 1)
endif ()
include (CMakePushCheckState)
include (CheckCXXSourceRuns)
cmake_push_check_state ()
set (CMAKE_REQUIRED_DEFINITIONS ${CSTD_FLAGS})
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)
if (USE_STD_REGEX)
add_definitions (-DUSE_STD_REGEX)
else ()
add_definitions (-DUSE_BOOST_REGEX)
endif ()
cmake_pop_check_state ()
###########################################################################
# 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_definitions ("-ftest-coverage -fprofile-arcs -O0 -D${PROJECT_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")
add_compile_options (-ftest-coverage -fprofile-arcs)
add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1")
link_libraries(gcov)
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_definitions (-fsanitize=${feature})
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${feature}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=${feature}")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${feature}")
add_compile_options (-fsanitize=${feature})
add_link_options (-fsanitize=${feature})
endforeach()
add_definitions (-g -fno-omit-frame-pointer)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (SANITIZE_ON_LINUX 1)
add_compile_options (-g -fno-omit-frame-pointer)
if (CMAKE_COMPILER_IS_GNUCC)
# turn on glibcxx extra annotations to find vector writes past end
add_definitions ("-D_GLIBCXX_SANITIZE_VECTOR=1")
endif ()
if (CMAKE_COMPILER_IS_GNUCC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions ("-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")
# set (SANITIZE_LIBRARIES "asan" "ubsan")
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)
set (CMAKE_CXX_CLANG_TIDY "clang-tidy;-header-filter=(${PROJECT_NAME})|(${PROJ_NAME})|(${PROJ_NAME_LOWER})|(_pvt.h)")
if (CLANG_TIDY_ARGS)
set (CMAKE_CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY};${CLANG_TIDY_ARGS}")
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 ()
if (CLANG_TIDY_FIX)
set (CMAKE_CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY};-fix")
endif ()
set (CMAKE_CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY};-checks=${CLANG_TIDY_CHECKS}")
message (STATUS "clang-tidy command line is: ${CMAKE_CXX_CLANG_TIDY}")
# 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/*.cpp" "src/*.h" "src/*.cu"
CACHE STRING "Glob patterns to include for clang-format")
set (CLANG_FORMAT_EXCLUDES
# Files "imported and modified" that we don't want to reformat, so
# they continue to match their upstream versions.
"src/include/OSL/Imathx/*"
"src/include/OSL/matrix22.h"
# Header files in testsuite are almost certainly osl headers, not C++
"testsuite/*.h"
# Header files in shaders are OSL, not C++
"src/shaders/*.h"
CACHE STRING "Glob patterns to exclude for clang-format")
find_program (CLANG_FORMAT_EXE
NAMES clang-format bin/clang-format
HINTS ${CLANG_FORMAT_EXE_HINT} ENV CLANG_FORMAT_EXE_HINT
ENV LLVM_DIRECTORY
NO_DEFAULT_PATH
DOC "Path to clang-format executable")
find_program (CLANG_FORMAT_EXE NAMES clang-format bin/clang-format)
if (CLANG_FORMAT_EXE)
message (STATUS "clang-format found: ${CLANG_FORMAT_EXE}")
# Start with the list of files to include when formatting...
file (GLOB_RECURSE FILES_TO_FORMAT ${CLANG_FORMAT_INCLUDES})
# ... then process any list of excludes we are given
foreach (_pat ${CLANG_FORMAT_EXCLUDES})
file (GLOB_RECURSE _excl ${_pat})
list (REMOVE_ITEM FILES_TO_FORMAT ${_excl})
endforeach ()
# message (STATUS "clang-format file list: ${FILES_TO_FORMAT}")
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target (clang-format
COMMAND "${CLANG_FORMAT_EXE}" -i -style=file ${FILES_TO_FORMAT} )
else ()
message (STATUS "clang-format not found.")
endif ()
endif ()
###########################################################################
# 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_definitions ("${EXTRA_CPP_ARGS}")
add_compile_options ("${EXTRA_CPP_ARGS}")
endif()
set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when building DSOs")
if (BUILDSTATIC)
message (STATUS "Building static libraries")
set (LIBRARY_BUILD_TYPE STATIC)
add_definitions(-D${PROJECT_NAME}_STATIC_BUILD=1)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# On Linux, the lack of -fPIC when building static libraries seems
# incompatible with the dynamic library needed for the Python bindings.
set (USE_PYTHON OFF)
set (USE_PYTHON3 OFF)
endif ()
###########################################################################
# 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 ()
set (LIBRARY_BUILD_TYPE SHARED)
endif()
# 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 ()
# Use .a files if LINKSTATIC is enabled
###########################################################################
# 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")
#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 ()
add_definitions (-DBoost_USE_STATIC_LIBS=1)
set (Boost_USE_STATIC_LIBS 1)
else ()
if (MSVC)
add_definitions (-DBOOST_ALL_DYN_LINK)
add_definitions (-DOPENEXR_DLL)
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 ()
if (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR} OR DEFINED ENV{CI})
add_definitions ("-D${PROJECT_NAME}_CI=1" "-DBUILD_CI=1")
if (WIN32)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
###########################################################################
# 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()
+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 ($OSL_EXTRA_NVCC_ARGS "" CACHE STRING "Custom args passed to nvcc when compiling CUDA code")
# Compile a CUDA file to PTX using NVCC
function ( NVCC_COMPILE cuda_src extra_headers ptx_generated extra_nvcc_args )
get_filename_component ( cuda_src_we ${cuda_src} NAME_WE )
get_filename_component ( cuda_src_dir ${cuda_src} DIRECTORY )
set (cuda_ptx "${CMAKE_CURRENT_BINARY_DIR}/${cuda_src_we}.ptx" )
set (${ptxlist} ${${ptxlist}} ${cuda_ptx} )
set (${ptx_generated} ${cuda_ptx} PARENT_SCOPE)
file ( GLOB cuda_headers "${cuda_src_dir}/*.h" )
list (APPEND cuda_headers ${extra_headers})
list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
list (TRANSFORM OPENEXR_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OPENEXR_INCLUDES)
list (TRANSFORM OpenImageIO_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OpenImageIO_INCLUDES)
if (${LLVM_VERSION} VERSION_GREATER_EQUAL 15.0)
# Until we fully support opaque pointers, we need to disable
# them when using LLVM 15.
list (APPEND LLVM_COMPILE_FLAGS -Xclang -no-opaque-pointers)
endif ()
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++14 -dc -O3 --use_fast_math --expt-relaxed-constexpr
${extra_nvcc_args}
${OSL_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 (NOT LLVM_AS_TOOL)
find_program (LLVM_AS_TOOL NAMES "llvm-as"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_LINK_TOOL)
find_program (LLVM_LINK_TOOL NAMES "llvm-link"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (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} ${CLANG_MSVC_FIX}
-D__CUDACC__ -DOSL_COMPILING_TO_BITCODE=1 -DNDEBUG -DOIIO_NO_SSE -D__CUDADEVRT_INTERNAL__
--language=cuda --cuda-device-only --cuda-gpu-arch=${CUDA_TARGET_ARCH}
-Wno-deprecated-register -Wno-format-security
-O3 -fno-math-errno -ffast-math -S -emit-llvm ${extra_clang_args}
${src} -o ${asm_cuda}
COMMAND ${LLVM_AS_TOOL} -f -o ${bc_cuda} ${asm_cuda}
DEPENDS ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
# 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_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
MAIN_DEPENDENCY ${llvm_src}
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
+190 -149
View File
@@ -1,71 +1,122 @@
# 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 (Curses_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_string (SPECIAL_COMPILE_FLAGS ""
"Custom compilation flags")
if (SPECIAL_COMPILE_FLAGS)
add_definitions (${SPECIAL_COMPILE_FLAGS})
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}")
include (ExternalProject)
option (BUILD_MISSING_DEPS "Try to download and build any missing dependencies" OFF)
###########################################################################
# IlmBase setup
find_package (OpenEXR 2.0 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)
message (FATAL_ERROR "OpenEXR/Ilmbase is too old")
# Boost setup
if (LINKSTATIC)
set (Boost_USE_STATIC_LIBS ON)
else ()
if (MSVC)
add_definitions (-DBOOST_ALL_DYN_LINK=1)
endif ()
endif ()
if (NOT OpenEXR_FIND_QUIETLY)
message (STATUS "OPENEXR_INCLUDE_DIR = ${OPENEXR_INCLUDE_DIR}")
message (STATUS "OPENEXR_LIBRARIES = ${OPENEXR_LIBRARIES}")
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 system thread)
# 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 ()
# end IlmBase setup
# On Linux, Boost 1.55 and higher seems to need to link against -lrt
if (CMAKE_SYSTEM_NAME MATCHES "Linux"
AND ${Boost_VERSION} VERSION_GREATER_EQUAL 105500)
list (APPEND Boost_LIBRARIES "rt")
endif ()
include_directories (SYSTEM "${Boost_INCLUDE_DIRS}")
link_directories ("${Boost_LIBRARY_DIRS}")
# end Boost setup
###########################################################################
###########################################################################
checked_find_package (ZLIB REQUIRED) # Needed by several packages
# IlmBase & OpenEXR
checked_find_package (OpenEXR REQUIRED
VERSION_MIN 2.3
RECOMMEND_MIN 2.4
RECOMMEND_MIN_REASON
"Even extremely critical patches are no longer supplied to < 2.4"
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 shouldn't be necessary, except for the common case of people
# building against Imath/OpenEXR 3.x when there is still a system-level
# install version of 2.x.
include_directories(BEFORE ${IMATH_INCLUDES})
if (MSVC AND NOT LINKSTATIC)
add_definitions (-DOPENEXR_DLL) # Is this needed for new versions?
endif ()
if (OPENEXR_VERSION VERSION_GREATER_EQUAL 2.5.99)
set (OSL_USING_IMATH 3)
else ()
set (OSL_USING_IMATH 2)
endif ()
# OpenImageIO
checked_find_package (OpenImageIO REQUIRED
VERSION_MIN 2.3.17
DEFINITIONS -DOIIO_HIDE_FORMAT=1)
find_package (OpenImageIO 1.7 REQUIRED)
include_directories ("${OPENIMAGEIO_INCLUDE_DIR}")
link_directories ("${OPENIMAGEIO_LIBRARY_DIRS}")
message (STATUS "Using OpenImageIO ${OPENIMAGEIO_VERSION}")
# end OpenImageIO setup
###########################################################################
checked_find_package (pugixml REQUIRED
VERSION_MIN 1.8)
###########################################################################
# LLVM library setup
find_package (LLVM 3.5 REQUIRED)
checked_find_package (LLVM REQUIRED
VERSION_MIN 9.0
VERSION_MAX 15.9
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}")
@@ -77,124 +128,114 @@ add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}")
if (LLVM_NAMESPACE)
add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}")
endif ()
# end LLVM library setup
###########################################################################
###########################################################################
# Boost setup
if (NOT Boost_FIND_QUIETLY)
message (STATUS "BOOST_ROOT ${BOOST_ROOT}")
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 upgrading to a newer LLVM: \n"
" brew upgrade llvm \n"
"${ColorReset}\n")
endif ()
if (NOT DEFINED Boost_ADDITIONAL_VERSIONS)
set (Boost_ADDITIONAL_VERSIONS "1.63" "1.62" "1.61" "1.60"
"1.59" "1.58" "1.57" "1.56" "1.55")
if (LLVM_VERSION VERSION_GREATER_EQUAL 15.0
AND ( (CMAKE_COMPILER_IS_APPLECLANG AND APPLECLANG_VERSION_STRING VERSION_LESS 15.0)
OR (CMAKE_COMPILER_IS_CLANG AND CLANG_VERSION_STRING VERSION_LESS 15.0)))
message (WARNING
"${ColorYellow}"
"If you are using LLVM 15 or higher, you should also use clang version "
"15 or higher, or you may get build errors.${ColorReset}\n")
endif ()
if (LINKSTATIC)
set (Boost_USE_STATIC_LIBS ON)
endif ()
set (Boost_USE_MULTITHREADED ON)
set (Boost_COMPONENTS system thread)
if (NOT USE_STD_REGEX)
list (APPEND Boost_COMPONENTS regex)
endif ()
if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG OR
${LLVM_VERSION} VERSION_LESS 3.6)
set (_CLANG_PREPROCESSOR_CAN_WORK ON)
endif ()
if (GCC_VERSION)
if (${GCC_VERSION} VERSION_LESS 4.9)
set (_CLANG_PREPROCESSOR_CAN_WORK ON)
if (LLVM_VERSION VERSION_GREATER_EQUAL 16.0)
message (ERROR "${ColorYellow}OSL is not yet compatible with LLVM 16.${ColorReset}\n")
if (CMAKE_CXX_STANDARD VERSION_LESS 17)
message (WARNING "${ColorYellow}LLVM 16+ requires C++17 or higher. "
"Please set CMAKE_CXX_STANDARD to 17 or higher.${ColorReset}\n")
endif ()
if (CMAKE_COMPILER_IS_GNUCC AND (GCC_VERSION VERSION_LESS 7.0))
message (WARNING "${ColorYellow}LLVM 16+ requires gcc 7.0 or higher.${ColorReset}\n")
endif ()
if (CMAKE_COMPILER_IS_CLANG AND (CLANG_VERSION_STRING VERSION_LESS 5.0))
message (WARNING "${ColorYellow}LLVM 16+ requires clang 5.0 or higher.${ColorReset}\n")
endif ()
endif ()
if (${LLVM_VERSION} VERSION_LESS 3.9)
# Bug in old LLVM creates some linkage problems we've seen involving
# some singleton globals that are duplicated when we include both
# the clang libs we need for the preprocessing as well as certain
# LLVM support libraries we also need, triggering assertions.
# See this for description of the issue:
# http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140203/203968.html
# Sweep under the rug by falling back to boost wave when using older
# LLVM (it seems fixed and no longer triggers for 3.9+).
set (_CLANG_PREPROCESSOR_CAN_WORK OFF)
checked_find_package (partio)
# From pythonutils.cmake
find_python ()
# Qt -- used for osltoy
set (qt5_modules Core Gui Widgets)
if (OPENGL_FOUND)
list (APPEND qt5_modules OpenGL)
endif ()
if (USE_BOOST_WAVE OR (NOT CLANG_LIBRARIES)
OR (NOT _CLANG_PREPROCESSOR_CAN_WORK))
# N.B. Using clang for preprocessing seems to work when using clang,
# or gcc 4.8.x, or LLVM <= 3.5. When those conditions aren't met,
# fall back on Boost Wave. We'll lift this restriction as soon as we
# fix whatever is broken.
list (APPEND Boost_COMPONENTS filesystem wave)
add_definitions (-DUSE_BOOST_WAVE=1)
message (STATUS "Using Boost Wave for preprocessing")
else ()
message (STATUS "Using clang internals for preprocessing")
endif ()
if (BOOST_CUSTOM)
set (Boost_FOUND true)
else ()
find_package (Boost 1.55 REQUIRED
COMPONENTS ${Boost_COMPONENTS})
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 ()
# 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 ()
# 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)
list (APPEND Boost_LIBRARIES "rt")
endif ()
# CUDA setup
if (USE_CUDA OR USE_OPTIX)
if (USE_LLVM_BITCODE)
if (NOT CUDA_TOOLKIT_ROOT_DIR AND NOT $ENV{CUDA_TOOLKIT_ROOT_DIR} STREQUAL "")
set (CUDA_TOOLKIT_ROOT_DIR $ENV{CUDA_TOOLKIT_ROOT_DIR})
endif ()
if (NOT 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 ()
if (NOT CUDA_FIND_QUIETLY OR NOT OptiX_FIND_QUIETLY)
message (STATUS "CUDA_TOOLKIT_ROOT_DIR = ${CUDA_TOOLKIT_ROOT_DIR}")
endif ()
include_directories (SYSTEM "${Boost_INCLUDE_DIRS}")
link_directories ("${Boost_LIBRARY_DIRS}")
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}")
# end Boost setup
###########################################################################
STRING (FIND ${LLVM_TARGETS} "NVPTX" nvptx_index)
if (NOT ${nvptx_index} GREATER -1)
message (FATAL_ERROR "NVPTX target is not available in the provided LLVM build")
endif()
set (CUDA_LIB_FLAGS "--cuda-path=${CUDA_TOOLKIT_ROOT_DIR}")
###########################################################################
# Partio
find_library(cuda_lib NAMES cudart
PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"
REQUIRED)
set(CUDA_LIBRARIES ${cuda_lib})
find_package (ZLIB)
if (USE_PARTIO)
find_package (Partio)
if (PARTIO_FOUND)
add_definitions ("-DUSE_PARTIO=1")
include_directories ("${PARTIO_INCLUDE_DIR}")
else ()
add_definitions ("-DUSE_PARTIO=0")
# testrender & testshade need libnvrtc
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "10.0")
find_library(nvrtc_lib NAMES nvrtc
PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"
REQUIRED)
set(CUDA_LIBRARIES ${CUDA_LIBRARIES} ${nvrtc_lib})
set(CUDA_EXTRA_LIBS ${CUDA_EXTRA_LIBS} dl)
endif()
endif()
# OptiX setup
if (USE_OPTIX AND OSL_BUILD_TESTS)
checked_find_package (OptiX REQUIRED
VERSION_MIN 7.0)
include_directories (BEFORE "${OPTIX_INCLUDES}")
if (NOT USE_LLVM_BITCODE OR NOT USE_FAST_MATH)
message (FATAL_ERROR "Enabling OptiX requires USE_LLVM_BITCODE=1 and USE_FAST_MATH=1")
endif ()
endif ()
endif (USE_PARTIO)
# end Partio setup
###########################################################################
###########################################################################
# 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}")
add_definitions ("-DUSE_EXTERNAL_PUGIXML")
endif()
# end Pugixml setup
###########################################################################
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 ()
function (osl_optix_target TARGET)
endfunction()
endif ()
+61
View File
@@ -0,0 +1,61 @@
# 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).
#
# If -DENABLE_INSTALL_<executable>=OFF was specified, the target will be built
# (in the build area) but will not be installed.
#
# Usage:
#
# fancy_add_executable ([ NAME targetname ... ]
# [ 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")
check_is_enabled (INSTALL_${_target_NAME} _target_NAME_INSTALL_enabled)
if (_target_NAME_INSTALL_enabled)
install_targets (${_target_NAME})
endif ()
else ()
message (STATUS "${ColorRed}Disabling ${_target_NAME} ${ColorReset}")
endif ()
endmacro ()
+49 -54
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,64 @@
# 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)
# On Mac, prefer the Homebrew version of Bison over the older version from
# MacOS/xcode in /usr/bin, which seems to be too old for the reentrant
# parser directives we use. Only do this if there is no BISON_ROOT
# specifying a particular Bison to use.
if (APPLE AND EXISTS /usr/local/opt
AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT})
find_program(BISON_EXECUTABLE NAMES /usr/local/opt/bison/bin/bison
DOC "path to the bison executable")
endif()
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)
checked_find_package (BISON 2.7 REQUIRED
PRINT BISON_EXECUTABLE)
checked_find_package (FLEX 2.3.35 REQUIRED
PRINT FLEX_EXECUTABLE)
if ( FLEX_EXECUTABLE AND BISON_EXECUTABLE )
macro ( FLEX_BISON flexsrc bisonsrc prefix srclist compiler_headers )
# mangle osoparse & oslparse symbols to avoid multiple library conflicts
# XXX: This may be excessive now that OSL::pvt::ExtraArg is mangled into the function signature
add_definitions(-D${prefix}parse=${PROJ_NAMESPACE_V}_${prefix}parse)
IF ( 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} --prefix=${prefix} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
MAIN_DEPENDENCY ${flexsrc}
DEPENDS ${${compiler_headers}}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
ENDMACRO ()
ENDIF ()
endmacro ()
endif ()
-34
View File
@@ -1,34 +0,0 @@
###########################################################################
# Fonts are not available yet.
option (INSTALL_DOCS "Install documentation" ON)
option (INSTALL_FONTS "Install default fonts" OFF)
###########################################################################
# 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 ()
# the RPATH to be used when installing
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
# 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)
+143
View File
@@ -0,0 +1,143 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
function ( EMBED_LLVM_BITCODE_IN_CPP src_list suffix output_name list_to_append_cpp extra_clang_args)
if (VERBOSE)
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP src_list=${src_list}")
endif ()
foreach ( src ${src_list} )
get_filename_component ( src_we ${src} NAME_WE )
set ( src_asm "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.s" )
set ( src_bc "${CMAKE_CURRENT_BINARY_DIR}/${src_we}${suffix}.bc" )
if (VERBOSE)
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP in=${src}")
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP asm=${src_asm}")
message (STATUS "EMBED_LLVM_BITCODE_IN_CPP bc=${src_bc}")
endif ()
list ( APPEND src_bc_list ${src_bc} )
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} ${TOOLCHAIN_FLAGS})
# Avoid generating __dso_handle external global
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-fno-use-cxa-atexit")
# Figure out what program we will use to make the bitcode.
if (NOT LLVM_BC_GENERATOR)
find_program (LLVM_BC_GENERATOR NAMES "clang++"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_BC_GENERATOR)
message (FATAL_ERROR "You must have a valid llvm bitcode generator (clang++) somewhere.")
endif ()
if (VERBOSE)
message (STATUS "Using LLVM_BC_GENERATOR ${LLVM_BC_GENERATOR} to generate bitcode.")
endif()
if (NOT LLVM_AS_TOOL)
find_program (LLVM_AS_TOOL NAMES "llvm-as"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
if (NOT LLVM_LINK_TOOL)
find_program (LLVM_LINK_TOOL NAMES "llvm-link"
PATHS "${LLVM_DIRECTORY}/bin" "${LLVM_DIRECTORY}/tools/llvm"
NO_CMAKE_PATH NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_ENVIRONMENT_PATH)
endif ()
# Fix specific problem I had on new Apple systems (e.g. Mavericks) with
# LLVM/libc++ installed -- for some reason, LLVM 3.4 wasn't finding it,
# so in that specific case, append another -I to point it in the right
# direction.
#if (APPLE AND ${LLVM_BC_GENERATOR} MATCHES ".*clang.*")
# exec_program ( "${LLVM_BC_GENERATOR}" ARGS --version OUTPUT_VARIABLE MY_CLANG_VERSION )
# string (REGEX REPLACE "clang version ([0-9][.][0-9]+).*" "\\1" MY_CLANG_VERSION "${MY_CLANG_VERSION}")
# if ((${MY_CLANG_VERSION} VERSION_GREATER "3.3")
# AND (EXISTS "/usr/lib/libc++.dylib")
# AND (EXISTS "/Library/Developer/CommandLineTools/usr/lib/c++/v1"))
# set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-I/Library/Developer/CommandLineTools/usr/lib/c++/v1")
# endif ()
#endif ()
list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
list (TRANSFORM OPENEXR_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OPENEXR_INCLUDES)
list (TRANSFORM OpenImageIO_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_OpenImageIO_INCLUDES)
if (${LLVM_VERSION} VERSION_GREATER_EQUAL 15.0)
# Until we fully support opaque pointers, we need to disable
# them when using LLVM 15.
list (APPEND LLVM_COMPILE_FLAGS -Xclang -no-opaque-pointers)
endif ()
# Command to turn the .cpp file into LLVM assembly language .s, into
# LLVM bitcode .bc, then back into a C++ file with the bc embedded!
add_custom_command ( OUTPUT ${src_bc}
COMMAND ${LLVM_BC_GENERATOR}
${LLVM_COMPILE_FLAGS}
"-I${CMAKE_CURRENT_SOURCE_DIR}"
"-I${CMAKE_SOURCE_DIR}/src/include"
"-I${CMAKE_BINARY_DIR}/include"
${ALL_OpenImageIO_INCLUDES}
${ALL_IMATH_INCLUDES}
#"-isystem ${Boost_INCLUDE_DIRS}" #Does not pick up usr installed boost/thread/tss.hpp for oslexec_pvt.h
"-I${Boost_INCLUDE_DIRS}"
-DOSL_COMPILING_TO_BITCODE=1
-Wno-deprecated-register
# the following 2 warnings can be restored when all 3rd parties have fixed their export macros
# (dllimport attribute is not supported when compiling for Cuda and triggers a ton of warnings)
-Wno-ignored-attributes -Wno-unknown-attributes
-O3 -fno-math-errno -S -emit-llvm ${extra_clang_args}
-o ${src_asm} ${src}
COMMAND ${LLVM_AS_TOOL} -f -o ${src_bc} ${src_asm}
# Do NOT setup a MAIN_DEPENDENCY because only 1 may exist
# and we may have the several outputs dependent on the same source
DEPENDS ${src} ${exec_headers} ${PROJECT_PUBLIC_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endforeach ()
if (VERBOSE)
message ( STATUS "^^^^^^^^^^^^^^^^^^^^^^^^^^" )
message ( STATUS "src_bc_list: ${src_bc_list} ")
message ( STATUS "^^^^^^^^^^^^^^^^^^^^^^^^^^" )
endif()
# Link all of the individual LLVM bitcode files
set ( linked_src_bc "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.bc" )
add_custom_command ( OUTPUT ${linked_src_bc}
COMMAND ${LLVM_LINK_TOOL} -internalize ${src_bc_list} -o ${linked_src_bc}
DEPENDS ${src_bc_list} ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src_list}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
# Serialize the linked bitcode into a CPP file
set ( src_bc_cpp "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.bc.cpp" )
add_custom_command ( OUTPUT ${src_bc_cpp}
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py"
${linked_src_bc} ${src_bc_cpp} ${output_name}
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${linked_src_bc}
${exec_headers} ${PROJECT_PUBLIC_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
# add generated .cpp with embedded bitcode to the list of sources
set ( ${list_to_append_cpp} ${${list_to_append_cpp}} ${src_bc_cpp} PARENT_SCOPE )
endfunction ( )
+71 -33
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
# Module to find LLVM
#
# This module defines the following variables:
@@ -8,6 +12,7 @@
# 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)
#
@@ -18,16 +23,24 @@
# try to find llvm-config, with a specific version if specified
if (LLVM_DIRECTORY)
set (LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
list (APPEND LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
endif ()
if (LLVM_ROOT)
list (APPEND LLVM_CONFIG_PATH_HINTS "${LLVM_ROOT}/bin")
endif ()
if (DEFINED ENV{LLVM_ROOT})
list (APPEND LLVM_CONFIG_PATH_HINTS "$ENV{LLVM_ROOT}/bin")
endif ()
list (APPEND LLVM_CONFIG_PATH_HINTS
"/usr/local/opt/llvm/${LLVM_VERSION}/bin/"
"/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}'")
@@ -48,18 +61,39 @@ execute_process (COMMAND ${LLVM_CONFIG} --libdir
execute_process (COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT ${LLVM_VERSION} VERSION_LESS 3.8)
execute_process (COMMAND ${LLVM_CONFIG} --system-libs
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 ()
# Older LLVM did not have llvm-config --system-libs, but we know that
# on Linux, we'll need curses.
find_package (Curses)
if (CURSES_FOUND)
list (APPEND LLVM_SYSTEM_LIBRARIES ${CURSES_LIBRARIES})
endif ()
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
@@ -68,10 +102,32 @@ 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)
clangEdit clangLex clangSupport)
find_library ( _CLANG_${COMPONENT}_LIBRARY
NAMES ${COMPONENT}
PATHS ${LLVM_LIB_DIR})
@@ -81,23 +137,19 @@ foreach (COMPONENT clangFrontend clangDriver clangSerialization
endforeach ()
# if (NOT LLVM_LIBRARY)
# execute_process (COMMAND ${LLVM_CONFIG} --libfiles engine
# OUTPUT_VARIABLE LLVM_LIBRARIES
# OUTPUT_STRIP_TRAILING_WHITESPACE)
# endif ()
# shared llvm library may not be available, this is not an error if we use LLVM_STATIC.
if ((LLVM_LIBRARY OR LLVM_LIBRARIES OR LLVM_STATIC) AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
if (LLVM_STATIC)
# 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
execute_process (COMMAND ${LLVM_CONFIG} --libfiles --link-static
OUTPUT_VARIABLE LLVM_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
string (REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
set (LLVM_LIBRARY "")
if (LLVM_LIBRARIES)
string (REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
set (LLVM_LIBRARY "")
endif ()
else ()
set (LLVM_LIBRARIES "${LLVM_LIBRARY}")
endif ()
@@ -111,17 +163,3 @@ find_package_handle_standard_args (LLVM
LLVM_LIBRARIES
VERSION_VAR LLVM_VERSION
)
if (LLVM_FOUND)
message (STATUS "LLVM version = ${LLVM_VERSION}")
if (NOT LLVM_FIND_QUIETLY)
message (STATUS "LLVM dir = ${LLVM_DIRECTORY}")
message (STATUS "LLVM includes = ${LLVM_INCLUDES}")
message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
message (STATUS "LLVM libraries = ${LLVM_LIBRARIES}")
message (STATUS "LLVM sys libs = ${LLVM_SYSTEM_LIBRARIES}")
message (STATUS "Clang libraries = ${CLANG_LIBRARIES}")
endif ()
else()
message (STATUS "LLVM not found. Specify LLVM_DIRECTORY to locate it.")
endif()
+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 ()
-82
View File
@@ -1,82 +0,0 @@
###########################################################################
# CMake module to find OpenImageIO
#
# This module will set
# OPENIMAGEIO_FOUND True, if found
# OPENIMAGEIO_INCLUDE_DIR directory where headers are found
# OPENIMAGEIO_LIBRARIES libraries for OIIO
# OPENIMAGEIO_LIBRARY_DIRS library dirs for OIIO
# OPENIMAGEIO_VERSION Version ("major.minor.patch")
# OPENIMAGEIO_VERSION_MAJOR Version major number
# OPENIMAGEIO_VERSION_MINOR Version minor number
# OPENIMAGEIO_VERSION_PATCH Version minor patch
#
# Special inputs:
# OPENIMAGEIOHOME - custom "prefix" location of OIIO installation
# (expecting bin, lib, include subdirectories)
#
# If 'OPENIMAGEHOME' not set, use the env variable of that name if available
if (NOT OPENIMAGEIOHOME AND NOT $ENV{OPENIMAGEIOHOME} STREQUAL "")
set (OPENIMAGEIOHOME $ENV{OPENIMAGEIOHOME})
endif ()
if (NOT OpenImageIO_FIND_QUIETLY)
message ( STATUS "OPENIMAGEIOHOME = ${OPENIMAGEIOHOME}" )
endif ()
find_library ( OPENIMAGEIO_LIBRARY
NAMES OpenImageIO
HINTS ${OPENIMAGEIOHOME}/lib
PATH_SUFFIXES lib64 lib
PATHS "${OPENIMAGEIOHOME}/lib" )
find_path ( OPENIMAGEIO_INCLUDE_DIR
NAMES OpenImageIO/imageio.h
HINTS ${OPENIMAGEIOHOME}/include
PATH_SUFFIXES include )
find_program ( OPENIMAGEIO_BIN
NAMES oiiotool
HINTS ${OPENIMAGEIOHOME}/bin
PATH_SUFFIXES bin )
# 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})
set (OPENIMAGEIO_VERSION "${OPENIMAGEIO_VERSION_MAJOR}.${OPENIMAGEIO_VERSION_MINOR}.${OPENIMAGEIO_VERSION_PATCH}")
endif ()
set ( OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
get_filename_component (OPENIMAGEIO_LIBRARY_DIRS "${OPENIMAGEIO_LIBRARY}" DIRECTORY CACHE)
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 bin = ${OPENIMAGEIO_BIN}" )
endif ()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (OpenImageIO
FOUND_VAR OPENIMAGEIO_FOUND
REQUIRED_VARS OPENIMAGEIO_INCLUDE_DIR OPENIMAGEIO_LIBRARIES
OPENIMAGEIO_LIBRARY_DIRS OPENIMAGEIO_VERSION
VERSION_VAR OPENIMAGEIO_VERSION
)
mark_as_advanced (
OPENIMAGEIO_INCLUDE_DIR
OPENIMAGEIO_LIBRARIES
OPENIMAGEIO_LIBRARY_DIRS
OPENIMAGEIO_VERSION
OPENIMAGEIO_VERSION_MAJOR
OPENIMAGEIO_VERSION_MINOR
OPENIMAGEIO_VERSION_PATCH
)
+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 ()
-36
View File
@@ -1,36 +0,0 @@
# 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.
find_library (PARTIO_LIBRARY
NAMES partio
PATHS "${PARTIO_HOME}/lib" "$ENV{PARTIO_HOME}/lib"
NO_DEFAULT_PATH)
find_library (PARTIO_LIBRARY NAMES partio)
find_path (PARTIO_INCLUDE_DIR
NAMES Partio.h
PATHS "${PARTIO_HOME}/include" "$ENV{PARTIO_HOME}/include"
NO_DEFAULT_PATH)
find_path (PARTIO_INCLUDE_DIR NAMES Partio.h)
# 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_LIBRARIES ${PARTIO_LIBRARY})
if (NOT Partio_FIND_QUIETLY)
message (STATUS "Partio include = ${PARTIO_INCLUDE_DIR}")
message (STATUS "Partio libraries = ${PARTIO_LIBRARIES}")
endif ()
else ()
message (STATUS "No Partio found")
endif()
mark_as_advanced (PARTIO_LIBRARIES PARTIO_INCLUDE_DIR)
-35
View File
@@ -1,35 +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
/usr/local/include
/usr/local/include/pugixml-1.8)
find_library (PUGIXML_LIBRARY
NAMES pugixml
PATHS ${PUGIXML_HOME}/lib
/usr/local/lib
/usr/local/lib/pugixml-1.8)
# 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! prefer a config if it can be found
find_package(partio CONFIG)
if (PARTIO_FOUND OR partio_FOUND)
if (VERBOSE)
message (STATUS "partio found via config")
endif ()
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()
+34
View File
@@ -0,0 +1,34 @@
# Copyright Contributors to the Open Shading Language 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" AND NOT ${CMAKE_COMPILER_ID} STREQUAL "Intel")
# Seems to be a problem on some systems, with pybind11 and python headers
set_property (SOURCE ${lib_SOURCES} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-macro-redefined ")
endif ()
# 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})
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 ()
+406
View File
@@ -0,0 +1,406 @@
# Copyright Contributors to the Open Shading Language 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" )
set (OSL_TEST_BIG_TIMEOUT 800 CACHE STRING "Timeout for tests that take a long time")
# add_one_testsuite() - set up one testsuite entry
#
# Usage:
# 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}")
file (MAKE_DIRECTORY "${testdir}")
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}
)
# We need to suppress the leak sanitizer for "texture" tests, because of a
# minor leak inside OIIO (140 bytes! -- inconsequential) but which we
# can't use the suppressions list becuase the leaks come from calls made
# inside JITed code for which there is not a good stack trace. Any real
# leaks from OIIO or its dependencies we assume will be caught by lsan on
# the OIIO side, where there is no JIT to complicate things.
if (${testname} MATCHES "^texture" OR ${testname} MATCHES "gettextureinfo")
list (APPEND _tst_ENV ASAN_OPTIONS=detect_leaks=0:$ENV{ASAN_OPTIONS})
endif ()
add_test ( NAME ${testname} COMMAND ${_tst_COMMAND} )
# message ("Test -- env ${_tst_ENV} cmd ${_tst_COMMAND}")
set_tests_properties (${testname} PROPERTIES ENVIRONMENT "${_tst_ENV}" )
# 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 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
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:$ENV{LD_LIBRARY_PATH})
endif()
endif ()
if (${testname} MATCHES "-reg")
# These are batched shading regression tests. Some are quite
# long, so give them a higher cost and timeout.
set_tests_properties (${testname} PROPERTIES LABELS batchregression
COST 15 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
endmacro ()
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})
set (test_all_batched $ENV{TESTSUITE_BATCHED})
set (test_all_rs_bitcode $ENV{TESTSUITE_RS_BITCODE})
# Add the tests if all is well.
set (ALL_TEST_LIST "")
set (_testsuite "${CMAKE_SOURCE_DIR}/testsuite")
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 "optix"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 )
endif ()
# Run the same test again with aggressive -O2 runtime
# optimization, triggered by setting TESTSHADE_OPT env variable.
# Skip OptiX-only tests and those with a NOOPTIMIZE marker file.
if (NOT _testname MATCHES "optix"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 )
endif ()
if (_testname MATCHES "render-" AND ${CMAKE_BUILD_TYPE} STREQUAL Debug)
set_tests_properties (${_testname} PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
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"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
# 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 ()
if (BUILD_BATCHED)
# When building for Batched support, also run it in Batched mode
# if there is an BATCHED marker file in the directory.
# If an environment variable $TESTSUITE_BATCHED is nonzero, then
# run all tests in Batched mode, even if there's no BATCHED marker.
if ((EXISTS "${_testsrcdir}/BATCHED" OR test_all_batched OR _testname MATCHES "batched")
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED-FIXME"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}.batched" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 TESTSHADE_BATCHED=1 )
endif ()
if ((EXISTS "${_testsrcdir}/BATCHED" OR test_all_batched OR _testname MATCHES "batched")
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED"
AND NOT EXISTS "${_testsrcdir}/NOBATCHED-FIXME"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.batched.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_BATCHED=1 )
endif ()
# When building for Batched support, optionally run a regression test
# if there is an BATCHED_REGRESSION marker file in the directory.
if ((EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
# optimized for right now
add_one_testsuite ("${_testname}.regress.batched.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 OSL_REGRESSION_TEST=BATCHED )
endif ()
if ((EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
AND EXISTS "${_testsrcdir}/NOOPTIMIZE")
# not optimized
add_one_testsuite ("${_testname}.regress.batched" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 OSL_REGRESSION_TEST=BATCHED )
endif ()
endif ()
# if there is an RS_BITCODE marker file in the directory.
if ((EXISTS "${_testsrcdir}/RS_BITCODE" OR test_all_rs_bitcode)
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/RS_BITCODE_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.rsbitcode.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 TESTSHADE_RS_BITCODE=1 )
endif ()
# if there is an RS_BITCODE_REGRESSION marker file in the directory.
if (EXISTS "${_testsrcdir}/RS_BITCODE_REGRESSION" OR (
test_all_rs_bitcode AND EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
# optimized for right now
add_one_testsuite ("${_testname}.regress.rsbitcode.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 OSL_REGRESSION_TEST=RS_BITCODE )
endif ()
endforeach ()
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 andor-reg and-or-not-synonyms
arithmetic area-reg arithmetic-reg
array array-reg array-copy-reg array-derivs array-range
array-aassign array-assign-reg array-length-reg
bitwise-and-reg bitwise-or-reg bitwise-shl-reg bitwise-shr-reg bitwise-xor-reg
blackbody blackbody-reg blendmath breakcont breakcont-reg
bug-array-heapoffsets bug-locallifetime bug-outputinit
bug-param-duplicate bug-peep bug-return
calculatenormal-reg
cellnoise closure closure-array closure-parameters closure-zero closure-conditional
color color-reg colorspace comparison
complement-reg compile-buffer compassign-reg
component-range
control-flow-reg connect-components
const-array-params const-array-fill
debugnan debug-uninit
derivs derivs-muldiv-clobber
draw_string
error-dupes error-serialized
example-deformer
example-batched-deformer
exit exponential
filterwidth-reg
for-reg format-reg fprintf
function-earlyreturn function-simple function-outputelem
function-overloads function-redef
geomath getattribute-camera getattribute-shader
getsymbol-nonheap gettextureinfo gettextureinfo-reg
globals-needed
group-outputs groupstring
hash hashnoise hex hyperb
ieee_fp ieee_fp-reg if if-reg incdec initlist
initops initops-instance-clash
intbits isconnected
isconstant
layers layers-Ciassign layers-entry layers-lazy layers-lazyerror
layers-nonlazycopy layers-repeatedoutputs
length-reg linearstep
logic loop luminance-reg
matrix matrix-reg matrix-arithmetic-reg
matrix-compref-reg max-reg message message-no-closure message-reg
mergeinstances-duplicate-entrylayers
mergeinstances-nouserdata mergeinstances-vararray
metadata-braces min-reg miscmath missing-shader
mix-reg
named-components
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
noise-gabor-reg
noise-generic
noise-perlin noise-simplex
noise-reg
normalize-reg
pnoise pnoise-cell pnoise-gabor
pnoise-generic pnoise-perlin
pnoise-reg
operator-overloading
opt-warnings
oslc-comma oslc-D oslc-M
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-type-as-variable
oslc-err-unknown-ctr
oslc-literalfold
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-reg
printf-whole-array
raytype raytype-reg raytype-specialized regex-reg reparam
render-background render-bumptest
render-cornell render-furnace-diffuse
render-mx-furnace-burley-diffuse
render-mx-furnace-oren-nayar
render-mx-furnace-sheen
render-mx-burley-diffuse
render-mx-dielectric render-mx-dielectric-glass
render-mx-conductor
render-mx-generalized-schlick render-mx-generalized-schlick-glass
render-mx-layer
render-mx-sheen
render-microfacet render-oren-nayar
render-uv render-veachmis render-ward
select select-reg shaderglobals shortcircuit
smoothstep-reg
spline spline-reg splineinverse splineinverse-ident
splineinverse-knots-ascend-reg splineinverse-knots-descend-reg
spline-boundarybug spline-derivbug
split-reg
string string-reg
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-environment texture-errormsg
texture-environment-opts-reg
texture-firstchannel texture-interp
texture-missingalpha texture-missingcolor texture-opts-reg texture-simple
texture-smallderivs texture-swirl texture-udim
texture-width texture-withderivs texture-wrap
trace-reg
trailing-commas
transcendental-reg
transitive-assign
transform transform-reg transformc transformc-reg trig trig-reg
typecast
unknown-instruction
userdata userdata-custom userdata-passthrough
vararray-connect vararray-default
vararray-deserialize vararray-param
vecctr vector vector-reg
wavelength_color wavelength_color-reg Werror xml xml-reg )
# Coordinate-aware gettextureinfo only works for TextureSystem >= 2.3.7
if (OpenImageIO_VERSION VERSION_GREATER_EQUAL 2.3.7)
TESTSUITE ( gettextureinfo-udim gettextureinfo-udim-reg )
endif ()
# Only run the ocio test if the OIIO we are using has OCIO support
if (OpenImageIO_HAS_OpenColorIO)
TESTSUITE ( ocio )
endif ()
# Add tests that require the Python bindings if we built them.
# We also exclude these tests if this is a sanitizer build, because the
# Python interpreter itself won't be linked with the right asan
# libraries to run correctly.
if (USE_PYTHON AND NOT SANITIZE)
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 texture3d-opts-reg )
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 ()
# Some regression tests have a lot of combinations and may need more time to finish
if (BUILD_BATCHED)
set_tests_properties (arithmetic-reg.regress.batched.opt
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
set_tests_properties (transform-reg.regress.batched.opt
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
set_tests_properties (matrix-reg.regress.rsbitcode.opt
PROPERTIES TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endmacro()

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