Performance of compressed textures

I couldn’t really find much information on this on the internet, so here goes: is using glCompressedTexImage faster than using glTexImage? Quite obviously, it will be faster right when you’re uploading the texture, but what about the sampling performance? Would the usage of compressed textures slow down rendering?

Reading compressed textures generally consumes lower bandwidth on the GPU and less storage in the texture cache, so you’d generally want to prefer them over uncompressed textures. But of course you should bench on the hardware you care about to ensure that you do in-fact get a speed up. You won’t if the internal format isn’t natively supported by the GPU and under-the-hood it’s emulating support for that internal format using another, less efficient format. So I’d be sure to query the internal format and make sure that it is supported and preferred by the driver as well as establish what format and type is preferred for the fastest population of textures having that internal format.

Also standard rules for smart use of texture bandwidth and caching apply here. For instance, allocate+populate MIPmaps and use MIPmap-based min filtering if your textures will be rendered minified, etc.

Separate from these issues though…

While both of these calls not only upload new content, they also allocate storage for the MIP level. You wouldn’t be using these after startup (or certainly during render time) if you care about performance. Allocate once on startup (or level load). Then just update the content of the storage (once or repeatedly, depending on your needs, at render time only if necessary). And for allocation, you should generally prefer allocating texture MIP storage using the glTexStorage API calls rather than using a bunch of gl*TexImage calls. For subsequent population, look at the gl*TexSubImage() APIs.

If you need render-time texture subloads, be sure to set a budget for how much data to upload per frame so as not to cause a large performance spike, and upload in such a way as to avoid implicit sync issues (e.g. PBOs, and possibly double-buffering textures).

2 Likes

Thank you for your reply, that clears everything up. I already knew about good measures when it comes to texture allocation, I was just wondering if compressed textures would be faster for sampling. I’ll do some benchmarks later to know for sure.