error: array of struct are not allowed as parameters

50 views
Skip to first unread message

Master Zap

unread,
Mar 10, 2020, 5:06:12 PM3/10/20
to OSL Developers
I'm trying to make an input that is an array of vector2 .... is that not possible?

I get the error "" but I was pretty sure this was supposed to work.

Someone (you) told me that actually, parameters of type "array of struct is implemented as struct of arrays"... but this error message seems to tell me it isn't possible at all ?

Guidance, sir?

/Z

Larry Gritz

unread,
Mar 10, 2020, 5:12:15 PM3/10/20
to OSL Developers List
Pretty sure you can have array of struct. But not arrays of structs that themselves contain arrays.

But that doesn't mean there isn't a bug somewhere...
--
Larry Gritz




Master Zap

unread,
Mar 10, 2020, 5:17:01 PM3/10/20
to OSL Developers
Lol, error message is in the subject line

Zap Andersson

unread,
Mar 10, 2020, 5:51:40 PM3/10/20
to osl...@googlegroups.com
I'm trying to have a struct of vector2, but can't figure out a syntax for the default?

#include <vector2.h>
shader blah (
      vector2 foo[] = { { 0.0, 0.0 } }    
)
{}

...yields above error?

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osl-dev/3DAEBE15-0E22-4DD7-BD60-6704936E89AE%40larrygritz.com.


--
--
Håkan "Zap" Andersson - http://twitter.com/MasterZap - the man, the myth, the concept.
--

Larry Gritz

unread,
Mar 12, 2020, 3:27:45 AM3/12/20
to OSL Developers List
Hmmm...

you are right, I get (in master):

blah.osl:3: error: array of struct are not allowed as parameters

Inside the body of the shader (if I give the array a definite length), it seems ok.

TBH, I need to look at the code and probably dig through past emails. I'm not entirely sure if this is unintentional (some kind of bug) or if there was a reason that parameters, but not ordinary variables, should not allow this. It surprises me seeing it now -- mostly because this seems like a common thing to try and I'm surprised nobody has noticed until now -- but on the other hand, maybe in my old age I'm just forgetting why this was an important limitation.

I'll try to have a better answer for you within a couple days.

-- lg


Larry Gritz

unread,
Mar 20, 2020, 8:23:03 PM3/20/20
to OSL Developers List
AHA!!

Finally was able to repro. Only if I build with USE_LLVM_BITCODE=0 (this is the default for windows, but not for Linux/OSX).

Should be all downhill from here, stay tuned.

-- lg


Larry Gritz

unread,
Mar 21, 2020, 5:43:38 PM3/21/20
to OSL Developers List
Sorry, I replied to the wrong thread!

I have fixed the 'fmod' problem, still working on this struct one. So sorry for the mixup.


Reply all
Reply to author
Forward
0 new messages