-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathGL_EXT_shader_16bit_storage.txt
More file actions
executable file
·252 lines (192 loc) · 10.3 KB
/
GL_EXT_shader_16bit_storage.txt
File metadata and controls
executable file
·252 lines (192 loc) · 10.3 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
Name
EXT_shader_16bit_storage
Name Strings
GL_EXT_shader_16bit_storage
GL_EXT_shader_8bit_storage
Contact
Jeff Bolz (jbolz 'at' nvidia.com)
Contributors
Contributors to KHR_shader_explicit_arithmetic_types
Notice
Copyright (c) 2018 The Khronos Group Inc. Copyright terms at
http://www.khronos.org/registry/speccopyright.html
Status
Number
TBD
Dependencies
This extension can be applied to OpenGL GLSL versions 1.40
(#version 140) and higher.
This extension can be applied to OpenGL ES ESSL versions 3.10
(#version 310) and higher.
All these versions map GLSL/ESSL semantics to the same SPIR-V 1.0
semantics (approximating the most recent versions of GLSL/ESSL).
This extension is written against the OpenGL Shading Language
specification, Language Version 4.60, Document Revision 3.
Overview
This extension adds minimal support to allow loading/storing 8/16-bit
integer and floating-point scalar and vector types from/to uniform and
storage buffers, and to convert those values to and from 32-bit types.
All other operations on these types are not supported.
The goal is to be able to load 8/16-bit data from buffer memory, in order
to reduce storage, bandwidth, and register usage requirements. To use
the values for any other operations, they must be promoted to 32-bit via
a constructor.
This extension can be implemented in terms of the SPV_KHR_16bit_storage
and SPV_KHR_8bit_storage SPIR-V extensions, and inherits most of its
limitations from those specs.
Modifications to the OpenGL Shading Language Specification, Version 4.60
Including the following lines in a shader can be used to control the
language features described in this extension:
#extension GL_EXT_shader_16bit_storage : <behavior>
#extension GL_EXT_shader_8bit_storage : <behavior>
If GL_EXT_shader_16bit_storage is not enabled, the new language affecting
16-bit types is not applied. If GL_EXT_shader_8bit_storage is not enabled,
the new language affecting 8-bit types is not applied.
New preprocessor #defines are added:
#define GL_EXT_shader_16bit_storage 1
#define GL_EXT_shader_8bit_storage 1
Changes to Chapter 3 of the OpenGL Shading Language Specification
If the extension GL_EXT_shader_8bit_storage is supported,
add the following keywords to Section 3.6 Keywords:
int8_t i8vec2 i8vec3 i8vec4
uint8_t u8vec2 u8vec3 u8vec4
If the extension GL_EXT_shader_16bit_storage is supported,
add the following keywords to Section 3.6 Keywords:
float16_t f16vec2 f16vec3 f16vec4
int16_t i16vec2 i16vec3 i16vec4
uint16_t u16vec2 u16vec3 u16vec4
Changes to Chapter 4 of the OpenGL Shading Language Specification
Add into the tables in section 4.1 a new table interleaved with the existing
tables:
Transparent types with explicit bit size
--------------------------------------------------------------------------
| Type | Meaning |
| | |
--------------------------------------------------------------------------
| float16_t | a 16-bit floating-point scalar |
| f16vec2 | a two-component 16-bit floating-point vector |
| f16vec3 | a three-component 16-bit floating-point vector |
| f16vec4 | a four-component 16-bit floating-point vector |
| int8_t | an 8-bit signed integer scalar |
| i8vec2 | a two-component 8-bit signed integer vector |
| i8vec3 | a three-component 8-bit signed integer vector |
| i8vec4 | a four-component 8-bit signed integer vector |
| int16_t | a 16-bit signed integer scalar |
| i16vec2 | a two-component 16-bit signed integer vector |
| i16vec3 | a three-component 16-bit signed integer vector |
| i16vec4 | a four-component 16-bit signed integer vector |
| uint8_t | a 8-bit unsigned integer scalar |
| u8vec2 | a two-component 8-bit unsigned integer vector |
| u8vec3 | a three-component 8-bit unsigned integer vector |
| u8vec4 | a four-component 8-bit unsigned integer vector |
| uint16_t | a 16-bit unsigned integer scalar |
| u16vec2 | a two-component 16-bit unsigned integer vector |
| u16vec3 | a three-component 16-bit unsigned integer vector |
| u16vec4 | a four-component 16-bit unsigned integer vector |
--------------------------------------------------------------------------
Add a new subsection 4.1.X 16-bit Types
Variables with the types float16_t, int16_t, and uint16_t represent
floating-point, signed integer, and unsigned integer types with exactly
16 bits, respectively. The int16_t includes a leading sign bit and is
in two's complement form. float16_t is a half-precision floating point
type with a leading sign bit, followed by 5 exponent bits, followed by
10 mantissa bits, as defined in the IEEE 754-2008 standard.
f16vec*, i16vec*, and u16vec* are 16-bit vector types where each
component is the corresponding 16-bit scalar type. Scalar and vector
16-bit types can be aggregated into arrays and structures. Variables of
any basic 16-bit type or aggregate type containing a 16-bit type must
not be used to declare variables, unless that variable is a structure
with uniform or buffer storage qualifier (see Section 4.3, Storage
Qualifiers).
16-bit scalar or vector types can only be loaded from uniform or buffer
memory, stored to buffer memory, or converted to and from 32-bit types
via constructors (see Section 5.4.1, Conversion and Scalar Constructors,
and Section 5.4.2 Vector and Matrix Constructors). Arrays and structures
containing 16-bit types do not have constructors.
16-bit types do not support implicit conversions (see Section 4.1.10,
Implicit Conversions), do not support swizzle, do not support component
selection (except to select a scalar from a vector), do not support
vector array subscripting syntax, and do not support any mathematical
operations.
Add a new subsection 4.1.X 8-bit Types
Variables with the types int8_t and uint8_t represent signed integer
and unsigned integer types with exactly 8 bits, respectively. The
int8_t includes a leading sign bit and is in two's complement form.
i8vec* and u8vec* are 8-bit vector types where each component is the
corresponding 8-bit scalar type. Scalar and vector 8-bit types can be
aggregated into arrays and structures. Variables of any basic 8-bit
type or aggregate type containing an 8-bit type must not be used to
declare variables, unless that variable is a structure with uniform or
buffer storage qualifier (see Section 4.3, Storage Qualifiers).
8-bit scalar or vector types can only be loaded from uniform or buffer
memory, stored to buffer memory, or converted to and from 32-bit types
via constructors (see Section 5.4.1, Conversion and Scalar Constructors,
and Section 5.4.2 Vector and Matrix Constructors). Arrays and structures
containing 8-bit types do not have constructors.
8-bit types do not support implicit conversions (see Section 4.1.10,
Implicit Conversions), do not support swizzle, do not support component
selection (except to select a scalar from a vector), do not support
vector array subscripting syntax, and do not support any mathematical
operations.
Changes to Chapter 5 of the OpenGL Shading Language Specification
Modify subsection 5.4.1, Conversion and Scalar Constructors
(add after the first list of constructor examples)
int8_t(int) // convert a int value to a int8_t
int8_t(uint) // convert a uint value to a int8_t
uint8_t(int) // convert a int value to a uint8_t
uint8_t(uint) // convert a uint value to a uint8_t
int(int8_t) // convert a int8_t value to a int
int(uint8_t) // convert a uint8_t value to a int
uint(int8_t) // convert a int8_t value to a uint
uint(uint8_t) // convert a uint8_t value to a uint
int16_t(int) // convert a int value to a int16_t
int16_t(uint) // convert a uint value to a int16_t
uint16_t(int) // convert a int value to a uint16_t
uint16_t(uint) // convert a uint value to a uint16_t
int(int16_t) // convert a int16_t value to a int
int(uint16_t) // convert a uint16_t value to a int
uint(int16_t) // convert a int16_t value to a uint
uint(uint16_t) // convert a uint16_t value to a uint
float16_t(float) // convert a float value to a float16_t
float(float16_t) // convert a float16_t value to a float
Modify subsection 5.4.2, Vector and Matrix Constructors
Add to the end of the section:
Constructors of or using 8-bit and 16-bit vector types must construct
from a type with the same number of components. The following is a
complete list of such constructors:
i8vec2(ivec2)
i8vec3(ivec3)
i8vec4(ivec4)
ivec2(i8vec2)
ivec3(i8vec3)
ivec4(i8vec4)
u8vec2(uvec2)
u8vec3(uvec3)
u8vec4(uvec4)
uvec2(u8vec2)
uvec3(u8vec3)
uvec4(u8vec4)
f16vec2(fvec2)
f16vec3(fvec3)
f16vec4(fvec4)
fvec2(f16vec2)
fvec3(f16vec3)
fvec4(f16vec4)
i16vec2(ivec2)
i16vec3(ivec3)
i16vec4(ivec4)
ivec2(i16vec2)
ivec3(i16vec3)
ivec4(i16vec4)
u16vec2(uvec2)
u16vec3(uvec3)
u16vec4(uvec4)
uvec2(u16vec2)
uvec3(u16vec3)
uvec4(u16vec4)
Issues
None.
Revision History
Rev. Date Author Changes
---- ----------- ------------------- --------------------------------
1 22-May-2018 Jeff Bolz Initial draft