How to use various mobile GPU compressed textures

Source: Internet
Author: User


Describes the GPU used by various mobile devices, as well as the format and usage of compressed textures supported by each GPU.

1. Mobile GPU Daquan
The current mobile market GPU has four major manufacturers:

1) Imagination Technologies PowerVR SGX Series

Representative Model: PowerVR SGX 535, PowerVR SGX 540, PowerVR SGX 543MP, PowerVR SGX 554MP, etc.
Masterpiece: Apple iphone full line, ipad full line, Samsung I9000, P3100, etc.

2) Qualcomm (Qualcomm) Adreno series

Representative Model: Adreno 200, Adreno 205, Adreno 220, Adreno 320, etc.
Masterpiece: HTC G10, G14, Xiaomi 1, 2, etc.

3) ARM's Mali series

Representative model: Mali-400, mali-t604, etc.
Masterpiece: Samsung Galaxy SII, Galaxy SIII, Galaxy Note1, Galaxy Note2 (Asian edition), etc.

4) Tegra series of Nvidia (NVIDIA)

< Span style= "font-family: Song body" > representative model: Nvidia TEGRA2, nvidia TEGRA3, etc.
Representative  : Google Nexus 7,htc one x etc

2. The necessity of compressing the texture
1) First of all, the difference between a file format and a texture format.
commonly used image File format has bmp,tga,jpg,gif,png, etc.
commonly used texture format r5g6b5,a4r4g4b4,a1r5g5b5,r8g8b8, a8r8g8b8 and so on. The

    file format is a special encoding of information used by an image to store information, stored on disk, or in memory, but not recognized by the GPU, because GPU-based GPUs are powerless for these complex computations. These file formats, when read into by the game, still need to be decompressed by the CPU into R5G6B5,A4R4G4B4,A1R5G5B5,R8G8B8, A8R8G8B8 and other pixel formats, and then transferred to the GPU side for use. The
    texture format is a pixel format that can be recognized by the GPU and can be quickly addressed and sampled.
For example, a DDS file is a commonly used file format for game development, which can contain A4R4G4B4 texture formats, A8R8G8B8 texture formats, and even DXT1 texture formats. Here the DDS file is a little container of meaning.

    OpenGL ES 2.0 supports the R5G6B5,A4R4G4B4,A1R5G5B5,R8G8B8,A8R8G8B8 and other texture formats mentioned above, where R5G6B5,A4R4G4B4, A1r5g5b5 consumes 2 bytes per pixel (byte), R8g8b8 consumes 3 bytes per pixel, and A8r8g8b8 consumes 4 bytes per pixel.

for a 512*512 texture, the R5G6B5 format of the file needs to occupy 512KB capacity, a8r8g8b8 format of the file needs to occupy 1MB capacity, if it is 1024*1024 texture, you need 2M and 4M of capacity, which is frequently required dozens of, Hundreds of or more textures of the game, the G capacity of the game on the mobile platform is not easy to accept (of course, there are 1, 2G of the masterpiece, containing thousands of images of the texture).

Smart designers are wondering if there is any other way to achieve a smaller texture capacity, both in color and detail, and in the smallest possible distortion. The compressed texture format came into being (of course, not the product after the mobile platform).

3. Common compressed texture formats
The compression textures based on OpenGL ES are commonly implemented in the following ways:
1) ETC1 (Ericsson texture compression)
2) PVRTC (PowerVR texture compression)
3) ATITC (ATI texture compression)
4) S3TC (S3 texture compression)

The ETC1 format is part of the OpenGL ES graphics standard and is supported by all Android devices.
The extension is: gl_oes_compressed_etc1_rgb8_texture, which does not support transparent channels, so it can only be used for opaque textures.
When loading a compressed texture, the <internal format> parameter supports the following format:
Gl_etc1_rgb8_oes (RGB, 0.5 bytes per pixel)

The supported GPUs are the PowerVR SGX series of the Imagination Technologies.
OpenGL es has a extension of: GL_IMG_TEXTURE_COMPRESSION_PVRTC.
The <internal format> parameter supports several formats when loading compressed textures:
Gl_compressed_rgb_pvrtc_4bppv1_img (RGB, 0.5 bytes per pixel)
Gl_compressed_rgb_pvrtc_2bppv1_img (RGB, 0.25 bytes per pixel)
Gl_compressed_rgba_pvrtc_4bppv1_img (RGBA, 0.5 bytes per pixel)
Gl_compressed_rgba_pvrtc_2bppv1_img (RGBA, 0.25 bytes per pixel)

The supported GPU is the Adreno family of Qualcomm.
The supported OpenGL ES extension is: GL_ATI_TEXTURE_COMPRESSION_ATITC.
The <internal format> parameter supports the following types of textures when loading compressed textures:
GL_ATC_RGB_AMD (RGB, 0.5 bytes per pixel)

Also known as DXTC, it is widely used on PCs, but it is still a novelty on mobile devices. The supported GPUs are the NVIDIA Tegra series.
The OpenGL es extension is:
Gl_ext_texture_compression_dxt1 and GL_EXT_TEXTURE_COMPRESSION_S3TC.
When loading a compressed texture, the parameters of the <internal format> are in the following formats:
GL_COMPRESSED_RGB_S3TC_DXT1 (RGB, 0.5 bytes per pixel)
GL_COMPRESSED_RGBA_S3TC_DXT1 (RGBA, 0.5 bytes per pixel)
GL_COMPRESSED_RGBA_S3TC_DXT3 (RGBA, 1 bytes per pixel)
GL_COMPRESSED_RGBA_S3TC_DXT5 (RGBA, 1 bytes per pixel)

Thus, the Mali series GPU only supports compressed textures in the ETC1 format, and the texture does not support transparent channels and has some limitations.
The above compressed texture format per pixel size relative to the A8R8G8B8 format ratio, the maximum compression ratio is 16:1, the minimum compression ratio is 4:1, for reducing the texture of the data capacity has a significant effect, corresponding to the memory bandwidth also has a significant advantage, thereby improving the game's operating efficiency (this feature has no absolute value, varies depending on the usage and bottleneck point of each game).

4. use of related APIs in OpenGL

1) Get the model of the GPU

Glgetstring (Gl_renderer)

2) The manufacturer that obtains the GPU

Glgetstring (Gl_vendor);

3) Get what compression textures the GPU supports

String extensions = (const char*) glgetstring (gl_extensions);

A. Determining whether to support compressed textures in the ETC1 format

Return (Extensions.find ("gl_oes_compressed_etc1_rgb8_texture")! = String::npos);

B. Determine if compression textures are supported in DXT format

Return (Extensions.find ("Gl_ext_texture_compression_dxt1")! = String::npos | |

Extensions.find ("GL_EXT_TEXTURE_COMPRESSION_S3TC")! = String::npos);

C. Determining whether to support compressed textures in the PVRTC format

Return (Extensions.find ("GL_IMG_TEXTURE_COMPRESSION_PVRTC")! = String::npos);

D. Determining whether to support compressed textures in the ATITC format

Return (Extensions.find ("gl_amd_compressed_atc_texture")! = String::npos | |

Extensions.find ("GL_ATI_TEXTURE_COMPRESSION_ATITC")! = String::npos);

4) Fill compressed texture data

void Glcompressedteximage2d (

Glenum Target,

Glint level,

Glenum Internalformat,

Glsizei width,

Glsizei height,

Glint Border,

Glsizei ImageSize,

Const glvoid * data);

The parameters here are not explained in detail, where Internalformat is the type of the compressed texture format.

5. Use of the compressed texture tool
Each compression texture and the corresponding vendor provide a tool for compressing the textures, which are divided into two versions:
A. Visual conversion tool (for art or small white use)
B. Command-line conversion tool (bulk use for programs)

The usage of each tool is described below.
1) Imagination Technologies PowerVR

Visual Conversion Interface

command line conversion scripts
For%%i in (*.TGA) do pvrtextool.exe-f pvrtc4-i%%i
(Convert all TGA files in this directory to a PVR file in "PVRTC4" encoded format without mipmap)
Detailed instructions for use: PvrTexTool.exe/?

2) Qualcomm Adreno
Tools Tools-and-resources

Visual Conversion Interface

command line conversion scripts
For%%i in (*.TGA) do QCompressCmd.exe%%i%%i.ktx "ATC RGBA Explicit" Yes
(Convert all TGA files in this catalogue into KTX files in the "ATC RGBA Explicit" encoded format, with mipmap)
Detailed instructions for use: QCompressCmd.exe/?

3) ARM Mali

Visual Conversion Interface

command line conversion scripts
For%%i in (*.TGA) do pvrtextool.exe-f etc-i%%i
(Convert all TGA files in this directory into a PVR file in the "ETC" encoded format, without mipmap here or using the PVRTexTool.exe, you can also use QCompressCmd.exe)
Detailed instructions for use: PVRTexTool.exe/?

4) NVIDIA Tegra
Can be converted using the DirectX Texture tool that comes with the DirectX SDK
Visual Conversion Interface

command line conversion scripts
For%%i in (*.TGA) do texconv.exe-f DXT5%%i
(Convert all TGA files in this directory to DDS files in "DXT5" encoded format without mipmap)
Detailed instructions for use: TexConv.exe/?

How to use various mobile GPU compressed textures

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.