glMapBufferRange.3G man page

glMapBufferRange, glMapNamedBufferRange — map all or part of a buffer object's data store into the client's address space

C Specification

void *glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);

void *glMapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access);

Parameters

target

Specifies the target to which the buffer object is bound for glMapBufferRange, which must be one of the buffer binding targets in the following table:

Buffer Binding Target Purpose
GL_ARRAY_BUFFER Vertex attributes
GL_ATOMIC_COUNTER_BUFFER Atomic counter storage
GL_COPY_READ_BUFFER Buffer copy source
GL_COPY_WRITE_BUFFER Buffer copy destination
GL_DISPATCH_INDIRECT_BUFFER Indirect compute dispatch commands
GL_DRAW_INDIRECT_BUFFER Indirect command arguments
GL_ELEMENT_ARRAY_BUFFER Vertex array indices
GL_PIXEL_PACK_BUFFER Pixel read target
GL_PIXEL_UNPACK_BUFFER Texture data source
GL_QUERY_BUFFER Query result buffer
GL_SHADER_STORAGE_BUFFER Read-write storage for shaders
GL_TEXTURE_BUFFER Texture data buffer
GL_TRANSFORM_FEEDBACK_BUFFER Transform feedback buffer
GL_UNIFORM_BUFFER Uniform block storage
buffer

Specifies the name of the buffer object for glMapNamedBufferRange.

offset

Specifies the starting offset within the buffer of the range to be mapped.

length

Specifies the length of the range to be mapped.

access

Specifies a combination of access flags indicating the desired access to the mapped range.

Description

glMapBufferRange and glMapNamedBufferRange map all or part of the data store of a specified buffer object into the client's address space. offset and length indicate the range of data in the buffer object that is to be mapped, in terms of basic machine units. access is a bitfield containing flags which describe the requested mapping. These flags are described below.

A pointer to the beginning of the mapped range is returned once all pending operations on the buffer object have completed, and may be used to modify and/or query the corresponding range of the data store according to the following flag bits set in access:

The following optional flag bits in access may be used to modify the mapping:

If an error occurs, a NULL pointer is returned.

If no error occurs, the returned pointer will reflect an allocation aligned to the value of GL_MIN_MAP_BUFFER_ALIGNMENT basic machine units. Subtracting offset from this returned pointer will always produce a multiple of the value of GL_MIN_MAP_BUFFER_ALIGNMENT.

The returned pointer values may not be passed as parameter values to GL commands. For example, they may not be used to specify array pointers, or to specify or query pixel or texture image data; such actions produce undefined results, although implementations may not check for such behavior for performance reasons.

Mappings to the data stores of buffer objects may have nonstandard performance characteristics. For example, such mappings may be marked as uncacheable regions of memory, and in such cases reading from them may be very slow. To ensure optimal performance, the client should use the mapping in a fashion consistent with the values of GL_BUFFER_USAGE for the buffer object and of access. Using a mapping in a fashion inconsistent with these values is liable to be multiple orders of magnitude slower than using normal memory.

Notes

Alignment of the returned pointer is guaranteed only if the version of the GL version is 4.2 or greater. Also, the GL_ATOMIC_COUNTER_BUFFER target is accepted only if the GL version is 4.2 or greater.

The GL_DISPATCH_INDIRECT_BUFFER and GL_SHADER_STORAGE_BUFFER targets are accepted only if the GL version is 4.3 or greater.

The GL_QUERY_BUFFER target is available only if the GL version is 4.4 or greater.

The GL_MAP_PERSISTENT_BIT and GL_MAP_COHERENT_BIT flags are available only if the GL version is 4.4 or greater.

Errors

GL_INVALID_ENUM is generated by glMapBufferRange if target is not one of the buffer binding targets listed above.

GL_INVALID_OPERATION is generated by glMapBufferRange if zero is bound to target.

GL_INVALID_OPERATION is generated by glMapNamedBufferRange if buffer is not the name of an existing buffer object.

GL_INVALID_VALUE is generated if offset or length is negative, if $offset + length$ is greater than the value of GL_BUFFER_SIZE for the buffer object, or if access has any bits set other than those defined above.

GL_INVALID_OPERATION is generated for any of the following conditions:

No error is generated if memory outside the mapped range is modified or queried, but the result is undefined and system errors (possibly including program termination) may occur.

Associated Gets

glGet() with pname GL_MIN_MAP_BUFFER_ALIGNMENT. The value must be a power of two that is at least 64.

Version Support

OpenGL Version
Function / Feature Name 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5
glMapBufferRange - -
glMapNamedBufferRange - - - - - - - - - - -

See Also

glMapBuffer(), glUnmapBuffer(), glFlushMappedBufferRange(), glBindBuffer(), glBufferStorage()

Referenced By

The man page glMapNamedBufferRange.3G(3) is an alias of glMapBufferRange.3G(3).

07/26/2017 [FIXME: source] [FIXME: manual]