Compare commits

...
48 Commits
Author SHA1 Message Date
Larry Gritz 2b1a7ec6c8 CHANGES 2017-03-01 18:24:01 -08:00
Larry Gritz fe42ddb15d Minor fixes for C++11 and use of std::atomic 2016-11-07 22:42:11 -08:00
Larry Gritz 7085e06d77 Travis: change to precise linux, we don't trust trusty 2016-11-07 22:42:11 -08:00
Larry Gritz 7eb31d02c7 Post-release version bump 2016-10-31 15:48:19 -07:00
Larry Gritz 39154a5598 CHANGES 2016-10-31 15:48:19 -07:00
Larry Gritz 5dd06f031e Typo bug transpose() vs transposed(). (#662)
Imath::M44f.transpose() transposes in place and returns the ref,
whereas transposed() returns the transpose without altering the original.

Not a symptomatic bug because we only did this on the result of an
inverse(), which was a temporary, so didn't hurt to mess with it in place.
But better to correct this code to properly reflect our intent.
2016-10-31 15:48:19 -07:00
Larry Gritz f7b869d89a Adjust Travis now that OIIO master is C++11 only
Still test against release OIIO with C++03
2016-10-14 18:47:37 -07:00
Larry Gritz 9680823437 Be sure to propagate C++ standard flags to the compilation of llvm_ops.cpp (#674)
We weren't properly transferring --std=c++11 from the directives to
compile OSL's implementation, to the command line that compiles
the llvm bitcode from llvm_ops.cpp. They should match.
2016-10-13 10:20:38 -07:00
Larry Gritz 3e62b5343c oslc better err reporting for use of non-function symbol as function. (#684)
See the new testsuite example. This crashed oslc before!
Fix it up to not crash (by marking the unfound function's symbol as NULL),
and also improve the resulting error message.

Fixes #681
2016-10-13 09:42:38 -07:00
Larry Gritz 69d213b0f1 Suppress clang 3.9 warnings (#683) 2016-10-13 09:33:49 -07:00
Larry Gritz 16afdcbadf Fix warning from last checkin 2016-10-04 11:12:11 -07:00
Larry Gritz 307abe1149 Bug fix: matrix param initialized with matrix(space,1) left out init ops (#675)
When generating the static construction values, it needed to recognize
that case and set the "completed" flag to false, so that it would know
that it couldn't be constructed statically and needed init ops emitted
for that paramter.
2016-10-04 11:11:58 -07:00
Larry Gritz 08e87f05b0 Bug fix: incorrect dropping of optional texture arguments.
There was a well-meaning optimization: dropping the setting of TextureOpt
fields when the value was known to overwrite the field with the default
value. But of course this should only happen when the value is CONSTANT,
it shouldn't happen just because the value passed is a param and the
parameter's default value is the option default value -- because the
param may be connected to an earlier layer that passes a different
value.

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

Fixes #670.
2016-09-27 15:45:25 -07:00
Larry Gritz 2d704ce671 Fix variant of spline() that didn't compute derivatives properly. (#666)
Specifically, the case where the knots are colors (without derivs), the
abscissa float with derivs.
2016-08-23 09:41:35 -07:00
Brecht Van Lommel ab65ebe086 Fix OSL compiler assert when indexing into closure type. (#663) 2016-08-04 16:30:31 -07:00
Larry Gritz bacb5c53b4 post-release version bump 2016-08-01 10:11:42 -07:00
Larry Gritz 7dc3928cf0 CHANGES 2016-08-01 10:09:59 -07:00
Larry Gritz f7cc4e595f oslc didn't understand hex integer constants (like 0x01fc). #653 2016-07-06 17:15:21 -07:00
Larry Gritz 3a882f40b9 Bug fix: incorrect instance merging when unspecified-length arrays differed. (#656)
Because the altered data offset wasn't transferred from the instance
overrides to the instance's full symbol table, it was comparing the
default values rather than the actual values, so two instances that
should not have been merged, were merged.

Also fixed a (harmless) bug in ShadingSystemImpl::ShaderGroupBegin,
where the serialized group is parsed, where it was double-calling
Parameter() to add the parameters.

Fixes #655
2016-07-06 17:13:36 -07:00
Larry Gritz cc3a0f3a53 Post-release version bump 2016-07-01 17:10:50 -07:00
Larry Gritz b1d621519d Update PDF docs 2016-07-01 17:10:15 -07:00
Larry Gritz c9d7f7d5f5 CHANGES 2016-07-01 17:10:15 -07:00
Larry Gritz af8420ff2a Fix subtle bug in optimize_ops that could seg fault. (#651)
The optimize_ops method had a convenience reference to the op being
examined in the loop.  We carefully do a reserve() first to make sure
that there was enough room for one insertion so that the reference would
still be valid if the constant-folding function has to add an op.  But
this relied on the assumption that no folder would insert more than one
op as it did its work, which was always true (once).

Oops, much later, a new way to speed up "mix" ops had a particular corner
case in which up to 7 new ops might be inserted, and I never went back
and fixed the now-broken assumption here.

The fix here is to change the reference to the op (which cannot be
changed dynamically) into a pointer to the op, which can be re-pointed
after calling the folding function to make sure that it's valid and
pointing to the (potentially new) correct position as it continues on in
the loop. So it is no longer sensitive to changes to the vector
allocation that might happen inside the folder.

I haven't changed this code for a long time. It's shocking that no
problems cropped up from this bug until this week! I guess it's not a
very common "corner case".
2016-07-01 17:10:15 -07:00
Larry Gritz f4cc52f4be Include file fixes after recent OIIO change that split atomic.h & thread.h (#650) 2016-07-01 16:42:20 -07:00
Larry Gritz 5c4708b34f Add gcc6 to the test matrix and fix resulting warnings. 2016-06-22 12:48:27 -07:00
Larry Gritz 4401bcba26 Make sure spec documents #pragma once 2016-06-14 11:52:53 -07:00
Larry Gritz eff0535bc0 Windows fix for lexer (#646)
Option "never-interactive" prevents flex from emitting calls to isatty,
which is not always present on Windows. This is fine because we never
use the lexer in interactive mode anyway.
2016-06-13 14:25:43 -07:00
Elvic Liang 3c7e081bb4 Fixed build break on Windows. (643) 2016-06-10 13:33:58 -07:00
Larry Gritz f93f04c823 Don't test or set "layer ran bits" on last layer.
Also be sure that the entry point doesn't use the "fast" calling convention.
2016-06-08 10:04:08 -07:00
Larry Gritz 882d6211e7 Improve docs:
* Explain rules for connections
* Explain that getattribute retrieves userdata
2016-05-01 08:57:03 -07:00
Larry Gritz eb483e08a0 Fix oslc incorrectly emitting init ops for constructor color(float).
We're talking about a construct like:

    shader foo (color c = color(1), ...)

It got it right if it was

    color c = color(1,1,1)

In both cases, it properly reduced the default value to a static constant
value, but the bug was that it ALSO (unnecessarily) had extra init ops
for that parameter. That would be eliminated in runtime optimization, the
shader certainly ran correctly, but it threw off oslinfo, which figures
that if init ops are present, it can't figure out what the default values
were.
2016-04-14 10:46:10 -07:00
Stefan Büttner 2122621386 Restrict find_program llvm to given path
LLVM can be installed on a system without clang.
So if LLVM_DIRECTORY pointed to a locally installed llvm/clang version
but the system had llvm without clang installed, until now the script would
find the system LLVM without clang and the build would fail.
And since LLVM is globally searched for if the hinted version failed,
it should not hurt to only search in the hinted paths.
2016-04-11 17:10:17 -07:00
Larry Gritz d132ce65d9 Warn for common misstep of forgetting constructor name. (635)
shader test ( output color Cout = 0 )
    {
        vector x = (1, 2, 3);
    }

See where this goes wrong? This code will make x be (3,3,3).  If you
don't know why, think about how the comma operator works in C, C++, and
related languages.

The user almost certainly meant

    vector x = vector (1, 2, 3);

With this change, the original (buggy) code will get the following
warning output:

    test.osl:3: warning: Comma operator is very confusing here. Did you mean to use a constructor: x = vector(...)?
2016-04-05 16:23:47 -07:00
Larry Gritz e30aeb3c69 Make an option to have OSL isconnected() return 1 for userdata parameters.
This adds a new ShadingSystem attribute, "userdata_isconnected". The
default of 0 is the old/usual behavior that most applications want.
However, setting this attribute to 1 will cause the OSL built-in
function isconnected(paramname) to return 1 not only for connected
parameters, but also for parameters that may be bound to userdata
(i.e., those that have lockgeom=0).

The use case for this involves a renderer implementation that can mix
C++ and OSL nodes within a shading group. The outputs exported by the
C++ nodes propagate their values to the downstream node via
get_userdata(), hijacking the mechanism that is generally used geometric
primitive variable interpolation. But from the point of view of the
downstream node, they should semantically appear to be a connection.
2016-04-05 16:23:47 -07:00
Larry Gritz 446d3303c1 bump release 2016-04-05 16:23:46 -07:00
Larry Gritz e9b5e2fdb1 Fix missing -lpthread 2016-03-01 14:52:21 -08:00
Larry Gritz 99c4ece489 CHANGES 2016-02-26 21:40:03 -08:00
Larry Gritz e8e84a5a2c Port FindOpenEXR.cmake fixes from OIIO 2016-02-26 21:31:30 -08:00
Larry Gritz 91b5a309cb Rewrite of FindOpenEXR.cmake 2016-02-26 21:30:36 -08:00
Larry Gritz 03724a9236 Travis: build OIIO optimized, even when testing DEBUG for OSL (for speed of CI tests). 2016-02-26 21:30:25 -08:00
Larry Gritz 2457d36432 For stdosl.h funcs marked builtin, auto-detect funny read-write cases. #620
As Chris points out in #618, the fact that params are marked as output
is all we need to know that function's parameters are not all read-only
(duh).
2016-02-26 21:29:49 -08:00
Larry Gritz 9a5b82f693 New ref images for recent OIIO texture improvement.
Related to https://github.com/OpenImageIO/oiio/pull/1369
We can remove the old-oiio1.5 images once 1.6 is the minimum standard for OSL.
2016-02-26 14:36:10 -08:00
Larry Gritz 205c8fadd9 Fix typos in docs
Fixes #622, Fixes #623
2016-02-22 21:21:13 -08:00
Larry Gritz 3e12071012 oslc bug -- getmatrix failed to note that the matrix argument is written. #618
This could lead to a cascade of optimization errors at runtime.
I have no idea why this never showed up as a problem before today.

In addition to fixing it on the oslc side, add a hacky fix to make sure
that old compiled shaders are retroactively fixed as they are loaded at
runtime.
2016-02-06 17:29:33 -08:00
Larry Gritz 86082e94a5 Better handling of multiple SIMD args (such as USE_SIMD=avx,f16c).
It botched this when passing along to precompiling for LLVM.
2016-02-06 17:29:33 -08:00
Larry Gritz de7935a7e8 Fix typos in docs.
Fixes #614
2016-02-06 17:29:33 -08:00
Larry Gritz 07782fcd28 Post-branch version bump 2016-01-29 11:20:30 -08:00
Larry Gritz 02cda6aaf0 Version/release 2016-01-29 11:15:22 -08:00
87 changed files with 717 additions and 442 deletions
+19 -13
View File
@@ -8,21 +8,21 @@ compiler:
os:
- linux
- osx
#osx_image: xcode7
dist: trusty
osx_image: xcode6.4
dist: precise
# Do a default build (C++03, sse2), an sse4.2 build, and a C++11 build.
# Also try with both gcc 4.8 and 4.9 (on Linux; on OSX these will be
# excluded).
env:
matrix:
- WHICHGCC=4.8 BUILD_FLAGS=""
- WHICHGCC=4.8 BUILD_FLAGS="USE_CPP11=1"
- WHICHGCC=4.9 BUILD_FLAGS=""
- WHICHGCC=5 BUILD_FLAGS="USE_CPP11=1"
- WHICHGCC=4.8 OIIOBRANCH=release BUILD_FLAGS=""
- WHICHGCC=4.8 OIIOBRANCH=release BUILD_FLAGS="USE_CPP11=1"
- WHICHGCC=4.8 BUILD_FLAGS="" DEBUG=1
- WHICHGCC=4.8 USE_CPP11=1
- WHICHGCC=4.9 USE_CPP11=1
- WHICHGCC=5 USE_CPP11=1
- WHICHGCC=6 USE_CPP11=1
- WHICHGCC=4.8 OIIOBRANCH=RB-1.7 USE_CPP11=0
- WHICHGCC=4.8 OIIOBRANCH=RB-1.7 USE_CPP11=1
- WHICHGCC=4.8 DEBUG=1 USE_CPP11=1
# Add-ons: specify apt packages for Linux
addons:
@@ -37,6 +37,8 @@ addons:
- g++-4.9
- gcc-5
- g++-5
- gcc-6
- g++-6
- libboost1.55-all-dev
- libtiff4-dev
- llvm3.4
@@ -56,6 +58,7 @@ before_install:
export PLATFORM=linux64 ;
cat /proc/cpuinfo ;
fi
- export OIIOPLATFORM=$PLATFORM
- if [ $DEBUG == 1 ] ; then export PLATFORM=${PLATFORM}.debug ; fi
- echo "Build platform name is $PLATFORM"
@@ -71,9 +74,9 @@ install:
export ILMBASE_HOME=$PWD/openexr-install ;
export OPENEXR_HOME=$PWD/openexr-install ;
fi
- export OIIOMAKEFLAGS="$OIIOMAKEFLAGS -j2"
- export OIIOMAKEFLAGS="$OIIOMAKEFLAGS -j2 DEBUG= "
- src/build-scripts/build_openimageio.bash
- export OPENIMAGEIOHOME=$PWD/OpenImageIO/dist/$PLATFORM
- export OPENIMAGEIOHOME=$PWD/OpenImageIO/dist/$OIIOPLATFORM
- export DYLD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$DYLD_LIBRARY_PATH
- export LD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$LD_LIBRARY_PATH
- export PATH=$OPENIMAGEIOHOME/bin:$PATH
@@ -113,10 +116,13 @@ matrix:
compiler: clang
- os: osx
compiler: clang
env: WHICHGCC=4.9 BUILD_FLAGS=""
env: WHICHGCC=4.9 USE_CPP11=1
- os: osx
compiler: clang
env: WHICHGCC=5 BUILD_FLAGS="USE_CPP11=1"
env: WHICHGCC=5 USE_CPP11=1
- os: osx
compiler: clang
env: WHICHGCC=6 USE_CPP11=1
notifications:
email:
+54 -4
View File
@@ -1,6 +1,59 @@
Changes:
Release 1.7 -- 29 Jan 2016 (compared to 1.6)
Release 1.7.6 -- 1 Mar 2017(compared to 1.7.5)
--------------------------------------------------
* Minor fixes for C++11 and use of std::atomic.
Release 1.7.5 -- 1 Nov 2016 (compared to 1.7.4)
--------------------------------------------------
* Fix oslc crash/assertion when indexing into a closure type. #663
* A version of spline() where the knots were colors without derivs
and the abscissa was a float with derivs, computed its result
derivatives incorrectly. #666
* Incorrect dropping of certain optional texture arguments. #671
* Bug fix: matrix parameters initialized with matrix(space,1) did not
initialize properly. #675
* Suppress warnings when compiling with clang 3.9. #683
* oslc: better error reporting for use of non-function symbol as a
function. #684
* Filed to properly propagate the C++ standard flags (e.g. -std=c++11)
when turning llvm_ops.cpp into LLVM bitcode. #674
Release 1.7.4 -- 1 Aug 2016 (compared to 1.7.3)
--------------------------------------------------
* Bug fix: incorrect instance merging when unspecified-length arrays
differed. (#656)
* Make oslc understand hex integer constants (like 0x01fc). #653
Release 1.7.3 -- 1 Jul 2016 (compared to 1.7.2)
--------------------------------------------------
* ShadingSystem attribute "userdata_isconnected", if set to a nonzero
integer, causes a shader call to isconnected(param) to return 1 if the
parameter is potentially connected to userdata (that is, if lockgeom=0
for that parameter). This if for particular renderer needs, and the
default remains for isconnected() to return 1 only if there is an
actual connection. #629 (1.8.0/1.7.3)
* oslc now will warn when assigning the result of a "comma operator",
which almost always is a programming error where the shader writer
omitted the type name when attempting to construct a vector or matrix.
#635 (1.8.0/1.7.3)
* Fix oslc incorrectly emitting init ops for constructor color(float).
#637 (1.8.0/1.7.3)
* Bug fix: don't test or set the "layer ran bits" on the last layer of the
group. #626 (1.8.0/1.7.3)
* Windows fixes: build breaks #643; fixes for lexer #646.
* Fixes for clean compile with gcc 6.x. #647
* Fix subtle bug in runtime optimizer that could seg fault. #651
Release 1.7.2 -- 1 Mar 2016 (compared to 1.7.1)
--------------------------------------------------
* Build: better handling of multiple USE_SIMD options. #617
* oslc bug: getmatrix() failed to note that the matrix argument was
written. #618
* CMake FindOpenEXR.cmake totally rewritten, much simpler and better. #621
Release 1.7 [1.7.1] -- 29 Jan 2016 (compared to 1.6)
-----------------------------------------------
Language, standard libary, and compiler changes (for shader writers):
* Language features:
@@ -1327,6 +1380,3 @@ Release 0.5.2 - Mar 14, 2011
"smartcubic", "cubic", "linear", "closest").
* Bug fixes to getmessage() and its handling of derivatives, which includes
a slight RendererServices API change.
+30 -9
View File
@@ -3,8 +3,8 @@ project (OSL)
# Release version of the library
set (OSL_LIBRARY_VERSION_MAJOR 1)
set (OSL_LIBRARY_VERSION_MINOR 7)
set (OSL_LIBRARY_VERSION_PATCH 1)
set (OSL_LIBRARY_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
set (OSL_LIBRARY_VERSION_PATCH 6)
set (OSL_LIBRARY_VERSION_RELEASE_TYPE "") # "dev", "betaX", "RCY", ""
# Version of the OSO file format and instruction set
set (OSO_FILE_VERSION_MAJOR 1)
@@ -152,6 +152,10 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
add_definitions ("-Wno-unused-local-typedefs")
endif ()
if (CLANG_VERSION_STRING VERSION_EQUAL 3.9 OR CLANG_VERSION_STRING VERSION_GREATER 3.9)
# Don't warn about using unknown preprocessor symbols in #if'set
add_definitions ("-Wno-expansion-to-defined")
endif ()
endif ()
# gcc specific options
@@ -260,6 +264,11 @@ else ()
add_definitions ("-DOSL_FAST_MATH=0")
endif ()
set (USE_OIIO_STATIC ON CACHE BOOL "If OIIO is built static")
if (USE_OIIO_STATIC)
add_definitions ("-DOIIO_STATIC_BUILD=1")
endif ()
if (OSL_NO_DEFAULT_TEXTURESYSTEM)
add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1")
endif ()
@@ -273,10 +282,12 @@ if (OSL_BUILD_CPP11 OR OSL_BUILD_CPP14)
if (OSL_BUILD_CPP11)
message (STATUS "Building for C++11")
add_definitions ("-std=c++11")
set (OSL_CSTD_FLAGS ${OSL_CSTD_FLAGS} "-std=c++11")
endif()
if (OSL_BUILD_CPP14)
message (STATUS "Building for C++14")
add_definitions ("-std=c++14")
set (OSL_CSTD_FLAGS ${OSL_CSTD_FLAGS} "-std=c++14")
endif()
if (CMAKE_COMPILER_IS_CLANG)
# C++ >= 11 doesn't like 'register' keyword, which is in Qt headers
@@ -289,10 +300,12 @@ if (USE_LIBCPLUSPLUS AND CMAKE_COMPILER_IS_CLANG)
add_definitions ("-stdlib=libc++")
endif ()
set (OSL_SIMD_FLAGS "")
if (NOT USE_SIMD STREQUAL "")
message (STATUS "Compiling with SIMD level ${USE_SIMD}")
if (USE_SIMD STREQUAL "0")
add_definitions ("-DOIIO_NO_SSE=1")
set (OSL_SIMD_FLAGS ${OSL_SIMD_FLAGS} "-DOIIO_NO_SSE=1")
else ()
string (REPLACE "," ";" SIMD_FEATURE_LIST ${USE_SIMD})
foreach (feature ${SIMD_FEATURE_LIST})
@@ -301,8 +314,10 @@ if (NOT USE_SIMD STREQUAL "")
endif ()
if (MSVC OR CMAKE_COMPILER_IS_INTEL)
add_definitions ("/arch:${feature}")
set (OSL_SIMD_FLAGS ${OSL_SIMD_FLAGS} "/arch:${feature}")
else ()
add_definitions ("-m${feature}")
set (OSL_SIMD_FLAGS ${OSL_SIMD_FLAGS} "-m${feature}")
endif ()
endforeach()
endif ()
@@ -516,11 +531,13 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
function-earlyreturn function-simple function-outputelem
geomath getattribute-camera getsymbol-nonheap gettextureinfo
group-outputs groupstring
hyperb ieee_fp if incdec initops intbits isconnected isconstant
hex hyperb
ieee_fp if incdec initops intbits isconnected isconstant
layers layers-Ciassign layers-entry layers-lazy
layers-nonlazycopy layers-repeatedoutputs
linearstep
logic loop matrix message mergeinstances-nouserdata
logic loop matrix message
mergeinstances-nouserdata mergeinstances-vararray
metadata-braces miscmath missing-shader
noise noise-cell
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
@@ -529,24 +546,28 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range
oslc-comma oslc-D
oslc-err-arrayindex oslc-err-closuremul
oslc-err-format oslc-err-intoverflow
oslc-err-noreturn oslc-err-outputparamvararray oslc-err-paramdefault
oslc-err-noreturn oslc-err-notfunc
oslc-err-outputparamvararray oslc-err-paramdefault
oslc-err-struct-array-init oslc-err-struct-dup
oslc-warn-commainit
oslc-variadic-macro
oslinfo-arrayparams oslinfo-metadata oslinfo-noparams
oslinfo-arrayparams oslinfo-colorctrfloat
oslinfo-metadata oslinfo-noparams
osl-imageio
printf-whole-array
raytype reparam
render-background render-bumptest
render-cornell render-furnace-diffuse
render-microfacet render-oren-nayar render-veachmis render-ward
shortcircuit spline splineinverse string
shortcircuit spline splineinverse spline-derivbug
string
struct struct-array struct-array-mixture
struct-err struct-in-struct-init struct-init-copy struct-layers
struct-with-array struct-within-struct
ternary
testshade-expr
texture-alpha texture-blur texture-derivs
texture-firstchannel texture-interp
texture-alpha texture-blur texture-connected-options
texture-derivs texture-firstchannel texture-interp
texture-missingcolor texture-simple
texture-smallderivs texture-swirl
texture-width texture-withderivs texture-wrap
+5
View File
@@ -98,6 +98,10 @@ ifneq (${USE_FAST_MATH},)
MY_CMAKE_FLAGS += -DUSE_FAST_MATH:BOOL=${USE_FAST_MATH}
endif
ifneq (${OPENEXR_HOME},)
MY_CMAKE_FLAGS += -DOPENEXR_HOME:STRING=${OPENEXR_HOME}
endif
ifneq (${ILMBASE_HOME},)
MY_CMAKE_FLAGS += -DILMBASE_HOME:STRING=${ILMBASE_HOME}
endif
@@ -328,6 +332,7 @@ help:
@echo " LINKSTATIC=1 Link with static external libraries when possible"
@echo " Finding and Using Dependencies:"
@echo " BOOST_HOME=path Custom Boost installation"
@echo " OPENEXR_HOME=path Custom OpenEXR installation"
@echo " ILMBASE_HOME=path Custom Ilmbase installation"
@echo " PARTIO_HOME= Use Partio from the given location"
@echo " USE_EXTERNAL_PUGIXML=1 Use the system PugiXML, not the one in OIIO"
+2 -3
View File
@@ -11,9 +11,8 @@ MY_CMAKE_FLAGS += -DHIDE_SYMBOLS:BOOL=1
MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=1
MY_CMAKE_FLAGS += -DLINKSTATIC:BOOL=1
MY_CMAKE_FLAGS += -DUSE_FAST_MATH:BOOL=1
MY_CMAKE_FLAGS += -DILMBASE_LIB_AREA:STRING=${ILMBASE_HOME}/lib/linux-ix86-64/gcc4.1
MY_CMAKE_FLAGS += -DILMBASE_CUSTOM:BOOL=True
MY_CMAKE_FLAGS += -DILMBASE_CUSTOM_LIBRARIES:STRING="Half-fPIC Iex-fPIC IexMath-fPIC IlmThread-fPIC Imath-fPIC"
MY_CMAKE_FLAGS += -DOPENEXR_CUSTOM_LIB_DIR:STRING=${ILMBASE_HOME}/lib/linux-ix86-64/gcc4.1
MY_CMAKE_FLAGS += -DOPENEXR_CUSTOM_LIB_SUFFIX:STRING="-fPIC"
# Don't build testshade or testrender (mostly because they require the
# image-handling parts of OIIO, which Pixar doesn't build)
+9 -30
View File
@@ -7,6 +7,7 @@ MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS="-DOSL_SPI=1"
## Generic OSX machines (including LG's laptop)
ifeq (${platform}, macosx)
USE_CPP11 ?= 1
MY_CMAKE_FLAGS += \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
@@ -86,24 +87,13 @@ ifeq ($(SP_OS), spinux1)
# Our minimal architecture for workstations and farm supports SSE 4.1
USE_SIMD = sse4.1
ifneq (,$(wildcard /usr/include/OpenEXR2))
MY_CMAKE_FLAGS += \
-DILMBASE_CUSTOM=1 \
-DILMBASE_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DILMBASE_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DILMBASE_CUSTOM_LIBRARIES="Imath Half IlmThread Iex"
else
MY_CMAKE_FLAGS += \
-DILMBASE_CUSTOM=1 \
-DILMBASE_CUSTOM_LIB_DIR=/usr/lib64 \
-DILMBASE_CUSTOM_LIBRARIES="SpiImath SpiHalf SpiIlmThread SpiIex"
endif
MY_CMAKE_FLAGS += \
-DLLVM_CUSTOM=1 \
-DLLVM_STATIC=1 \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libpthread.so" \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libcurses.so" \
-DLLVM_CUSTOM=1 \
-DLLVM_STATIC=1 \
-DLLVM_VERSION=${LLVM_VERSION} \
-DLLVM_DIRECTORY=${LLVM_DIRECTORY}
@@ -172,24 +162,13 @@ ifeq ($(SP_OS), rhel7)
# Our minimal architecture for workstations and farm supports SSE 4.1
USE_SIMD = sse4.1
ifneq (,$(wildcard /usr/include/OpenEXR2))
MY_CMAKE_FLAGS += \
-DILMBASE_CUSTOM=1 \
-DILMBASE_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DILMBASE_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DILMBASE_CUSTOM_LIBRARIES="Imath Half IlmThread Iex"
else
MY_CMAKE_FLAGS += \
-DILMBASE_CUSTOM=1 \
-DILMBASE_CUSTOM_LIB_DIR=/usr/lib64 \
-DILMBASE_CUSTOM_LIBRARIES="SpiImath SpiHalf SpiIlmThread SpiIex"
endif
MY_CMAKE_FLAGS += \
-DLLVM_CUSTOM=1 \
-DLLVM_STATIC=1 \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libpthread.so" \
-DEXTRA_OSLEXEC_LIBRARIES="/usr/lib64/libcurses.so" \
-DLLVM_CUSTOM=1 \
-DLLVM_STATIC=1 \
-DLLVM_VERSION=${LLVM_VERSION} \
-DLLVM_DIRECTORY=${LLVM_DIRECTORY}
+21 -10
View File
@@ -6,8 +6,8 @@ if (NOT VERBOSE)
set (Bison_FIND_QUIETLY true)
set (Boost_FIND_QUIETLY true)
set (Flex_FIND_QUIETLY true)
set (IlmBase_FIND_QUIETLY true)
set (LLVM_FIND_QUIETLY true)
set (OpenEXR_FIND_QUIETLY true)
set (OpenImageIO_FIND_QUIETLY true)
set (Partio_FIND_QUIETLY true)
set (PkgConfig_FIND_QUIETLY true)
@@ -52,16 +52,27 @@ endif ()
###########################################################################
# IlmBase setup
if (NOT ILMBASE_INCLUDE_DIR)
find_package (IlmBase REQUIRED)
if (NOT OPENEXR_FOUND)
find_package (OpenEXR REQUIRED)
endif ()
include_directories ("${ILMBASE_INCLUDE_DIR}")
include_directories ("${ILMBASE_INCLUDE_DIR}/OpenEXR")
#OpenEXR 2.2 still has problems with importing ImathInt64.h unqualified
#thus need for ilmbase/OpenEXR
include_directories ("${OPENEXR_INCLUDE_DIR}"
"${ILMBASE_INCLUDE_DIR}"
"${ILMBASE_INCLUDE_DIR}/OpenEXR")
macro (LINK_ILMBASE target)
target_link_libraries (${target} ${ILMBASE_LIBRARIES})
endmacro ()
if (${OPENEXR_VERSION} VERSION_LESS 2.0.0)
# OpenEXR 1.x had weird #include dirctives, this is also necessary:
include_directories ("${OPENEXR_INCLUDE_DIR}/OpenEXR")
else ()
add_definitions (-DUSE_OPENEXR_VERSION2=1)
endif ()
if (NOT OpenEXR_FIND_QUIETLY)
message (STATUS "ILMBASE_INCLUDE_DIR = ${ILMBASE_INCLUDE_DIR}")
message (STATUS "ILMBASE_LIBRARIES = ${ILMBASE_LIBRARIES}")
endif ()
# end IlmBase setup
###########################################################################
@@ -169,9 +180,9 @@ endif()
# try to find llvm-config, with a specific version if specified
if(LLVM_DIRECTORY)
FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS "${LLVM_DIRECTORY}/bin" NO_CMAKE_PATH)
FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH)
if(NOT LLVM_CONFIG)
FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS "${LLVM_DIRECTORY}/bin" NO_CMAKE_PATH)
FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH)
endif()
else()
FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})
-260
View File
@@ -1,260 +0,0 @@
# Module to find IlmBase
#
# This module will first look into the directories defined by the variables:
# - ILMBASE_HOME, ILMBASE_VERSION, ILMBASE_LIB_AREA
#
# It also supports non-standard names for the library components.
#
# To use a custom IlmBase:
# - Set the variable ILMBASE_CUSTOM to True
# - Set the variable ILMBASE_CUSTOM_LIBRARIES to a list of the libraries to
# use, e.g. "SpiImath SpiHalf SpiIlmThread SpiIex"
# - Optionally set the variable ILMBASE_CUSTOM_INCLUDE_DIR to any
# particularly weird place that the OpenEXR/*.h files may be found
# - Optionally set the variable ILMBASE_CUSTOM_LIB_DIR to any
# particularly weird place that the libraries files may be found
#
# This module defines the following variables:
#
# ILMBASE_INCLUDE_DIR - where to find half.h, IlmBaseConfig.h, etc.
# ILMBASE_LIBRARIES - list of libraries to link against when using IlmBase.
# ILMBASE_FOUND - True if IlmBase was found.
# Other standarnd issue macros
include (FindPackageHandleStandardArgs)
include (FindPackageMessage)
include (SelectLibraryConfigurations)
if( ILMBASE_USE_STATIC_LIBS )
set( _ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
endif()
endif()
# Macro to assemble a helper state variable
macro (SET_STATE_VAR varname)
set (tmp_ilmbaselibs ${ILMBASE_CUSTOM_LIBRARIES})
separate_arguments (tmp_ilmbaselibs)
set (tmp_lst
${ILMBASE_CUSTOM} | ${tmp_ilmbaselibs} |
${ILMBASE_HOME} | ${ILMBASE_VERSION} | ${ILMBASE_LIB_AREA}
)
set (${varname} "${tmp_lst}")
unset (tmp_ilmbaselibs)
unset (tmp_lst)
endmacro ()
# To enforce that find_* functions do not use inadvertently existing versions
if (ILMBASE_CUSTOM)
set (ILMBASE_FIND_OPTIONS "NO_DEFAULT_PATH")
endif ()
# Macro to search for an include directory
macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
find_path(${tmp_varname} ${includefile}
HINTS ${${libpath_var}}
PATH_SUFFIXES include
${ILMBASE_FIND_OPTIONS}
)
if (${tmp_varname})
mark_as_advanced (${tmp_varname})
endif ()
unset (tmp_varname)
endmacro ()
# Macro to search for the given library and adds the cached
# variable names to the specified list
macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
string (TOUPPER ${prefix}_${libname} tmp_prefix)
# Handle new library names for OpenEXR 2.1 build via cmake
string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION})
string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION )
find_library(${tmp_prefix}_LIBRARY_RELEASE
NAMES ${libname} ${libname}-${_ILMBASE_VERSION}
HINTS ${${libpath_var}}
PATH_SUFFIXES lib
${ILMBASE_FIND_OPTIONS}
)
find_library(${tmp_prefix}_LIBRARY_DEBUG
NAMES ${libname}d ${libname}_d ${libname}debug ${libname}_debug
HINTS ${${libpath_var}}
PATH_SUFFIXES lib
${ILMBASE_FIND_OPTIONS}
)
# Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES
select_library_configurations (${tmp_prefix})
list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
# Add to the list of variables which should be reset
list (APPEND ${cachelist_var}
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
mark_as_advanced (
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
unset (tmp_prefix)
endmacro ()
# Encode the current state of the external variables into a string
SET_STATE_VAR (ILMBASE_CURRENT_STATE)
# If the state has changed, clear the cached variables
if (ILMBASE_CACHED_STATE AND
NOT ILMBASE_CACHED_STATE STREQUAL ILMBASE_CURRENT_STATE)
foreach (libvar ${ILMBASE_CACHED_VARS})
unset (${libvar} CACHE)
endforeach ()
endif ()
# Generic search paths
set (IlmBase_generic_include_paths
${ILMBASE_CUSTOM_INCLUDE_DIR}
/usr/include
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/include
/sw/include
/opt/local/include)
set (IlmBase_generic_library_paths
${ILMBASE_CUSTOM_LIB_DIR}
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/sw/lib
/opt/local/lib)
# Search paths for the IlmBase files
if (ILMBASE_HOME)
if (ILMBASE_VERSION)
set (IlmBase_include_paths
${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/include
${ILMBASE_HOME}/include/ilmbase-${ILMBASE_VERSION})
set (IlmBase_library_paths
${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/lib
${ILMBASE_HOME}/lib/ilmbase-${ILMBASE_VERSION})
endif()
list (APPEND IlmBase_include_paths ${ILMBASE_HOME}/include)
set (IlmBase_library_paths
${ILMBASE_HOME}/lib
${ILMBASE_HOME}/lib64
${ILMBASE_LIB_AREA}
${IlmBase_library_paths})
endif ()
list (APPEND IlmBase_include_paths ${IlmBase_generic_include_paths})
list (APPEND IlmBase_library_paths ${IlmBase_generic_library_paths})
# Locate the header files
PREFIX_FIND_INCLUDE_DIR (IlmBase
OpenEXR/IlmBaseConfig.h IlmBase_include_paths)
if (ILMBASE_INCLUDE_DIR)
# Get the version from config file, if not already set.
if (NOT ILMBASE_VERSION)
FILE(STRINGS "${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h" ILMBASE_BUILD_SPECIFICATION
REGEX "^[ \t]*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
if(ILMBASE_BUILD_SPECIFICATION)
if (NOT IlmBase_FIND_QUIETLY)
message(STATUS "${ILMBASE_BUILD_SPECIFICATION}")
endif ()
string(REGEX REPLACE ".*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
"\\1" XYZ ${ILMBASE_BUILD_SPECIFICATION})
set("ILMBASE_VERSION" ${XYZ} CACHE STRING "Version of ILMBase lib")
else()
# Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though.
message(WARNING "Could not determine ILMBase library version, assuming 2.0.")
set("ILMBASE_VERSION" "2.0" CACHE STRING "Version of ILMBase lib")
endif()
endif()
endif ()
if (ILMBASE_CUSTOM)
if (NOT ILMBASE_CUSTOM_LIBRARIES)
message (FATAL_ERROR "Custom IlmBase libraries requested but ILMBASE_CUSTOM_LIBRARIES is not set.")
endif()
set (IlmBase_Libraries ${ILMBASE_CUSTOM_LIBRARIES})
separate_arguments(IlmBase_Libraries)
else ()
#elseif (${ILMBASE_VERSION} VERSION_LESS "2.1")
set (IlmBase_Libraries Half Iex Imath IlmThread)
#else ()
# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _ilmbase_libs_ver ${ILMBASE_VERSION})
# set (IlmBase_Libraries Half Iex-${_ilmbase_libs_ver} Imath-${_ilmbase_libs_ver} IlmThread-${_ilmbase_libs_ver})
endif ()
# Locate the IlmBase libraries
set (IlmBase_libvars "")
set (IlmBase_cachevars "")
foreach (ilmbase_lib ${IlmBase_Libraries})
PREFIX_FIND_LIB (IlmBase ${ilmbase_lib}
IlmBase_library_paths IlmBase_libvars IlmBase_cachevars)
endforeach ()
# Create the list of variables that might need to be cleared
set (ILMBASE_CACHED_VARS
ILMBASE_INCLUDE_DIR ${IlmBase_cachevars}
CACHE INTERNAL "Variables set by FindIlmBase.cmake" FORCE)
# Store the current state so that variables might be cleared if required
set (ILMBASE_CACHED_STATE ${ILMBASE_CURRENT_STATE}
CACHE INTERNAL "State last seen by FindIlmBase.cmake" FORCE)
# Link with pthreads if required
if (NOT WIN32 AND EXISTS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h)
file (STRINGS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h
ILMBASE_HAVE_PTHREAD
REGEX "^[ \\t]*#define[ \\t]+HAVE_PTHREAD[ \\t]1[ \\t]*\$"
)
if (ILMBASE_HAVE_PTHREAD)
find_package (Threads)
if (CMAKE_USE_PTHREADS_INIT)
set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
endif ()
endif ()
endif ()
# Use the standard function to handle ILMBASE_FOUND
FIND_PACKAGE_HANDLE_STANDARD_ARGS (IlmBase DEFAULT_MSG
ILMBASE_INCLUDE_DIR ${IlmBase_libvars})
if (ILMBASE_FOUND)
set (ILMBASE_LIBRARIES "")
foreach (tmplib ${IlmBase_libvars})
list (APPEND ILMBASE_LIBRARIES ${${tmplib}})
endforeach ()
list (APPEND ILMBASE_LIBRARIES ${ILMBASE_PTHREADS})
if (NOT IlmBase_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE (ILMBASE
"Found IlmBase: ${ILMBASE_LIBRARIES}"
"[${ILMBASE_INCLUDE_DIR}][${ILMBASE_LIBRARIES}][${ILMBASE_CURRENT_STATE}]"
)
endif ()
endif ()
# Restore the original find library ordering
if( ILMBASE_USE_STATIC_LIBS )
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
# Unset the helper variables to avoid pollution
unset (ILMBASE_CURRENT_STATE)
unset (IlmBase_include_paths)
unset (IlmBase_library_paths)
unset (IlmBase_generic_include_paths)
unset (IlmBase_generic_library_paths)
unset (IlmBase_libvars)
unset (IlmBase_cachevars)
unset (ILMBASE_PTHREADS)
+137
View File
@@ -0,0 +1,137 @@
# Module to find OpenEXR.
#
# This module will set
# OPENEXR_FOUND true, if found
# OPENEXR_INCLUDE_DIR directory where headers are found
# OPENEXR_LIBRARIES libraries for OpenEXR + IlmBase
# ILMBASE_LIBRARIES libraries just IlmBase
# OPENEXR_VERSION OpenEXR version (accurate for >= 2.0.0,
# otherwise will just guess 1.6.1)
#
# Special inputs:
# OPENEXR_CUSTOM_INCLUDE_DIR - custom location of headers
# OPENEXR_CUSTOM_LIB_DIR - custom location of libraries
# OPENEXR_CUSTOM_LIB_PREFIX - special snowflake library prefix
# OPENEXR_CUSTOM_LIB_SUFFIX - special snowflake library suffix
#
# Other standarnd issue macros
include (FindPackageHandleStandardArgs)
include (SelectLibraryConfigurations)
find_package (ZLIB REQUIRED)
# List of likely places to find the headers -- note priority override of
# OPENEXR_CUSTOM_INCLUDE_DIR and ${OPENEXR_HOME}/include.
# ILMBASE is needed in case ilmbase an openexr are installed in separate
# directories, like NixOS does
set (GENERIC_INCLUDE_PATHS
${OPENEXR_CUSTOM_INCLUDE_DIR}
${OPENEXR_HOME}/include
${ILMBASE_HOME}/include
/usr/include
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/include
/sw/include
/opt/local/include )
# List of likely places to find the libraries -- note priority override of
# OPENEXR_CUSTOM_LIB_DIR and ${OPENEXR_HOME}/lib.
set (GENERIC_LIBRARY_PATHS
${OPENEXR_CUSTOM_LIB_DIR}
${OPENEXR_HOME}/lib
${ILMBASE_HOME}/lib
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/sw/lib
/opt/local/lib
$ENV{PROGRAM_FILES}/OpenEXR/lib/static )
# Find the include file locations. We call find_path twice -- first using
# only the custom paths, then if that fails, try the default paths only.
# This seems to be the most robust way I can find to not get confused when
# both system and custom libraries are present.
find_path (ILMBASE_INCLUDE_PATH OpenEXR/IlmBaseConfig.h
PATHS ${GENERIC_INCLUDE_PATHS} NO_DEFAULT_PATH)
find_path (ILMBASE_INCLUDE_PATH OpenEXR/IlmBaseConfig.h)
find_path (OPENEXR_INCLUDE_PATH OpenEXR/OpenEXRConfig.h
PATHS ${GENERIC_INCLUDE_PATHS} NO_DEFAULT_PATH)
find_path (OPENEXR_INCLUDE_PATH OpenEXR/OpenEXRConfig.h)
# Handle request for static libs by altering CMAKE_FIND_LIBRARY_SUFFIXES.
# We will restore it at the end of this file.
set (_openexr_orig_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
if (OpenEXR_USE_STATIC_LIBS)
if (WIN32)
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else ()
set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif ()
endif ()
# Look for the libraries themselves, for all the components. Like with the
# headers, we do two finds -- first for custom locations, then for default.
set (_openexr_components IlmThread IlmImf Imath Iex Half)
foreach (COMPONENT ${_openexr_components})
string (TOUPPER ${COMPONENT} UPPERCOMPONENT)
set (FULL_COMPONENT_NAME ${OPENEXR_CUSTOM_LIB_PREFIX}${COMPONENT}${OPENEXR_CUSTOM_LIB_SUFFIX})
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY ${FULL_COMPONENT_NAME}
PATHS ${GENERIC_LIBRARY_PATHS} NO_DEFAULT_PATH)
find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY ${FULL_COMPONENT_NAME})
endforeach ()
#Half usually has no suffix
find_library (OPENEXR_HALF_LIBRARY ${OPENEXR_CUSTOM_LIB_PREFIX}Half
PATHS ${GENERIC_LIBRARY_PATHS} NO_DEFAULT_PATH)
find_library (OPENEXR_HALF_LIBRARY ${OPENEXR_CUSTOM_LIB_PREFIX}Half)
# Link with pthreads if required
find_package (Threads)
if (CMAKE_USE_PTHREADS_INIT)
set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
endif ()
# Set the FOUND, INCLUDE_DIR, and LIBRARIES variables.
if (ILMBASE_INCLUDE_PATH AND OPENEXR_INCLUDE_PATH AND
OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND
OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
set (OPENEXR_FOUND TRUE)
set (ILMBASE_FOUND TRUE)
set (ILMBASE_INCLUDE_DIR ${ILMBASE_INCLUDE_PATH} CACHE STRING "The include paths needed to use IlmBase")
set (OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDE_PATH} CACHE STRING "The include paths needed to use OpenEXR")
set (ILMBASE_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ILMBASE_PTHREADS} CACHE STRING "The libraries needed to use IlmBase")
set (OPENEXR_LIBRARIES ${OPENEXR_ILMIMF_LIBRARY} ${ILMBASE_LIBRARIES} ${ZLIB_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR")
endif ()
# Try to figure out version number
if (EXISTS "${OPENEXR_INCLUDE_DIR}/OpenEXR/ImfMultiPartInputFile.h")
# Must be at least 2.0
file(STRINGS "${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_STRING .*$")
string (REGEX MATCHALL "[0-9]+[.0-9]+" OPENEXR_VERSION ${TMP})
else ()
# Assume an old one, predates 2.x that had versions
set (OPENEXR_VERSION 1.6.1)
endif ()
find_package_handle_standard_args (OpenEXR
REQUIRED_VARS ILMBASE_INCLUDE_PATH OPENEXR_INCLUDE_PATH
OPENEXR_IMATH_LIBRARY OPENEXR_ILMIMF_LIBRARY
OPENEXR_IEX_LIBRARY OPENEXR_HALF_LIBRARY
VERSION_VAR OPENEXR_VERSION
)
MARK_AS_ADVANCED(
ILMBASE_INCLUDE_DIR
OPENEXR_INCLUDE_DIR
ILMBASE_LIBRARIES
OPENEXR_LIBRARIES
OPENEXR_ILMIMF_LIBRARY
OPENEXR_IMATH_LIBRARY
OPENEXR_IEX_LIBRARY
OPENEXR_HALF_LIBRARY
OPENEXR_VERSION)
# Restore the original CMAKE_FIND_LIBRARY_SUFFIXES
set (CMAKE_FIND_LIBRARY_SUFFIXES ${_openexr_orig_suffixes})
+42 -20
View File
@@ -62,7 +62,7 @@ Editor: Larry Gritz \\
\emph{lg@imageworks.com}
}
\date{{\large Date: 14 Jan, 2016 \\
%~ (with corrections, 14 Jan 2016)
(with corrections, 5 Jul 2016)
}
\bigskip
\bigskip
@@ -472,15 +472,15 @@ overridden with an instance-specific value of {\cf 2.2}.
\subsection*{Shader groups and layers}
\subsection*{Shader groups, layers, and connections}
A \emph{shader group} is an ordered sequence of individual shaders
called \emph{layers} that are executed in turn. Output parameters of an
earlier-executed layer may be \emph{connected} to an input parameter of
a later-executed layer. This connected network of layers is sometimes
called a \emph{shader network} or a \emph{shader DAG} (directed acyclic
graph). Of course, it is fine for the shader group to consist of a
single shader layer.
A \emph{shader group}\index{shader group} is an ordered sequence of
individual shaders called \emph{layers}\index{layer}\index{shader layer}
that are executed in turn. Output parameters of an earlier-executed layer
may be \emph{connected} to an input parameter of a later-executed layer.
This connected network of layers is sometimes called a \emph{shader network}
or a \emph{shader DAG} (directed acyclic graph). Of course, it is fine for
the shader group to consist of a single shader layer.
Below is a schematic showing how several shader instances may be
connected to form a shader group.
@@ -517,7 +517,7 @@ it might be done.}:
\end{code}
\noindent Or, expressed as serialized text (as detailed in
Appendix~\ref{chap:serialize}):
Chapter~\ref{sec:serialize}):
\begin{code}
param string name "rings.tx" ;
@@ -535,7 +535,18 @@ Appendix~\ref{chap:serialize}):
connect gam2.Cout wood1.grain ;
\end{code}
The rules for which data types may be connected are generally the same as
the rules determining which variables may be assigned to each other in OSL
source code:
\begin{itemize}
\item {\cf source} and {\cf dest} are the same data type.
\item {\cf source} and {\cf dest} are both \emph{triples} (\color, \point,
\vector, or \normal), even if they are not the same kind of triple.
\item {\cf source} is an {\cf int} and {\cf dest} is a {\cf float}.
\item {\cf source} is a {\cf float} or {\cf int} and {\cf dest} is a
\emph{triple} (the scalar value will be replicated for all three components
of the triple).
\end{itemize}
\subsection*{Geometric primitives}
@@ -547,7 +558,8 @@ polygons, and curves. The exact set of supported primitives may vary
from renderer to renderer.
Each geometric primitive carries around a set of named \emph{primitive
variables}. Nearly all shape types will have, among their primitive
variables} (also sometimes called \emph{interpolated values} or
\emph{user data}). Nearly all shape types will have, among their primitive
variables, control point positions that, when interpolated, actually
designate the shape. Some shapes will also allow the specification of
normals or other shape-specific data. Arbitrary user data may also be
@@ -842,6 +854,7 @@ uniform union unsigned varying virtual volatile
\indexapi{\#else}
\indexapi{\#endif}
\indexapi{\#include}
\indexapi{\#pragma}
Shader source code is passed through a standard C preprocessor as a
first step in parsing.
@@ -864,6 +877,7 @@ directives, including:
#else
#endif
#include
#pragma once
\end{code}
@@ -1450,7 +1464,8 @@ the {\cf int} type is renderer-dependent, but is guaranteed to be at
least 32 bits.
Integer constants are constructed the same way as in C. The following
are examples of {\cf int} constants: {\cf 1}, {\cf -32}, etc.
are examples of {\cf int} constants: {\cf 1}, {\cf -32}, etc. Integer
constants may be specified as hexidecimal, for example: {\cf 0x01cf}.
Unlike C, no unsigned, bool, char, short, or long types are supplied.
This is to simplify the process of writing shaders (as well as
@@ -2573,7 +2588,7 @@ loop:
\indexapi{for}
As in C++, a {\cf for} loop's initialization may contain variable
declarations and initializations, which are scoped locally to {\cf for}
declarations and initializations, which are scoped locally to the {\cf for}
loop itself. For example,
\begin{code}
@@ -2656,9 +2671,9 @@ P/\partial u$ and $\partial P/\partial v$ tangent to the surface at \P. \\
% {\cf Pl}). \\
%\hline
%\color\ {\ce Cl} & Incoming light color at P. \\
%\hline
\hline
\point\ {\ce Ps} & Position at which the light is being queried
(currently only used for light attentuation shaders) \\
(currently only used for light attenuation shaders) \\
%\\
%\hline
%\normal\ {\ce Ns} & Axis about which the light is being queried
@@ -2729,6 +2744,7 @@ P/\partial u$ and $\partial P/\partial v$ tangent to the surface at \P. \\
{\cf Ng} & R & R & \\
{\cf dPdu} & R & R & \\
{\cf dPdv} & R & R & \\
{\cf Ps} & & & R \\
{\cf u, v} & R & R & R \\
{\cf time} & R & R & R \\
{\cf dtime} & R & R & R \\
@@ -3417,7 +3433,7 @@ derivatives. Gabor noise allows several optional parameters to the
"direction", <vector>}
\vspace{12pt}
If {\cf anisotropic} is 0 (the default), Gabor noise
will be isotropic. If {\cf anisotripic} is 1, the Gabor noise will
will be isotropic. If {\cf anisotropic} is 1, the Gabor noise will
be anisotropic with the 3D frequency given by the {\cf direction}
vector (which defaults to {\cf (1,0,0)}). If {\cf anisotropic} is
2, a hybrid mode will be used which is anisotropic along the
@@ -4273,7 +4289,7 @@ given {\cf data} arrays. If the optional {\cf sort} parameter is present
and is nonzero, the ordering of the points
found will be sorted by distance from {\cf pos}, from closest to farthest;
otherwise, the results are guaranteed to be the {\cf maxpoints} closest
to {\cf pos}, but not necessarily softed by distance (this may be
to {\cf pos}, but not necessarily sorted by distance (this may be
faster for some implementations than when sorted results are
required). The return value is the number of points returned, ranging
from 0 (nothing found in the neighborhood) to the lesser of {\cf maxpoints}
@@ -4530,7 +4546,7 @@ the previous function.
\apiend
\apiitem{\colorclosure\ \colorclosure\ {\ce reflection} (normal N, float eta)}
\apiitem{\colorclosure\ {\ce reflection} (normal N, float eta)}
\indexapi{reflection()}
Returns a \colorclosure that represents sharp mirror-like reflection
@@ -4714,7 +4730,8 @@ int {\ce getattribute} (string object, string name, output \emph{type} destinati
int {\ce getattribute} (string object, string name, int arrayindex, \\
\bigspc\spc\spc output \emph{type} destination)}
\indexapi{getattribute()}
Searches for the renderer attribute with the given \emph{name}.
Retrieves a named renderer attribute or the value of an interpolated
geometric variable.
If an object is explicitly named, that is the only place that will be
searched (\qkw{global} means the global scene-wide attributes). For the
forms of the function with no object name, or if the object name is the
@@ -5077,7 +5094,12 @@ nothing (empty, no token).
<digit-sequence> ::= <digit> \{ <digit> \}
<hexdigit> ::= <digit> | "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "E" | "f" | "F"
<hexdigit-sequence> ::= <hexdigit> \{ <hexdigit> \}
<integer> ::= <sign> <digit-sequence>
\alt <sign> "0x" <hexdigit-sequence>
<floating-point> ::= <digit-sequence> <decimal-part-opt> <exponent-opt>
\alt <decimal-part> <exponent-opt>
Binary file not shown.
+3
View File
@@ -123,6 +123,9 @@ public:
/// int lazyunconnected Run layers lazily even if they have no
/// output connections (1). For debugging.
/// int lazy_userdata Retrieve userdata lazily (0).
/// int userdata_isconnected Should lockgeom=0 params (that may
/// receive userdata) return true from
/// isconnected()? (0)
/// int greedyjit Optimize and compile all shaders up front,
/// versus only as needed (0).
/// int lockgeom Default 'lockgeom' value for shader params
+2 -2
View File
@@ -20,8 +20,8 @@ else ()
ADD_LIBRARY ( oslcomp SHARED ${liboslcomp_srcs} )
endif ()
TARGET_LINK_LIBRARIES ( oslcomp ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
LINK_ILMBASE ( oslcomp )
TARGET_LINK_LIBRARIES ( oslcomp ${OPENIMAGEIO_LIBRARY} ${ILMBASE_LIBRARIES}
${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS oslcomp RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
+13 -3
View File
@@ -260,10 +260,18 @@ ASTfunction_declaration::add_meta (ASTNode *meta)
Symbol *metasym = metavar->sym();
if (metasym->name() == "builtin") {
m_is_builtin = true;
if (func()->typespec().is_closure()) // It is a builtin closure
if (func()->typespec().is_closure()) { // It is a builtin closure
// Force keyword arguments at the end
func()->argcodes(ustring(std::string(func()->argcodes().c_str()) + "."));
}
// For built-in functions, if any of the params are output,
// also automatically mark it as readwrite_special_case.
for (ASTNode *f = formals().get(); f; f = f->nextptr()) {
ASSERT (f->nodetype() == variable_declaration_node);
ASTvariable_declaration *v = (ASTvariable_declaration *)f;
if (v->is_output())
func()->readwrite_special_case (true);
}
}
else if (metasym->name() == "derivs")
func()->takes_derivs (true);
@@ -446,7 +454,8 @@ ASTindex::ASTindex (OSLCompilerImpl *comp, ASTNode *expr, ASTNode *index)
expr->nodetype() == structselect_node);
if (expr->typespec().is_array()) // array dereference
m_typespec = expr->typespec().elementtype();
else if (expr->typespec().is_triple()) // component access
else if (!expr->typespec().is_closure() &&
expr->typespec().is_triple()) // component access
m_typespec = TypeDesc::FLOAT;
else {
error ("indexing into non-array or non-component type");
@@ -900,6 +909,7 @@ ASTfunction_call::ASTfunction_call (OSLCompilerImpl *comp, ustring name,
}
if (m_sym->symtype() != SymTypeFunction) {
error ("'%s' is not a function", name.c_str());
m_sym = NULL;
return;
}
}
+8
View File
@@ -663,12 +663,15 @@ ASTvariable_declaration::param_one_default_literal (const Symbol *sym,
val = val->next();
completed = false;
}
bool one_arg = (val && ! val->nextptr());
for (int c = 0; c < 3; ++c) {
if (val.get())
++nargs;
if (val.get() && val->nodetype() == ASTNode::literal_node) {
f[c] = ((ASTliteral *)val.get())->floatval ();
val = val->next();
} else if (c > 0 && one_arg) {
f[c] = f[0];
} else {
f[c] = 0;
completed = false;
@@ -699,6 +702,11 @@ ASTvariable_declaration::param_one_default_literal (const Symbol *sym,
ASTNode::ref val = ctr->args();
float f[16];
int nargs = 0;
DASSERT (val.get());
if (val->nodetype() == ASTNode::literal_node && val->typespec().is_string()) {
val = val->next();
completed = false;
}
for (int c = 0; c < 16; ++c) {
if (val.get())
++nargs;
+25
View File
@@ -41,6 +41,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%option noyywrap
%option nounput noinput
/* never-interactive fixes a Windows compatibility problem where the
* lexer emits isatty calls that don't exist.
*/
%option never-interactive
/* Option 'prefix' creates a C++ lexer with the given prefix, so that
* we can link with other flex-generated lexers in the same application
* without name conflicts.
@@ -59,6 +64,7 @@ ALPHA [A-Za-z]
DIGIT [0-9]
/* Integer literal */
INTEGER {DIGIT}+
HEXINTEGER 0[xX][0-9a-fA-F]+
/* floating point literal (E, FLT1, FLT2, FLT3 are just helpers)
* NB: we don't allow leading +/- due to ambiguity between
* whether "a-0.5" is really "a -0.5" or "a - 0.5". Resolve this
@@ -91,6 +97,7 @@ CPLUSCOMMENT \/\/.*\n
#include <vector>
#include <string>
#include <OpenImageIO/thread.h>
#include "oslcomp_pvt.h"
using namespace OSL;
@@ -106,6 +113,8 @@ using namespace OSL::pvt;
#ifdef _MSC_VER
#define strtoll _strtoi64
#include <io.h>
#define isatty _isatty
#endif
#endif
@@ -196,6 +205,22 @@ void preprocess (const char *yytext);
SETLINE;
return INT_LITERAL;
}
{HEXINTEGER} {
long long llval = strtoll (yytext, (char**)NULL, 16);
// we do not detect overflow when the value is INT_MAX+1,
// because negation happens later and -(INT_MAX+1) == INT_MIN
if (llval > ((long long)UINT_MAX)+1) {
oslcompiler->error (oslcompiler->filename(),
oslcompiler->lineno(),
"integer overflow, value must be between %d and %d.",
INT_MIN, INT_MAX);
}
yylval.i = (int)llval;
SETLINE;
return INT_LITERAL;
}
{FLT} {
yylval.f = atof (yytext);
+32 -1
View File
@@ -122,6 +122,19 @@ ASTvariable_declaration::typecheck (TypeSpec expected)
typecheck_initlist (init, m_typespec, m_name.c_str());
// Warning to catch confusing comma operator in variable initializers.
// One place this comes up is when somebody forgets the proper syntax
// for constructors, for example
// color x = (a, b, c); // Sets x to (c,c,c)!
// when they really meant
// color x = color(a, b, c);
if (init->nodetype() == comma_operator_node && !typespec().is_closure() &&
(typespec().is_triple() || typespec().is_matrix())) {
warning ("Comma operator is very confusing here. "
"Did you mean to use a constructor: %s = %s(...)?",
m_name.c_str(), typespec().c_str());
}
return m_typespec;
}
@@ -432,6 +445,19 @@ ASTassign_expression::typecheck (TypeSpec expected)
return TypeSpec();
}
// Warning to catch confusing comma operator in assignment.
// One place this comes up is when somebody forgets the proper syntax
// for constructors, for example
// color x = (a, b, c); // Sets x to (c,c,c)!
// when they really meant
// color x = color(a, b, c);
if (expr()->nodetype() == comma_operator_node && !vt.is_closure() &&
(vt.is_triple() || vt.is_matrix())) {
warning ("Comma operator is very confusing here. "
"Did you mean to use a constructor: = %s(...)?",
vt.c_str());
}
return m_typespec = vt;
}
@@ -993,7 +1019,8 @@ ASTfunction_call::typecheck_builtin_specialcase ()
argwriteonly (1);
argwriteonly (2);
} else if (m_name == "getattribute" || m_name == "getmessage" ||
m_name == "gettextureinfo" || m_name == "dict_value") {
m_name == "gettextureinfo" || m_name == "getmatrix" ||
m_name == "dict_value") {
// these all write to their last argument
argwriteonly ((int)listlength(args()));
} else if (m_name == "pointcloud_get") {
@@ -1167,8 +1194,12 @@ ASTfunction_call::typecheck (TypeSpec expected)
actualargs += arg->typespec().string();
}
if (choices.size())
error ("No matching function call to '%s (%s)'\n Candidates are:\n%s",
m_name.c_str(), actualargs.c_str(), choices.c_str());
else
error ("No matching function call to '%s (%s)'",
m_name.c_str(), actualargs.c_str());
return TypeSpec();
}
+4 -7
View File
@@ -69,9 +69,7 @@ MACRO ( LLVM_COMPILE llvm_src srclist )
foreach (def ${CURRENT_DEFINITIONS})
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-D${def}")
endforeach()
if (USE_SIMD)
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} "-m${USE_SIMD}")
endif ()
set (LLVM_COMPILE_FLAGS ${LLVM_COMPILE_FLAGS} ${OSL_SIMD_FLAGS} ${OSL_CSTD_FLAGS})
# Figure out what program we will use to make the bitcode.
if (NOT LLVM_BC_GENERATOR)
@@ -116,6 +114,7 @@ MACRO ( LLVM_COMPILE llvm_src srclist )
"-I${ILMBASE_INCLUDE_DIR}"
"-I${Boost_INCLUDE_DIRS}"
-DOSL_COMPILING_TO_BITCODE=1
-Wno-deprecated-register
-O3 -fno-math-errno -S -emit-llvm -o ${llvm_asm} ${llvm_src}
COMMAND "${LLVM_DIRECTORY}/bin/llvm-as" -f -o ${llvm_bc} ${llvm_asm}
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/serialize-bc.bash" ${llvm_bc} ${llvm_bc_cpp}
@@ -142,14 +141,14 @@ endif ()
TARGET_LINK_LIBRARIES ( oslexec
${VISIBILITY_COMMAND} ${VISIBILITY_MAP_COMMAND}
${OPENIMAGEIO_LIBRARY} ${PUGIXML_LIBRARIES}
${OPENIMAGEIO_LIBRARY} ${ILMBASE_LIBRARIES}
${PUGIXML_LIBRARIES}
${PARTIO_LIBRARIES} ${ZLIB_LIBRARIES}
${Boost_LIBRARIES} ${CMAKE_DL_LIBS}
${LLVM_LIBRARY} ${LLVM_MCJIT_LIBRARY}
${LLVM_LIBRARIES} ${LLVM_LDFLAGS}
${EXTRA_OSLEXEC_LIBRARIES})
ADD_DEPENDENCIES (oslexec "${CMAKE_CURRENT_SOURCE_DIR}/liboslexec.map")
LINK_ILMBASE ( oslexec )
INSTALL ( TARGETS oslexec RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
@@ -157,11 +156,9 @@ INSTALL ( TARGETS oslexec RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIV
if (OSL_BUILD_TESTS)
add_executable (accum_test accum_test.cpp)
target_link_libraries ( accum_test oslexec oslcomp ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${EXTRA_OSLEXEC_LIBRARIES} )
link_ilmbase (accum_test)
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} ${EXTRA_OSLEXEC_LIBRARIES} )
link_ilmbase (llvmutil_test)
add_test (unit_llvmutil "${CMAKE_BINARY_DIR}/src/liboslexec/llvmutil_test")
endif ()
-3
View File
@@ -455,9 +455,6 @@ ShadingContext::free_dict_resources ()
}
#define USTR(cstr) (*((ustring *)&cstr))
#define TYPEDESC(x) (*(TypeDesc *)&x)
OSL_SHADEOP int osl_dict_find_iis (void *sg_, int nodeID, void *query)
{
+11 -3
View File
@@ -214,9 +214,13 @@ ShaderInstance::parameters (const ParamValueList &params)
m_instoverrides.resize (std::max (0, lastparam()));
// Set the initial lockgeom on the instoverrides, based on the master.
for (int i = 0, e = (int)m_instoverrides.size(); i < e; ++i)
m_instoverrides[i].lockgeom (master()->symbol(i)->lockgeom());
// Set the initial lockgeom and dataoffset on the instoverrides, based
// on the master.
for (int i = 0, e = (int)m_instoverrides.size(); i < e; ++i) {
Symbol *sym = master()->symbol(i);
m_instoverrides[i].lockgeom (sym->lockgeom());
m_instoverrides[i].dataoffset (sym->dataoffset());
}
BOOST_FOREACH (const ParamValue &p, params) {
if (p.name().size() == 0)
@@ -257,6 +261,9 @@ ShaderInstance::parameters (const ParamValueList &params)
p.interp() == ParamValue::INTERP_CONSTANT);
so->lockgeom (lockgeom);
DASSERT (so->dataoffset() == sm->dataoffset());
so->dataoffset (sm->dataoffset());
if (paramtype.arraylen < 0) {
// An array of definite size was supplied to a parameter
// that was an array of indefinite size. Magic! The trick
@@ -460,6 +467,7 @@ ShaderInstance::copy_code_from_master (ShaderGroup &group)
si->valuesource (m_instoverrides[i].valuesource());
si->connected_down (m_instoverrides[i].connected_down());
si->lockgeom (m_instoverrides[i].lockgeom());
si->dataoffset (m_instoverrides[i].dataoffset());
si->data (param_storage(i));
}
if (shadingsys().is_renderer_output (layername(), si->name(), &group)) {
+2 -2
View File
@@ -2023,8 +2023,8 @@ llvm_gen_texture_options (BackendLLVM &rop, int opnum,
Symbol &Val (*rop.opargsym(op,a));
TypeDesc valtype = Val.typespec().simpletype ();
const int *ival = Val.typespec().is_int() ? (const int *)Val.data() : NULL;
const float *fval = Val.typespec().is_float() ? (const float *)Val.data() : NULL;
const int *ival = Val.typespec().is_int() && Val.is_constant() ? (const int *)Val.data() : NULL;
const float *fval = Val.typespec().is_float() && Val.is_constant() ? (const float *)Val.data() : NULL;
#define PARAM_INT(paramname) \
if (name == Strings::paramname && valtype == TypeDesc::INT) { \
+6 -3
View File
@@ -150,7 +150,7 @@ initialize_llvm_helper_function_map ()
if (llvm_helper_function_map_initialized)
return; // already done
spin_lock lock (llvm_helper_function_map_mutex);
if (llvm_helper_function_map_initialized())
if (llvm_helper_function_map_initialized)
return;
#define DECL(name,signature) \
llvm_helper_function_map[#name] = HelperFuncRecord(signature,name); \
@@ -750,9 +750,10 @@ BackendLLVM::build_llvm_instance (bool groupentry)
// Note that the GroupData* is passed as a void*.
std::string unique_layer_name = Strutil::format ("%s_%d", inst()->layername(), inst()->id());
bool is_entry_layer = group().is_entry_layer(layer());
ll.current_function (
ll.make_function (unique_layer_name,
!inst()->entry_layer(), // fastcall for non-entry layer functions
!is_entry_layer, // fastcall for non-entry layer functions
ll.type_void(), // return type
llvm_type_sg_ptr(), llvm_type_groupdata_ptr()));
@@ -767,7 +768,7 @@ BackendLLVM::build_llvm_instance (bool groupentry)
ll.new_builder (entry_bb);
llvm::Value *layerfield = layer_run_ref(layer_remap(layer()));
if (inst()->entry_layer()) {
if (is_entry_layer && ! group().is_last_layer(layer())) {
// For entry layers, we need an extra check to see if it already
// ran. If it has, do an early return. Otherwise, set the 'ran' flag
// and then run the layer.
@@ -791,9 +792,11 @@ BackendLLVM::build_llvm_instance (bool groupentry)
llvm_gen_debug_printf (Strutil::format("enter layer %d %s %s",
this->layer(), inst()->layername(), inst()->shadername()));
// Mark this layer as executed
if (! group().is_last_layer(layer())) {
ll.op_store (ll.constant_bool(true), layerfield);
if (shadingsys().countlayerexecs())
ll.call_function ("osl_incr_layers_executed", sg_void_ptr());
}
// Setup the symbols
m_named_values.clear ();
+10 -5
View File
@@ -91,7 +91,15 @@ examples), as you are just coding in C++, but there are some rules:
*/
// Some gcc versions on some platforms seem to have max_align_t missing from
// their <cstddef>. Putting this here appears to make it build cleanly on
// those platforms while not hurting anything elsewhere.
namespace {
typedef long double max_align_t;
}
#include <iostream>
#include <cstddef>
#include "OSL/oslconfig.h"
#include "OSL/shaderglobals.h"
@@ -138,7 +146,6 @@ void * __dso_handle = 0; // necessary to avoid linkage issues in bitcode
#define DVEC(x) (*(Dual2<Vec3> *)x)
#define COL(x) (*(Color3 *)x)
#define DCOL(x) (*(Dual2<Color3> *)x)
#define TYPEDESC(x) (*(TypeDesc *)&x)
#ifndef OSL_SHADEOP
@@ -643,14 +650,14 @@ OSL_SHADEOP void osl_transformn_vmv(void *result, void* M_, void* v_)
{
const Vec3 &v = VEC(v_);
const Matrix44 &M = MAT(M_);
M.inverse().transpose().multDirMatrix (v, VEC(result));
M.inverse().transposed().multDirMatrix (v, VEC(result));
}
OSL_SHADEOP void osl_transformn_dvmdv(void *result, void* M_, void* v_)
{
const Dual2<Vec3> &v = DVEC(v_);
const Matrix44 &M = MAT(M_);
multDirMatrix (M.inverse().transpose(), v, DVEC(result));
multDirMatrix (M.inverse().transposed(), v, DVEC(result));
}
@@ -823,5 +830,3 @@ OSL_SHADEOP int osl_raytype_bit (void *sg_, int bit)
ShaderGlobals *sg = (ShaderGlobals *)sg_;
return (sg->raytype & bit) != 0;
}
+4
View File
@@ -435,6 +435,10 @@ OSOReaderToMaster::hint (string_view hintstring)
m_master->m_ops.back().argread(i, *str == 'r' || *str =='W');
}
ASSERT(m_nargs == i);
// Fix old bug where oslc forgot to mark getmatrix last arg as write
static ustring getmatrix("getmatrix");
if (m_master->m_ops.back().opname() == getmatrix)
m_master->m_ops.back().argwrite(m_nargs-1, true);
}
if (extract_prefix(h, "%argderivs{")) {
while (1) {
+2 -2
View File
@@ -227,13 +227,13 @@ inline void osl_transformv_dvmdv(void *result, const Matrix44 &M, void* v_)
inline void osl_transformn_vmv(void *result, const Matrix44 &M, void* v_)
{
const Vec3 &v = VEC(v_);
M.inverse().transpose().multDirMatrix (v, VEC(result));
M.inverse().transposed().multDirMatrix (v, VEC(result));
}
inline void osl_transformn_dvmdv(void *result, const Matrix44 &M, void* v_)
{
const Dual2<Vec3> &v = DVEC(v_);
multDirMatrix (M.inverse().transpose(), v, DVEC(result));
multDirMatrix (M.inverse().transposed(), v, DVEC(result));
}
+2 -4
View File
@@ -50,15 +50,13 @@ OSL_NAMESPACE_ENTER
namespace pvt {
#define USTR(cstr) (*((ustring *)&cstr))
OSL_SHADEOP void
osl_setmessage (ShaderGlobals *sg, const char *name_, long long type_, void *val, int layeridx, const char* sourcefile_, int sourceline)
{
const ustring &name (USTR(name_));
const ustring &sourcefile (USTR(sourcefile_));
// recreate TypeDesc -- we just crammed it into an int!
TypeDesc type (*(TypeDesc *)&type_);
TypeDesc type = TYPEDESC(type_);
bool is_closure = (type.basetype == TypeDesc::UNKNOWN); // secret code for closure
if (is_closure)
type.basetype = TypeDesc::PTR; // for closures, we store a pointer
@@ -105,7 +103,7 @@ osl_getmessage (ShaderGlobals *sg, const char *source_, const char *name_,
const ustring &sourcefile (USTR(sourcefile_));
// recreate TypeDesc -- we just crammed it into an int!
TypeDesc type (*(TypeDesc *)&type_);
TypeDesc type = TYPEDESC(type_);
bool is_closure = (type.basetype == TypeDesc::UNKNOWN); // secret code for closure
if (is_closure)
type.basetype = TypeDesc::PTR; // for closures, we store a pointer
+2 -2
View File
@@ -154,8 +154,8 @@ OSL_SHADEOP void osl_spline_dvdfv(void *out, const char *spline_, void *x,
Vec3 *knots, int knot_count, int knot_arraylen)
{
const Spline::SplineBasis *spline = Spline::getSplineBasis(USTR(spline_));
Spline::spline_evaluate<Vec3, float, Vec3, Vec3, false>
(spline, *(Vec3 *)out, *(float *)x, knots, knot_count, knot_arraylen);
Spline::spline_evaluate<Dual2<Vec3>, Dual2<float>, Vec3, Vec3, false>
(spline, DVEC(out), DFLOAT(x), knots, knot_count, knot_arraylen);
}
OSL_SHADEOP void osl_spline_dvfdv(void *out, const char *spline_, void *x,
+8 -2
View File
@@ -215,7 +215,7 @@ struct AttributeNeeded {
#define DVEC(x) (*(Dual2<Vec3> *)x)
#define COL(x) (*(Color3 *)x)
#define DCOL(x) (*(Dual2<Color3> *)x)
#define TYPEDESC(x) (*(TypeDesc *)&x)
#define TYPEDESC(x) OIIO::bit_cast<long long,TypeDesc>(x)
@@ -562,6 +562,7 @@ public:
int max_warnings_per_thread() const { return m_max_warnings_per_thread; }
bool countlayerexecs() const { return m_countlayerexecs; }
bool lazy_userdata () const { return m_lazy_userdata; }
bool userdata_isconnected () const { return m_userdata_isconnected; }
ustring commonspace_synonym () const { return m_commonspace_synonym; }
@@ -705,6 +706,7 @@ private:
bool m_lazyglobals; ///< Run lazily even if globals write?
bool m_lazyunconnected; ///< Run lazily even if not connected?
bool m_lazy_userdata; ///< Retrieve userdata lazily?
bool m_userdata_isconnected; ///< Userdata params isconnected()?
bool m_clearmemory; ///< Zero mem before running shader?
bool m_debugnan; ///< Root out NaN's?
bool m_debug_uninit; ///< Find use of uninitialized vars?
@@ -1433,12 +1435,16 @@ public:
int num_entry_layers () const { return m_num_entry_layers; }
bool is_last_layer (int layer) const {
return layer == nlayers()-1;
}
/// Is the given layer an entry point? It is if explicitly tagged as
/// such, or if no layers are so tagged then the last layer is the one
/// entry.
bool is_entry_layer (int layer) const {
return num_entry_layers() ? m_layers[layer]->entry_layer()
: (layer == nlayers()-1);
: is_last_layer(layer);
}
private:
+10
View File
@@ -42,6 +42,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%option noyywrap
%option nounput noinput
/* never-interactive fixes a Windows compatibility problem where the
* lexer emits isatty calls that don't exist.
*/
%option never-interactive
/* Option 'prefix' creates a C++ lexer with the given prefix, so that
* we can link with other flex-generated lexers in the same application
* without name conflicts.
@@ -106,6 +111,11 @@ using namespace OSL::pvt;
#define YY_NO_UNISTD_H
#endif
#ifdef _MSC_VER
#include <io.h>
#define isatty _isatty
#endif
%}
/* Declare modes */
+32 -30
View File
@@ -2044,20 +2044,17 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
for (int opnum = beginop; opnum < endop; opnum += 1) {
ASSERT (old_num_ops == num_ops); // better not happen unknowingly
DASSERT (num_ops == inst()->ops().size());
DASSERT (size_t(opnum) < inst()->ops().size());
if (m_stop_optimizing)
break;
// Before getting a reference to this op, be sure that a space
// is reserved at the end in case a folding routine inserts an
// op. That ensures that the reference won't be invalid.
inst()->ops().reserve (num_ops+1);
Opcode &op (inst()->ops()[opnum]);
Opcode *op = &inst()->ops()[opnum];
if (skipops) {
// If a previous optimization inserted ops and told us
// to skip over the new ones, we still need to unalias
// any symbols written by this op, but otherwise skip
// all subsequent optimizations until we run down the
// skipops counter.
block_unalias_written_args (op);
block_unalias_written_args (*op);
ASSERT (lastblock == m_bblockids[opnum] &&
"this should not be a new basic block");
--skipops;
@@ -2071,23 +2068,23 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
lastblock = m_bblockids[opnum];
}
// Nothing below here to do for no-ops, take early out.
if (op.opname() == u_nop)
if (op->opname() == u_nop)
continue;
// De-alias the readable args to the op and figure out if
// there are any constants involved.
for (int i = 0, e = op.nargs(); i < e; ++i) {
if (! op.argwrite(i)) { // Don't de-alias args that are written
int argindex = op.firstarg() + i;
for (int i = 0, e = op->nargs(); i < e; ++i) {
if (! op->argwrite(i)) { // Don't de-alias args that are written
int argindex = op->firstarg() + i;
int argsymindex = dealias_symbol (inst()->arg(argindex), opnum);
inst()->args()[argindex] = argsymindex;
}
if (op.argread(i))
use_stale_sym (oparg(op,i));
if (op->argread(i))
use_stale_sym (oparg(*op,i));
}
// If it's a simple assignment and the lvalue is "stale", go
// back and eliminate its last assignment.
if (is_simple_assign(op))
simple_sym_assign (oparg (op, 0), opnum);
if (is_simple_assign(*op))
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
// the addresses of symbols changing when we add a new one below.
@@ -2095,7 +2092,7 @@ 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());
const OpDescriptor *opd = shadingsys().op_descriptor (op->opname());
if (opd && opd->folder) {
int c = (*opd->folder) (*this, opnum);
if (c) {
@@ -2105,23 +2102,24 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
skipops = num_ops - old_num_ops;
endop += num_ops - old_num_ops; // adjust how far we loop
old_num_ops = num_ops;
op = &inst()->ops()[opnum]; // in case ops resized
}
}
}
// Clear local block aliases for any args that were written
// by this op
block_unalias_written_args (op);
block_unalias_written_args (*op);
// Now we handle assignments.
if (optimize() >= 2 && op.opname() == u_assign && m_opt_assign)
changed += optimize_assignment (op, opnum);
if (optimize() >= 2 && op->opname() == u_assign && m_opt_assign)
changed += optimize_assignment (*op, opnum);
if (optimize() >= 2 && m_opt_elide_useless_ops)
changed += useless_op_elision (op, opnum);
changed += useless_op_elision (*op, opnum);
if (m_stop_optimizing)
break;
// Peephole optimization involving pair of instructions (the second
// instruction will be in the same basic block.
if (optimize() >= 2 && m_opt_peephole && op.opname() != u_nop) {
if (optimize() >= 2 && m_opt_peephole && op->opname() != u_nop) {
// Find the next instruction in the same basic block
int op2num = next_block_instruction (opnum);
if (op2num) {
@@ -2133,6 +2131,7 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
// skipops = num_ops - old_num_ops;
endop += num_ops - old_num_ops; // adjust how far we loop
old_num_ops = num_ops;
op = &inst()->ops()[opnum]; // in case ops resized
}
}
}
@@ -2140,14 +2139,14 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
// Special cases for "if", "functioncall", and loops: Optimize the
// sequences of instructions in the bodies recursively in a way that
// allows us to be clever about the basic block alias tracking.
ustring opname = op.opname();
ustring opname = op->opname();
if ((opname == u_if || opname == u_functioncall ||
opname == u_for || opname == u_while || opname == u_dowhile)
&& shadingsys().m_opt_seed_bblock_aliases) {
// Find all symbols written anywhere in the instruction range
// of the bodies.
FastIntSet symwrites;
catalog_symbol_writes (opnum+1, op.farthest_jump(), symwrites);
catalog_symbol_writes (opnum+1, op->farthest_jump(), symwrites);
// Save the aliases from the basic block we are exiting.
// If & function call: save all prior aliases.
// Loops: dont save aliases involving syms written in the loop.
@@ -2163,11 +2162,11 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
// one (the body), loops have 4 (init, cond, body, incr),
int njumps = (opname == u_if) ? 2 : (opname == u_functioncall ? 1 : 4);
// Recursively optimize each body block.
// Don't use op after inserstions! Use inst()->op(opnum).
for (int j = 0; j < njumps; ++j)
changed += optimize_ops (j==0 ? opnum+1 : inst()->op(opnum).jump(j-1),
inst()->op(opnum).jump(j),
&saved_block_aliases);
for (int j = 0; j < njumps; ++j) {
changed += optimize_ops (j==0 ? opnum+1 : op->jump(j-1),
op->jump(j), &saved_block_aliases);
op = &inst()->ops()[opnum]; // in case ops resized
}
// Adjust optimization loop end if any instructions were added
num_ops = inst()->ops().size();
endop += num_ops - old_num_ops;
@@ -2182,13 +2181,13 @@ RuntimeOptimizer::optimize_ops (int beginop, int endop,
restored_aliases.swap (saved_block_aliases);
// catalog again, in case optimizations in those blocks
// caused writes that weren't apparent before.
catalog_symbol_writes (opnum+1, inst()->op(opnum).farthest_jump(), symwrites);
catalog_symbol_writes (opnum+1, op->farthest_jump(), symwrites);
copy_block_aliases (restored_aliases, saved_block_aliases,
&symwrites);
}
seed_block_aliases = &saved_block_aliases;
// Get ready to increment to the next instruction
opnum = inst()->op(opnum).farthest_jump() - 1;
opnum = op->farthest_jump() - 1;
}
}
m_block_aliases_stack.pop_back(); // Done with saved_block_aliases
@@ -2356,7 +2355,10 @@ RuntimeOptimizer::resolve_isconnected ()
ASSERT (fieldsymid >= 0);
s = inst()->symbol(fieldsymid);
}
int val = (s->connected() ? 1 : 0) + (s->connected_down() ? 2 : 0);
bool upconnected = s->connected();
if (!s->lockgeom() && shadingsys().userdata_isconnected())
upconnected = true;
int val = (upconnected ? 1 : 0) + (s->connected_down() ? 2 : 0);
turn_into_assign (op, add_constant(TypeDesc::TypeInt, &val),
"resolve isconnected()");
}
+4 -6
View File
@@ -631,7 +631,7 @@ ShadingSystemImpl::ShadingSystemImpl (RendererServices *renderer,
: m_renderer(renderer), m_texturesys(texturesystem), m_err(err),
m_statslevel (0), m_lazylayers (true),
m_lazyglobals (true), m_lazyunconnected(true),
m_lazy_userdata(false),
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_range_checking(true),
@@ -1034,6 +1034,7 @@ ShadingSystemImpl::attribute (string_view name, TypeDesc type,
ATTR_SET ("lazyglobals", int, m_lazyglobals);
ATTR_SET ("lazyunconnected", int, m_lazyunconnected);
ATTR_SET ("lazy_userdata", int, m_lazy_userdata);
ATTR_SET ("userdata_isconnected", int, m_userdata_isconnected);
ATTR_SET ("clearmemory", int, m_clearmemory);
ATTR_SET ("debug_nan", int, m_debugnan);
ATTR_SET ("debugnan", int, m_debugnan); // back-compatible alias
@@ -1137,6 +1138,7 @@ ShadingSystemImpl::getattribute (string_view name, TypeDesc type,
ATTR_DECODE ("lazyglobals", int, m_lazyglobals);
ATTR_DECODE ("lazyunconnected", int, m_lazyunconnected);
ATTR_DECODE ("lazy_userdata", int, m_lazy_userdata);
ATTR_DECODE ("userdata_isconnected", int, m_userdata_isconnected);
ATTR_DECODE ("clearmemory", int, m_clearmemory);
ATTR_DECODE ("debug_nan", int, m_debugnan);
ATTR_DECODE ("debugnan", int, m_debugnan); // back-compatible alias
@@ -1558,6 +1560,7 @@ ShadingSystemImpl::getstats (int level) const
BOOLOPT (lazyglobals);
BOOLOPT (lazyunconnected);
BOOLOPT (lazy_userdata);
BOOLOPT (userdata_isconnected);
BOOLOPT (clearmemory);
BOOLOPT (debugnan);
BOOLOPT (debug_uninit);
@@ -2121,7 +2124,6 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
// Zero-pad if we parsed fewer values than we needed
intvals.resize (type.numelements()*type.aggregate, 0);
ASSERT (int(type.numelements())*type.aggregate == int(intvals.size()));
Parameter (paramname, type, &intvals[0], lockgeom);
} else if (type.basetype == TypeDesc::FLOAT) {
floatvals.clear ();
floatvals.reserve (vals_to_preallocate);
@@ -2141,7 +2143,6 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
// Zero-pad if we parsed fewer values than we needed
floatvals.resize (type.numelements()*type.aggregate, 0);
ASSERT (int(type.numelements())*type.aggregate == int(floatvals.size()));
Parameter (paramname, type, &floatvals[0], lockgeom);
} else if (type.basetype == TypeDesc::STRING) {
stringvals.clear ();
stringvals.reserve (vals_to_preallocate);
@@ -2171,7 +2172,6 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
// Zero-pad if we parsed fewer values than we needed
stringvals.resize (type.numelements()*type.aggregate, ustring());
ASSERT (int(type.numelements())*type.aggregate == int(stringvals.size()));
Parameter (paramname, type, &stringvals[0], lockgeom);
}
if (Strutil::parse_prefix (p, "[[")) { // hints
@@ -3180,5 +3180,3 @@ osl_bind_interpolated_param (void *sg_, const void *name, long long type,
}
return 0; // no such user data
}
+1 -2
View File
@@ -12,7 +12,6 @@ else ()
ADD_LIBRARY ( oslquery SHARED ${liboslquery_srcs} )
endif ()
TARGET_LINK_LIBRARIES ( oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} )
LINK_ILMBASE ( oslquery )
TARGET_LINK_LIBRARIES ( oslquery ${OPENIMAGEIO_LIBRARY} ${ILMBASE_LIBRARIES} ${Boost_LIBRARIES} )
INSTALL ( TARGETS oslquery RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
-1
View File
@@ -8,7 +8,6 @@ if (BUILDSTATIC)
endif ()
ADD_EXECUTABLE ( oslc ${oslc_srcs} )
LINK_ILMBASE ( oslc )
TARGET_LINK_LIBRARIES ( oslc oslcomp ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS oslc RUNTIME DESTINATION bin )
+1
View File
@@ -37,6 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/sysutil.h>
#include <OpenImageIO/thread.h>
#include "OSL/oslcomp.h"
#include "OSL/oslexec.h"
-1
View File
@@ -1,5 +1,4 @@
SET ( oslinfo_srcs oslinfo.cpp )
ADD_EXECUTABLE ( oslinfo ${oslinfo_srcs} )
LINK_ILMBASE ( oslinfo )
TARGET_LINK_LIBRARIES ( oslinfo oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS oslinfo RUNTIME DESTINATION bin )
-1
View File
@@ -1,6 +1,5 @@
# The 'testrender' executable
FILE(GLOB testrender_src *.cpp)
ADD_EXECUTABLE ( testrender ${testrender_src} )
LINK_ILMBASE ( testrender )
TARGET_LINK_LIBRARIES ( testrender oslexec oslcomp oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS testrender RUNTIME DESTINATION bin )
+1
View File
@@ -37,6 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <OpenImageIO/argparse.h>
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/timer.h>
#include <OpenImageIO/thread.h>
#ifdef USE_EXTERNAL_PUGIXML
# include <pugixml.hpp>
-3
View File
@@ -1,7 +1,6 @@
# The 'testshade' executable
SET ( testshade_srcs testshade.cpp simplerend.cpp )
ADD_EXECUTABLE ( testshade ${testshade_srcs} testshademain.cpp )
LINK_ILMBASE ( testshade )
TARGET_LINK_LIBRARIES ( testshade oslexec oslcomp oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS testshade RUNTIME DESTINATION bin )
@@ -19,8 +18,6 @@ INSTALL ( TARGETS libtestshade RUNTIME DESTINATION bin LIBRARY DESTINATION lib A
# The 'testshade_dso' executable
ADD_EXECUTABLE ( testshade_dso testshade_dso.cpp )
LINK_ILMBASE ( testshade_dso )
TARGET_LINK_LIBRARIES ( testshade_dso ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
#oslexec oslcomp oslquery ${OPENIMAGEIO_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS testshade_dso RUNTIME DESTINATION bin )
+3
View File
@@ -78,6 +78,7 @@ static bool use_group_outputs = false;
static bool do_oslquery = false;
static bool inbuffer = false;
static bool use_shade_image = false;
static bool userdata_isconnected = false;
static int xres = 1, yres = 1;
static int num_threads = 0;
static std::string groupname;
@@ -133,6 +134,7 @@ set_shadingsys_options ()
shadingsys->attribute ("lockgeom", 1);
shadingsys->attribute ("debug_nan", debugnan);
shadingsys->attribute ("debug_uninit", debug_uninit);
shadingsys->attribute ("userdata_isconnected", userdata_isconnected);
if (! shaderpath.empty())
shadingsys->attribute ("searchpath:shader", shaderpath);
shadingsys_options_set = true;
@@ -469,6 +471,7 @@ getargs (int argc, const char *argv[])
"--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)",
"--userdata_isconnected", &userdata_isconnected, "Consider lockgeom=0 to be isconnected()",
"-v", &verbose, "Verbose output",
NULL);
if (ap.parse(argc, argv) < 0 || (shadernames.empty() && groupspec.empty())) {
Binary file not shown.
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
Compiled test.osl -> test.oso
a = 26 (hex 1a), b = -1 (hex ffffffff)
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env python
command = testshade("test")
+7
View File
@@ -0,0 +1,7 @@
shader
test ()
{
int a = 0x001a;
int b = 0xffffffff;
printf ("a = %d (hex %x), b = %d (hex %x)\n", a, a, b, b);
}
+20
View File
@@ -13,6 +13,26 @@ a=0.5
Downstream:
a connected: 1 (value=0.5)
b connected: 0 (value=0)
c connected: 0 (value=0)
mystruct1 connected: 1 (value=0)
mystruct1.x connected: 1 (value=3)
mystruct2 connected: 0 (value=3)
mystruct2.x connected: 0 (value=0)
Connect upstream.out to downstream.a
Connect upstream.struct1 to downstream.mystruct1
Upstream:
out connected: 2 (value=0.5)
notout connected: 0 (value=10)
struct1 connected: 2 (value=10)
struct1.x connected: 2 (value=3)
struct2 connected: 0 (value=3)
struct2.x connected: 0 (value=5)
a=0.5
Downstream:
a connected: 1 (value=0.5)
b connected: 0 (value=0)
c connected: 1 (value=0)
mystruct1 connected: 1 (value=0)
mystruct1.x connected: 1 (value=3)
mystruct2 connected: 0 (value=3)
+8 -1
View File
@@ -1,5 +1,12 @@
#!/usr/bin/env python
command = testshade("-g 1 1 --layer upstream upstream --layer downstream test " +
command = testshade("--layer upstream upstream --layer downstream test " +
"--connect upstream out downstream a " +
"--connect upstream struct1 downstream mystruct1")
# Run again, this time considering userdata (lockgeom=0) parameters to be
# isconnected(). This time, parameter c should look like a connection.
command += testshade("--userdata_isconnected " +
"--layer upstream upstream --layer downstream test " +
"--connect upstream out downstream a " +
"--connect upstream struct1 downstream mystruct1")
+2
View File
@@ -16,6 +16,7 @@ void status (MyStruct variable, string name)
shader test (float a = 0, float b = 0,
float c = 0 [[ int lockgeom=0 ]],
MyStruct mystruct1 = {0,0},
MyStruct mystruct2 = {0,0})
{
@@ -23,6 +24,7 @@ shader test (float a = 0, float b = 0,
printf ("Downstream:\n");
status (a, "a");
status (b, "b");
status (c, "c");
status (mystruct1, "mystruct1");
status (mystruct2, "mystruct2");
}
+12
View File
@@ -3,6 +3,7 @@ Parameter initialization:
matrixparam0 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
matrixparam1 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1m = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1world = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix (0.1) = 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1
matrix (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6)
@@ -20,6 +21,8 @@ testing with spaces:
matrix ("shader", 0) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
matrix ("shader", 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
= 0 0.70711 0 0 0 0.70711 0 0 0 0 1 0 0 0 0 1
matrix ("world", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix ("common", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Testing matrix from-to construction:
matrix ("common", "shader") = (0.70711 -0.70711 0 0 0.70711 0.70711 0 0 0 0 1 0 -0.70711 0.70711 0 1)
@@ -65,6 +68,7 @@ Parameter initialization:
matrixparam0 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
matrixparam1 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1m = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1world = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix (0.1) = 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1
matrix (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6)
@@ -82,6 +86,8 @@ testing with spaces:
matrix ("shader", 1) = 0.70711 0.70711 0 0 -0.70711 0.70711 0 0 0 0 1 0 1 0 0 1
matrix ("shader", 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
= 0.70711 0.70711 0 0 -0.70711 0.70711 0 0 0 0 1 0 1 0 0 1
matrix ("world", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix ("common", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Testing matrix from-to construction:
matrix ("common", "shader") = (0.70711 -0.70711 0 0 0.70711 0.70711 0 0 0 0 1 0 -0.70711 0.70711 0 1)
@@ -126,6 +132,7 @@ Parameter initialization:
matrixparam0 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
matrixparam1 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1m = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1world = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix (0.1) = 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1
matrix (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6)
@@ -143,6 +150,8 @@ testing with spaces:
matrix ("shader", 0) = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
matrix ("shader", 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
= 0 0.70711 0 0 0 0.70711 0 0 0 0 1 0 0 0 0 1
matrix ("world", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix ("common", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Testing matrix from-to construction:
matrix ("common", "shader") = (0.70711 -0.70711 0 0 0.70711 0.70711 0 0 0 0 1 0 -0.70711 0.70711 0 1)
@@ -187,6 +196,7 @@ Parameter initialization:
matrixparam0 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
matrixparam1 = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1m = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrixparam1world = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix (0.1) = 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1
matrix (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6)
@@ -204,6 +214,8 @@ testing with spaces:
matrix ("shader", 1) = 0.70711 0.70711 0 0 -0.70711 0.70711 0 0 0 0 1 0 1 0 0 1
matrix ("shader", 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
= 0.70711 0.70711 0 0 -0.70711 0.70711 0 0 0 0 1 0 1 0 0 1
matrix ("world", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
matrix ("common", 1) = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Testing matrix from-to construction:
matrix ("common", "shader") = (0.70711 -0.70711 0 0 0.70711 0.70711 0 0 0 0 1 0 -0.70711 0.70711 0 1)
+11 -1
View File
@@ -23,13 +23,15 @@ void matrix_fromto (string from, string to)
shader
test (matrix matrixparam0 = 0,
matrix matrixparam1 = 1,
matrix matrixparam1m = matrix(1))
matrix matrixparam1m = matrix(1),
matrix matrixparam1world = matrix("world",1))
{
// Test parameter initialization
printf ("Parameter initialization:\n");
printf (" matrixparam0 = %g\n", matrixparam0);
printf (" matrixparam1 = %g\n", matrixparam1);
printf (" matrixparam1m = %g\n", matrixparam1m);
printf (" matrixparam1world = %g\n", matrixparam1world);
printf ("\n");
// Test matrix constructors
@@ -68,6 +70,14 @@ test (matrix matrixparam0 = 0,
a, pretty(matrix ("shader", a, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)));
}
// World and comomon space construction
{
matrix Mw = matrix ("world", 1);
matrix Mc = matrix ("common", 1);
printf (" matrix (\"world\", 1) = %g\n", Mw);
printf (" matrix (\"common\", 1) = %g\n", Mc);
}
// Test "from-to" matrix construction and getmatrix calls
{
printf ("\nTesting matrix from-to construction:\n");
@@ -0,0 +1,5 @@
shader arrayparam(
color in_value[] = { color(1) },
output color out_value = in_value[0] )
{
}
@@ -0,0 +1,4 @@
Compiled arrayparam.osl -> arrayparam.oso
Compiled simple.osl -> simple.oso
1.000000 0.000000 1.000000
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env python
# This is a regression test for a bug in which instance merging was
# done incorrectly for shaders that differed only in the values given
# to parameters which were arrays of unspecified length.
command = testshade("--group data/shadergroup")
@@ -0,0 +1,7 @@
param color[1] in_value 0 0 1 ;
shader arrayparam param_node_2 ;
param color[1] in_value 1 0 0 ;
shader arrayparam param_node_1 ;
shader simple simple_surface ;
connect param_node_1.out_value simple_surface.a ;
connect param_node_2.out_value simple_surface.b ;
@@ -0,0 +1,7 @@
surface simple(
color a = color(0),
color b = color(0) )
{
printf("%f\n", a + b);
Ci = emission() * (a + b);
}
+3
View File
@@ -0,0 +1,3 @@
test.osl:2: error: 'cos' is not a function
test.osl:2: error: No matching function call to 'cos (int)'
FAILED test.osl
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env python
# command = oslc("test.osl")
# don't even need that -- it's automatic
failureok = 1 # this test is expected to have oslc errors
+9
View File
@@ -0,0 +1,9 @@
void mybug (float cos) {
cos(1); // inner scope cos is not a function
}
shader test ()
{
}
@@ -0,0 +1,3 @@
test.osl:3: warning: Comma operator is very confusing here. Did you mean to use a constructor: x = vector(...)?
test.osl:4: warning: Comma operator is very confusing here. Did you mean to use a constructor: = color(...)?
Compiled test.osl -> test.oso
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env python
# command = oslc("test.osl")
# don't even need that -- it's automatic
+5
View File
@@ -0,0 +1,5 @@
shader test ( output color Cout = 0 )
{
vector x = (1, 2, 3);
Cout = (u, v, 0);
}
@@ -0,0 +1,6 @@
Compiled test.osl -> test.oso
shader "test"
"foo" "color"
Default value: [ 0.1 0.2 0.3 ]
"bar" "color"
Default value: [ 0.75 0.75 0.75 ]
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env python
command = oslinfo("-v test")
+5
View File
@@ -0,0 +1,5 @@
shader test (color foo=color(0.1, 0.2, 0.3),
color bar=color(0.75))
{
printf ("foo=%f, bar=%f\n", foo, bar);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
Compiled test.osl -> test.oso
Output Cout to color.tif
Output Cout_dx to dx.tif
Output Cout_dy to dy.tif
spline in=0.492, result = 0.0262 0.52 0.47 dx = -0.0116 -0.0394 0.0594 dy = 0 0 0
spline in=0.508, result = 0.0163 0.48 0.53 dx = -0.00841 -0.0394 0.0594 dy = 0 0 0
spline in=0.492, result = 0.0262 0.52 0.47 dx = -0.0116 -0.0394 0.0594 dy = 0 0 0
spline in=0.508, result = 0.0163 0.48 0.53 dx = -0.00841 -0.0394 0.0594 dy = 0 0 0
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env python
command += testshade("-g 64 64 -od uint8 -o Cout color.tif -o Cout_dx dx.tif -o Cout_dy dy.tif test")
outputs = [ "out.txt", "color.tif", "dx.tif", "dy.tif" ]
+27
View File
@@ -0,0 +1,27 @@
shader test
(
float in = u,
string basis = "bspline",
int knots = 8,
color values[8] = {
color(0,0,0),
color(0,0,0),
color(1,0,0),
color(0,1,0),
color(0,0,1),
color(0,1,1),
color(1,1,1),
color(1,1,1)
},
output color Cout = 0,
output color Cout_dx = 0,
output color Cout_dy = 0,
)
{
Cout = spline (basis, in, knots, values);
if (u > 0.49 && u < 0.51 && v > 0.49 && v < 0.51)
printf ("spline in=%.3g, result = %.3g dx = %.3g dy = %.3g\n",
in, Cout, Dx(Cout), Dy(Cout));
Cout_dx = 0.5 + 10 * Dx(Cout);
Cout_dy = 0.5 + 10 * Dy(Cout);
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
shader attribs (output float value = 0)
{
value = v * 10;
}
Binary file not shown.
@@ -0,0 +1,6 @@
Compiled attribs.osl -> attribs.oso
Compiled test.osl -> test.oso
Connect A.value to root.swidth
Connect A.value to root.twidth
Output Cout to out.tif
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env python
command += testshade("-g 128 128 -layer A attribs -param:type=string filename " +
"../common/textures/grid.tx -layer root test -connect A value " +
"root swidth -connect A value root twidth -od uint8 -o Cout out.tif")
outputs = [ "out.txt", "out.tif" ]
@@ -0,0 +1,7 @@
surface test (string filename = "",
float s = u, float t = v,
float swidth = 1.0, float twidth = 1.0,
output color Cout = 0 )
{
Cout = texture (filename, s, t, "swidth", swidth, "twidth", twidth);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.