-
Notifications
You must be signed in to change notification settings - Fork 102
/
GL_EXT_null_initializer.txt
151 lines (92 loc) · 3.8 KB
/
GL_EXT_null_initializer.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
Name
EXT_null_initializer
Name Strings
GL_EXT_null_initializer
Contact
Alan Baker, Google (alanbaker 'at' google.com)
Contributors
Alan Baker, Google
Jeff Bolz, NVIDIA
Jason Ekstrand, Intel
John Kessenich, Google
Daniel Koch, NVIDIA
Status
Complete
Version
Last Modified Date: October 25, 2022
Revision: 4
Depenendencies
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.
This extension is written against the OpenGL Shading Language
Specification, version 4.60 (revision 7), dated July 10, 2019
This extension requires GL_KHR_vulkan_glsl
Overview
This extension adds a null initializer to GLSL and allows shared variables in
compute shaders to be null initialized. Null initializers are specified using
a new syntax of empty braces.
New Procedures and Functions
None.
New Tokens
None.
Modifications to GL_KHR_vulkan_glsl
Add to the "Mapping to SPIR-V" section
Mapping shared variable initializers:
Null initializers should be generated as OpConstantNull of the variable's type.
Modifications to the OpenGL Shading Language Specification, Version 4.60
Including the following line in a shader can be used to control the language
features described in this extension:
#extension GL_EXT_null_initializer : <behavior>
where <behavior> is as specified in section 3.3.
New preprocessor #defines are added to the OpenGL Shading Language:
#define GL_EXT_null_initializer 1
Add a new section 4.1.11.1 Null Initializers:
A null initializer is defined for the following types:
- bool: false
- Scalar integers: 0
- Scalar floating point: +0.0 (all bits 0)
- Composites: each member is recursively defined to be null according to their
constituent types
It is a compile-time error to null initialize any other type, or to null initialize an
unsized array type.
Null initialization can be achieved by using an empty brace expression.
For example,
vec4 x = { };
In section 4.3.8 Shared Variables:
Replace the paragraph:
Variables declared as shared may not have initializers and their contents are
undefined at the beginning of shader execution. Any data written to shared
variables will be visible to other work items (executing the same shader)
within the same workgroup.
With:
Variables declared as shared may only have null initializers (see section 4.1.11.1).
Uninitialized shared variables' contents are undefined at the beginning of shader
execution. Any data written to shared variables will be visible to other work items
(executing the same shader) within the same workgroup.
In section 9 Shading Language Grammar:
Add the following rule to "initializer: ...":
initializer :
LEFT_BRACE RIGHT_BRACE
Issues
1. How should the null initializer be specified?
Discussion: Common idioms include "{ }", "{ 0 }" and default constructors.
"{ 0 }" is problematic when considering structs nested inside structs.
RESOLVED. Only allow empty braces as a null initializer.
2. To what extent should null initializers be allowed?
Discussion: The tooling requirements to support null initializers is error
prone if they are accepted as a general initializer. Additionally, they are
useful beyond just shared variables.
RESOLVED. Allow null initializers generally.
Revision History
Revision 1 (Alan Baker)
- Internal revision
Revision 2 (Alan Baker)
- Clarify null initializers
Revision 3 (Alan Baker)
- Rename extension from GL_EXT_null_initialize_shared_memory
- Allow null initializers generally
- Restrict null initializers to sized types
Revision 4 (Alan Baker)
- Editorial changes