GLAPI/glBufferStorage: Difference between revisions
Bot: Adding better formatting. |
mNo edit summary |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
| name = glBufferStorage | | name = glBufferStorage | ||
| core = 4.4 | | core = 4.4 | ||
| core_extension = {{extref| | | core_extension = {{extref|buffer_storage}} | ||
}} | }} | ||
Line 11: | Line 11: | ||
void '''glBufferStorage'''(GLenum {{param|target}}, GLsizeiptr {{param|size}}, const GLvoid * {{param|data}}, GLbitfield {{param|flags}}); | void '''glBufferStorage'''(GLenum {{param|target}}, GLsizeiptr {{param|size}}, const GLvoid * {{param|data}}, GLbitfield {{param|flags}}); | ||
{{glapi buffertargets}} | |||
; size | ; size | ||
: Specifies the size in bytes of the buffer object's new data store. | : Specifies the size in bytes of the buffer object's new data store. | ||
Line 18: | Line 17: | ||
: Specifies a pointer to data that will be copied into the data store for initialization, or {{enum|NULL}} if no data is to be copied. | : Specifies a pointer to data that will be copied into the data store for initialization, or {{enum|NULL}} if no data is to be copied. | ||
; flags | ; flags | ||
: Specifies the intended usage of the buffer's data store. Must be a bitwise combination of the following flags. {{enum|GL_DYNAMIC_STORAGE_BIT}}, {{enum|GL_MAP_READ_BIT}}{{enum|GL_MAP_WRITE_BIT}}, {{enum|GL_MAP_PERSISTENT_BIT}}, {{enum|GL_MAP_COHERENT_BIT}}, and {{enum|GL_CLIENT_STORAGE_BIT}}. | : Specifies the intended usage of the buffer's data store. Must be a bitwise combination of the following flags. {{enum|GL_DYNAMIC_STORAGE_BIT}}, {{enum|GL_MAP_READ_BIT}}, {{enum|GL_MAP_WRITE_BIT}}, {{enum|GL_MAP_PERSISTENT_BIT}}, {{enum|GL_MAP_COHERENT_BIT}}, and {{enum|GL_CLIENT_STORAGE_BIT}}. | ||
== Description == | == Description == | ||
Line 24: | Line 23: | ||
'''glBufferStorage''' creates a new immutable data store for the buffer object currently bound to {{param|target}}. The size of the data store is specified by {{param|size}}. If an initial data is available, its address may be supplied in {{param|data}}. Otherwise, to create an uninitialized data store, {{param|data}} should be {{enum|NULL}}. | '''glBufferStorage''' creates a new immutable data store for the buffer object currently bound to {{param|target}}. The size of the data store is specified by {{param|size}}. If an initial data is available, its address may be supplied in {{param|data}}. Otherwise, to create an uninitialized data store, {{param|data}} should be {{enum|NULL}}. | ||
The {{param|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: ; {{enum|GL_DYNAMIC_STORAGE_BIT}} | The {{param|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: | ||
; {{enum|GL_DYNAMIC_STORAGE_BIT}} | |||
: The contents of the data store may be updated after creation through calls to {{apifunc|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 {{enum|GL_DYNAMIC_STORAGE_BIT}}. Regardless of the presence of this bit, buffers may always be updated with server-side calls such as {{apifunc|glCopyBufferSubData}} and {{apifunc|glClearBufferSubData}}. | : The contents of the data store may be updated after creation through calls to {{apifunc|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 {{enum|GL_DYNAMIC_STORAGE_BIT}}. Regardless of the presence of this bit, buffers may always be updated with server-side calls such as {{apifunc|glCopyBufferSubData}} and {{apifunc|glClearBufferSubData}}. | ||
; {{enum|GL_MAP_READ_BIT}} | ; {{enum|GL_MAP_READ_BIT}} | ||
Line 35: | Line 35: | ||
: 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 {{apifunc|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, | : 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 {{apifunc|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, | ||
; {{enum|GL_CLIENT_STORAGE_BIT}} | ; {{enum|GL_CLIENT_STORAGE_BIT}} | ||
: | : A hint that the buffer object's data should be stored in client memory. Assuming that such a distinction exists in the driver. | ||
The allowed combinations of flags are subject to certain restrictions. They are as follows: * If {{param|flags}} contains {{enum|GL_MAP_PERSISTENT_BIT}}, it must also contain at least one of {{enum|GL_MAP_READ_BIT}} or {{enum|GL_MAP_WRITE_BIT}}. | The allowed combinations of flags are subject to certain restrictions. They are as follows: | ||
* If {{param|flags}} contains {{enum|GL_MAP_PERSISTENT_BIT}}, it must also contain at least one of {{enum|GL_MAP_READ_BIT}} or {{enum|GL_MAP_WRITE_BIT}}. | |||
* If {{param|flags}} contains {{enum|GL_MAP_COHERENT_BIT}}, it must also contain {{enum|GL_MAP_PERSISTENT_BIT}}. | * If {{param|flags}} contains {{enum|GL_MAP_COHERENT_BIT}}, it must also contain {{enum|GL_MAP_PERSISTENT_BIT}}. | ||
Line 60: | Line 62: | ||
{{enum|GL_INVALID_VALUE}} is generated if {{param|flags}} contains {{enum|GL_MAP_COHERENT_BIT}}, but does not also contain {{enum|GL_MAP_PERSISTENT_BIT}}. | {{enum|GL_INVALID_VALUE}} is generated if {{param|flags}} contains {{enum|GL_MAP_COHERENT_BIT}}, but does not also contain {{enum|GL_MAP_PERSISTENT_BIT}}. | ||
{{enum|GL_INVALID_OPERATION}} is generated if the {{enum|GL_BUFFER_IMMUTABLE_STORAGE}} flag of the buffer bound to {{param|target}} is {{enum|GL_TRUE}}. | {{enum|GL_INVALID_OPERATION}} is generated if the {{enum|GL_BUFFER_IMMUTABLE_STORAGE}} flag of the buffer bound to {{param|target}} is {{enum|GL_TRUE}}. | ||
Line 83: | Line 83: | ||
[[Category:Core API Ref Buffer Objects|BufferStorage]] | [[Category:Core API Ref Buffer Objects|BufferStorage]] | ||
[[Category:Core API Reference|Bufferstorage]] | [[Category:Core API Reference|Bufferstorage]] | ||
[[Category:Buffer Object API State Functions|BufferStorage]] |
Latest revision as of 12:27, 9 July 2015
Core in version | 4.6 | |
---|---|---|
Core since version | 4.4 | |
Core ARB extension | ARB_buffer_storage |
glBufferStorage: creates and initializes a buffer object's immutable data store
Function Definition
void glBufferStorage(GLenum target, GLsizeiptr size, const GLvoid * data, GLbitfield flags);
- target
- Specifies the target buffer object. The symbolic constant must be GL_ARRAY_BUFFER, GL_ATOMIC_COUNTER_BUFFER, GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, GL_DRAW_INDIRECT_BUFFER, GL_DISPATCH_INDIRECT_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER, GL_QUERY_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TEXTURE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER, or GL_UNIFORM_BUFFER.
- size
- Specifies the size in bytes of the buffer object's new data store.
- 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.
- 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.
Description
glBufferStorage creates a new immutable data store for the buffer object currently bound to target. 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.
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:
- 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.
- 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.
- 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.
- 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.
- 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,
- GL_CLIENT_STORAGE_BIT
- A hint that the buffer object's data should be stored in client memory. Assuming that such a distinction exists in the driver.
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.
- If flags contains GL_MAP_COHERENT_BIT, it must also contain GL_MAP_PERSISTENT_BIT.
Notes
If data is NULL, a data store of the specified size is still created, but its contents remain uninitialized and thus undefined.
Errors
GL_INVALID_ENUM is generated if target is not one of the accepted buffer targets.
GL_INVALID_VALUE is generated if size is less than or equal to zero.
GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.
GL_OUT_OF_MEMORY is generated if the GL is unable to create a data store with the properties requested in flags.
GL_INVALID_VALUE is generated if flags has any bits set other than those defined above.
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.
GL_INVALID_VALUE is generated if flags contains GL_MAP_COHERENT_BIT, but does not also contain GL_MAP_PERSISTENT_BIT.
GL_INVALID_OPERATION is generated if the GL_BUFFER_IMMUTABLE_STORAGE flag of the buffer bound to target is GL_TRUE.
Associated Gets
glGetBufferParameter with argument GL_BUFFER_SIZE or GL_BUFFER_USAGE
See Also
glBufferData, glBindBuffer, glBufferSubData, glMapBuffer, glUnmapBuffer
Copyright
Copyright © 2013 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/.