htmlboss / OpenGL-Renderer

Modern OpenGL renderer written in C++17
MIT License
435 stars 29 forks source link

Use texture compression in `ResourceManager::LoadTexture` #20

Closed htmlboss closed 2 years ago

htmlboss commented 2 years ago

Was playing around with Valgrind to track down what I felt was excessive memory usage by the engine, which brought me to learn about on-the-fly texture compression offered by the OpenGL driver. Figured we should use that to reduce system memory usage, with the downside being we will have longer startup time as now the driver has to compress the images on the fly before uploading to the GPU.

Used the corresponding enums from Table 3 in https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml

With the OOB PBR Sponza scene, here are the results: RAM VRAM
Without compression 610 MB 1657 MB
With compression 397 MB 1464 MB
Difference -35% -12%

Screenshots

Before

Compiled with -g Screenshot from 2021-12-30 20-30-10

Compiled without -g image

After

Compiled with -g Screenshot from 2021-12-30 20-32-05

Compiled without -g Screenshot from 2021-12-30 20-34-15