1Name 2 3 NV_shader_atomic_float 4 5Name Strings 6 7 GL_NV_shader_atomic_float 8 9Contact 10 11 Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 12 13Contributors 14 15 Cyril Crassin, NVIDIA 16 Eric Werness, NVIDIA 17 Jeff Bolz, NVIDIA 18 19Status 20 21 Shipping 22 23Version 24 25 Last Modified Date: August 13, 2012 26 NVIDIA Revision: 2 27 28Number 29 30 419 31 32Dependencies 33 34 This extension is written against the OpenGL 4.2 (Compatibility Profile) 35 Specification. 36 37 This extension is written against version 4.20 (revision 6) of the OpenGL 38 Shading Language Specification. 39 40 This extension interacts with EXT_shader_image_load_store, 41 ARB_shader_image_load_store, and GLSL 4.20. 42 43 This extension interacts with NV_shader_buffer_store and NV_gpu_shader5. 44 45 This extension interacts with NV_gpu_program5. 46 47 This extension interacts with EXT_shader_image_load_store and 48 NV_gpu_program5. 49 50 This extension interacts with GLSL 4.30, ARB_shader_storage_buffer_object, 51 and ARB_compute_shader. 52 53Overview 54 55 This extension provides GLSL built-in functions and assembly opcodes 56 allowing shaders to perform atomic read-modify-write operations to buffer 57 or texture memory with floating-point components. The set of atomic 58 operations provided by this extension is limited to adds and exchanges. 59 Providing atomic add support allows shaders to atomically accumulate the 60 sum of floating-point values into buffer or texture memory across multiple 61 (possibly concurrent) shader invocations. 62 63 This extension provides GLSL support for atomics targeting image uniforms 64 (if GLSL 4.20, ARB_shader_image_load_store, or EXT_shader_image_load_store 65 is supported) or floating-point pointers (if NV_gpu_shader5 is supported). 66 Additionally, assembly opcodes for these operations is also provided if 67 NV_gpu_program5 is supported. 68 69New Procedures and Functions 70 71 None. 72 73New Tokens 74 75 None. 76 77Additions to Chapter 2 of the OpenGL 4.2 (Compatibility Profile) Specification 78(OpenGL Operation) 79 80 None. 81 82Additions to Chapter 3 of the OpenGL 4.2 (Compatibility Profile) Specification 83(Rasterization) 84 85 None. 86 87Additions to Chapter 4 of the OpenGL 4.2 (Compatibility Profile) Specification 88(Per-Fragment Operations and the Frame Buffer) 89 90 None. 91 92Additions to Chapter 5 of the OpenGL 4.2 (Compatibility Profile) Specification 93(Special Functions) 94 95 None. 96 97Additions to Chapter 6 of the OpenGL 4.2 (Compatibility Profile) Specification 98(State and State Requests) 99 100 None. 101 102Additions to the AGL/GLX/WGL Specifications 103 104 None. 105 106GLX Protocol 107 108 None. 109 110Modifications to the OpenGL Shading Language Specification, Version 4.20 111(revision 6) 112 113 Including the following line in a shader can be used to control the 114 language features described in this extension: 115 116 #extension GL_NV_shader_atomic_float : <behavior> 117 118 where <behavior> is as specified in section 3.3. 119 120 New preprocessor #defines are added to the OpenGL Shading Language: 121 122 #define GL_NV_shader_atomic_float 1 123 124 Modify Section 8.11, Image Functions (p. 149) 125 126 (add to "imageAtomicAdd" table cell, p. 151) 127 128 float imageAtomicAdd(IMAGE_PARAMS, float data) 129 130 (add to "imageAtomicExchange" table cell, p. 152) 131 132 float imageAtomicExchange(IMAGE_PARAMS, float data) 133 134Dependencies on EXT_shader_image_load_store, ARB_shader_image_load_store, and 135GLSL 4.20 136 137 If none of EXT_shader_image_load_store, ARB_shader_image_load_store, or 138 GLSL 4.20 are supported, the new floating-point variants of the built-in 139 functions imageAtomicAdd and imageAtomicExchange should be removed. 140 141Dependencies on NV_shader_buffer_store and NV_gpu_shader5 142 143 If NV_shader_buffer_store and NV_gpu_shader5 are supported, the following 144 functions should be added to the "Section 8.Y, Shader Memory Functions" 145 language in the NV_shader_buffer_store specification: 146 147 float atomicAdd(float *address, float data); 148 float atomicExchange(float *address, float data); 149 150Dependencies on NV_gpu_program5 151 152 If NV_gpu_program5 is supported and "OPTION NV_shader_atomic_float" is 153 specified in an assembly program, "F32" should be allowed as a storage 154 modifier to the ATOM instruction for the atomic operations "ADD" and 155 "EXCH". 156 157 (Add to "Section 2.X.6, Program Options" of the NV_gpu_program4 extension, 158 as extended by NV_gpu_program5:) 159 160 + Floating-Point Atomic Operations (NV_shader_atomic_float) 161 162 If a program specifies the "NV_shader_atomic_float" option, it may use 163 "F32" storage modifier with the "ATOM" and "ATOMIM" opcodes to perform 164 atomic floating-point add or exchange operations. 165 166 (Add to the table in "Section 2.X.8.Z, ATOM" in NV_gpu_program5:) 167 168 atomic storage 169 modifier modifiers operation 170 -------- ------------------ -------------------------------------- 171 ADD U32, S32, U64, F32 compute a sum 172 ... 173 EXCH U32, S32, U64, F32 exchange memory with operand 174 175Dependencies on EXT_shader_image_load_store and NV_gpu_program5 176 177 If EXT_shader_image_load_store and NV_gpu_program5 are supported and 178 "OPTION NV_shader_atomic_float" is specified in an assembly program, "F32" 179 should be allowed as a storage modifier to the ATOMIM instruction for the 180 atomic operations "ADD" and "EXCH". 181 182 (Add to the table in "Section 2.X.8.Z, ATOMIM" in the "Dependencies on 183 NV_gpu_program5" portion of the EXT_shader_image_load specification) 184 185 atomic storage 186 modifier modifiers operation 187 -------- ------------- -------------------------------------- 188 ADD U32, S32, F32 compute a sum 189 ... 190 EXCH U32, S32, F32 exchange memory with operand 191 192Dependencies on GLSL 4.30, ARB_shader_storage_buffer_object, and 193ARB_compute_shader 194 195 If GLSL 4.30 is supported, add the following atomic memory functions to 196 section 8.11 (Atomic Memory Functions) of the GLSL 4.30 specification: 197 198 float atomicAdd(inout float mem, float data); 199 float atomicExchange(inout float mem, float data); 200 201 If ARB_shader_storage_buffer_object or ARB_compute_shader are supported, 202 make similar edits to the functions documented in the 203 ARB_shader_storage_buffer object extension. 204 205 These functions are available if and only if GL_NV_shader_atomic_float is 206 enabled via the "#extension" directive. 207 208Errors 209 210 None. 211 212New State 213 214 None. 215 216New Implementation Dependent State 217 218 None. 219 220Issues 221 222 (1) What atomic operations should we support for floating-point targets? 223 224 RESOLVED: Floating-point atomic addition is the main functionality 225 targeted by this extension. We provide exchanges because the operation 226 needs no special hardware support. 227 228 We chose not to provide support for bitwise operations (AND/OR/XOR); 229 it's possible to support these by casting a pointer or aliasing an image 230 if required. Minimum, maximum, and compare-and-swap make sense, but the 231 underlying atomic hardware targeted by this extension does not support 232 floating-point comparisons. 233 234Revision History 235 236 Rev. Date Author Changes 237 ---- -------- -------- ----------------------------------------- 238 2 08/13/12 pbrown Add interaction with OpenGL 4.3 (and related ARB 239 extensions) supporting floating-point atomics 240 to shared and shader storage buffer memory. 241 242 1 pbrown Internal revisions. 243