-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathGLSL_NV_push_constant_bank.txt
More file actions
259 lines (175 loc) · 8.91 KB
/
GLSL_NV_push_constant_bank.txt
File metadata and controls
259 lines (175 loc) · 8.91 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
253
254
255
256
257
258
Name
NV_push_constant_bank
Name Strings
GL_NV_push_constant_bank
Contact
Vassili Nikolaev (vnikolaev 'at' nvidia.com), NVIDIA
Contributors
Piers Daniell, NVIDIA
Ashwin Lele, NVIDIA
Status
Provisional
Version
Last Modified Date: 2025-12-16
Revision: 1
Dependencies
This extension can be applied to OpenGL GLSL versions 4.60
(#version 460) and higher.
This extension is written against revision 5 of the OpenGL Shading Language
version 4.60, dated September 4, 2017.
This extension interacts with revision 43 of the GL_KHR_vulkan_glsl
extension, dated October 25, 2017.
This extension interacts with VK_KHR_push_descriptor.
Overview
This extension provides new layout qualifiers for push constant uniform
blocks that allow shaders to organize push constant data into multiple
independent memory banks and specify explicit byte offsets for block
members within those banks.
Traditional push constant blocks in GLSL/Vulkan share a single contiguous
memory region, this prevents multiple shader stages from using use push
constants with different layouts. This extension introduces the "bank"
layout qualifier to allow shaders to specify which logical bank of push
constant memory a block should reside in, and the "member_offset"
qualifier to specify the starting byte offset of the block's members
within that bank.
This is useful for:
- Allowing different pipeline stages to have non-overlapping push constant
layouts without conflicts
- Providing explicit control over memory placement for performance
optimization on specific hardware configurations
- Enabling larger effective push constant storage by utilizing multiple
banks
Example usage:
// Push constant in bank 0 at default offset
layout(push_constant) uniform PushDataA
{
mat4 modelMatrix;
};
// Push constant in bank 4 starting at byte offset 128
layout(push_constant, bank=4, member_offset=128) uniform PushDataB
{
vec4 b;
};
Mapping to SPIR-V
-----------------
For informational purposes (non-normative), the following is an
expected way for an implementation to map GLSL constructs to SPIR-V
constructs:
bank layout qualifier -> BankNV Decoration on OpVariable
member_offset layout qualifier -> MemberOffsetNV Decoration on OpVariable
The bank value specifies the logical push constant bank index.
The member_offset value specifies the byte offset within the bank.
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_NV_push_constant_bank : <behavior>
where <behavior> is as specified in section 3.3.
New preprocessor #defines are added:
#define GL_NV_push_constant_bank 1
Changes to Chapter 4 of The OpenGL Shading Language Specification, Version 4.60
Modify Section 4.4 (Layout Qualifiers)
Add to the table in section 4.4:
Layout Qualifier Qualifier Individual Block Block Allowed
Only Variable Member Interface
---------------- --------- ---------- ------ ------ ---------
bank = X uniform
(push_constant
only)
member_offset = X uniform
(push_constant
only)
Add new sub-section to Section 4.4.5, Uniform and Shader Storage Block
Layout Qualifiers
4.4.5.X Push Constant Bank Layout Qualifiers
The "bank" and "member_offset" layout qualifiers are used to control the
placement of push constant uniform blocks in memory. These qualifiers are
only valid on uniform blocks that also have the "push_constant" layout
qualifier. It is a compile-time error to use these qualifiers on blocks
without "push_constant" or on non-block declarations.
The layout qualifiers are:
layout-qualifier-id :
bank = integer-constant-expression
member_offset = integer-constant-expression
bank
----
The "bank" layout qualifier specifies which logical push constant memory
bank the uniform block should reside in. The value must be a non-negative
integer constant expression.
When "bank" is not specified, the block is placed in bank 0 (the default
push constant bank, which corresponds to the standard Vulkan push constant
range).
Different banks represent independent regions of push constant memory.
The number of available banks and the size of each bank is
implementation-dependent and can be queried through the Vulkan API.
Limits on bank indices and bank sizes are enforced at runtime by the
Vulkan driver. Valid Usage rules in the Vulkan specification define the
constraints, and validation layers will report errors when these limits
are exceeded. Shader compilation may succeed, but pipeline creation will
fail if limits are violated.
Multiple push constant blocks may use the same bank, but their memory
ranges (determined by member_offset and block size) must not overlap.
Overlapping ranges within the same bank result in undefined behavior.
Example:
// Block in default bank 0
layout(push_constant) uniform BlockA { vec4 a; };
// Block in bank 2
layout(push_constant, bank=2) uniform BlockB { vec4 b; };
// Another block in bank 2 (must not overlap with BlockB)
layout(push_constant, bank=2, member_offset=16) uniform BlockC { vec4 c; };
member_offset
-------------
The "member_offset" layout qualifier specifies the starting byte offset
within the bank where the block's members begin. The value must be a
non-negative integer constant expression representing a byte offset.
When "member_offset" is not specified, the block's members start at
byte offset 0 within the specified bank.
The member_offset value must satisfy the alignment requirements of the
block's members. Specifically:
- The offset must be a multiple of the alignment requirement of the
first member of the block
- For standard uniform block layout rules, the offset should typically
be a multiple of 16 bytes for vec4-aligned data
Limits on valid member_offset values are enforced at runtime by the
Vulkan driver. Valid Usage rules in the Vulkan specification define the
constraints, and validation layers will report errors when these limits
are exceeded. Shader compilation may succeed, but pipeline creation will
fail if limits are violated.
The member_offset qualifier specifies the base offset of the entire block
within the bank. Individual member offsets (using the standard "offset"
layout qualifier on block members) are then added relative to this base.
For example:
layout(push_constant, bank=0, member_offset=64) uniform Block
{
layout(offset=0) vec4 a; // At byte 64 in bank 0
layout(offset=16) vec4 b; // At byte 80 in bank 0
};
Example:
// Block starting at byte 0 in bank 4
layout(push_constant, bank=4) uniform BlockX { mat4 m; };
// Block starting at byte 128 in bank 4
layout(push_constant, bank=4, member_offset=128) uniform BlockY { vec4 v; };
Combined Usage
--------------
The "bank" and "member_offset" qualifiers may be used together or
independently:
// Default bank (0), default offset (0)
layout(push_constant) uniform Block1 { vec4 a; };
// Bank 3, default offset (0)
layout(push_constant, bank=3) uniform Block2 { vec4 b; };
// Default bank (0), offset 64
layout(push_constant, member_offset=64) uniform Block3 { vec4 c; };
// Bank 4, offset 128
layout(push_constant, bank=4, member_offset=128) uniform Block4 { vec4 d; };
Interactions with GL_KHR_vulkan_glsl
The "push_constant" layout qualifier is defined by GL_KHR_vulkan_glsl.
The "bank" and "member_offset" qualifiers introduced by this extension
extend the functionality of push constants as defined in GL_KHR_vulkan_glsl.
When targeting Vulkan, the bank and member_offset values are used to
determine which VkPushConstantRange the block maps to and at what
offset within that range.
Issues
None.
Revision History
Rev. Date Author Changes
---- ----------- ------ -------------------------------------------
1 16-Dec-2025 vnikolaev Initial revision.