-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathGLSL_EXT_shader_atomic_float2.txt
More file actions
executable file
·225 lines (150 loc) · 7.97 KB
/
GLSL_EXT_shader_atomic_float2.txt
File metadata and controls
executable file
·225 lines (150 loc) · 7.97 KB
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
Name
EXT_shader_atomic_float2
Name Strings
GL_EXT_shader_atomic_float2
Contact
Jason Ekstrand, Intel (jason.ekstrand 'at' intel.com)
Contributors
Jason Ekstrand, Intel
Status
Complete
Version
Last Modified Date: January 13, 2021
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.
This extension interacts with EXT_shader_explicit_arithmetic_types.
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 min and max
for 32 and 64-bit floating-point numbers and add, min, max, exchange,
load and store for 16-bit floating-point numbers. All operations are
supported on storage buffers and shared memory. The 32-bit atomic min
and max operations are also supported on images.
Atomic add allows shaders to atomically accumulate the sum of floating-point
values into a memory location across multiple (possibly concurrent)
shader invocations. Atomic min and max allow shaders to atomically
accumulate the minimum or maximum 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:
atomicLoad -> OpAtomicLoad
atomicStore -> OpAtomicStore
atomicAdd -> OpAtomicIAdd or OpAtomicFAdd, depending on the data type
atomicMin -> OpAtomicUMin, OpAtomicSMin, OpAtomicFMin, depending
on the data type
atomicMax -> OpAtomicUMax, OpAtomicSMax, OpAtomicFMax, 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_float2 : <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_float2 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 atomicMin(inout float mem, float data);
float atomicMin(inout float mem, float data, int scope, int storage, int sem);
double atomicMin(inout double mem, double data);
double atomicMin(inout double mem, double data, int scope, int storage, int sem);
float atomicMax(inout float mem, float data);
float atomicMax(inout float mem, float data, int scope, int storage, int sem);
double atomicMax(inout double mem, double data);
double atomicMax(inout double mem, double data, int scope, int storage, int sem);
If the EXT_shader_explicit_arithmetic_types is present, add Add the
following new functions to the table on p. 193:
float16_t atomicAdd(inout float16_t mem, float16_t data);
float16_t atomicAdd(inout float16_t mem, float16_t data, int scope, int storage, int sem);
float16_t atomicMin(inout float16_t mem, float16_t data);
float16_t atomicMin(inout float16_t mem, float16_t data, int scope, int storage, int sem);
float16_t atomicMax(inout float16_t mem, float16_t data);
float16_t atomicMax(inout float16_t mem, float16_t data, int scope, int storage, int sem);
float16_t atomicExchange(inout float16_t mem, float16_t data);
float16_t atomicExchange(inout float16_t mem, float16_t data, int scope, int storage, int sem);
float16_t atomicLoad(inout float16_t mem, int scope, int storage, int sem);
void atomicStore(inout float16_t mem, float16_t 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.
For the floating-point atomicMin functions, put the following in the
Description column:
Computes a new value by taking the minimum of the value of data
and the contents of mem. Given x and y are two numbers (neither
is NaN) and qNaN is an IEEE quiet NaN, sNaN is an IEEE signaling
NaN, and NaN is any NaN value, the minimum operation performed as
part of atomicMin has the following semantics:
* min(x, y) = x if x < y and y otherwise,
* min(-0, +0) = min(+0, -0) = +0 or -0,
* min(x, qNaN) = min(qNaN, x) = x,
* min(qNaN, qNaN) = qNaN,
* min(x, sNaN) = min(sNaN, x) = NaN or x, and
* min(NaN, sNaN) = min(sNaN, NaN) = NaN
For the floating-point atomicMax functions, put the following in the
Description column:
Computes a new value by taking the maximum of the value of data
and the contents of mem. Given x and y are two numbers (neither
is NaN) and qNaN is an IEEE quiet NaN, sNaN is an IEEE signaling
NaN, and NaN is any NaN value, the maximum operation performed as
part of atomicMax has the following semantics:
* max(x, y) = x if x > y and y otherwise,
* max(-0, +0) = max(+0, -0) = +0 or -0,
* max(x, qNaN) = max(qNaN, x) = x,
* max(qNaN, qNaN) = qNaN,
* max(x, sNaN) = max(sNaN, x) = NaN or x, and
* max(NaN, sNaN) = max(sNaN, NaN) = NaN
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 imageAtomicMin(IMAGE_PARAMS, float data);
float imageAtomicMin(IMAGE_PARAMS, float data, int scope, int storage, int sem);
float imageAtomicMax(IMAGE_PARAMS, float data);
float imageAtomicMax(IMAGE_PARAMS, 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 2021-01-13 jekstrand Internal revision.