Authored by Icecream95

GLSL decoder for DXT1

This is a reasonably fast GLSL DXT1 decoder which works on unmodified textures:

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16UI, width/4, height/4, 0,
                 GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, data);

This decoder is branchless, at least for some drivers/GPUs, and uses a bunch of tricks designed to make it harder to understand.

A version using two RGB565 textures and one R2 texture would probably be a lot faster - this decodes the RGB565 colours with bitwise operations - but that would require managing at least two separate textures, and anyway, how many drivers (and GPUs) support 2 bit-per-pixel formats?

DXT3 support could probably added increasing the decoding time by 20%-30%, but DXT5 would likely close to double the decode time, though at least no extra RGB565 conversions would have to be done.

The only filtering that can be done with this is NEAREST or NEAREST_MIPMAP_NEAREST, but I'm sure someone will add emulated bilinear filtering some day.

dxt1.frag 1.01 KB
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment