15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_copy_buffer
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_copy_buffer
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA Corporation (jbolz 'at' nvidia.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Rob Barris, Blizzard Entertainment
165bd8deadSopenharmony_ci    Bruce Merry, ARM
175bd8deadSopenharmony_ci    Eric Werness, NVIDIA
185bd8deadSopenharmony_ci    Greg Roth, NVIDIA
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ciNotice
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ci    Copyright (c) 2009-2013 The Khronos Group Inc. Copyright terms at
235bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciSpecification Update Policy
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
285bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
295bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
305bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
315bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
325bd8deadSopenharmony_ci    described in more detail at
335bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ciStatus
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    Complete. Approved by the ARB on March 19, 2009.
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ciVersion
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ci    Last Modified Date: September 6, 2017
425bd8deadSopenharmony_ci    Author Revision: 7
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ciNumber
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    ARB Extension #59
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ciDependencies
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    Written based on the wording of the OpenGL 3.0 (August 11, 2008 draft)
515bd8deadSopenharmony_ci    specification.
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ciOverview
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    This extension provides a mechanism to do an accelerated copy from one
565bd8deadSopenharmony_ci    buffer object to another. This may be useful to load buffer objects
575bd8deadSopenharmony_ci    in a "loading thread" while minimizing cost and synchronization effort
585bd8deadSopenharmony_ci    in the "rendering thread."
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ciIP Status
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    No known IP claims.
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ciNew Tokens
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    Accepted by the target parameters of BindBuffer, BufferData,
675bd8deadSopenharmony_ci    BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData,
685bd8deadSopenharmony_ci    GetBufferPointerv, MapBufferRange, FlushMappedBufferRange,
695bd8deadSopenharmony_ci    GetBufferParameteriv, BindBufferRange, BindBufferBase,
705bd8deadSopenharmony_ci    and CopyBufferSubData:
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ci    COPY_READ_BUFFER                    0x8F36
735bd8deadSopenharmony_ci    COPY_WRITE_BUFFER                   0x8F37
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ciNew Procedures and Functions
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    void CopyBufferSubData(enum readtarget, enum writetarget,
785bd8deadSopenharmony_ci                           intptr readoffset, intptr writeoffset,
795bd8deadSopenharmony_ci                           sizeiptr size);
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.0 Specification (Rasterization)
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    Add a new subsection "Copying Between Buffers" to section 2.9:
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci    All or part of one buffer object's data store may be copied to the
865bd8deadSopenharmony_ci    data store of another buffer object by calling
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    void CopyBufferSubData(enum readtarget, enum writetarget,
895bd8deadSopenharmony_ci                           intptr readoffset, intptr writeoffset,
905bd8deadSopenharmony_ci                           sizeiptr size);
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    with readtarget and writetarget each set to one of the targets
935bd8deadSopenharmony_ci    ARRAY_BUFFER, COPY_READ_BUFFER, COPY_WRITE_BUFFER,
945bd8deadSopenharmony_ci    ELEMENT_ARRAY_BUFFER, PIXEL_PACK_BUFFER, PIXEL_UNPACK_BUFFER,
955bd8deadSopenharmony_ci    TEXTURE_BUFFER, TRANSFORM_FEEDBACK_BUFFER, or UNIFORM_BUFFER. While
965bd8deadSopenharmony_ci    any of these targets may be used, the COPY_READ_BUFFER and
975bd8deadSopenharmony_ci    COPY_WRITE_BUFFER targets are provided specifically for copies, so
985bd8deadSopenharmony_ci    that they can be done without affecting other buffer binding targets
995bd8deadSopenharmony_ci    that may be in use. writeoffset and size specify the range of data
1005bd8deadSopenharmony_ci    in the buffer object bound to writetarget that is to be replaced, in
1015bd8deadSopenharmony_ci    terms of basic machine units. readoffset and size specify the range
1025bd8deadSopenharmony_ci    of data in the buffer object bound to readtarget that is to be
1035bd8deadSopenharmony_ci    copied to the corresponding region of writetarget.
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    An INVALID_VALUE error is generated if any of readoffset,
1065bd8deadSopenharmony_ci    writeoffset, or size are negative, if readoffset+size exceeds the
1075bd8deadSopenharmony_ci    size of the buffer object bound to readtarget, or if
1085bd8deadSopenharmony_ci    writeoffset+size exceeds the size of the buffer object bound to
1095bd8deadSopenharmony_ci    writetarget.
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    An INVALID_VALUE error is generated if the same buffer object is
1125bd8deadSopenharmony_ci    bound to both readtarget and writetarget, and the ranges
1135bd8deadSopenharmony_ci    [readoffset, readoffset+size) and [writeoffset, writeoffset+size)
1145bd8deadSopenharmony_ci    overlap.
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci    An INVALID_OPERATION error is generated if zero is bound to
1175bd8deadSopenharmony_ci    readtarget or writetarget.
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    An INVALID_OPERATION error is generated if the buffer objects bound
1205bd8deadSopenharmony_ci    to either readtarget or writetarget are mapped.
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 3.0 Specification (Special Functions)
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ci    Add to the list (page 310) of "Vertex Buffer Objects" commands "not
1255bd8deadSopenharmony_ci    compiled into the display list but are executed immediately":
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci        CopyBufferSubData
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci    None
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ciGLX Protocol
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ci    The following single command is sent to the server as
1365bd8deadSopenharmony_ci    a glxsingle request:
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    CopyBufferSubData
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci        1       CARD8           opcode
1415bd8deadSopenharmony_ci        1       221             GLX opcode
1425bd8deadSopenharmony_ci        2       10              request length
1435bd8deadSopenharmony_ci        4       GLX_CONTEXT_TAG context tag
1445bd8deadSopenharmony_ci        8       CARD64          readoffset
1455bd8deadSopenharmony_ci        8       CARD64          writeoffset
1465bd8deadSopenharmony_ci        8       CARD64          size
1475bd8deadSopenharmony_ci        4       ENUM            readtarget
1485bd8deadSopenharmony_ci        4       ENUM            writetarget
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ciErrors
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci    The error INVALID_VALUE is generated by CopyBufferSubData if
1535bd8deadSopenharmony_ci    readoffset, writeoffset, or size are less than zero, or if
1545bd8deadSopenharmony_ci    readoffset+size is greater than the value of BUFFER_SIZE of
1555bd8deadSopenharmony_ci    readtarget/readBuffer, or if writeoffset+size is greater than the
1565bd8deadSopenharmony_ci    value of BUFFER_SIZE of writetarget/writeBuffer.
1575bd8deadSopenharmony_ci
1585bd8deadSopenharmony_ci    The error INVALID_OPERATION is generated by CopyBufferSubData if
1595bd8deadSopenharmony_ci    either readtarget/readBuffer or writetarget/writeBuffer are mapped.
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ci    The error INVALID_VALUE is generated by CopyBufferSubData if
1625bd8deadSopenharmony_ci    readtarget/readBuffer and writetarget/writeBuffer are the same
1635bd8deadSopenharmony_ci    buffer object, and the ranges [readoffset, readoffset+size) and
1645bd8deadSopenharmony_ci    [writeoffset, writeoffset+size) overlap.
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ciNew State
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    (add to table 6.52, Miscellaneous State, p. 390)
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci                                            Initial
1715bd8deadSopenharmony_ci    Get Value           Type    Get Command Value   Description                 Sec.    Attribute
1725bd8deadSopenharmony_ci    ----------------    ----    ----------- ------- --------------------------- ------  ---------
1735bd8deadSopenharmony_ci    COPY_READ_BUFFER    Z+      GetIntegerv 0       Buffer object bound to the  2.9     none
1745bd8deadSopenharmony_ci                                                    copy buffer "read" binding
1755bd8deadSopenharmony_ci                                                    point
1765bd8deadSopenharmony_ci    COPY_WRITE_BUFFE    Z+      GetIntegerv 0       Buffer object bound to the  2.9     none
1775bd8deadSopenharmony_ci                                                    copy buffer "write"
1785bd8deadSopenharmony_ci                                                    binding point
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ciUsage Examples
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    Replace BufferSubData with a non-cache-polluting update:
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ci        BindBuffer(COPY_READ_BUFFER, tempBuffer);
1855bd8deadSopenharmony_ci        BufferData(COPY_READ_BUFFER, updateSize, NULL, STREAM_DRAW);
1865bd8deadSopenharmony_ci        // this may return a WriteCombined mapping!
1875bd8deadSopenharmony_ci        ptr = MapBuffer(COPY_READ_BUFFER, WRITE_ONLY);
1885bd8deadSopenharmony_ci        // fill ptr
1895bd8deadSopenharmony_ci        UnmapBuffer(COPY_READ_BUFFER);
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ci        BindBuffer(COPY_WRITE_BUFFER, vtxBuffer);
1925bd8deadSopenharmony_ci        // this copy ideally requires no CPU work on the data itself.
1935bd8deadSopenharmony_ci        CopyBufferSubData(COPY_READ_BUFFER, COPY_WRITE_BUFFER,
1945bd8deadSopenharmony_ci                          0, writeoffset, updateSize);
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ciIssues
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci    1) What should the new targets and parameters be named? READ/WRITE?
1995bd8deadSopenharmony_ci       SOURCE/DEST? Something else?
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    RESOLVED: READ and WRITE, because it's consistent with the <access>
2025bd8deadSopenharmony_ci    parameters and state.
2035bd8deadSopenharmony_ci
2045bd8deadSopenharmony_ci    2) How is this extension useful?
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci    This can be a desirable replacement to BufferSubData if there are
2075bd8deadSopenharmony_ci    large updates that will pollute the CPU cache. If generating the data
2085bd8deadSopenharmony_ci    can be offloaded to another thread, then the CPU cost of the update
2095bd8deadSopenharmony_ci    in the rendering thread can be very small.
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci    This can also be an alternate mechanism to MapBufferRange with the
2125bd8deadSopenharmony_ci    MAP_UNSYNCHRONIZED_BIT, by allowing the CPU to write into a temp
2135bd8deadSopenharmony_ci    buffer and then scheduling the update to be in-band with the
2145bd8deadSopenharmony_ci    rendering. MAP_UNSYNCHRONIZED_BIT can lead to hard-to-detect
2155bd8deadSopenharmony_ci    synchronization bugs if the GPU hasn't finished consuming the data
2165bd8deadSopenharmony_ci    that is overwritten (Write After Read hazard). Also, mapping a buffer
2175bd8deadSopenharmony_ci    may, on some implementations, require forcing the data store into a
2185bd8deadSopenharmony_ci    memory space more local to the CPU than to the GPU, which can adversely
2195bd8deadSopenharmony_ci    affect rendering performance.
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    Finally, if an implementation supports concurrent data transfers in
2225bd8deadSopenharmony_ci    one context/thread while doing rendering in another context/thread,
2235bd8deadSopenharmony_ci    this extension may be used to move data from system memory to video
2245bd8deadSopenharmony_ci    memory in preparation for copying it into another buffer, or texture,
2255bd8deadSopenharmony_ci    etc., in the rendering thread.
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci    (3) Why don't the new tokens and entry points in this extension have
2285bd8deadSopenharmony_ci       "ARB" suffixes like other ARB extensions?
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci        RESOLVED: Unlike most ARB extensions, this is a strict subset of
2315bd8deadSopenharmony_ci        functionality already approved in OpenGL 3.1. This extension
2325bd8deadSopenharmony_ci        exists only to support that functionality on older hardware that
2335bd8deadSopenharmony_ci        cannot implement a full OpenGL 3.1 driver. Since there are no
2345bd8deadSopenharmony_ci        possible behavior changes between the ARB extension and core
2355bd8deadSopenharmony_ci        features, source code compatibility is improved by not using
2365bd8deadSopenharmony_ci        suffixes on the extension.
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ciRevision History
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci    Revision 1, 2008/09/09
2415bd8deadSopenharmony_ci     - Initial draft
2425bd8deadSopenharmony_ci    Revision 2, 2008/09/26
2435bd8deadSopenharmony_ci     - Make EXT_direct_state_access interaction explicit.
2445bd8deadSopenharmony_ci    Revision 3, 2008/10/10
2455bd8deadSopenharmony_ci     - Fix missing entry points for the new targets.
2465bd8deadSopenharmony_ci    Revision 4, 2009/03/13
2475bd8deadSopenharmony_ci     - Move Named* entry point to EXT_direct_state_access.
2485bd8deadSopenharmony_ci    Revision 5, 2009/03/19
2495bd8deadSopenharmony_ci     - ARBify and remove ARB suffix from entry points and tokens.
2505bd8deadSopenharmony_ci    Revision 6, 2009/06/03
2515bd8deadSopenharmony_ci     - Add buffer target list and fix capitalization differences on
2525bd8deadSopenharmony_ci       parameter names per feedback from Jonathan Knispel
2535bd8deadSopenharmony_ci    Revision 7, 2017/09/06
2545bd8deadSopenharmony_ci     - Add GLX protocol.
255