PDA

View Full Version : Cannot assign to gl_Layer without complie error



tamato
05-04-2011, 02:17 PM
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

Alfonse Reinheart
05-04-2011, 02:25 PM
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.

tamato
05-04-2011, 02:30 PM
I haven't had any problems with it in the past, and chaning it from [3] to [] just now didn't do anything.

frank li
05-05-2011, 12:06 AM
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();
}

tamato
05-05-2011, 09:42 AM
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();
}

Alfonse Reinheart
05-05-2011, 01:41 PM
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.

tamato
05-05-2011, 04:44 PM
That was it!

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

Thanks!

frank li
05-05-2011, 06:50 PM
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.

kyle_
05-06-2011, 04:27 AM
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?

Alfonse Reinheart
05-06-2011, 05:50 AM
I can:


L-values must be writable. Variables that are built-in types, entire structures or arrays, structure fields, l-values with the field selector ( . ) applied to select components or swizzles without repeated fields, l-values within parentheses, and l-values dereferenced with the array subscript operator ( [ ] ) are all l-values.

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