OpenShadingLanguage icon indicating copy to clipboard operation
OpenShadingLanguage copied to clipboard

Allow list initializer as function argument.

Open ld-kerley opened this issue 11 months ago • 1 comments

Problem

Initializer lists are not allowed as function arguments, would be nice if they were, and would possibly simplify some of the MaterialX code base for OSL code generation.

struct vector2
{
    float x;
    float y;
};

void NG_switch_vector2I(vector2 in1, vector2 in2, vector2 in3, output vector2 out)
{
    out = in1;
}

shader test_shader
(
    vector2 input = {1,2},              // this works
    output float out = 0
)
{
    vector2 outVec;
    vector2 in1 = {0,1};                // this works

    NG_switch_vector2I(
        in1,                            // this works
        vector2(0.000000, 0.000000),    // this works
        {0.000000, 0.000000},           // this doesn't work
        outVec);

    out = outVec.x;
}

Expected behavior: I expected this to compile just fine...

Actual behavior: But it didn't... I get the following compile error.

 > oslc test.osl
test.osl:24: error: Cannot construct type 'unknown'
FAILED test.osl

Steps to Reproduce

  1. Compile the shader code above
  2. Get compile error

Versions

  • OSL branch/version: 1.13.8.0
  • OS: MacOS Sequoia
  • C++ compiler:
  • LLVM version: 17.0.6
  • OIIO version: 2.5.9.0

ld-kerley avatar Dec 05 '24 22:12 ld-kerley