DaemonEngine / crunch

Advanced DXTc texture compression and transcoding library and tool, upgraded with Unity improvements, added features, extended system and hardware support, deeply tested.
https://github.com/DaemonEngine/crunch
Other
16 stars 6 forks source link

Fixes some bugs in examples and factorize some code, test them in CI #61

Closed illwieckz closed 4 months ago

illwieckz commented 4 months ago

Fixes some bugs in examples and factorize some code.

The examples are now tested in CI.

illwieckz commented 4 months ago

The example1 CRN to DDS test doesn't work on macOS CI, I don't know why because I don't reproduce it on my end on macOS.

illwieckz commented 4 months ago
running: build/example1 c test/unvanquished_64.png -crn -out build/test/9/unvanquished_64.crn
example1 - Version v1.04 Built Jul  8 2024, 01:50:07
Loading source file: test/unvanquished_64.png
Source file size: 7471, Dimensions: 64x64
Actual Components: 4
Compressing to DXT5
Generating mipmaps using filter "kaiser"
Generated 6 mipmap levels in 0.004s
Compressing using quality level 128
Processing: 100%
Compressed to 2210 bytes, quality level: 128, effective bitrate: 3.237502
Writing CRN file: build/test/9/unvanquished_64.crn
running: build/example1 d build/test/9/unvanquished_64.crn -out build/test/9/unvanquished_64.dds
Loading source file: build/test/9/unvanquished_64.crn
Decompression mode only supports .dds or .crn files!
+ base64 build/test/9/unvanquished_64.crn
SHgAYoiYAAAIoquhAEAAQAcBAgAAAAAAAAAAAAEAAAAAAABiAAGMAIsAAe4AAd0ApAADywAAUwAyAAQeAADpADoAogAFBwAABakAAAeTAAAIPQAACHMAAAiCAAAIjwAACJoAgiwBG1BBBBLvN5NlUQhEDS/twBAfJAIgwww0k3JS5mg4GcFDSeW2NoCAcIWhCEInLprVIDn96AJApCAWDrMAUgDxwBa0SurOqUVmKYgUl2guMACROXV2SrsdtULQN0usCkupSc13AJBVLTADE3WwilRWDR2QgBATSLFxmA0KipNu0l6NL3HAtSXddLt1XE6AAsK3Uxl51SO27pK7bL1prtBASZktuqWJiN1v0dHd7fQDN/SC9dP/6+c79y+VdxkznQ/Ortbvz3AdTatCXY7uuxnEtb5E3j5LvRLOCWG12gmMk4YgLXNnC6hoBMhpbCqr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O+3LP/6vLfuycOy/bSF9KNTI17+lGtYAztcnK3YMveS28vLmYxMto6auVtRDXjKSkvdjG8n39PF0fIOrTK/qLWkOtUm44nwSs+uflpjHnKXX02Mvu+zQKQMA6fLp1mmSUvfUJnt+B05tcyf3g6U2+dLJdpRrP07kNMje1N0oMeDGqq8Qm3xpcaikxQdYC2UpxbMzHBGusrw534PLn0c/vrfD08m1Jvlaw/vp6FufCFmejPH/ZOv5/bT+jXOpdYaoaWfiDv5m70k/3vDX99OLh2+oTUd321kw9sE/f6X9AHyeMXfxyXfibheY38eS6F0LoXQ=

If I decode that file on my end and run crunch (even macOS crunch) on it, it says it's a valid crn file and decompresses it!

But it doesn't work in CI…

illwieckz commented 4 months ago

The example1 CRN to DDS test doesn't work on macOS CI, I don't know why because I don't reproduce it on my end on macOS.

Now fixed, a null-terminator was missing.

illwieckz commented 4 months ago

I don't know why the example1 test doesn't run on Windows MSVC Appveyor CI , while on my end a MinGW build runs correctly on wine.

slipher commented 4 months ago

I don't know why the example1 test doesn't run on Windows MSVC Appveyor CI , while on my end a MinGW build runs correctly on wine.

I reproduce a crash. It crashes when calling splitpath_s. I don't know what exactly was wrong, but anyway there is already a portable version file_utils::split_path. So example_platform files shouldn't be needed.

illwieckz commented 4 months ago

I don't know what exactly was wrong, but anyway there is already a portable version file_utils::split_path. So example_platform files shouldn't be needed.

It should be doable for example1 (I have a PoC that works in a branch), but that would be more problematic for example2 that is meant to be an example of how to not rely on crnlib:

example2

Shows how to transcodec CRN files to DDS using only the functionality in inc/crn_decomp.h. It does not link against against crnlib.lib or depend on it in any way. (Note: The complete source code, approx. 4800 lines, to the CRN transcoder is included in inc/crn_decomp.h.)

illwieckz commented 4 months ago

So example1 and example3 now use crnlib for both split_path and strcpy_safe, but example2 uses custom code to not link against crnlib.

illwieckz commented 4 months ago

This also extends the testing by running cross-compiled executables when possible (using wine, qemu-user…).

illwieckz commented 4 months ago

To avoid some warnings related to strncpy I imported a copy (without asserts) of strcpy_safe from crn_strutils.cpp into example2.cpp (which is expected to not build against libcrn).

I also added two commits fixing two kind of warnings in examples.

slipher commented 4 months ago

LGTM