Code Monkey home page Code Monkey logo

academysoftwarefoundation / openshadinglanguage Goto Github PK

View Code? Open in Web Editor NEW
2.0K 196.0 343.0 188.5 MB

Advanced shading language for production GI renderers

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.24% CMake 3.06% TeX 4.25% C++ 78.06% C 5.30% Shell 0.66% Python 5.60% GLSL 0.01% Yacc 0.81% Lex 0.42% HTML 0.70% CSS 0.07% Cuda 0.81%
osl shading-language shaders c-plus-plus computer-graphics computer-language llvm vfx open-shading-language

openshadinglanguage's Introduction

Open Shading Language Reel 2020

Build Status License CII Best Practices Documentation Status

Introduction

Welcome to Open Shading Language!

Open Shading Language (OSL) is a small but rich language for programmable shading in advanced renderers and other applications, ideal for describing materials, lights, displacement, and pattern generation.

OSL was originally developed by Sony Pictures Imageworks for use in its in- house renderer used for feature film animation and visual effects, released as open source so it could be used by other visual effects and animation studios and rendering software vendors. Now it's the de facto standard shading language for VFX and animated features, used across the industry in many commercial and studio- proprietary renderers. Because of this, the work on OSL received an Academy Award for Technical Achievement in 2017.

OSL is robust and production-proven, and has been used in films as diverse as "The Amazing Spider-Man," "Hotel Transylvania," "Edge of Tomorrow", "Ant Man", "Finding Dory," and many more. OSL support is in most leading renderers used for high-end VFX and animation work. For a full list of films and products, see the filmography.

The OSL code is distributed under the "New/3-clause BSD" license, and the documentation under the Creative Commons Attribution 4.0 International License. In short, you are free to use OSL in your own applications, whether they are free or commercial, open or proprietary, as well as to modify the OSL code and documentation as you desire, provided that you retain the original copyright notices as described in the license.

How OSL is different

OSL has syntax similar to C, as well as other shading languages. However, it is specifically designed for advanced rendering algorithms and has features such as radiance closures, BSDFs, and deferred ray tracing as first-class concepts.

OSL has several unique characteristics not found in other shading languages (certainly not all together). Here are some things you will find are different in OSL compared to other languages:

  • Surface and volume shaders compute radiance closures, not final colors.

    OSL's surface and volume shaders compute an explicit symbolic description, called a "closure", of the way a surface or volume scatters light, in units of radiance. These radiance closures may be evaluated in particular directions, sampled to find important directions, or saved for later evaluation and re-evaluation. This new approach is ideal for a physically-based renderer that supports ray tracing and global illumination.

    In contrast, other shading languages usually compute just a surface color as visible from a particular direction. These old shaders are "black boxes" that a renderer can do little with but execute to find this one piece of information (for example, there is no effective way to discover from them which directions are important to sample). Furthermore, the physical units of lights and surfaces are often underspecified, making it very difficult to ensure that shaders are behaving in a physically correct manner.

  • Surface and volume shaders do not loop over lights or shoot rays.

    There are no "light loops" or explicitly traced illumination rays in OSL surface shaders. Instead, surface shaders compute a radiance closure describing how the surface scatters light, and a part of the renderer called an "integrator" evaluates the closures for a particular set of light sources and determines in which directions rays should be traced. Effects that would ordinarily require explicit ray tracing, such as reflection and refraction, are simply part of the radiance closure and look like any other BSDF.

    Advantages of this approach include that integration and sampling may be batched or re-ordered to increase ray coherence; a "ray budget" can be allocated to optimally sample the BSDF; the closures may be used by for bidirectional ray tracing or Metropolis light transport; and the closures may be rapidly re-evaluated with new lighting without having to re-run the shaders.

  • Surface and light shaders are the same thing.

    OSL does not have a separate kind of shader for light sources. Lights are simply surfaces that are emissive, and all lights are area lights.

  • Transparency is just another kind of illumination.

    You don't need to explicitly set transparency/opacity variables in the shader. Transparency is just another way for light to interact with a surface, and is included in the main radiance closure computed by a surface shader.

  • 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 lights, etc. In other languages, this is usually accomplished by adding a plethora of "output variables" to the shaders that collect these individual quantities.

    OSL shaders need not be cluttered with any code or output variables to accomplish this. Instead, there is a regular-expression-based notation for describing which light paths should contribute to which outputs. This is all done on the renderer side (though supported by the OSL implementation). If you desire a new output, there is no need to modify the shaders at all; you only need to tell the renderer the new light path expression.

  • Shaders are organized into networks.

    OSL shaders are not monolithic, but rather can be organized into networks of shaders (sometimes called a shader group, graph, or DAG), with named outputs of some nodes being connected to named inputs of other nodes within the network. These connections may be done dynamically at render time, and do not affect compilation of individual shader nodes. Furthermore, the individual nodes are evaluated lazily, only when their outputs are "pulled" from the later nodes that depend on them (shader writers may remain blissfully unaware of these details, and write shaders as if everything is evaluated normally).

  • Arbitrary derivatives without grids or extra shading points.

    In OSL, you can take derivatives of any computed quantity in a shader, and use arbitrary quantities as texture coordinates and expect correct filtering. This does not require that shaded points be arranged in a rectangular grid, or have any particular connectivity, or that any "extra points" be shaded. This is because derivatives are not computed by finite differences with neighboring points, but rather by "automatic differentiation", computing partial differentials for the variables that lead to derivatives, without any intervention required by the shader writer.

  • OSL optimizes aggressively at render time

    OSL uses the LLVM compiler framework to translate shader networks into machine code on the fly (just in time, or "JIT"), and in the process heavily optimizes shaders and networks with full knowledge of the shader parameters and other runtime values that could not have been known when the shaders were compiled from source code. As a result, we are seeing our OSL shading networks execute 25% faster than the equivalent shaders hand-crafted in C! (That's how our old shaders worked in our renderer.)

What OSL consists of

The OSL open source distribution consists of the following components:

  • oslc, a standalone compiler that translates OSL source code into an assembly-like intermediate code (in the form of .oso files).

  • liboslc, a library that implements the OSLCompiler class, which contains the guts of the shader compiler, in case anybody needs to embed it into other applications and does not desire for the compiler to be a separate executable.

  • liboslquery, a library that implements the OSLQuery class, which allows applications to query information about compiled shaders, including a full list of its parameters, their types, and any metadata associated with them.

  • oslinfo, a command-line program that uses liboslquery to print to the console all the relevant information about a shader and its parameters.

  • liboslexec, a library that implements the ShadingSystem class, which allows compiled shaders to be executed within an application. Currently, it uses LLVM to JIT compile the shader bytecode to x86 instructions.

  • testshade, a program that lets you execute a shader (or connected shader network) on a rectangular array of points, and save any of its 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. 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.

  • Documentation -- at this point consisting of the OSL language specification (useful for shader writers), but in the future will have detailed documentation about how to integrate the OSL libraries into renderers.

Where OSL has been used

This list only contains films or products whose OSL use is stated or can be inferred from public sources, or that we've been told is ok to list here. If an OSL-using project is missing and it's not a secret, just email the OSL project leader or submit a PR with edits to this file.

Renderers and other production tools with OSL support

(In approximate order of adding OSL support)

Significant work using OSL, grouped by year of release date:

(Here we are considering "significant work" to mean a feature film released theatrically or on a major streaming platform, TV/streaming series heavily featuring visual effects or animation, or short films that have won or been nominated for major awards.)

  • (2012) Men in Black 3, The Amazing Spider-Man, Hotel Transylvania
  • (2013) Oz the Great and Powerful, Smurfs 2, Cloudy With a Chance of Meatballs 2
  • (2014) The Amazing Spider-Man 2, Blended, Edge of Tomorrow, 22 Jump Street, Guardians of the Galaxy, Fury, The Hunger Games: Mockingjay - Part 1, Exodus: Gods and Kings, The Interview
  • (2015) American Sniper, Insurgent, Avengers Age of Ultron, Ant Man, Pixels, Mission Impossible: Rogue Nation, Hotel Transylvania 2, Bridge of Spies, James Bond: Spectre, The Hunger Games: Mockingjay - Part 2, Concussion
  • (2016) Allegiant, Batman vs Superman: Dawn of Justice, The Huntsman, Angry Birds Movie, Alice Through the Looking Glass, Captain America: Civil War, Finding Dory, Piper, Independence Day: Resurgence, Ghostbusters, Star Trek Beyond, Suicide Squad, Kubo and the Two Strings, Kingsglaive: Final Fantasy XV, Storks, Miss Peregrine's Home for Peculiar Children, Fantastic Beasts and Where to Find Them, Assassin's Creed
  • (2017) Lego Batman, The Great Wall, A Cure for Wellness, Logan, Power Rangers, Life, Smurfs: The Lost Village, The Fate of the Furious, Alien Covenant, Guardians of the Galaxy 2, The Mummy, Wonder Woman, Cars 3, Baby Driver, Spider-Man: Homecoming, Dunkirk, The Emoji Movie, Detroit, Kingsman: The Golden Circle, Lego Ninjago Movie, Blade Runner 2049, Geostorm, Coco, Justice League, Thor: Ragnarok
  • (2018) Peter Rabbit, Black Panther, Annihilation, Red Sparrow, Pacific Rim Uprising, Avengers Infinity War, Deadpool 2, Incredibles 2, Jurassic World: Fallen Kingdom, Hotel Transylvania 3: Summer Vacation, Ant Man and the Wasp, Skyscraper, Mission Impossible: Fallout, The Meg, Kin, Smallfoot, Alpha, Venom, First Man, Bad Times at the El Royale, Fantastic Beasts: The Crimes of Grindelwald, Bohemian Rhapsody, Holmes and Watson, Spider-Man: Into the Spider-Verse
  • (2019) The Kid Who Would Be King, Alita: Battle Angel, Lego Movie 2, Lucky 13 (Love, Death, and Robots), Captain Marvel, Triple Frontier, Avengers: Endgame, Pokémon Detective Pikachu, Godzilla: King of Monsters, Rim of the World, John Wick 3 Parabellum, Men in Black International, Toy Story 4, Spider-Man: Far From Home, Hobbs & Shaw, Angry Birds 2, The Art of Racing in the Rain, Secret Life of Pets, The Mandalorian (S1), The Dark Crystal: Age of Resistance, The King, Jumanji: The Next Level, Richard Jewell, Game of Thrones (S8), Lost in Space (S1), Togo, Missing Link
  • (2020) Underwater, Birds of Prey, Onward, Bloodshot, Greyhound, The Old Guard, Mulan, Tenet, The New Mutants, Artemis Fowl, The Eight Hundred, Over the Moon, Wonder Woman 1984, Soul, The Mandalorian (S2), The Boys (S2), Umbrella Academy (S2)
  • (2021) Chaos Walking, Peter Rabbit 2: The Runaway, The Falcon and the Winder Soldier, Secret Magic Control Agency, Zack Snyder's Justice League, The Mitchells vs the Machines, Jupiter's Legacy, Luca, F9, Vivo, Jungle Cruise, Cinderella, Dune, No Time To Die, Ron's Gone Wrong, Venom: Let There Be Carnage, Last Night in Soho, Ghostbusters: Afterlife, Spider-Man 3: No Way Home, Matrix Resurrections, Sing 2
  • (2022) Hotel Transylvania 4: Transformania, Death on the Nile, Uncharted, Turning Red, The Adam Project, Doctor Strange in the Multiverse of Madness, Love, Death, and Robots: In Vaulted Halls Entombed, Jurassic World: Dominion, Lightyear, Thor: Love and Thunder, The Sea Beast, DC League of Super Pets, Minions: Rise of Gru, Bullet Train, Slumberland, Glass Onion, Archive 81 (series), Moon Night (series), Obi-Wan Kenobi (series), The Boys (S3), Andor (S1)
  • (2023 / upcoming) Ant-Man and the Wasp: Quantumania, The Mandalorian S3, The Magician's Elephant, Super Mario Bros Film, Guardians of the Galaxy 3, Spider-Man: Across the Spider-Verse, Elemental, ...

Building and Installation

Please read the INSTALL.md file for detailed instructions on how to build and install OSL.

Documentation

The OSL language specification can be found at src/doc/osl-languagespec.pdf (in a source distribution) or in the share/doc/OSL/osl-languagespec.pdf file of an installed binary distribution.

Experimental OSL Documentation on ReadTheDocs This will be the future documentation. It's probably as complete as the PDF, but it needs some proofreading, so the PDF is still considered the authoritative source for now. But some time soon, the old PDF specification will be deprecated in favor of this online documentation.

There is also a PDF version.

For those interested in learning to program shaders in OSL, there is the Siggraph 2022 Educator's Forum OSL Shaders for RenderMan course, which uses RenderMan in the examples and Supplementary Materials, but which is primarily about shader writing in OSL.

Contact & reporting problems

Simple "how do I...", "I'm having trouble", or "is this a bug" questions are best asked on the osl-dev developer mail list. That's where the most people will see it and potentially be able to answer your question quickly (more so than a GH "issue").

Bugs, build problems, and discovered vulnerabilities that you are relatively certain is a legit problem in the code, and for which you can give clear instructions for how to reproduce, should be reported as issues.

If you think you've found a potential vulnerability in OSL, please confidentially report it by emailing the project administrators at [email protected].

If any other issue requires confidentiality that precludes a public question or issue, you may contact the project administrator privately at [email protected].

Contributing

OSL welcomes code contributions, and nearly 50 people have done so over the years. We take code contributions via the usual GitHub pull request (PR) mechanism. Please see CONTRIBUTING for detailed instructions.

Contacts, Links, and References

OSL GitHub page

Read or subscribe to the OSL development mail list

Most recent PDF of the OSL language specification

OSL home page

Credits

The current project leadership is documented in the Governance file.

Many people have contributed features, bug fixes, and other changes to OSL over the years: Steve Agland, Shane Ambler, Martijn Berger, Farchad Bidgolirad, Nicholas Bishop, Curtis Black, Rasmus Bonnedal, Solomon Boulos, Stefan Bruens, Stefan Büttner, Matthaus G. Chajdas, Clark Chen, Alejandro Conty, Damien Courtois, Dieter De Baets, Thomas Dinges, Daniel Dresser, Mads Drøschler, Peter Ellerington, Luke Emrose, Louis Feng, Mark Final, Henri Fousse, Stephen Friedman, Syoyo Fujita, Tim Grant, Larry Gritz, Nicolas Guiard, Euan Haahr, Derek Haase, Sven-Hendrik Haase, John Haddon, Niklas Harrysson, Daniel Heckenberg, Chris Hellmuth, Adrien Herubel, Dan Horák, Thiago Ize, Matt Johnson, Ronan Keryell, Chris Kulla, Elvic Liang, Max Liani, Adam Martinez, John Mertic, Bastien Montagne, Steena Monteiro, Patrick Mours, Alexis Oblet, Erich Ocean, Mikko Ohtamaa, Jino Park, Alexei Pawlow, Jay Reynolds, Declan Russell, Benoit Ruiz, Patrick Scheibe, Alex Schworer, Jonathan Scruggs, Sergey Sharybin, Mark Sisson, Sandip Shukla, Cliff Stein, Stephan Steinbach, Luya Tshimbalanga, Esteban Tovagliari, Brecht Van Lommel, Alexander von Knorring, Aidan Welch, Alex Wells, Roman Zulak. (Listed alphabetically; if we've left anybody out, it is inadvertent, please let us know.)

We cannot possibly express sufficient gratitude to the managers at Sony Pictures Imageworks who allowed this project to proceed, supported it wholeheartedly, and permitted us to release the source, especially Rob Bredow, Brian Keeney, Barbara Ford, Rene Limberger, Erik Strauss, and Mike Ford.

Huge thanks also go to the crack shading team at SPI, and the brave lookdev TDs and CG supes willing to use OSL on their shows. They served as our guinea pigs, inspiration, testers, and a fantastic source of feedback. And of course, the many engineers, TDs, and artists elsewhere who incorporated OSL into their products and pipelines, especially the early risk-takers at Chaos Group, Double Negative, Pixar, DNA, Isotropix, and Animal Logic. Thank you, and we hope we've been responsive to your needs.

OSL was not developed in isolation. We owe a debt to the individuals and studios who patiently read early drafts of the language specification and gave us very helpful feedback and additional ideas, as well as to the continuing contributions and feedback of its current developers and users at other VFX and animation studios.

The OSL implementation depends upon several other open source packages, all with compatible licenses:

OSL's documentation incorporates parts of Markdeep (c) 2015-2016, Morgan McGuire, and highlight.js (c) 2006, Ivan Sagalaev, both distributed under BSD licenses.

openshadinglanguage's People

Contributors

aconty avatar adrienherubel avatar alexmwells avatar alexpux avatar amartinez-cg avatar boulos avatar brechtvl avatar chellmuth avatar cmstein avatar danieldresser-ie avatar darkhorse64 avatar debaetsd avatar declanrussell avatar derekhaase avatar dogtacos avatar est77 avatar etheory avatar farchadbidgolirad avatar fpsunflower avatar johnhaddon avatar lgritz avatar markfinal avatar marsupial avatar mprater avatar sambler avatar sergeyvfx avatar sfriedmapixar avatar steenax86 avatar svenstaro avatar tgrant-nv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openshadinglanguage's Issues

Instruction "exit" is not known

These two simple shaders:
shader test() { return; }
shader test() { exit(); }

Give the following error when run with e.g. testshade:
ERROR: Parsing shader "test": instruction "exit" is not known. Maybe compiled with a too-new oslc?

I couldn't find the code to handle this, I'm guessing this was never implemented in the LLVM backend. I can imagine this may not be so simple with the recursive function calls for layers in the generated code, it would probably require some extra overhead with if() statements that check for this exit condition.

If this feature has indeed been broken for so long it may be ok to just remove it and give an error in the compiler?

printf statement optimized out

Another bug found by Michel Anders, if you have these two shaders:

shader test_a(output color C = 0)
{
    C[1] = 1; // does not print when removing this line
    if(C[1] != 0.123456)
        printf("%f\n", C);
}
shader test_b(color C = 0)
{
    Ci = C * diffuse(N);
}

and connect them like this:

./testshade --layer layer_a test_a --layer layer_b test_b --connect layer_a C layer_b C

Then it will not print anything when removing the indicated line, but you would expect it to print in both cases. I guess it's because it fails to do constant folding for that line, that it succeeds in printing.

If you use a float instead of a color it never prints:

shader test_a(output float C = 0)
{
    C = 1;
    if(C != 0.123456)
        printf("%f\n", C);
}
shader test_b(float C = 0.0)
{
    Ci = C * diffuse(N);
}

I might look into a fix later, but don't have time anymore this week for it, so if anyone else feels like fixing go ahead.

Signed/Unsigned Mismatch errors

I have been trying to build against LLVM 3.5, and found the following signed/unsigned type-mismatch errors.

diff --git a/src/liboslexec/shadingsys.cpp b/src/liboslexec/shadingsys.cpp
index b3e1cf5..3907222 100644
--- a/src/liboslexec/shadingsys.cpp
+++ b/src/liboslexec/shadingsys.cpp
@@ -1990,7 +1990,7 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
             }
             // Zero-pad if we parsed fewer values than we needed
             intvals.resize (type.numelements()*type.aggregate, 0);
-            ASSERT (type.numelements()*type.aggregate == int(intvals.size()));
+            ASSERT (type.numelements()*type.aggregate == intvals.size());
             Parameter (paramname, type, &intvals[0], lockgeom);
         } else if (type.basetype == TypeDesc::FLOAT) {
             floatvals.clear ();
@@ -2010,7 +2010,7 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
             }
             // Zero-pad if we parsed fewer values than we needed
             floatvals.resize (type.numelements()*type.aggregate, 0);
-            ASSERT (type.numelements()*type.aggregate == int(floatvals.size()));
+            ASSERT (type.numelements()*type.aggregate == floatvals.size());
             Parameter (paramname, type, &floatvals[0], lockgeom);
         } else if (type.basetype == TypeDesc::STRING) {
             stringvals.clear ();
@@ -2040,7 +2040,7 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
             }
             // Zero-pad if we parsed fewer values than we needed
             stringvals.resize (type.numelements()*type.aggregate, ustring());
-            ASSERT (type.numelements()*type.aggregate == int(stringvals.size()));
+            ASSERT (type.numelements()*type.aggregate == stringvals.size());
             Parameter (paramname, type, &stringvals[0], lockgeom);
         }

closure color functions in OSL 1.6

What happened to bssrdf_cubic, bssrdf_gaussian, hair_R, hair_TRT, hair_TT functions in OSL 1.6 (corresponding functions in current stdosl.h?

Issue compiling 1.4.1 on Ubuntu 12.04

I attempted to compile the 1.4.1 release on Ubuntu 12.04 (64 bit) with GCC 4.7 and LLVM 3.0. This error is presented:

[ 53%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_gen.cpp.o
In file included from /workspace/osl/src/liboslexec/llvm_gen.cpp:37:0:
/workspace/osl/src/liboslexec/runtimeoptimize.h: In function ‘bool OSL::pvt::llvm_gen_getattribute(OSL::pvt::RuntimeOptimizer&, int)’:
/workspace/osl/src/liboslexec/runtimeoptimize.h:370:64: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]
cc1plus: all warnings being treated as errors

I went back to commit 9e7510f on RB-1.4 and was able to compile without any issues. Any insight into what may be causing this error?

ubersurface.oso compile error

When building, from master, on OSX, 10.8:

[ 83%] Generating ubersurface.oso
/usr/local/src/OpenShadingLanguage/src/shaders/ubersurface.osl:150: error: shader parameter 'Texture_' MUST have a default initializer
/usr/local/src/OpenShadingLanguage/src/shaders/ubersurface.osl:150: error: Syntax error: syntax error
FAILED /usr/local/src/OpenShadingLanguage/src/shaders/ubersurface.osl
make[2]: *** [shaders/ubersurface.oso] Error 1
make[1]: *** [shaders/CMakeFiles/shaders.dir/all] Error 2
make: *** [all] Error 2

Compilation with MSVC 2010 Express fails epic ;-)

Hi there,

i tried to build OSL 1.2, 1.3 and master branch with MSVC 2010 express using the WinSDK 7.1 for x64.

No matter which Boost version i use i always get errors like this one:

--snip--
Error 19 error C2874: using-declaration causes a multiple declaration of 'std::tr1::shared_ptr' D:\builder\source\OpenShadingLanguage-master\src\include\osl_pvt.h 37 oslexec 1

Error 12 error C2874: using-declaration causes a multiple declaration of 'boost::shared_ptr' D:\builder\install\openimageio\include\OpenImageIO\refcnt.h 47 oslcomp 1

--snip--

this repeats throughout the whole build process (many times)

Best regards

Shadowrom

Non-output function parameters can be modified

From a bug report to the Blender bug tracker by Michel Anders.

int refinc(int n)
{
    n = 0; // n is not marked as output so this should be illegal
    n++;   // ditto
    return n;
}

shader test()
{
    int h = 0;
    refinc(h);
    printf("%d\n", h);
}

If you run this compile and run shader, it will print 1, but actually modifying n in refinc should not be allowed, according to section 4.4 of the specification, so it should give a compile error.

Parameters to functions are similar to shader parameters, except that they do not permit initializers. A function call must pass values for all formal parameters. Function parameters in Open Shading Language are all passed by reference, and are read-only within the body of the function unless they are also designated as output (in the same manner as output shader parameters).

Pow(color, color) not supported in code (but is is in docs)

The OSL spec (1.4 and 1.5) specify that pow(type x, type y) is allowed (where type can be a color/vector/point/normal/float). I only find the second signature pow(type x, float y) to be supported by the compiler. This is supported by the code in llvm_instance.cpp:

    BINARY_OP_IMPL(pow),
[...]
    "osl_pow_vvf", "xXXf",
    "osl_pow_dvdvdf", "xXXX",
    "osl_pow_dvvdf", "xXXX",
    "osl_pow_dvdvf", "xXXf",

Either the specification or the implementation contains a bug here.

ambient occlusion function call

Ambient occlusion can currently be done a number of ways in OSL based renderers:

  • a renderer specific closure
  • a renderer specific light or lighting mode which provides uniform lighting and ignores non-diffuse closures

However in certain cases this is not enough. A common example is a dirt shader that wishes to procedurally darken the texture in "corner" regions of a model. This is typically done with ambient occlusion like queries either along the normal, the opposite of the normal, or specific axes. This color is then blended with other textures or noise patterns before finally being multiplied against a brdf closure.

As closures are not intended to be multiplied against each other, this must be expressed as a function that returns a color directly. The intent is to add renderer specific hooks in RendererServices API to perform this calculation.

The OSL prototype of the function should look like:

color occlusion(normal N, float maxdist, ...);

The varargs are intended for future expansion, as well as renderer specific settings. The default behavior would be to compute the occlusion using a cosine distribution over the hemisphere defined by the specified normal.

Can't build OSL with llvm 3.5(svn build)

Error in the llvm_util.cpp. Whether it is possible to build the project without using llvm?

In file included from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:70:0:
/usr/local/include/llvm/PassManager.h:34:15: error: ‘PassManager’ is already declared in this scope
using legacy::PassManager;
^
/usr/local/include/llvm/PassManager.h:35:15: error: ‘FunctionPassManager’ is already declared in this scope
using legacy::FunctionPassManager;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual uint8_t* OSL::pvt::OSL_Dummy_JITMemoryManager::startExceptionTable(const llvm::Function_, uintptr_t&)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:180:20: error: ‘class llvm::JITMemoryManager’ has no member named ‘startExceptionTable’
return mm->startExceptionTable (F, ActualSize);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual void OSL::pvt::OSL_Dummy_JITMemoryManager::endExceptionTable(const llvm::Function_, uint8_t_, uint8_t_, uint8_t_)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:184:13: error: ‘class llvm::JITMemoryManager’ has no member named ‘endExceptionTable’
mm->endExceptionTable (F, TableStart, TableEnd, FrameRegister);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual uint8_t_ OSL::pvt::OSL_Dummy_JITMemoryManager::allocateCodeSection(uintptr_t, unsigned int, unsigned int)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:211:66: error: no matching function for call to ‘llvm::JITMemoryManager::allocateCodeSection(uintptr_t&, unsigned int&, unsigned int&)’
return mm->allocateCodeSection(Size, Alignment, SectionID);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:211:66: note: candidate is:
In file included from /usr/local/include/llvm/ExecutionEngine/RuntimeDyld.h:19:0,
from /usr/local/include/llvm/ExecutionEngine/JITMemoryManager.h:13,
from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:73:
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:44:20: note: virtual uint8_t* llvm::RTDyldMemoryManager::allocateCodeSection(uintptr_t, unsigned int, unsigned int, llvm::StringRef)
virtual uint8_t allocateCodeSection(
^
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:44:20: note: candidate expects 4 arguments, 3 provided
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual uint8_t
OSL::pvt::OSL_Dummy_JITMemoryManager::allocateDataSection(uintptr_t, unsigned int, unsigned int, bool)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:216:78: error: no matching function for call to ‘llvm::JITMemoryManager::allocateDataSection(uintptr_t&, unsigned int&, unsigned int&, bool&)’
return mm->allocateDataSection(Size, Alignment, SectionID, IsReadOnly);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:216:78: note: candidate is:
In file included from /usr/local/include/llvm/ExecutionEngine/RuntimeDyld.h:19:0,
from /usr/local/include/llvm/ExecutionEngine/JITMemoryManager.h:13,
from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:73:
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:51:20: note: virtual uint8_t* llvm::RTDyldMemoryManager::allocateDataSection(uintptr_t, unsigned int, unsigned int, llvm::StringRef, bool)
virtual uint8_t allocateDataSection(
^
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:51:20: note: candidate expects 5 arguments, 4 provided
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual bool OSL::pvt::OSL_Dummy_JITMemoryManager::applyPermissions(std::string
)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:219:20: error: ‘class llvm::JITMemoryManager’ has no member named ‘applyPermissions’
return mm->applyPermissions(ErrMsg);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In constructor ‘OSL::pvt::LLVM_Util::LLVM_Util()’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:257:71: error: cannot allocate an object of abstract type ‘OSL::pvt::OSL_Dummy_JITMemoryManager’
m_llvm_jitmm = new OSL_Dummy_JITMemoryManager(m_thread->llvm_jitmm);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:146:7: note: because the following virtual functions are pure within ‘OSL::pvt::OSL_Dummy_JITMemoryManager’:
class OSL_Dummy_JITMemoryManager : public llvm::JITMemoryManager {
^
In file included from /usr/local/include/llvm/ExecutionEngine/RuntimeDyld.h:19:0,
from /usr/local/include/llvm/ExecutionEngine/JITMemoryManager.h:13,
from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:73:
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:44:20: note: virtual uint8_t* llvm::RTDyldMemoryManager::allocateCodeSection(uintptr_t, unsigned int, unsigned int, llvm::StringRef)
virtual uint8_t allocateCodeSection(
^
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:51:20: note: virtual uint8_t
llvm::RTDyldMemoryManager::allocateDataSection(uintptr_t, unsigned int, unsigned int, llvm::StringRef, bool)
virtual uint8_t allocateDataSection(
^
/usr/local/include/llvm/ExecutionEngine/RTDyldMemoryManager.h:103:16: note: virtual bool llvm::RTDyldMemoryManager::finalizeMemory(std::string
)
virtual bool finalizeMemory(std::string ErrMsg = 0) = 0;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In destructor ‘OSL::pvt::LLVM_Util::~LLVM_Util()’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:292:12: warning: possible problem detected in invocation of delete operator: [enabled by default]
delete m_llvm_passes;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:292:12: warning: invalid use of incomplete type ‘class llvm::PassManager’ [enabled by default]
In file included from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:33:0:
/home/maxis11/projects/OpenShadingLanguage/src/include/llvm_util.h:51:9: warning: forward declaration of ‘class llvm::PassManager’ [enabled by default]
class PassManager;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:292:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
delete m_llvm_passes;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:293:12: warning: possible problem detected in invocation of delete operator: [enabled by default]
delete m_llvm_func_passes;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:293:12: warning: invalid use of incomplete type ‘class llvm::FunctionPassManager’ [enabled by default]
In file included from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:33:0:
/home/maxis11/projects/OpenShadingLanguage/src/include/llvm_util.h:45:9: warning: forward declaration of ‘class llvm::FunctionPassManager’ [enabled by default]
class FunctionPassManager;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:293:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
delete m_llvm_func_passes;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In static member function ‘static void OSL::pvt::LLVM_Util::SetupLLVM()’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:310:5: error: ‘DisablePrettyStackTrace’ is not a member of ‘llvm’
llvm::DisablePrettyStackTrace = true;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘void OSL::pvt::LLVM_Util::setup_optimization_passes(int)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:415:24: error: cannot convert ‘llvm::legacy::FunctionPassManager
’ to ‘llvm::FunctionPassManager_’ in assignment
m_llvm_func_passes = new llvm::FunctionPassManager(module());
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:416:56: error: invalid initialization of reference of type ‘llvm::legacy::FunctionPassManager&’ from expression of type ‘llvm::FunctionPassManager’
llvm::FunctionPassManager &fpm (m_llvm_func_passes);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:425:19: error: cannot convert ‘llvm::legacy::PassManager
’ to ‘llvm::PassManager_’ in assignment
m_llvm_passes = new llvm::PassManager;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:426:46: error: invalid initialization of reference of type ‘llvm::legacy::PassManager&’ from expression of type ‘llvm::PassManager’
llvm::PassManager &passes (m_llvm_passes);
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘void OSL::pvt::LLVM_Util::do_optimize()’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:485:18: error: invalid use of incomplete type ‘class llvm::PassManager’
m_llvm_passes->run (module());
^
In file included from /home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:33:0:
/home/maxis11/projects/OpenShadingLanguage/src/include/llvm_util.h:51:9: error: forward declaration of ‘class llvm::PassManager’
class PassManager;
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual uint8_t* OSL::pvt::OSL_Dummy_JITMemoryManager::startExceptionTable(const llvm::Function
, uintptr_t&)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:181:5: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual uint8_t
OSL::pvt::OSL_Dummy_JITMemoryManager::allocateCodeSection(uintptr_t, unsigned int, unsigned int)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:212:5: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual uint8_t* OSL::pvt::OSL_Dummy_JITMemoryManager::allocateDataSection(uintptr_t, unsigned int, unsigned int, bool)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:217:5: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp: In member function ‘virtual bool OSL::pvt::OSL_Dummy_JITMemoryManager::applyPermissions(std::string*)’:
/home/maxis11/projects/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:220:5: warning: control reaches end of non-void function [-Wreturn-type]
}

Mistakes in the .pdf docs

Hi,
here a collection with mistakes I found in the .pdf docs.

-7.5, Gabor Noise: the "do_filter" point is listed twice.
-4.1 Shader Types, mention the type "light", but light brings up a compile error. (Unknown shader type: light).

Not a big deal, but nice to fix once.

Cheers,
Thomas

failed to find OpenimageIO/pugixml.hpp

building osl from source and I get this message with a non existent file, at least it doesn't exist in the install.

Gentoo AMD64.

<<<<<
make
platform=linux64, hw=x86_64
OSL_SITE = starvald_emeralian
dist_dir = dist/linux64
INSTALLDIR = /home/salamanderrake/src/blender/dependencies/osl/1.3
( cd build/linux64 ; make )
make[1]: Entering directory /home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64' make[2]: Entering directory/home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64'
make[3]: Entering directory /home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64' make[3]: Leaving directory/home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64'
[ 11%] Built target oslcomp
make[3]: Entering directory /home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64' make[3]: Leaving directory/home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64'
[ 18%] Built target oslquery
make[3]: Entering directory /home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64' make[3]: Leaving directory/home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64'
make[3]: Entering directory /home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64' [ 19%] Building CXX object liboslexec/CMakeFiles/oslexec.dir/dictionary.cpp.o /home/salamanderrake/src/blender/dependencies/osl/1.3/src/liboslexec/dictionary.cpp:39:35: fatal error: OpenImageIO/pugixml.hpp: No such file or directory compilation terminated. make[3]: *** [liboslexec/CMakeFiles/oslexec.dir/dictionary.cpp.o] Error 1 make[3]: Leaving directory/home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64'
make[2]: *** [liboslexec/CMakeFiles/oslexec.dir/all] Error 2
make[2]: Leaving directory /home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64' make[1]: *** [all] Error 2 make[1]: Leaving directory/home/salamanderrake/src/blender/dependencies/osl/1.3/build/linux64'
make: *** [cmake] Error 2

CMakeLists.txt : incorrect variable name

In CMakeLists.txt, lines 257, 258, 262 and 280, the variable names is OIIO_BUILD_CPP11, OIIO_BUILD_CPP14 and "-DOIIO_NO_SSE = 1" instead of OSL_BUILD_CPP11, OSL_BUILD_CPP14 and "-DOSL_NO_SSE = 1"

Thank you for your work and for reading

cmake fails to find IlmBase on Debian; should use pkg-config

I tried to compile OpenShadingLanguage on my Debian system, and while the build system apparently has some sort of configuration stuff for IlmBase, it fails on Debian.

I briefly looked at the cmake config stuff for it, in "src/cmake/modules/FindIlmBase.cmake", but it's pretty impenetrable (cmake: confusing), and I couldn't figure out how to fix it, or even how to manually alter the settings so I could specify my setup manually.

IlmBase's pkg-config setup gives the right compiler options to use to find IlmBase:

$ pkg-config --cflags IlmBase
-I/usr/include/OpenEXR  
$ pkg-config --libs IlmBase
-lImath -lHalf -lIex -lIlmThread -lpthread  

Really, FindIlmBase.cmake should use pkg-config to find what settings to use for IlmBase, as it should yield accurate info for any system which has IlmBase installed. [It could use the current more adhoc config stuff in the case where pkg-config isn't available, or doesn't know about IlmBase.

[I'm sorry I can't offer much help in changing this, as I don't know cmake.]

Segfault compiling shader with inverted closure

From a bug report to the Blender bug tracker by Emanuel Pinedo.
The following code segfaults olsc (and Blender):

shader note_test (closure color Closure1=0, output closure color Closure=0) { Closure = - Closure1; }

The error is:
osl_pvt.h:292: failed assertion '! is_closure() && "Don't call this if it could be a closure"'
(note the line is corresponding to the sources of OpenShadingLanguage-Release-1.4.0)

Still trying to simply build on ubuntu, RB-1.5

CMake Warning:
Manually-specified variables were not used by the project:

SELF_CONTAINED_INSTALL_TREE

-- Build files have been written to: /root/OpenShadingLanguage/build/linux64
( cd build/linux64 ; make )
make[1]: Entering directory '/root/OpenShadingLanguage/build/linux64'
make[2]: Entering directory '/root/OpenShadingLanguage/build/linux64'
make[3]: Entering directory '/root/OpenShadingLanguage/build/linux64'
[ 1%] Generating osllex.cpp
[ 2%] Generating oslgram.cpp
/root/OpenShadingLanguage/src/liboslcomp/oslgram.y: warning: 1 shift/reduce conf
lict [-Wconflicts-sr]
/root/OpenShadingLanguage/src/liboslcomp/oslgram.y: warning: 1 reduce/reduce con
flict [-Wconflicts-rr]
Scanning dependencies of target oslcomp
make[3]: Leaving directory '/root/OpenShadingLanguage/build/linux64'
make[3]: Entering directory '/root/OpenShadingLanguage/build/linux64'
[ 3%] Building CXX object src/liboslcomp/CMakeFiles/oslcomp.dir/ast.cpp.o
In file included from /root/OpenShadingLanguage/src/liboslcomp/ast.cpp:35:
In file included from /root/OpenShadingLanguage/src/include/osl_pvt.h:31:
/root/OpenShadingLanguage/src/include/OSL/oslconfig.h:109:13: error: no member
named 'string_view' in namespace 'OpenImageIO::v1_3'
using OIIO::string_view;
~~~~~~^
In file included from /root/OpenShadingLanguage/src/liboslcomp/ast.cpp:35:
/root/OpenShadingLanguage/src/include/osl_pvt.h:54:1: error: unknown type name
'string_view'
string_view shadertypename (ShaderType s);
^
/root/OpenShadingLanguage/src/include/osl_pvt.h:58:34: error: unknown type name
'string_view'
ShaderType shadertype_from_name (string_view name);
^
/root/OpenShadingLanguage/src/include/osl_pvt.h:76:32: error: unknown type name
'string_view'
ShaderUse shaderuse_from_name (string_view name);
^
In file included from /root/OpenShadingLanguage/src/liboslcomp/ast.cpp:36:
In file included from /root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:36:

/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:52:19: error: unknown type
name 'string_view'
bool compile (string_view filename,
^
/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:54:19: error: unknown type
name 'string_view'
string_view stdoslpath = string_view());
^
/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:59:26: error: unknown type
name 'string_view'
bool compile_buffer (string_view sourcecode, std::string &osobuffer,
^
/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:61:26: error: unknown type
name 'string_view'
string_view stdoslpath = string_view());
^
/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:65:5: error: unknown type
name 'string_view'
string_view output_filename () const;
^
/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:54:44: error: use of
undeclared identifier 'string_view'
string_view stdoslpath = string_view());
^
/root/OpenShadingLanguage/src/include/OSL/oslcomp.h:61:51: error: use of
undeclared identifier 'string_view'
string_view stdoslpath = string_view());
^
In file included from /root/OpenShadingLanguage/src/liboslcomp/ast.cpp:36:
In file included from /root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:37:

/root/OpenShadingLanguage/src/liboslcomp/ast.h:340:5: error: unknown type name
'string_view'
string_view shadertypename () const;
^
In file included from /root/OpenShadingLanguage/src/liboslcomp/ast.cpp:36:
/root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:69:19: error: unknown
type name 'string_view'
bool compile (string_view filename,
^
/root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:71:19: error: unknown
type name 'string_view'
string_view stdoslpath);
^
/root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:73:26: error: unknown
type name 'string_view'
bool compile_buffer (string_view sourcecode,
^
/root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:76:26: error: unknown
type name 'string_view'
string_view stdoslpath);
^
/root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:249:5: error: unknown
type name 'string_view'
string_view output_filename () const { return m_output_filename; }
^
/root/OpenShadingLanguage/src/liboslcomp/oslcomp_pvt.h:249:51: error: no viable
conversion from 'const std::string' (aka 'const basic_string') to
'int'
string_view output_filename () const { return m_output_filename; }
^~~~~~~~~~~~~~~~~
/root/OpenShadingLanguage/src/liboslcomp/ast.cpp:204:1: error: unknown type name

  'string_view'

string_view
^
19 errors generated.
src/liboslcomp/CMakeFiles/oslcomp.dir/build.make:70: recipe for target 'src/libo
slcomp/CMakeFiles/oslcomp.dir/ast.cpp.o' failed
make[3]: *** [src/liboslcomp/CMakeFiles/oslcomp.dir/ast.cpp.o] Error 1
make[3]: Leaving directory '/root/OpenShadingLanguage/build/linux64'
CMakeFiles/Makefile2:943: recipe for target 'src/liboslcomp/CMakeFiles/oslcomp.d
ir/all' failed
make[2]: *** [src/liboslcomp/CMakeFiles/oslcomp.dir/all] Error 2
make[2]: Leaving directory '/root/OpenShadingLanguage/build/linux64'
Makefile:143: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/root/OpenShadingLanguage/build/linux64'
Makefile:198: recipe for target 'cmake' failed
make: *** [cmake] Error 2

Runtime static initialization error in BackendLLVM::ShaderGlobalNameToIndex

When executing an OSL shader in very particular conditions (On Windows, with oslexec.dll on a slow disk) I randomly run into the assert :
ASSERT (sg_index >= 0); in BackendLLVM::llvm_global_symbol_ptr
The problem is that the symbol here actually is a global OSL symbol (generally 'u' in my test case).

The bug might come from the fact that the static 'fields' array in BackendLLVM::ShaderGlobalNameToIndex is initialized at runtime. When the function is called by multiple threads, given a particular set of conditions, a thread can consider the array as empty.

The assert is not triggered any more when the 'fields' array is initialized outside of the function, in an anonymous namespace.

Strict overflow issue with 1.4.4 on Ubuntu 12.04

Whilst attempting the build the 1.4.4 release on Ubuntu 12.04, I encountered the following problem.

/home/nicholas/projects/OpenShadingLanguage/OpenShadingLanguage_git/src/liboslexec/oslexec_pvt.h: In function ‘int OSL::pvt::constfold_getattribute(OSL::pvt::RuntimeOptimizer&, int)’:
/home/nicholas/projects/OpenShadingLanguage/OpenShadingLanguage_git/src/liboslexec/oslexec_pvt.h:1468:64: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]
/home/nicholas/projects/OpenShadingLanguage/OpenShadingLanguage_git/src/liboslexec/oslexec_pvt.h:1468:64: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]
cc1plus: all warnings being treated as errors
make[2]: *** [src/liboslexec/CMakeFiles/oslexec.dir/constfold.cpp.o] Error 1
make[1]: *** [src/liboslexec/CMakeFiles/oslexec.dir/all] Error 2
make: *** [all] Error 2

Updates to build with libc++

This is in reference to commit 6c56867

I'm only concerned here with the changes in src/CMakeLists.txt.

I understand that these changes are to bypass the use of the gcc extension of std::filebuf having a FILE* constructor by using boost_wave - is this planned to be a permanent solution or just a temporary fix?

line 129 -- if (EXISTS "/usr/lib/libc++.dylib" OR OSL_USE_LIBCPP)

The "OR OSL_USE_LIBCPP" needs to be removed, we are simply defining OSL_SYSTEM_HAS_LIBCPP. The search for libc++ needs to be more flexible. .so or .a suffixes on *nix machines possibly /usr/local/lib for user installed libs. .dll suffix and what locations would this be in on windows? Should the search for libc++ be added to cmake/modules or externalpackages.cmake? Could that lead to OSL_LIBCPP_PATH being user adjustable option?

OSL_USE_LIBCPP needs to be made visible to the user in ccmake or cmake-gui by adding -
set (OSL_USE_LIBCPP ON CACHE BOOL "Build using libc++ if available")

The last test that adds -stdlib need expanding - possibly --

if (CMAKE_COMPILER_IS_CLANG AND OSL_SYSTEM_HAS_LIBCPP AND OSL_USE_LIBCPP)
    message (STATUS "Using libc++")
    add_definitions ("-stdlib=libc++")
    if (NOT USE_BOOST_WAVE)
        error ("Boost wave needs to be enabled when using libc++")
    endif()
endif ()

If boost wave is temporary fix then most if not all of these cmake changes can be removed.

Confusing error message when standard library header is not found

In the file src/master/liboslcomp/oslcomp.cpp:
If the test on line 323 fails:
if (OIIO::Filesystem::exists (path.string())) {

The variable path will not be updated to contain "/stdosl.h" in the end. This makes the error reported on line 339 in the same file confusing since the path it says it can't find doesn't say anything about stdosl.h but only mentioning a missing directory. It makes more sense to explicitly say it's the standard library missing and write the full path to the missing file.

Off topic:
It's the first time I post here, would you prefer to see a patch here or is this form ok?

Array of struct containing an array fails

Section 5.9 of osl-languagespec states:

It is permitted to have a structure field that is an array, as well as to have an array of struc-
tures. But it is not permitted for one structure to have a field that is another structure. For
example:

struct A {
color a;
float b[4]; // struct may contain an array
};

A d[5]; // Array of structures
color e = d[0].a; // Field of one element of array of struct
d[2].b[4] = 0.25; // Element of a field of a struct in an array

While the last example is an error as the index for b should be < 4,
the array of structs line fails with:-
error: Nested structs with >1 levels of arrays are not allowed: A

I would vote that the compiler is fixed to match this spec rather than just adjusting the spec.

Trouble building on 32bit FreeBSD

I have had the 64bit version built and running since 1.5.10 was released. Now I have got around to getting all packages working and have trouble with 32bit builds.

With gcc 4.2 I get (4.8.3 also fails-see below)
/usr/include/c++/4.2/bits/stl_algobase.h:641: error: invalid conversion from 'const int' to 'const char*'

While clang words it as
/usr/include/c++/4.2/bits/stl_algobase.h:641:15: error: assigning to 'const char *' from incompatible type 'const int'

The error stems from testshade.cpp line 734 (master it is now line 758)
std::vector<const char *> layers (num_layers, NULL);

10.0-i386 works as it removes the old stdc++ and only offers clang's libc++
8.4 and 9.3 only have stdc++

Full clang error is

[ 94%] Building CXX object src/testshade/CMakeFiles/testshade.dir/simplerend.cpp.o
cd /wrkdirs/usr/ports/graphics/openshadinglanguage/work/.build/src/testshade && /usr/bin/clang++   -DBOOST_NO_RTTI -DBOOST_NO_TYPEID -DOSL_LLVM_VERSION=34 -DUSE_PARTIO=0 -O2 -pipe -fno-strict-aliasing -I/usr/local/include/flex -fno-rtti -march=i586 -O2 -pipe -fno-strict-aliasing -I/usr/local/include/flex -I/usr/local/llvm34/include -isystem /usr/local/include -I/wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/include -I/wrkdirs/usr/ports/graphics/openshadinglanguage/work/.build/include/OSL    -Wall -Werror -Qunused-arguments -Wno-unknown-pragmas -Wno-null-conversion -o CMakeFiles/testshade.dir/simplerend.cpp.o -c /wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/simplerend.cpp
In file included from /wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/testshade.cpp:30:
In file included from /usr/include/c++/4.2/iostream:45:
In file included from /usr/include/c++/4.2/ostream:45:
In file included from /usr/include/c++/4.2/ios:45:
In file included from /usr/include/c++/4.2/bits/char_traits.h:46:
/usr/include/c++/4.2/bits/stl_algobase.h:641:15: error: assigning to 'const char *' from incompatible type 'const int'
            *__first = __tmp;
                     ^ ~~~~~
/usr/include/c++/4.2/bits/stl_algobase.h:665:39: note: in instantiation of function template specialization 'std::__fill_n<true>::fill_n<const char **, int, int>' requested here
      return std::__fill_n<__scalar>::fill_n(__first, __n, __value);
                                      ^
/usr/include/c++/4.2/bits/stl_uninitialized.h:184:12: note: in instantiation of function template specialization 'std::fill_n<const char **, int, int>' requested here
    { std::fill_n(__first, __n, __x); }
           ^
/usr/include/c++/4.2/bits/stl_uninitialized.h:219:12: note: in instantiation of function template specialization 'std::__uninitialized_fill_n_aux<const char **, int, int>' requested here
      std::__uninitialized_fill_n_aux(__first, __n, __x, _Is_POD());
           ^
/usr/include/c++/4.2/bits/stl_uninitialized.h:306:12: note: in instantiation of function template specialization 'std::uninitialized_fill_n<const char **, int, int>' requested here
    { std::uninitialized_fill_n(__first, __n, __x); }
           ^
/usr/include/c++/4.2/bits/stl_vector.h:801:9: note: in instantiation of function template specialization 'std::__uninitialized_fill_n_a<const char **, int, int, const char *>' requested here
          std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value,
               ^
/usr/include/c++/4.2/bits/stl_vector.h:272:4: note: in instantiation of function template specialization 'std::vector<const char *, std::allocator<const char *> >::_M_initialize_dispatch<int>' requested here
          _M_initialize_dispatch(__first, __last, _Integral());
          ^
/wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/testshade.cpp:734:39: note: in instantiation of function template specialization 'std::vector<const char *, std::allocator<const char *> >::vector<int>' requested here
            std::vector<const char *> layers (num_layers, NULL);
                                      ^
1 error generated.
*** [src/testshade/CMakeFiles/testshade.dir/testshade.cpp.o] Error code 1

gcc 4.8.3 outputs

cd /wrkdirs/usr/ports/graphics/openshadinglanguage/work/.build/src/testshade && /usr/local/bin/g++48   -DOSL_LLVM_VERSION=34 -DUSE_PARTIO=0 -Dlibtestshade_EXPORTS -O2 -pipe -Wl,-rpath=/usr/local/lib/gcc48 -fno-strict-aliasing -I/usr/local/include/flex -Wl,-rpath=/usr/local/lib/gcc48 -fno-rtti -march=i586 -O2 -pipe -Wl,-rpath=/usr/local/lib/gcc48 -fno-strict-aliasing -I/usr/local/include/flex -Wl,-rpath=/usr/local/lib/gcc48 -fPIC -I/usr/local/llvm34/include -isystem /usr/local/include -I/wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/include -I/wrkdirs/usr/ports/graphics/openshadinglanguage/work/.build/include/OSL    -Wall -Werror -Wno-error=strict-overflow -o CMakeFiles/libtestshade.dir/simplerend.cpp.o -c /wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/simplerend.cpp
In file included from /usr/local/lib/gcc48/include/c++/vector:64:0,
                 from /wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/testshade.cpp:33:
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h: In instantiation of 'void std::vector<_Tp, _Alloc>::_M_initialize_dispatch(_Integer, _Integer, std::__true_type) [with _Integer = int; _Tp = const char*; _Alloc = std::allocator<const char*>]':
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h:404:55:   required from 'std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = int; _Tp = const char*; _Alloc = std::allocator<const char*>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<const char*>]'
/wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/testshade.cpp:734:63:   required from here
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h:1166:59: error: invalid conversion from 'int' to 'std::vector<const char*>::value_type {aka const char*}' [-fpermissive]
    _M_fill_initialize(static_cast<size_type>(__n), __value);
                                                           ^
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h:1212:7: error:   initializing argument 2 of 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = const char*; _Alloc = std::allocator<const char*>; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::value_type = const char*]' [-fpermissive]
       _M_fill_initialize(size_type __n, const value_type& __value)
       ^
In file included from /usr/local/lib/gcc48/include/c++/vector:64:0,
                 from /wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/testshade.cpp:33:
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h: In instantiation of 'void std::vector<_Tp, _Alloc>::_M_initialize_dispatch(_Integer, _Integer, std::__true_type) [with _Integer = int; _Tp = const char*; _Alloc = std::allocator<const char*>]':
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h:404:55:   required from 'std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = int; _Tp = const char*; _Alloc = std::allocator<const char*>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<const char*>]'
/wrkdirs/usr/ports/graphics/openshadinglanguage/work/imageworks-OpenShadingLanguage-45b8ba3/src/testshade/testshade.cpp:734:63:   required from here
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h:1166:59: error: invalid conversion from 'int' to 'std::vector<const char*>::value_type {aka const char*}' [-fpermissive]
    _M_fill_initialize(static_cast<size_type>(__n), __value);
                                                           ^
/usr/local/lib/gcc48/include/c++/bits/stl_vector.h:1212:7: error:   initializing argument 2 of 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = const char*; _Alloc = std::allocator<const char*>; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::value_type = const char*]' [-fpermissive]
       _M_fill_initialize(size_type __n, const value_type& __value)
       ^
*** [src/testshade/CMakeFiles/testshade.dir/testshade.cpp.o] Error code 1
*** [src/testshade/CMakeFiles/libtestshade.dir/testshade.cpp.o] Error code 1

Wrong function signature of surfacearea() in OSL specification.

It should be float surfacearea(), not int surfacearea()

diff --git a/src/doc/languagespec.tex b/src/doc/languagespec.tex
index a1cd776..0793093 100644
--- a/src/doc/languagespec.tex
+++ b/src/doc/languagespec.tex
@@ -4792,7 +4792,7 @@ by the shader (via {\cf setmessage()}).

 \apiend

-\apiitem{int {\ce surfacearea} ()}
+\apiitem{float {\ce surfacearea} ()}
 \indexapi{surfacearea()}
 Returns the surface area of the area light geometry being shaded.  This
 is meant to be used in conjunction with {\cf emission()} in order to 

OSX Issue: terminating with uncaught exception

Hello everyone.

I have OSX 10.9.4 and following libraries:

  • boost 1.56,
  • LLVM 3.4.2 with option --disable-terminfo,
  • OpenImageIO 1.5.2dev 881987ee5f with options BUILDSTATIC=1 LINKSTATIC=1,
  • OpenShadingLanguage 1.5.10 cbbdf6f with options BUILDSTATIC=1 LINKSTATIC=1 LLVM_STATIC=1

The issue can be easily reproducible with testshade and testrender. For example when I run testshade I have following error message:

libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >
Abort trap: 6

bt looks like this:

(gdb) bt
#0  0x00007fff95ae9866 in __pthread_kill ()
#1  0x00007fff9718535c in pthread_kill ()
#2  0x00007fff8d9a7b1a in abort ()
#3  0x00007fff93fedf31 in abort_message ()
#4  0x00007fff94013952 in default_terminate_handler ()
#5  0x00007fff8f889322 in _objc_terminate ()
#6  0x00007fff940111d1 in std::__terminate ()
#7  0x00007fff94010c5b in __cxa_throw ()
#8  0x0000000100013877 in boost::throw_exception<boost::lock_error> (e=@0x7fff5fbfb158) at throw_exception.hpp:69
#9  0x0000000100014ea3 in boost::mutex::lock (this=0x1016bc460) at mutex.hpp:119
#10 0x0000000100016ae3 in lock_guard (this=0x7fff5fbfb248, m_=@0x1016bc460) at lock_guard.hpp:38
#11 0x0000000100016a6d in lock_guard (this=0x7fff5fbfb248, m_=@0x1016bc460) at lock_guard.hpp:39
#12 0x0000000100925d7a in OpenImageIO::v1_5::pvt::ImageCacheImpl::purge_perthread_microcaches (this=0x103001e00) at /Users/victor/Development/OpenImageIO/src/libtexture/imagecache.cpp:2730
#13 0x0000000100927717 in OpenImageIO::v1_5::pvt::ImageCacheImpl::invalidate_all (this=0x103001e00, force=false) at /Users/victor/Development/OpenImageIO/src/libtexture/imagecache.cpp:2650
#14 0x00000001009205c5 in OpenImageIO::v1_5::pvt::ImageCacheImpl::attribute (this=0x103001e00, name=<value temporarily unavailable, due to optimizations>, type=<value temporarily unavailable, due to optimizations>, val=0x7fff5fbfc4f4) at /Users/victor/Development/OpenImageIO/src/libtexture/imagecache.cpp:1771
#15 0x00000001008f26a0 in OpenImageIO::v1_5::pvt::TextureSystemImpl::attribute (this=0x102803d70, name=<value temporarily unavailable, due to optimizations>, type=<value temporarily unavailable, due to optimizations>, val=0x7fff5fbfc4f4) at /Users/victor/Development/OpenImageIO/src/libtexture/texturesys.cpp:301
#16 0x000000010090243f in OpenImageIO::v1_5::pvt::TextureSystemImpl::attribute (this=0x102803d70, name=<value temporarily unavailable, due to optimizations>, val=1) at texture_pvt.h:72
#17 0x0000000100123006 in RendererServices (this=0x1016fcfe8, texsys=0x0) at /Users/victor/Development/OpenShadingLanguage/src/liboslexec/rendservices.cpp:65
#18 0x0000000100026709 in SimpleRenderer (this=0x1016fcfe8) at /Users/victor/Development/OpenShadingLanguage/src/testshade/simplerend.cpp:147
#19 0x00000001000266d5 in SimpleRenderer (this=0x1016fcfe8) at /Users/victor/Development/OpenShadingLanguage/src/testshade/simplerend.cpp:164
#20 0x000000010000edb4 in __cxx_global_var_init31 () at /Users/victor/Development/OpenShadingLanguage/src/testshade/testshade.cpp:84
#21 0x000000010000f0ba in global constructors keyed to a () at /Users/victor/Development/OpenShadingLanguage/src/testshade/testshade.cpp:354
#22 0x00007fff5fc11c2e in __dyld__ZN16ImageLoaderMachO18doModInitFunctionsERKN11ImageLoader11LinkContextE ()
#23 0x00007fff5fc11dba in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE ()
#24 0x00007fff5fc0ea62 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListE ()
#25 0x00007fff5fc0e8f6 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE ()
#26 0x00007fff5fc021da in __dyld__ZN4dyld24initializeMainExecutableEv ()
#27 0x00007fff5fc05560 in __dyld__ZN4dyld5_mainEPK12macho_headermiPPKcS5_S5_Pm ()
#28 0x00007fff5fc0127b in __dyld__ZN13dyldbootstrap5startEPK12macho_headeriPPKclS2_Pm ()
#29 0x00007fff5fc0105e in __dyld__dyld_start ()

It looks like boost's lock_guardboost::mutex throws EINVAL exception at mutex.hpp:119

Thanks for reading this. How is it possible to fix that?

gabornoise.cpp compile error

There is a compile time error with gabornoise.cpp :

[ 19%] Building CXX object liboslexec/CMakeFiles/oslexec.dir/gabornoise.cpp.o
~/dev/osl3/src/liboslexec/gabornoise.cpp:70:9: error: this decimal constant is unsigned only in ISO C90 [-Werror]
~/dev/osl3/src/liboslexec/gabornoise.cpp:69:28: error: ‘long’ invalid for ‘operator()’
cc1plus: all warnings being treated as errors

this can be fixed by changing line 70 to :

return (m_seed *= 3039177861u) / float(UINT_MAX);

previously it was :
return (m_seed *= 3039177861) / float(UINT_MAX);

Building with cmake + Visual Studio fails

cmake's Visual Studio generators and or Visual Studio make binaries appear in /Release/ or /Debug/ subdirectories. The custom command that compiles shaders does not take those variations into account. I propose to work around it by just copying oslc to the right place in case we are dealing with visual studio and or msbuild. Note NMake is unaffected by this.

--- a/OpenShadingLanguage-Release-1.5.10/src/shaders/CMakeLists.txt Wed Jul 30 19:38:26 2014
+++ b/OpenShadingLanguage-Release-1.5.10/src/shaders/CMakeLists.txt Mon Aug  4 15:55:45 2014
@@ -3,6 +3,12 @@
     MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/stdosl.h"
     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
 
+if(${CMAKE_GENERATOR} MATCHES "(Visual Studio.*)") #Work around visual studio outputting oslc.exe in a subfolder
+   add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../oslc/oslc"
+       COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/../oslc/${CMAKE_BUILD_TYPE}/oslc.exe" "${CMAKE_CURRENT_BINARY_DIR}/../oslc/"
+       DEPENDS oslc)
+endif()        
+   
 macro (osl_compile oslsrc objlist headers)
     # message (STATUS "OSL_COMPILE src=${oslsrc}")
     # message (STATUS "  src ${CMAKE_CURRENT_SOURCE_DIR}")

Support LLVM 3.6

I know LLVM 3.6 breaks in all kinds of ways because the classical JIT has been removed and now only MCJIT is in there. This is entirely unsupported by OSL right now because the JITMemoryManager is now also gone. I suppose this isn't going to happen to quickly but I think we can use this issue to track that nonetheless.

Visual Studio 2012 compilation

Hi, I tried to compile OSL with VC 2012 using the fixes Larry provided for the VC 2010 compilation.
And found out that VC 2012 defines __cplusplus as 199711L
So we have a nice mix of C++98 and C++11.

I got a whole bunch of errors related to std::shared_ptr and co.

external CMAKE file gives wrong error message when C++11 is not used with LLVM3.5

if (LLVM_VERSION VERSION_GREATER 3.4.9 AND NOT OSL_BUILD_CPP11)
message (FATAL_ERROR "LLVM ${LLVM_VERSION} requires C++11. You must build with USE_CPP11=1.")

should be

if (LLVM_VERSION VERSION_GREATER 3.4.9 AND NOT OSL_BUILD_CPP11)
message (FATAL_ERROR "LLVM ${LLVM_VERSION} requires C++11. You must build with OSL_BUILD_CPP11=1.")

Returning struct from nested function assertion

Compiling this

struct Test { float f; };

shader test()
{
    Test some_function()
    {
        Test a;
        return a;
    }

    Test b = some_function();
}

results in src/liboslcomp/typecheck.cpp:1241: Failed assertion '0': Don't know how to decode type code '49'

If some_function is not nested it still gives a compile error but no assertion is hit. I can try to fix this but I'm wondering if I should try to make it throw an error for this case or if returning structs should actually work?

Undefined reference to symbol _ZN4llvm15SmallPtrSetImplD2Ev

Here is the error stack.
[ 21%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/shadeimage.cpp.o
[ 22%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/backendllvm.cpp.o
[ 24%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_gen.cpp.o
[ 25%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_instance.cpp.o
[ 26%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_util.cpp.o
[ 27%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir//liboslcomp/ast.cpp.o
[ 28%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/
/liboslcomp/codegen.cpp.o
[ 29%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir//liboslcomp/oslcomp.cpp.o
[ 31%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/
/liboslcomp/symtab.cpp.o
[ 32%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir//liboslcomp/typecheck.cpp.o
[ 33%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/
/liboslquery/oslquery.cpp.o
[ 34%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/osogram.cpp.o
[ 35%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/osolex.cpp.o
[ 36%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/oslgram.cpp.o
[ 37%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/osllex.cpp.o
[ 39%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_ops.bc.cpp.o
Linking CXX shared library liboslexec.so
[ 75%] Built target oslexec
Scanning dependencies of target accum_test
[ 77%] Building CXX object src/liboslexec/CMakeFiles/accum_test.dir/accum_test.cpp.o
Linking CXX executable accum_test
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libLLVMMCJIT.a(MCJIT.o): undefined reference to symbol '_ZN4llvm15SmallPtrSetImplD2Ev'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libLLVM-3.4.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/liboslexec/accum_test] Error 1
make[1]: *** [src/liboslexec/CMakeFiles/accum_test.dir/all] Error 2
make: *** [all] Error 2

Trouble finding llvm in OS X build

Trying to build OSL on OS X 10.9.2, Xcode version 5.1.1. Successfully built and installed all dependencies in standard locations. OSL build fails with this output:

[vulcan:~/OpenSource/osl] alec% make
platform=macosx, hw=x86_64
OSL_SITE = vulcan.local
dist_dir = dist/macosx
INSTALLDIR = /Users/alec/OpenSource/osl
-- Project source dir = /Users/alec/OpenSource/osl
-- Project build dir = /Users/alec/OpenSource/osl/build/macosx
-- CMAKE_CXX_COMPILER is /usr/bin/c++
-- CMAKE_CXX_COMPILER_ID is Clang
-- Using clang as the compiler
-- platform = macosx
-- OPENIMAGEIOHOME =
-- BOOST_ROOT
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- filesystem
-- regex
-- system
-- thread
-- wave
-- Partio not found
-- LLVM version =
-- LLVM dir =
CMake Error at src/cmake/externalpackages.cmake:216 (message):
LLVM not found.
Call Stack (most recent call first):
CMakeLists.txt:193 (include)

-- Configuring incomplete, errors occurred!
See also "/Users/alec/OpenSource/osl/build/macosx/CMakeFiles/CMakeOutput.log".
make: *** [cmakesetup] Error 1

Any suggestions on how to get past this? Thanks!

Option to control inlining

I would like to suggest an addition to control the inlining of functions. While adding inline before each function could be tempting I think the simplicity of osl scripts would work well with a global option.

I suggest something like #pragma inlining on/off could be added near the top of a script to turn it on or off, with the render engine defining which is default.

As an example I have a script of 173 lines - SARock.osl. If you discount the input parameters and the function calls broken into three lines you end up with about 50 real lines of code. Due to it's repetitive nature it compiles to a 7.6MB oso file. I would expect non-inlining to reduce that to less than 1MB. This would also filter through to reduced memory usage when rendering.

support spectral rendering in the language (single wavelength)

In my renderer, I'm having to ignore two out of three RGB components. I do one wavelength per ray, and randomly sample across all wavelengths. When the final wavelength is integrated into the rendered image, I do the normal RGB weighting. What is surprising (perhaps) is that good color fidelity is achieved rather quickly, certainly faster than is needed to get a good (unbiased) rendering to begin with.

Single-wavelength rendering also make certain kinds of effects trivial, makes it easier to model physical lighting exactly, and is in general, IMO, easier conceptually to work with than RGB.

It would be great if OSL could have a mode that was optimized for this. :-)

OSL Trunk errors building against LLVM/CLang 3.5.1 Debian

Getting hit in on immediate area:

[ 60%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/backendllvm.cpp.o
[ 61%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_gen.cpp.o
[ 62%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_instance.cpp.o
[ 63%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_util.cpp.o
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:441:29: error:
no member named 'ParseBitcodeFile' in namespace 'llvm'; did you mean 'parseBitcodeFile'?
llvm::Module m = llvm::ParseBitcodeFile (buf, context(), err);
~~~~~~^~~~~~~~~~~~~~~~
parseBitcodeFile
/usr/lib/llvm-3.5/include/llvm/Bitcode/ReaderWriter.h:52:21: note: 'parseBitcodeFile' declared
here
ErrorOr<Module *> parseBitcodeFile(MemoryBuffer *Buffer,
^
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:441:63: error:
too many arguments to function call, expected 2, have 3
llvm::Module *m = llvm::ParseBitcodeFile (buf, context(), err);
~~~~~~~~~~~~~~~~~~~~~~ ^~~
/usr/lib/llvm-3.5/include/llvm/Bitcode/ReaderWriter.h:52:3: note: 'parseBitcodeFile' declared
here
ErrorOr<Module *> parseBitcodeFile(MemoryBuffer *Buffer,
^
2 errors generated.
src/liboslexec/CMakeFiles/oslexec.dir/build.make:777: recipe for target 'src/liboslexec/CMakeFiles/oslexec.dir/llvm_util.cpp.o' failed
make[2]: *
* [src/liboslexec/CMakeFiles/oslexec.dir/llvm_util.cpp.o] Error 1
CMakeFiles/Makefile2:1119: recipe for target 'src/liboslexec/CMakeFiles/oslexec.dir/all' failed
make[1]: *** [src/liboslexec/CMakeFiles/oslexec.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2
mdriftmeyer@horus:~/Projects/OpenShadingLanguage/cmake-osl-trunk$

Secondary area involving Boost 1.55:

Linking CXX executable oslc
[ 23%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_util.cpp.o
CMakeFiles/testshade_dso.dir/testshade_dso.cpp.o: In function main': /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text+0x14c): undefined reference tostd::1::cerr'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text+0x174): undefined reference to std::__1::cerr' CMakeFiles/testshade_dso.dir/testshade_dso.cpp.o: In functionstd::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::_1::char_traits >&, char const, unsigned long)':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x8c): undefined reference to std::__1::ios_base::getloc() const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x96): undefined reference tostd::__1::ctype::id'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x9b): undefined reference to std::__1::locale::use_facet(std::__1::locale::id&) const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0xba): undefined reference tostd::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x100): undefined reference to std::__1::ios_base::clear(unsigned int)' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x12e): undefined reference tostd::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x154): undefined reference to std::__1::ios_base::__set_badbit_and_consider_rethrow()' CMakeFiles/testshade_dso.dir/testshade_dso.cpp.o: In functionstd::__1::basic_ostream<char, std::__1::char_traits >::sentry::~sentry()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev]+0x63): undefined reference to std::__1::ios_base::clear(unsigned int)' CMakeFiles/testshade_dso.dir/testshade_dso.cpp.o: In functionstd::__1::__basic_string_common::__throw_length_error() const':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv]+0x1a): undefined reference to std::logic_error::logic_error(char const_)' CMakeFiles/testshade_dso.dir/testshade_dso.cpp.o: In function std::__1::basic_ostream<char, std::__1::char_traits >::flush()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0x6e): undefined reference tostd::__1::ios_base::clear(unsigned int)' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/testshade/testshade_dso.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0xac): undefined reference to std::__1::ios_base::__set_badbit_and_consider_rethrow()'
CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionmain': /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x3e): undefined reference to std::__1::cout'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x84e): undefined reference toOpenImageIO::v1_5::Filesystem::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0xa03): undefined reference to OpenImageIO::v1_5::Filesystem::exists(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0xb0b): undefined reference tostd::__1::cout' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0xc84): undefined reference to std::__1::cout'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0xd6b): undefined reference tostd::__1::cout' CMakeFiles/oslc.dir/oslcmain.cpp.o: In function (anonymous namespace)::OSLC_ErrorHandler::operator()(int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x10b0): undefined reference tostd::__1::cout' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x10c8): undefined reference to std::__1::cout'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x10e6): undefined reference tostd::__1::ios_base::getloc() const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x10ef): undefined reference to std::__1::ctype::id'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x10f4): undefined reference tostd::__1::locale::use_facet(std::__1::locale::id&) const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1111): undefined reference to std::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1135): undefined reference tostd::__1::cerr' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1154): undefined reference to std::__1::ios_base::getloc() const'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x115e): undefined reference tostd::__1::ctype<char>::id' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1163): undefined reference to std::__1::locale::use_facet(std::__1::locale::id&) const'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1181): undefined reference tostd::__1::locale::~locale()' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x11a5): undefined reference to std::__1::cerr'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x11c4): undefined reference tostd::__1::ios_base::getloc() const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x11ce): undefined reference to std::__1::ctype::id'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x11d3): undefined reference tostd::__1::locale::use_facet(std::__1::locale::id&) const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x11f1): undefined reference to std::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1212): undefined reference tostd::__1::cerr' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1231): undefined reference to std::__1::ios_base::getloc() const'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x123b): undefined reference tostd::__1::ctype<char>::id' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x1240): undefined reference to std::__1::locale::use_facet(std::__1::locale::id&) const'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x125e): undefined reference tostd::__1::locale::~locale()' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x12c5): undefined reference to std::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x12d4): undefined reference tostd::__1::locale::~locale()' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x12e3): undefined reference to std::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text+0x12f2): undefined reference tostd::__1::locale::~locale()' CMakeFiles/oslc.dir/oslcmain.cpp.o: In function boost::exception_ptr boost::exception_detail::get_static_exception_objectboost::exception_detail::bad_alloc_()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZN5boost16exception_detail27get_static_exception_objectINS0_10bad_alloc_EEENS_13exception_ptrEv[_ZN5boost16exception_detail27get_static_exception_objectINS0_10bad_alloc_EEENS_13exception_ptrEv]+0x43): undefined reference to std::bad_alloc::bad_alloc()' CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionstd::__1::__vector_base_common::__throw_length_error() const':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv[_ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv]+0x1a): undefined reference to std::logic_error::logic_error(char const*)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionstd::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::_1::char_traits >&, char const, unsigned long)':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x8c): undefined reference to std::__1::ios_base::getloc() const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x96): undefined reference tostd::__1::ctype::id'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x9b): undefined reference to std::__1::locale::use_facet(std::__1::locale::id&) const' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0xba): undefined reference tostd::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x100): undefined reference to std::__1::ios_base::clear(unsigned int)' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x12e): undefined reference tostd::__1::locale::~locale()'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m[_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m]+0x154): undefined reference to std::__1::ios_base::__set_badbit_and_consider_rethrow()' CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionstd::__1::basic_ostream<char, std::__1::char_traits >::sentry::~sentry()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD2Ev]+0x63): undefined reference to std::__1::ios_base::clear(unsigned int)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionstd::__1::__basic_string_common::__throw_length_error() const':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv]+0x1a): undefined reference to std::logic_error::logic_error(char const_)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In function std::__1::basic_ostream<char, std::__1::char_traits >::flush()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0x6e): undefined reference tostd::__1::ios_base::clear(unsigned int)' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv]+0xac): undefined reference to std::__1::ios_base::__set_badbit_and_consider_rethrow()'
CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionstd::__1::basic_ostream<char, std::__1::char_traits<char> >::write(char const_, long)': /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5writeEPKcl[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5writeEPKcl]+0x77): undefined reference to std::__1::ios_base::clear(unsigned int)'
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5writeEPKcl[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5writeEPKcl]+0xb5): undefined reference tostd::__1::ios_base::__set_badbit_and_consider_rethrow()' CMakeFiles/oslc.dir/oslcmain.cpp.o: In function boost::mutex::mutex()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZN5boost5mutexC2Ev[_ZN5boost5mutexC2Ev]+0x36): undefined reference tostd::runtime_error::runtime_error(char const_)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In function boost::mutex::unlock()':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZN5boost5mutex6unlockEv[_ZN5boost5mutex6unlockEv]+0x39): undefined reference tostd::runtime_error::runtime_error(char const*)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In function boost::exception_detail::error_info_injectorboost::lock_error::error_info_injector(boost::exception_detail::error_info_injectorboost::lock_error const&)':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text.ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEEC2ERKS3[ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEEC2ERKS3]+0x15): undefined reference to std::runtime_error::runtime_error(std::runtime_error const&)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionboost::exception_detail::error_info_injectorboost::lock_error::error_info_injector(boost::lock_error const&)':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text.ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEEC2ERKS2[ZN5boost16exception_detail19error_info_injectorINS_10lock_errorEEC2ERKS2]+0x12): undefined reference to std::runtime_error::runtime_error(std::runtime_error const&)' CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionstd::__1::basic_ostream<char, std::__1::char_traits >::put(char)':
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc]+0x87): undefined reference to std::__1::ios_base::clear(unsigned int)' /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc[_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc]+0xc4): undefined reference tostd::__1::ios_base::__set_badbit_and_consider_rethrow()'
CMakeFiles/oslc.dir/oslcmain.cpp.o: In function boost::mutex::lock()': /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZN5boost5mutex4lockEv[_ZN5boost5mutex4lockEv]+0x39): undefined reference tostd::runtime_error::runtime_error(char const
)'
CMakeFiles/oslc.dir/oslcmain.cpp.o: In function boost::exception_detail::error_info_injectorboost::thread_resource_error::error_info_injector(boost::exception_detail::error_info_injectorboost::thread_resource_error const&)': /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEEC2ERKS3_[_ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEEC2ERKS3_]+0x15): undefined reference to std::runtime_error::runtime_error(std::runtime_error const&)'
CMakeFiles/oslc.dir/oslcmain.cpp.o: In functionboost::exception_detail::error_info_injectorboost::thread_resource_error::error_info_injector(boost::thread_resource_error const&)': /home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/oslc/oslcmain.cpp:(.text._ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEEC2ERKS2_[_ZN5boost16exception_detail19error_info_injectorINS_21thread_resource_errorEEC2ERKS2_]+0x12): undefined reference to std::runtime_error::runtime_error(std::runtime_error const&)'
../liboslcomp/liboslcomp.so: undefined reference tostd::__1::ios_base::copyfmt(std::__1::ios_base const&)' ../liboslcomp/liboslcomp.so: undefined reference to typeinfo for std::__1::__shared_weak_count'
../liboslcomp/liboslcomp.so: undefined reference toboost::wave::grammars::cpp_grammar_gen<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > >, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> > >::parse_cpp_grammar(boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > > const&, boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > > const&, boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > const&, bool&, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >&, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> >&)' ../liboslcomp/liboslcomp.so: undefined reference to std::bad_alloc::bad_alloc()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
../liboslcomp/liboslcomp.so: undefined reference tostd::__1::num_put<char, std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > >::id' ../liboslcomp/liboslcomp.so: undefined reference to std::__1::ios_base::~ios_base()'
../liboslcomp/liboslcomp.so: undefined reference toboost::wave::grammars::expression_grammar_gen<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > >::evaluate(std::__1::__list_const_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, void_> const&, std::__1::__list_const_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, void_> const&, boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > const&, bool, boost::wave::grammars::value_error&)' ../liboslcomp/liboslcomp.so: undefined reference to std::__1::ios_base::__call_callbacks(std::__1::ios_base::event)'
../liboslcomp/liboslcomp.so: undefined reference tostd::bad_cast::bad_cast()' ../liboslcomp/liboslcomp.so: undefined reference to std::__1::locale::locale()'
../liboslcomp/liboslcomp.so: undefined reference toboost::wave::grammars::defined_grammar_gen<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > > >::parse_operator_defined(boost::wave::util::unput_queue_iterator<std::__1::__list_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, void_>, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> > > const&, boost::wave::util::unput_queue_iterator<std::__1::__list_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, void_>, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> > > const&, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> >&)' ../liboslcomp/liboslcomp.so: undefined reference to boost::wave::cpplexer::new_lexer_gen<std::__1::__wrap_iter<char
>, boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits, std::__1::allocator, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator >, char*> > >, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits, std::__1::allocator, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator >, char*> > > > >::new_lexer(std::__1::__wrap_iter<char*> const&, std::__1::__wrap_iter<char*> const&, boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits, std::__1::allocator, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator >, char*> > > const&, boost::wave::language_support)'
../liboslcomp/liboslcomp.so: undefined reference tostd::__1::cin' ../liboslcomp/liboslcomp.so: undefined reference to std::__1::codecvt<char, char, __mbstate_t>::id'
../liboslcomp/liboslcomp.so: undefined reference tostd::__1::__shared_weak_count::~__shared_weak_count()' src/testshade/CMakeFiles/testshade_dso.dir/build.make:96: recipe for target 'src/testshade/testshade_dso' failed make[2]: **\* [src/testshade/testshade_dso] Error 1 ../liboslcomp/liboslcomp.so: undefined reference to std::__1::locale::locale(std::__1::locale const&)'
../liboslcomp/liboslcomp.so: undefined reference tostd::__1::ios_base::init(void_)' ../liboslcomp/liboslcomp.so: undefined reference to OpenImageIO::v1_5::Filesystem::parent_path(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)'
../liboslcomp/liboslcomp.so: undefined reference totypeinfo for std::__1::ios_base' CMakeFiles/Makefile2:1397: recipe for target 'src/testshade/CMakeFiles/testshade_dso.dir/all' failed make[1]: *_\* [src/testshade/CMakeFiles/testshade_dso.dir/all] Error 2 make[1]: **\* Waiting for unfinished jobs.... ../liboslcomp/liboslcomp.so: undefined reference to std::__1::locale::has_facet(std::__1::locale::id&) const'
../liboslcomp/liboslcomp.so: undefined reference toboost::wave::grammars::defined_grammar_gen<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > > >::parse_operator_defined(boost::wave::util::unput_queue_iterator<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > >, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> > > const&, boost::wave::util::unput_queue_iterator<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > > >, boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> > > const&, std::__1::list<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::fast_pool_allocator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits<char>, std::__1::allocator<char>, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::__1::allocator<char> >, char_> > > >, boost::default_user_allocator_new_delete, boost::mutex, 32u, 0u> >&)' ../liboslcomp/liboslcomp.so: undefined reference to std::__1::__shared_weak_count::__release_shared()'
../liboslcomp/liboslcomp.so: undefined reference to`boost::wave::grammars::predefined_macros_grammar_gen<boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits, std::__1::allocator, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::_1::allocator >, char> > > > > >::parse_predefined_macro(boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits, std::__1::allocator, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::_1::allocator >, char> > > > > const&, boost::wave::cpplexer::lex_iterator<boost::wave::cpplexer::lex_token<boost::wave::util::file_position<boost::wave::util::flex_string<char, std::__1::char_traits, std::__1::allocator, boost::wave::util::CowString<boost::wave::util::AllocatorStringStorage<char, std::_1::allocator >, char> > > > > const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ 24%] src/oslc/CMakeFiles/oslc.dir/build.make:101: recipe for target 'src/oslc/oslc' failed
make[2]: *** [src/oslc/oslc] Error 1
CMakeFiles/Makefile2:1169: recipe for target 'src/oslc/CMakeFiles/oslc.dir/all' failed
make[1]: * [src/oslc/CMakeFiles/oslc.dir/all] Error 2
Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/
/liboslcomp/oslcomp.cpp.o
[ 25%] Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/osolex.cpp.o
/home/mdriftmeyer/Projects/OpenShadingLanguage/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:441:29: error:

Not sure if Boost 1.57 changes this, but if so I'll file a request in Debian to push for 1.57 Boost in Experimental.

Custom Shadeops

I haven't found anything regarding extending OSL with custom shadeops.

Is it in the milestones?

How one would go about it in the current state of the package, let's say, to implement a new type of texture lookup shadeop?

thank you

init argument with empty array

Hello,
I'm experiemnting with a OSL and a simple summation shader gives me compilation errors.

This compiles fine:

shader summation (
vector _input[1] = {0},
output vector _output = 0
)
{
vector s = 0;
for (int i = 0; i < arraylength(_input); ++i)
s += _input[i];
_output = s;
}

This errors out with: layers.osl:2: error: Too many initializers for a 'vector[]'

shader layers (
vector _input[] = {0},
output vector _output = 0
)
{...}

This errors out with: layers.osl:2: error: Syntax error: syntax error

shader layers (
vector _input[],
output vector _output = 0
)
{...}

This errors out with: layers.osl:2: error: Syntax error: syntax error

shader layers (
vector _input[] = {},
output vector _output = 0
)
{...}

I can't figure out what is the correct way to initialize the agument as empty array.

wildcardTransitionsFrom(...) description comment

In liboslexec/automata.h, should the following comment:

 /// Get the set of states that are reachable from the given state set by lambda
        void wildcardTransitionsFrom(const IntSet &states, IntSet &out_states)const;

read:

 /// Get the set of states that are reachable from the given state set by *wildcard*
        void wildcardTransitionsFrom(const IntSet &states, IntSet &out_states)const; 

?

renderer

Is there an open source renderer us new guys can use with OSL?

RB-1.5 -- ISO C++ 2011 error

I'm trying to build RB-1.5 and keep running into this error:

Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/llvm_util.cpp.o
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/type_traits:35:0,
from /usr/include/llvm/Support/MathExtras.h:21,
from /usr/include/llvm/ADT/SmallVector.h:20,
from /usr/include/llvm/ADT/ArrayRef.h:14,
from /usr/include/llvm/ADT/APInt.h:19,
from /usr/include/llvm/ADT/APFloat.h:20,
from /usr/include/llvm/IR/Constants.h:24,
from /home/reuben/code/OpenShadingLanguage/src/liboslexec/llvm_util.cpp:41:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

Now if I add the -std=c++11 to the CXXFLAGS in flags.make for that subdirectory, it continues but fails later on with:

Building CXX object src/liboslexec/CMakeFiles/oslexec.dir/shadingsys.cpp.o
In file included from src/liboslexec/shadingsys.cpp:49:0:
/usr/include/OpenImageIO/fmath.h:1301:13: error: ‘constexpr bool std::isnan(double)’ conflicts with a previous declaration using std::isnan;

The OpenImageIO/fmath.h is from openimageio-1.4.16

gcc-4.9.2
llvm-3.5.1

externalpackages.cmake does not find shared LLVM libs

Hi, I have my copy of LLVM 3.4.2 built with shared libraries, and with the current CMake setup in OSL, the LLVM packages are not found.

On the following lines, LLVM is looking for a library named libLLVM-3.4.2.so, which does not exist.
link

This entire setup is at odds with the recommended way of finding / configuring LLVM.
http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project

At the moment, I have worked around this, by applying the following patch (which does similar to the code path when LLVM_STATIC is defined on Line 206 but this is also quite wrong.

diff -Nur OpenShadingLanguage-Release-1.5.10_orig/src/cmake/externalpackages.cmake OpenShadingLanguage-Release-1.5.10/src/cmake/externalpackages.cmake
--- OpenShadingLanguage-Release-1.5.10_orig/src/cmake/externalpackages.cmake    2015-01-19 20:05:46.818128241 +0000
+++ OpenShadingLanguage-Release-1.5.10/src/cmake/externalpackages.cmake 2015-01-19 21:24:44.195788795 +0000
@@ -174,11 +174,11 @@
   execute_process (COMMAND ${LLVM_CONFIG} --includedir
        OUTPUT_VARIABLE LLVM_INCLUDES
        OUTPUT_STRIP_TRAILING_WHITESPACE)
+  execute_process (COMMAND ${LLVM_CONFIG} --libs
+       OUTPUT_VARIABLE LLVM_LIBRARY
+       OUTPUT_STRIP_TRAILING_WHITESPACE)
 endif()

-find_library ( LLVM_LIBRARY
-               NAMES LLVM-${LLVM_VERSION}
-               PATHS ${LLVM_LIB_DIR})
 message (STATUS "LLVM version  = ${LLVM_VERSION}")
 message (STATUS "LLVM dir      = ${LLVM_DIRECTORY}")

Cheers,
Mark

1.4.0 on Ubuntu 12.04 fails to compile

The error I get is:
build/src/liboslexec/llvm_ops.s:334:37: error: invalid use of function-only attribute
define void @osl_assert_nonnull(i8* readnone %x, i8* %msg) #3 {

Building fully-static OSL chain with CMake

Currently, it is very hard to build a full-static OSL. The main reason is that static libs (at least in Linux world, .a) do not embed the static libs they use. So e.g. libOpenImageIO.a holds absolutely no link to IlmImf.a (or .so), neither to libjpeg, etc.

Then, at OSL level, we have to explicitly add to link list all IlmBase, OpenEXR and OIIO (including its dependencies, jpeg, png, etc.)…

For now, I can see thrre ways to handle this:

  1. Add a STATIC_LINK_LIBS props, that should be filled by builders who want to compile against static Openexr/OIIO.
  2. Add all libs from OIIO cmake to OSL cmake, and use them in case of static building. This is perhaps the easiest automatic solution, but it would add many things to OSL cmake just to support that (rather specific) build scenario, not sure you guys would like that.
  3. Make OIIO cmake output in a text file a complete list of paths and libs it used to build, which could be automatically read by OSL cmake in case of static linking.

Solution 3) is my preferred one, even though slightly hacky, it should not add too much overhead to neither OIIO nor OSL cmake, and still allows for easy scripted build of the whole tool chain. Thoughts?

Regards,
Bastien

oslgram.y -- for loop off by one

Pretty sure this is wrong, did the math a few times and only count 8 tokens...

diff --git a/src/liboslcomp/oslgram.y b/src/liboslcomp/oslgram.y
index 396138f..971481b 100644
--- a/src/liboslcomp/oslgram.y
+++ b/src/liboslcomp/oslgram.y
@@ -636,7 +636,7 @@ loop_statement
                 {
                     $$ = new ASTloop_statement (oslcompiler,
                                                 ASTloop_statement::LoopFor,
-                                                $4, $5, $7, $9);
+                                                $3, $4, $6, $8);
                     $$->sourceline (@1.first_line);
                     oslcompiler->symtab().pop ();
                 }

Array assignment

WBN to extend the oso "assign" to be able to assign arrays in one instruction. This isn't allowed in OSL at the moment, but happens implicitly if you do structure assignment and the structure contains an array. Making it one assignment, instead of the current code generation for element-by-element copy, will make more compact oso's as well as make it very easy for the LLVM IR generation to turn it into a simple memcpy.

We could also open debate on whether we should allow assignment of arrays in the OSL source language. (The only important counter-argument is simply that C does not allow it, and we try to minimize gratuitous differences from C unless they are significant improvements or specializations for shader programming in particular.)

Are most microfacet-based OSL shaders physically incorrect because of fresnel?

Been trying my hand at OSL a fair bit the last couple days - it is pretty awesome to be honest, great work! I'm trying to implement Disney's PBR shader in pure OSL and I hope to contribute it back to this project once done. I have run into a few problems though. Here is the first:

I notice this pattern or equivalent in a lot of OSL shaders (for example this one):

Ci = (Kr * Cs) * microfacet("default", N, U, xalpha, yalpha, eta, 1);

I believe that the microfacet shader itself already has dielectric Fresnel built-in, hence the eta term. Fresnel should go to 1 when dot( N, I ) = 0. Basically there should be full reflection at grazing angles. But the above pattern doesn't allow that because even if microfacet() returns 1.0, it is modulated by the specular color.

Basically this means that at anything approaching grazing angles, if you use a non monochromatic specular color / coefficient, you are getting physically incorrect results. Almost every shader I see in OSL that has a specular component has what I believe is this "error."

I believe that either eta needs to be a color, which you can compute based on the specular color... something like this for each channel:

// from solve( f0 = (( 1-n ) / (1+n))^2, n ), assuming other medium is air.
float f0ToDielectricRefractionIndex( float f0 ) {
    return ( sqrt( f0 ) + 1 ) / ( 1 - sqrt( f0 ) );
}

Or you need to incorporate specular color into the microfacet distribution call so that it can be modulated to white at the grazing angles.

Or you need to call the microfacet distribution 3 times, once for each of the eta values representative of the specular color.

Disclaimer: I am somewhat new to PBR so I could be wrong about this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.