Home

GLMAPINVALIDATERANGEBIT

GL_MAP_INVALIDATE_RANGE_BIT is a bit flag used in OpenGL as part of the glMapBufferRange API. It indicates that the contents of the specified range of a buffer’s data store may be discarded when the mapping occurs, allowing the implementation to avoid preserving or reading the previous data for that range.

When mapping a buffer, this flag is typically combined with other map options such as GL_MAP_WRITE_BIT. The

Usage considerations include ensuring that the mapped range is entirely within the bounds of the buffer, and

Compatibility and origin: GL_MAP_INVALIDATE_RANGE_BIT is part of the ARB_map_buffer_range extension and is supported in OpenGL core

Example: glMapBufferRange(GL_ARRAY_BUFFER, offset, length, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT); followed by writes to the returned pointer, and glUnmapBuffer(GL_ARRAY_BUFFER).

effect
is
that
the
driver
may
invalidate
the
contents
of
the
mapped
range,
enabling
more
efficient
data
updates
by
reducing
memory
traffic.
Importantly,
the
flag
only
permits
discarding
the
previous
contents;
it
does
not
force
the
data
to
be
zero-filled.
After
mapping
with
this
flag,
the
application
should
not
rely
on
any
prior
values
in
the
mapped
range
until
new
writes
have
completed.
understanding
that
invalidation
applies
only
to
the
specified
range.
The
behavior
is
most
beneficial
when
the
application
intends
to
overwrite
the
region
completely
and
does
not
need
the
old
data.
The
flag
can
be
combined
with
GL_MAP_INVALIDATE_BUFFER_BIT
to
discard
the
entire
buffer,
though
that
affects
all
contents
rather
than
just
a
sub-range.
profiles
since
the
ARB_map_buffer_range
introduction.
It
is
commonly
used
in
performance-critical
scenarios
where
buffers
are
re-written
in
place,
such
as
streaming
vertex
data
or
dynamic
uniform
blocks.