Compare commits

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

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

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

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

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

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

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

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

---------

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

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

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

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

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

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

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

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

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

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

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

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

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

Change a couple of stray OIIO_CONSTEXPR14 occurrences as well.

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

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

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

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

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

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

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

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

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

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

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

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

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

---------

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

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

---------

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

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

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

---------

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

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

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

Fix runtest, was clobbering parameters to oiiodiff

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

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

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

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

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

* Initalize m_nvptx_target_machine to nullptr.

* Workaround clang/CUDA12 texref issue.

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

---------

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

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

Cover clang 17 compilation with MacOS-13 build

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2024-01-09 20:28:33 -08:00
Larry Gritz 04645499ab admin: Account for duplicate emails in the .mailmap (#1759)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-12-28 13:22:00 -08:00
Larry Gritz 0d9ab3c495 Stage for v1.13.6.0 (beta 1)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-12-20 12:26:30 -08:00
Larry Gritz cbb0e28159 Stage for v1.12.14.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-10-31 15:27:44 -07:00
Larry Gritz c9a37f5cd3 build: Fixes to build and test against OpenImageIO 2.5 (#1742)
The newly released OIIO 2.5 (and changes in master) adjusts a few of
its minimum dependencies (cmake, openexr, fmt) in ways that break some
of our CI test cases for OSL 1.12, and also deprecated a helper method
called ustringHash that OSL referenced in a few places.

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

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

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

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

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-10-04 22:04:20 -07:00
Larry Gritz facfe0b74a Fix default fmt logic changing in latest openimageio release (#1725)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-05 18:38:05 -07:00
Larry Gritz 2cdd061a5f docs: Move logos and add an icon-only logo (#1707)
Move from cryptically named ASWF/images to more descriptive ASWF/logos.

Add an icon only version of the logo.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-20 17:46:23 -07:00
Larry Gritz 17e0449263 docs: Update logos (#1705)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-20 17:41:26 -07:00
Larry Gritz 2d29966c48 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 17:49:33 -07:00
Larry Gritz 0be867f7bf Stage release v1.12.13.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 15:34:49 -07:00
Larry Gritz 362b01ecdd ci: switch oiio obsolete branch names to immutable tags
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-20 10:54:22 -07:00
Larry Gritz 657dab9da0 fix: Avoid deprecated OSLQuery ctr in test example (#1699)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-15 17:11:26 -07:00
Larry Gritz 26ad18688d ci: Add VFX Platform 2023 tests using new ASWF containers (#1696)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 15:06:36 -07:00
Larry Gritz a5857c5525 docs: Amend the filmography (#1695)
docs: Update the filmography

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 15:06:05 -07:00
Mitch Prater e2a3153667 docs: Fixed booboos from the previous README commit. (#1694)
Fixed booboos from the previous commit.
2023-06-14 15:05:49 -07:00
Mitch Prater 34fa5c3755 docs: README.md: added filmography and Siggraph OSL course info. (#1692)
Updated README.md to include LAIKA films and added Siggraph OSL course info to Documentation.
2023-06-14 15:05:38 -07:00
Larry Gritz 67a3c0b93c build: Changes to support fmt 10.0 (#1691)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 18:33:26 -07:00
Larry Gritz 60dcec97e7 cleanup: switch deprecated oiio simd names to modern (#1679)
Oops, I noticed that OSL was still using deprecated OIIO::simd type
aliases (float4, int4, bool4) instead of the modern vfloat4, vint4,
vbool4.

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:34:46 -07:00
Larry Gritz c9672c8a0d admin: Fix incorrect links in CONTRIBUTING (#1688)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:34:26 -07:00
AidanWelch e8fce16d36 Docs: Improve documentation of trace function (#1671)
Improve the documentation of optional parameters of trace to more accurately describe behavior.

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

Note from LG explaining:

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

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

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

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

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

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

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

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

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

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
2023-04-24 22:06:52 -07:00
Curtis Black 35aa264dc8 Add type information for needed attributes. (#1650)
We can currently query which attribute names and scopes are requested in a shader. This PR extends that idea to also allow querying the attribute types. This now more closely matches the equivalent available queries for user data.

For example, this shader:

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

allows us to do this:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:44:44 -08:00
Larry Gritz 434f04d336 docs: Update credits
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:44:27 -08:00
Larry Gritz a1002c61c1 Typo in test shaders (#1644)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-02-20 13:43:36 -08:00
Chris Hellmuth 92b0135971 Expose llvm groupdata size as a shadergroup attribute (#1642)
Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2023-02-20 13:43:13 -08:00
pellerington 3896d22a21 Changed snprintf formatting to satisfy some compilers. (#1640)
Signed-off-by: Peter Ellerington <elleringtonp@gmail.com>
2023-02-20 13:42:35 -08:00
Larry Gritz 500381cc64 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-30 14:23:01 -08:00
Larry Gritz b2b5e5eaba CHANGES and stage for v1.12.9.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-30 14:22:07 -08:00
Declan Russell 8e420b4bc8 Fix some windows GPU build errors (#1638)
Signed-off-by: Declan Russell <declan.russell@autodesk.com>
2023-01-30 09:45:33 -08:00
cmstein a90ed53f88 adding relaxed type-equivalency to ReParameter() (#1639)
Signed-off-by: Clifford Stein <cstein@imageworks.com>
2023-01-27 18:59:26 -08:00
danieldresser-ie 7ee3e36dbb Fix bug with masked wide llvm_gen_closure() (#1637)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-27 18:59:10 -08:00
Larry Gritz 18d79314df Fix doc typo
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-27 18:58:56 -08:00
danieldresser-ie 6f9c907db8 Remove unnecessary setting of locale::global (#1636)
Signed-off-by: Daniel Dresser <danield@image-engine.com>
2023-01-12 15:16:50 -08:00
Larry Gritz b20183d13e Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-12 15:16:23 -08:00
Larry Gritz cdbc05a2b2 CHANGES and stage for v1.12.8.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-03 14:00:02 -08:00
Alex Wells b218c1853b Fix batched support for closures with array types (#1630)
Fixed batched support for closures with array types.
Enabled testsuite/userdata-custom/BATCHED (follow up to PR1620/PR1621).

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 17:49:44 -08:00
Larry Gritz 100490bf8d CI: Fix build break by adjusting fmt version (#1631)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-01-02 11:48:46 -08:00
Larry Gritz 7130058741 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-03 12:37:54 -08:00
Larry Gritz 7394f997db Stage for v1.12.7.1
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-03 11:15:25 -08:00
Larry Gritz f7399cee8e CMake: Adjust how version overrides work (#1617)
Related to https://github.com/OpenImageIO/oiio/pull/3653

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

This patch changes the behavior as follows:

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

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

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

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

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

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

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

Nothing, it seems. So eliminate it.

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-12-02 22:22:25 -08:00
Larry Gritz 2dd1883f95 CI: Adjust when jobs are run to cut needless CI (#1615)
Changes:
* Scorecards and analysis -- allow new to cancel running old
* Scorecard only runs on main repo, no need to run on forks
* Nightly CI only runs on main repo, no need to run on forks

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-11-14 11:55:10 -08:00
Dieter De Baets 410c04ead8 Add clangSupport as dependency to fix linker error (#1613)
Signed-off-by: Dieter De Baets <dieter.baets@unity3d.com>
2022-11-14 11:54:55 -08:00
Larry Gritz a31fba5505 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-30 11:43:24 -07:00
Larry Gritz 98587dfdf8 CHANGES and stage for 1.12.7.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-30 11:10:36 -07:00
Larry Gritz 822518f920 Testing: run pointcloud tests when partio is found (#1611)
Wow, this has been lurking for a while. Our Findpartio.cmake tries
looking for a partio exported config, but if not found, falls back
to a simple code to find it manually.

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-23 18:03:23 -07:00
Damien Courtois 442b265940 fixed broken links to Isotropix products (#1598)
Signed-off-by: Damien Courtois <dcourtois@isotropix.com>
2022-10-19 15:46:24 -07:00
Larry Gritz 09bfd07da7 OSL::bitcast utility (#1610)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-19 09:15:37 -07:00
Larry Gritz 74a53ff545 Improve testing coverage (partial port of #1607)
Looking at the code coverage report and trying to get a higher
coverage amount, employing two strategies: (a) remove unused code
that is not covered because it's... unused; and (b) test things
that are used but aren't in the test run. Details follow.

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

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

get_alignment can also be OSL_DEV only as well as simplified

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

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

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

Signed-off-by: Dan Horák <dan@danny.cz>
2022-10-10 15:21:17 -07:00
Larry Gritz 4a44416156 Try to enable Sonar Cloud static analysis (#1551)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz a30b4f4290 Fix LPE leak in error condition (#1594)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-10-06 12:21:45 -07:00
Larry Gritz f31791b23a Fix memory leaks found by static analysis in leparse.cpp (#1593)
Several places in leparse.cpp were found by static analysis to have
memory leaks -- results of calling _parse() that, in the case of
early exists in error conditions, never got deleted.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Alex M. Wells <alex.m.wells@intel.com>
2022-10-06 10:53:11 -07:00
Larry Gritz cf725983de Batched analysis: ReadEvent remove uninitialized members (#1575)
The little ReadEvent class had two members that are never set when
OSL_DEV is not defined, nor are they accessible (the accessor
functions also are disabled based on OSL_DEV). It looked to the static
analyzer like the data members were uninitialized, which they
were. Add OSL_DEV guards around the declarations of those members as
well, so they aren't even present in the struct when not needed for
this debugging mode.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

IMPORTANT TO-DO / CAVEATS:

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

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

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

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

Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
2022-09-19 18:33:48 -07:00
Larry Gritz 6d9db5a761 Build: Make the version number be a cmake cache variable (#1579)
Rather than specify the version in the usual project() statement,

    project (OSL VERSION 1.13.0.0 ...)

this patch decouples it

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

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

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

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

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

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

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

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

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

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

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

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

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

!!!

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 15:58:50 -07:00
Larry Gritz d9db605bed Make sure all clang-format changes are in .git-blame-ignore-revs (#1568)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-09-01 12:21:10 -07:00
Larry Gritz 13d2c1914f New closure docs (#1564)
* Change the languagespec to document the new MaterialX-synchronized
  closures.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-29 09:30:54 -07:00
Larry Gritz 07b2d9fb15 Fix minor bugs and warnings uncovered by SonarCloud (#1556)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 23:26:22 -07:00
Larry Gritz 6c06652cfd Fixes needed to support OptiX 7.4 (#1559)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-28 23:25:14 -07:00
Larry Gritz 4ee62cd2ef clang-format: the very last piece of the puzzle (#1555)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-26 13:45:47 -07:00
Christopher Kulla 68c67633f5 Add missing cases for MaterilaX closure refraction index detection (#1557)
This allows the refraction index to be detected even if a medium closure
is not present. Additionally, the medium detection now traverses layer()
closures.

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

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

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

Also slightly bump up the error tolerance for this test.

Also add one alternative that seems to frequently pop up.

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

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

Yay for static analysis!

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 00:22:29 -07:00
Larry Gritz 61bb9ac11e Fix spelling
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-08-20 00:22:29 -07:00
Larry Gritz bd7d138f04 Spell check comments (#1550)
Yay for "codespell"

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

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

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

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

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

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

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

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

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

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

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

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

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

Add test cases for dielectric, conductor and generalized schlick closures

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

* Implement refraction case in microfacet closures

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

* Update reference images

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

* Relax diff threshold on render tests

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

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

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

* Add support for sheen in the layer closure

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

  * Add stub parameters and IDs for all MaterialX closures

  * Register all MaterialX closure types

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

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

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

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

Update reference images for new sampler

Signed-off-by: Chris Kulla <ckulla@gmail.com>
2022-07-22 18:15:10 -07:00
Larry Gritz 4e34e8dd20 Mark DCO task as long since done (#1532)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-07-22 18:14:46 -07:00
Adrien Herubel 905058ee13 Fix permission error and build errors when running serialize-bc.py on Linux (#1527)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-07-06 08:56:52 -07:00
Larry Gritz d3e443b766 Security policy fixes (#1529)
* Set up a SECURITY.md explaining how to confidentially report
  vulnerabilities.

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

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

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

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

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

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-30 16:23:13 -07:00
Adrien Herubel 71a518e9a5 Remove unwanted characters causing compilation errors in the MaterialX closure definitions (#1528)
Signed-off-by: Adrien Herubel <adrien.herubel@autodesk.com>
2022-06-24 11:16:40 -07:00
Larry Gritz 2bbd6610c8 Remove confusing licensing comment (#1521)
The implementation of simplex noise we've been using is public domain,
but looks like when we pasted the license notice into our repo, there
was one stray sentence (probably left over from an earlier license
scheme Stefan Gustavson used?) that makes reference to GPL. But the
software and its repo are NOT -- it's very clear that it's public
domain: https://github.com/stegu/perlin-noise/blob/master/LICENSE.md

So remove this confusing sentence.

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

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

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2022-06-20 11:10:51 -07:00
123 changed files with 1714 additions and 1379 deletions
-1
View File
@@ -4,7 +4,6 @@
Language: Cpp
BasedOnStyle: WebKit
SpaceBeforeParens: ControlStatements
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
+4
View File
@@ -43,3 +43,7 @@ c1045f2c2845a98e661c7181932a031eb3c76063
# clang-format: the very last piece of the puzzle (#1555)
4ee62cd2ef05543f818f4d95a19efc1d684a7381
5be7c6bd4e7bd2e560cb6be8c06f11985384a87a
# Raise CI formatting standard to clang-format 17
a9ce35135e6c022d538a4a184fee1b5ce908aed8
90d94caecbb97141c9df63abc634be6e8394b6c3
+3 -3
View File
@@ -18,6 +18,6 @@
- [ ] I have updated the documentation, if applicable.
- [ ] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
- [ ] My code follows the prevailing code style of this project. If I haven't
already run clang-format before submitting, I definitely will look at the CI
test that runs clang-format and fix anything that it highlights as being
nonconforming.
already run clang-format v17 before submitting, I definitely will look at
the CI test that runs clang-format and fix anything that it highlights as
being nonconforming.
+63 -56
View File
@@ -23,6 +23,8 @@ on:
# Full nightly build, for the main project repo (not for forks)
- cron: "0 6 * * *"
if: github.repository == 'AcademySoftwareFoundation/OpenShadingLanguage'
workflow_dispatch:
# This allows manual triggering of the workflow from the web
permissions: read-all
@@ -102,7 +104,7 @@ jobs:
cxx_std: 17
openimageio_ver: master
python_ver: 3.9
pybind11_ver: v2.6.2
pybind11_ver: v2.7.0
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: USE_OPENVDB=0
@@ -115,7 +117,14 @@ jobs:
cxx_compiler: icpc
cxx_std: 17
fmt_ver: 7.1.3
openimageio_ver: master
openimageio_ver: release
# Changes to OIIO's simd.h starting in commit 68666db9 (from PR
# #4187) seem to trigger compiler bugs in icc and generate wrong
# SIMD code. It's probably not worth tracking down for just this
# obsolete compiler. Just lock down to OIIO 2.5 for icc builds to
# avoid the problem.
# openimageio_ver: e41ac03c0b21 # works
# openimageio_ver: 68666db994d5 # broken
python_ver: 3.9
pybind11_ver: v2.9.0
# simd: avx2,f16c
@@ -138,6 +147,7 @@ jobs:
simd: avx2,f16c
batched: b8_AVX2_noFMA
setenvs: export OSL_CMAKE_FLAGS="-DSTOP_ON_WARNING=OFF" USE_OPENVDB=0
OPENCOLORIO_VERSION=v2.3.2 OPENCOLORIO_CXX=g++
- desc: gcc11/C++17 llvm15 py3.10 boost1.80 exr3.1 oiio-rel avx2
nametag: linux-vfx2023
runner: ubuntu-latest
@@ -171,7 +181,7 @@ jobs:
openexr_ver: v2.4.3
openimageio_ver: v2.4.13.0
python_ver: 2.7
pybind11_ver: v2.6.2
pybind11_ver: v2.7.0
simd: 0
setenvs: export PUGIXML_VERSION=v1.8
CMAKE_VERSION=3.15.5
@@ -217,25 +227,6 @@ jobs:
# texture system adequately and is able to ignore the benign
# "leaks."
# Test formatting. This test entry doesn't do a full build, it
# just runs clang-format on everything, and passes if nothing is
# misformatted. Upon failure, the build artifact will be the full
# source code with the formatting fixed (diffs will also appear in
# the console output).
- desc: "clang-format"
nametag: clang-format
runner: ubuntu-latest
container: aswftesting/ci-osl:2022-clang14
vfxyear: 2022
cxx_std: 17
openimageio_ver: release
python_ver: 3.9
simd: avx2,f16c
batched: b8_AVX2
skip_tests: 1
setenvs: export BUILDTARGET=clang-format
OPENIMAGEIO_CMAKE_FLAGS=-DUSE_PYTHON=0
# Test ABI stability. `abi_check` is the version or commit that we
# believe is the current standard against which we don't want to
# break the ABI. Basically, we will build that version as well as
@@ -255,7 +246,7 @@ jobs:
fmt_ver: 10.1.1
pybind11_ver: v2.10.0
skip_tests: 1
abi_check: 8374278a07d88358a6931dc2492f98ca49b21038
abi_check: 1726df72a9841df93bc74a5184d78cacb44b585d
setenvs: export OSL_CMAKE_FLAGS="-DOSL_BUILD_TESTS=0 -DBUILD_TESTING=OFF -DUSE_QT=0"
OPENIMAGEIO_CMAKE_FLAGS="-DUSE_PYTHON=0"
CMAKE_BUILD_TYPE=RelWithDebInfo
@@ -275,6 +266,8 @@ jobs:
USE_BATCHED: ${{matrix.batched}}
USE_SIMD: ${{matrix.simd}}
ABI_CHECK: ${{matrix.abi_check}}
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
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
@@ -326,6 +319,7 @@ jobs:
run: |
mkdir -p abi_standard/build
pushd abi_standard
export LD_LIBRARY_PATH="${PWD}/build/lib:${LD_LIBRARY_PATH}"
src/build-scripts/ci-build.bash
popd
- name: Check ABI
@@ -379,7 +373,7 @@ jobs:
setenvs: export LLVM_VERSION=10.0.0
OPENIMAGEIO_CMAKE_FLAGS="-DBUILD_FMT_VERSION=7.0.1"
PUGIXML_VERSION=v1.10
- desc: latest releases gcc11/C++17 llvm15 boost1.71 exr3.2 py3.9 avx2 batch-b16avx512
- desc: latest releases gcc11/C++17 llvm16 boost1.71 exr3.2 py3.9 avx2 batch-b16avx512
nametag: linux-latest-releases
runner: ubuntu-22.04
cxx_compiler: g++-11
@@ -391,11 +385,11 @@ jobs:
python_ver: "3.10"
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: export LLVM_VERSION=15.0.6
LLVM_DISTRO_NAME=ubuntu-18.04
setenvs: export LLVM_VERSION=16.0.4
LLVM_DISTRO_NAME=ubuntu-22.04
OPENCOLORIO_VERSION=v2.2.0
PUGIXML_VERSION=v1.13
- desc: bleeding edge gcc12/C++17 llvm16 oiio/ocio/exr/pybind-master boost1.71 py3.10 avx2 batch-b16avx512
- desc: bleeding edge gcc12/C++17 llvm17 oiio/ocio/exr/pybind-master boost1.71 py3.10 avx2 batch-b16avx512
nametag: linux-bleeding-edge
runner: ubuntu-22.04
cxx_compiler: g++-12
@@ -407,7 +401,7 @@ jobs:
python_ver: "3.10"
simd: avx2,f16c
batched: b8_AVX2,b8_AVX512,b16_AVX512
setenvs: export LLVM_VERSION=16.0.4
setenvs: export LLVM_VERSION=17.0.6
LLVM_DISTRO_NAME=ubuntu-22.04
OPENCOLORIO_VERSION=main
PUGIXML_VERSION=master
@@ -428,6 +422,27 @@ jobs:
LLVM_DISTRO_NAME=ubuntu-18.04
OPENCOLORIO_VERSION=v2.1.2
PUGIXML_VERSION=v1.11.4
# Test formatting. This test entry doesn't do a full build, it
# just runs clang-format on everything, and passes if nothing is
# misformatted. Upon failure, the build artifact will be the full
# source code with the formatting fixed (diffs will also appear in
# the console output).
- desc: "clang-format"
nametag: clang-format
runner: ubuntu-latest
container: aswftesting/ci-osl:2022-clang14
cxx_std: 17
extra_artifacts: "src/*.*"
openimageio_ver: release
python_ver: "3.10"
simd: avx2,f16c
batched: b8_AVX2
skip_tests: 1
setenvs: export BUILDTARGET=clang-format
LLVM_VERSION=17.0.6
LLVM_DISTRO_NAME=ubuntu-22.04
OPENIMAGEIO_CMAKE_FLAGS=-DUSE_PYTHON=0
QT_VERSION=0
runs-on: ${{matrix.runner}}
env:
@@ -482,45 +497,37 @@ jobs:
build/*.cmake
build/CMake*
build/testsuite/*/*.*
${{ matrix.extra_artifacts }}
macos:
name: "${{matrix.runner}} appleclang${{matrix.aclang}}/C++${{matrix.cxx_std}} py${{matrix.python_ver}} ${{matrix.desc}}"
name: "${{matrix.runner}} C++${{matrix.cxx_std}} py${{matrix.python_ver}} ${{matrix.desc}}"
strategy:
fail-fast: false
matrix:
include:
# - desc: MacOS-11
# runner: macos-11
# nametag: macos11-py310
# cc_compiler: /usr/local/opt/llvm@14/bin/clang
# cxx_compiler: /usr/local/opt/llvm@14/bin/clang++
# cxx_std: 17
# python_ver: "3.10"
# aclang: 13
# setenvs: export LLVMBREWVER="@14" DO_BREW_UPDATE=1
# OPENIMAGEIO_VERSION=release
# QT_BREW_VERSION="@5"
- desc: MacOS-12
runner: macos-12
nametag: macos12-p310
cc_compiler: /usr/local/opt/llvm@15/bin/clang
cxx_compiler: /usr/local/opt/llvm@15/bin/clang++
cxx_std: 17
python_ver: "3.10"
aclang: 13
setenvs: export LLVMBREWVER="@15" DO_BREW_UPDATE=1
OPENIMAGEIO_VERSION=master
- desc: MacOS-13
- desc: MacOS-13 llvm17
runner: macos-13
nametag: macos13-p311
cc_compiler: /usr/local/opt/llvm@15/bin/clang
cxx_compiler: /usr/local/opt/llvm@15/bin/clang++
cc_compiler: /usr/local/opt/llvm/bin/clang
cxx_compiler: /usr/local/opt/llvm/bin/clang++
cxx_std: 17
openimageio_ver: master
python_ver: "3.11"
aclang: 14
setenvs: export LLVMBREWVER="@15" DO_BREW_UPDATE=1
OPENIMAGEIO_VERSION=master
setenvs: export DO_BREW_UPDATE=1 CTEST_TEST_TIMEOUT=120
- desc: MacOS-14-ARM llvm17
runner: macos-14
nametag: macos14-arm-p311
cc_compiler: clang
cxx_compiler: clang++
Xcc_compiler: /usr/local/opt/llvm/bin/clang
Xcxx_compiler: /usr/local/opt/llvm/bin/clang++
cxx_std: 17
openimageio_ver: master
python_ver: "3.11"
aclang: 15
setenvs: export DO_BREW_UPDATE=1
runs-on: ${{matrix.runner}}
env:
@@ -549,7 +556,7 @@ jobs:
run: |
source src/build-scripts/install_homebrew_deps.bash
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then \
OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0" ; \
OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0 -DCMAKE_UNITY_BUILD=ON" ; \
source src/build-scripts/build_openimageio.bash ; \
else \
brew install --display-times -q openimageio ; \
+10 -2
View File
@@ -1,3 +1,8 @@
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenshadingLanguage
name: Publish Release Notice to ASWF Slack
on:
@@ -14,5 +19,8 @@ jobs:
- name: Notify Slack
id: slack
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_RELEASES_URL }}
uses: fedecalendino/slack-release-notifier@8329c1c2d20055ff874ce3eaed7021735d17069d # v2.1.0
project_name: "Open Shading Language"
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel: "#release-announcements"
project_logo: "https://artwork.aswf.io/projects/openshadinglanguage/Icon/Color/openshadinglanguage-Icon-Color.png"
uses: jmertic/slack-release-notifier@main
+47
View File
@@ -0,0 +1,47 @@
# This file establishes email equivalences so we can resolve what look like
# multiple authors, but actually are the same author who has used multiple
# emails over the course of their involvement with the project.
#
# The format is any of the following:
# <CANONICAL-EMAIL> <alternate-email>
# CANONICAL-NAME <CANONICAL-EMAIL> <alternate-email>
# CANONICAL-NAME <CANONICAL-EMAIL> alternate-name <alternate-email>
#
# You can check for duplicates with this command:
# git shortlog -sne --all
# That command (and others) will use this file to collapse the duplicates.
#
# If you see any duplicates we don't account for here, or if you look at your
# own entry here and want a different name or email to be your canonical one
# (we may not have guessed correctly and matched your preferences), please
# file a PR with the edits to this file.
Adam Martinez <amartinez.cg@gmail.com> amartinez-cg <amartinez.cg@gmail.com>
Alejandro Conty <aconty@imageworks.com> aconty <aconty@gmail.com>
Alejandro Conty <aconty@imageworks.com> Alejandro Conty <aconty@gmail.com>
Alex M. Wells <alex.m.wells@intel.com> <alex.m.wells@intel.com>
Alex M. Wells <alex.m.wells@intel.com> <AlexMWells@users.noreply.github.com>
Alex M. Wells <alex.m.wells@intel.com> <awells-np@argon.sea.pixar.com>
Alexis Oblet <alob@mikrosimage.eu> Alexis Oblet <aoblet@users.noreply.github.com>
Brecht Van Lommel <brecht@blender.org> <brecht@solidangle.com>
Brecht Van Lommel <brecht@blender.org> Brecht Van Lommel <brechtvanlommel@gmail.com>
Chris Kulla <ckulla@gmail.com> <ckulla@imageworks.com>
Chris Kulla <ckulla@gmail.com> <fpsunflower@users.noreply.github.com>
Chris Kulla <ckulla@gmail.com> Christopher Kulla <ckulla@gmail.com>
Chris Kulla <ckulla@gmail.com> fpsunflower <ckulla@gmail.com>
Clifford Stein <cstein@imageworks.com> Cliff Stein <clifford.stein@gmail.com>
Clifford Stein <cstein@imageworks.com> cmstein <cstein@imageworks.com>
Declan Russell <declan.russell@autodesk.com> Declan Russell <i7709212@bournemouth.ac.uk>
Derek Haase <derekhaase@gmail.com> Derek Haase <dhaase@imageworks.com>
Esteban Tovagliari <ramenhdr@gmail.com> est77 <ramenhdr@gmail.com>
Henri Fousse <henri.fousse@free.fr> darkhorse64 <henri.fousse@free.fr>
Larry Gritz <lg@imageworks.com> <larrygritz@gmail.com>
Larry Gritz <lg@imageworks.com> <lg@larrygritz.com>
Roman Zulak <marsupial@users.noreply.github.com> <rzulak@imageworks.com>
Roman Zulak <marsupial@users.noreply.github.com> Frederich Munch <marsupial@users.noreply.github.com>
Roman Zulak <marsupial@users.noreply.github.com> marsupial <marsupial@users.noreply.github.com>
Ronan Keryell <Ronan.Keryell@amd.com> Ronan Keryell <Ronan.Keryell@silkan.com>
Steena Monteiro <steena.monteiro@intel.com> steena.monteiro <smonteir@ortce-sklaw.jf.intel.com>
Sven-Hendrik Haase <sh@lutzhaase.com> Sven-Hendrik Haase <svenstaro@gmail.com>
Tim Grant <tgrant@nvidia.com> Tim Grant <87798327+tgrant-nv@users.noreply.github.com>
Tim Grant <tgrant@nvidia.com> timgrant <timgrant@users.noreply.github.com>
+124 -28
View File
@@ -1,20 +1,80 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Open Shading Language Project. -->
Release 1.13 -- October?? 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.
Release 1.13.11.0 -- 1 Sep 2024 (compared to 1.13.10.0)
---------------------------------------------------------
- *fix/batched*: Assume BatchedRendererServices texture derivatives are in st space. [#1828](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1828) (by sfriedmapixar) (1.13.10.0)
- *fix*: Make backfacing shadeop indicate backfacing shader-global is needed [#1827](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1827) (by sfriedmapixar) (1.13.10.0)
- *deps*: Handle various OpenImageIO deprecations and changes in the run-up to OIIO 3.0 [#1834](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1834) [#1806](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1806) [#1838](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1838) [#1842](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1842) [#1850](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1850) (1.13.10.0)
- *deps*: Adjust to OIIO change to IC/TS API [#1848](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1848) (1.13.10.0)
- *deps*: Llvm 18 compat issue - include libclangAPINotes [#1812](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1812) (1.13.10.0)
- *deps*: Make finding bison work better on Apple Silicon Macs + homebrew [#1822](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1822) (1.13.10.0)
- *ci*: Mods to CI to deal with OIIO master raising dependency mins [#1833](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1833) (1.13.10.0)
- *ci*: Deal with CentOS 7 EOL and disappearance of yum mirrors [#1839](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1839) (1.13.10.0)
- *ci*: Fix GHA CI after they upgraded nodejs [#1837](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1837) (1.13.10.0)
- *admin*: Change release notice icon to use the icon vs the normal logo so it shows up better [#1777](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1777) (by John Mertic) (1.13.10.0)
Release 1.13.10.0 -- 1 June 2024 (compared to 1.13.9.0)
--------------------------------------------------------
- *testrender*: Implement new Oren-Nayar model from OpenPBR [#1817](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1817) (by Christopher Kulla)
- *docs*: Fix outdated or wrong repo URLs [#1811](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1811)
Release 1.13.9.0 -- 1 May 2024 (compared to 1.13.8.0)
--------------------------------------------------------
- *deps*: Support for LLVM-18 [#1773](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1773) (by مهدي شينون (Mehdi Chinoune) [#1803](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1803) (by Larry Gritz)
- *fix*: Make isconnected() work with downstream renderer "connections." [#1782](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1782) (by sfriedmapixar)
- *cleanup*: Change OSL_CONSTEXPR14 to constexpr [#1805](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1805)
- *internals build*: Fix ifdef typo [#1804](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1804)
- *build*: Propagate cpp version [#1797](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1797)
- *build*: Print commit hash of locally built dependencies [#1798](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1798)
- *ci*: Lock down to OIIO 2.5 for icc tests [#1799](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1799)
- *ci*: Suppress leak sanitizer warnings about internals of robin_hash [#1807](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1807)
- *docs*: More detail about supported platforms in INSTALL.md [#1796](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1796)
Release 1.13.8.0 -- 1 Apr 2024 (compared to 1.13.7.0)
--------------------------------------------------------
* *fix(batched)*: Codegen bug for compref with varying index for batched shading [#1776](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1776) (by Alex Wells)
* *fix*: Calculatenormal needs fliphandedness [#1783](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1783) (by sfriedmapixar)
* *fix*: Print closure missing error message at compile time instead of run time. [#1781](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1781) (by sfriedmapixar)
* *int*: Change long-deprecated OIIO macro to new one [#1788](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1788)
* *ci*: Fix broken Macos-13 CI [#1780](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1780)
Release 1.13.7.0 -- 1 Mar 2024 (compared to 1.13.6.1)
--------------------------------------------------------
* *fix*: Mute partio error prints [#1774](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1774) (by olegul)
* *ci*: Test with Mac ARM runner [#1770](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1770)
* *docs*: Fix links to RTD docs from github landing page [#1768](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1768)
* *admin*: Switch release announcement workflow to jmertic's awesome action [#1766](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1766)
<br>
Release 1.13 -- Feb 1, 2024 (compared to 1.12)
===============================================
- beta 1: December 20, 2023
- release v1.13.6.1: Feb 1, 2024
### New minimum dependencies and compatibility changes:
* For GPU/OptiX mode, OptiX 6.0 support has been removed. For GPU rendering
with OptiX, a minimum of OptiX 7.0 is required, and the Cuda minimum has
been raised to 9.0 [#1737](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1737)
* The minimum version OpenImageIO has been raised from 2.2 to 2.4. [#1591](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1591) [#1722](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1722)
(to 2.3 in 1.13.0.3, to 2.4 in 1.13.4.0)
* Raise minimum CMake dependency from 3.12 to 3.15 [#1724](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1724) (1.13.5.0)
* Raise minimum Imath/OpenEXR from 2.3 to 2.4.
* The minimum CMake dependency has been raised from 3.12 to 3.15
[#1724](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1724) (1.13.5.0)
* The minimum Imath/OpenEXR has been raised from 2.3 to 2.4. (Note: OSL 1.13
is probably the last major release family that will support Imath/OpenEXR
2.x.)
### OSL Language and oslc compiler:
* There have been no substantive changes to the OSL language in this release.
### API changes, new options, new ShadingSystem features (for renderer writers):
### ⛰️ API changes, new options, new ShadingSystem features (for renderer writers):
* A new `shadingStateUniform` pointer field was added to ShaderGlobals for
planned future expansion and improved GPU support. #1585 (1.13.1.0)
* Adding relaxed type-equivalency to ReParameter() [#1639](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1639) (by cmstein) (1.13.2.1)
@@ -40,7 +100,8 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
* Rs fmt specification - Journaling Algorithm for error, warning, fprintf
[#1702](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1702) (by Steena Monteiro) [#1711](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1711) [#1715](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1715) (1.13.5.0)
### SIMD batched shading mode
### 🚀 SIMD batched shading mode
* Fix some array overruns (asymptomatic, but still potentially buggy) in
common_ancestor_between. #1577 (1.13.0.2)
* Fix issue with closure keyword parameters. #1620 (1.13.2.0/1.12.8.0)
@@ -48,8 +109,11 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
(1.13.2.0/1.12.8.0)
* Fix support for closures with array types. #1630 (1.13.2.0/1.12.8.0)
* Fix bug with masked wide llvm_gen_closure() [#1637](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1637) (by danieldresser-ie) (1.13.2.1)
* Fix Force LLVM Boolean [#1717](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1717) (by Alex Wells)
* Batched pointcloud if "index" is not passed [#1753](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1753) (by Alex Wells)
### 🚀 OptiX GPU rendering
### OptiX GPU rendering
* OptiX 6.0 support has been removed. For GPU rendering with OptiX, a minimum
of OptiX 7.0 is required.
* Big overhaul/simplification of how strings are represented on the GPU: the
@@ -80,8 +144,10 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
* OptiX PTX pipeline overhaul [#1680](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1680) (by Tim Grant) (1.13.5.0)
* Perf: Don't insert redundant run layer calls inside a basic block
[#1665](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1665) [#1669](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1669) [#1672](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1672) (by Chris Hellmuth) (1.13.4.0)
* Fix NVPTX TargetMachine leak, etc. [#1763](https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/1763) (by Tim Grant)
### 🐛/🔧 Internals: fixes, improvements, and developer concerns
### 🐛 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)
* Fix mismatched strides when calling OCIO for transformc with derivs [#1646](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1646) (1.13.4.0)
@@ -98,8 +164,6 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
* oslc: Add missing `fmod()` variants [#1643](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1643) (1.13.4.0)
* Simple constant folding of binary expressions now happen on the oslc side
[#1653](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1653) (1.13.4.0)
### 🔧 Internals and developer concerns
* platform.h:
* New `OSL_ALLOCA` macro to allocate on the stack. #1589 (1.13.0.3)
* Define OSL::bitcast utility. #1610 (1.13.2.0)
@@ -115,8 +179,12 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
* Give ShadingSystemImpl a handy use_optix() method [#1682](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1682) (1.13.4.0)
* Fix default fmt logic changing in latest openimageio release [#1725](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1725) (1.13.5.0)
* The recently added SS::find_symloc can have const args [#1723](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1723) (1.13.5.0)
* SymOverrideInfo bitfields should be the same type [#1745](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1745)
* Fix wrong offset of MxSheen param [#1751](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1751) (by Rasmus Bonnedal)
* Make get_texture_info robust to empty shaderglobals param [#1731](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1731)
### 🏗 Build/test/CI and platform ports
* CMake build system and scripts:
* The version number is now a cache variable, and so can be overridden at
build time using `-DOSL_VERSION=...`. Use with extreme caution! #1579
@@ -127,8 +195,9 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
* Fix incorrect CMake variable name to control symbol visibility
[#1681](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1681) (1.13.4.0)
* Change cmake option `USE_OPTIX` -> `OSL_USE_OPTIX` [#1668](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1668) (1.13.4.0)
* Fix duplicate osl lexing symbols when building as static libraries
* Fix duplicate osl lexing symbols when building as static libraries
[#1709](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1709) (by Brecht Van Lommel) (1.13.5.0)
* Better cmake verbose behavior [#1752](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1752)
* Dependency version support:
* Fix some issues that came up with the new icx 2022.0 compiler. #1601
(1.13.1.0)
@@ -140,6 +209,12 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
* Qt6 compatibility [#1655](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1655) (1.13.4.0)
* Fix warnings about Qt compilation and enums [#1661](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1661) (1.13.4.0)
* Changes to support fmt 10.0 [#1691](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1691) (1.13.5.0)
* Raise OpenEXR minimum to 2.4 [#1734](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1734)
* Fix Partio build errors on pointcloud functions for MSVC [#1757](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1757) (by Alex Wells)
* Bump Cuda minimum to 9.0 [#1737](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1737)
* LLVM 16 and 17 support: LLVM opaque pointers support [#1728](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1728),
LLVM new pass manager support [#1729](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1729),
finish LLVM 16 and 17 support [#1730](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1730) (all by Brecht Van Lommel)
* Testing and Continuous integration (CI) systems:
* Dynamic analysis using address and leak sanitizers. #1581 (1.13.0.3)
* `testshade --help` now prints TextureSystem options and all hardware
@@ -158,20 +233,41 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
[#1660](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1660) (by Massimo Paladin) (1.13.4.0)
* *ci*: Simplify build_llvm.bash script [#1703](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1703) (1.13.5.0)
* Test interactive parameter initialization in optix testrender [#1687](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1687) (by Chris Hellmuth) (1.13.5.0)
* Fix GPU job not actually enabling OptiX [#1738](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1738) (by Brecht Van Lommel)
* Fix python-oslquery test failure on macOS [#1739](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1739) (by Brecht Van Lommel)
* Disable MacOS-11 CI [#1746](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1746)
* Skip analysis and scorecard workflows on push if only docs changed [#1744](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1744)
* For clarity, use the term 'runner' instead of 'os' [#1743](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1743)
* Test ABI compliance [#1748](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1748)
* Fix tests passing when test commands fail [#1733](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1733) (by Brecht Van Lommel)
* *ci*: Test against LLVM 17 [#1760](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1760)
* Platform support:
* Include `immintrin.h` only when needed. #1605 (1.13.1.0)
* Changed snprintf formatting to satisfy some compilers.
[#1640](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1640) (by pellerington) (1.13.4.0)
* Fix some windows GPU build errors [#1638](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1638) (by Declan Russell) (1.13.4.0)
* Fix for Apple clang 14+ warnings [#1697](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1697) (1.13.5.0)
* Fix struct align/pack for MSVC [#1754](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1754) (by Rasmus Bonnedal)
* Refactor icc/icx specific pragma macros [#1756](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1756) (by Alex Wells)
### 📚 Documentation
* First stab at ReadTheDocs -- new [Experimental OSL Documentation on
ReadTheDocs](https://open-shading-language.readthedocs.io/)
is still a little rough, but eventually will be our primary documentation.
[#1736](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1736)
* `doc/RELEASING.md` documents our release process and versioning policies.
#1572 (1.13.0.2)
* Improve documentation of `trace` function [#1671](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1671) (by AidanWelch) (1.13.4.0)
* Update CONTRIBUTING [#1689](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1689) (1.13.5.0)
* Update logos [#1705](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1705), Move logos and add an icon-only logo [#1707](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1707) (1.13.5.0)
### 🏢 Project Administration
* Alert slack "release-announcements" channel upon OSL release [#1740](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1740) [#1749](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1749)
* Update pull request template [#1741](https://github.com/AcademySoftwareFoundation/OpenShadingLangauge/pull/1741)
* Account for duplicate emails in the .mailmap [#1759](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1759)
---
---
@@ -181,30 +277,30 @@ Release 1.13 -- October?? 2023 ?? (compared to 1.12)
Release 1.12.13.0 -- 1 July 2023 (compared to 1.12.12.0)
--------------------------------------------------------
- *fix*: Fix constant float values being converted to ints
[#1674](https://github.com/OpenImageIO/oiio/pull/1674) (by Declan Russell)
[#1674](https://github.com/OpenShadingLanguage/oiio/pull/1674) (by Declan Russell)
- *build*: Fix builds when USE_PYTHON=OFF
[#1675](https://github.com/OpenImageIO/oiio/pull/1675) (by Declan Russell)
[#1675](https://github.com/OpenShadingLanguage/oiio/pull/1675) (by Declan Russell)
- *build*: Changes to support fmt 10.0
[#1691](https://github.com/OpenImageIO/oiio/pull/1691)
[#1691](https://github.com/OpenShadingLanguage/oiio/pull/1691)
- *cleanup*: Switch deprecated oiio simd names to modern
[#1679](https://github.com/OpenImageIO/oiio/pull/1679)
[#1679](https://github.com/OpenShadingLanguage/oiio/pull/1679)
- *testing*: Avoid deprecated OSLQuery ctr in test example
[#1699](https://github.com/OpenImageIO/oiio/pull/1699)
[#1699](https://github.com/OpenShadingLanguage/oiio/pull/1699)
- *ci*: Fix package name for icc
[#1690](https://github.com/OpenImageIO/oiio/pull/1690)
[#1690](https://github.com/OpenShadingLanguage/oiio/pull/1690)
- *ci*: Add VFX Platform 2023 tests using new ASWF containers
[#1696](https://github.com/OpenImageIO/oiio/pull/1696)
[#1696](https://github.com/OpenShadingLanguage/oiio/pull/1696)
- *ci*: Switch oiio obsolete branch names to immutable tags
[#1701](https://github.com/OpenImageIO/oiio/pull/1701)
[#1701](https://github.com/OpenShadingLanguage/oiio/pull/1701)
- *docs*: Improve documentation of `trace` function
[#1671](https://github.com/OpenImageIO/oiio/pull/1671) (by AidanWelch)
[#1671](https://github.com/OpenShadingLanguage/oiio/pull/1671) (by AidanWelch)
- *docs*: README.md: added filmography and Siggraph OSL course info.
[#1692](https://github.com/OpenImageIO/oiio/pull/1692)
[#1694](https://github.com/OpenImageIO/oiio/pull/1694) (by Mitch Prater)
[#1692](https://github.com/OpenShadingLanguage/oiio/pull/1692)
[#1694](https://github.com/OpenShadingLanguage/oiio/pull/1694) (by Mitch Prater)
- *docs*: Amend the filmography
[#1695](https://github.com/OpenImageIO/oiio/pull/1695)
[#1695](https://github.com/OpenShadingLanguage/oiio/pull/1695)
- *docs*: Fix incorrect links in CONTRIBUTING
[#1688](https://github.com/OpenImageIO/oiio/pull/1688)
[#1688](https://github.com/OpenShadingLanguage/oiio/pull/1688)
Release 1.12.12.0 -- 1 May 2023 (compared to 1.12.11.0)
--------------------------------------------------------
+4 -4
View File
@@ -4,7 +4,7 @@
cmake_minimum_required (VERSION 3.15)
set (OSL_VERSION "1.13.5.0")
set (OSL_VERSION "1.13.11.0")
set (OSL_VERSION_OVERRIDE "" CACHE STRING
"Version override (use with caution)!")
mark_as_advanced (OSL_VERSION_OVERRIDE)
@@ -18,12 +18,12 @@ project (OSL VERSION ${OSL_VERSION}
set (PROJ_NAME ${PROJECT_NAME}) # short name
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
set (PROJECT_VERSION_RELEASE_TYPE "dev" CACHE STRING
set (PROJECT_VERSION_RELEASE_TYPE "" CACHE STRING
"Build type, for example: dev, beta2, RC1 (empty string for normal release)")
set (${PROJECT_NAME}_VERSION_RELEASE_TYPE ${PROJECT_VERSION_RELEASE_TYPE})
set (PROJECT_AUTHORS "Contributors to the Open Shading Language project")
option (${PROJECT_NAME}_SUPPORTED_RELEASE
"Set ON for supported release branch, OFF for master" OFF)
"Set ON for supported release branch, OFF for master" ON)
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
set (${PROJECT_NAME}_DEV_RELEASE OFF)
else ()
@@ -139,7 +139,7 @@ add_definitions (-DOSL_INTERNAL=1)
# To make sure we aren't relying on deprecated OIIO features, we define
# OIIO_DISABLE_DEPRECATED before including any OIIO headers.
add_definitions (-DOIIO_DISABLE_DEPRECATED=1)
add_definitions (-DOIIO_DISABLE_DEPRECATED=900000)
# Set the default namespace. For symbol hiding reasons, it's important that
# the project name is a subset of the namespace name.
+4 -3
View File
@@ -115,7 +115,8 @@ own repository on GitHub, and then clone it to get a repository on your
local machine.
2. Edit, compile, and test your changes. Run clang-format (see the
instructions on coding style below).
instructions on coding style below). Our current formatting standard,
as checked by our CI, uses clang-format 17.0.
3. Push your changes to your fork (each unrelated pull request to a separate
"topic branch", please).
@@ -170,14 +171,14 @@ file in which it appears.
#### Formatting
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) v17
to uniformly format our source code prior to PR submission. Make sure that
clang-format is installed on your local machine, and just run
make clang-format
and it will automatically reformat your code according to the configuration
file found in the `.clang-format` file at the root directory of the OIIO
file found in the `.clang-format` file at the root directory of the OSL
source code checkout.
One of the CI test matrix entries runs clang-format and fails if any
+19 -13
View File
@@ -4,7 +4,14 @@
Building OSL
============
OSL currently compiles and runs cleanly on Linux, Mac OS X, and Windows.
OSL currently compiles and runs cleanly on Linux (x86_64), Mac OS X (x86_64
and aarch64), and Windows (x86_64). It may build and run on other platforms as
well, but we don't officially support or test other than these platforms.
Shader execution is supported on the native architectures of those x86_64 and
aarch64 platforms, a special batched 8- or 16-wide SIMD execution mode
requiring x86_64 with AVX2 or AVX-512 instructions, as well as on NVIDIA GPUs
using Cuda+OptiX.
Dependencies
------------
@@ -12,11 +19,11 @@ 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.15 or newer** (tested through 3.27)
* Build system: [CMake](https://cmake.org/) **3.15 or newer** (tested through 3.29)
* A suitable C++14 or C++17 compiler to build OSL itself, which may be any of:
- GCC 6.1 or newer (tested through gcc 12.1)
- Clang 3.4 or newer (tested through clang 16)
- Clang 3.4 or newer (tested through clang 18)
- Microsoft Visual Studio 2017 or newer
- Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler
version 2022 or newer.
@@ -40,19 +47,18 @@ NEW or CHANGED dependencies since the last major release are **bold**.
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X).
* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, or 15, including
clang libraries. LLVM 16 doesn't work yet, we need to make changes
on the OSL side to be compatible.
* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, 15, 16, 17, or 18, including
clang libraries.
* (optional) For GPU rendering on NVIDIA GPUs:
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.
* [Cuda](https://developer.nvidia.com/cuda-downloads) 9.0 or higher. It is
recommended that you use 11.0 or higher.
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.82)
* [Boost](https://www.boost.org) 1.55 or newer (tested through boost 1.85)
* [Ilmbase or Imath](https://github.com/AcademySoftwareFoundation/Imath) 2.4
or newer (recommended: 3.1 or higher; tested through 3.2)
NOTE: It is likely that 1.13 is the last release that will support
NOTE: OSL 1.13.x is the last release family that will support
Imath/OpenEXR 2.x.
* [Flex](https://github.com/westes/flex) 2.5.35 or newer and
[GNU Bison](https://www.gnu.org/software/bison/) 2.7 or newer.
@@ -65,12 +71,12 @@ NEW or CHANGED dependencies since the last major release are **bold**.
be operative.
* (optional) Python: If you are building the Python bindings or running the
testsuite:
* Python >= 2.7 (tested against 2.7, 3.7, 3.8, 3.9, 3.10)
NOTE: It is likely that 1.13 is the last release that will support
Python 2.7.
* pybind11 >= 2.4.2 (Tested through 2.10)
* Python >= 2.7 (tested against 2.7, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12)
NOTE: OSL 1.13.x is the last release family that will support Python 2.7.
* pybind11 >= 2.4.2 (Tested through 2.12. Note that pybind11 v2.10+ does
not support Python < 3.6.)
* NumPy
* (optional) Qt5 >= 5.6 or Qt6 (tested Qt5 through 5.15 and Qt6 through 6.4).
* (optional) Qt5 >= 5.6 or Qt6 (tested Qt5 through 5.15 and Qt6 through 6.7).
If not found at build time, the `osltoy` application will be disabled.
+34 -18
View File
@@ -9,7 +9,7 @@
[![Build Status](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/workflows/CI/badge.svg)](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/actions)
[![License](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/LICENSE.md)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3061/badge)](https://bestpractices.coreinfrastructure.org/projects/3061)
[![Documentation Status](https://readthedocs.org/projects/open-shading-language/badge/?version=main)](https://open-shading-language.readthedocs.io/en/main/?badge=main)
Introduction
@@ -426,7 +426,7 @@ nominated for major awards.)
Obi-Wan Kenobi (series),
The Boys (S3),
Andor (S1)
* **(2023 / upcoming)**
* **(2023)**
Ant-Man and the Wasp: Quantumania,
The Mandalorian S3,
The Magician's Elephant,
@@ -434,6 +434,10 @@ nominated for major awards.)
Guardians of the Galaxy 3,
Spider-Man: Across the Spider-Verse,
Elemental,
The Marvels,
Leo
* **(2024 / upcoming)**
Ghostbusters: Frozen Empire,
...
@@ -452,7 +456,18 @@ The OSL language specification can be found at
distribution) or in the share/doc/OSL/osl-languagespec.pdf file of an
installed binary distribution.
For those interested in learning to program in OSL, there is the
[Experimental OSL Documentation on ReadTheDocs](https://open-shading-language.readthedocs.io/)
This will be the future documentation. It's probably as complete as the PDF,
but it needs some proofreading, so the PDF is still considered the
authoritative source for now. But some time soon, the old PDF specification
will be deprecated in favor of
this online documentation.
<!-- is the best place to start if you are interested in how to use OSL,
its APIs. -->
There is also a [PDF
version](https://readthedocs.org/projects/open-shading-language/downloads/pdf/latest/).
For those interested in learning to program shaders in OSL, there is the
[Siggraph 2022 Educator's Forum](https://dl.acm.org/doi/proceedings/10.1145/3532724)
[OSL Shaders for RenderMan](https://dl.acm.org/doi/abs/10.1145/3532724.3535604) course,
which uses RenderMan in the examples and
@@ -515,21 +530,22 @@ The current project leadership is documented in the
Many people have contributed features, bug fixes, and other changes to OSL
over the years: Steve Agland, Shane Ambler, Martijn Berger, Farchad
Bidgolirad, Nicholas Bishop, Solomon Boulos, Stefan Bruens, Stefan Büttner,
Matthaus G. Chajdas, Clark Chen, Alejandro Conty, Damien Courtois, Dieter De
Baets, Thomas Dinges, Daniel Dresser, Mads Drøschler, Peter Ellerington, Luke
Emrose, Louis Feng, Mark Final, Henri Fousse, Stephen Friedman, Syoyo Fujita,
Tim Grant, Larry Gritz, Nicolas Guiard, Euan Haahr, Derek Haase, Sven-Hendrik
Haase, John Haddon, Niklas Harrysson, Daniel Heckenberg, Chris Hellmuth,
Adrien Herubel, Dan Horák, Thiago Ize, Matt Johnson, Ronan Keryell, Chris
Kulla, Elvic Liang, Max Liani, Adam Martinez, John Mertic, Bastien Montagne,
Steena Monteiro, Patrick Mours, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino
Park, Alexei Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick
Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip
Shukla, Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari,
Brecht Van Lommel, Alexander von Knorring, Alex Wells, Roman Zulak. (Listed
alphabetically; if we've left anybody out, it is inadvertent, please let us
know.)
Bidgolirad, Nicholas Bishop, Curtis Black, Rasmus Bonnedal, Solomon Boulos,
Stefan Bruens, Stefan Büttner, Matthaus G. Chajdas, Clark Chen, Alejandro
Conty, Damien Courtois, Dieter De Baets, Thomas Dinges, Daniel Dresser, Mads
Drøschler, Peter Ellerington, Luke Emrose, Louis Feng, Mark Final, Henri
Fousse, Stephen Friedman, Syoyo Fujita, Tim Grant, Larry Gritz, Nicolas
Guiard, Ole Gulbrandsen, Euan Haahr, Derek Haase, Sven-Hendrik Haase, John
Haddon, Niklas Harrysson, Daniel Heckenberg, Chris Hellmuth, Adrien Herubel,
Dan Horák, Thiago Ize, Matt Johnson, Ronan Keryell, Chris Kulla, Elvic Liang,
Max Liani, Adam Martinez, John Mertic, Bastien Montagne, Steena Monteiro, John
Mertic, Patrick Mours, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park,
Alexei Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick Scheibe,
Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip Shukla,
Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, Brecht
Van Lommel, Thibault Vergne, Alexander von Knorring, Aidan Welch, Alex Wells,
Roman Zulak. (Listed alphabetically; if we've left anybody out, it is
inadvertent, please let us know.)
We cannot possibly express sufficient gratitude to the managers at Sony
Pictures Imageworks who allowed this project to proceed, supported it
+24 -6
View File
@@ -12,12 +12,6 @@ In no particular order:
BSD 3-Clause License
SPDX-License-Identifier: BSD-3-Clause
* OpenImageIO Copyright (c) Larry Gritz, et al.
https://github.com/OpenImageIO/oiio
Many bits of code flow back and forth between OIIO and OSL, especially
parts of the CMake build system.
* OpenEXR, Copyright (c) Contributors to the OpenEXR Project.
https://github.com/AcademySoftwareFoundation/OpenEXR
@@ -107,6 +101,30 @@ Public domain
but of course I'd appreciate it if you kept my name somewhere.
-------------------------------------------------------------------------
Apache 2.0 License.
SPDX-License-Identifier: Apache-2.0
* OpenImageIO Copyright (c) Contributors to the OpenImageIO Project.
https://github.com/AcademySoftwareFoundation/OpenImageIO
Many bits of code flow back and forth between OIIO and OSL, especially
parts of the CMake build system.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-------------------------------------------------------------------------
Modified Apache 2.0 License
+3 -3
View File
@@ -1,7 +1,7 @@
#
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: Modified Apache 2.0 License
# Coyright Notice From Pixar USD (Modified Apache 2.0 License)
# Copyright Notice From Pixar USD (Modified Apache 2.0 License)
# 90% of the content is changed to be compatible for installing OSL and its dependencies
#
# Based on USD build_scripts by Pixar Animation Studio
@@ -1331,8 +1331,8 @@ OPENVDB = Dependency("OpenVDB", InstallOpenVDB, "include/openvdb/openvdb.h")
############################################################
# OpenImageIO
# OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/Release-2.2.7.0.zip"
OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/Release-2.1.20.0.zip"
# OIIO_URL = "https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/Release-2.2.7.0.zip"
OIIO_URL = "https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/Release-2.1.20.0.zip"
def InstallOpenImageIO(context, force, buildArgs):
+4
View File
@@ -19,6 +19,7 @@ OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_SOURCE_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build}
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENCOLORIO_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE:=Release}
OPENCOLORIO_CXX=${OPENCOLORIO_CXX:=g++}
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
# Just need libs:
OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
@@ -43,9 +44,12 @@ cd ${OPENCOLORIO_SOURCE_DIR}
echo "git checkout ${OPENCOLORIO_VERSION} --force"
git checkout ${OPENCOLORIO_VERSION} --force
echo "Building OpenColorIO from commit" `git rev-parse --short HEAD`
time cmake -S . -B ${OPENCOLORIO_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${OPENCOLORIO_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
-DCMAKE_CXX_COMPILER=${OPENCOLORIO_CXX} \
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS}
time cmake --build ${OPENCOLORIO_BUILD_DIR} --config Release --target install
+1
View File
@@ -40,6 +40,7 @@ mkdir -p ${OPENEXR_INSTALL_DIR} && true
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force
echo "Building OpenEXR from commit" `git rev-parse --short HEAD`
cmake -S . -B ${OPENEXR_BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
+2 -1
View File
@@ -9,7 +9,7 @@
# Exit the whole script if any command fails.
set -ex
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=OpenImageIO/oiio}
OPENIMAGEIO_REPO=${OPENIMAGEIO_REPO:=AcademySoftwareFoundation/OpenImageIO}
OPENIMAGEIO_VERSION=${OPENIMAGEIO_VERSION:=release}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENIMAGEIO_SRCDIR=${OPENIMAGEIO_SRCDIR:=${LOCAL_DEPS_DIR}/OpenImageIO}
@@ -32,6 +32,7 @@ mkdir -p ${OPENIMAGEIO_BUILD_DIR} && true
pushd $OPENIMAGEIO_SRCDIR
git fetch --all -p
git checkout $OPENIMAGEIO_VERSION --force
echo "Building OpenImageIO from commit" `git rev-parse --short HEAD`
if [[ "$USE_SIMD" != "" ]] ; then
OPENIMAGEIO_CMAKE_FLAGS="$OPENIMAGEIO_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
+1
View File
@@ -37,6 +37,7 @@ cd ${PUGIXML_SRC_DIR}
echo "git checkout ${PUGIXML_VERSION} --force"
git checkout ${PUGIXML_VERSION} --force
echo "Building pugixml from commit" `git rev-parse --short HEAD`
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${PUGIXML_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release \
+1
View File
@@ -41,6 +41,7 @@ cd ${PYBIND11_SRC_DIR}
echo "git checkout ${PYBIND11_VERSION} --force"
git checkout ${PYBIND11_VERSION} --force
echo "Building pybind11 from commit" `git rev-parse --short HEAD`
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -S . -B ${PYBIND11_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release \
+22 -5
View File
@@ -39,11 +39,6 @@ export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD:=11}
export PARALLEL=${PARALLEL:=4}
export PAR_MAKEFLAGS=-j${PARALLEL}
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:=${PARALLEL}}
export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:=${PARALLEL}}
export LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=$HOME/ext}
export CMAKE_PREFIX_PATH=${LOCAL_DEPS_DIR}/dist:${CMAKE_PREFIX_PATH}
export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$LD_LIBRARY_PATH
@@ -52,6 +47,28 @@ export DYLD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$DYLD_LIBRARY_PATH
export TESTSUITE_CLEANUP_ON_SUCCESS=${TESTSUITE_CLEANUP_ON_SUCCESS:=1}
# For CI, default to building missing dependencies automatically
export OpenImageIO_BUILD_MISSING_DEPS=${OpenImageIO_BUILD_MISSING_DEPS:=all}
# Parallel builds
if [[ `uname -s` == "Linux" ]] ; then
echo "procs: " `nproc`
head -40 /proc/cpuinfo
export PARALLEL=${PARALLEL:=$((2 + `nproc`))}
elif [[ "${RUNNER_OS}" == "macOS" ]] ; then
echo "procs: " `sysctl -n hw.ncpu`
sysctl machdep.cpu.features
export PARALLEL=${PARALLEL:=$((2 + `sysctl -n hw.ncpu`))}
elif [[ "${RUNNER_OS}" == "Windows" ]] ; then
# Presumably Windows
export PARALLEL=${PARALLEL:=$((2 + ${NUMBER_OF_PROCESSORS}))}
else
export PARALLEL=${PARALLEL:=6}
fi
export PAR_MAKEFLAGS=-j${PARALLEL}
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:=${PARALLEL}}
export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:=${PARALLEL}}
mkdir -p build dist
echo "HOME = $HOME"
+8 -1
View File
@@ -12,12 +12,19 @@ set -ex
# Install system packages when those are acceptable for dependencies.
#
if [[ "$ASWF_ORG" != "" ]] ; then
# Using ASWF CentOS container
# Using ASWF container
export PATH=/opt/rh/devtoolset-6/root/usr/bin:/usr/local/bin:$PATH
#ls /etc/yum.repos.d
if [[ "$ASWF_VFXPLATFORM_VERSION" == "2021" || "$ASWF_VFXPLATFORM_VERSION" == "2022" ]] ; then
# CentOS 7 based containers need the now-nonexistant centos repo to be
# excluded or all the subsequent yum install commands will fail.
yum-config-manager --disable centos-sclo-rh && true
sed -i 's,^mirrorlist=,#,; s,^#baseurl=http://mirror\.centos\.org/centos/$releasever,baseurl=https://vault.centos.org/7.9.2009,' /etc/yum.repos.d/CentOS-Base.repo
fi
sudo /usr/bin/yum install -y giflib giflib-devel && true
# sudo /usr/bin/yum install -y ffmpeg ffmpeg-devel && true
+18 -20
View File
@@ -19,9 +19,9 @@ if [[ `which brew` == "" ]] ; then
exit 1
fi
set -ex
# set -ex
if [[ "$DO_BREW_UPDATE" != "" ]] ; then
if [[ "${DO_BREW_UPDATE:=0}" != "0" ]] ; then
brew update >/dev/null
fi
echo ""
@@ -31,42 +31,40 @@ 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.8 || true
# brew unlink python@3.9 || true
brew unlink python@3.10 || true
brew link --overwrite --force python@${PYTHON_VERSION} || true
brew upgrade --display-times -q cmake || true
brew install --display-times -q imath openexr
#brew upgrade --display-times -q cmake || true
brew install --display-times -q imath openexr opencolorio || true
#brew install --display-times -q freetype
brew install --display-times -q --overwrite --force opencolorio || true
brew install --display-times -q partio pugixml
brew install --display-times -q partio pugixml || true
brew install --display-times -q pybind11 numpy || true
brew install --display-times -q tbb || true
brew install --display-times -q openvdb || true
brew install --display-times -q flex bison
brew install --display-times -q fmt
brew install --display-times -q llvm${LLVMBREWVER}
brew install --display-times -q qt${QT_BREW_VERSION}
if [[ "${USE_QT}" != "0" ]] ; then
brew install --display-times -q qt${QT_VERSION}
fi
echo ""
echo "After brew installs:"
brew list --versions
# Needed on some systems
if [[ $PYTHON_VERSION != "2.7" ]] ; then
pip3 install numpy
else
pip install numpy
fi
pip${PYTHON_VERSION} install numpy || true
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export PATH=/usr/local/opt/qt5/bin:$PATH
export PATH=/usr/local/opt/python/libexec/bin:$PATH
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
# export PATH=/usr/local/opt/llvm${LLVMBREWVER}/bin:$PATH
export LLVM_DIRECTORY=/usr/local/opt/llvm${LLVMBREWVER}
export LLVM_ROOT=/usr/local/opt/llvm${LLVMBREWVER}
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH
export PATH=${HOMEBREW_PREFIX}/opt/qt5/bin:$PATH
export PATH=${HOMEBREW_PREFIX}/opt/python/libexec/bin:$PATH
export PYTHONPATH=${HOMEBREW_PREFIX}/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
# export PATH=${HOMEBREW_PREFIX}/opt/llvm${LLVMBREWVER}/bin:$PATH
export LLVM_DIRECTORY=${HOMEBREW_PREFIX}/opt/llvm${LLVMBREWVER}
export LLVM_ROOT=${HOMEBREW_PREFIX}/opt/llvm${LLVMBREWVER}
export PATH=${HOMEBREW_PREFIX}/opt/flex/bin:${HOMEBREW_PREFIX}/opt/bison/bin:$PATH
# Save the env for use by other stages
src/build-scripts/save-env.bash
+1
View File
@@ -1,3 +1,4 @@
# Small leaks that make CI fail, suppress until cause is identified.
leak:__cxa_thread_atexit
leak:std::string::_Rep::_S_create
leak:tsl::detail_robin_hash::robin_hash
+4
View File
@@ -59,13 +59,17 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
set (CMAKE_CXX_COMPILER_ID "AppleClang")
set (CMAKE_COMPILER_IS_APPLECLANG 1)
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" APPLECLANG_VERSION_STRING ${clang_full_version_string})
set (ANY_CLANG_VERSION_STRING ${APPLECLANG_VERSION_STRING})
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
set (CMAKE_COMPILER_IS_INTELCLANG 1)
string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string})
set (ANY_CLANG_VERSION_STRING ${INTELCLANG_VERSION_STRING})
message (VERBOSE "The compiler is Intel Clang: ${CMAKE_CXX_COMPILER_ID} version ${INTELCLANG_VERSION_STRING}")
else ()
set (CMAKE_COMPILER_IS_GENERICCLANG 1)
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
set (ANY_CLANG_VERSION_STRING ${CLANG_VERSION_STRING})
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}")
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+14 -2
View File
@@ -51,7 +51,9 @@ function ( NVCC_COMPILE cuda_src extra_headers ptx_generated extra_nvcc_args )
${LLVM_COMPILE_FLAGS}
-DOSL_USE_FAST_MATH=1
-m64 -arch ${CUDA_TARGET_ARCH} -ptx
--std=c++14 -dc --use_fast_math ${CUDA_OPT_FLAG_NVCC} ${NVCC_FTZ_FLAG} --expt-relaxed-constexpr
--std=c++${CMAKE_CXX_STANDARD}
-dc --use_fast_math ${CUDA_OPT_FLAG_NVCC} ${NVCC_FTZ_FLAG}
--expt-relaxed-constexpr
${extra_nvcc_args}
${OSL_EXTRA_NVCC_ARGS}
${cuda_src} -o ${cuda_ptx}
@@ -138,6 +140,16 @@ function ( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )
set (CLANG_FTZ_FLAG "-fcuda-flush-denormals-to-zero")
endif ()
if ("${CUDA_VERSION}" VERSION_GREATER_EQUAL "12.0")
# The textureReference API was removed in CUDA 12.0, but it's still referenced
# in the clang headers, so compilation will fail with 12.0 and newer toolkits
# due to the missing definitions.
#
# We don't actually require any of the clang CUDA texture intrinsics, so we can
# side-step the issue by preventing them from being included by the preprocessor.
set (CUDA_TEXREF_FIX "-D__CLANG_CUDA_TEXTURE_INTRINSICS_H__")
endif()
list (TRANSFORM IMATH_INCLUDES PREPEND -I
OUTPUT_VARIABLE ALL_IMATH_INCLUDES)
list (TRANSFORM OPENEXR_INCLUDES PREPEND -I
@@ -158,7 +170,7 @@ 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} ${CLANG_MSVC_FIX}
${LLVM_COMPILE_FLAGS} ${CUDA_LIB_FLAGS} ${CLANG_MSVC_FIX} ${CUDA_TEXREF_FIX}
-D__CUDACC__ -DOSL_COMPILING_TO_BITCODE=1 -DNDEBUG -DOIIO_NO_SSE -D__CUDADEVRT_INTERNAL__
--language=cuda --cuda-device-only --cuda-gpu-arch=${CUDA_TARGET_ARCH}
-Wno-deprecated-register -Wno-format-security
+5 -5
View File
@@ -117,7 +117,7 @@ checked_find_package (pugixml REQUIRED
# LLVM library setup
checked_find_package (LLVM REQUIRED
VERSION_MIN 9.0
VERSION_MAX 17.9
VERSION_MAX 18.9
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
@@ -139,9 +139,8 @@ if (APPLE AND LLVM_VERSION VERSION_EQUAL 10.0.1 AND EXISTS "/usr/local/Cellar/ll
" 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)))
if (LLVM_VERSION VERSION_GREATER_EQUAL 15.0 AND CMAKE_COMPILER_IS_CLANG
AND ANY_CLANG_VERSION_STRING VERSION_LESS 15.0)
message (WARNING
"${ColorYellow}"
"If you are using LLVM 15 or higher, you should also use clang version "
@@ -155,7 +154,8 @@ if (LLVM_VERSION VERSION_GREATER_EQUAL 16.0)
if (CMAKE_COMPILER_IS_GNUCC AND (GCC_VERSION VERSION_LESS 7.0))
message (WARNING "${ColorYellow}LLVM 16+ requires gcc 7.0 or higher.${ColorReset}\n")
endif ()
if (CMAKE_COMPILER_IS_CLANG AND (CLANG_VERSION_STRING VERSION_LESS 5.0))
if (CMAKE_COMPILER_IS_CLANG AND (CLANG_VERSION_STRING VERSION_LESS 5.0
OR APPLE_CLANG_VERSION_STRING VERSION_LESS 5.0))
message (WARNING "${ColorYellow}LLVM 16+ requires clang 5.0 or higher.${ColorReset}\n")
endif ()
endif ()
+8 -3
View File
@@ -21,9 +21,14 @@
# MacOS/xcode in /usr/bin, which seems to be too old for the reentrant
# parser directives we use. Only do this if there is no BISON_ROOT
# specifying a particular Bison to use.
if (APPLE AND EXISTS /usr/local/opt
AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT})
find_program(BISON_EXECUTABLE NAMES /usr/local/opt/bison/bin/bison
if (APPLE AND NOT BISON_ROOT AND NOT DEFINED ENV{BISON_ROOT}
AND (EXISTS /usr/local/opt OR EXISTS /opt/homebrew
OR DEFINED ENV{HOMEBREW_PREFIX}))
find_program(BISON_EXECUTABLE
NAMES
ENV{HOMEBREW_PREFIX}/opt/bison/bin/bison
/opt/homebrew/opt/bison/bin/bison
/usr/local/opt/bison/bin/bison
DOC "path to the bison executable")
endif()
+1 -1
View File
@@ -128,7 +128,7 @@ endif ()
foreach (COMPONENT clangFrontend clangDriver clangSerialization
clangParse clangSema clangAnalysis clangAST
clangASTMatchers clangBasic clangEdit clangLex
clangSupport)
clangSupport clangAPINotes)
find_library ( _CLANG_${COMPONENT}_LIBRARY
NAMES ${COMPONENT}
PATHS ${LLVM_LIB_DIR})
+1
View File
@@ -289,6 +289,7 @@ macro (osl_add_all_tests)
metadata-braces min-reg miscmath missing-shader
mix-reg
named-components
nestedloop-reg
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
noise-gabor-reg
+9 -2
View File
@@ -67,7 +67,7 @@ Editor: Larry Gritz \\
\emph{lg@imageworks.com}
}
\date{{\large Date: 27 Oct 2023 \\
% (with corrections, 24 Nov 2021)
(with corrections, 24 May 2024)
}
\bigskip
\bigskip
@@ -4640,7 +4640,7 @@ properties of the physically-based shading nodes of MaterialX v1.38
\subsection{Surface BSDF closures}
\apiitem{\closurecolor\ {\ce oren_nayar_diffuse_bsdf}(normal N, color albedo, float roughness)}
\apiitem{\closurecolor\ {\ce oren_nayar_diffuse_bsdf}(normal N, color albedo, float roughness, int energy_compensation=0)}
\indexapi{oren_nayar_diffuse_bsdf()}
Constructs a diffuse reflection BSDF based on the Oren-Nayar reflectance
@@ -4671,10 +4671,17 @@ model.
% Optional string parameter to name this component. For use in AOVs / LPEs.
% \apiend
\apiitem{energy_compensation}
\vspace{12pt}
Optional int parameter to select if energy compensation should be applied.
\apiend
The Oren-Nayar reflection model is described in M.\ Oren and S.\ K.\
Nayar, ``Generalization of Lambert's Reflectance Model,'' Proceedings of
SIGGRAPH 1994, pp.239-246 (July, 1994).
The energy compensated model is described in the white paper: ``An energy-preserving Qualitative Oren-Nayar model'' by Jamie Portsmouth.
\apiend
+5 -1
View File
@@ -1266,7 +1266,7 @@ properties of the physically-based shading nodes of MaterialX v1.38
### Surface BSDF closures
`closure color` **`oren_nayar_diffuse_bsdf`** `(normal N, color albedo, float roughness)`
`closure color` **`oren_nayar_diffuse_bsdf`** `(normal N, color albedo, float roughness, int energy_compensation=0)`
: Constructs a diffuse reflection BSDF based on the Oren-Nayar reflectance
model.
@@ -1282,10 +1282,14 @@ properties of the physically-based shading nodes of MaterialX v1.38
`roughness`
: Surface roughness [0,1]. A value of 0.0 gives Lambertian reflectance.
`energy_compensation`
: Optional int parameter to select if energy compensation should be applied.
The Oren-Nayar reflection model is described in M. Oren and S. K.
Nayar, "Generalization of Lambert's Reflectance Model," Proceedings of
SIGGRAPH 1994, pp.239-246 (July, 1994).
The energy compensated model is described in the white paper: "An energy-preserving Qualitative Oren-Nayar model" by Jamie Portsmouth.
`closure color` **`burley_diffuse_bsdf`** `(normal N, color albedo, float roughness)`
+3 -5
View File
@@ -219,7 +219,7 @@ public:
void* errormessage, Mask<WidthT> mask)
: m_result(result)
, m_resultHasDerivs(resultHasDerivs)
, m_resultType((chans == 1) ? TypeDesc::TypeFloat : TypeDesc::TypeColor)
, m_resultType((chans == 1) ? TypeFloat : TypeColor)
, m_alpha(alpha)
, m_alphaHasDerivs(alphaHasDerivs)
, m_errormessage(errormessage)
@@ -240,15 +240,13 @@ public:
// 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);
return MaskedData<WidthT>(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);
return MaskedData<WidthT>(TypeString, false, m_mask, m_errormessage);
}
private:
+5 -20
View File
@@ -32,36 +32,21 @@ public:
#ifdef __CUDA_ARCH__
/// On device, act as a pointer. None of these things are allowed on the
/// host.
T* operator->() const
{
return m_ptr;
}
T& operator*() const
{
return *m_ptr;
}
T* operator->() const { return m_ptr; }
T& operator*() const { return *m_ptr; }
#endif
/// Extract the raw device-side pointer. Use with caution! On the host,
/// this will not point to valid memory.
T* d_get() const
{
return m_ptr;
}
T* d_get() const { return m_ptr; }
/// Evaluate as bool is a null pointer check.
operator bool() const noexcept
{
return m_ptr != nullptr;
}
operator bool() const noexcept { return m_ptr != nullptr; }
/// Reset the pointer to `dptr`, which must be a device-side raw pointer,
/// or null. Since this device_ptr is non-owning, any previous value is
/// simply overwritten.
void reset(T* dptr = nullptr)
{
m_ptr = dptr;
}
void reset(T* dptr = nullptr) { m_ptr = dptr; }
private:
T* m_ptr = nullptr; // underlying pointer, initializes to null
+2 -8
View File
@@ -53,10 +53,7 @@ struct DeviceString {
// 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;
}
OSL_HOSTDEVICE const char* c_str() const { return m_chars; }
#endif
OSL_HOSTDEVICE bool operator==(const DeviceString& other) const
@@ -81,10 +78,7 @@ struct DeviceString {
return hash() != other;
}
OSL_HOSTDEVICE operator size_t() const
{
return hash();
}
OSL_HOSTDEVICE operator size_t() const { return hash(); }
#endif
};
+37 -37
View File
@@ -130,12 +130,12 @@ public:
// To better enable Scalar Replacement of Aggregates and other
// transformations, CLANG has easier time if the per element
// constructors declared.
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage() {}
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage(const T & val, const T & dx)
OSL_HOSTDEVICE constexpr DualStorage() {}
OSL_HOSTDEVICE constexpr DualStorage(const T & val, const T & dx)
: m_val(val)
, m_dx(dx)
{}
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage(const DualStorage &other)
OSL_HOSTDEVICE constexpr DualStorage(const DualStorage &other)
: m_val(other.m_val)
, m_dx(other.m_dx)
{}
@@ -159,13 +159,13 @@ public:
// To better enable Scalar Replacement of Aggregates and other
// transformations, CLANG has easier time if the per element
// constructors declared.
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage() {}
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage(const T & val, const T & dx, const T & dy)
OSL_HOSTDEVICE constexpr DualStorage() {}
OSL_HOSTDEVICE constexpr DualStorage(const T & val, const T & dx, const T & dy)
: m_val(val)
, m_dx(dx)
, m_dy(dy)
{}
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage(const DualStorage &other)
OSL_HOSTDEVICE constexpr DualStorage(const DualStorage &other)
: m_val(other.m_val)
, m_dx(other.m_dx)
, m_dy(other.m_dy)
@@ -192,15 +192,15 @@ public:
// To better enable Scalar Replacement of Aggregates and other
// transformations, CLANG has easier time if the per element
// constructors declared.
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage() {}
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage(const T & val, const T & dx, const T & dy, const T & dz)
OSL_HOSTDEVICE constexpr DualStorage() {}
OSL_HOSTDEVICE constexpr DualStorage(const T & val, const T & dx, const T & dy, const T & dz)
: m_val(val)
, m_dx(dx)
, m_dy(dy)
, m_dz(dz)
{}
OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage(const DualStorage &other)
OSL_HOSTDEVICE constexpr DualStorage(const DualStorage &other)
: m_val(other.m_val)
, m_dx(other.m_dx)
, m_dy(other.m_dy)
@@ -230,7 +230,7 @@ class Dual : public DualStorage<T, PARTIALS> {
static_assert (PARTIALS>=1, "Can't have a Dual with 0 partials");
public:
using value_type = T;
static OSL_FORCEINLINE OSL_HOSTDEVICE OSL_CONSTEXPR14 T zero() { return T(0.0); }
static OSL_FORCEINLINE OSL_HOSTDEVICE constexpr T zero() { return T(0.0); }
using DualStorage<T, PARTIALS>::elem;
template<int N>
@@ -240,13 +240,13 @@ public:
/// Default ctr leaves everything uninitialized
///
OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual ()
OSL_HOSTDEVICE constexpr Dual ()
: DualStorage<T, PARTIALS>()
{}
/// Construct a Dual from just a real value (derivs set to 0)
///
OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const T &x)
OSL_HOSTDEVICE constexpr Dual (const T &x)
: DualStorage<T, PARTIALS>()
{
val() = x;
@@ -258,7 +258,7 @@ public:
/// Copy constructor from another Dual of same dimension and different,
/// but castable, data type.
template<class F>
OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const Dual<F,PARTIALS> &x)
OSL_HOSTDEVICE constexpr Dual (const Dual<F,PARTIALS> &x)
: DualStorage<T, PARTIALS>()
{
OSL_INDEX_LOOP(i, elements, {
@@ -266,8 +266,8 @@ public:
});
}
//OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const Dual &x) = default;
OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const Dual &x)
//OSL_HOSTDEVICE constexpr Dual (const Dual &x) = default;
OSL_HOSTDEVICE constexpr Dual (const Dual &x)
: DualStorage<T, PARTIALS>(x)
{}
@@ -297,7 +297,7 @@ public:
set_expander(pvt::make_int_sequence<elements>(), values...);
}
OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (std::initializer_list<T> vals) {
OSL_HOSTDEVICE constexpr Dual (std::initializer_list<T> vals) {
#if OIIO_CPLUSPLUS_VERSION >= 14
static_assert (vals.size() == elements, "Wrong number of initializers");
#endif
@@ -401,7 +401,7 @@ template<class T> using Dual2 = Dual<T,2>;
/// Addition of duals.
///
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const Dual<T,P> &a, const Dual<T,P> &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator+ (const Dual<T,P> &a, const Dual<T,P> &b)
{
Dual<T,P> result = a;
OSL_INDEX_LOOP(i, P+1, {
@@ -412,7 +412,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const Dual<T
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const Dual<T,P> &a, const T &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator+ (const Dual<T,P> &a, const T &b)
{
Dual<T,P> result = a;
result.val() += b;
@@ -421,7 +421,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const Dual<T
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const T &a, const Dual<T,P> &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator+ (const T &a, const Dual<T,P> &b)
{
Dual<T,P> result = b;
result.val() += a;
@@ -450,7 +450,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P>& operator+= (Dual<T,P> &a, const T &b)
/// Subtraction of duals.
///
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T,P> &a, const Dual<T,P> &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator- (const Dual<T,P> &a, const Dual<T,P> &b)
{
Dual<T,P> result;
OSL_INDEX_LOOP(i, P+1, {
@@ -461,7 +461,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T,P> &a, const T &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator- (const Dual<T,P> &a, const T &b)
{
Dual<T,P> result = a;
result.val() -= b;
@@ -470,7 +470,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const T &a, const Dual<T,P> &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator- (const T &a, const Dual<T,P> &b)
{
Dual<T,P> result;
result.val() = a - b.val();
@@ -503,7 +503,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P>& operator-= (Dual<T,P> &a, const T &b)
/// Negation of duals.
///
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T,P> &a)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator- (const Dual<T,P> &a)
{
Dual<T,P> result;
OSL_INDEX_LOOP(i, P+1, {
@@ -516,7 +516,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T
/// Multiplication of duals. This will work for any Dual<T>*Dual<S>
/// where T*S is meaningful.
template<class T, int P, class S>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 auto
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr auto
operator* (const Dual<T,P> &a, const Dual<S,P> &b) -> Dual<decltype(a.val()*b.val()),P>
{
// Use the chain rule
@@ -533,7 +533,7 @@ operator* (const Dual<T,P> &a, const Dual<S,P> &b) -> Dual<decltype(a.val()*b.va
/// Dual<T> * S where T*S is meaningful.
template<class T, int P, class S,
DUAL_REQUIRES(is_Dual<S>::value == false)>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 auto
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr auto
operator* (const Dual<T,P> &a, const S &b) -> Dual<decltype(a.val()*b),P>
{
Dual<decltype(a.val()*b),P> result;
@@ -562,7 +562,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE const Dual<T,P>& operator*= (Dual<T,P> &a, const
/// Dual<T> * S where T*S is meaningful.
template<class T, int P, class S,
DUAL_REQUIRES(is_Dual<S>::value == false)>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 auto
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr auto
operator* (const S &b, const Dual<T,P> &a) -> Dual<decltype(a.val()*b),P>
{
return a*b;
@@ -573,7 +573,7 @@ operator* (const S &b, const Dual<T,P> &a) -> Dual<decltype(a.val()*b),P>
/// Division of duals.
///
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const Dual<T,P> &a, const Dual<T,P> &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator/ (const Dual<T,P> &a, const Dual<T,P> &b)
{
T bvalinv = T(1) / b.val();
T aval_bval = a.val() / b.val();
@@ -589,7 +589,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const Dual<T
/// Division of dual by scalar.
///
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const Dual<T,P> &a, const T &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator/ (const Dual<T,P> &a, const T &b)
{
T bvalinv = T(1) / b;
T aval_bval = a.val() / b;
@@ -605,7 +605,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const Dual<T
/// Division of scalar by dual.
///
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const T &aval, const Dual<T,P> &b)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator/ (const T &aval, const Dual<T,P> &b)
{
T bvalinv = T(1) / b.val();
T aval_bval = aval / b.val();
@@ -742,12 +742,12 @@ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr bool equalVal (const T &x, const Dual<T
/// equalAll is the same as equalVal generally, but for two Duals of the same
/// type, they also compare derivs.
template<class T>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 bool equalAll (const T &x, const T &y) {
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr bool equalAll (const T &x, const T &y) {
return equalVal(x, y);
}
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 bool equalAll (const Dual<T,P> &x, const Dual<T,P> &y) {
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr bool equalAll (const Dual<T,P> &x, const Dual<T,P> &y) {
bool r = true;
OSL_INDEX_LOOP(i, P+1, {
r &= (x.elem(i) == y.elem(i));
@@ -763,7 +763,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 bool equalAll (const Dual<T,P> &x
// function f(scalar), then the dual function F(<u,u'>) is defined as:
// F(<u,u'>) = < f(u), f'(u)*u' >
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P>
dualfunc (const Dual<T,P>& u, const T& f_val, const T& df_val)
{
Dual<T,P> result;
@@ -781,7 +781,7 @@ dualfunc (const Dual<T,P>& u, const T& f_val, const T& df_val)
// F(<u,u'>, <v,v'>) = < f(u,v), dfdu(u,v)u' + dfdv(u,v)v' >
// (from http://en.wikipedia.org/wiki/Automatic_differentiation)
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P>
dualfunc (const Dual<T,P>& u, const Dual<T,P>& v,
const T& f_val, const T& dfdu_val, const T& dfdv_val)
{
@@ -796,7 +796,7 @@ dualfunc (const Dual<T,P>& u, const Dual<T,P>& v,
// Helper for construction the result of a Dual function of three variables.
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P>
dualfunc (const Dual<T,P>& u, const Dual<T,P>& v, const Dual<T,P>& w,
const T& f_val, const T& dfdu_val, const T& dfdv_val, const T& dfdw_val)
{
@@ -815,7 +815,7 @@ dualfunc (const Dual<T,P>& u, const Dual<T,P>& v, const Dual<T,P>& w,
/// OIIO's fast_math.h fast_neg for a more full explanation of why this is
/// faster.
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> fast_neg (const Dual<T,P> &a)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> fast_neg (const Dual<T,P> &a)
{
Dual<T,P> result;
OSL_INDEX_LOOP(i, P+1, {
@@ -1210,7 +1210,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> fast_erfc(const Dual<T,P> &a)
// f(x) = sqrt(x), f'(x) = 1/(2*sqrt(x))
template<class T, int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> sqrt (const Dual<T,P> &a)
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> sqrt (const Dual<T,P> &a)
{
Dual<T,P> result;
if (OSL_LIKELY(a.val() > T(0))) {
@@ -1336,7 +1336,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> smoothstep (const Dual<T,P> &e0, const
#ifdef __CUDA_ARCH__
template<> inline OSL_HOSTDEVICE OSL_CONSTEXPR14 float3 Dual<float3, 2>::zero() {
template<> inline OSL_HOSTDEVICE constexpr float3 Dual<float3, 2>::zero() {
return float3{0.f, 0.f, 0.f};
}
#endif
+17 -17
View File
@@ -147,7 +147,7 @@ comp_x (const Vec3 &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Vec3::BaseType, P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Vec3::BaseType, P>
comp_x (const Dual<Vec3,P> &v)
{
Dual<Vec3::BaseType, P> result;
@@ -164,7 +164,7 @@ comp_y (const Vec3 &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Vec3::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Vec3::BaseType,P>
comp_y (const Dual<Vec3,P> &v)
{
Dual<Vec3::BaseType,P> result;
@@ -182,7 +182,7 @@ comp_z (const Vec3 &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Vec3::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Vec3::BaseType,P>
comp_z (const Dual<Vec3,P> &v)
{
Dual<Vec3::BaseType,P> result;
@@ -211,7 +211,7 @@ comp_z (const Color3 &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Color3::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Color3::BaseType,P>
comp_x (const Dual<Color3,P> &v)
{
Dual<Color3::BaseType, P> result;
@@ -222,7 +222,7 @@ comp_x (const Dual<Color3,P> &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Color3::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Color3::BaseType,P>
comp_y (const Dual<Color3,P> &v)
{
Dual<Color3::BaseType,P> result;
@@ -233,7 +233,7 @@ comp_y (const Dual<Color3,P> &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Color3::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Color3::BaseType,P>
comp_z (const Dual<Color3,P> &v)
{
Dual<Color3::BaseType,P> result;
@@ -252,7 +252,7 @@ comp_x (const Vec2 &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Vec2::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Vec2::BaseType,P>
comp_x (const Dual<Vec2,P> &v)
{
Dual<Vec2::BaseType,P> result;
@@ -270,7 +270,7 @@ comp_y (const Vec2 &v)
}
template<int P>
OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<Vec2::BaseType,P>
OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<Vec2::BaseType,P>
comp_y (const Dual<Vec2,P> &v)
{
Dual<Vec2::BaseType,P> result;
@@ -302,7 +302,7 @@ multMatrix (const Imath::Matrix33<T> &M, const Dual<Vec3,P> &src,
/// Multiply a row 3-vector (with derivatives) by a 3x3 matrix (no derivs).
///
template <class T, int P> OSL_HOSTDEVICE inline OSL_CONSTEXPR14
template <class T, int P> OSL_HOSTDEVICE inline constexpr
Dual<Vec3,P>
operator* (const Dual<Vec3,P> &src, const Imath::Matrix33<T> &M)
{
@@ -318,7 +318,7 @@ operator* (const Dual<Vec3,P> &src, const Imath::Matrix33<T> &M)
/// Multiply a row 3-vector (with derivatives) by a 3x3 matrix (no derivs).
///
template <class T, int P> OSL_HOSTDEVICE inline OSL_CONSTEXPR14
template <class T, int P> OSL_HOSTDEVICE inline constexpr
Dual<Color3,P>
operator* (const Dual<Color3,P> &src, const Imath::Matrix33<T> &M)
{
@@ -408,7 +408,7 @@ multiplyDirByMatrix (const Imath::Matrix44<S> &M,
}
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec3::BaseType, P>
OSL_HOSTDEVICE inline constexpr Dual<Vec3::BaseType, P>
dot (const Dual<Vec3,P> &a, const Dual<Vec3,P> &b)
{
auto ax = comp_x (a);
@@ -423,7 +423,7 @@ dot (const Dual<Vec3,P> &a, const Dual<Vec3,P> &b)
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec3::BaseType,P>
OSL_HOSTDEVICE inline constexpr Dual<Vec3::BaseType,P>
dot (const Dual<Vec3,P> &a, const Vec3 &b)
{
auto ax = comp_x (a);
@@ -438,7 +438,7 @@ dot (const Dual<Vec3,P> &a, const Vec3 &b)
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec3::BaseType,P>
OSL_HOSTDEVICE inline constexpr Dual<Vec3::BaseType,P>
dot (const Vec3 &a, const Dual<Vec3,P> &b)
{
return dot (b, a);
@@ -447,7 +447,7 @@ dot (const Vec3 &a, const Dual<Vec3,P> &b)
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec2::BaseType,P>
OSL_HOSTDEVICE inline constexpr Dual<Vec2::BaseType,P>
dot (const Dual<Vec2,P> &a, const Dual<Vec2,P> &b)
{
auto ax = comp_x (a);
@@ -460,7 +460,7 @@ dot (const Dual<Vec2,P> &a, const Dual<Vec2,P> &b)
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec2::BaseType,P>
OSL_HOSTDEVICE inline constexpr Dual<Vec2::BaseType,P>
dot (const Dual<Vec2,P> &a, const Vec2 &b)
{
auto ax = comp_x (a);
@@ -473,7 +473,7 @@ dot (const Dual<Vec2,P> &a, const Vec2 &b)
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec2::BaseType,P>
OSL_HOSTDEVICE inline constexpr Dual<Vec2::BaseType,P>
dot (const Vec2 &a, const Dual<Vec2,P> &b)
{
auto ax = comp_x (a);
@@ -504,7 +504,7 @@ cross (const Dual<Vec3,P> &a, const Dual<Vec3,P> &b)
template<int P>
OSL_HOSTDEVICE inline OSL_CONSTEXPR14 Dual<Vec3::BaseType,P>
OSL_HOSTDEVICE inline constexpr Dual<Vec3::BaseType,P>
length (const Dual<Vec3,P> &a)
{
auto ax = comp_x (a);
+10 -10
View File
@@ -24,15 +24,15 @@ struct ClosureParam {
#define fieldsize(st, fld) sizeof(((st *)0)->fld)
#define CLOSURE_INT_PARAM(st, fld) \
{ TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
{ TypeInt, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
#define CLOSURE_FLOAT_PARAM(st, fld) \
{ TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
{ TypeFloat, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
#define CLOSURE_COLOR_PARAM(st, fld) \
{ TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
{ TypeColor, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
#define CLOSURE_VECTOR_PARAM(st, fld) \
{ TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
{ TypeVector, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
#define CLOSURE_STRING_PARAM(st, fld) \
{ TypeDesc::TypeString, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
{ TypeString, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
#define CLOSURE_CLOSURE_PARAM(st, fld) \
{ TypeDesc::PTR, (int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
@@ -49,15 +49,15 @@ struct ClosureParam {
// NOTE: this keyword args have to be always at the end of the list
#define CLOSURE_INT_KEYPARAM(st, fld, key) \
{ TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
{ TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
#define CLOSURE_FLOAT_KEYPARAM(st, fld, key) \
{ TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
{ TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
#define CLOSURE_COLOR_KEYPARAM(st, fld, key) \
{ TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
{ TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
#define CLOSURE_VECTOR_KEYPARAM(st, fld, key) \
{ TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
{ TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
#define CLOSURE_STRING_KEYPARAM(st, fld, key) \
{ TypeDesc::TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
{ TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
#define CLOSURE_FINISH_PARAM(st) { TypeDesc(), sizeof(st), nullptr, alignof(st) }
+9 -36
View File
@@ -171,22 +171,13 @@ public:
}
OSL_FORCEINLINE ValueType value() const
{
return m_value;
}
OSL_FORCEINLINE ValueType value() const { return m_value; }
// count number of active bits
OSL_FORCEINLINE int count() const
{
return OSL::popcount(m_value);
}
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 int first_on() const { return OSL::countr_zero(m_value); }
OSL_FORCEINLINE Mask invert() const
{
@@ -239,10 +230,7 @@ public:
return (m_value != static_cast<ValueType>(0));
}
OSL_FORCEINLINE bool any_off() const
{
return (m_value < valid_bits);
}
OSL_FORCEINLINE bool any_off() const { return (m_value < valid_bits); }
OSL_FORCEINLINE bool any_off(const Mask& mask) const
{
@@ -257,39 +245,27 @@ public:
// 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(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_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(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 void set_all_off() { m_value = static_cast<ValueType>(0); }
OSL_FORCEINLINE bool operator==(const Mask& other) const
{
@@ -323,10 +299,7 @@ public:
return Mask(m_value | other.m_value);
}
OSL_FORCEINLINE Mask operator~() const
{
return invert();
}
OSL_FORCEINLINE Mask operator~() const { return invert(); }
template<int MinOccupancyT, int MaxOccupancyT = width, typename FunctorT>
+2 -8
View File
@@ -109,14 +109,8 @@ 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
+1 -1
View File
@@ -50,7 +50,7 @@
# ifdef OIIO_ERRORHANDLER_HIDE_PRINTF
# define OIIO_ERRORHANDLER_HIDE_PRINTF 1
# endif
# ifdef OIIO_HIDE_FORMAT
# ifndef OIIO_HIDE_FORMAT
# define OIIO_HIDE_FORMAT 1
# endif
#endif
+1 -1
View File
@@ -576,7 +576,7 @@ public:
// float blur = 0.001;
// ss->Parameter (*group, "blur", blur);
// Vec3 colorfilter (0.5f, 0.5f, 1.0f);
// ss->Parameter (*group, "colorfilter", TypeDesc::TypeColor,
// ss->Parameter (*group, "colorfilter", TypeColor,
// &colorfilter);
// ss->Shader ("surface", "texmap", "texturelayer");
// /* Second layer - generate the BSDF closure: */
+15 -15
View File
@@ -154,28 +154,28 @@ bitcast_to_uint (float x)
OSL_FORCEINLINE void
bjmix(vint4& a, vint4& b, vint4& c)
{
using OIIO::simd::rotl32;
a -= c; a ^= rotl32(c, 4); c += b;
b -= a; b ^= rotl32(a, 6); a += c;
c -= b; c ^= rotl32(b, 8); b += a;
a -= c; a ^= rotl32(c,16); c += b;
b -= a; b ^= rotl32(a,19); a += c;
c -= b; c ^= rotl32(b, 4); b += a;
using OIIO::simd::rotl;
a -= c; a ^= rotl(c, 4); c += b;
b -= a; b ^= rotl(a, 6); a += c;
c -= b; c ^= rotl(b, 8); b += a;
a -= c; a ^= rotl(c,16); c += b;
b -= a; b ^= rotl(a,19); a += c;
c -= b; c ^= rotl(b, 4); b += a;
}
// Perform a bjfinal (see OpenImageIO/hash.h) on 4 sets of values at once.
OSL_FORCEINLINE vint4
bjfinal(const vint4& a_, const vint4& b_, const vint4& c_)
{
using OIIO::simd::rotl32;
using OIIO::simd::rotl;
vint4 a(a_), b(b_), c(c_);
c ^= b; c -= rotl32(b,14);
a ^= c; a -= rotl32(c,11);
b ^= a; b -= rotl32(a,25);
c ^= b; c -= rotl32(b,16);
a ^= c; a -= rotl32(c,4);
b ^= a; b -= rotl32(a,14);
c ^= b; c -= rotl32(b,24);
c ^= b; c -= rotl(b,14);
a ^= c; a -= rotl(c,11);
b ^= a; b -= rotl(a,25);
c ^= b; c -= rotl(b,16);
a ^= c; a -= rotl(c,4);
b ^= a; b -= rotl(a,14);
c ^= b; c -= rotl(b,24);
return c;
}
#endif
+1 -2
View File
@@ -19,8 +19,7 @@ struct ShaderGlobals;
class ShaderGroup;
// Tags for polymorphic dispatch
template<int SimdWidthT> class WidthOf {
};
template<int SimdWidthT> class WidthOf {};
/// Opaque pointer to whatever the renderer uses to represent a
+13 -25
View File
@@ -299,16 +299,13 @@ public:
// Specializations
template<int WidthT>
struct Block<float, WidthT> : public BlockOfBuiltin<float, WidthT> {
};
struct Block<float, WidthT> : public BlockOfBuiltin<float, WidthT> {};
template<int WidthT>
struct Block<int, WidthT> : public BlockOfBuiltin<int, WidthT> {
};
struct Block<int, WidthT> : public BlockOfBuiltin<int, WidthT> {};
template<typename DataT, int WidthT>
struct Block<DataT*, WidthT> : public BlockOfBuiltin<DataT*, WidthT> {
};
struct Block<DataT*, WidthT> : public BlockOfBuiltin<DataT*, WidthT> {};
// Vec4 isn't used by external interfaces, but some internal
@@ -2283,15 +2280,9 @@ template<typename DataT, int WidthT> struct MaskedLaneProxy {
// visibility to end user whose IDE
// might display these methods vs. free
// functions
OSL_FORCEINLINE bool is_on() const
{
return m_mask.is_on(m_lane);
}
OSL_FORCEINLINE bool is_on() const { return m_mask.is_on(m_lane); }
OSL_FORCEINLINE bool is_off() const
{
return m_mask.is_off(m_lane);
}
OSL_FORCEINLINE bool is_off() const { return m_mask.is_off(m_lane); }
private:
Block<DataT, WidthT>& m_ref_wide_data;
@@ -2353,15 +2344,9 @@ struct MaskedArrayLaneProxy {
// visibility to end user whose IDE
// might display these methods vs. free
// functions
OSL_FORCEINLINE bool is_on() const
{
return m_mask.is_on(m_lane);
}
OSL_FORCEINLINE bool is_on() const { return m_mask.is_on(m_lane); }
OSL_FORCEINLINE bool is_off() const
{
return m_mask.is_off(m_lane);
}
OSL_FORCEINLINE bool is_off() const { return m_mask.is_off(m_lane); }
OSL_FORCEINLINE MaskedLaneProxy<DataT, WidthT>
operator[](int array_index) const
@@ -2726,7 +2711,8 @@ struct MaskedDeriv : public Masked<DataT, WidthT> {
template<typename FirstT, typename... ListT,
std::enable_if_t<std::is_same<typename std::decay<FirstT>::type,
MaskedDeriv>::value,
bool> = true>
bool>
= true>
OSL_FORCEINLINE MaskedDeriv(FirstT&& first, ListT&&... argList)
: Masked<DataT, WidthT>(std::forward<FirstT>(first),
std::forward<ListT>(argList)...)
@@ -2737,7 +2723,8 @@ struct MaskedDeriv : public Masked<DataT, WidthT> {
template<typename FirstT, typename... ListT,
std::enable_if_t<!std::is_same<typename std::decay<FirstT>::type,
MaskedDeriv>::value,
bool> = true>
bool>
= true>
OSL_FORCEINLINE MaskedDeriv(FirstT&& first, ListT&&... argList)
: Masked<DataT, WidthT>(std::forward<FirstT>(first),
std::forward<ListT>(argList)...,
@@ -3188,7 +3175,8 @@ template<typename DataT, int DerivIndexT> struct RefDeriv : public Ref<DataT> {
template<typename FirstT, typename... ListT,
std::enable_if_t<!std::is_same<typename std::decay<FirstT>::type,
RefDeriv>::value,
bool> = true>
bool>
= true>
explicit OSL_FORCEINLINE RefDeriv(FirstT&& first, ListT&&... argList)
: Ref<DataT>(std::forward<FirstT>(first),
std::forward<ListT>(argList)...,
+69 -267
View File
@@ -244,46 +244,25 @@ public:
// m_simple is always UNKNOWN for structures.
/// Is it a simple scalar int?
bool is_int() const
{
return m_simple == TypeDesc::TypeInt && !is_closure();
}
bool is_int() const { return m_simple == TypeInt && !is_closure(); }
/// Is it a simple scalar float?
bool is_float() const
{
return m_simple == TypeDesc::TypeFloat && !is_closure();
}
bool is_float() const { return m_simple == TypeFloat && !is_closure(); }
/// Is it a color?
bool is_color() const
{
return m_simple == TypeDesc::TypeColor && !is_closure();
}
bool is_color() const { return m_simple == TypeColor && !is_closure(); }
/// Is it a point?
bool is_point() const
{
return m_simple == TypeDesc::TypePoint && !is_closure();
}
bool is_point() const { return m_simple == TypePoint && !is_closure(); }
/// Is it a vector?
bool is_vector() const
{
return m_simple == TypeDesc::TypeVector && !is_closure();
}
bool is_vector() const { return m_simple == TypeVector && !is_closure(); }
/// Is it a normal?
bool is_normal() const
{
return m_simple == TypeDesc::TypeNormal && !is_closure();
}
bool is_normal() const { return m_simple == TypeNormal && !is_closure(); }
/// Is it a simple string?
bool is_string() const
{
return m_simple == TypeDesc::TypeString && !is_closure();
}
bool is_string() const { return m_simple == TypeString && !is_closure(); }
/// Is it a string or an array of strings?
///
@@ -357,9 +336,8 @@ public:
bool is_vectriple() const
{
return !is_closure()
&& (m_simple == TypeDesc::TypePoint
|| m_simple == TypeDesc::TypeVector
|| m_simple == TypeDesc::TypeNormal);
&& (m_simple == TypePoint || m_simple == TypeVector
|| m_simple == TypeNormal);
}
/// Is it based on a vector-like triple (point, vector, or normal)?
@@ -367,16 +345,12 @@ public:
bool is_vectriple_based() const
{
auto elem = m_simple.elementtype();
return (elem == TypeDesc::TypePoint || elem == TypeDesc::TypeVector
|| elem == TypeDesc::TypeNormal);
return (elem == TypePoint || elem == TypeVector || elem == TypeNormal);
}
/// Is it a simple matrix (but not an array or closure)?
///
bool is_matrix() const
{
return m_simple == TypeDesc::TypeMatrix && !is_closure();
}
bool is_matrix() const { return m_simple == TypeMatrix && !is_closure(); }
/// Is it a color closure?
///
@@ -647,133 +621,55 @@ public:
}
void dataoffset(int d)
{
m_dataoffset = d;
}
int dataoffset() const
{
return m_dataoffset;
}
void dataoffset(int d) { m_dataoffset = d; }
int dataoffset() const { return m_dataoffset; }
void wide_dataoffset(int d)
{
m_wide_dataoffset = d;
}
int wide_dataoffset() const
{
return m_wide_dataoffset;
}
void wide_dataoffset(int d) { m_wide_dataoffset = d; }
int wide_dataoffset() const { return m_wide_dataoffset; }
SymArena arena() const
{
return static_cast<SymArena>(m_arena);
}
SymArena arena() const { return static_cast<SymArena>(m_arena); }
void initializers(int d)
{
m_initializers = d;
}
int initializers() const
{
return m_initializers;
}
void initializers(int d) { m_initializers = d; }
int initializers() const { return m_initializers; }
bool has_derivs() const
{
return m_has_derivs;
}
void has_derivs(bool new_derivs)
{
m_has_derivs = new_derivs;
}
int size() const
{
return m_size;
}
void size(size_t newsize)
{
m_size = (int)newsize;
}
bool has_derivs() const { return m_has_derivs; }
void has_derivs(bool new_derivs) { m_has_derivs = new_derivs; }
int size() const { return m_size; }
void size(size_t newsize) { m_size = (int)newsize; }
/// Return the size for each point, including derivs.
///
int derivsize() const
{
return m_has_derivs ? 3 * m_size : m_size;
}
int derivsize() const { return m_has_derivs ? 3 * m_size : m_size; }
bool connected() const
{
return valuesource() == ConnectedVal;
}
bool connected_down() const
{
return m_connected_down;
}
void connected_down(bool c)
{
m_connected_down = c;
}
bool connected() const { return valuesource() == ConnectedVal; }
bool connected_down() const { return m_connected_down; }
void connected_down(bool c) { m_connected_down = c; }
/// Where did the symbol's value come from?
///
enum ValueSource { DefaultVal, InstanceVal, GeomVal, ConnectedVal };
ValueSource valuesource() const
{
return (ValueSource)m_valuesource;
}
void valuesource(ValueSource v)
{
m_valuesource = v;
}
ValueSource valuesource() const { return (ValueSource)m_valuesource; }
void valuesource(ValueSource v) { m_valuesource = v; }
const char* valuesourcename() const;
static const char* valuesourcename(ValueSource v);
int fieldid() const
{
return m_fieldid;
}
void fieldid(int id)
{
m_fieldid = id;
}
int fieldid() const { return m_fieldid; }
void fieldid(int id) { m_fieldid = id; }
int layer() const
{
return m_layer;
}
void layer(int id)
{
m_layer = id;
}
int layer() const { return m_layer; }
void layer(int id) { m_layer = id; }
int initbegin() const
{
return m_initbegin;
}
void initbegin(int i)
{
m_initbegin = i;
}
int initend() const
{
return m_initend;
}
void initend(int i)
{
m_initend = i;
}
int initbegin() const { return m_initbegin; }
void initbegin(int i) { m_initbegin = i; }
int initend() const { return m_initend; }
void initend(int i) { m_initend = i; }
void set_initrange(int b = 0, int e = 0)
{
m_initbegin = b;
m_initend = e;
}
bool has_init_ops() const
{
return m_initbegin != m_initend;
}
bool has_init_ops() const { return m_initbegin != m_initend; }
/// Clear read/write usage info.
///
@@ -817,42 +713,15 @@ public:
}
}
int firstread() const
{
return m_firstread;
}
int lastread() const
{
return m_lastread;
}
int firstwrite() const
{
return m_firstwrite;
}
int lastwrite() const
{
return m_lastwrite;
}
int firstuse() const
{
return std::min(firstread(), firstwrite());
}
int lastuse() const
{
return std::max(lastread(), lastwrite());
}
bool everread() const
{
return lastread() >= 0;
}
bool everwritten() const
{
return lastwrite() >= 0;
}
bool everused() const
{
return everread() || everwritten();
}
int firstread() const { return m_firstread; }
int lastread() const { return m_lastread; }
int firstwrite() const { return m_firstwrite; }
int lastwrite() const { return m_lastwrite; }
int firstuse() const { return std::min(firstread(), firstwrite()); }
int lastuse() const { return std::max(lastread(), lastwrite()); }
bool everread() const { return lastread() >= 0; }
bool everwritten() const { return lastwrite() >= 0; }
bool everused() const { return everread() || everwritten(); }
// everused_in_group is an even more stringent test -- not only must
// the symbol not be used within the shader but it also must not be
// used elsewhere in the group, by being connected to something downstream
@@ -873,14 +742,8 @@ public:
m_lastwrite = last;
}
bool initialized() const
{
return m_initialized;
}
void initialized(bool init)
{
m_initialized = init;
}
bool initialized() const { return m_initialized; }
void initialized(bool init) { m_initialized = init; }
bool lockgeom() const
{
@@ -889,76 +752,34 @@ public:
return !m_interpolated && !m_interactive;
}
bool interpolated() const
{
return m_interpolated;
}
void interpolated(bool val)
{
m_interpolated = val;
}
bool interpolated() const { return m_interpolated; }
void interpolated(bool val) { m_interpolated = val; }
bool interactive() const
{
return m_interactive;
}
void interactive(bool val)
{
m_interactive = val;
}
bool interactive() const { return m_interactive; }
void interactive(bool val) { m_interactive = val; }
bool noninteractive() const
{
return m_noninteractive;
}
void noninteractive(bool val)
{
m_noninteractive = val;
}
bool noninteractive() const { return m_noninteractive; }
void noninteractive(bool val) { m_noninteractive = val; }
bool allowconnect() const
{
return m_allowconnect;
}
void allowconnect(bool val)
{
m_allowconnect = val;
}
bool allowconnect() const { return m_allowconnect; }
void allowconnect(bool val) { m_allowconnect = val; }
int arraylen() const
{
return m_typespec.arraylength();
}
int arraylen() const { return m_typespec.arraylength(); }
void arraylen(int len)
{
m_typespec.make_array(len);
m_size = m_typespec.simpletype().size();
}
bool renderer_output() const
{
return m_renderer_output;
}
void renderer_output(bool v)
{
m_renderer_output = v;
}
bool renderer_output() const { return m_renderer_output; }
void renderer_output(bool v) { m_renderer_output = v; }
// When not uniform a symbol will have a varying value under batched
// execution and must use a Wide data type to hold different values
// for each data lane executing
bool is_uniform() const
{
return m_is_uniform;
}
bool is_varying() const
{
return (m_is_uniform == 0);
}
void make_varying()
{
m_is_uniform = false;
}
bool is_uniform() const { return m_is_uniform; }
bool is_varying() const { return (m_is_uniform == 0); }
void make_varying() { m_is_uniform = false; }
// Results of a compare_op and other ops with logically boolean
// results under certain conditions could be forced to be represented
@@ -972,32 +793,14 @@ public:
// 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.
bool forced_llvm_bool() const
{
return m_forced_llvm_bool;
}
void forced_llvm_bool(bool v)
{
m_forced_llvm_bool = v;
}
bool forced_llvm_bool() const { return m_forced_llvm_bool; }
void forced_llvm_bool(bool v) { m_forced_llvm_bool = v; }
bool readonly() const
{
return m_readonly;
}
void readonly(bool v)
{
m_readonly = v;
}
bool readonly() const { return m_readonly; }
void readonly(bool v) { m_readonly = v; }
bool is_constant() const
{
return symtype() == SymTypeConst;
}
bool is_temp() const
{
return symtype() == SymTypeTemp;
}
bool is_constant() const { return symtype() == SymTypeConst; }
bool is_temp() const { return symtype() == SymTypeTemp; }
// Retrieve the const float value (must be a const float!)
float get_float(int index = 0) const
@@ -1332,7 +1135,6 @@ OSL_NAMESPACE_EXIT
// Supply a fmtlib compatible custom formatter for TypeSpec.
#if FMT_VERSION >= 100000
FMT_BEGIN_NAMESPACE
template<> struct formatter<OSL::pvt::TypeSpec> : ostream_formatter {
};
template<> struct formatter<OSL::pvt::TypeSpec> : ostream_formatter {};
FMT_END_NAMESPACE
#endif
+3 -3
View File
@@ -1032,19 +1032,19 @@ public:
ASTliteral(OSLCompilerImpl* comp, int i)
: ASTNode(literal_node, comp), m_i(i)
{
m_typespec = TypeDesc::TypeInt;
m_typespec = TypeInt;
}
ASTliteral(OSLCompilerImpl* comp, float f)
: ASTNode(literal_node, comp), m_f(f)
{
m_typespec = TypeDesc::TypeFloat;
m_typespec = TypeFloat;
}
ASTliteral(OSLCompilerImpl* comp, ustring s)
: ASTNode(literal_node, comp), m_s(s)
{
m_typespec = TypeDesc::TypeString;
m_typespec = TypeString;
}
const char* nodetypename() const { return "literal"; }
+2 -2
View File
@@ -354,7 +354,7 @@ ASTNode::codegen_int(Symbol*, bool boolify, bool invert)
if (!type.is_int() || boolify || invert) {
// If they're not using an int as the condition, then it's an
// implied comparison to zero.
Symbol* tempvar = m_compiler->make_temporary(TypeDesc::TypeInt);
Symbol* tempvar = m_compiler->make_temporary(TypeInt);
Symbol* zerovar = NULL;
if (type.is_closure())
zerovar = m_compiler->make_constant((int)0);
@@ -1543,7 +1543,7 @@ ASTbinary_expression::codegen(Symbol* dest)
if (m_op == Mul || m_op == Div) {
// Need to coerce the weight into a color.
// N.B. The typecheck always reorders c=k*c into c=c*k.
rsym = coerce(rsym, TypeDesc::TypeColor, true);
rsym = coerce(rsym, TypeColor, true);
}
emitcode(opword(), dest, lsym, rsym);
return dest;
+15 -16
View File
@@ -26,7 +26,11 @@
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <clang/Frontend/Utils.h>
#include <clang/Lex/PreprocessorOptions.h>
#include <llvm/Support/Host.h>
#if OSL_LLVM_VERSION < 160
# include <llvm/Support/Host.h>
#else
# include <llvm/TargetParser/Host.h>
#endif
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/ToolOutputFile.h>
#include <llvm/Support/raw_ostream.h>
@@ -628,20 +632,15 @@ struct GlobalTable {
void
OSLCompilerImpl::initialize_globals()
{
static GlobalTable globals[]
= { { "P", TypeDesc::TypePoint, false },
{ "I", TypeDesc::TypeVector, false },
{ "N", TypeDesc::TypeNormal, false },
{ "Ng", TypeDesc::TypeNormal },
{ "u", TypeDesc::TypeFloat },
{ "v", TypeDesc::TypeFloat },
{ "dPdu", TypeDesc::TypeVector },
{ "dPdv", TypeDesc::TypeVector },
{ "Ps", TypeDesc::TypePoint },
{ "Ci", TypeSpec(TypeDesc::TypeColor, true), false },
{ "time", TypeDesc::TypeFloat },
{ "dtime", TypeDesc::TypeFloat },
{ "dPdtime", TypeDesc::TypeVector } };
static GlobalTable globals[] = {
{ "P", TypePoint, false }, { "I", TypeVector, false },
{ "N", TypeNormal, false }, { "Ng", TypeNormal },
{ "u", TypeFloat }, { "v", TypeFloat },
{ "dPdu", TypeVector }, { "dPdv", TypeVector },
{ "Ps", TypePoint }, { "Ci", TypeSpec(TypeColor, true), false },
{ "time", TypeFloat }, { "dtime", TypeFloat },
{ "dPdtime", TypeVector }
};
for (auto& g : globals) {
Symbol* s = new Symbol(ustring(g.name), g.type, SymTypeGlobal);
@@ -702,7 +701,7 @@ OSLCompilerImpl::write_oso_const_value(const ConstantSymbol* sym) const
else if (elemtype == TypeDesc::FLOAT)
for (int i = 0; i < nelements; ++i)
osofmt("{:.9g}{}", sym->floatval(i), nelements > 1 ? " " : "");
else if (equivalent(elemtype, TypeDesc::TypeVector))
else if (equivalent(elemtype, TypeVector))
for (int i = 0; i < nelements; ++i) {
Vec3 v = sym->get_vec3(i);
osofmt("{:.9g} {:.9g} {:.9g}{}", v.x, v.y, v.z,
+8 -8
View File
@@ -1110,14 +1110,14 @@ inline TypeDesc
OSL::pvt::osllextype (int lex)
{
switch (lex) {
case COLORTYPE : return TypeDesc::TypeColor;
case FLOATTYPE : return TypeDesc::TypeFloat;
case INTTYPE : return TypeDesc::TypeInt;
case MATRIXTYPE : return TypeDesc::TypeMatrix;
case NORMALTYPE : return TypeDesc::TypeNormal;
case POINTTYPE : return TypeDesc::TypePoint;
case STRINGTYPE : return TypeDesc::TypeString;
case VECTORTYPE : return TypeDesc::TypeVector;
case COLORTYPE : return TypeColor;
case FLOATTYPE : return TypeFloat;
case INTTYPE : return TypeInt;
case MATRIXTYPE : return TypeMatrix;
case NORMALTYPE : return TypeNormal;
case POINTTYPE : return TypePoint;
case STRINGTYPE : return TypeString;
case VECTORTYPE : return TypeVector;
case VOIDTYPE : return TypeDesc::NONE;
default: return TypeDesc::UNKNOWN;
}
+4 -7
View File
@@ -114,20 +114,17 @@ private:
/// the parent class to properly free it upon destruction.
class ConstantSymbol final : public Symbol {
public:
ConstantSymbol(ustring n, ustring val)
: Symbol(n, TypeDesc::TypeString, SymTypeConst)
ConstantSymbol(ustring n, ustring val) : Symbol(n, TypeString, SymTypeConst)
{
m_val.s = val.c_str();
set_dataptr(SymArena::Absolute, &m_val.s);
}
ConstantSymbol(ustring n, int val)
: Symbol(n, TypeDesc::TypeInt, SymTypeConst)
ConstantSymbol(ustring n, int val) : Symbol(n, TypeInt, SymTypeConst)
{
m_val.i = val;
set_dataptr(SymArena::Absolute, &m_val.i);
}
ConstantSymbol(ustring n, float val)
: Symbol(n, TypeDesc::TypeFloat, SymTypeConst)
ConstantSymbol(ustring n, float val) : Symbol(n, TypeFloat, SymTypeConst)
{
m_val.f = val;
set_dataptr(SymArena::Absolute, &m_val.f);
@@ -148,7 +145,7 @@ public:
set_dataptr(SymArena::Absolute, &m_val.i);
else if (type == TypeDesc::STRING)
set_dataptr(SymArena::Absolute, &m_val.s);
else if (equivalent(type, TypeDesc::TypeVector))
else if (equivalent(type, TypeVector))
set_dataptr(SymArena::Absolute, &m_val.v);
else {
OSL_DASSERT(arena() == SymArena::Unknown);
+37 -37
View File
@@ -426,7 +426,7 @@ ASTunary_expression::typecheck(TypeSpec expected)
m_typespec = t;
break;
case Not:
m_typespec = TypeDesc::TypeInt; // ! is always an int
m_typespec = TypeInt; // ! is always an int
break;
case Compl:
if (!t.is_int()) {
@@ -515,7 +515,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
if (m_op == And || m_op == Or) {
// Logical ops work can work on closures (since they test
// for nonemptiness, but always return int.
return m_typespec = TypeDesc::TypeInt;
return m_typespec = TypeInt;
}
// If we got this far, it's an op that's not allowed
errorfmt("Not allowed: '{} {} {}'", l, opname(), r);
@@ -538,10 +538,10 @@ ASTbinary_expression::typecheck(TypeSpec expected)
if (equivalent(l, r)) {
// handle a few couple special cases
if (m_op == Sub && l.is_point() && r.is_point()) // p-p == v
return m_typespec = TypeDesc::TypeVector;
return m_typespec = TypeVector;
if ((m_op == Add || m_op == Sub)
&& (l.is_point() || r.is_point())) // p +/- v, v +/- p == p
return m_typespec = TypeDesc::TypePoint;
return m_typespec = TypePoint;
// everything else: the first operand is also the return type
return m_typespec = l;
}
@@ -553,7 +553,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
case Mod:
// Mod only works with ints, and return ints.
if (l.is_int() && r.is_int())
return m_typespec = TypeDesc::TypeInt;
return m_typespec = TypeInt;
break;
case Equal:
@@ -563,7 +563,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
// Result is always an int.
if (equivalent(l, r) || (l.is_numeric() && r.is_int_or_float())
|| (l.is_int_or_float() && r.is_numeric()))
return m_typespec = TypeDesc::TypeInt;
return m_typespec = TypeInt;
break;
case Greater:
@@ -573,7 +573,7 @@ ASTbinary_expression::typecheck(TypeSpec expected)
// G/L comparisons only work with floats or ints, and always
// return int.
if (l.is_int_or_float() && r.is_int_or_float())
return m_typespec = TypeDesc::TypeInt;
return m_typespec = TypeInt;
break;
case BitAnd:
@@ -583,14 +583,14 @@ ASTbinary_expression::typecheck(TypeSpec expected)
case ShiftRight:
// Bitwise ops only work with ints, and return ints.
if (l.is_int() && r.is_int())
return m_typespec = TypeDesc::TypeInt;
return m_typespec = TypeInt;
break;
case And:
case Or:
// Logical ops work on any simple type (since they test for
// nonzeroness), but always return int.
return m_typespec = TypeDesc::TypeInt;
return m_typespec = TypeInt;
default: errorfmt("unknown binary operator");
}
@@ -606,7 +606,7 @@ TypeSpec
ASTternary_expression::typecheck(TypeSpec expected)
{
// FIXME - closures
TypeSpec c = typecheck_list(cond(), TypeDesc::TypeInt);
TypeSpec c = typecheck_list(cond(), TypeInt);
TypeSpec t = typecheck_list(trueexpr(), expected);
TypeSpec f = typecheck_list(falseexpr(), expected);
@@ -1268,9 +1268,9 @@ ASTfunction_call::typecheck_builtin_specialcase()
if (m_name == "transform") {
// Special case for transform: under the covers, it selects
// vector or normal special versions depending on its use.
if (typespec().simpletype() == TypeDesc::TypeVector)
if (typespec().simpletype() == TypeVector)
m_name = ustring("transformv");
else if (typespec().simpletype() == TypeDesc::TypeNormal)
else if (typespec().simpletype() == TypeNormal)
m_name = ustring("transformn");
}
@@ -1760,21 +1760,21 @@ public:
OSL_DASSERT(!s.is_closure() || s.is_color_closure());
const TypeDesc& td = s.simpletype();
if (td == TypeDesc::TypeFloat)
if (td == TypeFloat)
return 0;
if (td == TypeDesc::TypeInt)
if (td == TypeInt)
return 1;
if (td == TypeDesc::TypeColor)
if (td == TypeColor)
return 2;
if (td == TypeDesc::TypeVector)
if (td == TypeVector)
return 3;
if (td == TypeDesc::TypePoint)
if (td == TypePoint)
return 4;
if (td == TypeDesc::TypeNormal)
if (td == TypeNormal)
return 5;
if (td == TypeDesc::TypeMatrix)
if (td == TypeMatrix)
return 6;
if (td == TypeDesc::TypeString)
if (td == TypeString)
return 7;
if (s.is_color_closure())
@@ -2238,20 +2238,20 @@ OSLCompilerImpl::type_from_code(const char* code, int* advance)
TypeSpec t;
int i = 0;
switch (code[i]) {
case 'i': t = TypeDesc::TypeInt; break;
case 'f': t = TypeDesc::TypeFloat; break;
case 'c': t = TypeDesc::TypeColor; break;
case 'p': t = TypeDesc::TypePoint; break;
case 'v': t = TypeDesc::TypeVector; break;
case 'n': t = TypeDesc::TypeNormal; break;
case 'm': t = TypeDesc::TypeMatrix; break;
case 's': t = TypeDesc::TypeString; break;
case 'i': t = TypeInt; break;
case 'f': t = TypeFloat; break;
case 'c': t = TypeColor; break;
case 'p': t = TypePoint; break;
case 'v': t = TypeVector; break;
case 'n': t = TypeNormal; break;
case 'm': t = TypeMatrix; break;
case 's': t = TypeString; break;
case 'h': t = OSL::TypeUInt64; break; // ustringhash_pod
case 'x': t = TypeDesc(TypeDesc::NONE); break;
case 'X': t = TypeDesc(TypeDesc::PTR); break;
case 'L': t = TypeDesc(TypeDesc::LONGLONG); break;
case 'C': // color closure
t = TypeSpec(TypeDesc::TypeColor, true);
t = TypeSpec(TypeColor, true);
break;
case 'S': // structure
// Following the 'S' is the numeric structure ID
@@ -2337,21 +2337,21 @@ OSLCompilerImpl::code_from_type(TypeSpec type) const
} else if (type.is_closure() || type.is_closure_array()) {
out = 'C';
} else {
if (elem == TypeDesc::TypeInt)
if (elem == TypeInt)
out = 'i';
else if (elem == TypeDesc::TypeFloat)
else if (elem == TypeFloat)
out = 'f';
else if (elem == TypeDesc::TypeColor)
else if (elem == TypeColor)
out = 'c';
else if (elem == TypeDesc::TypePoint)
else if (elem == TypePoint)
out = 'p';
else if (elem == TypeDesc::TypeVector)
else if (elem == TypeVector)
out = 'v';
else if (elem == TypeDesc::TypeNormal)
else if (elem == TypeNormal)
out = 'n';
else if (elem == TypeDesc::TypeMatrix)
else if (elem == TypeMatrix)
out = 'm';
else if (elem == TypeDesc::TypeString)
else if (elem == TypeString)
out = 's';
else if (elem == TypeDesc::NONE)
out = 'x';
+10 -10
View File
@@ -319,11 +319,11 @@ BackendLLVM::addCUDAGlobalVariable(const std::string& name, int size,
llvm::Constant* constant = nullptr;
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
constant = ll.constant(*(const float*)init_data);
} else if (type == TypeDesc::TypeInt) {
} else if (type == TypeInt) {
constant = ll.constant(*(const int*)init_data);
} else if (type == TypeDesc::TypeString) {
} else if (type == TypeString) {
constant = ll.constant64(((const ustring*)init_data)->hash());
// N.B. Since this is the OptiX side specifically, we will represent
// strings as the ustringhash, so we know it as a constant.
@@ -456,13 +456,13 @@ BackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
if (sym.is_constant() && !sym.typespec().is_array() && !arrayindex) {
// Shortcut for simple constants
if (sym.typespec().is_float()) {
if (cast == TypeDesc::TypeInt)
if (cast == TypeInt)
return ll.constant((int)sym.get_float());
else
return ll.constant(sym.get_float());
}
if (sym.typespec().is_int()) {
if (cast == TypeDesc::TypeFloat)
if (cast == TypeFloat)
return ll.constant((float)sym.get_int());
else
return ll.constant(sym.get_int());
@@ -516,9 +516,9 @@ BackendLLVM::llvm_load_value(llvm::Value* ptr, const TypeSpec& type, int deriv,
return result;
// Handle int<->float type casting
if (type.is_float_based() && !type.is_array() && cast == TypeDesc::TypeInt)
if (type.is_float_based() && !type.is_array() && cast == TypeInt)
result = ll.op_float_to_int(result);
else if (type.is_int() && cast == TypeDesc::TypeFloat)
else if (type.is_int() && cast == TypeFloat)
result = ll.op_int_to_float(result);
else if (type.is_string() && cast == TypeDesc::LONGLONG) {
result = ll.ptr_to_cast(result, ll.type_longlong());
@@ -552,13 +552,13 @@ BackendLLVM::llvm_load_constant_value(const Symbol& sym, int arrayindex,
&& "Called llvm_load_constant_value with negative array index");
if (sym.typespec().is_float()) {
if (cast == TypeDesc::TypeInt)
if (cast == TypeInt)
return ll.constant((int)sym.get_float(arrayindex));
else
return ll.constant(sym.get_float(arrayindex));
}
if (sym.typespec().is_int()) {
if (cast == TypeDesc::TypeFloat)
if (cast == TypeFloat)
return ll.constant((float)sym.get_int(arrayindex));
else
return ll.constant(sym.get_int(arrayindex));
@@ -802,7 +802,7 @@ BackendLLVM::llvm_test_nonzero(Symbol& val, bool test_derivs)
TypeDesc t = ts.simpletype();
// Handle int case -- guaranteed no derivs, no multi-component
if (t == TypeDesc::TypeInt)
if (t == TypeInt)
return ll.op_ne(llvm_load_value(val), ll.constant(0));
// float-based
+11 -44
View File
@@ -304,20 +304,14 @@ public:
/// Return the ShaderGlobals pointer.
///
llvm::Value* sg_ptr() const
{
return m_llvm_shaderglobals_ptr;
}
llvm::Value* sg_ptr() const { return m_llvm_shaderglobals_ptr; }
llvm::Type* llvm_type_closure_component();
llvm::Type* llvm_type_closure_component_ptr();
/// Return the ShaderGlobals pointer cast as a void*.
///
llvm::Value* sg_void_ptr()
{
return ll.void_ptr(m_llvm_shaderglobals_ptr);
}
llvm::Value* sg_void_ptr() { return ll.void_ptr(m_llvm_shaderglobals_ptr); }
/// Cast the pointer variable specified by val to a pointer to the
/// basic type comprising `type`.
@@ -343,10 +337,7 @@ public:
/// Return the group data pointer.
///
llvm::Value* groupdata_ptr() const
{
return m_llvm_groupdata_ptr;
}
llvm::Value* groupdata_ptr() const { return m_llvm_groupdata_ptr; }
/// Return the group data pointer cast as a void*.
///
@@ -364,22 +355,13 @@ public:
TypeDesc type = TypeDesc::UNKNOWN);
/// Return the userdata base pointer.
llvm::Value* userdata_base_ptr() const
{
return m_llvm_userdata_base_ptr;
}
llvm::Value* userdata_base_ptr() const { return m_llvm_userdata_base_ptr; }
/// Return the output base pointer.
llvm::Value* output_base_ptr() const
{
return m_llvm_output_base_ptr;
}
llvm::Value* output_base_ptr() const { return m_llvm_output_base_ptr; }
/// Return the shade index
llvm::Value* shadeindex() const
{
return m_llvm_shadeindex;
}
llvm::Value* shadeindex() const { return m_llvm_shadeindex; }
// For a symloc, compute the llvm::Value of the pointer to its true,
// offset location from the base pointer for shade index `sindex`
@@ -507,10 +489,7 @@ public:
/// Return the basic block of the exit for the whole instance.
///
bool llvm_has_exit_instance_block() const
{
return m_exit_instance_block;
}
bool llvm_has_exit_instance_block() const { return m_exit_instance_block; }
/// Return the basic block of the exit for the whole instance.
///
@@ -531,10 +510,7 @@ public:
/// Print debugging line for the op
void llvm_generate_debug_op_printf(const Opcode& op);
llvm::Function* layer_func() const
{
return ll.current_function();
}
llvm::Function* layer_func() const { return ll.current_function(); }
/// Call this when JITing a texture-like call, to track how many.
void generated_texture_call(bool handle)
@@ -544,10 +520,7 @@ public:
shadingsys().m_stat_tex_calls_as_handles += 1;
}
void increment_useparam_ops()
{
shadingsys().m_stat_useparam_ops++;
}
void increment_useparam_ops() { shadingsys().m_stat_useparam_ops++; }
/// Return the mapping from symbol names to GlobalVariables.
std::map<std::string, llvm::GlobalVariable*>& get_const_map()
@@ -556,16 +529,10 @@ public:
}
/// Return whether or not we are compiling for an OptiX-based renderer.
bool use_optix()
{
return m_use_optix;
}
bool use_optix() { return m_use_optix; }
/// Return if we should compile against free function versions of Renderer Service.
bool use_rs_bitcode()
{
return m_use_rs_bitcode;
}
bool use_rs_bitcode() { return m_use_rs_bitcode; }
/// Return the userdata index for the given Symbol. Return -1 if the Symbol
/// is not an input parameter or is constant and therefore doesn't have an
+64 -20
View File
@@ -838,11 +838,12 @@ private:
std::vector<Position> m_function_stack;
std::vector<Position> m_before_if_block_stack;
std::vector<Position> m_after_if_block_stack;
std::vector<int> m_loop_depth_stack;
public:
OSL_FORCEINLINE FunctionTreeTracker() : m_top_of_stack(end_pos())
{
push_function_call();
push_function_call(0);
}
FunctionTreeTracker(const FunctionTreeTracker&) = delete;
@@ -977,11 +978,12 @@ public:
OSL_FORCEINLINE Iterator end() const { return Iterator(*this, end_pos()); }
OSL_FORCEINLINE void push_function_call()
OSL_FORCEINLINE void push_function_call(int loop_depth_at_function)
{
OSL_DEV_ONLY(std::cout << "DependencyTreeTracker push_function_call"
<< std::endl);
m_function_stack.push_back(m_top_of_stack);
m_loop_depth_stack.push_back(loop_depth_at_function);
}
OSL_FORCEINLINE void push_if_block()
@@ -1062,7 +1064,16 @@ public:
OSL_FORCEINLINE Position top_pos() const { return m_top_of_stack; }
OSL_FORCEINLINE void pop_function_call()
OSL_FORCEINLINE int loop_depth_at_start_of_call()
{
if (m_loop_depth_stack.empty()) {
return 0;
} else {
return m_loop_depth_stack.back();
}
}
OSL_FORCEINLINE void pop_function_call(int loop_depth_at_function)
{
OSL_DEV_ONLY(std::cout << "DependencyTreeTracker pop_function_call"
<< std::endl);
@@ -1090,6 +1101,9 @@ public:
process_exit(early_out.dtt_pos);
}
}
OSL_ASSERT(m_loop_depth_stack.back() == loop_depth_at_function);
m_loop_depth_stack.pop_back();
}
};
@@ -1182,15 +1196,9 @@ public:
}
#ifdef OSL_DEV
OSL_FORCEINLINE int op_num() const
{
return m_op_num;
}
OSL_FORCEINLINE int op_num() const { return m_op_num; }
OSL_FORCEINLINE int loop_op_index() const
{
return m_loop_op_index;
}
OSL_FORCEINLINE int loop_op_index() const { return m_loop_op_index; }
#endif
};
@@ -1220,8 +1228,11 @@ class LoopStack {
std::vector<LoopInfo> m_loop_info_by_depth;
bool is_inside_loop() const { return depth() != 0; }
public:
bool is_inside_loop() const { return !m_loop_info_by_depth.empty(); }
int depth() const { return m_loop_info_by_depth.size(); }
int current_loop_op_index() const
{
@@ -1609,7 +1620,7 @@ struct Analyzer {
OSL_NOINLINE void make_loops_control_flow_depend_on_early_out_conditions()
{
// Need change the loop control flow which is dependent upon
// Need to change the loop control flow which is dependent upon
// a conditional. By making a circular dependency between the this
// [return|exit|break|continue] operation and the conditionals value,
// any varying values in the conditional controlling
@@ -1992,9 +2003,11 @@ struct Analyzer {
// as the current block, there was no conditionals involved
OSL_DEV_ONLY(std::cout << " FUNCTION CALL BLOCK BEGIN"
<< std::endl);
m_execution_scope_stack.push_function_call();
m_execution_scope_stack.push_function_call(
m_loop_stack.depth());
discover_symbols_between(op_index + 1, opcode.jump(0));
m_execution_scope_stack.pop_function_call();
m_execution_scope_stack.pop_function_call(
m_loop_stack.depth());
OSL_DEV_ONLY(std::cout << " FUNCTION CALL BLOCK END"
<< std::endl);
@@ -2026,12 +2039,16 @@ struct Analyzer {
m_execution_scope_stack.process_return(
m_conditional_symbol_stack.top_pos());
// The return will need change the loop control flow which is dependent upon
// IF AND ONLY IF, the current loop control exists inside
// the current function, because the return should only early
// out of those loops, not any higher in the call stack.
// The return will need to change the loop control flow which is dependent upon
// a conditional. By making a circular dependency between the return operation
// and the conditionals value, any varying values in the conditional controlling
// the return should flow back to the loop control variable, which might need to
// be varying so allow lanes to terminate the loop independently
if (m_loop_stack.is_inside_loop()) {
if (m_loop_stack.depth()
> m_execution_scope_stack.loop_depth_at_start_of_call()) {
make_loops_control_flow_depend_on_early_out_conditions();
}
}
@@ -2043,12 +2060,18 @@ struct Analyzer {
m_execution_scope_stack.process_exit(
m_conditional_symbol_stack.top_pos());
// The exit will need change the loop control flow which is dependent upon
// IF AND ONLY IF, the current loop control exists inside
// the current function, because the return should only early
// out of those loops, not any higher in the call stack.
// A different mechanism will look for early outs when
// unwinding up the callstack.
// The exit will need to change the loop control flow which is dependent upon
// a conditional. By making a circular dependency between the exit operation
// and the conditionals value, any varying values in the conditional controlling
// the exit should flow back to the loop control variable, which might need to
// be varying so allow lanes to terminate the loop independently
if (m_loop_stack.is_inside_loop()) {
if (m_loop_stack.depth()
> m_execution_scope_stack.loop_depth_at_start_of_call()) {
make_loops_control_flow_depend_on_early_out_conditions();
}
}
@@ -2101,6 +2124,10 @@ struct Analyzer {
|| symbol_to_be_varying->typespec().is_closure()
|| symbol_to_be_varying->connected()
|| symbol_to_be_varying->connected_down());
OSL_DEV_ONLY(std::cout << "<<<< make_varying symbol: "
<< symbol_to_be_varying->unmangled().c_str()
<< " force=" << force << std::endl);
symbol_to_be_varying->make_varying();
auto range = m_symbols_dependent_upon.equal_range(
symbol_to_be_varying);
@@ -2113,6 +2140,9 @@ struct Analyzer {
recursively_mark_varying(dependent_symbol);
}
};
OSL_DEV_ONLY(std::cout << ">>>> end make_varying symbol: "
<< symbol_to_be_varying->unmangled().c_str()
<< std::endl);
}
};
@@ -2599,7 +2629,7 @@ struct Analyzer {
#endif
const auto& early_out = *earlyOutIter;
auto begin_dep_iter = m_conditional_symbol_stack.begin_at(
early_out.dtt_pos);
early_out.dtt_pos);
auto end_dep_iter = m_conditional_symbol_stack.end();
const Opcode& opcode = m_opcodes[op_index];
@@ -2645,6 +2675,8 @@ struct Analyzer {
OSL_NOINLINE void push_varying_of_shader_globals()
{
OSL_DEV_ONLY(std::cout << "push_varying_of_shader_globals begin"
<< std::endl);
for (auto&& s : inst()->symbols()) {
if (s.symtype() == SymTypeGlobal) {
// TODO: now that symbol has is_uniform()
@@ -2665,10 +2697,14 @@ struct Analyzer {
// so force their dependents to get marked
recursively_mark_varying(sym_ptr, true /*force*/);
}
OSL_DEV_ONLY(std::cout << "push_varying_of_shader_globals end"
<< std::endl);
}
OSL_NOINLINE void make_renderer_outputs_varying()
{
OSL_DEV_ONLY(std::cout << "make_renderer_outputs_varying begin"
<< std::endl);
// Mark all output parameters as varying to catch
// output parameters written to by uniform variables,
// as nothing would have made them varying, however as
@@ -2685,10 +2721,14 @@ struct Analyzer {
}
}
}
OSL_DEV_ONLY(std::cout << "make_renderer_outputs_varying end"
<< std::endl);
}
OSL_NOINLINE void make_interpolated_parameters_varying()
{
OSL_DEV_ONLY(std::cout << "make_interpolated_parameters_varying begin"
<< std::endl);
// Mark all interpolated parameters as varying,
// As we expect interpolated data, get_userdata will
// only provide varying values, so we must mark
@@ -2700,10 +2740,13 @@ struct Analyzer {
recursively_mark_varying(&s);
}
}
OSL_DEV_ONLY(std::cout << "make_interpolated_parameters_varying end"
<< std::endl);
}
OSL_NOINLINE void make_closures_varying()
{
OSL_DEV_ONLY(std::cout << "make_closures_varying begin" << std::endl);
// We assume that closures are always stored as varying pointers
FOREACH_SYM(Symbol & s, inst())
{
@@ -2713,6 +2756,7 @@ struct Analyzer {
recursively_mark_varying(&s);
}
}
OSL_DEV_ONLY(std::cout << "make_closures_varying end" << std::endl);
}
OSL_NOINLINE void push_varying_of_upstream_connections()
+43 -45
View File
@@ -381,7 +381,7 @@ BatchedBackendLLVM::llvm_zero_derivs(const Symbol& sym, llvm::Value* count)
llvm::Value* post_condition_mask = ll.op_and(condition_mask,
pre_condition_mask);
llvm::Value* cond_val = ll.test_if_mask_is_non_zero(
post_condition_mask);
post_condition_mask);
// Jump to either LoopBody or AfterLoop
ll.op_branch(cond_val, body_block, after_block);
@@ -702,7 +702,7 @@ BatchedBackendLLVM::llvm_widen_value_into_temp(const Symbol& sym, int deriv)
auto disable_masked_stores = ll.create_masking_scope(false);
for (int c = 0; c < t.aggregate(); ++c) {
// NOTE: we use the passed deriv to load, but store to value (deriv==0)
llvm::Value* v = llvm_load_value(sym, deriv, c, TypeDesc::UNKNOWN,
llvm::Value* v = llvm_load_value(sym, deriv, c, TypeUnknown,
/*is_uniform*/ false);
llvm_store_value(v, widePtr, t, 0, NULL, c, /*is_uniform*/ false);
}
@@ -739,7 +739,7 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
// Shortcut for simple constants
if (sym.typespec().is_float()) {
float float_val = sym.get_float();
if (cast == TypeDesc::TypeInt) {
if (cast == TypeInt) {
int int_val = static_cast<int>(float_val);
if (op_is_uniform) {
return ll.constant(int_val);
@@ -754,7 +754,7 @@ BatchedBackendLLVM::llvm_load_value(const Symbol& sym, int deriv,
}
if (sym.typespec().is_int()) {
int int_val = sym.get_int();
if (cast == TypeDesc::TypeFloat) {
if (cast == TypeFloat) {
float float_val = static_cast<float>(int_val);
if (op_is_uniform) {
return ll.constant(float_val);
@@ -806,9 +806,9 @@ BatchedBackendLLVM::llvm_load_mask(const Symbol& cond)
llvm::Value* llvm_mask = nullptr;
llvm::Value* llvm_mask_or_wide_int
= llvm_load_value(cond, /*deriv*/ 0, /*component*/ 0,
/*cast*/ TypeDesc::UNKNOWN, /*op_is_uniform*/ false);
/*cast*/ TypeUnknown, /*op_is_uniform*/ false);
if (cond.forced_llvm_bool()) {
// The llvm_load_value + TypeDesc::UNKNOWN will check and convert to llvm mask already
// The llvm_load_value + TypeUnknown will check and convert to llvm mask already
llvm_mask = llvm_mask_or_wide_int;
} else {
OSL_ASSERT(ll.llvm_typeof(llvm_mask_or_wide_int) == ll.type_wide_int());
@@ -890,19 +890,19 @@ BatchedBackendLLVM::llvm_load_value(llvm::Value* src_ptr, const TypeSpec& type,
result = ll.native_to_llvm_mask(result);
}
if (cast != TypeDesc::UNKNOWN) {
if (cast == TypeDesc::TypeInt) {
if (cast != TypeUnknown) {
if (cast == TypeInt) {
result = ll.op_bool_to_int(result);
} else if (cast == TypeDesc::TypeFloat) {
} else if (cast == TypeFloat) {
result = ll.op_bool_to_float(result);
}
}
}
// Handle int<->float type casting
if (type.is_float_based() && cast == TypeDesc::TypeInt)
if (type.is_float_based() && cast == TypeInt)
result = ll.op_float_to_int(result);
else if (type.is_int() && cast == TypeDesc::TypeFloat)
else if (type.is_int() && cast == TypeFloat)
result = ll.op_int_to_float(result);
else if (type.is_string() && cast == TypeDesc::LONGLONG)
result = ll.ptr_to_cast(result, ll.type_longlong());
@@ -911,12 +911,11 @@ BatchedBackendLLVM::llvm_load_value(llvm::Value* src_ptr, const TypeSpec& type,
// TODO: remove this assert once we have confirmed correct handling off all the
// different data types. Using OSL_ASSERT as a checklist to verify what we have
// handled so far during development
OSL_ASSERT(
cast == TypeDesc::UNKNOWN || cast == TypeDesc::TypeColor
|| cast == TypeDesc::TypeVector || cast == TypeDesc::TypePoint
|| cast == TypeDesc::TypeNormal || cast == TypeDesc::TypeFloat
|| cast == TypeDesc::TypeInt || cast == TypeDesc::TypeString
|| cast == TypeDesc::TypeMatrix || cast == TypeDesc::LONGLONG);
OSL_ASSERT(cast == TypeUnknown || cast == TypeColor
|| cast == TypeVector || cast == TypePoint
|| cast == TypeNormal || cast == TypeFloat
|| cast == TypeInt || cast == TypeString
|| cast == TypeMatrix || cast == TypeDesc::LONGLONG);
if ((ll.llvm_typeof(result) == ll.type_bool())
|| (ll.llvm_typeof(result) == ll.type_float())
@@ -991,9 +990,9 @@ BatchedBackendLLVM::llvm_load_value(llvm::Value* src_ptr, const TypeSpec& type,
OSL_ASSERT(ll.llvm_typeof(result) != ll.type_wide_bool());
// Handle int<->float type casting
if (type.is_float_based() && cast == TypeDesc::TypeInt)
if (type.is_float_based() && cast == TypeInt)
result = ll.op_float_to_int(result);
else if (type.is_int() && cast == TypeDesc::TypeFloat)
else if (type.is_int() && cast == TypeFloat)
result = ll.op_int_to_float(result);
else if (type.is_string() && cast == TypeDesc::LONGLONG)
result = ll.ptr_to_cast(result, ll.type_longlong());
@@ -1027,7 +1026,7 @@ BatchedBackendLLVM::llvm_load_constant_value(const Symbol& sym, int arrayindex,
if (elementType.is_float()) {
float float_elem = sym.get_float(arrayindex);
if (cast == TypeDesc::TypeInt) {
if (cast == TypeInt) {
int int_elem = static_cast<int>(float_elem);
if (op_is_uniform) {
return ll.constant(int_elem);
@@ -1042,7 +1041,7 @@ BatchedBackendLLVM::llvm_load_constant_value(const Symbol& sym, int arrayindex,
}
if (elementType.is_int()) {
int int_elem = sym.get_int(arrayindex);
if (cast == TypeDesc::TypeFloat) {
if (cast == TypeFloat) {
float float_elem = static_cast<float>(int_elem);
if (op_is_uniform) {
return ll.constant(float_elem);
@@ -1164,14 +1163,14 @@ BatchedBackendLLVM::llvm_load_arg(const Symbol& sym, bool derivs,
// get passed as a pointer instead of by value
// So let this case fall through
if (op_is_uniform) {
return llvm_load_value(sym, 0, 0, TypeDesc::UNKNOWN, op_is_uniform);
return llvm_load_value(sym, 0, 0, TypeUnknown, op_is_uniform);
} else if (sym.symtype() == SymTypeConst) {
// As the case to deliver a pointer to a symbol data
// doesn't provide an opportunity to promote a uniform constant
// to a wide value that the non-uniform function is expecting
// we will handle it here.
llvm::Value* wide_constant_value
= llvm_load_constant_value(sym, 0, 0, TypeDesc::UNKNOWN,
= llvm_load_constant_value(sym, 0, 0, TypeUnknown,
op_is_uniform);
// Have to have a place on the stack for the pointer to the wide constant to point to
@@ -1208,7 +1207,7 @@ BatchedBackendLLVM::llvm_load_arg(const Symbol& sym, bool derivs,
for (int c = 0; c < t.aggregate(); ++c) {
// Will automatically widen value if needed
llvm::Value* v = llvm_load_value(sym, d, arrayIndex, c,
TypeDesc::UNKNOWN,
TypeUnknown,
op_is_uniform);
llvm_store_value(v, tmpptr, t, d, arrayIndex, c,
op_is_uniform);
@@ -1460,10 +1459,11 @@ BatchedBackendLLVM::llvm_broadcast_uniform_value_from_mem(
// Load the uniform component from the temporary
// base passing false for op_is_uniform, the llvm_load_value will
// automatically broadcast the uniform value to a vector type
llvm::Value* wide_component_value = llvm_load_value(
pointerTotempUniform, dest_type, derivIndex,
llvm_array_index, componentIndex, true /*src_is_uniform*/,
TypeDesc::UNKNOWN, false /*op_is_uniform*/);
llvm::Value* wide_component_value
= llvm_load_value(pointerTotempUniform, dest_type,
derivIndex, llvm_array_index,
componentIndex, true /*src_is_uniform*/,
TypeUnknown, false /*op_is_uniform*/);
bool success = llvm_store_value(wide_component_value,
Destination, derivIndex,
llvm_array_index,
@@ -1556,7 +1556,7 @@ BatchedBackendLLVM::groupdata_field_ptr(int fieldnum, TypeDesc type,
bool is_uniform, bool forceBool)
{
llvm::Value* result = ll.void_ptr(groupdata_field_ref(fieldnum));
if (type != TypeDesc::UNKNOWN) {
if (type != TypeUnknown) {
if (is_uniform) {
result = ll.ptr_to_cast(result, forceBool ? ll.type_bool()
: llvm_type(type));
@@ -1713,9 +1713,10 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name,
int numDeriv = s.has_derivs() ? 3 : 1;
for (int d = 0; d < numDeriv; ++d) {
for (int c = 0; c < t.simpletype().aggregate; ++c) {
llvm::Value* wide_value = llvm_load_value(
s, /*deriv=*/d, /*component*/ c,
TypeDesc::UNKNOWN, function_is_uniform);
llvm::Value* wide_value
= llvm_load_value(s, /*deriv=*/d,
/*component*/ c, TypeUnknown,
function_is_uniform);
// Store our wide pointer on the stack
llvm_store_value(wide_value, tmpptr, t, d, NULL, c,
/*dst_is_uniform*/ false);
@@ -1748,7 +1749,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name,
auto disable_masked_stores = ll.create_masking_scope(false);
for (int a = 0; a < t.simpletype().aggregate; ++a) {
llvm::Value* wide_constant_value
= llvm_load_constant_value(s, 0, a, TypeDesc::UNKNOWN,
= llvm_load_constant_value(s, 0, a, TypeUnknown,
function_is_uniform);
// Store our wide pointer on the stack
llvm_store_value(wide_constant_value, tmpptr, t, 0, NULL, a,
@@ -1765,8 +1766,7 @@ BatchedBackendLLVM::llvm_call_function(const FuncSpec& name,
OSL_DEV_ONLY(std::cout << "....pushing " << s.name().c_str()
<< " as value" << std::endl);
valargs[i] = llvm_load_value(s, /*deriv*/ 0, /*component*/ 0,
TypeDesc::UNKNOWN,
function_is_uniform);
TypeUnknown, function_is_uniform);
}
}
@@ -1852,7 +1852,7 @@ BatchedBackendLLVM::llvm_test_nonzero(const Symbol& val, bool test_derivs)
TypeDesc t = ts.simpletype();
// Handle int case -- guaranteed no derivs, no multi-component
if (t == TypeDesc::TypeInt) {
if (t == TypeInt) {
// Because we allow temporaries and local results of comparison operations
// to use the native bool type of i1, we will need to build an matching constant 0
// for comparisons.
@@ -1911,8 +1911,7 @@ BatchedBackendLLVM::llvm_assign_impl(const Symbol& Result, const Symbol& Src,
if (Result.typespec().is_closure() || Src.typespec().is_closure()) {
if (Src.typespec().is_closure()) {
llvm::Value* srcval = llvm_load_value(Src, 0, arrind, 0,
TypeDesc::UNKNOWN,
op_is_uniform);
TypeUnknown, op_is_uniform);
llvm_store_value(srcval, Result, 0, arrind, 0);
} else {
llvm::Value* null_value = ll.constant_ptr(NULL, ll.type_void_ptr());
@@ -2030,8 +2029,7 @@ BatchedBackendLLVM::llvm_assign_impl(const Symbol& Result, const Symbol& Src,
// src and result both have derivs -- copy them
// allow a uniform Src to store to a varying Result,
val = llvm_load_value(Src, d, arrind, i,
TypeDesc::UNKNOWN,
op_is_uniform);
TypeUnknown, op_is_uniform);
}
llvm_store_value(val, Result, d, arrind, i);
}
@@ -2041,7 +2039,7 @@ BatchedBackendLLVM::llvm_assign_impl(const Symbol& Result, const Symbol& Src,
// src and result both have derivs -- copy them
// allow a uniform Src to store to a varying Result,
val = llvm_load_value(Src, d, arrind, srccomp,
TypeDesc::UNKNOWN, op_is_uniform);
TypeUnknown, op_is_uniform);
}
if (dstcomp == -1) {
@@ -2085,13 +2083,13 @@ BatchedBackendLLVM::append_arg_to(llvm::raw_svector_ostream& OS,
const TypeDesc& td = arg.type();
const char* name = nullptr;
if (td == TypeDesc::TypeInt)
if (td == TypeInt)
name = "i";
else if (td == TypeDesc::TypeMatrix)
else if (td == TypeMatrix)
name = "m";
else if (td == TypeDesc::TypeString)
else if (td == TypeString)
name = "s";
else if (td == TypeDesc::TypeFloat)
else if (td == TypeFloat)
name = arg.has_derivs() ? "df" : "f";
else if (td.aggregate == 3 && td.basetype == TypeDesc::FLOAT
&& td.arraylen == 0)
+58 -49
View File
@@ -597,7 +597,7 @@ LLVMGEN(llvm_gen_aref)
bool index_is_uniform = Index.is_uniform();
// Get array index we're interested in
llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeDesc::TypeInt,
llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeInt,
index_is_uniform);
if (!index)
return false;
@@ -680,7 +680,7 @@ LLVMGEN(llvm_gen_aassign)
OSL_ASSERT(index_is_uniform || !resultIsUniform);
// Get array index we're interested in
llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeDesc::TypeInt,
llvm::Value* index = rop.loadLLVMValue(Index, 0, 0, TypeInt,
index_is_uniform);
if (!index)
@@ -1006,11 +1006,9 @@ LLVMGEN(llvm_gen_andor)
bool result_is_uniform = result.is_uniform();
llvm::Value* i1_res = NULL;
llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeDesc::TypeInt,
op_is_uniform);
llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeDesc::TypeInt,
op_is_uniform);
llvm::Value* i1_res = NULL;
llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeInt, op_is_uniform);
llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeInt, op_is_uniform);
llvm::Value* zero_set = op_is_uniform ? rop.ll.constant(0)
: rop.ll.wide_constant(0);
@@ -2104,7 +2102,7 @@ LLVMGEN(llvm_gen_bitwise_binary_op)
bool op_is_uniform = A.is_uniform() && B.is_uniform();
bool result_is_uniform = Result.is_uniform();
TypeDesc type = TypeDesc::TypeInt;
TypeDesc type = TypeInt;
bool is_logical_op = op.opname() == op_bitand || op.opname() == op_bitor
|| op.opname() == op_xor;
if (is_logical_op) {
@@ -2287,7 +2285,8 @@ LLVMGEN(llvm_gen_compref)
bool op_is_uniform = Result.is_uniform();
llvm::Value* c = rop.llvm_load_value(Index);
llvm::Value* c = rop.llvm_load_value(Index, /*deriv=*/0, /*component=*/0,
TypeDesc::UNKNOWN, Index.is_uniform());
if (Index.is_uniform()) {
if (rop.inst()->master()->range_checking()) {
@@ -2425,8 +2424,7 @@ LLVMGEN(llvm_gen_compassign)
}
for (int d = 0; d < 3; ++d) { // deriv
llvm::Value* val = rop.llvm_load_value(Val, d, 0,
TypeDesc::TypeFloat,
llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeFloat,
op_is_uniform);
if (Index.is_constant()) {
int i = Index.get_int();
@@ -2485,8 +2483,7 @@ LLVMGEN(llvm_gen_compassign)
for (int d = 0; d < 3; ++d) { // deriv
llvm::Value* val = rop.llvm_load_value(Val, d, 0,
TypeDesc::TypeFloat,
llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeFloat,
op_is_uniform);
llvm::Value* valc0 = rop.llvm_load_value(Result, d, 0,
@@ -2601,8 +2598,7 @@ LLVMGEN(llvm_gen_mxcompref)
int r = Imath::clamp(Row.get_int(), 0, 3);
int c = Imath::clamp(Col.get_int(), 0, 3);
int comp = 4 * r + c;
val = rop.llvm_load_value(M, 0, comp, TypeDesc::TypeFloat,
op_is_uniform);
val = rop.llvm_load_value(M, 0, comp, TypeFloat, op_is_uniform);
} else {
llvm::Value* comp = rop.ll.op_mul(row, components_are_uniform
? rop.ll.constant(4)
@@ -2700,8 +2696,7 @@ LLVMGEN(llvm_gen_mxcompassign)
}
}
llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeDesc::TypeFloat,
op_is_uniform);
llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeFloat, op_is_uniform);
if (Row.is_constant() && Col.is_constant()) {
int r = Imath::clamp(Row.get_int(), 0, 3);
@@ -2758,9 +2753,8 @@ LLVMGEN(llvm_gen_construct_color)
for (int d = 0; d < dmax; ++d) { // loop over derivs
for (int c = 0; c < 3; ++c) { // loop over components
const Symbol& comp = *rop.opargsym(op, c + 1 + using_space);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0,
TypeDesc::TypeFloat,
result_is_uniform);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat,
result_is_uniform);
rop.llvm_store_value(val, Result, d, NULL, c);
}
}
@@ -2924,7 +2918,8 @@ LLVMGEN(llvm_gen_filterwidth)
}
rop.ll.call_function(rop.build_name(func_spec),
{ &args[0], argCount });
{ &args[0],
cspan<llvm::Value*>::size_type(argCount) });
// Don't have 2nd order derivs
rop.llvm_zero_derivs(Result);
}
@@ -3236,9 +3231,8 @@ LLVMGEN(llvm_gen_construct_triple)
for (int d = 0; d < dmax; ++d) { // loop over derivs
for (int c = 0; c < 3; ++c) { // loop over components
const Symbol& comp = *rop.opargsym(op, c + 1 + using_space);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0,
TypeDesc::TypeFloat,
op_is_uniform);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat,
op_is_uniform);
if (op_is_uniform && !resultIsUniform) {
rop.llvm_broadcast_uniform_value(val, Result, d, c);
@@ -3250,9 +3244,8 @@ LLVMGEN(llvm_gen_construct_triple)
// Do the transformation in-place, if called for
if (using_space) {
ustring from, to; // N.B. initialize to empty strings
if (Space.is_constant()) {
from = Space.get_string();
ustring from = Space.get_string();
if (from == Strings::common
|| from == rop.shadingsys().commonspace_synonym())
return true; // no transformation necessary
@@ -3302,9 +3295,9 @@ LLVMGEN(llvm_gen_construct_triple)
// Dynamically build function name
FuncSpec func_spec("build_transform_matrix");
func_spec.arg_varying(TypeDesc::TypeMatrix);
func_spec.arg_varying(TypeMatrix);
func_spec.arg(Space, false /*derivs*/, space_is_uniform);
func_spec.arg_uniform(TypeDesc::TypeString);
func_spec.arg_uniform(TypeString);
func_spec.mask();
succeeded_as_int = rop.ll.call_function(rop.build_name(func_spec),
@@ -3326,7 +3319,7 @@ LLVMGEN(llvm_gen_construct_triple)
FuncSpec func_spec(transform_name);
func_spec.arg(Result, Result.has_derivs(), resultIsUniform);
func_spec.arg(Result, Result.has_derivs(), resultIsUniform);
func_spec.arg_varying(TypeDesc::TypeMatrix44);
func_spec.arg_varying(TypeMatrix);
func_spec.mask();
rop.ll.call_function(rop.build_name(func_spec), args);
@@ -3583,7 +3576,7 @@ LLVMGEN(llvm_gen_transform)
rop.ll.mask_as_int(rop.ll.current_mask()) };
FuncSpec func_spec("build_transform_matrix");
func_spec.arg_varying(TypeDesc::TypeMatrix44);
func_spec.arg_varying(TypeMatrix);
// Ignore derivatives if unneeded or unsupplied
func_spec.arg(*From, from_is_uniform);
func_spec.arg(*To, to_is_uniform);
@@ -3613,7 +3606,7 @@ LLVMGEN(llvm_gen_transform)
// The matrix is always varying if we looked it up,
// if it was passed directly in "To", then we respect to's uniformity
// otherwise it will be the varying result of the callback to the renderer
func_spec.arg(TypeDesc::TypeMatrix44,
func_spec.arg(TypeMatrix,
To->typespec().is_matrix() ? to_is_uniform : false);
func_spec.arg(*Result, has_derivs, result_is_uniform);
@@ -3638,7 +3631,7 @@ LLVMGEN(llvm_gen_transform)
// The matrix is always varying if we looked it up,
// if it was passed directly in "To", then we respect to's uniformity
// otherwise it will be the varying result of the callback to the renderer
func_spec.arg(TypeDesc::TypeMatrix44,
func_spec.arg(TypeMatrix,
To->typespec().is_matrix() ? to_is_uniform : false);
func_spec.mask();
@@ -4271,7 +4264,7 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
llvm::Value* wide_const_fone_value = rop.ll.wide_constant(1.0f);
llvm::Value* const_zero_value = rop.ll.constant(0);
llvm::Value* wrap_default_value = rop.ll.constant(
static_cast<int>(Tex::Wrap::Default));
static_cast<int>(Tex::Wrap::Default));
llvm::Value* sblur = wide_const_fzero_value;
llvm::Value* tblur = wide_const_fzero_value;
@@ -4290,7 +4283,7 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
llvm::Value* twrap = wrap_default_value;
llvm::Value* rwrap = wrap_default_value;
llvm::Value* mipmode = rop.ll.constant(
static_cast<int>(Tex::MipMode::Default));
static_cast<int>(Tex::MipMode::Default));
llvm::Value* interpmode = rop.ll.constant(
static_cast<int>(Tex::InterpMode::SmartBicubic));
llvm::Value* anisotropic = rop.ll.constant(32);
@@ -4495,8 +4488,7 @@ llvm_batched_texture_options(BatchedBackendLLVM& rop, int opnum,
continue;
}
if (name == Strings::missingcolor
&& equivalent(valtype, TypeDesc::TypeColor)) {
if (name == Strings::missingcolor && equivalent(valtype, TypeColor)) {
if (!missingcolor_buffer) {
// If not already done, allocate enough storage for the
// missingcolor value (4 floats), and call the special
@@ -4825,8 +4817,7 @@ llvm_batched_texture_varying_options(BatchedBackendLLVM& rop, int opnum,
PARAM_VARYING_STRING_CODE(interp, osl_texture_decode_interpmode,
interpmode)
if (name == Strings::missingcolor
&& equivalent(valtype, TypeDesc::TypeColor)) {
if (name == Strings::missingcolor && equivalent(valtype, TypeColor)) {
OSL_ASSERT(missingcolor_buffer != nullptr);
int num_components = valtype.aggregate;
@@ -5826,7 +5817,7 @@ llvm_batched_noise_options(BatchedBackendLLVM& rop, int opnum,
}
rop.ll.call_function("osl_noiseparams_set_bandwidth", opt,
rop.llvm_load_value(Val, 0, NULL, 0,
TypeDesc::TypeFloat));
TypeFloat));
} else if (name == Strings::impulses
&& (Val.typespec().is_float() || Val.typespec().is_int())) {
if (!Val.is_uniform()) {
@@ -5835,7 +5826,7 @@ llvm_batched_noise_options(BatchedBackendLLVM& rop, int opnum,
}
rop.ll.call_function("osl_noiseparams_set_impulses", opt,
rop.llvm_load_value(Val, 0, NULL, 0,
TypeDesc::TypeFloat));
TypeFloat));
} else {
rop.shadingcontext()->errorfmt(
"Unknown {} optional argument: \"{}\", <{}> ({}:{})",
@@ -5915,7 +5906,7 @@ llvm_batched_noise_varying_options(BatchedBackendLLVM& rop, int opnum,
llvm::Value* wide_bandwidth
= rop.llvm_load_value(Val,
/*deriv=*/0, /*component=*/0,
/*cast=*/TypeDesc::TypeFloat,
/*cast=*/TypeFloat,
/*op_is_uniform=*/false);
llvm::Value* scalar_bandwidth = rop.ll.op_extract(wide_bandwidth,
leadLane);
@@ -5930,7 +5921,7 @@ llvm_batched_noise_varying_options(BatchedBackendLLVM& rop, int opnum,
llvm::Value* wide_impulses
= rop.llvm_load_value(Val,
/*deriv=*/0, /*component=*/0,
/*cast=*/TypeDesc::TypeFloat,
/*cast=*/TypeFloat,
/*op_is_uniform=*/false);
llvm::Value* scalar_impulses = rop.ll.op_extract(wide_impulses,
leadLane);
@@ -6758,13 +6749,18 @@ LLVMGEN(llvm_gen_getmessage)
rop.ll.call_function(rop.build_name(FuncSpec("getmessage").mask()),
args);
} else {
llvm::Value* nameVal = rop.llvm_load_value(Name);
llvm::Value* nameVal
= rop.llvm_load_value(Name, /*deriv=*/0, /*component=*/0,
TypeDesc::UNKNOWN, nameVal_is_uniform);
if (nameVal_is_uniform) {
args[nameArgumentIndex] = nameVal;
}
llvm::Value* sourceVal = has_source ? rop.llvm_load_value(Source)
: rop.ll.constant(ustring());
llvm::Value* sourceVal
= has_source
? rop.llvm_load_value(Source, /*deriv=*/0, /*component=*/0,
TypeDesc::UNKNOWN, sourceVal_is_uniform)
: rop.ll.constant(ustring());
if (sourceVal_is_uniform) {
args[sourceArgumentIndex] = sourceVal;
}
@@ -6928,7 +6924,9 @@ LLVMGEN(llvm_gen_calculatenormal)
args[arg_count++] = rop.ll.mask_as_int(rop.ll.current_mask());
func_spec.mask();
}
rop.ll.call_function(rop.build_name(func_spec), { &args[0], arg_count });
rop.ll.call_function(rop.build_name(func_spec),
{ &args[0],
cspan<llvm::Value*>::size_type(arg_count) });
if (Result.has_derivs())
rop.llvm_zero_derivs(Result);
@@ -7002,6 +7000,16 @@ LLVMGEN(llvm_gen_spline)
&& (!has_knot_count
|| (has_knot_count && Knot_count.typespec().is_int())));
if (has_knot_count && !Knot_count.is_uniform()) {
// TODO: varying knot count support could be added below as we already
// have a loop to handle varying spline basis. Just need to add tests
// to exercise and verify functions properly, until then...
rop.shadingcontext()->errorfmt(
"spline nknots parameter is varying, batched code gen requires a constant or uniform nknots, called from ({}:{})",
op.sourcefile(), op.sourceline());
return false;
}
bool op_is_uniform = Spline.is_uniform() && Value.is_uniform()
&& Knots.is_uniform();
@@ -7052,7 +7060,8 @@ LLVMGEN(llvm_gen_spline)
args.push_back(rop.llvm_void_ptr(Value)); // make things easy
args.push_back(rop.llvm_void_ptr(Knots));
if (has_knot_count)
args.push_back(rop.llvm_load_value(Knot_count));
args.push_back(rop.llvm_load_value(
Knot_count)); // TODO: add support for varying Knot_count
else
args.push_back(rop.ll.constant((int)Knots.typespec().arraylength()));
args.push_back(rop.ll.constant((int)Knots.typespec().arraylength()));
@@ -7094,7 +7103,7 @@ LLVMGEN(llvm_gen_spline)
leadLane);
args[splineNameArgumentIndex] = scalar_splineName;
lanesMatchingSplineName = rop.ll.op_lanes_that_match_masked(
scalar_splineName, splineNameVal, remainingMask);
scalar_splineName, splineNameVal, remainingMask);
OSL_ASSERT(lanesMatchingSplineName);
//rop.llvm_print_mask("lanesMatchingSplineName", lanesMatchingSplineName);
@@ -7340,7 +7349,7 @@ LLVMGEN(llvm_gen_closure)
llvm::Value* dest_base = rop.ll.offset_ptr(mem_void_ptr, p.offset);
llvm::Type* dest_type = rop.ll.llvm_type(
static_cast<const TypeSpec&>(p.type).simpletype());
static_cast<const TypeSpec&>(p.type).simpletype());
dest_base = rop.ll.ptr_to_cast(dest_base, dest_type);
if (num_elements > 1) {
+10 -11
View File
@@ -1203,7 +1203,7 @@ BatchedBackendLLVM::llvm_assign_initial_value(
ll.constant(ncomps),
ll.constant("<get_userdata>") };
ll.call_function(build_name(FuncSpec("naninf_check_offset")
.arg_uniform(TypeDesc::TypeInt)
.arg_uniform(TypeInt)
.mask()),
args);
}
@@ -1465,7 +1465,7 @@ BatchedBackendLLVM::llvm_generate_debugnan(const Opcode& op)
ncheck,
ll.constant(op.opname()) };
ll.call_function(build_name(FuncSpec("naninf_check_offset")
.arg_varying(TypeDesc::TypeInt)
.arg_varying(TypeInt)
.mask()),
args);
@@ -1495,7 +1495,7 @@ BatchedBackendLLVM::llvm_generate_debugnan(const Opcode& op)
ncheck,
ll.constant(op.opname()) };
ll.call_function(build_name(FuncSpec("naninf_check_offset")
.arg_uniform(TypeDesc::TypeInt)
.arg_uniform(TypeInt)
.mask()),
args);
}
@@ -1639,14 +1639,14 @@ BatchedBackendLLVM::llvm_generate_debug_uninit(const Opcode& op)
ll.call_function(build_name(
FuncSpec("uninit_check_values_offset")
.arg_uniform(TypeDesc::PTR)
.arg_varying(TypeDesc::TypeInt)
.arg_varying(TypeInt)
.mask()),
args);
} else {
ll.call_function(build_name(
FuncSpec("uninit_check_values_offset")
.arg_varying(TypeDesc::PTR)
.arg_varying(TypeDesc::TypeInt)
.arg_varying(TypeInt)
.mask()),
args);
}
@@ -1671,7 +1671,7 @@ BatchedBackendLLVM::llvm_generate_debug_uninit(const Opcode& op)
ll.call_function(build_name(
FuncSpec("uninit_check_values_offset")
.arg_uniform(TypeDesc::PTR)
.arg_uniform(TypeDesc::TypeInt)),
.arg_uniform(TypeInt)),
args);
} else {
llvm::Value* args[]
@@ -1694,7 +1694,7 @@ BatchedBackendLLVM::llvm_generate_debug_uninit(const Opcode& op)
ll.call_function(build_name(
FuncSpec("uninit_check_values_offset")
.arg_varying(TypeDesc::PTR)
.arg_uniform(TypeDesc::TypeInt)
.arg_uniform(TypeInt)
.mask()),
args);
}
@@ -2109,10 +2109,9 @@ BatchedBackendLLVM::build_llvm_instance(bool groupentry)
ll.constant(0),
ll.constant(ncomps),
ll.constant("<none>") };
ll.call_function(build_name(
FuncSpec("naninf_check_offset")
.arg_uniform(TypeDesc::TypeInt)
.mask()),
ll.call_function(build_name(FuncSpec("naninf_check_offset")
.arg_uniform(TypeInt)
.mask()),
args);
}
}
+19
View File
@@ -14,6 +14,15 @@ using namespace OSL::pvt;
OSL_NAMESPACE_ENTER
#ifdef OIIO_TEXTURESYSTEM_CREATE_SHARED
namespace {
std::mutex shared_texturesys_mutex;
std::shared_ptr<TextureSystem> shared_texturesys;
} // namespace
#endif
template<int WidthT>
BatchedRendererServices<WidthT>::BatchedRendererServices(TextureSystem* texsys)
: m_texturesys(texsys)
@@ -27,7 +36,17 @@ BatchedRendererServices<WidthT>::BatchedRendererServices(TextureSystem* texsys)
OSL_ASSERT(
0 && "RendererServices was not passed a working TextureSystem*");
#else
# ifdef OIIO_TEXTURESYSTEM_CREATE_SHARED
{
std::lock_guard<std::mutex> lock(shared_texturesys_mutex);
if (!shared_texturesys) {
shared_texturesys = TextureSystem::create(true /* shared */);
}
m_texturesys = shared_texturesys.get();
}
# else
m_texturesys = TextureSystem::create(true /* shared */);
# endif
// Make some good guesses about default options
m_texturesys->attribute("automip", 1);
m_texturesys->attribute("autotile", 64);
+5 -5
View File
@@ -43,17 +43,17 @@ print_component_value(std::ostream& out, ShadingSystemImpl* ss, TypeDesc type,
const void* data)
{
if (type == TypeDesc::TypeInt)
if (type == TypeInt)
out << *(int*)data;
else if (type == TypeDesc::TypeFloat)
else if (type == TypeFloat)
out << *(float*)data;
else if (type == TypeDesc::TypeColor)
else if (type == TypeColor)
out << "(" << ((Color3*)data)->x << ", " << ((Color3*)data)->y << ", "
<< ((Color3*)data)->z << ")";
else if (type == TypeDesc::TypeVector)
else if (type == TypeVector)
out << "(" << ((Vec3*)data)->x << ", " << ((Vec3*)data)->y << ", "
<< ((Vec3*)data)->z << ")";
else if (type == TypeDesc::TypeString)
else if (type == TypeString)
out << "\"" << *((ustring*)data) << "\"";
else if (type == TypeDesc::PTR) // this only happens for closures
print_closure(out, *(const ClosureColor**)data, ss);
+28 -40
View File
@@ -291,7 +291,7 @@ DECLFOLDER(constfold_dot)
if (A.is_constant() && B.is_constant()) {
OSL_DASSERT(A.typespec().is_triple() && B.typespec().is_triple());
float result = A.get_vec3().dot(B.get_vec3());
int cind = rop.add_constant(TypeDesc::TypeFloat, &result);
int cind = rop.add_constant(TypeFloat, &result);
rop.turn_into_assign(op, cind, "dot(const,const)");
return 1;
}
@@ -376,8 +376,7 @@ DECLFOLDER(constfold_eq)
}
// Turn the 'eq R A B' into 'assign R X' where X is 0 or 1.
static const int int_zero = 0, int_one = 1;
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const == const");
return 1;
}
@@ -404,8 +403,7 @@ DECLFOLDER(constfold_neq)
}
// Turn the 'neq R A B' into 'assign R X' where X is 0 or 1.
static const int int_zero = 0, int_one = 1;
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const != const");
return 1;
}
@@ -436,8 +434,7 @@ DECLFOLDER(constfold_lt)
} else {
return 0; // unhandled case
}
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const < const");
return 1;
}
@@ -468,8 +465,7 @@ DECLFOLDER(constfold_le)
} else {
return 0; // unhandled case
}
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const <= const");
return 1;
}
@@ -500,8 +496,7 @@ DECLFOLDER(constfold_gt)
} else {
return 0; // unhandled case
}
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const > const");
return 1;
}
@@ -532,8 +527,7 @@ DECLFOLDER(constfold_ge)
} else {
return 0; // unhandled case
}
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const >= const");
return 1;
}
@@ -552,8 +546,7 @@ DECLFOLDER(constfold_or)
bool val = A.get_int() || B.get_int();
// Turn the 'or R A B' into 'assign R X' where X is 0 or 1.
static const int int_zero = 0, int_one = 1;
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const || const");
return 1;
}
@@ -572,8 +565,7 @@ DECLFOLDER(constfold_and)
OSL_DASSERT(A.typespec().is_int() && B.typespec().is_int());
bool val = A.get_int() && B.get_int();
static const int int_zero = 0, int_one = 1;
int cind = rop.add_constant(TypeDesc::TypeInt,
val ? &int_one : &int_zero);
int cind = rop.add_constant(TypeInt, val ? &int_one : &int_zero);
rop.turn_into_assign(op, cind, "const && const");
return 1;
}
@@ -1300,7 +1292,7 @@ DECLFOLDER(constfold_concat)
}
// If we made it this far, all args were constants, and the
// concatenation is in result.
int cind = rop.add_constant(TypeDesc::TypeString, &result);
int cind = rop.add_constant(TypeString, &result);
rop.turn_into_assign(op, cind, "const fold concat");
return 1;
}
@@ -1604,7 +1596,7 @@ DECLFOLDER(constfold_mix)
if (B.connected()) {
// Add the test and conditional for X==0, in which case we can
// just R=A and not have to access B
int cond = rop.add_temp(TypeDesc::TypeInt);
int cond = rop.add_temp(TypeInt);
int fzero = rop.add_constant(0.0f);
rop.insert_code(opnum++, u_eq, RuntimeOptimizer::GroupWithNext,
cond, Xind, fzero);
@@ -1621,7 +1613,7 @@ DECLFOLDER(constfold_mix)
if (A.connected()) {
// Add the test and conditional for X==1, in which case we can
// just R=B and not have to access A
int cond = rop.add_temp(TypeDesc::TypeInt);
int cond = rop.add_temp(TypeInt);
int fone = rop.add_constant(1.0f);
rop.insert_code(opnum++, u_eq, RuntimeOptimizer::GroupWithNext,
cond, Xind, fone);
@@ -2043,7 +2035,7 @@ DECLFOLDER(constfold_matrix)
// turn it into a constant rather than calling getmatrix at
// execution time.
Matrix44 Mresult = Mfrom * Mto;
int cind = rop.add_constant(TypeDesc::TypeMatrix, &Mresult);
int cind = rop.add_constant(TypeMatrix, &Mresult);
rop.turn_into_assign(op, cind, "const fold matrix");
return 1;
}
@@ -2079,7 +2071,7 @@ DECLFOLDER(constfold_matrix)
}
}
if (all_const) {
rop.turn_into_assign(op, rop.add_constant(TypeDesc::TypeMatrix, M),
rop.turn_into_assign(op, rop.add_constant(TypeMatrix, M),
"const fold matrix");
return 1;
}
@@ -2142,14 +2134,14 @@ DECLFOLDER(constfold_getmatrix)
rop.inst()->args()[op.firstarg() + 0] = dataarg;
// Now turn it into an assignment
Matrix44 Mresult = Mfrom * Mto;
int cind = rop.add_constant(TypeDesc::TypeMatrix, &Mresult);
int cind = rop.add_constant(TypeMatrix, &Mresult);
rop.turn_into_assign(op, cind, "getmatrix of known matrix");
// Now insert a new instruction that assigns 1 to the
// original return result of getmatrix.
const int one = 1;
const int args_to_add[] = { resultarg,
rop.add_constant(TypeDesc::TypeInt, &one) };
rop.add_constant(TypeInt, &one) };
rop.insert_code(opnum, u_assign, args_to_add,
RuntimeOptimizer::RecomputeRWRanges,
RuntimeOptimizer::GroupWithNext);
@@ -2316,22 +2308,19 @@ DECLFOLDER(constfold_getattribute)
bool found = false;
// Check global things first
if (attr_name == "osl:version" && attr_type == TypeDesc::TypeInt) {
if (attr_name == "osl:version" && attr_type == TypeInt) {
int* val = (int*)(char*)buf;
*val = OSL_VERSION;
found = true;
} else if (attr_name == "shader:shadername"
&& attr_type == TypeDesc::TypeString) {
} else if (attr_name == "shader:shadername" && attr_type == TypeString) {
ustring* up = (ustring*)(char*)buf;
*up = ustring(rop.inst()->shadername());
found = true;
} else if (attr_name == "shader:layername"
&& attr_type == TypeDesc::TypeString) {
} else if (attr_name == "shader:layername" && attr_type == TypeString) {
ustring* up = (ustring*)(char*)buf;
*up = rop.inst()->layername();
found = true;
} else if (attr_name == "shader:groupname"
&& attr_type == TypeDesc::TypeString) {
} else if (attr_name == "shader:groupname" && attr_type == TypeString) {
ustring* up = (ustring*)(char*)buf;
*up = rop.group().name();
found = true;
@@ -2374,7 +2363,7 @@ DECLFOLDER(constfold_getattribute)
// original return result of getattribute.
const int one = 1;
const int args_to_add[] = { oldresultarg,
rop.add_constant(TypeDesc::TypeInt, &one) };
rop.add_constant(TypeInt, &one) };
rop.insert_code(opnum, u_assign, args_to_add,
RuntimeOptimizer::RecomputeRWRanges,
RuntimeOptimizer::GroupWithNext);
@@ -2438,9 +2427,9 @@ DECLFOLDER(constfold_gettextureinfo)
// Now insert a new instruction that assigns 1 to the
// original return result of gettextureinfo.
int one = 1;
const int args_to_add[]
= { oldresultarg, rop.add_constant(TypeDesc::TypeInt, &one) };
int one = 1;
const int args_to_add[] = { oldresultarg,
rop.add_constant(TypeInt, &one) };
rop.insert_code(opnum, u_assign, args_to_add,
RuntimeOptimizer::RecomputeRWRanges,
RuntimeOptimizer::GroupWithNext);
@@ -2587,7 +2576,7 @@ DECLFOLDER(constfold_texture)
// Just turn the param name into empty string and it will
// be skipped.
ustring empty;
int cind = rop.add_constant(TypeDesc::TypeString, &empty);
int cind = rop.add_constant(TypeString, &empty);
rop.inst()->args()[op.firstarg() + i] = cind;
rop.inst()->args()[op.firstarg() + i + 1] = cind;
any_elided = true;
@@ -2739,8 +2728,7 @@ DECLFOLDER(constfold_pointcloud_search)
// Query results all copied. The only thing left to do is to assign
// status (query result count) to the original "result".
const int args_to_add[] = { result_sym,
rop.add_constant(TypeDesc::TypeInt, &count) };
const int args_to_add[] = { result_sym, rop.add_constant(TypeInt, &count) };
rop.insert_code(opnum, u_assign, args_to_add,
RuntimeOptimizer::RecomputeRWRanges,
RuntimeOptimizer::GroupWithNext);
@@ -2789,7 +2777,7 @@ DECLFOLDER(constfold_pointcloud_get)
&data[0]);
rop.shadingsys().pointcloud_stats(0, 1, 0);
rop.turn_into_assign(op, rop.add_constant(TypeDesc::TypeInt, &ok),
rop.turn_into_assign(op, rop.add_constant(TypeInt, &ok),
"Folded constant pointcloud_get");
// Now make a constant array for those results we just retrieved...
@@ -2908,7 +2896,7 @@ DECLFOLDER(constfold_noise)
cell(n, Vec3(input[0], input[1], input[2]));
else
cell(n, Vec3(input[0], input[1], input[2]), input[3]);
int cind = rop.add_constant(TypeDesc::TypePoint, &n);
int cind = rop.add_constant(TypePoint, &n);
rop.turn_into_assign(op, cind, "const fold cellnoise");
return 1;
}
+11 -15
View File
@@ -59,7 +59,6 @@ static ustring op_xor("xor");
static ustring u_distance("distance");
static ustring u_index("index");
static ustring u__empty; // empty/default ustring
@@ -1560,7 +1559,7 @@ LLVMGEN(llvm_gen_compassign)
}
for (int d = 0; d < 3; ++d) { // deriv
llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeDesc::TypeFloat);
llvm::Value* val = rop.llvm_load_value(Val, d, 0, TypeFloat);
if (Index.is_constant()) {
int i = Index.get_int();
i = Imath::clamp(i, 0, 2);
@@ -1671,7 +1670,7 @@ LLVMGEN(llvm_gen_mxcompassign)
}
}
llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeDesc::TypeFloat);
llvm::Value* val = rop.llvm_load_value(Val, 0, 0, TypeFloat);
if (Row.is_constant() && Col.is_constant()) {
int r = Imath::clamp(Row.get_int(), 0, 3);
@@ -1831,8 +1830,7 @@ LLVMGEN(llvm_gen_construct_color)
for (int d = 0; d < dmax; ++d) { // loop over derivs
for (int c = 0; c < 3; ++c) { // loop over components
const Symbol& comp = *rop.opargsym(op, c + 1 + using_space);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0,
TypeDesc::TypeFloat);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat);
rop.llvm_store_value(val, Result, d, NULL, c);
}
}
@@ -1877,8 +1875,7 @@ LLVMGEN(llvm_gen_construct_triple)
for (int d = 0; d < dmax; ++d) { // loop over derivs
for (int c = 0; c < 3; ++c) { // loop over components
const Symbol& comp = *rop.opargsym(op, c + 1 + using_space);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0,
TypeDesc::TypeFloat);
llvm::Value* val = rop.llvm_load_value(comp, d, NULL, 0, TypeFloat);
rop.llvm_store_value(val, Result, d, NULL, c);
}
}
@@ -2440,8 +2437,8 @@ LLVMGEN(llvm_gen_andor)
Symbol& b = *rop.opargsym(op, 2);
llvm::Value* i1_res = NULL;
llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeDesc::TypeInt);
llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeDesc::TypeInt);
llvm::Value* a_val = rop.llvm_load_value(a, 0, 0, TypeInt);
llvm::Value* b_val = rop.llvm_load_value(b, 0, 0, TypeInt);
if (op.opname() == op_and) {
// From the old bitcode generated
// define i32 @osl_and_iii(i32 %a, i32 %b) nounwind readnone ssp {
@@ -2721,8 +2718,7 @@ llvm_gen_texture_options(BackendLLVM& rop, int opnum, int first_optional_arg,
errormessage = rop.llvm_get_pointer(Val);
continue;
}
if (name == Strings::missingcolor
&& equivalent(valtype, TypeDesc::TypeColor)) {
if (name == Strings::missingcolor && equivalent(valtype, TypeColor)) {
if (!missingcolor) {
// If not already done, allocate enough storage for the
// missingcolor value (4 floats), and call the special
@@ -3091,12 +3087,12 @@ llvm_gen_noise_options(BackendLLVM& rop, int opnum, int first_optional_arg)
&& (Val.typespec().is_float() || Val.typespec().is_int())) {
rop.ll.call_function("osl_noiseparams_set_bandwidth", opt,
rop.llvm_load_value(Val, 0, NULL, 0,
TypeDesc::TypeFloat));
TypeFloat));
} else if (name == Strings::impulses
&& (Val.typespec().is_float() || Val.typespec().is_int())) {
rop.ll.call_function("osl_noiseparams_set_impulses", opt,
rop.llvm_load_value(Val, 0, NULL, 0,
TypeDesc::TypeFloat));
TypeFloat));
} else {
rop.shadingcontext()->errorfmt(
"Unknown {} optional argument: \"{}\", <{}> ({}:{})",
@@ -3831,11 +3827,11 @@ LLVMGEN(llvm_gen_closure)
const ClosureRegistry::ClosureEntry* clentry
= rop.shadingsys().find_closure(closure_name);
if (!clentry) {
rop.llvm_gen_error(fmtformat(
rop.shadingcontext()->errorfmt(
"Closure '{}' is not supported by the current renderer, called from {}:{} in shader \"{}\", layer {} \"{}\", group \"{}\"",
closure_name, op.sourcefile(), op.sourceline(),
rop.inst()->shadername(), rop.layer(), rop.inst()->layername(),
rop.group().name()));
rop.group().name());
return false;
}
+16 -1
View File
@@ -482,6 +482,9 @@ BackendLLVM::build_offsets_of_ShaderGlobals(
offset_by_index.push_back(offsetof(ShaderGlobals, flipHandedness));
offset_by_index.push_back(offsetof(ShaderGlobals, backfacing));
}
void
BackendLLVM::llvm_assign_initial_value(const Symbol& sym, bool force)
{
@@ -1626,7 +1629,13 @@ BackendLLVM::prepare_module_for_cuda_jit()
for (llvm::Function& fn : *ll.module()) {
if (fn.hasFnAttribute("osl-lib-function")) {
fn.setLinkage(llvm::GlobalValue::ExternalLinkage);
} else if (fn.getName().startswith(group().name().c_str())) {
}
#if OSL_LLVM_VERSION >= 180
else if (fn.getName().starts_with(group().name().c_str()))
#else
else if (fn.getName().startswith(group().name().c_str()))
#endif
{
fn.setLinkage(llvm::GlobalValue::PrivateLinkage);
}
}
@@ -1638,9 +1647,15 @@ BackendLLVM::prepare_module_for_cuda_jit()
// Don't modify the inlining attribute for:
// * group entry functions
// * llvm library functions
#if OSL_LLVM_VERSION >= 180
if (fn.getName().starts_with("__direct_callable__")
|| fn.getName().starts_with("llvm."))
continue;
#else
if (fn.getName().startswith("__direct_callable__")
|| fn.getName().startswith("llvm."))
continue;
#endif
// Merge layer functions which are only called from one place
if (merge_layer_funcs && !fn.hasFnAttribute("osl-lib-function")
+4 -4
View File
@@ -639,19 +639,19 @@ osl_step_vvv(void* result, void* edge, void* x)
OSL_SHADEOP int
osl_isnan_if(float f)
{
return OIIO::isnan(f);
return std::isnan(f);
}
OSL_SHADEOP int
osl_isinf_if(float f)
{
return OIIO::isinf(f);
return std::isinf(f);
}
OSL_SHADEOP int
osl_isfinite_if(float f)
{
return OIIO::isfinite(f);
return std::isfinite(f);
}
@@ -705,7 +705,7 @@ safe_div(float a, float b)
// to see if is finite and return 0.0f when it is not.
// Typical implementation isfinite is (fabs(v) != INF), so not too expensive.
float q = a / b;
return OIIO::isfinite(q) ? q : 0.0f;
return std::isfinite(q) ? q : 0.0f;
// TODO: add a FTZ mode and only add checking the result when FTZ is disabled
#endif
}
+4
View File
@@ -349,7 +349,11 @@ public:
// Should handle promoting whatever the constant value is (most likely zeroinitializer)
llvm::ConstantFolder Folder;
auto* signExtConstant
#if OSL_LLVM_VERSION < 180
= Folder.CreateCast(
#else
= Folder.FoldCast(
#endif
llvm::Instruction::SExt,
constant, m_native_mask_type);
+58 -41
View File
@@ -45,7 +45,11 @@
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/ErrorOr.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/Host.h>
#if OSL_LLVM_VERSION < 160
# include <llvm/Support/Host.h>
#else
# include <llvm/TargetParser/Host.h>
#endif
#include <llvm/Support/raw_os_ostream.h>
#if OSL_LLVM_VERSION < 140
# include <llvm/Support/TargetRegistry.h>
@@ -359,10 +363,7 @@ public:
{
mm->registerEHFrames(Addr, LoadAddr, Size);
}
void deregisterEHFrames() override
{
mm->deregisterEHFrames();
}
void deregisterEHFrames() override { mm->deregisterEHFrames(); }
uint64_t getSymbolAddress(const std::string& Name) override
{
@@ -431,6 +432,7 @@ LLVM_Util::LLVM_Util(const PerThreadInfo& per_thread_info, int debuglevel,
, m_llvm_func_passes(NULL)
, m_new_pass_manager(NULL)
, m_llvm_exec(NULL)
, m_nvptx_target_machine(nullptr)
, m_vector_width(vector_width)
, m_llvm_type_native_mask(nullptr)
, mVTuneNotifier(nullptr)
@@ -488,26 +490,20 @@ LLVM_Util::LLVM_Util(const PerThreadInfo& per_thread_info, int debuglevel,
else
m_llvm_type_addrint = (llvm::Type*)llvm::Type::getInt64Ty(
*m_llvm_context);
m_llvm_type_int_ptr = (llvm::PointerType*)llvm::Type::getInt32PtrTy(
*m_llvm_context);
m_llvm_type_int8_ptr = (llvm::PointerType*)llvm::Type::getInt8PtrTy(
*m_llvm_context);
m_llvm_type_int64_ptr = (llvm::PointerType*)llvm::Type::getInt64PtrTy(
*m_llvm_context);
m_llvm_type_bool = (llvm::Type*)llvm::Type::getInt1Ty(*m_llvm_context);
m_llvm_type_bool_ptr = (llvm::PointerType*)llvm::Type::getInt1PtrTy(
*m_llvm_context);
m_llvm_type_char = (llvm::Type*)llvm::Type::getInt8Ty(*m_llvm_context);
m_llvm_type_longlong = (llvm::Type*)llvm::Type::getInt64Ty(*m_llvm_context);
m_llvm_type_void = (llvm::Type*)llvm::Type::getVoidTy(*m_llvm_context);
m_llvm_type_char_ptr = (llvm::PointerType*)llvm::Type::getInt8PtrTy(
*m_llvm_context);
m_llvm_type_float_ptr = (llvm::PointerType*)llvm::Type::getFloatPtrTy(
*m_llvm_context);
m_llvm_type_longlong_ptr = (llvm::PointerType*)llvm::Type::getInt64PtrTy(
*m_llvm_context);
m_llvm_type_void_ptr = m_llvm_type_char_ptr;
m_llvm_type_double_ptr = llvm::Type::getDoublePtrTy(*m_llvm_context);
m_llvm_type_int_ptr = llvm::PointerType::get(m_llvm_type_int, 0);
m_llvm_type_int8_ptr = llvm::PointerType::get(m_llvm_type_int8, 0);
m_llvm_type_int64_ptr = llvm::PointerType::get(m_llvm_type_int64, 0);
m_llvm_type_bool_ptr = llvm::PointerType::get(m_llvm_type_bool, 0);
m_llvm_type_char_ptr = llvm::PointerType::get(m_llvm_type_char, 0);
m_llvm_type_void_ptr = m_llvm_type_char_ptr;
m_llvm_type_float_ptr = llvm::PointerType::get(m_llvm_type_float, 0);
m_llvm_type_longlong_ptr = llvm::PointerType::get(m_llvm_type_int64, 0);
m_llvm_type_double_ptr = llvm::PointerType::get(m_llvm_type_double, 0);
// A triple is a struct composed of 3 floats
std::vector<llvm::Type*> triplefields(3, m_llvm_type_float);
@@ -561,7 +557,7 @@ void
LLVM_Util::ustring_rep(UstringRep rep)
{
m_ustring_rep = rep;
m_llvm_type_ustring = llvm::Type::getInt8PtrTy(*m_llvm_context);
m_llvm_type_ustring = m_llvm_type_int8_ptr;
// ^^ When m_ustring_rep != UstringRep::charptr, we'd ideally want to make
// it a uint directly, but that is wreaking havoc with function
// signatures, so continue to disguise it as a pointer.
@@ -585,6 +581,7 @@ LLVM_Util::~LLVM_Util()
delete m_new_pass_manager;
delete m_builder;
delete m_llvm_debug_builder;
delete m_nvptx_target_machine;
module(NULL);
// DO NOT delete m_llvm_jitmm; // just the dummy wrapper around the real MM
}
@@ -775,17 +772,17 @@ LLVM_Util::debug_push_inlined_function(OIIO::ustring function_name,
llvm::DINode::FlagPrototyped | llvm::DINode::FlagNoReturn);
llvm::DISubprogram* function = nullptr;
function = m_llvm_debug_builder->createFunction(
mDebugCU, // Scope
function_name.c_str(), // Name
// We are inlined function so not sure supplying a linkage name
// makes sense
/*function_name.c_str()*/ llvm::StringRef(), // Linkage Name
file, // File
static_cast<unsigned int>(sourceline), // Line Number
mSubTypeForInlinedFunction, // subroutine type
method_scope_line, // Scope Line,
fnFlags,
llvm::DISubprogram::toSPFlags(true /*isLocalToUnit*/,
mDebugCU, // Scope
function_name.c_str(), // Name
// We are inlined function so not sure supplying a linkage name
// makes sense
/*function_name.c_str()*/ llvm::StringRef(), // Linkage Name
file, // File
static_cast<unsigned int>(sourceline), // Line Number
mSubTypeForInlinedFunction, // subroutine type
method_scope_line, // Scope Line,
fnFlags,
llvm::DISubprogram::toSPFlags(true /*isLocalToUnit*/,
true /*isDefinition*/,
true /*false*/ /*isOptimized*/));
@@ -1511,8 +1508,14 @@ LLVM_Util::make_jit_execengine(std::string* err, TargetISA requestedISA,
std::unique_ptr<llvm::RTDyldMemoryManager>(
new MemoryManager(m_llvm_jitmm)));
#if OSL_LLVM_VERSION >= 180
engine_builder.setOptLevel(jit_aggressive()
? llvm::CodeGenOptLevel::Aggressive
: llvm::CodeGenOptLevel::Default);
#else
engine_builder.setOptLevel(jit_aggressive() ? llvm::CodeGenOpt::Aggressive
: llvm::CodeGenOpt::Default);
#endif
llvm::TargetOptions options;
// Enables FMA's in IR generation.
@@ -1814,7 +1817,12 @@ LLVM_Util::nvptx_target_machine()
m_nvptx_target_machine = llvm_target->createTargetMachine(
ModuleTriple.str(), CUDA_TARGET_ARCH, "+ptx50", options,
llvm::Reloc::Static, llvm::CodeModel::Small,
llvm::CodeGenOpt::Default);
#if OSL_LLVM_VERSION >= 180
llvm::CodeGenOptLevel::Default
#else
llvm::CodeGenOpt::Default
#endif
);
OSL_ASSERT(m_nvptx_target_machine
&& "Unable to create TargetMachine for NVPTX");
@@ -2954,7 +2962,12 @@ LLVM_Util::prune_and_internalize_module(
|| llvm::cast<llvm::GlobalValue>(val)
->hasLocalLinkage()) {
if (!debug()
|| !val->getName().startswith("llvm.dbg")) {
#if OSL_LLVM_VERSION >= 180
|| !val->getName().starts_with("llvm.dbg")
#else
|| !val->getName().startswith("llvm.dbg")
#endif
) {
__OSL_PRUNE_ONLY(
std::cout
<< "remove symbol table for value: "
@@ -4666,8 +4679,8 @@ LLVM_Util::op_gather(llvm::Type* src_type, llvm::Value* src_ptr,
llvm::Value* unmasked_value = wide_constant(0.0f);
llvm::Value* args[] = {
unmasked_value, void_ptr(src_ptr), wide_index, int_mask,
constant(4) // not sure why the scale
unmasked_value, void_ptr(src_ptr), wide_index, int_mask,
constant(4) // not sure why the scale
};
return builder().CreateCall(func_avx512_gather_ps,
toArrayRef(args));
@@ -5602,9 +5615,9 @@ LLVM_Util::apply_return_to(llvm::Value* existing_mask)
OSL_ASSERT(masked_function_context().return_count > 0);
llvm::Value* loc_of_return_mask = masked_function_context().location_of_mask;
llvm::Value* rs_mask = op_load_mask(loc_of_return_mask);
llvm::Value* result = builder().CreateSelect(rs_mask, existing_mask,
rs_mask);
llvm::Value* rs_mask = op_load_mask(loc_of_return_mask);
llvm::Value* result = builder().CreateSelect(rs_mask, existing_mask,
rs_mask);
return result;
}
@@ -6483,7 +6496,11 @@ LLVM_Util::ptx_compile_group(llvm::Module*, const std::string& name,
llvm::raw_svector_ostream assembly_stream(assembly);
// TODO: Make sure rounding modes, etc., are set correctly
# if OSL_LLVM_VERSION >= 100
# if OSL_LLVM_VERSION >= 180
target_machine->addPassesToEmitFile(mpm, assembly_stream,
nullptr, // FIXME: Correct?
llvm::CodeGenFileType::AssemblyFile);
# elif OSL_LLVM_VERSION >= 100
target_machine->addPassesToEmitFile(mpm, assembly_stream,
nullptr, // FIXME: Correct?
llvm::CGFT_AssemblyFile);
+5 -5
View File
@@ -417,21 +417,21 @@ OSOReaderToMaster::hint(string_view hintstring)
if (m_master->m_symbols.size()) {
// metadata is attached to a particular symbol
Symbol& sym(m_master->m_symbols.back());
if (type == TypeDesc::TypeInt && ident == "lockgeom"
if (type == TypeInt && ident == "lockgeom"
&& Strutil::parse_int(h, ival) && ival >= 0)
sym.interpolated(!ival); // soft deprecated
else if (type == TypeDesc::TypeInt && ident == "interpolated"
else if (type == TypeInt && ident == "interpolated"
&& Strutil::parse_int(h, ival) && ival >= 0)
sym.interpolated(ival);
else if (type == TypeDesc::TypeInt && ident == "interactive"
else if (type == TypeInt && ident == "interactive"
&& Strutil::parse_int(h, ival) && ival >= 0)
sym.interactive(ival);
else if (type == TypeDesc::TypeInt && ident == "allowconnect"
else if (type == TypeInt && ident == "allowconnect"
&& Strutil::parse_int(h, ival) && ival >= 0)
sym.allowconnect(ival);
} else {
// metadata is attached at the shader level
if (type == TypeDesc::TypeInt && ident == "range_checking"
if (type == TypeInt && ident == "range_checking"
&& Strutil::parse_int(h, ival) && ival >= 0)
m_master->range_checking(ival != 0);
}
+1 -1
View File
@@ -538,7 +538,7 @@ ColorSystem::lookup_blackbody_rgb(float T /*Kelvin*/) const
constexpr int stride = sizeof(Color3) / sizeof(float);
int sti = stride * ti;
Color3 rgb = OIIO::lerp(
// Have all gathers use the same indices by having different base registers
// Have all gathers use the same indices by having different base registers
// for each of the 6 components
Color3((blackbody_components + 0)[sti], (blackbody_components + 1)[sti],
(blackbody_components + 2)[sti]),
+30 -113
View File
@@ -805,10 +805,7 @@ public:
}
#endif
void clear_symlocs()
{
m_symlocs.clear();
}
void clear_symlocs() { m_symlocs.clear(); }
void add_symlocs(cspan<SymLocationDesc> symlocs)
{
for (auto& s : symlocs)
@@ -874,7 +871,8 @@ private:
void setup_op_descriptors();
RendererServices* m_renderer; ///< Renderer services
TextureSystem* m_texturesys; ///< Texture system
std::shared_ptr<TextureSystem> m_texturesys_sp;
TextureSystem* m_texturesys; ///< Texture system
ErrorHandler* m_err; ///< Error handler
mutable std::list<std::string> m_errseen, m_warnseen;
@@ -1518,10 +1516,7 @@ public:
typedef std::vector<SymOverrideInfo> SymOverrideInfoVec;
static_assert(sizeof(SymOverrideInfo) == 8, "SymOverrideInfo size");
SymOverrideInfo* instoverride(int i)
{
return &m_instoverrides[i];
}
SymOverrideInfo* instoverride(int i) { return &m_instoverrides[i]; }
const SymOverrideInfo* instoverride(int i) const
{
return &m_instoverrides[i];
@@ -1838,19 +1833,10 @@ public:
}
#endif
// Is this shader group equivalent to ret void?
bool does_nothing() const
{
return m_does_nothing;
}
void does_nothing(bool new_val)
{
m_does_nothing = new_val;
}
bool does_nothing() const { return m_does_nothing; }
void does_nothing(bool new_val) { m_does_nothing = new_val; }
long long int executions() const
{
return m_executions;
}
long long int executions() const { return m_executions; }
void start_running()
{
@@ -1859,25 +1845,13 @@ public:
#endif
}
void name(ustring name)
{
m_name = name;
}
ustring name() const
{
return m_name;
}
void name(ustring name) { m_name = name; }
ustring name() const { return m_name; }
std::string serialize() const;
void lock() const
{
m_mutex.lock();
}
void unlock() const
{
m_mutex.unlock();
}
void lock() const { m_mutex.lock(); }
void unlock() const { m_mutex.unlock(); }
// Find which layer index corresponds to the layer name. Return -1 if
// not found.
@@ -1889,10 +1863,7 @@ public:
/// Return a unique ID of this group.
///
int id() const
{
return m_id;
}
int id() const { return m_id; }
/// Mark all layers as not entry points and set m_num_entry_layers to 0.
void clear_entry_layers();
@@ -1906,15 +1877,9 @@ public:
mark_entry_layer(find_layer(layername));
}
int num_entry_layers() const
{
return m_num_entry_layers;
}
int num_entry_layers() const { return m_num_entry_layers; }
bool is_last_layer(int layer) const
{
return layer == nlayers() - 1;
}
bool is_last_layer(int layer) const { return layer == nlayers() - 1; }
/// Is the given layer an entry point? It is if explicitly tagged as
/// such, or if no layers are so tagged then the last layer is the one
@@ -1925,10 +1890,7 @@ public:
: is_last_layer(layer);
}
int raytype_queries() const
{
return m_raytype_queries;
}
int raytype_queries() const { return m_raytype_queries; }
/// Optionally set which ray types are known to be on or off (0 means
/// not known at optimize time).
@@ -1937,19 +1899,10 @@ public:
m_raytypes_on = raytypes_on;
m_raytypes_off = raytypes_off;
}
int raytypes_on() const
{
return m_raytypes_on;
}
int raytypes_off() const
{
return m_raytypes_off;
}
int raytypes_on() const { return m_raytypes_on; }
int raytypes_off() const { return m_raytypes_off; }
void clear_symlocs()
{
m_symlocs.clear();
}
void clear_symlocs() { m_symlocs.clear(); }
void add_symlocs(cspan<SymLocationDesc> symlocs)
{
for (auto& s : symlocs) {
@@ -1989,10 +1942,7 @@ public:
// live with the group and copy the initial data.
void setup_interactive_arena(cspan<uint8_t> paramblock);
uint8_t* interactive_arena_ptr()
{
return m_interactive_arena.get();
}
uint8_t* interactive_arena_ptr() { return m_interactive_arena.get(); }
device_ptr<uint8_t>& device_interactive_arena()
{
@@ -2331,25 +2281,13 @@ public:
/// Return a pointer to the shading group for this context.
///
ShaderGroup* group()
{
return m_group;
}
const ShaderGroup* group() const
{
return m_group;
}
void group(ShaderGroup* grp)
{
m_group = grp;
}
ShaderGroup* group() { return m_group; }
const ShaderGroup* group() const { return m_group; }
void group(ShaderGroup* grp) { m_group = grp; }
/// Return a reference to the MessageList containing messages.
///
MessageList& messages()
{
return m_messages;
}
MessageList& messages() { return m_messages; }
#if OSL_USE_BATCHED
BatchedMessageBuffer& batched_messages_buffer()
{
@@ -2376,10 +2314,7 @@ public:
int array_lookup, int index, TypeDesc attr_type,
void* attr_dest);
PerThreadInfo* thread_info() const
{
return m_threadinfo;
}
PerThreadInfo* thread_info() const { return m_threadinfo; }
TextureSystem::Perthread* texture_thread_info() const
{
@@ -2399,20 +2334,11 @@ public:
return thread_info()->llvm_thread_info;
}
TextureOpt* texture_options_ptr()
{
return &m_textureopt;
}
TextureOpt* texture_options_ptr() { return &m_textureopt; }
RendererServices::NoiseOpt* noise_options_ptr()
{
return &m_noiseopt;
}
RendererServices::NoiseOpt* noise_options_ptr() { return &m_noiseopt; }
RendererServices::TraceOpt* trace_options_ptr()
{
return &m_traceopt;
}
RendererServices::TraceOpt* trace_options_ptr() { return &m_traceopt; }
void* alloc_scratch(size_t size, size_t align = 1)
{
@@ -2423,15 +2349,9 @@ public:
bool ocio_transform(StringParam fromspace, StringParam tospace,
const Color& C, Color& Cout);
void incr_layers_executed()
{
++m_stat_layers_executed;
}
void incr_layers_executed() { ++m_stat_layers_executed; }
void incr_get_userdata_calls()
{
++m_stat_get_userdata_calls;
}
void incr_get_userdata_calls() { ++m_stat_get_userdata_calls; }
// Clear the stats we record per-execution in this context (unlocked)
void clear_runtime_stats()
@@ -2581,10 +2501,7 @@ private:
// When interpreting symbol addresses we need to know if the
// wide data offsets should be used
int batch_size_executed;
bool execution_is_batched() const
{
return batch_size_executed != 0;
}
bool execution_is_batched() const { return batch_size_executed != 0; }
};
+8 -8
View File
@@ -330,14 +330,14 @@ inline TypeDesc
OSL::pvt::osolextype (int lex)
{
switch (lex) {
case COLORTYPE : return TypeDesc::TypeColor;
case FLOATTYPE : return TypeDesc::TypeFloat;
case INTTYPE : return TypeDesc::TypeInt;
case MATRIXTYPE : return TypeDesc::TypeMatrix;
case NORMALTYPE : return TypeDesc::TypeNormal;
case POINTTYPE : return TypeDesc::TypePoint;
case STRINGTYPE : return TypeDesc::TypeString;
case VECTORTYPE : return TypeDesc::TypeVector;
case COLORTYPE : return TypeColor;
case FLOATTYPE : return TypeFloat;
case INTTYPE : return TypeInt;
case MATRIXTYPE : return TypeMatrix;
case NORMALTYPE : return TypeNormal;
case POINTTYPE : return TypePoint;
case STRINGTYPE : return TypeString;
case VECTORTYPE : return TypeVector;
case VOIDTYPE : return TypeDesc::NONE;
default: return TypeDesc::UNKNOWN;
}
+8 -1
View File
@@ -3,6 +3,7 @@
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
#include <cstdarg>
#include <sstream>
#include "pointcloud.h"
@@ -29,7 +30,13 @@ PointCloud::get(ustringhash filename, bool write)
// Not found. Create a new one.
Partio::ParticlesDataMutable* partio_cloud = nullptr;
if (!write) {
partio_cloud = Partio::read(filename.c_str(), false);
// Mute Partio error prints: by default Partio::read sends errors directly
// to std::err, but in most cases we want errors to go via errorfmt so the
// renderer can recognize the message as an error, as we do in
// pointcloud_search and pointcloud_get.
std::stringstream m_errorStream;
partio_cloud = Partio::read(filename.c_str(), false, m_errorStream);
if (!partio_cloud)
return nullptr;
} else {
+3 -3
View File
@@ -72,13 +72,13 @@ struct SortedPointCompare {
inline Partio::ParticleAttributeType
PartioType(TypeDesc t)
{
if (t == TypeDesc::TypeFloat)
if (t == TypeFloat)
return Partio::FLOAT;
if (t.basetype == TypeDesc::FLOAT && t.aggregate == TypeDesc::VEC3)
return Partio::VECTOR;
if (t == TypeDesc::TypeInt)
if (t == TypeInt)
return Partio::INT;
if (t == TypeDesc::TypeString)
if (t == TypeString)
return Partio::INDEXEDSTR;
return Partio::NONE;
}
+18
View File
@@ -19,6 +19,14 @@ using namespace OSL::pvt;
OSL_NAMESPACE_ENTER
#ifdef OIIO_TEXTURESYSTEM_CREATE_SHARED
namespace {
std::mutex shared_texturesys_mutex;
std::shared_ptr<TextureSystem> shared_texturesys;
} // namespace
#endif
RendererServices::RendererServices(TextureSystem* texsys) : m_texturesys(texsys)
{
@@ -31,7 +39,17 @@ RendererServices::RendererServices(TextureSystem* texsys) : m_texturesys(texsys)
OSL_ASSERT(
0 && "RendererServices was not passed a working TextureSystem*");
#else
# ifdef OIIO_TEXTURESYSTEM_CREATE_SHARED
{
std::lock_guard<std::mutex> lock(shared_texturesys_mutex);
if (!shared_texturesys) {
shared_texturesys = TextureSystem::create(true /* shared */);
}
m_texturesys = shared_texturesys.get();
}
# else
m_texturesys = TextureSystem::create(true /* shared */);
# endif
// Make some good guesses about default options
m_texturesys->attribute("automip", 1);
m_texturesys->attribute("autotile", 64);
+8 -4
View File
@@ -42,6 +42,8 @@ static ustring u_setmessage("setmessage");
static ustring u_getmessage("getmessage");
static ustring u_getattribute("getattribute");
static ustring u_backfacing("backfacing");
static ustring u_calculatenormal("calculatenormal");
static ustring u_flipHandedness("flipHandedness");
static ustring u_N("N");
static ustring u_I("I");
@@ -2499,8 +2501,9 @@ RuntimeOptimizer::resolve_isconnected()
bool upconnected = s->connected();
if (s->interpolated() && shadingsys().userdata_isconnected())
upconnected = true;
int val = (upconnected ? 1 : 0) + (s->connected_down() ? 2 : 0);
turn_into_assign(op, add_constant(TypeDesc::TypeInt, &val),
bool downconnected = s->connected_down() || s->renderer_output();
int val = (upconnected ? 1 : 0) + (downconnected ? 2 : 0);
turn_into_assign(op, add_constant(TypeInt, &val),
"resolve isconnected()");
}
}
@@ -3350,8 +3353,9 @@ RuntimeOptimizer::run()
m_unknown_closures_needed = true;
}
} else if (op.opname() == u_backfacing) {
m_globals_needed.insert(u_N);
m_globals_needed.insert(u_I);
m_globals_needed.insert(u_backfacing);
} else if (op.opname() == u_calculatenormal) {
m_globals_needed.insert(u_flipHandedness);
} else if (op.opname() == u_getattribute) {
Symbol* sym1 = opargsym(op, 1);
OSL_DASSERT(sym1 && sym1->typespec().is_string());
+6 -15
View File
@@ -81,20 +81,11 @@ public:
/// and returning its index.
int add_constant(const TypeSpec& type, const void* data,
TypeDesc datatype = TypeDesc::UNKNOWN);
int add_constant(float c) { return add_constant(TypeDesc::TypeFloat, &c); }
int add_constant(int c) { return add_constant(TypeDesc::TypeInt, &c); }
int add_constant(ustring s)
{
return add_constant(TypeDesc::TypeString, &s);
}
int add_constant(const Matrix44& c)
{
return add_constant(TypeDesc::TypeMatrix, &c);
}
int add_constantc(const Color3& c)
{
return add_constant(TypeDesc::TypeColor, &c);
}
int add_constant(float c) { return add_constant(TypeFloat, &c); }
int add_constant(int c) { return add_constant(TypeInt, &c); }
int add_constant(ustring s) { return add_constant(TypeString, &s); }
int add_constant(const Matrix44& c) { return add_constant(TypeMatrix, &c); }
int add_constantc(const Color3& c) { return add_constant(TypeColor, &c); }
int add_constantv(const Vec3& c, const TypeSpec& vectype)
{
return add_constant(vectype, &c);
@@ -102,7 +93,7 @@ public:
int add_constant(string_view s)
{
ustring u(s);
return add_constant(TypeDesc::TypeString, &s);
return add_constant(TypeString, &s);
}
/// Create a new temporary variable of the given type, return its index.
+41 -39
View File
@@ -905,17 +905,17 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src,
tmp_int = *(const unsigned char*)src;
src = &tmp_int;
}
srctype = TypeDesc::TypeInt;
srctype = TypeInt;
}
float tmp_float;
if (srctype == TypeDesc::TypeInt && dsttype.basetype == TypeDesc::FLOAT) {
if (srctype == TypeInt && dsttype.basetype == TypeDesc::FLOAT) {
// int -> float-based : up-convert the source to float
if (src) {
tmp_float = (float)(*(const int*)src);
src = &tmp_float;
}
srctype = TypeDesc::TypeFloat;
srctype = TypeFloat;
}
// Just copy equivalent types
@@ -925,9 +925,9 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src,
return true;
}
if (srctype == TypeDesc::TypeFloat) {
if (srctype == TypeFloat) {
// float->triple conversion
if (equivalent(dsttype, TypeDesc::TypePoint)) {
if (equivalent(dsttype, TypePoint)) {
if (dst && src) {
float f = *(const float*)src;
((OSL::Vec3*)dst)->setValue(f, f, f);
@@ -935,7 +935,7 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src,
return true;
}
// float->int
if (dsttype == TypeDesc::TypeInt) {
if (dsttype == TypeInt) {
if (dst && src)
*(int*)dst = (int)*(const float*)src;
return true;
@@ -964,26 +964,23 @@ ShadingSystem::convert_value(void* dst, TypeDesc dsttype, const void* src,
}
// float[3] -> triple
if ((srctype == TypeFloatArray3 && equivalent(dsttype, TypeDesc::TypePoint))
|| (dsttype == TypeFloatArray3
&& equivalent(srctype, TypeDesc::TypePoint))) {
if ((srctype == TypeFloatArray3 && equivalent(dsttype, TypePoint))
|| (dsttype == TypeFloatArray3 && equivalent(srctype, TypePoint))) {
if (dst && src)
memmove(dst, src, dsttype.size());
return true;
}
// float[4] -> vec4
if ((srctype == TypeFloatArray4 && equivalent(dsttype, TypeDesc::TypeFloat4))
|| (dsttype == TypeFloatArray4
&& equivalent(srctype, TypeDesc::TypeFloat4))) {
if ((srctype == TypeFloatArray4 && equivalent(dsttype, TypeFloat4))
|| (dsttype == TypeFloatArray4 && equivalent(srctype, TypeFloat4))) {
if (dst && src)
memmove(dst, src, dsttype.size());
return true;
}
// float[2] -> triple
if (srctype == TypeFloatArray2
&& equivalent(dsttype, TypeDesc::TypePoint)) {
if (srctype == TypeFloatArray2 && equivalent(dsttype, TypePoint)) {
if (dst && src) {
float f0 = ((const float*)src)[0];
float f1 = ((const float*)src)[1];
@@ -1203,7 +1200,12 @@ ShadingSystemImpl::ShadingSystemImpl(RendererServices* renderer,
OSL_ASSERT(0
&& "ShadingSystem was not passed a working TextureSystem*");
#else
# if OIIO_TEXTURESYSTEM_CREATE_SHARED
m_texturesys_sp = TextureSystem::create(true /* shared */);
m_texturesys = m_texturesys_sp.get();
# else
m_texturesys = TextureSystem::create(true /* shared */);
# endif
// Make some good guesses about default options
m_texturesys->attribute("automip", 1);
m_texturesys->attribute("autotile", 64);
@@ -2031,11 +2033,11 @@ ShadingSystemImpl::attribute(ShaderGroup* group, string_view name,
group->mark_entry_layer(ustring(((const char**)val)[i]));
return true;
}
if (name == "exec_repeat" && type == TypeDesc::TypeInt) {
if (name == "exec_repeat" && type == TypeInt) {
group->m_exec_repeat = *(const int*)val;
return true;
}
if (name == "groupname" && type == TypeDesc::TypeString) {
if (name == "groupname" && type == TypeString) {
group->name(ustring(((const char**)val)[0]));
return true;
}
@@ -2051,11 +2053,11 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
if (!group)
return false;
if (name == "groupname" && type == TypeDesc::TypeString) {
if (name == "groupname" && type == TypeString) {
*(ustring*)val = group->name();
return true;
}
if (name == "num_layers" && type == TypeDesc::TypeInt) {
if (name == "num_layers" && type == TypeInt) {
*(int*)val = group->nlayers();
return true;
}
@@ -2123,7 +2125,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
*(ustring*)val = ustring(group->serialize());
return true;
}
if (name == "exec_repeat" && type == TypeDesc::TypeInt) {
if (name == "exec_repeat" && type == TypeInt) {
*(int*)val = group->m_exec_repeat;
return true;
}
@@ -2151,7 +2153,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
destroy_thread_info(threadinfo);
}
if (name == "num_textures_needed" && type == TypeDesc::TypeInt) {
if (name == "num_textures_needed" && type == TypeInt) {
*(int*)val = (int)group->m_textures_needed.size();
return true;
}
@@ -2160,12 +2162,12 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
*(ustring**)val = n ? &group->m_textures_needed[0] : NULL;
return true;
}
if (name == "unknown_textures_needed" && type == TypeDesc::TypeInt) {
if (name == "unknown_textures_needed" && type == TypeInt) {
*(int*)val = (int)group->m_unknown_textures_needed;
return true;
}
if (name == "num_closures_needed" && type == TypeDesc::TypeInt) {
if (name == "num_closures_needed" && type == TypeInt) {
*(int*)val = (int)group->m_closures_needed.size();
return true;
}
@@ -2174,12 +2176,12 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
*(ustring**)val = n ? &group->m_closures_needed[0] : NULL;
return true;
}
if (name == "unknown_closures_needed" && type == TypeDesc::TypeInt) {
if (name == "unknown_closures_needed" && type == TypeInt) {
*(int*)val = (int)group->m_unknown_closures_needed;
return true;
}
if (name == "num_globals_needed" && type == TypeDesc::TypeInt) {
if (name == "num_globals_needed" && type == TypeInt) {
*(int*)val = (int)group->m_globals_needed.size();
return true;
}
@@ -2197,7 +2199,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
return true;
}
if (name == "num_userdata" && type == TypeDesc::TypeInt) {
if (name == "num_userdata" && type == TypeInt) {
*(int*)val = (int)group->m_userdata_names.size();
return true;
}
@@ -2221,7 +2223,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
*(char**)val = n ? &group->m_userdata_derivs[0] : NULL;
return true;
}
if (name == "num_attributes_needed" && type == TypeDesc::TypeInt) {
if (name == "num_attributes_needed" && type == TypeInt) {
*(int*)val = (int)group->m_attributes_needed.size();
return true;
}
@@ -2240,11 +2242,11 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
*(TypeDesc**)val = n ? &group->m_attribute_types[0] : NULL;
return true;
}
if (name == "unknown_attributes_needed" && type == TypeDesc::TypeInt) {
if (name == "unknown_attributes_needed" && type == TypeInt) {
*(int*)val = (int)group->m_unknown_attributes_needed;
return true;
}
if (name == "group_id" && type == TypeDesc::TypeInt) {
if (name == "group_id" && type == TypeInt) {
*(int*)val = (int)group->id();
return true;
}
@@ -2260,7 +2262,7 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
*(void**)val = n ? &group->m_userdata_init_vals[0] : NULL;
return true;
}
if (name == "llvm_groupdata_size" && type == TypeDesc::TypeInt) {
if (name == "llvm_groupdata_size" && type == TypeInt) {
*(int*)val = (int)group->llvm_groupdata_size();
return true;
}
@@ -3089,21 +3091,21 @@ ShadingSystemImpl::ShaderGroupBegin(string_view groupname, string_view usage,
}
TypeDesc type;
if (typestring == "int")
type = TypeDesc::TypeInt;
type = TypeInt;
else if (typestring == "float")
type = TypeDesc::TypeFloat;
type = TypeFloat;
else if (typestring == "color")
type = TypeDesc::TypeColor;
type = TypeColor;
else if (typestring == "point")
type = TypeDesc::TypePoint;
type = TypePoint;
else if (typestring == "vector")
type = TypeDesc::TypeVector;
type = TypeVector;
else if (typestring == "normal")
type = TypeDesc::TypeNormal;
type = TypeNormal;
else if (typestring == "matrix")
type = TypeDesc::TypeMatrix;
type = TypeMatrix;
else if (typestring == "string")
type = TypeDesc::TypeString;
type = TypeString;
else {
err = true;
errdesc = fmtformat("Unknown type: {}", typestring);
@@ -4591,7 +4593,7 @@ osl_naninf_check(int ncomps, const void* vals_, int has_derivs, void* sg,
for (int d = 0; d < (has_derivs ? 3 : 1); ++d) {
for (int c = firstcheck, e = c + nchecks; c < e; ++c) {
int i = d * ncomps + c;
if (!OIIO::isfinite(vals[i])) {
if (!std::isfinite(vals[i])) {
OSL::errorfmt(ec, "Detected {} value in {}{} at {}:{} (op {})",
vals[i], d > 0 ? "the derivatives of " : "",
OSL::ustringhash_from(symbolname_),
@@ -4627,7 +4629,7 @@ osl_uninit_check(long long typedesc_, void* vals_, void* sg,
if (typedesc.basetype == TypeDesc::FLOAT) {
float* vals = (float*)vals_;
for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c)
if (!OIIO::isfinite(vals[c])) {
if (!std::isfinite(vals[c])) {
uninit = true;
vals[c] = 0;
}
+2 -2
View File
@@ -9,7 +9,7 @@
namespace pvt {
OIIO_CONSTEXPR14 inline size_t
constexpr inline size_t
pvtstrlen(const char* s)
{
if (s == nullptr)
@@ -23,7 +23,7 @@ pvtstrlen(const char* s)
} // namespace pvt
namespace UStringHash {
OIIO_CONSTEXPR14 inline size_t
constexpr inline size_t
Hash(const char* s)
{
size_t len = pvt::pvtstrlen(s);
+4 -4
View File
@@ -74,8 +74,8 @@ __OSL_MASKED_OP3(dict_find, Wi, Wi, Ws)(void* bsg_, void* wout, void* wnodeID,
int nodeID = wNID[lane];
ustring query = wQ[lane];
wOut[lane] = bsg->uniform.context->dict_find(
nullptr /*causes errors be reported through ShadingContext*/,
nodeID, query);
nullptr /*causes errors be reported through ShadingContext*/,
nodeID, query);
});
}
@@ -109,8 +109,8 @@ __OSL_MASKED_OP3(dict_find, Wi, Ws, Ws)(void* bsg_, void* wout,
ustring dictionary = wD[lane];
ustring query = wQ[lane];
wOut[lane] = bsg->uniform.context->dict_find(
nullptr /*causes errors be reported through ShadingContext*/,
dictionary, query);
nullptr /*causes errors be reported through ShadingContext*/,
dictionary, query);
});
}
+2 -2
View File
@@ -300,8 +300,8 @@ splineinverse_search(const MatrixT& M, R_T& result, X_T& xval, KArrayT knots,
// We can NOT use the low and high knot values,
// so will need to extract 2 more knot values
// to detect if we are increasing
K_T k1 = knots[1]; // knots is proxy, must export to local
K_T k2 = knots[knot_count - 2];
K_T k1 = knots[1]; // knots is proxy, must export to local
K_T k2 = knots[knot_count - 2];
increasing = k1 < k2;
}
+3 -6
View File
@@ -25,17 +25,14 @@ OSL_USING_DATA_WIDTH(__OSL_WIDTH)
#include "define_opname_macros.h"
#define __OSL_XMACRO_ARGS (isnan, OIIO::isnan)
//#define __OSL_XMACRO_ARGS (isnan,std::isnan)
#define __OSL_XMACRO_ARGS (isnan, std::isnan)
#include "wide_optest_float_xmacro.h"
#define __OSL_XMACRO_ARGS (isinf, OIIO::isinf)
#define __OSL_XMACRO_ARGS (isinf, std::isinf)
//#define __OSL_XMACRO_ARGS (isinf, sfm::isinf)
//#define __OSL_XMACRO_ARGS (isinf, std::isinf)
#include "wide_optest_float_xmacro.h"
#define __OSL_XMACRO_ARGS (isfinite, OIIO::isfinite)
//#define __OSL_XMACRO_ARGS (isfinite,std::isfinite)
#define __OSL_XMACRO_ARGS (isfinite, std::isfinite)
#include "wide_optest_float_xmacro.h"
+191 -36
View File
@@ -112,19 +112,11 @@ default_texture(BatchedRendererServices* bsr, ustring filename,
float dsdy = wdsdy[lane];
float dtdy = wdtdy[lane];
retVal = bsr->texturesys()->texture(
texture_handle, texture_thread_info, opt, ws[lane], wt[lane], dsdx,
dtdx, dsdy, dtdy, 4, (float*)&result_simd,
texture_handle, texture_thread_info, opt, ws[lane], wt[lane], dsdx,
dtdx, dsdy, dtdy, 4, (float*)&result_simd,
has_derivs ? (float*)&dresultds_simd : NULL,
has_derivs ? (float*)&dresultdt_simd : NULL);
OIIO::simd::vfloat4 dresultdx_simd;
OIIO::simd::vfloat4 dresultdy_simd;
if (has_derivs) {
// Correct our st texture space gradients into xy-space gradients
dresultdx_simd = dresultds_simd * dsdx + dresultdt_simd * dtdx;
dresultdy_simd = dresultds_simd * dsdy + dresultdt_simd * dtdy;
}
// NOTE: regardless of the value of "retVal" we will always copy over the texture system's results.
// We are relying on the texture system properly filling in missing or fill colors
@@ -142,10 +134,10 @@ default_texture(BatchedRendererServices* bsr, ustring filename,
MaskedDx<Color3> resultDx(resultRef);
MaskedDy<Color3> resultDy(resultRef);
resultDx[lane] = Color3(dresultdx_simd[0], dresultdx_simd[1],
dresultdx_simd[2]);
resultDy[lane] = Color3(dresultdy_simd[0], dresultdy_simd[1],
dresultdy_simd[2]);
resultDx[lane] = Color3(dresultds_simd[0], dresultds_simd[1],
dresultds_simd[2]);
resultDy[lane] = Color3(dresultdt_simd[0], dresultdt_simd[1],
dresultdt_simd[2]);
}
} else if (Masked<float>::is(resultRef)) {
alphaChannelIndex = 1;
@@ -154,8 +146,8 @@ default_texture(BatchedRendererServices* bsr, ustring filename,
MaskedDy<float> resultDy(resultRef);
result[lane] = result_simd[0];
if (resultRef.has_derivs()) {
resultDx[lane] = dresultdx_simd[0];
resultDy[lane] = dresultdy_simd[0];
resultDx[lane] = dresultds_simd[0];
resultDy[lane] = dresultdt_simd[0];
}
}
@@ -165,8 +157,8 @@ default_texture(BatchedRendererServices* bsr, ustring filename,
if (alphaRef.has_derivs()) {
MaskedDx<float> alphaDx(alphaRef);
MaskedDy<float> alphaDy(alphaRef);
alphaDx[lane] = dresultdx_simd[alphaChannelIndex];
alphaDy[lane] = dresultdy_simd[alphaChannelIndex];
alphaDx[lane] = dresultds_simd[alphaChannelIndex];
alphaDy[lane] = dresultdt_simd[alphaChannelIndex];
}
}
//std::cout << "s: " << s.get(i) << " t: " << t.get(i) << " color: " << resultColor << " " << wideResult.get(i) << std::endl;
@@ -311,16 +303,6 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename,
has_derivs ? (float*)&dresultdt_simd : nullptr,
has_derivs ? (float*)&dresultdr_simd : nullptr);
OIIO::simd::vfloat4 dresultdx_simd;
OIIO::simd::vfloat4 dresultdy_simd;
if (has_derivs) {
// Correct our str texture space gradients into xyz-space gradients
dresultdx_simd = dresultds_simd * dPdx.x + dresultdt_simd * dPdx.y
+ dresultdr_simd * dPdx.z;
dresultdy_simd = dresultds_simd * dPdy.x + dresultdt_simd * dPdy.y
+ dresultdr_simd * dPdy.z;
}
// NOTE: regardless of the value of "retVal" we will always copy over the texture system's results.
// We are relying on the texture system properly filling in missing or fill colors
@@ -337,10 +319,10 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename,
if (resultRef.has_derivs()) {
MaskedDx<Color3> resultDx(resultRef);
MaskedDy<Color3> resultDy(resultRef);
resultDx[lane] = Color3(dresultdx_simd[0], dresultdx_simd[1],
dresultdx_simd[2]);
resultDy[lane] = Color3(dresultdy_simd[0], dresultdy_simd[1],
dresultdy_simd[2]);
resultDx[lane] = Color3(dresultds_simd[0], dresultds_simd[1],
dresultds_simd[2]);
resultDy[lane] = Color3(dresultdt_simd[0], dresultdt_simd[1],
dresultdt_simd[2]);
}
} else if (Masked<float>::is(resultRef)) {
alphaChannelIndex = 1;
@@ -349,8 +331,8 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename,
if (resultRef.has_derivs()) {
MaskedDx<float> resultDx(resultRef);
MaskedDy<float> resultDy(resultRef);
resultDx[lane] = dresultdx_simd[0];
resultDy[lane] = dresultdy_simd[0];
resultDx[lane] = dresultds_simd[0];
resultDy[lane] = dresultdt_simd[0];
}
}
@@ -361,8 +343,8 @@ default_texture3d(BatchedRendererServices* bsr, ustring filename,
if (alphaRef.has_derivs()) {
MaskedDx<float> alphaDx(alphaRef);
MaskedDy<float> alphaDy(alphaRef);
alphaDx[lane] = dresultdx_simd[alphaChannelIndex];
alphaDy[lane] = dresultdy_simd[alphaChannelIndex];
alphaDx[lane] = dresultds_simd[alphaChannelIndex];
alphaDy[lane] = dresultdt_simd[alphaChannelIndex];
}
}
@@ -561,6 +543,164 @@ dispatch_environment(BatchedRendererServices* bsr, ustring filename,
} // namespace
static OSL_NOINLINE void
transformWideTextureGradients(BatchedTextureOutputs& outputs,
Wide<const float> dsdx, Wide<const float> dtdx,
Wide<const float> dsdy, Wide<const float> dtdy)
{
MaskedData resultRef = outputs.result();
if (resultRef.valid() && resultRef.has_derivs()) {
if (Masked<float>::is(resultRef)) {
OSL_FORCEINLINE_BLOCK
{
MaskedDx<float> drds(resultRef);
MaskedDy<float> drdt(resultRef);
OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH))
for (int i = 0; i < __OSL_WIDTH; ++i) {
float drdsVal = drds[i];
float drdtVal = drdt[i];
float drdx = drdsVal * dsdx[i] + drdtVal * dtdx[i];
float drdy = drdsVal * dsdy[i] + drdtVal * dtdy[i];
drds[i] = drdx;
drdt[i] = drdy;
}
}
} else {
// keep assert out of inlined code
OSL_DASSERT(Masked<Color3>::is(resultRef));
OSL_FORCEINLINE_BLOCK
{
//printf("doint color\n");
MaskedDx<Color3> widedrds(resultRef);
MaskedDy<Color3> widedrdt(resultRef);
OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH))
for (int i = 0; i < __OSL_WIDTH; ++i) {
Color3 drdsColor = widedrds[i];
Color3 drdtColor = widedrdt[i];
widedrds[i] = drdsColor * dsdx[i] + drdtColor * dtdx[i];
widedrdt[i] = drdsColor * dsdy[i] + drdtColor * dtdy[i];
}
}
}
}
MaskedData alphaRef = outputs.alpha();
OSL_FORCEINLINE_BLOCK
if (alphaRef.valid() && alphaRef.has_derivs()) {
MaskedDx<float> dads(alphaRef);
MaskedDy<float> dadt(alphaRef);
OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH))
for (int i = 0; i < __OSL_WIDTH; ++i) {
float dadsVal = dads[i];
float dadtVal = dadt[i];
float dadx = dadsVal * dsdx[i] + dadtVal * dtdx[i];
float dady = dadsVal * dsdy[i] + dadtVal * dtdy[i];
dads[i] = dadx;
dadt[i] = dady;
}
}
}
static OSL_NOINLINE void
transformWideTextureGradientsTexture3d(BatchedTextureOutputs& outputs,
Wide<const Vec3> Pdx,
Wide<const Vec3> Pdy,
Wide<const Vec3> Pdz)
{
MaskedData resultRef = outputs.result();
if (resultRef.valid() && resultRef.has_derivs()) {
if (Masked<float>::is(resultRef)) {
OSL_FORCEINLINE_BLOCK
{
MaskedDx<float> drds(resultRef);
MaskedDy<float> drdt(resultRef);
//MaskedDz<float> drdr(resultRef); // our duals don't actually have space for this
OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH))
for (int i = 0; i < __OSL_WIDTH; ++i) {
float dres_xVal = drds[i];
float dres_yVal = drdt[i];
//float dres_zVal = drdr[i];
Vec3 v3pdx = Pdx[i];
Vec3 v3pdy = Pdy[i];
//Vec3 v3pdz = Pdz[i];
float dres_x = dres_xVal * v3pdx.x
+ dres_yVal
* v3pdx.y; // + dres_zVal * v3pdx.z;
float dres_y = dres_xVal * v3pdy.x
+ dres_yVal
* v3pdy.y; // + dres_zVal * v3pdy.z;
//float dres_z = dres_xVal * v3pdz.x + dres_yVal * v3pdz.y + dres_zVal * v3pdz.z;
drds[i] = dres_x;
drdt[i] = dres_y;
//drdr[i] = dres_z;
}
}
} else {
// keep assert out of inlined code
OSL_DASSERT(Masked<Color3>::is(resultRef));
OSL_FORCEINLINE_BLOCK
{
MaskedDx<Color3> widedrp1(resultRef);
MaskedDy<Color3> widedrp2(resultRef);
//MaskedDz<Color3> widedrp3(resultRef);
OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH))
for (int i = 0; i < __OSL_WIDTH; ++i) {
Color3 drdp1Color = widedrp1[i];
Color3 drdp2Color = widedrp2[i];
//Color3 drdp3Color = widedrp3[i];
Vec3 v3pdx = Pdx[i];
Vec3 v3pdy = Pdy[i];
//Vec3 v3pdz = Pdz[i];
widedrp1[i] = drdp1Color * v3pdx.x
+ drdp2Color
* v3pdx.y; // + drdp3Color * v3pdx.z;
widedrp2[i] = drdp1Color * v3pdy.x
+ drdp2Color
* v3pdy.y; // + drdp3Color * v3pdy.z;
//widedrp3[i] = drdp1Color * v3pdz.x + drdp2Color * v3pdz.y + drdp3Color * v3pdz.z;
}
}
}
}
MaskedData alphaRef = outputs.alpha();
OSL_FORCEINLINE_BLOCK
if (alphaRef.valid() && alphaRef.has_derivs()) {
MaskedDx<float> dap1(alphaRef);
MaskedDy<float> dap2(alphaRef);
// MaskedDz<float> dap3(alphaRef);
OSL_OMP_PRAGMA(omp simd simdlen(__OSL_WIDTH))
for (int i = 0; i < __OSL_WIDTH; ++i) {
float dadp1Val = dap1[i];
float dadp2Val = dap2[i];
//float dadp3Val = dap3[i];
Vec3 v3pdx = Pdx[i];
Vec3 v3pdy = Pdy[i];
//Vec3 v3pdz = Pdz[i];
float dadpx = dadp1Val * v3pdx.x
+ dadp2Val * v3pdx.y; // + dadp3Val * v3pdx.z;
float dadpy = dadp1Val * v3pdy.x
+ dadp2Val * v3pdy.y; // + dadp3Val * v3pdy.z;
//float dadpz = dadp1Val * v3pdz.x + dadp2Val * v3pdz.y + dadp3Val * v3pdz.z;
dap1[i] = dadpx;
dap2[i] = dadpy;
//dap3[i] = dadpz;
}
}
}
OSL_BATCHOP int
__OSL_MASKED_OP(texture)(void* bsg_, void* name, void* handle, const void* opt_,
@@ -590,6 +730,14 @@ __OSL_MASKED_OP(texture)(void* bsg_, void* name, void* handle, const void* opt_,
Wide<const float>(dsdy), Wide<const float>(dtdy),
outputs);
// Correct our st texture space gradients into xy-space gradients
if (resultHasDerivs || alphaHasDerivs) {
transformWideTextureGradients(outputs, Wide<const float>(dsdx),
Wide<const float>(dtdx),
Wide<const float>(dsdy),
Wide<const float>(dtdy));
}
OSL_FORCEINLINE_BLOCK
if (outputs.errormessage().valid()) {
Masked<ustring> err(outputs.errormessage());
@@ -637,6 +785,13 @@ __OSL_MASKED_OP(texture3d)(void* bsg_, void* name, void* handle,
Wide<const Vec3>(wPdy), Wide<const Vec3>(wPdz),
outputs);
// Correct our P (Vec3) space gradients into xyz-space gradients
if (resultHasDerivs || alphaHasDerivs) {
transformWideTextureGradientsTexture3d(outputs, Wide<const Vec3>(wPdx),
Wide<const Vec3>(wPdy),
Wide<const Vec3>(wPdz));
}
OSL_FORCEINLINE_BLOCK
if (outputs.errormessage().valid()) {
Masked<ustring> err(outputs.errormessage());
+7 -7
View File
@@ -39,7 +39,7 @@ __OSL_OP(naninf_check)(int ncomps, const void* vals_, int has_derivs,
for (int d = 0; d < (has_derivs ? 3 : 1); ++d) {
for (int c = firstcheck, e = c + nchecks; c < e; ++c) {
int i = d * ncomps + c;
if (!OIIO::isfinite(vals[i])) {
if (!std::isfinite(vals[i])) {
ctx->errorfmt("Detected {} value in {}{} at {}:{} (op {})",
vals[i], d > 0 ? "the derivatives of " : "",
USTR(symbolname), USTR(sourcefile), sourceline,
@@ -68,7 +68,7 @@ __OSL_MASKED_OP1(naninf_check_offset,
for (int c = firstcheck, e = c + nchecks; c < e; ++c) {
int i = d * ncomps + c;
mask.foreach ([=](ActiveLane lane) -> void {
if (!OIIO::isfinite(vals[i * __OSL_WIDTH + lane])) {
if (!std::isfinite(vals[i * __OSL_WIDTH + lane])) {
ctx->errorfmt(
"Detected {} value in {}{} at {}:{} (op {}) batch lane:{}",
vals[i * __OSL_WIDTH + lane],
@@ -107,7 +107,7 @@ __OSL_MASKED_OP1(naninf_check_offset,
int firstcheck = wOffsets[lane];
for (int c = firstcheck, e = c + nchecks; c < e; ++c) {
int i = d * ncomps + c;
if (!OIIO::isfinite(vals[i * __OSL_WIDTH + lane])) {
if (!std::isfinite(vals[i * __OSL_WIDTH + lane])) {
ctx->errorfmt(
"Detected {} value in {}{} at {}:{} (op {}) batch lane:{}",
vals[i * __OSL_WIDTH + lane],
@@ -143,7 +143,7 @@ __OSL_OP2(uninit_check_values_offset, X,
if (typedesc.basetype == TypeDesc::FLOAT) {
float* vals = (float*)vals_;
for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c)
if (!OIIO::isfinite(vals[c])) {
if (!std::isfinite(vals[c])) {
uninit = true;
vals[c] = 0;
}
@@ -200,7 +200,7 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX,
float* vals = (float*)vals_;
for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c)
mask.foreach ([=, &lanes_uninit](ActiveLane lane) -> void {
if (!OIIO::isfinite(vals[c * __OSL_WIDTH + lane])) {
if (!std::isfinite(vals[c * __OSL_WIDTH + lane])) {
lanes_uninit.set_on(lane);
vals[c * __OSL_WIDTH + lane] = 0;
}
@@ -265,7 +265,7 @@ __OSL_MASKED_OP2(uninit_check_values_offset, X,
mask.foreach ([=, &lanes_uninit](ActiveLane lane) -> void {
int firstcheck = wOffsets[lane];
for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c)
if (!OIIO::isfinite(vals[c])) {
if (!std::isfinite(vals[c])) {
lanes_uninit.set_on(lane);
vals[c] = 0;
}
@@ -331,7 +331,7 @@ __OSL_MASKED_OP2(uninit_check_values_offset, WX,
mask.foreach ([=, &lanes_uninit](ActiveLane lane) -> void {
int firstcheck = wOffsets[lane];
for (int c = firstcheck, e = firstcheck + nchecks; c < e; ++c)
if (!OIIO::isfinite(vals[c * __OSL_WIDTH + lane])) {
if (!std::isfinite(vals[c * __OSL_WIDTH + lane])) {
lanes_uninit.set_on(lane);
vals[c * __OSL_WIDTH + lane] = 0;
}
+1 -1
View File
@@ -175,7 +175,7 @@ gabor_cell(GaborParams& gp, const Vec3& c_i, const Dual2<Vec3>& x_c_i,
Dual2<float> gk = gabor_kernel(w_i_t_s_f, omega_i_t_s_f,
phi_i_t_s_f, a_i_t_s_f,
x_k_i_t); // 2D
if (!OIIO::isfinite(gk.val())) {
if (!std::isfinite(gk.val())) {
// Numeric failure of the filtered version. Fall
// back on the unfiltered.
gk = gabor_kernel(gp.weight, omega_i, phi_i, gp.a,
+13 -13
View File
@@ -367,7 +367,7 @@ gabor_cell(const sfm::GaborUniformParams& gup, const sfm::GaborParams& gp,
//bool not_finite = std::isnan(gk.val()) | std::isinf(gk.val());
bool not_finite = std::isnan(gk.val()) || std::isinf(gk.val());
#else
bool not_finite = !OIIO::isfinite(gk.val());
bool not_finite = !std::isfinite(gk.val());
#endif
if (OSL_UNLIKELY(not_finite)) {
// Numeric failure of the filtered version. Fall
@@ -563,16 +563,16 @@ scalar_gabor3(const Dual2<Vec3>& P, const sfm::GaborUniformParams& gup,
// to better enable SROA (Scalar Replacement of Aggregates) optimizations
if (seed == 0) {
result.val().x = resultPart.val();
result.dx().x = resultPart.dx();
result.dy().x = resultPart.dy();
result.dx().x = resultPart.dx();
result.dy().x = resultPart.dy();
} else if (seed == 1) {
result.val().y = resultPart.val();
result.dx().y = resultPart.dx();
result.dy().y = resultPart.dy();
result.dx().y = resultPart.dx();
result.dy().y = resultPart.dy();
} else {
result.val().z = resultPart.val();
result.dx().z = resultPart.dx();
result.dy().z = resultPart.dy();
result.dx().z = resultPart.dx();
result.dy().z = resultPart.dy();
}
}
#endif
@@ -646,16 +646,16 @@ scalar_pgabor3(const Dual2<Vec3>& P, const Vec3& Pperiod,
// to better enable SROA (Scalar Replacement of Aggregates) optimizations
if (seed == 0) {
result.val().x = resultPart.val();
result.dx().x = resultPart.dx();
result.dy().x = resultPart.dy();
result.dx().x = resultPart.dx();
result.dy().x = resultPart.dy();
} else if (seed == 1) {
result.val().y = resultPart.val();
result.dx().y = resultPart.dx();
result.dy().y = resultPart.dy();
result.dx().y = resultPart.dx();
result.dy().y = resultPart.dy();
} else {
result.val().z = resultPart.val();
result.dx().z = resultPart.dx();
result.dy().z = resultPart.dy();
result.dx().z = resultPart.dx();
result.dy().z = resultPart.dy();
}
}
#endif
+13 -6
View File
@@ -218,7 +218,7 @@ static OIIO::mutex shading_mutex;
static ShadingSystem* shadingsys = NULL;
static OIIO_RendererServices* renderer = NULL;
static ErrorRecorder errhandler;
static std::shared_ptr<TextureSystem> shared_texsys;
static void
@@ -226,7 +226,14 @@ setup_shadingsys()
{
OIIO::lock_guard lock(shading_mutex);
if (!shadingsys) {
renderer = new OIIO_RendererServices(TextureSystem::create(true));
#if OIIO_TEXTURESYSTEM_CREATE_SHARED
if (!shared_texsys)
shared_texsys = TextureSystem::create(true);
auto ts = shared_texsys.get();
#else
auto ts = TextureSystem::create(true);
#endif
renderer = new OIIO_RendererServices(ts);
shadingsys = new ShadingSystem(renderer, NULL, &errhandler);
}
}
@@ -381,16 +388,16 @@ parse_param(string_view paramname, string_view val, ImageSpec& spec)
// Surrounded by quotes? it's a string (strip off the quotes)
val.remove_prefix(1);
val.remove_suffix(1);
type = TypeDesc::TypeString;
type = TypeString;
} else if (Strutil::string_is<int>(val)) {
// Looks like an int, is an int
type = TypeDesc::TypeInt;
type = TypeInt;
} else if (Strutil::string_is<float>(val)) {
// Looks like a float, is a float
type = TypeDesc::TypeFloat;
type = TypeFloat;
} else {
// Everything else is assumed a string
type = TypeDesc::TypeString;
type = TypeString;
}
}
+5 -6
View File
@@ -432,9 +432,8 @@ OSLToyMainWindow::OSLToyMainWindow(OSLToyRenderer* rend, int xr, int yr)
QPixmap pixmap(xres, yres);
OIIO::ImageBuf checks(
OIIO::ImageSpec(xres, yres, 3, OIIO::TypeDesc::UINT8));
const float white[] = { 1, 1, 1 };
const float black[] = { 0, 0, 0 };
OIIO::ImageBufAlgo::checker(checks, 16, 16, 1, white, black);
OIIO::ImageBufAlgo::checker(checks, 16, 16, 1, 1.0f /* white */,
0.0f /* black */);
renderView->update(checks);
textTabs = new QTabWidget;
@@ -798,7 +797,7 @@ OSLToyMainWindow::osl_do_rerender(float /*frametime*/)
float start = timer();
renderer()->set_time(start);
renderer()->render_image();
OIIO_UNUSED_OK float rendertime = timer() - start;
OIIO_MAYBE_UNUSED float rendertime = timer() - start;
renderView->update(renderer()->framebuffer());
@@ -1052,14 +1051,14 @@ OSLToyMainWindow::make_param_adjustment_row(ParamRec* param,
auto label_and_adjust_layout = new QHBoxLayout;
label_and_adjust->setLayout(label_and_adjust_layout);
std::string labeltext;
if (param->type == TypeDesc::TypeColor)
if (param->type == TypeColor)
labeltext = string_view(&("RGB"[c]), 1);
else
labeltext = string_view(&("xyz"[c]), 1);
auto channellabel = QtUtils::make_qlabelfmt("{}", labeltext);
label_and_adjust_layout->addWidget(channellabel);
auto adjustWidget = new QtUtils::DoubleSpinBox(param->fdefault[c]);
if (param->type == TypeDesc::TypeColor) {
if (param->type == TypeColor) {
adjustWidget->setRange(0.0, 1.0);
}
label_and_adjust_layout->addWidget(adjustWidget);
+11 -12
View File
@@ -298,8 +298,7 @@ OSLToyRenderer::get_array_attribute(ShaderGlobals* sg, bool derivatives,
// In order to test getattribute(), respond positively to
// "options"/"blahblah"
if (object == "options" && name == "blahblah"
&& type == TypeDesc::TypeFloat) {
if (object == "options" && name == "blahblah" && type == TypeFloat) {
*(float*)val = 3.14159;
return true;
}
@@ -333,7 +332,7 @@ OSLToyRenderer::get_userdata(bool derivatives, ustring name, TypeDesc type,
// look up something specific to the primitive, rather than have hard-
// coded names.
if (name == u_s && type == TypeDesc::TypeFloat) {
if (name == u_s && type == TypeFloat) {
((float*)val)[0] = sg->u;
if (derivatives) {
((float*)val)[1] = sg->dudx;
@@ -341,7 +340,7 @@ OSLToyRenderer::get_userdata(bool derivatives, ustring name, TypeDesc type,
}
return true;
}
if (name == u_t && type == TypeDesc::TypeFloat) {
if (name == u_t && type == TypeFloat) {
((float*)val)[0] = sg->v;
if (derivatives) {
((float*)val)[1] = sg->dvdx;
@@ -359,7 +358,7 @@ OSLToyRenderer::get_osl_version(ShaderGlobals* /*sg*/, bool /*derivs*/,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeInt) {
if (type == TypeInt) {
((int*)val)[0] = OSL_VERSION;
return true;
}
@@ -386,7 +385,7 @@ OSLToyRenderer::get_camera_projection(ShaderGlobals* /*sg*/, bool /*derivs*/,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeString) {
if (type == TypeString) {
((ustring*)val)[0] = m_projection;
return true;
}
@@ -400,7 +399,7 @@ OSLToyRenderer::get_camera_fov(ShaderGlobals* /*sg*/, bool derivs,
ustring /*name*/, void* val)
{
// N.B. in a real renderer, this may be time-dependent
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_fov;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -415,7 +414,7 @@ OSLToyRenderer::get_camera_pixelaspect(ShaderGlobals* /*sg*/, bool derivs,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_pixelaspect;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -446,7 +445,7 @@ OSLToyRenderer::get_camera_clip_near(ShaderGlobals* /*sg*/, bool derivs,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_hither;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -461,7 +460,7 @@ OSLToyRenderer::get_camera_clip_far(ShaderGlobals* /*sg*/, bool derivs,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_yon;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -493,7 +492,7 @@ OSLToyRenderer::get_camera_shutter_open(ShaderGlobals* /*sg*/, bool derivs,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_shutter[0];
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -508,7 +507,7 @@ OSLToyRenderer::get_camera_shutter_close(ShaderGlobals* /*sg*/, bool derivs,
ustring /*object*/, TypeDesc type,
ustring /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_shutter[1];
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
+1 -1
View File
@@ -105,7 +105,7 @@ ImageBuf_to_QImage(const OIIO::ImageBuf& ib)
return {};
if (ib.cachedpixels())
const_cast<ImageBuf*>(&ib)->make_writeable(true);
const_cast<ImageBuf*>(&ib)->make_writable(true);
return QImage((const uchar*)ib.localpixels(), spec.width, spec.height,
(int)spec.scanline_bytes(), format);
}
+2 -2
View File
@@ -58,9 +58,9 @@ struct Background {
#if 0 // DEBUG: visualize importance table
using namespace OIIO;
ImageOutput* out = ImageOutput::create("bg.exr");
ImageSpec spec(res, res, 3, TypeDesc::TypeFloat);
ImageSpec spec(res, res, 3, TypeFloat);
if (out && out->open("bg.exr", spec))
out->write_image(TypeDesc::TypeFloat, &values[0]);
out->write_image(TypeFloat, &values[0]);
delete out;
#endif
}
+2 -2
View File
@@ -445,7 +445,7 @@ OptixRaytracer::make_optix_materials()
quad_hitgroup_desc.hitgroup.moduleCH = wrapper_module;
quad_hitgroup_desc.hitgroup.entryFunctionNameCH
= "__closesthit__closest_hit_osl";
quad_hitgroup_desc.hitgroup.moduleAH = wrapper_module;
quad_hitgroup_desc.hitgroup.moduleAH = wrapper_module;
quad_hitgroup_desc.hitgroup.entryFunctionNameAH = "__anyhit__any_hit_shadow";
quad_hitgroup_desc.hitgroup.moduleIS = quad_module;
quad_hitgroup_desc.hitgroup.entryFunctionNameIS = "__intersection__quad";
@@ -494,7 +494,7 @@ OptixRaytracer::make_optix_materials()
sphere_hitgroup_desc.hitgroup.moduleAH = wrapper_module;
sphere_hitgroup_desc.hitgroup.entryFunctionNameAH
= "__anyhit__any_hit_shadow";
sphere_hitgroup_desc.hitgroup.moduleIS = sphere_module;
sphere_hitgroup_desc.hitgroup.moduleIS = sphere_module;
sphere_hitgroup_desc.hitgroup.entryFunctionNameIS = "__intersection__sphere";
OptixProgramGroup sphere_hitgroup;
create_optix_pg(&sphere_hitgroup_desc, 1, &program_options,
+94 -16
View File
@@ -101,6 +101,7 @@ struct MxOrenNayarDiffuseParams {
float roughness;
// optional
ustring label;
int energy_compensation;
};
struct MxBurleyDiffuseParams {
@@ -316,6 +317,8 @@ register_closures(OSL::ShadingSystem* shadingsys)
CLOSURE_COLOR_PARAM(MxOrenNayarDiffuseParams, albedo),
CLOSURE_FLOAT_PARAM(MxOrenNayarDiffuseParams, roughness),
CLOSURE_STRING_KEYPARAM(MxOrenNayarDiffuseParams, label, "label"),
CLOSURE_INT_KEYPARAM(MxOrenNayarDiffuseParams, energy_compensation,
"energy_compensation"),
CLOSURE_FINISH_PARAM(MxOrenNayarDiffuseParams) } },
{ "burley_diffuse_bsdf",
MX_BURLEY_DIFFUSE_ID,
@@ -459,23 +462,24 @@ template<int trans> struct Diffuse final : public BSDF, DiffuseParams {
struct OrenNayar final : public BSDF, OrenNayarParams {
OrenNayar(const OrenNayarParams& params) : BSDF(), OrenNayarParams(params)
{
// precompute some constants
float s2 = sigma * sigma;
A = 1 - 0.50f * s2 / (s2 + 0.33f);
B = 0.45f * s2 / (s2 + 0.09f);
}
Sample eval(const Vec3& wo, const OSL::Vec3& wi) const override
{
float NL = N.dot(wi);
float NV = N.dot(wo);
if (NL > 0 && NV > 0) {
float LV = wo.dot(wi);
float s = LV - NL * NV;
// Simplified math from: "A tiny improvement of Oren-Nayar reflectance model"
// by Yasuhiro Fujii
// http://mimosa-pudica.net/improved-oren-nayar.html
// NOTE: This is using the math to match the original ON model, not the tweak
// proposed in the text which is a slightly different BRDF
float LV = wo.dot(wi);
float s = LV - NL * NV;
// NOTE: This is using the math to match the original qualitative ON model
// (QON in the paper above) and not the tweak proposed in the text which
// is a slightly different BRDF (FON in the paper above). This is done for
// backwards compatibility purposes only.
float s2 = sigma * sigma;
float A = 1 - 0.50f * s2 / (s2 + 0.33f);
float B = 0.45f * s2 / (s2 + 0.09f);
float stinv = s > 0 ? s / std::max(NL, NV) : 0.0f;
return { wi, Color3(A + B * stinv), NL * float(M_1_PI), 1.0f };
}
@@ -489,9 +493,77 @@ struct OrenNayar final : public BSDF, OrenNayarParams {
Sampling::sample_cosine_hemisphere(N, rx, ry, out_dir, pdf);
return eval(wo, out_dir);
}
};
struct EnergyCompensatedOrenNayar : public BSDF, MxOrenNayarDiffuseParams {
EnergyCompensatedOrenNayar(const MxOrenNayarDiffuseParams& params)
: BSDF(), MxOrenNayarDiffuseParams(params)
{
}
Sample eval(const Vec3& wo, const OSL::Vec3& wi) const override
{
float NL = N.dot(wi);
float NV = N.dot(wo);
if (NL > 0 && NV > 0) {
float LV = wo.dot(wi);
float s = LV - NL * NV;
// Code below from Jamie Portsmouth's tech report on Energy conversion Oren-Nayar
// See slack thread for whitepaper:
// https://academysoftwarefdn.slack.com/files/U03SWQFPD08/F06S50CUKV1/oren_nayar.pdf
// TODO: rho should be the albedo which is a parameter of the closure in the Mx parameters
// This only matters for the color-saturation aspect of the BRDF which is rather subtle anyway
// and not always desireable for artists. Hardcoding to 1 leaves the coloring entirely up to the
// closure weight.
const Color3 rho = albedo;
const float sigma = roughness;
float AF = 1.0f / (1.0f + constant1_FON * sigma);
float stinv = s > 0 ? s / std::max(NL, NV) : s;
float f_ss = AF * (1.0 + sigma * stinv); // single-scatt. BRDF
float EFo = E_FON_analytic(NV); // EFo at rho=1 (analytic)
float EFi = E_FON_analytic(NL); // EFi at rho=1 (analytic)
float avgEF = AF * (1.0f + constant2_FON * sigma); // avg. albedo
Color3 rho_ms = (rho * rho) * avgEF
/ (Color3(1.0f)
- rho * std::max(0.0f, 1.0f - avgEF));
float f_ms = std::max(1e-7f, 1.0f - EFo)
* std::max(1e-7f, 1.0f - EFi)
/ std::max(1e-7f, 1.0f - avgEF); // multi-scatter lobe
return { wi, Color3(rho * f_ss + rho_ms * f_ms), NL * float(M_1_PI),
1.0f };
}
return {};
}
Sample sample(const Vec3& wo, float rx, float ry,
float /*rz*/) const override
{
Vec3 out_dir;
float pdf;
Sampling::sample_cosine_hemisphere(N, rx, ry, out_dir, pdf);
return eval(wo, out_dir);
}
private:
float A, B;
static constexpr float constant1_FON = float(0.5 - 2.0 / (3.0 * M_PI));
static constexpr float constant2_FON = float(2.0 / 3.0
- 28.0 / (15.0 * M_PI));
float E_FON_analytic(float mu) const
{
const float sigma = roughness;
float AF = 1.0f
/ (1.0f
+ constant1_FON * sigma); // Fujii model A coefficient
float BF = sigma * AF; // Fujii model B coefficient
float Si = sqrtf(std::max(0.0f, 1.0f - mu * mu));
float G = Si * (OIIO::fast_acos(mu) - Si * mu)
+ 2.0 * ((Si / mu) * (1.0 - Si * Si * Si) - Si) / 3.0f;
float E = AF + (BF * float(M_1_PI)) * G;
return E;
}
};
struct Phong final : public BSDF, PhongParams {
@@ -1615,14 +1687,20 @@ process_bsdf_closure(const OSL::ShaderGlobals& sg, ShadingResult& result,
ok = result.bsdf.add_bsdf<Transparent>(cw);
break;
case MX_OREN_NAYAR_DIFFUSE_ID: {
// translate MaterialX parameters into existing closure
const MxOrenNayarDiffuseParams* srcparams
= comp->as<MxOrenNayarDiffuseParams>();
OrenNayarParams params = {};
params.N = srcparams->N;
params.sigma = srcparams->roughness;
ok = result.bsdf.add_bsdf<OrenNayar>(cw * srcparams->albedo,
params);
if (srcparams->energy_compensation) {
// energy compensation handled by its own BSDF
ok = result.bsdf.add_bsdf<EnergyCompensatedOrenNayar>(
cw, *srcparams);
} else {
// translate MaterialX parameters into existing closure
OrenNayarParams params = {};
params.N = srcparams->N;
params.sigma = srcparams->roughness;
ok = result.bsdf.add_bsdf<OrenNayar>(cw * srcparams->albedo,
params);
}
break;
}
case MX_BURLEY_DIFFUSE_ID: {
@@ -1646,7 +1724,7 @@ process_bsdf_closure(const OSL::ShaderGlobals& sg, ShadingResult& result,
}
case MX_CONDUCTOR_ID: {
const MxConductorParams& params = *comp->as<MxConductorParams>();
ok = result.bsdf.add_bsdf<
ok = result.bsdf.add_bsdf<
MxMicrofacet<MxConductorParams, GGXDist, false>>(cw, params,
1.0f);
break;
+2 -2
View File
@@ -35,8 +35,8 @@ struct BSDF {
BSDF() {}
virtual Color3 get_albedo(const Vec3& /*wo*/) const { return Color3(1); }
virtual Sample eval(const Vec3& wo, const Vec3& wi) const = 0;
virtual Sample sample(const Vec3& wo, float rx, float ry,
float rz) const = 0;
virtual Sample sample(const Vec3& wo, float rx, float ry, float rz) const
= 0;
};
/// Represents a weighted sum of BSDFS
+16 -21
View File
@@ -364,28 +364,23 @@ SimpleRaytracer::parse_scene_xml(const std::string& scenefile)
float f[3];
string_view val(attr.value());
if (parse_prefix_and_ints(val, "int ", 1, &i))
shadingsys->Parameter(*group, attr.name(),
TypeDesc::TypeInt,
shadingsys->Parameter(*group, attr.name(), TypeInt,
store.Int(i));
else if (parse_prefix_and_floats(val, "float ", 1, f))
shadingsys->Parameter(*group, attr.name(),
TypeDesc::TypeFloat,
store.Float(f[0]));
TypeFloat, store.Float(f[0]));
else if (parse_prefix_and_floats(val, "vector ", 3, f))
shadingsys->Parameter(*group, attr.name(),
TypeDesc::TypeVector,
store.Vec(f));
TypeVector, store.Vec(f));
else if (parse_prefix_and_floats(val, "point ", 3, f))
shadingsys->Parameter(*group, attr.name(),
TypeDesc::TypePoint,
store.Vec(f));
TypePoint, store.Vec(f));
else if (parse_prefix_and_floats(val, "color ", 3, f))
shadingsys->Parameter(*group, attr.name(),
TypeDesc::TypeColor,
store.Vec(f));
TypeColor, store.Vec(f));
else
shadingsys->Parameter(*group, attr.name(),
TypeDesc::TypeString,
TypeString,
store.Str(attr.value()));
}
} else if (strcmp(gnode.name(), "Shader") == 0) {
@@ -589,7 +584,7 @@ SimpleRaytracer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
// look up something specific to the primitive, rather than have hard-
// coded names.
if (name == u_s && type == TypeDesc::TypeFloat) {
if (name == u_s && type == TypeFloat) {
((float*)val)[0] = sg->u;
if (derivatives) {
((float*)val)[1] = sg->dudx;
@@ -597,7 +592,7 @@ SimpleRaytracer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
}
return true;
}
if (name == u_t && type == TypeDesc::TypeFloat) {
if (name == u_t && type == TypeFloat) {
((float*)val)[0] = sg->v;
if (derivatives) {
((float*)val)[1] = sg->dvdx;
@@ -615,7 +610,7 @@ SimpleRaytracer::get_osl_version(ShaderGlobals* /*sg*/, bool /*derivs*/,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeInt) {
if (type == TypeInt) {
((int*)val)[0] = OSL_VERSION;
return true;
}
@@ -642,7 +637,7 @@ SimpleRaytracer::get_camera_projection(ShaderGlobals* /*sg*/, bool /*derivs*/,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeString) {
if (type == TypeString) {
((ustring*)val)[0] = m_projection;
return true;
}
@@ -656,7 +651,7 @@ SimpleRaytracer::get_camera_fov(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*name*/, void* val)
{
// N.B. in a real renderer, this may be time-dependent
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_fov;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -671,7 +666,7 @@ SimpleRaytracer::get_camera_pixelaspect(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_pixelaspect;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -702,7 +697,7 @@ SimpleRaytracer::get_camera_clip_near(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_hither;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -717,7 +712,7 @@ SimpleRaytracer::get_camera_clip_far(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_yon;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -749,7 +744,7 @@ SimpleRaytracer::get_camera_shutter_open(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_shutter[0];
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -764,7 +759,7 @@ SimpleRaytracer::get_camera_shutter_close(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_shutter[1];
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
+1 -1
View File
@@ -57,7 +57,7 @@ static std::string scenefile, imagefile;
static std::string shaderpath;
static bool shadingsys_options_set = false;
static bool use_optix = OIIO::Strutil::stoi(
OIIO::Sysutil::getenv("TESTSHADE_OPTIX"));
OIIO::Sysutil::getenv("TESTSHADE_OPTIX"));
static bool optix_no_inline = false;
static bool optix_no_inline_layer_funcs = false;
static bool optix_no_merge_layer_funcs = false;
+15 -17
View File
@@ -470,14 +470,12 @@ SimpleRenderer::get_array_attribute(ShaderGlobals* sg, bool derivatives,
// In order to test getattribute(), respond positively to
// "options"/"blahblah"
if (object == "options" && name == "blahblah"
&& type == TypeDesc::TypeFloat) {
if (object == "options" && name == "blahblah" && type == TypeFloat) {
*(float*)val = 3.14159;
return true;
}
if (object.empty() && name == "shading:index"
&& type == TypeDesc::TypeInt) {
if (object.empty() && name == "shading:index" && type == TypeInt) {
*(int*)val = OSL::get_shade_index(sg);
return true;
}
@@ -511,7 +509,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
// look up something specific to the primitive, rather than have hard-
// coded names.
if (name == u_s && type == TypeDesc::TypeFloat) {
if (name == u_s && type == TypeFloat) {
((float*)val)[0] = sg->u;
if (derivatives) {
((float*)val)[1] = sg->dudx;
@@ -519,7 +517,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
}
return true;
}
if (name == u_t && type == TypeDesc::TypeFloat) {
if (name == u_t && type == TypeFloat) {
((float*)val)[0] = sg->v;
if (derivatives) {
((float*)val)[1] = sg->dvdx;
@@ -527,7 +525,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
}
return true;
}
if (name == u_red && type == TypeDesc::TypeFloat && sg->P.x > 0.5f) {
if (name == u_red && type == TypeFloat && sg->P.x > 0.5f) {
((float*)val)[0] = sg->u;
if (derivatives) {
((float*)val)[1] = sg->dudx;
@@ -535,7 +533,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
}
return true;
}
if (name == u_green && type == TypeDesc::TypeFloat && sg->P.x < 0.5f) {
if (name == u_green && type == TypeFloat && sg->P.x < 0.5f) {
((float*)val)[0] = sg->v;
if (derivatives) {
((float*)val)[1] = sg->dvdx;
@@ -543,7 +541,7 @@ SimpleRenderer::get_userdata(bool derivatives, ustringhash name, TypeDesc type,
}
return true;
}
if (name == u_blue && type == TypeDesc::TypeFloat
if (name == u_blue && type == TypeFloat
&& ((static_cast<int>(sg->P.y * 12) % 2) == 0)) {
((float*)val)[0] = 1.0f - sg->u;
if (derivatives) {
@@ -743,7 +741,7 @@ SimpleRenderer::get_osl_version(ShaderGlobals* /*sg*/, bool /*derivs*/,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeInt) {
if (type == TypeInt) {
((int*)val)[0] = OSL_VERSION;
return true;
}
@@ -770,7 +768,7 @@ SimpleRenderer::get_camera_projection(ShaderGlobals* /*sg*/, bool /*derivs*/,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeString) {
if (type == TypeString) {
((ustring*)val)[0] = m_projection;
return true;
}
@@ -784,7 +782,7 @@ SimpleRenderer::get_camera_fov(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*name*/, void* val)
{
// N.B. in a real renderer, this may be time-dependent
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_fov;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -799,7 +797,7 @@ SimpleRenderer::get_camera_pixelaspect(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_pixelaspect;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -830,7 +828,7 @@ SimpleRenderer::get_camera_clip_near(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_hither;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -845,7 +843,7 @@ SimpleRenderer::get_camera_clip_far(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_yon;
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -877,7 +875,7 @@ SimpleRenderer::get_camera_shutter_open(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_shutter[0];
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
@@ -892,7 +890,7 @@ SimpleRenderer::get_camera_shutter_close(ShaderGlobals* /*sg*/, bool derivs,
ustringhash /*object*/, TypeDesc type,
ustringhash /*name*/, void* val)
{
if (type == TypeDesc::TypeFloat) {
if (type == TypeFloat) {
((float*)val)[0] = m_shutter[1];
if (derivs)
memset((char*)val + type.size(), 0, 2 * type.size());
+28 -20
View File
@@ -87,7 +87,7 @@ static bool userdata_isconnected = false;
static bool print_outputs = false;
static bool output_placement = true;
static bool use_optix = OIIO::Strutil::stoi(
OIIO::Sysutil::getenv("TESTSHADE_OPTIX"));
OIIO::Sysutil::getenv("TESTSHADE_OPTIX"));
static bool optix_no_inline = false;
static bool optix_no_inline_layer_funcs = false;
static bool optix_no_merge_layer_funcs = false;
@@ -129,7 +129,6 @@ static char* userdata_base_ptr = nullptr;
static char* output_base_ptr = nullptr;
static bool use_rs_bitcode
= false; // use free function bitcode version of renderer services
static int jbufferMB = 16;
// Testshade thread tracking and assignment.
@@ -522,24 +521,24 @@ add_param(ParamValueList& params, string_view command, string_view paramname,
}
// If it is or might be a matrix, look for 16 comma-separated floats
if ((type == TypeDesc::UNKNOWN || type == TypeDesc::TypeMatrix)
if ((type == TypeDesc::UNKNOWN || type == TypeMatrix)
&& parse_float_list(stringval, f, 16)) {
params.emplace_back(paramname, TypeDesc::TypeMatrix, 1, f);
params.emplace_back(paramname, TypeMatrix, 1, f);
param_hints.push_back(hint);
return;
}
// If it is or might be a vector type, look for 3 comma-separated floats
if ((type == TypeDesc::UNKNOWN || equivalent(type, TypeDesc::TypeVector))
if ((type == TypeDesc::UNKNOWN || equivalent(type, TypeVector))
&& parse_float_list(stringval, f, 3)) {
if (type == TypeDesc::UNKNOWN)
type = TypeDesc::TypeVector;
type = TypeVector;
params.emplace_back(paramname, type, 1, f);
param_hints.push_back(hint);
return;
}
// If it is or might be an int, look for an int that takes up the whole
// string.
if ((type == TypeDesc::UNKNOWN || type == TypeDesc::TypeInt)
if ((type == TypeDesc::UNKNOWN || type == TypeInt)
&& OIIO::Strutil::string_is<int>(stringval)) {
params.emplace_back(paramname, OIIO::Strutil::stoi(stringval));
param_hints.push_back(hint);
@@ -547,7 +546,7 @@ add_param(ParamValueList& params, string_view command, string_view paramname,
}
// If it is or might be an float, look for a float that takes up the
// whole string.
if ((type == TypeDesc::UNKNOWN || type == TypeDesc::TypeFloat)
if ((type == TypeDesc::UNKNOWN || type == TypeFloat)
&& OIIO::Strutil::string_is<float>(stringval)) {
params.emplace_back(paramname, OIIO::Strutil::stof(stringval));
param_hints.push_back(hint);
@@ -595,7 +594,7 @@ add_param(ParamValueList& params, string_view command, string_view paramname,
// All remaining cases -- it's a string
const char* s = ustring(stringval).c_str();
params.emplace_back(paramname, TypeDesc::TypeString, 1, &s);
params.emplace_back(paramname, TypeString, 1, &s);
param_hints.push_back(hint);
}
@@ -675,8 +674,12 @@ print_info()
else
#endif
rend = new SimpleRenderer;
TextureSystem* texturesys = TextureSystem::create();
auto texturesys = TextureSystem::create();
#if OIIO_TEXTURESYSTEM_CREATE_SHARED
shadingsys = new ShadingSystem(rend, texturesys.get(), &errhandler);
#else
shadingsys = new ShadingSystem(rend, texturesys, &errhandler);
#endif
rend->init_shadingsys(shadingsys);
set_shadingsys_options();
@@ -1269,8 +1272,8 @@ save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys,
// We are outputting an integer variable, so we need to
// convert it to floating point.
float* pixel = OSL_ALLOCA(float, nchans);
OIIO::convert_types(TypeDesc::BASETYPE(t.basetype), data,
TypeDesc::FLOAT, pixel, nchans);
OIIO::convert_pixel_values(TypeDesc::BASETYPE(t.basetype), data,
TypeDesc::FLOAT, pixel, nchans);
outputimg->setpixel(x, y, &pixel[0]);
if (print_outputs) {
print(" {} :", outputvarnames[i]);
@@ -1418,9 +1421,9 @@ batched_save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys,
int y = by[batchIndex];
int data = batchResults[batchIndex];
float pixel[1];
OIIO::convert_types(TypeDesc::BASETYPE(t.basetype), &data,
TypeDesc::FLOAT, &pixel[0],
1 /*nchans*/);
OIIO::convert_pixel_values(TypeDesc::BASETYPE(t.basetype),
&data, TypeDesc::FLOAT,
&pixel[0], 1 /*nchans*/);
outputimg->setpixel(x, y, &pixel[0]);
if (print_outputs) {
*oStreams[batchIndex]
@@ -1442,9 +1445,9 @@ batched_save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys,
intPixel[c] = batchResults[batchIndex][c];
}
OIIO::convert_types(TypeDesc::BASETYPE(t.basetype),
intPixel, TypeDesc::FLOAT, floatPixel,
3 /*nchans*/);
OIIO::convert_pixel_values(TypeDesc::BASETYPE(t.basetype),
intPixel, TypeDesc::FLOAT,
floatPixel, 3 /*nchans*/);
outputimg->setpixel(x, y, floatPixel);
if (print_outputs) {
(*oStreams[batchIndex])
@@ -1963,7 +1966,12 @@ test_shade(int argc, const char* argv[])
// Request a TextureSystem (by default it will be the global shared
// one). This isn't strictly necessary, if you pass nullptr to
// ShadingSystem ctr, it will ask for the shared one internally.
#if OIIO_TEXTURESYSTEM_CREATE_SHARED
std::shared_ptr<TextureSystem> texturesys_owned = TextureSystem::create();
TextureSystem* texturesys = texturesys_owned.get();
#else
TextureSystem* texturesys = TextureSystem::create();
#endif
// Create a new shading system. We pass it the RendererServices
// object that services callbacks from the shading system, the
@@ -2327,8 +2335,8 @@ test_shade(int argc, const char* argv[])
std::cout << "ERRORS left in TextureSystem:\n" << err << "\n";
retcode = EXIT_FAILURE;
}
OIIO::ImageCache* ic = texturesys->imagecache();
err = ic ? ic->geterror() : std::string();
auto ic = texturesys->imagecache();
err = ic ? ic->geterror() : std::string();
if (!err.empty()) {
std::cout << "ERRORS left in ImageCache:\n" << err << "\n";
retcode = EXIT_FAILURE;
+1 -1
View File
@@ -20,7 +20,7 @@ testing with spaces:
color ("hsl", 0, 0, 0.5) = 0.5 0.5 0.5
color ("hsl", 0.5, 1, 0.1) = 0 0.2 0.2
color ("YIQ", 0.5, 0.25, 0.25) = 0.8939 0.270375 0.649225
color ("XYZ", 0.25, 0.5, 0.25) = -0.0831534 0.705882 0.176283
color ("XYZ", 0.25, 0.5, 0.25) = -0.08315 0.7059 0.1763
luminance(0.5 0.75 0.75) = 0.696873
luminance(0.5 0.5 0.5) = 0.5
+1 -1
View File
@@ -20,7 +20,7 @@ testing with spaces:
color ("hsl", 0, 0, 0.5) = 0.5 0.5 0.5
color ("hsl", 0.5, 1, 0.1) = 0 0.2 0.2
color ("YIQ", 0.5, 0.25, 0.25) = 0.8939 0.270375 0.649225
color ("XYZ", 0.25, 0.5, 0.25) = -0.0831534 0.705883 0.176283
color ("XYZ", 0.25, 0.5, 0.25) = -0.08315 0.7059 0.1763
luminance(0.5 0.75 0.75) = 0.696873
luminance(0.5 0.5 0.5) = 0.5
+1 -1
View File
@@ -63,7 +63,7 @@ test (color cparam = color (.1, .7, .2),
printf (" color (\"YIQ\", %g, %g, %g) = %g\n",
pretty(Y), pretty(I), pretty(Q), pretty(color("YIQ", Y,I,Q)));
float x = 0.25, y = 0.5, z = 0.25;
printf (" color (\"XYZ\", %g, %g, %g) = %g\n",
printf (" color (\"XYZ\", %0.4g, %0.4g, %0.4g) = %0.4g\n",
pretty(x), pretty(y), pretty(z), pretty(color("XYZ",x,y,z)));
}
+7 -2
View File
@@ -38,9 +38,13 @@ find_library(CUDA_cuda_LIBRARY cuda HINTS ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES
# TODO: move to sm_60?
set(CUDA_TARGET_ARCH sm_35)
set (CMAKE_CXX_STANDARD 14 CACHE STRING
"C++ standard to build with (14, 17, 20, etc.)")
# Compile our "renderer" to PTX
cuda_compile_ptx(CUDA_PTX_FILES cuda_grid_renderer.cu
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc --std=c++14
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc
--std=c++${CMAKE_CXX_STANDARD}
--expt-relaxed-constexpr
-I${OSL_INCLUDES}
-I${IMATH_INCLUDES}
@@ -58,7 +62,8 @@ add_custom_target(cuda_grid_renderer_ptx ALL
# Compile the rend_lib shadeops to PTX
cuda_compile_ptx(CUDA_PTX_FILES rend_lib.cu
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc --std=c++14
OPTIONS --gpu-architecture=${CUDA_TARGET_ARCH} --use_fast_math -dc
--std=c++${CMAKE_CXX_STANDARD}
--expt-relaxed-constexpr
-I${OSL_INCLUDES}
-I${IMATH_INCLUDES}
+1 -1
View File
@@ -337,7 +337,7 @@ register_closures(ShadingSystem& ss)
const char* cuda_compile_options[] = { "--gpu-architecture=compute_35",
"--use_fast_math", "-dc",
"--std=c++11" };
"--std=c++" #OSL_CPLUSPLUS_VERSION };
std::string
build_trampoline_ptx(OSL::ShaderGroup& group, std::string init_name,
@@ -0,0 +1,9 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
shader printcalculatenormal ()
{
normal n2 = calculatenormal(P+1);
printf ("calculatenormal = %f", n2);
}

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