fix: calculatenormal needs fliphandedness (#1783)
* Have OSL indicate when it needs fliphandedness in shader globals. * Add testsuite test to check that calculatenormal() triggers a globals_needed flipHandedness value. --------- Signed-off-by: Stephen Friedman <sfriedma@pixar.com>
This commit is contained in:
@@ -42,6 +42,8 @@ static ustring u_setmessage("setmessage");
|
||||
static ustring u_getmessage("getmessage");
|
||||
static ustring u_getattribute("getattribute");
|
||||
static ustring u_backfacing("backfacing");
|
||||
static ustring u_calculatenormal("calculatenormal");
|
||||
static ustring u_flipHandedness("flipHandedness");
|
||||
static ustring u_N("N");
|
||||
static ustring u_I("I");
|
||||
|
||||
@@ -3352,6 +3354,8 @@ RuntimeOptimizer::run()
|
||||
} else if (op.opname() == u_backfacing) {
|
||||
m_globals_needed.insert(u_N);
|
||||
m_globals_needed.insert(u_I);
|
||||
} else if (op.opname() == u_calculatenormal) {
|
||||
m_globals_needed.insert(u_flipHandedness);
|
||||
} else if (op.opname() == u_getattribute) {
|
||||
Symbol* sym1 = opargsym(op, 1);
|
||||
OSL_DASSERT(sym1 && sym1->typespec().is_string());
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright Contributors to the Open Shading Language project.
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
shader printcalculatenormal ()
|
||||
{
|
||||
normal n2 = calculatenormal(P+1);
|
||||
printf ("calculatenormal = %f", n2);
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
Need 2 globals: I N
|
||||
Need 2 globals: P flipHandedness
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
|
||||
|
||||
command += testshade("-g 2 2 -debug printbackfacing")
|
||||
command += testshade("-g 2 2 -debug printcalculatenormal")
|
||||
|
||||
# debug output is very verbose, use regexp to filter down to
|
||||
# only the line we're interested in testing
|
||||
|
||||
Reference in New Issue
Block a user