Compare commits

...
16 Commits
Author SHA1 Message Date
Larry Gritz 2bd85490b9 CHANGES, rebuild docs, bump version for 1.3.2 2013-06-19 23:55:29 -07:00
Larry Gritz 3e78b9c415 Bug fix -- filterwidth() wasn't properly enforcing that it needs derivs.
Also remove type checking table entry for aastep, which was never implemented.
2013-06-19 23:54:52 -07:00
Larry Gritz 5049bceeac Get rid of TBB references 2013-06-19 15:42:27 -07:00
Brecht Van Lommel fb869bb112 Fix missing output of shader parameters when returning from a block.
Early 'return' was jumping to the exit_instance_block, but we were
incorrectly putting the code that copies output variables to their
destination layer before this block, rather than after.  The solution
is to do the output copying after that jump point.
2013-06-19 13:04:24 -07:00
Brecht Van Lommel e3a43c2557 oslc now gives a compile error when trying to use a function as a variable,
previously it would output non working bytecode.
2013-06-19 13:04:24 -07:00
Larry Gritz 8d1e362d86 Avoid incorrect heap addressing when retrieving a symbol's address 2013-06-19 12:52:14 -07:00
Larry Gritz e2b744b41c Nicer debug printing when op doesn't have an associated source line 2013-06-19 12:51:32 -07:00
Brecht Van Lommel fc97bc018d Fix missing osl_fmod_vvf and dual functions on Windows. 2013-06-19 12:50:45 -07:00
Larry Gritz 12efa45e2d CHANGES, rebuild docs, bump version for 1.3.1 2013-05-15 14:37:19 -07:00
Larry Gritz a746da86ae Fix missing integer min, max, and clamp declarations 2013-05-15 14:36:44 -07:00
Larry Gritz 41b73da7e3 Add make and CMake options USE_EXTERNAL_PUGIXML to use external/system
PugiXML rather than the one from the OIIO distribution.  This is especially
helpful for sites that build OIIO with its USE_EXTERNAL_PUGIXML mode.
2013-05-15 13:49:36 -07:00
Larry Gritz 92e48c9ea5 Eliminate random() from the spec; never implemented, not missed.
Augment description of hash() to allow it to hash integers and strings.
2013-05-14 09:15:42 -07:00
Larry Gritz 5fcc5c1520 Workaround cmake bug where some platforms don't set NDEBUG for RelWithDebInfo 2013-05-14 09:14:21 -07:00
est77 02fe54bf43 Added cmake option to enable/disable RTTI. 2013-05-14 09:14:01 -07:00
Larry Gritz 60c990cbf3 Fix pair construction problems with some compilers 2013-04-23 12:49:43 -07:00
Larry Gritz 34f84f791d Fix shared_ptr ambiguity
Have an OSL::shared_ptr, which is either std::shared_ptr (if C++11) or
boost::shared_ptr (not C++11).

Change all explicit refs to boost::shared_ptr and the occasional
implicit reference to OIIO::shared_ptr, all to OSL::shared_ptr.
2013-04-23 12:49:33 -07:00
22 changed files with 263 additions and 194 deletions
+35
View File
@@ -1,3 +1,38 @@
Release 1.3.2 - 19 Jun 2013 (compared to 1.3.1)
-----------------------------------------------
* fmod(triple,triple,float) was not working properly in Windows.
* Nicer debug printing (for developers) when an op doesn't have an
associated source line.
* Avoid incorrect heap addressing when retrieving a symbol's address.
* oslc new gives a compile error when trying to use a function as
if it were an ordinary variable.
* Fix for a bug where an early 'return' from a shader could lead to
output parameters not being properly copied to the inputs of their
downstream connections.
* Fix bug where filterwidth() didn't properly mark itself as needing
derivatives of its argument.
Release 1.3.1 - 15 May 2013 (compared to 1.3.0)
-----------------------------------------------
* The integer versions of min(), max(), and clamp() were not working
properly.
* Added CMake option 'ENABLERTTI' that enables use of RTTI for sites that
must link against an RTTI-enabled LLVM (the default is to assume LLVM
is built without RTTI, so we don't use it either).
* Work around CMake bug where on some platforms, CMake doesn't define the
'NDEBUG' when making the 'RelWithDebInfo' target (which is sometimes
used for profiling).
* Docs: Eliminated discussion of random(), which was never implemented
and we can't think of a good use case.
* Add Make/CMake option 'USE_EXTERNAL_PUGIXML' which if set to nonzero
will find and use a system-installed PugiXML rather than assuming that
it's included in libOpenImageIO. When used, it will also use the
environment variable PUGIXML_HOME (if set) as a hint for where to find
it, in case it's not in a usual system library directory.
Release 1.3.0 - 14 Feb 2013 (compared to 1.2)
----------------------------------------------
+5 -5
View File
@@ -44,10 +44,6 @@ MY_CMAKE_FLAGS += -DVERBOSE:BOOL=1
TEST_FLAGS += -V
endif
ifneq (${USE_TBB},)
MY_CMAKE_FLAGS += -DUSE_TBB:BOOL=${USE_TBB}
endif
ifneq (${LLVM_DIRECTORY},)
MY_CMAKE_FLAGS += -DLLVM_DIRECTORY:STRING=${LLVM_DIRECTORY}
endif
@@ -100,6 +96,10 @@ ifneq (${BUILDSTATIC},)
MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=${BUILDSTATIC}
endif
ifneq (${USE_EXTERNAL_PUGIXML},)
MY_CMAKE_FLAGS += -DUSE_EXTERNAL_PUGIXML:BOOL=${USE_EXTERNAL_PUGIXML} -DPUGIXML_HOME=${PUGIXML_HOME}
endif
ifdef DEBUG
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug
endif
@@ -238,7 +238,6 @@ help:
@echo " make VERBOSE=1 ... Show all compilation commands"
@echo " make MYCC=xx MYCXX=yy ... Use custom compilers"
@echo " make OSL_SITE=xx Use custom site build mods"
@echo " make USE_TBB=0 ... Don't use TBB"
@echo " make LLVM_VERSION=2.9 ... Specify which LLVM version to use"
@echo " make LLVM_DIRECTORY=xx ... Specify where LLVM lives"
@echo " make LLVM_NAMESPACE=xx ... Specify custom LLVM namespace"
@@ -251,4 +250,5 @@ help:
@echo " make PARTIO_HOME=... Use Partio from the given location"
@echo " make STOP_ON_WARNING=0 Do not stop building if compiler warns"
@echo " make BUILDSTATIC=1 ... Build static library instead of shared"
@echo " make USE_EXTERNAL_PUGIXML=1 Use the system PugiXML, not the one in OIIO"
@echo ""
+36 -20
View File
@@ -3,7 +3,7 @@ project (OSL)
# Release version of the library
set (OSL_LIBRARY_VERSION_MAJOR 1)
set (OSL_LIBRARY_VERSION_MINOR 3)
set (OSL_LIBRARY_VERSION_PATCH 0)
set (OSL_LIBRARY_VERSION_PATCH 2)
# Version of the OSO file format and instruction set
set (OSO_FILE_VERSION_MAJOR 1)
@@ -28,6 +28,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions ("-DDEBUG=1")
set (DEBUGMODE ON)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# cmake bug workaround -- on some platforms, cmake doesn't set
# NDEBUG for RelWithDebInfo mode
add_definitions ("-DNDEBUG")
endif ()
# Figure out which compiler we're using
@@ -54,24 +59,29 @@ if (NOT MSVC)
endif ()
endif ()
## disable RTTI
## NOTE(ckulla): LLVM builds without RTTI by default so beware
## if you find the need to turn this on, as OSL classes
## extending LLVM ones will cause linker errors (unless you
## rebuild LLVM with rtti enabled)
if (MSVC)
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-" )
else ()
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
endif()
## enable RTTI
## NOTE: LLVM builds without RTTI by default so beware
## if you find the need to turn this on, to use OSL in a
## project that requires RTTI for example, you need to build
## LLVM with RRTI, otherwise OSL classes extending LLVM ones
## will cause linker errors.
set (ENABLERTTI OFF CACHE BOOL "Build with RTTI. Requires a LLVM build with RTTI enabled.")
# For gcc < 4.3 and certain Clang versions, Boost needs some extra help
# detecting that we've disabled RTTI.
if ((CMAKE_COMPILER_IS_GNUCC AND GCC_VERSION VERSION_LESS 4.3)
OR CMAKE_COMPILER_IS_CLANG)
add_definitions ("-DBOOST_NO_RTTI")
add_definitions ("-DBOOST_NO_TYPEID")
endif ()
if (NOT ENABLERTTI)
if (MSVC)
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-" )
else ()
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
endif()
# For gcc < 4.3, Boost needs some extra help detecting that we've
# disabled RTTI.
if ((CMAKE_COMPILER_IS_GNUCC AND GCC_VERSION VERSION_LESS 4.3)
OR CMAKE_COMPILER_IS_CLANG)
add_definitions ("-DBOOST_NO_RTTI")
add_definitions ("-DBOOST_NO_TYPEID")
endif ()
endif()
# Needed for static boost libraries on Windows
if (WIN32 AND Boost_USE_STATIC_LIBS)
@@ -115,7 +125,9 @@ endif ()
set (VERBOSE OFF CACHE BOOL "Print lots of messages while compiling")
set (BUILDSTATIC OFF CACHE BOOL "Build static library instead of shared")
set (HIDE_SYMBOLS OFF CACHE BOOL "Hide symbols not in the public API")
set (USE_TBB ON CACHE BOOL "Use TBB if needed")
set (USE_EXTERNAL_PUGIXML OFF CACHE BOOL
"Use an externally built shared library version of the pugixml library")
set (PUGIXML_HOME "" CACHE STRING "Hint about where to find external PugiXML library")
if (WIN32)
set (USE_BOOST_WAVE ON CACHE BOOL "Use Boost Wave as preprocessor")
set (USE_LLVM_BITCODE OFF CACHE BOOL "Generate embedded LLVM bitcode")
@@ -129,6 +141,10 @@ if (LLVM_NAMESPACE)
add_definitions ("-DLLVM_NAMESPACE=${LLVM_NAMESPACE}")
endif ()
if (USE_EXTERNAL_PUGIXML)
add_definitions ("-DUSE_EXTERNAL_PUGIXML")
endif ()
if (EXTRA_CPP_DEFINITIONS)
add_definitions ("${EXTRA_CPP_DEFINITIONS}")
endif()
@@ -146,7 +162,7 @@ include (flexbison)
include_directories (
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include
${OPENIMAGEIO_INCLUDES} ${TBB_INCLUDES}
${OPENIMAGEIO_INCLUDES}
)
+14 -47
View File
@@ -103,53 +103,6 @@ link_directories ("${Boost_LIBRARY_DIRS}")
###########################################################################
###########################################################################
# TBB (Intel Thread Building Blocks) setup
setup_path (TBB_HOME "${THIRD_PARTY_TOOLS_HOME}"
"Location of the TBB library install")
mark_as_advanced (TBB_HOME)
if (USE_TBB)
set (TBB_VERSION 22_004oss)
if (MSVC)
find_library (TBB_LIBRARY
NAMES tbb
PATHS ${TBB_HOME}/lib
PATHS ${THIRD_PARTY_TOOLS_HOME}/lib/
${TBB_HOME}/tbb-${TBB_VERSION}/lib/
)
find_library (TBB_DEBUG_LIBRARY
NAMES tbb_debug
PATHS ${TBB_HOME}/lib
PATHS ${THIRD_PARTY_TOOLS_HOME}/lib/
${TBB_HOME}/tbb-${TBB_VERSION}/lib/)
endif (MSVC)
find_path (TBB_INCLUDES tbb/tbb_stddef.h
${TBB_HOME}/include/tbb${TBB_VERSION}
${THIRD_PARTY_TOOLS}/include/tbb${TBB_VERSION}
${PROJECT_SOURCE_DIR}/include
${OPENIMAGEIOHOME}/include/OpenImageIO
)
if (TBB_INCLUDES OR TBB_LIBRARY)
set (TBB_FOUND TRUE)
add_definitions ("-DUSE_TBB=1")
if (VERBOSE)
message (STATUS "TBB includes = ${TBB_INCLUDES}")
message (STATUS "TBB library = ${TBB_LIBRARY}")
endif ()
else ()
message (STATUS "TBB not found")
endif ()
else ()
add_definitions ("-DUSE_TBB=0")
message (STATUS "TBB will not be used")
set(TBB_INCLUDES "")
set(TBB_LIBRARY "")
endif ()
# end TBB setup
###########################################################################
###########################################################################
# Partio
@@ -184,6 +137,20 @@ endif (USE_PARTIO)
###########################################################################
###########################################################################
# Pugixml setup. Normally we just use the version bundled with oiio, but
# some linux distros are quite particular about having separate packages so we
# allow this to be overridden to use the distro-provided package if desired.
if (USE_EXTERNAL_PUGIXML)
find_package (PugiXML REQUIRED)
# insert include path to pugixml first, to ensure that the external
# pugixml is found, and not the one in OIIO's include directory.
include_directories (BEFORE ${PUGIXML_INCLUDE_DIR})
endif()
# end Pugixml setup
###########################################################################
###########################################################################
# LLVM library setup
+29
View File
@@ -0,0 +1,29 @@
# Find the pugixml XML parsing library.
#
# Sets the usual variables expected for find_package scripts:
#
# PUGIXML_INCLUDE_DIR - header location
# PUGIXML_LIBRARIES - library to link against
# PUGIXML_FOUND - true if pugixml was found.
find_path (PUGIXML_INCLUDE_DIR
NAMES pugixml.hpp
PATHS ${PUGIXML_HOME}/include)
find_library (PUGIXML_LIBRARY
NAMES pugixml
PATHS ${PUGIXML_HOME}/lib)
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
include (FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (PugiXML DEFAULT_MSG PUGIXML_LIBRARY
PUGIXML_INCLUDE_DIR)
if (PUGIXML_FOUND)
set (PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
message (STATUS "PugiXML include = ${PUGIXML_INCLUDE_DIR}")
message (STATUS "PugiXML library = ${PUGIXML_LIBRARY}")
else ()
message (STATUS "No PugiXML found")
endif()
mark_as_advanced (PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
+9 -22
View File
@@ -63,7 +63,7 @@ Editor: Larry Gritz \\
\emph{lg@imageworks.com}
}
\date{{\large Date: 28 Jan, 2013 \\
~ %(with corrections, 22 Feb, 2012)
~ (with corrections, 15 May, 2013)
}
\bigskip
\bigskip
@@ -388,8 +388,6 @@ other open source packages:
{\cf http://openimageio.org}
\item Ilmbase \copyright\ 2006, Industrial Light \& Magic.
{\cf http://www.openexr.com}
\item Thread Building Blocks (TBB), \copyright\ 2005--2008 Intel Corporation.\\
{\cf http://www.threadingbuildingblocks.org/}
\item Boost \copyright\ various authors. {\cf http://www.boost.org}
\item LLVM \copyright\ 2003-2010 University of Illinois at
Urbana-Champaign. {\cf http://llvm.org}
@@ -3483,14 +3481,16 @@ The old {\cf cellnoise(...coords...)} function is equivalent to
\apiitem{\emph{type} {\ce hash} (float u) \\
\emph{type} {\ce hash} (float u, float v) \\
\emph{type} {\ce hash} (point p) \\
\emph{type} {\ce hash} (point p, float t)}
\emph{type} {\ce hash} (point p, float t) \\
\emph{type} {\ce hash} (int i) \\
\emph{type} {\ce hash} (string s)}
\indexapi{hash()}
Returns a deterministic, repeatable \emph{hash} of the 1-, 2-, 3-, or
4-D coordinates. The return values will be evenly distributed on
$[0,1]$ and be completely repeatable when passed the same coordinates
again, yet will be uncorrellated to hashes of any other positions
(including nearby points). This is like having a random value indexed
spatially, but that will be repeatable from frame to frame of an
4-D coordinates, integer, or string. The return values will be evenly
distributed on $[0,1]$ and be completely repeatable when passed the same
coordinates again, yet will be uncorrellated to hashes of any other
positions (including nearby points). This is like having a random value
indexed spatially, but that will be repeatable from frame to frame of an
animation (provided its input is \emph{precisely} identical).
The return \emph{type} may be any of \float, \color, \point, \vector, or
@@ -3500,19 +3500,6 @@ The return \emph{type} may be any of \float, \color, \point, \vector, or
function.
\apiend
\apiitem{\emph{type} {\ce random} ()}
\indexapi{random()}
Returns a pseudorandom value uniformly distributed on $[0,1]$. Use with
extreme caution --- the results are not necessarily repeatable from
frame to frame.
The return \emph{type} may be any of \float, \color, \point, \vector, or
\normal, depending on the type of the variable the result is assigned to
(or based on an explicit type cast). For multi-component return types
(e.g., \point), each component is an uncorrelated \float\ {\cf random()}
function.
\apiend
\apiitem{\emph{type} {\ce spline} (string basis, float x, \emph{type} $\mathtt{y}_0$, \emph{type} $\mathtt{y}_1$, ... \emph{type} $\mathtt{y}_{n-1}$)\\
\emph{type} {\ce spline} (string basis, float x, \emph{type} y[]) \\
\emph{type} {\ce spline} (string basis, float x, int nknots, \emph{type} y[])}
Binary file not shown.
+18 -12
View File
@@ -36,6 +36,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/// renderer that wanted things a different way.
/////////////////////////////////////////////////////////////////////////
// Test if we are using C++11
#if (__cplusplus >= 201103L)
#define OSL_USING_CPLUSPLUS11 1
#endif
// Symbol export defines
#include "export.h"
@@ -51,6 +56,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <OpenImageIO/typedesc.h>
#include <OpenImageIO/ustring.h>
// Sort out smart pointers
#ifdef OSL_USING_CPLUSPLUS11
# include <memory>
#else
# include <boost/shared_ptr.hpp>
#endif
// Extensions to Imath
#include "matrix22.h"
@@ -96,20 +108,14 @@ using OIIO::TypeDesc;
using OIIO::ustring;
using OIIO::ustringHash;
// Sort out smart pointers
#ifdef OSL_USING_CPLUSPLUS11
using std::shared_ptr;
#else
using boost::shared_ptr;
#endif
// These symbols define whether the shading system uses runflags, point
// indices, or spans. Exactly one should be set to 1!
// N.B. Spans not fully supported currently.
#define USE_RUNFLAGS 0
#define USE_RUNINDICES 0
#define USE_RUNSPANS 1
// Temporary measure to identify the branch with LLVM support. Sorry.
#define LLVM_SUPPORT 1
OSL_NAMESPACE_EXIT
#endif /* OSLCONFIG_H */
+1 -1
View File
@@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "oslconfig.h"
#include <OpenImageIO/refcnt.h> // just to get shared_ptr from boost ?!
#include <OpenImageIO/refcnt.h>
#include <OpenImageIO/ustring.h>
+4
View File
@@ -396,6 +396,10 @@ ASTvariable_ref::ASTvariable_ref (OSLCompilerImpl *comp, ustring name)
// find the things that almost matched and offer suggestions.
return;
}
if (m_sym->symtype() == SymTypeFunction) {
error ("function '%s' can't be used as a variable", name.c_str());
return;
}
m_typespec = m_sym->typespec();
}
+2 -1
View File
@@ -29,6 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OSL_AST_H
#define OSL_AST_H
#include <boost/intrusive_ptr.hpp>
#include "OpenImageIO/refcnt.h"
#include "oslconfig.h"
@@ -56,7 +57,7 @@ class TypeSpec;
///
class ASTNode : public OIIO::RefCnt {
public:
typedef intrusive_ptr<ASTNode> ref; ///< Ref-counted pointer to an ASTNode
typedef boost::intrusive_ptr<ASTNode> ref; ///< Ref-counted pointer to an ASTNode
/// List of all the types of AST nodes.
///
+4 -3
View File
@@ -932,14 +932,16 @@ ASTfunction_call::typecheck_builtin_specialcase ()
// N.B. This counts arguments in the same way that opcodes do --
// assuming "arg 0" is the return value.
size_t nargs = listlength(args());
if (m_name == "area") {
if (m_name == "area" || m_name == "filterwidth") {
argtakesderivs (1, true);
#if 0
} else if (m_name == "aastep") {
// all but the 5-arg version take derivs of edge param
argtakesderivs (1, nargs<5);
// aastep(f,f) and aastep(f,f,str) take derivs of s param
if (nargs == 2 || list_nth(args(),2)->typespec().is_string())
argtakesderivs (2, true);
#endif
} else if (m_name == "bump" || m_name == "displace") {
// FIXME -- come back to this
} else if (m_name == "calculatenormal") {
@@ -1103,7 +1105,6 @@ ASTfunction_call::typecheck (TypeSpec expected)
static const char * builtin_func_args [] = {
"aastep", "fff", "ffff", "fffff", "fffs", "ffffs", "fffffs", "!deriv", NULL,
"area", "fp", "!deriv", NULL,
"arraylength", "i?[]", NULL,
"backfacing", "i", NULL,
@@ -1122,7 +1123,7 @@ static const char * builtin_func_args [] = {
"vsv.", "vsvvv.", "!tex", "!rw", "!deriv", NULL,
"error", "xs*", "!printf", NULL,
"exit", "x", NULL,
"filterwidth", "ff", "vp", "vv", NULL,
"filterwidth", "ff", "vp", "vv", "!deriv", NULL,
"format", "ss*", "!printf", NULL,
"fprintf", "xs*", "!printf", NULL,
"getattribute", "is?", "is?[]", "iss?", "iss?[]", "isi?", "isi?[]", "issi?", "issi?[]", "!rw", NULL, // FIXME -- further checking?
+2 -2
View File
@@ -92,7 +92,7 @@ MACRO ( LLVM_COMPILE llvm_src srclist )
-I${CMAKE_SOURCE_DIR}/include
-I${CMAKE_BINARY_DIR}/include
-I${OPENIMAGEIO_INCLUDES} -I${ILMBASE_INCLUDE_DIR}
-I${Boost_INCLUDE_DIRS} -I${TBB_INCLUDES} -O3 -S -emit-llvm -o ${llvm_asm} ${llvm_src}
-I${Boost_INCLUDE_DIRS} -O3 -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}
@@ -119,7 +119,7 @@ endif ()
TARGET_LINK_LIBRARIES ( oslexec
${VISIBILITY_COMMAND} ${VISIBILITY_MAP_COMMAND}
${OPENIMAGEIO_LIBRARY}
${OPENIMAGEIO_LIBRARY} ${PUGIXML_LIBRARIES}
${PARTIO_LIBRARIES} ${ZLIB_LIBRARIES}
${Boost_LIBRARIES} ${CMAKE_DL_LIBS}
${LLVM_LIBRARY} ${EXTRA_OSLEXEC_LIBRARIES})
+3 -1
View File
@@ -152,8 +152,10 @@ ShadingContext::symbol_data (Symbol &sym)
if (! sgroup.llvm_compiled_version())
return NULL; // can't retrieve symbol if we didn't JIT and runit
if (sym.dataoffset() >= 0) // lives on the heap
if (sym.dataoffset() >= 0 && (int)m_heap.size() > sym.dataoffset()) {
// lives on the heap
return &m_heap[sym.dataoffset()];
}
// doesn't live on the heap
if ((sym.symtype() == SymTypeParam || sym.symtype() == SymTypeOutputParam) &&
+8 -1
View File
@@ -36,7 +36,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/algorithm/string.hpp>
#include <OpenImageIO/dassert.h>
#include <OpenImageIO/pugixml.hpp>
#ifdef USE_EXTERNAL_PUGIXML
# include <pugixml.hpp>
#else
# include <OpenImageIO/pugixml.hpp>
#endif
#include "oslexec_pvt.h"
@@ -45,7 +50,9 @@ OSL_NAMESPACE_ENTER
namespace pvt { // OSL::pvt
#ifndef USE_EXTERNAL_PUGIXML
namespace pugi = OIIO::pugi;
#endif
+2 -1
View File
@@ -388,7 +388,8 @@ ShaderInstance::print ()
size_t slash = filename.find_last_of ("/");
if (slash != std::string::npos)
filename.erase (0, slash+1);
out << " (" << filename << ":" << op.sourceline() << ")";
if (filename.length())
out << " (" << filename << ":" << op.sourceline() << ")";
out << "\n";
}
return out.str ();
+5 -5
View File
@@ -916,6 +916,11 @@ RuntimeOptimizer::build_llvm_instance (bool groupentry)
build_llvm_code (inst()->maincodebegin(), inst()->maincodeend());
if (llvm_has_exit_instance_block()) {
builder().CreateBr (m_exit_instance_block);
builder().SetInsertPoint (m_exit_instance_block);
}
// Transfer all of this layer's outputs into the downstream shader's
// inputs.
for (int layer = m_layer+1; layer < group().nlayers(); ++layer) {
@@ -937,11 +942,6 @@ RuntimeOptimizer::build_llvm_instance (bool groupentry)
}
// llvm_gen_debug_printf ("done copying connections");
if (llvm_has_exit_instance_block()) {
builder().CreateBr (m_exit_instance_block);
builder().SetInsertPoint (m_exit_instance_block);
}
// All done
// llvm_gen_debug_printf (std::string("exit layer ")+inst()->shadername());
builder().CreateRetVoid();
+67 -63
View File
@@ -278,6 +278,71 @@ OSL_SHADEOP void osl_##name##_dvdvv (void *r_, void *a_, void *b_) \
}
// Mixed vec func(vec,float)
#define MAKE_BINARY_PERCOMPONENT_VF_OP(name,floatfunc,dualfunc) \
OSL_SHADEOP void osl_##name##_vvf (void *r_, void *a_, float b) { \
Vec3 &r (VEC(r_)); \
Vec3 &a (VEC(a_)); \
r[0] = floatfunc (a[0], b); \
r[1] = floatfunc (a[1], b); \
r[2] = floatfunc (a[2], b); \
} \
\
OSL_SHADEOP void osl_##name##_dvdvdf (void *r_, void *a_, void *b_) \
{ \
Dual2<Vec3> &r (DVEC(r_)); \
Dual2<Vec3> &a (DVEC(a_)); \
Dual2<float> &b (DFLOAT(b_)); \
Dual2<float> ax, ay, az; \
ax = dualfunc (Dual2<float> (a.val().x, a.dx().x, a.dy().x), \
Dual2<float> (b.val(), b.dx(), b.dy())); \
ay = dualfunc (Dual2<float> (a.val().y, a.dx().y, a.dy().y), \
Dual2<float> (b.val(), b.dx(), b.dy())); \
az = dualfunc (Dual2<float> (a.val().z, a.dx().z, a.dy().z), \
Dual2<float> (b.val(), b.dx(), b.dy())); \
/* Now swizzle back */ \
r.set (Vec3( ax.val(), ay.val(), az.val()), \
Vec3( ax.dx(), ay.dx(), az.dx() ), \
Vec3( ax.dy(), ay.dy(), az.dy() )); \
} \
\
OSL_SHADEOP void osl_##name##_dvvdf (void *r_, void *a_, void *b_) \
{ \
Dual2<Vec3> &r (DVEC(r_)); \
Vec3 &a (VEC(a_)); \
Dual2<float> &b (DFLOAT(b_)); \
/* Swizzle the Dual2<Vec3>'s into 3 Dual2<float>'s */ \
Dual2<float> ax, ay, az; \
ax = dualfunc (Dual2<float> (a.x), \
Dual2<float> (b.val(), b.dx(), b.dy())); \
ay = dualfunc (Dual2<float> (a.y), \
Dual2<float> (b.val(), b.dx(), b.dy())); \
az = dualfunc (Dual2<float> (a.z), \
Dual2<float> (b.val(), b.dx(), b.dy())); \
/* Now swizzle back */ \
r.set (Vec3( ax.val(), ay.val(), az.val()), \
Vec3( ax.dx(), ay.dx(), az.dx() ), \
Vec3( ax.dy(), ay.dy(), az.dy() )); \
} \
\
OSL_SHADEOP void osl_##name##_dvdvf (void *r_, void *a_, float b_) \
{ \
Dual2<Vec3> &r (DVEC(r_)); \
Dual2<Vec3> &a (DVEC(a_)); \
Dual2<float> b (b_); \
/* Swizzle the Dual2<Vec3>'s into 3 Dual2<float>'s */ \
Dual2<float> ax, ay, az; \
ax = dualfunc (Dual2<float> (a.val().x, a.dx().x, a.dy().x), b);\
ay = dualfunc (Dual2<float> (a.val().y, a.dx().y, a.dy().y), b);\
az = dualfunc (Dual2<float> (a.val().z, a.dx().z, a.dy().z), b);\
/* Now swizzle back */ \
r.set (Vec3( ax.val(), ay.val(), az.val()), \
Vec3( ax.dx(), ay.dx(), az.dx() ), \
Vec3( ax.dy(), ay.dy(), az.dy() )); \
}
MAKE_UNARY_PERCOMPONENT_OP (sin, sinf, sin)
MAKE_UNARY_PERCOMPONENT_OP (cos, cosf, cos)
MAKE_UNARY_PERCOMPONENT_OP (tan, tanf, tan)
@@ -446,72 +511,10 @@ MAKE_UNARY_PERCOMPONENT_OP (exp, fast_expf, fast_expf)
MAKE_UNARY_PERCOMPONENT_OP (exp2, exp2f, exp2)
MAKE_UNARY_PERCOMPONENT_OP (expm1, expm1f, expm1)
MAKE_BINARY_PERCOMPONENT_OP (pow, safe_pow, pow)
MAKE_BINARY_PERCOMPONENT_VF_OP (pow, safe_pow, pow)
MAKE_UNARY_PERCOMPONENT_OP (erf, erff, erf)
MAKE_UNARY_PERCOMPONENT_OP (erfc, erfcf, erfc)
// Mixed vec pow(vec,float)
OSL_SHADEOP void osl_pow_vvf (void *r_, void *a_, float b) {
Vec3 &r (VEC(r_));
Vec3 &a (VEC(a_));
r[0] = safe_pow (a[0], b);
r[1] = safe_pow (a[1], b);
r[2] = safe_pow (a[2], b);
}
OSL_SHADEOP void osl_pow_dvdvdf (void *r_, void *a_, void *b_)
{
Dual2<Vec3> &r (DVEC(r_));
Dual2<Vec3> &a (DVEC(a_));
Dual2<float> &b (DFLOAT(b_));
Dual2<float> ax, ay, az;
ax = pow (Dual2<float> (a.val().x, a.dx().x, a.dy().x),
Dual2<float> (b.val(), b.dx(), b.dy()));
ay = pow (Dual2<float> (a.val().y, a.dx().y, a.dy().y),
Dual2<float> (b.val(), b.dx(), b.dy()));
az = pow (Dual2<float> (a.val().z, a.dx().z, a.dy().z),
Dual2<float> (b.val(), b.dx(), b.dy()));
/* Now swizzle back */
r.set (Vec3( ax.val(), ay.val(), az.val()),
Vec3( ax.dx(), ay.dx(), az.dx() ),
Vec3( ax.dy(), ay.dy(), az.dy() ));
}
OSL_SHADEOP void osl_pow_dvvdf (void *r_, void *a_, void *b_)
{
Dual2<Vec3> &r (DVEC(r_));
Vec3 &a (VEC(a_));
Dual2<float> &b (DFLOAT(b_));
/* Swizzle the Dual2<Vec3>'s into 3 Dual2<float>'s */
Dual2<float> ax, ay, az;
ax = pow (Dual2<float> (a.x),
Dual2<float> (b.val(), b.dx(), b.dy()));
ay = pow (Dual2<float> (a.y),
Dual2<float> (b.val(), b.dx(), b.dy()));
az = pow (Dual2<float> (a.z),
Dual2<float> (b.val(), b.dx(), b.dy()));
/* Now swizzle back */
r.set (Vec3( ax.val(), ay.val(), az.val()),
Vec3( ax.dx(), ay.dx(), az.dx() ),
Vec3( ax.dy(), ay.dy(), az.dy() ));
}
OSL_SHADEOP void osl_pow_dvdvf (void *r_, void *a_, float b_)
{
Dual2<Vec3> &r (DVEC(r_));
Dual2<Vec3> &a (DVEC(a_));
Dual2<float> b (b_);
/* Swizzle the Dual2<Vec3>'s into 3 Dual2<float>'s */
Dual2<float> ax, ay, az;
ax = pow (Dual2<float> (a.val().x, a.dx().x, a.dy().x), b);
ay = pow (Dual2<float> (a.val().y, a.dx().y, a.dy().y), b);
az = pow (Dual2<float> (a.val().z, a.dx().z, a.dy().z), b);
/* Now swizzle back */
r.set (Vec3( ax.val(), ay.val(), az.val()),
Vec3( ax.dx(), ay.dx(), az.dx() ),
Vec3( ax.dy(), ay.dy(), az.dy() ));
}
inline float safe_sqrt (float f) {
if (f <= 0.0f) {
@@ -596,6 +599,7 @@ inline Dual2<float> safe_fmod (const Dual2<float> &a, const Dual2<float> &b) {
}
MAKE_BINARY_PERCOMPONENT_OP (fmod, safe_fmod, safe_fmod);
MAKE_BINARY_PERCOMPONENT_VF_OP (fmod, safe_fmod, safe_fmod)
OSL_SHADEOP float osl_smoothstep_ffff(float e0, float e1, float x) { return smoothstep(e0, e1, x); }
+8 -6
View File
@@ -38,10 +38,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/regex_fwd.hpp>
#include <boost/unordered_map.hpp>
#include <boost/intrusive_ptr.hpp>
#include "OpenImageIO/ustring.h"
#include "OpenImageIO/thread.h"
#include "OpenImageIO/paramlist.h"
#include <OpenImageIO/ustring.h>
#include <OpenImageIO/thread.h>
#include <OpenImageIO/paramlist.h>
#include <OpenImageIO/refcnt.h>
#include "oslexec.h"
#include "oslclosure.h"
@@ -249,7 +251,7 @@ inline void stlfree (T &v)
/// individual instances of the shader.
class ShaderMaster : public RefCnt {
public:
typedef intrusive_ptr<ShaderMaster> ref;
typedef boost::intrusive_ptr<ShaderMaster> ref;
ShaderMaster (ShadingSystemImpl &shadingsys) : m_shadingsys(shadingsys) { }
~ShaderMaster ();
@@ -471,7 +473,7 @@ public:
/// that is suitable to pass as a range for BOOST_FOREACH.
friend std::pair<Symbol *,Symbol *> param_range (ShaderInstance *i) {
if (i->firstparam() == i->lastparam())
return std::pair<Symbol*,Symbol*> (NULL, NULL);
return std::pair<Symbol*,Symbol*> ((Symbol*)NULL, (Symbol*)NULL);
else
return std::pair<Symbol*,Symbol*> (&i->m_instsymbols[0] + i->firstparam(),
&i->m_instsymbols[0] + i->lastparam());
@@ -479,7 +481,7 @@ public:
friend std::pair<const Symbol *,const Symbol *> param_range (const ShaderInstance *i) {
if (i->firstparam() == i->lastparam())
return std::pair<const Symbol*,const Symbol*> (NULL, NULL);
return std::pair<const Symbol*,const Symbol*> ((const Symbol*)NULL, (const Symbol*)NULL);
else
return std::pair<const Symbol*,const Symbol*> (&i->m_instsymbols[0] + i->firstparam(),
&i->m_instsymbols[0] + i->lastparam());
+2 -3
View File
@@ -33,7 +33,6 @@ using namespace OSL::pvt;
#if USE_PARTIO
#include <Partio.h>
#include <boost/unordered_map.hpp>
#include <boost/shared_ptr.hpp>
#endif
@@ -48,7 +47,7 @@ public:
~PointCloud ();
static PointCloud *get (ustring filename, bool read=true);
typedef boost::unordered_map<ustring, boost::shared_ptr<Partio::ParticleAttribute>, ustringHash> AttributeMap;
typedef boost::unordered_map<ustring, shared_ptr<Partio::ParticleAttribute>, ustringHash> AttributeMap;
// N.B./FIXME(C++11): shared_ptr is probably overkill, but
// scoped_ptr is not copyable and therefore can't be used in
// standard containers. When C++11 is uniquitous, unique_ptr is the
@@ -63,7 +62,7 @@ public:
};
typedef boost::unordered_map<ustring, boost::shared_ptr<PointCloud>, ustringHash> PointCloudMap;
typedef boost::unordered_map<ustring, shared_ptr<PointCloud>, ustringHash> PointCloudMap;
// See above note about shared_ptr vs unique_ptr.
static PointCloudMap pointclouds;
static spin_mutex pointcloudmap_mutex;
+3
View File
@@ -134,12 +134,15 @@ normal mod (normal a, float b) { return a - b*floor(a/b); }
color mod (color a, float b) { return a - b*floor(a/b); }
float mod (float a, float b) { return a - b*floor(a/b); }
PERCOMP2 (min)
int min (int a, int b) BUILTIN;
PERCOMP2 (max)
int max (int a, int b) BUILTIN;
normal clamp (normal x, normal minval, normal maxval) { return max(min(x,maxval),minval); }
vector clamp (vector x, vector minval, vector maxval) { return max(min(x,maxval),minval); }
point clamp (point x, point minval, point maxval) { return max(min(x,maxval),minval); }
color clamp (color x, color minval, color maxval) { return max(min(x,maxval),minval); }
float clamp (float x, float minval, float maxval) { return max(min(x,maxval),minval); }
int clamp (int x, int minval, int maxval) { return max(min(x,maxval),minval); }
#if 0
normal mix (normal x, normal y, normal a) { return x*(1-a) + y*a; }
normal mix (normal x, normal y, float a) { return x*(1-a) + y*a; }
+6 -1
View File
@@ -37,7 +37,12 @@ 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/pugixml.hpp>
#ifdef USE_EXTERNAL_PUGIXML
# include <pugixml.hpp>
#else
# include <OpenImageIO/pugixml.hpp>
#endif
#include <boost/thread.hpp>
#include <boost/ref.hpp>