vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
547 stars 90 forks source link

Asymptote 2.71 ERROR: 0:12: 'array without size' : supported in geometry shaders only #284

Closed justonlyasy closed 2 years ago

justonlyasy commented 2 years ago

When I compile any 3D asy code with the command asy -f pdf <name>.asy, I get the error following:

ERROR: 0:12: 'array without size' :  supported in geometry shaders only  
ERROR: 0:17: 'array without size' :  supported in geometry shaders only  

◦
GL Compile error
1: #version 400
2: #extension GL_ARB_uniform_buffer_object : enable
3: #extension GL_ARB_shader_storage_buffer_object : enable
4: #extension GL_ARB_compute_shader : enable
5: layout(local_size_x=1) in;
6: 
7: uniform uint elements;
8: 
9: layout(binding=0, std430) buffer sumBuffer
10: {
11:   uint sum[];
12: };
13: 
14: layout(binding=1, std430) buffer offsetBuffer
15: {
16:   uint offset[];
17: };
18: 
19: uint ceilquotient(uint a, uint b)
20: {
21:   return (a+b-1u)/b;
22: }
23: 
24: void main(void)
25: {
26:   uint id=gl_GlobalInvocationID.x;
27: 
28:   uint m=ceilquotient(elements,gl_NumWorkGroups.x);
29:   uint row=m*id;
30:   uint col=min(m,elements-row);
31:   uint stop=row+col;
32: 
33:   uint Sum=offset[row];
34:   for(uint i=row+1u; i < stop; ++i)
35:     Sum += offset[i];
36: 
37:   sum[id]=Sum;
38: }

Please let me know the reason of this. Thanks.

johncbowman commented 2 years ago

Your GPU or driver apparently lacks compute shaders (this requires GLSL 4.30 or later, released back in 2013).

What platform and OS are you running on and what GPU do you have?

This should have been automatically detected at compilation time, but maybe you are using a prebuilt binary?

In the meantime you can do the partial sum indexing on the CPU by adding the -noGPUindexing option to the command line. Let me know if this solves the issue.

Or you could try updating your graphics drivers to something more recent.

justonlyasy commented 2 years ago

With new release 2.73, I get a new different error:

ERROR: 0:6: 'array without size' :  supported in geometry shaders only  

◦
GL Compile error
1: #version 400
2: #extension GL_ARB_uniform_buffer_object : enable
3: #extension GL_ARB_shader_storage_buffer_object : enable
4: layout(binding=2, std430) buffer countBuffer {
5:   uint count[];
6: };
7: 
8: uniform uint width;
9: 
10: void main()
11: {
12:   atomicAdd(count[uint(gl_FragCoord.y)*width+uint(gl_FragCoord.x)],1u);
13:   discard;
14: }

All examples with 2.70 work normally.

johncbowman commented 2 years ago

That means, in addition to lacking compute shaders you lack Shader Storage Buffer Objects (SSBOs), also introduced in GLSL 4.30 in 2013. In the next release, we'll try to detect such legacy OpenGL environments, so that transparency will be (incorrectly) handled like it was in version 2.70, in WebGL, and under Mac OS X. But you can likely solve both issues by upgrading your graphics drivers (unless you are using very old hardware too).

johncbowman commented 2 years ago

Followup: legacy OpenGL environments are now detected in commit 19d0bce77ac7772d341577ccb26519708caff7e1, and the upcoming 2.74 release.