GLAPI/glCopyImageSubData

From OpenGL.org
Jump to: navigation, search
glCopyImageSubData
Core in version 4.4
Core since version 4.3
Core ARB extension ARB_copy_image

glCopyImageSubData: perform a raw data copy between two images

Function Definition

 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​);
srcName
The name of a texture or renderbuffer object from which to copy.
srcTarget
The target representing the namespace of the source name srcName​.
srcLevel
The mipmap level to read from the source.
srcX
The X coordinate of the left edge of the souce region to copy.
srcY
The Y coordinate of the top edge of the souce region to copy.
srcZ
The Z coordinate of the near edge of the souce region to copy.
dstName
The name of a texture or renderbuffer object to which to copy.
dstTarget
The target representing the namespace of the destination name dstName​.
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

glCopyImageSubData may be used to copy data from one image (i.e. texture or renderbuffer) to another. glCopyImageSubData does not perform general-purpose conversions such as scaling, resizing, blending, color-space, or format conversions. It should be considered to operate in a manner similar to a CPU memcpy. CopyImageSubData can copy between images with different internal formats, provided the formats are compatible.

glCopyImageSubData also allows copying between certain types of compressed and uncompressed internal formats. This copy does not perform on-the-fly compression or decompression. When copying from an uncompressed internal format to a compressed internal format, each texel of uncompressed data becomes a single block of compressed data. When copying 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 must be the same size the block size of the compressed formats. Thus it is 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.

The dimensions are always specified in texels, even for compressed texture formats. However, it should be noted that 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.

Layers 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 layers or faces may be copied between these objects with a single call by specifying the starting layer with srcZ​ and dstZ​, and the number of layers to be copied with srcDepth​. Cubemap textures always have six faces which are selected by a zero-based face index.

For the purposes of glCopyImageSubData, 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 shown below, or
  • one format is compressed and the other is uncompressed, and the below table lists lists the two formats in the same row.

If the formats are not compatible GL_INVALID_OPERATION​ is generated.

Class Internal Formats
128-bit GL_RGBA32F​, GL_RGBA32UI​, GL_RGBA32I​
96-bit GL_RGB32F​, GL_RGB32UI​, GL_RGB32I​
64-bit GL_RGBA16F​, GL_RG32F​, GL_RGBA16UI​, GL_RG32UI​, GL_RGBA16I​, GL_RG32I​, GL_RGBA16​, GL_RGBA16_SNORM​
48-bit GL_RGB16​, GL_RGB16_SNORM​, GL_RGB16F​, GL_RGB16UI​, GL_RGB16I​
32-bit GL_RG16F​, GL_R11F_G11F_B10F​, GL_R32F​, GL_RGB10_A2UI​, GL_RGBA8UI​, GL_RG16UI​, GL_R32UI​, GL_RGBA8I​, GL_RG16I​, GL_R32I​, GL_RGB10_A2​, GL_RGBA8​, GL_RG16​, GL_RGBA8_SNORM​, GL_RG16_SNORM​, GL_SRGB8_ALPHA8​, GL_RGB9_E5​
24-bit GL_RGB8​, GL_RGB8_SNORM​, GL_SRGB8​, GL_RGB8UI​, GL_RGB8I​
16-bit GL_R16F​, GL_RG8UI​, GL_R16UI​, GL_RG8I​, GL_R16I​, GL_RG8​, GL_R16​, GL_RG8_SNORM​, GL_R16_SNORM​
8-bit GL_R8UI​, GL_R8I​, GL_R8​, GL_R8_SNORM​
GL_VIEW_CLASS_RGTC1_RED​ GL_COMPRESSED_RED_RGTC1​, GL_COMPRESSED_SIGNED_RED_RGTC1​
GL_VIEW_CLASS_RGTC2_RG​ GL_COMPRESSED_RG_RGTC2​, GL_COMPRESSED_SIGNED_RG_RGTC2​
GL_VIEW_CLASS_BPTC_UNORM​ GL_COMPRESSED_RGBA_BPTC_UNORM​, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM​
GL_VIEW_CLASS_BPTC_FLOAT​ GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT​, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT​
S3TC texture view compatibility
Class Internal formats
GL_S3TC_DXT1_RGB​ GL_COMPRESSED_RGB_S3TC_DXT1_EXT​, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT​
GL_S3TC_DXT1_RGBA​ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT​, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT​
GL_S3TC_DXT3_RGBA​ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT​, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT​
GL_S3TC_DXT5_RGBA​ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT​, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT​


Texel / Block Size Uncompressed Internal Format Compressed Internal Format(s)
128-bit GL_RGBA32UI​, GL_RGBA32I​, GL_RGBA32F​ 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​
64-bit GL_RGBA16UI​, GL_RGBA16I​, GL_RGBA16F​, GL_RG32F​, GL_RG32UI​, GL_RG32I​, GL_RGBA16​, GL_RGBA16_SNORM​ 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 the 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

See Also

glGenTextures, glTexImage1D, glTexImage2D, glTexImage2DMultisample, glTexImage3D, glTexImage3DMultisample, glTexStorage1D, glTexStorage2D, glTexStorage2DMultisample, glTexStorage3D, glTexStorage3DMultisample, glTextureView

Copyright

Copyright © 2012 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/.