Compare commits

..
387 Commits
Author SHA1 Message Date
Larry Gritz f4db549061 runner
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 22:40:36 -07:00
Larry Gritz 4debd96adc Set up workflows to have subsequent PR pushes cancel previous in-progress jobs
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 22:30:58 -07:00
Larry Gritz 30a4a95b7e Experiment: use new big runner to speed up the expensive analysis run
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 22:18:46 -07:00
Larry Gritz a38aa58c0e typo
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 22:08:46 -07:00
Larry Gritz e126a20df7 Analysis build for avx512 as well for more code coverage
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 22:05:08 -07:00
Larry Gritz 52cf2ee418 Improve testing coverage
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.

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.

Remove deprecated version of LLVM_Util::make_function.

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 21:54:57 -07:00
Larry Gritz 83a1e7e74b WIP: improve coverage analysis
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.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-10 18:06:54 -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
2027 changed files with 214096 additions and 31039 deletions
+37
View File
@@ -6,3 +6,40 @@ 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
+132
View File
@@ -0,0 +1,132 @@
# 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-20.04-8c-32g-300h
# 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}}
PARALLEL: 24
# 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"
+405 -618
View File
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
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
jobs:
analysis:
name: Scorecards analysis
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
# Needs for private repositories.
contents: read
actions: read
steps:
- name: "Checkout code"
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@3e15ea8318eee9b333819ec77a36aca8d39df13e # v1.1.1
with:
results_file: results.sarif
results_format: sarif
# (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results for public repositories to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with:
sarif_file: results.sarif
+3
View File
@@ -8,3 +8,6 @@ build
\#*\#
*.pyc
*.log
.vscode
.envrc
+1 -1
View File
@@ -50,4 +50,4 @@ This is a checklist for TSC's to review as part of the intake process. The TSC s
- [X] License scan completed and no issues found
- Minor issues were found but already fixed in PR https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1145
- [X] Code repository imported to ASWF GitHub organization
- [ ] Developer Certificate of Origin past commit signoff done and DCO Probot enabled.
- [X] Developer Certificate of Origin post commit signoff done and DCO Probot enabled.
+390 -13
View File
@@ -1,6 +1,394 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Release 1.13 -- ?? 2023 ?? (compared to 1.12)
--------------------------------------------------
Dependency and standards requirements changes:
* OptiX 6.0 support has been removed. For GPU rendering with OptiX, a minimum
of OptiX 7.0 is required.
* The minimum version OpenImageIO has been raised from 2.2 to 2.3. #1591
(1.13.0.3)
OSL Language and oslc compiler:
* Bug fix: shader params whose default values involve "init ops" could be
incorrectly initialized if their values came from instance parameters set to
zero. #1578 (1.13.0.2)
OSL Standard library:
API changes, new options, new ShadingSystem features (for renderer writers):
* A new `shadingStateUniform` pointer field was added to ShaderGlobals for
planned future expansion and improved GPU support. #1585 (1.13.1.0)
SIMD batched shading mode:
* Fix some array overruns (asymptomatic, but still potentially buggy) in
common_ancestor_between. #1577 (1.13.0.2)
OptiX rendering:
* OptiX 6.0 support has been removed. For GPU rendering with OptiX, a minimum
of OptiX 7.0 is required.
* Big overhaul/simplification of how strings are represented on the GPU: the
extra level of indirection to global variables is removed, and strings are
simply represented in ordinary variables as the hash of their characters.
#1531 (1.13.0.0) #1553 (1.13.0.1)
* Better PTX cache hit rate by eliminating several sources of not being
strictly deterministic in the PTX text we were generating. #1566 #1570
(1.13.0.1)
Performance improvements:
Bug fixes and other improvements (internals):
* Fix memory leak in oslc ASTvariable_declaration. #1576 (1.13.0.2)
* Fix memory leaks in LPE code in error conditions. #1593 #1594 (1.13.0.3)
Internals/developer concerns:
* platform.h:
- New `OSL_ALLOCA` macro to allocate on the stack. #1589 (1.13.0.3)
Build & test system improvements:
* CMake build system and scripts:
- The version number is now a cache variable, and so can be overridden at
build time using `-DOSL_VERSION=...`. Use with extreme caution! #1579
(1.13.0.2)
* Dependency version support:
- Fix some issues that came up with the new icx 2022.0 compiler. #1601
(1.13.1.0)
* Testing and Continuous integration (CI) systems:
- Dynamic analysis using address and leak sanitizers. #1581 (1.13.0.3)
- `testshade --help` now prints TextureSystem options and all hardware
information. #1584 (1.13.0.3)
- Improvements to SonarCloud and coverage analysis. #1596 (1.13.0.3)
* Platform support:
Documentation:
* `doc/RELEASING.md` documents our release process and versioning policies.
#1572 (1.13.0.2)
Release 1.12 -- 1 Oct 2022 (compared to 1.11)
----------------------------------------------
Big Deal Changes:
* **Batch shading**: A fully operational "batch shading" support when using
CPUs supporting the Intel AVX2 or AVX512 instruction set architectures,
allows shading 8 or 16 points at a time, accelerated by using SIMD
instructions. (Changes contributed by Intel.)
* **OptiX**: A reasonable subset of the OSL language can run on NVIDIA GPUs
for Cuda or OptiX-based renderers.
* **Standardized material closures**: Synchronize with MaterialX on a minimum
standard set of material closures. This is reflected in both the OSL spec as
well as reference implementations of those closures in testrender. #1533
#1536 #1537 #1538 #1539 #1541 #1542 #1547 #1557
Dependency and standards requirements changes:
* The minimum (and default) compilation mode is now C++14. C++17 and 20 are
also supported. #1362 #1369 (1.12.2)
* Minimum compilers are now gcc 6.1 (no more support for gcc 4.8), MSVS
2017 or newer (no more support for 2015).
* Minimum LLVM is now 9.0. Support for LLVM 7 and 8 have ben dropped.
#1441 (1.12.3)
* Minimum OpenImageIO is now 2.2: Support for OIIO 2.0 and 2.1 have been
dropped. #1426 (1.12.3)
* Minimum OpenEXR version is now 2.3 (raised from 2.0). #1406 (1.12.3)
OSL Language and oslc compiler:
* `#pragma error "message"` and `#pragma warning "message"` can be used to
conditionally inject a compile-time error or warning. #1300 (1.12.1)
* Check for errors when when writing oso files (for example, disk volume
full). #1360 (1.12.2/1.11.14)
* A new flavor of `gettextureinfo(texturename, paramname, s, t, destination)`
allows for querying of texture metadata about the particular UDIM tile
that will be used for particular (s,t) texture coordinates. #1398 (1.12.3)
* Better error detection when OSL user functions write to function parameters
that are not marked as output. #1417 (1.12.3)
* Detect and better error message when using a type name where a variable
identifier should be. #1457 (1.12.4.2)
OSL Standard library:
* vector2.h is updated with a mod() function for vector2. #1312 (1.12.1/1.11.12)
* Preliminary work for adding standard MaterialX closures. 31371 (1.12.2)
* Fix previously-broken color conversions from RGB to xyY. #1410 (1.12.3)
* Fully removed MaterialX shaders (get those from the MaterialX project).
#1450 (1.12.3)
* Fix incorrect implementation of `matrix4 * vector4` in vector4.h #1513
(1.12.5.0)
API changes, new options, new ShadingSystem features (for renderer writers):
* Custom experimental llvm optimization levels 10, 11, 12, and 13. These
are stripped down versions of 0, 1, 2, 3 (corresponding to clang's -O0,
-O1, -O2, -O3) but we think for shaders are just as performant but with
lower JIT time. These are currently experimental, but we are benchmarking
to determine if they should be the new defaults. #1250 (1.12.0.0)
* ShadingSystem attribute "searchpath:library" gives a searchpath for finding
runtime-loadable implementation modules for ISA-optimized operations.
#1310 (1.12.1)
* Output variable placement -- now you can designate where shader outputs
should go and the shader will put results there, instead of the app using
find_symbol() and symbol_address after the shader is executed. #1328 (1.12.2)
* Userdata input placement -- now you can designate where interpolated
userdata should be copied from directly, rather then via callbacks to
RendererServices::get_userdata(). #1391 (1.12.3)
* Better hiding of the Matrix22 class, which was never actually part of the
public APIs. #1480 (1.12.4.5)
* Add ACES2065-1 and ACEScg as shading system color spaces (#1486) (1.12.4.6)
* Expanded warnings (via enabling the "opt_warnings" attribute of the
ShadingSystem) for operations that try to create new strings mid-shader, or
that need to access the characters of strings mid-shader. These are only
triggered for those cases that cannot be resolved by the end of the "runtime
optimization" phase. #1497 (1.12.4.6)
SIMD batched shading mode:
* Added support for masked operations to LLVMUtil. #1248 #1250 (1.12.0.0)
* Add interface to ShadingSystem for batched execution. #1272 (1.12.0.1)
* Add interface to batched RendererServices. #1276 (1.12.0.1)
* Batched testshade. #1298 (1.12.1)
* ShadingSystem plumbing to support batched execution. #1301 (1.12.1)
* Batched analysis to figure out which symbols need to be varying or uniform,
and which operations require masking. #1313 #1318 #1322 (1.12.1)
* Additional infrastructure for batched analysis. #1316 (1.12.1)
* Add implementation for BatchedBackendLLVM. #1330 (1.12.1)
* ISA-specific modules. #1345 (1.12.2)
* Introduction of CI testing of batched mode. #1357 #1367 (1.12.2)
* Control flow and string ops. #1372 (1.12.2)
* Matrix operations. #1378 (1.12.2) #1485 (1.12.4.6)
* Batched algebraic, trig, and transcendental functions. #1385 (1.12.2)
* Batched noise. #1394 (1.12.3)
* Batched implementation of all color operations. #1408 (1.12.3)
* Batched bitwise ops. #1413 (1.12.3)
* Batched spline and spline inverse. #1422 (1.12.3)
* Batched texture, gettextureinfo, texture3d, environment. #1436 (1.12.3)
* Batched dictionary functionality (dict_find, etc.) #1445 (1.12.3)
* Enable batched execution of most testsuite. #1453 (1.12.4.1)
* Batched isnan, isinf, isfinite. #1456 (1.12.4.2)
* Batched userdata and output placement. #1455 (1.12.4.2)
* Batched pointcloud functions. #1464 (1.12.4.4)
* Batched closures (#1500)
OptiX rendering:
* Explicitly set the OptiX pipeline stack size. #1254 (1.12.0.0)
* CI tests now at least compile and build with USE_OPTIX=1 (though not yet
run the tests). #1281 (1.12.0.1)
* A simple self-contained Cuda/OptiX example has been added as
testsuite/example-cuda. #1280 (1.12.0.1)
* Overhaul in how strings are communicated to the GPU side. #1309 (1.12.1)
* Removal of runtime compilation of Cuda (libnvrtc dependency eliminated).
#1309 (1.12.1)
* Fix problems with unresolved symbols on GPU, particularly when multiple
shaders call certain functions like printf. #1401 (1.12.3)
* Changed prototype of osl_get_attribute callback to work properly on
GPU. #1404 (1.12.3)
* Fix missing hostdevice modifier on some matrix operators. #1409 (1.12.3)
* Fix race conditions when compiling for OptiX 7. #1411 (1.12.3)
* osl_get_attribute() uses device strings when compiling for OptiX.
#1435 (1.12.3)
* Fix issue with OptiX + clang 14 with duplicate symbols. #1561 (1.12.6.0)
Performance improvements:
* Less mutex locking around use and retrieval of ColorSystem related to
doing color transforms. #1405 (1.12.3)
* Constant folding of `startswith()`. #1507 (1.12.5.0)
Bug fixes and other improvements (internals):
* Fix derivatives of texture calls when only derivatives of the "alpha"
value are needed. #1251 (1.12.0.0)
* When uninitialized value detection is used, fix possible "false positive"
related to the condition variable of do-while loops. #1252 (1.12.0.0)
* Avoid some pointless copies of output variables from a used layer to a
downstream layer that is known to not be used. #1253 (1.12.0.0)
* Stats now print more information about build options and runtime hardware
capabilities. #1258 #1259 (1.12.0.1)
* The osl and oso parsers are now re-entrant, which allows different threads
to concurrently compile or load shaders. #969 (1.12.0.1)
* Fix asymptomatic potential runtime optimizer bug where certain
multi-component values were not correctly recognized as nonzero. #1266
(1.12.0.1/1.11.9)
* Fix optimizer bug where an `output` parameter that is also marked as
`[[lockgeom=0]]`, i.e., it gets a value from a userdata input, but also
passes it to a downstream connection or a renderer output, could end up
with an incorrect value if it was never read in the shader (including if
the only times it was read were optimized away). #1295 (1.12.0.1)
* Ensure that OSLCompiler::LoadMemoryCompiledShader returns false upon parse
failure. #1302 (1.12.1/1.11.10)
* During runtime optimization, don't merge layers that produce renderer
outputs (the semantics of doing so are very fishy). #1296 (1.12.1)
* Eliminate unnecessary error messages to stderr for broken point clouds.
#1333 (1.12.1/1.11.13)
* Fix undefined behavior that could result in crashes that resulted from
the Symbol class having no virtual destructor. #1397 (1.12.3)
* Fix in runtime optimizer where tracking of messages and unknown messages
relied on uninitialized variables. #1447 (1.11.17/1.12.3)
* Stop internally using OIIO::string_view::c_str(), which will someday be
removed. #1458 (1.12.4.2)
* Correctly track that the backfacing() function requires N and I shader
globals. #1462 (1.12.4.4)
* Print all 4 levels of version numbers in help messages. #1477 (1.12.4.4)
* Fix GPU code generation crash. #1479 (1.12.4.4)
* Work to transition internals to use modern std::format notation for
formatted output. #1487 #1490 (1.12.4.6) #1504 #1506 (1.12.5.0)
* testrender improvements:
* Fix testrender memory error on teardown. #1499 (1.12.4.6)
* Modernize the sampler in testrender, improving quality and performance.
#1534 (1.12.6.0)
* Switch to cone tracing for derivatives. #1543 (1.12.6.0)
* Fix error that prevented correct typecheck of ternary operator. #1552
(1.12.6.0)
Internals/developer concerns:
* Use the `final` keyword in certain internal classes where applicable.
#1260 (1.12.0.1/1.11.9)
* Minor fixes to the internal TypeSpec and Symbol classes. #1267 (1.12.0.1)
* Switch from deprecated call to OIIO::parallel_image to the new version.
#1317 (1.11.11/1.12.1)
* The "archive_groupname" handling is now careful to sanitize the filenames
it deals with, closing some security and safety holes. #1383 (1.12.2)
* More migration of string formatting to new std::format style. #1389 (1.12.3)
#1469 #1470 (1.12.4.4)
* llvm_util: Switch some uses of ptr+len to span. #1390 (1.12.3)
* OSL no longer uses sscanf internally (which has icky locale-dependent
behavior), and instead use locale-independent OIIO::Strutil utilities
whenever we need to parse strings. #1432 (1.12.3)
* Avoid use of OIIO::string_view::str() which is not corresponding to the
official C++17 std::string_view. #1467 (1.12.4.4)
* Prototype of "free function" approach that will someday mostly supplant
the way we use RendererServices, and will help to unlock feature completion
for GPU and other back ends. This experimental feature is not expected
to be used in OSL 1.12. #1494 (1.12.5.0)
* Work on gradually converting printf-style formatted strings to fmt /
std::format style. #1493 (1.12.5.0)
* LLVM_Util: allow naming of llvm symbols to help with IR debugging. #1530
(1.12.6.0)
* clang-format the code base. #1508 #1509 #1511 #1512 #1515 #1518 #1540
(1.12.5.0) #1555 #1562 #1568 (1.12.6.0)
* A round of spell-checking all the comments in the code base. #1550
(1.12.5.0)
Build & test system improvements:
* CMake build system and scripts:
- We now use .git-blame-ignore-revs to record commits that consist
entirely of reformatting, so that 'git blame' does not misattribute
authorship to the trivial changes of those commits. #1244 (1.12.0.0)
- Miscellaneous improvements to cmake scripts. #1247 (1.12.0.0)
- Instead of defaulting to looking for Python 2.7, the OSL build now
defaults to whatever Python is found (though a specific one can still
be requested via the PYTHON_VERSION variable). #1249 (1.12.0.0/1.11.8)
#1286 (1.12.0.1/1.11.9)
- Extend checked_find_package with VERSION_MIN and VERSION_MAX. #1303
(1.12.1/1.11.10)
- Make the CMake build scripts more friendly to being a subproject.
#1304 #1319 (1.11.11/1.12.1)
- We weren't properly hiding non-public symbols. #1337 (1.12.1/1.11.12)
- Fully split oslquery and oslnoise libraries from oslexec, no more
redundant modules put into both. #1346 #1348 (1.12.1)
- Support for CMake 3.20 #1354 (1.12.2/1.11.14)
- Important change to `Makefile` wrapper: We have a 'Makefile' that just
wraps cmake for ease of use. This has changed its practice of putting
builds in `build/ARCH` to just `build` (and local installs from
`dist/ARCH` to `dist`) to better match common cmake practice. So where
your local builds end up may shift a bit. #1396 (1.12.3)
- Be more careful about not writing over a sensitive install area
unless CMAKE_INSTALL_PREFIX is explicitly set. #1421 (1.12.3)
- PROJECT_VERSION_RELEASE_TYPE and OSL_SUPPORTED_RELEASE are now
cache variables that can have build-time overrides. #1443 (1.12.3)
- Use PROJECT_IS_TOP_LEVEL (not OSL_IS_SUBPROJECT) to confirm with
CMake 21 conventions. #1443 (1.12.3)
- New TIME_COMMANDS option, when enabled, can help debug performance of
the build. #1443 (1.12.3)
- New CMake variable `DOWNSTREAM_CXX_STANDARD` sets the downstream
minimum C++ requirement, separately from `CMAKE_CXX_STANDARD` which sets
what we build OSL itself with. Clarify that currently, OSL can be used
downstream by C++14, even if it is built with C++17 or higher. #1454
(1.12.4.1)
- Make exported cmake configs relocatable by using relative paths. #1466
(1.12.4.4)
* Dependency version support:
- Build properly against Cuda 11 and OptiX 7.1. #1232 (1.12.0.1)
and up to OptiX 7.4 #1559 (1.12.6.0)
- PugiXML build fixes on some systems. #1262 (1.12.0.1/1.11.8)
- Cuda/OptiX back end: Add `__CUDADEVRT_INTERNAL__` define to bitcode
generation, needed to avoid duplicate cudaMalloc symbols with CUDA9+
#1271 (1.12.0.1)
- Build against LLVM 11 #1274 (1.12.0.1), LLVM 12 #1351 (1.12.1.0)
#1412 (1.12.3), LLVM 13 #1420 (1.12.3), LLVM 14 #1492 (1.12.4.6)
LLVM 15 #1592 (1.12.6.2)
- Fix build break against recent OIIO master change where m_mutex field
was removed from ImageInput. #1281 (1.12.0.1/1.11.9)
- Work to ensure that OIIO will build correctly against the upcoming
Imath 3.0 and OpenEXR 3.0. #1299 (1.11.10/1.12.1) #1332 (1.11.11/1.12.1)
#1341 (1.11.12/1.12.1) #1356 #1368 (1.11.13/1.12.2) #1489 (1.12.4.6)
- Improved finding of llvm components when using static libraries. #1375
(1.12.2)
- No longer use boost regex, completely rely on std::regex now that OSL
is C++14 minimum. #1377. (1.12.2)
- Support for OpenImageIO 2.3 changes. #1393 (1.12.3)
- Some rearrangement of `#include` and other trickery ensures that OSL
always includes headers from its favored version of Imath, rather than
the ones that OIIO prefers (in cases where OIIO and OSL were each based
on different Imath versions). #1460 (1.12.4.2)
- Various fixes for functionality and warnings for Intel icc and icx
compilers. #1459 #1473 #1475. (1.12.4.4)
- Fixes for recent OIIO TextureSystem changes that hide Imath types.
#1476 (1.12.4.4)
- Changes to work correctly with OpenImageIO 2.4 and its master being
the start of 2.5. #1569 (1.12.6.0)
* Testing and Continuous integration (CI) systems:
- Eliminate the old Travis CI and Appveyor. #1334 #1338 (1.12.1)
- Use ccache + GitHub 'cache' action to greatly speed up CI runs. #1335
(1.12.1)
- Divide the CI stages into separate steps, combine dependency-building
scripts for CentOS and Ubuntu ito a single script. #1338 (1.12.1)
- CI tests clang11, also batched shading with clang. #1379 (1.12.2)
- CI speeds up OIIO builds by not building its tests. #1380 (1.12.2)
- CI tests gcc11 #1381 (1.12.2) and gcc12 #1565 (1.12.6)
- Deal with OpenColorIO changing its master branch to "main". #1429
(1.12.3)
- Fix tests for texture3d now that OIIO has dropped support for Field3D.
#1437 (1.12.3)
- Test against LLVM13/clang13 for the VFX Platform 2022 tests. #1434
(1.12.3)
- CI test against MacOS-11 #1434 (1.12.3) and MacOS-12 #1554 (1.12.6)
#1522 (1.12.5)
- Add testsuite coverage of environment(). #1438 (1.12.3)
- Use a project-specific environment variable `OSL_CI` instead of the more
generic `CI` to avoid clashes with other systems. #1446 (1.12.3)
- Deal with OpenEXR and Imath changing its master branch to "main". #1463
(1.12.4.4)
- testrender fix sphere tangents, per MaterialX suggestion. #1465
(1.12.4.4)
- Allow testsuite tests to use oiiotool for image diffs instead of idiff.
#1472 (1.12.4.4)
- Allow `-Werror` to be disabled even on CI branches. #1471 (1.12.4.4)
- CI Tests against the Intel icc and icx compilers! #1459 #1473 (1.12.4.4)
#1501 (1.12.5.0)
- Overhaul of GHA ci.yml to use strategy matrix. #1474 (1.12.4.4)
- Test against clang 14 and fix new warnings. #1498 (1.12.5.0)
- Test against clang 15 and fix new warnings. #1586 (1.12.6.2)
- A scorecards workflow guards against a variety of security issues of
the CI system itself. #1529 (1.12.6.0)
- Enable SonarCloud static analysis. #1551 #1556 #1563 (1.12.6.0)
* Platform support:
- Various Windows compile fixes. #1263 #1285 (1.12.0.1)
- Windows+Cuda build fixes. #1292 (1.12.0.1)
- Fix warnings about pointer casts on Windows. #1484 (1.12.4.5)
- Various Windows build fixes. #1502 (1.12.5.0)
* The oso and osl lexers/parsers are now given internal symbol names that
are fully versioned, to avoid possible clash if multiple OSL releases are
both linked into the same application. #1255 (1.12.0.0)
Documentation:
* A simple self-contained Cuda/OptiX example has been added as
testsuite/example-cuda. #1280 (1.12.0.1)
* Update CLAs, Charter, GOVERNANCE, particularly after acceptance of new
CLAs and moving the repo to the ASWF GitHub account. #1308 #1240 #1314
(1.11.11/1.12.1)
* First steps in new documentation and scripts for building OSL on Windows.
#1326 (1.12.1)
* Fix missing explanation of the optional "errormessage" parameter to
environment() and texture3d(). #1442 (1.12.3/1.11.17)
* A SECURITY.md file explains how to confidentially report vulnerabilities.
#1529 (1.12.6)
* Document all the new MaterialX closures. #1564
Release 1.11.17.0 -- 7 Jan 2022 (compared to 1.11.16.0)
-------------------------------------------------------
* Fix in runtime optimizer where tracking of messages and unknown messages
@@ -41,7 +429,7 @@ Release 1.11.14.1 -- 1 Jun 2021 (compared to 1.11.14.0)
Release 1.11.14 -- 10 May 2021 (compared to 1.11.13)
----------------------------------------------------
* oslc/OSLCompiler: Check for errors when when writing oslc (for example,
* oslc/OSLCompiler: Check for errors when when writing oso (for example,
disk volume full). #1360
* Fix crash generating closure function calls with LLVM 11. #1361
* Build: LLVM 12 compatibility. #1351
@@ -438,8 +826,6 @@ Build & test system improvements:
llvm-config named `llvm-config-64`. #1238 (1.11.7.1)
- Fixes for OIIO 2.2 which has eliminated use of tinyformat in favor of
always relying on fmtlib. #1242 (1.11.7.1)
- Address problem with LLVM 10.0.1 on Mac when installed by Homebrew.
#1245 (1.11.7.2)
* A new build-time CMake variable `OSL_LIBNAME_SUFFIX` lets you optionally
add a custom suffix to the main libraries that are built. (Use with
caution.) #970 (1.11.0)
@@ -467,7 +853,7 @@ Build & test system improvements:
use clang library components for preprocessing. #1089 (1.11.3)
* Add an optional build-time `EXTRA_WARNINGS` option (default: OFF) that
enables even more picky than usual warnings. Fix many warnings that cropped
up during testing, mostly related to unused function paramters. #1106 (1.11.3)
up during testing, mostly related to unused function parameters. #1106 (1.11.3)
* The testsuite can run in parallel, with a number of threads set by the
environment variable `CTEST_PARALLEL_LEVEL`. #1119 (1.11.4)
* oslconfig.h is now generated by a cmake configure_file step, from
@@ -477,11 +863,6 @@ Build & test system improvements:
* Fix typo that botched the version in the .pc pkgconfig file. #1168 (1.11.6)
* CI test against gcc9 and gcc10. #1192 (1.11.6)
* Propagate RTTI compile options to exported cmake config. #1194 (1.11.6)
* New file .git-blame-ignore-revs lists the hashes of commits that only
performed bulk reformatting, so that they don't misattribute authorship
or modification date. Everybody do this in your local repo:
`git config blame.ignoreRevsFile .git-blame-ignore-revs`
#1244 (1.11.7.2)
Documentation:
* Make it clear that the documentation is licensed under the CC-BY-4.0
@@ -493,10 +874,6 @@ Documentation:
example for others writing renderers. #1202 (1.11.6)
* Fix incorrect descripton in `spline()` regarding the number of spline
values required for each interpolation type. #1239 (1.11.7.1)
* Extensive fixing of typos and misspellings in docs and comments. #1243
(1.11.7.2)
* Renamed "LICENSE-THIRD-PARTY.md" to "THIRD-PARTY.md" to avoid confusing
GitHub's reporting of the project's license. (1.11.7.2)
Release 1.10.13 -- 1 Aug 2020 (compared to 1.10.12)
+31 -14
View File
@@ -3,18 +3,20 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
cmake_minimum_required (VERSION 3.12)
project (OSL VERSION 1.11.17.0
set (OSL_VERSION "1.13.1.0" CACHE STRING "Version")
project (OSL VERSION ${OSL_VERSION}
LANGUAGES CXX C
HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/OpenShadingLanguage")
set (PROJ_NAME ${PROJECT_NAME}) # short name
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
set (PROJECT_VERSION_RELEASE_TYPE "" CACHE STRING
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_AUTHORS "Contributors to the Open Shading Language project")
option (${PROJECT_NAME}_SUPPORTED_RELEASE
"Set ON for supported release branch, OFF for master" ON)
"Set ON for supported release branch, OFF for master" OFF)
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
set (${PROJECT_NAME}_DEV_RELEASE OFF)
else ()
@@ -79,11 +81,6 @@ include (GNUInstallDirs)
option (VERBOSE "Print lots of messages while compiling" OFF)
set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING
"Customized outer namespace base name (version will be added)")
option (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH "Should the inner namespace include the patch number" OFF)
set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
CACHE STRING "Set the SO version in the SO name of the output library")
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)
@@ -94,11 +91,10 @@ else ()
endif ()
option (OSL_BUILD_PLUGINS "Bool OSL plugins, for example OIIO plugin" ON)
option (OSL_BUILD_SHADERS "Build shaders" ON)
option (OSL_BUILD_MATERIALX "Build MaterialX shaders" OFF)
option (USE_OPTIX "Include OptiX support" OFF)
set (OPTIX_EXTRA_LIBS CACHE STRING "Extra lib targets needed for OptiX")
set (CUDA_EXTRA_LIBS CACHE STRING "Extra lib targets needed for CUDA")
set (CUDA_TARGET_ARCH "sm_35" CACHE STRING "CUDA GPU architecture (e.g. sm_35)")
set (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"
@@ -127,16 +123,23 @@ 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 (OIIO_NAMESPACE_INCLUDE_PATCH)
if (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH)
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE_V}_${PROJECT_VERSION_PATCH}")
endif ()
message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
@@ -160,6 +163,7 @@ include (pythonutils)
include (externalpackages)
include (flexbison)
include (cuda_macros)
include (llvm_macros)
# Include all our testing apparatus and utils, but not if it's a subproject
if (${PROJECT_NAME}_BUILD_TESTS AND PROJECT_IS_TOP_LEVEL)
@@ -170,12 +174,28 @@ endif ()
include_directories (
BEFORE
"${OSL_LOCAL_DEPS_DIR}/include"
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_BINARY_DIR}/src/include"
"${CMAKE_BINARY_DIR}/include"
)
# 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)
@@ -200,9 +220,6 @@ endif ()
if (OSL_BUILD_SHADERS)
add_subdirectory (src/shaders)
if (OSL_BUILD_MATERIALX)
add_subdirectory (src/shaders/MaterialX)
endif ()
endif ()
option (INSTALL_DOCS "Install documentation" ON)
+13 -9
View File
@@ -173,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
@@ -217,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
@@ -233,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) {
@@ -244,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;
}
+2 -1
View File
@@ -134,11 +134,12 @@ Current voting members of the TSC are:
* Eric Enderton - NVIDIA
* Stephen Friedman - Pixar
* Nicolas Guiard - Isotropix
* Derek Haase - DNEG
* Clint Hanson - DNEG
* Adrien Herubel - Autodesk
* Lee Kerley - Sony Pictures Imageworks
* Mitch Prater - Laika
* Brecht Van Lommel - Blender
* Alex Wells - Intel
### TSC Nomination and Succession
+34 -41
View File
@@ -12,19 +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.12 or newer (tested through 3.21)
* Build system: [CMake](https://cmake.org/) 3.12 or newer (tested through 3.24)
* A suitable C++11 compiler to build OSL itself, which may be any of:
- GCC 4.8.5 or newer (tested through gcc 11.2)
- Clang 3.4 or newer (tested through clang 13)
- Microsoft Visual Studio 2015 or newer
- Intel C++ compiler icc version 13 (?) or newer
* 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 15)
- Microsoft Visual Studio 2017 or newer
- Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler
version 2022 or newer.
OSL should compile also properly with C++14 or C++17, but they are not
required (unless you are using LLVM >= 10, in which case at least C++14
is needed).
* **[OpenImageIO](http://openimageio.org) 2.0 or newer** (tested through 2.3)
* **[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
@@ -38,20 +35,21 @@ 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) 7, 8, 9, 10, 11, 12, or 13**, including clang
libraries.
* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, or 15, including
clang libraries.
Note that LLVM 10+ is not compatible with C++11, and requires C++14 or
later. If you *must* build OSL with C++11, you need to use an LLVM that
is LLVM 9 or earlier.
* (optional) For GPU rendering on NVIDIA GPUs:
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.
* [Cuda](https://developer.nvidia.com/cuda-downloads) 8.0 or higher.
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.76)
* [Ilmbase or Imath](http://openexr.com/downloads.html) 2.0 or newer (tested through 3.1)
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.80)
* [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
@@ -62,10 +60,10 @@ NEW or CHANGED dependencies since the last major release are **bold**.
If it is not found at build time, the OSL `pointcloud` functions will not
be operative.
* (optional) Python: If you are building the Python bindings or running the
testsuite:
* Python >= 2.7 (tested against 2.7, 3.6, 3.7, 3.8, 3.9)
* pybind11 >= 2.4.2 (Tested through 2.7).
* NumPy
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.
@@ -76,13 +74,13 @@ Build process
Here are the steps to check out, build, and test the OSL distribution:
0. Install and build dependencies.
1. Install and build dependencies.
1. Check out a copy of the source code from the Git repository:
2. Check out a copy of the source code from the Git repository:
git clone https://github.com/AcademySoftwareFoundation/OpenShadingLanguage.git osl
2. Change to the distribution directory and 'make'
3. Change to the distribution directory and 'make'
cd osl
make
@@ -98,22 +96,17 @@ Here are the steps to check out, build, and test the OSL distribution:
"make STOP_ON_WARNING=0", that create a build that will only stop for
full errors, not warnings.
3. After compilation, you'll end up with a full OSL distribution in
dist/ARCH, where ARCH is the architecture you are building on, one of
"linux", "linux64", "macosx", "windows", or "windows64".
4. After compilation, you'll end up with a full OSL distribution in
dist/
Note: The default is to make an optimized "release" build. If
instead type 'make debug' at the top level, you will end up with
a debug build (no optimization, full symbols) in "dist/ARCH.debug".
4. Add the "dist/ARCH/bin" to your $PATH, and "dist/ARCH/lib" to your
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on OS X), or copy the contents
5. Add the "dist/bin" to your $PATH, and "dist/lib" to your
$LD_LIBRAY_PATH (or $DYLD_LIBRARY_PATH on MacOS), or copy the contents
of those files to appropriate directories. Public include files
(those needed when building applications that incorporate OSL)
can be found in "dist/ARCH/include", and documentation can be found
in "dist/ARCH/share/doc".
can be found in "dist/include", and documentation can be found
in "dist/share/doc".
5. After building (and setting your library path), you can run the
6. After building (and setting your library path), you can run the
test suite with:
make test
+23 -31
View File
@@ -22,15 +22,6 @@ working_dir := ${shell pwd}
# Figure out which architecture we're on
include ${working_dir}/src/make/detectplatform.mk
# Presence of make variables DEBUG and PROFILE cause us to make special
# builds, which we put in their own areas.
ifdef DEBUG
variant +=.debug
endif
ifdef PROFILE
variant +=.profile
endif
MY_MAKE_FLAGS ?=
MY_NINJA_FLAGS ?=
MY_CMAKE_FLAGS ?=
@@ -47,10 +38,8 @@ endif
# Set up variables holding the names of platform-dependent directories --
# set these after evaluating site-specific instructions
top_build_dir ?= build
build_dir ?= ${top_build_dir}/${platform}${variant}
top_dist_dir ?= dist
dist_dir ?= ${top_dist_dir}/${platform}${variant}
build_dir ?= build
dist_dir ?= dist
INSTALL_PREFIX ?= ${working_dir}/${dist_dir}
@@ -116,10 +105,6 @@ ifneq (${OSL_LIBNAME_SUFFIX},)
MY_CMAKE_FLAGS += -DOSL_LIBNAME_SUFFIX:STRING=${OSL_LIBNAME_SUFFIX}
endif
ifneq (${OIIO_LIBNAME_SUFFIX},)
MY_CMAKE_FLAGS += -DOIIO_LIBNAME_SUFFIX:STRING=${OIIO_LIBNAME_SUFFIX}
endif
ifneq (${OSL_BUILD_TESTS},)
MY_CMAKE_FLAGS += -DOSL_BUILD_TESTS:BOOL=${OSL_BUILD_TESTS}
endif
@@ -128,10 +113,6 @@ ifneq (${OSL_BUILD_SHADERS},)
MY_CMAKE_FLAGS += -DOSL_BUILD_SHADERS:BOOL=${OSL_BUILD_SHADERS}
endif
ifneq (${OSL_BUILD_MATERIALX},)
MY_CMAKE_FLAGS += -DOSL_BUILD_MATERIALX:BOOL=${OSL_BUILD_MATERIALX}
endif
ifdef DEBUG
CMAKE_BUILD_TYPE=Debug
endif
@@ -171,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
@@ -251,7 +240,7 @@ endif
#########################################################################
# Top-level documented targets
all: dist
all: install
# 'make debug' is implemented via recursive make setting DEBUG
debug:
@@ -271,7 +260,7 @@ config:
cd ${build_dir} ; \
${CMAKE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${MY_CMAKE_FLAGS} ../.. ; \
${MY_CMAKE_FLAGS} ${working_dir} ; \
fi)
@@ -309,7 +298,7 @@ clang-format: config
)
# 'make dist' is just a synonym for 'make install'
# DEPRECATED: 'make dist' is just a synonym for 'make install'
dist : install
TEST_FLAGS += --force-new-ctest-process --output-on-failure
@@ -341,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}
#########################################################################
@@ -361,7 +350,6 @@ help:
@echo " make profile Build and install for profiling"
@echo " make clean Remove the temporary files in ${build_dir}"
@echo " make realclean Remove both ${build_dir} AND ${dist_dir}"
@echo " make nuke Remove ALL of build and dist (not just ${platform})"
@echo " make test Run tests"
@echo " make testall Run all tests, even broken ones"
@echo " make clang-format Run clang-format on all the source files"
@@ -372,7 +360,7 @@ help:
@echo " STOP_ON_WARNING=0 Do not stop building if compiler warns"
@echo " OSL_SITE=xx Use custom site build mods"
@echo " MYCC=xx MYCXX=yy Use custom compilers"
@echo " CMAKE_CXX_STANDARD=14 Compile in C++14 mode (default is C++11)"
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)"
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"
@@ -395,7 +383,7 @@ help:
@echo " BOOST_ROOT=path Custom Boost installation"
@echo " USE_QT=0 Skip anything that needs Qt"
@echo " LLVM-related options:"
@echo " LLVM_VERSION=7.0 Specify which LLVM version to use"
@echo " LLVM_VERSION=12.0 Specify which LLVM version to use"
@echo " LLVM_DIRECTORY=xx Specify where LLVM lives"
@echo " LLVM_NAMESPACE=xx Specify custom LLVM namespace"
@echo " LLVM_STATIC=1 Use static LLVM libraries"
@@ -406,11 +394,15 @@ help:
@echo " USE_FAST_MATH=1 Use faster, but less accurate math (set to 0 for libm defaults)"
@echo " OSL_BUILD_TESTS=0 Don't build unit tests, testshade, testrender"
@echo " OSL_BUILD_SHADERS=0 Don't build any shaders"
@echo " OSL_BUILD_MATERIALX=1 Build MaterialX shaders"
@echo " USE_SIMD=arch Build with SIMD support (comma-separated choices:"
@echo " 0, sse2, sse3, ssse3, sse4.1, sse4.2, f16c,"
@echo " avx, avx2, avx512f)"
@echo " USE_OPTIX=1 Build the OptiX test renderer"
@echo " 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 ""
+33 -16
View File
@@ -235,6 +235,7 @@ adding OSL support):
* Ubisoft motion picture group's proprietary renderer
* [Autodesk/SolidAngle: Arnold](https://www.solidangle.com/arnold/)
* [Autodesk: 3DS Max 2019](https://help.autodesk.com/view/3DSMAX/2019/ENU/?guid=__developer_3ds_max_sdk_features_rendering_osl_html)
* [Maxon: Redshift](https://www.maxon.net/en/redshift)
Films using OSL (grouped by year of release date):
* **(2012)**
@@ -392,9 +393,22 @@ Films using OSL (grouped by year of release date):
Matrix Resurrections
* **(2022 / upcoming)**
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,
Bullet Train,
...
Building and Installation
-------------------------
@@ -425,9 +439,13 @@ certain is a legit problem in the code, and for which you can give clear
instructions for how to reproduce, should be [reported as
issues](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/issues).
If confidentiality precludes a public question or issue, you may contact the
project administrator privately at [lg@imageworks.com](lg@imageworks.com),
including for security-related issues.
If you think you've found a potential vulnerability in OSL, please
confidentially report it by emailing the project administrators at
[security@openshadinglanguage.org](security@openshadinglanguage.org).
If any other issue requires confidentiality that precludes a public question
or issue, you may contact the project administrator privately at
[lg@larrygritz.com](lg@larrygritz.com).
Contributing
@@ -451,7 +469,6 @@ Contacts, Links, and References
[OSL home page](http://openshadinglanguage.org)
[Sony Pictures Imageworks main open source page](http://opensource.imageworks.com)
@@ -464,18 +481,18 @@ The current project leadership is documented in the
Many people have contributed features, bug fixes, and other changes to OSL
over the years: Steve Agland, Shane Ambler, Martijn Berger, Farchad
Bidgolirad, Nicholas Bishop, Solomon Boulos, Stefan Bruens, Stefan Büttner,
Matthaus G. Chajdas, Clark Chen, Alejandro Conty, Thomas Dinges, Mads
Drøschler, Luke Emrose, Louis Feng, Mark Final, Henri Fousse, Syoyo Fujita,
Tim Grant, Larry Gritz, Nicolas Guiard, Euan Haahr, Derek Haase, Sven-Hendrik
Haase, John Haddon, Niklas Harrysson, Daniel Heckenberg, Thiago Ize, Matt
Johnson, Ronan Keryell, Chris Kulla, Elvic Liang, Max Liani, Adam Martinez,
John Mertic, Bastien Montagne, Steena Monteiro, Alexis Oblet, Erich Ocean,
Mikko Ohtamaa, Jino Park, Alexei Pawlow, Jay Reynolds, Benoit Ruiz, Declan
Russell, Patrick Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin,
Sandip Shukla, Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban
Tovagliari, Brecht Van Lommel, Alexander von Knorring, Alex Wells, Roman
Zulak. (Listed alphabetically; if we've left anybody out, it is inadvertent,
please let us know.)
Matthaus G. Chajdas, Clark Chen, Alejandro Conty, Dieter De Baets, Thomas
Dinges, Mads Drøschler, 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, Adrien Herubel, Thiago Ize, Matt Johnson, Ronan Keryell, Chris
Kulla, Elvic Liang, Max Liani, Adam Martinez, John Mertic, Bastien Montagne,
Steena Monteiro, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park, Alexei
Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick Scheibe, Alex
Schworer, Jonathan Scruggs, Sergey Sharybin, Sandip Shukla, Cliff Stein,
Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, Brecht Van Lommel,
Alexander von Knorring, Alex Wells, Roman Zulak. (Listed alphabetically; if
we've left anybody out, it is inadvertent, please let us know.)
We cannot possibly express sufficient gratitude to the managers at Sony
Pictures Imageworks who allowed this project to proceed, supported it
+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.
+181 -1
View File
@@ -109,5 +109,185 @@ Public domain
-------------------------------------------------------------------------
If we have left anything out, it is unintentional. Please let us know.
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.
+37 -336
View File
@@ -7,96 +7,31 @@ ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits)
endif
# For SpComp2 builds, do:
#
# make OSL_SPCOMP2=1 spcomp2_install
# or
# make OSL_SPCOMP2=1 SPCOMP2_LOCAL_PATH=/test/path spcomp2_install_local
#
# For Arnold builds, do:
#
# make OSL_ARNOLD=1
#
# For a Rez-bound build, do:
#
# make OSL_SPIREZ=1
#
# (Options: OSL_REZ_NAME=blah REZ_PACKAGE_ROOT=path)
#
# Otherwise a default 'make' will make a fully generic OSL build.
OSL_SPCOMP2 ?= 0
OSL_ARNOLD ?= 0
OSL_SPIREZ ?= 0
OSL_REZ_NAME ?= OSL
OSL_VERS = $(shell grep "OSL VERSION" CMakeLists.txt | egrep -o "[0-9.]+")
ONEVERS = $(shell site/spi/format_version.py ${OSL_VERS})
OSL_SPCOMP2_VERSION ?= ${ONEVERS}
ifeq (${OSL_SPCOMP2},1)
$(info Building for SpComp2)
OSL_ARNOLD := 0
NAMESPACE ?= 'OSL_SpComp2'
SOVERSION ?= ${OSL_SPCOMP2_VERSION}
PYLIB_LIB_PREFIX ?= 1
PYLIB_INCLUDE_SONAME ?= 1
OPENIMAGEIO_SPCOMP2_VERSION ?= 20103
OPENEXR_VERSION ?= 2.2.0
else ifeq (${OSL_ARNOLD},1)
$(info Building for Arnold)
NAMESPACE ?= 'OSL_Arnold'
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
OPENEXR_VERSION ?= 2.4.0
else ifeq (${OSL_SPIREZ},1)
$(info Building for Rez distribution)
NAMESPACE ?= 'OSL'
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
MY_CMAKE_FLAGS += -DOSL_SPIREZ=1 -DOSL_REZ_PACKAGE_NAME=${OSL_REZ_NAME}
MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
OPENIMAGEIO_VERSION ?= 2.2.0.0
OPENEXR_VERSION ?= 2.4.0
$(info Building against OpenImageIO ${OPENIMAGEIO_VERSION})
else
$(info Building generic OSL)
NAMESPACE ?= 'OSL'
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
endif
$(info Building generic OSL)
PYLIB_LIB_PREFIX ?= 0
PYLIB_INCLUDE_SONAME ?= 0
#$(info MAKECMDGOALS = $(MAKECMDGOALS))
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
## Detect which SPI platform and set $platform, $COMPILER,
## and PYTHON_VERSION. Lots of other decisions are based on these.
ifeq (${SP_OS}, rhel7)
# Rhel7 (current)
platform := rhel7
SPI_COMPILER_PLATFORM ?= gcc-6.3
ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
SPCOMP2_COMPILER ?= gcc48m64
CMAKE_CXX_STANDARD ?= 11
else
SPCOMP2_COMPILER ?= gcc63
ifeq (${SPI_COMPILER_PLATFORM},gcc-6.3)
CMAKE_CXX_STANDARD ?= 14
endif
SP_PLATFORM ?= linux
SP_PROC ?= x86_64
SP_REZ_OS ?= CentOS-7
LLVM_VERSION ?= 12.0.0
else ifeq (${platform}, macosx)
# Generic OSX machines (including LG's laptop)
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
SP_OS ?= macosx
SP_PLATFORM ?= macosx
SP_PROC ?= x86_64
SP_REZ_OS ?= MacOS
else
$(error Unknown SP_OS=${SP_OS} platform=${platform})
endif # endif ${SP_OS}
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS} -DSP_PLATFORM=${SP_PLATFORM}
MY_CMAKE_FLAGS += -DSP_PROC=${SP_PROC} -DSP_REZ_OS=${SP_REZ_OS}
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS}
MY_CMAKE_FLAGS += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOSL_SPI=1" -DOSL_SITE:STRING=spi
MY_CMAKE_FLAGS += -DSPI_TESTS=1
@@ -104,6 +39,7 @@ 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)
@@ -118,34 +54,15 @@ ifeq (${SP_OS}, rhel7)
export CCACHE_CPP2 ?= 1
# Override lib64 and use SPI convention of lib
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_LIBDIR="${INSTALL_PREFIX}/lib"
ifeq (${OSL_SPCOMP2},1)
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
else ifeq (${OSL_SPIREZ},1)
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
else ifeq (${OSL_ARNOLD},1)
OIIO_LIBNAME_SUFFIX ?= _Arnold
OSL_LIBNAME_SUFFIX ?= _Arnold
endif
#
# Compilers:
#
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_8.0.0
ifeq (${COMPILER},clang6)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_6.0.1
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang7)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_7.0.1
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang8)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_8.0.0
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang9)
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/rhel7/llvm_12.0.0
LLVM_DIRECTORY ?= /shots/spi/home/software/packages/llvm/${LLVM_VERSION}/${SPI_COMPILER_PLATFORM}
ifeq (${COMPILER},clang9)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/9.0.1-1/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
@@ -154,7 +71,11 @@ ifeq (${SP_OS}, rhel7)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang11)
LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/11.0.0-rc1/${SPI_COMPILER_PLATFORM}
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)
@@ -171,11 +92,6 @@ ifeq (${SP_OS}, rhel7)
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
MY_CMAKE_FLAGS += -DCMAKE_C_FLAGS="--gcc-toolchain=/usr" \
-DCMAKE_CXX_FLAGS="--gcc-toolchain=/usr" \
-DTOOLCHAIN_FLAGS="--gcc-toolchain=/usr"
endif
MY_CMAKE_FLAGS +=
-DLLVM_STATIC=1 \
@@ -186,33 +102,9 @@ ifeq (${SP_OS}, rhel7)
# Boost
#
BOOSTVERS ?= 1.70
BOOSTSPSUFFIX ?=
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
MY_CMAKE_FLAGS += -DBOOST_VERS_SP=${BOOSTVERSSP}
# $(info BOOSTVERSSP ${BOOSTVERSSP})
ifeq (${BOOSTVERS},1.55)
SPBOOST_INC_DIR ?= /usr/include/boost_${BOOSTVERSSP}
SPBOOST_LIB_DIR ?= /usr/lib64/boost_${BOOSTVERSSP}
ifeq (${BOOSTSPSUFFIX}, sp)
SPBOOST_LIBNAMESTART ?= lib${BOOSTSPSUFFIX}boost_${shell echo ${BOOSTVERS} | sed "s/\\./_/"}_0
else
SPBOOST_LIBNAMESTART ?= lib${BOOSTSPSUFFIX}boost
endif
SPBOOST_LIBNAMEEND ?= -gcc48-mt-${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${BOOSTVERS} \
-DBoost_INCLUDE_DIRS=${SPBOOST_INC_DIR} \
-DBoost_LIBRARY_DIRS=${SPBOOST_LIB_DIR} \
-DBoost_LIBRARIES:STRING="${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_filesystem${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_regex${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_system${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_thread${SPBOOST_LIBNAMEEND}.so"
else
# Our Boost >= 1.61 setup is MUCH simpler and more standard
SPBOOST_INC_DIR := /usr/include/boostroot/boost${BOOSTVERSSP}.0
SPBOOST_LIB_DIR := /usr/lib64/boostroot/boost${BOOSTVERSSP}.0
MY_CMAKE_FLAGS += \
-DBOOST_INCLUDEDIR=${SPBOOST_INC_DIR} \
-DBOOST_LIBRARYDIR=${SPBOOST_LIB_DIR}
endif
MY_CMAKE_FLAGS += \
-DBOOST_INCLUDEDIR=/usr/include/boostroot/boost${BOOSTVERS}.0 \
-DBOOST_LIBRARYDIR=/usr/lib64/boostroot/boost${BOOSTVERS}.0
#
# Python
@@ -220,11 +112,7 @@ ifeq (${SP_OS}, rhel7)
Python_INCLUDE_DIR ?= /usr/include/python${PYTHON_VERSION}
PYTHON_LIBRARY_DIR ?= /usr/lib64
Python_LIBRARY ?= ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
ifeq (${PYTHON_VERSION},3.6)
# Special sauce for Python 3.6
Python_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
Python_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
else ifeq (${PYTHON_VERSION},3.7)
ifeq (${PYTHON_VERSION},3.7)
# Special sauce for Python 3.7
Python_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
Python_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
@@ -241,51 +129,29 @@ ifeq (${SP_OS}, rhel7)
# Set our preferred OpenEXR path, but allow env variable to override
# with custom/test version.
ifneq (${OPENEXR_VERSION},)
# If OPENEXR_VERSION is set, grab from the rez area
OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
else ifeq (${OpenEXR_ROOT},)
# If not getting from rez, get from the system install
MY_CMAKE_FLAGS += \
-DOPENEXR_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_LIBRARY_DIR=/usr/lib64/OpenEXR2
endif
OPENEXR_VERSION ?= 2.4.1-2
OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}
$(info OpenEXR_ROOT = $(OpenEXR_ROOT))
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
Partio_VERSION ?= 1.10.6
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
partio_ROOT ?= ${REZ_PACKAGE_ROOT}/partio/${Partio_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
MY_CMAKE_FLAGS += -Dpartio_ROOT="${partio_ROOT}"
pugixml_VERSION ?= 1.10.0
pugixml_ROOT ?= ${REZ_PACKAGE_ROOT}/pugixml/${pugixml_VERSION}/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -Dpugixml_ROOT="${pugixml_ROOT}"
# set up OSL distribution environment
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
ifeq (${OSL_SPIREZ},1)
OpenImageIO_ROOT := ${REZ_PACKAGE_ROOT}/OpenImageIO/${OPENIMAGEIO_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
$(info OpenImageIO_ROOT ${OpenImageIO_ROOT})
else ifeq (${OSL_SPCOMP2},1)
OpenImageIO_ROOT := $(SPCOMP2_ROOT)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)
else ifeq (${OSL_ARNOLD},1)
OpenImageIO_ROOT ?= ${working_dir}/../OpenImageIO_local/dist/${platform}${variant}/
else ifneq (${OpenImageIO_ROOT},)
# User supplied something
endif
ifneq ($(OpenImageIO_ROOT),)
MY_CMAKE_FLAGS += -DOpenImageIO_ROOT=${OpenImageIO_ROOT}
endif
# Cuda/OptiX
USE_OPTIX ?= 1
CUDA_VERSION ?= 11.0.1
OPTIX_VERSION ?= 7.1.0
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}
CUDA_EXTRA_LIBS ?= ${CUDA_TOOLKIT_ROOT_DIR}/lib64/libnvrtc.so
OptiX_ROOT ?= /shots/spi/home/lib/arnold/rhel7/optix_${OPTIX_VERSION}
OPTIXHOME = ${OptiX_ROOT}
MY_CMAKE_FLAGS += -DUSE_OPTIX=${USE_OPTIX} \
@@ -300,53 +166,29 @@ else ifeq (${platform}, macosx)
CMAKE_CXX_STANDARD ?= 14
USE_SIMD ?= sse4.2
MY_CMAKE_FLAGS += -DCMAKE_BUILD_WITH_INSTALL_RPATH=1
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/lib"
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
BOOSTVERS=${BOOSTVERS}${BOOSTSPSUFFIX}
LLVM_DIRECTORY ?= /usr/local/opt/llvm
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, gcc48)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc5)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc6)
ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc8)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc9)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER},clang6)
else ifeq (${COMPILER},clang14)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@6/6.0.1_2/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm@6/6.0.1_2/bin/clang++
else ifeq (${COMPILER},clang7)
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
else ifeq (${COMPILER},clang15)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@7/7.0.1_1/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm@7/7.0.1_1/bin/clang++
else ifeq (${COMPILER},clang8)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@8/8.0.1_1/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm/8.0.1/bin/clang++
else ifeq (${COMPILER},clang9)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm@9/9.0.1/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm@9/9.0.1/bin/clang++
else ifeq (${COMPILER},clang10)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/Cellar/llvm/10.0.0/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/Cellar/llvm/10.0.0/bin/clang++
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
@@ -366,151 +208,10 @@ else ifeq (${platform}, macosx)
# end generic OSX
else
$(error Unknown SP_OS=${SP_OS} platform=${platform})
$(error Unknown SP_OS=${SP_OS})
endif # endif ${SP_OS}
ifeq (${OSL_SPIREZ},1)
# Rpath touch-ups
# NOTE: This MUST match the order and naming of the Rez variants
# set in rez/package.py.in
REZ_INSTALL_PATH := ${REZ_PACKAGE_ROOT}/${OSL_REZ_NAME}/${OSL_VERS}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}/cuda-${CUDA_VERSION}/optix-${OPTIX_VERSION}
MY_CMAKE_FLAGS += -DOSL_REZ_INSTALL_PATH=${REZ_INSTALL_PATH}
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_RPATH="${REZ_INSTALL_PATH}/lib;@executable_path/../lib;${OpenImageIO_ROOT}/lib"
INSTALL_PREFIX := ${working_dir}/dist/${platform}
endif
ifneq (${VERBOSE},)
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
endif
############################################################################
# SpComp2 magic incantations follow. Here be dragons.
############################################################################
CPPSTDSUFFIX=
SPCOMP2_INSTALL_ROOT ?= $(SPCOMP2_ROOT)
BOOSTVERSSP?=${BOOSTVERS}${BOOSTSPSUFFIX}
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
OIIO_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OpenImageIO/${SPARCH}/v${OPENIMAGEIO_SPCOMP2_VERSION}
# $(info New rhel7 OIIO_SPCOMP2_PATH is ${OIIO_SPCOMP2_PATH})
PYVERNOSPACE=${shell echo ${PYTHON_VERSION} | sed "s/\\.//"}
SPPYARCH=$(SPARCH)-py$(PYVERNOSPACE)
all: dist
local: dist
.PHONY: spcomp2_install spcomp2_install_local clean all
spi: MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
spi: debug dist
spcomp2_install_local: SPCOMP2_INSTALL_ROOT = $(SPCOMP2_LOCAL_PATH)
spcomp2_install_local: spcomp2_install
comma:= ,
empty:=
space:= $(empty) $(empty)
#OSL_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OSL/${SP_OS}-${SPCOMP2_COMPILER}$(CPPSTDSUFFIX)-boost${SPCOMP2_BOOSTVERS_SUFFIX}/v${OSL_SPCOMP2_VERSION}
#$(info New rhel7 OSL_SPCOMP2_PATH is ${OSL_SPCOMP2_PATH})
#INSTALL_SPCOMP2_CURRENT = $(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)
#INSTALL_BIN_LOCATION = $(INSTALL_SPCOMP2_CURRENT)/bin
SPCOMP2_RPATH_OPT ?= ${OpenImageIO_ROOT}/lib:${partio_ROOT}/lib
SPCOMP2_RPATH_DEBUG ?= ${OpenImageIO_ROOT}/lib:${partio_ROOT}/lib/debug
#PYSPCOMP2_RPATH_OPT ?= ${SPCOMP2_RPATH_OPT}:${OSL_SPCOMP2_PATH}/lib:${PYTHON_LIBRARY_DIR}
#PYSPCOMP2_RPATH_DEBUG ?= ${SPCOMP2_RPATH_DEBUG}:${OSL_SPCOMP2_PATH}/lib/debug:${PYTHON_LIBRARY_DIR}
spcomp2: MY_CMAKE_FLAGS += \
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)/lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
-DPYLIB_LIB_PREFIX:BOOL=ON \
-DPYMODULE_SUFFIX="V${OSL_SPCOMP2_VERSION}"
spcomp2: dist
spcomp2_debug: MY_CMAKE_FLAGS += \
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OSL/$(SPARCH)/v$(OSL_SPCOMP2_VERSION)/lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
-DPYLIB_LIB_PREFIX:BOOL=ON \
-DPYMODULE_SUFFIX="V${OSL_SPCOMP2_VERSION}"
spcomp2_debug: debug
spcomp2_install_fixup_rhel7: spcomp2 spcomp2_debug
echo $(SPCOMP2_INSTALL_ROOT)
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslexec${OSL_LIBNAME_SUFFIX}.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslexec.so
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslcomp${OSL_LIBNAME_SUFFIX}.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslcomp.so
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/liboslquery${OSL_LIBNAME_SUFFIX}.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/liboslquery.so
# patchelf --set-rpath ${PYSPCOMP2_RPATH_OPT} ${dist_dir}/python/libPyOSL.so
# patchelf --set-rpath ${PYSPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/python/libPyOSL.so
# This goal can't start with 'install' because something elsewhere picks
# it up and starts doing bad things
spcomp2_install: spcomp2_install_fixup_${SP_OS}
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
--project=oslexec \
--version=$(OSL_SPCOMP2_VERSION) \
--root=$(SPCOMP2_INSTALL_ROOT) \
--arch=$(SPARCH) \
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
--namespace=${NAMESPACE} \
--srcdir=${dist_dir}/lib \
--builddir_o=${dist_dir}/lib \
--builddir_d=${dist_dir}.debug/lib
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
--project=oslquery \
--version=$(OSL_SPCOMP2_VERSION) \
--root=$(SPCOMP2_INSTALL_ROOT) \
--arch=$(SPARCH) \
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
--namespace=${NAMESPACE} \
--srcdir=${dist_dir}/lib \
--builddir_o=${dist_dir}/lib \
--builddir_d=${dist_dir}.debug/lib
#perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
# --project=oslcomp \
# --version=$(OSL_SPCOMP2_VERSION) \
# --root=$(SPCOMP2_INSTALL_ROOT) \
# --arch=$(SPARCH) \
# --headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OSL/*)) \
# --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
# --namespace=${NAMESPACE} \
# --srcdir=${dist_dir}/lib \
# --builddir_o=${dist_dir}/lib \
# --builddir_d=${dist_dir}.debug/lib
#perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
# --project=PyOSL \
# --version=$(OSL_SPCOMP2_VERSION) \
# --root=$(SPCOMP2_INSTALL_ROOT) \
# --arch=$(SPPYARCH) \
# --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread"\
# --namespace=${NAMESPACE} \
# --srcdir=${dist_dir}/python \
# --builddir_o=${dist_dir}/python \
# --builddir_d=${dist_dir}.debug/python
-72
View File
@@ -1,72 +0,0 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Build a variant for Rez/general use
-----------------------------------
Skip this section if you are instead building for SpComp2.
Note: For testing or to make your own local rez package, you can customize
either the rez package name, or the rez install location name, with make
flags `OSL_REZ_NAME=blah REZ_PACKAGE_ROOT=/path/to/my/rez/pkgs` appended
to the `make` commands of any of the variants listed below. For example,
make OSL_SPIREZ=1 OSL_REZ_NAME=oiio_test REZ_PACKAGE_ROOT=/path/to/my/rez/pkgs
Variants:
# C++11/gcc4.8 compat, Python 2.7, Boost 1.55, OptiX 6, Cuda 10.1
# OIIO 2.2.0.0, OpenEXR 2.2
make nuke
make spi OSL_SPIREZ=1 BOOSTVERS=1.55 USE_OPTIX=1 CUDA_VERSION=10.1 OPTIX_VERSION=6.0.0 OPENIMAGEIO_VERSION=2.2.0.0 OPENEXR_VERSION=2.2.0 PYTHON_VERSION=2.7
# C++11/gcc6.3 compat, Python 2.7, Boost 1.70, OptiX 6, Cuda 10.1
# OIIO 2.2.0.0, OpenEXR 2.4
make nuke
make spi OSL_SPIREZ=1 SPI_COMPILER_PLATFORM=gcc-6.3 BOOSTVERS=1.70 USE_OPTIX=1 CUDA_VERSION=10.1 OPTIX_VERSION=6.0.0 OPENIMAGEIO_VERSION=2.2.0.0 OPENEXR_VERSION=2.4.0 PYTHON_VERSION=2.7
You can do any of these on your local machine.
Rez/general release (do for each variant)
-----------------------------------------
This must be done from compile42 (for correct write permissions on certain
shared directories), even if you did the build itself locally.
For any of the variants that you built above:
( cd dist/rhel7 ; rez release --skip-repo-errors )
That command will release the dist to the studio.
Appwrapper binary releases
--------------------------
We don't currently do this.
<!---
This step is for the ONE general/rez variant that we believe is the
canonical source of command line oslc and oslinfo. After building and
releasing as above,
cp dist/rhel7/OSL_*.xml /shots/spi/home/lib/app_cfg/OSL
That will make appcfg aware of the release.
To also make this release the new facility default:
db-any spi/home/OSL.bin highest /shots/spi/home/lib/app_cfg/OSL/OSL_A.B.C.D.xml
where A.B.C.D is the version.
--->
SpComp2 build and release
-------------------------
Phasing out support for this.
-11
View File
@@ -3,18 +3,7 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
option (${PROJ_NAME}_SPIREZ "Enable extra bits for building for SPI Rez install" OFF)
set (${PROJ_NAME}_REZ_PACKAGE_NAME CACHE STRING "${PROJECT_NAME}")
if (${PROJ_NAME}_SPIREZ)
message (STATUS "Creating package.py from package.py.in")
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/rez/package.py.in" "${CMAKE_BINARY_DIR}/package.py")
set (appcfg_filename "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}.xml")
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/appcfg.xml.in" "${appcfg_filename}")
install (FILES ${CMAKE_BINARY_DIR}/package.py
"${PROJECT_SOURCE_DIR}/site/spi/rez/CMakeLists.txt"
${appcfg_filename}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT developer)
endif ()
-31
View File
@@ -1,31 +0,0 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
cmake_minimum_required(VERSION 2.8)
project(OSL)
include(RezBuild)
rez_install_dirs(
include lib share
# python
DESTINATION .
)
# Bin specified separately so it can be marked as EXECUTABLE, otherwise it
# installs with only read permissions.
rez_install_dirs(
bin
DESTINATION .
EXECUTABLE
)
rez_install_cmake(
DESTINATION .
INCLUDE_DIRS include
LIBRARY_DIRS lib
LIBRARIES oslexec oslcomp oslquery
oslexec_d oslcomp_d oslquery_d
)
-59
View File
@@ -1,59 +0,0 @@
# -*- coding: utf-8 -*-
#
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#
# Documentation on packages and available attributes can be found at:
# https://github.com/nerdvegas/rez/wiki/Package-Definition-Guide
name = '@OSL_REZ_PACKAGE_NAME@'
version = '@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@'
description = \
"""
Rez package of Open Shading Language (OSL)
"""
authors = ['Larry Gritz <lg@imageworks.com>']
# Add dependencies to other Rez packages here
requires = [
'platform-@SP_PLATFORM@', 'arch-@SP_PROC@', 'os-@SP_REZ_OS@',
'OpenImageIO-@OPENIMAGEIO_VERSION_MAJOR@.@OPENIMAGEIO_VERSION_MINOR@.@OPENIMAGEIO_VERSION_PATCH@'
]
#build_command = 'python {root}/build.py'
# Rez has a limitation where it is not possible to add variants to a package that
# does not have any: https://github.com/nerdvegas/rez/wiki/Variants#single-variants.
# Unless you are 100% certain that your package will NEVER require any variants,
# you should define your package with at least one variant.
variants = [
[
'@SPI_COMPILER_PLATFORM@',
'python-@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@',
'boost-@BOOST_VERS_SP@',
'cuda-@CUDA_VERSION@',
'optix-@OPTIX_VERSION@'
],
]
def commands():
# Add import statements here, not at the top of the file!
# Uncomment if you have executables under bin/
env.PATH.append("{root}/bin")
env.LD_LIBRARY_PATH.append("{root}/lib")
# Uncomment if you have Python code under python/
env.PYTHONPATH.append("{root}/python")
# For SpImport.Packages, append the python directory
#env.SPIMPORT_PACKAGES.append("{root}/python")
if building:
env.CMAKE_MODULE_PATH.append('{root}')
# Add env vars or custom code you want executed only at build time
+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.
+5 -2
View File
@@ -14,7 +14,7 @@ uname
if [[ `uname` == "Linux" ]] ; then
LLVM_VERSION=${LLVM_VERSION:=8.0.0}
LLVM_VERSION=${LLVM_VERSION:=13.0.0}
LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR:=${PWD}/llvm-install}
if [[ "$GITHUB_WORKFLOW" != "" ]] ; then
LLVM_DISTRO_NAME=${LLVM_DISTRO_NAME:=ubuntu-18.04}
@@ -29,7 +29,10 @@ if [[ `uname` == "Linux" ]] ; then
fi
LLVMTAR=clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-${LLVM_DISTRO_NAME}.tar.xz
echo LLVMTAR = $LLVMTAR
if [[ "$LLVM_VERSION" == "10.0.0" ]] || [[ "$LLVM_VERSION" == "11.0.0" ]] || [[ "$LLVM_VERSION" == "11.1.0" ]] || [[ "$LLVM_VERSION" == "12.0.0" ]] ; then
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
+9 -9
View File
@@ -15,7 +15,7 @@ OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v1.1.1}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
OPENCOLORIO_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"}
@@ -25,7 +25,7 @@ OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
-DOCIO_BUILD_GPU_TESTS=OFF \
-DOCIO_BUILD_PYTHON=OFF -DOCIO_BUILD_PYGLUE=OFF \
-DOCIO_BUILD_JAVA=OFF \
-DOCIO_BUILD_STATIC=${OCIO_BUILD_STATIC:=OFF}"
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"
BASEDIR=`pwd`
pwd
echo "OpenColorIO install dir will be: ${OPENCOLORIO_INSTALL_DIR}"
@@ -34,20 +34,20 @@ mkdir -p ${LOCAL_DEPS_DIR}
pushd ${LOCAL_DEPS_DIR}
# Clone OpenColorIO project from GitHub and build
if [[ ! -e OpenColorIO ]] ; then
echo "git clone ${OPENCOLORIO_REPO} OpenColorIO"
git clone ${OPENCOLORIO_REPO} OpenColorIO
if [[ ! -e ${OPENCOLORIO_SOURCE_DIR} ]] ; then
echo "git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}"
git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}
fi
cd OpenColorIO
cd ${OPENCOLORIO_SOURCE_DIR}
echo "git checkout ${OPENCOLORIO_VERSION} --force"
git checkout ${OPENCOLORIO_VERSION} --force
mkdir -p build
cd build
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_BUILDOPTS} ${OPENCOLORIO_SOURCE_DIR}
time cmake --build . --config Release --target install
popd
+6 -34
View File
@@ -11,8 +11,8 @@
set -ex
# Which OpenEXR to retrieve, how to build it
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/openexr/openexr.git}
OPENEXR_VERSION=${OPENEXR_VERSION:=v2.4.1}
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/AcademySoftwareFoundation/openexr.git}
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.1.1}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
@@ -20,7 +20,6 @@ OPENEXR_SOURCE_DIR=${OPENEXR_SOURCE_DIR:=${LOCAL_DEPS_DIR}/openexr}
OPENEXR_BUILD_DIR=${OPENEXR_BUILD_DIR:=${LOCAL_DEPS_DIR}/openexr-build}
OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENEXR_BUILD_TYPE=${OPENEXR_BUILD_TYPE:=Release}
CMAKE_GENERATOR=${CMAKE_GENERATOR:="Unix Makefiles"}
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
BASEDIR=$PWD
@@ -29,49 +28,24 @@ pwd
echo "Building OpenEXR ${OPENEXR_VERSION}"
echo "OpenEXR build dir will be: ${OPENEXR_BUILD_DIR}"
echo "OpenEXR install dir will be: ${OPENEXR_INSTALL_DIR}"
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
echo "OpenEXR Build type is ${OPENEXR_BUILD_TYPE}"
if [[ "$CMAKE_GENERATOR" == "" ]] ; then
OPENEXR_GENERATOR_CMD="-G \"$CMAKE_GENERATOR\""
fi
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
# Clone OpenEXR project (including IlmBase) from GitHub and build
if [[ ! -e ${OPENEXR_SOURCE_DIR} ]] ; then
echo "git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}"
git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}
fi
mkdir -p ${OPENEXR_INSTALL_DIR} && true
mkdir -p ${OPENEXR_BUILD_DIR} && true
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force
if [[ ${OPENEXR_VERSION} == "v2.2.0" ]] || [[ ${OPENEXR_VERSION} == "v2.2.1" ]] \
|| [[ ${OPENEXR_VERSION} == "v2.2.2" ]] ; then
mkdir -p ${OPENEXR_BUILD_DIR}/IlmBase && true
mkdir -p ${OPENEXR_BUILD_DIR}/OpenEXR && true
cd ${OPENEXR_BUILD_DIR}/IlmBase
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} ${OPENEXR_GENERATOR_CMD} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
-DCMAKE_CXX_STANDARD=11 \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/IlmBase
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
cd ${OPENEXR_BUILD_DIR}/OpenEXR
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} ${OPENEXR_GENERATOR_CMD} \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}\;${OPENEXR_INSTALL_DIR}" \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DBUILD_UTILS=0 -DBUILD_TESTS=0 \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}/OpenEXR
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
elif [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
if [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
# Simplified setup for 2.3+
cd ${OPENEXR_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
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}" \
@@ -84,7 +58,7 @@ elif [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
else
# Simplified setup for 2.4+
cd ${OPENEXR_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} -G "$CMAKE_GENERATOR" \
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}" \
@@ -112,5 +86,3 @@ export ILMBASE_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
export OPENEXR_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
export LD_LIBRARY_PATH=$OPENEXR_ROOT/lib:$LD_LIBRARY_PATH
export ILMBASE_ROOT_DIR=$OPENEXR_INSTALL_DIR
export OPENEXR_ROOT_DIR=$OPENEXR_INSTALL_DIR
+3 -3
View File
@@ -10,10 +10,10 @@
set -ex
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=OpenImageIO/oiio}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=master}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=release}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENIMAGEIO_SRCDIR=${OPENIMAGEIO_SRCDIR:=${LOCAL_DEPS_DIR}/OpenImageIO}
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build/$PLATFORM}
OPENIMAGEIO_BUILD_DIR=${OPENIMAGEIO_BUILD_DIR:=${OPENIMAGEIO_SRCDIR}/build}
OPENIMAGEIO_INSTALLDIR=${OPENIMAGEIO_INSTALLDIR:=${LOCAL_DEPS_DIR}/dist}
OPENIMAGEIO_CMAKE_FLAGS=${OPENIMAGEIO_CMAKE_FLAGS:=""}
OPENIMAGEIO_BUILD_TYPE=${OPENIMAGEIO_BUILD_TYPE:=Release}
@@ -42,7 +42,7 @@ fi
# if [[ "$ARCH" == "windows64" ]] ; then
pushd ${OPENIMAGEIO_BUILD_DIR}
cmake ../.. -G "$CMAKE_GENERATOR" \
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="$OPENIMAGEIO_BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX="$OPENIMAGEIO_INSTALLDIR" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
+11 -7
View File
@@ -11,7 +11,7 @@ set -ex
# Repo and branch/tag/commit of pybind11 to download if we don't have it yet
PYBIND11_REPO=${PYBIND11_REPO:=https://github.com/pybind/pybind11.git}
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.4.3}
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.8.1}
# Where to put pybind11 repo source (default to the ext area)
PYBIND11_SRC_DIR=${PYBIND11_SRC_DIR:=${PWD}/ext/pybind11}
@@ -20,7 +20,7 @@ PYBIND11_BUILD_DIR=${PYBIND11_BUILD_DIR:=${PYBIND11_SRC_DIR}/build}
# Install area for pybind11 (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
PYBIND11_INSTALL_DIR=${PYBIND11_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
#PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
if [[ "${PYTHON_VERSION}" != "" ]] ; then
PYBIND11_BUILD_OPTS+=" -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION}"
@@ -38,16 +38,20 @@ if [[ ! -e ${PYBIND11_SRC_DIR} ]] ; then
git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}
fi
cd ${PYBIND11_SRC_DIR}
echo "git checkout ${PYBIND11_VERSION} --force"
git checkout ${PYBIND11_VERSION} --force
mkdir -p ${PYBIND11_BUILD_DIR}
cd ${PYBIND11_BUILD_DIR}
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
-DPYBIND11_TEST=OFF \
${PYBIND11_BUILD_OPTS} ..
time cmake --build . --config Release --target install
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
+17 -3
View File
@@ -12,17 +12,31 @@ if [[ "$USE_SIMD" != "" ]] ; then
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
fi
pushd build/$PLATFORM
cmake ../.. -G "$CMAKE_GENERATOR" \
if [[ -n "$CODECOV" ]] ; then
OSL_CMAKE_FLAGS="$OSL_CMAKE_FLAGS -DCODECOV=${CODECOV}"
fi
pushd build
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_INSTALL_PREFIX="$OSL_ROOT" \
-DUSE_PYTHON="${USE_PYTHON:=1}" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
-DUSE_BATCHED="${USE_BATCHED:=0}" \
-DCMAKE_INSTALL_LIBDIR="$OSL_ROOT/lib" \
-DCMAKE_CXX_STANDARD="$CMAKE_CXX_STANDARD" \
$OSL_CMAKE_FLAGS -DVERBOSE=1
time cmake --build . --target ${BUILDTARGET:=install} --config ${CMAKE_BUILD_TYPE}
# Save a copy of the generated files for debugging broken CI builds.
mkdir cmake-save || /bin/true
cp -r CMake* *.cmake cmake-save
: ${BUILDTARGET:=install}
if [[ "$BUILDTARGET" != "none" ]] ; then
echo "Parallel build ${CMAKE_BUILD_PARALLEL_LEVEL} of target ${BUILDTARGET}"
time ${OSL_CMAKE_BUILD_WRAPPER} cmake --build . --target ${BUILDTARGET} --config ${CMAKE_BUILD_TYPE}
fi
popd
if [[ "${DEBUG_CI:=0}" != "0" ]] ; then
+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
+5 -26
View File
@@ -8,28 +8,6 @@
# Since it sets many env variables needed by the caller, it should be run
# with 'source', not in a separate shell.
# Figure out the platform
if [[ $RUNNER_OS == macOS ]] ; then
export ARCH=macosx
elif [[ $RUNNER_OS == Linux ]] ; then
export ARCH=linux64
elif [[ $RUNNER_OS == Windows ]] ; then
export ARCH=windows64
elif [[ `uname -m` == aarch64 ]] ; then
export ARCH=aarch64
else
export ARCH=unknown
exit -1
fi
export PLATFORM=$ARCH
if [[ "${DEBUG:=0}" != "0" ]] ; then
export PLATFORM=${PLATFORM}.debug
fi
echo "Architecture is $ARCH"
echo "Build platform name is $PLATFORM"
# Environment variables we always need
export PATH=/usr/local/bin/_ccache:/usr/lib/ccache:$PATH
export USE_CCACHE=${USE_CCACHE:=1}
@@ -40,12 +18,12 @@ if [[ "${RUNNER_OS}" == "macOS" ]] ; then
fi
mkdir -p $CCACHE_DIR
export OSL_ROOT=$PWD/dist/$PLATFORM
export OSL_ROOT=$PWD/dist
export DYLD_LIBRARY_PATH=$OSL_ROOT/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$OSL_ROOT/lib:$LD_LIBRARY_PATH
export OIIO_LIBRARY_PATH=$OSL_ROOT/lib:${OIIO_LIBRARY_PATH}
export LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt
export ASAN_OPTIONS=print_suppressions=0
export ASAN_OPTIONS=print_suppressions=0:detect_odr_violation=1
export USE_PYTHON=${USE_PYTHON:=1}
export PYTHON_VERSION=${PYTHON_VERSION:="2.7"}
@@ -74,7 +52,7 @@ export DYLD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$DYLD_LIBRARY_PATH
export TESTSUITE_CLEANUP_ON_SUCCESS=${TESTSUITE_CLEANUP_ON_SUCCESS:=1}
mkdir -p build/$PLATFORM dist/$PLATFORM
mkdir -p build dist
echo "HOME = $HOME"
echo "PWD = $PWD"
@@ -83,13 +61,14 @@ echo "uname -a: " `uname -a`
echo "uname -m: " `uname -m`
echo "uname -s: " `uname -s`
echo "uname -n: " `uname -n`
echo "nproc " `nproc`
pwd
ls
env | sort
if [[ `uname -s` == "Linux" ]] ; then
head -40 /proc/cpuinfo
elif [[ $ARCH == macosx ]] ; then
elif [[ ${RUNNER_OS} == "macOS" ]] ; then
sysctl machdep.cpu.features
fi
+18 -4
View File
@@ -8,12 +8,26 @@
# any command in it fails. This is crucial for CI tests.
set -ex
: ${CTEST_EXCLUSIONS:="broken"}
: ${CTEST_TEST_TIMEOUT:=60}
$OSL_ROOT/bin/testshade --help
echo "Parallel test " ${CTEST_PARALLEL_LEVEL}
pushd build/$PLATFORM
time ctest -C ${CMAKE_BUILD_TYPE} -E broken --force-new-ctest-process \
--output-on-failure --timeout ${CTEST_TEST_TIMEOUT:=180} ${CTEST_ARGS}
echo "Parallel test ${CTEST_PARALLEL_LEVEL}"
echo "Default timeout ${CTEST_TEST_TIMEOUT}"
echo "Test exclusions '${CTEST_EXCLUSIONS}'"
echo "CTEST_ARGS '${CTEST_ARGS}'"
pushd build
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process --output-on-failure \
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS} \
|| \
ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process \
--rerun-failed --repeat until-pass:5 -R render --output-on-failure \
--timeout ${CTEST_TEST_TIMEOUT} -E "${CTEST_EXCLUSIONS}" ${CTEST_ARGS}
# The weird construct above allows the render-* tests to run multiple times
popd
+2 -2
View File
@@ -73,7 +73,7 @@ from __future__ import print_function, absolute_import
###
### Only one main doc region will be output by the `docdeep` program,
### specified with the `-d` command line argument. Any other doc-regions
### will not be included in the documention output of that run.
### will not be included in the documentation output of that run.
###
### However, one doc-region may *include* the text of another doc-region
### as follows:
@@ -114,7 +114,7 @@ from __future__ import print_function, absolute_import
### For pre-code comments, the contiguous comment region associated with
### a declaration immediately precedes the declaration. Such a comment
### set has its first line start with `///>`. For post-code comments,
### the documentaiton comments follows the code declaration, and this is
### the documentation comments follows the code declaration, and this is
### designated by having its first line start with `///<`. I like to
### just remember that the `<` or `>` points in the direction of the code
### declaration that the comment applies to.
Binary file not shown.
+83 -15
View File
@@ -19,9 +19,44 @@ if [[ "$ASWF_ORG" != "" ]] ; then
#ls /etc/yum.repos.d
sudo yum install -y giflib giflib-devel && true
sudo yum install -y opencv opencv-devel && true
sudo yum install -y Field3D Field3D-devel && true
sudo yum install -y ffmpeg ffmpeg-devel && true
# sudo 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 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
@@ -31,21 +66,30 @@ else
time sudo apt-get -q install -y \
git cmake ninja-build ccache g++ \
libboost-dev libboost-thread-dev \
libboost-filesystem-dev libboost-regex-dev \
libboost-dev libboost-thread-dev libboost-filesystem-dev \
libilmbase-dev libopenexr-dev \
python-dev python-numpy \
libtiff-dev libgif-dev libpng-dev \
flex bison libbison-dev \
libpugixml-dev \
libopencolorio-dev \
qt5-default
libopencolorio-dev
time sudo apt-get -q install -y \
qt5-default || /bin/true
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH
if [[ "$CXX" == "g++-4.8" ]] ; then
time sudo apt-get install -y g++-4.8
elif [[ "$CXX" == "g++-6" ]] ; then
# Nonstandard python versions
if [[ "${PYTHON_VERSION}" == "3.9" ]] ; then
time sudo apt-get -q install -y python3.9-dev python3-numpy
pip3 --version
pip3 install numpy
elif [[ "$PYTHON_VERSION" == "2.7" ]] ; then
time sudo apt-get -q install -y python-dev python-numpy
else
pip3 install numpy
fi
if [[ "$CXX" == "g++-6" ]] ; then
time sudo apt-get install -y g++-6
elif [[ "$CXX" == "g++-7" ]] ; then
time sudo apt-get install -y g++-7
@@ -57,6 +101,20 @@ else
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
@@ -95,20 +153,30 @@ fi
# fi
if [[ "$OPENCOLORIO_VERSION" != "" ]] ; then
# Temporary (?) fix: GH ninja having problems, fall back to make
CMAKE_GENERATOR="Unix Makefiles" \
source src/build-scripts/build_opencolorio.bash
fi
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then
# There are many parts of OIIO we don't need to build
# There are many parts of OIIO we don't need to build for OSL's tests
export ENABLE_iinfo=0 ENABLE_iv=0 ENABLE_igrep=0
export ENABLE_iconvert=0 ENABLE_testtex=0
# For speed of compiling OIIO, disable the file formats that we don't
# need for OSL's tests
export ENABLE_BMP=0 ENABLE_cineon=0 ENABLE_DDS=0 ENABLE_DPX=0 ENABLE_FITS=0
export ENABLE_ICO=0 ENABLE_iff=0 ENABLE_jpeg2000=0 ENABLE_PNM=0 ENABLE_PSD=0
export ENABLE_RLA=0 ENABLE_SGI=0 ENABLE_SOCKET=0 ENABLE_SOFTIMAGE=0
export ENABLE_TARGA=0 ENABLE_WEBP=0
export OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0"
# We don't need to run OIIO's tests
export OPENIMAGEIO_CMAKE_FLAGS+=" -DOIIO_BUILD_TESTING=OFF -DOIIO_BUILD_TESTS=0"
# Don't let warnings in OIIO break OSL's CI run
export OPENIMAGEIO_CMAKE_FLAGS+=" -DSTOP_ON_WARNING=OFF"
export OPENIMAGEIO_CMAKE_FLAGS+=" -DUSE_OPENGL=0"
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
+2 -2
View File
@@ -5,9 +5,9 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# DEP_DIR="$PWD/ext/dist"
DEP_DIR="$PWD/dist/$PLATFORM"
DEP_DIR="$PWD/dist"
mkdir -p "$DEP_DIR"
INT_DIR="build/$PLATFORM"
INT_DIR="build"
VCPKG_INSTALLATION_ROOT=/c/vcpkg
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:=.}
+10 -6
View File
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# This script, which assumes it is runnign on a Mac OSX with Homebrew
# This script, which assumes it is running on a Mac OSX with Homebrew
# installed, does a "brew install" in all packages reasonably needed by
# OSL and its dependencies.
@@ -20,20 +20,24 @@ if [[ `which brew` == "" ]] ; then
fi
#brew update >/dev/null
if [[ "$DO_BREW_UPDATE" != "" ]] ; then
brew update >/dev/null
fi
echo ""
echo "Before my brew installs:"
brew list --versions
brew install --display-times -q gcc ccache cmake ninja boost || true
brew link --overwrite gcc
brew install --display-times -q python@${PYTHON_VERSION} || true
brew unlink python@2.7 || true
brew unlink python@3.9 || true
brew unlink python@3.8 || true
brew unlink python@3.9 || true
brew unlink python@3.10 || true
brew link --overwrite --force python@${PYTHON_VERSION} || true
brew upgrade --display-times -q cmake || true
brew install --display-times -q libtiff ilmbase openexr
brew install --display-times -q libpng giflib webp jpeg-turbo freetype
brew install --display-times -q ilmbase openexr
#brew install --display-times -q freetype
brew install --display-times -q opencolorio partio pugixml
brew install --display-times -q pybind11 numpy || true
brew install --display-times -q tbb || true
@@ -57,7 +61,7 @@ fi
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 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
-5
View File
@@ -1,5 +0,0 @@
leak:Imf_2_2
leak:Imf_2_3
leak:Imf_2_4
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
+1
View File
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
+11 -4
View File
@@ -8,7 +8,7 @@ include(CMakeFindDependencyMacro)
# add here all the find_dependency() whenever switching to config based dependencies
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 3.0)
find_dependency(Imath @OpenEXR_VERSION@)
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@)
@@ -19,9 +19,16 @@ endif ()
find_dependency(OpenImageIO @OpenImageIO_VERSION@ REQUIRED)
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set_and_check (@PROJECT_NAME@_INCLUDES "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set_and_check (@PROJECT_NAME@_LIB_DIR "@CMAKE_INSTALL_FULL_LIBDIR@")
# Compute the installation prefix relative to this file
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
# There's no guarantee that CMAKE_INSTALL_XXXDIR is a relative path so we extract the final component to handle absolute paths
get_filename_component(_INCLUDE_DIR_NAME "@CMAKE_INSTALL_INCLUDEDIR@" NAME)
get_filename_component(_LIB_DIR_NAME "@CMAKE_INSTALL_LIBDIR@" NAME)
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_INCLUDES "${_IMPORT_PREFIX}/${_INCLUDE_DIR_NAME}")
set_and_check (@PROJECT_NAME@_LIB_DIR "${_IMPORT_PREFIX}/${_LIB_DIR_NAME}")
#...logic to determine installedPrefix from the own location...
#set (@PROJECT_NAME@_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@")
+65 -20
View File
@@ -3,10 +3,27 @@
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
set (REQUIED_DEPS "" CACHE STRING
set (REQUIRED_DEPS "" CACHE STRING
"Additional dependencies to consider required (semicolon-separated list, or ALL)")
set (OPTIONAL_DEPS "" CACHE STRING
"Additional dependencies to consider optional (semicolon-separated list, or ALL)")
option (ALWAYS_PREFER_CONFIG "Prefer a dependency's exported config file if it's available" OFF)
# Utility function to list the names and values of all variables matching
# the pattern (case-insensitive)
function (dump_matching_variables pattern)
string (TOLOWER ${pattern} _pattern_lower)
get_cmake_property(_allvars VARIABLES)
list (SORT _allvars)
foreach (_var IN LISTS _allvars)
string (TOLOWER ${_var} _var_lower)
if (_var_lower MATCHES ${_pattern_lower})
message (STATUS " ${_var} = ${${_var}}")
endif ()
endforeach ()
endfunction ()
# checked_find_package(Pkgname ...) is a wrapper for find_package, with the
@@ -20,8 +37,11 @@ set (OPTIONAL_DEPS "" CACHE STRING
# turned off explicitly from one of these sources.
# * Print a message if the package is enabled but not found. This is based
# on ${Pkgname}_FOUND or $PKGNAME_FOUND.
# * Optional DEFINITIONS <string> are passed to add_definitions if the
# * Optional DEFINITIONS <string>... are passed to add_definitions if the
# package is found.
# * Optional SETVARIABLES <id>... is a list of CMake variables to set to
# TRUE if the package is found (they will not be set or changed if the
# package is not found).
# * Optional PRINT <list> is a list of variables that will be printed
# if the package is found, if VERBOSE is on.
# * Optional DEPS <list> is a list of hard dependencies; for each one, if
@@ -42,6 +62,10 @@ set (OPTIONAL_DEPS "" CACHE STRING
# version, accepting but warning if it is below this number (even
# if above the true minimum version accepted). The warning message
# can give an optional explanation, passed as RECOMMEND_MIN_REASON.
# * Optional PREFER_CONFIG, if supplied, tries to use an exported config
# file from the package before using a FindPackage.cmake module.
# * Optional DEBUG turns on extra debugging information related to how
# this package is found.
#
# N.B. This needs to be a macro, not a function, because the find modules
# will set(blah val PARENT_SCOPE) and we need that to be the global scope,
@@ -49,16 +73,20 @@ set (OPTIONAL_DEPS "" CACHE STRING
macro (checked_find_package pkgname)
cmake_parse_arguments(_pkg # prefix
# noValueKeywords:
"REQUIRED"
"REQUIRED;PREFER_CONFIG;DEBUG"
# singleValueKeywords:
"ENABLE;ISDEPOF;VERSION_MIN;VERSION_MAX;RECOMMEND_MIN;RECOMMEND_MIN_REASON"
# multiValueKeywords:
"DEFINITIONS;PRINT;DEPS"
"DEFINITIONS;PRINT;DEPS;SETVARIABLES"
# argsToParse:
${ARGN})
string (TOLOWER ${pkgname} pkgname_lower)
string (TOUPPER ${pkgname} pkgname_upper)
if (NOT VERBOSE)
set (_pkg_VERBOSE ${VERBOSE})
if (_pkg_DEBUG)
set (_pkg_VERBOSE ON)
endif ()
if (NOT _pkg_VERBOSE)
set (${pkgname}_FIND_QUIETLY true)
set (${pkgname_upper}_FIND_QUIETLY true)
endif ()
@@ -85,8 +113,19 @@ macro (checked_find_package pkgname)
set (_quietskip true)
endif ()
endif ()
set (_config_status "")
if (_enable OR _pkg_REQUIRED)
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
# was already found
elseif (_pkg_PREFER_CONFIG OR ALWAYS_PREFER_CONFIG)
find_package (${pkgname} CONFIG ${_pkg_UNPARSED_ARGUMENTS})
if (${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
set (_config_status "from CONFIG")
endif ()
endif ()
if (NOT (${pkgname}_FOUND OR ${pkgname_upper}_FOUND))
find_package (${pkgname} ${_pkg_UNPARSED_ARGUMENTS})
endif()
if ((${pkgname}_FOUND OR ${pkgname_upper}_FOUND)
AND ${pkgname}_VERSION
AND (_pkg_VERSION_MIN OR _pkg_VERSION_MAX))
@@ -106,21 +145,11 @@ macro (checked_find_package pkgname)
set (${pkgname}_VERSION ${${_vervar}})
endif ()
endforeach ()
message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${ColorReset}")
if (VERBOSE)
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
${_pkg_PRINT})
list (REMOVE_DUPLICATES _vars_to_print)
foreach (_v IN LISTS _vars_to_print)
if (NOT "${${_v}}" STREQUAL "")
message (STATUS " ${_v} = ${${_v}}")
endif ()
endforeach ()
endif ()
message (STATUS "${ColorGreen}Found ${pkgname} ${${pkgname}_VERSION} ${_config_status}${ColorReset}")
add_definitions (${_pkg_DEFINITIONS})
foreach (_v IN LISTS _pkg_SETVARIABLES)
set (${_v} TRUE)
endforeach ()
if (_pkg_RECOMMEND_MIN)
if (${${pkgname}_VERSION} VERSION_LESS ${_pkg_RECOMMEND_MIN})
message (STATUS "${ColorYellow}Recommend ${pkgname} >= ${_pkg_RECOMMEND_MIN} ${_pkg_RECOMMEND_MIN_REASON} ${ColorReset}")
@@ -148,6 +177,22 @@ macro (checked_find_package pkgname)
message (FATAL_ERROR "${ColorRed}${pkgname} is required, aborting.${ColorReset}")
endif ()
endif()
if (_pkg_VERBOSE AND (${pkgname}_FOUND OR ${pkgname_upper}_FOUND OR _pkg_DEBUG))
if (_pkg_DEBUG)
dump_matching_variables (${pkgname})
endif ()
set (_vars_to_print ${pkgname}_INCLUDES ${pkgname_upper}_INCLUDES
${pkgname}_INCLUDE_DIR ${pkgname_upper}_INCLUDE_DIR
${pkgname}_INCLUDE_DIRS ${pkgname_upper}_INCLUDE_DIRS
${pkgname}_LIBRARIES ${pkgname_upper}_LIBRARIES
${_pkg_PRINT})
list (REMOVE_DUPLICATES _vars_to_print)
foreach (_v IN LISTS _vars_to_print)
if (NOT "${${_v}}" STREQUAL "")
message (STATUS " ${_v} = ${${_v}}")
endif ()
endforeach ()
endif ()
else ()
if (NOT _quietskip)
message (STATUS "${ColorRed}Not using ${pkgname} -- disabled ${_disablereason} ${ColorReset}")
+75 -77
View File
@@ -27,11 +27,13 @@ message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
###########################################################################
# C++ language standard
#
set (CMAKE_CXX_STANDARD 11 CACHE STRING
"C++ standard to prefer (11, 14, 17, 20, etc.)")
set (CMAKE_CXX_STANDARD 14 CACHE STRING
"C++ standard to build with (14, 17, 20, etc.)")
set (DOWNSTREAM_CXX_STANDARD 14 CACHE STRING
"C++ minimum standard to impose on downstream clients")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
message (STATUS "Building for C++${CMAKE_CXX_STANDARD}")
message (STATUS "Building with C++${CMAKE_CXX_STANDARD}, downstream minimum C++${DOWNSTREAM_CXX_STANDARD}")
###########################################################################
@@ -49,7 +51,8 @@ else ()
set (GCC_VERSION 0)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang"
OR CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
# If using any flavor of clang, set CMAKE_COMPILER_IS_CLANG. If it's
# Apple's variety, set CMAKE_COMPILER_IS_APPLECLANG and
# APPLECLANG_VERSION_STRING, otherwise for generic clang set
@@ -63,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)
@@ -80,10 +89,14 @@ endif ()
###########################################################################
# Turn on more detailed warnings and optionally consider warnings as errors
#
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
option (STOP_ON_WARNING "Stop building if there are any compiler warnings" OFF)
else ()
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)
@@ -91,10 +104,8 @@ if (NOT MSVC)
if (EXTRA_WARNINGS)
add_compile_options ("-Wextra")
endif ()
if (STOP_ON_WARNING OR DEFINED ENV{${PROJECT_NAME}_CI})
if (STOP_ON_WARNING)
add_compile_options ("-Werror")
# N.B. Force CI builds to use -Werror, even if STOP_ON_WARNING has
# been switched off by default, which we may do in release branches.
endif ()
endif ()
@@ -114,7 +125,7 @@ set (CXX_VISIBILITY_PRESET "hidden" CACHE STRING "Symbol visibility (hidden or d
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
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
@@ -138,6 +149,7 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
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
@@ -147,9 +159,16 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
add_compile_options ("-Wno-unused-local-typedefs")
endif ()
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.9)
# Don't warn about using unknown preprocessor symbols in #if'set
# Don't warn about using unknown preprocessor symbols in `#if`
add_compile_options ("-Wno-expansion-to-defined")
endif ()
# Suppress warnings about our strategic use of bitwise operations in place
# of logical operators to produce branchless code in some places.
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 14.0
OR 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")
@@ -177,9 +196,14 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
add_compile_options ("-fno-math-errno")
endif ()
if (INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 2022.1.0)
# New versions of icx warn about changing certain floating point options
add_compile_options ("-Wno-overriding-t-option")
endif ()
if (MSVC)
# Microsoft specific options
add_compile_options (/W1)
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)
@@ -194,6 +218,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
endif ()
# Remember the -std flags we need will be used later for custom Cuda builds
set (CSTD_FLAGS "")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_INTEL)
set (CSTD_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
@@ -201,6 +226,10 @@ endif ()
# We will use this for ccache and timing
set (MY_RULE_LAUNCH "")
###########################################################################
# Use ccache if found
#
@@ -304,6 +333,33 @@ if (NOT USE_SIMD STREQUAL "")
add_compile_options (${SIMD_COMPILE_FLAGS})
endif ()
###########################################################################
# Batched SIMD shader execution options.
#
# The USE_BATCHED option may be set to indicate that support for batched
# SIMD shader execution be compiled along with targe specific libraries
set (USE_BATCHED "" CACHE STRING "Build batched SIMD shader execution for (0, b8_AVX, b8_AVX2, b8_AVX2_noFMA, b8_AVX512, b8_AVX512_noFMA, b16_AVX512, b16_AVX512_noFMA)")
option (VEC_REPORT "Enable compiler's reporting system for vectorization" OFF)
set (BATCHED_SUPPORT_DEFINES "")
set (BATCHED_TARGET_LIBS "")
set (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 ()
set (BATCHED_SUPPORT_DEFINES ${BATCHED_SUPPORT_DEFINES} "__OSL_SUPPORTS_${batched_target}")
endforeach()
else ()
message (STATUS "Compiling with NO batched SIMD targets, USE_BATCHED=0")
endif ()
else ()
message (STATUS "Compiling with NO batched SIMD targets, USE_BATCHED is empty")
endif ()
###########################################################################
# Preparation to test for compiler/language features
@@ -313,26 +369,6 @@ endif ()
include (CMakePushCheckState)
include (CheckCXXSourceRuns)
###########################################################################
# Find out if it's safe for us to use std::regex or if we need boost.regex.
# This is primarily about gcc 4.8 having a broken regex implementation.
# This will be obsolete once our minimum supported gcc is >= 4.9.
#
cmake_push_check_state ()
check_cxx_source_runs("
#include <regex>
int main() {
std::string r = std::regex_replace(std::string(\"abc\"), std::regex(\"b\"), \" \");
return r == \"a c\" ? 0 : -1;
}"
USE_STD_REGEX)
cmake_pop_check_state ()
if (USE_STD_REGEX)
add_definitions (-DUSE_STD_REGEX)
else ()
add_definitions (-DUSE_BOOST_REGEX)
endif ()
###########################################################################
# Code coverage options
@@ -340,11 +376,9 @@ endif ()
option (CODECOV "Build code coverage tests" OFF)
if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
message (STATUS "Compiling for code coverage analysis")
add_compile_options ("-ftest-coverage -fprofile-arcs -O0")
add_compile_options (-ftest-coverage -fprofile-arcs)
add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
link_libraries(gcov)
endif ()
@@ -358,22 +392,9 @@ if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
foreach (feature ${SANITIZE_FEATURE_LIST})
message (STATUS " sanitize feature: ${feature}")
add_compile_options (-fsanitize=${feature})
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${feature}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=${feature}")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${feature}")
add_link_options (-fsanitize=${feature})
endforeach()
add_compile_options (-g -fno-omit-frame-pointer)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (SANITIZE_ON_LINUX 1)
endif ()
if (CMAKE_COMPILER_IS_GNUCC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_compile_options ("-fuse-ld=gold")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=gold")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
set (SANITIZE_LIBRARIES "asan;pthread")
# set (SANITIZE_LIBRARIES "asan" "ubsan")
endif()
if (CMAKE_COMPILER_IS_GNUCC)
# turn on glibcxx extra annotations to find vector writes past end
add_definitions ("-D_GLIBCXX_SANITIZE_VECTOR=1")
@@ -439,40 +460,17 @@ endif ()
# is being built as a subproject.
if (PROJECT_IS_TOP_LEVEL)
set (CLANG_FORMAT_EXE_HINT "" CACHE PATH "clang-format executable's directory (will search if not specified")
set (CLANG_FORMAT_INCLUDES # "src/*.h" "src/*.cpp"
"src/include/*.h"
"src/liboslcomp/*.cpp"
"src/liboslcomp/*.h"
"src/liboslquery/*.cpp"
"src/liboslquery/*.h"
"src/oslinfo/*.cpp"
"src/oslc/*.cpp"
"src/osl.imageio/*.cpp"
"src/osltoy/*.cpp"
"src/osltoy/*.h"
"testsuite/*.cpp"
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"
# Files that are currently being modified with the SIMD batch
# shading -- we'll reformat those only after that project work is
# completed, to avoid nasty merge conflicts.
"src/include/OSL/rendererservices.h"
"src/include/OSL/*llvm*"
"src/liboslexec/*llvm*"
"src/liboslexec/oslexec_pvt.h"
# Files that are currently being modified with the OptiX work --
# we'll reformat those only after that project work is completed, to
# avoid nasty merge conflicts.
"src/include/OSL/device_string.h"
"src/include/OSL/oslexec.h"
"src/testrender/cuda/*"
# Header files in testsuite are almost certainly osl headers, not C++
"testsuite/*.h"
""
# 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
+24 -6
View File
@@ -2,14 +2,17 @@
# 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 ptx_generated extra_nvcc_args )
function ( NVCC_COMPILE cuda_src extra_headers ptx_generated extra_nvcc_args )
get_filename_component ( cuda_src_we ${cuda_src} NAME_WE )
get_filename_component ( cuda_src_dir ${cuda_src} DIRECTORY )
set (cuda_ptx "${CMAKE_CURRENT_BINARY_DIR}/${cuda_src_we}.ptx" )
set (${ptxlist} ${${ptxlist}} ${cuda_ptx} )
set (${ptx_generated} ${cuda_ptx} PARENT_SCOPE)
file ( GLOB cuda_headers "${cuda_src_dir}/*.h" )
list (APPEND cuda_headers ${extra_headers})
list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
@@ -34,8 +37,9 @@ function ( NVCC_COMPILE cuda_src ptx_generated extra_nvcc_args )
${LLVM_COMPILE_FLAGS}
-DOSL_USE_FAST_MATH=1
-m64 -arch ${CUDA_TARGET_ARCH} -ptx
--std=c++${CMAKE_CXX_STANDARD} -dc -O3 --use_fast_math --expt-relaxed-constexpr
--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
@@ -76,6 +80,20 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
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")
@@ -105,13 +123,13 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
${ALL_IMATH_INCLUDES}
${ALL_OPENEXR_INCLUDES}
"-I${Boost_INCLUDE_DIRS}"
${LLVM_COMPILE_FLAGS} ${CUDA_LIB_FLAGS}
${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_DIRECTORY}/bin/llvm-as" -f -o ${bc_cuda} ${asm_cuda}
COMMAND ${LLVM_AS_TOOL} -f -o ${bc_cuda} ${asm_cuda}
DEPENDS ${exec_headers} ${PROJECT_PUBLIC_HEADERS} ${src}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
@@ -126,8 +144,8 @@ function ( LLVM_COMPILE_CUDA llvm_src headers prefix llvm_bc_cpp_generated extra
MAKE_CUDA_BITCODE (${llvm_src} "" llvm_bc "${extra_clang_args}")
add_custom_command (OUTPUT ${llvm_bc_cpp}
COMMAND python "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
COMMAND ${Python_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_bc} ${llvm_bc_cpp} ${prefix}
MAIN_DEPENDENCY ${llvm_src}
DEPENDS "${CMAKE_SOURCE_DIR}/src/liboslexec/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
DEPENDS "${CMAKE_SOURCE_DIR}/src/build-scripts/serialize-bc.py" ${llvm_src} ${headers} ${llvm_bc}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
endfunction ()
+18 -39
View File
@@ -49,9 +49,6 @@ if (BOOST_CUSTOM)
# Boost_VERSION, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES.
else ()
set (Boost_COMPONENTS filesystem system thread)
if (NOT USE_STD_REGEX)
list (APPEND Boost_COMPONENTS regex)
endif ()
# The FindBoost.cmake interface is broken if it uses boost's installed
# cmake output (e.g. boost 1.70.0, cmake <= 3.14). Specifically it fails
# to set the expected variables printed below. So until that's fixed
@@ -83,22 +80,18 @@ checked_find_package (ZLIB REQUIRED) # Needed by several packages
# IlmBase & OpenEXR
checked_find_package (OpenEXR REQUIRED
VERSION_MIN 2.0
RECOMMEND_MIN 2.2
VERSION_MIN 2.3
RECOMMEND_MIN 2.4
RECOMMEND_MIN_REASON
"OpenEXR 2.2 is the oldest version our CI tests against, and the minimum that supports DWA compression"
"Even extremely critical patches are no longer supplied to < 2.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 shoudn't be necessary, except for the common case of people
# library. This shouldn't be necessary, except for the common case of people
# building against Imath/OpenEXR 3.x when there is still a system-level
# install version of 2.x.
include_directories(BEFORE ${IMATH_INCLUDES})
if (CMAKE_COMPILER_IS_CLANG AND OPENEXR_VERSION VERSION_LESS 2.3)
# clang C++ >= 11 doesn't like 'register' keyword in old exr headers
add_compile_options (-Wno-deprecated-register)
endif ()
if (MSVC AND NOT LINKSTATIC)
add_definitions (-DOPENEXR_DLL) # Is this needed for new versions?
endif ()
@@ -111,15 +104,9 @@ endif ()
# OpenImageIO
set (OIIO_LIBNAME_SUFFIX "" CACHE STRING
"Optional name appended to OIIO libraries that are built")
checked_find_package (OpenImageIO REQUIRED
VERSION_MIN 2.0
PRINT OIIOTOOL_BIN)
if (OPENIMAGEIO_FOUND)
include_directories ("${OPENIMAGEIO_INCLUDES}")
endif ()
VERSION_MIN 2.3.17
DEFINITIONS -DOIIO_HIDE_FORMAT=1)
checked_find_package (pugixml REQUIRED
VERSION_MIN 1.8)
@@ -127,7 +114,7 @@ checked_find_package (pugixml REQUIRED
# LLVM library setup
checked_find_package (LLVM REQUIRED
VERSION_MIN 7.0
VERSION_MIN 9.0
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
@@ -140,27 +127,23 @@ add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}")
if (LLVM_NAMESPACE)
add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}")
endif ()
if (LLVM_VERSION VERSION_GREATER_EQUAL 10.0.0 AND
CMAKE_CXX_STANDARD VERSION_LESS 14)
message (FATAL_ERROR
"LLVM 10+ requires C++14 or higher (was ${CMAKE_CXX_STANDARD}). "
"To build against this LLVM ${LLVM_VERSION}, you need to set "
"build option CMAKE_CXX_STANDARD=14. The minimum requirements "
"for that are gcc >= 5.1, clang >= 3.5, Apple clang >= 7, "
"icc >= 7, MSVS >= 2017. "
"If you must use C++11, you need to build against LLVM 9 or earlier.")
endif ()
if (APPLE AND LLVM_VERSION VERSION_EQUAL 10.0.1 AND EXISTS "/usr/local/Cellar/llvm")
message (WARNING
"${ColorYellow}If you are using LLVM 10.0.1 installed by Homebrew, "
"please note that a known bug in LLVM may produce a link error where "
"it says it can't find libxml2.tbd. If you encounter this, please "
"try downgrading to LLVM 9: \n"
" brew uninstall llvm \n"
" brew install llvm@9 \n"
" export LLVM_DIRECTORY=/usr/local/opt/llvm@9 "
"try upgrading to a newer LLVM: \n"
" brew upgrade llvm \n"
"${ColorReset}\n")
endif ()
if (LLVM_VERSION VERSION_GREATER_EQUAL 15.0
AND ( (CMAKE_COMPILER_IS_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 ()
checked_find_package (partio)
@@ -203,10 +186,6 @@ if (USE_CUDA OR USE_OPTIX)
message (FATAL_ERROR "NVPTX target is not available in the provided LLVM build")
endif()
if (${CUDA_VERSION} VERSION_GREATER 8 AND ${LLVM_VERSION} VERSION_LESS 6)
message (FATAL_ERROR "CUDA ${CUDA_VERSION} requires LLVM 6.0 or greater")
endif ()
set (CUDA_LIB_FLAGS "--cuda-path=${CUDA_TOOLKIT_ROOT_DIR}")
find_library(cuda_lib NAMES cudart
@@ -227,7 +206,7 @@ if (USE_CUDA OR USE_OPTIX)
# OptiX setup
if (USE_OPTIX)
checked_find_package (OptiX REQUIRED
VERSION_MIN 5.1)
VERSION_MIN 7.0)
include_directories (BEFORE "${OPTIX_INCLUDES}")
if (NOT USE_LLVM_BITCODE OR NOT USE_FAST_MATH)
message (FATAL_ERROR "Enabling OptiX requires USE_LLVM_BITCODE=1 and USE_FAST_MATH=1")
+8 -2
View File
@@ -12,6 +12,9 @@
# The executable may be disabled individually using any of the usual
# check_is_enabled() conventions (e.g. -DENABLE_<executable>=OFF).
#
# If -DENABLE_INSTALL_<executable>=OFF was specified, the target will be built
# (in the build area) but will not be installed.
#
# Usage:
#
# fancy_add_executable ([ NAME targetname ... ]
@@ -42,13 +45,16 @@ macro (fancy_add_executable)
target_include_directories (${_target_NAME} SYSTEM PRIVATE ${_target_SYSTEM_INCLUDE_DIRS})
endif ()
if (_target_DEFINITIONS)
target_compile_definitions (${_target_name} PRIVATE ${_target_DEFINITIONS})
target_compile_definitions (${_target_NAME} PRIVATE ${_target_DEFINITIONS})
endif ()
if (_target_LINK_LIBRARIES)
target_link_libraries (${_target_NAME} PRIVATE ${_target_LINK_LIBRARIES})
endif ()
set_target_properties (${_target_NAME} PROPERTIES FOLDER "Tools")
install_targets (${_target_NAME})
check_is_enabled (INSTALL_${_target_NAME} _target_NAME_INSTALL_enabled)
if (_target_NAME_INSTALL_enabled)
install_targets (${_target_NAME})
endif ()
else ()
message (STATUS "${ColorRed}Disabling ${_target_NAME} ${ColorReset}")
endif ()
+19 -3
View File
@@ -17,11 +17,27 @@
# for the .y and .l files.
checked_find_package (BISON REQUIRED)
checked_find_package (FLEX REQUIRED)
# 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()
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 (VERBOSE)
message (STATUS "FLEX_BISON flex=${flexsrc} bison=${bisonsrc} prefix=${prefix}")
endif ()
@@ -56,7 +72,7 @@ if ( FLEX_EXECUTABLE AND BISON_EXECUTABLE )
set ( FB_WINCOMPAT )
endif ()
add_custom_command ( OUTPUT ${flexoutputcxx}
COMMAND ${FLEX_EXECUTABLE} ${FB_WINCOMPAT} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}"
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} )
+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 ( )
-136
View File
@@ -1,136 +0,0 @@
###########################################################################
# OpenImageIO https://www.openimageio.org
# Copyright 2008-present Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md
#
# For an up-to-date version of this file, see:
# https://github.com/OpenImageIO/oiio/blob/master/src/cmake/Modules/FindOpenImageIO.cmake
#
###########################################################################
#
# CMake module to find OpenImageIO
#
# This module will set
# OPENIMAGEIO_FOUND True, if found
# OPENIMAGEIO_INCLUDES directory where headers are found
# OPENIMAGEIO_LIBRARIES libraries for OIIO
# OPENIMAGEIO_LIBRARY_DIRS library dirs for OIIO
# OPENIMAGEIO_VERSION Version ("major.minor.patch.tweak")
# OPENIMAGEIO_VERSION_MAJOR Version major number
# OPENIMAGEIO_VERSION_MINOR Version minor number
# OPENIMAGEIO_VERSION_PATCH Version minor patch
# OPENIMAGEIO_VERSION_TWEAK Version minor tweak
# OIIOTOOL_BIN Path to oiiotool executable
#
# Imported targets:
# OpenImageIO::OpenImageIO The libOpenImageIO library.
# OpenImageIO::oiiotool The oiiotool executable.
#
# Special inputs:
# OpenImageIO_ROOT - if using CMake >= 3.12, will automatically search
# this area for OIIO components.
# OPENIMAGEIO_ROOT_DIR - custom "prefix" location of OIIO installation
# (expecting bin, lib, include subdirectories)
# This is deprecated, but will work for a while.
# OpenImageIO_FIND_QUIETLY - if set, print minimal console output
# OIIO_LIBNAME_SUFFIX - if set, optional nonstandard library suffix
#
###########################################################################
#
# NOTE: This file is deprecated.
#
# In OIIO 2.1+, we generate OpenImageIOConfig.cmake files that are now the
# preferred way for downstream projects to find an installed OIIO. There
# should be no need to copy this FindOpenImageIO.cmake file into downstream
# projects, *unless* they need to work with a range of OIIO versions that
# may include <2.1, which would lack the generated config files.
#
###########################################################################
# Prefer an OpenImageIO cmake config file if it can be found
find_package(OpenImageIO CONFIG)
if (TARGET OpenImageIO::OpenImageIO)
set (OPENIMAGEIO_VERSION ${OpenImageIO_VERSION})
else ()
# If 'OPENIMAGE_HOME' not set, use the env variable of that name if available
if (NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "")
set (OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR})
endif ()
find_library ( OPENIMAGEIO_LIBRARY
NAMES OpenImageIO${OIIO_LIBNAME_SUFFIX}
HINTS ${OPENIMAGEIO_ROOT_DIR}
PATH_SUFFIXES lib64 lib )
find_path ( OPENIMAGEIO_INCLUDE_DIR
NAMES OpenImageIO/imageio.h
HINTS ${OPENIMAGEIO_ROOT_DIR} )
find_program ( OIIOTOOL_BIN
NAMES oiiotool
HINTS ${OPENIMAGEIO_ROOT_DIR} )
# Try to figure out version number
set (OIIO_VERSION_HEADER "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h")
if (EXISTS "${OIIO_VERSION_HEADER}")
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MAJOR .*$")
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MAJOR ${TMP})
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MINOR .*$")
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MINOR ${TMP})
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_PATCH .*$")
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_PATCH ${TMP})
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_TWEAK .*$")
if (TMP)
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_TWEAK ${TMP})
else ()
set (OPENIMAGEIO_VERSION_TWEAK 0)
endif ()
set (OPENIMAGEIO_VERSION "${OPENIMAGEIO_VERSION_MAJOR}.${OPENIMAGEIO_VERSION_MINOR}.${OPENIMAGEIO_VERSION_PATCH}.${OPENIMAGEIO_VERSION_TWEAK}")
endif ()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (OpenImageIO
FOUND_VAR OPENIMAGEIO_FOUND
REQUIRED_VARS OPENIMAGEIO_INCLUDE_DIR OPENIMAGEIO_LIBRARY
OPENIMAGEIO_VERSION
VERSION_VAR OPENIMAGEIO_VERSION
)
if (OPENIMAGEIO_FOUND)
set (OpenImageIO_VERSION ${OPENIMAGEIO_VERSION})
set (OPENIMAGEIO_INCLUDES ${OPENIMAGEIO_INCLUDE_DIR})
set (OpenImageIO_INCLUDES ${OPENIMAGEIO_INCLUDE_DIR})
set (OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
get_filename_component (OPENIMAGEIO_LIBRARY_DIRS "${OPENIMAGEIO_LIBRARY}" DIRECTORY)
if (NOT OpenImageIO_FIND_QUIETLY)
message ( STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDE_DIR}" )
message ( STATUS "OpenImageIO libraries = ${OPENIMAGEIO_LIBRARIES}" )
message ( STATUS "OpenImageIO library_dirs = ${OPENIMAGEIO_LIBRARY_DIRS}" )
message ( STATUS "OpenImageIO oiiotool = ${OIIOTOOL_BIN}" )
endif ()
if (NOT TARGET OpenImageIO::OpenImageIO)
add_library(OpenImageIO::OpenImageIO UNKNOWN IMPORTED)
set_target_properties(OpenImageIO::OpenImageIO PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENIMAGEIO_INCLUDES}")
set_property(TARGET OpenImageIO::OpenImageIO APPEND PROPERTY
IMPORTED_LOCATION "${OPENIMAGEIO_LIBRARIES}")
endif ()
if (NOT TARGET OpenImageIO::oiiotool AND EXISTS "${OIIOTOOL_BIN}")
add_executable(OpenImageIO::oiiotool IMPORTED)
set_target_properties(OpenImageIO::oiiotool PROPERTIES
IMPORTED_LOCATION "${OIIOTOOL_BIN}")
endif ()
endif ()
mark_as_advanced (
OPENIMAGEIO_INCLUDE_DIR
OPENIMAGEIO_LIBRARY
)
endif ()
+1 -1
View File
@@ -10,7 +10,7 @@
# PARTIO_LIBRARIES - library to link against
# PARTIO_FOUND - true if Partio was found.
# Hack! perfer a config if it can be found
# Hack! prefer a config if it can be found
find_package(partio CONFIG)
if (PARTIO_FOUND OR partio_FOUND)
if (VERBOSE)
+1 -1
View File
@@ -1,4 +1,4 @@
# Copyright Contributors to the Open Shading Languge project.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
+2 -2
View File
@@ -64,7 +64,7 @@ macro (setup_python_module)
set (target_name ${lib_TARGET})
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_COMPILER_ID} STREQUAL "Intel")
# Seems to be a problem on some systems, with pybind11 and python headers
set_property (SOURCE ${lib_SOURCES} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-macro-redefined ")
endif ()
@@ -77,7 +77,7 @@ macro (setup_python_module)
PRIVATE
pybind11::pybind11
Python::Python
${lib_LIBS} ${SANITIZE_LIBRARIES})
${lib_LIBS})
if (APPLE)
set_target_properties (${target_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif ()
+183 -43
View File
@@ -1,4 +1,4 @@
# Copyright Contributors to the Open Shading Languge project.
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/
@@ -16,6 +16,10 @@ add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/testsuite/runtest.py")
add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest.py" )
set (OSL_TEST_BIG_TIMEOUT 800 CACHE STRING "Timeout for tests that take a long time")
# add_one_testsuite() - set up one testsuite entry
#
# Usage:
@@ -26,10 +30,12 @@ add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest
# [COMMAND cmd...] - optional override of launch command
# )
#
macro (add_one_testsuite testname testsrcdir)
cmake_parse_arguments (_tst "" "" "ENV;COMMAND" ${ARGN})
set (testsuite "${CMAKE_SOURCE_DIR}/testsuite")
set (testdir "${CMAKE_BINARY_DIR}/testsuite/${testname}")
file (MAKE_DIRECTORY "${testdir}")
if (NOT _tst_COMMAND)
set (_tst_COMMAND ${Python_EXECUTABLE} "${testsuite}/runtest.py" ${testdir})
if (MSVC_IDE)
@@ -45,7 +51,17 @@ macro (add_one_testsuite testname testsrcdir)
OSL_TESTSUITE_SRC=${testsrcdir}
OSL_TESTSUITE_CUR=${testdir}
)
file (MAKE_DIRECTORY "${testdir}")
# We need to suppress the leak sanitizer for "texture" tests, because of a
# minor leak inside OIIO (140 bytes! -- inconsequential) but which we
# can't use the suppressions list becuase the leaks come from calls made
# inside JITed code for which there is not a good stack trace. Any real
# leaks from OIIO or its dependencies we assume will be caught by lsan on
# the OIIO side, where there is no JIT to complicate things.
if (${testname} MATCHES "^texture" OR ${testname} MATCHES "gettextureinfo")
list (APPEND _tst_ENV ASAN_OPTIONS=detect_leaks=0:$ENV{ASAN_OPTIONS})
endif ()
add_test ( NAME ${testname} COMMAND ${_tst_COMMAND} )
# message ("Test -- env ${_tst_ENV} cmd ${_tst_COMMAND}")
set_tests_properties (${testname} PROPERTIES ENVIRONMENT "${_tst_ENV}" )
@@ -53,10 +69,10 @@ macro (add_one_testsuite testname testsrcdir)
# from piling up together, allocate a few cores each.
if (${testname} MATCHES "^render-")
set_tests_properties (${testname} PROPERTIES LABELS render
PROCESSORS 4 COST 10)
PROCESSORS 4 COST 10 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
# Some labeling for fun
if (${testname} MATCHES "^texture-")
if (${testname} MATCHES "^texture")
set_tests_properties (${testname} PROPERTIES LABELS texture
PROCESSORS 2 COST 4)
endif ()
@@ -68,9 +84,15 @@ macro (add_one_testsuite testname testsrcdir)
set_tests_properties (${testname} PROPERTIES LABELS optix)
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "10.0")
# Make sure libnvrtc-builtins.so is reachable
set_property (TEST ${testname} APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CUDA_TOOLKIT_ROOT_DIR}/lib64)
set_property (TEST ${testname} APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CUDA_TOOLKIT_ROOT_DIR}/lib64:$ENV{LD_LIBRARY_PATH})
endif()
endif ()
if (${testname} MATCHES "-reg")
# These are batched shading regression tests. Some are quite
# long, so give them a higher cost and timeout.
set_tests_properties (${testname} PROPERTIES LABELS batchregression
COST 15 TIMEOUT ${OSL_TEST_BIG_TIMEOUT})
endif ()
endmacro ()
@@ -82,6 +104,8 @@ macro ( TESTSUITE )
set (_ats_LABEL "broken")
endif ()
set (test_all_optix $ENV{TESTSUITE_OPTIX})
set (test_all_batched $ENV{TESTSUITE_BATCHED})
set (test_all_rs_bitcode $ENV{TESTSUITE_RS_BITCODE})
# Add the tests if all is well.
set (ALL_TEST_LIST "")
set (_testsuite "${CMAKE_SOURCE_DIR}/testsuite")
@@ -98,9 +122,10 @@ macro ( TESTSUITE )
# Run the test unoptimized, unless it matches a few patterns that
# we don't test unoptimized (or has an OPTIMIZEONLY marker file).
if (NOT _testname MATCHES "^getattribute-shader" AND
NOT _testname MATCHES "optix" AND
NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
if (NOT _testname MATCHES "optix"
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}" "${_testsrcdir}"
ENV TESTSHADE_OPT=0 )
endif ()
@@ -108,10 +133,15 @@ macro ( TESTSUITE )
# optimization, triggered by setting TESTSHADE_OPT env variable.
# Skip OptiX-only tests and those with a NOOPTIMIZE marker file.
if (NOT _testname MATCHES "optix"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
AND NOT EXISTS "${_testsrcdir}/NOSCALAR"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION"
AND NOT EXISTS "${_testsrcdir}/NOOPTIMIZE")
add_one_testsuite ("${_testname}.opt" "${_testsrcdir}"
ENV TESTSHADE_OPT=2 )
endif ()
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
@@ -119,7 +149,8 @@ macro ( TESTSUITE )
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}/NOOPTIX-FIXME"
AND NOT EXISTS "${_testsrcdir}/BATCHED_REGRESSION")
# Unoptimized
if (NOT EXISTS "${_testsrcdir}/OPTIMIZEONLY")
add_one_testsuite ("${_testname}.optix" "${_testsrcdir}"
@@ -129,51 +160,128 @@ macro ( TESTSUITE )
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 and-or-not-synonyms arithmetic
array array-derivs array-range array-aassign
blackbody blendmath breakcont
TESTSUITE ( aastep allowconnect-err andor-reg and-or-not-synonyms
arithmetic area-reg arithmetic-reg
array array-reg array-copy-reg array-derivs array-range
array-aassign array-assign-reg array-length-reg
bitwise-and-reg bitwise-or-reg bitwise-shl-reg bitwise-shr-reg bitwise-xor-reg
blackbody blackbody-reg blendmath breakcont breakcont-reg
bug-array-heapoffsets bug-locallifetime bug-outputinit
bug-param-duplicate bug-peep bug-return
cellnoise closure closure-array color comparison
compile-buffer
calculatenormal-reg
cellnoise closure closure-array color color-reg colorspace comparison
complement-reg compile-buffer compassign-reg
component-range
connect-components
control-flow-reg connect-components
const-array-params const-array-fill
debugnan debug-uninit
derivs derivs-muldiv-clobber
draw_string
error-dupes error-serialized
example-deformer
example-batched-deformer
exit exponential
fprintf
filterwidth-reg
for-reg format-reg fprintf
function-earlyreturn function-simple function-outputelem
function-overloads function-redef
geomath getattribute-camera getattribute-shader
getsymbol-nonheap gettextureinfo
getsymbol-nonheap gettextureinfo gettextureinfo-reg
globals-needed
group-outputs groupstring
hash hashnoise hex hyperb
ieee_fp if incdec initlist initops intbits isconnected isconstant
ieee_fp ieee_fp-reg if if-reg incdec initlist
initops initops-instance-clash
intbits isconnected
isconstant
layers layers-Ciassign layers-entry layers-lazy layers-lazyerror
layers-nonlazycopy layers-repeatedoutputs
linearstep
logic loop matrix message
length-reg linearstep
logic loop luminance-reg
matrix matrix-reg matrix-arithmetic-reg
matrix-compref-reg max-reg message message-no-closure message-reg
mergeinstances-duplicate-entrylayers
mergeinstances-nouserdata mergeinstances-vararray
metadata-braces miscmath missing-shader
metadata-braces min-reg miscmath missing-shader
mix-reg
named-components
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
noise-gabor-reg
noise-generic
noise-perlin noise-simplex
pnoise pnoise-cell pnoise-gabor pnoise-perlin
noise-reg
normalize-reg
pnoise pnoise-cell pnoise-gabor
pnoise-generic pnoise-perlin
pnoise-reg
operator-overloading
opt-warnings
oslc-comma oslc-D oslc-M
@@ -187,8 +295,9 @@ macro (osl_add_all_tests)
oslc-err-outputparamvararray oslc-err-paramdefault
oslc-err-struct-array-init oslc-err-struct-ctr
oslc-err-struct-dup oslc-err-struct-print
oslc-err-type-as-variable
oslc-err-unknown-ctr
# oslc-pragma-warnerr
oslc-pragma-warnerr
oslc-warn-commainit
oslc-variadic-macro
oslc-version
@@ -197,14 +306,29 @@ macro (osl_add_all_tests)
osl-imageio
paramval-floatpromotion
pragma-nowarn
printf-reg
printf-whole-array
raytype raytype-specialized reparam
raytype raytype-reg raytype-specialized regex-reg reparam
render-background render-bumptest
render-cornell render-furnace-diffuse
render-microfacet render-oren-nayar render-veachmis render-ward
select shortcircuit spline splineinverse splineinverse-ident
render-mx-furnace-burley-diffuse
render-mx-furnace-oren-nayar
render-mx-furnace-sheen
render-mx-burley-diffuse
render-mx-dielectric render-mx-dielectric-glass
render-mx-conductor
render-mx-generalized-schlick render-mx-generalized-schlick-glass
render-mx-layer
render-mx-sheen
render-microfacet render-oren-nayar
render-uv render-veachmis render-ward
select select-reg shaderglobals shortcircuit
smoothstep-reg
spline spline-reg splineinverse splineinverse-ident
splineinverse-knots-ascend-reg splineinverse-knots-descend-reg
spline-boundarybug spline-derivbug
string
split-reg
string string-reg
struct struct-array struct-array-mixture
struct-err struct-init-copy
struct-isomorphic-overload struct-layers
@@ -214,33 +338,40 @@ macro (osl_add_all_tests)
testshade-expr
texture-alpha texture-alpha-derivs
texture-blur texture-connected-options
texture-derivs texture-errormsg
texture-derivs texture-environment texture-errormsg
texture-environment-opts-reg
texture-firstchannel texture-interp
texture-missingalpha texture-missingcolor texture-simple
texture-missingalpha texture-missingcolor texture-opts-reg texture-simple
texture-smallderivs texture-swirl texture-udim
texture-width texture-withderivs texture-wrap
trace-reg
trailing-commas
transcendental-reg
transitive-assign
transform transformc trig typecast
transform transform-reg transformc transformc-reg trig trig-reg
typecast
unknown-instruction
userdata userdata-passthrough
vararray-connect vararray-default
vararray-deserialize vararray-param
vecctr vector
wavelength_color Werror xml )
vecctr vector vector-reg
wavelength_color wavelength_color-reg Werror xml xml-reg )
if (OPENIMAGEIO_VERSION VERSION_GREATER_EQUAL 2.1)
# I'm too lazy to set this test up to work with OIIO versions too
# old to have proper exported cmake config files. So just skip it
# for OIIO 2.0.
TESTSUITE (example-deformer)
# 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 on Linux,
# because the Python interpreter itself won't be linked with the right asan
# We also exclude these tests if this is a sanitizer build, because the
# Python interpreter itself won't be linked with the right asan
# libraries to run correctly.
if (USE_PYTHON AND NOT SANITIZE_ON_LINUX)
if (USE_PYTHON AND NOT SANITIZE)
TESTSUITE ( python-oslquery )
endif ()
@@ -248,7 +379,7 @@ macro (osl_add_all_tests)
execute_process ( COMMAND ${OpenImageIO_LIB_DIR}/../bin/oiiotool --help
OUTPUT_VARIABLE oiiotool_help )
if (oiiotool_help MATCHES "openvdb")
TESTSUITE ( texture3d )
TESTSUITE ( texture3d texture3d-opts-reg )
endif()
# Only run pointcloud tests if Partio is found
@@ -261,4 +392,13 @@ macro (osl_add_all_tests)
TESTSUITE ( testoptix testoptix-noise example-cuda)
endif ()
# Some regression tests have a lot of combinations and may need more time to finish
if (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()
+738 -88
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+5 -5
View File
@@ -11,7 +11,7 @@
_testshade_ basics
==================================================
The OSL software distribution inculdes `testshade`, a command-line utility
The OSL software distribution includes `testshade`, a command-line utility
that was written for OSL unit tests, and for a "test harness" in which we
can execute shaders for debugging (the shaders or OSL itself) in isolation
from any particular rendering system.
@@ -28,7 +28,7 @@ itself, it has a number of potential uses in a production studio, including:
* Baking procedural patterns into textures.
* Benchmarking shaders and evaluating their performance, including
comparitive tests such as "is it faster to code it this way or that way?"
comparative tests such as "is it faster to code it this way or that way?"
* Exploring the inner workings of OSL's runtime optimizer, to answer
questions like: "will this idiom optimize away at runtime when I use
@@ -176,7 +176,7 @@ Helpful command line arguments:
For the sake of simplicity, this document presents almost all examples as if
they consisted of just a single shader node. But `testshade` is able to
specify and execut entire shader groups (networks of shader nodes). The
specify and execute entire shader groups (networks of shader nodes). The
remainder of this section will explain how this can be done.
Let's make a simple shader network as an example.
@@ -582,7 +582,7 @@ single texture lookup.
## Controling optimization
## Controlling optimization
You can control the optimization level overall:
@@ -638,7 +638,7 @@ that they are not optimized away so as to lead you to an inaccurate
reflection of what optimizations would really happen at render time. At the
same time, be careful not to inadvertently set `lockgeom=0` for parameters
that will typically be set to default values, instance values, or
connections from layers that are likely to be analized and found to emit
connections from layers that are likely to be analyzed and found to emit
constants for theor outputs -- you also don't want your benchmarks to
incorrectly disable optimizations what would typically happen at render
time.
+225 -225
View File
@@ -135,7 +135,7 @@ template <class T> class Matrix33
//------------
~Matrix33 () = default;
//----------------------
// Compatibility with Sb
//----------------------
@@ -378,8 +378,8 @@ template <class T> class Matrix33
//-------------------------------------------------------------
// Set matrix to shear x for each y coord. by given factor h[0]
// and to shear y for each x coord. by given factor h[1]
// Set matrix to shear x for each y coord. by given factor h.x
// and to shear y for each x coord. by given factor h.y
//-------------------------------------------------------------
template <class S>
@@ -867,16 +867,16 @@ template <class S, class T>
IMATH_HOSTDEVICE Vec3<S> operator * (const Vec3<S> &v, const Matrix33<T> &m);
template <class S, class T>
const Vec3<S> & operator *= (Vec3<S> &v, const Matrix44<T> &m);
IMATH_HOSTDEVICE const Vec3<S> & operator *= (Vec3<S> &v, const Matrix44<T> &m);
template <class S, class T>
Vec3<S> operator * (const Vec3<S> &v, const Matrix44<T> &m);
IMATH_HOSTDEVICE Vec3<S> operator * (const Vec3<S> &v, const Matrix44<T> &m);
template <class S, class T>
const Vec4<S> & operator *= (Vec4<S> &v, const Matrix44<T> &m);
IMATH_HOSTDEVICE const Vec4<S> & operator *= (Vec4<S> &v, const Matrix44<T> &m);
template <class S, class T>
Vec4<S> operator * (const Vec4<S> &v, const Matrix44<T> &m);
IMATH_HOSTDEVICE Vec4<S> operator * (const Vec4<S> &v, const Matrix44<T> &m);
//-------------------------
// Typedefs for convenience
@@ -1133,7 +1133,7 @@ Matrix33<T>::equalWithAbsError (const Matrix33<T> &m, T e) const
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this)[i][j], m[i][j], e))
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this).x[i][j], m.x[i][j], e))
return false;
return true;
@@ -1145,7 +1145,7 @@ Matrix33<T>::equalWithRelError (const Matrix33<T> &m, T e) const
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this)[i][j], m[i][j], e))
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this).x[i][j], m.x[i][j], e))
return false;
return true;
@@ -1356,9 +1356,9 @@ Matrix33<T>::multVecMatrix(const Vec2<S> &src, Vec2<S> &dst) const
{
S a, b, w;
a = src[0] * x[0][0] + src[1] * x[1][0] + x[2][0];
b = src[0] * x[0][1] + src[1] * x[1][1] + x[2][1];
w = src[0] * x[0][2] + src[1] * x[1][2] + x[2][2];
a = src.x * x[0][0] + src.y * x[1][0] + x[2][0];
b = src.x * x[0][1] + src.y * x[1][1] + x[2][1];
w = src.x * x[0][2] + src.y * x[1][2] + x[2][2];
dst.x = a / w;
dst.y = b / w;
@@ -1371,8 +1371,8 @@ Matrix33<T>::multDirMatrix(const Vec2<S> &src, Vec2<S> &dst) const
{
S a, b;
a = src[0] * x[0][0] + src[1] * x[1][0];
b = src[0] * x[0][1] + src[1] * x[1][1];
a = src.x * x[0][0] + src.y * x[1][0];
b = src.x * x[0][1] + src.y * x[1][1];
dst.x = a;
dst.y = b;
@@ -1464,14 +1464,14 @@ Matrix33<T>::gjInverse (bool singExc) const
{
int pivot = i;
T pivotsize = t[i][i];
T pivotsize = t.x[i][i];
if (pivotsize < 0)
pivotsize = -pivotsize;
for (j = i + 1; j < 3; j++)
{
T tmp = t[j][i];
T tmp = t.x[j][i];
if (tmp < 0)
tmp = -tmp;
@@ -1497,24 +1497,24 @@ Matrix33<T>::gjInverse (bool singExc) const
{
T tmp;
tmp = t[i][j];
t[i][j] = t[pivot][j];
t[pivot][j] = tmp;
tmp = t.x[i][j];
t.x[i][j] = t.x[pivot][j];
t.x[pivot][j] = tmp;
tmp = s[i][j];
s[i][j] = s[pivot][j];
s[pivot][j] = tmp;
tmp = s.x[i][j];
s.x[i][j] = s.x[pivot][j];
s.x[pivot][j] = tmp;
}
}
for (j = i + 1; j < 3; j++)
{
T f = t[j][i] / t[i][i];
T f = t.x[j][i] / t.x[i][i];
for (k = 0; k < 3; k++)
{
t[j][k] -= f * t[i][k];
s[j][k] -= f * s[i][k];
t.x[j][k] -= f * t.x[i][k];
s.x[j][k] -= f * s.x[i][k];
}
}
}
@@ -1525,7 +1525,7 @@ Matrix33<T>::gjInverse (bool singExc) const
{
T f;
if ((f = t[i][i]) == 0)
if ((f = t.x[i][i]) == 0)
{
if (singExc)
throw ::IMATH_INTERNAL_NAMESPACE::SingMatrixExc ("Cannot invert singular matrix.");
@@ -1535,18 +1535,18 @@ Matrix33<T>::gjInverse (bool singExc) const
for (j = 0; j < 3; j++)
{
t[i][j] /= f;
s[i][j] /= f;
t.x[i][j] /= f;
s.x[i][j] /= f;
}
for (j = 0; j < i; j++)
{
f = t[j][i];
f = t.x[j][i];
for (k = 0; k < 3; k++)
{
t[j][k] -= f * t[i][k];
s[j][k] -= f * s[i][k];
t.x[j][k] -= f * t.x[i][k];
s.x[j][k] -= f * s.x[i][k];
}
}
}
@@ -1580,7 +1580,7 @@ Matrix33<T>::inverse (bool singExc) const
x[2][0] * x[0][1] - x[0][0] * x[2][1],
x[0][0] * x[1][1] - x[1][0] * x[0][1]);
T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
{
@@ -1588,7 +1588,7 @@ Matrix33<T>::inverse (bool singExc) const
{
for (int j = 0; j < 3; ++j)
{
s[i][j] /= r;
s.x[i][j] /= r;
}
}
}
@@ -1600,9 +1600,9 @@ Matrix33<T>::inverse (bool singExc) const
{
for (int j = 0; j < 3; ++j)
{
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
{
s[i][j] /= r;
s.x[i][j] /= r;
}
else
{
@@ -1641,7 +1641,7 @@ Matrix33<T>::inverse (bool singExc) const
{
for (int j = 0; j < 2; ++j)
{
s[i][j] /= r;
s.x[i][j] /= r;
}
}
}
@@ -1653,9 +1653,9 @@ Matrix33<T>::inverse (bool singExc) const
{
for (int j = 0; j < 2; ++j)
{
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
{
s[i][j] /= r;
s.x[i][j] /= r;
}
else
{
@@ -1670,8 +1670,8 @@ Matrix33<T>::inverse (bool singExc) const
}
}
s[2][0] = -x[2][0] * s[0][0] - x[2][1] * s[1][0];
s[2][1] = -x[2][0] * s[0][1] - x[2][1] * s[1][1];
s.x[2][0] = -x[2][0] * s.x[0][0] - x[2][1] * s.x[1][0];
s.x[2][1] = -x[2][0] * s.x[0][1] - x[2][1] * s.x[1][1];
return s;
}
@@ -1758,8 +1758,8 @@ IMATH_HOSTDEVICE const Matrix33<T> &
Matrix33<T>::setScale (const Vec2<S> &s)
{
memset (x, 0, sizeof (x));
x[0][0] = s[0];
x[1][1] = s[1];
x[0][0] = s.x;
x[1][1] = s.y;
x[2][2] = 1;
return *this;
@@ -1770,13 +1770,13 @@ template <class S>
IMATH_HOSTDEVICE const Matrix33<T> &
Matrix33<T>::scale (const Vec2<S> &s)
{
x[0][0] *= s[0];
x[0][1] *= s[0];
x[0][2] *= s[0];
x[0][0] *= s.x;
x[0][1] *= s.x;
x[0][2] *= s.x;
x[1][0] *= s[1];
x[1][1] *= s[1];
x[1][2] *= s[1];
x[1][0] *= s.y;
x[1][1] *= s.y;
x[1][2] *= s.y;
return *this;
}
@@ -1794,8 +1794,8 @@ Matrix33<T>::setTranslation (const Vec2<S> &t)
x[1][1] = 1;
x[1][2] = 0;
x[2][0] = t[0];
x[2][1] = t[1];
x[2][0] = t.x;
x[2][1] = t.y;
x[2][2] = 1;
return *this;
@@ -1813,9 +1813,9 @@ template <class S>
IMATH_HOSTDEVICE const Matrix33<T> &
Matrix33<T>::translate (const Vec2<S> &t)
{
x[2][0] += t[0] * x[0][0] + t[1] * x[1][0];
x[2][1] += t[0] * x[0][1] + t[1] * x[1][1];
x[2][2] += t[0] * x[0][2] + t[1] * x[1][2];
x[2][0] += t.x * x[0][0] + t.y * x[1][0];
x[2][1] += t.x * x[0][1] + t.y * x[1][1];
x[2][2] += t.x * x[0][2] + t.y * x[1][2];
return *this;
}
@@ -1846,10 +1846,10 @@ IMATH_HOSTDEVICE const Matrix33<T> &
Matrix33<T>::setShear (const Vec2<S> &h)
{
x[0][0] = 1;
x[0][1] = h[1];
x[0][1] = h.y;
x[0][2] = 0;
x[1][0] = h[0];
x[1][0] = h.x;
x[1][1] = 1;
x[1][2] = 0;
@@ -1885,13 +1885,13 @@ Matrix33<T>::shear (const Vec2<S> &h)
{
Matrix33<T> P (*this);
x[0][0] = P[0][0] + h[1] * P[1][0];
x[0][1] = P[0][1] + h[1] * P[1][1];
x[0][2] = P[0][2] + h[1] * P[1][2];
x[0][0] = P.x[0][0] + h.y * P.x[1][0];
x[0][1] = P.x[0][1] + h.y * P.x[1][1];
x[0][2] = P.x[0][2] + h.y * P.x[1][2];
x[1][0] = P[1][0] + h[0] * P[0][0];
x[1][1] = P[1][1] + h[0] * P[0][1];
x[1][2] = P[1][2] + h[0] * P[0][2];
x[1][0] = P.x[1][0] + h.x * P.x[0][0];
x[1][1] = P.x[1][1] + h.x * P.x[0][1];
x[1][2] = P.x[1][2] + h.x * P.x[0][2];
return *this;
}
@@ -1983,21 +1983,21 @@ template <class T>
IMATH_HOSTDEVICE inline
Matrix44<T>::Matrix44 (Matrix33<T> r, Vec3<T> t)
{
x[0][0] = r[0][0];
x[0][1] = r[0][1];
x[0][2] = r[0][2];
x[0][0] = r.x[0][0];
x[0][1] = r.x[0][1];
x[0][2] = r.x[0][2];
x[0][3] = 0;
x[1][0] = r[1][0];
x[1][1] = r[1][1];
x[1][2] = r[1][2];
x[1][0] = r.x[1][0];
x[1][1] = r.x[1][1];
x[1][2] = r.x[1][2];
x[1][3] = 0;
x[2][0] = r[2][0];
x[2][1] = r[2][1];
x[2][2] = r[2][2];
x[2][0] = r.x[2][0];
x[2][1] = r.x[2][1];
x[2][2] = r.x[2][2];
x[2][3] = 0;
x[3][0] = t[0];
x[3][1] = t[1];
x[3][2] = t[2];
x[3][0] = t.x;
x[3][1] = t.y;
x[3][2] = t.z;
x[3][3] = 1;
}
@@ -2261,7 +2261,7 @@ Matrix44<T>::equalWithAbsError (const Matrix44<T> &m, T e) const
{
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this)[i][j], m[i][j], e))
if (!IMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*this).x[i][j], m.x[i][j], e))
return false;
return true;
@@ -2273,7 +2273,7 @@ Matrix44<T>::equalWithRelError (const Matrix44<T> &m, T e) const
{
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this)[i][j], m[i][j], e))
if (!IMATH_INTERNAL_NAMESPACE::equalWithRelError ((*this).x[i][j], m.x[i][j], e))
return false;
return true;
@@ -2598,10 +2598,10 @@ Matrix44<T>::multVecMatrix(const Vec3<S> &src, Vec3<S> &dst) const
{
S a, b, c, w;
a = src[0] * x[0][0] + src[1] * x[1][0] + src[2] * x[2][0] + x[3][0];
b = src[0] * x[0][1] + src[1] * x[1][1] + src[2] * x[2][1] + x[3][1];
c = src[0] * x[0][2] + src[1] * x[1][2] + src[2] * x[2][2] + x[3][2];
w = src[0] * x[0][3] + src[1] * x[1][3] + src[2] * x[2][3] + x[3][3];
a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0] + x[3][0];
b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1] + x[3][1];
c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2] + x[3][2];
w = src.x * x[0][3] + src.y * x[1][3] + src.z * x[2][3] + x[3][3];
dst.x = a / w;
dst.y = b / w;
@@ -2614,9 +2614,9 @@ Matrix44<T>::multDirMatrix(const Vec3<S> &src, Vec3<S> &dst) const
{
S a, b, c;
a = src[0] * x[0][0] + src[1] * x[1][0] + src[2] * x[2][0];
b = src[0] * x[0][1] + src[1] * x[1][1] + src[2] * x[2][1];
c = src[0] * x[0][2] + src[1] * x[1][2] + src[2] * x[2][2];
a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0];
b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1];
c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2];
dst.x = a;
dst.y = b;
@@ -2737,14 +2737,14 @@ Matrix44<T>::gjInverse (bool singExc) const
{
int pivot = i;
T pivotsize = t[i][i];
T pivotsize = t.x[i][i];
if (pivotsize < 0)
pivotsize = -pivotsize;
for (j = i + 1; j < 4; j++)
{
T tmp = t[j][i];
T tmp = t.x[j][i];
if (tmp < 0)
tmp = -tmp;
@@ -2772,24 +2772,24 @@ Matrix44<T>::gjInverse (bool singExc) const
{
T tmp;
tmp = t[i][j];
t[i][j] = t[pivot][j];
t[pivot][j] = tmp;
tmp = t.x[i][j];
t.x[i][j] = t.x[pivot][j];
t.x[pivot][j] = tmp;
tmp = s[i][j];
s[i][j] = s[pivot][j];
s[pivot][j] = tmp;
tmp = s.x[i][j];
s.x[i][j] = s.x[pivot][j];
s.x[pivot][j] = tmp;
}
}
for (j = i + 1; j < 4; j++)
{
T f = t[j][i] / t[i][i];
T f = t.x[j][i] / t.x[i][i];
for (k = 0; k < 4; k++)
{
t[j][k] -= f * t[i][k];
s[j][k] -= f * s[i][k];
t.x[j][k] -= f * t.x[i][k];
s.x[j][k] -= f * s.x[i][k];
}
}
}
@@ -2812,18 +2812,18 @@ Matrix44<T>::gjInverse (bool singExc) const
for (j = 0; j < 4; j++)
{
t[i][j] /= f;
s[i][j] /= f;
t.x[i][j] /= f;
s.x[i][j] /= f;
}
for (j = 0; j < i; j++)
{
f = t[j][i];
f = t.x[j][i];
for (k = 0; k < 4; k++)
{
t[j][k] -= f * t[i][k];
s[j][k] -= f * s[i][k];
t.x[j][k] -= f * t.x[i][k];
s.x[j][k] -= f * s.x[i][k];
}
}
}
@@ -2866,7 +2866,7 @@ Matrix44<T>::inverse (bool singExc) const
0,
1);
T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
{
@@ -2874,7 +2874,7 @@ Matrix44<T>::inverse (bool singExc) const
{
for (int j = 0; j < 3; ++j)
{
s[i][j] /= r;
s.x[i][j] /= r;
}
}
}
@@ -2886,9 +2886,9 @@ Matrix44<T>::inverse (bool singExc) const
{
for (int j = 0; j < 3; ++j)
{
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
{
s[i][j] /= r;
s.x[i][j] /= r;
}
else
{
@@ -2903,9 +2903,9 @@ Matrix44<T>::inverse (bool singExc) const
}
}
s[3][0] = -x[3][0] * s[0][0] - x[3][1] * s[1][0] - x[3][2] * s[2][0];
s[3][1] = -x[3][0] * s[0][1] - x[3][1] * s[1][1] - x[3][2] * s[2][1];
s[3][2] = -x[3][0] * s[0][2] - x[3][1] * s[1][2] - x[3][2] * s[2][2];
s.x[3][0] = -x[3][0] * s.x[0][0] - x[3][1] * s.x[1][0] - x[3][2] * s.x[2][0];
s.x[3][1] = -x[3][0] * s.x[0][1] - x[3][1] * s.x[1][1] - x[3][2] * s.x[2][1];
s.x[3][2] = -x[3][0] * s.x[0][2] - x[3][1] * s.x[1][2] - x[3][2] * s.x[2][2];
return s;
}
@@ -2959,13 +2959,13 @@ Matrix44<T>::setEulerAngles (const Vec3<S>& r)
{
S cos_rz, sin_rz, cos_ry, sin_ry, cos_rx, sin_rx;
cos_rz = Math<T>::cos (r[2]);
cos_ry = Math<T>::cos (r[1]);
cos_rx = Math<T>::cos (r[0]);
cos_rz = Math<T>::cos (r.z);
cos_ry = Math<T>::cos (r.y);
cos_rx = Math<T>::cos (r.x);
sin_rz = Math<T>::sin (r[2]);
sin_ry = Math<T>::sin (r[1]);
sin_rx = Math<T>::sin (r[0]);
sin_rz = Math<T>::sin (r.z);
sin_ry = Math<T>::sin (r.y);
sin_rx = Math<T>::sin (r.x);
x[0][0] = cos_rz * cos_ry;
x[0][1] = sin_rz * cos_ry;
@@ -2999,19 +2999,19 @@ Matrix44<T>::setAxisAngle (const Vec3<S>& axis, S angle)
S sine = Math<T>::sin (angle);
S cosine = Math<T>::cos (angle);
x[0][0] = unit[0] * unit[0] * (1 - cosine) + cosine;
x[0][1] = unit[0] * unit[1] * (1 - cosine) + unit[2] * sine;
x[0][2] = unit[0] * unit[2] * (1 - cosine) - unit[1] * sine;
x[0][0] = unit.x * unit.x * (1 - cosine) + cosine;
x[0][1] = unit.x * unit.y * (1 - cosine) + unit.z * sine;
x[0][2] = unit.x * unit.z * (1 - cosine) - unit.y * sine;
x[0][3] = 0;
x[1][0] = unit[0] * unit[1] * (1 - cosine) - unit[2] * sine;
x[1][1] = unit[1] * unit[1] * (1 - cosine) + cosine;
x[1][2] = unit[1] * unit[2] * (1 - cosine) + unit[0] * sine;
x[1][0] = unit.x * unit.y * (1 - cosine) - unit.z * sine;
x[1][1] = unit.y * unit.y * (1 - cosine) + cosine;
x[1][2] = unit.y * unit.z * (1 - cosine) + unit.x * sine;
x[1][3] = 0;
x[2][0] = unit[0] * unit[2] * (1 - cosine) + unit[1] * sine;
x[2][1] = unit[1] * unit[2] * (1 - cosine) - unit[0] * sine;
x[2][2] = unit[2] * unit[2] * (1 - cosine) + cosine;
x[2][0] = unit.x * unit.z * (1 - cosine) + unit.y * sine;
x[2][1] = unit.y * unit.z * (1 - cosine) - unit.x * sine;
x[2][2] = unit.z * unit.z * (1 - cosine) + cosine;
x[2][3] = 0;
x[3][0] = 0;
@@ -3032,13 +3032,13 @@ Matrix44<T>::rotate (const Vec3<S> &r)
S m10, m11, m12;
S m20, m21, m22;
cos_rz = Math<S>::cos (r[2]);
cos_ry = Math<S>::cos (r[1]);
cos_rx = Math<S>::cos (r[0]);
cos_rz = Math<S>::cos (r.z);
cos_ry = Math<S>::cos (r.y);
cos_rx = Math<S>::cos (r.x);
sin_rz = Math<S>::sin (r[2]);
sin_ry = Math<S>::sin (r[1]);
sin_rx = Math<S>::sin (r[0]);
sin_rz = Math<S>::sin (r.z);
sin_ry = Math<S>::sin (r.y);
sin_rx = Math<S>::sin (r.x);
m00 = cos_rz * cos_ry;
m01 = sin_rz * cos_ry;
@@ -3052,20 +3052,20 @@ Matrix44<T>::rotate (const Vec3<S> &r)
Matrix44<T> P (*this);
x[0][0] = P[0][0] * m00 + P[1][0] * m01 + P[2][0] * m02;
x[0][1] = P[0][1] * m00 + P[1][1] * m01 + P[2][1] * m02;
x[0][2] = P[0][2] * m00 + P[1][2] * m01 + P[2][2] * m02;
x[0][3] = P[0][3] * m00 + P[1][3] * m01 + P[2][3] * m02;
x[0][0] = P.x[0][0] * m00 + P.x[1][0] * m01 + P.x[2][0] * m02;
x[0][1] = P.x[0][1] * m00 + P.x[1][1] * m01 + P.x[2][1] * m02;
x[0][2] = P.x[0][2] * m00 + P.x[1][2] * m01 + P.x[2][2] * m02;
x[0][3] = P.x[0][3] * m00 + P.x[1][3] * m01 + P.x[2][3] * m02;
x[1][0] = P[0][0] * m10 + P[1][0] * m11 + P[2][0] * m12;
x[1][1] = P[0][1] * m10 + P[1][1] * m11 + P[2][1] * m12;
x[1][2] = P[0][2] * m10 + P[1][2] * m11 + P[2][2] * m12;
x[1][3] = P[0][3] * m10 + P[1][3] * m11 + P[2][3] * m12;
x[1][0] = P.x[0][0] * m10 + P.x[1][0] * m11 + P.x[2][0] * m12;
x[1][1] = P.x[0][1] * m10 + P.x[1][1] * m11 + P.x[2][1] * m12;
x[1][2] = P.x[0][2] * m10 + P.x[1][2] * m11 + P.x[2][2] * m12;
x[1][3] = P.x[0][3] * m10 + P.x[1][3] * m11 + P.x[2][3] * m12;
x[2][0] = P[0][0] * m20 + P[1][0] * m21 + P[2][0] * m22;
x[2][1] = P[0][1] * m20 + P[1][1] * m21 + P[2][1] * m22;
x[2][2] = P[0][2] * m20 + P[1][2] * m21 + P[2][2] * m22;
x[2][3] = P[0][3] * m20 + P[1][3] * m21 + P[2][3] * m22;
x[2][0] = P.x[0][0] * m20 + P.x[1][0] * m21 + P.x[2][0] * m22;
x[2][1] = P.x[0][1] * m20 + P.x[1][1] * m21 + P.x[2][1] * m22;
x[2][2] = P.x[0][2] * m20 + P.x[1][2] * m21 + P.x[2][2] * m22;
x[2][3] = P.x[0][3] * m20 + P.x[1][3] * m21 + P.x[2][3] * m22;
return *this;
}
@@ -3089,9 +3089,9 @@ IMATH_HOSTDEVICE const Matrix44<T> &
Matrix44<T>::setScale (const Vec3<S> &s)
{
memset (x, 0, sizeof (x));
x[0][0] = s[0];
x[1][1] = s[1];
x[2][2] = s[2];
x[0][0] = s.x;
x[1][1] = s.y;
x[2][2] = s.z;
x[3][3] = 1;
return *this;
@@ -3102,20 +3102,20 @@ template <class S>
IMATH_HOSTDEVICE const Matrix44<T> &
Matrix44<T>::scale (const Vec3<S> &s)
{
x[0][0] *= s[0];
x[0][1] *= s[0];
x[0][2] *= s[0];
x[0][3] *= s[0];
x[0][0] *= s.x;
x[0][1] *= s.x;
x[0][2] *= s.x;
x[0][3] *= s.x;
x[1][0] *= s[1];
x[1][1] *= s[1];
x[1][2] *= s[1];
x[1][3] *= s[1];
x[1][0] *= s.y;
x[1][1] *= s.y;
x[1][2] *= s.y;
x[1][3] *= s.y;
x[2][0] *= s[2];
x[2][1] *= s[2];
x[2][2] *= s[2];
x[2][3] *= s[2];
x[2][0] *= s.z;
x[2][1] *= s.z;
x[2][2] *= s.z;
x[2][3] *= s.z;
return *this;
}
@@ -3140,9 +3140,9 @@ Matrix44<T>::setTranslation (const Vec3<S> &t)
x[2][2] = 1;
x[2][3] = 0;
x[3][0] = t[0];
x[3][1] = t[1];
x[3][2] = t[2];
x[3][0] = t.x;
x[3][1] = t.y;
x[3][2] = t.z;
x[3][3] = 1;
return *this;
@@ -3160,10 +3160,10 @@ template <class S>
IMATH_HOSTDEVICE const Matrix44<T> &
Matrix44<T>::translate (const Vec3<S> &t)
{
x[3][0] += t[0] * x[0][0] + t[1] * x[1][0] + t[2] * x[2][0];
x[3][1] += t[0] * x[0][1] + t[1] * x[1][1] + t[2] * x[2][1];
x[3][2] += t[0] * x[0][2] + t[1] * x[1][2] + t[2] * x[2][2];
x[3][3] += t[0] * x[0][3] + t[1] * x[1][3] + t[2] * x[2][3];
x[3][0] += t.x * x[0][0] + t.y * x[1][0] + t.z * x[2][0];
x[3][1] += t.x * x[0][1] + t.y * x[1][1] + t.z * x[2][1];
x[3][2] += t.x * x[0][2] + t.y * x[1][2] + t.z * x[2][2];
x[3][3] += t.x * x[0][3] + t.y * x[1][3] + t.z * x[2][3];
return *this;
}
@@ -3178,13 +3178,13 @@ Matrix44<T>::setShear (const Vec3<S> &h)
x[0][2] = 0;
x[0][3] = 0;
x[1][0] = h[0];
x[1][0] = h.x;
x[1][1] = 1;
x[1][2] = 0;
x[1][3] = 0;
x[2][0] = h[1];
x[2][1] = h[2];
x[2][0] = h.y;
x[2][1] = h.z;
x[2][2] = 1;
x[2][3] = 0;
@@ -3237,8 +3237,8 @@ Matrix44<T>::shear (const Vec3<S> &h)
for (int i=0; i < 4; i++)
{
x[2][i] += h[1] * x[0][i] + h[2] * x[1][i];
x[1][i] += h[0] * x[0][i];
x[2][i] += h.y * x[0][i] + h.z * x[1][i];
x[1][i] += h.x * x[0][i];
}
return *this;
@@ -3253,9 +3253,9 @@ Matrix44<T>::shear (const Shear6<S> &h)
for (int i=0; i < 4; i++)
{
x[0][i] = P[0][i] + h.yx * P[1][i] + h.zx * P[2][i];
x[1][i] = h.xy * P[0][i] + P[1][i] + h.zy * P[2][i];
x[2][i] = h.xz * P[0][i] + h.yz * P[1][i] + P[2][i];
x[0][i] = P.x[0][i] + h.yx * P.x[1][i] + h.zx * P.x[2][i];
x[1][i] = h.xy * P.x[0][i] + P.x[1][i] + h.zy * P.x[2][i];
x[2][i] = h.xz * P.x[0][i] + h.yz * P.x[1][i] + P.x[2][i];
}
return *this;
@@ -3285,17 +3285,17 @@ operator << (std::ostream &s, const Matrix33<T> &m)
width = static_cast<int>(s.precision()) + 8;
}
s << "(" << std::setw (width) << m[0][0] <<
" " << std::setw (width) << m[0][1] <<
" " << std::setw (width) << m[0][2] << "\n" <<
s << "(" << std::setw (width) << m.x[0][0] <<
" " << std::setw (width) << m.x[0][1] <<
" " << std::setw (width) << m.x[0][2] << "\n" <<
" " << std::setw (width) << m[1][0] <<
" " << std::setw (width) << m[1][1] <<
" " << std::setw (width) << m[1][2] << "\n" <<
" " << std::setw (width) << m.x[1][0] <<
" " << std::setw (width) << m.x[1][1] <<
" " << std::setw (width) << m.x[1][2] << "\n" <<
" " << std::setw (width) << m[2][0] <<
" " << std::setw (width) << m[2][1] <<
" " << std::setw (width) << m[2][2] << ")\n";
" " << std::setw (width) << m.x[2][0] <<
" " << std::setw (width) << m.x[2][1] <<
" " << std::setw (width) << m.x[2][2] << ")\n";
s.flags (oldFlags);
return s;
@@ -3320,25 +3320,25 @@ operator << (std::ostream &s, const Matrix44<T> &m)
width = static_cast<int>(s.precision()) + 8;
}
s << "(" << std::setw (width) << m[0][0] <<
" " << std::setw (width) << m[0][1] <<
" " << std::setw (width) << m[0][2] <<
" " << std::setw (width) << m[0][3] << "\n" <<
s << "(" << std::setw (width) << m.x[0][0] <<
" " << std::setw (width) << m.x[0][1] <<
" " << std::setw (width) << m.x[0][2] <<
" " << std::setw (width) << m.x[0][3] << "\n" <<
" " << std::setw (width) << m[1][0] <<
" " << std::setw (width) << m[1][1] <<
" " << std::setw (width) << m[1][2] <<
" " << std::setw (width) << m[1][3] << "\n" <<
" " << std::setw (width) << m.x[1][0] <<
" " << std::setw (width) << m.x[1][1] <<
" " << std::setw (width) << m.x[1][2] <<
" " << std::setw (width) << m.x[1][3] << "\n" <<
" " << std::setw (width) << m[2][0] <<
" " << std::setw (width) << m[2][1] <<
" " << std::setw (width) << m[2][2] <<
" " << std::setw (width) << m[2][3] << "\n" <<
" " << std::setw (width) << m.x[2][0] <<
" " << std::setw (width) << m.x[2][1] <<
" " << std::setw (width) << m.x[2][2] <<
" " << std::setw (width) << m.x[2][3] << "\n" <<
" " << std::setw (width) << m[3][0] <<
" " << std::setw (width) << m[3][1] <<
" " << std::setw (width) << m[3][2] <<
" " << std::setw (width) << m[3][3] << ")\n";
" " << std::setw (width) << m.x[3][0] <<
" " << std::setw (width) << m.x[3][1] <<
" " << std::setw (width) << m.x[3][2] <<
" " << std::setw (width) << m.x[3][3] << ")\n";
s.flags (oldFlags);
return s;
@@ -3353,9 +3353,9 @@ template <class S, class T>
IMATH_HOSTDEVICE inline const Vec2<S> &
operator *= (Vec2<S> &v, const Matrix33<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + m[2][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + m[2][1]);
S w = S(v.x * m[0][2] + v.y * m[1][2] + m[2][2]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + m.x[2][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + m.x[2][1]);
S w = S(v.x * m.x[0][2] + v.y * m.x[1][2] + m.x[2][2]);
v.x = x / w;
v.y = y / w;
@@ -3367,9 +3367,9 @@ template <class S, class T>
IMATH_HOSTDEVICE inline Vec2<S>
operator * (const Vec2<S> &v, const Matrix33<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + m[2][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + m[2][1]);
S w = S(v.x * m[0][2] + v.y * m[1][2] + m[2][2]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + m.x[2][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + m.x[2][1]);
S w = S(v.x * m.x[0][2] + v.y * m.x[1][2] + m.x[2][2]);
return Vec2<S> (x / w, y / w);
}
@@ -3379,9 +3379,9 @@ template <class S, class T>
IMATH_HOSTDEVICE inline const Vec3<S> &
operator *= (Vec3<S> &v, const Matrix33<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1]);
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1]);
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2]);
v.x = x;
v.y = y;
@@ -3394,22 +3394,22 @@ template <class S, class T>
IMATH_HOSTDEVICE inline Vec3<S>
operator * (const Vec3<S> &v, const Matrix33<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1]);
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1]);
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2]);
return Vec3<S> (x, y, z);
}
template <class S, class T>
inline const Vec3<S> &
IMATH_HOSTDEVICE inline const Vec3<S> &
operator *= (Vec3<S> &v, const Matrix44<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]);
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + m[3][3]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + m.x[3][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + m.x[3][1]);
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + m.x[3][2]);
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + m.x[3][3]);
v.x = x / w;
v.y = y / w;
@@ -3419,26 +3419,26 @@ operator *= (Vec3<S> &v, const Matrix44<T> &m)
}
template <class S, class T>
inline Vec3<S>
IMATH_HOSTDEVICE inline Vec3<S>
operator * (const Vec3<S> &v, const Matrix44<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]);
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + m[3][3]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + m.x[3][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + m.x[3][1]);
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + m.x[3][2]);
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + m.x[3][3]);
return Vec3<S> (x / w, y / w, z / w);
}
template <class S, class T>
inline const Vec4<S> &
IMATH_HOSTDEVICE inline const Vec4<S> &
operator *= (Vec4<S> &v, const Matrix44<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1]);
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2]);
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + v.w * m.x[3][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + v.w * m.x[3][1]);
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + v.w * m.x[3][2]);
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + v.w * m.x[3][3]);
v.x = x;
v.y = y;
@@ -3449,13 +3449,13 @@ operator *= (Vec4<S> &v, const Matrix44<T> &m)
}
template <class S, class T>
inline Vec4<S>
IMATH_HOSTDEVICE inline Vec4<S>
operator * (const Vec4<S> &v, const Matrix44<T> &m)
{
S x = S(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0]);
S y = S(v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1]);
S z = S(v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2]);
S w = S(v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3]);
S x = S(v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + v.w * m.x[3][0]);
S y = S(v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + v.w * m.x[3][1]);
S z = S(v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + v.w * m.x[3][2]);
S w = S(v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + v.w * m.x[3][3]);
return Vec4<S> (x, y, z, w);
}
+58 -6
View File
@@ -16,9 +16,21 @@
#include <OSL/oslconfig.h>
#if OSL_USING_IMATH < 3
# include <OSL/matrix22.h>
#endif
OSL_NAMESPACE_ENTER
#if OSL_USING_IMATH >= 3
using Matrix22 = Imath::Matrix22<Float>;
#else
using Matrix22 = Imathx::Matrix22<Float>;
#endif
// Choose to treat helper functions as static
// so their symbols don't escape and possibly collide
// with other compilation units who might be compiled with
@@ -244,16 +256,17 @@ affineInverse(const Matrix44 &m)
// match results between LLVM IR based implementation and
// compiler optimized versions which may have optimized
// differently than the LLVM IR version.
// Clang doesn't currently have a way to control fast-math/fp:strict
// at a per function level, so we will resort to disabling optimization
// for this function. Not ideal, but this is already a slow path
// for exceptional situations.
// GCC could use __attribute__((optimize("-fno-fast-math")))
// NOTE: only using "inline" to get ODR (One Definition Rule) behavior
static inline OSL_HOSTDEVICE Matrix44
nonAffineInverse(const Matrix44 &source) OSL_CLANG_ATTRIBUTE(optnone)
#if !OSL_INTEL_CLASSIC_COMPILER_VERSION
OSL_GNUC_ATTRIBUTE(optimize("fp-contract=off"))
#endif
nonAffineInverse(const Matrix44 &source);
Matrix44 OSL_HOSTDEVICE nonAffineInverse(const Matrix44 &source)
{
OSL_INTEL_PRAGMA(float_control(strict,on,push))
OSL_CLANG_PRAGMA(clang fp contract(off))
using ScalarT = typename Matrix44::BaseType;
Matrix44 t(source);
@@ -452,4 +465,43 @@ multiplyMatrixByMatrix (const Matrix44 &a,
}
// Calculate the determinant of a 2x2 matrix.
template<typename F>
static OSL_FORCEINLINE OSL_HOSTDEVICE F
det2x2(F a, F b, F c, F d)
{
return a * d - b * c;
}
// calculate the determinant of a 3x3 matrix in the form:
// | a1, b1, c1 |
// | a2, b2, c2 |
// | a3, b3, c3 |
template<typename F>
static OSL_FORCEINLINE OSL_HOSTDEVICE F
det3x3(F a1, F a2, F a3, F b1, F b2, F b3, F c1, F c2, F c3)
{
return a1 * det2x2( b2, b3, c2, c3 )
- b1 * det2x2( a2, a3, c2, c3 )
+ c1 * det2x2( a2, a3, b2, b3 );
}
// calculate the determinant of a 4x4 matrix.
template<typename F>
static OSL_FORCEINLINE OSL_HOSTDEVICE F
det4x4(const Imath::Matrix44<F>& m)
{
// Changed all Vec3 subscripts to access data members versus array casts
// assign to individual variable names to aid selecting correct elements
F a1 = m.x[0][0], b1 = m.x[0][1], c1 = m.x[0][2], d1 = m.x[0][3];
F a2 = m.x[1][0], b2 = m.x[1][1], c2 = m.x[1][2], d2 = m.x[1][3];
F a3 = m.x[2][0], b3 = m.x[2][1], c3 = m.x[2][2], d3 = m.x[2][3];
F a4 = m.x[3][0], b4 = m.x[3][1], c4 = m.x[3][2], d4 = m.x[3][3];
return a1 * det3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4)
- b1 * det3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4)
+ c1 * det3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4)
- d1 * det3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4);
}
OSL_NAMESPACE_EXIT
+1 -1
View File
@@ -72,7 +72,7 @@ public:
AccumRule(int outidx, bool toalpha)
: m_outidx(outidx), m_save_to_alpha(toalpha) {};
/// Called to accumulate from AccumAutomata. It will select the right ouput from
/// Called to accumulate from AccumAutomata. It will select the right output from
/// the given vector based in the AOV index number (they are guaranteed to match)
void accum(const Color3& color, std::vector<AovOutput>& outputs) const;
+456
View File
@@ -0,0 +1,456 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#pragma once
#include <OSL/batched_shaderglobals.h>
#include <OSL/batched_texture.h>
#include <OSL/oslconfig.h>
#include <OSL/rendererservices.h>
#include <OpenImageIO/ustring.h>
OSL_NAMESPACE_ENTER
// Implementation detail: virtual methods that have a corresponding
// virtual bool is_overridden_* method
// will not be called unless is_overridden_*() returns true;
// This requirement allows the codegenerator to use target specific
// default implementations instead of virtual function calls
// See <OSL/wide.h> for detailed documentation and implementation,
// here is a brief summary of Structure of Array data layout wrappers
//
// Wide<T> contains a T value for WidthT lanes and is accessed
// with [lane] where lane in [0-(WidthT-1)]
//
// Masked<T> bundles a T value for WidthT lanes with a bitmask representing
// the active lanes. So you don't see a Mask or other representation of active
// lanes passed separately, it should be bundled with the data it applies to
//
// MaskedData bundles any type of value for WidthT lanes with a bitmask
// representing the active lanes. MaskData can be invalid, may have derivs,
// and underlying data type can be queried or tested. IE:
// void myFunction(MaskedData<16> any) {
// if (Masked<Vec3>::is(any) {
// Masked<Vec3> vecVal(any);
//
// RefData bundles any type of value. RefData can be invalid, may have derivs,
// and underlying data type can be queried or tested. IE:
// void myFunction(RefData any) {
// if (Ref<int[2]>::is(any) {
// Ref<int[2]> pairVal(any);
template<int WidthT> class OSLEXECPUBLIC BatchedRendererServices {
public:
typedef TextureSystem::Perthread TexturePerthread;
static constexpr int width = WidthT;
// To avoid having the specify the WidthT parameter
// to every templated wrapper, we can create class
// scoped aliases for this class's WidthT
OSL_USING_DATA_WIDTH(WidthT);
BatchedRendererServices(TextureSystem* texsys = NULL);
virtual ~BatchedRendererServices() {}
/// Get the 4x4 matrix that transforms by the specified
/// transformation at the given time. Return a Mask with lanes set to
/// true if ok, false on error.
virtual Mask get_matrix(BatchedShaderGlobals* bsg, Masked<Matrix44> wresult,
Wide<const TransformationPtr> wxform,
Wide<const float> wtime)
{
return Mask(false);
}
/// Get the 4x4 matrix that transforms by the specified
/// transformation at the given time. Return a Mask with lanes set to true
/// if ok, false on error. The default implementation is to use get_matrix and
/// invert it, but a particular renderer may have a better technique
/// and overload the implementation.
virtual Mask get_inverse_matrix(BatchedShaderGlobals* bsg,
Masked<Matrix44> wresult,
Wide<const TransformationPtr> wxform,
Wide<const float> wtime);
virtual bool is_overridden_get_inverse_matrix_WmWxWf() const = 0;
/// Get the 4x4 matrix that transforms points from the named
/// 'from' coordinate system to "common" space at the given time.
/// Return a Mask with lanes set to true if ok, false if the named matrix
/// is not known.
virtual Mask get_matrix(BatchedShaderGlobals* bsg, Masked<Matrix44> wresult,
ustring from, Wide<const float> wtime)
{
return Mask(false);
}
virtual Mask get_matrix(BatchedShaderGlobals* bsg, Masked<Matrix44> result,
Wide<const ustring> wfrom, Wide<const float> wtime);
virtual bool is_overridden_get_matrix_WmWsWf() const = 0;
/// Get the 4x4 matrix that transforms points from "common" space to
/// the named 'to' coordinate system to at the given time. The
/// default implementation is to use get_matrix and invert it, but a
/// particular renderer may have a better technique and overload the
/// implementation.
virtual Mask get_inverse_matrix(BatchedShaderGlobals* bsg,
Masked<Matrix44> wresult, ustring to,
Wide<const float> wtime);
virtual bool is_overridden_get_inverse_matrix_WmsWf() const = 0;
virtual Mask get_inverse_matrix(BatchedShaderGlobals* bsg,
Masked<Matrix44> wresult,
Wide<const ustring> wto,
Wide<const float> wtime);
virtual bool is_overridden_get_inverse_matrix_WmWsWf() const = 0;
// non linear transformations are currently unsupported,
// but could be added if needed
/// Identify if the the named attribute from the renderer can be treated as uniform
/// across all batches to the shader. We assume all attributes are varying unless
/// identified as uniform by the renderer. NOTE: To enable constant folding of
/// an attribute value, it must be uniform and retrievable with
/// a NULL BatchedShaderGlobals
virtual bool is_attribute_uniform(ustring object, ustring name)
{
return false;
}
/// Get the named attribute from the renderer and if found then
/// write it into 'val'. Otherwise, return false. If no object is
/// specified (object == ustring()), then the renderer should search *first*
/// for the attribute on the currently shaded object, and next, if
/// unsuccessful, on the currently shaded "scene".
virtual Mask get_attribute(BatchedShaderGlobals* bsg, ustring object,
ustring name, MaskedData wval)
{
return Mask(false);
}
/// Similar to get_attribute(); this method will fetch the 'index'
/// element of an attribute array.
virtual Mask get_array_attribute(BatchedShaderGlobals* bsg, ustring object,
ustring name, int index, MaskedData wval)
{
return Mask(false);
}
virtual bool get_attribute_uniform(BatchedShaderGlobals* bsg,
ustring object, ustring name,
RefData val)
{
return false;
}
/// Similar to get_attribute(); this method will fetch the 'index'
/// element of an attribute array.
virtual bool get_array_attribute_uniform(BatchedShaderGlobals* bsg,
ustring object, ustring name,
int index, RefData val)
{
return false;
}
/// Get multiple named user-data from the current object and write them into
/// 'val'. If derivatives is true, the derivatives should be written into val
/// as well. It is assumed the results are varying and returns Mask
// with its bit set to off if no user-data with the given name and type was
/// found.
virtual Mask get_userdata(ustring name, BatchedShaderGlobals* bsg,
MaskedData wval)
{
return Mask(false);
}
// Currently texture handles are serviced by the non-batched
// RendererServices interface. If necessary, customized ones could
// be added here. Decided to wait until the use case arises
/// Texturing is setup for a single filename/handle and
/// BatchedTextureOptions (containing uniform and varying sections)
/// and supports varying texture coordinates and derivatives.
/// BatchedTextureOutputs (defined in batched_texture.h) encapsulates a
/// Masked result + derivs, Masked alpha channel + derivs, and Masked
/// errormessage. Primary purpose is to allow a single Mask instance to
/// be shared among the multiple Masked accessors.
/// Filtered 2D texture lookup for a single point.
///
/// s,t are the texture coordinates; dsdx, dtdx, dsdy, and dtdy are
/// the differentials of s and t change in some canonical directions
/// x and y. The choice of x and y are not important to the
/// implementation; it can be any imposed 2D coordinates, such as
/// pixels in screen space, adjacent samples in parameter space on a
/// surface, etc.
///
/// The filename will always be passed, and it's ok for the renderer
/// implementation to use only that (and in fact should be prepared to
/// deal with texture_handle and texture_thread_info being NULL). But
/// sometimes OSL can figure out the texture handle or thread info also
/// and may pass them as non-NULL, in which case the renderer may (if it
/// can) use that extra information to perform a less expensive texture
/// lookup.
///
/// Return Mask with lanes set to true if the file is found and could be
/// opened, otherwise return false.
///
/// If the errormessage is NULL, this method is expected to
/// handle the errors fully, including forwarding them to the renderer
/// or shading system. If errormessage is non-NULL, any resulting error
/// messages (in case of failure, when the function returns false) will
/// be stored there, leaving it up to the caller/shader to handle the
/// error.
///
virtual Mask
texture(ustring filename, TextureSystem::TextureHandle* texture_handle,
TextureSystem::Perthread* texture_thread_info,
const BatchedTextureOptions& options, BatchedShaderGlobals* bsg,
Wide<const float> ws, Wide<const float> wt, Wide<const float> wdsdx,
Wide<const float> wdtdx, Wide<const float> wdsdy,
Wide<const float> wdtdy, BatchedTextureOutputs& outputs);
virtual bool is_overridden_texture() const = 0;
/// Filtered 3D texture lookup for a single point.
///
/// P is the volumetric texture coordinate; dPd{x,y,z} are the
/// differentials of P in some canonical directions x, y, and z.
/// The choice of x,y,z are not important to the implementation; it
/// can be any imposed 3D coordinates, such as pixels in screen
/// space and depth along the ray, etc.
///
/// The filename will always be passed, and it's ok for the renderer
/// implementation to use only that (and in fact should be prepared to
/// deal with texture_handle and texture_thread_info being NULL). But
/// sometimes OSL can figure out the texture handle or thread info also
/// and may pass them as non-NULL, in which case the renderer may (if it
/// can) use that extra information to perform a less expensive texture
/// lookup.
///
/// Return a Mask with lanes set to true if the file is found and could
/// be opened, otherwise return false.
///
/// If the errormessage parameter is NULL, this method is expected to
/// handle the errors fully, including forwarding them to the renderer
/// or shading system. If errormessage is non-NULL, any resulting error
/// messages (in case of failure, when the function returns false) will
/// be stored there, leaving it up to the caller/shader to handle the
/// error.
virtual Mask texture3d(ustring filename,
TextureSystem::TextureHandle* texture_handle,
TextureSystem::Perthread* texture_thread_info,
const BatchedTextureOptions& options,
BatchedShaderGlobals* bsg, Wide<const Vec3> wP,
Wide<const Vec3> wdPdx, Wide<const Vec3> wdPdy,
Wide<const Vec3> wdPdz,
BatchedTextureOutputs& outputs);
virtual bool is_overridden_texture3d() const = 0;
/// Filtered environment lookup for a single point.
///
/// R is the directional texture coordinate; dRd[xy] are the
/// differentials of R in canonical directions x, y.
///
/// The filename will always be passed, and it's ok for the renderer
/// implementation to use only that (and in fact should be prepared to
/// deal with texture_handle and texture_thread_info being NULL). But
/// sometimes OSL can figure out the texture handle or thread info also
/// and may pass them as non-NULL, in which case the renderer may (if it
/// can) use that extra information to perform a less expensive texture
/// lookup.
///
/// Return a Mask with lanes set to true if the file is found and could
/// be opened, otherwise return false.
///
/// If the errormessage parameter is NULL, this method is expected to
/// handle the errors fully, including forwarding them to the renderer
/// or shading system. If errormessage is non-NULL, any resulting error
/// messages (in case of failure, when the function returns false) will
/// be stored there, leaving it up to the caller/shader to handle the
/// error.
virtual Mask environment(ustring filename,
TextureSystem::TextureHandle* texture_handle,
TextureSystem::Perthread* texture_thread_info,
const BatchedTextureOptions& options,
BatchedShaderGlobals* bsg, Wide<const Vec3> wR,
Wide<const Vec3> wdRdx, Wide<const Vec3> wdRdy,
BatchedTextureOutputs& outputs);
virtual bool is_overridden_environment() const = 0;
/// Get information about the given texture. Return a Mask with lanes
/// set to true if found and the data has been put in *data. Mask lanes
/// set to false if the texture doesn't exist, doesn't have the requested
/// data, if the data doesn't match the type requested. or some other
/// failure.
///
/// The filename will always be passed, and it's ok for the renderer
/// implementation to use only that (and in fact should be prepared to
/// deal with texture_handle and texture_thread_info being NULL). But
/// sometimes OSL can figure out the texture handle or thread info also
/// and may pass them as non-NULL, in which case the renderer may (if it
/// can) use that extra information to perform a less expensive texture
/// lookup.
virtual TextureSystem::TextureHandle* resolve_udim_uniform(
BatchedShaderGlobals* bsg, TexturePerthread* texture_thread_info,
ustring filename, TextureSystem::TextureHandle* texture_handle, float S,
float T);
virtual void resolve_udim(BatchedShaderGlobals* bsg,
TexturePerthread* texture_thread_info,
ustring filename,
TextureSystem::TextureHandle* texture_handle,
Wide<const float> wS, Wide<const float> wT,
Masked<TextureSystem::TextureHandle*> wresult);
// Assumes any UDIM has been resolved already
virtual bool get_texture_info_uniform(
BatchedShaderGlobals* bsg, TexturePerthread* texture_thread_info,
ustring filename, TextureSystem::TextureHandle* texture_handle,
int subimage, ustring dataname, RefData val);
/// Lookup nearest points in a point cloud. It will search for
/// points around the given center within the specified radius. A
/// list of indices is returned so the programmer can later retrieve
/// attributes with pointcloud_get. The indices array is mandatory,
/// but distances MaskedData can be invalid (empty), may or may not
/// have derivs, will always be float[], and contains the mask to use
/// for the operations.
///
/// out_num_points will contain the number of points found, always < max_points
// To enable sharing of single mask with multiple outputs we use
// a class to encapsulate multiple wide pointers with a single mask.
// Because the Masked accessors will be constructed by the helper methods
// once inlined compilers will see the same mask_value is used for both.
class PointCloudSearchResults {
void* m_wnum_points;
void* m_windices;
int m_indices_array_length;
void* m_wdistances;
int m_distances_array_length;
bool m_distances_have_derivs;
Mask m_mask;
public:
PointCloudSearchResults(void* wnum_points, void* windices,
int indices_array_length, void* wdistances,
int distances_array_length,
int distances_have_derivs, int mask_value)
: m_wnum_points(wnum_points)
, m_windices(windices)
, m_indices_array_length(indices_array_length)
, m_wdistances(wdistances)
, m_distances_array_length(distances_array_length)
, m_distances_have_derivs(distances_have_derivs)
, m_mask(mask_value)
{
}
OSL_FORCEINLINE Mask mask() const { return m_mask; }
// NOTE: Always assign to a local object before calling an
// array subscript operator []. Bugs can occur if the []
// is called on a temporary object as a reference to a
// temporary object would be created.
// DO NOT DO THIS:
// auto out_num_points = results.wnum_points()[lane];
// instead
// auto wnum_points = results.wnum_points();
// auto out_num_points = wnum_points[lane];
OSL_FORCEINLINE Masked<int> wnum_points() const
{
return Masked<int>(m_wnum_points, m_mask);
}
OSL_FORCEINLINE Masked<int[]> windices() const
{
return Masked<int[]>(m_windices, m_indices_array_length, m_mask);
}
OSL_FORCEINLINE bool has_distances() const
{
return m_wdistances != nullptr;
}
OSL_FORCEINLINE Masked<float[]> wdistances() const
{
return Masked<float[]>(m_wdistances, m_distances_array_length,
m_mask);
}
OSL_FORCEINLINE bool distances_have_derivs() const
{
return m_distances_have_derivs;
}
OSL_FORCEINLINE MaskedDx<float[]> wdistancesDx() const
{
return MaskedDx<float[]>(m_wdistances, m_distances_array_length,
m_mask);
}
OSL_FORCEINLINE MaskedDy<float[]> wdistancesDy() const
{
return MaskedDy<float[]>(m_wdistances, m_distances_array_length,
m_mask);
}
};
virtual void pointcloud_search(BatchedShaderGlobals* bsg, ustring filename,
const void* wcenter,
Wide<const float> wradius, int max_points,
bool sort, PointCloudSearchResults& results);
virtual bool is_overridden_pointcloud_search() const = 0;
virtual Mask pointcloud_get(BatchedShaderGlobals* bsg, ustring filename,
Wide<const int[]> windices,
Wide<const int> wnum_points, ustring attr_name,
MaskedData wout_data);
virtual bool is_overridden_pointcloud_get() const = 0;
virtual Mask pointcloud_write(BatchedShaderGlobals* bsg, ustring filename,
Wide<const OSL::Vec3> wpos, int nattribs,
const ustring* attr_names,
const TypeDesc* attr_types,
const void** pointers_to_wide_attr_value,
Mask mask);
virtual bool is_overridden_pointcloud_write() const = 0;
/// Options for the trace call.
using TraceOpt = RendererServices::TraceOpt;
/// Immediately trace a ray from P in the direction R. Return true
/// if anything hit, otherwise false.
virtual void trace(TraceOpt& options, BatchedShaderGlobals* bsg,
Masked<int> result, Wide<const Vec3> wP,
Wide<const Vec3> wdPdx, Wide<const Vec3> wdPdy,
Wide<const Vec3> wR, Wide<const Vec3> wdRdx,
Wide<const Vec3> wdRdy);
virtual void getmessage(BatchedShaderGlobals* bsg, Masked<int> wresult,
ustring source, ustring name, MaskedData wval);
// pointcloud_search is T.B.D.
/// Return a pointer to the texture system (if available).
virtual TextureSystem* texturesys() const;
protected:
TextureSystem* m_texturesys; // A place to hold a TextureSystem
};
OSL_NAMESPACE_EXIT
+215
View File
@@ -0,0 +1,215 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#pragma once
#if !defined(OSL_USE_BATCHED) || (OSL_USE_BATCHED == 0)
# error batched_shaderglobals.h should not be included unless OSL_USE_BATCHED is defined to 1
#endif
#include <OSL/wide.h>
#include <OSL/shaderglobals.h>
OSL_NAMESPACE_ENTER
namespace pvt {
class BatchedBackendLLVM;
}
struct UniformShaderGlobals {
UniformShaderGlobals() = default;
UniformShaderGlobals(const UniformShaderGlobals& other) = delete;
/// There are three opaque pointers that may be set by the renderer here
/// in the ShaderGlobals before shading execution begins, and then
/// retrieved again from the within the implementation of various
/// RendererServices methods. Exactly what they mean and how they are
/// used is renderer-dependent, but roughly speaking it's probably a
/// pointer to some internal renderer state (needed for, say, figuring
/// out how to retrieve userdata), state about the ray tree (needed to
/// resume for a trace() call), and information about the object being
/// shaded.
void* renderstate;
void* tracedata;
void* objdata;
/// Back-pointer to the ShadingContext (set and used by OSL itself --
/// renderers shouldn't mess with this at all).
ShadingContext* context;
/// Pointer to the RendererServices object. This is how OSL finds its
/// way back to the renderer for callbacks.
RendererServices* renderer;
/// Bit field of ray type flags.
int raytype;
// We want to manually pad this structure out to 64 byte boundary
// and make it simple to duplicate in LLVM without relying on
// compiler structure alignment rules
int pad0;
int pad1;
int pad2;
int pad3;
int pad4;
void dump()
{
#define __OSL_DUMP(VARIABLE_NAME) \
std::cout << #VARIABLE_NAME << " = " << VARIABLE_NAME << std::endl;
std::cout << "UniformShaderGlobals = {" << std::endl;
__OSL_DUMP(renderstate);
__OSL_DUMP(tracedata);
__OSL_DUMP(objdata);
__OSL_DUMP(context);
__OSL_DUMP(renderer);
__OSL_DUMP(raytype);
std::cout << "};" << std::endl;
#undef __OSL_DUMP
}
};
static_assert(sizeof(UniformShaderGlobals) % 64 == 0,
"UniformShaderGlobals must be padded to a 64byte boundary");
template<int WidthT> struct alignas(64) VaryingShaderGlobals {
VaryingShaderGlobals() = default;
VaryingShaderGlobals(const VaryingShaderGlobals& other) = delete;
template<typename T> using Block = OSL::Block<T, WidthT>;
/// Surface position (and its x & y differentials).
Block<Vec3> P, dPdx, dPdy;
/// P's z differential, used for volume shading only.
Block<Vec3> dPdz;
/// Incident ray, and its x and y derivatives.
Block<Vec3> I, dIdx, dIdy;
/// Shading normal, already front-facing.
Block<Vec3> N;
/// True geometric normal.
Block<Vec3> Ng;
/// 2D surface parameter u, and its differentials.
Block<float> u, dudx, dudy;
/// 2D surface parameter v, and its differentials.
Block<float> v, dvdx, dvdy;
/// Surface tangents: derivative of P with respect to surface u and v.
Block<Vec3> dPdu, dPdv;
/// Time for this shading sample.
Block<float> time;
/// Time interval for the frame (or shading sample).
Block<float> dtime;
/// Velocity vector: derivative of position P with respect to time.
Block<Vec3> dPdtime;
/// For lights or light attenuation shaders: the point being illuminated
/// (Ps), and its differentials.
Block<Vec3> Ps, dPsdx, dPsdy;
/// Opaque pointers set by the renderer before shader execution, to
/// allow later retrieval of the object->common and shader->common
/// transformation matrices, by the RendererServices
/// get_matrix/get_inverse_matrix methods. This doesn't need to point
/// to the 4x4 matrix itself; rather, it's just a pointer to whatever
/// structure the RenderServices::get_matrix() needs to (if and when
/// requested) generate the 4x4 matrix for the right time value.
Block<TransformationPtr> object2common;
Block<TransformationPtr> shader2common;
/// The output closure will be placed here. The rendererer should
/// initialize this to NULL before shading execution, and this is where
/// it can retrieve the output closure from after shader execution has
/// completed.
Block<ClosureColor*> Ci;
/// Surface area of the emissive object (used by light shaders for
/// energy normalization).
Block<float> surfacearea;
/// If nonzero, will flip the result of calculatenormal().
Block<int> flipHandedness;
/// If nonzero, we are shading the back side of a surface.
Block<int> backfacing;
void dump()
{
#define __OSL_DUMP(VARIABLE_NAME) VARIABLE_NAME.dump(#VARIABLE_NAME)
std::cout << "VaryingShaderGlobals = {" << std::endl;
__OSL_DUMP(P);
__OSL_DUMP(dPdx);
__OSL_DUMP(dPdy);
__OSL_DUMP(dPdz);
__OSL_DUMP(I);
__OSL_DUMP(dIdx);
__OSL_DUMP(dIdy);
__OSL_DUMP(N);
__OSL_DUMP(Ng);
__OSL_DUMP(u);
__OSL_DUMP(dudx);
__OSL_DUMP(dudy);
__OSL_DUMP(v);
__OSL_DUMP(dvdx);
__OSL_DUMP(dvdy);
__OSL_DUMP(dPdu);
__OSL_DUMP(dPdv);
__OSL_DUMP(time);
__OSL_DUMP(dtime);
__OSL_DUMP(dPdtime);
__OSL_DUMP(Ps);
__OSL_DUMP(dPsdx);
__OSL_DUMP(dPsdy);
__OSL_DUMP(object2common);
__OSL_DUMP(shader2common);
__OSL_DUMP(Ci);
__OSL_DUMP(surfacearea);
__OSL_DUMP(flipHandedness);
__OSL_DUMP(backfacing);
std::cout << "};" << std::endl;
#undef __OSL_DUMP
}
};
template<int WidthT> struct alignas(64) BatchedShaderGlobals {
BatchedShaderGlobals() {}
// Disallow copying
BatchedShaderGlobals(const BatchedShaderGlobals&) = delete;
UniformShaderGlobals uniform;
VaryingShaderGlobals<WidthT> varying;
void dump()
{
std::cout << "BatchedShaderGlobals"
<< " = {" << std::endl;
uniform.dump();
varying.dump();
std::cout << "};" << std::endl;
}
};
#define __OSL_USING_SHADERGLOBALS(WIDTH_OF_OSL_DATA) \
using BatchedShaderGlobals \
= OSL_NAMESPACE::BatchedShaderGlobals<WIDTH_OF_OSL_DATA>;
#undef OSL_USING_DATA_WIDTH
#ifdef __OSL_USING_BATCHED_TEXTURE
# define OSL_USING_DATA_WIDTH(WIDTH_OF_OSL_DATA) \
__OSL_USING_WIDE(WIDTH_OF_OSL_DATA) \
__OSL_USING_SHADERGLOBALS(WIDTH_OF_OSL_DATA) \
__OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA)
#else
# define OSL_USING_DATA_WIDTH(WIDTH_OF_OSL_DATA) \
__OSL_USING_WIDE(WIDTH_OF_OSL_DATA) \
__OSL_USING_SHADERGLOBALS(WIDTH_OF_OSL_DATA)
#endif
OSL_NAMESPACE_EXIT
+288
View File
@@ -0,0 +1,288 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#pragma once
#include <OSL/wide.h>
OSL_NAMESPACE_ENTER
namespace Tex {
using OIIO::Tex::InterpMode;
using OIIO::Tex::MipMode;
using OIIO::Tex::Wrap;
} // namespace Tex
struct UniformTextureOptions {
// Options that must be the same for all points we're texturing at once
int firstchannel = 0; ///< First channel of the lookup
int subimage = 0; ///< Subimage or face ID
ustring subimagename; ///< Subimage name
Tex::Wrap swrap = Tex::Wrap::Default; ///< Wrap mode in the s direction
Tex::Wrap twrap = Tex::Wrap::Default; ///< Wrap mode in the t direction
Tex::Wrap rwrap
= Tex::Wrap::Default; ///< Wrap mode in the r direction (volumetric)
Tex::MipMode mipmode = Tex::MipMode::Default; ///< Mip mode
Tex::InterpMode interpmode
= Tex::InterpMode::SmartBicubic; ///< Interpolation mode
int anisotropic = 32; ///< Maximum anisotropic ratio
int conservative_filter = 1; ///< True: over-blur rather than alias
float fill = 0.0f; ///< Fill value for missing channels
const float* missingcolor = nullptr; ///< Color for missing texture
};
template<int WidthT> struct VaryingTextureOptions {
Block<float, WidthT> sblur; ///< Blur amount
Block<float, WidthT> tblur;
Block<float, WidthT> rblur; // For 3D volume texture lookups only:
Block<float, WidthT> swidth; ///< Multiplier for derivatives
Block<float, WidthT> twidth;
Block<float, WidthT> rwidth; // For 3D volume texture lookups only:
#if OIIO_VERSION_GREATER_EQUAL(2, 4, 0)
Block<float, WidthT> rnd; // For stochastic sampling
#endif
};
static_assert(std::alignment_of<VaryingTextureOptions<16>>::value
== VecReg<16>::alignment,
"Expect alignment of data member to set alignment of struct");
static_assert(std::alignment_of<VaryingTextureOptions<8>>::value
== VecReg<8>::alignment,
"Expect alignment of data member to set alignment of struct");
template<int WidthT> struct BatchedTextureOptions {
VaryingTextureOptions<WidthT> varying;
UniformTextureOptions uniform;
// Options set INTERNALLY by libtexture after the options are passed
// by the user. Users should not attempt to alter these!
int private_envlayout = 0; // Layout for environment wrap
// Implementation detail
// keep order synchronized to the data members in this structure
enum class LLVMMemberIndex {
sblur = 0,
tblur,
rblur,
swidth,
twidth,
rwidth,
#if OIIO_VERSION_GREATER_EQUAL(2, 4, 0)
rnd,
#endif
firstchannel,
subimage,
subimagename,
swrap,
twrap,
rwrap,
mipmode,
interpmode,
anisotropic,
conservative_filter,
fill,
missingcolor,
private_envlayout,
count
};
};
static_assert(std::alignment_of<BatchedTextureOptions<16>>::value
== VecReg<16>::alignment,
"Expect alignment of data member to set alignment of struct");
static_assert(std::alignment_of<BatchedTextureOptions<8>>::value
== VecReg<8>::alignment,
"Expect alignment of data member to set alignment of struct");
#ifdef OIIO_TEXTURE_SIMD_BATCH_WIDTH
// Code here is to validate our OSL BatchedTextureOptions<WidthT> is binary compatible
// and safe to reinterpret_cast<TextureOptBatch*>
static_assert((OIIO::Tex::BatchWidth == 16) || (OIIO::Tex::BatchWidth == 8),
"This validation requires OIIO_TEXTURE_SIMD_BATCH_WIDTH=16");
namespace validate_offsets {
OSL_PRAGMA_WARNING_PUSH
OSL_GCC_PRAGMA(GCC diagnostic ignored "-Winvalid-offsetof")
typedef BatchedTextureOptions<OIIO::Tex::BatchWidth> BTO;
static constexpr size_t uniform_offset = offsetof(BTO, uniform);
static constexpr size_t varying_offset = offsetof(BTO, varying);
typedef VaryingTextureOptions<OIIO::Tex::BatchWidth> VTO;
static_assert(offsetof(OIIO::TextureOptBatch, sblur) % 64 == 0,
"oops unaligned wide variable");
static_assert(offsetof(OIIO::TextureOptBatch, tblur) % 64 == 0,
"oops unaligned wide variable");
static_assert(offsetof(OIIO::TextureOptBatch, rblur) % 64 == 0,
"oops unaligned wide variable");
static_assert(offsetof(OIIO::TextureOptBatch, swidth) % 64 == 0,
"oops unaligned wide variable");
static_assert(offsetof(OIIO::TextureOptBatch, twidth) % 64 == 0,
"oops unaligned wide variable");
static_assert(offsetof(OIIO::TextureOptBatch, rwidth) % 64 == 0,
"oops unaligned wide variable");
# if OIIO_VERSION_GREATER_EQUAL(2, 4, 0)
static_assert(offsetof(OIIO::TextureOptBatch, rnd) % 64 == 0,
"oops unaligned wide variable");
# endif
static_assert(sizeof(OIIO::TextureOptBatch)
== sizeof(BatchedTextureOptions<16>),
"BatchedTextureOptions size differs from OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, sblur)
== varying_offset + offsetof(VTO, sblur),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, tblur)
== varying_offset + offsetof(VTO, tblur),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, rblur)
== varying_offset + offsetof(VTO, rblur),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, swidth)
== varying_offset + offsetof(VTO, swidth),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, twidth)
== varying_offset + offsetof(VTO, twidth),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, rwidth)
== varying_offset + offsetof(VTO, rwidth),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, firstchannel)
== uniform_offset + offsetof(UniformTextureOptions, firstchannel),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, subimage)
== uniform_offset + offsetof(UniformTextureOptions, subimage),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, subimagename)
== uniform_offset + offsetof(UniformTextureOptions, subimagename),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, swrap)
== uniform_offset + offsetof(UniformTextureOptions, swrap),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, twrap)
== uniform_offset + offsetof(UniformTextureOptions, twrap),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, rwrap)
== uniform_offset + offsetof(UniformTextureOptions, rwrap),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, mipmode)
== uniform_offset + offsetof(UniformTextureOptions, mipmode),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, interpmode)
== uniform_offset + offsetof(UniformTextureOptions, interpmode),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, anisotropic)
== uniform_offset + offsetof(UniformTextureOptions, anisotropic),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, conservative_filter)
== uniform_offset
+ offsetof(UniformTextureOptions, conservative_filter),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, fill)
== uniform_offset + offsetof(UniformTextureOptions, fill),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
static_assert(
offsetof(OIIO::TextureOptBatch, missingcolor)
== uniform_offset + offsetof(UniformTextureOptions, missingcolor),
"BatchedTextureOptions members offset different than OIIO::TextureOptBatch");
OSL_PRAGMA_WARNING_POP
} // namespace validate_offsets
#endif
// The wrapper class itself exists to get the 3 different MaskedDataRef classes
// to all share the same mask value (after inlining) vs. 3 different copies
// NOTE: detection and access to derivatives for result and alpha can be done
// using methods "has_derivs", "maskedDx()", and "maskedDy()"
// Detection of nchannels shouldn't be necessary, instead check results().is<float>() or results.is<Color3>()
template<int WidthT> class BatchedTextureOutputs {
public:
explicit BatchedTextureOutputs(void* result, bool resultHasDerivs,
int chans, void* alpha, bool alphaHasDerivs,
void* errormessage, Mask<WidthT> mask)
: m_result(result)
, m_resultHasDerivs(resultHasDerivs)
, m_resultType((chans == 1) ? TypeDesc::TypeFloat : TypeDesc::TypeColor)
, m_alpha(alpha)
, m_alphaHasDerivs(alphaHasDerivs)
, m_errormessage(errormessage)
, m_mask(mask)
{
ASSERT(chans == 1 || chans == 3);
}
OSL_FORCEINLINE Mask<WidthT> mask() const { return m_mask; }
// The return value will be Masked<float, WidthT> or Masked<Vec3, WidthT>
OSL_FORCEINLINE MaskedData<WidthT> result()
{
return MaskedData<WidthT>(m_resultType, m_resultHasDerivs, m_mask,
m_result);
}
// The return value maybe invalid or be Masked<float, WidthT>
OSL_FORCEINLINE MaskedData<WidthT> alpha()
{
return MaskedData<WidthT>(TypeDesc::TypeFloat, m_alphaHasDerivs, m_mask,
m_alpha);
}
// The return value maybe invalid or be Masked<ustring, WidthT>
OSL_FORCEINLINE MaskedData<WidthT> errormessage()
{
return MaskedData<WidthT>(TypeDesc::TypeString, false, m_mask,
m_errormessage);
}
private:
void* m_result;
bool m_resultHasDerivs;
TypeDesc m_resultType;
void* m_alpha;
bool m_alphaHasDerivs;
void* m_errormessage;
Mask<WidthT> m_mask;
};
#define __OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA) \
using BatchedTextureOutputs \
= OSL_NAMESPACE::BatchedTextureOutputs<WIDTH_OF_OSL_DATA>; \
using BatchedTextureOptions \
= OSL_NAMESPACE::BatchedTextureOptions<WIDTH_OF_OSL_DATA>;
#undef OSL_USING_DATA_WIDTH
#ifdef __OSL_USING_SHADERGLOBALS
# define OSL_USING_DATA_WIDTH(WIDTH_OF_OSL_DATA) \
__OSL_USING_WIDE(WIDTH_OF_OSL_DATA) \
__OSL_USING_SHADERGLOBALS(WIDTH_OF_OSL_DATA) \
__OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA)
#else
# define OSL_USING_DATA_WIDTH(WIDTH_OF_OSL_DATA) \
__OSL_USING_WIDE(WIDTH_OF_OSL_DATA) \
__OSL_USING_BATCHED_TEXTURE(WIDTH_OF_OSL_DATA)
#endif
OSL_NAMESPACE_EXIT
+64 -13
View File
@@ -7,7 +7,7 @@
#include <OSL/oslconfig.h>
#ifdef __CUDA_ARCH__
#include <optix.h>
# include <optix.h>
#endif
// USAGE NOTES:
@@ -19,6 +19,14 @@
OSL_NAMESPACE_ENTER
// Strings are handled differently in OptiX 6 vs OptiX 7.
//
// In OptiX 7+:
// Strings are not stored on the GPU at all. Strings are represented by
// their hash values which are computed at compile-time. Because of this,
// we have no access to either the strings' contents or their lengths.
//
// In OptiX 6:
// Strings are stored in a block of CUDA device memory. String variables hold a
// pointer to the start of the char array for each string. Each canonical string
// has a unique entry in the table, so two strings can be tested for equality by
@@ -28,32 +36,72 @@ OSL_NAMESPACE_ENTER
// stored in the table, in the 16 bytes preceding the characters.
struct DeviceString {
#ifdef __CUDA_ARCH__
size_t m_chars;
#else
const char* m_chars;
#endif
#ifdef __CUDA_ARCH__
OSL_HOSTDEVICE DeviceString() {}
OSL_HOSTDEVICE DeviceString(uint64_t i) : m_chars(i) {}
#endif
OSL_HOSTDEVICE uint64_t hash() const
{
#ifdef __CUDA_ARCH__
return m_chars;
#else
return *(uint64_t*)(m_chars - sizeof(uint64_t) - sizeof(uint64_t));
#endif
}
// In OptiX 7 we don't store the string's length. Make this a compile
// time error.
#ifndef __CUDA_ARCH__
OSL_HOSTDEVICE uint64_t length() const
{
return *(uint64_t*)(m_chars - sizeof(uint64_t));
}
#endif
// In OptiX 7 we can't return the string's contents. Make this a compile
// time error.
#ifndef __CUDA_ARCH__
OSL_HOSTDEVICE const char* c_str() const
{
return m_chars;
}
#endif
OSL_HOSTDEVICE bool operator== (const DeviceString& other) const
OSL_HOSTDEVICE bool operator==(const DeviceString& other) const
{
return m_chars == other.m_chars;
}
OSL_HOSTDEVICE bool operator!= (const DeviceString& other) const
OSL_HOSTDEVICE bool operator!=(const DeviceString& other) const
{
return m_chars != other.m_chars;
}
#ifdef __CUDA_ARCH__
OSL_HOSTDEVICE bool operator==(const size_t other) const
{
return hash() == other;
}
OSL_HOSTDEVICE bool operator!=(const size_t other) const
{
return hash() != other;
}
OSL_HOSTDEVICE operator size_t() const
{
return hash();
}
#endif
};
@@ -61,9 +109,9 @@ struct DeviceString {
// macro is the same as the USTR macro defined in oslexec_pvt.h when compiling
// for the host.
#ifndef __CUDA_ARCH__
# define HDSTR(cstr) (*((ustring *)&cstr))
# define HDSTR(cstr) (*((ustring*)&cstr))
#else
# define HDSTR(cstr) (*(OSL::DeviceString*)&cstr)
# define HDSTR(cstr) (*((OSL::DeviceString*)&cstr))
#endif
@@ -79,19 +127,22 @@ typedef DeviceString StringParam;
#ifdef __CUDA_ARCH__
namespace DeviceStrings {
#define STRDECL(str,var_name) \
extern __device__ OSL_NAMESPACE::DeviceString var_name;
#include <OSL/strdecls.h>
#undef STRDECL
}
# define STRDECL(str, var_name) \
extern __device__ OSL_NAMESPACE::DeviceString var_name;
# undef STRDECL
} // namespace DeviceStrings
#else
# ifdef OSL_HOST_RS_BITCODE
# define STRING_PARAMS(x) RS_##x
# else
# define STRING_PARAMS(x) StringParams::x
# endif
#endif
OSL_NAMESPACE_EXIT
#ifdef __CUDA_ARCH__
namespace StringParams = OSL_NAMESPACE::DeviceStrings;
#else
#ifndef __CUDA_ARCH__
namespace StringParams = OSL_NAMESPACE::Strings;
#endif
+1 -1
View File
@@ -223,7 +223,7 @@ public:
// delegating access to element storage to the DualStorage base class
template<
class T, // Base data type
int PARTIALS=1 // Number of dimentions of partial derivs
int PARTIALS=1 // Number of dimensions of partial derivs
>
class Dual : public DualStorage<T, PARTIALS> {
static const int elements = PARTIALS+1; // main value + partials
+2 -1
View File
@@ -42,7 +42,8 @@
/// another.
#if defined(_WIN32) || defined(__CYGWIN__)
# if defined(OSL_STATIC_BUILD) || defined(OSL_STATIC_DEFINE)
# if defined(OSL_STATIC_BUILD) || defined(OSL_STATIC_DEFINE) \
|| defined(__CUDACC__)
# define OSL_DLL_IMPORT
# define OSL_DLL_EXPORT
# define OSL_DLL_LOCAL
File diff suppressed because it is too large Load Diff
+401
View File
@@ -0,0 +1,401 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#pragma once
#include <type_traits>
#include <OSL/oslconfig.h>
OSL_NAMESPACE_ENTER
// clang-format off
// Define popcount and countr_zero
#if OSL_CPLUSPLUS_VERSION >= 20
// For C++20 and beyond, these are in the standard library
using std::popcount;
using std::countr_zero;
#elif OSL_INTEL_CLASSIC_COMPILER_VERSION
#include <immintrin.h>
OSL_FORCEINLINE int popcount(uint32_t x) noexcept { return _mm_popcnt_u32(x);}
OSL_FORCEINLINE int popcount(uint64_t x) noexcept { return _mm_popcnt_u64(x); }
OSL_FORCEINLINE int countr_zero(uint32_t x) noexcept { return _bit_scan_forward(x); }
OSL_FORCEINLINE int countr_zero(uint64_t x) noexcept {
unsigned __int32 index;
_BitScanForward64(&index, x);
return static_cast<int>(index);
}
#elif defined(__GNUC__) || defined(__clang__)
OSL_FORCEINLINE int popcount(uint32_t x) noexcept { return __builtin_popcount(x); }
OSL_FORCEINLINE int popcount(uint64_t x) noexcept { return __builtin_popcountll(x); }
OSL_FORCEINLINE int countr_zero(uint32_t x) noexcept { return __builtin_ctz(x); }
OSL_FORCEINLINE int countr_zero(uint64_t x) noexcept { return __builtin_ctzll(x); }
#elif defined(_MSC_VER)
OSL_FORCEINLINE int popcount(uint32_t x) noexcept { return static_cast<int>(__popcnt(x)); }
OSL_FORCEINLINE int popcount(uint64_t x) noexcept { return static_cast<int>(__popcnt64(x)); }
OSL_FORCEINLINE int countr_zero(uint32_t x) noexcept {
unsigned long index;
_BitScanForward(&index, x);
return static_cast<int>(index);
}
OSL_FORCEINLINE int countr_zero(uint64_t x) noexcept {
unsigned long index;
_BitScanForward64(&index, x);
return static_cast<int>(index);
}
#else
# error "popcount and coutr_zero implementations needed for this compiler"
#endif
// clang-format on
// Simple wrapper to identify a single lane index vs. a mask_value
class Lane {
const int m_index;
public:
explicit OSL_FORCEINLINE Lane(int index) : m_index(index) {}
Lane() = delete;
OSL_FORCEINLINE Lane(const Lane& other) : m_index(other.m_index) {}
OSL_FORCEINLINE int value() const { return m_index; }
OSL_FORCEINLINE
operator int() const { return m_index; }
};
// Simple wrapper to identify an active lane
// Active lanes will bypass mask testing during assignments to Masked::LaneProxy's
// But be careful if you ever have two Masked::LaneProxy's with
// different masks
class ActiveLane : public Lane {
public:
explicit OSL_FORCEINLINE ActiveLane(int index) : Lane(index) {}
ActiveLane() = delete;
OSL_FORCEINLINE ActiveLane(const ActiveLane& other) : Lane(other) {}
};
template<int WidthT> class Mask {
typedef unsigned short Value16Type;
static_assert(sizeof(Value16Type) == 2, "unexpected platform");
typedef unsigned int Value32Type;
static_assert(sizeof(Value32Type) == 4, "unexpected platform");
typedef unsigned long long Value64Type;
static_assert(sizeof(Value64Type) == 8, "unexpected platform");
typedef
typename std::conditional<WidthT <= 32, Value32Type, Value64Type>::type
Value32or64Type;
public:
#if 0 // Enable 16bit integer storage of masks, vs 32bit.
typedef typename std::conditional<WidthT <= 16,
Value16Type,
Value32or64Type>::type ValueType;
#else
typedef Value32or64Type ValueType;
#endif
static constexpr int width = WidthT;
protected:
static constexpr int value_width = sizeof(ValueType) * 8;
static_assert(value_width >= WidthT, "unsupported WidthT");
static constexpr ValueType valid_bits
= static_cast<ValueType>(0xFFFFFFFFFFFFFFFF) >> (value_width - WidthT);
public:
OSL_FORCEINLINE Mask() {}
explicit OSL_FORCEINLINE Mask(Lane lane) : m_value(1 << lane.value()) {}
explicit OSL_FORCEINLINE Mask(bool all_on_or_off)
: m_value((all_on_or_off) ? valid_bits : 0)
{
}
explicit constexpr OSL_FORCEINLINE Mask(std::false_type) : m_value(0) {}
explicit constexpr OSL_FORCEINLINE Mask(std::true_type)
: m_value(valid_bits)
{
}
explicit OSL_FORCEINLINE Mask(Value16Type value_)
: m_value(static_cast<ValueType>(value_))
{
}
explicit OSL_FORCEINLINE Mask(Value32Type value_)
: m_value(static_cast<ValueType>(value_))
{
}
explicit OSL_FORCEINLINE Mask(Value64Type value_)
: m_value(static_cast<ValueType>(value_))
{
}
explicit OSL_FORCEINLINE Mask(int value_)
: m_value(static_cast<ValueType>(value_))
{
}
OSL_FORCEINLINE Mask(const Mask& other) : m_value(other.m_value) {}
template<int OtherWidthT,
typename = pvt::enable_if_type<(OtherWidthT < WidthT)>>
explicit OSL_FORCEINLINE Mask(const Mask<OtherWidthT>& other)
: m_value(static_cast<ValueType>(other.value()))
{
}
OSL_FORCEINLINE ValueType value() const
{
return m_value;
}
// count number of active bits
OSL_FORCEINLINE int count() const
{
return OSL::popcount(m_value);
}
// NOTE: undefined result if no bits are on
OSL_FORCEINLINE int first_on() const
{
return OSL::countr_zero(m_value);
}
OSL_FORCEINLINE Mask invert() const
{
return Mask((~m_value) & valid_bits);
}
// Test only, don't allow assignment to force
// more verbose set_on or set_off to be used
// NOTE: As the actual lane value is embedded
// inside an integral type, we would have to
// return a proxy which could complicate
// codegen, so keeping it simple(r)
OSL_FORCEINLINE bool operator[](int lane) const
{
// __assume(lane >= 0 && lane < width);
//return (m_value & (1<<lane))==(1<<lane);
//return (m_value >>lane) & 1;
// From testing code generation this is the preferred form
return (m_value & (1 << lane));
}
OSL_FORCEINLINE bool is_on(int lane) const
{
// From testing code generation this is the preferred form
//return (m_value & (1<<lane))==(1<<lane);
return (m_value & (1 << lane));
}
OSL_FORCEINLINE bool is_off(int lane) const
{
// From testing code generation this is the preferred form
return (m_value & (1 << lane)) == 0;
}
OSL_FORCEINLINE bool all_on() const
{
// TODO: is this more expensive than == ?
return (m_value >= valid_bits);
}
OSL_FORCEINLINE bool all_off() const
{
return (m_value == static_cast<ValueType>(0));
}
OSL_FORCEINLINE bool any_on() const
{
return (m_value != static_cast<ValueType>(0));
}
OSL_FORCEINLINE bool any_off() const
{
return (m_value < valid_bits);
}
OSL_FORCEINLINE bool any_off(const Mask& mask) const
{
return m_value != (m_value & mask.m_value);
}
// Setters
// For SIMD loops, set_on and set_off work better
// than a generic set(lane,flag).
// And in most all cases, the starting state
// for the mask was all on or all off,
// So really only set_on or set_off is required
// Choose to not provide a generic set(int lane, bool flag)
OSL_FORCEINLINE void set_on(int lane)
{
m_value |= (1 << lane);
}
OSL_FORCEINLINE void set_on_if(int lane, bool cond)
{
m_value |= (cond << lane);
}
OSL_FORCEINLINE void set_all_on()
{
m_value = valid_bits;
}
OSL_FORCEINLINE void set_count_on(int count)
{
m_value = valid_bits >> (width - count);
}
OSL_FORCEINLINE void set_off(int lane)
{
m_value &= (~(1 << lane));
}
OSL_FORCEINLINE void set_off_if(int lane, bool cond)
{
m_value &= (~(cond << lane));
}
OSL_FORCEINLINE void set_all_off()
{
m_value = static_cast<ValueType>(0);
}
OSL_FORCEINLINE bool operator==(const Mask& other) const
{
return m_value == other.m_value;
}
OSL_FORCEINLINE bool operator!=(const Mask& other) const
{
return m_value != other.m_value;
}
OSL_FORCEINLINE Mask& operator&=(const Mask& other)
{
m_value = m_value & other.m_value;
return *this;
}
OSL_FORCEINLINE Mask& operator|=(const Mask& other)
{
m_value = m_value | other.m_value;
return *this;
}
OSL_FORCEINLINE Mask operator&(const Mask& other) const
{
return Mask(m_value & other.m_value);
}
OSL_FORCEINLINE Mask operator|(const Mask& other) const
{
return Mask(m_value | other.m_value);
}
OSL_FORCEINLINE Mask operator~() const
{
return invert();
}
template<int MinOccupancyT, int MaxOccupancyT = width, typename FunctorT>
OSL_FORCEINLINE void foreach (FunctorT f) const
{
// Expect compile time dead code elimination to skip this when possible
if (MaxOccupancyT == 0)
return;
// Expect compile time dead code elimination to skip this when possible
if (MinOccupancyT == 0) {
if (all_off())
return;
}
OSL_DASSERT(any_on());
// Expect compile time dead code elimination to emit
// one branch or the other
if (MaxOccupancyT == 1) {
ActiveLane active_lane(first_on());
f(active_lane);
} else {
Mask m(m_value);
do {
ActiveLane active_lane(m.first_on());
f(active_lane);
m.set_off(active_lane);
} while (m.any_on());
}
}
// Serially apply functor f to each
// lane active in the Mask
template<typename FunctorT> OSL_FORCEINLINE void foreach (FunctorT f) const
{
foreach
<0, width, FunctorT>(f);
}
// non-inlined version to isolate inherently serial codegen
// of functor f from other call site whose code gen might
// be SIMD in nature. Not inlining prevents optimizer from
// mixing serial code gen with call site which could inhibit
// ability to generate SIMD code.
template<int MinOccupancyT, int MaxOccupancyT = width, typename FunctorT>
OSL_NOINLINE void invoke_foreach(FunctorT f) const;
template<typename FunctorT>
OSL_NOINLINE void invoke_foreach(FunctorT f) const;
// Treat m_value as private, but access is needed for #pragma's to reference it in reduction clauses
ValueType m_value;
};
template<int WidthT>
template<typename FunctorT>
void
Mask<WidthT>::invoke_foreach(FunctorT f) const
{
foreach
<0, width, FunctorT>(f);
}
template<int WidthT>
template<int MinOccupancyT, int MaxOccupancyT, typename FunctorT>
void
Mask<WidthT>::invoke_foreach(FunctorT f) const
{
foreach
<MinOccupancyT, MaxOccupancyT, FunctorT>(f);
}
OSL_NAMESPACE_EXIT
+1 -1
View File
@@ -959,7 +959,7 @@ Matrix22<T>::inverse (bool singExc) const
{
#ifndef __CUDA_ARCH__
if (singExc)
throw Imath::SingMatrixExc ("Cannot invert "
throw std::invalid_argument ("Cannot invert "
"singular matrix.");
#endif
return Matrix22();
+15 -3
View File
@@ -109,8 +109,14 @@ OSL_ALIGNAS(16) ClosureComponent : public ClosureColor
Vec3 w; ///< Weight of this component
/// Handy method for getting the parameter memory as a void*.
OSL_HOSTDEVICE void* data() { return (char*)(this + 1); }
OSL_HOSTDEVICE const void* data() const { return (const char*)(this + 1); }
OSL_HOSTDEVICE void* data()
{
return (char*)(this + 1);
}
OSL_HOSTDEVICE const void* data() const
{
return (const char*)(this + 1);
}
/// Handy methods for extracting the underlying parameters as a struct
template<typename T> OSL_HOSTDEVICE const T* as() const
@@ -120,7 +126,7 @@ OSL_ALIGNAS(16) ClosureComponent : public ClosureColor
template<typename T> OSL_HOSTDEVICE T* as()
{
return reinterpret_cast<const T*>(data());
return reinterpret_cast<T*>(data());
}
};
@@ -140,4 +146,10 @@ struct OSLEXECPUBLIC ClosureAdd : public ClosureColor {
const ClosureColor* closureB;
};
/// Type for pointers to closures
typedef ClosureColor* ClosureColorPtr;
typedef ClosureComponent* ClosureComponentPtr;
typedef ClosureAdd* ClosureAddPtr;
typedef ClosureMul* ClosureMulPtr;
OSL_NAMESPACE_EXIT
+100 -69
View File
@@ -4,10 +4,9 @@
#pragma once
#include <OSL/platform.h>
#include <OSL/export.h>
#include <OSL/oslversion.h>
#include <OSL/platform.h>
// All the things we need from Imath.
@@ -24,15 +23,31 @@
# include <OSL/Imathx/ImathVec.h>
# include <OSL/Imathx/ImathMatrix.h>
# include <OSL/Imathx/ImathColor.h>
# include <OSL/matrix22.h>
#endif
// The fmt library causes trouble for Cuda. Work around by disabling it from
// oiio headers (OIIO <= 2.1) or telling fmt not to use the troublesome
// int128 that Cuda doesn't understand (OIIO >= 2.2).
// We included the Imath files we needed, so set the OIIO_IMATH_H_INCLUDED
// symbol to prevent OpenImageIO/Imath.h from including them again (or
// before), which is critical if they turn out to be different versions.
#define OIIO_IMATH_H_INCLUDED 1
// The fmt library causes trouble for Cuda. Work around by telling fmt not to
// use the troublesome int128 that Cuda doesn't understand.
#ifdef __CUDA_ARCH__
# define OIIO_USE_FMT 0
# define FMT_USE_INT128 0
# ifndef FMT_USE_INT128
# define FMT_USE_INT128 0
# endif
#endif
// For OSL internal compilation only, get deprecation warnings if we call OIIO
// methods that use the old printf style interface.
#ifdef OSL_INTERNAL
# ifdef OIIO_ERRORHANDLER_HIDE_PRINTF
# define OIIO_ERRORHANDLER_HIDE_PRINTF 1
# endif
# ifdef OIIO_HIDE_FORMAT
# define OIIO_HIDE_FORMAT 1
# endif
#endif
// All the things we need from OpenImageIO
@@ -47,6 +62,8 @@
OSL_NAMESPACE_ENTER
#define OSL_USE_BATCHED @BUILD_BATCHED@
/// Various compile-time defaults are defined here that could, in
/// principle, be redefined if you are using OSL in some particular
/// renderer that wanted things a different way.
@@ -73,11 +90,6 @@ using Color3 = Imath::Color3<Float>;
using Matrix33 = Imath::Matrix33<Float>;
using Matrix44 = Imath::Matrix44<Float>;
#if OSL_USING_IMATH >= 3
using Matrix22 = Imath::Matrix22<Float>;
#else
using Matrix22 = Imathx::Matrix22<Float>;
#endif
/// Assume that we are dealing with OpenImageIO's texture system. It
@@ -89,13 +101,51 @@ using OIIO::TextureOpt;
// And some other things we borrow from OIIO...
using OIIO::ErrorHandler;
using OIIO::TypeDesc;
using OIIO::ustring;
using OIIO::ustringHash;
using OIIO::ustringhash;
using OIIO::string_view;
using OIIO::span;
using OIIO::cspan;
using OIIO::TypeDesc;
using OIIO::TypeUnknown;
using OIIO::TypeFloat;
using OIIO::TypeColor;
using OIIO::TypePoint;
using OIIO::TypeVector;
using OIIO::TypeNormal;
using OIIO::TypeMatrix;
using OIIO::TypeFloat4;
using OIIO::TypeString;
using OIIO::TypeInt;
using OIIO::TypeFloat2;
using OIIO::TypeVector2;
using OIIO::TypeVector4;
using OIIO::Strutil::print;
template<typename Str, typename... Args>
OSL_NODISCARD inline std::string
fmtformat(const Str& fmt, Args&&... args)
{
return OIIO::Strutil::fmt::format(fmt, std::forward<Args>(args)...);
}
// N.B. SymArena is not really "configuration", but we cram it here for
// lack of a better home.
/// The different memory arenas where symbols may live on the app side
enum class SymArena {
Unknown = 0, // Unknown/uninitialized value
Absolute, // Absolute address
Heap, // Belongs to context heap
Outputs, // Belongs to output arena
UserData, // UserData arena
// ShaderGlobals, // RESERVED
};
/////////////////////////////////////////////////////////////////////////
@@ -120,47 +170,14 @@ using OIIO::cspan;
namespace pvt {
#if (OSL_CPLUSPLUS_VERSION >= 14)
template<int... IntegerListT>
using int_sequence = std::integer_sequence<int, IntegerListT...>;
template<int... IntegerListT>
using int_sequence = std::integer_sequence<int, IntegerListT...>;
template<int EndBeforeT>
using make_int_sequence = std::make_integer_sequence<int, EndBeforeT>;
template<int EndBeforeT>
using make_int_sequence = std::make_integer_sequence<int, EndBeforeT>;
template<bool... BoolListT >
using bool_sequence = std::integer_sequence<bool, BoolListT... >;
#else
// std::integer_sequence requires c++14 library support,
// we have our own version here in case the environment is c++14 compiler
// building against c++11 library.
template<int... IntegerListT>
struct int_sequence
{
};
template<int StartAtT, int EndBeforeT, typename IntSequenceT>
struct int_sequence_generator;
template<int StartAtT, int EndBeforeT, int... IntegerListT>
struct int_sequence_generator<StartAtT, EndBeforeT, int_sequence<IntegerListT...>>
{
typedef typename int_sequence_generator<StartAtT+1, EndBeforeT, int_sequence<IntegerListT..., StartAtT>>::type type;
};
template<int EndBeforeT, int... IntegerListT>
struct int_sequence_generator<EndBeforeT, EndBeforeT, int_sequence<IntegerListT...>>
{
typedef int_sequence<IntegerListT...> type;
};
template<int EndBeforeT>
using make_int_sequence = typename int_sequence_generator<0, EndBeforeT, int_sequence<> >::type;
template<bool... BoolListT >
struct bool_sequence
{
};
#endif
template<bool... BoolListT >
using bool_sequence = std::integer_sequence<bool, BoolListT... >;
#if (OSL_CPLUSPLUS_VERSION >= 17)
template<class... ListT>
@@ -194,21 +211,8 @@ static OSL_FORCEINLINE OSL_HOSTDEVICE void static_foreach(const FunctorT &iFunct
static_foreach<ConstantWrapperT>(pvt::make_int_sequence<N>(), iFunctor);
}
#if (OSL_CPLUSPLUS_VERSION >= 14)
template<int N>
using ConstIndex = std::integral_constant<int, N>;
#else
template<int N>
struct ConstIndex : public std::integral_constant<int, N>
{
// C++14 adds this conversion operator we need to allow non-generic
// lambda functions (pre C++14) to accept an "int" instead of a
// typed ConstIndex<N> with "auto"
constexpr int operator()() const noexcept {
return N;
}
};
#endif
template<int N>
using ConstIndex = std::integral_constant<int, N>;
// During development it can be useful to output extra information
@@ -221,3 +225,30 @@ static OSL_FORCEINLINE OSL_HOSTDEVICE void static_foreach(const FunctorT &iFunct
OSL_NAMESPACE_EXIT
namespace std { // not necessary in C++17, then we can just say std::hash
#ifndef OIIO_USTRING_HAS_STDHASH
// Not a new enough OIIO to define std::hash<ustring>, so we'll do it
template<> struct hash<OSL::ustring> {
std::size_t operator()(OSL::ustring u) const noexcept { return u.hash(); }
};
template<> struct hash<OSL::ustringhash> {
OSL_HOSTDEVICE constexpr std::size_t
operator()(OSL::ustringhash u) const noexcept
{
return u.hash();
}
};
#endif
// Not necessary once minimum OIIO defines operator< for ustringhash
template<> struct less<OSL::ustringhash> {
OSL_HOSTDEVICE constexpr bool operator()(OSL::ustringhash u,
OSL::ustringhash v) const noexcept
{
return u.hash() < v.hash();
}
};
} // namespace std
+433 -183
View File
@@ -8,14 +8,13 @@
#include <OSL/oslconfig.h>
#include <OSL/shaderglobals.h>
#include <OSL/rendererservices.h>
#include <OpenImageIO/refcnt.h>
#include <OpenImageIO/ustring.h>
OSL_NAMESPACE_ENTER
// Various forward declarations
class RendererServices;
class ShaderGroup;
typedef std::shared_ptr<ShaderGroup> ShaderGroupRef;
@@ -23,8 +22,19 @@ struct ClosureParam;
struct PerThreadInfo;
class ShadingContext;
class ShaderSymbol;
class OSLQuery;
#if OSL_USE_BATCHED
template<int WidthT> struct alignas(64) BatchedShaderGlobals;
template<typename DataT, int WidthT> struct Wide;
#endif
/// RendererServices free function bitcode may reference global variables that
/// only exist in the renderer's program space and won't automatically be
/// found when referenced in JIT'd code inside OSL. A renderer may register
/// the addresses of these global variables to allow valid JIT to occur.
void OSLEXECPUBLIC
register_JIT_Global(const char* global_var_name, void* global_var_addr);
/// Opaque pointer to whatever the renderer uses to represent a
/// (potentially motion-blurred) coordinate transformation.
@@ -40,27 +50,73 @@ namespace pvt {
class ShadingSystemImpl;
}
#ifdef __CUDA_ARCH__
# define STRING_PARAMS(x) UStringHash::Hash(__OSL_STRINGIFY(x))
#else
# define STRING_PARAMS(x) StringParams::x
#endif
namespace Strings {
#ifdef __CUDA_ARCH__
#define STRDECL(str,var_name) extern __device__ ustring var_name;
# define STRDECL(str, var_name)
#else
// Any strings referenced inside of a libsoslexec/wide/*.cpp
// or liboslnoise/wide/*.cpp will need OSLEXECPUBLIC
#define STRDECL(str,var_name) OSLEXECPUBLIC extern const ustring var_name;
// Any strings referenced inside of a libsoslexec/wide/*.cpp
// or liboslnoise/wide/*.cpp will need OSLEXECPUBLIC
# define STRDECL(str, var_name) OSLEXECPUBLIC extern const ustring var_name;
#endif
#include <OSL/strdecls.h>
#undef STRDECL
}; // namespace Strings
}; // namespace Strings
class OSLEXECPUBLIC ShadingSystem
{
/// Description of where a symbol is located on the app side.
struct SymLocationDesc {
public:
ShadingSystem (RendererServices *renderer=NULL,
TextureSystem *texturesystem=NULL,
ErrorHandler *err=NULL);
~ShadingSystem ();
using offset_t = int64_t;
using stride_t = int64_t;
static const int64_t AutoStride = std::numeric_limits<stride_t>::min();
SymLocationDesc() {}
SymLocationDesc(string_view name, TypeDesc type, bool derivs = false,
SymArena arena = SymArena::Heap, offset_t offset = -1,
stride_t stride = AutoStride)
: name(name)
, type(type)
, offset(offset)
, stride(stride == AutoStride ? type.size() : stride)
, arena(arena)
, derivs(derivs)
{
}
bool operator==(ustring n) const { return name == n; }
friend bool operator<(ustring n, const SymLocationDesc& sld)
{
return n < sld.name;
}
friend bool operator<(const SymLocationDesc& sld, ustring n)
{
return sld.name < n;
}
ustring name; ///< Name of the symbol
TypeDesc type; ///< Data type of the symbol
offset_t offset
= -1; ///< Offset from arena base for point 0 (batched mode assumes userdata at point 0 is readable)
stride_t stride = AutoStride; ///< Stride in bytes between shade points
SymArena arena = SymArena::Heap; ///< Memory arena type for the symbol
bool derivs = false; ///< Space allocated for derivs also
};
class OSLEXECPUBLIC ShadingSystem {
public:
ShadingSystem(RendererServices* renderer = NULL,
TextureSystem* texturesystem = NULL,
ErrorHandler* err = NULL);
~ShadingSystem();
/// Set an attribute controlling the shading system. Return true
/// if the name and type were recognized and the attrib was set.
@@ -87,10 +143,11 @@ public:
/// int no_noise Replace noise with constant value. (0)
/// int no_pointcloud Skip pointcloud lookups. (0)
/// int exec_repeat How many times to run each group (1).
/// int opt_warnings Warn on certain failure to runtime-optimize
/// certain shader constructs. (0)
/// int gpu_opt_error Consider a hard error if certain shader
/// constructs cannot be optimized away. (0)
/// int opt_warnings Warn on failure to runtime-optimize certain
/// shader constructs. (0)
/// int gpu_opt_error Issue a hard error if certain shader
/// constructs cannot be optimized away, which
/// have no way to run on GPU. (0)
/// 2. Attributes that should be set by applications/renderers that
/// incorporate OSL:
/// string commonspace Name of "common" coord system ("world")
@@ -164,7 +221,7 @@ public:
/// opt_fold_getattribute, opt_middleman, opt_texture_handle
/// opt_seed_bblock_aliases
/// int opt_passes Number of optimization passes per layer (10)
/// int llvm_optimize Which of several LLVM optimize strategies (0)
/// int llvm_optimize Which of several LLVM optimize strategies (1)
/// int llvm_debug Set LLVM extra debug level (0)
/// int llvm_debug_layers Extra printfs upon entering and leaving
/// layer functions.
@@ -174,8 +231,7 @@ public:
/// for debugging. (0)
/// int llvm_dumpasm Print the CPU assembly code from the JIT (0)
/// string llvm_prune_ir_strategy Strategy for pruning unnecessary
/// IR (choices: "prune" [default],
/// "internalize", or "none").
/// IR (choices: "prune" [default], or "none").
/// int max_local_mem_KB Error if shader group needs more than this
/// much local storage to execute (1024K)
/// string debug_groupname Name of shader group -- debug only this one
@@ -190,22 +246,27 @@ public:
/// Note: the attributes referred to as "string" are actually on the app
/// side as ustring or const char* (they have the same data layout), NOT
/// std::string!
bool attribute (string_view name, TypeDesc type, const void *val);
bool attribute(string_view name, TypeDesc type, const void* val);
// Shortcuts for common types
bool attribute (string_view name, int val) {
return attribute (name, TypeDesc::INT, &val);
bool attribute(string_view name, int val)
{
return attribute(name, TypeDesc::INT, &val);
}
bool attribute (string_view name, float val) {
return attribute (name, TypeDesc::FLOAT, &val);
bool attribute(string_view name, float val)
{
return attribute(name, TypeDesc::FLOAT, &val);
}
bool attribute (string_view name, double val) {
float f = (float) val;
return attribute (name, TypeDesc::FLOAT, &f);
bool attribute(string_view name, double val)
{
float f = (float)val;
return attribute(name, TypeDesc::FLOAT, &f);
}
bool attribute (string_view name, string_view val) {
const char *s = val.c_str();
return attribute (name, TypeDesc::STRING, &s);
bool attribute(string_view name, string_view val)
{
std::string valstr(val);
const char* s = valstr.c_str();
return attribute(name, TypeDesc::STRING, &s);
}
@@ -221,50 +282,100 @@ public:
/// called unconditionally.
/// int exec_repeat How many times to run the group (1).
///
bool attribute (ShaderGroup *group, string_view name,
TypeDesc type, const void *val);
bool attribute (ShaderGroup *group, string_view name, int val) {
return attribute (group, name, TypeDesc::INT, &val);
bool attribute(ShaderGroup* group, string_view name, TypeDesc type,
const void* val);
bool attribute(ShaderGroup* group, string_view name, int val)
{
return attribute(group, name, TypeDesc::INT, &val);
}
bool attribute (ShaderGroup *group, string_view name, float val) {
return attribute (group, name, TypeDesc::FLOAT, &val);
bool attribute(ShaderGroup* group, string_view name, float val)
{
return attribute(group, name, TypeDesc::FLOAT, &val);
}
bool attribute (ShaderGroup *group, string_view name, double val) {
float f = (float) val;
return attribute (group, name, TypeDesc::FLOAT, &f);
bool attribute(ShaderGroup* group, string_view name, double val)
{
float f = (float)val;
return attribute(group, name, TypeDesc::FLOAT, &f);
}
bool attribute (ShaderGroup *group, string_view name, string_view val) {
const char *s = val.c_str();
return attribute (group, name, TypeDesc::STRING, &s);
bool attribute(ShaderGroup* group, string_view name, string_view val)
{
std::string valstr(val);
const char* s = valstr.c_str();
return attribute(group, name, TypeDesc::STRING, &s);
}
/// Get the named attribute, store it in value.
/// Get the named attribute of the ShadingSystem, store it in `*val`.
/// Return `true` if found and it was compatible with the type
/// specified, otherwise return `false` and do not modify the contents
/// of `*val`. It is up to the caller to ensure that `val` points to
/// the right kind and size of storage for the given type.
///
bool getattribute (string_view name, TypeDesc type, void *val);
/// In addition to being able to retrieve all the attributes that are
/// documented as settable by the `attribute()` call, `getattribute()`
/// can also retrieve the following read-only attributes:
///
/// - `string osl:simd`, `string hw:simd` : A comma-separated list of
/// CPU hardware SIMD features. The `osl:simd` is a list of features
/// enabled when OSL was built, and `hw:simd` is a list of features
/// detected on the actual hardware at runtime.
///
/// - `string osl:cuda_version` : The version string of the Cuda version
/// OSL is using (empty string if no Cuda support was enabled at build
/// time).
///
/// - `string osl:optix_version` : The version string of the OptiX
/// version OSL is using (empty string if no OptiX support was enabled
/// at build time).
///
/// - `string osl:dependencies` : A comma-separated list of OSL's major
/// library build dependencies and their versions (for example,
/// "OIIO-2.3.0,LLVM-10.0.0,OpenEXR-2.5.0").
///
bool getattribute(string_view name, TypeDesc type, void* val);
// Shortcuts for common types
bool getattribute (string_view name, int &val) {
return getattribute (name, TypeDesc::INT, &val);
/// Shortcut getattribute() for retrieving a single integer.
/// The value is placed in `val`, and the function returns `true` if the
/// attribute was found and was legally convertible to an int.
bool getattribute(string_view name, int& val)
{
return getattribute(name, TypeDesc::INT, &val);
}
bool getattribute (string_view name, float &val) {
return getattribute (name, TypeDesc::FLOAT, &val);
/// Shortcut getattribute() for retrieving a single float.
/// The value is placed in `val`, and the function returns `true` if the
/// attribute was found and was legally convertible to a float.
bool getattribute(string_view name, float& val)
{
return getattribute(name, TypeDesc::FLOAT, &val);
}
bool getattribute (string_view name, double &val) {
bool getattribute(string_view name, double& val)
{
float f;
bool ok = getattribute (name, TypeDesc::FLOAT, &f);
bool ok = getattribute(name, TypeDesc::FLOAT, &f);
if (ok)
val = f;
return ok;
}
bool getattribute (string_view name, char **val) {
return getattribute (name, TypeDesc::STRING, val);
/// Shortcut getattribute() for retrieving a single string as a
/// `const char*`. The value is placed in `val`, and the function
/// returns `true` if the attribute was found.
bool getattribute(string_view name, char** val)
{
return getattribute(name, TypeDesc::STRING, val);
}
bool getattribute (string_view name, ustring &val) {
return getattribute (name, TypeDesc::STRING, (char **)&val);
/// Shortcut getattribute() for retrieving a single string as a
/// `ustring`. The value is placed in `val`, and the function returns
/// `true` if the attribute was found.
bool getattribute(string_view name, ustring& val)
{
return getattribute(name, TypeDesc::STRING, (char**)&val);
}
bool getattribute (string_view name, std::string &val) {
const char *s = NULL;
bool ok = getattribute (name, TypeDesc::STRING, &s);
/// Shortcut getattribute() for retrieving a single string as a
/// `std::string`. The value is placed in `val`, and the function
/// returns `true` if the attribute was found.
bool getattribute(string_view name, std::string& val)
{
const char* s = NULL;
bool ok = getattribute(name, TypeDesc::STRING, &s);
if (ok)
val = s;
return ok;
@@ -335,31 +446,37 @@ public:
/// Note: the attributes referred to as "string" are actually on the app
/// side as ustring or const char* (they have the same data layout), NOT
/// std::string!
bool getattribute (ShaderGroup *group, string_view name,
TypeDesc type, void *val);
bool getattribute(ShaderGroup* group, string_view name, TypeDesc type,
void* val);
// Shortcuts for common types
bool getattribute (ShaderGroup *group, string_view name, int &val) {
return getattribute (group, name, TypeDesc::INT, &val);
bool getattribute(ShaderGroup* group, string_view name, int& val)
{
return getattribute(group, name, TypeDesc::INT, &val);
}
bool getattribute (ShaderGroup *group, string_view name, float &val) {
return getattribute (group, name, TypeDesc::FLOAT, &val);
bool getattribute(ShaderGroup* group, string_view name, float& val)
{
return getattribute(group, name, TypeDesc::FLOAT, &val);
}
bool getattribute (ShaderGroup *group, string_view name, double &val) {
bool getattribute(ShaderGroup* group, string_view name, double& val)
{
float f;
bool ok = getattribute (group, name, TypeDesc::FLOAT, &f);
bool ok = getattribute(group, name, TypeDesc::FLOAT, &f);
if (ok)
val = f;
return ok;
}
bool getattribute (ShaderGroup *group, string_view name, char **val) {
return getattribute (group, name, TypeDesc::STRING, val);
bool getattribute(ShaderGroup* group, string_view name, char** val)
{
return getattribute(group, name, TypeDesc::STRING, val);
}
bool getattribute (ShaderGroup *group, string_view name, ustring &val) {
return getattribute (group, name, TypeDesc::STRING, (char **)&val);
bool getattribute(ShaderGroup* group, string_view name, ustring& val)
{
return getattribute(group, name, TypeDesc::STRING, (char**)&val);
}
bool getattribute (ShaderGroup *group, string_view name, std::string &val) {
const char *s = NULL;
bool ok = getattribute (group, name, TypeDesc::STRING, &s);
bool getattribute(ShaderGroup* group, string_view name, std::string& val)
{
const char* s = NULL;
bool ok = getattribute(group, name, TypeDesc::STRING, &s);
if (ok)
val = s;
return ok;
@@ -368,8 +485,7 @@ public:
/// Load compiled shader (oso) from a memory buffer, overriding
/// shader lookups in the shader search path
bool LoadMemoryCompiledShader (string_view shadername,
string_view buffer);
bool LoadMemoryCompiledShader(string_view shadername, string_view buffer);
// The basic sequence for declaring a shader group looks like this:
// ShadingSystem *ss = ...;
@@ -395,7 +511,7 @@ public:
/// Signal the start of a new shader group. The return value is a
/// reference-counted opaque handle to the ShaderGroup.
ShaderGroupRef ShaderGroupBegin (string_view groupname = string_view());
ShaderGroupRef ShaderGroupBegin(string_view groupname = string_view());
/// Alternate way to specify a shader group. The group specification
/// syntax looks like this: (as a string, all whitespace is equivalent):
@@ -405,13 +521,13 @@ public:
/// For the sake of easy assembling on command lines, a comma ',' may
/// substitute for the semicolon as a separator, and the last separator
/// before the end of the string is optional.
ShaderGroupRef ShaderGroupBegin (string_view groupname,
string_view shaderusage,
string_view groupspec = string_view());
ShaderGroupRef ShaderGroupBegin(string_view groupname,
string_view shaderusage,
string_view groupspec = string_view());
/// Signal the end of a new shader group.
///
bool ShaderGroupEnd (ShaderGroup& group);
bool ShaderGroupEnd(ShaderGroup& group);
/// Set a parameter of the next shader that will be added to the group,
/// optionally setting the 'lockgeom' metadata for that parameter
@@ -420,32 +536,37 @@ public:
/// against changes by the geometry, and therefore the shader should not
/// optimize assuming that the instance value (the 'val' specified by
/// this call) is a constant.
bool Parameter (ShaderGroup& group, string_view name, TypeDesc t,
const void *val, bool lockgeom=true);
bool Parameter(ShaderGroup& group, string_view name, TypeDesc t,
const void* val, bool lockgeom = true);
// Shortcuts for param passing a single int, float, or string.
bool Parameter (ShaderGroup& group, string_view name,
int val, bool lockgeom=true) {
return Parameter (group, name, TypeDesc::INT, &val, lockgeom);
bool Parameter(ShaderGroup& group, string_view name, int val,
bool lockgeom = true)
{
return Parameter(group, name, TypeDesc::INT, &val, lockgeom);
}
bool Parameter (ShaderGroup& group, string_view name,
float val, bool lockgeom=true) {
return Parameter (group, name, TypeDesc::FLOAT, &val, lockgeom);
bool Parameter(ShaderGroup& group, string_view name, float val,
bool lockgeom = true)
{
return Parameter(group, name, TypeDesc::FLOAT, &val, lockgeom);
}
bool Parameter (ShaderGroup& group, string_view name,
const std::string& val, bool lockgeom=true) {
const char *s = val.c_str();
return Parameter (group, name, TypeDesc::STRING, &s, lockgeom);
bool Parameter(ShaderGroup& group, string_view name, const std::string& val,
bool lockgeom = true)
{
const char* s = val.c_str();
return Parameter(group, name, TypeDesc::STRING, &s, lockgeom);
}
bool Parameter (ShaderGroup& group, string_view name,
ustring val, bool lockgeom=true) {
return Parameter (group, name, TypeDesc::STRING, (const char**)&val, lockgeom);
bool Parameter(ShaderGroup& group, string_view name, ustring val,
bool lockgeom = true)
{
return Parameter(group, name, TypeDesc::STRING, (const char**)&val,
lockgeom);
}
/// Append a new shader instance onto the specified group. The shader
/// instance will get any pending parameters that were set by
/// Parameter() calls since the last Shader() call for the group.
bool Shader (ShaderGroup& group, string_view shaderusage,
string_view shadername, string_view layername);
bool Shader(ShaderGroup& group, string_view shaderusage,
string_view shadername, string_view layername);
/// Connect two shaders within the specified group. The source layer
/// must be *upstream* of down destination layer (i.e. source must be
@@ -461,9 +582,9 @@ public:
/// `ConnectShaders (group, "lay1", "mycolorout[2]",
/// "lay2", "myfloatinput")`
///
bool ConnectShaders (ShaderGroup &group,
string_view srclayer, string_view srcparam,
string_view dstlayer, string_view dstparam);
bool ConnectShaders(ShaderGroup& group, string_view srclayer,
string_view srcparam, string_view dstlayer,
string_view dstparam);
/// Replace a parameter value in a previously-declared shader group.
/// This is meant to called after the ShaderGroupBegin/End, but will
@@ -472,27 +593,30 @@ public:
/// indicates that it's a parameter that may be overridden by the
/// geometric primitive). This call gives you a way of changing the
/// instance value, even if it's not a geometric override.
bool ReParameter (ShaderGroup &group,
string_view layername, string_view paramname,
TypeDesc type, const void *val);
bool ReParameter(ShaderGroup& group, string_view layername,
string_view paramname, TypeDesc type, const void* val);
// Shortcuts for param passing a single int, float, or string.
bool ReParameter (ShaderGroup &group, string_view layername,
string_view paramname, int val) {
return ReParameter (group, layername, paramname, TypeDesc::INT, &val);
bool ReParameter(ShaderGroup& group, string_view layername,
string_view paramname, int val)
{
return ReParameter(group, layername, paramname, TypeDesc::INT, &val);
}
bool ReParameter (ShaderGroup &group, string_view layername,
string_view paramname, float val) {
return ReParameter (group, layername, paramname, TypeDesc::FLOAT, &val);
bool ReParameter(ShaderGroup& group, string_view layername,
string_view paramname, float val)
{
return ReParameter(group, layername, paramname, TypeDesc::FLOAT, &val);
}
bool ReParameter (ShaderGroup &group, string_view layername,
string_view paramname, const std::string& val) {
const char *s = val.c_str();
return ReParameter (group, layername, paramname, TypeDesc::STRING, &s);
bool ReParameter(ShaderGroup& group, string_view layername,
string_view paramname, const std::string& val)
{
const char* s = val.c_str();
return ReParameter(group, layername, paramname, TypeDesc::STRING, &s);
}
bool ReParameter (ShaderGroup &group, string_view layername,
string_view paramname, ustring val) {
return ReParameter (group, layername, paramname, TypeDesc::STRING,
(const char**)&val);
bool ReParameter(ShaderGroup& group, string_view layername,
string_view paramname, ustring val)
{
return ReParameter(group, layername, paramname, TypeDesc::STRING,
(const char**)&val);
}
// Non-threadsafe versions of Parameter, Shader, ConnectShaders, and
@@ -503,13 +627,13 @@ public:
// concurrently). If there is any doubt about that, use the versions
// above that take an explicit `ShaderGroup&`, which are thread-safe
// and re-entrant.
bool Parameter (string_view name, TypeDesc t, const void *val,
bool lockgeom=true);
bool Shader (string_view shaderusage, string_view shadername,
string_view layername);
bool ConnectShaders (string_view srclayer, string_view srcparam,
string_view dstlayer, string_view dstparam);
bool ShaderGroupEnd (void);
bool Parameter(string_view name, TypeDesc t, const void* val,
bool lockgeom = true);
bool Shader(string_view shaderusage, string_view shadername,
string_view layername);
bool ConnectShaders(string_view srclayer, string_view srcparam,
string_view dstlayer, string_view dstparam);
bool ShaderGroupEnd(void);
/// Create a per-thread data needed for shader execution. It's very
/// important for the app to never use a PerThreadInfo from more than
@@ -517,11 +641,11 @@ public:
/// for each renderer thread), and destroy it with destroy_thread_info
/// when the thread terminates (and before the ShadingSystem is
/// destroyed).
PerThreadInfo * create_thread_info();
PerThreadInfo* create_thread_info();
/// Destroy a PerThreadInfo that was allocated by
/// create_thread_info().
void destroy_thread_info (PerThreadInfo *threadinfo);
void destroy_thread_info(PerThreadInfo* threadinfo);
/// Get a ShadingContext that we can use. The context is specific to a
/// renderer thread, and should never be passed between or shared by
@@ -529,25 +653,47 @@ public:
/// thread-specific pointer created by create_thread_info. The context
/// can be used to shade many points; a typical usage is to allocate
/// just one context per thread and use it for the whole run.
ShadingContext *get_context (PerThreadInfo *threadinfo,
TextureSystem::Perthread *texture_threadinfo=NULL);
ShadingContext*
get_context(PerThreadInfo* threadinfo,
TextureSystem::Perthread* texture_threadinfo = NULL);
/// Return a ShadingContext to the pool.
///
void release_context (ShadingContext *ctx);
void release_context(ShadingContext* ctx);
/// Execute the shader group in this context. If ctx is NULL, then
/// execute will request one (based on the running thread) on its own
/// and then return it when it's done. This is just a wrapper around
/// execute_init, execute_layer of the last (presumably group entry)
/// layer, and execute_cleanup. If run==false, just do the binding and
/// setup, don't actually run the shader.
bool execute (ShadingContext &ctx, ShaderGroup &group,
ShaderGlobals &globals, bool run=true);
/// Execute the shader group in this context on shading point
/// `shadeindex`. If ctx is nullptr, then execute will request one
/// (based on the running thread) on its own and then return it when
/// it's done. This is just a wrapper around execute_init,
/// execute_layer of the last (presumably group entry) layer, and
/// execute_cleanup. If run==false, just do the binding and setup, don't
/// actually run the shader.
bool execute(ShadingContext& ctx, ShaderGroup& group, int shadeindex,
ShaderGlobals& globals, void* userdata_base_ptr,
void* output_base_ptr, bool run = true);
/// Future execute signature that will be range based. Shader globals will be
/// obtained from renderer services.
#if 0 // TODO in future PR
bool execute(ShadingContext& ctx, ShaderGroup& group, OpaqueShadingStateUniformPtr ssu,
int shadeindex_begin_at, int shadeindex_end_before
void* userdata_base_ptr,
void* output_base_ptr, bool run = true);
#endif
// DEPRECATED(2.0): no shadeindex or base pointers
bool execute(ShadingContext& ctx, ShaderGroup& group,
ShaderGlobals& globals, bool run = true)
{
return execute(ctx, group, 0, globals, nullptr, nullptr, run);
}
// DEPRECATED(2.0): ctx pointer
bool execute (ShadingContext *ctx, ShaderGroup &group,
ShaderGlobals &globals, bool run=true);
bool execute(ShadingContext* ctx, ShaderGroup& group,
ShaderGlobals& globals, bool run = true)
{
return execute(*ctx, group, globals, run);
}
/// Bind a shader group and globals to the context, in preparation to
/// execute, including optimization and JIT of the group (if it has not
@@ -557,32 +703,59 @@ public:
/// preparation, but don't actually run the shader. Return true if the
/// shader executed, false if it did not (including if the shader itself
/// was empty).
bool execute_init (ShadingContext &ctx, ShaderGroup &group,
ShaderGlobals &globals, bool run=true);
bool execute_init(ShadingContext& ctx, ShaderGroup& group, int shadeindex,
ShaderGlobals& globals, void* userdata_base_ptr,
void* output_base_ptr, bool run = true);
// DEPRECATED(2.0): no shadeindex or base pointers
bool execute_init(ShadingContext& ctx, ShaderGroup& group,
ShaderGlobals& globals, bool run = true)
{
return execute_init(ctx, group, 0, globals, nullptr, nullptr, run);
}
/// Execute the layer whose index is specified, in this context. It is
/// presumed that execute_init() has already been called, with
/// Execute the layer whose layernumber is specified, in this context.
/// It is presumed that execute_init() has already been called, with
/// run==true, and that the call to execute_init() returned true. (One
/// reason why it might have returned false is if the shader group
/// turned out, after optimization, to do nothing.)
bool execute_layer (ShadingContext &ctx, ShaderGlobals &globals,
int layernumber);
bool execute_layer(ShadingContext& ctx, int shadeindex,
ShaderGlobals& globals, void* userdata_base_ptr,
void* output_base_ptr, int layernumber);
/// Execute the layer by name.
bool execute_layer (ShadingContext &ctx, ShaderGlobals &globals,
ustring layername);
bool execute_layer(ShadingContext& ctx, int shadeindex,
ShaderGlobals& globals, void* userdata_base_ptr,
void* output_base_ptr, ustring layername);
/// Execute the layer that has the given ShaderSymbol as an output.
/// (The symbol is one returned by find_symbol()).
bool execute_layer (ShadingContext &ctx, ShaderGlobals &globals,
const ShaderSymbol *symbol);
bool execute_layer(ShadingContext& ctx, int shadeindex,
ShaderGlobals& globals, void* userdata_base_ptr,
void* output_base_ptr, const ShaderSymbol* symbol);
// DEPRECATED(2.0): no shadeindex or base pointers
bool execute_layer(ShadingContext& ctx, ShaderGlobals& globals,
int layernumber)
{
return execute_layer(ctx, 0, globals, nullptr, nullptr, layernumber);
}
bool execute_layer(ShadingContext& ctx, ShaderGlobals& globals,
ustring layername)
{
return execute_layer(ctx, 0, globals, nullptr, nullptr, layername);
}
bool execute_layer(ShadingContext& ctx, ShaderGlobals& globals,
const ShaderSymbol* symbol)
{
return execute_layer(ctx, 0, globals, nullptr, nullptr, symbol);
}
/// Signify that the context is done with the current execution of the
/// group that was kicked off by execute_init and one or more calls to
/// execute_layer.
bool execute_cleanup (ShadingContext &ctx);
bool execute_cleanup(ShadingContext& ctx);
/// Find the named layer within a group and return its index, or -1
/// if no such named layer exists.
int find_layer (const ShaderGroup &group, ustring layername) const;
int find_layer(const ShaderGroup& group, ustring layername) const;
/// Get a raw pointer to a named symbol (such as you'd need to pull
/// out the value of an output parameter). ctx is the shading
@@ -599,10 +772,10 @@ public:
///
/// These are considered somewhat deprecated, in favor of using
/// find_symbol(), symbol_typedesc(), and symbol_address().
const void* get_symbol (const ShadingContext &ctx, ustring layername,
ustring symbolname, TypeDesc &type) const;
const void* get_symbol (const ShadingContext &ctx, ustring symbolname,
TypeDesc &type) const;
const void* get_symbol(const ShadingContext& ctx, ustring layername,
ustring symbolname, TypeDesc& type) const;
const void* get_symbol(const ShadingContext& ctx, ustring symbolname,
TypeDesc& type) const;
/// Search for an output symbol by name (and optionally, layer) within
/// the optimized shader group. If the symbol is found, return an opaque
@@ -616,84 +789,162 @@ public:
/// separately, or by concatenating "layername.symbolname", but note
/// that the latter will involve string manipulation inside find_symbol
/// and is much more expensive than specifying them separately.
const ShaderSymbol* find_symbol (const ShaderGroup &group,
ustring layername, ustring symbolname) const;
const ShaderSymbol* find_symbol (const ShaderGroup &group,
ustring symbolname) const;
const ShaderSymbol* find_symbol(const ShaderGroup& group, ustring layername,
ustring symbolname) const;
const ShaderSymbol* find_symbol(const ShaderGroup& group,
ustring symbolname) const;
/// Given an opaque ShaderSymbol*, return the TypeDesc describing it.
/// Note that a closure will end up with a TypeDesc::UNKNOWN value.
TypeDesc symbol_typedesc (const ShaderSymbol *sym) const;
TypeDesc symbol_typedesc(const ShaderSymbol* sym) const;
/// Given a context (that has executed a shader) and an opaque
/// ShaderSymbol*, return the actual memory address where the value of
/// the symbol resides within the heap memory of the context. This
/// is only valid for the shader execution that had happened immediately
/// prior for this context, but it is a very inexpensive operation.
const void* symbol_address (const ShadingContext &ctx,
const ShaderSymbol *sym) const;
const void* symbol_address(const ShadingContext& ctx,
const ShaderSymbol* sym) const;
#if OSL_USE_BATCHED
/// 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
/// 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
bool configure_batch_execution_at(int width);
template<int WidthT> class OSLEXECPUBLIC BatchedExecutor {
ShadingSystem& m_shading_system;
public:
explicit OSL_FORCEINLINE BatchedExecutor(ShadingSystem& ss)
: m_shading_system(ss)
{
}
OSL_FORCEINLINE BatchedExecutor(const BatchedExecutor&) = default;
/// Ensure that the group has been JITed.
void jit_group(ShaderGroup* group, ShadingContext* ctx);
/// If option "greedyjit" was set, this call will trigger all
/// shader groups that have not yet been compiled to do so with the
/// specified number of threads (0 means use all available HW cores).
void jit_all_groups(int nthreads = 0);
bool execute(ShadingContext& ctx, ShaderGroup& group, int batch_size,
Wide<const int, WidthT> wide_shadeindex,
BatchedShaderGlobals<WidthT>& globals_batch,
void* userdata_base_ptr, void* output_base_ptr,
bool run = true);
bool execute_init(ShadingContext& ctx, ShaderGroup& group,
int batch_size,
Wide<const int, WidthT> wide_shadeindex,
BatchedShaderGlobals<WidthT>& globals_batch,
void* userdata_base_ptr, void* output_base_ptr,
bool run = true);
bool execute_layer(ShadingContext& ctx, int batch_size,
Wide<const int, WidthT> wide_shadeindex,
BatchedShaderGlobals<WidthT>& globals_batch,
void* userdata_base_ptr, void* output_base_ptr,
int layernumber);
bool execute_layer(ShadingContext& ctx, int batch_size,
Wide<const int, WidthT> wide_shadeindex,
BatchedShaderGlobals<WidthT>& globals_batch,
void* userdata_base_ptr, void* output_base_ptr,
ustring layername);
bool execute_layer(ShadingContext& ctx, int batch_size,
Wide<const int, WidthT> wide_shadeindex,
BatchedShaderGlobals<WidthT>& globals_batch,
void* userdata_base_ptr, void* output_base_ptr,
const ShaderSymbol* symbol);
};
template<int WidthT> OSL_FORCEINLINE BatchedExecutor<WidthT> batched()
{
return BatchedExecutor<WidthT>(*this);
}
#endif
/// Return the statistics output as a huge string.
///
std::string getstats (int level=1) const;
std::string getstats(int level = 1) const;
void register_closure (string_view name, int id, const ClosureParam *params,
PrepareClosureFunc prepare, SetupClosureFunc setup);
void register_closure(string_view name, int id, const ClosureParam* params,
PrepareClosureFunc prepare, SetupClosureFunc setup);
/// Query either by name or id an existing closure. If name is non
/// NULL it will use it for the search, otherwise id would be used
/// and the name will be placed in name if successful. Also return
/// pointer to the params array in the last argument. All args are
/// optional but at least one of name or id must non NULL.
bool query_closure (const char **name, int *id,
const ClosureParam **params);
bool query_closure(const char** name, int* id, const ClosureParam** params);
/// For the proposed shader "global" name, return the corresponding
/// SGBits enum.
static SGBits globals_bit (ustring name);
static SGBits globals_bit(ustring name);
/// For the SGBits value, return the shader "globals" name.
static ustring globals_name (SGBits bit);
static ustring globals_name(SGBits bit);
/// For the proposed raytype name, return the bit pattern that
/// describes it, or 0 for an unrecognized name. (This retrieves
/// data passed in via attribute("raytypes")).
int raytype_bit (ustring name);
int raytype_bit(ustring name);
/// Configure the default raytypes to assume to be on (or off) at optimization
/// time for the given group. The raytypes_on gives a bitfield describing which
/// ray flags are known to be 1, and raytypes_off describes which ray flags are
/// known to be 0. Bits that are not set in either set of flags are not known
/// to the optimizer, and will be determined strictly at execution time.
void set_raytypes(ShaderGroup *group, int raytypes_on, int raytypes_off);
void set_raytypes(ShaderGroup* group, int raytypes_on, int raytypes_off);
/// Clear any known mappings of symbol locations.
void clear_symlocs();
void clear_symlocs(ShaderGroup* group);
/// Add symbol location mappings.
void add_symlocs(cspan<SymLocationDesc> symlocs);
void add_symlocs(ShaderGroup* group, cspan<SymLocationDesc> symlocs);
/// Ensure that the group has been optimized and optionally JITed. The ctx pointer
/// supplies a ShadingContext to use.
void optimize_group (ShaderGroup *group, ShadingContext *ctx, bool do_jit = true);
void optimize_group(ShaderGroup* group, ShadingContext* ctx,
bool do_jit = true);
/// Ensure that the group has been optimized and optionally JITed. This is a
/// convenience function that simply calls set_raytypes followed by
/// optimize_group. The ctx supplies a ShadingContext to use.
void optimize_group (ShaderGroup *group, int raytypes_on,
int raytypes_off, ShadingContext *ctx, bool do_jit = true);
void optimize_group(ShaderGroup* group, int raytypes_on, int raytypes_off,
ShadingContext* ctx, bool do_jit = true);
/// If option "greedyjit" was set, this call will trigger all
/// shader groups that have not yet been compiled to do so with the
/// specified number of threads (0 means use all available HW cores).
void optimize_all_groups (int nthreads=0, bool do_jit = true);
void optimize_all_groups(int nthreads = 0, bool do_jit = true);
/// Return a pointer to the TextureSystem being used.
TextureSystem * texturesys () const;
TextureSystem* texturesys() const;
/// Return a pointer to the RendererServices being used.
RendererServices * renderer () const;
RendererServices* renderer() const;
/// Archive the entire shader group so that it can be reconstituted
/// later.
bool archive_shadergroup (ShaderGroup &group, string_view filename);
bool archive_shadergroup(ShaderGroup& group, string_view filename);
// DEPRECATED(2.0)
bool archive_shadergroup (ShaderGroup *group, string_view filename);
bool archive_shadergroup(ShaderGroup* group, string_view filename);
/// Construct and return an OSLQuery initialized with an existing
/// ShaderGroup. For a shader group already loaded by the ShadingSystem,
/// this is much less expensive than constructing an OSLQuery by reading
/// the oso from disk, as would be done by liboslquery.
OSLQuery oslquery(const ShaderGroup& group, int layernum);
/// Helper function -- copy or convert a source value (described by
/// srctype) to destination (described by dsttype). The function
@@ -766,9 +1017,8 @@ bool
shade_image(ShadingSystem& shadingsys, ShaderGroup& group,
const ShaderGlobals* defaultsg, OIIO::ImageBuf& buf,
cspan<ustring> outputs,
ShadeImageLocations shadelocations = ShadePixelCenters,
OIIO::ROI roi = OIIO::ROI(),
OIIO::parallel_options popt = 0);
ShadeImageLocations shadelocations = ShadePixelCenters,
OIIO::ROI roi = OIIO::ROI(), OIIO::parallel_options popt = 0);
#endif
+75 -22
View File
@@ -9,6 +9,8 @@
#include <limits>
#include <type_traits>
#include <OSL/oslconfig.h>
#include <OpenImageIO/fmath.h>
#include <OpenImageIO/hash.h>
#include <OpenImageIO/simd.h>
@@ -100,7 +102,9 @@ struct NoiseParams;
namespace pvt {
using namespace OIIO::simd;
using namespace OIIO::bjhash;
#ifdef __OSL_WIDE_PVT
namespace sfm = OSL::__OSL_WIDE_PVT::sfm;
#endif
typedef void (*NoiseGenericFunc)(int outdim, float *out, bool derivs,
int indim, const float *in,
const float *period, NoiseParams *params);
@@ -137,6 +141,19 @@ inline OSL_HOSTDEVICE float bits_to_01 (unsigned int bits) {
}
OSL_FORCEINLINE OSL_HOSTDEVICE int
bitcast_to_uint (float x)
{
#if OPENIMAGEIO_VERSION >= 20500
return OIIO::bitcast<unsigned int, float>(x);
#else
// obsolete call
return OIIO::bit_cast<float, unsigned int>(x);
#endif
}
#ifndef __CUDA_ARCH__
// Perform a bjmix (see OpenImageIO/hash.h) on 4 sets of values at once.
OSL_FORCEINLINE void
@@ -227,7 +244,7 @@ reference_inthash (const unsigned int k[N]) {
OSL_FORCEINLINE OSL_HOSTDEVICE unsigned int
inthash (const unsigned int k0, const unsigned int k1) {
// now hash the data!
unsigned int start_val = 0xdeadbeef + (2 << 2) + 13;
unsigned int start_val = 0xdeadbeef + (2 << 2) + 13; //NOSONAR
unsigned int a = start_val + k0;
unsigned int b = start_val + k1;
@@ -463,7 +480,7 @@ struct HashNoise: public IntHashNoiseBase<HashNoise> {
static OSL_FORCEINLINE OSL_HOSTDEVICE unsigned int
transformToUint(float val)
{
return OIIO::bit_cast<float,unsigned int>(val);
return bitcast_to_uint(val);
}
};
@@ -540,7 +557,6 @@ using PeriodicHashNoise = PeriodicAdaptionOf<HashNoise>;
inline OSL_HOSTDEVICE int
inthashi (int x)
{
@@ -553,7 +569,7 @@ inline OSL_HOSTDEVICE int
inthashf (float x)
{
return static_cast<int>(
inthash(OIIO::bit_cast<float,unsigned int>(x))
inthash(bitcast_to_uint(x))
);
}
@@ -562,8 +578,8 @@ inthashf (float x, float y)
{
return static_cast<int>(
inthash(
OIIO::bit_cast<float,unsigned int>(x),
OIIO::bit_cast<float,unsigned int>(y)
bitcast_to_uint(x),
bitcast_to_uint(y)
)
);
}
@@ -574,9 +590,9 @@ inthashf (const float *x)
{
return static_cast<int>(
inthash(
OIIO::bit_cast<float,unsigned int>(x[0]),
OIIO::bit_cast<float,unsigned int>(x[1]),
OIIO::bit_cast<float,unsigned int>(x[2])
bitcast_to_uint(x[0]),
bitcast_to_uint(x[1]),
bitcast_to_uint(x[2])
)
);
}
@@ -587,10 +603,10 @@ inthashf (const float *x, float y)
{
return static_cast<int>(
inthash(
OIIO::bit_cast<float,unsigned int>(x[0]),
OIIO::bit_cast<float,unsigned int>(x[1]),
OIIO::bit_cast<float,unsigned int>(x[2]),
OIIO::bit_cast<float,unsigned int>(y)
bitcast_to_uint(x[0]),
bitcast_to_uint(x[1]),
bitcast_to_uint(x[2]),
bitcast_to_uint(y)
)
);
}
@@ -636,7 +652,7 @@ OSL_FORCEINLINE OSL_HOSTDEVICE Dual2<float> select(const bool b, const Dual2<flo
// versus requiring a stack location.
// Without this work per component, gathers & scatters were being emitted
// when used inside SIMD loops.
#if OSL_NON_INTEL_CLANG
#if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION && !OSL_INTEL_LLVM_COMPILER_VERSION
// Clang's vectorizor was really insistent that a select operation could not be replaced
// with control flow, so had to re-introduce the ? operator to make it happy
return Dual2<float> (
@@ -1150,16 +1166,16 @@ private:
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic () {}
public:
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1; //NOSONAR
}
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px, float py) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1; //NOSONAR
}
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px, float py, float pz) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1;
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1; //NOSONAR
}
OSL_FORCEINLINE OSL_HOSTDEVICE HashScalarPeriodic (float px, float py, float pz, float pw) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
@@ -1221,16 +1237,16 @@ public:
struct HashVectorPeriodic {
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1; //NOSONAR
}
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px, float py) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1; //NOSONAR
}
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px, float py, float pz) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
m_py = OIIO::ifloor(py); if (m_py < 1) m_py = 1;
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1;
m_pz = OIIO::ifloor(pz); if (m_pz < 1) m_pz = 1; //NOSONAR
}
OSL_FORCEINLINE OSL_HOSTDEVICE HashVectorPeriodic (float px, float py, float pz, float pw) {
m_px = OIIO::ifloor(px); if (m_px < 1) m_px = 1;
@@ -1877,7 +1893,7 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Vec3 &result, const H &hash,
u, v, w);
result = scale3 (result);
#else
static_assert(std::is_same<Vec3i, decltype(hash(X, Y, Z))>::value, "This re-implementation was developed for Hashs returning a vector type only");
static_assert(std::is_same<Vec3i, decltype(hash(X, Y, Z))>::value, "This re-implementation was developed for hashes returning a vector type only");
// Want to avoid repeating the same hash work 3 times in a row
// so rather than executing the vector version, we will use HashScalar
// and directly mask its results on a per component basis
@@ -2241,6 +2257,9 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Dual2<Vec3> &result, const H &hash,
Dual2<float> t = fade(fz);
Dual2<float> s = fade(fw);
// With Dual2<Vec3> data types, a lot of code is generated below
// which caused some runaway compiler memory consumption when vectorizing
#if !OSL_INTEL_CLASSIC_COMPILER_VERSION
auto l_result = OIIO::lerp (
OIIO::trilerp (grad (hash (X , Y , Z , W ), fx , fy , fz , fw ),
grad (hash (X+1, Y , Z , W ), fx-1.0f, fy , fz , fw ),
@@ -2261,6 +2280,40 @@ OSL_FORCEINLINE OSL_HOSTDEVICE void perlin (Dual2<Vec3> &result, const H &hash,
grad (hash (X+1, Y+1, Z+1, W+1), fx-1.0f, fy-1.0f, fz-1.0f, fw-1.0f),
u, v, t),
s);
#else
// Use a loop to avoid repeating code gen twice
Dual2<Vec3> v0, v1;
// GCC emits -Wmaybe-uninitialized errors for v0,v1.
// To avoid, GCC uses reference version above
// Clang doesn't want to vectorize with the vIndex loop
// To enable vectorization, Clang uses reference version above
OSL_INTEL_PRAGMA(nounroll_and_jam)
for(int vIndex=0; vIndex < 2;++vIndex) {
int vW = W + vIndex;
Dual2<float> vfw = fw - float(vIndex);
Dual2<Vec3> vResult = OIIO::trilerp (
grad (hash (X , Y , Z , vW ), fx , fy , fz , vfw ),
grad (hash (X+1, Y , Z , vW ), fx-1.0f, fy , fz , vfw ),
grad (hash (X , Y+1, Z , vW ), fx , fy-1.0f, fz , vfw ),
grad (hash (X+1, Y+1, Z , vW ), fx-1.0f, fy-1.0f, fz , vfw ),
grad (hash (X , Y , Z+1, vW ), fx , fy , fz-1.0f, vfw ),
grad (hash (X+1, Y , Z+1, vW ), fx-1.0f, fy , fz-1.0f, vfw ),
grad (hash (X , Y+1, Z+1, vW ), fx , fy-1.0f, fz-1.0f, vfw ),
grad (hash (X+1, Y+1, Z+1, vW ), fx-1.0f, fy-1.0f, fz-1.0f, vfw ),
u, v, t);
// Rather than dynamic indexing array,
// use masking to store outputs,
// to better enable SROA (Scalar Replacement of Aggregates) optimizations
if (vIndex == 0) {
v0 = vResult;
} else {
v1 = vResult;
}
}
auto l_result = OIIO::lerp (v0, v1, s);
#endif
result = scale4 (l_result);
}
+23 -5
View File
@@ -61,7 +61,7 @@ class OSOReaderQuery; // Just so OSLQuery can friend OSLReaderQuery
/// ~~~
///
/// And the `Parameter` structure will hold all the information you need
/// about that paramter. For example:
/// about that parameter. For example:
///
/// ~~~
/// std::cout << "Parameter " << p->name
@@ -123,13 +123,18 @@ public:
}
///< Construct an OSLQuery and open a compiled shader from a disk file.
/// The `shadername` may be either the name of the `.oso` file, or the
/// name of the shader. The optional `searchpath` paramter gives a
/// name of the shader. The optional `searchpath` parameter gives a
/// colon-separated list of directories to search for compiled shaders.
OSLQuery(const ShaderGroup* group, int layernum) { init(group, layernum); }
OSL_DEPRECATED("Use ShadingSystem::oslquery(group,layernum)")
OSLQuery(const ShaderGroup* group, int layernum);
///< Construct an OSLQuery and initialize it with an existing
/// `ShaderGroup` (which must have been built using the `ShadingSystem`
/// runtime API for OSL.
/// runtime API for OSL). This constructor only exists in liboslexec,
/// with a full shading system, and not in liboslquery.
/// This is deprecated, and instead we recommend retrieving an OSLQuery
/// via `ShadingSystem::oslquery(group, layernum)`.
// DEPRECATED(1.12)
~OSLQuery();
///< Clean up and destruct the `OSLQuery`.
@@ -153,6 +158,9 @@ public:
/// fill out an OSLQuery structure for the given layer of the group.
/// This is much faster than using open() to read it from an oso file on
/// disk.
/// This is deprecated, and instead we recommend retrieving an OSLQuery
/// via `ShadingSystem::oslquery(group, layernum)`.
// DEPRECATED(1.12)
const ustring shadertype(void) const { return m_shadertypename; }
///< Return the shader type: "surface", "displacement", "volume",
@@ -206,8 +214,16 @@ private:
std::vector<Parameter> m_meta; //< Meta-data about the shader
friend class pvt::OSOReaderQuery;
// Internal error reporting routine, with printf-like arguments.
// Internal error reporting routine, with std::format-like arguments.
template<typename Str, typename... Args>
inline void errorfmt(const Str& fmt, Args&&... args) const
{
append_error(
OIIO::Strutil::fmt::format(fmt, std::forward<Args>(args)...));
}
// DEPRECATED(1.12): old style printf-like arguments.
template<typename... Args>
OSL_DEPRECATED("Use errfmt instead, with std::format args")
inline void errorf(const char* fmt, const Args&... args) const
{
append_error(OIIO::Strutil::sprintf(fmt, args...));
@@ -219,6 +235,8 @@ private:
m_error += '\n';
m_error += message;
}
friend class ShadingSystem;
};
+23 -3
View File
@@ -36,13 +36,14 @@
100 * OSL_VERSION_MINOR + \
OSL_VERSION_PATCH)
// Magic macros to make OSL_LIBRARY_VERSION_STRING that looks like "1.2.3"
#define OSL_MAKE_VERSION_STRING2(a,b,c,d) #a "." #b "." #c #d
#define OSL_MAKE_VERSION_STRING(a,b,c,d) OSL_MAKE_VERSION_STRING2(a,b,c,d)
// Magic macros to make OSL_LIBRARY_VERSION_STRING that looks like "1.2.3.0"
#define OSL_MAKE_VERSION_STRING2(a,b,c,d,e) #a "." #b "." #c "." #d #e
#define OSL_MAKE_VERSION_STRING(a,b,c,d,e) OSL_MAKE_VERSION_STRING2(a,b,c,d,e)
#define OSL_LIBRARY_VERSION_STRING \
OSL_MAKE_VERSION_STRING(OSL_LIBRARY_VERSION_MAJOR, \
OSL_LIBRARY_VERSION_MINOR, \
OSL_LIBRARY_VERSION_PATCH, \
OSL_LIBRARY_VERSION_TWEAK, \
OSL_LIBRARY_VERSION_RELEASE_TYPE)
#define OSL_INTRO_STRING "Open Shading Language " OSL_LIBRARY_VERSION_STRING
#define OSL_COPYRIGHT_STRING "Copyright Contributors to the Open Shading Language project."
@@ -86,4 +87,23 @@ namespace @PROJ_NAME@ = @PROJ_NAMESPACE_V@;
#define OSL_SHADER_INSTALL_DIR "@OSL_SHADER_INSTALL_DIR@"
// Macro helpers to build function names based on other macros
#define __OSL_CONCAT_INDIRECT(A, B) A ## B
#define __OSL_CONCAT(A, B) __OSL_CONCAT_INDIRECT(A,B)
#define __OSL_CONCAT3(A, B, C) __OSL_CONCAT(__OSL_CONCAT(A,B),C)
#define __OSL_CONCAT4(A, B, C, D) __OSL_CONCAT(__OSL_CONCAT3(A,B,C),D)
#define __OSL_CONCAT5(A, B, C, D, E) __OSL_CONCAT(__OSL_CONCAT4(A,B,C,D),E)
#define __OSL_CONCAT6(A, B, C, D, E, F) __OSL_CONCAT(__OSL_CONCAT5(A,B,C,D,E),F)
#define __OSL_CONCAT7(A, B, C, D, E, F, G) __OSL_CONCAT(__OSL_CONCAT6(A,B,C,D,E,F),G)
#define __OSL_CONCAT8(A, B, C, D, E, F, G, H) __OSL_CONCAT(__OSL_CONCAT7(A,B,C,D,E,F,G),H)
#define __OSL_CONCAT9(A, B, C, D, E, F, G, H, I) __OSL_CONCAT(__OSL_CONCAT8(A,B,C,D,E,F,G,H),I)
#define __OSL_CONCAT10(A, B, C, D, E, F, G, H, I, J) __OSL_CONCAT(__OSL_CONCAT9(A,B,C,D,E,F,G,H,I),J)
#if defined(__OSL_TARGET_ISA) && defined(__OSL_WIDTH)
#define __OSL_WIDE_PVT __OSL_CONCAT5(b,__OSL_WIDTH,_,__OSL_TARGET_ISA,_pvt)
#endif
#define __OSL_INDIRECT_STRINGIFY(x) #x
#define __OSL_STRINGIFY(x) __OSL_INDIRECT_STRINGIFY(x)
#endif /* OSLVERSION_H */
+90 -37
View File
@@ -26,6 +26,19 @@
/////////////////////////////////////////////////////////////////////////
// Detect which compiler and version we're using
// Notes:
// __GNUC__ is defined for gcc and all clang varieties
// __clang__ is defined for all clang varieties (generic, Apple, and Intel)
// __apple_build_version__ is only defined for Apple clang
// __INTEL_COMPILER is defined only for icc
// __INTEL_LLVM_COMPILER is defined only for icx
// _MSC_VER is defined for MSVS compiler (not gcc/clang/icc even on Windows)
// _WIN32 is defined on Windows regardless of compiler
// __CUDACC__ is defined any time we are compiling a module for Cuda
// (both for the host pass and the device pass). "Do this
// when using nvcc or clang with ptx target."
// __CUDA_ARCH__ is only defined when doing the device pass. "Do this only
// for code that will actually run on the GPU."
// Define OSL_GNUC_VERSION to hold an encoded gcc version (e.g. 40802 for
// 4.8.2), or 0 if not a GCC release. N.B.: This will be 0 for clang.
@@ -39,7 +52,7 @@
// 30402 for clang 3.4.2), or 0 if not a generic Clang release.
// N.B. This will be 0 for the clang Apple distributes (which has different
// version numbers entirely).
#if defined(__clang__) && !defined(__apple_build_version__)
#if defined(__clang__) && !defined(__apple_build_version__) && !defined(__INTEL_LLVM_COMPILER)
# define OSL_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__)
#else
# define OSL_CLANG_VERSION 0
@@ -48,39 +61,59 @@
// Define OSL_APPLE_CLANG_VERSION to hold an encoded Apple Clang version
// (e.g. 70002 for clang 7.0.2), or 0 if not an Apple Clang release.
#if defined(__clang__) && defined(__apple_build_version__)
# if defined(__INTEL_LLVM_COMPILER)
# error Not expected for __INTEL_LLVM_COMPILER to be defined with an __apple_build_version__
# endif
# define OSL_APPLE_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__)
#else
# define OSL_APPLE_CLANG_VERSION 0
#endif
// The classic Intel(r) C++ Compiler on OSX may still define __clang__
// combine with testing OSL_INTEL_CLASSIC_COMPILER_VERSION to further differentiate if needed.
// Define OSL_INTEL_COMPILER to hold an encoded Intel compiler version
// (e.g. 1900), or 0 if not an Intel compiler.
// Define OSL_INTEL_CLASSIC_COMPILER_VERSION to hold an encoded Intel(r) C++ Compiler version
// (e.g. 1900), or 0 if not an Intel(r) C++ Compiler.
#if defined(__INTEL_COMPILER)
# define OSL_INTEL_COMPILER __INTEL_COMPILER
# define OSL_INTEL_CLASSIC_COMPILER_VERSION __INTEL_COMPILER
#else
# define OSL_INTEL_COMPILER 0
# define OSL_INTEL_CLASSIC_COMPILER_VERSION 0
#endif
// Intel's compiler on OSX may still define __clang__
// and we have need to know when using a true clang compiler
#if !defined(__INTEL_COMPILER) && defined(__clang__)
#define OSL_NON_INTEL_CLANG __clang__
// Define OSL_INTEL_LLVM_COMPILER_VERSION 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.
#if defined(__INTEL_LLVM_COMPILER)
# define OSL_INTEL_LLVM_COMPILER_VERSION __INTEL_LLVM_COMPILER
# define OSL_INTEL_CLANG_VERSION (10000*__clang_major__ + 100*__clang_minor__ + __clang_patchlevel__)
#else
#define OSL_NON_INTEL_CLANG 0
# define OSL_INTEL_LLVM_COMPILER_VERSION 0
# define OSL_INTEL_CLANG_VERSION 0
#endif
// Define OSL_ANY_CLANG to 0 or 1 to indicate if any Clang based compiler is in use
#if defined(__clang__)
# define OSL_ANY_CLANG 1
#else
# define OSL_ANY_CLANG 0
#endif
// Tests for MSVS versions, always 0 if not MSVS at all.
#if defined(_MSC_VER)
# if _MSC_VER < 1900
# error "This version of OSL is meant to work only with Visual Studio 2015 or later"
# endif
# define OSL_MSVS_VERSION _MSC_VER
# define OSL_MSVS_AT_LEAST_2013 (_MSC_VER >= 1800)
# define OSL_MSVS_BEFORE_2013 (_MSC_VER < 1800)
# define OSL_MSVS_AT_LEAST_2015 (_MSC_VER >= 1900)
# define OSL_MSVS_BEFORE_2015 (_MSC_VER < 1900)
# define OSL_MSVS_AT_LEAST_2017 (_MSC_VER >= 1910)
# define OSL_MSVS_BEFORE_2017 (_MSC_VER < 1910)
# if OSL_MSVS_BEFORE_2017
# error "This version of OSL is meant to work only with Visual Studio 2017 or later"
# endif
#else
# define OSL_MSVS_VERSION 0
# define OSL_MSVS_AT_LEAST_2013 0
# define OSL_MSVS_BEFORE_2013 0
# define OSL_MSVS_AT_LEAST_2015 0
@@ -90,50 +123,39 @@
#endif
// Note about __CUDACC__ versus __CUDA_ARCH__:
//
// __CUDACC__ defined any time we are compiling a module for Cuda
// (both for the host pass and the device pass). "Do this
// when using nvcc or clang with ptx target."
// __CUDA_ARCH__ is only defined when doing the device pass. "Do this only
// for code that will actually run on the GPU."
/////////////////////////////////////////////////////////////////////////
// Detect which C++ standard we're using, and handy macros.
// See https://en.cppreference.com/w/cpp/compiler_support
//
// Note: oslversion.h defines OSL_BUILD_CPP11 to be 1 if OSL was built
// using C++11. In contrast, OSL_CPLUSPLUS_VERSION defined below will be set
// to the right number for the C++ standard being compiled RIGHT NOW. These
// two things may be the same when compiling OSL, but they may not be the
// same if another package is compiling against OSL and using these headers
// (OSL may be C++11 but the client package may be newer, or vice versa --
// use these two symbols to differentiate these cases, when important).
// Note: oslversion.h defines OSL_BUILD_CPP to be 14, 17, etc., to reflect
// the version that OSL itself was built with. In contrast,
// OSL_CPLUSPLUS_VERSION defined below will be set to the right number for
// the C++ standard being compiled RIGHT NOW by whomever is parsing these
// header files. These two things may be the same when compiling OSL, but
// they may not be the same if another package is compiling against OSL and
// using these headers (e.g., OSL may be C++14 but the client package may be
// newer, or vice versa -- use these two symbols to differentiate these
// cases, when important).
#if (__cplusplus >= 202001L)
# define OSL_CPLUSPLUS_VERSION 20
# define OSL_CONSTEXPR14 constexpr
# define OSL_CONSTEXPR17 constexpr
# define OSL_CONSTEXPR20 constexpr
#elif (__cplusplus >= 201703L)
# define OSL_CPLUSPLUS_VERSION 17
# define OSL_CONSTEXPR14 constexpr
# define OSL_CONSTEXPR17 constexpr
# define OSL_CONSTEXPR20 /* not constexpr before C++20 */
#elif (__cplusplus >= 201402L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
# define OSL_CPLUSPLUS_VERSION 14
# define OSL_CONSTEXPR14 constexpr
# define OSL_CONSTEXPR17 /* not constexpr before C++17 */
# define OSL_CONSTEXPR20 /* not constexpr before C++20 */
#elif (__cplusplus >= 201103L) || _MSC_VER >= 1900
# define OSL_CPLUSPLUS_VERSION 11
# define OSL_CONSTEXPR14 /* not constexpr before C++14 */
# define OSL_CONSTEXPR17 /* not constexpr before C++17 */
# define OSL_CONSTEXPR20 /* not constexpr before C++20 */
#else
# error "This version of OSL requires C++11"
# error "This version of OSL requires C++14 or above"
#endif
// DEPRECATED(1.12): use C++14 constexpr
#define OSL_CONSTEXPR14 constexpr
// In C++20 (and some compilers before that), __has_cpp_attribute can
@@ -211,6 +233,11 @@
#define OSL_CLANG_ATTRIBUTE(value)
#endif
#if OSL_GNUC_VERSION
#define OSL_GNUC_ATTRIBUTE(value) __attribute__((value))
#else
#define OSL_GNUC_ATTRIBUTE(value)
#endif
#ifndef OSL_DEBUG
@@ -237,6 +264,16 @@
#define OSL_OMP_PRAGMA(aUnQuotedPragma)
#endif
#define OSL_OMP_SIMD_LOOP(...) OSL_OMP_PRAGMA(omp simd __VA_ARGS__)
#if (OSL_GCCVERSION || OSL_INTEL_CLASSIC_COMPILER_VERSION || OSL_INTEL_LLVM_COMPILER_VERSION)
# define OSL_OMP_COMPLEX_SIMD_LOOP(...) OSL_OMP_SIMD_LOOP(__VA_ARGS__)
#else
// Ignore requests to vectorize complex/nested SIMD loops for certain
// compilers/versions that are not currently vectorizing complex loops.
# define OSL_OMP_COMPLEX_SIMD_LOOP(...)
#endif
// OSL_FORCEINLINE is a function attribute that attempts to make the
// function always inline. On many compilers regular 'inline' is only
// advisory. Put this attribute before the function return type, just like
@@ -446,6 +483,20 @@
#endif
/// OSL_ALLOCA is used to allocate smallish amount of memory on the stack,
/// equivalent of C99 type var_name[size].
///
/// NOTE: in a debug build, this will assert for allocations >= 1MB, which is
/// much too big. Hopefully this will keep us from abusing alloca and having
/// stack overflows. The rule of thumb is that it's ok to use alloca for small
/// things of bounded size, but not for anything that could be arbitrarily
/// big, which should instead use heap allocation.
#if defined(__GNUC__)
# define OSL_ALLOCA(type, size) (assert(size < (1<<20)), (size) != 0 ? (reinterpret_cast<type*>(__builtin_alloca((size) * sizeof(type)))) : nullptr)
#else
# define OSL_ALLOCA(type, size) (assert(size < (1<<20)), (size) != 0 ? (reinterpret_cast<type*>(alloca((size) * sizeof(type)))) : nullptr)
#endif
OSL_NAMESPACE_ENTER
#if OSL_CPLUSPLUS_VERSION >= 20
@@ -480,4 +531,6 @@ DataT* assume_aligned(DataT* ptr)
#endif
static constexpr int MaxSupportedSimdLaneCount = 16;
OSL_NAMESPACE_EXIT
+36 -11
View File
@@ -9,15 +9,18 @@
#include <OSL/oslconfig.h>
#include <OpenImageIO/ustring.h>
OSL_NAMESPACE_ENTER
class RendererServices;
template<int WidthT>
class BatchedRendererServices;
class ShadingContext;
struct ShaderGlobals;
// Tags for polymorphic dispatch
template <int SimdWidthT>
class WidthOf {};
/// Opaque pointer to whatever the renderer uses to represent a
@@ -39,6 +42,7 @@ OSL_GCC_PRAGMA(GCC diagnostic ignored "-Wunused-parameter")
/// RendererServices defines an abstract interface through which a
/// renderer may provide callback to the ShadingSystem.
class OSLEXECPUBLIC RendererServices {
// Keep interface in sync with rs_free_function.h
public:
typedef TextureSystem::TextureHandle TextureHandle;
typedef TextureSystem::Perthread TexturePerthread;
@@ -190,6 +194,10 @@ public:
/// read or sampled.
virtual bool good (TextureHandle *texture_handle);
/// Return true if the texture handle (previously returned by
/// get_texture_handle()) is udim
virtual bool is_udim (TextureHandle *texture_handle);
/// Filtered 2D texture lookup for a single point.
///
/// s,t are the texture coordinates; dsdx, dtdx, dsdy, and dtdy are
@@ -316,6 +324,16 @@ public:
void *data,
ustring *errormessage);
virtual bool get_texture_info (ustring filename,
TextureHandle *texture_handle,
float s, float t,
TexturePerthread *texture_thread_info,
ShadingContext *shading_context,
int subimage,
ustring dataname, TypeDesc datatype,
void *data,
ustring *errormessage);
/// Lookup nearest points in a point cloud. It will search for
/// points around the given center within the specified radius. A
@@ -356,6 +374,15 @@ public:
bool shade; ///< whether to shade what is hit
ustring traceset; ///< named trace set
TraceOpt () : mindist(0.0f), maxdist(1.0e30), shade(false) { }
enum class LLVMMemberIndex
{
mindist = 0,
maxdist,
shade,
traceset,
count
};
};
/// Immediately trace a ray from P in the direction R. Return true
@@ -378,15 +405,6 @@ public:
/// Return a pointer to the texture system (if available).
virtual TextureSystem *texturesys () const;
/// Register a string with the renderer, so that the renderer can arrange
/// to make the string available in GPU memory as needed. Optionally specify
/// a variable name to associate with the string value.
virtual uint64_t register_string (const std::string& str,
const std::string& var_name)
{
return 0;
}
virtual uint64_t register_global (const std::string& var_name,
uint64_t value)
{
@@ -412,6 +430,13 @@ public:
direction(1.0f,0.0f,0.0f), bandwidth(1.0f), impulses(16.0f) { }
};
/// A renderer may choose to support batched execution by providing pointers
/// to objects satisfying the BatchedRendererServices<WidthOf<#>> interface
/// for specific batch sizes.
/// Unless overridden, a nullptr is returned.
virtual BatchedRendererServices<16> * batched(WidthOf<16>);
virtual BatchedRendererServices<8> * batched(WidthOf<8>);
protected:
TextureSystem *m_texturesys; // A place to hold a TextureSystem
};
+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
#include <OSL/oslconfig.h>
// Make all the strings defined in OSL
// available to the renderer services free functions
OSL_NAMESPACE_ENTER
namespace Strings {
#define STRDECL(str, var_name) OSLEXECPUBLIC extern const ustring var_name;
#include <OSL/strdecls.h>
#undef STRDECL
}; // namespace Strings
OSL_NAMESPACE_EXIT
#ifdef OSL_HOST_RS_BITCODE
extern "C" {
# define STRDECL(str, var_name) \
const OSL::ustring& RS_##var_name = OSL::Strings::var_name;
# include <OSL/strdecls.h>
# undef STRDECL
}
#endif
#include <OSL/device_string.h>
#include <OSL/shaderglobals.h>
// Prefix for OSL shade op declarations.
// "C" linkage (no C++ name mangling) and local visibility
#define OSL_RSOP extern "C"
// We are choosing to use unique names encoding parameters directly
// as opposed to using overloaded functions.
// Keep free functions in sync with virtual function based RendererServices.
/// Get the 4x4 matrix that transforms by the specified
/// transformation at the given time. Return true if ok, false
/// on error.
OSL_RSOP bool
rs_get_matrix_xform_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::TransformationPtr from, float time);
/// Get the 4x4 matrix that transforms by the specified
/// transformation at the given time. Return true if ok, false on
/// error. Suggested implementation is to use rs_get_matrix_xform_time and
/// invert it, but a particular renderer may have a better technique.
OSL_RSOP bool
rs_get_inverse_matrix_xform_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::TransformationPtr xform, float time);
/// Get the 4x4 matrix that transforms points from the named
/// 'from' coordinate system to "common" space at the given time.
/// Returns true if ok, false if the named matrix is not known.
OSL_RSOP bool
rs_get_matrix_space_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::StringParam from, float time);
/// Get the 4x4 matrix that transforms points from "common" space to
/// the named 'to' coordinate system to at the given time. Suggested
/// implementation is to use rs_get_matrix_space_time and invert it, but a
/// particular renderer may have a better technique.
OSL_RSOP bool
rs_get_inverse_matrix_space_time(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::StringParam to, float time);
/// Get the 4x4 matrix that transforms by the specified
/// transformation. Return true if ok, false on error. Since no
/// time value is given, also return false if the transformation may
/// be time-varying.
OSL_RSOP bool
rs_get_matrix_xform(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::TransformationPtr xform);
/// Get the 4x4 matrix that transforms by the specified
/// transformation. Return true if ok, false on error. Since no
/// time value is given, also return false if the transformation may
/// be time-varying. Suggested implementation is to use
/// rs_get_matrix_xform and invert it, but a particular renderer may have a
/// better technique.
OSL_RSOP bool
rs_get_inverse_matrix_xform(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::TransformationPtr xform);
/// Get the 4x4 matrix that transforms 'from' to "common" space.
/// Since there is no time value passed, return false if the
/// transformation may be time-varying (as well as if it's not found
/// at all).
OSL_RSOP bool
rs_get_matrix_space(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::StringParam from);
/// Get the 4x4 matrix that transforms points from "common" space to
/// the named 'to' coordinate system. Since there is no time value
/// passed, return false if the transformation may be time-varying
/// (as well as if it's not found at all). Suggested
/// implementation is to use rs_get_matrix_space and invert it, but a
/// particular renderer may have a better technique.
OSL_RSOP bool
rs_get_inverse_matrix_space(OSL::ShaderGlobals* sg, OSL::Matrix44& result,
OSL::StringParam to);
/// Transform points Pin[0..npoints-1] in named coordinate system
/// 'from' into 'to' coordinates, storing the result in Pout[] using
/// the specified vector semantic (POINT, VECTOR, NORMAL). The
/// function returns true if the renderer correctly transformed the
/// points, false if it failed (for example, because it did not know
/// the name of one of the coordinate systems). Suggested implementation
/// is simply to make appropriate calls to rs_get_matrix_space and
/// get_inverse_matrix_space. The existence of this function is to allow
/// some renderers to provide transformations that cannot be
/// expressed by a 4x4 matrix.
///
/// Note, the virtual function based RendererServices::transform_points
/// provides additional functionality/modes that are only used during
/// code generation to detect if it required to even call rs_transform_points
/// during evaluation of the shader. There is no need for the free
/// function version to handle these additional modes.
///
/// Note to implementations: just return 'false'
/// if there isn't a special nonlinear transformation between the
/// two spaces.
OSL_RSOP bool
rs_transform_points(OSL::ShaderGlobals* sg, OSL::StringParam from,
OSL::StringParam to, float time, const OSL::Vec3* Pin,
OSL::Vec3* Pout, int npoints,
OSL::TypeDesc::VECSEMANTICS vectype);
+159 -131
View File
@@ -86,14 +86,14 @@ namespace fast_grad2 {
Vec2( -1.0f, -1.0f ), Vec2( 1.0f, 0.0f ), Vec2( -1.0f, 0.0f ), Vec2( 1.0f, 1.0f ),
Vec2( -1.0f, 1.0f ), Vec2( 0.0f, -1.0f ), Vec2( 0.0f, 1.0f ), Vec2( 1.0f, -1.0f ));
//static constexpr uint8_t x_one_mask = 0b10001010;
static constexpr uint8_t x_one_mask = 0x8A;
//static constexpr uint8_t x_one_mask = 0b10001010;
static constexpr uint8_t x_one_mask = 0x8A;
//static constexpr uint8_t x_neg_one_mask = 0b00010101;
static constexpr uint8_t x_neg_one_mask = 0x15;
//static constexpr uint8_t y_one_mask = 0b01011000;
static constexpr uint8_t y_one_mask = 0x58;
static constexpr uint8_t x_neg_one_mask = 0x15;
//static constexpr uint8_t y_one_mask = 0b01011000;
static constexpr uint8_t y_one_mask = 0x58;
//static constexpr uint8_t y_neg_one_mask = 0b10100001;
static constexpr uint8_t y_neg_one_mask = 0xA1;
static constexpr uint8_t y_neg_one_mask = 0xA1;
#ifdef __OSL_EMIT_GRAD_MASKS
class OSLEXECPUBLIC mask_emitter {
@@ -193,22 +193,23 @@ namespace fast_grad4 {
Vec4( -1.0f, 1.0f, 1.0f, 0.0f ), Vec4( -1.0f, 1.0f, -1.0f, 0.0f ), Vec4( -1.0f, -1.0f, 1.0f, 0.0f ), Vec4( -1.0f, -1.0f, -1.0f, 0.0f ));
//static constexpr uint32_t x_one_mask = 0b00001111000011110000111100000000;
static constexpr uint32_t x_one_mask = 0x0F0F0F00;
//static constexpr uint32_t x_one_mask = 0b00001111000011110000111100000000;
static constexpr uint32_t x_one_mask = 0x0F0F0F00;
//static constexpr uint32_t x_neg_one_mask = 0b11110000111100001111000000000000;
static constexpr uint32_t x_neg_one_mask = 0xF0F0F000;
//static constexpr uint32_t y_one_mask = 0b00110011001100110000000000001111;
static constexpr uint32_t y_one_mask = 0x3333000F;
static constexpr uint32_t x_neg_one_mask = 0xF0F0F000;
//static constexpr uint32_t y_one_mask = 0b00110011001100110000000000001111;
static constexpr uint32_t y_one_mask = 0x3333000F;
//static constexpr uint32_t y_neg_one_mask = 0b11001100110011000000000011110000;
static constexpr uint32_t y_neg_one_mask = 0xCCCC00F0;
//static constexpr uint32_t z_one_mask = 0b01010101000000000011001100110011;
static constexpr uint32_t z_one_mask = 0x55003333;
static constexpr uint32_t y_neg_one_mask = 0xCCCC00F0;
//static constexpr uint32_t z_one_mask = 0b01010101000000000011001100110011;
static constexpr uint32_t z_one_mask = 0x55003333;
//static constexpr uint32_t z_neg_one_mask = 0b10101010000000001100110011001100;
static constexpr uint32_t z_neg_one_mask = 0xAA00CCCC;
//static constexpr uint32_t w_one_mask = 0b00000000010101010101010101010101;
static constexpr uint32_t w_one_mask = 0x00555555;
static constexpr uint32_t z_neg_one_mask = 0xAA00CCCC;
//static constexpr uint32_t w_one_mask = 0b00000000010101010101010101010101;
static constexpr uint32_t w_one_mask = 0x00555555;
//static constexpr uint32_t w_neg_one_mask = 0b00000000101010101010101010101010;
static constexpr uint32_t w_neg_one_mask = 0x00AAAAAA;
static constexpr uint32_t w_neg_one_mask = 0x00AAAAAA;
#ifdef __OSL_EMIT_GRAD_MASKS
class OSLEXECPUBLIC mask_emitter {
@@ -254,29 +255,29 @@ namespace fast_simplex {
//static constexpr uint64_t corner2_i_offset_mask = 0b1101000010110000000000000000000000000000000000000000000000000000;
static constexpr uint64_t corner2_i_offset_mask = 0xD0B0000000000000;
static constexpr uint64_t corner2_i_offset_mask = 0xD0B0000000000000;
//static constexpr uint64_t corner2_j_offset_mask = 0b0000000000000000000000000000000011000100000000001000110000000000;
static constexpr uint64_t corner2_j_offset_mask = 0x00000000C4008C00;
static constexpr uint64_t corner2_j_offset_mask = 0x00000000C4008C00;
//static constexpr uint64_t corner2_k_offset_mask = 0b0000000000000000000000001010001000000000000000000000000010001010;
static constexpr uint64_t corner2_k_offset_mask = 0x000000A20000008A;
static constexpr uint64_t corner2_k_offset_mask = 0x000000A20000008A;
//static constexpr uint64_t corner2_l_offset_mask = 0b0000000100000001000000000000000100000001000000000000000100000001;
static constexpr uint64_t corner2_l_offset_mask = 0x0101000101000101;
static constexpr uint64_t corner2_l_offset_mask = 0x0101000101000101;
//static constexpr uint64_t corner3_i_offset_mask = 0b1101000110110001000000001010000011000000000000000000000000000000;
static constexpr uint64_t corner3_i_offset_mask = 0xD1B100A0C0000000;
static constexpr uint64_t corner3_i_offset_mask = 0xD1B100A0C0000000;
//static constexpr uint64_t corner3_j_offset_mask = 0b1100000000000000000000000000000011000101000000001000110110001000;
static constexpr uint64_t corner3_j_offset_mask = 0xC0000000C5008D88;
static constexpr uint64_t corner3_j_offset_mask = 0xC0000000C5008D88;
//static constexpr uint64_t corner3_k_offset_mask = 0b0000000010100000000000001010001100000000000000001000100010001011;
static constexpr uint64_t corner3_k_offset_mask = 0x00A000A30000888B;
static constexpr uint64_t corner3_k_offset_mask = 0x00A000A30000888B;
//static constexpr uint64_t corner3_l_offset_mask = 0b0001000100010001000000000000001100000101000000000000010100000011;
static constexpr uint64_t corner3_l_offset_mask = 0x1111000305000503;
static constexpr uint64_t corner3_l_offset_mask = 0x1111000305000503;
//static constexpr uint64_t corner4_i_offset_mask = 0b1101000110110001000000001010001111000101000000001000000010000000;
static constexpr uint64_t corner4_i_offset_mask = 0xD1B100A3C5008080;
static constexpr uint64_t corner4_i_offset_mask = 0xD1B100A3C5008080;
//static constexpr uint64_t corner4_j_offset_mask = 0b1101000110000000000000001000000011000101000000001000110110001011;
static constexpr uint64_t corner4_j_offset_mask = 0xD1800080C5008D8B;
static constexpr uint64_t corner4_j_offset_mask = 0xD1800080C5008D8B;
//static constexpr uint64_t corner4_k_offset_mask = 0b1000000010110001000000001010001110000000000000001000110110001011;
static constexpr uint64_t corner4_k_offset_mask = 0x80B100A380008D8B;
static constexpr uint64_t corner4_k_offset_mask = 0x80B100A380008D8B;
//static constexpr uint64_t corner4_l_offset_mask = 0b0101000100110001000000000010001101000101000000000000110100001011;
static constexpr uint64_t corner4_l_offset_mask = 0x5131002345000D0B;
static constexpr uint64_t corner4_l_offset_mask = 0x5131002345000D0B;
#ifdef __OSL_EMIT_GRAD_MASKS
@@ -389,7 +390,7 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
return fast_grad2::lut_wide.get(h & 7);
#else
int clamped_index = h&7;
uint8_t bit_index = 0x01 << clamped_index;
uint8_t bit_index = uint8_t(1) << clamped_index;
float x = 0.0f;
if (bit_index & fast_grad2::x_one_mask)
x = 1.0f;
@@ -419,7 +420,7 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
// and use a mask to blend 1.0f and -1.0f on the appropriate indices
//return fast_grad3::lut_wide.get(h & 15);
int clamped_index = h&15;
uint16_t bit_index = 0x0001 << clamped_index;
uint16_t bit_index = uint16_t(1) << clamped_index;
float x = 0.0f;
if (bit_index & fast_grad3::x_one_mask)
x = 1.0f;
@@ -439,8 +440,8 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
z = -1.0f;
return Vec3(x,y,z);
}
#endif
}
template<int seedT>
static OSL_FORCEINLINE const Vec4
@@ -455,7 +456,7 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
// table lookup, so turn index into a linear bit index
// and use a mask to blend 1.0f and -1.0f on the appropriate indices
int clamped_index = h&31;
uint32_t bit_index = 0x00000001 << clamped_index;
uint32_t bit_index = uint32_t(1) << clamped_index;
float x = 0.0f;
if (bit_index & fast_grad4::x_one_mask)
x = 1.0f;
@@ -656,27 +657,36 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
// Noise contributions from the simplex corners
// Calculate the contribution from the three corners
Vec2 g0 = grad2<seedT> (i, j);
Vec2 g1 = grad2<seedT> (i+i1, j+j1);
Vec2 g2 = grad2<seedT> (i+1, j+1);
// As we do not expect any coherency between data lanes
// Hoisted work out of conditionals to encourage masking blending
// versus a check for coherency
// In other words we will do all the work, all the time versus
// trying to manage it on a per lane basis.
// NOTE: this may be slower if used for serial vs. simd
float t0 = 0.5f - x0 * x0 - y0 * y0;
float t20 = t0 * t0;
float t40 = t20 * t20;
float tn0 = t40 * (g0.x * x0 + g0.y * y0);
float n0 = (t0 >= 0.0f) ? tn0 : 0.0f;
Vec2 g0 = grad2<seedT> (i, j);
float n0 = t40 * (g0.x * x0 + g0.y * y0);
if (t0 < 0.0f)
n0 = 0.0f;
float t1 = 0.5f - x1 * x1 - y1 * y1;
float t21 = t1 * t1;
float t41 = t21 * t21;
float tn1 = t41 * (g1.x * x1 + g1.y * y1);
float n1 = (t1 >= 0.0f) ? tn1 : 0.0f;
Vec2 g1 = grad2<seedT> (i+i1, j+j1);
float n1 = t41 * (g1.x * x1 + g1.y * y1);
if (t1 < 0.0f)
n1 = 0.0f;
float t2 = 0.5f - x2 * x2 - y2 * y2;
float t22 = t2 * t2;
float t42 = t22 * t22;
float tn2 = t42 * (g2.x * x2 + g2.y * y2);
float n2 = (t2 >= 0.0f) ? tn2 : 0.0f;
Vec2 g2 = grad2<seedT> (i+1, j+1);
float n2 = t42 * (g2.x * x2 + g2.y * y2);
if (t2 < 0.0f)
n2 = 0.0f;
// Sum up and scale the result. The scale is empirical, to make it
// cover [-1,1], and to make it approximately match the range of our
@@ -687,26 +697,29 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
// Compute derivative, if requested by supplying non-null pointers
// for the last two arguments
if (derivPolicy.has_derivs()) {
/* A straight, unoptimised calculation would be like:
* *dnoise_dx = -8.0f * t20 * t0 * x0 * ( g0.x * x0 + g0.y * y0 ) + t40 * g0.x;
* *dnoise_dy = -8.0f * t20 * t0 * y0 * ( g0.x * x0 + g0.y * y0 ) + t40 * g0.y;
* *dnoise_dx += -8.0f * t21 * t1 * x1 * ( g1.x * x1 + g1.y * y1 ) + t41 * g1.x;
* *dnoise_dy += -8.0f * t21 * t1 * y1 * ( g1.x * x1 + g1.y * y1 ) + t41 * g1.y;
* *dnoise_dx += -8.0f * t22 * t2 * x2 * ( g2.x * x2 + g2.y * y2 ) + t42 * g2.x;
* *dnoise_dy += -8.0f * t22 * t2 * y2 * ( g2.x * x2 + g2.y * y2 ) + t42 * g2.y;
*/
// As we always calculated g# above,
// we need to zero out those who were invalid
// before they are used in more calculations
g0 = (t0 >= 0.0f) ? g0 : Vec2(0.0f);
g1 = (t1 >= 0.0f) ? g1 : Vec2(0.0f);
g2 = (t2 >= 0.0f) ? g2 : Vec2(0.0f);
/* A straight, unoptimised calculation would be like:
* *dnoise_dx = -8.0f * t20 * t0 * x0 * ( g0[0] * x0 + g0[1] * y0 ) + t40 * g0[0];
* *dnoise_dy = -8.0f * t20 * t0 * y0 * ( g0[0] * x0 + g0[1] * y0 ) + t40 * g0[1];
* *dnoise_dx += -8.0f * t21 * t1 * x1 * ( g1[0] * x1 + g1[1] * y1 ) + t41 * g1[0];
* *dnoise_dy += -8.0f * t21 * t1 * y1 * ( g1[0] * x1 + g1[1] * y1 ) + t41 * g1[1];
* *dnoise_dx += -8.0f * t22 * t2 * x2 * ( g2[0] * x2 + g2[1] * y2 ) + t42 * g2[0];
* *dnoise_dy += -8.0f * t22 * t2 * y2 * ( g2[0] * x2 + g2[1] * y2 ) + t42 * g2[1];
*/
if (t0 < 0.0f)
g0 = Vec2(0.0f);
float temp0 = t20 * t0 * (g0.x * x0 + g0.y * y0);
float dnoise_dx = temp0 * x0;
float dnoise_dy = temp0 * y0;
if (t1 < 0.0f)
g1 = Vec2(0.0f);
float temp1 = t21 * t1 * (g1.x * x1 + g1.y * y1);
dnoise_dx += temp1 * x1;
dnoise_dy += temp1 * y1;
if (t2 < 0.0f)
g2 = Vec2(0.0f);
float temp2 = t22 * t2 * (g2.x* x2 + g2.y * y2);
dnoise_dx += temp2 * x2;
dnoise_dy += temp2 * y2;
@@ -844,38 +857,42 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
// In other words we will do all the work, all the time versus
// trying to manage it on a per lane basis.
// NOTE: this may be slower if used for serial vs. simd
Vec3 g0 = grad3<seedT>(i, j, k);
Vec3 g1 = grad3<seedT>(i+i1, j+j1, k+k1);
Vec3 g2 = grad3<seedT>(i+i2, j+j2, k+k2);
Vec3 g3 = grad3<seedT>(i+1, j+1, k+1);
// Calculate the contribution from the four corners
float t0 = 0.5f - x0*x0 - y0*y0 - z0*z0;
float t20 = t0 * t0;
float t40 = t20 * t20;
Vec3 g0 = grad3<seedT>(i, j, k);
// NOTE: avoid array access of points, always use
// the real data members to avoid aliasing issues
//n0 = t40 * (g0[0] * x0 + g0[1] * y0 + g0[2] * z0);
float tn0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
float n0 = (t0 >= 0.0f) ? tn0 : 0.0f;
//n0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
float n0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
if (t0 < 0.0f)
n0 = 0.0f;
float t1 = 0.5f - x1*x1 - y1*y1 - z1*z1;
float t21 = t1 * t1;
float t41 = t21 * t21;
float tn1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1);
float n1 = (t1 >= 0.0f) ? tn1 : 0.0f;
Vec3 g1 = grad3<seedT>(i+i1, j+j1, k+k1);
float n1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1);
if (t1 < 0.0f)
n1 = 0.0f;
float t2 = 0.5f - x2*x2 - y2*y2 - z2*z2;
float t22 = t2 * t2;
float t42 = t22 * t22;
float tn2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2);
float n2 = (t2 >= 0.0f) ? tn2 : 0.0f;
Vec3 g2 = grad3<seedT>(i+i2, j+j2, k+k2);
float n2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2);
if (t2 < 0.0f)
n2 = 0.0f;
float t3 = 0.5f - x3*x3 - y3*y3 - z3*z3;
float t23 = t3 * t3;
float t43 = t23 * t23;
float tn3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3);
float n3 = (t3 >= 0.0f) ? tn3 : 0.0f;
Vec3 g3 = grad3<seedT>(i+1, j+1, k+1);
float n3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3);
if (t3 < 0.0f)
n3 = 0.0f;
// Sum up and scale the result. The scale is empirical, to make it
// cover [-1,1], and to make it approximately match the range of our
@@ -885,40 +902,43 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
if (derivPolicy.has_derivs()) {
/* A straight, unoptimized calculation would be like:
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0.x, g0.y, g0.z, x0, y0, z0) + t40 * g0.x;
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0.x, g0.y, g0.z, x0, y0, z0) + t40 * g0.y;
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0.x, g0.y, g0.z, x0, y0, z0) + t40 * g0.z;
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1.x, g1.y, g1.z, x1, y1, z1) + t41 * g1.x;
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1.x, g1.y, g1.z, x1, y1, z1) + t41 * g1.y;
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1.x, g1.y, g1.z, x1, y1, z1) + t41 * g1.z;
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2.x, g2.y, g2.z, x2, y2, z2) + t42 * g2.x;
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2.x, g2.y, g2.z, x2, y2, z2) + t42 * g2.y;
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2.x, g2.y, g2.z, x2, y2, z2) + t42 * g2.z;
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3.x, g3.y, g3.z, x3, y3, z3) + t43 * g3.x;
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3.x, g3.y, g3.z, x3, y3, z3) + t43 * g3.y;
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3.x, g3.y, g3.z, x3, y3, z3) + t43 * g3.z;
*/
// As we always calculated g# above,
// we need to zero out those who were invalid
// before they are used in more calculations
g0 = (t0 >= 0.0f) ? g0 : Vec3(0.0f);
g1 = (t1 >= 0.0f) ? g1 : Vec3(0.0f);
g2 = (t2 >= 0.0f) ? g2 : Vec3(0.0f);
g3 = (t3 >= 0.0f) ? g3 : Vec3(0.0f);
/* A straight, unoptimized calculation would be like:
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0[0], g0[1], g0[2], x0, y0, z0) + t40 * g0[0];
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0[0], g0[1], g0[2], x0, y0, z0) + t40 * g0[1];
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0[0], g0[1], g0[2], x0, y0, z0) + t40 * g0[2];
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1[0], g1[1], g1[2], x1, y1, z1) + t41 * g1[0];
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1[0], g1[1], g1[2], x1, y1, z1) + t41 * g1[1];
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1[0], g1[1], g1[2], x1, y1, z1) + t41 * g1[2];
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2[0], g2[1], g2[2], x2, y2, z2) + t42 * g2[0];
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2[0], g2[1], g2[2], x2, y2, z2) + t42 * g2[1];
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2[0], g2[1], g2[2], x2, y2, z2) + t42 * g2[2];
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3[0], g3[1], g3[2], x3, y3, z3) + t43 * g3[0];
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3[0], g3[1], g3[2], x3, y3, z3) + t43 * g3[1];
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3[0], g3[1], g3[2], x3, y3, z3) + t43 * g3[2];
*/
if (t0 < 0.0f)
g0 = Vec3(0.0f);
float temp0 = t20 * t0 * (g0.x * x0 + g0.y * y0 + g0.z * z0);
float dnoise_dx = temp0 * x0;
float dnoise_dy = temp0 * y0;
float dnoise_dz = temp0 * z0;
if (t1 < 0.0f)
g1 = Vec3(0.0f);
float temp1 = t21 * t1 * (g1.x * x1 + g1.y * y1 + g1.z * z1);
dnoise_dx += temp1 * x1;
dnoise_dy += temp1 * y1;
dnoise_dz += temp1 * z1;
if (t2 < 0.0f)
g2 = Vec3(0.0f);
float temp2 = t22 * t2 * (g2.x * x2 + g2.y * y2 + g2.z * z2);
dnoise_dx += temp2 * x2;
dnoise_dy += temp2 * y2;
dnoise_dz += temp2 * z2;
if (t3 < 0.0f)
g3 = Vec3(0.0f);
float temp3 = t23 * t3 * (g3.x * x3 + g3.y * y3 + g3.z * z3);
dnoise_dx += temp3 * x3;
dnoise_dy += temp3 * y3;
@@ -1074,45 +1094,49 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
// In other words we will do all the work, all the time versus
// trying to manage it on a per lane basis.
// NOTE: this may be slower if used for serial vs. simd
Vec4 g0 = grad4<seedT>(i, j, k, l);
Vec4 g1 = grad4<seedT>(i+i1, j+j1, k+k1, l+l1);
Vec4 g2 = grad4<seedT>(i+i2, j+j2, k+k2, l+l2);
Vec4 g3 = grad4<seedT>(i+i3, j+j3, k+k3, l+l3);
Vec4 g4 = grad4<seedT>(i+1, j+1, k+1, l+1);
// Calculate the contribution from the five corners
float t0 = 0.5f - x0*x0 - y0*y0 - z0*z0 - w0*w0;
// NOTE: avoid array access of points, always use
// the real data members to avoid aliasing issues
float t0 = 0.5f - x0*x0 - y0*y0 - z0*z0 - w0*w0;
float t20 = t0 * t0;
float t40 = t20 * t20;
float tn0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0 + g0.w * w0);
float n0 = (t0 >= 0.0f) ? tn0 : 0.0f;
Vec4 g0 = grad4<seedT>(i, j, k, l);
float n0 = t40 * (g0.x * x0 + g0.y * y0 + g0.z * z0 + g0.w * w0);
if (t0 < 0.0f)
n0 = 0.0f;
float t1 = 0.5f - x1*x1 - y1*y1 - z1*z1 - w1*w1;
float t21 = t1 * t1;
float t41 = t21 * t21;
float tn1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1 + g1.w * w1);
float n1 = (t1 >= 0.0f) ? tn1 : 0.0f;
Vec4 g1 = grad4<seedT>(i+i1, j+j1, k+k1, l+l1);
float n1 = t41 * (g1.x * x1 + g1.y * y1 + g1.z * z1 + g1.w * w1);
if (t1 < 0.0f)
n1 = 0.0f;
float t2 = 0.5f - x2*x2 - y2*y2 - z2*z2 - w2*w2;
float t22 = t2 * t2;
float t42 = t22 * t22;
float tn2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2 + g2.w * w2);
float n2 = (t2 >= 0.0f) ? tn2 : 0.0f;
Vec4 g2 = grad4<seedT>(i+i2, j+j2, k+k2, l+l2);
float n2 = t42 * (g2.x * x2 + g2.y * y2 + g2.z * z2 + g2.w * w2);
if (t2 < 0.0f)
n2 = 0.0f;
float t3 = 0.5f - x3*x3 - y3*y3 - z3*z3 - w3*w3;
float t23 = t3 * t3;
float t43 = t23 * t23;
float tn3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3 + g3.w * w3);
float n3 = (t3 >= 0.0f) ? tn3 : 0.0f;
Vec4 g3 = grad4<seedT>(i+i3, j+j3, k+k3, l+l3);
float n3 = t43 * (g3.x * x3 + g3.y * y3 + g3.z * z3 + g3.w * w3);
if (t3 < 0.0f)
n3 = 0.0f;
float t4 = 0.5f - x4*x4 - y4*y4 - z4*z4 - w4*w4;
float t24 = t4 * t4;
float t44 = t24 * t24;
float tn4 = t44 * (g4.x * x4 + g4.y * y4 + g4.z * z4 + g4.w * w4);
float n4 = (t4 >= 0.0f) ? tn4 : 0.0f;
Vec4 g4 = grad4<seedT>(i+1, j+1, k+1, l+1);
float n4 = t44 * (g4.x * x4 + g4.y * y4 + g4.z * z4 + g4.w * w4);
if (t4 < 0.0f)
n4 = 0.0f;
// Sum up and scale the result. The scale is empirical, to make it
// cover [-1,1], and to make it approximately match the range of our
@@ -1121,57 +1145,61 @@ static fast_simplex::mask_emitter the_fast_simplex_mask_emitter;
float noise = scale * (n0 + n1 + n2 + n3 + n4);
if (derivPolicy.has_derivs()) {
/* A straight, unoptimised calculation would be like:
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.x;
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.y;
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.z;
* *dnoise_dw = -8.0f * t20 * t0 * w0 * dot(g0.x, g0.y, g0.z, g0.w, x0, y0, z0, w0) + t40 * g0.w;
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.x;
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.y;
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.z;
* *dnoise_dw = -8.0f * t21 * t1 * w1 * dot(g1.x, g1.y, g1.z, g1.w, x1, y1, z1, w1) + t41 * g1.w;
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.x;
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.y;
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.z;
* *dnoise_dw += -8.0f * t22 * t2 * w2 * dot(g2.x, g2.y, g2.z, g2.w, x2, y2, z2, w2) + t42 * g2.w;
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.x;
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.y;
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.z;
* *dnoise_dw += -8.0f * t23 * t3 * w3 * dot(g3.x, g3.y, g3.z, g3.w, x3, y3, z3, w3) + t43 * g3.w;
* *dnoise_dx += -8.0f * t24 * t4 * x4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.x;
* *dnoise_dy += -8.0f * t24 * t4 * y4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.y;
* *dnoise_dz += -8.0f * t24 * t4 * z4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.z;
* *dnoise_dw += -8.0f * t24 * t4 * w4 * dot(g4.x, g4.y, g4.z, g4.w, x4, y4, z4, w4) + t44 * g4.w;
*/
// As we always calculated g# above,
// we need to zero out those who were invalid
// before they are used in more calculations
g0 = (t0 >= 0.0f) ? g0 : Vec4(0.0f);
g1 = (t1 >= 0.0f) ? g1 : Vec4(0.0f);
g2 = (t2 >= 0.0f) ? g2 : Vec4(0.0f);
g3 = (t3 >= 0.0f) ? g3 : Vec4(0.0f);
g4 = (t4 >= 0.0f) ? g4 : Vec4(0.0f);
/* A straight, unoptimised calculation would be like:
* *dnoise_dx = -8.0f * t20 * t0 * x0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[0];
* *dnoise_dy = -8.0f * t20 * t0 * y0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[1];
* *dnoise_dz = -8.0f * t20 * t0 * z0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[2];
* *dnoise_dw = -8.0f * t20 * t0 * w0 * dot(g0[0], g0[1], g0[2], g0[3], x0, y0, z0, w0) + t40 * g0[3];
* *dnoise_dx += -8.0f * t21 * t1 * x1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[0];
* *dnoise_dy += -8.0f * t21 * t1 * y1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[1];
* *dnoise_dz += -8.0f * t21 * t1 * z1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[2];
* *dnoise_dw = -8.0f * t21 * t1 * w1 * dot(g1[0], g1[1], g1[2], g1[3], x1, y1, z1, w1) + t41 * g1[3];
* *dnoise_dx += -8.0f * t22 * t2 * x2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[0];
* *dnoise_dy += -8.0f * t22 * t2 * y2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[1];
* *dnoise_dz += -8.0f * t22 * t2 * z2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[2];
* *dnoise_dw += -8.0f * t22 * t2 * w2 * dot(g2[0], g2[1], g2[2], g2[3], x2, y2, z2, w2) + t42 * g2[3];
* *dnoise_dx += -8.0f * t23 * t3 * x3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[0];
* *dnoise_dy += -8.0f * t23 * t3 * y3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[1];
* *dnoise_dz += -8.0f * t23 * t3 * z3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[2];
* *dnoise_dw += -8.0f * t23 * t3 * w3 * dot(g3[0], g3[1], g3[2], g3[3], x3, y3, z3, w3) + t43 * g3[3];
* *dnoise_dx += -8.0f * t24 * t4 * x4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[0];
* *dnoise_dy += -8.0f * t24 * t4 * y4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[1];
* *dnoise_dz += -8.0f * t24 * t4 * z4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[2];
* *dnoise_dw += -8.0f * t24 * t4 * w4 * dot(g4[0], g4[1], g4[2], g4[3], x4, y4, z4, w4) + t44 * g4[3];
*/
if (t0 < 0.0f)
g0 = Vec4(0.0f);
float temp0 = t20 * t0 * (g0.x * x0 + g0.y * y0 + g0.z * z0 + g0.w * w0);
float dnoise_dx = temp0 * x0;
float dnoise_dy = temp0 * y0;
float dnoise_dz = temp0 * z0;
float dnoise_dw = temp0 * w0;
if (t1 < 0.0f)
g1 = Vec4(0.0f);
float temp1 = t21 * t1 * (g1.x * x1 + g1.y * y1 + g1.z * z1 + g1.w * w1);
dnoise_dx += temp1 * x1;
dnoise_dy += temp1 * y1;
dnoise_dz += temp1 * z1;
dnoise_dw += temp1 * w1;
if (t2 < 0.0f)
g2 = Vec4(0.0f);
float temp2 = t22 * t2 * (g2.x * x2 + g2.y * y2 + g2.z * z2 + g2.w * w2);
dnoise_dx += temp2 * x2;
dnoise_dy += temp2 * y2;
dnoise_dz += temp2 * z2;
dnoise_dw += temp2 * w2;
if (t3 < 0.0f)
g3 = Vec4(0.0f);
float temp3 = t23 * t3 * (g3.x * x3 + g3.y * y3 + g3.z * z3 + g3.w * w3);
dnoise_dx += temp3 * x3;
dnoise_dy += temp3 * y3;
dnoise_dz += temp3 * z3;
dnoise_dw += temp3 * w3;
if (t4 < 0.0f)
g4 = Vec4(0.0f);
float temp4 = t24 * t4 * (g4.x * x4 + g4.y * y4 + g4.z * z4 + g4.w * w4);
dnoise_dx += temp4 * x4;
dnoise_dy += temp4 * y4;
+479
View File
@@ -0,0 +1,479 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
//#include <iostream>
#include <OSL/dual.h>
#include <OSL/dual_vec.h>
using namespace std;
OSL_NAMESPACE_ENTER
namespace __OSL_WIDE_PVT {
// SIMD FRIENDLY MATH
// Scalar code meant to be used from inside
// compiler vectorized SIMD loops.
// No intrinsics or assembly, just vanilla C++
namespace sfm {
template<int MT, int DivisorT> struct Multiplier {
static OSL_FORCEINLINE float multiply(float value)
{
return value * (static_cast<float>(MT) / static_cast<float>(DivisorT));
}
};
template<int DivisorT> struct Multiplier<0, DivisorT> {
static OSL_FORCEINLINE float multiply(float value) { return 0.0f; }
};
template<int DivisorT> struct Multiplier<DivisorT, DivisorT> {
static OSL_FORCEINLINE float multiply(float value) { return value; }
};
template<int ValueT> struct Negative {
static constexpr int value = -ValueT;
};
template<int MT, int DivisorT> struct ProxyElement {
OSL_FORCEINLINE float operator*(float value) const
{
return value * (static_cast<float>(MT) / static_cast<float>(DivisorT));
}
OSL_FORCEINLINE float to_float() const
{
return static_cast<float>(MT) / static_cast<float>(DivisorT);
}
};
template<int DivisorT> struct ProxyElement<0, DivisorT> {
OSL_FORCEINLINE ProxyElement<0, DivisorT> operator*(float) const
{
return ProxyElement<0, DivisorT>();
}
OSL_FORCEINLINE float operator+(float value) const { return value; }
template<int OtherMt, int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<OtherMt, OtherDivisorT>
operator+(ProxyElement<OtherMt, OtherDivisorT>) const
{
return ProxyElement<OtherMt, OtherDivisorT>();
}
OSL_FORCEINLINE float to_float() const { return 0.0f; }
};
template<int MT> struct ProxyElement<MT, 1> {
OSL_FORCEINLINE float operator*(float value) const
{
return static_cast<float>(MT) * value;
}
template<int OtherDivisorT>
OSL_FORCEINLINE float
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
{
return static_cast<float>(MT + 1);
}
template<int OtherMT>
OSL_FORCEINLINE ProxyElement<OtherMT + MT, 1>
operator+(ProxyElement<OtherMT, 1>) const
{
return ProxyElement<OtherMT + MT, 1>();
}
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<MT, 1>
operator+(ProxyElement<0, OtherDivisorT>) const
{
return ProxyElement<MT, 1>();
}
OSL_FORCEINLINE float to_float() const { return static_cast<float>(MT); }
};
template<> struct ProxyElement<0, 1> {
OSL_FORCEINLINE ProxyElement<0, 1> operator*(float) const
{
return ProxyElement<0, 1>();
}
OSL_FORCEINLINE float operator+(float value) const { return value; }
template<int OtherMt, int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<OtherMt, OtherDivisorT>
operator+(ProxyElement<OtherMt, OtherDivisorT>) const
{
return ProxyElement<OtherMt, OtherDivisorT>();
}
OSL_FORCEINLINE float to_float() const { return 0.0f; }
};
template<int DivisorT> struct ProxyElement<DivisorT, DivisorT> {
OSL_FORCEINLINE float operator*(float value) const { return value; }
OSL_FORCEINLINE float operator+(float value) const
{
return 1.0f + value; //
}
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<2, 1>
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
{
return ProxyElement<2, 1>();
}
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<0, DivisorT>
operator+(ProxyElement<0, OtherDivisorT>) const
{
return ProxyElement<0, DivisorT>();
}
OSL_FORCEINLINE float to_float() const { return 1.0f; }
};
//
template<> struct ProxyElement<1, 1> {
OSL_FORCEINLINE float operator*(float value) const { return value; }
OSL_FORCEINLINE float operator+(float value) const { return 1.0f + value; }
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<2, 1>
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
{
return ProxyElement<2, 1>();
}
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<0, 1>
operator+(ProxyElement<0, OtherDivisorT>) const
{
return ProxyElement<0, 1>();
}
OSL_FORCEINLINE float to_float() const { return 1.0f; }
};
template<> struct ProxyElement<-1, 1> {
OSL_FORCEINLINE float operator*(float value) const { return -value; }
OSL_FORCEINLINE float operator+(float value) const
{
return -1.0f + value;
} //
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<0, 1>
operator+(ProxyElement<OtherDivisorT, OtherDivisorT>) const
{
return ProxyElement<0, 1>();
}
template<int OtherDivisorT>
OSL_FORCEINLINE ProxyElement<-1, 1>
operator+(ProxyElement<0, OtherDivisorT>) const
{
return ProxyElement<-1, 1>();
}
OSL_FORCEINLINE float to_float() const { return -1.0f; }
};
template<typename ProxyElementX_T, typename ProxyElementY_T,
typename ProxyElementZ_T>
struct ProxyVec3 {
ProxyVec3() = delete;
OSL_FORCEINLINE ProxyVec3(const ProxyVec3& other)
: x(other.x), y(other.y), z(other.z)
{
}
OSL_FORCEINLINE ProxyVec3(const ProxyElementX_T& x_,
const ProxyElementY_T& y_,
const ProxyElementZ_T& z_)
: x(x_), y(y_), z(z_)
{
}
ProxyElementX_T x;
ProxyElementY_T y;
ProxyElementZ_T z;
};
template<typename ProxyElementX_T, typename ProxyElementY_T,
typename ProxyElementZ_T>
OSL_FORCEINLINE ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>
makeProxyVec3(ProxyElementX_T x, ProxyElementY_T y, ProxyElementZ_T z)
{
return ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>(x, y,
z);
}
OSL_FORCEINLINE
Vec3
makeProxyVec3(float x, float y, float z)
{
return Vec3(x, y, z);
}
template<int MT, int DivisorT>
OSL_FORCEINLINE auto
operator+(float a, ProxyElement<MT, DivisorT> b) -> decltype(b + a)
{
return b + a;
}
template<int MT, int DivisorT>
OSL_FORCEINLINE auto
operator*(float a, ProxyElement<MT, DivisorT> b) -> decltype(b * a)
{
return b * a;
}
OSL_FORCEINLINE
float
unproxy_element(float value)
{
return value;
}
OSL_FORCEINLINE
Vec3
unproxy_element(const Vec3& value)
{
return value;
}
template<typename ProxyElementX_T, typename ProxyElementY_T,
typename ProxyElementZ_T>
OSL_FORCEINLINE Vec3
unproxy_element(
const ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>& value)
{
return Vec3(unproxy_element(value.x), unproxy_element(value.y),
unproxy_element(value.z));
}
template<int MT, int DivisorT>
OSL_FORCEINLINE float
unproxy_element(ProxyElement<MT, DivisorT> value)
{
return value.to_float();
}
template<typename ProxyElementX_T, typename ProxyElementY_T,
typename ProxyElementZ_T>
OSL_FORCEINLINE Vec3
unproxy_vec3(
const ProxyVec3<ProxyElementX_T, ProxyElementY_T, ProxyElementZ_T>& a)
{
return Vec3(unproxy_element(a.x), unproxy_element(a.y),
unproxy_element(a.z));
}
OSL_FORCEINLINE Vec3
unproxy_vec3(const Vec3& a)
{
return a;
}
//Specialize operators for Vec3 to interact with ProxyElements:
template<int MT, int DivisorT>
OSL_FORCEINLINE auto
operator*(ProxyElement<MT, DivisorT> a, const Vec3& b)
-> decltype(makeProxyVec3(a * b.x, a* b.y, a* b.z))
{
return makeProxyVec3(a * b.x, a * b.y, a * b.z);
}
template<int MT, int DivisorT>
OSL_FORCEINLINE auto
operator+(ProxyElement<MT, DivisorT> a, const Vec3& b)
-> decltype(makeProxyVec3(a + b.x, a + b.y, a + b.z))
{
return makeProxyVec3(a + b.x, a + b.y, a + b.z);
}
template<typename XT, typename YT, typename ZT>
OSL_FORCEINLINE auto
operator+(ProxyVec3<XT, YT, ZT> a, const Vec3& b)
-> decltype(makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z))
{
return makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z);
}
template<typename XT, typename YT, typename ZT, typename X2T, typename Y2T,
typename Z2T>
OSL_FORCEINLINE auto
operator+(ProxyVec3<XT, YT, ZT> a, ProxyVec3<X2T, Y2T, Z2T> b)
-> decltype(makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z))
{
return makeProxyVec3(a.x + b.x, a.y + b.y, a.z + b.z);
}
template<typename XT, typename YT, typename ZT>
OSL_FORCEINLINE auto
operator*(ProxyVec3<XT, YT, ZT> a, float b)
-> decltype(makeProxyVec3(a.x * b, a.y* b, a.z* b))
{
return makeProxyVec3(a.x * b, a.y * b, a.z * b);
}
template<int MT, int DivisorT>
OSL_FORCEINLINE auto
operator+(const Vec3& a, ProxyElement<MT, DivisorT> b) -> decltype(b + a)
{
return b + a;
}
template<typename XT, typename YT, typename ZT>
OSL_FORCEINLINE auto
operator+(const Vec3& a, ProxyVec3<XT, YT, ZT> b) -> decltype(b + a)
{
return b + a;
}
template<int MT, int DivisorT>
OSL_FORCEINLINE auto
operator*(const Vec3& a, const ProxyElement<MT, DivisorT>& b) -> decltype(b * a)
{
return b * a;
}
//Dual2
// Specialize operators for Dual2 to interact with ProxyElements
template<class T, int MT, int DivisorT>
OSL_FORCEINLINE Dual2<T>
operator*(ProxyElement<MT, DivisorT> b, const Dual2<T>& a)
{
return Dual2<T>(unproxy_element(a.val() * b), unproxy_element(a.dx() * b),
unproxy_element(a.dy() * b));
}
template<class T, int MT, int DivisorT>
OSL_FORCEINLINE Dual2<T>
operator+(const Dual2<T>& a, ProxyElement<MT, DivisorT> b)
{
return Dual2<T>(a.val() + b, a.dx(), a.dy());
}
template<typename XT, typename YT, typename ZT>
OSL_FORCEINLINE Dual2<Vec3>
operator*(ProxyVec3<XT, YT, ZT> a, const Dual2<float>& b)
{
return Dual2<Vec3>(unproxy_vec3(a * b.val()), unproxy_vec3(a * b.dx()),
unproxy_vec3(a * b.dy()));
}
template<typename XT, typename YT, typename ZT>
OSL_FORCEINLINE Dual2<Vec3>
operator*(const Dual2<float>& b, ProxyVec3<XT, YT, ZT> a)
{
return Dual2<Vec3>(unproxy_vec3(a * b.val()), unproxy_vec3(a * b.dx()),
unproxy_vec3(a * b.dy()));
}
template<typename XT, typename YT, typename ZT>
OSL_FORCEINLINE Dual2<Vec3>
operator+(const Dual2<Vec3>& b, ProxyVec3<XT, YT, ZT> a)
{
return Dual2<Vec3>(unproxy_vec3(b.val() + a), b.dx(), b.dy());
}
OSL_FORCEINLINE
Dual2<float>
unproxy_element(const Dual2<float>& value)
{
return value;
}
OSL_FORCEINLINE
Dual2<Vec3>
unproxy_element(const Dual2<Vec3>& value)
{
return value;
}
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 StaticMatrix44 {
ProxyElement<M00, DivisorT> m00;
ProxyElement<M01, DivisorT> m01;
ProxyElement<M02, DivisorT> m02;
ProxyElement<M03, DivisorT> m03;
ProxyElement<M10, DivisorT> m10;
ProxyElement<M11, DivisorT> m11;
ProxyElement<M12, DivisorT> m12;
ProxyElement<M13, DivisorT> m13;
ProxyElement<M20, DivisorT> m20;
ProxyElement<M21, DivisorT> m21;
ProxyElement<M22, DivisorT> m22;
ProxyElement<M23, DivisorT> m23;
ProxyElement<M30, DivisorT> m30;
ProxyElement<M31, DivisorT> m31;
ProxyElement<M32, DivisorT> m32;
ProxyElement<M33, DivisorT> m33;
};
// For debugging purposes, you can swap in a DynamicMatrix44 for a StaticMatrix44
#if __OSL_DEBUG_STATIC_MATRIX44
struct DynamicMatrix44 {
float m00;
float m01;
float m02;
float m03;
float m10;
float m11;
float m12;
float m13;
float m20;
float m21;
float m22;
float m23;
float m30;
float m31;
float m32;
float m33;
};
#endif
} // namespace sfm
} // namespace __OSL_WIDE_PVT
OSL_NAMESPACE_EXIT
+79 -8
View File
@@ -68,7 +68,7 @@ namespace sfm
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if OSL_INTEL_COMPILER
#if OSL_INTEL_CLASSIC_COMPILER_VERSION
// std::isinf wasn't vectorizing and was branchy. This slightly
// perturbed version fairs better and is branch free when vectorized
// with the Intel compiler.
@@ -86,6 +86,24 @@ namespace sfm
using std::isinf;
#endif
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE T
negate(const T &x) {
#if OSL_FAST_MATH
// Compiler using a constant bit mask to perform negation,
// and reading a constant involves accessing its memory location.
// Alternatively the compiler can create a 0 value in register
// in a constant time not involving the memory subsystem.
// So we can subtract from 0 to effectively negate a value.
// Handling of +0.0f and -0.0f might differ from IEE here.
// But in graphics practice we don't see a problem with codes
// using this approach and a measurable 10%(+|-5%) performance gain
return T(0) - x;
#else
return -x;
#endif
}
OSL_FORCEINLINE OSL_HOSTDEVICE Dual2<float>
absf (const Dual2<float> &x)
{
@@ -94,11 +112,7 @@ namespace sfm
// return x.val() >= 0.0f ? x : -x;
// NOTE: negation happens outside of conditional, then is blended based on the condition
#if OPENIMAGEIO_VERSION >= 20112
Dual2<float> neg_x = OIIO::fast_neg(x);
#else
Dual2<float> neg_x = -x;
#endif
bool cond = x.val() < 0.0f;
// Blend per builtin component to allow
@@ -131,7 +145,7 @@ namespace sfm
//return static_cast<int>(rintf(x));
return rintf(x);
#else
// emulate rounding by adding/substracting 0.5
// emulate rounding by adding/subtracting 0.5
return static_cast<int>(x + copysignf(0.5f, x));
// Other possible factorings
@@ -249,14 +263,71 @@ namespace sfm
}
}
#if OSL_ANY_CLANG && !OSL_INTEL_CLASSIC_COMPILER_VERSION && !OSL_INTEL_LLVM_COMPILER_VERSION
// To make clang's loop vectorizor happy
// we need to make sure result of min and max
// is truly by value, not address or reference
// to the original.
// This required creating temporary result
// versus just returning by value (which could have been elided)
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE
T min_val(const T &left, const T &right)
{
T result(right);
if (right > left)
result = left;
return result;
}
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE
T max_val(const T &left, const T &right)
{
T result(left);
if (right > left)
result = right;
return result;
}
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE
T select_val(bool cond, const T &left, const T &right)
{
T result(right);
if (cond)
result = left;
return result;
}
#else
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE
T min_val(T left, T right)
{
return (right > left)? left : right;
}
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE
T max_val(T left, T right)
{
return (right > left)? right: left;
return (right > left)? right : left;
}
template<typename T>
OSL_FORCEINLINE OSL_HOSTDEVICE
T select_val(bool cond, const T left, const T right)
{
if (cond)
return left;
else
return right;
}
#endif
#if OSL_USING_IMATH >= 3
using Matrix33 = OSL::Matrix33;
#else
@@ -370,7 +441,7 @@ namespace sfm
// Considering having functionally equivalent versions of Vec3, Color3, Matrix44
// with slight modifications to inlining and implementation to avoid aliasing and
// improve likelyhood of proper privation of local variables within a SIMD loop
// improve likelihood of proper privation of local variables within a SIMD loop
} // namespace sfm
+4
View File
@@ -17,6 +17,9 @@ class RendererServices;
/// coordinate transformation.
typedef const void* TransformationPtr;
/// Type for an opaque pointer to whatever the Shading System uses to represent
/// Uniform State.
typedef const void* OpaqueShadingStateUniformPtr;
/// The ShaderGlobals structure represents the state describing a particular
@@ -83,6 +86,7 @@ struct ShaderGlobals {
/// Back-pointer to the ShadingContext (set and used by OSL itself --
/// renderers shouldn't mess with this at all).
ShadingContext* context;
OpaqueShadingStateUniformPtr shadingStateUniform;
/// Pointer to the RendererServices object. This is how OSL finds its
/// way back to the renderer for callbacks.
+5
View File
@@ -139,5 +139,10 @@ STRDECL("SMPTE", SMPTE)
STRDECL("HDTV", HDTV)
STRDECL("CIE", CIE)
STRDECL("AdobeRGB", AdobeRGB)
STRDECL("ACES2065-1", ACES2065_1)
STRDECL("ACEScg", ACEScg)
STRDECL("colorsystem", colorsystem)
STRDECL("arraylength", arraylength)
STRDECL("unknown", unknown)
STRDECL("ERROR: Unknown color space transformation \"%s\" -> \"%s\"\n",
ErrorColorTransform)

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