Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5fa7493be | ||
|
|
b9bef036a0 | ||
|
|
7bc025c0f9 | ||
|
|
7a9e006bce | ||
|
|
7992fca485 | ||
|
|
ab7a20fc51 | ||
|
|
3921c29b6a | ||
|
|
4d0721af96 | ||
|
|
53374d0771 | ||
|
|
44775a9b7f | ||
|
|
884a98f8dc | ||
|
|
d0bc80a7db | ||
|
|
1afd40ec05 | ||
|
|
42d4586340 | ||
|
|
a8b4f4a0d6 | ||
|
|
f17ef1cc97 | ||
|
|
060886510f | ||
|
|
fe24f7999b | ||
|
|
fd4b290185 | ||
|
|
21542d21f2 | ||
|
|
17f17b047f | ||
|
|
7380dca655 | ||
|
|
0472556fab | ||
|
|
b4ec1c2033 | ||
|
|
f630ea84e9 | ||
|
|
6f428d5d4d | ||
|
|
4ac5eefe47 | ||
|
|
ef3bc05484 | ||
|
|
69356cf77b | ||
|
|
effe45a532 | ||
|
|
762c5ba815 | ||
|
|
8e1cb4fc7e | ||
|
|
33754ff7a3 | ||
|
|
37e7c0c9b6 | ||
|
|
eccc616f1f | ||
|
|
f71df206d2 | ||
|
|
9968a45ebd | ||
|
|
624dfc253c | ||
|
|
7519e51072 | ||
|
|
f696fff108 | ||
|
|
ef068bf1c7 | ||
|
|
a7da1a4a34 | ||
|
|
87443aaab4 | ||
|
|
d8ecfed2f9 | ||
|
|
bf4f27c47d | ||
|
|
9e23b6b8ee | ||
|
|
93f22c55cd | ||
|
|
8cda886637 | ||
|
|
2f4cf2ff90 | ||
|
|
cbd2409a02 | ||
|
|
1290dd9d05 | ||
|
|
8beab16f27 | ||
|
|
379b3ab30e | ||
|
|
a9d9a225b2 | ||
|
|
4c4ea31c4f | ||
|
|
62296cadf1 | ||
|
|
2c4a717472 | ||
|
|
b038b03cb3 | ||
|
|
8f9f5007c8 | ||
|
|
65a930fd5e | ||
|
|
3c7881a23f | ||
|
|
c125d18822 | ||
|
|
2b0ef8b5bf | ||
|
|
a1a3d5d15b | ||
|
|
380f1d1010 | ||
|
|
d8b6e5d6c3 | ||
|
|
d5310e0599 | ||
|
|
d316943b1a | ||
|
|
27a491d12e | ||
|
|
bf7b78e7a5 | ||
|
|
7cfa13febf | ||
|
|
512867fb9f | ||
|
|
517adf40c2 | ||
|
|
09574cd2a9 | ||
|
|
39cd99bab5 | ||
|
|
f2c8d70f75 | ||
|
|
085ceb3f20 | ||
|
|
04510cdf1f | ||
|
|
54ce6f0fe4 | ||
|
|
2bbc7f79fc |
@@ -2,29 +2,25 @@
|
||||
|
||||
language: cpp
|
||||
sudo: false
|
||||
#compiler:
|
||||
# - clang
|
||||
# - gcc
|
||||
#os:
|
||||
# - linux
|
||||
# - osx
|
||||
osx_image: xcode7.3
|
||||
dist: precise
|
||||
dist: trusty
|
||||
|
||||
|
||||
# Add-ons: specify apt packages for Linux
|
||||
addons:
|
||||
apt:
|
||||
apt:
|
||||
sources:
|
||||
- boost-latest
|
||||
- ubuntu-toolchain-r-test
|
||||
- george-edison55-precise-backports
|
||||
packages:
|
||||
- cmake
|
||||
- cmake-data
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- gcc-6
|
||||
- g++-6
|
||||
- libboost1.55-all-dev
|
||||
- libtiff4-dev
|
||||
- llvm-3.4-dev
|
||||
- clang-3.4
|
||||
|
||||
@@ -41,7 +37,7 @@ before_install:
|
||||
sysctl machdep.cpu.features ;
|
||||
elif [ $TRAVIS_OS_NAME == linux ] ; then
|
||||
export PLATFORM=linux64 ;
|
||||
cat /proc/cpuinfo ;
|
||||
cat /proc/cpuinfo | head -26 ;
|
||||
fi
|
||||
- export OIIOPLATFORM=$PLATFORM
|
||||
- if [ "$DEBUG" == 1 ] ; then export PLATFORM=${PLATFORM}.debug ; fi
|
||||
@@ -58,7 +54,9 @@ install:
|
||||
export ILMBASE_HOME=$PWD/openexr-install ;
|
||||
export OPENEXR_HOME=$PWD/openexr-install ;
|
||||
fi
|
||||
- export OIIOMAKEFLAGS="$OIIOMAKEFLAGS -j2 DEBUG= "
|
||||
- export OIIOMAKEFLAGS="$OIIOMAKEFLAGS -j2 DEBUG= USE_PYTHON=0 OIIO_BUILD_TESTS=0"
|
||||
- export OPENIMAGEIO_SITE=travis
|
||||
- export OSL_SITE=travis
|
||||
- src/build-scripts/build_openimageio.bash
|
||||
- export OPENIMAGEIOHOME=$PWD/OpenImageIO/dist/$OIIOPLATFORM
|
||||
- export DYLD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$DYLD_LIBRARY_PATH
|
||||
@@ -76,8 +74,9 @@ script:
|
||||
- make VERBOSE=1 $BUILD_FLAGS cmakesetup
|
||||
- make -j2 $BUILD_FLAGS
|
||||
- export OSLHOME=$PWD/dist/$PLATFORM
|
||||
- export DYLD_LIBRARY_PATH=$OSLHOME/lib:$DYLD_LIBRARY_PATH
|
||||
- export DYLD_LIBRARY_PATH=$OSLHOME/lib:$DYLD_LIBRARY_PATH
|
||||
- export LD_LIBRARY_PATH=$OSLHOME/lib:$LD_LIBRARY_PATH
|
||||
- export OIIO_LIBRARY_PATH=$OSLHOME/lib:${OIIO_LIBRARY_PATH}
|
||||
- export PYTHONPATH=$OSLHOME/python:$OPENIMAGEIOHOME/python:$PYTHONPATH
|
||||
- make $BUILD_FLAGS test
|
||||
|
||||
@@ -108,17 +107,24 @@ matrix:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: DEBUG=1 USE_CPP11=1 USE_CPP=11
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: DEBUG=1 USE_CPP11=1 USE_CPP=11
|
||||
# Test against the older release branch of OIIO (all the other tests
|
||||
# are against OIIO master), and also use C++03.
|
||||
#- os: osx
|
||||
# compiler: clang
|
||||
# env: DEBUG=1 USE_CPP11=1 USE_CPP=11
|
||||
# Test against the current release branch of OIIO (most of the other
|
||||
# tests are against OIIO master).
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: OIIOBRANCH=release USE_CPP11=0
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: OIIOBRANCH=release USE_CPP11=0
|
||||
env: OIIOBRANCH=release USE_CPP11=1 USE_CPP=11
|
||||
# Test against the previous release branch of OIIO, which may still be
|
||||
# used, and also use C++03.
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: OIIOBRANCH=RB-1.8 USE_CPP11=1
|
||||
# Seems LLVM 3.4 has disappeared from Homebrew, so there's not an
|
||||
# easy way to test C++03 builds on OSX on TravisCI.
|
||||
#- os: osx
|
||||
# compiler: clang
|
||||
# env: OIIOBRANCH=release USE_CPP11=0 LLVMBREWVER=3.4
|
||||
# Linux only: test gcc 6 (catch new warnings hot off the presses) and
|
||||
# also use a higher SIMD level, avx and f16c, to make sure all is well.
|
||||
# TravisCI's OSX images don't yet support avx/f16c, so we only do this
|
||||
|
||||
@@ -1,5 +1,96 @@
|
||||
Release 1.8 [1.8.3] -- 20 Feb 2017 (compared to 1.7)
|
||||
Release 1.8.14 -- 1 May 2018 (compared to 1.8.13)
|
||||
--------------------------------------------------
|
||||
* New SS attribute "error_repeats", if set to non-zero, turns off the
|
||||
suppression of multiple identical errors and warnings. Setting it (even to
|
||||
its existing value) also clears the "already seen" lists. #880
|
||||
* Update to fix with some changes in OpenImageIO 1.9. #882
|
||||
|
||||
Release 1.8.13 -- 1 Apr 2018 (compared to 1.8.12)
|
||||
--------------------------------------------------
|
||||
* Build the version into the shared library .so names. #876
|
||||
|
||||
Release 1.8.12 -- 1 Nov 2017 (compared to 1.8.11)
|
||||
--------------------------------------------------
|
||||
* Improve type checking error messages with structs. #761
|
||||
|
||||
Release 1.8.11 -- 3 Oct 2017 (compared to 1.8.10)
|
||||
--------------------------------------------------
|
||||
* Builds properly against LLVM 5.0, and if compiled by clang 5.0.
|
||||
* Changes to test/CI with recent OIIO release.
|
||||
|
||||
Release 1.8.10 -- 1 Jul 2017 (compared to 1.8.9)
|
||||
--------------------------------------------------
|
||||
* Missing faceforward() implementation was added to stdosl.h. #759
|
||||
* `testshade` new option `--shader <shadername> <layername>` is a
|
||||
convenience that takes the place of a separate `--layer` and `--shader`
|
||||
arguments, and makes the command line look more similar to the serialized
|
||||
(text) description of a shader group. #763
|
||||
* README.md, CHANGES.md, and INSTALL.md are now installed in the "doc"
|
||||
directory of a fully-built dist area, rather than at its top level.
|
||||
* `smoothstep()` now has variants where the arguments and return type may
|
||||
be color, vector, etc. (previously it only worked for `float`. #765
|
||||
* `mix()` now has a variant that combines closures. #766
|
||||
* testshade comprehensive documentation in `doc/testshade.md.html`, just
|
||||
view with your browser.
|
||||
* Fixed a numerical precision problem with `inversespline()`. #772
|
||||
* Fixed a bug in transitive assignment of indexed arrays, like
|
||||
`f[0] = f[1] = f[2]`. This previously hit an assertion. #774
|
||||
* New standard OSL function `hash()` makes a repeatable integer hash of
|
||||
a float, 2 floats, a triple, or triple + float. #775
|
||||
* New `hashnoise()` is similar to cellnoise(), but has a different
|
||||
repeatable 0.0-1.0 range value for every input position (whereas cellnoise
|
||||
is constant between integer coordinates). #775
|
||||
|
||||
Release 1.8.9 -- 1 Jun 2017 (compared to 1.8.8)
|
||||
--------------------------------------------------
|
||||
* Minor speedup when passing blank subimage name:
|
||||
texture (..., "subimage", "", ...)
|
||||
#749
|
||||
* Fix namespace clash after recent OIIO (master branch) PugiXML version
|
||||
upgrade.
|
||||
* Several testshade changes: renamed options --scalest/--offsetst to
|
||||
--scaleuv/--offsetuv to more closely say what they really do;
|
||||
rename -od to -d to match how oiiotool and maketx call the same
|
||||
option; automatically convert to sRGB when instructed to save an
|
||||
output image as JPEG, GIF, or PNG; -runstats is more careful with
|
||||
timing to not include image output in shader run time; new --print
|
||||
option prints outputs to console (don't use with large images!). #757
|
||||
|
||||
Release 1.8.8 -- 1 May 2017 (compared to 1.8.7)
|
||||
--------------------------------------------------
|
||||
* New ShadingSystem::set_raytypes() can be used to configure default ray
|
||||
types for subsequent lazy optimization of the group upon first execution.
|
||||
#733
|
||||
* Hide symbol visibility for extern "C" linkage osl_* functions that LLVM
|
||||
needs. #732
|
||||
* New oslc-time macros OSL_VERSION, OSL_VERSION_MAJOR, OSL_VERSION_MINOR,
|
||||
OSL_VERSION_PATCH lets you easily test OSL version while compiling your
|
||||
shader. You can also find out at runtime with getattribute("osl:version").
|
||||
#747
|
||||
|
||||
Release 1.8.7 -- 1 Apr 2017 (compared to 1.8.6)
|
||||
--------------------------------------------------
|
||||
* Fix possible division-by-zero when computing derivatives in
|
||||
pointcloud_search. #710
|
||||
* When using clang components as the C preprocessor for .osl files, better
|
||||
reporting of any C preprocessor errors. #719
|
||||
* Fix minor inconsistency in the behavior of `normalize()` when the input
|
||||
has derivatives versus when it does not. #720
|
||||
* Fixes to using clang for the C preprocessing -- we discovered cases where
|
||||
it's unreliable for older clang versions, so it now only works when using
|
||||
LLVM >= 3.9 (for older LLVM versions, we fall back to boost wave for our
|
||||
preprocessing needs). #721
|
||||
* Fix an optimization bug where calls to `trace()` could accidentally get
|
||||
elided if the results of the function call were unused in the shader.
|
||||
This is incorrect! Because `trace()` has side effects upon subsequent
|
||||
calls to `getmessage("trace",...)`. #722
|
||||
* Fixed linkage problems where some of our unit test programs were unwisely
|
||||
linking against both liboslcomp and liboslexec (not necessary, and caused
|
||||
problems for certain LLVM components that appeared statically in both).
|
||||
|
||||
|
||||
Release 1.8 [1.8.6] -- 1 Mar 2017 (compared to 1.7)
|
||||
---------------------------------------------------
|
||||
|
||||
Dependency and standards changes:
|
||||
* OSL now builds properly against LLVM 3.9 and 4.0 (in addition to 3.5 and
|
||||
@@ -15,7 +106,8 @@ Dependency and standards changes:
|
||||
**OSL 1.8 is the last release that will build against C++03. Future
|
||||
major releases will require C++11 as a minimum.**
|
||||
* OpenImageIO: This release of OSL should build properly against OIIO
|
||||
1.6 or newer.
|
||||
1.6 or newer (although 1.7 is the current release and therefore
|
||||
recommended).
|
||||
|
||||
**New library: `liboslnoise`** and header `oslnoise.h` expose OSL's noise
|
||||
functions to C++ apps. Currently, only signed and unsigned perlin, and
|
||||
@@ -87,10 +179,6 @@ API changes, new options, new ShadingSystem features (for renderer writers):
|
||||
* Attribute "llvm_debug_ops" adds a printf before running each op.
|
||||
This is mostly for debugging OSL itself, not for users. (1.8.3)
|
||||
|
||||
<!--* Shader group attribute additions/changes:
|
||||
* RendererServices:
|
||||
-->
|
||||
|
||||
Performance improvements:
|
||||
* New runtime optimization: better at understanding the initial values of
|
||||
output parameters and what optimizations can be done based on that. #657
|
||||
@@ -151,6 +239,12 @@ Build & test system improvements and developer goodies:
|
||||
* Improve search for Partio. #689 (1.8.3)
|
||||
* More robust finding of LLVM components. (1.8.3)
|
||||
* OSL now builds properly with LLVM 3.9 and 4.0. #693 (1.8.3)
|
||||
* When available (and with the right compiler version combinations), OSL
|
||||
will rely on Clang library internals to "preprocess" oso input, rather
|
||||
than Boost Wave. This solves problems particularly on OSX and FreeBSD
|
||||
where clang/C++11-compiled OSL was having trouble using Boost Wave if
|
||||
Boost was not compiled in C++11 mode (which is difficult to ensure if
|
||||
you don't control the machine or build boost yourself). #715 (1.8.5)
|
||||
|
||||
Documentation:
|
||||
* Various typos fixed.
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
project (OSL)
|
||||
|
||||
# Release version of the library
|
||||
set (OSL_LIBRARY_VERSION_MAJOR 1)
|
||||
set (OSL_LIBRARY_VERSION_MINOR 8)
|
||||
set (OSL_LIBRARY_VERSION_PATCH 3)
|
||||
set (OSL_LIBRARY_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
|
||||
set (PROJ_NAME OSL)
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 8)
|
||||
set (PROJECT_VERSION_PATCH 14)
|
||||
set (OSL_LIBRARY_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set (OSL_LIBRARY_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set (OSL_LIBRARY_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
set (OSL_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
||||
set (OSL_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
||||
set (OSL_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||
set (OSL_LIBRARY_VERSION_RELEASE_TYPE "") # "dev", "betaX", "RCY", ""
|
||||
|
||||
# Version of the OSO file format and instruction set
|
||||
set (OSO_FILE_VERSION_MAJOR 1)
|
||||
set (OSO_FILE_VERSION_MINOR 0)
|
||||
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 2.8.4)
|
||||
cmake_policy (SET CMP0017 NEW)
|
||||
endif ()
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||
cmake_policy (SET CMP0025 NEW) # Detect AppleClang for new CMake
|
||||
endif ()
|
||||
message (STATUS "CMake version is ${CMAKE_VERSION}")
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
cmake_policy (SET CMP0017 NEW)
|
||||
cmake_policy (SET CMP0025 NEW) # Detect AppleClang for new CMake
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.2.2)
|
||||
cmake_policy (SET CMP0042 OLD)
|
||||
# cmake_policy (SET CMP0042 OLD)
|
||||
cmake_policy (SET CMP0046 OLD)
|
||||
endif ()
|
||||
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
|
||||
@@ -117,14 +121,14 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
# Linux/FreeBSD/Hurd: also hide all the symbols of dependent
|
||||
# libraries to prevent clashes if an app using this library is
|
||||
# linked against other verions of our dependencies.
|
||||
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/libOpenImageIO/libOpenImageIO.map")
|
||||
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/build-scripts/hidesymbols.map")
|
||||
endif ()
|
||||
endif ()
|
||||
if (LLVM_STATIC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT DEBUGMODE)
|
||||
# Linux: When linking against LLVM statically, we can also hide
|
||||
# all its symbols to prevent clashes if OSL is linked against an
|
||||
# app that also embeds LLVM.
|
||||
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/liboslexec/liboslexec.map")
|
||||
set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/build-scripts/hidesymbols.map")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
@@ -243,6 +247,9 @@ set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::
|
||||
set (OSL_BUILD_PLUGINS ON CACHE BOOL "Bool OSL plugins, for example OIIO plugin")
|
||||
set (USE_CCACHE ON CACHE BOOL "Use ccache if found")
|
||||
set (CODECOV OFF CACHE BOOL "Build code coverage tests")
|
||||
option (USE_BOOST_WAVE "Use Boost Wave for C preprocessor (alternative is to use clang)" OFF)
|
||||
set (SOVERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}
|
||||
CACHE STRING "Set the SO version in the SO name of the output library")
|
||||
|
||||
# Use ccache if found
|
||||
find_program (CCACHE_FOUND ccache)
|
||||
@@ -351,12 +358,10 @@ set (CMAKE_MODULE_PATH
|
||||
include (util_macros)
|
||||
include (platform)
|
||||
include (externalpackages)
|
||||
include (oiio)
|
||||
include (flexbison)
|
||||
include_directories (
|
||||
"${CMAKE_SOURCE_DIR}/src/include"
|
||||
"${CMAKE_BINARY_DIR}/include/OSL"
|
||||
"${OPENIMAGEIO_INCLUDES}"
|
||||
)
|
||||
|
||||
|
||||
@@ -550,7 +555,7 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
|
||||
geomath getattribute-camera getattribute-shader
|
||||
getsymbol-nonheap gettextureinfo
|
||||
group-outputs groupstring
|
||||
hex hyperb
|
||||
hash hashnoise hex hyperb
|
||||
ieee_fp if incdec initops intbits isconnected isconstant
|
||||
layers layers-Ciassign layers-entry layers-lazy
|
||||
layers-nonlazycopy layers-repeatedoutputs
|
||||
@@ -570,6 +575,7 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
|
||||
oslc-err-struct-array-init oslc-err-struct-dup
|
||||
oslc-warn-commainit
|
||||
oslc-variadic-macro
|
||||
oslc-version
|
||||
oslinfo-arrayparams oslinfo-colorctrfloat
|
||||
oslinfo-metadata oslinfo-noparams
|
||||
osl-imageio
|
||||
@@ -578,7 +584,8 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
|
||||
render-background render-bumptest
|
||||
render-cornell render-furnace-diffuse
|
||||
render-microfacet render-oren-nayar render-veachmis render-ward
|
||||
select shortcircuit spline splineinverse spline-derivbug
|
||||
select shortcircuit spline splineinverse
|
||||
spline-boundarybug spline-derivbug
|
||||
string
|
||||
struct struct-array struct-array-mixture
|
||||
struct-err struct-init-copy struct-layers
|
||||
@@ -592,7 +599,9 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
|
||||
texture-missingcolor texture-simple
|
||||
texture-smallderivs texture-swirl texture-udim
|
||||
texture-width texture-withderivs texture-wrap
|
||||
trailing-commas transform transformc trig typecast
|
||||
trailing-commas
|
||||
transitive-assign
|
||||
transform transformc trig typecast
|
||||
unknown-instruction
|
||||
vararray-connect vararray-default
|
||||
vararray-deserialize vararray-param
|
||||
|
||||
@@ -6,9 +6,17 @@ OSL currently compiles and runs cleanly on Linux, Mac OS X, and Windows.
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
OSL requires the following dependencies:
|
||||
OSL requires the following dependencies or tools:
|
||||
|
||||
* [OpenImageIO](http://openimageio.org) 1.7 or newer
|
||||
* Build system: [CMake](https://cmake.org/) 3.0 or newer
|
||||
|
||||
* A suitable C++11 compiler to build OSL itself, which may be any of:
|
||||
- GCC 4.8.5 or newer
|
||||
- Clang 3.4 or newer
|
||||
- Microsoft Visual Studio 2015 or newer
|
||||
- Intel C++ compiler icc version 13 (?) or newer
|
||||
|
||||
* [OpenImageIO](http://openimageio.org) 1.6 or newer
|
||||
|
||||
OSL uses OIIO both for its texture mapping functionality as well as
|
||||
numerous utility classes. If you are integrating OSL into an existing
|
||||
@@ -26,7 +34,7 @@ OSL requires the following dependencies:
|
||||
well as for $OPENIMAGEIOHOME/lib to be in your LD_LIBRARY_PATH (or
|
||||
DYLD_LIBRARY_PATH on OS X) and then OSL's build scripts will be able
|
||||
to find it.
|
||||
* [LLVM](http://www.llvm.org) 3.4, 3.5, 3.9, or 4.0
|
||||
* [LLVM](http://www.llvm.org) 3.4, 3.5, 3.9, 4.0, or 5.0
|
||||
|
||||
It's possible that other intermediate versions will work, but we are not
|
||||
testing them. Please note that for version 3.5 or later, you'll need to
|
||||
@@ -36,10 +44,21 @@ OSL requires the following dependencies:
|
||||
JIT may be important for interactive applications). We anticipate that
|
||||
future OSL releases will improve JIT performance and then drop support
|
||||
for the older LLVM versions.
|
||||
|
||||
Optionally, if Clang libraries are installed alongside LLVM, OSL will
|
||||
in most circumstances use Clang's internals for C-style preprocessing of
|
||||
OSL source. If not found, it will fall back on Boost Wave (but on many
|
||||
platforms, that requires that Boost has been built in C++11 mode).
|
||||
|
||||
* [Boost](www.boost.org) 1.55 or newer.
|
||||
* [Imath/OpenEXR](http://openexr.com/downloads.html)
|
||||
* [Flex](https://github.com/westes/flex)
|
||||
* [GNU Bison](https://www.gnu.org/software/bison/)
|
||||
* [PugiXML](http://pugixml.org/)
|
||||
* [Partio](https://www.disneyanimation.com/technology/partio.html) --
|
||||
optional, but if it is not found at build time, the OSL `pointcloud`
|
||||
functions will not be operative.
|
||||
|
||||
|
||||
|
||||
Build process
|
||||
|
||||
@@ -39,10 +39,10 @@ CMAKE ?= cmake
|
||||
ifndef OSL_SITE
|
||||
OSL_SITE := ${shell uname -n}
|
||||
endif
|
||||
ifneq (${shell echo ${OSL_SITE} | grep imageworks},)
|
||||
ifneq (${shell echo ${OSL_SITE} | grep imageworks.com},)
|
||||
include ${working_dir}/site/spi/Makefile-bits
|
||||
endif
|
||||
ifneq (${shell echo ${OSL_SITE} | grep pixar},)
|
||||
ifneq (${shell echo ${OSL_SITE} | grep pixar.com},)
|
||||
include ${working_dir}/site/pixar/Makefile-bits
|
||||
endif
|
||||
|
||||
@@ -86,6 +86,10 @@ ifneq (${USE_LLVM_BITCODE},)
|
||||
MY_CMAKE_FLAGS += -DUSE_LLVM_BITCODE:BOOL=${USE_LLVM_BITCODE}
|
||||
endif
|
||||
|
||||
ifneq (${USE_BOOST_WAVE},)
|
||||
MY_CMAKE_FLAGS += -DUSE_BOOST_WAVE:BOOL=${USE_BOOST_WAVE}
|
||||
endif
|
||||
|
||||
ifneq (${NAMESPACE},)
|
||||
MY_CMAKE_FLAGS += -DOSL_NAMESPACE:STRING=${NAMESPACE}
|
||||
endif
|
||||
@@ -126,6 +130,10 @@ ifneq (${BUILDSTATIC},)
|
||||
MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=${BUILDSTATIC}
|
||||
endif
|
||||
|
||||
ifneq (${SOVERSION},)
|
||||
MY_CMAKE_FLAGS += -DSOVERSION:STRING=${SOVERSION}
|
||||
endif
|
||||
|
||||
ifneq (${LINKSTATIC},)
|
||||
MY_CMAKE_FLAGS += -DLINKSTATIC:BOOL=${LINKSTATIC}
|
||||
endif
|
||||
@@ -352,10 +360,11 @@ help:
|
||||
@echo " LLVM_NAMESPACE=xx Specify custom LLVM namespace"
|
||||
@echo " LLVM_STATIC=1 Use static LLVM libraries"
|
||||
@echo " USE_LLVM_BITCODE=0 Don't generate embedded LLVM bitcode"
|
||||
@echo " USE_BOOST_WAVE=1 Force boost wave rather than clang preprocessor"
|
||||
@echo " OSL build-time options:"
|
||||
@echo " NAMESPACE=name Wrap OSL APIs in another namespace"
|
||||
@echo " USE_FAST_MATH=1 Use faster, but less accurate math (set to 0 for libm defaults)"
|
||||
@echo " OSL_BUILD_TESTS=0 Skip building the unit tests, testshade, testrender"
|
||||
@echo " OSL_BUILD_TESTS=0 Don't build unit tests, testshade, testrender"
|
||||
@echo " USE_SIMD=arch Build with SIMD support (choices: 0, sse2, sse3,"
|
||||
@echo " ssse3, sse4.1, sse4.2, f16c,"
|
||||
@echo " comma-separated ok)"
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
README for Open Shading Language
|
||||
================================
|
||||
<div align="center">
|
||||
<img src="https://github.com/imageworks/OpenShadingLanguage/blob/master/src/doc/Figures/osl-short.png" width=256 height=128>
|
||||
</div>
|
||||
|
||||
|
||||
Open Shading Language
|
||||
=====================
|
||||
|
||||
Build status:
|
||||
|
||||
[](https://travis-ci.org/imageworks/OpenShadingLanguage)
|
||||
|
||||
Table of contents
|
||||
------------------
|
||||
**Table of contents**
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [How OSL is different](#how-osl-is-different)
|
||||
@@ -31,9 +35,8 @@ house renderer used for feature film animation and visual effects, released
|
||||
as open source so it could be used by other visual effects and animation
|
||||
studios and rendering software vendors. Now it's the de facto standard
|
||||
shading language for VFX and animated features, used across the industry in
|
||||
many commercial and studio- proprietary renderers. Because of this, its
|
||||
designer won an Academy Award for Technical Achievement in 2017, for the
|
||||
work on OSL.
|
||||
many commercial and studio- proprietary renderers. Because of this, the work
|
||||
on OSL received an Academy Award for Technical Achievement in 2017.
|
||||
|
||||
OSL is robust and production-proven, and has been used in films as diverse
|
||||
as "The Amazing Spider-Man," "Hotel Transylvania," "Edge of Tomorrow", "Ant
|
||||
@@ -41,14 +44,14 @@ Man", "Finding Dory," and many more. OSL support is in most leading
|
||||
renderers used for high-end VFX and animation work. For a full list of films
|
||||
and products, see the [filmography](#where-osl-has-been-used).
|
||||
|
||||
The OSL code is distributed under the "New BSD" license (see the
|
||||
"LICENSE" file that comes with the distribution), and the documentation
|
||||
under the Creative Commons Attribution 3.0 Unported License
|
||||
(http://creativecommons.org/licenses/by/3.0/). In short, you are free
|
||||
to use OSL in your own applications, whether they are free or
|
||||
The OSL code is distributed under the
|
||||
["New BSD" license](https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE),
|
||||
and the documentation under the [Creative Commons Attribution 3.0 Unported
|
||||
License](http://creativecommons.org/licenses/by/3.0/). In short, you are
|
||||
free to use OSL in your own applications, whether they are free or
|
||||
commercial, open or proprietary, as well as to modify the OSL code and
|
||||
documentation as you desire, provided that you retain the original
|
||||
copyright notices as described in the license.
|
||||
documentation as you desire, provided that you retain the original copyright
|
||||
notices as described in the license.
|
||||
|
||||
|
||||
How OSL is different
|
||||
@@ -239,6 +242,7 @@ adding OSL support):
|
||||
* [DNA Research: 3Delight](http://www.3delight.com/)
|
||||
* Ubisoft motion picture group's proprietary renderer
|
||||
* [Autodesk/SolidAngle: Arnold](https://www.solidangle.com/arnold/)
|
||||
* [Autodesk: 3DS Max 2019](https://help.autodesk.com/view/3DSMAX/2019/ENU/?guid=__developer_3ds_max_sdk_features_rendering_osl_html)
|
||||
|
||||
Films using OSL (grouped by year of release date):
|
||||
* **(2012)**
|
||||
@@ -266,21 +270,55 @@ Films using OSL (grouped by year of release date):
|
||||
Angry Birds Movie, Alice Through the Looking Glass,
|
||||
Captain America: Civil War,
|
||||
Finding Dory, Piper,
|
||||
Independence Day: Resurgence,
|
||||
Ghostbusters,
|
||||
Star Trek Beyond,
|
||||
Suicide Squad,
|
||||
Kingsglaive: Final Fantasy XV,
|
||||
Storks,
|
||||
Miss Peregrine's Home for Peculiar Children, Assassin's Creed
|
||||
Miss Peregrine's Home for Peculiar Children,
|
||||
Assassin's Creed,
|
||||
Fantastic Beasts and Where to Find Them
|
||||
* **(2017)**
|
||||
Lego Batman,
|
||||
The Great Wall,
|
||||
A Cure for Wellness,
|
||||
Logan,
|
||||
Power Rangers,
|
||||
Life,
|
||||
Smurfs: The Lost Village,
|
||||
The Fate of the Furious,
|
||||
Alien Covenant,
|
||||
Guardians of the Galaxy 2,
|
||||
The Mummy,
|
||||
Wonder Woman,
|
||||
Cars 3,
|
||||
Baby Driver,
|
||||
Spider-Man: Homecoming,
|
||||
Dunkirk,
|
||||
The Emoji Movie,
|
||||
Detroit,
|
||||
Kingsman: The Golden Circle,
|
||||
Lega Ninjago Movie,
|
||||
Blade Runner 2049,
|
||||
Geostorm,
|
||||
Coco,
|
||||
Justice League,
|
||||
Thor: Ragnarok
|
||||
* **(2018) / upcoming**
|
||||
Peter Rabbit,
|
||||
Black Panther,
|
||||
Annnihilation,
|
||||
Red Sparrow,
|
||||
Pacific Rom Uprising
|
||||
...
|
||||
|
||||
|
||||
Building OSL
|
||||
------------
|
||||
|
||||
Please see the "INSTALL.md" file in the OSL distribution for instructions
|
||||
for building the OSL source code.
|
||||
Please see the [INSTALL.md](INSTALL.md) file in the OSL distribution for
|
||||
instructions for building the OSL source code.
|
||||
|
||||
|
||||
Contacts, Links, and References
|
||||
@@ -313,11 +351,12 @@ Van Lommel.
|
||||
|
||||
Additionally, many others have contributed features, bug fixes, and other
|
||||
changes: Steve Agland, Shane Ambler, Martijn Berger, Farchad Bidgolirad,
|
||||
Nicholas Bishop, Stefan Büttner, Matthaus G. Chajdas, Thomas Dinges, Henri
|
||||
Fousse, Syoyo Fujita, Derek Haase, Sven-Hendrik Haase, John Haddon, Daniel
|
||||
Heckenberg, Ronan Keryell, Elvic Liang, Max Liani, Bastien Montagne, Erich
|
||||
Ocean, Mikko Ohtamaa, Alex Schworer, Sergey Sharybin, Stephan Steinbach,
|
||||
Esteban Tovagliari, Alexander von Knorring, Roman Zulak. (Listed
|
||||
Nicholas Bishop, Stefan Büttner, Matthaus G. Chajdas, Thomas Dinges, Mark
|
||||
Final, Henri Fousse, Syoyo Fujita, Tim Grant, Derek Haase, Sven-Hendrik
|
||||
Haase, John Haddon, Daniel Heckenberg, Matt Johnson, Ronan Keryell, Elvic
|
||||
Liang, Max Liani, Bastien Montagne, Alexis Oblet, Erich Ocean, Mikko
|
||||
Ohtamaa, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Stephan
|
||||
Steinbach, Esteban Tovagliari, Alexander von Knorring, Roman Zulak. (Listed
|
||||
alphabetically; if we've left anybody out, please let us know.)
|
||||
|
||||
We cannot possibly express sufficient gratitude to the managers at Sony
|
||||
|
||||
@@ -91,10 +91,12 @@ else ifeq (${platform}, macosx)
|
||||
# clang from the site-specific places we have installed them.
|
||||
ifeq (${COMPILER}, gcc5)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-5
|
||||
-DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER}, gcc6)
|
||||
MY_CMAKE_FLAGS += \
|
||||
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-6 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-6
|
||||
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
|
||||
USE_LIBCPLUSPLUS := 0
|
||||
else ifeq (${COMPILER},clang35)
|
||||
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.5 -DCMAKE_CXX_COMPILER=clang++-3.5
|
||||
else ifeq (${COMPILER},clang38)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
global: *OSL*; test_shade; *osl*imageio*; *osl_input_extensions;
|
||||
local: osl_*; *;
|
||||
};
|
||||
@@ -25,7 +25,7 @@ brew install ilmbase openexr
|
||||
brew install boost-python
|
||||
brew install opencolorio partio
|
||||
brew install freetype libraw libpng webp
|
||||
brew install llvm34
|
||||
brew install llvm${LLVMBREWVER}
|
||||
#brew install homebrew/science/hdf5 --with-threadsafe
|
||||
#brew install field3d webp ffmpeg openjpeg opencv
|
||||
echo ""
|
||||
|
||||
@@ -74,6 +74,38 @@ endif ()
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# OpenImageIO
|
||||
|
||||
find_package (OpenImageIO 1.6 REQUIRED)
|
||||
include_directories ("${OPENIMAGEIO_INCLUDE_DIR}")
|
||||
link_directories ("${OPENIMAGEIO_LIBRARY_DIRS}")
|
||||
message (STATUS "Using OpenImageIO ${OPENIMAGEIO_VERSION}")
|
||||
|
||||
# end OpenImageIO setup
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# LLVM library setup
|
||||
|
||||
find_package (LLVM 3.4 REQUIRED)
|
||||
|
||||
if (LLVM_FOUND)
|
||||
# ensure include directory is added (in case of non-standard locations
|
||||
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
|
||||
link_directories ("${LLVM_LIB_DIR}")
|
||||
# Extract and concatenate major & minor, remove wayward patches,
|
||||
# dots, and "svn" or other suffixes.
|
||||
string (REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1\\2" OSL_LLVM_VERSION ${LLVM_VERSION})
|
||||
add_definitions (-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION})
|
||||
add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}")
|
||||
endif ()
|
||||
|
||||
# end LLVM library setup
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Boost setup
|
||||
|
||||
@@ -95,11 +127,51 @@ if (BOOST_CUSTOM)
|
||||
set (Boost_FOUND true)
|
||||
# N.B. For a custom version, the caller had better set up the variables
|
||||
# Boost_VERSION, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES.
|
||||
if (USE_BOOST_WAVE)
|
||||
add_definitions (-DUSE_BOOST_WAVE=1)
|
||||
endif ()
|
||||
else ()
|
||||
set (Boost_COMPONENTS filesystem regex system thread wave)
|
||||
set (Boost_COMPONENTS system thread)
|
||||
if (NOT USE_STD_REGEX)
|
||||
list (APPEND Boost_COMPONENTS regex)
|
||||
endif ()
|
||||
if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG OR
|
||||
${LLVM_VERSION} VERSION_LESS 3.6)
|
||||
set (_CLANG_PREPROCESSOR_CAN_WORK ON)
|
||||
endif ()
|
||||
if (GCC_VERSION)
|
||||
if (${GCC_VERSION} VERSION_LESS 4.9)
|
||||
set (_CLANG_PREPROCESSOR_CAN_WORK ON)
|
||||
endif ()
|
||||
endif ()
|
||||
if (${LLVM_VERSION} VERSION_LESS 3.9)
|
||||
# Bug in old LLVM creates some linkage problems we've seen involving
|
||||
# some singleton globals that are duplicated when we include both
|
||||
# the clang libs we need for the preprocessing as well as certain
|
||||
# LLVM support libraries we also need, triggering assertions.
|
||||
# See this for description of the issue:
|
||||
# http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140203/203968.html
|
||||
# Sweep under the rug by falling back to boost wave when using older
|
||||
# LLVM (it seems fixed and no longer triggers for 3.9+).
|
||||
set (_CLANG_PREPROCESSOR_CAN_WORK OFF)
|
||||
endif ()
|
||||
if (USE_BOOST_WAVE OR (NOT CLANG_LIBRARIES)
|
||||
OR (NOT USE_CPP11 AND NOT USE_CPP14)
|
||||
OR (NOT _CLANG_PREPROCESSOR_CAN_WORK))
|
||||
# N.B. Using clang for preprocessing seems to work when using clang,
|
||||
# or gcc 4.8.x, or LLVM <= 3.5. When those conditions aren't met,
|
||||
# fall back on Boost Wave. We'll lift this restriction as soon as we
|
||||
# fix whatever is broken.
|
||||
# Also, for C++03, we need Boost Wave still, because we're too lazy
|
||||
# to deal with it.
|
||||
list (APPEND Boost_COMPONENTS filesystem wave)
|
||||
add_definitions (-DUSE_BOOST_WAVE=1)
|
||||
message (STATUS "Using Boost Wave for preprocessing")
|
||||
else ()
|
||||
message (STATUS "Using clang internals for preprocessing")
|
||||
endif ()
|
||||
find_package (Boost 1.42 REQUIRED
|
||||
COMPONENTS ${Boost_COMPONENTS}
|
||||
)
|
||||
COMPONENTS ${Boost_COMPONENTS})
|
||||
endif ()
|
||||
|
||||
# On Linux, Boost 1.55 and higher seems to need to link against -lrt
|
||||
@@ -153,108 +225,3 @@ if (USE_EXTERNAL_PUGIXML)
|
||||
endif()
|
||||
# end Pugixml setup
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# LLVM library setup
|
||||
|
||||
# try to find llvm-config, with a specific version if specified
|
||||
if (LLVM_DIRECTORY)
|
||||
set (LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
|
||||
endif ()
|
||||
list (APPEND LLVM_CONFIG_PATH_HINTS
|
||||
"/usr/local/opt/llvm/${LLVM_VERSION}/bin/"
|
||||
"/usr/local/opt/llvm/bin/")
|
||||
find_program (LLVM_CONFIG
|
||||
NAMES llvm-config-${LLVM_VERSION} llvm-config
|
||||
HINTS ${LLVM_CONFIG_PATH_HINTS} NO_DEFAULT_PATH)
|
||||
find_program (LLVM_CONFIG
|
||||
NAMES llvm-config-${LLVM_VERSION} llvm-config
|
||||
HINTS ${LLVM_CONFIG_PATH_HINTS})
|
||||
if (VERBOSE)
|
||||
message (STATUS "Found llvm-config '${LLVM_CONFIG}'")
|
||||
endif ()
|
||||
|
||||
if (NOT LLVM_DIRECTORY)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --prefix
|
||||
OUTPUT_VARIABLE LLVM_DIRECTORY
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --version
|
||||
OUTPUT_VARIABLE LLVM_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --libdir
|
||||
OUTPUT_VARIABLE LLVM_LIB_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --includedir
|
||||
OUTPUT_VARIABLE LLVM_INCLUDES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if (NOT ${LLVM_VERSION} VERSION_LESS 3.8)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --system-libs
|
||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else ()
|
||||
# Older LLVM did not have llvm-config --system-libs, but we know that
|
||||
# on Linux, we'll need curses.
|
||||
find_package (Curses)
|
||||
if (CURSES_FOUND)
|
||||
list (APPEND LLVM_SYSTEM_LIBRARIES ${CURSES_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
find_library ( LLVM_LIBRARY
|
||||
NAMES LLVM-${LLVM_VERSION} LLVM
|
||||
PATHS ${LLVM_LIB_DIR})
|
||||
find_library ( LLVM_MCJIT_LIBRARY
|
||||
NAMES LLVMMCJIT
|
||||
PATHS ${LLVM_LIB_DIR})
|
||||
|
||||
# if (NOT LLVM_LIBRARY)
|
||||
# execute_process (COMMAND ${LLVM_CONFIG} --libfiles engine
|
||||
# OUTPUT_VARIABLE LLVM_LIBRARIES
|
||||
# OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# endif ()
|
||||
|
||||
# shared llvm library may not be available, this is not an error if we use LLVM_STATIC.
|
||||
if ((LLVM_LIBRARY OR LLVM_LIBRARIES OR LLVM_STATIC) AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
|
||||
# ensure include directory is added (in case of non-standard locations
|
||||
include_directories (BEFORE "${LLVM_INCLUDES}")
|
||||
if (NOT OSL_LLVM_VERSION)
|
||||
# Extract and concatenate major & minor, remove wayward patches,
|
||||
# dots, and "svn" or other suffixes.
|
||||
string (REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1\\2" OSL_LLVM_VERSION ${LLVM_VERSION})
|
||||
endif ()
|
||||
add_definitions (-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION})
|
||||
add_definitions (-DOSL_LLVM_FULL_VERSION="${LLVM_VERSION}")
|
||||
link_directories ("${LLVM_LIB_DIR}")
|
||||
if (LLVM_STATIC)
|
||||
# if static LLVM libraries were requested, use llvm-config to generate
|
||||
# the list of what libraries we need, and substitute that in the right
|
||||
# way for LLVM_LIBRARY.
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --libfiles
|
||||
OUTPUT_VARIABLE LLVM_LIBRARIES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string (REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
|
||||
set (LLVM_LIBRARY "")
|
||||
else ()
|
||||
set (LLVM_LIBRARIES "${LLVM_LIBRARY}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
message (STATUS "LLVM version = ${LLVM_VERSION}")
|
||||
if (NOT LLVM_FIND_QUIETLY)
|
||||
message (STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
|
||||
message (STATUS "LLVM dir = ${LLVM_DIRECTORY}")
|
||||
message (STATUS "LLVM includes = ${LLVM_INCLUDES}")
|
||||
message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
|
||||
message (STATUS "LLVM libraries = ${LLVM_LIBRARIES}")
|
||||
message (STATUS "LLVM sys libs = ${LLVM_SYSTEM_LIBRARIES}")
|
||||
endif ()
|
||||
|
||||
if (NOT LLVM_LIBRARIES)
|
||||
message (FATAL_ERROR "LLVM not found.")
|
||||
endif()
|
||||
|
||||
# end LLVM library setup
|
||||
###########################################################################
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
# Module to find LLVM
|
||||
#
|
||||
# This module defines the following variables:
|
||||
# LLVM_FOUND - True if llvm found.
|
||||
# LLVM_VERSION - Full LLVM version
|
||||
# LLVM_INCLUDES - where to find llvm headers
|
||||
# LLVM_LIBRARIES - List of LLVM libraries to link against
|
||||
# LLVM_SYSTEM_LIBRARIES - additional libraries needed by LLVM
|
||||
# LLVM_DIRECTORY - If not already set, the root of the LLVM install
|
||||
# LLVM_LIB_DIR - where to find llvm libs
|
||||
# CLANG_LIBRARIES - list of libraries for clang components (optional,
|
||||
# those may not be found)
|
||||
#
|
||||
# The following input symbols may be used to help guide the search:
|
||||
# LLVM_DIRECTORY - the root of the LLVM installation (if custom)
|
||||
# LLVM_FIND_QUIETLY - if true, will suppress most console output
|
||||
# LLVM_STATIC - if true, will prefer static LLVM libs to dynamic
|
||||
|
||||
# try to find llvm-config, with a specific version if specified
|
||||
if (LLVM_DIRECTORY)
|
||||
set (LLVM_CONFIG_PATH_HINTS "${LLVM_DIRECTORY}/bin")
|
||||
endif ()
|
||||
list (APPEND LLVM_CONFIG_PATH_HINTS
|
||||
"/usr/local/opt/llvm/${LLVM_VERSION}/bin/"
|
||||
"/usr/local/opt/llvm/bin/")
|
||||
find_program (LLVM_CONFIG
|
||||
NAMES llvm-config-${LLVM_VERSION} llvm-config
|
||||
HINTS ${LLVM_CONFIG_PATH_HINTS} NO_DEFAULT_PATH)
|
||||
find_program (LLVM_CONFIG
|
||||
NAMES llvm-config-${LLVM_VERSION} llvm-config
|
||||
HINTS ${LLVM_CONFIG_PATH_HINTS})
|
||||
if (NOT LLVM_FIND_QUIETLY)
|
||||
message (STATUS "Found llvm-config '${LLVM_CONFIG}'")
|
||||
endif ()
|
||||
|
||||
if (NOT LLVM_DIRECTORY)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --prefix
|
||||
OUTPUT_VARIABLE LLVM_DIRECTORY
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --version
|
||||
OUTPUT_VARIABLE LLVM_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --libdir
|
||||
OUTPUT_VARIABLE LLVM_LIB_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --includedir
|
||||
OUTPUT_VARIABLE LLVM_INCLUDES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if (NOT ${LLVM_VERSION} VERSION_LESS 3.8)
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --system-libs
|
||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else ()
|
||||
# Older LLVM did not have llvm-config --system-libs, but we know that
|
||||
# on Linux, we'll need curses.
|
||||
find_package (Curses)
|
||||
if (CURSES_FOUND)
|
||||
list (APPEND LLVM_SYSTEM_LIBRARIES ${CURSES_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
find_library ( LLVM_LIBRARY
|
||||
NAMES LLVM-${LLVM_VERSION} LLVM
|
||||
PATHS ${LLVM_LIB_DIR})
|
||||
find_library ( LLVM_MCJIT_LIBRARY
|
||||
NAMES LLVMMCJIT
|
||||
PATHS ${LLVM_LIB_DIR})
|
||||
|
||||
|
||||
foreach (COMPONENT clangFrontend clangDriver clangSerialization
|
||||
clangParse clangSema clangAnalysis clangAST clangBasic
|
||||
clangEdit clangLex)
|
||||
find_library ( _CLANG_${COMPONENT}_LIBRARY
|
||||
NAMES ${COMPONENT}
|
||||
PATHS ${LLVM_LIB_DIR})
|
||||
if (_CLANG_${COMPONENT}_LIBRARY)
|
||||
list (APPEND CLANG_LIBRARIES ${_CLANG_${COMPONENT}_LIBRARY})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
|
||||
# if (NOT LLVM_LIBRARY)
|
||||
# execute_process (COMMAND ${LLVM_CONFIG} --libfiles engine
|
||||
# OUTPUT_VARIABLE LLVM_LIBRARIES
|
||||
# OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# endif ()
|
||||
|
||||
# shared llvm library may not be available, this is not an error if we use LLVM_STATIC.
|
||||
if ((LLVM_LIBRARY OR LLVM_LIBRARIES OR LLVM_STATIC) AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
|
||||
if (LLVM_STATIC)
|
||||
# if static LLVM libraries were requested, use llvm-config to generate
|
||||
# the list of what libraries we need, and substitute that in the right
|
||||
# way for LLVM_LIBRARY.
|
||||
execute_process (COMMAND ${LLVM_CONFIG} --libfiles
|
||||
OUTPUT_VARIABLE LLVM_LIBRARIES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string (REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
|
||||
set (LLVM_LIBRARY "")
|
||||
else ()
|
||||
set (LLVM_LIBRARIES "${LLVM_LIBRARY}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (LLVM
|
||||
REQUIRED_VARS
|
||||
LLVM_INCLUDES
|
||||
LLVM_LIBRARIES
|
||||
VERSION_VAR LLVM_VERSION
|
||||
)
|
||||
|
||||
if (LLVM_FOUND)
|
||||
message (STATUS "LLVM version = ${LLVM_VERSION}")
|
||||
if (NOT LLVM_FIND_QUIETLY)
|
||||
message (STATUS "LLVM dir = ${LLVM_DIRECTORY}")
|
||||
message (STATUS "LLVM includes = ${LLVM_INCLUDES}")
|
||||
message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
|
||||
message (STATUS "LLVM libraries = ${LLVM_LIBRARIES}")
|
||||
message (STATUS "LLVM sys libs = ${LLVM_SYSTEM_LIBRARIES}")
|
||||
message (STATUS "Clang libraries = ${CLANG_LIBRARIES}")
|
||||
endif ()
|
||||
else()
|
||||
message (STATUS "LLVM not found. Specify LLVM_DIRECTORY to locate it.")
|
||||
endif()
|
||||
@@ -0,0 +1,82 @@
|
||||
###########################################################################
|
||||
# CMake module to find OpenImageIO
|
||||
#
|
||||
# This module will set
|
||||
# OPENIMAGEIO_FOUND True, if found
|
||||
# OPENIMAGEIO_INCLUDE_DIR directory where headers are found
|
||||
# OPENIMAGEIO_LIBRARIES libraries for OIIO
|
||||
# OPENIMAGEIO_LIBRARY_DIRS library dirs for OIIO
|
||||
# OPENIMAGEIO_VERSION Version ("major.minor.patch")
|
||||
# OPENIMAGEIO_VERSION_MAJOR Version major number
|
||||
# OPENIMAGEIO_VERSION_MINOR Version minor number
|
||||
# OPENIMAGEIO_VERSION_PATCH Version minor patch
|
||||
#
|
||||
# Special inputs:
|
||||
# OPENIMAGEIOHOME - custom "prefix" location of OIIO installation
|
||||
# (expecting bin, lib, include subdirectories)
|
||||
#
|
||||
|
||||
|
||||
# If 'OPENIMAGEHOME' not set, use the env variable of that name if available
|
||||
if (NOT OPENIMAGEIOHOME AND NOT $ENV{OPENIMAGEIOHOME} STREQUAL "")
|
||||
set (OPENIMAGEIOHOME $ENV{OPENIMAGEIOHOME})
|
||||
endif ()
|
||||
|
||||
|
||||
if (NOT OpenImageIO_FIND_QUIETLY)
|
||||
message ( STATUS "OPENIMAGEIOHOME = ${OPENIMAGEIOHOME}" )
|
||||
endif ()
|
||||
|
||||
find_library ( OPENIMAGEIO_LIBRARY
|
||||
NAMES OpenImageIO
|
||||
HINTS ${OPENIMAGEIOHOME}/lib
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS "${OPENIMAGEIOHOME}/lib" )
|
||||
find_path ( OPENIMAGEIO_INCLUDE_DIR
|
||||
NAMES OpenImageIO/imageio.h
|
||||
HINTS ${OPENIMAGEIOHOME}/include
|
||||
PATH_SUFFIXES include )
|
||||
find_program ( OPENIMAGEIO_BIN
|
||||
NAMES oiiotool
|
||||
HINTS ${OPENIMAGEIOHOME}/bin
|
||||
PATH_SUFFIXES bin )
|
||||
|
||||
# Try to figure out version number
|
||||
set (OIIO_VERSION_HEADER "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h")
|
||||
if (EXISTS "${OIIO_VERSION_HEADER}")
|
||||
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MAJOR .*$")
|
||||
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MAJOR ${TMP})
|
||||
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MINOR .*$")
|
||||
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MINOR ${TMP})
|
||||
file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_PATCH .*$")
|
||||
string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_PATCH ${TMP})
|
||||
set (OPENIMAGEIO_VERSION "${OPENIMAGEIO_VERSION_MAJOR}.${OPENIMAGEIO_VERSION_MINOR}.${OPENIMAGEIO_VERSION_PATCH}")
|
||||
endif ()
|
||||
|
||||
set ( OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
|
||||
get_filename_component (OPENIMAGEIO_LIBRARY_DIRS "${OPENIMAGEIO_LIBRARY}" DIRECTORY CACHE)
|
||||
|
||||
if (NOT OpenImageIO_FIND_QUIETLY)
|
||||
message ( STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDE_DIR}" )
|
||||
message ( STATUS "OpenImageIO libraries = ${OPENIMAGEIO_LIBRARIES}" )
|
||||
message ( STATUS "OpenImageIO library_dirs = ${OPENIMAGEIO_LIBRARY_DIRS}" )
|
||||
message ( STATUS "OpenImageIO bin = ${OPENIMAGEIO_BIN}" )
|
||||
endif ()
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (OpenImageIO
|
||||
FOUND_VAR OPENIMAGEIO_FOUND
|
||||
REQUIRED_VARS OPENIMAGEIO_INCLUDE_DIR OPENIMAGEIO_LIBRARIES
|
||||
OPENIMAGEIO_LIBRARY_DIRS OPENIMAGEIO_VERSION
|
||||
VERSION_VAR OPENIMAGEIO_VERSION
|
||||
)
|
||||
|
||||
mark_as_advanced (
|
||||
OPENIMAGEIO_INCLUDE_DIR
|
||||
OPENIMAGEIO_LIBRARIES
|
||||
OPENIMAGEIO_LIBRARY_DIRS
|
||||
OPENIMAGEIO_VERSION
|
||||
OPENIMAGEIO_VERSION_MAJOR
|
||||
OPENIMAGEIO_VERSION_MINOR
|
||||
OPENIMAGEIO_VERSION_PATCH
|
||||
)
|
||||
@@ -8,10 +8,14 @@
|
||||
|
||||
find_path (PUGIXML_INCLUDE_DIR
|
||||
NAMES pugixml.hpp
|
||||
PATHS ${PUGIXML_HOME}/include)
|
||||
PATHS ${PUGIXML_HOME}/include
|
||||
/usr/local/include
|
||||
/usr/local/include/pugixml-1.8)
|
||||
find_library (PUGIXML_LIBRARY
|
||||
NAMES pugixml
|
||||
PATHS ${PUGIXML_HOME}/lib)
|
||||
PATHS ${PUGIXML_HOME}/lib
|
||||
/usr/local/lib
|
||||
/usr/local/lib/pugixml-1.8)
|
||||
|
||||
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
###########################################################################
|
||||
# OpenImageIO
|
||||
|
||||
|
||||
# If 'OPENIMAGEHOME' not set, use the env variable of that name if available
|
||||
if (NOT OPENIMAGEIOHOME)
|
||||
if (NOT $ENV{OPENIMAGEIOHOME} STREQUAL "")
|
||||
set (OPENIMAGEIOHOME $ENV{OPENIMAGEIOHOME})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
if (NOT OpenImageIO_FIND_QUIETLY)
|
||||
MESSAGE ( STATUS "OPENIMAGEIOHOME = ${OPENIMAGEIOHOME}" )
|
||||
endif ()
|
||||
|
||||
find_library ( OPENIMAGEIO_LIBRARY
|
||||
NAMES OpenImageIO
|
||||
HINTS ${OPENIMAGEIOHOME}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS "${OPENIMAGEIOHOME}/lib" )
|
||||
find_path ( OPENIMAGEIO_INCLUDES
|
||||
NAMES OpenImageIO/imageio.h
|
||||
HINTS ${OPENIMAGEIOHOME}
|
||||
PATH_SUFFIXES include )
|
||||
find_program ( OPENIMAGEIO_BIN
|
||||
NAMES oiiotool
|
||||
HINTS ${OPENIMAGEIOHOME}
|
||||
PATH_SUFFIXES bin )
|
||||
if (NOT OpenImageIO_FIND_QUIETLY)
|
||||
MESSAGE ( STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDES}" )
|
||||
MESSAGE ( STATUS "OpenImageIO library = ${OPENIMAGEIO_LIBRARY}" )
|
||||
MESSAGE ( STATUS "OpenImageIO bin = ${OPENIMAGEIO_BIN}" )
|
||||
endif ()
|
||||
IF ( OPENIMAGEIO_INCLUDES AND OPENIMAGEIO_LIBRARY )
|
||||
SET ( OPENIMAGEIO_FOUND TRUE )
|
||||
ELSE ()
|
||||
MESSAGE ( FATAL_ERROR "OpenImageIO not found" )
|
||||
ENDIF ()
|
||||
|
||||
# end OpenImageIO setup
|
||||
###########################################################################
|
||||
@@ -1,5 +1,7 @@
|
||||
set (public_docs osl-languagespec.pdf)
|
||||
# Some day: CLA-INDIVIDUAL CLA-CORPORATE
|
||||
set (public_docs osl-languagespec.pdf
|
||||
testshade.md.html
|
||||
markdeep.min.js
|
||||
)
|
||||
|
||||
install (FILES ${public_docs} DESTINATION doc COMPONENT documentation)
|
||||
|
||||
@@ -7,4 +9,9 @@ install ( FILES "${PROJECT_SOURCE_DIR}/LICENSE"
|
||||
"${PROJECT_SOURCE_DIR}/INSTALL.md"
|
||||
"${PROJECT_SOURCE_DIR}/CHANGES.md"
|
||||
"${PROJECT_SOURCE_DIR}/README.md"
|
||||
DESTINATION . )
|
||||
DESTINATION doc )
|
||||
|
||||
|
||||
file (GLOB testshade_figures "Figures/testshade/*.jpg")
|
||||
install (FILES ${testshade_figures}
|
||||
DESTINATION doc/Figures/testshade )
|
||||
|
||||
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
@@ -21,7 +21,7 @@
|
||||
\usepackage{xspace}
|
||||
%\usepackage{multicol}
|
||||
%\usepackage{color}
|
||||
\usepackage{html}
|
||||
\usepackage{hyperref}
|
||||
%\usepackage{version}
|
||||
\usepackage{makeidx}
|
||||
\usepackage[chapter]{algorithm}
|
||||
@@ -62,7 +62,7 @@ Editor: Larry Gritz \\
|
||||
\emph{lg@imageworks.com}
|
||||
}
|
||||
\date{{\large Date: 6 Feb 2017 \\
|
||||
% (with corrections, 6 Feb 2017)
|
||||
(with corrections, 30 Jun 2017)
|
||||
}
|
||||
\bigskip
|
||||
\bigskip
|
||||
@@ -103,6 +103,7 @@ Editor: Larry Gritz \\
|
||||
\def\pnoise{{\cf pnoise()}\xspace}
|
||||
\def\psnoise{{\cf psnoise()}\xspace}
|
||||
\def\cellnoise{{\cf cellnoise()}\xspace}
|
||||
\def\hashnoise{{\cf hashnoise()}\xspace}
|
||||
\def\illuminance{{\cf illuminance}\xspace}
|
||||
\def\illuminate{{\cf illuminate}\xspace}
|
||||
|
||||
@@ -375,12 +376,12 @@ other open source packages:
|
||||
|
||||
\begin{itemize}
|
||||
\item {\cf OpenImageIO} \copyright\ 2008 Larry Gritz et al.
|
||||
{\cf http://openimageio.org}
|
||||
\url{http://openimageio.org}
|
||||
\item Ilmbase \copyright\ 2006, Industrial Light \& Magic.
|
||||
{\cf http://www.openexr.com}
|
||||
\item Boost \copyright\ various authors. {\cf http://www.boost.org}
|
||||
\url{http://www.openexr.com}
|
||||
\item Boost \copyright\ various authors. \url{http://www.boost.org}
|
||||
\item LLVM \copyright\ 2003-2010 University of Illinois at
|
||||
Urbana-Champaign. {\cf http://llvm.org}
|
||||
Urbana-Champaign. \url{http://llvm.org}
|
||||
\end{itemize}
|
||||
|
||||
These other packages are all distributed under licenses that allow them
|
||||
@@ -872,6 +873,18 @@ directives, including:
|
||||
#pragma once
|
||||
\end{code}
|
||||
|
||||
\noindent Additionally, the following preprocessor symbols will already be
|
||||
defined by the compiler:
|
||||
|
||||
\smallskip
|
||||
|
||||
\begin{tabular}{p{1.5in} p{3.5in}}
|
||||
{\cf OSL_VERSION_MAJOR} & Major version (e.g., 1) \\[0.5ex]
|
||||
{\cf OSL_VERSION_MINOR} & Minor version (e.g., 9) \\[0.5ex]
|
||||
{\cf OSL_VERSION_PATCH} & Patch version (e.g., 3) \\[0.5ex]
|
||||
{\cf OSL_VERSION} & Combined version number = 10000*major + 100*minor + patch
|
||||
(e.g., 10903 for version 1.9.3)
|
||||
\end{tabular}
|
||||
|
||||
|
||||
\chapter{Gross syntax, shader types, parameters, functions}
|
||||
@@ -3351,13 +3364,18 @@ and performs a linear
|
||||
interpolation between 0 and 1 when ${\mathit edge0} < x < {\mathit edge1}$.
|
||||
\apiend
|
||||
|
||||
\apiitem{float {\ce smoothstep} (float edge0, float edge1, float x)}
|
||||
\apiitem{float {\ce smoothstep} (float edge0, float edge1, float x) \\
|
||||
\emph{type} {\ce smoothstep} (\emph{type} edge0, \emph{type} edge1, \emph{type} x)}
|
||||
\indexapi{smoothstep()}
|
||||
Returns 0 if $x \le {\mathit edge0}$, and 1 if $x \ge {\mathit edge1}$,
|
||||
and performs a smooth Hermite
|
||||
interpolation between 0 and 1 when ${\mathit edge0} < x < {\mathit edge1}$.
|
||||
This is useful in cases where you would want a thresholding function
|
||||
with a smooth transition.
|
||||
|
||||
The \emph{type} may be any of of \float, \color, \point, \vector, or
|
||||
\normal. For \color and \point-like types, the computations are
|
||||
performed component-by-component (separately for $x$, $y$, and $z$).
|
||||
\apiend
|
||||
|
||||
\apiitem{float {\ce smooth_linearstep} (float edge0, float edge1, float x, float eps)}
|
||||
@@ -3419,6 +3437,14 @@ large-scale average is 0.5, and its values are evenly distributed over
|
||||
$[0,1]$.
|
||||
\apiend
|
||||
|
||||
\apiitem{"hash"}
|
||||
\vspace{12pt}
|
||||
A function that returns a different, uncorrelated (but deterministic and
|
||||
repeatable) value at every real input coordinate. The range is $[0,1]$, its
|
||||
large-scale average is 0.5, and its values are evenly distributed over
|
||||
$[0,1]$.
|
||||
\apiend
|
||||
|
||||
\apiitem{"simplex"}
|
||||
\vspace{12pt}
|
||||
A signed simplex noise with an output range of $[-1,1]$,
|
||||
@@ -3559,29 +3585,31 @@ The old {\cf cellnoise(...coords...)} function is equivalent to
|
||||
{\cf noise("cell",...coords...)}.
|
||||
\apiend
|
||||
|
||||
\begin{comment} % couldn't find a use for this
|
||||
\apiitem{\emph{type} {\ce hash} (float u) \\
|
||||
\emph{type} {\ce hash} (float u, float v) \\
|
||||
\emph{type} {\ce hash} (point p) \\
|
||||
\emph{type} {\ce hash} (point p, float t) \\
|
||||
\emph{type} {\ce hash} (int i) \\
|
||||
\emph{type} {\ce hash} (string s)}
|
||||
\indexapi{hash()}
|
||||
\apiitem{\emph{type} {\ce hashnoise} (float u) \\
|
||||
\emph{type} {\ce hashnoise} (float u, float v) \\
|
||||
\emph{type} {\ce hashnoise} (point p) \\
|
||||
\emph{type} {\ce hashnoise} (point p, float t)}
|
||||
\indexapi{hashnoise()}
|
||||
\NEW % 1.9
|
||||
Returns a deterministic, repeatable \emph{hash} of the 1-, 2-, 3-, or
|
||||
4-D coordinates, integer, or string. The return values will be evenly
|
||||
4-D coordinates. The return values will be evenly
|
||||
distributed on $[0,1]$ and be completely repeatable when passed the same
|
||||
coordinates again, yet will be uncorrellated to hashes of any other
|
||||
positions (including nearby points). This is like having a random value
|
||||
indexed spatially, but that will be repeatable from frame to frame of an
|
||||
animation (provided its input is \emph{precisely} identical).
|
||||
|
||||
The return \emph{type} may be any of \float, \color, \point, \vector, or
|
||||
\normal, depending on the type of the variable the result is assigned to
|
||||
(or based on an explicit type cast). For multi-component return types
|
||||
(e.g., \point), each component is an uncorrelated \float\ {\cf hash}
|
||||
function.
|
||||
\apiend
|
||||
\end{comment}
|
||||
|
||||
\apiitem{int {\ce hash} (float u) \\
|
||||
int {\ce hash} (float u, float v) \\
|
||||
int {\ce hash} (point p) \\
|
||||
int {\ce hash} (point p, float t) \\
|
||||
int {\ce hash) (int i)}}
|
||||
\indexapi{hash()}
|
||||
\NEW % 1.9
|
||||
Returns a deterministic, repeatable integer \emph{hash} of the 1-, 2-, 3-,
|
||||
or 4-D coordinates.
|
||||
\apiend
|
||||
|
||||
\apiitem{\emph{type} {\ce spline} (string basis, float x, \emph{type} $\mathtt{y}_0$, \emph{type} $\mathtt{y}_1$, ... \emph{type} $\mathtt{y}_{n-1}$)\\
|
||||
\emph{type} {\ce spline} (string basis, float x, \emph{type} y[]) \\
|
||||
@@ -4797,6 +4825,7 @@ wish to make queryable.
|
||||
\hline
|
||||
{\bf Name} & {\bf Type} & {\bf Description} \\
|
||||
\hline
|
||||
{\cf "osl:version"} & {\cf int} & Major*10000 + Minor*100 + patch. \\
|
||||
{\cf "shader:shadername"} & {\cf string} & Name of the shader master. \\
|
||||
{\cf "shader:layername"} & {\cf string} & Name of the layer instance. \\
|
||||
{\cf "shader:groupname"} & {\cf string} & Name of the shader group. \\
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
\newenvironment{smallcode}{\small \renewcommand{\baselinestretch}{0.8} \verbatimtab}{\endverbatimtab \renewcommand{\baselinestretch}{1}}
|
||||
\newenvironment{tinycode}{\footnotesize \renewcommand{\baselinestretch}{0.75} \verbatimtab}{\endverbatimtab \renewcommand{\baselinestretch}{1}}
|
||||
|
||||
\begin{htmlonly}
|
||||
\renewenvironment{code}{\begin{verbatim}}{\end{verbatim}}
|
||||
\newenvironment{smallcode}{\begin{verbatim}}{\end{verbatim}}
|
||||
\newenvironment{tinycode}{\begin{verbatim}}{\end{verbatim}}
|
||||
\end{htmlonly}
|
||||
% \begin{htmlonly}
|
||||
% \renewenvironment{code}{\begin{verbatim}}{\end{verbatim}}
|
||||
% \newenvironment{smallcode}{\begin{verbatim}}{\end{verbatim}}
|
||||
% \newenvironment{tinycode}{\begin{verbatim}}{\end{verbatim}}
|
||||
% \end{htmlonly}
|
||||
|
||||
\newcommand{\includedcode}[1]{{\small \verbatimtabinput{#1}}}
|
||||
\newcommand{\smallincludedcode}[1]{{\small \renewcommand{\baselinestretch}{0.8} \verbatimtabinput{#1} \renewcommand{\baselinestretch}{1}}}
|
||||
@@ -76,15 +76,15 @@
|
||||
%end{latexonly}
|
||||
|
||||
|
||||
\begin{htmlonly}
|
||||
\newcommand{\apiitem}[1]{\medskip \noindent {\bf #1} \begin{quote}}
|
||||
\newcommand{\apiend}{\end{quote}}
|
||||
\def\halfspc{\begin{rawhtml} \end{rawhtml}}
|
||||
\def\spc{\halfspc\halfspc}
|
||||
\pagecolor[named]{White}
|
||||
\def\chapwidthbegin{\begin{rawhtml}<p><table cellspacing=1><tr><td width=550>\end{rawhtml}}
|
||||
\def\chapwidthend{\begin{rawhtml}</td></tr></table>\end{rawhtml}}
|
||||
\end{htmlonly}
|
||||
%\begin{htmlonly}
|
||||
%\newcommand{\apiitem}[1]{\medskip \noindent {\bf #1} \begin{quote}}
|
||||
%\newcommand{\apiend}{\end{quote}}
|
||||
%\def\halfspc{\begin{rawhtml} \end{rawhtml}}
|
||||
%\def\spc{\halfspc\halfspc}
|
||||
%\pagecolor[named]{White}
|
||||
%\def\chapwidthbegin{\begin{rawhtml}<p><table cellspacing=1><tr><td width=550>\end{rawhtml}}
|
||||
%\def\chapwidthend{\begin{rawhtml}</td></tr></table>\end{rawhtml}}
|
||||
%\end{htmlonly}
|
||||
|
||||
|
||||
\newcommand{\apibinding}[3]{\apiitem{#1\\[1ex]#2\\[1ex]#3}}
|
||||
|
||||
@@ -312,11 +312,21 @@ inline bool operator<= (const Dual2<T> &a, const Dual2<T> &b) {
|
||||
return a.val() <= b.val();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator<= (const Dual2<T> &a, const T &b) {
|
||||
return a.val() <= b;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator>= (const Dual2<T> &a, const Dual2<T> &b) {
|
||||
return a.val() >= b.val();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator>= (const Dual2<T> &a, const T &b) {
|
||||
return a.val() >= b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Eliminate the derivatives of a number
|
||||
|
||||
@@ -371,21 +371,22 @@ length (const Dual2<Vec3> &a)
|
||||
inline Dual2<Vec3>
|
||||
normalize (const Dual2<Vec3> &a)
|
||||
{
|
||||
if (a.val().x == 0 && a.val().y == 0 && a.val().z == 0) {
|
||||
Dual2<float> ax (a.val().x, a.dx().x, a.dy().x);
|
||||
Dual2<float> ay (a.val().y, a.dx().y, a.dy().y);
|
||||
Dual2<float> az (a.val().z, a.dx().z, a.dy().z);
|
||||
Dual2<float> length = sqrt(ax * ax + ay * ay + az * az);
|
||||
if (length.val() > 0.0f) {
|
||||
// NOTE: do a full division here to match what OpenEXR Imath does in the non-dual case
|
||||
ax = ax / length;
|
||||
ay = ay / length;
|
||||
az = az / length;
|
||||
return Dual2<Vec3>(Vec3(ax.val(), ay.val(), az.val()),
|
||||
Vec3(ax.dx(), ay.dx(), az.dx()),
|
||||
Vec3(ax.dy(), ay.dy(), az.dy()));
|
||||
} else {
|
||||
return Dual2<Vec3> (Vec3(0, 0, 0),
|
||||
Vec3(0, 0, 0),
|
||||
Vec3(0, 0, 0));
|
||||
} else {
|
||||
Dual2<float> ax (a.val().x, a.dx().x, a.dy().x);
|
||||
Dual2<float> ay (a.val().y, a.dx().y, a.dy().y);
|
||||
Dual2<float> az (a.val().z, a.dx().z, a.dy().z);
|
||||
Dual2<float> inv_length = 1.0f / sqrt(ax*ax + ay*ay + az*az);
|
||||
ax = ax*inv_length;
|
||||
ay = ay*inv_length;
|
||||
az = az*inv_length;
|
||||
return Dual2<Vec3> (Vec3(ax.val(), ay.val(), az.val()),
|
||||
Vec3(ax.dx(), ay.dx(), az.dx() ),
|
||||
Vec3(ax.dy(), ay.dy(), az.dy() ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define OSL_DLL_EXPORT __declspec(dllexport)
|
||||
#define OSL_DLL_LOCAL
|
||||
#endif
|
||||
#define OSL_LLVM_EXPORT __declspec(dllexport)
|
||||
//#define OSL_LLVM_EXPORT __declspec(dllexport)
|
||||
#define OSL_LLVM_EXPORT OSL_DLL_LOCAL
|
||||
#else
|
||||
#if (10000*__GNUC__ + 100*__GNUC_MINOR__ + __GNUC_PATCHLEVEL__) > 40102
|
||||
#define OSL_DLL_IMPORT __attribute__ ((visibility ("default")))
|
||||
@@ -86,7 +87,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define OSL_DLL_EXPORT
|
||||
#define OSL_DLL_LOCAL
|
||||
#endif
|
||||
#define OSL_LLVM_EXPORT OSL_DLL_EXPORT
|
||||
#define OSL_LLVM_EXPORT OSL_DLL_LOCAL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -121,6 +121,10 @@ public:
|
||||
const std::vector<llvm::Type*> ¶mtypes,
|
||||
bool varargs=false);
|
||||
|
||||
/// Add a global mapping of a function to its callable address
|
||||
/// explicitly instead of relying on dlsym.
|
||||
void add_function_mapping (llvm::Function *func, void *addr);
|
||||
|
||||
/// Set up a new current function that subsequent basic blocks will
|
||||
/// be added to.
|
||||
void current_function (llvm::Function *func) { m_current_function = func; }
|
||||
|
||||
@@ -110,6 +110,9 @@ public:
|
||||
/// fails to find the layer or parameter? (1)
|
||||
/// int strict_messages Issue error if a message is set after
|
||||
/// being queried (1).
|
||||
/// int error_repeats If zero, suppress repeats of errors and
|
||||
/// warnings that are exact duplicates of
|
||||
/// earlier ones. (0)
|
||||
/// int lazylayers Evaluate shader layers only when their
|
||||
/// outputs are first needed (1)
|
||||
/// int lazyglobals Run layers lazily even if they write to
|
||||
@@ -556,15 +559,19 @@ public:
|
||||
/// data passed in via attribute("raytypes")).
|
||||
int raytype_bit (ustring name);
|
||||
|
||||
/// Configure the default raytypes to assume to be on (or off) at optimization
|
||||
/// time for the given group. The raytypes_on gives a bitfield describing which
|
||||
/// ray flags are known to be 1, and raytypes_off describes which ray flags are
|
||||
/// known to be 0. Bits that are not set in either set of flags are not known
|
||||
/// to the optimizer, and will be determined strictly at execution time.
|
||||
void set_raytypes(ShaderGroup *group, int raytypes_on, int raytypes_off);
|
||||
|
||||
/// Ensure that the group has been optimized and JITed.
|
||||
/// Ensure that the group has been optimized and JITed.
|
||||
void optimize_group (ShaderGroup *group);
|
||||
|
||||
/// Ensure that the group has been optimized and JITed. The raytypes_on
|
||||
/// gives a bitfield describing which ray flags are known to be 1, and
|
||||
/// raytypes_off describes which ray flags are known to be 0. Bits that
|
||||
/// are not set in either set of flags are not known to the optimizer,
|
||||
/// and will be determined strictly at execution time.
|
||||
/// Ensure that the group has been optimized and JITed. This is a
|
||||
/// convenience function that simply calls set_raytypes followed by optimize_group.
|
||||
void optimize_group (ShaderGroup *group, int raytypes_on,
|
||||
int raytypes_off);
|
||||
|
||||
|
||||
@@ -77,11 +77,23 @@ template <typename S > Vec3 vnoise (S x);
|
||||
template <typename S, typename T> Vec3 vnoise (S x, T y);
|
||||
|
||||
// Cell noise on 1-4 dimensional domain, range [0,1].
|
||||
// cellnoise is constant within each unit cube (cell) on the domain, but
|
||||
// discontinuous at integer boundaries (and uncorrellated from cell to
|
||||
// cell).
|
||||
template <typename S > float cellnoise (S x);
|
||||
template <typename S, typename T> float cellnoise (S x, T y);
|
||||
template <typename S > Vec3 vcellnoise (S x);
|
||||
template <typename S, typename T> Vec3 vcellnoise (S x, T y);
|
||||
|
||||
// Hash noise on 1-4 dimensional domain, range [0,1].
|
||||
// hashnoise is like cellnoise, but without the 'floor' -- in other words,
|
||||
// it's an uncorrellated hash that is different for every floating point
|
||||
// value.
|
||||
template <typename S > float hashnoise (S x);
|
||||
template <typename S, typename T> float hashnoise (S x, T y);
|
||||
template <typename S > Vec3 vhashnoise (S x);
|
||||
template <typename S, typename T> Vec3 vhashnoise (S x, T y);
|
||||
|
||||
// FIXME -- eventually consider adding to the public API:
|
||||
// * periodic varieties
|
||||
// * varieties with derivatives
|
||||
@@ -436,6 +448,232 @@ private:
|
||||
|
||||
|
||||
|
||||
inline int
|
||||
inthashi (int x)
|
||||
{
|
||||
unsigned int i[1];
|
||||
i[0] = (unsigned int)x;
|
||||
return (int) inthash<1>(i);
|
||||
}
|
||||
|
||||
inline int
|
||||
inthashf (float x)
|
||||
{
|
||||
unsigned int i[1];
|
||||
i[0] = OIIO::bit_cast<float,unsigned int>(x);
|
||||
return (int) inthash<1>(i);
|
||||
}
|
||||
|
||||
inline int
|
||||
inthashf (float x, float y)
|
||||
{
|
||||
unsigned int i[2];
|
||||
i[0] = OIIO::bit_cast<float,unsigned int>(x);
|
||||
i[1] = OIIO::bit_cast<float,unsigned int>(y);
|
||||
return (int) inthash<2>(i);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
inthashf (const float *x)
|
||||
{
|
||||
unsigned int i[3];
|
||||
i[0] = OIIO::bit_cast<float,unsigned int>(x[0]);
|
||||
i[1] = OIIO::bit_cast<float,unsigned int>(x[1]);
|
||||
i[2] = OIIO::bit_cast<float,unsigned int>(x[2]);
|
||||
return (int) inthash<3>(i);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
inthashf (const float *x, float y)
|
||||
{
|
||||
unsigned int i[4];
|
||||
i[0] = OIIO::bit_cast<float,unsigned int>(x[0]);
|
||||
i[1] = OIIO::bit_cast<float,unsigned int>(x[1]);
|
||||
i[2] = OIIO::bit_cast<float,unsigned int>(x[2]);
|
||||
i[3] = OIIO::bit_cast<float,unsigned int>(y);
|
||||
return (int) inthash<4>(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct HashNoise {
|
||||
HashNoise () { }
|
||||
|
||||
inline void operator() (float &result, float x) const {
|
||||
unsigned int iv[1];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (x);
|
||||
hash1<1> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (float &result, float x, float y) const {
|
||||
unsigned int iv[2];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (x);
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (y);
|
||||
hash1<2> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (float &result, const Vec3 &p) const {
|
||||
unsigned int iv[3];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (p.x);
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (p.y);
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (p.z);
|
||||
hash1<3> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (float &result, const Vec3 &p, float t) const {
|
||||
unsigned int iv[4];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (p.x);
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (p.y);
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (p.z);
|
||||
iv[3] = OIIO::bit_cast<float,unsigned int> (t);
|
||||
hash1<4> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, float x) const {
|
||||
unsigned int iv[2];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (x);
|
||||
hash3<2> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, float x, float y) const {
|
||||
unsigned int iv[3];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (x);
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (y);
|
||||
hash3<3> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, const Vec3 &p) const {
|
||||
unsigned int iv[4];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (p.x);
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (p.y);
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (p.z);
|
||||
hash3<4> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, const Vec3 &p, float t) const {
|
||||
unsigned int iv[5];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (p.x);
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (p.y);
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (p.z);
|
||||
iv[3] = OIIO::bit_cast<float,unsigned int> (t);
|
||||
hash3<5> (result, iv);
|
||||
}
|
||||
|
||||
private:
|
||||
template <int N>
|
||||
inline void hash1 (float &result, const unsigned int k[N]) const {
|
||||
result = bits_to_01(inthash<N>(k));
|
||||
}
|
||||
|
||||
template <int N>
|
||||
inline void hash3 (Vec3 &result, unsigned int k[N]) const {
|
||||
k[N-1] = 0; result.x = bits_to_01 (inthash<N> (k));
|
||||
k[N-1] = 1; result.y = bits_to_01 (inthash<N> (k));
|
||||
k[N-1] = 2; result.z = bits_to_01 (inthash<N> (k));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct PeriodicHashNoise {
|
||||
PeriodicHashNoise () { }
|
||||
|
||||
inline void operator() (float &result, float x, float px) const {
|
||||
unsigned int iv[1];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (x, px));
|
||||
hash1<1> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (float &result, float x, float y,
|
||||
float px, float py) const {
|
||||
unsigned int iv[2];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (x, px));
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (wrap (y, py));
|
||||
hash1<2> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (float &result, const Vec3 &p,
|
||||
const Vec3 &pp) const {
|
||||
unsigned int iv[3];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (p.x, pp.x));
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (wrap (p.y, pp.y));
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (wrap (p.z, pp.z));
|
||||
hash1<3> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (float &result, const Vec3 &p, float t,
|
||||
const Vec3 &pp, float tt) const {
|
||||
unsigned int iv[4];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (p.x, pp.x));
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (wrap (p.y, pp.y));
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (wrap (p.z, pp.z));
|
||||
iv[3] = OIIO::bit_cast<float,unsigned int> (wrap (t, tt));
|
||||
hash1<4> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, float x, float px) const {
|
||||
unsigned int iv[2];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (x, px));
|
||||
hash3<2> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, float x, float y,
|
||||
float px, float py) const {
|
||||
unsigned int iv[3];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (x, px));
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (wrap (y, py));
|
||||
hash3<3> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, const Vec3 &p, const Vec3 &pp) const {
|
||||
unsigned int iv[4];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (p.x, pp.x));
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (wrap (p.y, pp.y));
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (wrap (p.z, pp.z));
|
||||
hash3<4> (result, iv);
|
||||
}
|
||||
|
||||
inline void operator() (Vec3 &result, const Vec3 &p, float t,
|
||||
const Vec3 &pp, float tt) const {
|
||||
unsigned int iv[5];
|
||||
iv[0] = OIIO::bit_cast<float,unsigned int> (wrap (p.x, pp.x));
|
||||
iv[1] = OIIO::bit_cast<float,unsigned int> (wrap (p.y, pp.y));
|
||||
iv[2] = OIIO::bit_cast<float,unsigned int> (wrap (p.z, pp.z));
|
||||
iv[3] = OIIO::bit_cast<float,unsigned int> (wrap (t, tt));
|
||||
hash3<5> (result, iv);
|
||||
}
|
||||
|
||||
private:
|
||||
template <int N>
|
||||
inline void hash1 (float &result, const unsigned int k[N]) const {
|
||||
result = bits_to_01(inthash<N>(k));
|
||||
}
|
||||
|
||||
template <int N>
|
||||
inline void hash3 (Vec3 &result, unsigned int k[N]) const {
|
||||
k[N-1] = 0; result.x = bits_to_01 (inthash<N> (k));
|
||||
k[N-1] = 1; result.y = bits_to_01 (inthash<N> (k));
|
||||
k[N-1] = 2; result.z = bits_to_01 (inthash<N> (k));
|
||||
}
|
||||
|
||||
inline float wrap (float s, float period) const {
|
||||
period = floorf (period);
|
||||
if (period < 1.0f)
|
||||
period = 1.0f;
|
||||
return s - period * floorf (s / period);
|
||||
}
|
||||
|
||||
inline Vec3 wrap (const Vec3 &s, const Vec3 &period) {
|
||||
return Vec3 (wrap (s[0], period[0]),
|
||||
wrap (s[1], period[1]),
|
||||
wrap (s[2], period[2]));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Define select(bool,truevalue,falsevalue) template that works for a
|
||||
// variety of types that we can use for both scalars and vectors. Because ?:
|
||||
@@ -2629,6 +2867,7 @@ namespace oslnoise {
|
||||
DECLNOISE (snoise, SNoise)
|
||||
DECLNOISE (noise, Noise)
|
||||
DECLNOISE (cellnoise, CellNoise)
|
||||
DECLNOISE (hashnoise, HashNoise)
|
||||
|
||||
#undef DECLNOISE
|
||||
|
||||
|
||||
@@ -164,11 +164,18 @@ private:
|
||||
std::vector<Parameter> m_meta; ///< Meta-data about the shader
|
||||
friend class pvt::OSOReaderQuery;
|
||||
|
||||
#if OIIO_VERSION >= 10803
|
||||
/// Internal error reporting routine, with printf-like arguments.
|
||||
/// void error (const char *message, ...) const
|
||||
template<typename... Args>
|
||||
inline void error (string_view fmt, const Args&... args) const {
|
||||
append_error(OIIO::Strutil::format (fmt, args...));
|
||||
}
|
||||
#else
|
||||
// Fallback for older OIIO
|
||||
TINYFORMAT_WRAP_FORMAT (void, error, const,
|
||||
std::ostringstream msg;, msg, append_error(msg.str());)
|
||||
void append_error (string_view message) const {
|
||||
std::ostringstream msg;, msg, append_error(msg.str());)
|
||||
#endif
|
||||
void append_error (const std::string& message) const {
|
||||
if (m_error.size())
|
||||
m_error += '\n';
|
||||
m_error += message;
|
||||
|
||||
@@ -40,6 +40,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// for compiled shaders.
|
||||
// These are all independent, though loosely coupled.
|
||||
|
||||
// Version of the language:
|
||||
#define @PROJ_NAME@_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define @PROJ_NAME@_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define @PROJ_NAME@_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define @PROJ_NAME@_VERSION (10000 * @PROJ_NAME@_VERSION_MAJOR + \
|
||||
100 * @PROJ_NAME@_VERSION_MINOR + \
|
||||
@PROJ_NAME@_VERSION_PATCH)
|
||||
|
||||
// Version of this library:
|
||||
#define OSL_LIBRARY_VERSION_MAJOR @OSL_LIBRARY_VERSION_MAJOR@
|
||||
#define OSL_LIBRARY_VERSION_MINOR @OSL_LIBRARY_VERSION_MINOR@
|
||||
@@ -81,10 +89,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifdef OSL_NAMESPACE
|
||||
// Macros to use in each file to enter and exit the right name spaces.
|
||||
#define OSL_NAMESPACE_ENTER namespace OSL_NAMESPACE { namespace OSL {
|
||||
#define OSL_NAMESPACE_EXIT }; }; using namespace OSL_NAMESPACE;
|
||||
#define OSL_NAMESPACE_EXIT } } using namespace OSL_NAMESPACE;
|
||||
#else
|
||||
#define OSL_NAMESPACE_ENTER namespace OSL {
|
||||
#define OSL_NAMESPACE_EXIT };
|
||||
#define OSL_NAMESPACE_EXIT }
|
||||
#endif
|
||||
|
||||
// OSL_BUILD_CPP11 will be 1 if this OSL was built using C++11
|
||||
|
||||
@@ -18,10 +18,16 @@ if (BUILDSTATIC)
|
||||
ADD_DEFINITIONS ( -DBUILD_STATIC=1 )
|
||||
else ()
|
||||
ADD_LIBRARY ( oslcomp SHARED ${liboslcomp_srcs} )
|
||||
set_target_properties( oslcomp
|
||||
PROPERTIES
|
||||
VERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION} )
|
||||
endif ()
|
||||
|
||||
TARGET_LINK_LIBRARIES ( oslcomp ${OPENIMAGEIO_LIBRARY} ${ILMBASE_LIBRARIES}
|
||||
${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
TARGET_LINK_LIBRARIES ( oslcomp ${OPENIMAGEIO_LIBRARIES} ${ILMBASE_LIBRARIES}
|
||||
${Boost_LIBRARIES} ${CMAKE_DL_LIBS}
|
||||
${CLANG_LIBRARIES} ${LLVM_LIBRARIES} ${LLVM_LDFLAGS}
|
||||
${LLVM_SYSTEM_LIBRARIES})
|
||||
|
||||
INSTALL ( TARGETS oslcomp RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <cstdarg>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
@@ -534,11 +534,13 @@ ASTassign_expression::codegen (Symbol *dest)
|
||||
return dest;
|
||||
}
|
||||
|
||||
if (index)
|
||||
if (index) {
|
||||
index->codegen_assign (operand);
|
||||
else if (operand != dest)
|
||||
dest = operand; // so transitive assignment works for array refs
|
||||
} else if (operand != dest) {
|
||||
emitcode (typespec().is_array() ? "arraycopy" : "assign",
|
||||
dest, operand);
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <streambuf>
|
||||
#include <cstdio>
|
||||
#include <cerrno>
|
||||
#include <cstdarg>
|
||||
|
||||
#include "oslcomp_pvt.h"
|
||||
|
||||
#include <OpenImageIO/strutil.h>
|
||||
#include <OpenImageIO/platform.h>
|
||||
#include <OpenImageIO/sysutil.h>
|
||||
#include <OpenImageIO/strutil.h>
|
||||
#include <OpenImageIO/dassert.h>
|
||||
@@ -46,13 +47,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <boost/wave.hpp>
|
||||
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
|
||||
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
|
||||
#if OIIO_VERSION < 10604
|
||||
#include <boost/filesystem.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef USE_BOOST_WAVE
|
||||
# define USE_BOOST_WAVE 0
|
||||
#endif
|
||||
#if USE_BOOST_WAVE
|
||||
# include <boost/wave.hpp>
|
||||
# include <boost/wave/cpplexer/cpp_lex_token.hpp>
|
||||
# include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
|
||||
#else
|
||||
# if !defined(__STDC_CONSTANT_MACROS)
|
||||
# define __STDC_CONSTANT_MACROS 1
|
||||
# endif
|
||||
# include <clang/Frontend/CompilerInstance.h>
|
||||
# include <clang/Frontend/TextDiagnosticPrinter.h>
|
||||
# include <clang/Frontend/Utils.h>
|
||||
# include <clang/Basic/TargetInfo.h>
|
||||
# include <clang/Lex/PreprocessorOptions.h>
|
||||
# include <llvm/Support/ToolOutputFile.h>
|
||||
# include <llvm/Support/Host.h>
|
||||
# include <llvm/Support/MemoryBuffer.h>
|
||||
# include <llvm/Support/raw_ostream.h>
|
||||
#endif
|
||||
|
||||
|
||||
OSL_NAMESPACE_ENTER
|
||||
|
||||
@@ -200,6 +220,8 @@ OSLCompilerImpl::preprocess_file (const std::string &filename,
|
||||
|
||||
|
||||
|
||||
#if USE_BOOST_WAVE
|
||||
|
||||
bool
|
||||
OSLCompilerImpl::preprocess_buffer (const std::string &buffer,
|
||||
const std::string &filename,
|
||||
@@ -231,6 +253,14 @@ OSLCompilerImpl::preprocess_buffer (const std::string &buffer,
|
||||
ctx.get_language() | boost::wave::support_option_variadics);
|
||||
ctx.set_language (lang);
|
||||
|
||||
ctx.add_macro_definition (OIIO::Strutil::format("OSL_VERSION_MAJOR=%d",
|
||||
OSL_LIBRARY_VERSION_MAJOR).c_str());
|
||||
ctx.add_macro_definition (OIIO::Strutil::format("OSL_VERSION_MINOR=%d",
|
||||
OSL_LIBRARY_VERSION_MINOR).c_str());
|
||||
ctx.add_macro_definition (OIIO::Strutil::format("OSL_VERSION_PATCH=%d",
|
||||
OSL_LIBRARY_VERSION_PATCH).c_str());
|
||||
ctx.add_macro_definition (OIIO::Strutil::format("OSL_VERSION=%d",
|
||||
OSL_LIBRARY_VERSION_CODE).c_str());
|
||||
for (size_t i = 0; i < defines.size(); ++i) {
|
||||
if (defines[i][1] == 'D')
|
||||
ctx.add_macro_definition (defines[i].c_str()+2);
|
||||
@@ -293,6 +323,123 @@ OSLCompilerImpl::preprocess_buffer (const std::string &buffer,
|
||||
}
|
||||
|
||||
|
||||
#else /* LLVM: vvvvvvvvvv */
|
||||
|
||||
bool
|
||||
OSLCompilerImpl::preprocess_buffer (const std::string &buffer,
|
||||
const std::string &filename,
|
||||
const std::string &stdoslpath,
|
||||
const std::vector<std::string> &defines,
|
||||
const std::vector<std::string> &includepaths,
|
||||
std::string &result)
|
||||
{
|
||||
std::string instring;
|
||||
if (!stdoslpath.empty())
|
||||
instring = OIIO::Strutil::format("#include \"%s\"\n", stdoslpath);
|
||||
else
|
||||
instring = "\n";
|
||||
instring += buffer;
|
||||
std::unique_ptr<llvm::MemoryBuffer> mbuf (llvm::MemoryBuffer::getMemBuffer(instring, filename));
|
||||
|
||||
clang::CompilerInstance inst;
|
||||
|
||||
// Set up error capture for the preprocessor
|
||||
std::string preproc_errors;
|
||||
llvm::raw_string_ostream errstream(preproc_errors);
|
||||
clang::DiagnosticOptions *diagOptions = new clang::DiagnosticOptions();
|
||||
clang::TextDiagnosticPrinter *diagPrinter =
|
||||
new clang::TextDiagnosticPrinter(errstream, diagOptions);
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
|
||||
clang::DiagnosticsEngine *diagEngine =
|
||||
new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter);
|
||||
inst.setDiagnostics(diagEngine);
|
||||
|
||||
#if OSL_LLVM_VERSION <= 34
|
||||
clang::TargetOptions &targetopts = inst.getTargetOpts();
|
||||
targetopts.Triple = llvm::sys::getDefaultTargetTriple();
|
||||
clang::TargetInfo *target =
|
||||
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &targetopts);
|
||||
#else // LLVM 3.5+
|
||||
const std::shared_ptr<clang::TargetOptions> &targetopts =
|
||||
std::make_shared<clang::TargetOptions>(inst.getTargetOpts());
|
||||
targetopts->Triple = llvm::sys::getDefaultTargetTriple();
|
||||
clang::TargetInfo *target =
|
||||
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), targetopts);
|
||||
#endif
|
||||
|
||||
inst.setTarget(target);
|
||||
|
||||
inst.createFileManager();
|
||||
inst.createSourceManager(inst.getFileManager());
|
||||
#if OSL_LLVM_VERSION <= 35
|
||||
clang::FrontendInputFile inputFile(mbuf.release(), clang::IK_None);
|
||||
inst.InitializeSourceManager(inputFile);
|
||||
#else
|
||||
clang::SourceManager &sm = inst.getSourceManager();
|
||||
sm.setMainFileID (sm.createFileID(std::move(mbuf), clang::SrcMgr::C_User));
|
||||
#endif
|
||||
|
||||
inst.getPreprocessorOutputOpts().ShowCPP = 1;
|
||||
inst.getPreprocessorOutputOpts().ShowMacros = 0;
|
||||
|
||||
clang::HeaderSearchOptions &headerOpts = inst.getHeaderSearchOpts();
|
||||
headerOpts.UseBuiltinIncludes = 0;
|
||||
headerOpts.UseStandardSystemIncludes = 0;
|
||||
headerOpts.UseStandardCXXIncludes = 0;
|
||||
std::string directory = OIIO::Filesystem::parent_path(filename);
|
||||
if (directory.empty())
|
||||
directory = OIIO::Filesystem::current_path();
|
||||
headerOpts.AddPath (directory, clang::frontend::Angled, false, true);
|
||||
for (auto&& inc : includepaths) {
|
||||
headerOpts.AddPath (inc, clang::frontend::Angled,
|
||||
false /* not a framework */,
|
||||
true /* ignore sys root */);
|
||||
}
|
||||
|
||||
clang::PreprocessorOptions &preprocOpts = inst.getPreprocessorOpts();
|
||||
preprocOpts.UsePredefines = 0;
|
||||
preprocOpts.addMacroDef (OIIO::Strutil::format("OSL_VERSION_MAJOR=%d",
|
||||
OSL_LIBRARY_VERSION_MAJOR).c_str());
|
||||
preprocOpts.addMacroDef (OIIO::Strutil::format("OSL_VERSION_MINOR=%d",
|
||||
OSL_LIBRARY_VERSION_MINOR).c_str());
|
||||
preprocOpts.addMacroDef (OIIO::Strutil::format("OSL_VERSION_PATCH=%d",
|
||||
OSL_LIBRARY_VERSION_PATCH).c_str());
|
||||
preprocOpts.addMacroDef (OIIO::Strutil::format("OSL_VERSION=%d",
|
||||
OSL_LIBRARY_VERSION_CODE).c_str());
|
||||
for (auto&& d : defines) {
|
||||
if (d[1] == 'D')
|
||||
preprocOpts.addMacroDef (d.c_str()+2);
|
||||
else if (d[1] == 'U')
|
||||
preprocOpts.addMacroUndef (d.c_str()+2);
|
||||
}
|
||||
|
||||
inst.getLangOpts().LineComment = 1;
|
||||
|
||||
#if OSL_LLVM_VERSION >= 35
|
||||
inst.createPreprocessor(clang::TU_Prefix);
|
||||
#else
|
||||
inst.createPreprocessor();
|
||||
#endif
|
||||
|
||||
llvm::raw_string_ostream ostream(result);
|
||||
diagPrinter->BeginSourceFile (inst.getLangOpts(), &inst.getPreprocessor());
|
||||
clang::DoPrintPreprocessedInput (inst.getPreprocessor(),
|
||||
&ostream, inst.getPreprocessorOutputOpts());
|
||||
diagPrinter->EndSourceFile ();
|
||||
|
||||
if (preproc_errors.size()) {
|
||||
while (preproc_errors.size() &&
|
||||
preproc_errors[preproc_errors.size()-1] == '\n')
|
||||
preproc_errors.erase (preproc_errors.size()-1);
|
||||
error (ustring(), -1, "%s", preproc_errors.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void
|
||||
OSLCompilerImpl::read_compile_options (const std::vector<std::string> &options,
|
||||
@@ -856,7 +1003,11 @@ OSLCompilerImpl::write_oso_file (const std::string &outfilename,
|
||||
// %argderivs documents which arguments have derivs taken of
|
||||
// them by the op.
|
||||
if (op->argtakesderivs_all()) {
|
||||
#if OIIO_VERSION >= 10803
|
||||
oso (" %%argderivs{");
|
||||
#else
|
||||
oso (" %cargderivs{", '%'); // trick to work with older OIIO
|
||||
#endif
|
||||
int any = 0;
|
||||
for (int i = 0; i < op->nargs(); ++i)
|
||||
if (op->argtakesderivs(i)) {
|
||||
|
||||
@@ -323,8 +323,15 @@ private:
|
||||
void write_oso_const_value (const ConstantSymbol *sym) const;
|
||||
void write_oso_symbol (const Symbol *sym);
|
||||
void write_oso_metadata (const ASTNode *metanode) const;
|
||||
// void oso (const char *fmt, ...) const;
|
||||
|
||||
#if OIIO_VERSION >= 10803
|
||||
template<typename... Args>
|
||||
inline void oso (string_view fmt, const Args&... args) const {
|
||||
(*m_osofile) << OIIO::Strutil::format (fmt, args...);
|
||||
}
|
||||
#else
|
||||
TINYFORMAT_WRAP_FORMAT (void, oso, const, , (*m_osofile), )
|
||||
#endif
|
||||
|
||||
void track_variable_lifetimes () {
|
||||
track_variable_lifetimes (m_ircode, m_opargs, symtab().allsyms());
|
||||
|
||||
@@ -43,40 +43,6 @@ OSL_NAMESPACE_ENTER
|
||||
namespace pvt { // OSL::pvt
|
||||
|
||||
|
||||
std::string
|
||||
TypeSpec::string () const
|
||||
{
|
||||
std::string str;
|
||||
if (is_closure() || is_closure_array()) {
|
||||
str += "closure color";
|
||||
if (is_unsized_array())
|
||||
str += "[]";
|
||||
else if (arraylength() > 0)
|
||||
str += Strutil::format ("[%d]", arraylength());
|
||||
}
|
||||
else if (structure() > 0) {
|
||||
str += Strutil::format ("struct %d", structure());
|
||||
if (is_unsized_array())
|
||||
str += "[]";
|
||||
else if (arraylength() > 0)
|
||||
str += Strutil::format ("[%d]", arraylength());
|
||||
} else {
|
||||
str += simpletype().c_str();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
TypeSpec::c_str () const
|
||||
{
|
||||
ustring s (this->string());
|
||||
return s.c_str ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string
|
||||
Symbol::mangled () const
|
||||
{
|
||||
|
||||
@@ -1275,6 +1275,7 @@ static const char * builtin_func_args [] = {
|
||||
"getattribute", "is?", "is?[]", "iss?", "iss?[]", "isi?", "isi?[]", "issi?", "issi?[]", "!rw", NULL, // FIXME -- further checking?
|
||||
"getmessage", "is?", "is?[]", "iss?", "iss?[]", "!rw", NULL,
|
||||
"gettextureinfo", "iss?", "iss?[]", "!rw", NULL, // FIXME -- further checking?
|
||||
"hashnoise", NOISE_ARGS, NULL,
|
||||
"isconnected", "i?", NULL,
|
||||
"isconstant", "i?", NULL,
|
||||
"noise", GNOISE_ARGS, NOISE_ARGS, "!deriv", NULL,
|
||||
|
||||
@@ -116,7 +116,7 @@ MACRO ( LLVM_COMPILE llvm_src srclist )
|
||||
"-I${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"-I${CMAKE_SOURCE_DIR}/src/include"
|
||||
"-I${CMAKE_BINARY_DIR}/include/OSL"
|
||||
"-I${OPENIMAGEIO_INCLUDES}"
|
||||
"-I${OPENIMAGEIO_INCLUDE_DIR}"
|
||||
"-I${ILMBASE_INCLUDE_DIR}"
|
||||
"-I${Boost_INCLUDE_DIRS}"
|
||||
-DOSL_COMPILING_TO_BITCODE=1
|
||||
@@ -143,6 +143,10 @@ if (BUILDSTATIC)
|
||||
ADD_LIBRARY ( oslexec STATIC ${liboslexec_srcs} )
|
||||
else ()
|
||||
ADD_LIBRARY ( oslexec SHARED ${liboslexec_srcs} )
|
||||
set_target_properties( oslexec
|
||||
PROPERTIES
|
||||
VERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION} )
|
||||
endif ()
|
||||
|
||||
TARGET_LINK_LIBRARIES ( oslexec
|
||||
@@ -151,20 +155,21 @@ TARGET_LINK_LIBRARIES ( oslexec
|
||||
${PUGIXML_LIBRARIES}
|
||||
${PARTIO_LIBRARIES} ${ZLIB_LIBRARIES}
|
||||
${Boost_LIBRARIES} ${CMAKE_DL_LIBS}
|
||||
${CLANG_LIBRARIES}
|
||||
${LLVM_LIBRARY} ${LLVM_MCJIT_LIBRARY}
|
||||
${LLVM_LIBRARIES} ${LLVM_LDFLAGS}
|
||||
${LLVM_SYSTEM_LIBRARIES})
|
||||
ADD_DEPENDENCIES (oslexec "${CMAKE_CURRENT_SOURCE_DIR}/liboslexec.map")
|
||||
ADD_DEPENDENCIES (oslexec "${CMAKE_SOURCE_DIR}/src/build-scripts/hidesymbols.map")
|
||||
|
||||
INSTALL ( TARGETS oslexec RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
|
||||
|
||||
# Unit tests
|
||||
if (OSL_BUILD_TESTS)
|
||||
add_executable (accum_test accum_test.cpp)
|
||||
target_link_libraries ( accum_test oslexec oslcomp ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
target_link_libraries ( accum_test oslexec ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
add_test (unit_accum "${CMAKE_BINARY_DIR}/src/liboslexec/accum_test")
|
||||
|
||||
add_executable (llvmutil_test llvmutil_test.cpp)
|
||||
target_link_libraries ( llvmutil_test oslexec oslcomp ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
target_link_libraries ( llvmutil_test oslexec ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
add_test (unit_llvmutil "${CMAKE_BINARY_DIR}/src/liboslexec/llvmutil_test")
|
||||
endif ()
|
||||
|
||||
@@ -150,6 +150,7 @@ DECL (osl_incr_layers_executed, "xX")
|
||||
|
||||
NOISE_IMPL(cellnoise)
|
||||
//NOISE_DERIV_IMPL(cellnoise)
|
||||
NOISE_IMPL(hashnoise)
|
||||
NOISE_IMPL(noise)
|
||||
NOISE_DERIV_IMPL(noise)
|
||||
NOISE_IMPL(snoise)
|
||||
@@ -166,6 +167,7 @@ NOISE_IMPL(unullnoise)
|
||||
NOISE_DERIV_IMPL(unullnoise)
|
||||
PNOISE_IMPL(pcellnoise)
|
||||
//PNOISE_DERIV_IMPL(pcellnoise)
|
||||
PNOISE_IMPL(phashnoise)
|
||||
PNOISE_IMPL(pnoise)
|
||||
PNOISE_DERIV_IMPL(pnoise)
|
||||
PNOISE_IMPL(psnoise)
|
||||
@@ -178,6 +180,11 @@ DECL (osl_noiseparams_set_direction, "xXv")
|
||||
DECL (osl_noiseparams_set_bandwidth, "xXf")
|
||||
DECL (osl_noiseparams_set_impulses, "xXf")
|
||||
DECL (osl_count_noise, "xX")
|
||||
DECL (osl_hash_ii, "ii")
|
||||
DECL (osl_hash_if, "if")
|
||||
DECL (osl_hash_iff, "iff")
|
||||
DECL (osl_hash_iv, "iX")
|
||||
DECL (osl_hash_ivf, "iXf")
|
||||
|
||||
DECL (osl_spline_fff, "xXXXXii")
|
||||
DECL (osl_spline_dfdfdf, "xXXXXii")
|
||||
|
||||
@@ -1133,13 +1133,27 @@ DECLFOLDER(constfold_hash)
|
||||
{
|
||||
// Try to turn R=hash(s) into R=C
|
||||
Opcode &op (rop.inst()->ops()[opnum]);
|
||||
Symbol &S (*rop.inst()->argsymbol(op.firstarg()+1));
|
||||
if (S.is_constant()) {
|
||||
ASSERT (S.typespec().is_string());
|
||||
int result = (int) (*(ustring *)S.data()).hash();
|
||||
int cind = rop.add_constant (result);
|
||||
rop.turn_into_assign (op, cind, "const fold hash");
|
||||
return 1;
|
||||
Symbol *S (rop.inst()->argsymbol(op.firstarg()+1));
|
||||
Symbol *T (op.nargs() > 2 ? rop.inst()->argsymbol(op.firstarg()+2) : NULL);
|
||||
if (S->is_constant() && (T == NULL || T->is_constant())) {
|
||||
int cind = -1;
|
||||
if (S->typespec().is_string()) {
|
||||
cind = rop.add_constant ((int) (*(ustring *)S->data()).hash());
|
||||
} else if (op.nargs() == 2 && S->typespec().is_int()) {
|
||||
cind = rop.add_constant (inthashi (S->get_int()));
|
||||
} else if (op.nargs() == 2 && S->typespec().is_float()) {
|
||||
cind = rop.add_constant (inthashf (S->get_float()));
|
||||
} else if (op.nargs() == 3 && S->typespec().is_float() && T->typespec().is_float()) {
|
||||
cind = rop.add_constant (inthashf (S->get_float(), T->get_float()));
|
||||
} else if (op.nargs() == 2 && S->typespec().is_triple()) {
|
||||
cind = rop.add_constant (inthashf ((const float *)S->data()));
|
||||
} else if (op.nargs() == 3 && S->typespec().is_triple() && T->typespec().is_float()) {
|
||||
cind = rop.add_constant (inthashf ((const float *)S->data(), T->get_float()));
|
||||
}
|
||||
if (cind >= 0) {
|
||||
rop.turn_into_assign (op, cind, "const fold hash");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -2245,7 +2259,11 @@ DECLFOLDER(constfold_getattribute)
|
||||
bool found = false;
|
||||
|
||||
// Check global things first
|
||||
if (attr_name == "shader:shadername" && attr_type == TypeDesc::TypeString) {
|
||||
if (attr_name == "osl:version" && attr_type == TypeDesc::TypeInt) {
|
||||
int *val = (int *)(char *)buf;
|
||||
*val = OSL_VERSION;
|
||||
found = true;
|
||||
} else if (attr_name == "shader:shadername" && attr_type == TypeDesc::TypeString) {
|
||||
ustring *up = (ustring *)(char *)buf;
|
||||
*up = ustring(rop.inst()->shadername());
|
||||
found = true;
|
||||
|
||||
@@ -261,8 +261,8 @@ Dictionary::dict_find (int nodeID, ustring query)
|
||||
if (nodeID <= 0 || nodeID >= (int)m_nodes.size())
|
||||
return 0; // invalid node ID
|
||||
|
||||
const Dictionary::Node &node (m_nodes[nodeID]);
|
||||
Query q (node.document, nodeID, query);
|
||||
int document = m_nodes[nodeID].document;
|
||||
Query q (document, nodeID, query);
|
||||
QueryMap::iterator qfound = m_cache.find (q);
|
||||
if (qfound != m_cache.end()) {
|
||||
return qfound->second.valueoffset;
|
||||
@@ -271,7 +271,7 @@ Dictionary::dict_find (int nodeID, ustring query)
|
||||
// Query was not found. Do the expensive lookup and cache it
|
||||
pugi::xpath_node_set matches;
|
||||
try {
|
||||
matches = node.node.select_nodes (query.c_str());
|
||||
matches = m_nodes[nodeID].node.select_nodes (query.c_str());
|
||||
}
|
||||
catch (const pugi::xpath_exception& e) {
|
||||
m_context->error ("Invalid dict_find query '%s': %s",
|
||||
@@ -286,7 +286,7 @@ Dictionary::dict_find (int nodeID, ustring query)
|
||||
int firstmatch = (int) m_nodes.size();
|
||||
int last = -1;
|
||||
for (int i = 0, e = (int)matches.size(); i < e; ++i) {
|
||||
m_nodes.push_back (Node (node.document, matches[i].node()));
|
||||
m_nodes.push_back (Node (document, matches[i].node()));
|
||||
int nodeid = (int) m_nodes.size()-1;
|
||||
if (last < 0) {
|
||||
// If this is the first match, add a cache entry for it
|
||||
|
||||
@@ -671,7 +671,7 @@ ShaderGroup::ShaderGroup (string_view name)
|
||||
: m_optimized(0), m_does_nothing(false),
|
||||
m_llvm_groupdata_size(0), m_num_entry_layers(0),
|
||||
m_llvm_compiled_version(NULL),
|
||||
m_name(name), m_exec_repeat(1), m_raytype_queries(-1)
|
||||
m_name(name), m_exec_repeat(1), m_raytype_queries(-1), m_raytypes_on(0), m_raytypes_off(0)
|
||||
{
|
||||
m_executions = 0;
|
||||
m_stat_total_shading_time_ticks = 0;
|
||||
@@ -685,7 +685,7 @@ ShaderGroup::ShaderGroup (const ShaderGroup &g, string_view name)
|
||||
m_llvm_groupdata_size(0), m_num_entry_layers(g.m_num_entry_layers),
|
||||
m_llvm_compiled_version(NULL),
|
||||
m_layers(g.m_layers),
|
||||
m_name(name), m_exec_repeat(1), m_raytype_queries(-1)
|
||||
m_name(name), m_exec_repeat(1), m_raytype_queries(-1), m_raytypes_on(0), m_raytypes_off(0)
|
||||
{
|
||||
m_executions = 0;
|
||||
m_stat_total_shading_time_ticks = 0;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
global: *OSL*; osl_*; test_shade;
|
||||
local: *;
|
||||
};
|
||||
@@ -59,6 +59,7 @@ static ustring op_for("for");
|
||||
static ustring op_format("format");
|
||||
static ustring op_ge("ge");
|
||||
static ustring op_gt("gt");
|
||||
static ustring op_hashnoise("hashnoise");
|
||||
static ustring op_if("if");
|
||||
static ustring op_le("le");
|
||||
static ustring op_logb("logb");
|
||||
@@ -2171,6 +2172,12 @@ llvm_gen_texture_options (BackendLLVM &rop, int opnum,
|
||||
PARAM_INT (subimage)
|
||||
|
||||
if (name == Strings::subimage && valtype == TypeDesc::STRING) {
|
||||
if (Val.is_constant()) {
|
||||
ustring v = *(ustring *)Val.data();
|
||||
if (! v && ! subimage_set) {
|
||||
continue; // Ignore nulls unless they are overrides
|
||||
}
|
||||
}
|
||||
llvm::Value *val = rop.llvm_load_value (Val);
|
||||
rop.ll.call_function ("osl_texture_set_subimagename", opt, val);
|
||||
subimage_set = true;
|
||||
@@ -2683,6 +2690,9 @@ LLVMGEN (llvm_gen_noise)
|
||||
} else if (name == Strings::cell || name == Strings::cellnoise) {
|
||||
name = periodic ? Strings::pcellnoise : Strings::cellnoise;
|
||||
derivs = false; // cell noise derivs are always zero
|
||||
} else if (name == Strings::hash || name == Strings::hashnoise) {
|
||||
name = periodic ? Strings::phashnoise : Strings::hashnoise;
|
||||
derivs = false; // hash noise derivs are always zero
|
||||
} else if (name == Strings::simplex && !periodic) {
|
||||
name = Strings::simplexnoise;
|
||||
} else if (name == Strings::usimplex && !periodic) {
|
||||
@@ -2708,6 +2718,7 @@ LLVMGEN (llvm_gen_noise)
|
||||
if (name == Strings::uperlin || name == Strings::noise ||
|
||||
name == Strings::usimplexnoise || name == Strings::usimplex ||
|
||||
name == Strings::cell || name == Strings::cellnoise ||
|
||||
name == Strings::hash || name == Strings::hashnoise ||
|
||||
name == Strings::pcellnoise || name == Strings::pnoise)
|
||||
name = ustring("unullnoise");
|
||||
else
|
||||
|
||||
@@ -952,7 +952,7 @@ BackendLLVM::initialize_llvm_group ()
|
||||
|
||||
for (HelperFuncMap::iterator i = llvm_helper_function_map.begin(),
|
||||
e = llvm_helper_function_map.end(); i != e; ++i) {
|
||||
const char *funcname = i->first.c_str();
|
||||
const std::string &funcname (i->first);
|
||||
bool varargs = false;
|
||||
const char *types = i->second.argtypes;
|
||||
int advance;
|
||||
@@ -971,7 +971,8 @@ BackendLLVM::initialize_llvm_group ()
|
||||
}
|
||||
types += advance;
|
||||
}
|
||||
ll.make_function (funcname, false, llvm_type(rettype), params, varargs);
|
||||
llvm::Function *f = ll.make_function (funcname, false, llvm_type(rettype), params, varargs);
|
||||
ll.add_function_mapping (f, (void *)i->second.function);
|
||||
}
|
||||
|
||||
// Needed for closure setup
|
||||
|
||||
@@ -285,7 +285,12 @@ public:
|
||||
mm->registerEHFrames (Addr, LoadAddr, Size);
|
||||
}
|
||||
virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
|
||||
#if OSL_LLVM_VERSION < 50
|
||||
mm->deregisterEHFrames(Addr, LoadAddr, Size);
|
||||
#else
|
||||
// TODO: verify this is correct
|
||||
mm->deregisterEHFrames();
|
||||
#endif
|
||||
}
|
||||
virtual uint64_t getSymbolAddress(const std::string &Name) {
|
||||
return mm->getSymbolAddress (Name);
|
||||
@@ -483,31 +488,38 @@ LLVM_Util::module_from_bitcode (const char *bitcode, size_t size,
|
||||
if (err)
|
||||
err->clear();
|
||||
|
||||
// Keep uninitialized so compiler will error if not set through macros below
|
||||
llvm::Module *m;
|
||||
|
||||
#if OSL_LLVM_VERSION <= 34
|
||||
|
||||
#if OSL_LLVM_VERSION <= 35 /* Old JIT vvvvvvvvvvvvvvvvvvvvvvvvvvvv */
|
||||
llvm::MemoryBuffer* buf =
|
||||
llvm::MemoryBuffer::getMemBuffer (llvm::StringRef(bitcode, size), name);
|
||||
|
||||
m = llvm::getLazyBitcodeModule (buf, context(), err);
|
||||
|
||||
#else // > 34
|
||||
|
||||
# if OSL_LLVM_VERSION <= 36
|
||||
typedef llvm::ErrorOr<llvm::Module*> ErrorOrModule;
|
||||
# elif OSL_LLVM_VERSION < 40
|
||||
typedef llvm::ErrorOr<std::unique_ptr<llvm::Module> > ErrorOrModule;
|
||||
// Create a lazily deserialized IR module
|
||||
// This can only be done for old JIT
|
||||
# if OSL_LLVM_VERSION >= 35
|
||||
llvm::Module *m = llvm::getLazyBitcodeModule (buf, context()).get();
|
||||
# else
|
||||
llvm::Module *m = llvm::getLazyBitcodeModule (buf, context(), err);
|
||||
# endif
|
||||
// don't delete buf, the module has taken ownership of it
|
||||
|
||||
#if 0
|
||||
// Debugging: print all functions in the module
|
||||
for (llvm::Module::iterator i = m->begin(); i != m->end(); ++i)
|
||||
std::cout << " found " << i->getName().data() << "\n";
|
||||
#endif
|
||||
return m;
|
||||
#endif /* End of LLVM <= 3.5 Old JIT section ^^^^^^^^^^^^^^^^^^^^^ */
|
||||
|
||||
|
||||
#if OSL_LLVM_VERSION >= 36 /* MCJIT vvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
|
||||
# if OSL_LLVM_VERSION >= 40
|
||||
typedef llvm::Expected<std::unique_ptr<llvm::Module> > ErrorOrModule;
|
||||
# else
|
||||
typedef llvm::ErrorOr<std::unique_ptr<llvm::Module> > ErrorOrModule;
|
||||
# endif
|
||||
|
||||
# if OSL_LLVM_VERSION >= 40 || defined(OSL_FORCE_BITCODE_PARSE)
|
||||
|
||||
llvm::MemoryBufferRef buf =
|
||||
llvm::MemoryBufferRef(llvm::StringRef(bitcode, size), name);
|
||||
|
||||
# ifdef OSL_FORCE_BITCODE_PARSE
|
||||
//
|
||||
// None of the below seems to be an issue for 3.9 and above.
|
||||
@@ -523,54 +535,33 @@ LLVM_Util::module_from_bitcode (const char *bitcode, size_t size,
|
||||
// lazily deserialize the bitcode, MCJIT is unable to find the
|
||||
// called functions due to disagreement about whether a leading "_"
|
||||
// is part of the symbol name.
|
||||
|
||||
ErrorOrModule ModuleOrErr = llvm::parseBitcodeFile (buf, context());
|
||||
# else
|
||||
ErrorOrModule ModuleOrErr = llvm::getLazyBitcodeModule(buf, context());
|
||||
# endif
|
||||
|
||||
# else /* !OSL_FORCE_BITCODE_PARSE */
|
||||
|
||||
std::unique_ptr<llvm::MemoryBuffer> buf (
|
||||
llvm::MemoryBuffer::getMemBuffer (llvm::StringRef(bitcode, size),
|
||||
name, false));
|
||||
# if OSL_LLVM_VERSION >= 36
|
||||
ErrorOrModule ModuleOrErr = llvm::getLazyBitcodeModule(std::move(buf),
|
||||
context());
|
||||
# else /* OSL_LLVM_VERSION == 35 */
|
||||
ErrorOrModule ModuleOrErr = llvm::getLazyBitcodeModule(buf.get(),
|
||||
context());
|
||||
# endif /* OSL_LLVM_VERSION >= 36 */
|
||||
|
||||
llvm::MemoryBuffer::getMemBuffer (llvm::StringRef(bitcode, size), name, false));
|
||||
ErrorOrModule ModuleOrErr = llvm::getLazyBitcodeModule(std::move(buf), context());
|
||||
# endif
|
||||
|
||||
if (err) {
|
||||
#if OSL_LLVM_VERSION < 40
|
||||
error_string(ModuleOrErr.getError(), err);
|
||||
#else
|
||||
# if OSL_LLVM_VERSION >= 40
|
||||
error_string(ModuleOrErr.takeError(), err);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if OSL_LLVM_VERSION <= 36
|
||||
m = ModuleOrErr.get();
|
||||
# if OSL_LLVM_VERSION == 35
|
||||
// If module exists ownership of buf has been transfered.
|
||||
if (m) buf.release();
|
||||
# else
|
||||
error_string(ModuleOrErr.getError(), err);
|
||||
# endif
|
||||
#else
|
||||
m = ModuleOrErr ? ModuleOrErr->release() : nullptr;
|
||||
#endif
|
||||
|
||||
#endif // <= 34
|
||||
|
||||
#if 0
|
||||
}
|
||||
llvm::Module *m = ModuleOrErr ? ModuleOrErr->release() : nullptr;
|
||||
# if 0
|
||||
// Debugging: print all functions in the module
|
||||
for (llvm::Module::iterator i = m->begin(); i != m->end(); ++i)
|
||||
std::cout << " found " << i->getName().data() << "\n";
|
||||
#endif
|
||||
|
||||
# endif
|
||||
return m;
|
||||
|
||||
#endif /* MCJIT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
|
||||
}
|
||||
|
||||
|
||||
@@ -779,7 +770,7 @@ LLVM_Util::do_optimize (std::string *out_err)
|
||||
{
|
||||
ASSERT(m_llvm_module && "No module to optimize!");
|
||||
|
||||
#if OSL_LLVM_VERSION >= 35 && !defined(OSL_FORCE_BITCODE_PARSE)
|
||||
#if OSL_LLVM_VERSION > 35 && !defined(OSL_FORCE_BITCODE_PARSE)
|
||||
LLVMErr err = m_llvm_module->materializeAll();
|
||||
if (error_string(std::move(err), out_err))
|
||||
return;
|
||||
@@ -872,12 +863,16 @@ LLVM_Util::make_function (const std::string &name, bool fastcall,
|
||||
llvm::Type *arg3,
|
||||
llvm::Type *arg4)
|
||||
{
|
||||
llvm::Function *func = llvm::cast<llvm::Function>(
|
||||
module()->getOrInsertFunction (name, rettype,
|
||||
arg1, arg2, arg3, arg4, NULL));
|
||||
if (fastcall)
|
||||
func->setCallingConv(llvm::CallingConv::Fast);
|
||||
return func;
|
||||
std::vector<llvm::Type*> argtypes;
|
||||
if (arg1)
|
||||
argtypes.push_back(arg1);
|
||||
if (arg2)
|
||||
argtypes.push_back(arg2);
|
||||
if (arg3)
|
||||
argtypes.push_back(arg3);
|
||||
if (arg4)
|
||||
argtypes.push_back(arg4);
|
||||
return make_function (name, fastcall, rettype, argtypes, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -901,6 +896,14 @@ LLVM_Util::make_function (const std::string &name, bool fastcall,
|
||||
|
||||
|
||||
|
||||
void
|
||||
LLVM_Util::add_function_mapping (llvm::Function *func, void *addr)
|
||||
{
|
||||
execengine()->addGlobalMapping (func, addr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
llvm::Value *
|
||||
LLVM_Util::current_function_arg (int a)
|
||||
{
|
||||
|
||||
@@ -278,6 +278,7 @@ OSL_SHADEOP void osl_ ##opname## _dvdvdf (char *name, char *r, char *x, char *y,
|
||||
|
||||
|
||||
NOISE_IMPL (cellnoise, CellNoise)
|
||||
NOISE_IMPL (hashnoise, HashNoise)
|
||||
NOISE_IMPL (noise, Noise)
|
||||
NOISE_IMPL_DERIV (noise, Noise)
|
||||
NOISE_IMPL (snoise, SNoise)
|
||||
@@ -474,6 +475,7 @@ OSL_SHADEOP void osl_ ##opname## _dvdvdfvf (char *name, char *r, char *x, char *
|
||||
|
||||
|
||||
PNOISE_IMPL (pcellnoise, PeriodicCellNoise)
|
||||
PNOISE_IMPL (phashnoise, PeriodicHashNoise)
|
||||
PNOISE_IMPL (pnoise, PeriodicNoise)
|
||||
PNOISE_IMPL_DERIV (pnoise, PeriodicNoise)
|
||||
PNOISE_IMPL (psnoise, PeriodicSNoise)
|
||||
@@ -697,6 +699,10 @@ struct GenericNoise {
|
||||
NullNoise noise; noise(result, s);
|
||||
} else if (name == Strings::unull) {
|
||||
UNullNoise noise; noise(result, s);
|
||||
} else if (name == Strings::hash) {
|
||||
HashNoise hashnoise;
|
||||
hashnoise(result.val(), s.val());
|
||||
result.clear_d();
|
||||
} else {
|
||||
((ShadingContext *)sg->context)->error ("Unknown noise type \"%s\"", name.c_str());
|
||||
}
|
||||
@@ -729,6 +735,10 @@ struct GenericNoise {
|
||||
NullNoise noise; noise(result, s, t);
|
||||
} else if (name == Strings::unull) {
|
||||
UNullNoise noise; noise(result, s, t);
|
||||
} else if (name == Strings::hash) {
|
||||
HashNoise hashnoise;
|
||||
hashnoise(result.val(), s.val(), t.val());
|
||||
result.clear_d();
|
||||
} else {
|
||||
((ShadingContext *)sg->context)->error ("Unknown noise type \"%s\"", name.c_str());
|
||||
}
|
||||
@@ -763,6 +773,10 @@ struct GenericPNoise {
|
||||
} else if (name == Strings::gabor) {
|
||||
GaborPNoise gnoise;
|
||||
gnoise (name, result, s, sp, sg, opt);
|
||||
} else if (name == Strings::hash) {
|
||||
PeriodicHashNoise hashnoise;
|
||||
hashnoise(result.val(), s.val(), sp);
|
||||
result.clear_d();
|
||||
} else {
|
||||
((ShadingContext *)sg->context)->error ("Unknown noise type \"%s\"", name.c_str());
|
||||
}
|
||||
@@ -786,6 +800,10 @@ struct GenericPNoise {
|
||||
} else if (name == Strings::gabor) {
|
||||
GaborPNoise gnoise;
|
||||
gnoise (name, result, s, t, sp, tp, sg, opt);
|
||||
} else if (name == Strings::hash) {
|
||||
PeriodicHashNoise hashnoise;
|
||||
hashnoise(result.val(), s.val(), t.val(), sp, tp);
|
||||
result.clear_d();
|
||||
} else {
|
||||
((ShadingContext *)sg->context)->error ("Unknown noise type \"%s\"", name.c_str());
|
||||
}
|
||||
@@ -857,6 +875,40 @@ osl_count_noise (void *sg_)
|
||||
}
|
||||
|
||||
|
||||
|
||||
OSL_SHADEOP int
|
||||
osl_hash_ii (int x)
|
||||
{
|
||||
return inthashi (x);
|
||||
}
|
||||
|
||||
OSL_SHADEOP int
|
||||
osl_hash_if (float x)
|
||||
{
|
||||
return inthashf (x);
|
||||
}
|
||||
|
||||
OSL_SHADEOP int
|
||||
osl_hash_iff (float x, float y)
|
||||
{
|
||||
return inthashf (x, y);
|
||||
}
|
||||
|
||||
|
||||
OSL_SHADEOP int
|
||||
osl_hash_iv (float *x)
|
||||
{
|
||||
return inthashf (x);
|
||||
}
|
||||
|
||||
|
||||
OSL_SHADEOP int
|
||||
osl_hash_ivf (float *x, float y)
|
||||
{
|
||||
return inthashf (x, y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace pvt
|
||||
OSL_NAMESPACE_EXIT
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace Strings {
|
||||
extern ustring interp, closest, linear, cubic, smartcubic;
|
||||
extern ustring perlin, uperlin, noise, snoise, pnoise, psnoise;
|
||||
extern ustring cell, cellnoise, pcellnoise;
|
||||
extern ustring hash, hashnoise, phashnoise;
|
||||
extern ustring genericnoise, genericpnoise, gabor, gabornoise, gaborpnoise;
|
||||
extern ustring simplex, usimplex, simplexnoise, usimplexnoise;
|
||||
extern ustring anisotropic, direction, do_filter, bandwidth, impulses;
|
||||
@@ -151,7 +152,7 @@ struct OpDescriptor {
|
||||
: name(n), llvmgen(ll), folder(fold), simple_assign(simple), flags(flags)
|
||||
{}
|
||||
|
||||
enum FlagValues { None=0, Tex=1 };
|
||||
enum FlagValues { None=0, Tex=1, SideEffects=2 };
|
||||
};
|
||||
|
||||
|
||||
@@ -208,8 +209,9 @@ struct AttributeNeeded {
|
||||
}
|
||||
};
|
||||
|
||||
// Prefix for OSL shade up declarations, so LLVM can find them
|
||||
#define OSL_SHADEOP extern "C" OSL_LLVM_EXPORT
|
||||
// Prefix for OSL shade op declarations. Make them local visibility, but
|
||||
// "C" linkage (no C++ name mangling).
|
||||
#define OSL_SHADEOP extern "C" OSL_DLL_LOCAL
|
||||
|
||||
|
||||
// Handy re-casting macros
|
||||
@@ -501,7 +503,32 @@ public:
|
||||
TypeDesc type, const void *val);
|
||||
|
||||
// Internal error, warning, info, and message reporting routines that
|
||||
// take printf-like arguments. Based on Tinyformat.
|
||||
// take printf-like arguments.
|
||||
#if OIIO_VERSION >= 10803
|
||||
template<typename T1, typename... Args>
|
||||
inline void error (string_view fmt, const T1& v1, const Args&... args) const {
|
||||
error (Strutil::format (fmt, v1, args...));
|
||||
}
|
||||
void error (const std::string &message) const;
|
||||
|
||||
template<typename T1, typename... Args>
|
||||
inline void warning (string_view fmt, const T1& v1, const Args&... args) const {
|
||||
warning (Strutil::format (fmt, v1, args...));
|
||||
}
|
||||
void warning (const std::string &message) const;
|
||||
|
||||
template<typename T1, typename... Args>
|
||||
inline void info (string_view fmt, const T1& v1, const Args&... args) const {
|
||||
info (Strutil::format (fmt, v1, args...));
|
||||
}
|
||||
void info (const std::string &message) const;
|
||||
|
||||
template<typename T1, typename... Args>
|
||||
inline void message (string_view fmt, const T1& v1, const Args&... args) const {
|
||||
message (Strutil::format (fmt, v1, args...));
|
||||
}
|
||||
void message (const std::string &message) const;
|
||||
#else
|
||||
TINYFORMAT_WRAP_FORMAT (void, error, const,
|
||||
std::ostringstream msg;, msg, error(msg.str());)
|
||||
TINYFORMAT_WRAP_FORMAT (void, warning, const,
|
||||
@@ -510,13 +537,11 @@ public:
|
||||
std::ostringstream msg;, msg, info(msg.str());)
|
||||
TINYFORMAT_WRAP_FORMAT (void, message, const,
|
||||
std::ostringstream msg;, msg, message(msg.str());)
|
||||
|
||||
/// Error reporting routines that take a pre-formatted string only.
|
||||
///
|
||||
void error (const std::string &message) const;
|
||||
void warning (const std::string &message) const;
|
||||
void info (const std::string &message) const;
|
||||
void message (const std::string &message) const;
|
||||
#endif
|
||||
|
||||
std::string getstats (int level=1) const;
|
||||
|
||||
@@ -589,8 +614,7 @@ public:
|
||||
/// The group is set and won't be changed again; take advantage of
|
||||
/// this by optimizing the code knowing all our instance parameters
|
||||
/// (at least the ones that can't be overridden by the geometry).
|
||||
void optimize_group (ShaderGroup &group,
|
||||
int raytypes_on=0, int raytypes_off=0);
|
||||
void optimize_group (ShaderGroup &group);
|
||||
|
||||
/// After doing all optimization and code JIT, we can clean up by
|
||||
/// deleting the instances' code and arguments, and paring their
|
||||
@@ -727,6 +751,7 @@ private:
|
||||
bool m_debug_uninit; ///< Find use of uninitialized vars?
|
||||
bool m_lockgeom_default; ///< Default value of lockgeom
|
||||
bool m_strict_messages; ///< Strict checking of message passing usage?
|
||||
bool m_error_repeats; ///< Allow repeats of identical err/warn?
|
||||
bool m_range_checking; ///< Range check arrays & components?
|
||||
bool m_unknown_coordsys_error; ///< Error to use unknown xform name?
|
||||
bool m_connection_error; ///< Error for ConnectShaders to fail?
|
||||
@@ -1470,6 +1495,15 @@ public:
|
||||
|
||||
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).
|
||||
void set_raytypes (int raytypes_on, int raytypes_off) {
|
||||
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; }
|
||||
|
||||
private:
|
||||
// Put all the things that are read-only (after optimization) and
|
||||
// needed on every shade execution at the front of the struct, as much
|
||||
@@ -1486,6 +1520,8 @@ private:
|
||||
ustring m_name;
|
||||
int m_exec_repeat; ///< How many times to execute group
|
||||
int m_raytype_queries; ///< Bitmask of raytypes queried
|
||||
int m_raytypes_on; ///< Bitmask of raytypes we assume to be on
|
||||
int m_raytypes_off; ///< Bitmask of raytypes we assume to be off
|
||||
mutable mutex m_mutex; ///< Thread-safe optimization
|
||||
std::vector<ustring> m_textures_needed;
|
||||
std::vector<ustring> m_closures_needed;
|
||||
@@ -1682,6 +1718,27 @@ public:
|
||||
// Process all the recorded errors, warnings, printfs
|
||||
void process_errors () const;
|
||||
|
||||
#if OIIO_VERSION >= 10803
|
||||
template<typename... Args>
|
||||
inline void error (string_view fmt, const Args&... args) const {
|
||||
record_error(ErrorHandler::EH_ERROR, Strutil::format (fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warning (string_view fmt, const Args&... args) const {
|
||||
record_error(ErrorHandler::EH_WARNING, Strutil::format (fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info (string_view fmt, const Args&... args) const {
|
||||
record_error(ErrorHandler::EH_INFO, Strutil::format (fmt, args...));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void message (string_view fmt, const Args&... args) const {
|
||||
record_error(ErrorHandler::EH_MESSAGE, Strutil::format (fmt, args...));
|
||||
}
|
||||
#else
|
||||
TINYFORMAT_WRAP_FORMAT (void, error, const,
|
||||
std::ostringstream msg;, msg,
|
||||
record_error(ErrorHandler::EH_ERROR, msg.str());)
|
||||
@@ -1694,6 +1751,7 @@ public:
|
||||
TINYFORMAT_WRAP_FORMAT (void, message, const,
|
||||
std::ostringstream msg;, msg,
|
||||
record_error(ErrorHandler::EH_MESSAGE, msg.str());)
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
#include "oslexec_pvt.h"
|
||||
using namespace OSL;
|
||||
using namespace OSL::pvt;
|
||||
@@ -269,14 +271,20 @@ RendererServices::pointcloud_search (ShaderGlobals *sg,
|
||||
float *d_distance_dx = out_distances + derivs_offset;
|
||||
float *d_distance_dy = out_distances + derivs_offset * 2;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
d_distance_dx[i] = 1.0f / out_distances[i] *
|
||||
((center.x - positions[i].x) * dCdx.x +
|
||||
(center.y - positions[i].y) * dCdx.y +
|
||||
(center.z - positions[i].z) * dCdx.z);
|
||||
d_distance_dy[i] = 1.0f / out_distances[i] *
|
||||
((center.x - positions[i].x) * dCdy.x +
|
||||
(center.y - positions[i].y) * dCdy.y +
|
||||
(center.z - positions[i].z) * dCdy.z);
|
||||
if (out_distances[i] > 0) {
|
||||
d_distance_dx[i] = 1.0f / out_distances[i] *
|
||||
((center.x - positions[i].x) * dCdx.x +
|
||||
(center.y - positions[i].y) * dCdx.y +
|
||||
(center.z - positions[i].z) * dCdx.z);
|
||||
d_distance_dy[i] = 1.0f / out_distances[i] *
|
||||
((center.x - positions[i].x) * dCdy.x +
|
||||
(center.y - positions[i].y) * dCdy.y +
|
||||
(center.z - positions[i].z) * dCdy.z);
|
||||
} else {
|
||||
// distance is 0, derivs would be infinite which could cause trouble downstream
|
||||
d_distance_dx[i] = 0;
|
||||
d_distance_dy[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ RuntimeOptimizer::RuntimeOptimizer (ShadingSystemImpl &shadingsys,
|
||||
m_next_newconst(0), m_next_newtemp(0),
|
||||
m_stat_opt_locking_time(0), m_stat_specialization_time(0),
|
||||
m_stop_optimizing(false),
|
||||
m_raytypes_on(0), m_raytypes_off(0)
|
||||
m_raytypes_on(group.raytypes_on()), m_raytypes_off(group.raytypes_off())
|
||||
{
|
||||
memset (&m_shaderglobals, 0, sizeof(ShaderGlobals));
|
||||
m_shaderglobals.context = shadingcontext();
|
||||
@@ -1195,12 +1195,13 @@ RuntimeOptimizer::use_stale_sym (int sym)
|
||||
|
||||
|
||||
bool
|
||||
RuntimeOptimizer::is_simple_assign (Opcode &op)
|
||||
RuntimeOptimizer::is_simple_assign (Opcode &op, const OpDescriptor *opd)
|
||||
{
|
||||
// Simple only if arg0 is the only write, and is write only.
|
||||
if (op.argwrite_bits() != 1 || op.argread(0))
|
||||
return false;
|
||||
const OpDescriptor *opd = shadingsys().op_descriptor (op.opname());
|
||||
if (! opd)
|
||||
opd = shadingsys().op_descriptor (op.opname());
|
||||
if (!opd || !opd->simple_assign)
|
||||
return false; // reject all other known non-simple assignments
|
||||
// Make sure the result isn't also read
|
||||
@@ -2131,9 +2132,11 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
|
||||
if (op->argread(i))
|
||||
use_stale_sym (oparg(*op,i));
|
||||
}
|
||||
|
||||
const OpDescriptor *opd = shadingsys().op_descriptor (op->opname());
|
||||
// If it's a simple assignment and the lvalue is "stale", go
|
||||
// back and eliminate its last assignment.
|
||||
if (is_simple_assign(*op))
|
||||
if (is_simple_assign(*op, opd))
|
||||
simple_sym_assign (oparg (*op, 0), opnum);
|
||||
// Make sure there's room for several more symbols, so that we
|
||||
// can add a few consts if we need to, without worrying about
|
||||
@@ -2142,7 +2145,6 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
|
||||
// For various ops that we know how to effectively
|
||||
// constant-fold, dispatch to the appropriate routine.
|
||||
if (optimize() >= 2 && m_opt_constant_fold) {
|
||||
const OpDescriptor *opd = shadingsys().op_descriptor (op->opname());
|
||||
if (opd && opd->folder) {
|
||||
int c = (*opd->folder) (*this, opnum);
|
||||
if (c) {
|
||||
@@ -2163,7 +2165,8 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
|
||||
// Now we handle assignments.
|
||||
if (optimize() >= 2 && op->opname() == u_assign && m_opt_assign)
|
||||
changed += optimize_assignment (*op, opnum);
|
||||
if (optimize() >= 2 && m_opt_elide_useless_ops)
|
||||
if (optimize() >= 2 && m_opt_elide_useless_ops && opd
|
||||
&& !(opd->flags & OpDescriptor::SideEffects))
|
||||
changed += useless_op_elision (*op, opnum);
|
||||
if (m_stop_optimizing)
|
||||
break;
|
||||
|
||||
@@ -156,9 +156,17 @@ public:
|
||||
int turn_into_nop (int begin, int end, string_view why=NULL);
|
||||
|
||||
void debug_opt_impl (string_view message) const;
|
||||
#if OIIO_VERSION >= 10803
|
||||
template<typename... Args>
|
||||
inline void debug_opt (string_view fmt, const Args&... args) const {
|
||||
debug_opt_impl (Strutil::format (fmt, args...));
|
||||
}
|
||||
#else
|
||||
TINYFORMAT_WRAP_FORMAT (void, debug_opt, const,
|
||||
std::ostringstream msg;, msg,
|
||||
debug_opt_impl(msg.str());)
|
||||
#endif
|
||||
|
||||
void debug_opt_ops (int opbegin, int opend, string_view message) const;
|
||||
void debug_turn_into (const Opcode &op, int numops,
|
||||
string_view newop, int newarg0,
|
||||
@@ -239,7 +247,8 @@ public:
|
||||
|
||||
/// Is the op a "simple" assignment (arg 0 completely overwritten,
|
||||
/// no side effects or funny business)?
|
||||
bool is_simple_assign (Opcode &op);
|
||||
/// Optional OpDescriptor is passed to save an extra lookup.
|
||||
bool is_simple_assign (Opcode &op, const OpDescriptor *opd=NULL);
|
||||
|
||||
/// Called when symbol sym is "simply" assigned at the given op. An
|
||||
/// assignment is considered simple if it completely overwrites the
|
||||
|
||||
@@ -447,11 +447,19 @@ ShadingSystem::archive_shadergroup (ShaderGroup *group, string_view filename)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShadingSystem::set_raytypes (ShaderGroup *group, int raytypes_on, int raytypes_off)
|
||||
{
|
||||
DASSERT (group);
|
||||
group->set_raytypes(raytypes_on, raytypes_off);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShadingSystem::optimize_group (ShaderGroup *group)
|
||||
{
|
||||
optimize_group (group, 0, 0); // No knowledge of the ray flags
|
||||
DASSERT (group);
|
||||
m_impl->optimize_group (*group);
|
||||
}
|
||||
|
||||
|
||||
@@ -460,8 +468,10 @@ void
|
||||
ShadingSystem::optimize_group (ShaderGroup *group,
|
||||
int raytypes_on, int raytypes_off)
|
||||
{
|
||||
ASSERT (group);
|
||||
m_impl->optimize_group (*group, raytypes_on, raytypes_off);
|
||||
// convenience function for backwards compatibility
|
||||
set_raytypes (group, raytypes_on, raytypes_off);
|
||||
optimize_group (group);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -597,6 +607,7 @@ ustring cubic("cubic"), smartcubic("smartcubic");
|
||||
ustring perlin("perlin"), uperlin("uperlin");
|
||||
ustring noise("noise"), snoise("snoise");
|
||||
ustring cell("cell"), cellnoise("cellnoise"), pcellnoise("pcellnoise");
|
||||
ustring hash("hash"), hashnoise("hashnoise"), phashnoise("phashnoise");
|
||||
ustring pnoise("pnoise"), psnoise("psnoise");
|
||||
ustring genericnoise("genericnoise"), genericpnoise("genericpnoise");
|
||||
ustring gabor("gabor"), gabornoise("gabornoise"), gaborpnoise("gaborpnoise");
|
||||
@@ -632,6 +643,7 @@ ShadingSystemImpl::ShadingSystemImpl (RendererServices *renderer,
|
||||
m_lazy_userdata(false), m_userdata_isconnected(false),
|
||||
m_clearmemory (false), m_debugnan (false), m_debug_uninit(false),
|
||||
m_lockgeom_default (true), m_strict_messages(true),
|
||||
m_error_repeats(false),
|
||||
m_range_checking(true),
|
||||
m_unknown_coordsys_error(true), m_connection_error(true),
|
||||
m_greedyjit(false), m_countlayerexecs(false),
|
||||
@@ -783,6 +795,7 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
constfold_##fold, simp, flag);
|
||||
#define OP(name,ll,fold,simp,flag) OP2(name,name,ll,fold,simp,flag)
|
||||
#define TEX OpDescriptor::Tex
|
||||
#define SIDE OpDescriptor::SideEffects
|
||||
|
||||
// name llvmgen folder simple flags
|
||||
OP (aassign, aassign, aassign, false, 0);
|
||||
@@ -835,7 +848,7 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
OP (eq, compare_op, eq, true, 0);
|
||||
OP (erf, generic, erf, true, 0);
|
||||
OP (erfc, generic, erfc, true, 0);
|
||||
OP (error, printf, none, false, 0);
|
||||
OP (error, printf, none, false, SIDE);
|
||||
OP (exit, return, none, false, 0);
|
||||
OP (exp, generic, exp, true, 0);
|
||||
OP (exp2, generic, exp2, true, 0);
|
||||
@@ -855,6 +868,7 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
OP (gettextureinfo, gettextureinfo, gettextureinfo,false, TEX);
|
||||
OP (gt, compare_op, gt, true, 0);
|
||||
OP (hash, generic, hash, true, 0);
|
||||
OP (hashnoise, noise, noise, true, 0);
|
||||
OP (if, if, if, false, 0);
|
||||
OP (inversesqrt, generic, inversesqrt, true, 0);
|
||||
OP (isconnected, generic, none, true, 0);
|
||||
@@ -890,9 +904,9 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
OP (pointcloud_search, pointcloud_search, pointcloud_search,
|
||||
false, TEX);
|
||||
OP (pointcloud_get, pointcloud_get, pointcloud_get,false, TEX);
|
||||
OP (pointcloud_write, pointcloud_write, none, false, 0);
|
||||
OP (pointcloud_write, pointcloud_write, none, false, SIDE);
|
||||
OP (pow, generic, pow, true, 0);
|
||||
OP (printf, printf, none, false, 0);
|
||||
OP (printf, printf, none, false, SIDE);
|
||||
OP (psnoise, noise, noise, true, 0);
|
||||
OP (radians, generic, radians, true, 0);
|
||||
OP (raytype, raytype, raytype, true, 0);
|
||||
@@ -901,7 +915,7 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
OP (return, return, none, false, 0);
|
||||
OP (round, generic, none, true, 0);
|
||||
OP (select, select, select, true, 0);
|
||||
OP (setmessage, setmessage, setmessage, false, 0);
|
||||
OP (setmessage, setmessage, setmessage, false, SIDE);
|
||||
OP (shl, bitwise_binary_op, none, true, 0);
|
||||
OP (shr, bitwise_binary_op, none, true, 0);
|
||||
OP (sign, generic, none, true, 0);
|
||||
@@ -928,7 +942,7 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
OP (tanh, generic, none, true, 0);
|
||||
OP (texture, texture, texture, true, TEX);
|
||||
OP (texture3d, texture3d, none, true, TEX);
|
||||
OP (trace, trace, none, false, 0);
|
||||
OP (trace, trace, none, false, SIDE);
|
||||
OP (transform, transform, transform, true, 0);
|
||||
OP (transformn, transform, transform, true, 0);
|
||||
OP (transformv, transform, transform, true, 0);
|
||||
@@ -936,12 +950,13 @@ shading_system_setup_op_descriptors (ShadingSystemImpl::OpDescriptorMap& op_desc
|
||||
OP (trunc, generic, none, true, 0);
|
||||
OP (useparam, useparam, useparam, false, 0);
|
||||
OP (vector, construct_triple, triple, true, 0);
|
||||
OP (warning, printf, warning, false, 0);
|
||||
OP (warning, printf, warning, false, SIDE);
|
||||
OP (wavelength_color, blackbody, none, true, 0);
|
||||
OP (while, loop_op, none, false, 0);
|
||||
OP (xor, bitwise_binary_op, xor, true, 0);
|
||||
#undef OP
|
||||
#undef TEX
|
||||
#undef SIDE
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,6 +1135,14 @@ ShadingSystemImpl::attribute (string_view name, TypeDesc type,
|
||||
m_renderer_outputs.push_back (ustring(((const char **)val)[i]));
|
||||
return true;
|
||||
}
|
||||
if (name == "error_repeats") {
|
||||
// Special case: setting error_repeats also clears the "previously
|
||||
// seen" error and warning lists.
|
||||
m_errseen.clear();
|
||||
m_warnseen.clear();
|
||||
ATTR_SET ("error_repeats", int, m_error_repeats);
|
||||
}
|
||||
|
||||
return false;
|
||||
#undef ATTR_SET
|
||||
#undef ATTR_SET_STRING
|
||||
@@ -1143,6 +1166,7 @@ ShadingSystemImpl::getattribute (string_view name, TypeDesc type,
|
||||
}
|
||||
|
||||
lock_guard guard (m_mutex); // Thread safety
|
||||
|
||||
ATTR_DECODE_STRING ("searchpath:shader", m_searchpath);
|
||||
ATTR_DECODE ("statistics:level", int, m_statslevel);
|
||||
ATTR_DECODE ("lazylayers", int, m_lazylayers);
|
||||
@@ -1180,6 +1204,7 @@ ShadingSystemImpl::getattribute (string_view name, TypeDesc type,
|
||||
ATTR_DECODE ("llvm_debug_layers", int, m_llvm_debug_layers);
|
||||
ATTR_DECODE ("llvm_debug_ops", int, m_llvm_debug_ops);
|
||||
ATTR_DECODE ("strict_messages", int, m_strict_messages);
|
||||
ATTR_DECODE ("error_repeats", int, m_error_repeats);
|
||||
ATTR_DECODE ("range_checking", int, m_range_checking);
|
||||
ATTR_DECODE ("unknown_coordsys_error", int, m_unknown_coordsys_error);
|
||||
ATTR_DECODE ("connection_error", int, m_connection_error);
|
||||
@@ -1491,7 +1516,7 @@ ShadingSystemImpl::error (const std::string &msg) const
|
||||
lock_guard guard (m_errmutex);
|
||||
int n = 0;
|
||||
BOOST_FOREACH (std::string &s, m_errseen) {
|
||||
if (s == msg)
|
||||
if (s == msg && !m_error_repeats)
|
||||
return;
|
||||
++n;
|
||||
}
|
||||
@@ -1509,7 +1534,7 @@ ShadingSystemImpl::warning (const std::string &msg) const
|
||||
lock_guard guard (m_errmutex);
|
||||
int n = 0;
|
||||
BOOST_FOREACH (std::string &s, m_warnseen) {
|
||||
if (s == msg)
|
||||
if (s == msg && !m_error_repeats)
|
||||
return;
|
||||
++n;
|
||||
}
|
||||
@@ -1602,6 +1627,7 @@ ShadingSystemImpl::getstats (int level) const
|
||||
BOOLOPT (debug_uninit);
|
||||
BOOLOPT (lockgeom_default);
|
||||
BOOLOPT (strict_messages);
|
||||
BOOLOPT (error_repeats);
|
||||
BOOLOPT (range_checking);
|
||||
BOOLOPT (greedyjit);
|
||||
BOOLOPT (countlayerexecs);
|
||||
@@ -2603,8 +2629,7 @@ ShadingSystemImpl::group_post_jit_cleanup (ShaderGroup &group)
|
||||
|
||||
|
||||
void
|
||||
ShadingSystemImpl::optimize_group (ShaderGroup &group,
|
||||
int raytypes_on, int raytypes_off)
|
||||
ShadingSystemImpl::optimize_group (ShaderGroup &group)
|
||||
{
|
||||
if (group.optimized())
|
||||
return; // already optimized
|
||||
@@ -2640,7 +2665,6 @@ ShadingSystemImpl::optimize_group (ShaderGroup &group,
|
||||
|
||||
ShadingContext *ctx = get_context ();
|
||||
RuntimeOptimizer rop (*this, group, ctx);
|
||||
rop.set_raytypes (raytypes_on, raytypes_off);
|
||||
rop.run ();
|
||||
|
||||
// Copy some info recorted by the RuntimeOptimizer into the group
|
||||
|
||||
@@ -191,20 +191,20 @@ void spline_inverse (const SplineBasis *spline,
|
||||
// account for out-of-range inputs, just clamp to the values we have
|
||||
bool increasing = knots[1] < knots[knot_count-2];
|
||||
if (increasing) {
|
||||
if (y < knots[1]) {
|
||||
if (y <= knots[1]) {
|
||||
x = YTYPE(0);
|
||||
return;
|
||||
}
|
||||
if (y > knots[knot_count-2]) {
|
||||
if (y >= knots[knot_count-2]) {
|
||||
x = YTYPE(1);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (y > knots[1]) {
|
||||
if (y >= knots[1]) {
|
||||
x = YTYPE(0);
|
||||
return;
|
||||
}
|
||||
if (y < knots[knot_count-2]) {
|
||||
if (y <= knots[knot_count-2]) {
|
||||
x = YTYPE(1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,44 @@ TypeSpec::TypeSpec (const char *name, int structid, int arraylen)
|
||||
|
||||
|
||||
|
||||
std::string
|
||||
TypeSpec::string () const
|
||||
{
|
||||
std::string str;
|
||||
if (is_closure() || is_closure_array()) {
|
||||
str += "closure color";
|
||||
if (is_unsized_array())
|
||||
str += "[]";
|
||||
else if (arraylength() > 0)
|
||||
str += Strutil::format ("[%d]", arraylength());
|
||||
}
|
||||
else if (structure() > 0) {
|
||||
StructSpec *ss = structspec();
|
||||
if (ss)
|
||||
str += Strutil::format ("struct %s", structspec()->name());
|
||||
else
|
||||
str += Strutil::format ("struct %d", structure());
|
||||
if (is_unsized_array())
|
||||
str += "[]";
|
||||
else if (arraylength() > 0)
|
||||
str += Strutil::format ("[%d]", arraylength());
|
||||
} else {
|
||||
str += simpletype().c_str();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
TypeSpec::c_str () const
|
||||
{
|
||||
ustring s (this->string());
|
||||
return s.c_str ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
TypeSpec::structure_id (const char *name, bool add)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,10 @@ if (BUILDSTATIC)
|
||||
ADD_LIBRARY ( oslnoise STATIC ${liboslnoise_srcs} )
|
||||
else ()
|
||||
ADD_LIBRARY ( oslnoise SHARED ${liboslnoise_srcs} )
|
||||
set_target_properties( oslnoise
|
||||
PROPERTIES
|
||||
VERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION} )
|
||||
endif ()
|
||||
|
||||
TARGET_LINK_LIBRARIES ( oslnoise ${OPENIMAGEIO_LIBRARY} ${ILMBASE_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
|
||||
|
||||
@@ -272,7 +272,6 @@ test_cell ()
|
||||
};
|
||||
|
||||
for (int i = 0; i < 2*N; ++i) {
|
||||
// Signed perlin noise
|
||||
float x = 0.5f + float(i)/float(N);
|
||||
Vec3 p (x, x, x);
|
||||
float t = x;
|
||||
@@ -318,6 +317,81 @@ test_cell ()
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_hash ()
|
||||
{
|
||||
const int N = 1;
|
||||
static float results_1d[2*N+1] = {
|
||||
0.983315, 0.914303
|
||||
};
|
||||
static float results_2d[2*N+1] = {
|
||||
0.716016, 0.360764
|
||||
};
|
||||
static float results_3d[2*N+1] = {
|
||||
0.311887, 0.273953
|
||||
};
|
||||
static float results_4d[2*N+1] = {
|
||||
0.480826, 0.84257
|
||||
};
|
||||
static Vec3 vresults_1d[2*N+1] = {
|
||||
Vec3(0.253513, 0.658608, 0.718555), Vec3(0.673784, 0.825515, 0.827693)
|
||||
};
|
||||
static Vec3 vresults_2d[2*N+1] = {
|
||||
Vec3(0.172726, 0.779528, 0.780237), Vec3(0.431263, 0.443849, 0.592155)
|
||||
};
|
||||
static Vec3 vresults_3d[2*N+1] = {
|
||||
Vec3(0.59078, 0.79799, 0.0202766), Vec3(0.593547, 0.156555, 0.978352)
|
||||
};
|
||||
static Vec3 vresults_4d[2*N+1] = {
|
||||
Vec3(0.297735, 0.240833, 0.386421), Vec3(0.642915, 0.367309, 0.879035)
|
||||
};
|
||||
|
||||
for (int i = 0; i < 2*N; ++i) {
|
||||
float x = 0.5f + float(i)/float(N);
|
||||
Vec3 p (x, x, x);
|
||||
float t = x;
|
||||
float s1 = hashnoise (x);
|
||||
float s2 = hashnoise (x, x);
|
||||
float s3 = hashnoise (p);
|
||||
float s4 = hashnoise (p, t);
|
||||
// std::cerr << s4 << ", ";
|
||||
OIIO_CHECK_EQUAL_THRESH (s1, results_1d[i], eps);
|
||||
OIIO_CHECK_EQUAL_THRESH (s2, results_2d[i], eps);
|
||||
OIIO_CHECK_EQUAL_THRESH (s3, results_3d[i], eps);
|
||||
OIIO_CHECK_EQUAL_THRESH (s4, results_4d[i], eps);
|
||||
|
||||
// Test vector variety
|
||||
Vec3 vs1 = vhashnoise (x);
|
||||
Vec3 vs2 = vhashnoise (x, x);
|
||||
Vec3 vs3 = vhashnoise (p);
|
||||
Vec3 vs4 = vhashnoise (p, t);
|
||||
// std::cerr << "Vec3" << vs4 << ",";
|
||||
OIIO_CHECK_EQUAL_THRESH (vs1, vresults_1d[i], eps);
|
||||
OIIO_CHECK_EQUAL_THRESH (vs2, vresults_2d[i], eps);
|
||||
OIIO_CHECK_EQUAL_THRESH (vs3, vresults_3d[i], eps);
|
||||
OIIO_CHECK_EQUAL_THRESH (vs4, vresults_4d[i], eps);
|
||||
}
|
||||
|
||||
if (make_images) {
|
||||
MAKE_IMAGE (hashnoise);
|
||||
}
|
||||
|
||||
#if DO_BENCHMARKS
|
||||
// Time trials
|
||||
benchmark1 ("hashnoise(f) ", hashnoise<float>, 0.5f);
|
||||
benchmark2 ("hashnoise(f,f) ", hashnoise<float,float>, 0.5f, 0.5f);
|
||||
benchmark1 ("hashnoise(v) ", hashnoise<const Vec3&>, Vec3(0,0,0));
|
||||
benchmark2 ("hashnoise(v,f) ", hashnoise<const Vec3&,float>, Vec3(0,0,0), 0.5f);
|
||||
|
||||
benchmark1 ("vhashnoise(f) ", vhashnoise<float>, 0.5f);
|
||||
benchmark2 ("vhashnoise(f,f)", vhashnoise<float,float>, 0.5f, 0.5f);
|
||||
benchmark1 ("vhashnoise(v) ", vhashnoise<const Vec3&>, Vec3(0,0,0));
|
||||
benchmark2 ("vhashnoise(v,f)", vhashnoise<const Vec3&,float>, Vec3(0,0,0), 0.5f);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
getargs (int argc, const char *argv[])
|
||||
{
|
||||
@@ -349,10 +423,19 @@ getargs (int argc, const char *argv[])
|
||||
int
|
||||
main (int argc, char const *argv[])
|
||||
{
|
||||
#if !defined(NDEBUG) || defined(OIIO_CI) || defined(OIIO_CODE_COVERAGE)
|
||||
// For the sake of test time, reduce the default iterations for DEBUG,
|
||||
// CI, and code coverage builds. Explicit use of --iters or --trials
|
||||
// will override this, since it comes before the getargs() call.
|
||||
iterations /= 10;
|
||||
ntrials = 1;
|
||||
#endif
|
||||
|
||||
getargs (argc, argv);
|
||||
|
||||
test_perlin ();
|
||||
test_cell ();
|
||||
test_hash ();
|
||||
|
||||
return unit_test_failures;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ if (BUILDSTATIC)
|
||||
ADD_LIBRARY ( oslquery STATIC ${liboslquery_srcs} )
|
||||
else ()
|
||||
ADD_LIBRARY ( oslquery SHARED ${liboslquery_srcs} )
|
||||
set_target_properties( oslquery
|
||||
PROPERTIES
|
||||
VERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION} )
|
||||
endif ()
|
||||
|
||||
TARGET_LINK_LIBRARIES ( oslquery ${OPENIMAGEIO_LIBRARY} ${ILMBASE_LIBRARIES} ${Boost_LIBRARIES} )
|
||||
|
||||
@@ -37,6 +37,10 @@ macro (add_oiio_plugin)
|
||||
add_library (${_target_name} SHARED ${_plugin_DEFAULT_ARGS})
|
||||
target_link_libraries (${_target_name} ${OPENIMAGEIO_LIBRARY} ${_plugin_LINK_LIBRARIES})
|
||||
set_target_properties (${_target_name} PROPERTIES PREFIX "" FOLDER "Plugins")
|
||||
set_target_properties( ${_target_name}
|
||||
PROPERTIES
|
||||
VERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION} )
|
||||
oiio_install_targets (${_target_name})
|
||||
endmacro ()
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ public:
|
||||
virtual bool close ();
|
||||
virtual int current_subimage (void) const { return m_subimage; }
|
||||
virtual int current_miplevel (void) const { return m_miplevel; }
|
||||
#if OIIO_PLUGIN_VERSION < 21 /* OIIO < 1.9 */
|
||||
virtual bool seek_subimage (int subimage, int miplevel, ImageSpec &newspec);
|
||||
virtual bool read_native_scanline (int y, int z, void *data);
|
||||
virtual bool read_native_scanlines (int ybegin, int yend, int z,
|
||||
@@ -110,6 +111,19 @@ public:
|
||||
virtual bool read_native_tile (int x, int y, int z, void *data);
|
||||
virtual bool read_native_tiles (int xbegin, int xend, int ybegin, int yend,
|
||||
int zbegin, int zend, void *data);
|
||||
#else
|
||||
virtual bool seek_subimage (int subimage, int miplevel);
|
||||
virtual bool read_native_scanline (int subimage, int miplevel,
|
||||
int y, int z, void *data);
|
||||
virtual bool read_native_scanlines (int subimage, int miplevel,
|
||||
int ybegin, int yend, int z,
|
||||
void *data);
|
||||
virtual bool read_native_tile (int subimage, int miplevel,
|
||||
int x, int y, int z, void *data);
|
||||
virtual bool read_native_tiles (int subimage, int miplevel,
|
||||
int xbegin, int xend, int ybegin, int yend,
|
||||
int zbegin, int zend, void *data);
|
||||
#endif
|
||||
private:
|
||||
std::string m_filename; ///< Stash the filename
|
||||
ShaderGroupRef m_group;
|
||||
@@ -227,7 +241,7 @@ static ErrorRecorder errhandler;
|
||||
static void
|
||||
setup_shadingsys ()
|
||||
{
|
||||
lock_guard lock (shading_mutex);
|
||||
OIIO::lock_guard lock (shading_mutex);
|
||||
if (! shadingsys) {
|
||||
renderer = new OIIO_RendererServices (TextureSystem::create(true));
|
||||
shadingsys = new ShadingSystem (renderer, NULL, &errhandler);
|
||||
@@ -490,14 +504,14 @@ OSLInput::open (const std::string &name, ImageSpec &newspec,
|
||||
}
|
||||
// std::cout << "Processing group specification:\n---\n"
|
||||
// << groupspec << "\n---\n";
|
||||
lock_guard lock (shading_mutex);
|
||||
OIIO::lock_guard lock (shading_mutex);
|
||||
m_group = shadingsys->ShaderGroupBegin ("", "surface", groupspec);
|
||||
if (! m_group)
|
||||
return false; // Failed
|
||||
shadingsys->ShaderGroupEnd ();
|
||||
}
|
||||
if (Strutil::ends_with (shadername, ".oso")) { // Compiled shader
|
||||
lock_guard lock (shading_mutex);
|
||||
OIIO::lock_guard lock (shading_mutex);
|
||||
shadername.remove_suffix (4);
|
||||
m_group = shadingsys->ShaderGroupBegin ();
|
||||
for (size_t p = 0, np = m_topspec.extra_attribs.size(); p < np; ++p) {
|
||||
@@ -515,7 +529,7 @@ OSLInput::open (const std::string &name, ImageSpec &newspec,
|
||||
if (Strutil::ends_with (shadername, ".osl")) { // shader source
|
||||
}
|
||||
if (Strutil::ends_with (shadername, ".oslbody")) { // shader source
|
||||
lock_guard lock (shading_mutex);
|
||||
OIIO::lock_guard lock (shading_mutex);
|
||||
shadername.remove_suffix (8);
|
||||
static int exprcount = 0;
|
||||
std::string exprname = OIIO::Strutil::format("expr_%d", exprcount++);
|
||||
@@ -554,7 +568,16 @@ OSLInput::open (const std::string &name, ImageSpec &newspec,
|
||||
TypeDesc(TypeDesc::STRING,m_outputs.size()),
|
||||
&m_outputs[0]);
|
||||
|
||||
#if OIIO_PLUGIN_VERSION < 21
|
||||
return ok && seek_subimage (0, 0, newspec);
|
||||
#else
|
||||
ok &= seek_subimage (0, 0);
|
||||
if (ok)
|
||||
newspec = spec();
|
||||
else
|
||||
close ();
|
||||
return ok;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -569,10 +592,16 @@ OSLInput::close ()
|
||||
|
||||
|
||||
bool
|
||||
OSLInput::seek_subimage (int subimage, int miplevel, ImageSpec &newspec)
|
||||
OSLInput::seek_subimage (int subimage, int miplevel
|
||||
#if OIIO_PLUGIN_VERSION < 21
|
||||
, ImageSpec &newspec
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (subimage == current_subimage() && miplevel == current_miplevel()) {
|
||||
#if OIIO_PLUGIN_VERSION < 21
|
||||
newspec = spec();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -593,15 +622,27 @@ OSLInput::seek_subimage (int subimage, int miplevel, ImageSpec &newspec)
|
||||
m_spec.full_height = m_spec.height;
|
||||
m_spec.full_depth = m_spec.depth;
|
||||
}
|
||||
#if OIIO_PLUGIN_VERSION < 21
|
||||
newspec = spec();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
OSLInput::read_native_scanlines (int ybegin, int yend, int z, void *data)
|
||||
OSLInput::read_native_scanlines (
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
int subimage, int miplevel,
|
||||
#endif
|
||||
int ybegin, int yend, int z, void *data)
|
||||
{
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
lock_guard lock (m_mutex);
|
||||
if (! seek_subimage (subimage, miplevel))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// Create an ImageBuf wrapper of the user's data
|
||||
ImageSpec spec = m_spec; // Make a spec that describes just this scanline
|
||||
spec.y = ybegin;
|
||||
@@ -622,17 +663,35 @@ OSLInput::read_native_scanlines (int ybegin, int yend, int z, void *data)
|
||||
|
||||
|
||||
bool
|
||||
OSLInput::read_native_scanline (int y, int z, void *data)
|
||||
OSLInput::read_native_scanline (
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
int subimage, int miplevel,
|
||||
#endif
|
||||
int y, int z, void *data)
|
||||
{
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
return read_native_scanlines (subimage, miplevel, y, y+1, z, data);
|
||||
#else
|
||||
return read_native_scanlines (y, y+1, z, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
OSLInput::read_native_tiles (int xbegin, int xend, int ybegin, int yend,
|
||||
OSLInput::read_native_tiles (
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
int subimage, int miplevel,
|
||||
#endif
|
||||
int xbegin, int xend, int ybegin, int yend,
|
||||
int zbegin, int zend, void *data)
|
||||
{
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
lock_guard lock (m_mutex);
|
||||
if (! seek_subimage (subimage, miplevel))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// Create an ImageBuf wrapper of the user's data
|
||||
ImageSpec spec = m_spec; // Make a spec that describes just this scanline
|
||||
spec.x = xbegin;
|
||||
@@ -655,10 +714,24 @@ OSLInput::read_native_tiles (int xbegin, int xend, int ybegin, int yend,
|
||||
|
||||
|
||||
bool
|
||||
OSLInput::read_native_tile (int x, int y, int z, void *data)
|
||||
OSLInput::read_native_tile (
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
int subimage, int miplevel,
|
||||
#endif
|
||||
int x, int y, int z, void *data)
|
||||
{
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
lock_guard lock (m_mutex);
|
||||
if (! seek_subimage (subimage, miplevel))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return
|
||||
read_native_tiles (x, std::min (x+m_spec.tile_width, m_spec.x+m_spec.width),
|
||||
read_native_tiles (
|
||||
#if OIIO_PLUGIN_VERSION >= 21
|
||||
subimage, miplevel,
|
||||
#endif
|
||||
x, std::min (x+m_spec.tile_width, m_spec.x+m_spec.width),
|
||||
y, std::min (y+m_spec.tile_height, m_spec.y+m_spec.height),
|
||||
z, std::min (z+m_spec.tile_depth, m_spec.z+m_spec.depth),
|
||||
data);
|
||||
|
||||
@@ -165,6 +165,9 @@ color mix (color x, color y, color a) BUILTIN;
|
||||
color mix (color x, color y, float a) BUILTIN;
|
||||
float mix (float x, float y, float a) BUILTIN;
|
||||
#endif
|
||||
closure color mix (closure color x, closure color y, float a) { return x*(1-a) + y*a; }
|
||||
closure color mix (closure color x, closure color y, color a) { return x*(1-a) + y*a; }
|
||||
|
||||
normal select (normal x, normal y, normal cond) BUILTIN;
|
||||
vector select (vector x, vector y, vector cond) BUILTIN;
|
||||
point select (point x, point y, point cond) BUILTIN;
|
||||
@@ -202,8 +205,14 @@ float distance (point a, point b, point q)
|
||||
}
|
||||
normal normalize (normal v) BUILTIN;
|
||||
vector normalize (vector v) BUILTIN;
|
||||
vector faceforward (vector N, vector I, vector Nref) BUILTIN;
|
||||
vector faceforward (vector N, vector I) BUILTIN;
|
||||
vector faceforward (vector N, vector I, vector Nref)
|
||||
{
|
||||
return (dot(I, Nref) > 0) ? -N : N;
|
||||
}
|
||||
vector faceforward (vector N, vector I)
|
||||
{
|
||||
return faceforward(N, I, Ng);
|
||||
}
|
||||
vector reflect (vector I, vector N) { return I - 2*dot(N,I)*N; }
|
||||
vector refract (vector I, vector N, float eta) {
|
||||
float IdotN = dot (I, N);
|
||||
@@ -434,6 +443,19 @@ normal step (normal edge, normal x) BUILTIN;
|
||||
float step (float edge, float x) BUILTIN;
|
||||
float smoothstep (float edge0, float edge1, float x) BUILTIN;
|
||||
|
||||
color smoothstep (color edge0, color edge1, color in)
|
||||
{
|
||||
return color (smoothstep(edge0[0], edge1[0], in[0]),
|
||||
smoothstep(edge0[1], edge1[1], in[1]),
|
||||
smoothstep(edge0[2], edge1[2], in[2]));
|
||||
}
|
||||
vector smoothstep (vector edge0, vector edge1, vector in)
|
||||
{
|
||||
return vector (smoothstep(edge0[0], edge1[0], in[0]),
|
||||
smoothstep(edge0[1], edge1[1], in[1]),
|
||||
smoothstep(edge0[2], edge1[2], in[2]));
|
||||
}
|
||||
|
||||
float linearstep (float edge0, float edge1, float x) {
|
||||
float result;
|
||||
if (edge0 != edge1) {
|
||||
@@ -478,6 +500,14 @@ float aastep (float edge, float s) {
|
||||
}
|
||||
|
||||
|
||||
// Noise and related functions
|
||||
|
||||
int hash (int u) BUILTIN;
|
||||
int hash (float u) BUILTIN;
|
||||
int hash (float u, float v) BUILTIN;
|
||||
int hash (point p) BUILTIN;
|
||||
int hash (point p, float t) BUILTIN;
|
||||
|
||||
// Derivatives and area operators
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# The 'testrender' executable
|
||||
FILE(GLOB testrender_src *.cpp)
|
||||
ADD_EXECUTABLE ( testrender ${testrender_src} )
|
||||
TARGET_LINK_LIBRARIES ( testrender oslexec oslcomp oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
TARGET_LINK_LIBRARIES ( testrender oslexec oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
INSTALL ( TARGETS testrender RUNTIME DESTINATION bin )
|
||||
|
||||
@@ -51,6 +51,7 @@ SimpleRenderer::SimpleRenderer ()
|
||||
0.1f, 1000.0f, 256, 256);
|
||||
|
||||
// Set up getters
|
||||
m_attr_getters[ustring("osl:version")] = &SimpleRenderer::get_osl_version;
|
||||
m_attr_getters[ustring("camera:resolution")] = &SimpleRenderer::get_camera_resolution;
|
||||
m_attr_getters[ustring("camera:projection")] = &SimpleRenderer::get_camera_projection;
|
||||
m_attr_getters[ustring("camera:pixelaspect")] = &SimpleRenderer::get_camera_pixelaspect;
|
||||
@@ -280,6 +281,18 @@ SimpleRenderer::get_userdata (bool derivatives, ustring name, TypeDesc type,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SimpleRenderer::get_osl_version (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val)
|
||||
{
|
||||
if (type == TypeDesc::TypeInt) {
|
||||
((int *)val)[0] = OSL_VERSION;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SimpleRenderer::get_camera_resolution (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val)
|
||||
|
||||
@@ -98,6 +98,8 @@ private:
|
||||
AttrGetterMap m_attr_getters;
|
||||
|
||||
// Attribute getters
|
||||
bool get_osl_version (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val);
|
||||
bool get_camera_resolution (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val);
|
||||
bool get_camera_projection (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
|
||||
@@ -57,7 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "util.h"
|
||||
|
||||
|
||||
using namespace OIIO;
|
||||
using namespace OSL;
|
||||
|
||||
namespace { // anonymous namespace
|
||||
@@ -236,6 +235,9 @@ void parse_scene() {
|
||||
}
|
||||
text.push_back(0); // make sure text ends with trailing 0
|
||||
|
||||
#ifdef USING_OIIO_PUGI
|
||||
namespace pugi = OIIO::pugi;
|
||||
#endif
|
||||
// build DOM tree
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result parse_result = doc.load_file(scenefile.c_str());
|
||||
@@ -585,6 +587,7 @@ void scanline_worker(Counter& counter, std::vector<Color3>& pixels) {
|
||||
} // anonymous namespace
|
||||
|
||||
int main (int argc, const char *argv[]) {
|
||||
using namespace OIIO;
|
||||
Timer timer;
|
||||
|
||||
// Create a new shading system. We pass it the RendererServices
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# The 'testshade' executable
|
||||
SET ( testshade_srcs testshade.cpp simplerend.cpp )
|
||||
ADD_EXECUTABLE ( testshade ${testshade_srcs} testshademain.cpp )
|
||||
TARGET_LINK_LIBRARIES ( testshade oslexec oslcomp oslquery ${OPENIMAGEIO_LIBRARY} ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
TARGET_LINK_LIBRARIES ( testshade oslexec oslquery ${OPENIMAGEIO_LIBRARY} ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
INSTALL ( TARGETS testshade RUNTIME DESTINATION bin )
|
||||
|
||||
# The 'libtestshade' library
|
||||
@@ -9,9 +9,13 @@ if (BUILDSTATIC)
|
||||
ADD_LIBRARY ( "libtestshade" STATIC ${testshade_srcs} )
|
||||
else ()
|
||||
ADD_LIBRARY ( "libtestshade" SHARED ${testshade_srcs} )
|
||||
set_target_properties( libtestshade
|
||||
PROPERTIES
|
||||
VERSION ${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}
|
||||
SOVERSION ${SOVERSION} )
|
||||
endif ()
|
||||
|
||||
TARGET_LINK_LIBRARIES (libtestshade oslexec oslcomp oslquery ${OPENIMAGEIO_LIBRARY} ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
|
||||
TARGET_LINK_LIBRARIES (libtestshade oslexec oslquery ${OPENIMAGEIO_LIBRARY} ${OPENEXR_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
|
||||
SET_TARGET_PROPERTIES (libtestshade PROPERTIES PREFIX "")
|
||||
|
||||
INSTALL ( TARGETS libtestshade RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
||||
|
||||
@@ -150,6 +150,7 @@ SimpleRenderer::SimpleRenderer ()
|
||||
0.1f, 1000.0f, 256, 256);
|
||||
|
||||
// Set up getters
|
||||
m_attr_getters[ustring("osl:version")] = &SimpleRenderer::get_osl_version;
|
||||
m_attr_getters[ustring("camera:resolution")] = &SimpleRenderer::get_camera_resolution;
|
||||
m_attr_getters[ustring("camera:projection")] = &SimpleRenderer::get_camera_projection;
|
||||
m_attr_getters[ustring("camera:pixelaspect")] = &SimpleRenderer::get_camera_pixelaspect;
|
||||
@@ -387,6 +388,18 @@ SimpleRenderer::get_userdata (bool derivatives, ustring name, TypeDesc type,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SimpleRenderer::get_osl_version (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val)
|
||||
{
|
||||
if (type == TypeDesc::TypeInt) {
|
||||
((int *)val)[0] = OSL_VERSION;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SimpleRenderer::get_camera_resolution (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val)
|
||||
|
||||
@@ -101,6 +101,8 @@ private:
|
||||
AttrGetterMap m_attr_getters;
|
||||
|
||||
// Attribute getters
|
||||
bool get_osl_version (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val);
|
||||
bool get_camera_resolution (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
TypeDesc type, ustring name, void *val);
|
||||
bool get_camera_projection (ShaderGlobals *sg, bool derivs, ustring object,
|
||||
|
||||
@@ -79,6 +79,7 @@ static bool do_oslquery = false;
|
||||
static bool inbuffer = false;
|
||||
static bool use_shade_image = false;
|
||||
static bool userdata_isconnected = false;
|
||||
static bool print_outputs = false;
|
||||
static int xres = 1, yres = 1;
|
||||
static int num_threads = 0;
|
||||
static std::string groupname;
|
||||
@@ -101,8 +102,8 @@ static ShaderGroupRef shadergroup;
|
||||
static std::string archivegroup;
|
||||
static int exprcount = 0;
|
||||
static bool shadingsys_options_set = false;
|
||||
static float sscale = 1, tscale = 1;
|
||||
static float soffset = 0, toffset = 0;
|
||||
static float uscale = 1, vscale = 1;
|
||||
static float uoffset = 0, voffset = 0;
|
||||
|
||||
|
||||
|
||||
@@ -226,6 +227,17 @@ add_shader (int argc, const char *argv[])
|
||||
|
||||
|
||||
|
||||
static void
|
||||
action_shaderdecl (int argc, const char *argv[])
|
||||
{
|
||||
// `--shader shadername layername` is exactly equivalent to:
|
||||
// `--layer layername` followed by naming the shader.
|
||||
layername = argv[2];
|
||||
add_shader (1, argv+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The --expr ARG command line option will take ARG that is a snipped of
|
||||
// OSL source code, embed it in some boilerplate shader wrapper, compile
|
||||
// it from memory, and run that in the same way that would have been done
|
||||
@@ -448,12 +460,16 @@ getargs (int argc, const char *argv[])
|
||||
"--options %s", &extraoptions, "Set extra OSL options",
|
||||
"-o %L %L", &outputvars, &outputfiles,
|
||||
"Output (variable, filename)",
|
||||
"-od %s", &dataformatname, "Set the output data format to one of: "
|
||||
"-d %s", &dataformatname, "Set the output data format to one of: "
|
||||
"uint8, half, float",
|
||||
"-od %s", &dataformatname, "", // old name
|
||||
"--print", &print_outputs, "Print values of all -o outputs to console instead of saving images",
|
||||
"--groupname %s", &groupname, "Set shader group name",
|
||||
"--layer %s", &layername, "Set next layer name",
|
||||
"--param %@ %s %s", &action_param, NULL, NULL,
|
||||
"Add a parameter (args: name value) (options: type=%s, lockgeom=%d)",
|
||||
"--shader %@ %s %s", &action_shaderdecl, NULL, NULL,
|
||||
"Declare a shader node (args: shader layername)",
|
||||
"--connect %L %L %L %L",
|
||||
&connections, &connections, &connections, &connections,
|
||||
"Connect fromlayer fromoutput tolayer toinput",
|
||||
@@ -480,8 +496,10 @@ getargs (int argc, const char *argv[])
|
||||
"--shadeimage", &use_shade_image, "Use shade_image utility",
|
||||
"--noshadeimage %!", &use_shade_image, "Don't use shade_image utility",
|
||||
"--expr %@ %s", &specify_expr, NULL, "Specify an OSL expression to evaluate",
|
||||
"--offsetst %f %f", &soffset, &toffset, "Offset s & t texture coordinates (default: 0 0)",
|
||||
"--scalest %f %f", &sscale, &tscale, "Scale s & t texture lookups (default: 1, 1)",
|
||||
"--offsetuv %f %f", &uoffset, &voffset, "Offset s & t texture coordinates (default: 0 0)",
|
||||
"--offsetst %f %f", &uoffset, &voffset, "", // old name
|
||||
"--scaleuv %f %f", &uscale, &vscale, "Scale s & t texture lookups (default: 1, 1)",
|
||||
"--scalest %f %f", &uscale, &vscale, "", // old name
|
||||
"--userdata_isconnected", &userdata_isconnected, "Consider lockgeom=0 to be isconnected()",
|
||||
"-v", &verbose, "Verbose output",
|
||||
NULL);
|
||||
@@ -571,17 +589,17 @@ setup_shaderglobals (ShaderGlobals &sg, ShadingSystem *shadingsys,
|
||||
if (pixelcenters) {
|
||||
// Our patch is like an "image" with shading samples at the
|
||||
// centers of each pixel.
|
||||
sg.u = sscale * (float)(x+0.5f) / xres + soffset;
|
||||
sg.v = tscale * (float)(y+0.5f) / yres + toffset;
|
||||
sg.dudx = sscale / xres;
|
||||
sg.dvdy = tscale / yres;
|
||||
sg.u = uscale * (float)(x+0.5f) / xres + uoffset;
|
||||
sg.v = vscale * (float)(y+0.5f) / yres + voffset;
|
||||
sg.dudx = uscale / xres;
|
||||
sg.dvdy = vscale / yres;
|
||||
} else {
|
||||
// Our patch is like a Reyes grid of points, with the border
|
||||
// samples being exactly on u,v == 0 or 1.
|
||||
sg.u = sscale * ((xres == 1) ? 0.5f : (float) x / (xres - 1)) + soffset;
|
||||
sg.v = tscale * ((yres == 1) ? 0.5f : (float) y / (yres - 1)) + toffset;
|
||||
sg.dudx = sscale / std::max (1, xres-1);
|
||||
sg.dvdy = tscale / std::max (1, yres-1);
|
||||
sg.u = uscale * ((xres == 1) ? 0.5f : (float) x / (xres - 1)) + uoffset;
|
||||
sg.v = vscale * ((yres == 1) ? 0.5f : (float) y / (yres - 1)) + voffset;
|
||||
sg.dudx = uscale / std::max (1, xres-1);
|
||||
sg.dvdy = vscale / std::max (1, yres-1);
|
||||
}
|
||||
|
||||
// Assume that position P is simply (u,v,1), that makes the patch lie
|
||||
@@ -742,6 +760,8 @@ setup_output_images (ShadingSystem *shadingsys,
|
||||
static void
|
||||
save_outputs (ShadingSystem *shadingsys, ShadingContext *ctx, int x, int y)
|
||||
{
|
||||
if (print_outputs)
|
||||
printf ("Pixel (%d, %d):\n", x, y);
|
||||
// For each output requested on the command line...
|
||||
for (size_t i = 0; i < outputfiles.size(); ++i) {
|
||||
// Skip if we couldn't open the image or didn't match a known output
|
||||
@@ -755,18 +775,30 @@ save_outputs (ShadingSystem *shadingsys, ShadingContext *ctx, int x, int y)
|
||||
if (!data)
|
||||
continue; // Skip if symbol isn't found
|
||||
|
||||
int nchans = outputimgs[i]->nchannels();
|
||||
if (t.basetype == TypeDesc::FLOAT) {
|
||||
// If the variable we are outputting is float-based, set it
|
||||
// directly in the output buffer.
|
||||
outputimgs[i]->setpixel (x, y, (const float *)data);
|
||||
if (print_outputs) {
|
||||
printf (" %s :", outputvarnames[i].c_str());
|
||||
for (int c = 0; c < nchans; ++c)
|
||||
printf (" %g", ((const float *)data)[c]);
|
||||
printf ("\n");
|
||||
}
|
||||
} else if (t.basetype == TypeDesc::INT) {
|
||||
// We are outputting an integer variable, so we need to
|
||||
// convert it to floating point.
|
||||
int nchans = outputimgs[i]->nchannels();
|
||||
float *pixel = (float *) alloca (nchans * sizeof(float));
|
||||
OIIO::convert_types (TypeDesc::BASETYPE(t.basetype), data,
|
||||
TypeDesc::FLOAT, pixel, nchans);
|
||||
outputimgs[i]->setpixel (x, y, &pixel[0]);
|
||||
if (print_outputs) {
|
||||
printf (" %s :", outputvarnames[i].c_str());
|
||||
for (int c = 0; c < nchans; ++c)
|
||||
printf (" %d", ((const int *)data)[c]);
|
||||
printf ("\n");
|
||||
}
|
||||
}
|
||||
// N.B. Drop any outputs that aren't float- or int-based
|
||||
}
|
||||
@@ -1117,6 +1149,7 @@ test_shade (int argc, const char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
double runtime = timer.lap();
|
||||
|
||||
if (outputfiles.size() == 0)
|
||||
std::cout << "\n";
|
||||
@@ -1124,7 +1157,26 @@ test_shade (int argc, const char *argv[])
|
||||
// Write the output images to disk
|
||||
for (size_t i = 0; i < outputimgs.size(); ++i) {
|
||||
if (outputimgs[i]) {
|
||||
outputimgs[i]->write (outputimgs[i]->name());
|
||||
if (! print_outputs) {
|
||||
std::string filename = outputimgs[i]->name();
|
||||
// JPEG, GIF, and PNG images should be automatically saved
|
||||
// as sRGB because they are almost certainly supposed to
|
||||
// be displayed on web pages.
|
||||
using namespace OIIO;
|
||||
if (Strutil::iends_with (filename, ".jpg") ||
|
||||
Strutil::iends_with (filename, ".jpeg") ||
|
||||
Strutil::iends_with (filename, ".gif") ||
|
||||
Strutil::iends_with (filename, ".png")) {
|
||||
ImageBuf ccbuf;
|
||||
ImageBufAlgo::colorconvert (ccbuf, *outputimgs[i],
|
||||
"linear", "sRGB", false,
|
||||
"", "");
|
||||
ccbuf.set_write_format (outputimgs[i]->spec().format);
|
||||
ccbuf.write (filename);
|
||||
} else {
|
||||
outputimgs[i]->write (filename);
|
||||
}
|
||||
}
|
||||
delete outputimgs[i];
|
||||
outputimgs[i] = NULL;
|
||||
}
|
||||
@@ -1132,10 +1184,11 @@ test_shade (int argc, const char *argv[])
|
||||
|
||||
// Print some debugging info
|
||||
if (debug || runstats || profile) {
|
||||
double runtime = timer.lap();
|
||||
double writetime = timer.lap();
|
||||
std::cout << "\n";
|
||||
std::cout << "Setup: " << OIIO::Strutil::timeintervalformat (setuptime,2) << "\n";
|
||||
std::cout << "Run : " << OIIO::Strutil::timeintervalformat (runtime,2) << "\n";
|
||||
std::cout << "Write: " << OIIO::Strutil::timeintervalformat (writetime,2) << "\n";
|
||||
std::cout << "\n";
|
||||
std::cout << shadingsys->getstats (5) << "\n";
|
||||
OIIO::TextureSystem *texturesys = shadingsys->texturesys();
|
||||
|
||||
@@ -28,6 +28,9 @@ Compiled test.osl -> test.oso
|
||||
mix (3 3 3, 5 5 5, 0 0 0) = 3 3 3 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 0.25 0.25 0.25) = 3.5 3.5 3.5 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 1 1 1) = 5 5 5 [0 0 0, 0 0 0]
|
||||
smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point/float smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
varying:
|
||||
clamp (0, 0, 0) = 0
|
||||
clamp (0, 0, 0) = 0
|
||||
@@ -58,6 +61,7 @@ Compiled test.osl -> test.oso
|
||||
mix (0 0 0, 0 0 0, 0) = 0 0 0 [0 0 0, 1 1 1]
|
||||
mix (0 0 0, 0 0 0, 0.25) = 0 0 0 [0.25 0.25 0.25, 1 1 1]
|
||||
mix (0 0 0, 0 0 0, 1) = 0 0 0 [1 1 1, 1 1 1]
|
||||
smoothstep (0 0 0, 0 0 0, 0 0 0) = 1 1 1
|
||||
clamp (1, 3, 5) = 3
|
||||
clamp (3, 1, 5) = 3
|
||||
clamp (5, 1, 3) = 3
|
||||
@@ -87,6 +91,9 @@ Compiled test.osl -> test.oso
|
||||
mix (3 3 3, 5 5 5, 0 0 0) = 3 3 3 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 0.25 0.25 0.25) = 3.5 3.5 3.5 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 1 1 1) = 5 5 5 [0 0 0, 0 0 0]
|
||||
smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point/float smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
varying:
|
||||
clamp (1, 0, 1) = 1
|
||||
clamp (0, 1, 1) = 1
|
||||
@@ -103,7 +110,7 @@ Compiled test.osl -> test.oso
|
||||
mix (0, 1, 0) = 0 [0, 1]
|
||||
mix (0, 1, 0.25) = 0.25 [0.25, 1]
|
||||
mix (0, 1, 1) = 1 [1, 1]
|
||||
smoothstep (0, 1, 1) = 1
|
||||
smoothstep (1, 1, 0) = 0
|
||||
clamp (1 1 1, 0 0 0, 1 1 1) = 1 1 1
|
||||
clamp (0 0 0, 1 1 1, 1 1 1) = 1 1 1
|
||||
clamp (1 1 1, 1 1 1, 0 0 0) = 1 1 1
|
||||
@@ -117,6 +124,7 @@ Compiled test.osl -> test.oso
|
||||
mix (0 0 0, 1 1 1, 0) = 0 0 0 [0 0 0, 1 1 1]
|
||||
mix (0 0 0, 1 1 1, 0.25) = 0.25 0.25 0.25 [0.25 0.25 0.25, 1 1 1]
|
||||
mix (0 0 0, 1 1 1, 1) = 1 1 1 [1 1 1, 1 1 1]
|
||||
smoothstep (1 1 1, 1 1 1, 0 0 0) = 0 0 0
|
||||
clamp (1, 3, 5) = 3
|
||||
clamp (3, 1, 5) = 3
|
||||
clamp (5, 1, 3) = 3
|
||||
@@ -146,6 +154,9 @@ Compiled test.osl -> test.oso
|
||||
mix (3 3 3, 5 5 5, 0 0 0) = 3 3 3 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 0.25 0.25 0.25) = 3.5 3.5 3.5 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 1 1 1) = 5 5 5 [0 0 0, 0 0 0]
|
||||
smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point/float smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
varying:
|
||||
clamp (0, 1, 1) = 1
|
||||
clamp (1, 0, 1) = 1
|
||||
@@ -162,7 +173,7 @@ Compiled test.osl -> test.oso
|
||||
mix (1, 1, 0) = 1 [0, 1]
|
||||
mix (1, 1, 0.25) = 1 [0.25, 1]
|
||||
mix (1, 1, 1) = 1 [1, 1]
|
||||
smoothstep (1, 1, 0) = 0
|
||||
smoothstep (0, 1, 1) = 1
|
||||
clamp (0 0 0, 1 1 1, 1 1 1) = 1 1 1
|
||||
clamp (1 1 1, 0 0 0, 1 1 1) = 1 1 1
|
||||
clamp (1 1 1, 0 0 0, 1 1 1) = 1 1 1
|
||||
@@ -176,6 +187,7 @@ Compiled test.osl -> test.oso
|
||||
mix (1 1 1, 1 1 1, 0) = 1 1 1 [0 0 0, 1 1 1]
|
||||
mix (1 1 1, 1 1 1, 0.25) = 1 1 1 [0.25 0.25 0.25, 1 1 1]
|
||||
mix (1 1 1, 1 1 1, 1) = 1 1 1 [1 1 1, 1 1 1]
|
||||
smoothstep (0 0 0, 1 1 1, 1 1 1) = 1 1 1
|
||||
clamp (1, 3, 5) = 3
|
||||
clamp (3, 1, 5) = 3
|
||||
clamp (5, 1, 3) = 3
|
||||
@@ -205,6 +217,9 @@ Compiled test.osl -> test.oso
|
||||
mix (3 3 3, 5 5 5, 0 0 0) = 3 3 3 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 0.25 0.25 0.25) = 3.5 3.5 3.5 [0 0 0, 0 0 0]
|
||||
mix (3 3 3, 5 5 5, 1 1 1) = 5 5 5 [0 0 0, 0 0 0]
|
||||
smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
point/float smoothstep (1 1 1, 5 5 5, 3 3 3) = 0.5 0.5 0.5
|
||||
varying:
|
||||
clamp (1, 1, 2) = 1
|
||||
clamp (1, 1, 2) = 1
|
||||
@@ -235,4 +250,5 @@ Compiled test.osl -> test.oso
|
||||
mix (1 1 1, 2 2 2, 0) = 1 1 1 [0 0 0, 1 1 1]
|
||||
mix (1 1 1, 2 2 2, 0.25) = 1.25 1.25 1.25 [0.25 0.25 0.25, 1 1 1]
|
||||
mix (1 1 1, 2 2 2, 1) = 2 2 2 [1 1 1, 1 1 1]
|
||||
smoothstep (1 1 1, 2 2 2, 1 1 1) = 0 0 0
|
||||
|
||||
|
||||
@@ -53,6 +53,11 @@ test ()
|
||||
t = 1.0;
|
||||
m = mix (b,c,t);
|
||||
printf (" mix (%g, %g, %g) = %g [%g, %g]\n", b, c, t, m, Dx(m), Dy(m));
|
||||
printf (" smoothstep (%g, %g, %g) = %g\n", a, c, b, smoothstep (a,c,b));
|
||||
printf (" point smoothstep (%g, %g, %g) = %g\n", a, c, b,
|
||||
smoothstep (point(a),point(c),point(b)));
|
||||
printf (" point/float smoothstep (%g, %g, %g) = %g\n", a, c, b,
|
||||
smoothstep (point(a),point(c),b[0]));
|
||||
}
|
||||
|
||||
printf (" varying:\n");
|
||||
@@ -81,7 +86,7 @@ test ()
|
||||
t = 1.0;
|
||||
m = mix (b,c,t);
|
||||
printf (" mix (%g, %g, %g) = %g [%g, %g]\n", b, c, t, m, Dx(m), Dy(m));
|
||||
printf (" smoothstep (%g, %g, %g) = %g\n", b, c, a, smoothstep (b,c,a));
|
||||
printf (" smoothstep (%g, %g, %g) = %g\n", a, c, b, smoothstep (a,c,b));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -107,5 +112,6 @@ test ()
|
||||
t = 1.0;
|
||||
m = mix (b,c,t);
|
||||
printf (" mix (%g, %g, %g) = %g [%g, %g]\n", b, c, t, m, Dx(m), Dy(m));
|
||||
printf (" smoothstep (%g, %g, %g) = %g\n", a, c, b, smoothstep (a,c,b));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ cross product: c = cross(1 -1 1, 1 1 1) = -2 0 2 Dx(c) = -4 0 4 Dy(c) = -4 0 4
|
||||
|
||||
comp assign: C[0]=u, C[1]=v: now C = 1 0 0, Dx(C) = 1 0 0, Dy(C) = 0 1 0
|
||||
|
||||
normalize: n = normalize(1 1 1) = 0.5774 0.5774 0.5774 Dx(n) = 5.96e-08 5.96e-08 5.96e-08 Dy(n) = 0.3849 -0.7698 0.3849
|
||||
normalize: n = normalize(1 1 1) = 0.5774 0.5774 0.5774 Dx(n) = 3.441e-08 3.441e-08 3.441e-08 Dy(n) = 0.3849 -0.7698 0.3849
|
||||
|
||||
length: l = length(1 1 1) = 1.732 Dx(l) = 1.732 Dy(l) = 0.5774
|
||||
|
||||
@@ -309,7 +309,7 @@ cross product: c = cross(1 -1 1, 1 1 1) = -2 0 2 Dx(c) = -4 0 4 Dy(c) = -4 0 4
|
||||
|
||||
comp assign: C[0]=u, C[1]=v: now C = 0 1 0, Dx(C) = 1 0 0, Dy(C) = 0 1 0
|
||||
|
||||
normalize: n = normalize(1 -1 1) = 0.5774 -0.5774 0.5774 Dx(n) = 0.3849 0.7698 0.3849 Dy(n) = 5.96e-08 -5.96e-08 5.96e-08
|
||||
normalize: n = normalize(1 -1 1) = 0.5774 -0.5774 0.5774 Dx(n) = 0.3849 0.7698 0.3849 Dy(n) = 3.441e-08 -3.441e-08 3.441e-08
|
||||
|
||||
length: l = length(1 -1 1) = 1.732 Dx(l) = 0.5774 Dy(l) = 1.732
|
||||
|
||||
@@ -416,7 +416,7 @@ cross product: c = cross(2 -2 2, 2 2 2) = -8 0 8 Dx(c) = -8 0 8 Dy(c) = -8 0 8
|
||||
|
||||
comp assign: C[0]=u, C[1]=v: now C = 1 1 0, Dx(C) = 1 0 0, Dy(C) = 0 1 0
|
||||
|
||||
normalize: n = normalize(2 0 2) = 0.7071 0 0.7071 Dx(n) = 2.98e-08 0.3536 2.98e-08 Dy(n) = 2.98e-08 -0.3536 2.98e-08
|
||||
normalize: n = normalize(2 0 2) = 0.7071 0 0.7071 Dx(n) = 2.107e-08 0.3536 2.107e-08 Dy(n) = 2.107e-08 -0.3536 2.107e-08
|
||||
|
||||
length: l = length(2 0 2) = 2.828 Dx(l) = 1.414 Dy(l) = 1.414
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Compiled test.osl -> test.oso
|
||||
Without repeated errors:
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: there
|
||||
@@ -8,3 +9,85 @@ ERROR: Shader error [test]: hi
|
||||
ERROR: Shader error [test]: there
|
||||
|
||||
|
||||
With repeated errors:
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: there
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: there
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: there
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: there
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: there
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: there
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: there
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
WARNING: Shader warning [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: there
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
ERROR: Shader error [test]: hi
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
command = testshade("-g 2 2 test")
|
||||
command = "echo 'Without repeated errors:' >> out.txt 2>&1 ;\n"
|
||||
command += testshade("-g 2 2 test")
|
||||
|
||||
command += "echo 'With repeated errors:' >> out.txt 2>&1 ;\n"
|
||||
command += testshade("--options error_repeats=1 -g 2 2 test")
|
||||
|
||||
@@ -3,6 +3,8 @@ Compiled test.osl -> test.oso
|
||||
hypot (3, 4, 5) = 7.07107
|
||||
reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0
|
||||
reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1
|
||||
testing total-internal reflection:
|
||||
refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0
|
||||
frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0
|
||||
@@ -23,6 +25,8 @@ Compiled test.osl -> test.oso
|
||||
hypot (3, 4, 5) = 7.07107
|
||||
reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0
|
||||
reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1
|
||||
testing total-internal reflection:
|
||||
refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0
|
||||
frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0
|
||||
@@ -43,6 +47,8 @@ Compiled test.osl -> test.oso
|
||||
hypot (3, 4, 5) = 7.07107
|
||||
reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0
|
||||
reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1
|
||||
testing total-internal reflection:
|
||||
refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0
|
||||
frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0
|
||||
@@ -63,6 +69,8 @@ Compiled test.osl -> test.oso
|
||||
hypot (3, 4, 5) = 7.07107
|
||||
reflect (0.447214 -0.894427 0, 0 1 0) = 0.447214 0.894427 0
|
||||
reflect (0.447214 -0.894427 0, -1 0 0) = -0.447214 -0.894427 0
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107) = 0 0 1
|
||||
faceforward (0 0 1, 0 -0.707107 -0.707107, 0 0 -1) = 0 0 -1
|
||||
testing total-internal reflection:
|
||||
refract (0.707107 -0.707107 0, 0 1 0, 1.42) = 0 0 0
|
||||
frensel: Kr= 1 Kt = 0 R = 0.707107 0.707107 0 T = 0 0 0
|
||||
|
||||
@@ -16,6 +16,14 @@ test ()
|
||||
printf (" reflect (%g, %g) = %g\n", vI, vN, pretty(reflect (vI, vN)));
|
||||
vN = vector(-1, 0, 0);
|
||||
printf (" reflect (%g, %g) = %g\n", vI, vN, pretty(reflect (vI, vN)));
|
||||
vI = vector(0, -1, -1);
|
||||
vI = normalize(vI);
|
||||
vN = vector(0, 0, 1);
|
||||
printf (" faceforward (%g, %g) = %g\n",
|
||||
vN, vI, pretty(faceforward (vN, vI)));
|
||||
vector vNg = vector(0, 0, -1);
|
||||
printf (" faceforward (%g, %g, %g) = %g\n",
|
||||
vN, vI, vNg, pretty(faceforward (vN, vI, vNg)));
|
||||
|
||||
// test total internal reflection (going from greater to lesser IOR)
|
||||
printf (" testing total-internal reflection:\n");
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
Compiled test.osl -> test.oso
|
||||
Executing...
|
||||
../common/textures/grid.tx resolution: 1024 1024 (1)
|
||||
../common/textures/grid.tx channels: 4 (1)
|
||||
../common/textures/grid.tx texturetype: Plain Texture (1)
|
||||
../common/textures/grid.tx textureformat: Plain Texture (1)
|
||||
../common/textures/grid.tx datawindow: 0 0 1023 1023 (1)
|
||||
../common/textures/grid.tx displaywindow: 0 0 1023 1023 (1)
|
||||
../common/textures/grid.tx datetime: 2014:11:29 23:20:23 (1)
|
||||
../common/textures/grid.tx averagecolor: 0.608983 0.608434 0.608728
|
||||
../common/textures/grid.tx averagealpha: 1
|
||||
../common/textures/grid.tx unknown constantcolor
|
||||
../common/textures/grid.tx unknown constantalpha
|
||||
../common/textures/grid.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
Invalid image file "badfile"
|
||||
badfile data: not found (0)
|
||||
../common/textures/grid.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
Executing...
|
||||
win.exr resolution: 100 50 (1)
|
||||
win.exr channels: 3 (1)
|
||||
win.exr texturetype: Plain Texture (1)
|
||||
win.exr textureformat: Plain Texture (1)
|
||||
win.exr datawindow: 10 20 109 69 (1)
|
||||
win.exr displaywindow: 0 0 299 199 (1)
|
||||
win.exr averagecolor: 0 0 0
|
||||
win.exr unknown averagealpha
|
||||
win.exr unknown constantcolor
|
||||
win.exr unknown constantalpha
|
||||
win.exr foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
Invalid image file "badfile"
|
||||
badfile data: not found (0)
|
||||
win.exr exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
Executing...
|
||||
green.tx resolution: 128 128 (1)
|
||||
green.tx channels: 4 (1)
|
||||
green.tx texturetype: Plain Texture (1)
|
||||
green.tx textureformat: Plain Texture (1)
|
||||
green.tx datawindow: 0 0 127 127 (1)
|
||||
green.tx displaywindow: 0 0 127 127 (1)
|
||||
green.tx averagecolor: 0.101961 0.501961 0.101961
|
||||
green.tx averagealpha: 1
|
||||
green.tx constantcolor: 0.101961 0.501961 0.101961
|
||||
green.tx constantalpha: 1
|
||||
green.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
Invalid image file "badfile"
|
||||
badfile data: not found (0)
|
||||
green.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
Compiled test.osl -> test.oso
|
||||
Executing...
|
||||
../common/textures/grid.tx resolution: 1024 1024 (1)
|
||||
../common/textures/grid.tx channels: 4 (1)
|
||||
../common/textures/grid.tx texturetype: Plain Texture (1)
|
||||
../common/textures/grid.tx textureformat: Plain Texture (1)
|
||||
../common/textures/grid.tx datawindow: 0 0 1023 1023 (1)
|
||||
../common/textures/grid.tx displaywindow: 0 0 1023 1023 (1)
|
||||
../common/textures/grid.tx datetime: 2014:11:29 23:20:23 (1)
|
||||
../common/textures/grid.tx averagecolor: 0.608983 0.608434 0.608728
|
||||
../common/textures/grid.tx averagealpha: 1
|
||||
../common/textures/grid.tx unknown constantcolor
|
||||
../common/textures/grid.tx unknown constantalpha
|
||||
../common/textures/grid.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
Invalid image file "badfile": Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
badfile data: not found (0)
|
||||
../common/textures/grid.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
Executing...
|
||||
win.exr resolution: 100 50 (1)
|
||||
win.exr channels: 3 (1)
|
||||
win.exr texturetype: Plain Texture (1)
|
||||
win.exr textureformat: Plain Texture (1)
|
||||
win.exr datawindow: 10 20 109 69 (1)
|
||||
win.exr displaywindow: 0 0 299 199 (1)
|
||||
win.exr averagecolor: 0 0 0
|
||||
win.exr unknown averagealpha
|
||||
win.exr unknown constantcolor
|
||||
win.exr unknown constantalpha
|
||||
win.exr foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
Invalid image file "badfile": Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
badfile data: not found (0)
|
||||
win.exr exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
Executing...
|
||||
green.tx resolution: 128 128 (1)
|
||||
green.tx channels: 4 (1)
|
||||
green.tx texturetype: Plain Texture (1)
|
||||
green.tx textureformat: Plain Texture (1)
|
||||
green.tx datawindow: 0 0 127 127 (1)
|
||||
green.tx displaywindow: 0 0 127 127 (1)
|
||||
green.tx averagecolor: 0.101961 0.501961 0.101961
|
||||
green.tx averagealpha: 1
|
||||
green.tx constantcolor: 0.101961 0.501961 0.101961
|
||||
green.tx constantalpha: 1
|
||||
green.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
Invalid image file "badfile": Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
badfile data: not found (0)
|
||||
green.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
Compiled test.osl -> test.oso
|
||||
Executing...
|
||||
../common/textures/grid.tx resolution: 1024 1024 (1)
|
||||
../common/textures/grid.tx channels: 4 (1)
|
||||
../common/textures/grid.tx texturetype: Plain Texture (1)
|
||||
../common/textures/grid.tx textureformat: Plain Texture (1)
|
||||
../common/textures/grid.tx datawindow: 0 0 1023 1023 (1)
|
||||
../common/textures/grid.tx displaywindow: 0 0 1023 1023 (1)
|
||||
../common/textures/grid.tx datetime: 2014:11:29 23:20:23 (1)
|
||||
../common/textures/grid.tx averagecolor: 0.608983 0.608434 0.608728
|
||||
../common/textures/grid.tx averagealpha: 1
|
||||
../common/textures/grid.tx unknown constantcolor
|
||||
../common/textures/grid.tx unknown constantalpha
|
||||
../common/textures/grid.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile"
|
||||
badfile data: not found (0)
|
||||
../common/textures/grid.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
Executing...
|
||||
win.exr resolution: 100 50 (1)
|
||||
win.exr channels: 3 (1)
|
||||
win.exr texturetype: Plain Texture (1)
|
||||
win.exr textureformat: Plain Texture (1)
|
||||
win.exr datawindow: 10 20 109 69 (1)
|
||||
win.exr displaywindow: 0 0 299 199 (1)
|
||||
win.exr averagecolor: 0 0 0
|
||||
win.exr unknown averagealpha
|
||||
win.exr unknown constantcolor
|
||||
win.exr unknown constantalpha
|
||||
win.exr foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile"
|
||||
badfile data: not found (0)
|
||||
win.exr exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
Executing...
|
||||
green.tx resolution: 128 128 (1)
|
||||
green.tx channels: 4 (1)
|
||||
green.tx texturetype: Plain Texture (1)
|
||||
green.tx textureformat: Plain Texture (1)
|
||||
green.tx datawindow: 0 0 127 127 (1)
|
||||
green.tx displaywindow: 0 0 127 127 (1)
|
||||
green.tx averagecolor: 0.101961 0.501961 0.101961
|
||||
green.tx averagealpha: 1
|
||||
green.tx constantcolor: 0.101961 0.501961 0.101961
|
||||
green.tx constantalpha: 1
|
||||
green.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile"
|
||||
badfile data: not found (0)
|
||||
green.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
@@ -12,7 +12,8 @@ Executing...
|
||||
../common/textures/grid.tx unknown constantcolor
|
||||
../common/textures/grid.tx unknown constantalpha
|
||||
../common/textures/grid.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile"
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile": Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
badfile data: not found (0)
|
||||
../common/textures/grid.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
@@ -29,7 +30,8 @@ win.exr unknown averagealpha
|
||||
win.exr unknown constantcolor
|
||||
win.exr unknown constantalpha
|
||||
win.exr foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile"
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile": Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
badfile data: not found (0)
|
||||
win.exr exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
@@ -46,7 +48,8 @@ green.tx averagealpha: 1
|
||||
green.tx constantcolor: 0.101961 0.501961 0.101961
|
||||
green.tx constantalpha: 1
|
||||
green.tx foobar: not found (0)
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile"
|
||||
ERROR: [RendererServices::get_texture_info] Invalid image file "badfile": Image "badfile" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.
|
||||
|
||||
badfile data: not found (0)
|
||||
green.tx exists? 1 (return 1)
|
||||
badfile3 exists? 0 (return 1)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Compiled test.osl -> test.oso
|
||||
hash(u=0.25) = -1518044388
|
||||
hash(u=0.25, v=0.25) = -1622002383
|
||||
hash(p=0.25 0.25 1) = -11273046
|
||||
hash(p=0.25 0.25 1, t=0.25) = -2129896790
|
||||
hash(u=0.75) = -1375811879
|
||||
hash(u=0.75, v=0.25) = -802388107
|
||||
hash(p=0.75 0.25 1) = -1172708893
|
||||
hash(p=0.75 0.25 1, t=0.25) = 1884197054
|
||||
hash(u=0.25) = -1518044388
|
||||
hash(u=0.25, v=0.75) = 1343286349
|
||||
hash(p=0.25 0.75 1) = 451400267
|
||||
hash(p=0.25 0.75 1, t=0.75) = 418112862
|
||||
hash(u=0.75) = -1375811879
|
||||
hash(u=0.75, v=0.75) = 2050085294
|
||||
hash(p=0.75 0.75 1) = 1398623619
|
||||
hash(p=0.75 0.75 1, t=0.75) = -626565092
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
command = testshade("-g 2 2 -center test")
|
||||
@@ -0,0 +1,8 @@
|
||||
shader
|
||||
test ()
|
||||
{
|
||||
printf ("hash(u=%g) = %d\n", u, hash(u));
|
||||
printf ("hash(u=%g, v=%g) = %d\n", u,v, hash(u,v));
|
||||
printf ("hash(p=%g) = %d\n", P, hash(P));
|
||||
printf ("hash(p=%g, t=%g) = %d\n", P,v, hash(P,v));
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Compiled test.osl -> test.oso
|
||||
|
||||
Output Cout to out.tif
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
command = testshade("-g 128 128 -od uint8 -o Cout out.tif test")
|
||||
outputs = [ "out.txt", "out.tif" ]
|
||||
@@ -0,0 +1,36 @@
|
||||
shader
|
||||
test (float angle = 10, float scale = 20,
|
||||
output color Cout = 0)
|
||||
{
|
||||
// setup some coordinates
|
||||
float theta = radians(angle);
|
||||
float ru = cos(theta) * u + sin(theta) * v;
|
||||
float rv = sin(theta) * u - cos(theta) * v;
|
||||
ru *= scale;
|
||||
rv *= scale;
|
||||
float rz = (scale * (u + v)) / M_SQRT2;
|
||||
float t = u*scale;
|
||||
|
||||
Cout = 0;
|
||||
if (v < 0.49) {
|
||||
// float noise in 1,2,3,4 dimensions
|
||||
if (u < 0.24)
|
||||
Cout = (float) hashnoise(ru);
|
||||
else if (u > 0.26 && u < 0.49)
|
||||
Cout = (float) hashnoise(ru, rv);
|
||||
else if (u > 0.51 && u < 0.74)
|
||||
Cout = (float) hashnoise(point(ru, rv, rz));
|
||||
else if (u > 0.76)
|
||||
Cout = (float) hashnoise(point(ru, rv, rz), t);
|
||||
} else if (v > 0.51) {
|
||||
// color noise in 1,2,3,4 dimensions
|
||||
if (u < 0.24)
|
||||
Cout = hashnoise(ru);
|
||||
else if (u > 0.26 && u < 0.49)
|
||||
Cout = hashnoise(ru, rv);
|
||||
else if (u > 0.51 && u < 0.74)
|
||||
Cout = hashnoise(point(ru, rv, rz));
|
||||
else if (u > 0.76)
|
||||
Cout = hashnoise(point(ru, rv, rz), t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Compiled test.osl -> test.oso
|
||||
Test versions:
|
||||
OK!
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
command += testshade ("test")
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
shader test ()
|
||||
{
|
||||
int ok = 1;
|
||||
printf ("Test versions:\n");
|
||||
int version = 0;
|
||||
getattribute ("osl:version", version);
|
||||
if (version != OSL_VERSION) {
|
||||
printf ("OSL_VERSION and attribute \"osl:version\" DO NOT MATCH!\n");
|
||||
ok = 0;
|
||||
}
|
||||
if (version != OSL_VERSION_MAJOR*10000+OSL_VERSION_MINOR*100+OSL_VERSION_PATCH) {
|
||||
printf ("OSL_VERSION and (maj*10000+min*100+patch) DO NOT MATCH!\n");
|
||||
ok = 0;
|
||||
}
|
||||
if (ok)
|
||||
printf ("OK!\n");
|
||||
// printf ("Version = %d\n", version);
|
||||
// printf ("VERSION = %d\n", OSL_VERSION);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Compiled test.osl -> test.oso
|
||||
(0.600000,0.000000)
|
||||
(0.600000,0.000000)
|
||||
(0.600000,0.306262)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
command = testshade("test")
|
||||
@@ -0,0 +1,22 @@
|
||||
// Reguression test -- this used to have a bug where right at 0.6, there
|
||||
// was a precision problem.
|
||||
|
||||
|
||||
float invspline(float x, float uu){
|
||||
string basis = "bspline";
|
||||
float knots[8];
|
||||
for (int i=0;i<4;i++) knots[i] = x;
|
||||
for (int i=4;i<8;i++) knots[i] = 1.0;
|
||||
float floats[8] ={0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};
|
||||
return splineinverse(basis,uu,knots);
|
||||
}
|
||||
|
||||
surface test() {
|
||||
float uu;
|
||||
uu = 0.59;
|
||||
printf("(%f,%f)\n",0.6,invspline(0.6,uu));
|
||||
uu = 0.6;
|
||||
printf("(%f,%f)\n",0.6,invspline(0.6,uu));
|
||||
uu = 0.61;
|
||||
printf("(%f,%f)\n",0.6,invspline(0.6,uu));
|
||||
}
|
||||