Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Nov 27, 2015
  1. @lgritz

    Fix some subtle bugs in the recent improved basic block alias analysis.

    lgritz committed
    * The temporary coalescing has always relied on the assumption that temp
      lifetimes can simply be compared for overlap in their min/max
      instruction numbers, and this is only possible if their lifetime
      doesn't cross a loop boundary. As long as temporaries are restricted
      to live within one basic block, this is safe -- and they do so as a
      natural consequence of how they are created and used. EXCEPT that as a
      result of the new analysis, their values could end up being used
      outside their original basic blocks, and then could be inappropriate
      coalesced. Oops.
      The easy fix for this one is that when we save and restore the alias
      list, we exclude temporaries from the copy. The fix is in the
      implementation of copy_block_aliases.
    * There are a couple circumstances in which code transformations call
      block_unalias() to say that a block-local symbol alias is no longer
      valid. The implementation just looks up that alias and removes it from
      the list. EXCEPT... now there is not just one list, but also the ones
      in the outer recursive scope. Oops.
      The fix here is that we keep track of a stack of such scopes, and
      bock_unalias walks up the stack and removes the alias from callers as
    There are a couple minor odds and ends, mostly slight renames and
    comments and clarifications.
Commits on Nov 25, 2015
  1. @lgritz
Commits on Nov 21, 2015
  1. @Nazg-Gul @lgritz
  2. @Nazg-Gul @lgritz

    Make building of OSL plugins optional

    Nazg-Gul committed with lgritz
    Those aren't always needed and might give some extra pain to setup
    building static libraries on Linux due to the -fPIC crazyness.
  3. @Nazg-Gul @lgritz
  4. @Nazg-Gul

    Support OSLQuery from a given bytecode

    Nazg-Gul committed
    This is handy feature to have for applications which has OSL in-memory bytecode
    cache but still needs to run OSLQuery on such shaders without creating temporary
    files on the disk.
    Currently only explicit query.open_bytecode() call is supported, this is because
    it's not really possible to distinguish filepath from memory buffer being passed
    to the constructor.
Commits on Nov 19, 2015
  1. @lgritz

    OSL optimization: much better tracking of basic block aliases.

    lgritz committed
    OSL's runtime optimizer tracks "value aliases" (one variable being set
    to be the same as another, or a constant), such as a=1, b=u. So then in
    subsequent use, if it sees c=a*d, it knows that can simplify to c=d
    (because a==1) and e = b-u can simplify to e=0 (because b and u hold the
    same value).  When a symbol's value is altered, of course the alias is
    removed from the active list. Also, we clear the list when we begin a
    new basic block (any contiguous series of instructions with strictly
    sequential control flow), because we don't know what values are held by
    variables at breaks of control flow.
    However... there are a couple special (but common) cases where we know
    that even though an instruction is the target of a jump and therefore
    the beginning of a new basic block, we need not throw out all the prior
    information we have learned. For example,
        // start of basic block 0
        a = 0;
        if (u < 0.5) {
            // start of basic block 1
            t = a;
        } else {
            // start of basic block 2
            t = u;
        // start of basic block 3
        z = a;
    We can observe that basic blocks 1 and 2 can ONLY run immediately after
    block 0 finishes, and therefore they (each, separately) ought to be able
    to inherit whatever value aliases were known at the end of block 0.
    Also, at the start of block 3, although it cannot be certain what is in
    t (because it was written inside the body of the 'if'), we SHOULD be
    able to still know that 'a', which was not modified by either branch of
    the 'if', should still have the value it started with before the
    And similarly, we can make some deductions about aliases when we descend
    into function calls (remember that all function calls are inlined in OSL,
    though they still look like distinct basic blocks).
    And also loops! Although loops are tricky because they may be entered
    from EITHER the preceding block, or from already having executed the
    loop body, so it's important that the body only be seeded with the prior
    aliases after they have been scrubbed of any aliases involving symbols
    that are modified in the loop.
    Careful tracking of this information turns out to make the value
    alias tracking much more effective, because it doesn't have to throw out
    everything it knows at the start of every new basic block. This provides
    much more information for the runtime optimizer to bring to bear for
    further code simplifications.
    I'm seeing pretty substantial reductions in the number of post-optimized
    instructions and symbols, as reported by the stats. Often this
    translates to improvements in runtime, but is extremely dependent on the
    shaders.  It will never take longer, but sometimes it is not noticeably
    faster.  But for other complex scenes, I'm seeing as much as 10% of
    overall render time improvement! I look forward to hearng how much this
    improves times across a wider range of scenes that people try.
    Just in case I botched this, I've added a global ShadingSystem attribute
    "opt_seed_bblock_aliases" which can be set to 0 to disable this new
    optimization. I hope it won't be needed, but it's there to disable this
    specific feature in cases where we suspect that it's behaving
  2. @lgritz
Commits on Nov 18, 2015
  1. @lgritz

    Merge pull request #584 from lgritz/lg-debugopt

    lgritz committed
    Refactor of optimize_ops and debugging info
Commits on Nov 16, 2015
  1. @lgritz
  2. @lgritz
  3. @lgritz
  4. @lgritz

    Refactor optimize_ops to split out the optimization of assignments into

    lgritz committed
    a separate method, and also slightly different calling of peephole2.
  5. @lgritz

    Refactor debug printing of instance

    lgritz committed
    Remove ShaderInstance::print(), move it to RuntimeOptimizer:printinst(),
    since the only place it was called was by RuntimeOptimizer and I wanted
    to change what it prints in a way that needs some RuntimeOptimizer
    To wit: when it does the debug print of the instructions, have it
    point out which instructions are the heads of new basic blocks.
  6. @lgritz
  7. @lgritz

    Use boost::thread_specific_ptr, don't rely on it in OIIO namespace.

    lgritz committed
    The reason for this is that I want to take the inclusion of boost:tsp
    out of the OIIO thread.h public header file. These are the only places
    in OIIO that we use it.
  8. @lgritz
Commits on Nov 9, 2015
  1. @lgritz
Commits on Nov 4, 2015
  1. @lgritz

    Fix broken test from isconstant

    lgritz committed
  2. @lgritz

    isconstant(expr) returns 1 if the expression can be turned into a con…

    lgritz committed
    at runtime (with full knowledge of the shader group's parameters values and
    This is primarily a debugging aid for advanced shader writers to verify
    their assumptions about what expressions can end up being constant-folded
    by the runtime optimizer. Also an aid for me in debugging that the runtime
    optimizer is behaving as I expect.
  3. @lgritz

    Change error reporting for unknown closures from JIT-time to execute-…

    lgritz committed
    When a closure is referenced that the renderer doesn't know, instead of
    making a JIT-time error as the shader is being compiled, make it a
    shader execution time error if it actually tries to execute the code
    that creates the closure. This helps to prevent spurious errors from
    renderer/shader mismatches, unless the shader actually tries to make
    that closure.
Commits on Nov 3, 2015
  1. @lgritz

    Improve runtime optimizer debugging messages -- include source file/line

    lgritz committed
    Some refactoring to make most of the runtime opt debug messages go
    through a central reporting function, and have that function reference
    the source file and line number. Makes it even easier for me to debug
    deep optimizer issues.
  2. @lgritz

    Improve debugging messages

    lgritz committed
  3. @lgritz
  4. @lgritz
  5. @lgritz
  6. @lgritz
Commits on Oct 30, 2015
  1. @lgritz
  2. @lgritz

    Fix CMakeLists.txt typos for C++11 compilation

    lgritz committed
    Oops, probably happened when copying bits of CMakeLists.txt back and
    forth between OSL and OIIO.
    Fixes #570
Commits on Oct 29, 2015
  1. @lgritz

    linearstep & smooth_linearstep: handle degenerate edge0==edge1 case.

    lgritz committed
    Also add a testsuite that exercises these two new functions, including
    the degenerate cases.
  2. @lgritz

    smooth_linearstep: Ensure that it's as efficient as possible when eps…

    lgritz committed
    … == 0.
    Try to make sure that when eps detected to be constant and 0, it's as
    close as possible to being as efficient as linearstep, by rearranging
    the various clauses of the 'if'.
  3. @lgritz

    Fixes for OIIO 1.5 compatibility.

    lgritz committed
    I'd inadvertently allowed a build break and a possible bug creep into
    OSL 1.7 (dev) that depended on new features of OIIO 1.6 (dev). This
    patch restores OSL trunk so that it will build correctly against the
    stable release branch of OIIO which is currently 1.5.
  4. @lgritz


    lgritz committed
  5. @lgritz


    lgritz committed
Commits on Oct 28, 2015
  1. @lgritz

    Rebuild PDF docs

    lgritz committed
Something went wrong with that request. Please try again.