15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_shader_atomic_counters 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_shader_atomic_counters 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciStatus 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Complete 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciVersion 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Last Modified Date: June 23, 2011 205bd8deadSopenharmony_ci NVIDIA Revision: 1 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciNumber 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci 423 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciDependencies 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci ARB_shader_atomic_counters and NV_gpu_program5 are required. 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci This extension is written against the NV_gpu_program4 specification, as 315bd8deadSopenharmony_ci extended by NV_gpu_program5. 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciOverview 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci This extension builds upon the ARB_shader_atomic_counters and 365bd8deadSopenharmony_ci NV_gpu_program5 extensions to provide assembly language support for 375bd8deadSopenharmony_ci incrementing, decrementing, and querying the values of atomic counters 385bd8deadSopenharmony_ci stored in buffer object memory. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci The extension uses the same set of atomic counter buffer binding points as 415bd8deadSopenharmony_ci the ARB_shader_atomic_counters extension; applications using this 425bd8deadSopenharmony_ci extension should use the APIs specified there to bind buffers. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ciNew Procedures and Functions 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci None. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ciNew Tokens 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci None. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci (All modifications are relative to Section 2.X, GPU Programs, from the 555bd8deadSopenharmony_ci NV_gpu_program4 specification.) 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci Modify Section 2.X.2, Program Grammar 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci (add after the long list of grammar rules) If a program specifies the 605bd8deadSopenharmony_ci NV_shader_atomic_counters program option, the following rules are added 615bd8deadSopenharmony_ci to the NV_gpu_program4 base program grammar: 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci <instruction> ::= <AtomCtrInstruction> 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci <AtomCtrInstruction> ::= <ATOMCTRop_instruction> 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci <ATOMCTRop_instuction> ::= <ATOMCTRop> <opModifiers> <instResult> "," 685bd8deadSopenharmony_ci <counterUseV> 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci <ATOMCop> ::= "ATOMCTR" 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci <opModifier> ::= "INCR" 735bd8deadSopenharmony_ci | "DECR" 745bd8deadSopenharmony_ci | "GET" 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci <namingStatement> ::= <COUNTER_statement> 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci <COUNTER_statement> ::= "COUNTER" <establishName> <counterSingleInit> 795bd8deadSopenharmony_ci <COUNTER_statement> ::= "COUNTER" <establishName> <optArraySize> 805bd8deadSopenharmony_ci <counterMultipleInit> 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci <counterSingleInit> ::= <counterUseDS> 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci <counterMultipleInit> ::= "{" <counterItemList> "}" 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci <counterItemList> ::= <counterUseDM> 875bd8deadSopenharmony_ci <counterItemList> ::= <counterUseDM> "," <counterItemList> 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci <counterUseV> ::= <counterVarName> <optArrayMem> 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci <counterUseDS> ::= <counterBufBinding> <arrayMemAbs> 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci <counterUseDM> ::= <counterUseDS> 945bd8deadSopenharmony_ci <counterUseDM> ::= <counterBufBinding> 955bd8deadSopenharmony_ci <counterUseDM> ::= <counterBufBinding> <arrayRange> 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci <counterBufBinding> ::= "program" "." "counter" <arrayMemAbs> 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci Add New Section 2.X.3.Y, Atomic Counter Buffers, after Section 2.X.3.6, 1015bd8deadSopenharmony_ci Program Parameter Buffers 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Atomic counter buffers are arrays consisting of single-component unsigned 1045bd8deadSopenharmony_ci integer values stored in a buffer object. The GL provides an 1055bd8deadSopenharmony_ci implementation-dependent number of atomic counter buffer object binding 1065bd8deadSopenharmony_ci points to which buffer objects can be attached. Atomic counter variables 1075bd8deadSopenharmony_ci can be changed either by updating the contents of bound buffer objects, by 1085bd8deadSopenharmony_ci changing the buffer object attached to a binding point, or by using the 1095bd8deadSopenharmony_ci ATOMCTR instruction in a shader to increment or decrement the current 1105bd8deadSopenharmony_ci value. 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci Atomic counter buffer bindings are established by calling BindBufferBase, 1135bd8deadSopenharmony_ci BindBufferOffsetEXT, or BindBufferRange with a target of 1145bd8deadSopenharmony_ci ATOMIC_COUNTER_BUFFER, as documented in the ARB_shader_atomic_counters 1155bd8deadSopenharmony_ci extension. The number of atomic counter buffer object binding points is 1165bd8deadSopenharmony_ci given by the value of the constant MAX_ATOMIC_COUNTER_BUFFER_BINDINGS. 1175bd8deadSopenharmony_ci There is a limit on the maximum number of words of a buffer object that 1185bd8deadSopenharmony_ci can be accessed using any single parameter buffer binding point, given by 1195bd8deadSopenharmony_ci the implementation-dependent constant MAX_ATOMIC_COUNTER_BUFFER_SIZE. 1205bd8deadSopenharmony_ci Buffer objects larger than this size may be used, but the results of 1215bd8deadSopenharmony_ci accessing portions of the buffer object beyond the limit are undefined. 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci Atomic counter variables may only be used as operands in the ATOMCTR 1245bd8deadSopenharmony_ci instruction; they may not be used by used as results or operands in 1255bd8deadSopenharmony_ci general instructions. Atomic counter variables must be declared 1265bd8deadSopenharmony_ci explicitly via the <COUNTER_statement> grammar rule. Atomic counter 1275bd8deadSopenharmony_ci buffer bindings can not be used directly in executable instructions. 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci Atomic counter variables may be declared as arrays, but all bindings 1305bd8deadSopenharmony_ci assigned to the array must use the same binding point and must increase 1315bd8deadSopenharmony_ci consecutively. 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci Binding Components Underlying State 1345bd8deadSopenharmony_ci ----------------------------- ---------- ----------------------------- 1355bd8deadSopenharmony_ci program.counter[a][b] (x,x,x,x) atomic counter buffer a, 1365bd8deadSopenharmony_ci element b 1375bd8deadSopenharmony_ci program.counter[a][b..c] (x,x,x,x) atomic counter buffer a, 1385bd8deadSopenharmony_ci elements b through c 1395bd8deadSopenharmony_ci program.counter[a] (x,x,x,x) atomic counter buffer a, 1405bd8deadSopenharmony_ci all elements 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci Table X.Y: Atomic Counter Buffer Bindings. <a> indicates a buffer 1435bd8deadSopenharmony_ci number, <b> and <c> indicate individual elements. 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci If an atomic counter buffer binding matches "program.counter[a][b]", the 1465bd8deadSopenharmony_ci atomic counter variable is associated with element <b> of the buffer 1475bd8deadSopenharmony_ci object bound to binding point <a>. If no buffer object is bound to 1485bd8deadSopenharmony_ci binding point <a>, or the bound buffer object is not large enough to hold 1495bd8deadSopenharmony_ci an element <b>, reads from the binding return zero and writes to the 1505bd8deadSopenharmony_ci binding have no effect. The binding point <a> must be a nonnegative 1515bd8deadSopenharmony_ci integer constant. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci For atomic counter array declarations, "program.counter[a][b..c]" is 1545bd8deadSopenharmony_ci equivalent to specifying elements <b> through <c> of the buffer object 1555bd8deadSopenharmony_ci bound to binding point <a> in order. 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci For atomic counter array declarations, "program.counter[a]" is equivalent 1585bd8deadSopenharmony_ci to specifying the entire buffer -- elements 0 through <n>-1, where <n> is 1595bd8deadSopenharmony_ci either the size of the array (if declared) or the implementation-dependent 1605bd8deadSopenharmony_ci maximum atomic counter buffer object size limit (if no size is declared). 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci Modify Section 2.X.4, Program Execution Environment 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci (Add to the set of opcodes in Table X.13) 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci Modifiers 1685bd8deadSopenharmony_ci Instruction F I C S H D Out Inputs Description 1695bd8deadSopenharmony_ci ----------- - - - - - - --- -------- -------------------------------- 1705bd8deadSopenharmony_ci ATOMCTR - X X - - U s - atomic counter operation 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci Modify Section 2.X.4.1, Program Instruction Modifiers 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci (Add to Table X.14, Instruction Modifiers, and to the corresponding 1765bd8deadSopenharmony_ci description following the table) 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci Modifier Description 1795bd8deadSopenharmony_ci -------- ----------------------------------------------- 1805bd8deadSopenharmony_ci INCR Increment an atomic counter variable 1815bd8deadSopenharmony_ci DECR Decrement an atomic counter variable 1825bd8deadSopenharmony_ci GET Query the value of an atomic counter variable 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci For atomic counter instructions, the "INCR", "DECR", and "GET" atomic 1855bd8deadSopenharmony_ci counter instruction modifiers specify an operation to perform on an atomic 1865bd8deadSopenharmony_ci counter variable. Atomic counter instruction modifiers are supported by 1875bd8deadSopenharmony_ci the ATOMCTR instruction and are covered in more detail in the description 1885bd8deadSopenharmony_ci of that instruction. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci Modify Section 2.X.6, Program Options 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci + Atomic Counter Support (NV_shader_atomic_counters) 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci If a program specifies the "NV_shader_atomic_counters" option, it may use 1955bd8deadSopenharmony_ci the COUNTER statement to declare atomic counter variables and the ATOMCTR 1965bd8deadSopenharmony_ci instruction to increment, decrement, or query the values of atomic counter 1975bd8deadSopenharmony_ci variables. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci Modify Section 2.X.8, Program Instruction Set 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci Section 2.X.8.Z, ATOMCTR: Atomic Counter Operation 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci The ATOMCTR instruction performs an atomic global counter operation by 2055bd8deadSopenharmony_ci reading from memory corresponding to the atomic counter variable specified 2065bd8deadSopenharmony_ci in the instruction, optionally modifying that memory, and then returning 2075bd8deadSopenharmony_ci an scalar unsigned integer result. The memory transaction is atomic, 2085bd8deadSopenharmony_ci guaranteeing that no other write to the memory accessed will occur between 2095bd8deadSopenharmony_ci the time it is read and written by the ATOMCTR instruction. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci The ATOMCTR instruction requires an atomic counter instruction modifier, 2125bd8deadSopenharmony_ci as enumerated in Table X.Y. The instruction modifier specifies the type 2135bd8deadSopenharmony_ci of operation to perform. 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci atomic 2165bd8deadSopenharmony_ci modifier operation 2175bd8deadSopenharmony_ci -------- ------------------------------------------------- 2185bd8deadSopenharmony_ci INCR increment counter (returns non-incremented value) 2195bd8deadSopenharmony_ci DECR decrement counter (returns decremented value) 2205bd8deadSopenharmony_ci GET query counter 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ci Table X.Y, Supported atomic and storage modifiers for the ATOM 2235bd8deadSopenharmony_ci instruction. 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci ATOMCTR performs a scalar atomic operation and returns an atomic counter 2265bd8deadSopenharmony_ci value in the <x> component of the result vector. The <y>, <z>, and <w> 2275bd8deadSopenharmony_ci components of the result vector are undefined. 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci address = AtomicCounterAddress(op0); 2305bd8deadSopenharmony_ci result = BufferMemoryLoad(address, U32); 2315bd8deadSopenharmony_ci switch (atomicModifier) { 2325bd8deadSopenharmony_ci case INCR: 2335bd8deadSopenharmony_ci writeval = result + 1; 2345bd8deadSopenharmony_ci break; 2355bd8deadSopenharmony_ci case DECR: 2365bd8deadSopenharmony_ci writeval = result - 1; 2375bd8deadSopenharmony_ci result = writeval; // return decremented value 2385bd8deadSopenharmony_ci break; 2395bd8deadSopenharmony_ci case GET: 2405bd8deadSopenharmony_ci return result; // no memory store 2415bd8deadSopenharmony_ci BufferMemoryStore(address, writeval, U32); 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ci If an incremented or decremented counter value overflows the representable 2445bd8deadSopenharmony_ci range of counter values, it will wrap. 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci ATOMCTR supports only signed and unsigned integer data type modifiers, but 2475bd8deadSopenharmony_ci no storage modifers. The memory holding the atomic counter and the result 2485bd8deadSopenharmony_ci vector are treated as scalar signed or unsigned integers, according to the 2495bd8deadSopenharmony_ci data type modifier. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci None. 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 2575bd8deadSopenharmony_ciOperations and the Frame Buffer) 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci None. 2605bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions) 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ci None. 2635bd8deadSopenharmony_ci 2645bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.0 Specification (State and 2655bd8deadSopenharmony_ciState Requests) 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci None. 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 2.0 Specification (Invariance) 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ci None. 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci None. 2765bd8deadSopenharmony_ci 2775bd8deadSopenharmony_ciErrors 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci None. 2805bd8deadSopenharmony_ci 2815bd8deadSopenharmony_ciNew State 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ci None. 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ciNew Implementation Dependent State 2865bd8deadSopenharmony_ci 2875bd8deadSopenharmony_ci None. 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ciIssues 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci (1) Should this extension have its own extension string entry, or should 2925bd8deadSopenharmony_ci its existence be implied by the presence of the 2935bd8deadSopenharmony_ci ARB_shader_atomic_counters and NV_gpu_program5 extensions? 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci RESOLVED: Provide a separate extension string entry. 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ciRevision History 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci Rev. Date Author Changes 3005bd8deadSopenharmony_ci ---- --------- -------- -------------------------------------------- 3015bd8deadSopenharmony_ci 1 20-Jun-11 pbrown Internal spec development. 302