GLBUFFERSTORAGE(3G)

  .SH "NAME" glBufferStorage, glNamedBufferStorage - creates and initializes a buffer object's immutable data store
  .SH "C SPECIFICATION"

      .HP u void glBufferStorage(GLenum target, GLsizeiptr size, const GLvoid * data, GLbitfield flags);
      .HP u void glNamedBufferStorage(GLuint buffer, GLsizei size, const void *data, GLbitfield flags);

  .SH "PARAMETERS"

      .PP target

              Specifies the target to which the buffer object is bound for glBufferStorage, which must be one of the buffer binding targets in the following table:
              <xi:include></xi:include>

          .RE
          .PP buffer

                  Specifies the name of the buffer object for glNamedBufferStorage function.

              .RE
              .PP size

                      Specifies the size in bytes of the buffer object's new data store.

                  .RE
                  .PP data

                          Specifies a pointer to data that will be copied into the data store for initialization, or NULL if no data is to be copied.

                      .RE
                      .PP flags

                              Specifies the intended usage of the buffer's data store. Must be a bitwise combination of the following flags. GL_DYNAMIC_STORAGE_BIT, GL_MAP_READ_BIT GL_MAP_WRITE_BIT, GL_MAP_PERSISTENT_BIT, GL_MAP_COHERENT_BIT, and GL_CLIENT_STORAGE_BIT.

                          .RE

                      .SH "DESCRIPTION"

                        .PP glBufferStorage and glNamedBufferStorage create a new immutable data store. For glBufferStorage, the buffer object currently bound to target will be initialized. For glNamedBufferStorage, buffer is the name of the buffer object that will be configured. The size of the data store is specified by size. If an initial data is available, its address may be supplied in data. Otherwise, to create an uninitialized data store, data should be NULL.
                        .PP The flags parameters specifies the intended usage of the buffer's data store. It must be a bitwise combination of a subset of the following flags:
                            .PP GL_DYNAMIC_STORAGE_BIT

                                    The contents of the data store may be updated after creation through calls to glBufferSubData(). If this bit is not set, the buffer content may not be directly updated by the client. The data argument may be used to specify the initial content of the buffer's data store regardless of the presence of the GL_DYNAMIC_STORAGE_BIT. Regardless of the presence of this bit, buffers may always be updated with server-side calls such as glCopyBufferSubData() and glClearBufferSubData().

                                .RE
                                .PP GL_MAP_READ_BIT

                                        The data store may be mapped by the client for read access and a pointer in the client's address space obtained that may be read from.

                                    .RE
                                    .PP GL_MAP_WRITE_BIT

                                            The data store may be mapped by the client for write access and a pointer in the client's address space obtained that may be written through.

                                        .RE
                                        .PP GL_MAP_PERSISTENT_BIT

                                                The client may request that the server read from or write to the buffer while it is mapped. The client's pointer to the data store remains valid so long as the data store is mapped, even during execution of drawing or dispatch commands.

                                            .RE
                                            .PP GL_MAP_COHERENT_BIT

                                                    Shared access to buffers that are simultaneously mapped for client access and are used by the server will be coherent, so long as that mapping is performed using glMapBufferRange(). That is, data written to the store by either the client or server will be immediately visible to the other with no further action taken by the application. In particular,

                                            •
                                                            If GL_MAP_COHERENT_BIT is not set and the client performs a write followed by a call to the glMemoryBarrier() command with the GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT set, then in subsequent commands the server will see the writes.
                                                          .RE

                                                •
                                                                If GL_MAP_COHERENT_BIT is set and the client performs a write, then in subsequent commands the server will see the writes.
                                                              .RE

                                                    •
                                                                    If GL_MAP_COHERENT_BIT is not set and the server performs a write, the application must call glMemoryBarrier() with the GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT set and then call glFenceSync() with GL_SYNC_GPU_COMMANDS_COMPLETE (or glFinish). Then the CPU will see the writes after the sync is complete.
                                                                  .RE

                                                        •
                                                                        If GL_MAP_COHERENT_BIT is set and the server does a write, the app must call glFenceSync with GL_SYNC_GPU_COMMANDS_COMPLETE (or glFinish()). Then the CPU will see the writes after the sync is complete.
                                                                      .RE
                                                                    .sp

                                                                .RE
                                                                .PP GL_CLIENT_STORAGE_BIT

                                                                        When all other criteria for the buffer storage allocation are met, this bit may be used by an implementation to determine whether to use storage that is local to the server or to the client to serve as the backing store for the buffer.

                                                                    .RE

                                                                .PP The allowed combinations of flags are subject to certain restrictions. They are as follows:

                                                                •
                                                                          If flags contains GL_MAP_PERSISTENT_BIT, it must also contain at least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT.
                                                                        .RE

                                                                    •
                                                                              If flags contains GL_MAP_COHERENT_BIT, it must also contain GL_MAP_PERSISTENT_BIT.
                                                                            .RE

                                                                      .SH "NOTES"

                                                                        .PP glBufferStorage is available only if the GL version is 4.4 or greater.
                                                                        .PP glNamedBufferStorage is available only if the GL version is 4.5 or greater.
                                                                        .PP If data is NULL, a data store of the specified size is still created, but its contents remain uninitialized and thus undefined.

                                                                      .SH "ERRORS"

                                                                        .PP GL_INVALID_ENUM is generated by glBufferStorage if target is not one of the accepted buffer targets.
                                                                        .PP GL_INVALID_OPERATION is generated by glNamedBufferStorage if buffer is not the name of an existing buffer object.
                                                                        .PP GL_INVALID_VALUE is generated if size is less than or equal to zero.
                                                                        .PP GL_INVALID_OPERATION is generated by glBufferStorage if the reserved buffer object name 0 is bound to target.
                                                                        .PP GL_OUT_OF_MEMORY is generated if the GL is unable to create a data store with the properties requested in flags.
                                                                        .PP GL_INVALID_VALUE is generated if flags has any bits set other than those defined above.
                                                                        .PP GL_INVALID_VALUE error is generated if flags contains GL_MAP_PERSISTENT_BIT but does not contain at least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT.
                                                                        .PP GL_INVALID_VALUE is generated if flags contains GL_MAP_COHERENT_BIT, but does not also contain GL_MAP_PERSISTENT_BIT.
                                                                        .PP GL_INVALID_OPERATION is generated by glBufferStorage if the GL_BUFFER_IMMUTABLE_STORAGE flag of the buffer bound to target is GL_TRUE.

                                                                      .SH "ASSOCIATED GETS"

                                                                        .PP glGetBufferSubData()
                                                                        .PP glGetBufferParameter() with argument GL_BUFFER_SIZE or GL_BUFFER_USAGE

                                                                        .SH "VERSION SUPPORT"
                                                                            .TS allbox tab(:); l l l l l l l l l l l l l l l l l l l l l l l l l l. T{ glBufferStorage T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T} T{ glNamedBufferStorage T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}:T{ T}

                                                                      .SH "SEE ALSO"

                                                                        .PP glBindBuffer(), glBufferSubData(), glMapBuffer(), glUnmapBuffer()

                                                                        .SH "COPYRIGHT"
                                                                            .PP Copyright © 2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

COPYRIGHT
Copyright © 2014 Khronos Group