GPUOpen-Tools / compressonator

Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs
1.3k stars 195 forks source link

Leaking thread objects when encoding with BC6 / BC7 and disabled multithreading #314

Open ChristianFischer opened 6 months ago

ChristianFischer commented 6 months ago

When I was trying to use the Compressonator SDK to encode textures using BC6 / BC7, I've encountered several issues after trying to disable multithreading. This can easily be reproduced by adding this lines to sdk_sample1.cpp:

    options.dwnumThreads           = 1;
    options.bDisableMultiThreading = true;

and run the command sdk_sample1 runtime/images/ruby.dds runtime/images/ruby_bc7.dds BC7 0.05

Without clearing the threads properly, this could lead into serious performance issues when encoding a large amount of images during the lifetime of an application. It would be preferred when those threads wouldnt be created in the first place.

Additionally to this issues, there would be also an opportunity for optimization. With their default values, the codecs always create threads for encoding as well as a decoder object. Even when cleaned up properly, either the encoder or decoder objects won't be used, so it could be useful to tell the codec whether to be used as an encoder or decoder and just initialize the required objects.