AcademySoftwareFoundation / OpenShadingLanguage

Advanced shading language for production GI renderers
BSD 3-Clause "New" or "Revised" License
2.05k stars 347 forks source link

PR/FixCompRefWithVaryingIndex #1776

Closed AlexMWells closed 4 months ago

AlexMWells commented 4 months ago

Description

Fix bug in batched codegen of compref when the index is varying. The llvm_load_value 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 BatchedAnalysis where a early out (return) needs to change the loop 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).

Tests

Added nestloop-reg to testsuite to reproduce bug and verify its fixed.

Checklist: