-
Notifications
You must be signed in to change notification settings - Fork 103
/
GLSL_EXT_shader_atomic_float.txt
executable file
·172 lines (105 loc) · 5.43 KB
/
GLSL_EXT_shader_atomic_float.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
Name
EXT_shader_atomic_float
Name Strings
GL_EXT_shader_atomic_float
Contact
Vikram Kushwaha, NVIDIA (vkushwaha 'at' nvidia.com)
Contributors
Daniel Koch, NVIDIA
Jeff Bolz, NVIDIA
Vikram Kushwaha, NVIDIA
Status
Complete
Version
Last Modified Date: April 9, 2020
Number
OpenGL Extension #XXX
Dependencies
This extension is written against version 4.60.7 of the OpenGL
Shading Language Specification, dated July 10, 2019.
This extension interacts with GL_KHR_memory_scope_semantics.
Overview
This extension provides additional GLSL built-in functions allowing shaders to
perform additional atomic read-modify-write operations on floating point numbers.
These operations are limited to add, exchange, load and store.
Atomic add allows shaders to atomically accumulate the sum of floating-point
values into a memory location across multiple (possibly concurrent)
shader invocations. Similarly, atomic exchange exchanges floating point
data with a memory location atomically.
Atomic load and store gets and sets the data respectively from memory atomically.
Some of these functions also have variants that specify the scopes and memory
semantics for atomic operations. The meanings of scopes and semantics are defined in
detail in the Vulkan Memory Model section of the Vulkan specification.
Mapping to SPIR-V
-----------------
For informational purposes (non-specification), the following is an
expected way for an implementation to map GLSL constructs to SPIR-V
constructs:
atomicAdd -> OpAtomicIAdd or OpAtomicFAdd, depending on the data type
New Tokens
None.
Additions to OpenGL 4.60 Specification
None.
Additions to the AGL/GLX/WGL Specifications
None.
GLX Protocol
None.
Modifications to the OpenGL Shading Language Specification, Version 4.60.7
Including the following line in a shader can be used to control the
language features described in this extension:
#extension GL_EXT_shader_atomic_float : <behavior>
where <behavior> is as specified in section 3.3.
New preprocessor #defines are added to the OpenGL Shading Language:
#define GL_EXT_shader_atomic_float 1
Additions to Chapter 8 of the OpenGL Shading Language Specification
(Built-in Functions)
Modify Section 8.11, Atomic Memory Functions, p. 192
Add the following new functions to the table on p. 193:
float atomicAdd(inout float mem, float data);
float atomicAdd(inout float mem, float data, int scope, int storage, int sem);
double atomicAdd(inout double mem, double data);
double atomicAdd(inout double mem, double data, int scope, int storage, int sem);
float atomicExchange(inout float mem, float data);
float atomicExchange(inout float mem, float data, int scope, int storage, int sem);
double atomicExchange(inout double mem, double data);
double atomicExchange(inout double mem, double data, int scope, int storage, int sem);
float atomicLoad(inout float mem, int scope, int storage, int sem);
double atomicLoad(inout double mem, int scope, int storage, int sem);
void atomicStore(inout float mem, float data, int scope, int storage, int sem);
void atomicStore(inout double mem, double data, int scope, int storage, int sem);
The values passed as scope, storage, and sem parameters must all be integer
constant expressions. Valid values are listed in the Scope and Semantics section
of the GL_KHR_memory_scope_semantics extension. scope must be a gl_Scope* value,
sem* must be a gl_Semantics* value, and storage* must be a combination of
gl_StorageSemantics* values.
Modify Section 8.12, Image Functions
Change the 3rd bullet about float image variables to:
a float image variable (type starts 'image') and a format qualifier of
r32f, used with a data argument of type float.
Modify the rows in table on p. 196 to include:
float imageAtomicAdd(IMAGE_PARAMS, float data);
float imageAtomicAdd(IMAGE_PARAMS, float data, int scope, int storage, int sem);
float imageAtomicExchange(IMAGE_PARAMS, float data, int scope, int storage, int sem);
Add new rows to table on p. 196:
Syntax Description
float imageAtomicLoad(readonly IMAGE_PARAMS, Returns the contents of texel atomically.
int scope, int storage, int sem);
void imageAtomicStore(writeonly IMAGE_PARAMS, Stores data into the texel atomically.
float data, int scope, int storage, int sem);
The values passed as scope, storage, and sem parameters must all be integer
constant expressions. Valid values are listed in the Scope and Semantics section
of the GL_KHR_memory_scope_semantics extension. scope must be a gl_Scope* value,
sem* must be a gl_Semantics* value, and storage* must be a combination of
gl_StorageSemantics* values.
Errors
None.
New State
None.
New Implementation Dependent State
None.
Issues
None.
Revision History
Rev. Date Author Changes
---- ----------- ------ -------------------------------------------
1 2020-04-09 vkushwaha-nv Internal revision.