GLCOPYIMAGESUBDATA(3G)

πŸ’… NAME πŸ’…

Okay bestie, welcome to the 3G manual page for glCopyImageSubData β€” it does a raw data copy between two images. That's it, that's the vibe. ✨


πŸŽ€ C SPECIFICATION πŸŽ€

void glCopyImageSubData(GLuint srcName, GLenum srcTarget,
                        GLint srcLevel, GLint srcX, GLint srcY,
                        GLint srcZ, GLuint dstName, GLenum dstTarget,
                        GLint dstLevel, GLint dstX, GLint dstY,
                        GLint dstZ, GLsizei srcWidth, GLsizei srcHeight,
                        GLsizei srcDepth);

πŸ¦‹ PARAMETERS πŸ¦‹

  • srcName β€” the name of a texture or renderbuffer object you're copying from.
  • srcTarget β€” the target that tells you which namespace the source name srcName lives in.
  • srcLevel β€” the mipmap level to read from the source. πŸ‘‘
  • srcX β€” the X coordinate of the left edge of the source region to copy.
  • srcY β€” the Y coordinate of the top edge of the source region to copy.
  • srcZ β€” the Z coordinate of the near edge of the source region to copy.
  • dstName β€” the name of a texture or renderbuffer object you're copying to.
  • dstTarget β€” the target that tells you which namespace the destination name dstName lives in.
  • dstX β€” the X coordinate of the left edge of the destination region.
  • dstY β€” the Y coordinate of the top edge of the destination region.
  • dstZ β€” the Z coordinate of the near edge of the destination region.
  • srcWidth β€” the width of the region to be copied.
  • srcHeight β€” the height of the region to be copied.
  • srcDepth β€” the depth of the region to be copied.

🌈 DESCRIPTION 🌈

So glCopyImageSubData is literally for copying data from one image (aka a texture or a renderbuffer) to another. And no, it does not do general-purpose conversions β€” no scaling, no resizing, no blending, no color-space conversions, no format conversions. Think of it as a CPU memcpy but for images, bestie. πŸ’… CopyImageSubData can copy between images with different internal formats, as long as those formats are compatible.

It also lets you copy between certain types of compressed and uncompressed internal formats. Important though: this copy does not do on-the-fly compression or decompression. 😭 When you copy from an uncompressed internal format to a compressed internal format, each texel of uncompressed data becomes a single block of compressed data. When you copy from a compressed internal format to an uncompressed internal format, a block of compressed data becomes a single texel of uncompressed data. The texel size of the uncompressed format has to be the same size as the block size of the compressed format. So yeah β€” it's permitted to copy between a 128-bit uncompressed format and a compressed format which uses 8-bit 4x4 blocks, or between a 64-bit uncompressed format and a compressed format which uses 4-bit 4x4 blocks. ✨

The source object is identified by srcName and srcTarget, and the destination object is identified by dstName and dstTarget. The interpretation of the name depends on the value of the corresponding target parameter. If target is GL_RENDERBUFFER, the name is interpreted as the name of a renderbuffer object. If the target parameter is a texture target, the name is interpreted as a texture object. All non-proxy texture targets are accepted, with the exception of GL_TEXTURE_BUFFER and the cubemap face selectors. 🫢

srcLevel and dstLevel identify the source and destination level of detail. For textures, this must be a valid level of detail in the texture object. For renderbuffers, this value must be zero. πŸ‘‘

srcX, srcY, and srcZ specify the lower left texel coordinates of a srcWidth-wide by srcHeight-high by srcDepth-deep rectangular subregion of the source texel array. Similarly, dstX, dstY and dstZ specify the coordinates of a subregion of the destination texel array. The source and destination subregions must be contained entirely within the specified level of the corresponding image objects. No sneaking out of bounds, okay? πŸ™ˆ

The dimensions are always specified in texels, even for compressed texture formats. But like, note this: if only one of the source and destination textures is compressed, then the number of texels touched in the compressed image will be a factor of the block size larger than in the uncompressed image. πŸ’€

Slices of a GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_3D and faces of GL_TEXTURE_CUBE_MAP are all compatible provided they share a compatible internal format, and multiple slices or faces may be copied between these objects with a single call by specifying the starting slice with srcZ and dstZ, and the number of slices to be copied with srcDepth. Cubemap textures always have six faces which are selected by a zero-based face index. πŸŽ€

For the purposes of CopyImageSubData, two internal formats are considered compatible if any of the following conditions are met:

  • the formats are the same,
  • the formats are considered compatible according to the compatibility rules used for texture views as defined in section 3.9.X. In particular, if both internal formats are listed in the same entry of Table 3.X.2, they are considered compatible, or
  • one format is compressed and the other is uncompressed and Table 4.X.1 lists the two formats in the same row.

If the formats are not compatible, an INVALID_OPERATION error is generated. 🚨

πŸ“Š Table 1. Sized Internal Formats

⭐ 64-bit

  • Uncompressed Internal Format: GL_RGBA32UI, GL_RGBA32I, GL_RGBA32F
  • Compressed Internal Format(s):
    • GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
    • GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
    • GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
    • GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
    • GL_COMPRESSED_RG_RGTC2
    • GL_COMPRESSED_SIGNED_RG_RGTC2
    • GL_COMPRESSED_RGBA_BPTC_UNORM
    • GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM
    • GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT
    • GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT

⭐ 128-bit

  • Uncompressed Internal Format: GL_RGBA16UI, GL_RGBA16I, GL_RGBA16F, GL_RG32F, GL_RG32UI, GL_RG32I, GL_RGBA16, GL_RGBA16_SNORM
  • Compressed Internal Format(s):
    • GL_COMPRESSED_RGB_S3TC_DXT1_EXT
    • GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
    • GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
    • GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
    • GL_COMPRESSED_RED_RGTC1
    • GL_COMPRESSED_SIGNED_RED_RGTC1

πŸ’€ ERRORS πŸ’€

  • GL_INVALID_OPERATION is generated if the texel size of the uncompressed image is not equal to the block size of the compressed image. 😭
  • GL_INVALID_ENUM is generated if either target parameter is not GL_RENDERBUFFER, a valid non-proxy texture target other than GL_TEXTURE_BUFFER, or is one of the cubemap face selectors.
  • GL_INVALID_ENUM is generated if target does not match the type of the object.
  • GL_INVALID_OPERATION is generated if either object is a texture and the texture is not complete.
  • GL_INVALID_OPERATION is generated if the source and destination internal formats are not compatible, or if the number of samples do not match.
  • GL_INVALID_VALUE is generated if either name does not correspond to a valid renderbuffer or texture object according to the corresponding target parameter.
  • GL_INVALID_VALUE is generated if the specified level of either the source or destination is not a valid level for the corresponding image.
  • GL_INVALID_VALUE is generated if the dimensions of either subregion exceeds the boundaries of the corresponding image object, or if the image format is compressed and the dimensions of the subregion fail to meet the alignment constraints of the format. 🚩

πŸ” ASSOCIATED GETS πŸ”

glGet() with argument GL_MAX_COMPUTE_WORK_GROUP_COUNT

✨ VERSION SUPPORT ✨

Okay so this is essentially the glow-up timeline of glCopyImageSubData β€” which OpenGL versions claim it and which ones are like "who is she." The original table is headed OpenGL Version across the top, with a Function / Feature Name column down the side, and exactly one function row: glCopyImageSubData.

Here's the whole grid, translated so you don't have to squint at box-drawing characters, bestie πŸ’…

  • glCopyImageSubData β€” row by row, version by version:
    • OpenGL 2.0 β€” - (not supported, don't even try)
    • OpenGL 2.1 β€” -
    • OpenGL 3.0 β€” -
    • OpenGL 3.1 β€” -
    • OpenGL 3.2 β€” -
    • OpenGL 3.3 β€” -
    • OpenGL 4.0 β€” -
    • OpenGL 4.1 β€” -
    • OpenGL 4.2 β€” -
    • OpenGL 4.3 β€” βœ” (she's here!! πŸŽ€)
    • OpenGL 4.4 β€” βœ”
    • OpenGL 4.5 β€” βœ”

So the whole vibe is: nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, then 4.3 rolls in and it's fully supported from there on out. Ten dashes, three checkmarks, that's the tea β˜• glCopyImageSubData is a 4.3-and-later girlie, no cap.


🌸 SEE ALSO 🌸

  • glDispatchComputeIndirect()

That's genuinely the only one listed. Short and sweet, she doesn't need a big entourage 🫢


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

Yes bestie, the copyright section really does show up twice in the source β€” the full one with the license terms, then the short one. I'm keeping both because I keep every single detail, always. πŸ’–

And that's the whole page, start to finish πŸ¦‹ Little sign-off moment for you: this one's sourced from [FIXME: source], dated 08/09/2021, and it's the manual page for GLCOPYIMAGESUBDATA(3G). Iconic, honestly. Go copy some images, but only on 4.3+. Periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from