what is the equivalent of the DirectDraw Surface (DDS) format for opengl on linux?

StackOverflow https://stackoverflow.com/questions/23653068

  •  22-07-2023
  •  | 
  •  

Question

DDS format has been made for directX right ? so it's should be optimized for it and not for openGL I guess.

So, there is another format(s) ? if yes, what format is a good choice ? what reason(s) ?

also, since I'm working on linux, I'm also concerned by making textures on linux. So I need a format who can be imported/exported by gimp.

Was it helpful?

Solution

The DDS format is useful for storing compressed textures. If you store the file in the same compression as it will be stored in the GPU memory, you don't need to decode and re-encode for GPU storage, instead you can just move it directly to memory.

The DDS format is basically used to store S3 Texture Compression data. The internal DDS formats DTX3 and DTX5 are for example S3TC formats that are also supported by OpenGL: http://www.opengl.org/wiki/S3_Texture_Compression

DDS also can store pre-calculated mipmaps. Again this is a trade-off (larger file size) for reducing loading times, as the mipmaps could also be calculated at loading time. As you can see, if you have the right code to parse the DDS file, e.g. the payload will be taken in its compressed form and not decoded on the host machine, then it is perfectly fine to use a DDS.

For an alternative, @CoffeeandCode pointed out the KTX format in his answer. These files use a different compression algorithm (see here). The advantage is that this compression is mandatory in newer OpenGL versions, while S3TC compression was always only available as an extension (and has patent problems). I don't know how they compare in quality and if you can expect OpenGL 4.3 on your target platforms.

My Take: If you are targeting recent hardware and OpenGL support (OpenGL ES 3 or OpenGL 4.3), you should use the KTX format and respective texture formats (libktx will generate the texture objects for you). If you need to be able to run on older hardware or happen to already have a lot of DDS data, you should probably stick with DDS for the time being.

OTHER TIPS

There is nothing particularly D3D-"optimized" about DDS.

Once you read the header correctly, the (optionally) pre-compressed data is binary compatible with S3TC. Both DDS and OpenGL's equivalent (KTX) are capable of storing cubemap arrays and mipmaps in a single image file, that is their primary appeal.

With other formats, you may wind up using the driver to compress and/or generate mipmaps, and the driver usually does a poor job quality wise. The drivers are usually designed to do this quickly because they have a lot of textures that need to be compressed / mipmapped. You can use a higher quality mipmap downsample filter / compression implementation offline since the amount of time required to complete is rather unimportant.

The key benefits of DDS / KTX are:

  1. Offline computation of mipmaps
  2. Offline compression
  3. Store all layers of a texture array/cubemap

Doing (1) and (2) offline can both improve image quality and reduce the overhead of loading textures at run-time. (3) is mostly for convenience, but a welcomed one.

I think the closest equivalent to DDS for DirectX is KTX, but even DDS works fine under OpenGL once parsed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top