Reputation: 18178
I've read, that
a single global variable can be declared as an SSBO
and I've tried to declarebuffer vec2 name[];
in a geometry shader (#version 440
). The compilation fails, stating the following:
OpenGL does not allow declaring buffer variable 'name' in the global scope. Use buffer blocks instead.
So, what am I missing?
Upvotes: 1
Views: 299
Reputation: 473174
This appears to be an error in the Wiki due to a change in the specification in an update to GLSL 4.40. That is, the original version of GLSL 4.40 said:
The buffer qualifier can be used with any of the basic data types, or when declaring a variable whose type is a structure, or an array of any of these.
Buffer variables may only be declared inside interface blocks (section 4.3.9 “Interface Blocks”), which are then referred to as shader storage blocks. It is a compile-time error to declare buffer variables at global scope (outside a block). Buffer variables cannot have initializers.
Obviously, that's contradictory. The first paragraph suggests that declaring naked buffer variables is OK. The second paragraph says that buffer variables can only be part of buffer
-qualified interface blocks.
One of the revisions to 4.40 changed it to:
The buffer qualifier can be used to declare interface blocks (section 4.3.9 “Interface Blocks”), which are then referred to as shader storage blocks. It is a compile-time error to declare buffer variables at global scope (outside a block).
So clearly, at one time this was true. The ARB_shader_storage_buffer_object specification still has the old wording. The Wiki simply needs to be updated with the current behavior.
Upvotes: 2
Reputation: 22157
According to the GLSL 4.5 Specification (Section 4.3.7 Buffer Variables):
The buffer qualifier can be used to declare interface blocks (section 4.3.9 “Interface Blocks”), which are then referred to as shader storage blocks. It is a compile-time error to declare buffer variables at global scope (outside a block).
Upvotes: 0