compressonator icon indicating copy to clipboard operation
compressonator copied to clipboard

Can't save file on macOS build of CLI

Open ShukantPal opened this issue 4 years ago • 7 comments

Building with the changes in #167

Compressonator fails to save output images to my disk. It seems like it's trying to make Qt save the image, and Qt doesn't support compressed textures.

https://github.com/GPUOpen-Tools/compressonator/blob/dd1560ed782e6491111407ed82c7ebe56b14f87e/applications/_plugins/common/textureio.cpp#L831

I made a log in this if statement and found it's returning here. After more debugging, it seems like the plugin_image isn't being installed for some reason - and that's why it is falling back to Qt?

https://github.com/GPUOpen-Tools/compressonator/blob/dd1560ed782e6491111407ed82c7ebe56b14f87e/applications/_plugins/common/textureio.cpp#L788

Do you have an idea why this could be?

ShukantPal avatar Aug 08 '21 01:08 ShukantPal

Digging into this more, it looks like the IMAGE plugin also registers with an extension. I was trying to save to ASTC / DDS.

ShukantPal avatar Aug 08 '21 01:08 ShukantPal

I did a bit more debugging:

https://github.com/GPUOpen-Tools/compressonator/blob/dd1560ed782e6491111407ed82c7ebe56b14f87e/applications/_plugins/common/textureio.cpp#L731

The file_extension was an empty string - and it turns out the code fallbacks here:

https://github.com/GPUOpen-Tools/compressonator/blob/815d1b6fa01223cdbeb3e399e56b44e5c10fcdd7/applications/_plugins/common/cmp_fileio.cpp#L250

CMP_CPP17 or CMP_CPP14 weren't defined for me. It turns out you don't want macOS to fallback to C++11 here (😭):

https://github.com/GPUOpen-Tools/compressonator/blob/fa095e1c5c317bf682a6eb1d20a93a49e24978be/CMakeLists.txt#L34

I patched the commented out code for the C++11 fallback:

260      std::string file_extension;
261      bool incDot = false;
262      bool upperCase = false;
263      if (incDot)
264         file_extension = fn.substr(fn.find_last_of("."));
265       else
266          file_extension = fn.substr(fn.find_last_of(".") + 1);
267      if (upperCase)
268         std::transform(file_extension.begin(), file_extension.end(), file_extension.begin(),::toupper);
269      else
270         std::transform(file_extension.begin(), file_extension.end(), file_extension.begin(), ::tolower);
             return file_extension;

It still doesn't work for ASTC - but it works for DDS. Still though, the DDS file was corrupt so there are other bugs.


Enabling C++ 14, 17 doesn't work because the compiler outputs:

error: invalid argument '-std=c++14' not allowed with 'C'

ShukantPal avatar Aug 08 '21 02:08 ShukantPal

I don't think the CLI supports macOS builds at this point :)

ShukantPal avatar Aug 08 '21 02:08 ShukantPal

I have the same bug on windows CLI, processing but doesn't save any files, 415083 release works fine

Manoa1911 avatar Aug 10 '21 18:08 Manoa1911

@ShukantPal Will investigate why current master cmake is having issues on building CLI. @Manoa1911 Is this with running the installed cli or build and run from master source?

In these cases are you using only using c++11 for build and testing?

NPCompress avatar Aug 10 '21 18:08 NPCompress

it's installed release version 4.2.5185

Manoa1911 avatar Aug 10 '21 21:08 Manoa1911

@NPCompress For macOS, yes I had to use C++11 since Compressonator's build will ignore C++14, 17 for macOS.

ShukantPal avatar Aug 11 '21 02:08 ShukantPal