AcademySoftwareFoundation / MaterialX

MaterialX is an open standard for the exchange of rich material and look-development content across applications and renderers.
http://www.materialx.org/
Apache License 2.0
1.88k stars 355 forks source link

GLSL Struct initialization complicates MSL cross compilation #2098

Open ld-kerley opened 3 weeks ago

ld-kerley commented 3 weeks ago

While looking at getting Masuo's Hextiling PR working #2094 for MSL, I discovered that GLSL and MSL differ in how structs are initialized.

I think its an easy refactor for the Hextiling PR, but noting this difference here, so we can investigate a more robust solution in the future.

Below is the problematic code from Masuo's PR.

HextileData tile_data = HextileData(
        st1, st2, st3,
        vec3(w1, w2, w3),
        trm1, trm2, trm3,
        ddx1, ddx2, ddx3,
        ddy1, ddy2, ddy3
    );

The workaround is to create the object and then initialize each member separately.

HextileData tile_data;

tile_data.coord1 = st1;
... 

But I can imagine cases where this might not be desirable.

msuzuki-nvidia commented 3 weeks ago

I think no issues with the suggested change.

ld-kerley commented 3 weeks ago

Thanks Masuo, for the Hextile PR I think we can roll with the refactor - I just wanted to log the issue here so we can remember to perhaps investigate a more robust solution moving forwards, or at least have the issue here for future people to discover if they need the same work around.