File: EMSCRIPTEN_explicit_uniform_binding.txt

package info (click to toggle)
emscripten 3.1.6~dfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 114,112 kB
  • sloc: ansic: 583,052; cpp: 391,943; javascript: 79,361; python: 54,180; sh: 49,997; pascal: 4,658; makefile: 3,426; asm: 2,191; lisp: 1,869; ruby: 488; cs: 142
file content (173 lines) | stat: -rw-r--r-- 6,682 bytes parent folder | download
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
Name

    EMSCRIPTEN_explicit_uniform_binding

Name Strings

    GL_EMSCRIPTEN_explicit_uniform_binding

Contributors

    Jukka Jylänki, Unity Technologies
    Brendan Duncan, Unity Technologies

Contact

    Jukka Jylänki, Unity Technologies (jukkaj 'at' unity3d.com)
    Brendan Duncan, Unity Technologies (brendan.duncan 'at' unity3d.com)

Status

    Implemented in Emscripten 2.0.18 and newer for OpenGL ES 2 and
    OpenGL ES 3 contexts. (April 2021)

Version

    Date: April 13, 2021
    Revision: 1

Dependencies

    Emscripten 2.0.18 compiler targeting OpenGL ES 2.0 or OpenGL ES 3.0
    versions.

    Written against the OpenGL ES 2.0.25 and WebGL 1 specifications.

Overview

    WebGL 1 API provides a special type of uniforms called texture samplers.
    The organization of these samplers is designed around the concept of
    a file of device global multitexturing binding points. This provides a
    layer of indirection: instead of directly connecting texture objects to
    sampler uniforms in the shader, textures are set active in multitexturing
    binding points, and samplers uniforms then each select a binding point to
    sample from.

    WebGL 2 API provides support for Uniform Buffer Objects (UBOs). Again,
    instead of directly connecting a GPU buffer to a uniform block in the
    shader, each UBO variable is connected to a slot in a file of uniform
    block binding points, and the uniform block variables are assigned to
    read from one of these uniform block binding points.

    Sampler uniforms are assigned a multitexturing unit by calling the
    function gl.uniform1i(). Uniform blocks are assigned a uniform block
    binding point by calling the function gl.uniformBlockBinding().

    By default after a successful shader link, all samplers and uniform blocks
    are initially assigned the binding point zero. Instead of programmatically
    reassigning the binding points in Wasm/JS code, it can be useful to specify
    the default binding point to use in GLSL shader code. This allows a shader
    compilation backend to generate multiple shader programs that have mutually
    compatible layouts, without needing further coordination in application
    code.

    This extension adds support for specifying the initial multitexturing and
    uniform block binding points for texture samplers and uniform blocks. This
    is achieved via the same syntax that is available in Desktop OpenGL 4.2 and
    the extension ARB_shading_language_420pack. There, a programmer may choose
    to specify the integer binding point of a texture sampler or a uniform
    block in advance directly in the submitted shader code. The GLSL directive

        layout(binding = x) uniform sampler2D diffuse;

    specifies that the sampler 'diffuse' should sample a texture located in
    multitexturing unit 'x'.

    Likewise, specifying

        layout(binding = x) uniform myBlock { vec4 color; }

    specifies that the uniform block 'myBlock' should read from the Uniform
    Buffer Object located at uniform block binding point 'x'.

    In sibling specifications, support for explicit binding points exist in
    Desktop OpenGL 4.2 core specification and in the extension
    ARB_shading_language_420pack.

New Procedures and Functions

    None.

New Tokens

    None.

Additions to OpenGL ES Shading Language 1.00 Specification

  Add to sampler qualifiers:

    The qualifier "layout(binding = x)" can be prepended to a texture sampler
    variable directive to bind the integer multitexturing unit that the given
    sampler reads from:

        layout(binding = x) uniform sampler2D diffuse;

    Only one layout qualifier may appear in a single declaration.

    Any sampler declared without a binding identifier is initially assigned to
    sample from multitexturing unit zero. After a program is linked, the binding
    points used for samplers with or without a binding identifier can be updated
    by the OpenGL API.

    If the binding identifier is used with an array, the first element of the 
    array takes the specified unit and each subsequent element takes the next 
    consecutive unit.

    If the binding is less than zero, or greater than or equal to the 
    implementation-dependent maximum supported number of units, a compilation 
    error will occur. When the binding identifier is used with an array of size
    N, all elements of the array from binding through binding + N - 1 must be 
    within this range.

Additions to OpenGL ES Shading Language 3.00 Specification

  Add to Layout Qualifiers:

    The qualifier "layout(binding = x)" can be prepended to a uniform block
    variable directive:

        layout(binding = x) uniform myBlock { vec4 color; }

    The binding identifier specifies the uniform buffer binding point 
    corresponding to the uniform block, which will be used to obtain the 
    values of the member variables of the block.

    Only one layout qualifier may appear in a single declaration.

    Any uniform block declared without a binding identifier is initially 
    assigned to block binding point zero. After a program is linked, the 
    binding points used for uniform blocks declared with or without a binding 
    identifier can be updated by the OpenGL API.

    If the binding identifier is used with a uniform block instanced as an 
    array then the first element of the array takes the specified block binding
    and each subsequent element takes the next consecutive uniform block 
    binding point.

    If the binding point for any uniform block instance is less than zero, or 
    greater than or equal to the implementation-dependent maximum number of 
    uniform buffer bindings, a compilation error will occur.  When the binding 
    identifier is used with a uniform block instanced as an array of size N, 
    all elements of the array from binding through binding + N - 1 must be
    within this range.

Additions to Emscripten compiler

    Instead of utilizing the runtime method WebGLRenderingContext.getExtension()
    to coordinate enabling the extension, EMSCRIPTEN_explicit_uniform_binding
    activation is controlled at compile time by specifying the flag

        -s GL_EXPLICIT_UNIFORM_BINDING=1

    to 'emcc' or 'em++' linker command line in the Emscripten compiler.

    When this flag is passed, the extension EMSCRIPTEN_explicit_uniform_binding
    is enabled for all contexts created in the application.

    The choice of compile time activation is due to the considerable increase in
    code size that is involved in enabling this extension.

Revision History

    Revision 1.0, April 13, 2021: juj
        - First version