Skip to content

Commit e9a78a2

Browse files
sfriedmapixarlgritz
authored andcommitted
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 <[email protected]>
1 parent 2c7c4f2 commit e9a78a2

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/liboslexec/runtimeoptimize.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ static ustring u_setmessage("setmessage");
4242
static ustring u_getmessage("getmessage");
4343
static ustring u_getattribute("getattribute");
4444
static ustring u_backfacing("backfacing");
45+
static ustring u_calculatenormal("calculatenormal");
46+
static ustring u_flipHandedness("flipHandedness");
4547
static ustring u_N("N");
4648
static ustring u_I("I");
4749

@@ -3352,6 +3354,8 @@ RuntimeOptimizer::run()
33523354
} else if (op.opname() == u_backfacing) {
33533355
m_globals_needed.insert(u_N);
33543356
m_globals_needed.insert(u_I);
3357+
} else if (op.opname() == u_calculatenormal) {
3358+
m_globals_needed.insert(u_flipHandedness);
33553359
} else if (op.opname() == u_getattribute) {
33563360
Symbol* sym1 = opargsym(op, 1);
33573361
OSL_DASSERT(sym1 && sym1->typespec().is_string());
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright Contributors to the Open Shading Language project.
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
4+
5+
shader printcalculatenormal ()
6+
{
7+
normal n2 = calculatenormal(P+1);
8+
printf ("calculatenormal = %f", n2);
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Need 2 globals: I N
2+
Need 2 globals: P flipHandedness

testsuite/globals-needed/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
66

77
command += testshade("-g 2 2 -debug printbackfacing")
8+
command += testshade("-g 2 2 -debug printcalculatenormal")
89

910
# debug output is very verbose, use regexp to filter down to
1011
# only the line we're interested in testing

0 commit comments

Comments
 (0)