Skip to content

Commit 124b63d

Browse files
authored
Specify which operations are "Draw Operations" and "Read Operations". (#3469)
Specify it categorically based on "are allowed to read/write" behavior, and provide lists and annotations less normatively.
1 parent 0b13fff commit 124b63d

2 files changed

Lines changed: 105 additions & 44 deletions

File tree

specs/latest/1.0/index.html

Lines changed: 74 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,15 @@ <h3><a name="THE_DRAWING_BUFFER">The Drawing Buffer</a></h3>
348348
</p>
349349
<p>
350350
WebGL presents its drawing buffer to the HTML page compositor immediately before a
351-
compositing operation, but only if at least one of the following has occurred since the
351+
compositing operation, but only if at least one of the following have been called since the
352352
previous compositing operation:
353353
<ul>
354354
<li>Context creation</li>
355355
<li>Canvas resize</li>
356356
<li>
357-
<code>clear</code>, <code>drawArrays</code>, or <code>drawElements</code> has been
358-
called while the drawing buffer is the currently bound framebuffer
357+
Any of the
358+
<a href=#DRAW_OPERATIONS>[Draw Operations]</a>,
359+
called while the drawing buffer is the currently bound (draw) framebuffer.
359360
</li>
360361
</ul>
361362
</p>
@@ -2575,6 +2576,9 @@ <h4>Texture objects</h4>
25752576
GLint border)
25762577
<span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;3.7.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCopyTexImage2D.xml">man page</a>)</span>
25772578
<dd>
2579+
A <a href=#READ_OPERATIONS>[Read Operation]</a>.
2580+
<br>
2581+
25782582
If an attempt is made to call this function with no WebGLTexture bound (see above), an
25792583
<code>INVALID_OPERATION</code> error is generated. <br><br>
25802584

@@ -2595,6 +2599,9 @@ <h4>Texture objects</h4>
25952599
GLint x, GLint y, GLsizei width, GLsizei height)
25962600
<span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-3.7.2">OpenGL ES 2.0 &sect;3.7.2</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCopyTexSubImage2D.xml">man page</a>)</span>
25972601
<dd>
2602+
A <a href=#READ_OPERATIONS>[Read Operation]</a>.
2603+
<br>
2604+
25982605
If an attempt is made to call this function with no WebGLTexture bound (see above), an
25992606
<code>INVALID_OPERATION</code> error is generated. <br><br>
26002607

@@ -3316,43 +3323,66 @@ <h4>Uniforms and attributes</h4>
33163323

33173324
<!-- ======================================================================================================= -->
33183325

3319-
<h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h4>
3326+
<h4><a id=DRAW_OPERATIONS>Draw Operations</a></h4>
33203327

33213328
<p>
3322-
OpenGL ES 2.0 has 3 calls which can render to the drawing buffer: <code>clear</code>,
3323-
<code>drawArrays</code> and <code>drawElements</code>. Furthermore rendering can
3329+
OpenGL ES 2.0 has several calls which are allowed to
3330+
write to the currently bound (draw) framebuffer.
3331+
WebGL categorizes all such calls as <a href=#DRAW_OPERATIONS>[Draw Operations]</a>.
3332+
</p>
3333+
<p>
3334+
Furthermore, rendering can
33243335
be directed to the drawing buffer or to a Framebuffer object. When rendering is
3325-
directed to the drawing buffer, making any of the 3 rendering calls shall
3336+
directed to the drawing buffer, making any of the rendering calls shall
33263337
cause the drawing buffer to be presented to the HTML page compositor at the start
33273338
of the next compositing operation.
33283339
</p>
3329-
33303340
<p>
3331-
If any one of these 3 calls attempts to draw to a missing attachment of a complete framebuffer,
3341+
These include, but (due to additions in extensions or in WebGL 2.0) are not limited to:
3342+
<ul>
3343+
<li><code>clear</code></li>
3344+
<li><code>drawArrays</code></li>
3345+
<li><code>drawElements</code></li>
3346+
</ul>
3347+
For instance,
3348+
<a href="https://registry.khronos.org/webgl/extensions/ANGLE_instanced_arrays/">ANGLE_instanced_arrays</a>
3349+
adds <code>drawArraysInstancedANGLE</code>, and
3350+
<a href="https://registry.khronos.org/webgl/specs/latest/2.0/">WebGL 2.0</a>
3351+
adds <code>drawArraysInstanced</code>.
3352+
</p>
3353+
<p>
3354+
If any one of these calls attempts to draw to a missing attachment of a complete framebuffer,
33323355
nothing is drawn to that attachment and no error is generated
33333356
per <a href="../1.0/index.html#DRAWING_TO_MISSING_ATTACHMENT">Drawing to a Missing Attachment</a>.
33343357
</p>
33353358

33363359
<dl class="methods">
33373360
<dt class="idl-code">void clear(GLbitfield mask)
33383361
<span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.2.3">OpenGL ES 2.0 &sect;4.2.3</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glClear.xml">man page</a>)</span>
3362+
<dd>
3363+
A <a href=#DRAW_OPERATIONS>[Draw Operation]</a>.
33393364
<dt class="idl-code">void drawArrays(GLenum mode, GLint first, GLsizei count)
33403365
<span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDrawArrays.xml">man page</a>)</span>
3341-
<dd>
3366+
<dd>
3367+
A <a href=#DRAW_OPERATIONS>[Draw Operation]</a>.
3368+
<br>
33423369
If <em>first</em> is negative, an <code>INVALID_VALUE</code> error will be generated.
33433370
If the CURRENT_PROGRAM is null, an <code>INVALID_OPERATION</code> error will be generated.
33443371
<dt class="idl-code">void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset)
33453372
<span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-2.8">OpenGL ES 2.0 &sect;2.8</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDrawElements.xml">man page</a>)</span>
33463373
<dd>
3374+
A <a href=#DRAW_OPERATIONS>[Draw Operation]</a>.
3375+
<br>
33473376
Draw using the currently bound element array buffer. The given offset is in bytes, and
33483377
must be a valid multiple of the size of the given type or an <code>INVALID_OPERATION</code>
33493378
error will be generated; in addition the offset must be non-negative or an
33503379
<code>INVALID_VALUE</code> error will be generated; see <a href="#BUFFER_OFFSET_AND_STRIDE">
33513380
Buffer Offset and Stride Requirements</a>. If <code>count</code> is greater than zero,
33523381
then a non-null <code>WebGLBuffer</code> must be bound to the <code>ELEMENT_ARRAY_BUFFER</code>
3353-
binding point or an <code>INVALID_OPERATION</code> error will be generated.<br><br>
3382+
binding point or an <code>INVALID_OPERATION</code> error will be generated.<br>
3383+
<br>
33543384
If the CURRENT_PROGRAM is null, an <code>INVALID_OPERATION</code> error will be generated.
3355-
3385+
<br>
33563386
WebGL performs additional error checking beyond that specified in OpenGL ES 2.0 during
33573387
calls to <code>drawArrays</code>
33583388
and <code>drawElements</code>. See <a href="#ATTRIBS_AND_RANGE_CHECKING">Enabled Vertex
@@ -3365,17 +3395,33 @@ <h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h
33653395

33663396
<!-- ======================================================================================================= -->
33673397

3368-
<h4><a name="readpixels">Reading back pixels</a></h4>
3398+
<h4><a id=READ_OPERATIONS>Read Operations</a></h4>
33693399

33703400
<p>
3371-
Pixels in the current framebuffer can be read back into an ArrayBufferView object.
3401+
OpenGL ES 2.0 has several calls which which are allowed to
3402+
read from the currently bound (read) framebuffer.
3403+
WebGL categorizes all such calls as <a href=#READ_OPERATIONS>[Read Operations]</a>.
3404+
</p>
3405+
<p>
3406+
These include, but (due to additions in extensions or in WebGL 2.0) are not limited to:
3407+
<ul>
3408+
<li><code>copyTexImage2D</code></li>
3409+
<li><code>copyTexSubImage2D</code></li>
3410+
<li><code>readPixels</code></li>
3411+
</ul>
33723412
</p>
33733413

33743414
<dl class="methods">
33753415
<dt class="idl-code">void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
33763416
GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels)
33773417
<span class="gl-spec">(<a href="http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf#nameddest=section-4.3.1">OpenGL ES 2.0 &sect;4.3.1</a>, <a class="nonnormative" href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glReadPixels.xml">man page</a>)</span>
33783418
<dd>
3419+
A <a href=#READ_OPERATIONS>[Read Operation]</a>.
3420+
<br>
3421+
3422+
Pixels in the current framebuffer are read back into an ArrayBufferView object.
3423+
<br>
3424+
33793425
Fills <code>pixels</code> with the pixel data in the specified rectangle of the frame
33803426
buffer. The data returned from readPixels must be up-to-date as of the most recently
33813427
sent drawing command.
@@ -3929,17 +3975,10 @@ <h3><a name="FBO_ATTACHMENTS">Framebuffer Object Attachments</a></h3>
39293975

39303976
<ul>
39313977
<li> <code>checkFramebufferStatus</code> must return <code>FRAMEBUFFER_UNSUPPORTED</code>.
3932-
<li> The following calls, which either modify or read the framebuffer, must generate
3978+
<li> <a href=#DRAW_OPERATIONS>[Draw Operations]</a> and <a href=#READ_OPERATIONS>[Read Operations]</a>,
3979+
which either draw to or read from the framebuffer, must generate
39333980
an <code>INVALID_FRAMEBUFFER_OPERATION</code> error and return early, leaving the contents of
39343981
the framebuffer, destination texture or destination memory untouched.
3935-
<ul>
3936-
<li> clear
3937-
<li> copyTexImage2D
3938-
<li> copyTexSubImage2D
3939-
<li> drawArrays
3940-
<li> drawElements
3941-
<li> readPixels
3942-
</ul>
39433982
</ul>
39443983

39453984
The following combinations of framebuffer object attachments, when all of the attachments are
@@ -4021,11 +4060,13 @@ <h3><a name="PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a></h3>
40214060
<h3><a name="READS_OUTSIDE_FRAMEBUFFER">Reading Pixels Outside the Framebuffer</a></h3>
40224061

40234062
<p>
4024-
In the WebGL API, three functions read the framebuffer: <code>copyTexImage2D</code>,
4025-
<code>copyTexSubImage2D</code>, and <code>readPixels</code>. <code>copyTexImage2D</code> is defined to
4026-
generate the RGBA value (0, 0, 0, 0) for any pixel outside of the bound framebuffer.
4027-
<code>copyTexSubImage2D</code> and <code>readPixels</code> are defined not to touch the corresponding
4028-
destination range for any pixel outside the bound framebuffer.
4063+
For <a href=#READ_OPERATIONS>[Read Operations]</a>,
4064+
reads from out-of-bounds pixels sub-areas do not touch their corresponding destination sub-areas.
4065+
</p>
4066+
<p>
4067+
WebGL (behaves as if it) pre-initializes resources to zeros.
4068+
Therefore for example <code>copyTexImage2D</code> will have zeros in sub-areas that correspond to
4069+
out-of-bounds framebuffer reads.
40294070
</p>
40304071

40314072
<h3><a name="STENCIL_SEPARATE_LIMIT">Stencil Separate Mask and Reference Value</a></h3>
@@ -4262,14 +4303,8 @@ <h3><a name="READING_FROM_MISSING_ATTACHMENT">Reading From a Missing Attachment<
42624303
that does not have a color attachment.
42634304
</p>
42644305
<p>
4265-
In the WebGL API, such operations that require data from an attachment that is missing will
4266-
generate an <code>INVALID_OPERATION</code> error. This applies to the following functions:
4267-
4268-
<ul>
4269-
<li> <code>copyTexImage2D</code>
4270-
<li> <code>copyTexSubImage2D</code>
4271-
<li> <code>readPixels</code>
4272-
</ul>
4306+
In the WebGL API, any <a href=#READ_OPERATIONS>[Read Operations]</a> that require data from an attachment that is missing will
4307+
generate an <code>INVALID_OPERATION</code> error.
42734308
</p>
42744309

42754310
<h3><a name="DRAWING_TO_MISSING_ATTACHMENT">Drawing To a Missing Attachment</a></h3>
@@ -4279,14 +4314,9 @@ <h3><a name="DRAWING_TO_MISSING_ATTACHMENT">Drawing To a Missing Attachment</a><
42794314
that does not have a color attachment.
42804315
</p>
42814316
<p>
4282-
In the WebGL API, such operations that draw to an attachment that is missing will draw
4283-
nothing to that attachment. No error is generated. This applies to the following functions:
4284-
4285-
<ul>
4286-
<li> <code>clear</code>
4287-
<li> <code>drawArrays</code>
4288-
<li> <code>drawElements</code>
4289-
</ul>
4317+
In the WebGL API, any <a href=#DRAW_OPERATIONS>[Draw Operations]</a>
4318+
that draw to an attachment that is missing will draw
4319+
nothing to that attachment. No error is generated.
42904320
</p>
42914321

42924322
<h3><a name="NAN_LINE_WIDTH">NaN Line Width</a></h3>

specs/latest/2.0/index.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,12 @@ <h4>Framebuffer objects</h4>
14221422
</p>
14231423
</dt>
14241424
<dd>
1425+
Both a
1426+
<a href="../1.0/#READ_OPERATIONS">[Read Operation]</a>
1427+
and a
1428+
<a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
1429+
<br>
1430+
14251431
Transfer a rectangle of pixel values from one region of the read framebuffer to another in the draw
14261432
framebuffer. If the value of SAMPLE_BUFFERS for the read framebuffer is one and the value of
14271433
SAMPLE_BUFFERS for the draw framebuffer is zero, the samples corresponding to each pixel location in
@@ -1463,6 +1469,8 @@ <h4>Framebuffer objects</h4>
14631469
</p>
14641470
</dt>
14651471
<dd>
1472+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
1473+
<br>
14661474
Equivalent to calling <code>invalidateSubFramebuffer</code> with <code>x</code> and <code>y</code>
14671475
set to 0 and <code>width</code> and <code>height</code> set to the largest framebuffer object's
14681476
attachments' width and height.
@@ -1476,6 +1484,8 @@ <h4>Framebuffer objects</h4>
14761484
</p>
14771485
</dt>
14781486
<dd>
1487+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
1488+
<br>
14791489
Signal the GL that it need not preserve all contents of a bound framebuffer object.
14801490
</dd>
14811491
<dt>
@@ -2055,6 +2065,9 @@ <h4>Texture objects</h4>
20552065
</p>
20562066
</dt>
20572067
<dd>
2068+
A <a href="../1.0/#READ_OPERATIONS">[Read Operation]</a>.
2069+
<br>
2070+
20582071
If an attempt is made to call this function with no WebGLTexture bound (see above), an
20592072
<code>INVALID_OPERATION</code> error is generated. <br><br>
20602073

@@ -2421,6 +2434,9 @@ <h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h
24212434
</span>
24222435
</p>
24232436
</dt>
2437+
<dd>
2438+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
2439+
</dd>
24242440
<dt>
24252441
<p class="idl-code">void drawElements(GLenum mode, GLsizei count, GLenum type, GLintptr offset)
24262442
<span class="gl-spec">
@@ -2429,6 +2445,9 @@ <h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h
24292445
</span>
24302446
</p>
24312447
</dt>
2448+
<dd>
2449+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
2450+
</dd>
24322451
<dt>
24332452
<p class="idl-code">void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
24342453
<span class="gl-spec">
@@ -2438,6 +2457,8 @@ <h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h
24382457
</p>
24392458
</dt>
24402459
<dd>
2460+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
2461+
<br>
24412462
Draw <code>instanceCount</code> instances of geometry using the currently enabled vertex attributes.
24422463
Vertex attributes which have a non-zero divisor advance once every divisor instances.<br><br>
24432464
</dd>
@@ -2450,6 +2471,8 @@ <h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h
24502471
</p>
24512472
</dt>
24522473
<dd>
2474+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
2475+
<br>
24532476
Draw <code>instanceCount</code> instances of geometry using the currently bound element array buffer.
24542477
Vertex attributes which have a non-zero divisor advance once every divisor instances.<br><br>
24552478
</dd>
@@ -2462,6 +2485,8 @@ <h4><a name="WRITING_TO_THE_DRAWING_BUFFER">Writing to the drawing buffer</a></h
24622485
</p>
24632486
</dt>
24642487
<dd>
2488+
A <a href="../1.0/#DRAW_OPERATIONS">[Draw Operation]</a>.
2489+
<br>
24652490
Draw using the currently bound element array buffer. All error conditions specified for
24662491
<code>drawElements</code> in the section <a href="../1.0/index.html#WRITING_TO_THE_DRAWING_BUFFER">Writing
24672492
to the drawing buffer</a> of the WebGL 1.0 specification apply.<br><br>
@@ -2501,6 +2526,9 @@ <h4><a name="readpixels">Reading back pixels</a></h4>
25012526
</span>
25022527
</dt>
25032528
<dd>
2529+
A <a href="../1.0/#READ_OPERATIONS">[Read Operation]</a>.
2530+
<br>
2531+
25042532
<p>If a WebGLBuffer is bound to the <code>PIXEL_PACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
25052533
<p>
25062534
If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met,
@@ -2559,6 +2587,8 @@ <h4>Multiple render targets</h4>
25592587
</dt>
25602588
<dd>
25612589
Define the draw buffers to which all fragment colors are written.
2590+
<br>
2591+
This does not draw, this only sets up state for subsequent calls.
25622592
</dd>
25632593
<dt>
25642594
<div class="idl-code">
@@ -2573,6 +2603,7 @@ <h4>Multiple render targets</h4>
25732603
(<a href="https://www.khronos.org/registry/OpenGL/specs/es/3.0/es_spec_3.0.pdf#nameddest=subsection.4.2.3">OpenGL ES 3.0.6 &sect;4.2.3</a>,
25742604
<a href="http://www.khronos.org/opengles/sdk/docs/man3/html/glClearBuffer.xhtml" class="nonnormative">man page</a>)
25752605
</span>
2606+
These are <a href="../1.0/#DRAW_OPERATIONS">[Draw Operations]</a>.
25762607
</p>
25772608
</div>
25782609
</dt>

0 commit comments

Comments
 (0)