File: README.md

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (54 lines) | stat: -rw-r--r-- 2,308 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Texture Compressor

This directory contains a compressor for GPU texture formats. It is primarily
meant for compressing thumbnails to save memory. Currently, only the ETC1 format
is supported, and this is only used on Android.

## Goals

  * Fast: Compressing a 4K screenshot takes less than 100ms (roughly 100
    megapixels/s). Currently, it can achieve 220 megapixels/s on x64 desktop.
  * Safe: Free of memory safety issues and suitable for running in the
    privileged browser process.
  * Portable: SIMD code shared across x86 (SSE) and ARM (NEON). Easy to modify
    and validate for correctness.

## Algorithm

Vectorization is done by assigning each 4x4 SIMD lane to a different block. This
minimizes cross-lane shuffle operations (which are typically architecture
dependent) and makes the code significantly more portable.

Compression of ETC1 is done by first searching through the flip / no-flip and
individual / differential space to decide on the quantization of average, then
searching through selector tables and values for each subblock.

Detailed comments about the algorithm can be found in the source.

## Similar projects

  * [etcpak][etcpak] heavily inspired this project. Most of the algorithm
    (except vectorization scheme) and math tricks are borrowed from etcpak.
  * [ISPC Texture Compressor][ispctexcomp] influenced the vectorization scheme.
    Unlike this project, the compressor is written in ISPC and requires a
    dedicated compiler.
  * [AOSP ETC1 library][aospetc1] also uses a similar search algorithm and is
    easier to read, thanks to the scalar implementation.

While reading the code, the [ETC1 specification][etc1spec] should also be
useful.

## (Currently) Missing Pieces

This project is functional, but still a work-in-progress. The following pieces
are missing:

  * Testing coverage
  * Dynamic dispatch (multiversioning) and AVX2 support
  * Running on stable toolchain (using the `wide` crate instead of
    `#[feature(portable_simd)]`)

[etcpak]: https://github.com/wolfpld/etcpak
[ispctexcomp]: https://github.com/GameTechDev/ISPCTextureCompressor
[aospetc1]: https://cs.android.com/android/platform/superproject/main/+/main:frameworks/native/opengl/libs/ETC1/
[etc1spec]: https://registry.khronos.org/DataFormat/specs/1.1/dataformat.1.1.html#ETC1