{"id":13732045,"url":"https://github.com/GPUOpen-Tools/compressonator","last_synced_at":"2025-05-08T06:31:14.205Z","repository":{"id":41047340,"uuid":"56007467","full_name":"GPUOpen-Tools/compressonator","owner":"GPUOpen-Tools","description":"Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs","archived":false,"fork":false,"pushed_at":"2024-06-19T13:30:35.000Z","size":740150,"stargazers_count":1300,"open_issues_count":81,"forks_count":196,"subscribers_count":75,"default_branch":"master","last_synced_at":"2024-10-29T15:34:12.621Z","etag":null,"topics":["3d-models","analysis","astc","bc1","bc6h","bc7","compression","compressonator","decompression","dxtc","dxtc1","etc1","etc2","gui-application","mipmaps","sdk","texture-compression"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GPUOpen-Tools.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license/astc/license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-11T21:02:16.000Z","updated_at":"2024-10-15T13:17:46.000Z","dependencies_parsed_at":"2024-02-20T16:02:37.836Z","dependency_job_id":"62e8480a-59e1-4e47-9fcc-a0dc8832b1bc","html_url":"https://github.com/GPUOpen-Tools/compressonator","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUOpen-Tools%2Fcompressonator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUOpen-Tools%2Fcompressonator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUOpen-Tools%2Fcompressonator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GPUOpen-Tools%2Fcompressonator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GPUOpen-Tools","download_url":"https://codeload.github.com/GPUOpen-Tools/compressonator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224142857,"owners_count":17262885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-models","analysis","astc","bc1","bc6h","bc7","compression","compressonator","decompression","dxtc","dxtc1","etc1","etc2","gui-application","mipmaps","sdk","texture-compression"],"created_at":"2024-08-03T02:01:44.681Z","updated_at":"2024-11-14T23:30:47.238Z","avatar_url":"https://github.com/GPUOpen-Tools.png","language":"C++","readme":"\n# Compressonator\n[![CMake](https://github.com/GPUOpen-Tools/compressonator/actions/workflows/cmake.yml/badge.svg)](https://github.com/GPUOpen-Tools/compressonator/actions/workflows/cmake.yml)\n![download](https://img.shields.io/github/downloads/GPUOpen-Tools/Compressonator/total.svg)\n![download](https://img.shields.io/github/downloads/GPUOpen-Tools/Compressonator/V4.5.52/total.svg)\n\n*Download the latest revision for changes that have been made since the last major release by clicking the CMake button above or the link [here](https://github.com/GPUOpen-Tools/compressonator/actions/workflows/cmake.yml). Currently, only Compressonator Framework and Compressonator CLI are built every revision.*\n\nCompressonator is a set of tools to allow artists and developers to more easily create compressed texture assets or model mesh optimizations and easily visualize the quality impact of various compression and rendering technologies.  It consists of a GUI application, a command line application and an SDK for easy integration into a developer tool chain.\n\nCompressonator supports Microsoft Windows® and Linux builds.\n\nFor more details goto the online Compressonator Documents: http://compressonator.readthedocs.io/en/latest/ \n\n## Build System Updates ##\nThe code is undergoing a build setup update. This notice will be removed when the changes are completed!\nCurrently: To use the sln builds run build\\fetch_dependencies.py to fetch required external lib dependencies into a Common folder\nabove this repository.\n\n\nGet Prebuilt Binaries and Installer here:\n---------------------------------------------------\n\u003cdiv\u003e\n  \u003ca href=\"https://github.com/GPUOpen-Tools/Compressonator/releases/latest/\"\u003e\u003cimg src=\"http://gpuopen-librariesandsdks.github.io/media/latest-release-button.svg\" alt=\"Latest release\" title=\"Latest release\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\nTo build the source files follow the instructions in http://compressonator.readthedocs.io/en/latest/build_from_source/build_instructions.html\n\n## CMake Build Configuration ##\nAs of v4.2, The cmake command line options have settings to build specific libs and applications\n\nExamples: Generating Visual Studio Solution File\n\n```c++\nEnable building all\n    cmake -G \"Visual Studio 15 2017 Win64\"  \n    \nDisable all builds except external libs, minimal cmake base setup     \n    cmake -DOPTION_ENABLE_ALL_APPS=OFF -G \"Visual Studio 15 2017 Win64\"\n    \nEnable only CLI app build    \n    cmake -DOPTION_ENABLE_ALL_APPS=OFF -DOPTION_BUILD_APPS_CMP_CLI=ON -G \"Visual Studio 15 2017 Win64\"\n```\n\nFor more details reference the CMakeList file on the root folder.\n\n## Style and Format Change ##\n\nThe source code of this product is being reformatted to follow the Google C++ Style Guide https://google.github.io/styleguide/cppguide.html\n\nIn the interim you may encounter a mix of both an older C++ coding style, as well as the newer Google C++ Style.\n\nPlease refer to the _clang-format file in the root directory of the product for additional style information.\n\n\n## Compressonator Core\nProvides block level API access to updated performance and quality driven BCn codecs. The library is designed to be a small self-contained, cross-platform, and linkable library for user applications.\n\nExample usage is shown as below to compress and decompress a single 4x4 image block using BC1 encoder\n\n```c++\n\n// To use Compressonator Core \"C\" interfaces, just include\n// a single header file and CMP_Core lib into  your projects\n\n#include \"CMP_Core.h\"\n\n// Compress a sample image shape0 which is a 4x4 RGBA_8888 block.\n// Users can use a pointer to any sized image buffers to reference\n// a 4x4 block by supplying a stride offset for the next row.\n// Optional BC1 settings is set to null in this example\n\nunsigned char shape0_RGBA[64] = { filled with image source data as RGBA ...};\n\n// cmpBuffer is a byte array of 8 byte to hold the compressed results.\nunsigned char cmpBuffer[8]   = { 0 };\n\n// Compress the source into cmpBuffer\nCompressBlockBC1(shape0_RGBA, 16, cmpBuffer,null);\n\n// Example to decompress comBuffer back to a RGBA_8888 4x4 image block\nunsigned char imgBuffer[64] = { 0 };\nDecompressBlockBC1(cmpBuffer,imgBuffer,null)\n\n```\n\n## Compressonator Framework\n\nIncludes Compressonator core with interfaces for multi-threading, mipmap generation, file access of images and HPC pipeline interfaces.\n\n**Example Mip Level Processing using CPU**\n\n```c++\n\n// To use Compressonator Framework \"C\" interfaces, just include\n// a single header file and CMP_Framework lib into  your projects\n\n#include \"compressonator.h\"\n\n //--------------------------\n // Init frameworks\n // plugin and IO interfaces\n //--------------------------\n CMP_InitFramework();\n\n//---------------\n// Load the image\n//---------------\nCMP_MipSet MipSetIn;\nmemset(\u0026MipSetIn, 0, sizeof(CMP_MipSet));\ncmp_status = CMP_LoadTexture(pszSourceFile, \u0026MipSetIn);\nif (cmp_status != CMP_OK) {\n    std::printf(\"Error %d: Loading source file!\\n\",cmp_status);\n    return -1;\n}\n\n//----------------------------------------------------------------------\n// generate mipmap level for the source image, if not already generated\n//----------------------------------------------------------------------\n\nif (MipSetIn.m_nMipLevels \u003c= 1)\n{\n    CMP_INT requestLevel = 10; // Request 10 miplevels for the source image\n\n    //------------------------------------------------------------------------\n    // Checks what the minimum image size will be for the requested mip levels\n    // if the request is too large, a adjusted minimum size will be returned\n    //------------------------------------------------------------------------\n    CMP_INT nMinSize = CMP_CalcMinMipSize(MipSetIn.m_nHeight, MipSetIn.m_nWidth, 10);\n\n    //--------------------------------------------------------------\n    // now that the minimum size is known, generate the miplevels\n    // users can set any requested minumum size to use. The correct\n    // miplevels will be set acordingly.\n    //--------------------------------------------------------------\n    CMP_GenerateMIPLevels(\u0026MipSetIn, nMinSize);\n}\n\n//==========================\n// Set Compression Options\n//==========================\nKernelOptions   kernel_options;\nmemset(\u0026kernel_options, 0, sizeof(KernelOptions));\n\nkernel_options.format   = destFormat;   // Set the format to process\nkernel_options.fquality = fQuality;     // Set the quality of the result\nkernel_options.threads  = 0;            // Auto setting\n\n//=====================================================\n// example of using BC1 encoder options \n// kernel_options.bc15 is valid for BC1 to BC5 formats\n//=====================================================\nif (destFormat == CMP_FORMAT_BC1)\n{\n    // Enable punch through alpha setting\n    kernel_options.bc15.useAlphaThreshold = true;\n    kernel_options.bc15.alphaThreshold    = 128;\n\n    // Enable setting channel weights\n    kernel_options.bc15.useChannelWeights = true;\n    kernel_options.bc15.channelWeights[0] = 0.3086f;\n    kernel_options.bc15.channelWeights[1] = 0.6094f;\n    kernel_options.bc15.channelWeights[2] = 0.0820f;\n}\n\n//--------------------------------------------------------------\n// Setup a results buffer for the processed file,\n// the content will be set after the source texture is processed\n// in the call to CMP_ProcessTexture()\n//--------------------------------------------------------------\nCMP_MipSet MipSetCmp;\nmemset(\u0026MipSetCmp, 0, sizeof(CMP_MipSet));\n\n//===============================================\n// Compress the texture using Framework Lib\n//===============================================\ncmp_status = CMP_ProcessTexture(\u0026MipSetIn, \u0026MipSetCmp, kernel_options, CompressionCallback);\nif (cmp_status != CMP_OK) {\n  ...\n}\n\n//----------------------------------------------------------------\n// Save the result into a DDS file\n//----------------------------------------------------------------\ncmp_status = CMP_SaveTexture(pszDestFile, \u0026MipSetCmp);\n\nCMP_FreeMipSet(\u0026MipSetIn);\nCMP_FreeMipSet(\u0026MipSetCmp);\n\n```\n\n**Example GPU based processing using OpenCL**\n\n```c++\n\n// Note: Only MD x64 build is used for GPU processing\n// SDK files required for application:\n//     compressonator.h\n//     CMP_Framework_xx.lib  For static libs xx is either MD or MDd, \n//                      When using DLL's make sure the  CMP_Framework_xx_DLL.dll is in exe path\n//\n// File(s) required to run with the built application\n//\n// Using OpenCL (OCL) \n//     CMP_GPU_OCL_MD_DLL.dll    or CMP_GPU_OCL_MDd_DLL.dll\n//     Encode Kernel files in plugins/compute folder\n//     BC1_Encode_Kernel.cpp\n//     BC1_Encode_Kernel.h\n//     BCn_Common_kernel.h\n//     Common_Def.h\n//\n// Using DirectX (DXC) \n//     CMP_GPU_DXC_MD_DLL.dll    or CMP_GPU_DXC_MDd_DLL.dll\n//     Encode Kernel files in plugins/compute folder\n//     BC1_Encode_Kernel.hlsl\n//     BCn_Common_kernel.h\n//     Common_Def.h\n\n#include \"compressonator.h\"\n\nCMP_FORMAT      destFormat = CMP_FORMAT_BC1;\n\n//---------------\n// Load the image\n//---------------\nCMP_MipSet MipSetIn;\nmemset(\u0026MipSetIn, 0, sizeof(CMP_MipSet));\nif (CMP_LoadTexture(pszSourceFile, \u0026MipSetIn) != CMP_OK) {\n    std::printf(\"Error: Loading source file!\\n\");\n    return -1;\n  } \n\n //-----------------------------------------------------\n // when using GPU: The texture must have width and height as a multiple of 4\n // Check texture for width and height\n //-----------------------------------------------------\n if ((MipSetIn.m_nWidth % 4) \u003e 0 || (MipSetIn.m_nHeight % 4) \u003e 0) {\n    std::printf(\"Error: Texture width and height must be multiple of 4\\n\");\n    return -1;\n }\n    \n//----------------------------------------------------------------------------------------------------------\n// Set the target compression format and the host framework to use\n// For this example OpenCL is been used\n//-----------------------------------------------------------------------------------------------------------\nKernelOptions   kernel_options;\nmemset(\u0026kernel_options, 0, sizeof(KernelOptions));\n\nkernel_options.encodeWith = CMP_GPU_OCL;         // Using OpenCL GPU Encoder, can replace with DXC for DirectX\nkernel_options.format     = destFormat;          // Set the format to process\nkernel_options.fquality   = fQuality;            // Set the quality of the result\n\n//--------------------------------------------------------------\n// Setup a results buffer for the processed file,\n// the content will be set after the source texture is processed\n// in the call to CMP_ProcessTexture()\n//--------------------------------------------------------------\nCMP_MipSet MipSetCmp;\nmemset(\u0026MipSetCmp, 0, sizeof(CMP_MipSet));\n\n//===============================================\n// Compress the texture using Framework Lib\n//===============================================\ncmp_status = CMP_ProcessTexture(\u0026MipSetIn, \u0026MipSetCmp, kernel_options, CompressionCallback);\nif (cmp_status != CMP_OK) {\n  ...\n}\n\n//----------------------------------------------------------------\n// Save the result into a DDS file\n//----------------------------------------------------------------\ncmp_status = CMP_SaveTexture(pszDestFile, \u0026MipSetCmp);\n\nCMP_FreeMipSet(\u0026MipSetIn);\nCMP_FreeMipSet(\u0026MipSetCmp);\n\n```\n\n## Compressonator SDK\n\nCompressonator SDK supported codecs includes BC1-BC7/DXTC, ETC1, ETC2, ASTC, ATC, ATI1N, ATI2N, all available in a single library.\n\nWith the new SDK installation, several example applications with source code are provided that demonstrate how easy it is to add texture compression to your own applications using either \"High Level\" or \"Block Level\" APIs.\n\nA simple thread safe interface can compress, decompress and transcode any image as required\n\n`CMP_ConvertTexture(CMP_Texture* pSourceTexture, CMP_Texture* pDestTexture,...);`\n\n**For Example:**\n\n```c++\n\n// To use Compressonator's portable \"C\" interfaces, just include\n// a single header file and Compresonator.lib into  your projects\n\n#include \"Compressonator.h\"\n...\n\n//==========================\n// Load Source Texture\n//==========================\nCMP_Texture srcTexture;\n// note that LoadDDSFile function is a utils function to initialize the source CMP_Texture\n// you can also initialize the source CMP_Texture the same way as initialize destination CMP_Texture\nif (!LoadDDSFile(pszSourceFile, srcTexture))\n{\n  ...\n}\n\n//===================================\n// Initialize Compressed Destination\n//===================================\nCMP_Texture destTexture;\ndestTexture.dwSize     = sizeof(destTexture);\ndestTexture.dwWidth    = srcTexture.dwWidth;\ndestTexture.dwHeight   = srcTexture.dwHeight;\ndestTexture.dwPitch    = 0;\ndestTexture.format     = CMP_FORMAT_BC6H;\ndestTexture.dwDataSize = CMP_CalculateBufferSize(\u0026destTexture);\ndestTexture.pData      = (CMP_BYTE*)malloc(destTexture.dwDataSize);\n\n//==========================\n// Set Compression Options\n//==========================\nCMP_CompressOptions options = {0};\noptions.dwSize       = sizeof(options);\noptions.fquality     = 0.05f;\noptions.dwnumThreads = 8;\n\n//==========================\n// Compress Texture\n//==========================\nCMP_ERROR   cmp_status;\ncmp_status = CMP_ConvertTexture(\u0026srcTexture, \u0026destTexture, \u0026options, \u0026CompressionCallback, NULL, NULL);\nif (cmp_status != CMP_OK)\n{\n  ...\n}\n\n//==========================\n// Save Compressed Testure\n//==========================\nSaveDDSFile(pszDestFile, destTexture))\n\nfree(srcTexture.pData);\nfree(destTexture.pData);\n\n```\n\n\n## Compressonator CLI\nCommand line application that can be batch processed and supports:\n\n- Texture Compression, Decompression, Format Transcoding.\n- 3D Model Optimization and Mesh Compression.\n- Performance and Analysis Logs such as SSIM, MSE, PSNR.\n- MIP Maps, Image Differences, etc. ...\n\n```\nC:\\\u003eCompressonatorCLI -fd BC7 .\\images .results\n```\n```\nC:\\\u003eCompressonatorCLI -log -fd BC7 .\\images\\ruby.png ruby_bc7.dds\n```\n```\nCompressonatorCLI Performance Log v1.0\n\nSource        : .\\images\\ruby.png, Height 416, Wideth 576, Size 0.936 MBytes\nDestination   : ruby_bc7.dds\nUsing         : CPU\nQuality       : 0.05\nProcessed to  : BC7        with  1 iteration(s) in 1.422 seconds\nMSE           : 0.78\nPSNR          : 49.2\nSSIM          : 0.9978\nTotal time    : 1.432 seconds\n\n--------------\n```\n\n\n## Compressonator GUI\nComprehensive graphical application that can be used to visualize Images and 3D Models, with support for:\n\n- Texture Compression, Decompression, Format Transcoding.\n- 3D Model Optimization and Mesh Compression.\n- Multiple Image and 3D Model Views.\n- MIP Maps, Differences, Analysis, etc. ...\n\n![screenshot 1](https://github.com/GPUOpen-Tools/Compressonator/blob/master/docs/source/gui_tool/user_guide/media/image51.png)\n\n**glTF 2.0 Model Render View**\n\n![screenshot 2](https://github.com/GPUOpen-Tools/Compressonator/blob/master/docs/source/gui_tool/user_guide/media/image96.png)\n\n\n## Contributors\n\nCompressonator's GitHub repository (http://github.com/GPUOpen-Tools/Compressonator) is moderated by Advanced Micro Devices, Inc. as part of the GPUOpen initiative.\n\nAMD encourages any and all contributors to submit changes, features, and bug fixes via Git pull requests to this repository.\n\nUsers are also encouraged to submit issues and feature requests via the repository's issue tracker.\n\n \n","funding_links":[],"categories":["Graphics"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGPUOpen-Tools%2Fcompressonator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGPUOpen-Tools%2Fcompressonator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGPUOpen-Tools%2Fcompressonator/lists"}