GLTEXBUFFERRANGE(3G)

πŸ’… glTexBufferRange / glTextureBufferRange β€” the 3G manual page, bestie

Okay so welcome to the GLTEXBUFFERRANGE(3G) page, and no cap this one is about two functions that attach a range of a buffer object's data store to a buffer texture object. It's giving "buffer texture glow-up" energy. ✨


✨ NAME ✨

glTexBufferRange, glTextureBufferRange β€” attach a range of a buffer object's data store to a buffer texture object. That's the whole name-section vibe, periodt. 🫢


🌸 C SPECIFICATION 🌸

void glTexBufferRange(GLenum target, GLenum internalformat,
                      GLuint buffer, GLintptr offset, GLsizeiptr size);

void glTextureBufferRange(GLuint texture, GLenum internalformat,
                          GLuint buffer, GLintptr offset, GLsizei size);

Look at those signatures. The way they're just sitting there being all C-like and iconic. πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • target β€” Specifies the target to which the texture object is bound for glTexBufferRange. Must be GL_TEXTURE_BUFFER. No substitutions, bestie.
  • texture β€” Specifies the texture object name for glTextureBufferRange.
  • internalformat β€” Specifies the internal format of the data in the store belonging to buffer.
  • buffer β€” Specifies the name of the buffer object whose storage to attach to the active buffer texture.
  • offset β€” Specifies the offset of the start of the range of the buffer's data store to attach.
  • size β€” Specifies the size of the range of the buffer's data store to attach.

πŸ¦‹ DESCRIPTION πŸ¦‹

So glTexBufferRange and glTextureBufferRange attach a range of the data store of a specified buffer object to a specified texture object, and they specify the storage format for the texture image found in the buffer object. The texture object must be a buffer texture. Like, that's not optional. πŸ™ˆ

If buffer is zero, any buffer object attached to the buffer texture is detached and no new buffer object is attached. If buffer is non-zero, it must be the name of an existing buffer object. That's the rule, fr fr. πŸ”₯

The start and size of the range are specified by offset and size respectively, both measured in basic machine units. offset must be greater than or equal to zero, size must be greater than zero, and the sum of offset and size must not exceed the value of GL_BUFFER_SIZE for buffer. Furthermore, offset must be an integer multiple of the value of GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT. So basically: check your alignment, bestie. πŸ’–

Okay so internalformat is like… the personality of your texture, and it must be one of these sized internal formats β€” no vibes-based guessing, bestie. Here's the whole menu: sized internal format, base type, how many components, whether it's normalized, and then exactly what lands in components 0, 1, 2 and 3. πŸ’…

  • GL_R8 β€” base type ubyte, 1 component, Norm: YES, components 0..3 β†’ R, 0, 0, 1
  • GL_R16 β€” base type ushort, 1 component, Norm: YES, components 0..3 β†’ R, 0, 0, 1
  • GL_R16F β€” base type half, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R32F β€” base type float, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R8I β€” base type byte, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R16I β€” base type short, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R32I β€” base type int, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R8UI β€” base type ubyte, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R16UI β€” base type ushort, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_R32UI β€” base type uint, 1 component, Norm: NO, components 0..3 β†’ R, 0, 0, 1
  • GL_RG8 β€” base type ubyte, 2 components, Norm: YES, components 0..3 β†’ R, G, 0, 1
  • GL_RG16 β€” base type ushort, 2 components, Norm: YES, components 0..3 β†’ R, G, 0, 1
  • GL_RG16F β€” base type half, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG32F β€” base type float, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG8I β€” base type byte, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG16I β€” base type short, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG32I β€” base type int, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG8UI β€” base type ubyte, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG16UI β€” base type ushort, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RG32UI β€” base type uint, 2 components, Norm: NO, components 0..3 β†’ R, G, 0, 1
  • GL_RGB32F β€” base type float, 3 components, Norm: NO, components 0..3 β†’ R, G, B, 1
  • GL_RGB32I β€” base type int, 3 components, Norm: NO, components 0..3 β†’ R, G, B, 1
  • GL_RGB32UI β€” base type uint, 3 components, Norm: NO, components 0..3 β†’ R, G, B, 1
  • GL_RGBA8 β€” base type uint, 4 components, Norm: YES, components 0..3 β†’ R, G, B, A
  • GL_RGBA16 β€” base type short, 4 components, Norm: YES, components 0..3 β†’ R, G, B, A
  • GL_RGBA16F β€” base type half, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA32F β€” base type float, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA8I β€” base type byte, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA16I β€” base type short, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA32I β€” base type int, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA8UI β€” base type ubyte, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA16UI β€” base type ushort, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A
  • GL_RGBA32UI β€” base type uint, 4 components, Norm: NO, components 0..3 β†’ R, G, B, A

Read that table like a playlist, not a vibe β€” every format, base type, component count and norm flag above is exactly what it is, no substitutions, okay? 🫢


πŸ¦‹ how many texels tho

So when a range of a buffer object gets attached to a buffer texture, the specified range of the buffer object's data store is literally taken as the texture's texel array. That's it, that's the whole relationship. πŸŽ€

And the number of texels in the buffer texture's texel array is given by this lil formula right here:

$$ \left\lfloor { size \over { components \times
sizeof(base\_type) } } \right\rfloor $$

where components and base_type are the element count and base data type for elements, as specified in the table above ✨ (so like, the components column and the base type column, not vibes).

Then β€” and this is the part people skip and then get confused β€” the number of texels in the texel array is clamped to the value of the implementation-dependent limit GL_MAX_TEXTURE_BUFFER_SIZE. So your math can say one thing and your driver can say "no bestie, smaller." πŸ’€

⚠️ And when a buffer texture is accessed in a shader, the results of a texel fetch are undefined if the specified texel coordinate is negative, or greater than or equal to the clamped number of texels in the texel array. So stay in bounds, fr fr β€” out-of-range reads are giving chaos and not the cute kind. 😭

πŸ’€ ERRORS (aka the vibe check fails) πŸ’€

okay so bestie, this is where the driver says "no <3" β€” here's every way you can break it:

  • GL_INVALID_ENUM β€” gets thrown by glTexBufferRange if target isn't GL_TEXTURE_BUFFER. like, wrong door, babe.
  • GL_INVALID_OPERATION β€” gets thrown by glTextureBufferRange if texture isn't the name of an actually-existing texture object. not a vibe.
  • GL_INVALID_ENUM β€” also thrown by glTextureBufferRange if the effective target of texture isn't GL_TEXTURE_BUFFER.
  • GL_INVALID_ENUM β€” thrown if internalformat isn't one of the sized internal formats described above. no off-brand formats in this house 🚫
  • GL_INVALID_OPERATION β€” thrown if buffer isn't zero and isn't the name of an existing buffer object.
  • GL_INVALID_VALUE β€” thrown if offset is negative, if size is less than or equal to zero, or if offset + size is greater than the value of GL_BUFFER_SIZE for buffer. math girlies stay winning πŸ“
  • GL_INVALID_VALUE β€” thrown if offset isn't an integer multiple of the value of GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT. alignment is not a suggestion, it's a lifestyle ✨

πŸ‘€ ASSOCIATED GETS (the receipts)

  • glGet() with argument GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT
  • glGetTexLevelParameter() with arguments GL_TEXTURE_BUFFER_OFFSET or GL_TEXTURE_BUFFER_SIZE.

πŸ—“οΈ VERSION SUPPORT (who gets to sit with us)

the chart lowkey slaps, so here's the whole thing spelled out. the columns were OpenGL versions 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, and the dashes mean "nope, not invited" while the βœ” means "she's here, she's iconic":

  • glTexBufferRange β€” - in 2.0, - in 2.1, - in 3.0, - in 3.1, - in 3.2, - in 3.3, - in 4.0, - in 4.1, - in 4.2, βœ” in 4.3, βœ” in 4.4, βœ” in 4.5
  • glTextureBufferRange β€” - in 2.0, - in 2.1, - in 3.0, - in 3.1, - in 3.2, - in 3.3, - in 4.0, - in 4.1, - in 4.2, - in 4.3, - in 4.4, βœ” in 4.5
so like… glTexBufferRange said "I'm available from 4.3 onward πŸ’…" and glTextureBufferRange showed up fashionably late at 4.5 only. main character energy fr fr.

🫢 SEE ALSO

glTexBuffer().


Copyright Β© 2012-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 Β© 2012-2014 Khronos Group


and that's the whole page bestie, we ate and left no crumbs πŸ“ the source says [FIXME: source], the version is from 08/09/2021, and the page goes by GLTEXBUFFERRANGE(3G) β€” take care of her, she's iconic πŸ‘‘βœ¨

πŸ“¦ where this page comes from