15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    NV_pixel_buffer_object
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_NV_pixel_buffer_object
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Contributors to ARB_pixel_buffer_object
125bd8deadSopenharmony_ci    Greg Roth, NVIDIA
135bd8deadSopenharmony_ci
145bd8deadSopenharmony_ciContact
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Mathias Heyer, NVIDIA Corporation (mheyer 'at' nvidia.com) 
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciStatus
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Complete.
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciVersion
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Last Modified Date: April 27th, 2020
255bd8deadSopenharmony_ci    Revision: 3.0
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciNumber
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    OpenGL ES Extension #134
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciDependencies
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    Written based on the wording of the OpenGL ES 2.0 specification.
345bd8deadSopenharmony_ci    
355bd8deadSopenharmony_ci    OES_mapbuffer affects the definition of this specification
365bd8deadSopenharmony_ci    EXT_map_buffer_range affects the definition of this specification 
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ciOverview
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    This extension permits buffer objects to be used not only with vertex
415bd8deadSopenharmony_ci    array data, but also with pixel data.  The intent is to provide more
425bd8deadSopenharmony_ci    acceleration opportunities for OpenGL pixel commands.
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    While a single buffer object can be bound for both vertex arrays and
455bd8deadSopenharmony_ci    pixel commands, we use the designations vertex buffer object (VBO)
465bd8deadSopenharmony_ci    and pixel buffer object (PBO) to indicate their particular usage in
475bd8deadSopenharmony_ci    a given situation.
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ci    This extension does not add any new functionality to buffer objects
505bd8deadSopenharmony_ci    themselves.  It simply adds two new targets to which buffer objects
515bd8deadSopenharmony_ci    can be bound: GL_PIXEL_PACK_BUFFER_NV and GL_PIXEL_UNPACK_BUFFER_NV.
525bd8deadSopenharmony_ci    When a buffer object is bound to the GL_PIXEL_PACK_BUFFER_NV target,
535bd8deadSopenharmony_ci    commands such as glReadPixels pack (write) their data into a buffer
545bd8deadSopenharmony_ci    object. When a buffer object is bound to the GL_PIXEL_UNPACK_BUFFER_NV
555bd8deadSopenharmony_ci    target, commands such as glTexImage2D unpack (read) their
565bd8deadSopenharmony_ci    data from a buffer object.
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    There are a several approaches to improve graphics performance
595bd8deadSopenharmony_ci    with PBOs.  Some of the most interesting approaches are:
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    - Streaming texture updates:  If the application uses
625bd8deadSopenharmony_ci      glMapBufferOES/glMapBufferRangeEXT/glUnmapBufferOES to write
635bd8deadSopenharmony_ci      its data for glTexSubImage into a buffer object, at least one of
645bd8deadSopenharmony_ci      the data copies usually required to download a texture can be
655bd8deadSopenharmony_ci      eliminated, significantly increasing texture download performance.
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    - Asynchronous glReadPixels:  If an application needs to read back a
685bd8deadSopenharmony_ci      number of images and process them with the CPU, the existing GL
695bd8deadSopenharmony_ci      interface makes it nearly impossible to pipeline this operation.
705bd8deadSopenharmony_ci      The driver will typically send the hardware a readback command
715bd8deadSopenharmony_ci      when glReadPixels is called, and then wait for all of the data to
725bd8deadSopenharmony_ci      be available before returning control to the application.  Then,
735bd8deadSopenharmony_ci      the application can either process the data immediately or call
745bd8deadSopenharmony_ci      glReadPixels again; in neither case will the readback overlap with
755bd8deadSopenharmony_ci      the processing.  If the application issues several readbacks
765bd8deadSopenharmony_ci      into several buffer objects, however, and then maps each one to
775bd8deadSopenharmony_ci      process its data, then the readbacks can proceed in parallel with
785bd8deadSopenharmony_ci      the data processing.
795bd8deadSopenharmony_ci
805bd8deadSopenharmony_ci    - Render to vertex array:  The application can use a fragment
815bd8deadSopenharmony_ci      program to render some image into one of its buffers, then read
825bd8deadSopenharmony_ci      this image out into a buffer object via glReadPixels.  Then, it can
835bd8deadSopenharmony_ci      use this buffer object as a source of vertex data.
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ciNew Procedures and Functions
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    None.
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ciNew Tokens
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci    Accepted by the <target> parameters of BindBuffer, BufferData,
945bd8deadSopenharmony_ci    BufferSubData, MapBufferOES, MapBufferRangeEXT, UnmapBufferOES,
955bd8deadSopenharmony_ci    FlushMappedBufferRangeEXT, GetBufferParameteriv, and
965bd8deadSopenharmony_ci    GetBufferPointervOES:
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci        PIXEL_PACK_BUFFER_NV                        0x88EB
995bd8deadSopenharmony_ci        PIXEL_UNPACK_BUFFER_NV                      0x88EC
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
1025bd8deadSopenharmony_ci    GetFloatv:
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci        PIXEL_PACK_BUFFER_BINDING_NV                0x88ED
1055bd8deadSopenharmony_ci        PIXEL_UNPACK_BUFFER_BINDING_NV              0x88EF
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL Operation)
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci -- Section 2.9 "Buffer Objects"
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci    Replace the first two paragraphs with:
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci    "The vertex data arrays described in section 2.8 are stored in
1155bd8deadSopenharmony_ci    client memory.  It is sometimes desirable to store frequently accessed
1165bd8deadSopenharmony_ci    client data, such as vertex array and pixel data, in high-performance
1175bd8deadSopenharmony_ci    server memory.  GL buffer objects provide a mechanism for clients to
1185bd8deadSopenharmony_ci    use to allocate, initialize, and access such memory."
1195bd8deadSopenharmony_ci
1205bd8deadSopenharmony_ci    The name space for buffer objects is the unsigned integer, with zero
1215bd8deadSopenharmony_ci    reserved for the GL.  A buffer object is created by binding an unused
1225bd8deadSopenharmony_ci    name to a buffer target.  The binding is effected by calling
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci       void BindBuffer(enum target, uint buffer);
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    <target> must be one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1275bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV.  The ARRAY_BUFFER
1285bd8deadSopenharmony_ci    target is discussed in section 2.9.1  The ELEMENT_ARRAY_BUFFER target
1295bd8deadSopenharmony_ci    is discussed in section 2.9.2.  The PIXEL_UNPACK_BUFFER_NV and
1305bd8deadSopenharmony_ci    PIXEL_PACK_BUFFER_NV targets are discussed later in sections 3.7.1 and
1315bd8deadSopenharmony_ci    4.3.  If the buffer object named <buffer> has not been
1325bd8deadSopenharmony_ci    previously bound or has been deleted since the last binding, the
1335bd8deadSopenharmony_ci    GL creates a new state vector, initialized with a zero-sized memory
1345bd8deadSopenharmony_ci    buffer and comprising the state values listed in table 2.5."
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    Replace the 5th paragraph with:
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    "Initially, each buffer object target is bound to zero.  There is
1395bd8deadSopenharmony_ci    no buffer object corresponding to the name zero so client attempts
1405bd8deadSopenharmony_ci    to modify or query buffer object state for a target bound to zero
1415bd8deadSopenharmony_ci    generate an INVALID_OPERATION error."
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci    Replace the phrase listing the valid targets for BufferData in the
1445bd8deadSopenharmony_ci    9th paragraph with:
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci    "with <target> set to one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1475bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV,"
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    In the 10th paragraph describing buffer object usage modes, replace
1505bd8deadSopenharmony_ci    the phrase "specified once" with "specified once per repetition of
1515bd8deadSopenharmony_ci    the usage pattern" for the STREAM_* and STATIC_* usage values.
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci    Also in the 10th paragraph describing buffer object usage modes,
1545bd8deadSopenharmony_ci    replace the phrases "of a GL drawing command." and "for GL drawing
1555bd8deadSopenharmony_ci    commands." with "for GL drawing and image specification commands." for
1565bd8deadSopenharmony_ci    the *_DRAW usage values.
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci    Replace the phrase listing the valid targets for BufferSubData with:
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci    "with <target> set to one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1615bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV."
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    Replace the phrase listing the valid targets for MapBufferOES with:
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    "with <target> set to one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1665bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV."
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    Replace the phrase listing the valid targets for UnmapBufferOES with:
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci    "with <target> set to one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1715bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV."
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    Replace the phrase listing the valid targets for MapBufferRangeEXT
1745bd8deadSopenharmony_ci    with:
1755bd8deadSopenharmony_ci
1765bd8deadSopenharmony_ci    "with <target> set to one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1775bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV."
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    Replace the phrase listing the valid targets for
1805bd8deadSopenharmony_ci    FlushMappedBufferRangeEXT with:
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    "with <target> set to one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER,
1835bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_NV, or PIXEL_PACK_BUFFER_NV."
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci -- Section 2.9.2 "Array Indices in Buffer Objects"
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci    Delete the 3rd paragraph that explains how the ELEMENT_ARRAY_BUFFER
1885bd8deadSopenharmony_ci    target is acceptable for the commands specified in section 2.9.
1895bd8deadSopenharmony_ci    The updated section 2.9 language already says this.
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
1925bd8deadSopenharmony_ci
1935bd8deadSopenharmony_ci -- Section 3.6 "Pixel Rectangles"
1945bd8deadSopenharmony_ci
1955bd8deadSopenharmony_ci    Replace the last two paragraphs with:
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    "This section describes only how these rectangles are defined in
1985bd8deadSopenharmony_ci     buffer object and client memory, and the steps involved in
1995bd8deadSopenharmony_ci     transferring pixel rectangles from buffer object or client memory
2005bd8deadSopenharmony_ci     to the GL or vice-versa.
2015bd8deadSopenharmony_ci     Parameters controlling the encoding of pixels in buffer object or
2025bd8deadSopenharmony_ci     client memory (for reading and writing) are set with the command
2035bd8deadSopenharmony_ci     PixelStorei."
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci -- Rename Section 3.6.1 "Pixel Storage Modes and Pixel Buffer Objects"
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ci    Add to the end of the section:
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    "In addition to storing pixel data in client memory, pixel data
2105bd8deadSopenharmony_ci    may also be stored in buffer objects (described in section 2.9).
2115bd8deadSopenharmony_ci    The current pixel unpack and pack buffer objects are designated
2125bd8deadSopenharmony_ci    by the PIXEL_UNPACK_BUFFER_NV and PIXEL_PACK_BUFFER_NV targets
2135bd8deadSopenharmony_ci    respectively.
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci    Initially, zero is bound for the PIXEL_UNPACK_BUFFER_NV, indicating
2165bd8deadSopenharmony_ci    that image specification commands such as TexImage*D source their
2175bd8deadSopenharmony_ci    pixels from client memory pointer parameters.  However, if a non-zero
2185bd8deadSopenharmony_ci    buffer object is bound as the current pixel unpack buffer, then
2195bd8deadSopenharmony_ci    the pointer parameter is treated as an offset into the designated
2205bd8deadSopenharmony_ci    buffer object."
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci -- Section 3.6.2 "Transfer of Pixel Rectangles", page 61.
2245bd8deadSopenharmony_ci
2255bd8deadSopenharmony_ci    Change the 1st sentence of the 1st paragraph to read:
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci    "The process of transferring pixels encoded in buffer object
2285bd8deadSopenharmony_ci     or client memory is diagrammed in figure 3.5."
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci    Change the 4th sentence of the 2nd paragraph to read:
2315bd8deadSopenharmony_ci
2325bd8deadSopenharmony_ci    "<data> refers to the data to be transferred."
2335bd8deadSopenharmony_ci
2345bd8deadSopenharmony_ci    [data is no longer necessarily a pointer.]
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci    Change the initial phrase in the 1st sentence of the 1st paragraph
2375bd8deadSopenharmony_ci    in subsection "Unpacking" to read:
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ci    "Data are taken from the currently bound pixel unpack buffer or
2405bd8deadSopenharmony_ci    client memory as a sequence of..."
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    Insert this paragraph after the 1st paragraph in subsection 
2435bd8deadSopenharmony_ci    "Unpacking":
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ci    "If a pixel unpack buffer is bound (as indicated by a non-zero
2465bd8deadSopenharmony_ci    value of PIXEL_UNPACK_BUFFER_BINDING_NV), <data> is an offset
2475bd8deadSopenharmony_ci    into the pixel unpack buffer and the pixels are unpacked from the
2485bd8deadSopenharmony_ci    buffer relative to this offset; otherwise, <data> is a pointer to
2495bd8deadSopenharmony_ci    a block client memory and the pixels are unpacked from the client
2505bd8deadSopenharmony_ci    memory relative to the pointer.  If a pixel unpack buffer object
2515bd8deadSopenharmony_ci    is bound and unpacking the pixel data according to the process
2525bd8deadSopenharmony_ci    described below would access memory beyond the size of the pixel
2535bd8deadSopenharmony_ci    unpack buffer's memory size, INVALID_OPERATION results.  If a pixel
2545bd8deadSopenharmony_ci    unpack buffer object is bound and <data> is not evenly divisible
2555bd8deadSopenharmony_ci    into the number of basic machine units needed to store in memory the
2565bd8deadSopenharmony_ci    corresponding GL data type from table 3.4 for the <type> parameter,
2575bd8deadSopenharmony_ci    INVALID_OPERATION results."
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ci -- Section 3.7.1 "Texture Image Specification", page 66.
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci    Replace the last phrase in the 2nd to last sentence in the 1st
2625bd8deadSopenharmony_ci    paragraph with:
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ci    "and a reference to the image data in the currently bound pixel unpack
2655bd8deadSopenharmony_ci    buffer or client memory, as described in section 3.6.2."
2665bd8deadSopenharmony_ci
2675bd8deadSopenharmony_ci    Replace the 1st sentence in the 9th paragraph with:
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    "The image itself (referred to by <data>) is a sequence of groups
2705bd8deadSopenharmony_ci    of values."
2715bd8deadSopenharmony_ci
2725bd8deadSopenharmony_ci    Replace the last paragraph with:
2735bd8deadSopenharmony_ci
2745bd8deadSopenharmony_ci    "If the data argument of TexImage2D is a NULL pointer, and the
2755bd8deadSopenharmony_ci     pixel unpack buffer object is zero, a two- or three-dimensional
2765bd8deadSopenharmony_ci     texel array is created with the specified target, level, internalformat,
2775bd8deadSopenharmony_ci     border, width, height, and depth, but with unspecified image contents.
2785bd8deadSopenharmony_ci     In this case no pixel values are accessed in client memory, and no pixel
2795bd8deadSopenharmony_ci     processing is performed. Errors are generated, however, exactly as though
2805bd8deadSopenharmony_ci     the data pointer were valid. Otherwise if the pixel unpack buffer object
2815bd8deadSopenharmony_ci     is non-zero, the data argument is treatedly normally to refer to the
2825bd8deadSopenharmony_ci     beginning of the pixel unpack buffer object's data."
2835bd8deadSopenharmony_ci
2845bd8deadSopenharmony_ci -- Section 3.7.3 "Compressed Texture Images", page 73.
2855bd8deadSopenharmony_ci
2865bd8deadSopenharmony_ci    Replace the 3rd sentence of the 2nd paragraph with:
2875bd8deadSopenharmony_ci
2885bd8deadSopenharmony_ci    "<data> refers to compressed image data stored in the compressed
2895bd8deadSopenharmony_ci    image format corresponding to internalformat.  If a pixel
2905bd8deadSopenharmony_ci    unpack buffer is bound (as indicated by a non-zero value of
2915bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_BINDING_NV), <data> is an offset into the
2925bd8deadSopenharmony_ci    pixel unpack buffer and the compressed data is read from the buffer
2935bd8deadSopenharmony_ci    relative to this offset; otherwise, <data> is a pointer to a block
2945bd8deadSopenharmony_ci    client memory and the compressed data is read from the client memory
2955bd8deadSopenharmony_ci    relative to the pointer."
2965bd8deadSopenharmony_ci    
2975bd8deadSopenharmony_ci    Replace the 2nd sentence in the 3rd paragraph with:
2985bd8deadSopenharmony_ci
2995bd8deadSopenharmony_ci    "Compressed texture images are treated as an array of <imageSize>
3005bd8deadSopenharmony_ci    ubytes relative to <data>.  If a pixel unpack buffer object is bound
3015bd8deadSopenharmony_ci    and data+imageSize is greater than the size of the pixel buffer,
3025bd8deadSopenharmony_ci    INVALID_OPERATION results."
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment
3055bd8deadSopenharmony_ciOperations and the Frame Buffer)
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ci -- Section 4.3 "Reading Pixels", page 104.
3085bd8deadSopenharmony_ci
3095bd8deadSopenharmony_ci    Replace the first paragraph with:
3105bd8deadSopenharmony_ci    
3115bd8deadSopenharmony_ci    "Pixels may be read from the framebuffer to pixel pack buffer or 
3125bd8deadSopenharmony_ci     client memory using the ReadPixels commands, as described below.
3135bd8deadSopenharmony_ci     Pixels may also be copied from pixel unpack buffer, client memory or
3145bd8deadSopenharmony_ci     the framebuffer to texture images in the GL using the TexImage2D and
3155bd8deadSopenharmony_ci     CopyTexImage2D commands, as described in section 3.7.1.
3165bd8deadSopenharmony_ci
3175bd8deadSopenharmony_ci -- Section 4.3.1 "Reading Pixels", page 104.
3185bd8deadSopenharmony_ci
3195bd8deadSopenharmony_ci    Replace 1st sentence of the 1st paragraph with:
3205bd8deadSopenharmony_ci
3215bd8deadSopenharmony_ci    "The method for reading pixels from the framebuffer and placing them in
3225bd8deadSopenharmony_ci    pixel pack buffer or client memory is diagrammed in figure 4.2."
3235bd8deadSopenharmony_ci
3245bd8deadSopenharmony_ci    Add this paragraph after the 1st paragraph:
3255bd8deadSopenharmony_ci
3265bd8deadSopenharmony_ci    "Initially, zero is bound for the PIXEL_PACK_BUFFER_NV, indicating
3275bd8deadSopenharmony_ci    that image read and query commands such as ReadPixels return
3285bd8deadSopenharmony_ci    pixels results into client memory pointer parameters.  However, if
3295bd8deadSopenharmony_ci    a non-zero buffer object is bound as the current pixel pack buffer,
3305bd8deadSopenharmony_ci    then the pointer parameter is treated as an offset into the designated
3315bd8deadSopenharmony_ci    buffer object."
3325bd8deadSopenharmony_ci
3335bd8deadSopenharmony_ci    Rename "Placement in Client Memory" to "Placement in Pixel Pack
3345bd8deadSopenharmony_ci    Buffer or Client Memory".
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci    Insert this paragraph at the start of the newly renamed
3375bd8deadSopenharmony_ci    subsection "Placement in Pixel Pack Buffer or Client Memory":
3385bd8deadSopenharmony_ci
3395bd8deadSopenharmony_ci    "If a pixel pack buffer is bound (as indicated by a non-zero value
3405bd8deadSopenharmony_ci    of PIXEL_PACK_BUFFER_BINDING_NV), <data> is an offset into the
3415bd8deadSopenharmony_ci    pixel pack buffer and the pixels are packed into the
3425bd8deadSopenharmony_ci    buffer relative to this offset; otherwise, <data> is a pointer to a
3435bd8deadSopenharmony_ci    block client memory and the pixels are packed into the client memory
3445bd8deadSopenharmony_ci    relative to the pointer.  If a pixel pack buffer object is bound and
3455bd8deadSopenharmony_ci    packing the pixel data according to the pixel pack storage state
3465bd8deadSopenharmony_ci    would access memory beyond the size of the pixel pack buffer's
3475bd8deadSopenharmony_ci    memory size, INVALID_OPERATION results.  If a pixel pack buffer object
3485bd8deadSopenharmony_ci    is bound and <data> is not evenly divisible into the number of basic
3495bd8deadSopenharmony_ci    machine units needed to store in memory the corresponding GL data type
3505bd8deadSopenharmony_ci    from table 3.5 for the <type> parameter, INVALID_OPERATION results."
3515bd8deadSopenharmony_ci
3525bd8deadSopenharmony_ci
3535bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 2.0 Specification (Special Functions)
3545bd8deadSopenharmony_ci
3555bd8deadSopenharmony_ci    None
3565bd8deadSopenharmony_ci
3575bd8deadSopenharmony_ci
3585bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State
3595bd8deadSopenharmony_ciRequests)
3605bd8deadSopenharmony_ci
3615bd8deadSopenharmony_ci--- Section 6.1.3 Enumerated Queries
3625bd8deadSopenharmony_ci
3635bd8deadSopenharmony_ci    Change the 1st sentence of the 3rd paragraph to read:
3645bd8deadSopenharmony_ci    "The command
3655bd8deadSopenharmony_ci        void GetBufferParameteriv( enum target, enum value, T data );
3665bd8deadSopenharmony_ci    returns information about <target>, which may be one of ARRAY_BUFFER,
3675bd8deadSopenharmony_ci    ELEMENT_ARRAY_BUFFER, PIXEL_PACK_BUFFER_NV, PIXEL_UNPACK_BUFFER_NV
3685bd8deadSopenharmony_ci    indicating the currently bound vertex array, element array, pixel pack
3695bd8deadSopenharmony_ci    and pixel unpack buffer object."
3705bd8deadSopenharmony_ci
3715bd8deadSopenharmony_ci -- Section 6.1.13 "Buffer Object Queries".
3725bd8deadSopenharmony_ci
3735bd8deadSopenharmony_ci    (description of glGetBufferPointervOES)  
3745bd8deadSopenharmony_ci    Change the 2nd sentence of the 2nd paragraph to read:
3755bd8deadSopenharmony_ci    "<target> is ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, PIXEL_PACK_BUFFER_NV,
3765bd8deadSopenharmony_ci    or PIXEL_UNPACK_BUFFER_NV."
3775bd8deadSopenharmony_ci
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ciErrors
3805bd8deadSopenharmony_ci
3815bd8deadSopenharmony_ci    INVALID_ENUM is generated if the <target> parameter of
3825bd8deadSopenharmony_ci    BindBuffer, BufferData, BufferSubData, MapBufferOES, UnmapBufferOES,
3835bd8deadSopenharmony_ci    GetBufferParameteriv or GetBufferPointervOES is not
3845bd8deadSopenharmony_ci    one of ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, PIXEL_PACK_BUFFER_NV,
3855bd8deadSopenharmony_ci    or PIXEL_UNPACK_BUFFER_NV.
3865bd8deadSopenharmony_ci
3875bd8deadSopenharmony_ci    INVALID_OPERATION is generated if CompressedTexImage2D, 
3885bd8deadSopenharmony_ci    CompressedTexSubImage2D, TexImage2D or TexSubImage2D would unpack
3895bd8deadSopenharmony_ci    (read) data from the currently bound PIXEL_UNPACK_BUFFER_NV buffer
3905bd8deadSopenharmony_ci    object such that the memory reads required for the command would exceed
3915bd8deadSopenharmony_ci    the memory (data store) size of the buffer object.
3925bd8deadSopenharmony_ci
3935bd8deadSopenharmony_ci    INVALID_OPERATION is generated if ReadPixels or ReadnPixelsEXT 
3945bd8deadSopenharmony_ci    would pack (write) data to the currently bound PIXEL_PACK_BUFFER_NV
3955bd8deadSopenharmony_ci    buffer object such that the memory writes required for the command would
3965bd8deadSopenharmony_ci    exceed the memory (data store) size of the buffer object.
3975bd8deadSopenharmony_ci
3985bd8deadSopenharmony_ci    INVALID_OPERATION is generated by ReadPixels or ReadnPixelsEXT
3995bd8deadSopenharmony_ci    if the current PIXEL_PACK_BUFFER_BINDING_NV value is non-zero and the
4005bd8deadSopenharmony_ci    table/image/values/span/img/data parameter is not evenly divisible
4015bd8deadSopenharmony_ci    into the number of basic machine units needed to store in memory a
4025bd8deadSopenharmony_ci    datum indicated by the type parameter.
4035bd8deadSopenharmony_ci
4045bd8deadSopenharmony_ci    INVALID_OPERATION is generated by TexImage2D or TexSubImage2D
4055bd8deadSopenharmony_ci    if current PIXEL_UNPACK_BUFFER_BINDING_NV value is non-zero and the data
4065bd8deadSopenharmony_ci    parameter is not evenly divisible into the number of basic machine
4075bd8deadSopenharmony_ci    units needed to store in memory a datum indicated by the type
4085bd8deadSopenharmony_ci    parameter.
4095bd8deadSopenharmony_ci
4105bd8deadSopenharmony_ciDependencies on OES_mapbuffer
4115bd8deadSopenharmony_ci    
4125bd8deadSopenharmony_ci    If OES_mapbuffer is not present, references to MapBufferOES and
4135bd8deadSopenharmony_ci    UnmapBufferOES should be ignored and language referring to mapped
4145bd8deadSopenharmony_ci    buffer objects should be removed.
4155bd8deadSopenharmony_ci
4165bd8deadSopenharmony_ciDependencies on EXT_map_buffer_range
4175bd8deadSopenharmony_ci    
4185bd8deadSopenharmony_ci    If EXT_map_buffer_range is not present, references to
4195bd8deadSopenharmony_ci    MapBufferRangeEXT anf FlushMappedBufferRangeEXT should be ignored.
4205bd8deadSopenharmony_ci    
4215bd8deadSopenharmony_ciNew State
4225bd8deadSopenharmony_ci
4235bd8deadSopenharmony_ci(table 6.13, Pixels, p. 147)
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci                                                         Initial
4265bd8deadSopenharmony_ci    Get Value                        Type   Get Command  Value    Sec    
4275bd8deadSopenharmony_ci    -------------------------------  ----   -----------  -------  ------ 
4285bd8deadSopenharmony_ci    PIXEL_PACK_BUFFER_BINDING_NV    Z+     GetIntegerv  0        4.3.1  
4295bd8deadSopenharmony_ci    PIXEL_UNPACK_BUFFER_BINDING_NV  Z+     GetIntegerv  0        3.6.1  
4305bd8deadSopenharmony_ci
4315bd8deadSopenharmony_ci
4325bd8deadSopenharmony_ci
4335bd8deadSopenharmony_ciUsage Examples
4345bd8deadSopenharmony_ci
4355bd8deadSopenharmony_ci    Convenient macro definition for specifying buffer offsets:
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ci        #define BUFFER_OFFSET(i) ((char *)NULL + (i))
4385bd8deadSopenharmony_ci
4395bd8deadSopenharmony_ci    Example 1: Render to vertex array:
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci        const int numberVertices = 100;
4425bd8deadSopenharmony_ci
4435bd8deadSopenharmony_ci        // Create a buffer object for a number of vertices consisting of
4445bd8deadSopenharmony_ci        // 4 float values per vertex
4455bd8deadSopenharmony_ci        glGenBuffers(1, vertexBuffer);
4465bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, vertexBuffer);
4475bd8deadSopenharmony_ci        glBufferData(GL_PIXEL_PACK_BUFFER_NV, numberVertices*4,
4485bd8deadSopenharmony_ci                     NULL, GL_DYNAMIC_DRAW);
4495bd8deadSopenharmony_ci
4505bd8deadSopenharmony_ci        // Render vertex data into 100x1 strip of framebuffer using a
4515bd8deadSopenharmony_ci        // shader program
4525bd8deadSopenharmony_ci        glUseProgram(program);
4535bd8deadSopenharmony_ci        renderVertexData();
4545bd8deadSopenharmony_ci        glBindProgramARB(FRAGMENT_PROGRAM_ARB, 0);
4555bd8deadSopenharmony_ci
4565bd8deadSopenharmony_ci        // Read the vertex data back from framebuffer
4575bd8deadSopenharmony_ci        glReadPixels(0, 0, numberVertices, 1, GL_BGRA, GL_UNSIGNED_BYTE,
4585bd8deadSopenharmony_ci                     BUFFER_OFFSET(0));
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ci        // Change the binding point of the buffer object to
4615bd8deadSopenharmony_ci        // the vertex array binding point
4625bd8deadSopenharmony_ci        glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
4635bd8deadSopenharmony_ci
4645bd8deadSopenharmony_ci        glEnableVertexAttribArray(0);
4655bd8deadSopenharmony_ci        glVertexAttribPointer(0, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, BUFFER_OFFSET(0));
4665bd8deadSopenharmony_ci        glDrawArrays(TRIANGLE_STRIP, 0, numberVertices);
4675bd8deadSopenharmony_ci
4685bd8deadSopenharmony_ci
4695bd8deadSopenharmony_ci    Example 2: Streaming textures
4705bd8deadSopenharmony_ci
4715bd8deadSopenharmony_ci    Streaming textures using pixel buffer objects:
4725bd8deadSopenharmony_ci
4735bd8deadSopenharmony_ci        const int texWidth = 256;
4745bd8deadSopenharmony_ci        const int texHeight = 256;
4755bd8deadSopenharmony_ci        const int texsize = texWidth * texHeight * 4;
4765bd8deadSopenharmony_ci        void *pboMemory, *texData;
4775bd8deadSopenharmony_ci
4785bd8deadSopenharmony_ci        // Define texture level zero (without an image); notice the
4795bd8deadSopenharmony_ci        // explicit bind to the zero pixel unpack buffer object so that
4805bd8deadSopenharmony_ci        // pass NULL for the image data leaves the texture image
4815bd8deadSopenharmony_ci        // unspecified.
4825bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_UNPACK_BUFFER_NV, 0);
4835bd8deadSopenharmony_ci        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0,
4845bd8deadSopenharmony_ci                     GL_RGBA, GL_UNSIGNED_BYTE, NULL);
4855bd8deadSopenharmony_ci
4865bd8deadSopenharmony_ci        // Create and bind texture image buffer object
4875bd8deadSopenharmony_ci        glGenBuffers(1, &texBuffer);
4885bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_UNPACK_BUFFER_NV, texBuffer);
4895bd8deadSopenharmony_ci
4905bd8deadSopenharmony_ci        // Setup texture environment
4915bd8deadSopenharmony_ci        ...
4925bd8deadSopenharmony_ci
4935bd8deadSopenharmony_ci        texData = getNextImage();
4945bd8deadSopenharmony_ci
4955bd8deadSopenharmony_ci        while (texData) {
4965bd8deadSopenharmony_ci
4975bd8deadSopenharmony_ci            // Reset the contents of the texSize-sized buffer object
4985bd8deadSopenharmony_ci            glBufferData(GL_PIXEL_UNPACK_BUFFER_NV, texSize, NULL,
4995bd8deadSopenharmony_ci                         GL_STREAM_DRAW);
5005bd8deadSopenharmony_ci
5015bd8deadSopenharmony_ci            // Map the texture image buffer (the contents of which
5025bd8deadSopenharmony_ci            // are undefined due to the previous glBufferData)
5035bd8deadSopenharmony_ci            pboMemory = glMapBufferOES(GL_PIXEL_UNPACK_BUFFER_NV,
5045bd8deadSopenharmony_ci                                    GL_WRITE_ONLY);
5055bd8deadSopenharmony_ci
5065bd8deadSopenharmony_ci            // Modify (sub-)buffer data
5075bd8deadSopenharmony_ci            memcpy(pboMemory, texData, texsize);
5085bd8deadSopenharmony_ci
5095bd8deadSopenharmony_ci            // Unmap the texture image buffer
5105bd8deadSopenharmony_ci            glUnmapBufferOES(GL_PIXEL_UNPACK_BUFFER_NV);
5115bd8deadSopenharmony_ci
5125bd8deadSopenharmony_ci            // Update (sub-)teximage from texture image buffer
5135bd8deadSopenharmony_ci            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight,
5145bd8deadSopenharmony_ci                            GL_RGBA, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
5155bd8deadSopenharmony_ci
5165bd8deadSopenharmony_ci            // Draw textured geometry
5175bd8deadSopenharmony_ci            ...
5185bd8deadSopenharmony_ci
5195bd8deadSopenharmony_ci            texData = getNextImage();
5205bd8deadSopenharmony_ci        }
5215bd8deadSopenharmony_ci
5225bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_UNPACK_BUFFER_NV, 0);
5235bd8deadSopenharmony_ci
5245bd8deadSopenharmony_ci
5255bd8deadSopenharmony_ci    Example 3: Asynchronous glReadPixels
5265bd8deadSopenharmony_ci
5275bd8deadSopenharmony_ci    Traditional glReadPixels:
5285bd8deadSopenharmony_ci
5295bd8deadSopenharmony_ci        const int imagewidth = 640;
5305bd8deadSopenharmony_ci        const int imageheight = 480;
5315bd8deadSopenharmony_ci        GLubyte readBuffer[imagewidth*imageheight*4];
5325bd8deadSopenharmony_ci
5335bd8deadSopenharmony_ci        // Render to framebuffer
5345bd8deadSopenharmony_ci        renderScene()
5355bd8deadSopenharmony_ci
5365bd8deadSopenharmony_ci        // Read image from framebuffer
5375bd8deadSopenharmony_ci        glReadPixels(0, 0, imagewidth, imageheight, GL_RGBA,
5385bd8deadSopenharmony_ci                     GL_UNSIGNED_BYTE, readBuffer);
5395bd8deadSopenharmony_ci
5405bd8deadSopenharmony_ci        // Process image when glReadPixels returns after reading the
5415bd8deadSopenharmony_ci        // whole buffer
5425bd8deadSopenharmony_ci        processImage(readBuffer);
5435bd8deadSopenharmony_ci
5445bd8deadSopenharmony_ci
5455bd8deadSopenharmony_ci    Asynchronous glReadPixels:
5465bd8deadSopenharmony_ci
5475bd8deadSopenharmony_ci        const int imagewidth = 640;
5485bd8deadSopenharmony_ci        const int imageheight = 480;
5495bd8deadSopenharmony_ci        const int imageSize = imagewidth*imageheight*4;
5505bd8deadSopenharmony_ci
5515bd8deadSopenharmony_ci        glGenBuffers(2, imageBuffers);
5525bd8deadSopenharmony_ci
5535bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[0]);
5545bd8deadSopenharmony_ci        glBufferData(GL_PIXEL_PACK_BUFFER_NV, imageSize / 2, NULL,
5555bd8deadSopenharmony_ci                     GL_STREAM_DRAW);
5565bd8deadSopenharmony_ci
5575bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[1]);
5585bd8deadSopenharmony_ci        glBufferData(GL_PIXEL_PACK_BUFFER_NV, imageSize / 2, NULL,
5595bd8deadSopenharmony_ci                     GL_STREAM_DRAW);
5605bd8deadSopenharmony_ci
5615bd8deadSopenharmony_ci        // Render to framebuffer
5625bd8deadSopenharmony_ci        glDrawBuffer(GL_BACK);
5635bd8deadSopenharmony_ci        renderScene();
5645bd8deadSopenharmony_ci
5655bd8deadSopenharmony_ci        // Bind two different buffer objects and start the glReadPixels
5665bd8deadSopenharmony_ci        // asynchronously. Each call will return directly after
5675bd8deadSopenharmony_ci        // starting the DMA transfer.
5685bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[0]);
5695bd8deadSopenharmony_ci        glReadPixels(0, 0, imagewidth, imageheight/2, GL_RGBA,
5705bd8deadSopenharmony_ci                     GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
5715bd8deadSopenharmony_ci
5725bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[1]);
5735bd8deadSopenharmony_ci        glReadPixels(0, imageheight/2, imagewidth, imageheight/2, GL_RGBA,
5745bd8deadSopenharmony_ci                     GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
5755bd8deadSopenharmony_ci
5765bd8deadSopenharmony_ci        // Process partial images.  Mapping the buffer waits for
5775bd8deadSopenharmony_ci        // outstanding DMA transfers into the buffer to finish.
5785bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[0]);
5795bd8deadSopenharmony_ci        pboMemory1 = glMapBufferRangeEXT(GL_PIXEL_PACK_BUFFER_NV, 0,
5805bd8deadSopenharmony_ci                                         imageSize/2, GL_MAP_READ_BIT_EXT);
5815bd8deadSopenharmony_ci        processImage(pboMemory1);
5825bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[1]);
5835bd8deadSopenharmony_ci        pboMemory2 = glMapBufferRangeEXT(GL_PIXEL_PACK_BUFFER_NV, 0,
5845bd8deadSopenharmony_ci                                         imageSize/2, GL_MAP_READ_BIT_EXT);
5855bd8deadSopenharmony_ci        processImage(pboMemory2);
5865bd8deadSopenharmony_ci
5875bd8deadSopenharmony_ci        // Unmap the image buffers
5885bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[0]);
5895bd8deadSopenharmony_ci        glUnmapBuffer(GL_PIXEL_PACK_BUFFER_NV);
5905bd8deadSopenharmony_ci        glBindBuffer(GL_PIXEL_PACK_BUFFER_NV, imageBuffers[1]);
5915bd8deadSopenharmony_ci        glUnmapBuffer(GL_PIXEL_PACK_BUFFER_NV);
5925bd8deadSopenharmony_ci
5935bd8deadSopenharmony_ci
5945bd8deadSopenharmony_ciIssues
5955bd8deadSopenharmony_ci
5965bd8deadSopenharmony_ci
5975bd8deadSopenharmony_ci    1)  Can a given buffer be used for both vertex and pixel data?
5985bd8deadSopenharmony_ci
5995bd8deadSopenharmony_ci        RESOLVED: YES.  All buffers can be used with all buffer bindings,
6005bd8deadSopenharmony_ci        in whatever combinations the application finds useful.  Consider
6015bd8deadSopenharmony_ci        yourself warned, however, by the following issue.
6025bd8deadSopenharmony_ci
6035bd8deadSopenharmony_ci    2)  May implementations make use of the target as a hint to select
6045bd8deadSopenharmony_ci        an appropriate memory space for the buffer?
6055bd8deadSopenharmony_ci
6065bd8deadSopenharmony_ci        RESOLVED: YES, as long as such behavior is transparent to the
6075bd8deadSopenharmony_ci        application. Some implementations may choose different memory 
6085bd8deadSopenharmony_ci        spaces for different targets.
6095bd8deadSopenharmony_ci        In fact, one can imagine arbitrarily complicated heuristics for
6105bd8deadSopenharmony_ci        selecting the memory space, based on factors such as the target,
6115bd8deadSopenharmony_ci        the "usage" argument, and the application's observed behavior.
6125bd8deadSopenharmony_ci
6135bd8deadSopenharmony_ci        While it is entirely legal to create a buffer object by binding
6145bd8deadSopenharmony_ci        it to GL_ARRAY_BUFFER and loading it with data, then using it
6155bd8deadSopenharmony_ci        with the GL_PIXEL_UNPACK_BUFFER_NV or GL_PIXEL_PACK_BUFFER_NV
6165bd8deadSopenharmony_ci        binding, such behavior is liable to confuse the driver and may
6175bd8deadSopenharmony_ci        hurt performance.  If the driver implemented the hypothetical
6185bd8deadSopenharmony_ci        heuristic described earlier, such a buffer might have already
6195bd8deadSopenharmony_ci        been located in AGP memory, and so the driver would have to choose
6205bd8deadSopenharmony_ci        between two bad options: relocate the buffer into video memory, or
6215bd8deadSopenharmony_ci        accept lower performance caused by streaming pixel data from AGP.
6225bd8deadSopenharmony_ci
6235bd8deadSopenharmony_ci    3)  Should the INVALID_OPERATION error be generated if a pixel
6245bd8deadSopenharmony_ci        command would access data outside the range of the bound PBO?
6255bd8deadSopenharmony_ci
6265bd8deadSopenharmony_ci        RESOLVED:  YES.  This requires considering the command parameters
6275bd8deadSopenharmony_ci        (such as width/height/depth/format/type/pointer), the current
6285bd8deadSopenharmony_ci        pixel store (pack/unpack) state, and the command operation itself
6295bd8deadSopenharmony_ci        to determine the maximum addressed byte for the pixel command.
6305bd8deadSopenharmony_ci
6315bd8deadSopenharmony_ci        This behavior should increase the reliability of using PBO and
6325bd8deadSopenharmony_ci        guard against programmer mistakes.
6335bd8deadSopenharmony_ci
6345bd8deadSopenharmony_ci        This is particularly important for glReadPixels where returning
6355bd8deadSopenharmony_ci        data into a region outside the PBO could cause corruption of
6365bd8deadSopenharmony_ci        application memory.
6375bd8deadSopenharmony_ci
6385bd8deadSopenharmony_ci        Such bounds checking is substantially more expensive for VBO
6395bd8deadSopenharmony_ci        accesses because bounds checking on a per-vertex element basis
6405bd8deadSopenharmony_ci        for each of multiple enabled vertex arrays prior to performing
6415bd8deadSopenharmony_ci        the command compromises the performance justification of VBO.
6425bd8deadSopenharmony_ci
6435bd8deadSopenharmony_ci     4) If a pixel command with a bound PBO accesses data outside the
6445bd8deadSopenharmony_ci        range of the PBO, thereby generating a GL_INVALID_OPERATION error,
6455bd8deadSopenharmony_ci        can the pixel command end up being partially processed?
6465bd8deadSopenharmony_ci
6475bd8deadSopenharmony_ci        RESOLVED:  NO.  As for all GL errors excepting GL_OUT_OF_MEMORY
6485bd8deadSopenharmony_ci        situations, "the command generating the error is ignored so that
6495bd8deadSopenharmony_ci        it has no effect on GL state or framebuffer contents."
6505bd8deadSopenharmony_ci
6515bd8deadSopenharmony_ci        This means implementations must determine before the pixel command
6525bd8deadSopenharmony_ci        is performed whether the resulting read or write operations on
6535bd8deadSopenharmony_ci        the bound PBO will exceed the size of the PBO.
6545bd8deadSopenharmony_ci
6555bd8deadSopenharmony_ci        This means an implementation is NOT allowed to detect out of
6565bd8deadSopenharmony_ci        bounds accesses in the middle of performing the command.
6575bd8deadSopenharmony_ci  
6585bd8deadSopenharmony_ci     5) Should an INVALID_OPERATION error be generated if the offset
6595bd8deadSopenharmony_ci        within a pixel buffer to a datum comprising of N basic machine
6605bd8deadSopenharmony_ci        units is not a multiple of N?
6615bd8deadSopenharmony_ci
6625bd8deadSopenharmony_ci        RESOLVED:  YES.  This was stated for VBOs but no error was
6635bd8deadSopenharmony_ci        defined if the rule was violated.  Perhaps this needs to be
6645bd8deadSopenharmony_ci        better specified for VBO.
6655bd8deadSopenharmony_ci
6665bd8deadSopenharmony_ci        For PBO, it is reasonable and cheap to enforce the alignment rule.
6675bd8deadSopenharmony_ci        For pixel commands it means making sure the offset is evenly
6685bd8deadSopenharmony_ci        divisible by the component or group size in basic machine units.
6695bd8deadSopenharmony_ci
6705bd8deadSopenharmony_ci        This check is independent of the pixel store state because the
6715bd8deadSopenharmony_ci        pixel store state is specified in terms of pixels (not basic
6725bd8deadSopenharmony_ci        machine units) so pixel store addressing cannot create an
6735bd8deadSopenharmony_ci        unaligned access as long as the base offset is aligned.
6745bd8deadSopenharmony_ci
6755bd8deadSopenharmony_ci        Certain commands (specifically,
6765bd8deadSopenharmony_ci        glCompressedTexImage2D, glCompressedTexSubImage2D) are not
6775bd8deadSopenharmony_ci        affected by this error because the data accessed is addressed
6785bd8deadSopenharmony_ci        at the granularity of basic machine units.
6795bd8deadSopenharmony_ci
6805bd8deadSopenharmony_ci     6) Various commands do not make explicit reference to supporting
6815bd8deadSopenharmony_ci        packing or unpacking from a pixel buffer object but rather specify
6825bd8deadSopenharmony_ci        that parameters are handled in the same manner as glReadPixels,
6835bd8deadSopenharmony_ci        or the glCompressedTexImage commands.  So do such
6845bd8deadSopenharmony_ci        commands (example: glCompressedTexSubImage2D) use pixel buffers?
6855bd8deadSopenharmony_ci
6865bd8deadSopenharmony_ci        RESOLVED:  YES.  Commands that have their behavior defined based
6875bd8deadSopenharmony_ci        on commands that read or write from pixel buffers will themselves
6885bd8deadSopenharmony_ci        read or write from pixel buffers.  Relying on this reduces the
6895bd8deadSopenharmony_ci        amount of specification language to be updated.
6905bd8deadSopenharmony_ci
6915bd8deadSopenharmony_ci     7) What is the complete list of commands that can unpack (read)
6925bd8deadSopenharmony_ci        pixels from the current pixel unpack buffer object?
6935bd8deadSopenharmony_ci
6945bd8deadSopenharmony_ci            glCompressedTexImage2D
6955bd8deadSopenharmony_ci            glCompressedTexSubImage2D
6965bd8deadSopenharmony_ci            glTexImage2D
6975bd8deadSopenharmony_ci            glTexSubImage2D
6985bd8deadSopenharmony_ci
6995bd8deadSopenharmony_ci     8) What is the complete list of commands that can pack (write)
7005bd8deadSopenharmony_ci        pixels into the current pixel pack buffer object?
7015bd8deadSopenharmony_ci
7025bd8deadSopenharmony_ci            glReadPixels
7035bd8deadSopenharmony_ci
7045bd8deadSopenharmony_ci     9) Prior to this extension, passing zero for the data argument of
7055bd8deadSopenharmony_ci        glTexImage2D defined a texture image level without supplying an image.
7065bd8deadSopenharmony_ci        How does this behavior change with this extension?
7075bd8deadSopenharmony_ci
7085bd8deadSopenharmony_ci        RESOLVED:  The "unspecified image" behavior of the glTexImage
7095bd8deadSopenharmony_ci        calls only applies when bound to a zero pixel unpack buffer
7105bd8deadSopenharmony_ci        object.
7115bd8deadSopenharmony_ci
7125bd8deadSopenharmony_ci        When bound to a non-zero pixel unpack buffer object, the data
7135bd8deadSopenharmony_ci        argument to these calls is treated as an offset rather than
7145bd8deadSopenharmony_ci        a pointer so zero is a reasonable and even likely value that
7155bd8deadSopenharmony_ci        corresponds to the very beginning of the buffer object's data.
7165bd8deadSopenharmony_ci
7175bd8deadSopenharmony_ci        So to create a texture image level with unspecified image data,
7185bd8deadSopenharmony_ci        you MUST bind to the zero pixel unpack buffer object.
7195bd8deadSopenharmony_ci
7205bd8deadSopenharmony_ci        See the ammended language at the end of section 3.7.1.
7215bd8deadSopenharmony_ci
7225bd8deadSopenharmony_ci    10) How does this extension support video frame grabbers?
7235bd8deadSopenharmony_ci
7245bd8deadSopenharmony_ci        RESOLVED:  This extension extends buffer objects so they can
7255bd8deadSopenharmony_ci        operate with pixel commands, rather than just vertex array
7265bd8deadSopenharmony_ci        commands.
7275bd8deadSopenharmony_ci
7285bd8deadSopenharmony_ci        We anticipate that a future extension may provide a mechanism
7295bd8deadSopenharmony_ci        for transferring video frames from video frame grabber hardware
7305bd8deadSopenharmony_ci        or vertices from motion capture hardware (or any other source
7315bd8deadSopenharmony_ci        of aquired real-time data) directly into a buffer object to
7325bd8deadSopenharmony_ci        eliminate a copy.  Ideally, such transfers would be possible
7335bd8deadSopenharmony_ci        without requiring mapping of the buffer object.  But this
7345bd8deadSopenharmony_ci        extension does not provide such functionality.
7355bd8deadSopenharmony_ci
7365bd8deadSopenharmony_ci        We anticipate such functionality to involve binding a buffer
7375bd8deadSopenharmony_ci        object to a new target type, configuring a source (or sink) for
7385bd8deadSopenharmony_ci        data (video frames, motion capture vertex sets, etc.), and then
7395bd8deadSopenharmony_ci        commands to initiate data transfers to the bound buffer object.
7405bd8deadSopenharmony_ci        
7415bd8deadSopenharmony_ci    11) Is this the "right" way to expose render-to-vertex-array?
7425bd8deadSopenharmony_ci
7435bd8deadSopenharmony_ci        DISCUSSION:  You can use this extension to render an image
7445bd8deadSopenharmony_ci        into a framebuffer, copy the pixels into a buffer object with
7455bd8deadSopenharmony_ci        glReadPixels, and then configure vertex arrays to source the pixel
7465bd8deadSopenharmony_ci        data as vertex attributes.  This necessarily involves a copy
7475bd8deadSopenharmony_ci        from the framebuffer to the buffer object.  Future extensions
7485bd8deadSopenharmony_ci        may provide mechanisms for copy-free render-to-vertex-array
7495bd8deadSopenharmony_ci        capabilities but that is not a design goal of this extension.
7505bd8deadSopenharmony_ci        
7515bd8deadSopenharmony_ciRevision History
7525bd8deadSopenharmony_ci
7535bd8deadSopenharmony_ci    3   04/27/2020 fix example code: GL_STREAM_READ is not available in ES2.0
7545bd8deadSopenharmony_ci                   glMapBufferOES does not allow reading from the mapped pointer.
7555bd8deadSopenharmony_ci    2   10/23/2012 more cleanup, interaction with EXT_map_buffer_range
7565bd8deadSopenharmony_ci    1   04/19/2012 initial revision
7575bd8deadSopenharmony_ci        - took ARB_pixel_buffer_object, stripped everything not applicable to 
7585bd8deadSopenharmony_ci          ES, changed references to tables and sections; changed all wording
7595bd8deadSopenharmony_ci          to fit ES' language.
7605bd8deadSopenharmony_ci
761