Code Monkey home page Code Monkey logo

cuttlefish's Introduction

Introduction

Cuttlefish

Cuttlefish is a texture conversion library and tool. A command line tool is provided for most texture conversion needs, such as running manually or part of an asset conversion pipeline. The library may be used to integrate more advanced texture generation within other software.

Features include:

  • Load almost any image format. (all supported by FreeImage)
  • Perform simple operations on input images such as resizing, flipping and rotating, and generating normalmaps.
  • Create 1D, 2D, 3D, and cube textures, as well as texture arrays.
  • Generate mipmaps.
  • Convert to most formats supported by the GPU, including:
    • Most standard uncompressed formats. (normalized integers, non-normalized integers, floating point, etc.)
    • S3TC formats (BC/DXT)
    • ETC
    • ASTC
    • PVRTC
  • Save the output texture in DDS, KTX, or PVR format.

Dependencies

The following software is required to build Cuttlefish:

The submodules can be downloaded by running the command

Cuttlefish$ git submodule update --init

When using the BC6H and BC7 encoders, it's highly recommended to install the ISPC compiler. This will use higher quality encoders that are also faster compared to the fallback used when ISP isn't available.

Note: Use the CUTTLEFISH_ISPC_PATH CMake variable when ISPC isn't visible on the system PATH.

Platforms

Cuttlefish has been built for and tested on the following platforms:

  • Linux (GCC and LLVM clang)
  • Windows (requires Visual Studio 2015 or later)
  • macOS

Building and Installing

CMake is used as the build system. The way to invoke CMake differs for different platforms.

Linux/macOS

To create a release build, execute the following commands:

Cuttlefish$ mkdir build
Cuttlefish$ cd build
Cuttlefish/build$ cmake .. -DCMAKE_BUILD_TYPE=Release
Cuttlefish/build$ make

The tests can be run by running the command:

Cuttlefish/build$ ctest

The library and tool may then be installed by running the command:

Cuttlefish/build$ sudo make install

macOS Universal Binary

To create a universal binary on macOS, set the CMAKE_OSX_ARCHITECTURES variable. For example, for an x86_64/arm64 universal binary, add the argument -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64. Building a universal binary requires creating an Xcode project with the -GXcode argument to CMake.

Note: when installing ISPC through homebrew not all targets are supported. For example, when installing on an ARM CPU (e.g. M1), only ARM targets are supported. Download from the ISPC website to get a version that supports both x86 and ARM targets.

Note: when creating an install package using shared libraries with Xcode, add the -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON option when running CMake. This avoids CMake breaking the code signature, which will make the executable unrunnable. The executables won't run in the build directory, however.

Windows

Building is generally performed through Visual Studio. This can either be done through the CMake GUI tool or on the command line. To generate Visual Studio 2017 projects from the command line, you can run the commands:

Cuttlefish$ mkdir build
Cuttlefish$ cd build
Cuttlefish\build$ cmake .. -G "Visual Studio 15 2017 Win64"

Once generated, the project may be opened through Visual Studio and built as normal. The RUN_TESTS project may be built in order to run the tests.

In order to install the libraries and tool, run Visual Studio as administrator, perform a release build, and run the INSTALL project. The default installation location is C:\Program Files\Cuttlefish. After installation, it's recommended to place the C:\Program Files\Cuttlefish\bin folder on your PATH environment variable to run the cuttlefish tool from the command line.

Options

The following options may be used when running cmake:

Compile Options:

  • -DCMAKE_BUILD_TYPE=Debug|Release: Building in Debug or Release. This should always be specified.
  • -DCMAKE_INSTALL_PREFIX=path: Sets the path to install to when running make install.
  • -DCUTTLEFISH_SHARED=ON|OFF: Set to ON to build with shared libraries, OFF to build with static libraries. Default is OFF.
  • -DCUTTLEFISH_ISPC_PATH=path: The path to the ISPC compiler. If unset, ispc will be searched in the PATH or default instal location.

Enabled Builds

  • -DCUTTLEFISH_BUILD_TESTS=ON|OFF: Set to ON to build the unit tests. gtest must also be found in order to build the unit tests. Defaults to ON.
  • -DCUTTLEFISH_BUILD_DOCS=ON|OFF: Set to ON to build the documentation. doxygen must also be found in order to build the documentation. Defaults to ON.
  • -DCUTTLEFISH_BUILD_TOOL=ON|OFF: Set to ON to build the tool. Defaults to ON.
  • -DCUTTLEFISH_FORCE_INTERNAL_FREEIMAGE=ON|OFF: Set to ON to force building FreeImage internally even if a system version is found. Defaults to OFF.
  • -DCUTTLEFISH_BUILD_S3TC=ON|OFF: Set to ON to build S3TC texture compression support. Defaults to ON.
  • -DCUTTLEFISH_BUILD_ETC=ON|OFF: Set to ON to build ETC texture compression support. Defaults to ON.
  • -DCUTTLEFISH_BUILD_ASTC=ON|OFF: Set to ON to build ASTC texture compression support. Defaults to ON.
  • -DCUTTLEFISH_BUILD_PVRTC=ON|OFF: Set to ON to build PVRTC texture compression support. Defaults to ON. If the PVRTexTool library isn't found, support will be disabled.

Miscellaneous Options:

  • -DCUTTLEFISH_OUTPUT_DIR=directory: The folder to place the output files. This may be explicitly left empty in order to output to the defaults used by cmake, but this may prevent tests and executables from running properly when CUTTLEFISH_SHARED is set to ON. Defaults to ${CMAKE_BINARY_DIR}/output.
  • -DCUTTLEFISH_EXPORTS_DIR=directory: The folder to place the cmake exports when building. This directory can be added to the module path when embedding in other projects to be able to use the library_find() cmake function. Defaults to ${CMAKE_BINARY_DIR}/cmake.
  • -DCUTTLEFISH_ROOT_FOLDER=folder: The root folder for the projects in IDEs that support them. (e.g. Visual Studio or XCode) This is useful if embedding Cuttlefish in another project. Defaults to Cuttlefish.
  • -DCUTTLEFISH_INSTALL=ON|OFF: Allow installation for Cuttlefish components. This can be useful when embedding in other projects to prevent installations from including Cuttlefish. For example, when statically linking into a shared library. Default is ON.
  • -DCUTTLEFISH_INSTALL_PVRTEXLIB=ON|OFF: Include the PVRTextTool library with the installation. This allows the installation to be used for machines that don't have PVRTexTool installed, and can avoid adjusting the PATH environment variable on some platforms. Default is ON.
  • -DCUTTLEFISH_INSTALL_SET_RPATH=ON|OFF: Set rpath during install for the library and tool on installation. Set to OFF if including in another project that wants to control the rpath. Default is ON.
  • -DPVRTEXLIB_ROOT=directory: The location of the PVRTexTool library platform subdirectories. If the PVRTexTool library is not installed to the standard location on this machine, this variable can be set to tell CMake where to look for the library. The given folder must contain a subdirectory for the current platform (one of OSX_x86, Linux_x86_64, Linux_x86_32, Windows_x86_64, or Windows_x86_32) that contains the library files.
  • -DCMAKE_OSX_DEPLOYMENT_TARGET=version: Minimum version of macOS to target when building for Mac. Defaults to 10.14, which is the minimum required for the PVRTexTool library.

Once you have built and installed Cuttlefish, you can find the library by calling find_package(Cuttlefish) within your CMake files. You can either link to the Cuttlefish::lib target or use the Cuttlefish_LIBRARIES and Cuttlefish_INCLUDE_DIRS CMake variables. The Cuttlefish::tool target may also be used for the tool executable.

Note: In order for find_package() to succeed, you will need to add the base installation path to CMAKE_PREFIX_PATH.

Limitations

Texture file format limitations

Some texture file formats have limitations for what texture formats are used. The following formats are not supported:

  • DDS
    • R4G4B4A4
    • B4G4R4A4
    • B5G6R5
    • R5G5B5A1
    • B5G5R5A1
    • R8G8B8
    • B8G8R8
    • A8B8G8R8
    • A2R10G10B10
    • R16G16B16
    • ETC/EAC compressed formats
    • ASTC compressed formats
    • PVRTC compressed formats
  • KTX
    • R4G4
    • A4R4G4B4
    • B8G8R8
  • PVR
    • All formats supported

Custom PVR metadata

Metadata is used to enhance the PVR file format to provide information beyond what is supported by the base format. The metadata values are:

  • FourCC: FOURCC('C', 'T', 'F', 'S')
  • Key: one of the following:
    • FOURCC('B', 'C', '1', 'A'): set for BC1_RGBA format. (i.e. BC1 with 1-bit alpha)
    • FOURCC('B', 'C', '1', 0): set for BC1_RGB format. (i.e. BC1 with no alpha)
    • FOURCC('A', 'R', 'R', 'Y'): set for texture arrays. This can be used to differentiate between a non-array texture and an array with 1 element.
    • FOURCC('D', 'I', 'M', '1'): set for 1D textures.
  • Data Size:: 4
  • Data: (uint32_t)0

A dummy data field of 4 bytes is used because the PVRTexTool GUI tool will crash with a data size of 0.

Further Documentation

cuttlefish's People

Contributors

akb825 avatar urkle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cuttlefish's Issues

PVRTC needs a squarepo2 option

PVRTexTool has a --square argument for resizing since PVRTC must be square pow2 textures. Since Cuttlefish supports PVRTC, this would save scripts from having to compute the max(pow2(width), pow2(height)) to pass down for the resize option. I can do this in the shell/python scripts that I have for now.

--resize squarepo2 squarepo2 cubic

error: file format DDS doesn't support format A8B8G8R8 with type (*insert any*)

Currently it seems impossible to actually create certain types of DDS textures. Uncompressed format "A8B8G8R8" will always fail because of the error message in the title of this issue. It doesn't matter what is selected as the type: unorm, snorm, uint, int, ufloat, or float. The tool itself will also always try to use the default "unorm" type if the "--type" command is omitted completely, so the error message is always present.

Figured I'd also provide a bit more context. I am on Windows 11, using the x64 version of cuttlefish.exe. The command I am attempting can be the most basic possible using only (--input in.png --format A8B8G8R8 --output out.dds) and the error message above will still be triggered.

Edit: Ok this issue may be invalid, maybe I'm misunderstanding the type. I got A8B8G8R8 mixed up with B8G8R8A8 (the latter is what I was actually trying to make) and it works. Also, R8G8B8A8 also works. So it is just A8B8G8R8 this is giving the error message. Maybe I'm not understanding how to use that format.

Failure to write when output folder doesn't exist.

Many tools that process textures often have subfolders that need to be created. I noted that cuttlefish was failing to write on these cases when I'd wipe the parent directory. It would be useful to have cuttlefish build subdirectories if they don't exist when providing an output path to simplify scripting and repeatability of texture processing.

I was trying cuttlefish after switching off PVRTexToolCLI, and this was one notable difference and breakage in the texture processing between these utilities.

This is the basic source to create the full path of directories and then open a file. This could be split out into a mkdir call, and the fopen call could just proceed normally then. Current behavior is a rather cryptic failure to write message,, so so I thought the encoder was failing.

// https://stackoverflow.com/questions/7430248/creating-a-new-directory-in-c

void rek_mkdir(char *path) {
    char *sep = strrchr(path, '/');
    if(sep != NULL) {
        *sep = 0;
        rek_mkdir(path);
        *sep = '/';
    }
    if(mkdir(path, 0777) && errno != EEXIST)
        printf("error while trying to create '%s'\n%m\n", path); 
}

FILE *fopen_mkdir(char *path, char *mode) {
    char *sep = strrchr(path, '/');
    if(sep) { 
        char *path0 = strdup(path);
        path0[ sep - path ] = 0;
        rek_mkdir(path0);
        free(path0);
    }
    return fopen(path,mode);
}

Many tests fail: error: couldn't load image 'texture.png'

63/84 Test #63: CuttlefishResizeCatmullRom ...........***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start 64: CuttlefishResizePO2
64/84 Test #64: CuttlefishResizePO2 ..................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start 65: CuttlefishResizeInvalidX
65/84 Test #65: CuttlefishResizeInvalidX .............   Passed    0.01 sec
      Start 66: CuttlefishResizeInvalidY
66/84 Test #66: CuttlefishResizeInvalidY .............   Passed    0.01 sec
      Start 67: CuttlefishMipmap
67/84 Test #67: CuttlefishMipmap .....................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start 68: CuttlefishMipmapLevels
68/84 Test #68: CuttlefishMipmapLevels ...............***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

Version: 2.7.1
clang-14
FreeBSD 13.1

BC7 encoder is very slow

This is an issue with choice to use NVTT, but perhaps a better/faster replacement for BC7 (and I assume BC6H) are needed.

Configure prints "FreeImage not found" and "PVRTexLib not found" even though all git submodules are present

===>  Configuring for cuttlefish-texture-compressor-2.6.0
===>  Performing out-of-source build
/bin/mkdir -p /disk-samsung/freebsd-ports/misc/cuttlefish/work/.build
-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Found Threads: TRUE  
-- Looking for FreeImage
FreeImage not found
PVRTexLib not found
-- Configuring done
-- Generating done

FreeBSD 13.1

--swizzle channel ordering not working as expected.

I've been trying to swizzle some textures with the following command on macOS, but the channel ordering doesn't look correct. I looked over the swizzle sources, and it makes sense, so maybe the jpeg/png code is loading in images as rbga instead of rgba. I wasn't able to debug from the Xcode project, but I'll work on trying to correct it.

This works to get the g and a channels populated with data, but I'm setting ba = gr (confirmed data in PVRTexToolGUI)
cuttlefish --swizzle xxgr -f ASTC_4x4 --srgb -i Image.jpeg -o Image.ktx
cuttlefish --swizzle xxgr -f ASTC_4x4 --srgb -i Image.png -o Image.ktx

Was expecting to use, ga = gr
cuttlefish --swizzle xgxr -f ASTC_4x4 --srgb -i Image.jpeg -o Image.ktx
cuttlefish --swizzle xgxr -f ASTC_4x4 --srgb -i Image.png -o Image.ktx

This should be a noop, but the channels are reordered.
cuttlefish --swizzle rgba -f ASTC_4x4 --srgb -i Image.png -o Image.ktx

Channel info from first swizzle on a Image.jpeg.

image

error: unknown type name 'CMP_Vec3ui'

In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_encode_kernel.cpp:23:
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_encode_kernel.h:28:
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:450:9: error: unknown type name 'CMP_Vec3ui'
typedef CMP_Vec3ui CGU_Vec3ui;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:451:9: error: unknown type name 'CMP_Vec3ui'
typedef CMP_Vec3ui CGV_Vec3ui;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:453:9: error: unknown type name 'CMP_Vec2f'
typedef CMP_Vec2f  CGU_Vec2f;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:454:9: error: unknown type name 'CMP_Vec3f'
typedef CMP_Vec3f  CGU_Vec3f;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:456:9: error: unknown type name 'CMP_Vec4uc'
typedef CMP_Vec4uc CGU_Vec4uc;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:457:9: error: unknown type name 'CMP_Vec4uc'
typedef CMP_Vec4uc CGV_Vec4uc;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:458:9: error: unknown type name 'CMP_Vec4i'
typedef CMP_Vec4i  CGU_Vec4i;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:459:9: error: unknown type name 'CMP_Vec4ui'
typedef CMP_Vec4ui CGU_Vec4ui;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:460:9: error: unknown type name 'CMP_Vec4ui'
typedef CMP_Vec4ui CGV_Vec4ui;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:461:9: error: unknown type name 'CMP_Vec4f'
typedef CMP_Vec4f  CGU_Vec4f;
        ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:462:9: error: unknown type name 'CMP_Vec4f'
typedef CMP_Vec4f  CGV_Vec4f;
        ^
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_encode_kernel.cpp:35:
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_common_encoder.h:30:
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:49:12: error: use of undeclared identifier 'fabs'
    return fabs(x);
           ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:61:17: error: use of undeclared identifier 'fabs'
    return (pow(fabs(Color), 1.0f / 2.4f) * 1.055f - 0.055f);
                ^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:66:10: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
    Color.x = cmp_linearToSrgbf(Color.x);
    ~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:66:38: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
    Color.x = cmp_linearToSrgbf(Color.x);
                                ~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:67:10: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
    Color.y = cmp_linearToSrgbf(Color.y);
    ~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:67:38: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
    Color.y = cmp_linearToSrgbf(Color.y);
                                ~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:68:10: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
    Color.z = cmp_linearToSrgbf(Color.z);
    ~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:68:38: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
    Color.z = cmp_linearToSrgbf(Color.z);
                                ~~~~~^~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Version: 2.5.5
clang-13.1
FreeBSD 13.1

Artifacts in alpha channel with BC1_RGB compression

Hi,

I have the following image without any alpha (fully white) which I wanted to convert into BC1_RGB. However when I do so I end-up with blocky artifacts in the Alpha channel/component of the texture. Using BC1_RGBA solves the issue. I'm not sure if that's the intended behavior, I would have expected something fully white or black, and not an hybrid.

(I'm checking out my files in RenderDoc.)

Source image:
train_debug_RGB

DDS image is produced with the following command:
cuttlefish --input "train_debug_RGB.png" --file-format dds --mipmap --format BC1_RGB --output "train_debug_RGB.dds"

When I check the alpha of the DDS file in RenderDoc this is what I see:
dds_artifacts

As I far I can see, my PNG file doesn't any alpha/transparency (other than fully white, so I'm considering it's opaque). So I don't understand why some blocks would end-up being 0 and not 255. I also noticed the issue on older versions as well, so it doesn't seem to be a regression.


Technical details:

  • Cuttlefish version: 2.7.3 (with release binaries, haven't compiled it myself)
  • OS: Linux Manjaro (LLVM 15.0.7, DRM 3.52, 6.3.5-2-MANJARO)
  • Kernel: 6.3.5
  • GPU: AMD Radeon RX 7900 XT (amdgpu drivers)
  • CPU: Ryzen 9 3900X
  • RAM: 64GB

BC1 vs. BC7

There seems to be a color issue on the BC1 output. The red and yellows turn green and black. All encoded textures except the BC1 thumbnails look correct on macOS - so ASTC, BC7, ETC2. I don't think this is 565 vs. 888 issue either. I know BC1 only has the two endpoints and selectors for 2 other values, so maybe BC7 is just that much better at fitting the 4 colors in the 4x4 block.

Tiny 4x4 block
AttribSimple

Here's a snapshot of the thumbnails in macOS
image

The commands to generate BC1 vs BC7 for the png.
cuttlefish -f BC1_RGB --srgb -Q high -i AttribSimple.png -o AttribSimpleBC1s.ktx --alpha none
cuttlefish -f BC7 --srgb -Q high -i AttribSimple.png -o AttribSimpleBC7s.ktx --alpha none

I ended up adding a "--resize 8 8 box" to provide a 4x4 BC1 blocks for each corner.

missing submodule commit for libsquish

โฏ git pull --recurse-submodules
Fetching submodule lib/FreeImage
Fetching submodule lib/ISPCTextureCompressor
Fetching submodule lib/PVRTexToolLib
Fetching submodule lib/astc-encoder
Fetching submodule lib/astc-encoder/Source/GoogleTest
Fetching submodule lib/bc7enc_rdo
Fetching submodule lib/compressonator
Fetching submodule lib/etc2comp
Fetching submodule lib/glm
Fetching submodule lib/libsquish
Already up to date.
fatal: remote error: upload-pack: not our ref a9087786ced42a1a4ee137c1ad5bf197dd2d6b72
fatal: Fetched in submodule path 'lib/libsquish', but it did not contain a9087786ced42a1a4ee137c1ad5bf197dd2d6b72. Direct fetching of that commit failed.

a9087786ced42a1a4ee137c1ad5bf197dd2d6b72 is missing. It looks like libsquish over on github has no history. Only 5 commits.

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [lib/CMakeFiles/cuttlefish_lib.dir/libsquish/squish.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/cuttlefish_lib.dir/all] Error 2
make: *** [all] Error 2

Fails while building.

Many tests fail: error: couldn't load image 'texture.png'

/bin/ln -s /usr/ports/misc/cuttlefish/work/Cuttlefish-2.7.2/tool/test/texture.png /usr/ports/misc/cuttlefish/work/.build/ || true
ln: /usr/ports/misc/cuttlefish/work/.build//texture.png: File exists
GTest not installed. Skipping tests.
PVRTexLib not found.
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /usr/ports/misc/cuttlefish/work/.build
ninja: no work to do.
[  0% 1/1] cd /usr/ports/misc/cuttlefish/work/.build && /usr/local/bin/ctest --force-new-ctest-process
Test project /usr/ports/misc/cuttlefish/work/.build
      Start  1: CuttlefishNoArgs
 1/83 Test  #1: CuttlefishNoArgs .....................   Passed    0.01 sec
      Start  2: CuttlefishHelp
 2/83 Test  #2: CuttlefishHelp .......................   Passed    0.01 sec
      Start  3: CuttlefishSaveDds
 3/83 Test  #3: CuttlefishSaveDds ....................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start  4: CuttlefishSaveKtx
 4/83 Test  #4: CuttlefishSaveKtx ....................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start  5: CuttlefishSavePvr
 5/83 Test  #5: CuttlefishSavePvr ....................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start  6: CuttlefishSaveUnknownFileType
 6/83 Test  #6: CuttlefishSaveUnknownFileType ........   Passed    0.01 sec
      Start  7: CuttlefishSaveMissingFileTypeParam
 7/83 Test  #7: CuttlefishSaveMissingFileTypeParam ...   Passed    0.01 sec
      Start  8: CuttlefishMissingOutput
 8/83 Test  #8: CuttlefishMissingOutput ..............   Passed    0.01 sec
      Start  9: CuttlefishMultipleOutput
 9/83 Test  #9: CuttlefishMultipleOutput .............   Passed    0.01 sec
      Start 10: CuttlefishSaveBC3
10/83 Test #10: CuttlefishSaveBC3 ....................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

The project is built out-source, in /usr/ports/misc/cuttlefish/work/.build
There is a symbolic link that the port creates there for 'texture.png' but this error occurs any way.

System call log also contains this error:

 46879 ctest    GIO   fd 3 wrote 212 bytes
       "Command: "/usr/ports/misc/cuttlefish/work/Cuttlefish-2.7.2/tool/test/run-test.sh" "/usr/ports/misc/cuttlefish/work/.build/output/cuttlefish" "-i texture.png -f R8G8B8A8 -s rgb -o /dev/null --file-format pvr" "1"
       "
 46879 ctest    RET   write 212/0xd4
 46879 ctest    CALL  write(0x3,0x82f60e840,0x46)
 46879 ctest    GIO   fd 3 wrote 70 bytes
       "Directory: /usr/ports/misc/cuttlefish/work/Cuttlefish-2.7.2/tool/test
       "
 46879 ctest    RET   write 70/0x46
 46879 ctest    CALL  write(0x3,0x82f60e840,0x3e)
 46879 ctest    GIO   fd 3 wrote 62 bytes
       ""CuttlefishSwizzleInvalidNumber" start time: May 31 08:24 PDT
       "
 46879 ctest    RET   write 62/0x3e
 46879 ctest    CALL  write(0x3,0x82f60e840,0x8)
 46879 ctest    GIO   fd 3 wrote 8 bytes
       "Output:
       "
 46879 ctest    RET   write 8
 46879 ctest    CALL  write(0x3,0x82f60e840,0x3b)
 46879 ctest    GIO   fd 3 wrote 59 bytes
       "----------------------------------------------------------
       "
 46879 ctest    RET   write 59/0x3b
 46879 ctest    CALL  write(0x3,0x82f60e840,0x2467)
 46879 ctest    GIO   fd 3 wrote 4096 bytes
       "error: swizzle must contain 4 elements of r, g, b, a, or x

        Usage: cuttlefish [options]

        General options:
          -h, --help     display this help message
          -j, --jobs [n] the number of jobs to convert with; if n is omitted, use all
                         available cores
          -q, --quiet    suppress all non-error output
          -v, --verbose  verbose output

        Input files: at least one required, cannot mix different types
          -i, --input file               the input image for a standard texture
          -a, --array [n] file           the input image for an array or 3D texture:
                                           n: the index of the image
                                           file: the path to the image
          -c, --cube face file           the input image for a cube map:
                                           face: the face, which is one of:
                                             +x, -x, +y, -y, +z, -z
                                           file: the path to the image
          -C, --cube-array n face file   the input image for a cube map:
                                           n: the index of the image
                                           face: the face, which is one of:
                                             +x, -x, +y, -y, +z, -z
                                           file: the path to the image
          -I, --input-list type file     specify a file with a list of image paths:
                                           type: type of texture, which is one of the
                                             following: image, array, cube, cube-array;
                                             cube faces are in the order:
                                             +x, -x, +y, -y, +z, -z
                                           file: path to a file containing a list of

Version: 2.7.2
FreeBSD 13.2

Many tests fail: error: couldn't load image 'texture.png'

68/83 Test #68: CuttlefishMipmapFilter ...............***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start 69: CuttlefishMipmapLevelsFilter
69/83 Test #69: CuttlefishMipmapLevelsFilter .........***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

      Start 70: CuttlefishNormalimap
70/83 Test #70: CuttlefishNormalimap .................***Failed    0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1

Version: 2.7.1
clang-14
FreeBSD 13.1

Texture::maxMipmapLevels returns (seemingly) incorrect value for non-square images

As title. With an attached image of WxH 256x1024 pixels, the returned value from Texture::maxMipmapLevels is 11, however any mipmap levels after 9 has a width of 0. This causes Texture::generateMipmaps to generate mipmaps that have an area of 0 and report that 11 mipmaps were created via Texture::mipLevelCount.

A workaround for this is to call Texture::maxMipLevels with the minimum of the width and height of the image, then pass that into Texture::generateMipmaps, but a better solution would seem to be to patch Texture::maxMipmapLevels to return the minimum of levelCount{Width,Height,Depth} instead of the maximum.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.