OCIOv2 with OSL native support, part III


Patrick Hodoul
 

HI,

That's again the OCIOv2 generating an OSL shader code related topic. Now I currently implement the corresponding OSL unit test framework in OCIO, and unfortunately I face some execution problems.

To have some context, the OSL shader declaration is:
shader OSL_OCIOMain(color4 inColor = {color(0), 1}, output color4 outColor = {color(0), 1})

And my framework mainly copies & pastes the [osl]/testsuite/example-deformer/osldeformer.cpp unit test.

The output parameter declaration is causing some trouble. The code snippet is:
<...>
OSL::SymLocationDesc outputs("layer1.outColor", OIIO::TypeFloat4, false,
                                 OSL::SymArena::Outputs,
                                 0 /* output arena offset of "out" */,
                                 sizeof(OSL::Vec4) /* point to point stride */);
    shadsys->add_symlocs(mygroup.get(), outputs);
<...>
    shadsys->optimize_group(mygroup.get(), ctx);
    const OSL::ShaderSymbol * outsym
        = shadsys->find_symbol(*mygroup.get(), OSL::ustring("layer1"), OSL::ustring("outColor"));
When the unit test runs, "shadsys->optimize_group()" generates the following outputs (from llvm_instance.cpp:1138):

No output copy for struct vector4 outColor because of type mismatch vs symloc=float4

There is a mismatch between the OSL C++ declaration and the OSL shader declaration (structure vs. type). As I used the 'color4' for the input and output variables of the shader, I found nothing equivalent in OSL C++ & OIIO C++ types so, I switched to OIIO::TypeFloat4 and OSL::Vec4. But that's clearly not the right choice.

What should be the declared types (for C++ OSL & OIIO) to match the shader 'color4' type (which is a structure containing a color and a float) ?

Thanks,
Patrick

Join osl-dev@lists.aswf.io to automatically receive all group messages.