-
Notifications
You must be signed in to change notification settings - Fork 98
/
GLSL_NV_shader_sm_builtins.txt
160 lines (104 loc) · 5.32 KB
/
GLSL_NV_shader_sm_builtins.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
Name
NV_shader_sm_builtins
Name Strings
GL_NV_shader_sm_builtins
Contact
Daniel Koch (dkoch 'at' nvidia.com), NVIDIA
Contributors
Jeff Bolz, NVIDIA
Status
Complete
Version
Last Modified Date: 2019-05-17
Revision: 1
Number
N/A
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.
This extension is written against revision 7 of the OpenGL Shading Language
version 4.50, dated May 9, 2017.
This extension interacts with revision 36 of the GL_KHR_vulkan_glsl
extension, dated February 13, 2017.
This extension interacts with GL_NV_mesh_shader.
This extension interacts with GL_NV_ray_tracing.
Overview
This extension adds the functionality of NV_shader_thread_group
that was not subsumed by KHR_shader_subgroup.
In particular, this extension adds new shader inputs to query
* the number of warps running on a SM (gl_WarpsPerSMNV),
* the number of SMs on the GPU (gl_SMCountNV),
* the warp id (gl_WarpIDNV), and
* the SM id (gl_SMIDNV).
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:
gl_WarpsPerSMNV -> WarpsPerSMNV decorated OpVariable
gl_SMCountNV -> SMCountNV decorated OpVariable
gl_WarpIDNV -> WarpIDNV decorated OpVariable
gl_SMIDNV -> SMIDNV decorated OpVariable
Modifications to The OpenGL Shading Language Specification, Version 4.50
(Revision 7)
Including the following line in a shader can be used to control the
language features described in this extension:
#extension GL_NV_shader_sm_builtins : <behavior>
where <behavior> is as specified in section 3.3.
New preprocessor #defines are added to the OpenGL Shading Language:
#define GL_NV_shader_sm_builtins 1
Modify Section 7.1, Built-in Languages Variable, p. 122
(Add to the list of built-in variables for the compute, vertex,
geometry, tessellation control, tessellation evaluation, fragment,
mesh, task, ray generation, intersection, any-hit, closest-hit,
miss, and callable shading languages)
highp in uint gl_WarpsPerSMNV;
highp in uint gl_SMCountNV;
highp in uint gl_WarpIDNV;
highp in uint gl_SMIDNV;
The variable gl_WarpsPerSMNV holds the maximum number of warps executing
on a SM.
The variable gl_SMCountNV holds the number of SMs on the device.
The variable gl_WarpIDNV holds the warp id of the executing invocation.
This variable is in the range 0 to gl_WarpsPerSMNV-1.
The variable gl_SMIDNV holds the SM id of the executing invocation.
This variable is in the range 0 to gl_SMCountNV-1.
Dependencies on NV_mesh_shader
If GL_NV_mesh_shader is not supported, ignore all references to mesh and
task shaders.
Dependencies on NV_ray_tracing
If GL_NV_ray_tracing is not supported, ignore all references to
ray generation, intersection, any-hit, closest-hit, miss, and callable
shaders.
Issues
1) What functionality is provided by NV_shader_thread_group that is not
already provided by other mechanisms?
NV_shader_thread_group
in uint gl_ThreadInWarpNV in uint gl_SubgroupInvocationID (KHR_shader_subgroup_basic)
in uint gl_Thread??MaskNV in uvec4 gl_Subgroup??Mask (KHR_shader_subgroup_ballot)
in bool gl_HelperThreadNV in bool glHelperInvocation (GLSL 4.50, ESSL 3.10)
in uint gl_WarpIDNV; <-- (added by this extension)
in uint gl_SMIDNV; <-- (added by this extension)
uniform uint gl_WarpSizeNV in uint gl_SubgroupSize (KHR_shader_subgroup_basic)
uniform uint gl_WarpsPerSMNV; <-- (added by this extension)
uniform uint gl_SMCountNV; <-- (added by this extension)
activeThreadsNV() subgroupBallot(true) (KHR_shader_subgroup_ballot)
ballotThreadNV(bool) subgroupBallot(bool) (KHR_shader_subgroup_ballot)
quadSwizzle0NV(value) subgroupQuadBroadcast(value, 0) (KHR_shader_subgroup_quad)
quadSwizzle1NV(value) subgroupQuadBroadcast(value, 1) (KHR_shader_subgroup_quad)
quadSwizzle2NV(value) subgroupQuadBroadcast(value, 2) (KHR_shader_subgroup_quad)
quadSwizzle3NV(value) subgroupQuadBroadcast(value, 3) (KHR_shader_subgroup_quad)
quadSwizzleXNV(value) subgroupQuadSwapHorizontal(value) (KHR_shader_subgroup_quad)
quadSwizzleYNV(value) subgroupQuadSwapVertical(value) (KHR_shader_subgroup_quad)
2) Are there any differences between the builtins added here, and the
ones defined in NV_shader_thread_group?
RESOLVED: Yes. In NV_shader_thread_group, gl_WarpsPerSMNV and gl_SMCountNV
were built-in uniforms. In this extension we've made them built-in inputs
which is consistent with changes we've made in KHR_shader_subgroups, and
because we don't have built-in uniforms in Vulkan.
Revision History
Rev. Date Author Changes
---- ---------- -------- -----------------------------------------
1 2019-05-17 dkoch Internal revisions.