Compare commits
12
Commits
main
...
Release-1.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a0ac07b1d | ||
|
|
a475874451 | ||
|
|
e30f08ca0f | ||
|
|
2d203cb5c4 | ||
|
|
b9146e3bd6 | ||
|
|
95808567bb | ||
|
|
31db6868ee | ||
|
|
b2cef598f4 | ||
|
|
707a343b57 | ||
|
|
223a816494 | ||
|
|
9bbeeca807 | ||
|
|
b0673b832d |
@@ -1,4 +1,95 @@
|
||||
Release 1.1.0 - Mar 14, 2011 (compared to 1.0.0)
|
||||
Release 1.2.1 - 6 Nov, 2012 (compared to 1.2.0)
|
||||
-----------------------------------------------
|
||||
* Fix incorrect oso output of matrix parameter initialization. (This did
|
||||
not affect shader execution, but could result in oslquery/oslinfo not
|
||||
reporting default matrix parameter values correctly.)
|
||||
* Build: remove unused OpenGL and GLEW searching from CMake files.
|
||||
* Build: Fix a variety of compiler warnings, particularly on newer compilers,
|
||||
32 bit platforms, and Windows.
|
||||
* Build: Find LLVM correctly even when using "svn" LLVM versions.
|
||||
* Bug fix: oslinfo didn't print int metadata values properly.
|
||||
|
||||
|
||||
|
||||
Release 1.2.0 - Aug 30, 2012 (compared to 1.1)
|
||||
----------------------------------------------
|
||||
Note: this is more or less the production-hardened version of OSL that
|
||||
was used to complete Men in Black 3, The Amazing Spider-Man, and Hotel
|
||||
Transylvania.
|
||||
|
||||
New tools/utilities:
|
||||
* New program "testrender" is a tiny ray-tracing renderer that uses OSL
|
||||
for shading. Features are very minimal (only spheres are permitted at
|
||||
this time) and there has been no attention to performance, but it
|
||||
demonstrates how the OSL libraries may be integrated into a working
|
||||
renderer, what interfaces the renderer needs to supply, and how the
|
||||
BSDFs/radiance closures should be evaluated and integrated (including
|
||||
with multiple importance sampling).
|
||||
* shaders/ubersurface.osl is an example of a general purpose surface
|
||||
shader.
|
||||
|
||||
Language, standard libary, and compiler changes:
|
||||
* texture()/texture3d() support for subimage/face selection by name as
|
||||
well as by numeric index.
|
||||
* getattribute() performs automatic type conversions that mostly
|
||||
correspond to the kind of automatic type casting you would get from
|
||||
ordinary assignments in OSL. For example, getattribute("attrib",mycolor)
|
||||
used to fail if "attrib" turned out to be a float rather than a color;
|
||||
but now it succeeds and copies the float value to all three channels
|
||||
of mycolor.
|
||||
|
||||
ShadingSystem API changes and new options:
|
||||
* Remove unused 'size' parameter from the register_closure API.
|
||||
|
||||
Optimization improvements:
|
||||
* Constant-fold pointcloud_search calls when the position is a constant if
|
||||
the search returns few enough results, by doing the query at optimization
|
||||
time and putting the results into new constant arrays.
|
||||
* Matrix parameters initialized by m=matrix(constA,constB,...) now
|
||||
statically initialize, and no longer need to run initialization code
|
||||
each time the shader executes.
|
||||
|
||||
Bug fixes and minor improvements:
|
||||
* Fix pointcloud_search to optionally take a 'sort' parameter, as
|
||||
originally documented.
|
||||
* Unit tests weren't properly run as part of the testsuite.
|
||||
* Track local+temp memory usage of optimized shaders and consider it an
|
||||
error if a shader needs more than a maximum amount at runtime, set with
|
||||
the "max_local_mem_KB" attribute.
|
||||
* Add pointcloud statistics.
|
||||
* Fix derivative error for sincos() when the inputs have no derivatives but
|
||||
the outputs do.
|
||||
* Bug fix to vector-returning Gabor noise (it could previously generate
|
||||
different values for different platforms).
|
||||
* printf() of closures built from other closures allows for proper
|
||||
recursive printing of the closure tree.
|
||||
|
||||
Build & test system improvements and developer goodies:
|
||||
* Simplify the namespace scheme.
|
||||
* Remove support for certain old dependencies: OIIO versions < 0.10,
|
||||
LLVM < 3.0, and Boost < 1.40.
|
||||
* Lots of little fixes to solve compiler warnings on various compilers.
|
||||
* Support for newer OSX releases, particularly if /usr/bin/cpp-4.2 is not
|
||||
found.
|
||||
* Better support for Boost::wave (portable C preprocessor replacement).
|
||||
Build with 'make USE_BOOST_WAVE=1' to force Wave use instead of system
|
||||
cpp.
|
||||
* You can select a custom LLVM namespace with 'make LLVM_NAMESPACE=...'.
|
||||
* Symbols that are not part of the OSL public APIs are now hidden from the
|
||||
linker in Linux/OSX if the CMake variable HIDE_SYMBOLS is on.
|
||||
* New Makefile/CMake option LLVM_STATIC can be used to use static LLVM
|
||||
libraries rather than the default dynamic libraries.
|
||||
* Support for LLVM 3.1.
|
||||
* Support for building with Clang 3.1 (lots of warning fixes).
|
||||
* Makefile/CMake variable EXTRA_CPP_DEFINITIONS allows you to inject
|
||||
additional compiler flags that you may need to customize the build for
|
||||
your site or a choice of unusual compiler.
|
||||
* Add support for 'PROFILE=1' builds that are appropriate for use with
|
||||
a profile.
|
||||
|
||||
|
||||
|
||||
Release 1.1.0 - Mar 14, 2012 (compared to 1.0.0)
|
||||
------------------------------------------------
|
||||
Language, standard libary, and compiler changes:
|
||||
* Allow closures as parameters to closures.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
|
||||
Copyright (c) 2009-2012 Sony Pictures Imageworks Inc., et al.
|
||||
All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -23,6 +23,11 @@ renderer used for feature film animation and visual effects. The
|
||||
language specification was developed with input by other visual effects
|
||||
and animation studios who also wish to use it.
|
||||
|
||||
OSL is robust and production-proven, and was the exclusive shading
|
||||
system for big VFX films such as "Men in Black 3: and "The Amazing
|
||||
Spider-Man," animated features such as "Hotel Transylvania", and several
|
||||
other films currently in production.
|
||||
|
||||
OSL is distributed under the "New BSD" license (see the "LICENSE" file
|
||||
that comes with the distribution). In short, you are free to use it in
|
||||
your own applications, whether they are free or commercial, open or
|
||||
@@ -93,7 +98,7 @@ find are different in OSL compared to other languages:
|
||||
surface, and is included in the main radiance closure computed by a
|
||||
surface shader.
|
||||
|
||||
* Renderer outputs (AOV's) are specified using "light path expressions."
|
||||
* Renderer outputs (AOV's) may be specified using "light path expressions."
|
||||
|
||||
Sometimes it is desirable to output images containing individual
|
||||
lighting components such as specular, diffuse, reflection, individual
|
||||
@@ -178,8 +183,16 @@ The OSL open source distribution consists of the following components:
|
||||
outputs as images. This allows for verification of shaders (and the
|
||||
shading system) without needing to be integrated into a fully
|
||||
functional renderer, and is the basis for most of our testsuite
|
||||
verification. Also note that the source code for testshade is
|
||||
currently the best example of how to call the OSL libraries.
|
||||
verification. Along with testrender, testshade is a good example
|
||||
of how to call the OSL libraries.
|
||||
|
||||
* testrender, a tiny ray-tracing renderer that uses OSL for shading.
|
||||
Features are very minimal (only spheres are permitted at this time)
|
||||
and there has been no attention to performance, but it demonstrates how
|
||||
the OSL libraries may be integrated into a working renderer, what
|
||||
interfaces the renderer needs to supply, and how the BSDFs/radiance
|
||||
closures should be evaluated and integrated (including with multiple
|
||||
importance sampling).
|
||||
|
||||
* A few sample shaders.
|
||||
|
||||
@@ -202,41 +215,30 @@ Current state of the project and road map
|
||||
-----------------------------------------
|
||||
|
||||
At Sony Pictures Imageworks, we are exclusively using OSL in our
|
||||
proprietary renderer, "Arnold." Multiple major visual effects films as
|
||||
well as feature animation are in production now. Our shader-writing
|
||||
team works entirely in OSL, all productions use OSL, and we've even
|
||||
removed all the code from the renderer that allows people to write the
|
||||
old-style "C" shaders. At the time we removed the old shader facility,
|
||||
the OSL shaders were consistently outperforming their equivalent old
|
||||
compiled C shaders in the old system.
|
||||
|
||||
What's missing? Here are a number of things that we wish had been
|
||||
included in the first public release of the code but are not ready yet,
|
||||
we promise that we are working on them:
|
||||
|
||||
* More documentation, in particular the "Integration Guide" that
|
||||
documents all the public APIs of the OSL libraries that you use when
|
||||
integrating into a renderer.
|
||||
|
||||
* The 'testshade' program runs shaders on an unwrapped flat rectangular
|
||||
array of points, and does not have any good way to test whether lights
|
||||
are working properly. We will eventually have another test program
|
||||
that will render a "lit ball" that will be more indicative of how the
|
||||
integration and lighting work.
|
||||
|
||||
* Currently, you have to write your own "integrator" from scratch when
|
||||
incorporating into a renderer application, which is less than ideal.
|
||||
We will eventually provide at least one sample integrator which may be
|
||||
used in a renderer, and outline what you need to do for more
|
||||
sophisticated integration strategies.
|
||||
|
||||
* Our set of sample shaders is quite anemic. We will eventually have a
|
||||
more extensive set of useful shaders.
|
||||
proprietary renderer, "Arnold." Completed productions that used 100%
|
||||
OSL for their shading include Men in Black 3, The Amazing Spider-Man,
|
||||
and Hotel Transylvania, and other unreleased shows that are still in
|
||||
production. Our shader-writing team works entirely in OSL, all
|
||||
productions use OSL, and we've even removed all the code from the
|
||||
renderer that allows people to write the old-style "C" shaders. At the
|
||||
time we removed the old shader facility, the OSL shaders were
|
||||
consistently outperforming their equivalent old compiled C shaders in
|
||||
the old system.
|
||||
|
||||
In the longer term, there are a number of projects we hope to get to
|
||||
leading to a 2.x or 3.x cut of the language and library. Among our
|
||||
long-term goals:
|
||||
|
||||
* More documentation, in particular the "Integration Guide" that
|
||||
documents all the public APIs of the OSL libraries that you use when
|
||||
integrating into a renderer. Currently, the source code to
|
||||
"testrender" is the best/only example of how to integrate OSL into a
|
||||
renderer.
|
||||
|
||||
* Our set of sample shaders is quite anemic. We will eventually have a
|
||||
more extensive set of useful, production-quality shaders and utility
|
||||
functions you can call from your shaders.
|
||||
|
||||
* Currently "closure primitives" are implemented in C++ in the OSL
|
||||
library or in the renderer, but we would like a future spec of the
|
||||
language to allow new closure primitives to be implemented in OSL
|
||||
@@ -297,6 +299,7 @@ The main developers of OSL are (in order of joining the project):
|
||||
Alejandro Conty
|
||||
Jay Reynolds
|
||||
Solomon Boulos
|
||||
Adam Martinez
|
||||
|
||||
We cannot possibly express sufficient gratitude to the managers at Sony
|
||||
Pictures Imageworks who allowed this project to proceed, supported it
|
||||
|
||||
+4
-3
@@ -2,8 +2,8 @@ project (OSL)
|
||||
|
||||
# Release version of the library
|
||||
set (OSL_LIBRARY_VERSION_MAJOR 1)
|
||||
set (OSL_LIBRARY_VERSION_MINOR 1)
|
||||
set (OSL_LIBRARY_VERSION_PATCH 0)
|
||||
set (OSL_LIBRARY_VERSION_MINOR 2)
|
||||
set (OSL_LIBRARY_VERSION_PATCH 1)
|
||||
|
||||
# Version of the OSO file format and instruction set
|
||||
set (OSO_FILE_VERSION_MAJOR 1)
|
||||
@@ -229,7 +229,8 @@ TESTSUITE ( arithmetic array array-derivs array-range
|
||||
derivs derivs-muldiv-clobber error-dupes exponential
|
||||
function-earlyreturn function-simple function-outputelem
|
||||
geomath getsymbol-nonheap gettextureinfo hyperb
|
||||
ieee_fp if incdec initops intbits layers layers-lazy
|
||||
ieee_fp if incdec initops intbits
|
||||
layers layers-Ciassign layers-lazy
|
||||
logic loop matrix message miscmath missing-shader
|
||||
noise noise-cell
|
||||
noise-gabor noise-gabor2d-filter noise-gabor3d-filter
|
||||
|
||||
@@ -162,16 +162,6 @@ link_directories ("${Boost_LIBRARY_DIRS}")
|
||||
# end Boost setup
|
||||
###########################################################################
|
||||
|
||||
###########################################################################
|
||||
# OpenGL setup
|
||||
|
||||
if (USE_OPENGL)
|
||||
find_package (OpenGL)
|
||||
endif ()
|
||||
message (STATUS "OPENGL_FOUND=${OPENGL_FOUND} USE_OPENGL=${USE_OPENGL}")
|
||||
|
||||
# end OpenGL setup
|
||||
###########################################################################
|
||||
|
||||
###########################################################################
|
||||
# TBB (Intel Thread Building Blocks) setup
|
||||
@@ -218,28 +208,6 @@ endif ()
|
||||
# end TBB setup
|
||||
###########################################################################
|
||||
|
||||
###########################################################################
|
||||
# GL Extension Wrangler library setup
|
||||
|
||||
if (USE_OPENGL)
|
||||
set (GLEW_VERSION 1.5.1)
|
||||
find_library (GLEW_LIBRARIES
|
||||
NAMES GLEW)
|
||||
find_path (GLEW_INCLUDES
|
||||
NAMES glew.h
|
||||
PATH_SUFFIXES GL)
|
||||
if (GLEW_INCLUDES AND GLEW_LIBRARIES)
|
||||
set (GLEW_FOUND TRUE)
|
||||
message (STATUS "GLEW includes = ${GLEW_INCLUDES}")
|
||||
message (STATUS "GLEW library = ${GLEW_LIBRARIES}")
|
||||
else ()
|
||||
message (STATUS "GLEW not found")
|
||||
endif ()
|
||||
endif (USE_OPENGL)
|
||||
|
||||
# end GL Extension Wrangler library setup
|
||||
###########################################################################
|
||||
|
||||
|
||||
###########################################################################
|
||||
# LLVM library setup
|
||||
@@ -273,7 +241,10 @@ message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
|
||||
if (LLVM_LIBRARY 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}")
|
||||
# Extract any wayward dots or "svn" suffixes from the version to yield
|
||||
# an integer version number we can use to make compilation decisions.
|
||||
string (REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION})
|
||||
string (REGEX REPLACE "svn" "" OSL_LLVM_VERSION ${OSL_LLVM_VERSION})
|
||||
message (STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
|
||||
add_definitions ("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}")
|
||||
if (LLVM_STATIC)
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
\def\langname{Open Shading Language\xspace}
|
||||
\def\product{{\sffamily Open Shading Language}\xspace}
|
||||
\def\versionnumber{1.1}
|
||||
\def\versionnumber{1.2}
|
||||
\def\productver{\product\ {\sffamily \versionnumber}\xspace}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Editor: Larry Gritz \\
|
||||
\emph{lg@imageworks.com}
|
||||
\bigskip \\
|
||||
}
|
||||
\date{{\large Date: 14 Mar, 2012 \\
|
||||
\date{{\large Date: 5 June, 2012 \\
|
||||
%(with corrections, 22 Feb, 2012)
|
||||
}}
|
||||
|
||||
|
||||
@@ -529,9 +529,6 @@ public:
|
||||
TypeDesc type, void *val, bool derivatives) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
TextureSystem *m_texturesys; // For default texture implementation
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define OSL_LIBRARY_VERSION_STRING \
|
||||
OSL_MAKE_VERSION_STRING(OSL_LIBRARY_VERSION_MAJOR, \
|
||||
OSL_LIBRARY_VERSION_MINOR, OSL_LIBRARY_VERSION_PATCH)
|
||||
#define OSL_INTRO_STRING "OpenShadingLanguage " OSL_LIBRARY_VERSION_STRING
|
||||
#define OSL_COPYRIGHT_STRING "(c) Copyright 2009-2012 Sony Pictures Imageworks, et al. All rights reserved."
|
||||
|
||||
|
||||
// Version numbers for the compiled shader format. The major number
|
||||
|
||||
@@ -728,11 +728,6 @@ public:
|
||||
private:
|
||||
// Special code generation for short-circuiting logical ops
|
||||
Symbol *codegen_logic (Symbol *dest);
|
||||
// Special code generation for closure multiplies
|
||||
Symbol *codegen_closure (Symbol *dest);
|
||||
// Helper, for closure expressions only: does either subtree involve
|
||||
// closure symbol s?
|
||||
bool subtrees_involve_closure (Symbol *s);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+26
-109
@@ -648,12 +648,13 @@ ASTvariable_declaration::param_one_default_literal (const Symbol *sym,
|
||||
completed = false;
|
||||
}
|
||||
} else if (type.is_matrix()) {
|
||||
float f = 0;
|
||||
if (islit && lit->typespec().is_int())
|
||||
f = lit->intval();
|
||||
else if (islit && lit->typespec().is_float())
|
||||
f = lit->floatval();
|
||||
else if (init && init->typespec() == type &&
|
||||
if (islit && lit->typespec().is_int()) {
|
||||
float f = lit->intval();
|
||||
out += Strutil::format ("%.8g 0 0 0 0 %.8g 0 0 0 0 %.8g 0 0 0 0 %.8g ", f, f, f, f);
|
||||
} else if (islit && lit->typespec().is_float()) {
|
||||
float f = lit->floatval();
|
||||
out += Strutil::format ("%.8g 0 0 0 0 %.8g 0 0 0 0 %.8g 0 0 0 0 %.8g ", f, f, f, f);
|
||||
} else if (init && init->typespec() == type &&
|
||||
init->nodetype() == ASTNode::type_constructor_node) {
|
||||
ASTtype_constructor *ctr = (ASTtype_constructor *) init;
|
||||
ASTNode::ref val = ctr->args();
|
||||
@@ -665,26 +666,23 @@ ASTvariable_declaration::param_one_default_literal (const Symbol *sym,
|
||||
if (val.get() && val->nodetype() == ASTNode::literal_node) {
|
||||
f[c] = ((ASTliteral *)val.get())->floatval ();
|
||||
val = val->next();
|
||||
if (! val.get()) // we're done -- no more args
|
||||
break;
|
||||
} else {
|
||||
f[c] = 0;
|
||||
completed = false;
|
||||
}
|
||||
}
|
||||
if (nargs == 1)
|
||||
out += Strutil::format ("%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g ",
|
||||
f[0], f[0], f[0], f[0], f[0], f[0], f[0], f[0])
|
||||
+ Strutil::format ("%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g ",
|
||||
f[0], f[0], f[0], f[0], f[0], f[0], f[0], f[0]);
|
||||
out += Strutil::format ("%.8g 0 0 0 0 %.8g 0 0 0 0 %.8g 0 0 0 0 %.8g ",
|
||||
f[0], f[0], f[0], f[0]);
|
||||
else
|
||||
out += Strutil::format ("%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g ",
|
||||
f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7])
|
||||
+ Strutil::format ("%.8g %.8g %.8g %.8g %.8g %.8g %.8g %.8g",
|
||||
f[8], f[9], f[10], f[11], f[12], f[13], f[14], f[15]);
|
||||
} else {
|
||||
f = 0;
|
||||
std::string s = Strutil::format ("%.8g ", f);
|
||||
for (int i = 0; i < 16; ++i)
|
||||
out += s;
|
||||
out += "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ";
|
||||
completed = false;
|
||||
}
|
||||
} else if (type.is_string()) {
|
||||
@@ -1230,24 +1228,30 @@ ASTunary_expression::codegen (Symbol *dest)
|
||||
Symbol *
|
||||
ASTbinary_expression::codegen (Symbol *dest)
|
||||
{
|
||||
// Special case for logal ops that short-circuit
|
||||
// Special case for logic ops that short-circuit
|
||||
if (m_op == And || m_op == Or)
|
||||
return codegen_logic (dest);
|
||||
|
||||
// Special case for closure operations
|
||||
if (typespec().is_closure())
|
||||
return codegen_closure (dest);
|
||||
|
||||
Symbol *lsym = left()->codegen ();
|
||||
Symbol *rsym = right()->codegen ();
|
||||
if (dest == NULL || ! equivalent (dest->typespec(), typespec()))
|
||||
dest = m_compiler->make_temporary (typespec());
|
||||
|
||||
// FIXME -- what about coerced types, do we need a temp and copy here?
|
||||
// Special case for closure operations
|
||||
if (typespec().is_closure()) {
|
||||
ASSERT (m_op == Mul || m_op == Div || m_op == Add);
|
||||
if (m_op == Mul || m_op == Div) {
|
||||
// Need to coerce the weight into a color.
|
||||
// N.B. The typecheck always reorders c=k*c into c=c*k.
|
||||
rsym = coerce (rsym, TypeDesc::TypeColor, true);
|
||||
}
|
||||
emitcode (opword(), dest, lsym, rsym);
|
||||
return dest;
|
||||
}
|
||||
|
||||
// Promote ints to float-like types, for mixed arithmetic
|
||||
if ((m_op == Mul || m_op == Div || m_op == Add || m_op == Sub)) {
|
||||
if ((lsym->typespec().is_closure() || lsym->typespec().is_floatbased()) && rsym->typespec().is_int()) {
|
||||
if (lsym->typespec().is_floatbased() && rsym->typespec().is_int()) {
|
||||
if (rsym->symtype() == SymTypeConst) {
|
||||
float val = ((ConstantSymbol *)rsym)->floatval();
|
||||
rsym = m_compiler->make_constant (val);
|
||||
@@ -1256,7 +1260,7 @@ ASTbinary_expression::codegen (Symbol *dest)
|
||||
rsym = m_compiler->make_temporary (lsym->typespec());
|
||||
emitcode ("assign", rsym, tmp); // type coercion
|
||||
}
|
||||
} else if (lsym->typespec().is_int() && (rsym->typespec().is_closure() || rsym->typespec().is_floatbased())) {
|
||||
} else if (lsym->typespec().is_int() && rsym->typespec().is_floatbased()) {
|
||||
if (lsym->symtype() == SymTypeConst) {
|
||||
float val = ((ConstantSymbol *)lsym)->floatval();
|
||||
lsym = m_compiler->make_constant (val);
|
||||
@@ -1306,93 +1310,6 @@ ASTbinary_expression::codegen_logic (Symbol *dest)
|
||||
|
||||
|
||||
|
||||
bool
|
||||
ASTbinary_expression::subtrees_involve_closure (Symbol *s)
|
||||
{
|
||||
if (m_op == Mul || m_op == Div) {
|
||||
// N.B. The typecheck always reorders c=k*c into c=c*k.
|
||||
ASSERT (left()->typespec().is_closure() &&
|
||||
!right()->typespec().is_closure());
|
||||
// There are only a couple cases here. Either this node is
|
||||
// closure_variable * scalar (is the var s?)
|
||||
// or closure_binary_expression * scalar (recurse)
|
||||
// or closure_function * scalar (definitely not s)
|
||||
ASTNode *l = left().get();
|
||||
if (l->nodetype() == variable_ref_node)
|
||||
return ((ASTvariable_ref *)l)->sym() == s;
|
||||
else if (l->nodetype() == binary_expression_node)
|
||||
return ((ASTbinary_expression *)l)->subtrees_involve_closure (s);
|
||||
else
|
||||
return false;
|
||||
} else if (m_op == Add) {
|
||||
// There are only a couple cases here. Left and right can each
|
||||
// either be a closure variable (test it), a binary expression
|
||||
// (recurse), or a closure function (definitely false).
|
||||
bool left_uses_result = false, right_uses_result = false;
|
||||
ASTNode *l = left().get(), *r = right().get();
|
||||
if (l->nodetype() == variable_ref_node)
|
||||
left_uses_result |= ((ASTvariable_ref *)l)->sym() == s;
|
||||
else if (l->nodetype() == binary_expression_node)
|
||||
left_uses_result |= ((ASTbinary_expression *)l)->subtrees_involve_closure (s);
|
||||
if (r->nodetype() == variable_ref_node)
|
||||
right_uses_result |= ((ASTvariable_ref *)l)->sym() == s;
|
||||
else if (r->nodetype() == binary_expression_node)
|
||||
right_uses_result |= ((ASTbinary_expression *)r)->subtrees_involve_closure (s);
|
||||
return left_uses_result | right_uses_result;
|
||||
}
|
||||
ASSERT (0 && "unhandled closure op case"); // can't get here
|
||||
}
|
||||
|
||||
|
||||
|
||||
Symbol *
|
||||
ASTbinary_expression::codegen_closure (Symbol *dest)
|
||||
{
|
||||
if (dest == NULL || ! equivalent (dest->typespec(), typespec()))
|
||||
dest = m_compiler->make_temporary (typespec());
|
||||
|
||||
if (m_op == Mul || m_op == Div) {
|
||||
// Special handling of r = closure * k (or closure/k)
|
||||
// Instead of generating "closure tmp1 ... ; mul r tmp1 k",
|
||||
// generate the more efficient "closure r ... ; mul r r k".
|
||||
// N.B. The typecheck always reorders c=k*c into c=c*k.
|
||||
Symbol *lsym = left()->codegen (dest);
|
||||
Symbol *rsym = coerce (right()->codegen(), TypeDesc::TypeColor, true);
|
||||
emitcode (opword(), dest, lsym, rsym);
|
||||
} else if (m_op == Add) {
|
||||
ASSERT (left()->typespec().is_closure() &&
|
||||
right()->typespec().is_closure());
|
||||
// Special handling of r = closure1 + closure2, which in reality
|
||||
// is often r = k1*closure1 + k2*closure2, and thus would lead to
|
||||
// code like this:
|
||||
// mul tmp1 k1 c1 ; mul tmp2 k2 c2 ; add r tmp1 tmp2
|
||||
// And note that the add (and maybe the muls) implicitly have
|
||||
// a clear and copy in them. Instead, generate this:
|
||||
// mul r k1 c1; mul tmp2 k2 c2; add r r tmp2
|
||||
// This results in one fewer temp, fewer copies. BUT... must be
|
||||
// careful of situations like r = k1*c1 + k2*r, where we might
|
||||
// overwrite r too soon.
|
||||
Symbol *lsym;
|
||||
if (! subtrees_involve_closure (dest)) {
|
||||
// None of the subtrees involve the destination, so use it
|
||||
lsym = left()->codegen (dest);
|
||||
} else {
|
||||
// The subtrees involve the destination, so be safe and let it
|
||||
// generate a new destination.
|
||||
lsym = left()->codegen ();
|
||||
}
|
||||
Symbol *rsym = right()->codegen ();
|
||||
emitcode (opword(), dest, lsym, rsym);
|
||||
} else {
|
||||
// I don't think this can happen
|
||||
ASSERT (0 && "unhandled closure op case");
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Symbol *
|
||||
ASTternary_expression::codegen (Symbol *dest)
|
||||
{
|
||||
|
||||
@@ -263,7 +263,7 @@ NdfAutomata::tostr()const
|
||||
std::string s;
|
||||
for (size_t i = 0; i < m_states.size(); ++i) {
|
||||
char temp[32];
|
||||
snprintf(temp, 32, "%ld : ", i);
|
||||
snprintf(temp, 32, "%d : ", (int)i);
|
||||
s += temp + m_states[i]->tostr() + "\n";
|
||||
}
|
||||
return s;
|
||||
@@ -411,7 +411,7 @@ DfAutomata::tostr()const
|
||||
std::string s;
|
||||
for (size_t i = 0; i < m_states.size(); ++i) {
|
||||
char temp[32];
|
||||
snprintf(temp, 32, "%ld : ", i);
|
||||
snprintf(temp, 32, "%d : ", (int)i);
|
||||
s += temp + m_states[i]->tostr() + "\n";
|
||||
}
|
||||
return s;
|
||||
|
||||
@@ -59,15 +59,17 @@ public:
|
||||
// seed based on the cell containing P
|
||||
fast_rng (const Vec3 &p, int seed=0) {
|
||||
// Use guts of cellnoise
|
||||
unsigned int pi[4] = { quick_floor(p[0]), quick_floor(p[1]),
|
||||
quick_floor(p[2]), seed };
|
||||
unsigned int pi[4] = { unsigned(quick_floor(p[0])),
|
||||
unsigned(quick_floor(p[1])),
|
||||
unsigned(quick_floor(p[2])),
|
||||
unsigned(seed) };
|
||||
m_seed = inthash<4>(pi);
|
||||
if (! m_seed)
|
||||
m_seed = 1;
|
||||
}
|
||||
// Return uniform on [0,1)
|
||||
float operator() () {
|
||||
return (m_seed *= 3039177861) / float(UINT_MAX);
|
||||
return (m_seed *= 3039177861u) / float(UINT_MAX);
|
||||
}
|
||||
// Return poisson distribution with the given mean
|
||||
int poisson (float mean) {
|
||||
|
||||
@@ -45,8 +45,8 @@ static void
|
||||
usage ()
|
||||
{
|
||||
std::cout <<
|
||||
"oslc -- Open Shading Language compiler\n"
|
||||
"(c) Copyright 2009-2010 Sony Pictures Imageworks, Inc. All Rights Reserved.\n"
|
||||
"oslc -- Open Shading Language compiler " OSL_LIBRARY_VERSION_STRING "\n"
|
||||
OSL_COPYRIGHT_STRING "\n"
|
||||
"Usage: oslc [options] file\n"
|
||||
" Options:\n"
|
||||
"\t--help Print this usage message\n"
|
||||
|
||||
@@ -51,7 +51,8 @@ using namespace OSL;
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
std::cout << "oslinfo -- list parameters of a compiled OSL shader\n";
|
||||
std::cout << "oslinfo " OSL_LIBRARY_VERSION_STRING " -- list parameters of a compiled OSL shader\n";
|
||||
std::cout << OSL_COPYRIGHT_STRING "\n";
|
||||
std::cout << "Usage: oslinfo [options] file0 [file1 ...]\n";
|
||||
std::cout << "Options:\n";
|
||||
std::cout << " -v Verbose\n";
|
||||
@@ -130,6 +131,8 @@ print_metadata (const OSLQuery::Parameter &m)
|
||||
{
|
||||
std::string typestring (m.type.c_str());
|
||||
std::cout << "\t\tmetadata: " << typestring << ' ' << m.name << " =";
|
||||
for (unsigned int d = 0; d < m.idefault.size(); ++d)
|
||||
std::cout << " " << m.idefault[d];
|
||||
for (unsigned int d = 0; d < m.fdefault.size(); ++d)
|
||||
std::cout << " " << m.fdefault[d];
|
||||
for (unsigned int d = 0; d < m.sdefault.size(); ++d)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
shader a (output color out = 0)
|
||||
{
|
||||
printf ("a start, Ci = '%s'\n", Ci);
|
||||
Ci = color(1,0,0) * emission();
|
||||
printf ("a end, Ci = '%s'\n", Ci);
|
||||
out = color(0,1,u);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
shader b (color in = color(0,1,0))
|
||||
{
|
||||
printf ("b start, Ci = '%s'\n", Ci);
|
||||
Ci = in * emission();
|
||||
printf ("b end, Ci = '%s'\n", Ci);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Compiled a.osl -> a.oso
|
||||
Compiled b.osl -> b.oso
|
||||
Connect alayer.out to blayer.in
|
||||
b start, Ci = ''
|
||||
a start, Ci = ''
|
||||
a end, Ci = '(1, 0, 0) * emission ()'
|
||||
b end, Ci = '(0, 1, 0.5) * emission ()'
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
command += testshade("-layer alayer a --layer blayer b --connect alayer out blayer in")
|
||||
@@ -1,4 +1,9 @@
|
||||
Compiled test.osl -> test.oso
|
||||
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
|
||||
|
||||
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)
|
||||
= 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
|
||||
@@ -56,6 +61,11 @@ Testing matrix math:
|
||||
(M!=M) ? 0
|
||||
(M==Ident) ? 0
|
||||
(M!=Ident) ? 1
|
||||
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
|
||||
|
||||
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)
|
||||
= 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
|
||||
@@ -112,6 +122,11 @@ Testing matrix math:
|
||||
(M!=M) ? 0
|
||||
(M==Ident) ? 0
|
||||
(M!=Ident) ? 1
|
||||
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
|
||||
|
||||
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)
|
||||
= 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
|
||||
@@ -168,6 +183,11 @@ Testing matrix math:
|
||||
(M!=M) ? 0
|
||||
(M==Ident) ? 0
|
||||
(M!=Ident) ? 1
|
||||
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
|
||||
|
||||
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)
|
||||
= 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
|
||||
|
||||
@@ -21,8 +21,17 @@ void matrix_fromto (string from, string to)
|
||||
|
||||
|
||||
shader
|
||||
test ()
|
||||
test (matrix matrixparam0 = 0,
|
||||
matrix matrixparam1 = 1,
|
||||
matrix matrixparam1m = matrix(1))
|
||||
{
|
||||
// Test parameter initialization
|
||||
printf ("Parameter initialization:\n");
|
||||
printf (" matrixparam0 = %g\n", matrixparam0);
|
||||
printf (" matrixparam1 = %g\n", matrixparam1);
|
||||
printf (" matrixparam1m = %g\n", matrixparam1m);
|
||||
printf ("\n");
|
||||
|
||||
// Test matrix constructors
|
||||
{
|
||||
float a = 0.1, b = 0.2, c = 0.3, d = 0.4,
|
||||
|
||||
Reference in New Issue
Block a user