<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>1. Is it ok to declare an unsized array in an interface block? In other words, is this ok?<br>
<br></div> out blk {<br></div> vec4 foo[];<br> };<br><br></div>The nVidia Linux driver allows this, but Mesa currently doesn't. AFAICT the spec says it's ok. In fact, the spec defines the built-in interface block gl_PerVertex this way:<br>
<br></div><div> out gl_PerVertex {<br></div><div> vec4 gl_Position;<br></div><div> float gl_PointSize;<br></div><div> float gl_ClipDistance[];<br> };<br><br></div><div>So it seems like it ought to be allowed for user-defined interface blocks too.<br>
</div><div><br></div>2. If you declare an unsized array in an interface block, is it legal to redeclare that interface block later and specify an array size? E.g.:<br><br></div><div> out blk {<br></div><div> vec4 foo[];<br>
};<br></div><div> out blk {<br></div><div> vec4 foo[2];<br> };<br><br></div><div>I can't find any text in the spec saying whether this is allowed, but it seems reasonable that if the answer to question 1 is yes, then this should be allowed too, since it's parallel to what's allowed outside of interface blocks.<br>
</div><div><br>3. How about redeclaring a named interface block and specifying a size?<br><br></div> out blk {<br></div> vec4 foo[];<br></div><div> } ifc_name;<br></div> out blk {<br></div> vec4 foo[2];<br>
</div> } ifc_name;<br><br></div>It seems to me that this should have the same answer as question 2, but nVidia disallows this (it gives a compile error: declaration of "ifc_name" conflicts with previous declaration at ...).<br>
<br></div>4. How about if you redeclare an interface block that has some arrays and some non-arrays? E.g.:<br><br></div> out blk {<br></div> vec4 foo[];<br></div> vec4 bar;<br> };<br></div> out blk {<br>
</div> vec4 foo[2];<br></div> vec4 bar;<br> };<br><br></div>It seems to me that this should also have the same answer as question 2, but nVidia rejects this with a compile error too (declaration of "bar" conflicts with previous declaration at ...).<br>
<br></div>5. How about if you redeclare an interface block and give it different members? E.g.:<br><br></div> out blk {<br></div> vec4 foo[];<br></div> vec4 bar;<br> };<br></div> out blk {<br></div>
vec3 baz;<br> };<br><br></div>This seems like it should definitely give an error, since the spec says "Matched block names within an interface ... must match in terms of having the same number of declarations with the same sequence of types and the same sequence of member names, as well as having the same member-wise layout qualification ...".<br>
<br></div>But the nVidia driver allows this.<br><br><br></div>I'm baffled as to what behaviour I should implement in Mesa. At the very least I'm pretty sure I have to allow gl_PerVertex to be redeclared, since (a) that's the only way to give the gl_ClipDistance input a size in a geometry shader, and (b) redeclaring gl_PerVertex is explicitly permitted by GLSL 4.10 section 7.1.1 (and I'm pretty sure the text there is meant as a clarification, rather than a new rule).<br>
<br>But for anything beyond that, the spec seems open to interpretation. And I don't feel like I can use nVidia's implementation for guidance, because of the inconsistencies and non-compliant behaviour I noted above.<br>
<br></div>Any thoughts?<br></div>