forked from AcademySoftwareFoundation/OpenShadingLanguage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(batched): codegen bug for compref with varying index (AcademySoft…
…wareFoundation#1776) Fix bug in batched codegen of compref when the index is varying. The loadvalue was left to defaulted to uniform load, which we can't store into a varying/wide result. Fixed similar bug in getmessage, and added check for spline knotcount to be uniform (although varying support could be added). This bug exposed a missed optimization in BatchedAnalyser where a early out (return) needs to change the conditional to be varying to support masking. However no check was being done to see if the loop control existed higher in the callstack. So now the execution scope tracks loop nesting depth to see if the current function is really in a loop or not. This allows the loop control flow to remain uniform (avoiding masking and more complex control flow). Added nestloop-reg to testsuite to reproduce bug and verify its fixed. --------- Signed-off-by: Alex M. Wells <[email protected]>
- Loading branch information
1 parent
58aec3d
commit baa9a09
Showing
6 changed files
with
140 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright Contributors to the Open Shading Language project. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
|
||
############################### | ||
# | ||
############################### | ||
command += testshade("-t 1 -g 32 32 -od uint8 test -o cout out.tif ") | ||
outputs.append ("out.tif") | ||
|
||
# expect a few LSB failures | ||
failthresh = 0.008 | ||
failpercent = 3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright Contributors to the Open Shading Language project. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
float limit_early_return(float channel) { | ||
if (channel > 1.0) { | ||
//exit(); | ||
return 1.0; | ||
} | ||
return channel; | ||
} | ||
|
||
float limit_single_return(float channel) { | ||
float result = channel; | ||
if (channel > 1.0) { | ||
result = 1.0; | ||
} | ||
return result; | ||
} | ||
|
||
color soft_clip(color in_color) | ||
{ | ||
color result; | ||
for (int i=0; i < 3; ++i) | ||
{ | ||
#if 1 | ||
result[i] = limit_early_return(in_color[i]); | ||
#else | ||
result[i] = limit_single_return(in_color[i]); | ||
#endif | ||
} | ||
return result; | ||
} | ||
|
||
shader test (output color cout = 0) | ||
{ | ||
color pixel = 2*P; | ||
cout = soft_clip(pixel); | ||
} |