Cannot assign to gl_Layer without complie error

Not sure which board this go on, but here is the problem:

I’m getting the complier error:
error(#160) Cannot convert between ‘unknown qualifier array of float’ to ‘default varying array of float’

The extact line of code that is causing the problem is

in float vInstance[3];

gl_Layer = int(vInstance[0]);

This code has no problems running on various Intel cards on Win7 and ipad

Where this started being a problem is on a Integrated AMD Radeon HD 6310 card on a Win7 machine.

The processor on the offending machine is: 1.6 GHz AMD eOntario T56N Dual Core APU

Thank you

in float vInstance[3];

Shouldn’t that be rather than [3]? I don’t think that geometry shader inputs are statically sized arrays (even though they have a size based on the static input type). At least, not for 3.2 core geometry shaders.

I haven’t had any problems with it in the past, and chaning it from [3] to [] just now didn’t do anything.

Could you please paste out the whole shader? I can’t get the compiler error when running it on win7-32bit + Ontario + Cat11.4. The geometry shader is designed as,

#version 400

layout (triangles) in;
layout (triangle_strip, max_vertices=100) out;

in float v[3];

void main(void)
{
for (int iii = 0; iii < gl_VerticesIn; iii++)
{
gl_Position = gl_in[iii].gl_Position;
EmitVertex();
gl_Layer = int(v[0]);
}
EndPrimitive();
}

and just to make sure it is clear, Catalyst 11.4 is being used.

#version 400

layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;

in float vInstance[3];

void main()
{
gl_Layer = int(vInstance[0]);

gl_ClipDistance = gl_in[0].gl_ClipDistance;
gl_Position = gl_in[0].gl_Position;
EmitVertex();

gl_ClipDistance = gl_in[1].gl_ClipDistance;
gl_Position = gl_in[1].gl_Position;
EmitVertex();

gl_ClipDistance = gl_in[2].gl_ClipDistance;
gl_Position = gl_in[2].gl_Position;
EmitVertex();
EndPrimitive();

}

error(#160) Cannot convert between ‘unknown qualifier array of float’ to ‘default varying array of float’

gl_ClipDistance (both the input and the output version) is an array. You cannot copy an array using the “=” operator. You must copy each element individually.

That was it!

I guess on nVidia cards if you don’t specify the index it’ll just use index 0.

Thanks!

The array assignment operation is allowed in the GLSL spec. I think it’s a bug in AMD driver. As a workaround, you could copy each elements instead.

Can you cite spec on this one?

I can:

Emphasis added. So apparently you can assign entire arrays in GLSL.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.