OpenShadingLanguage icon indicating copy to clipboard operation
OpenShadingLanguage copied to clipboard

Remove direct access to ShaderGlobals members from llvm_ops

Open lgritz opened this issue 3 years ago • 1 comments

This is a stepping stone to "shader globals placement".

Turns out that there were only two functions in llvm_ops.cpp that directly needed to know the layout of the ShaderGlobals struct: the implementations of osl_calculatenormal, and osl_raytype_bit.

For osl_calculatenormal, just pass the flipHandedness flag directly, instead of the ShaderGlobals ptr, from which the field was extracted.

For osl_raytype_bit, I changed the function to only retrieve the bit corresponding to a raytype name (and it's not in llvm_ops any more), and the "bitwise and" code is just directly generated as bitcode.

I managed to complete the batched shading implementation of calculatenormal! But for batched raytype_bit, I handled the case with a constant name, but for the unknown name I got a little confused and I'm hoping Alex can bail me out with some hand-holding or tell me what needs to be done exactly.

Signed-off-by: Larry Gritz [email protected]

lgritz avatar Sep 28 '21 03:09 lgritz

LGTM for the scalar path.

fpsunflower avatar Sep 28 '21 04:09 fpsunflower