• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    NV_shader_atomic_counters
4
5Name Strings
6
7    GL_NV_shader_atomic_counters
8
9Contact
10
11    Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com)
12
13Status
14
15    Complete
16
17Version
18
19    Last Modified Date:         June 23, 2011
20    NVIDIA Revision:            1
21
22Number
23
24    423
25
26Dependencies
27
28    ARB_shader_atomic_counters and NV_gpu_program5 are required.
29
30    This extension is written against the NV_gpu_program4 specification, as
31    extended by NV_gpu_program5.
32
33Overview
34
35    This extension builds upon the ARB_shader_atomic_counters and
36    NV_gpu_program5 extensions to provide assembly language support for
37    incrementing, decrementing, and querying the values of atomic counters
38    stored in buffer object memory.
39
40    The extension uses the same set of atomic counter buffer binding points as
41    the ARB_shader_atomic_counters extension; applications using this
42    extension should use the APIs specified there to bind buffers.
43
44New Procedures and Functions
45
46    None.
47
48New Tokens
49
50    None.
51
52Additions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation)
53
54    (All modifications are relative to Section 2.X, GPU Programs, from the
55     NV_gpu_program4 specification.)
56
57    Modify Section 2.X.2, Program Grammar
58
59    (add after the long list of grammar rules) If a program specifies the
60    NV_shader_atomic_counters program option, the following rules are added
61    to the NV_gpu_program4 base program grammar:
62
63    <instruction>           ::= <AtomCtrInstruction>
64
65    <AtomCtrInstruction>    ::= <ATOMCTRop_instruction>
66
67    <ATOMCTRop_instuction>  ::= <ATOMCTRop> <opModifiers> <instResult> ","
68                                  <counterUseV>
69
70    <ATOMCop>               ::= "ATOMCTR"
71
72    <opModifier>            ::= "INCR"
73                              | "DECR"
74                              | "GET"
75
76    <namingStatement>       ::= <COUNTER_statement>
77
78    <COUNTER_statement>     ::= "COUNTER" <establishName> <counterSingleInit>
79    <COUNTER_statement>     ::= "COUNTER" <establishName> <optArraySize>
80                                  <counterMultipleInit>
81
82    <counterSingleInit>     ::= <counterUseDS>
83
84    <counterMultipleInit>   ::= "{" <counterItemList> "}"
85
86    <counterItemList>       ::= <counterUseDM>
87    <counterItemList>       ::= <counterUseDM> "," <counterItemList>
88
89    <counterUseV>           ::= <counterVarName> <optArrayMem>
90
91    <counterUseDS>          ::= <counterBufBinding> <arrayMemAbs>
92
93    <counterUseDM>          ::= <counterUseDS>
94    <counterUseDM>          ::= <counterBufBinding>
95    <counterUseDM>          ::= <counterBufBinding> <arrayRange>
96
97    <counterBufBinding>     ::= "program" "." "counter" <arrayMemAbs>
98
99
100    Add New Section 2.X.3.Y, Atomic Counter Buffers, after Section 2.X.3.6,
101    Program Parameter Buffers
102
103    Atomic counter buffers are arrays consisting of single-component unsigned
104    integer values stored in a buffer object.  The GL provides an
105    implementation-dependent number of atomic counter buffer object binding
106    points to which buffer objects can be attached.  Atomic counter variables
107    can be changed either by updating the contents of bound buffer objects, by
108    changing the buffer object attached to a binding point, or by using the
109    ATOMCTR instruction in a shader to increment or decrement the current
110    value.
111
112    Atomic counter buffer bindings are established by calling BindBufferBase,
113    BindBufferOffsetEXT, or BindBufferRange with a target of
114    ATOMIC_COUNTER_BUFFER, as documented in the ARB_shader_atomic_counters
115    extension.  The number of atomic counter buffer object binding points is
116    given by the value of the constant MAX_ATOMIC_COUNTER_BUFFER_BINDINGS.
117    There is a limit on the maximum number of words of a buffer object that
118    can be accessed using any single parameter buffer binding point, given by
119    the implementation-dependent constant MAX_ATOMIC_COUNTER_BUFFER_SIZE.
120    Buffer objects larger than this size may be used, but the results of
121    accessing portions of the buffer object beyond the limit are undefined.
122
123    Atomic counter variables may only be used as operands in the ATOMCTR
124    instruction; they may not be used by used as results or operands in
125    general instructions.  Atomic counter variables must be declared
126    explicitly via the <COUNTER_statement> grammar rule.  Atomic counter
127    buffer bindings can not be used directly in executable instructions.
128
129    Atomic counter variables may be declared as arrays, but all bindings
130    assigned to the array must use the same binding point and must increase
131    consecutively.
132
133      Binding                        Components  Underlying State
134      -----------------------------  ----------  -----------------------------
135      program.counter[a][b]          (x,x,x,x)   atomic counter buffer a,
136                                                   element b
137      program.counter[a][b..c]        (x,x,x,x)  atomic counter buffer a,
138                                                   elements b through c
139      program.counter[a]              (x,x,x,x)  atomic counter buffer a,
140                                                   all elements
141
142      Table X.Y: Atomic Counter Buffer Bindings.  <a> indicates a buffer
143      number, <b> and <c> indicate individual elements.
144
145    If an atomic counter buffer binding matches "program.counter[a][b]", the
146    atomic counter variable is associated with element <b> of the buffer
147    object bound to binding point <a>.  If no buffer object is bound to
148    binding point <a>, or the bound buffer object is not large enough to hold
149    an element <b>, reads from the binding return zero and writes to the
150    binding have no effect.  The binding point <a> must be a nonnegative
151    integer constant.
152
153    For atomic counter array declarations, "program.counter[a][b..c]" is
154    equivalent to specifying elements <b> through <c> of the buffer object
155    bound to binding point <a> in order.
156
157    For atomic counter array declarations, "program.counter[a]" is equivalent
158    to specifying the entire buffer -- elements 0 through <n>-1, where <n> is
159    either the size of the array (if declared) or the implementation-dependent
160    maximum atomic counter buffer object size limit (if no size is declared).
161
162
163    Modify Section 2.X.4, Program Execution Environment
164
165    (Add to the set of opcodes in Table X.13)
166
167                  Modifiers
168      Instruction F I C S H D  Out Inputs    Description
169      ----------- - - - - - -  --- --------  --------------------------------
170      ATOMCTR     - X X - - U  s   -         atomic counter operation
171
172
173    Modify Section 2.X.4.1, Program Instruction Modifiers
174
175    (Add to Table X.14, Instruction Modifiers, and to the corresponding
176    description following the table)
177
178      Modifier  Description
179      --------  -----------------------------------------------
180      INCR      Increment an atomic counter variable
181      DECR      Decrement an atomic counter variable
182      GET       Query the value of an atomic counter variable
183
184    For atomic counter instructions, the "INCR", "DECR", and "GET" atomic
185    counter instruction modifiers specify an operation to perform on an atomic
186    counter variable.  Atomic counter instruction modifiers are supported by
187    the ATOMCTR instruction and are covered in more detail in the description
188    of that instruction.
189
190    Modify Section 2.X.6, Program Options
191
192    + Atomic Counter Support (NV_shader_atomic_counters)
193
194    If a program specifies the "NV_shader_atomic_counters" option, it may use
195    the COUNTER statement to declare atomic counter variables and the ATOMCTR
196    instruction to increment, decrement, or query the values of atomic counter
197    variables.
198
199
200    Modify Section 2.X.8, Program Instruction Set
201
202    Section 2.X.8.Z, ATOMCTR:  Atomic Counter Operation
203
204    The ATOMCTR instruction performs an atomic global counter operation by
205    reading from memory corresponding to the atomic counter variable specified
206    in the instruction, optionally modifying that memory, and then returning
207    an scalar unsigned integer result.  The memory transaction is atomic,
208    guaranteeing that no other write to the memory accessed will occur between
209    the time it is read and written by the ATOMCTR instruction.
210
211    The ATOMCTR instruction requires an atomic counter instruction modifier,
212    as enumerated in Table X.Y.  The instruction modifier specifies the type
213    of operation to perform.
214
215      atomic
216      modifier   operation
217      --------   -------------------------------------------------
218       INCR      increment counter (returns non-incremented value)
219       DECR      decrement counter (returns decremented value)
220       GET       query counter
221
222     Table X.Y, Supported atomic and storage modifiers for the ATOM
223     instruction.
224
225    ATOMCTR performs a scalar atomic operation and returns an atomic counter
226    value in the <x> component of the result vector.  The <y>, <z>, and <w>
227    components of the result vector are undefined.
228
229      address = AtomicCounterAddress(op0);
230      result = BufferMemoryLoad(address, U32);
231      switch (atomicModifier) {
232      case INCR:
233        writeval = result + 1;
234        break;
235      case DECR:
236        writeval = result - 1;
237        result = writeval;   // return decremented value
238        break;
239      case GET:
240        return result;  // no memory store
241      BufferMemoryStore(address, writeval, U32);
242
243    If an incremented or decremented counter value overflows the representable
244    range of counter values, it will wrap.
245
246    ATOMCTR supports only signed and unsigned integer data type modifiers, but
247    no storage modifers.  The memory holding the atomic counter and the result
248    vector are treated as scalar signed or unsigned integers, according to the
249    data type modifier.
250
251
252Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization)
253
254    None.
255
256Additions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment
257Operations and the Frame Buffer)
258
259    None.
260Additions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions)
261
262    None.
263
264Additions to Chapter 6 of the OpenGL 2.0 Specification (State and
265State Requests)
266
267    None.
268
269Additions to Appendix A of the OpenGL 2.0 Specification (Invariance)
270
271    None.
272
273Additions to the AGL/GLX/WGL Specifications
274
275    None.
276
277Errors
278
279    None.
280
281New State
282
283    None.
284
285New Implementation Dependent State
286
287    None.
288
289Issues
290
291    (1) Should this extension have its own extension string entry, or should
292        its existence be implied by the presence of the
293        ARB_shader_atomic_counters and NV_gpu_program5 extensions?
294
295      RESOLVED:  Provide a separate extension string entry.
296
297Revision History
298
299    Rev.    Date    Author    Changes
300    ----  --------- --------  --------------------------------------------
301     1    20-Jun-11 pbrown    Internal spec development.
302