/* -*- tab-width: 4; -*- */1/* vi: set sw=2 ts=4 expandtab: */23#ifndef KTX_H_A55A6F00956F42F3A137C11929827FE14#define KTX_H_A55A6F00956F42F3A137C11929827FE156/*7* Copyright 2010-2018 The Khronos Group, Inc.8* SPDX-License-Identifier: Apache-2.09*10* See the accompanying LICENSE.md for licensing details for all files in11* the KTX library and KTX loader tests.12*/1314/**15* @file16* @~English17*18* @brief Declares the public functions and structures of the19* KTX API.20*21* @author Mark Callow, Edgewise Consulting and while at HI Corporation22* @author Based on original work by Georg Kolling, Imagination Technology23*24* @snippet{doc} version.h API version25*/2627#include <limits.h>28#include <stdio.h>29#include <stdbool.h>30#include <sys/types.h>3132#include <KHR/khr_df.h>3334/*35* Don't use khrplatform.h in order not to break apps existing36* before these definitions were needed.37*/38#if defined(KHRONOS_STATIC)39#define KTX_API40#elif defined(_WIN32) || defined(__CYGWIN__)41#if !defined(KTX_API)42#if __GNUC__43#define KTX_API __attribute__ ((dllimport))44#elif _MSC_VER45#define KTX_API __declspec(dllimport)46#else47#error "Your compiler's equivalent of dllimport is unknown"48#endif49#endif50#elif defined(__ANDROID__)51#define KTX_API __attribute__((visibility("default")))52#else53#define KTX_API54#endif5556#if defined(_WIN32) && !defined(KHRONOS_STATIC)57#if !defined(KTX_APIENTRY)58#define KTX_APIENTRY __stdcall59#endif60#else61#define KTX_APIENTRY62#endif6364/* To avoid including <KHR/khrplatform.h> define our own types. */65typedef unsigned char ktx_uint8_t;66typedef bool ktx_bool_t;67#ifdef _MSC_VER68typedef unsigned __int16 ktx_uint16_t;69typedef signed __int16 ktx_int16_t;70typedef unsigned __int32 ktx_uint32_t;71typedef signed __int32 ktx_int32_t;72typedef size_t ktx_size_t;73typedef unsigned __int64 ktx_uint64_t;74typedef signed __int64 ktx_int64_t;75#else76#include <stdint.h>77typedef uint16_t ktx_uint16_t;78typedef int16_t ktx_int16_t;79typedef uint32_t ktx_uint32_t;80typedef int32_t ktx_int32_t;81typedef size_t ktx_size_t;82typedef uint64_t ktx_uint64_t;83typedef int64_t ktx_int64_t;84#endif8586/* This will cause compilation to fail if size of uint32 != 4. */87typedef unsigned char ktx_uint32_t_SIZE_ASSERT[sizeof(ktx_uint32_t) == 4];8889/*90* This #if allows libktx to be compiled with strict c99. It avoids91* compiler warnings or even errors when a gl.h is already included.92* "Redefinition of (type) is a c11 feature". Obviously this doesn't help if93* gl.h comes after. However nobody has complained about the unguarded typedefs94* since they were introduced so this is unlikely to be a problem in practice.95* Presumably everybody is using platform default compilers not c99 or else96* they are using C++.97*/98#if !defined(GL_NO_ERROR)99/*100* To avoid having to including gl.h ...101*/102typedef unsigned char GLboolean;103typedef unsigned int GLenum;104typedef int GLint;105typedef int GLsizei;106typedef unsigned int GLuint;107typedef unsigned char GLubyte;108#endif109110#ifdef __cplusplus111extern "C" {112#endif113114/**115* @~English116* @brief Key string for standard writer metadata.117*/118#define KTX_ANIMDATA_KEY "KTXanimData"119/**120* @~English121* @brief Key string for standard orientation metadata.122*/123#define KTX_ORIENTATION_KEY "KTXorientation"124/**125* @~English126* @brief Key string for standard swizzle metadata.127*/128#define KTX_SWIZZLE_KEY "KTXswizzle"129/**130* @~English131* @brief Key string for standard writer metadata.132*/133#define KTX_WRITER_KEY "KTXwriter"134/**135* @~English136* @brief Key string for standard writer supercompression parameter metadata.137*/138#define KTX_WRITER_SCPARAMS_KEY "KTXwriterScParams"139/**140* @~English141* @brief Standard KTX 1 format for 1D orientation value.142*/143#define KTX_ORIENTATION1_FMT "S=%c"144/**145* @~English146* @brief Standard KTX 1 format for 2D orientation value.147*/148#define KTX_ORIENTATION2_FMT "S=%c,T=%c"149/**150* @~English151* @brief Standard KTX 1 format for 3D orientation value.152*/153#define KTX_ORIENTATION3_FMT "S=%c,T=%c,R=%c"154/**155* @~English156* @brief Required unpack alignment157*/158#define KTX_GL_UNPACK_ALIGNMENT 4159#define KTX_FACESLICE_WHOLE_LEVEL UINT_MAX160161#define KTX_TRUE true162#define KTX_FALSE false163164/**165* @~English166* @brief Error codes returned by library functions.167*/168typedef enum ktx_error_code_e {169KTX_SUCCESS = 0, /*!< Operation was successful. */170KTX_FILE_DATA_ERROR, /*!< The data in the file is inconsistent with the spec. */171KTX_FILE_ISPIPE, /*!< The file is a pipe or named pipe. */172KTX_FILE_OPEN_FAILED, /*!< The target file could not be opened. */173KTX_FILE_OVERFLOW, /*!< The operation would exceed the max file size. */174KTX_FILE_READ_ERROR, /*!< An error occurred while reading from the file. */175KTX_FILE_SEEK_ERROR, /*!< An error occurred while seeking in the file. */176KTX_FILE_UNEXPECTED_EOF, /*!< File does not have enough data to satisfy request. */177KTX_FILE_WRITE_ERROR, /*!< An error occurred while writing to the file. */178KTX_GL_ERROR, /*!< GL operations resulted in an error. */179KTX_INVALID_OPERATION, /*!< The operation is not allowed in the current state. */180KTX_INVALID_VALUE, /*!< A parameter value was not valid. */181KTX_NOT_FOUND, /*!< Requested metadata key or required dynamically loaded GPU function was not found. */182KTX_OUT_OF_MEMORY, /*!< Not enough memory to complete the operation. */183KTX_TRANSCODE_FAILED, /*!< Transcoding of block compressed texture failed. */184KTX_UNKNOWN_FILE_FORMAT, /*!< The file not a KTX file */185KTX_UNSUPPORTED_TEXTURE_TYPE, /*!< The KTX file specifies an unsupported texture type. */186KTX_UNSUPPORTED_FEATURE, /*!< Feature not included in in-use library or not yet implemented. */187KTX_LIBRARY_NOT_LINKED, /*!< Library dependency (OpenGL or Vulkan) not linked into application. */188KTX_DECOMPRESS_LENGTH_ERROR, /*!< Decompressed byte count does not match expected byte size */189KTX_DECOMPRESS_CHECKSUM_ERROR, /*!< Checksum mismatch when decompressing */190KTX_ERROR_MAX_ENUM = KTX_DECOMPRESS_CHECKSUM_ERROR /*!< For safety checks. */191} ktx_error_code_e;192/**193* @~English194* @deprecated Use #ktx_error_code_e.195* @brief For backward compatibility196*/197#define KTX_error_code ktx_error_code_e198199#define KTX_IDENTIFIER_REF { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }200#define KTX_ENDIAN_REF (0x04030201)201#define KTX_ENDIAN_REF_REV (0x01020304)202#define KTX_HEADER_SIZE (64)203204/**205* @~English206* @brief Result codes returned by library functions.207*/208typedef enum ktx_error_code_e ktxResult;209210/**211* @class ktxHashList212* @~English213* @brief Opaque handle to a ktxHashList.214*/215typedef struct ktxKVListEntry* ktxHashList;216217typedef struct ktxStream ktxStream;218219#define KTX_APIENTRYP KTX_APIENTRY *220/**221* @class ktxHashListEntry222* @~English223* @brief Opaque handle to an entry in a @ref ktxHashList.224*/225typedef struct ktxKVListEntry ktxHashListEntry;226227typedef enum ktxOrientationX {228KTX_ORIENT_X_LEFT = 'l', KTX_ORIENT_X_RIGHT = 'r'229} ktxOrientationX;230231typedef enum ktxOrientationY {232KTX_ORIENT_Y_UP = 'u', KTX_ORIENT_Y_DOWN = 'd'233} ktxOrientationY;234235typedef enum ktxOrientationZ {236KTX_ORIENT_Z_IN = 'i', KTX_ORIENT_Z_OUT = 'o'237} ktxOrientationZ;238239typedef enum class_id {240ktxTexture1_c = 1,241ktxTexture2_c = 2242} class_id;243244/**245* @~English246* @brief Struct describing the logical orientation of an image.247*/248struct ktxOrientation {249ktxOrientationX x; /*!< Orientation in X */250ktxOrientationY y; /*!< Orientation in Y */251ktxOrientationZ z; /*!< Orientation in Z */252};253254#define KTXTEXTURECLASSDEFN \255class_id classId; \256struct ktxTexture_vtbl* vtbl; \257struct ktxTexture_vvtbl* vvtbl; \258struct ktxTexture_protected* _protected; \259ktx_bool_t isArray; \260ktx_bool_t isCubemap; \261ktx_bool_t isCompressed; \262ktx_bool_t generateMipmaps; \263ktx_uint32_t baseWidth; \264ktx_uint32_t baseHeight; \265ktx_uint32_t baseDepth; \266ktx_uint32_t numDimensions; \267ktx_uint32_t numLevels; \268ktx_uint32_t numLayers; \269ktx_uint32_t numFaces; \270struct ktxOrientation orientation; \271ktxHashList kvDataHead; \272ktx_uint32_t kvDataLen; \273ktx_uint8_t* kvData; \274ktx_size_t dataSize; \275ktx_uint8_t* pData;276277278/**279* @class ktxTexture280* @~English281* @brief Base class representing a texture.282*283* ktxTextures should be created only by one of the provided284* functions and these fields should be considered read-only.285*/286typedef struct ktxTexture {287KTXTEXTURECLASSDEFN288} ktxTexture;289/**290* @typedef ktxTexture::classId291* @~English292* @brief Identify the class type.293*294* Since there are no public ktxTexture constructors, this can only have295* values of ktxTexture1_c or ktxTexture2_c.296*/297/**298* @typedef ktxTexture::vtbl299* @~English300* @brief Pointer to the class's vtble.301*/302/**303* @typedef ktxTexture::vvtbl304* @~English305* @brief Pointer to the class's vtble for Vulkan functions.306*307* A separate vtble is used so this header does not need to include vulkan.h.308*/309/**310* @typedef ktxTexture::_protected311* @~English312* @brief Opaque pointer to the class's protected variables.313*/314/**315* @typedef ktxTexture::isArray316* @~English317*318* KTX_TRUE if the texture is an array texture, i.e,319* a GL_TEXTURE_*_ARRAY target is to be used.320*/321/**322* @typedef ktxTexture::isCubemap323* @~English324*325* KTX_TRUE if the texture is a cubemap or cubemap array.326*/327/**328* @typedef ktxTexture::isCompressed329* @~English330*331* KTX_TRUE if the texture's format is a block compressed format.332*/333/**334* @typedef ktxTexture::generateMipmaps335* @~English336*337* KTX_TRUE if mipmaps should be generated for the texture by338* ktxTexture_GLUpload() or ktxTexture_VkUpload().339*/340/**341* @typedef ktxTexture::baseWidth342* @~English343* @brief Width of the texture's base level.344*/345/**346* @typedef ktxTexture::baseHeight347* @~English348* @brief Height of the texture's base level.349*/350/**351* @typedef ktxTexture::baseDepth352* @~English353* @brief Depth of the texture's base level.354*/355/**356* @typedef ktxTexture::numDimensions357* @~English358* @brief Number of dimensions in the texture: 1, 2 or 3.359*/360/**361* @typedef ktxTexture::numLevels362* @~English363* @brief Number of mip levels in the texture.364*365* Must be 1, if @c generateMipmaps is KTX_TRUE. Can be less than a366* full pyramid but always starts at the base level.367*/368/**369* @typedef ktxTexture::numLevels370* @~English371* @brief Number of array layers in the texture.372*/373/**374* @typedef ktxTexture::numFaces375* @~English376* @brief Number of faces: 6 for cube maps, 1 otherwise.377*/378/**379* @typedef ktxTexture::orientation380* @~English381* @brief Describes the logical orientation of the images in each dimension.382*383* ktxOrientationX for X, ktxOrientationY for Y and ktxOrientationZ for Z.384*/385/**386* @typedef ktxTexture::kvDataHead387* @~English388* @brief Head of the hash list of metadata.389*/390/**391* @typedef ktxTexture::kvDataLen392* @~English393* @brief Length of the metadata, if it has been extracted in its raw form,394* otherwise 0.395*/396/**397* @typedef ktxTexture::kvData398* @~English399* @brief Pointer to the metadata, if it has been extracted in its raw form,400* otherwise NULL.401*/402/**403* @typedef ktxTexture::dataSize404* @~English405* @brief Byte length of the texture's uncompressed image data.406*/407/**408* @typedef ktxTexture::pData409* @~English410* @brief Pointer to the start of the image data.411*/412413/**414* @memberof ktxTexture415* @~English416* @brief Signature of function called by the <tt>ktxTexture_Iterate*</tt>417* functions to receive image data.418*419* The function parameters are used to pass values which change for each image.420* Obtain values which are uniform across all images from the @c ktxTexture421* object.422*423* @param [in] miplevel MIP level from 0 to the max level which is424* dependent on the texture size.425* @param [in] face usually 0; for cube maps, one of the 6 cube426* faces in the order +X, -X, +Y, -Y, +Z, -Z,427* 0 to 5.428* @param [in] width width of the image.429* @param [in] height height of the image or, for 1D textures430* textures, 1.431* @param [in] depth depth of the image or, for 1D & 2D432* textures, 1.433* @param [in] faceLodSize number of bytes of data pointed at by434* @p pixels.435* @param [in] pixels pointer to the image data.436* @param [in,out] userdata pointer for the application to pass data to and437* from the callback function.438*/439440typedef KTX_error_code441(* PFNKTXITERCB)(int miplevel, int face,442int width, int height, int depth,443ktx_uint64_t faceLodSize,444void* pixels, void* userdata);445446/* Don't use KTX_APIENTRYP to avoid a Doxygen bug. */447typedef void (KTX_APIENTRY* PFNKTEXDESTROY)(ktxTexture* This);448typedef KTX_error_code449(KTX_APIENTRY* PFNKTEXGETIMAGEOFFSET)(ktxTexture* This, ktx_uint32_t level,450ktx_uint32_t layer,451ktx_uint32_t faceSlice,452ktx_size_t* pOffset);453typedef ktx_size_t454(KTX_APIENTRY* PFNKTEXGETDATASIZEUNCOMPRESSED)(ktxTexture* This);455typedef ktx_size_t456(KTX_APIENTRY* PFNKTEXGETIMAGESIZE)(ktxTexture* This, ktx_uint32_t level);457typedef ktx_size_t458(KTX_APIENTRY* PFNKTEXGETLEVELSIZE)(ktxTexture* This, ktx_uint32_t level);459typedef KTX_error_code460(KTX_APIENTRY* PFNKTEXITERATELEVELS)(ktxTexture* This, PFNKTXITERCB iterCb,461void* userdata);462463typedef KTX_error_code464(KTX_APIENTRY* PFNKTEXITERATELOADLEVELFACES)(ktxTexture* This,465PFNKTXITERCB iterCb,466void* userdata);467typedef KTX_error_code468(KTX_APIENTRY* PFNKTEXLOADIMAGEDATA)(ktxTexture* This,469ktx_uint8_t* pBuffer,470ktx_size_t bufSize);471typedef ktx_bool_t472(KTX_APIENTRY* PFNKTEXNEEDSTRANSCODING)(ktxTexture* This);473474typedef KTX_error_code475(KTX_APIENTRY* PFNKTEXSETIMAGEFROMMEMORY)(ktxTexture* This,476ktx_uint32_t level,477ktx_uint32_t layer,478ktx_uint32_t faceSlice,479const ktx_uint8_t* src,480ktx_size_t srcSize);481482typedef KTX_error_code483(KTX_APIENTRY* PFNKTEXSETIMAGEFROMSTDIOSTREAM)(ktxTexture* This,484ktx_uint32_t level,485ktx_uint32_t layer,486ktx_uint32_t faceSlice,487FILE* src, ktx_size_t srcSize);488typedef KTX_error_code489(KTX_APIENTRY* PFNKTEXWRITETOSTDIOSTREAM)(ktxTexture* This, FILE* dstsstr);490typedef KTX_error_code491(KTX_APIENTRY* PFNKTEXWRITETONAMEDFILE)(ktxTexture* This,492const char* const dstname);493typedef KTX_error_code494(KTX_APIENTRY* PFNKTEXWRITETOMEMORY)(ktxTexture* This,495ktx_uint8_t** bytes, ktx_size_t* size);496typedef KTX_error_code497(KTX_APIENTRY* PFNKTEXWRITETOSTREAM)(ktxTexture* This,498ktxStream* dststr);499500/**501* @memberof ktxTexture502* @~English503* @brief Table of virtual ktxTexture methods.504*/505struct ktxTexture_vtbl {506PFNKTEXDESTROY Destroy;507PFNKTEXGETIMAGEOFFSET GetImageOffset;508PFNKTEXGETDATASIZEUNCOMPRESSED GetDataSizeUncompressed;509PFNKTEXGETIMAGESIZE GetImageSize;510PFNKTEXGETLEVELSIZE GetLevelSize;511PFNKTEXITERATELEVELS IterateLevels;512PFNKTEXITERATELOADLEVELFACES IterateLoadLevelFaces;513PFNKTEXNEEDSTRANSCODING NeedsTranscoding;514PFNKTEXLOADIMAGEDATA LoadImageData;515PFNKTEXSETIMAGEFROMMEMORY SetImageFromMemory;516PFNKTEXSETIMAGEFROMSTDIOSTREAM SetImageFromStdioStream;517PFNKTEXWRITETOSTDIOSTREAM WriteToStdioStream;518PFNKTEXWRITETONAMEDFILE WriteToNamedFile;519PFNKTEXWRITETOMEMORY WriteToMemory;520PFNKTEXWRITETOSTREAM WriteToStream;521};522523/****************************************************************524* Macros to give some backward compatibility to the previous API525****************************************************************/526527/**528* @~English529* @brief Helper for calling the Destroy virtual method of a ktxTexture.530* @copydoc ktxTexture2.ktxTexture2_Destroy531*/532#define ktxTexture_Destroy(This) (This)->vtbl->Destroy(This)533534/**535* @~English536* @brief Helper for calling the GetImageOffset virtual method of a537* ktxTexture.538* @copydoc ktxTexture2.ktxTexture2_GetImageOffset539*/540#define ktxTexture_GetImageOffset(This, level, layer, faceSlice, pOffset) \541(This)->vtbl->GetImageOffset(This, level, layer, faceSlice, pOffset)542543/**544* @~English545* @brief Helper for calling the GetDataSizeUncompressed virtual method of a ktxTexture.546*547* For a ktxTexture1 this will always return the value of This->dataSize.548*549* @copydetails ktxTexture2.ktxTexture2_GetDataSizeUncompressed550*/551#define ktxTexture_GetDataSizeUncompressed(This) \552(This)->vtbl->GetDataSizeUncompressed(This)553554/**555* @~English556* @brief Helper for calling the GetImageSize virtual method of a ktxTexture.557* @copydoc ktxTexture2.ktxTexture2_GetImageSize558*/559#define ktxTexture_GetImageSize(This, level) \560(This)->vtbl->GetImageSize(This, level)561562/**563* @~English564* @brief Helper for calling the GetImageSize virtual method of a ktxTexture.565* @copydoc ktxTexture2.ktxTexture2_GetImageSize566*/567#define ktxTexture_GetLevelSize(This, level) \568(This)->vtbl->GetLevelSize(This, level)569570/**571* @~English572* @brief Helper for calling the IterateLevels virtual method of a ktxTexture.573* @copydoc ktxTexture2.ktxTexture2_IterateLevels574*/575#define ktxTexture_IterateLevels(This, iterCb, userdata) \576(This)->vtbl->IterateLevels(This, iterCb, userdata)577578/**579* @~English580* @brief Helper for calling the IterateLoadLevelFaces virtual method of a581* ktxTexture.582* @copydoc ktxTexture2.ktxTexture2_IterateLoadLevelFaces583*/584#define ktxTexture_IterateLoadLevelFaces(This, iterCb, userdata) \585(This)->vtbl->IterateLoadLevelFaces(This, iterCb, userdata)586587/**588* @~English589* @brief Helper for calling the LoadImageData virtual method of a ktxTexture.590* @copydoc ktxTexture2.ktxTexture2_LoadImageData591*/592#define ktxTexture_LoadImageData(This, pBuffer, bufSize) \593(This)->vtbl->LoadImageData(This, pBuffer, bufSize)594595/**596* @~English597* @brief Helper for calling the NeedsTranscoding virtual method of a ktxTexture.598* @copydoc ktxTexture2.ktxTexture2_NeedsTranscoding599*/600#define ktxTexture_NeedsTranscoding(This) (This)->vtbl->NeedsTranscoding(This)601602/**603* @~English604* @brief Helper for calling the SetImageFromMemory virtual method of a605* ktxTexture.606* @copydoc ktxTexture2.ktxTexture2_SetImageFromMemory607*/608#define ktxTexture_SetImageFromMemory(This, level, layer, faceSlice, \609src, srcSize) \610(This)->vtbl->SetImageFromMemory(This, level, layer, faceSlice, src, srcSize)611612/**613* @~English614* @brief Helper for calling the SetImageFromStdioStream virtual method of a615* ktxTexture.616* @copydoc ktxTexture2.ktxTexture2_SetImageFromStdioStream617*/618#define ktxTexture_SetImageFromStdioStream(This, level, layer, faceSlice, \619src, srcSize) \620(This)->vtbl->SetImageFromStdioStream(This, level, layer, faceSlice, \621src, srcSize)622623/**624* @~English625* @brief Helper for calling the WriteToStdioStream virtual method of a626* ktxTexture.627* @copydoc ktxTexture2.ktxTexture2_WriteToStdioStream628*/629#define ktxTexture_WriteToStdioStream(This, dstsstr) \630(This)->vtbl->WriteToStdioStream(This, dstsstr)631632/**633* @~English634* @brief Helper for calling the WriteToNamedfile virtual method of a635* ktxTexture.636* @copydoc ktxTexture2.ktxTexture2_WriteToNamedFile637*/638#define ktxTexture_WriteToNamedFile(This, dstname) \639(This)->vtbl->WriteToNamedFile(This, dstname)640641/**642* @~English643* @brief Helper for calling the WriteToMemory virtual method of a ktxTexture.644* @copydoc ktxTexture2.ktxTexture2_WriteToMemory645*/646#define ktxTexture_WriteToMemory(This, ppDstBytes, pSize) \647(This)->vtbl->WriteToMemory(This, ppDstBytes, pSize)648649/**650* @~English651* @brief Helper for calling the WriteToStream virtual method of a ktxTexture.652* @copydoc ktxTexture2.ktxTexture2_WriteToStream653*/654#define ktxTexture_WriteToStream(This, dststr) \655(This)->vtbl->WriteToStream(This, dststr)656657658/**659* @class ktxTexture1660* @~English661* @brief Class representing a KTX version 1 format texture.662*663* ktxTextures should be created only by one of the ktxTexture_Create*664* functions and these fields should be considered read-only.665*/666typedef struct ktxTexture1 {667KTXTEXTURECLASSDEFN668ktx_uint32_t glFormat; /*!< Format of the texture data, e.g., GL_RGB. */669ktx_uint32_t glInternalformat; /*!< Internal format of the texture data,670e.g., GL_RGB8. */671ktx_uint32_t glBaseInternalformat; /*!< Base format of the texture data,672e.g., GL_RGB. */673ktx_uint32_t glType; /*!< Type of the texture data, e.g, GL_UNSIGNED_BYTE.*/674struct ktxTexture1_private* _private; /*!< Private data. */675} ktxTexture1;676677/*===========================================================*678* KTX format version 2 *679*===========================================================*/680681/**682* @~English683* @brief Enumerators identifying the supercompression scheme.684*/685typedef enum ktxSupercmpScheme {686KTX_SS_NONE = 0, /*!< No supercompression. */687KTX_SS_BASIS_LZ = 1, /*!< Basis LZ supercompression. */688KTX_SS_ZSTD = 2, /*!< ZStd supercompression. */689KTX_SS_ZLIB = 3, /*!< ZLIB supercompression. */690KTX_SS_BEGIN_RANGE = KTX_SS_NONE,691KTX_SS_END_RANGE = KTX_SS_ZLIB,692KTX_SS_BEGIN_VENDOR_RANGE = 0x10000,693KTX_SS_END_VENDOR_RANGE = 0x1ffff,694KTX_SS_BEGIN_RESERVED = 0x20000695} ktxSupercmpScheme;696697/**698* @class ktxTexture2699* @~English700* @brief Class representing a KTX version 2 format texture.701*702* ktxTextures should be created only by one of the ktxTexture_Create*703* functions and these fields should be considered read-only.704*/705typedef struct ktxTexture2 {706KTXTEXTURECLASSDEFN707ktx_uint32_t vkFormat;708ktx_uint32_t* pDfd;709ktxSupercmpScheme supercompressionScheme;710ktx_bool_t isVideo;711ktx_uint32_t duration;712ktx_uint32_t timescale;713ktx_uint32_t loopcount;714struct ktxTexture2_private* _private; /*!< Private data. */715} ktxTexture2;716717/*718* If Doxygen sees this macro it gets confused and fails to spot719* references to ktxTexture_*() functions in the running text. It720* also complains it can't find the reference when @ref is used721* with a fully qualified method name to make an intra-class722* reference in the @c ktxTexture class.723* See https://github.com/doxygen/doxygen/issues/10311.724*725* Not documenting the macro is the lesser of two evils.726*/727#if !defined(KTX_DOXYGEN_SKIP)728/**729* @brief Helper for casting ktxTexture1 and ktxTexture2 to ktxTexture.730*731* Use with caution.732*/733#define ktxTexture(t) ((ktxTexture*)t)734#endif735736/**737* @memberof ktxTexture738* @~English739* @brief Structure for passing texture information to ktxTexture1\_Create() and740* ktxTexture2\_Create().741*742* @sa @ref ktxTexture1::ktxTexture1\_Create() "ktxTexture1_Create()"743* @sa @ref ktxTexture2::ktxTexture2\_Create() "ktxTexture2_Create()"744*/745typedef struct746{747ktx_uint32_t glInternalformat; /*!< Internal format for the texture, e.g.,748GL_RGB8. Ignored when creating a749ktxTexture2. */750ktx_uint32_t vkFormat; /*!< VkFormat for texture. Ignored when creating a751ktxTexture1. */752ktx_uint32_t* pDfd; /*!< Pointer to DFD. Used only when creating a753ktxTexture2 and only if vkFormat is754VK_FORMAT_UNDEFINED. */755ktx_uint32_t baseWidth; /*!< Width of the base level of the texture. */756ktx_uint32_t baseHeight; /*!< Height of the base level of the texture. */757ktx_uint32_t baseDepth; /*!< Depth of the base level of the texture. */758ktx_uint32_t numDimensions; /*!< Number of dimensions in the texture, 1, 2759or 3. */760ktx_uint32_t numLevels; /*!< Number of mip levels in the texture. Should be7611 if @c generateMipmaps is KTX_TRUE; */762ktx_uint32_t numLayers; /*!< Number of array layers in the texture. */763ktx_uint32_t numFaces; /*!< Number of faces: 6 for cube maps, 1 otherwise. */764ktx_bool_t isArray; /*!< Set to KTX_TRUE if the texture is to be an765array texture. Means OpenGL will use a766GL_TEXTURE_*_ARRAY target. */767ktx_bool_t generateMipmaps; /*!< Set to KTX_TRUE if mipmaps should be768generated for the texture when loading769into a 3D API. */770} ktxTextureCreateInfo;771772/**773* @memberof ktxTexture774* @~English775* @brief Enum for requesting, or not, allocation of storage for images.776*777* @sa ktxTexture1_Create() and ktxTexture2_Create().778*/779typedef enum {780KTX_TEXTURE_CREATE_NO_STORAGE = 0, /*!< Don't allocate any image storage. */781KTX_TEXTURE_CREATE_ALLOC_STORAGE = 1 /*!< Allocate image storage. */782} ktxTextureCreateStorageEnum;783784/**785* @memberof ktxTexture786* @~English787* @brief Flags for requesting services during creation.788*789* @sa ktxTexture_CreateFrom*790*/791enum ktxTextureCreateFlagBits {792KTX_TEXTURE_CREATE_NO_FLAGS = 0x00,793KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT = 0x01,794/*!< Load the images from the KTX source. */795KTX_TEXTURE_CREATE_RAW_KVDATA_BIT = 0x02,796/*!< Load the raw key-value data instead of797creating a @c ktxHashList from it. */798KTX_TEXTURE_CREATE_SKIP_KVDATA_BIT = 0x04,799/*!< Skip any key-value data. This overrides800the RAW_KVDATA_BIT. */801KTX_TEXTURE_CREATE_CHECK_GLTF_BASISU_BIT = 0x08802/*!< Load texture compatible with the rules803of KHR_texture_basisu glTF extension */804};805/**806* @memberof ktxTexture807* @~English808* @brief Type for TextureCreateFlags parameters.809*810* @sa ktxTexture_CreateFrom*()811*/812typedef ktx_uint32_t ktxTextureCreateFlags;813814/*===========================================================*815* ktxStream816*===========================================================*/817818/*819* This is unsigned to allow ktxmemstreams to use the820* full amount of memory available. Platforms will821* limit the size of ktxfilestreams to, e.g, MAX_LONG822* on 32-bit and ktxfilestreams raises errors if823* offset values exceed the limits. This choice may824* need to be revisited if we ever start needing -ve825* offsets.826*827* Should the 2GB file size handling limit on 32-bit828* platforms become a problem, ktxfilestream will have829* to be changed to explicitly handle large files by830* using the 64-bit stream functions.831*/832#if defined(_MSC_VER) && defined(_WIN64)833typedef unsigned __int64 ktx_off_t;834#else835typedef off_t ktx_off_t;836#endif837typedef struct ktxMem ktxMem;838typedef struct ktxStream ktxStream;839840enum streamType { eStreamTypeFile = 1, eStreamTypeMemory = 2, eStreamTypeCustom = 3 };841842/**843* @~English844* @brief type for a pointer to a stream reading function845*/846typedef KTX_error_code (*ktxStream_read)(ktxStream* str, void* dst,847const ktx_size_t count);848/**849* @~English850* @brief type for a pointer to a stream skipping function851*/852typedef KTX_error_code (*ktxStream_skip)(ktxStream* str,853const ktx_size_t count);854855/**856* @~English857* @brief type for a pointer to a stream writing function858*/859typedef KTX_error_code (*ktxStream_write)(ktxStream* str, const void *src,860const ktx_size_t size,861const ktx_size_t count);862863/**864* @~English865* @brief type for a pointer to a stream position query function866*/867typedef KTX_error_code (*ktxStream_getpos)(ktxStream* str, ktx_off_t* const offset);868869/**870* @~English871* @brief type for a pointer to a stream position query function872*/873typedef KTX_error_code (*ktxStream_setpos)(ktxStream* str, const ktx_off_t offset);874875/**876* @~English877* @brief type for a pointer to a stream size query function878*/879typedef KTX_error_code (*ktxStream_getsize)(ktxStream* str, ktx_size_t* const size);880881/**882* @~English883* @brief Destruct a stream884*/885typedef void (*ktxStream_destruct)(ktxStream* str);886887/**888* @~English889*890* @brief Interface of ktxStream.891*892* @author Maksim Kolesin893* @author Georg Kolling, Imagination Technology894* @author Mark Callow, HI Corporation895*/896struct ktxStream897{898ktxStream_read read; /*!< pointer to function for reading bytes. */899ktxStream_skip skip; /*!< pointer to function for skipping bytes. */900ktxStream_write write; /*!< pointer to function for writing bytes. */901ktxStream_getpos getpos; /*!< pointer to function for getting current position in stream. */902ktxStream_setpos setpos; /*!< pointer to function for setting current position in stream. */903ktxStream_getsize getsize; /*!< pointer to function for querying size. */904ktxStream_destruct destruct; /*!< destruct the stream. */905906enum streamType type;907union {908FILE* file; /**< a stdio FILE pointer for a ktxFileStream. */909ktxMem* mem; /**< a pointer to a ktxMem struct for a ktxMemStream. */910struct911{912void* address; /**< pointer to the data. */913void* allocatorAddress; /**< pointer to a memory allocator. */914ktx_size_t size; /**< size of the data. */915} custom_ptr; /**< pointer to a struct for custom streams. */916} data; /**< pointer to the stream data. */917ktx_off_t readpos; /**< used by FileStream for stdin. */918ktx_bool_t closeOnDestruct; /**< Close FILE* or dispose of memory on destruct. */919};920921/*922* See the implementation files for the full documentation of the following923* functions.924*/925926/**927* @~English928* @brief typedef of function pointer returned by GLGetProcAddress functions.929*/930typedef void (KTX_APIENTRY* PFNVOIDFUNCTION)(void);931/**932* @~English933* @brief typedef of pointer to function for retrieving OpenGL function pointers.934*/935typedef PFNVOIDFUNCTION (KTX_APIENTRY* PFNGLGETPROCADDRESS) (const char *proc);936/*937* Load pointers for the OpenGL functions needed by ktxTexture_GLUpload.938*/939KTX_API KTX_error_code KTX_APIENTRY940ktxLoadOpenGL(PFNGLGETPROCADDRESS pfnGLGetProcAddress);941942/*943* These four create a ktxTexture1 or ktxTexture2 according to the data944* header, and return a pointer to the base ktxTexture class.945*/946KTX_API KTX_error_code KTX_APIENTRY947ktxTexture_CreateFromStdioStream(FILE* stdioStream,948ktxTextureCreateFlags createFlags,949ktxTexture** newTex);950951KTX_API KTX_error_code KTX_APIENTRY952ktxTexture_CreateFromNamedFile(const char* const filename,953ktxTextureCreateFlags createFlags,954ktxTexture** newTex);955956KTX_API KTX_error_code KTX_APIENTRY957ktxTexture_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size,958ktxTextureCreateFlags createFlags,959ktxTexture** newTex);960961KTX_API KTX_error_code KTX_APIENTRY962ktxTexture_CreateFromStream(ktxStream* stream,963ktxTextureCreateFlags createFlags,964ktxTexture** newTex);965966/*967* Returns a pointer to the image data of a ktxTexture object.968*/969KTX_API ktx_uint8_t* KTX_APIENTRY970ktxTexture_GetData(ktxTexture* This);971972/*973* Returns the pitch of a row of an image at the specified level.974* Similar to the rowPitch in a VkSubResourceLayout.975*/976KTX_API ktx_uint32_t KTX_APIENTRY977ktxTexture_GetRowPitch(ktxTexture* This, ktx_uint32_t level);978979/*980* Return the element size of the texture's images.981*/982KTX_API ktx_uint32_t KTX_APIENTRY983ktxTexture_GetElementSize(ktxTexture* This);984985/*986* Returns the size of all the image data of a ktxTexture object in bytes.987*/988KTX_API ktx_size_t KTX_APIENTRY989ktxTexture_GetDataSize(ktxTexture* This);990991/* Uploads a texture to OpenGL {,ES}. */992KTX_API KTX_error_code KTX_APIENTRY993ktxTexture_GLUpload(ktxTexture* This, GLuint* pTexture, GLenum* pTarget,994GLenum* pGlerror);995996/*997* Iterate over the levels or faces in a ktxTexture object.998*/999KTX_API KTX_error_code KTX_APIENTRY1000ktxTexture_IterateLevelFaces(ktxTexture* This, PFNKTXITERCB iterCb,1001void* userdata);1002/*1003* Create a new ktxTexture1.1004*/1005KTX_API KTX_error_code KTX_APIENTRY1006ktxTexture1_Create(const ktxTextureCreateInfo* const createInfo,1007ktxTextureCreateStorageEnum storageAllocation,1008ktxTexture1** newTex);10091010/*1011* These four create a ktxTexture1 provided the data is in KTX format.1012*/1013KTX_API KTX_error_code KTX_APIENTRY1014ktxTexture1_CreateFromStdioStream(FILE* stdioStream,1015ktxTextureCreateFlags createFlags,1016ktxTexture1** newTex);10171018KTX_API KTX_error_code KTX_APIENTRY1019ktxTexture1_CreateFromNamedFile(const char* const filename,1020ktxTextureCreateFlags createFlags,1021ktxTexture1** newTex);10221023KTX_API KTX_error_code KTX_APIENTRY1024ktxTexture1_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size,1025ktxTextureCreateFlags createFlags,1026ktxTexture1** newTex);10271028KTX_API KTX_error_code KTX_APIENTRY1029ktxTexture1_CreateFromStream(ktxStream* stream,1030ktxTextureCreateFlags createFlags,1031ktxTexture1** newTex);1032KTX_API void KTX_APIENTRY1033ktxTexture1_Destroy(ktxTexture1* This);10341035KTX_API ktx_bool_t KTX_APIENTRY1036ktxTexture1_NeedsTranscoding(ktxTexture1* This);10371038KTX_API ktx_error_code_e KTX_APIENTRY1039ktxTexture1_LoadImageData(ktxTexture1* This, ktx_uint8_t* pBuffer, ktx_size_t bufSize);10401041/*1042* These four write a ktxTexture1 object to a KTX v1 file.1043*/1044KTX_API KTX_error_code KTX_APIENTRY1045ktxTexture1_WriteToStdioStream(ktxTexture1* This, FILE* dstsstr);10461047KTX_API KTX_error_code KTX_APIENTRY1048ktxTexture1_WriteToNamedFile(ktxTexture1* This, const char* const dstname);10491050KTX_API KTX_error_code KTX_APIENTRY1051ktxTexture1_WriteToMemory(ktxTexture1* This,1052ktx_uint8_t** bytes, ktx_size_t* size);10531054KTX_API KTX_error_code KTX_APIENTRY1055ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream *dststr);10561057/*1058* These four write a ktxTexture1 object to a KTX v2 file.1059*/1060KTX_API KTX_error_code KTX_APIENTRY1061ktxTexture1_WriteKTX2ToStdioStream(ktxTexture1* This, FILE* dstsstr);10621063KTX_API KTX_error_code KTX_APIENTRY1064ktxTexture1_WriteKTX2ToNamedFile(ktxTexture1* This, const char* const dstname);10651066KTX_API KTX_error_code KTX_APIENTRY1067ktxTexture1_WriteKTX2ToMemory(ktxTexture1* This,1068ktx_uint8_t** bytes, ktx_size_t* size);10691070KTX_API KTX_error_code KTX_APIENTRY1071ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream *dststr);10721073/*1074* Create a new ktxTexture2.1075*/1076KTX_API KTX_error_code KTX_APIENTRY1077ktxTexture2_Create(const ktxTextureCreateInfo* const createInfo,1078ktxTextureCreateStorageEnum storageAllocation,1079ktxTexture2** newTex);10801081/*1082* Create a new ktxTexture2 as a copy of an existing texture.1083*/1084KTX_API KTX_error_code KTX_APIENTRY1085ktxTexture2_CreateCopy(ktxTexture2* orig, ktxTexture2** newTex);10861087/*1088* These four create a ktxTexture2 provided the data is in KTX2 format.1089*/1090KTX_API KTX_error_code KTX_APIENTRY1091ktxTexture2_CreateFromStdioStream(FILE* stdioStream,1092ktxTextureCreateFlags createFlags,1093ktxTexture2** newTex);10941095KTX_API KTX_error_code KTX_APIENTRY1096ktxTexture2_CreateFromNamedFile(const char* const filename,1097ktxTextureCreateFlags createFlags,1098ktxTexture2** newTex);10991100KTX_API KTX_error_code KTX_APIENTRY1101ktxTexture2_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size,1102ktxTextureCreateFlags createFlags,1103ktxTexture2** newTex);11041105KTX_API KTX_error_code KTX_APIENTRY1106ktxTexture2_CreateFromStream(ktxStream* stream,1107ktxTextureCreateFlags createFlags,1108ktxTexture2** newTex);11091110KTX_API void KTX_APIENTRY1111ktxTexture2_Destroy(ktxTexture2* This);11121113KTX_API KTX_error_code KTX_APIENTRY1114ktxTexture2_CompressBasis(ktxTexture2* This, ktx_uint32_t quality);11151116KTX_API KTX_error_code KTX_APIENTRY1117ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t level);11181119KTX_API KTX_error_code KTX_APIENTRY1120ktxTexture2_DeflateZLIB(ktxTexture2* This, ktx_uint32_t level);11211122KTX_API void KTX_APIENTRY1123ktxTexture2_GetComponentInfo(ktxTexture2* This, ktx_uint32_t* numComponents,1124ktx_uint32_t* componentByteLength);11251126KTX_API KTX_error_code KTX_APIENTRY1127ktxTexture2_GetImageOffset(ktxTexture2* This, ktx_uint32_t level,1128ktx_uint32_t layer, ktx_uint32_t faceSlice,1129ktx_size_t* pOffset);11301131KTX_API ktx_uint32_t KTX_APIENTRY1132ktxTexture2_GetNumComponents(ktxTexture2* This);11331134KTX_API khr_df_transfer_e KTX_APIENTRY1135ktxTexture2_GetTransferFunction_e(ktxTexture2* This);1136/* For backward compatibility. */1137KTX_API khr_df_transfer_e KTX_APIENTRY1138ktxTexture2_GetOETF_e(ktxTexture2* This);1139KTX_API ktx_uint32_t KTX_APIENTRY1140ktxTexture2_GetOETF(ktxTexture2* This);11411142KTX_API khr_df_model_e KTX_APIENTRY1143ktxTexture2_GetColorModel_e(ktxTexture2* This);11441145KTX_API ktx_bool_t KTX_APIENTRY1146ktxTexture2_GetPremultipliedAlpha(ktxTexture2* This);11471148KTX_API khr_df_primaries_e KTX_APIENTRY1149ktxTexture2_GetPrimaries_e(ktxTexture2* This);11501151KTX_API ktx_bool_t KTX_APIENTRY1152ktxTexture2_NeedsTranscoding(ktxTexture2* This);11531154KTX_API ktx_error_code_e KTX_APIENTRY1155ktxTexture2_SetTransferFunction(ktxTexture2* This, khr_df_transfer_e tf);1156/* For backward compatibility. */1157KTX_API ktx_error_code_e KTX_APIENTRY1158ktxTexture2_SetOETF(ktxTexture2* This, khr_df_transfer_e oetf);11591160KTX_API ktx_error_code_e KTX_APIENTRY1161ktxTexture2_SetPrimaries(ktxTexture2* This, khr_df_primaries_e primaries);11621163KTX_API ktx_error_code_e KTX_APIENTRY1164ktxTexture2_LoadImageData(ktxTexture2* This, ktx_uint8_t* pBuffer, ktx_size_t bufSize);1165/*1166* For rare testing scenarios. Use ktxTexture2_LoadImageData.1167*/1168KTX_API ktx_error_code_e KTX_APIENTRY1169ktxTexture2_LoadDeflatedImageData(ktxTexture2* This,1170ktx_uint8_t* pBuffer, ktx_size_t bufSize);11711172/*1173* These four write a ktxTexture2 object to a KTX v2 file.1174*/1175KTX_API KTX_error_code KTX_APIENTRY1176ktxTexture2_WriteToStdioStream(ktxTexture2* This, FILE* dstsstr);11771178KTX_API KTX_error_code KTX_APIENTRY1179ktxTexture2_WriteToNamedFile(ktxTexture2* This, const char* const dstname);11801181KTX_API KTX_error_code KTX_APIENTRY1182ktxTexture2_WriteToMemory(ktxTexture2* This,1183ktx_uint8_t** bytes, ktx_size_t* size);11841185KTX_API KTX_error_code KTX_APIENTRY1186ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream *dststr);11871188/**1189* @~English1190* @brief Flags specifiying UASTC encoding options.1191*/1192typedef enum ktx_pack_uastc_flag_bits_e {1193KTX_PACK_UASTC_LEVEL_FASTEST = 0,1194/*!< Fastest compression. 43.45dB. */1195KTX_PACK_UASTC_LEVEL_FASTER = 1,1196/*!< Faster compression. 46.49dB. */1197KTX_PACK_UASTC_LEVEL_DEFAULT = 2,1198/*!< Default compression. 47.47dB. */1199KTX_PACK_UASTC_LEVEL_SLOWER = 3,1200/*!< Slower compression. 48.01dB. */1201KTX_PACK_UASTC_LEVEL_VERYSLOW = 4,1202/*!< Very slow compression. 48.24dB. */1203KTX_PACK_UASTC_MAX_LEVEL = KTX_PACK_UASTC_LEVEL_VERYSLOW,1204/*!< Maximum supported quality level. */1205KTX_PACK_UASTC_LEVEL_MASK = 0xF,1206/*!< Mask to extract the level from the other bits. */1207KTX_PACK_UASTC_FAVOR_UASTC_ERROR = 8,1208/*!< Optimize for lowest UASTC error. */1209KTX_PACK_UASTC_FAVOR_BC7_ERROR = 16,1210/*!< Optimize for lowest BC7 error. */1211KTX_PACK_UASTC_ETC1_FASTER_HINTS = 64,1212/*!< Optimize for faster transcoding to ETC1. */1213KTX_PACK_UASTC_ETC1_FASTEST_HINTS = 128,1214/*!< Optimize for fastest transcoding to ETC1. */1215KTX_PACK_UASTC__ETC1_DISABLE_FLIP_AND_INDIVIDUAL = 2561216/*!< Not documented in BasisU code. */1217} ktx_pack_uastc_flag_bits_e;1218typedef ktx_uint32_t ktx_pack_uastc_flags;12191220/**1221* @~English1222* @brief Options specifiying ASTC encoding quality levels.1223*/1224typedef enum ktx_pack_astc_quality_levels_e {1225KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST = 0,1226/*!< Fastest compression. */1227KTX_PACK_ASTC_QUALITY_LEVEL_FAST = 10,1228/*!< Fast compression. */1229KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM = 60,1230/*!< Medium compression. */1231KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH = 98,1232/*!< Slower compression. */1233KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE = 100,1234/*!< Very slow compression. */1235KTX_PACK_ASTC_QUALITY_LEVEL_MAX = KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE,1236/*!< Maximum supported quality level. */1237} ktx_pack_astc_quality_levels_e;12381239/**1240* @~English1241* @brief Options specifiying ASTC encoding block dimensions1242*/1243typedef enum ktx_pack_astc_block_dimension_e {1244// 2D formats1245KTX_PACK_ASTC_BLOCK_DIMENSION_4x4, //: 8.00 bpp1246KTX_PACK_ASTC_BLOCK_DIMENSION_5x4, //: 6.40 bpp1247KTX_PACK_ASTC_BLOCK_DIMENSION_5x5, //: 5.12 bpp1248KTX_PACK_ASTC_BLOCK_DIMENSION_6x5, //: 4.27 bpp1249KTX_PACK_ASTC_BLOCK_DIMENSION_6x6, //: 3.56 bpp1250KTX_PACK_ASTC_BLOCK_DIMENSION_8x5, //: 3.20 bpp1251KTX_PACK_ASTC_BLOCK_DIMENSION_8x6, //: 2.67 bpp1252KTX_PACK_ASTC_BLOCK_DIMENSION_10x5, //: 2.56 bpp1253KTX_PACK_ASTC_BLOCK_DIMENSION_10x6, //: 2.13 bpp1254KTX_PACK_ASTC_BLOCK_DIMENSION_8x8, //: 2.00 bpp1255KTX_PACK_ASTC_BLOCK_DIMENSION_10x8, //: 1.60 bpp1256KTX_PACK_ASTC_BLOCK_DIMENSION_10x10, //: 1.28 bpp1257KTX_PACK_ASTC_BLOCK_DIMENSION_12x10, //: 1.07 bpp1258KTX_PACK_ASTC_BLOCK_DIMENSION_12x12, //: 0.89 bpp1259// 3D formats1260KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3, //: 4.74 bpp1261KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3, //: 3.56 bpp1262KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3, //: 2.67 bpp1263KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4, //: 2.00 bpp1264KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4, //: 1.60 bpp1265KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4, //: 1.28 bpp1266KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5, //: 1.02 bpp1267KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5, //: 0.85 bpp1268KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5, //: 0.71 bpp1269KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6, //: 0.59 bpp1270KTX_PACK_ASTC_BLOCK_DIMENSION_MAX = KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x61271/*!< Maximum supported blocks. */1272} ktx_pack_astc_block_dimension_e;12731274/**1275* @~English1276* @brief Options specifying ASTC encoder mode.1277*/1278typedef enum ktx_pack_astc_encoder_mode_e {1279KTX_PACK_ASTC_ENCODER_MODE_DEFAULT,1280/*!< Selects LDR mode if component size is <= 8-bit, HDR otherwise. */1281KTX_PACK_ASTC_ENCODER_MODE_LDR,1282/*!< Always encode in low dynamic range mode. */1283KTX_PACK_ASTC_ENCODER_MODE_HDR,1284/*!< Always encode in high dynamic range mode. */1285KTX_PACK_ASTC_ENCODER_MODE_MAX = KTX_PACK_ASTC_ENCODER_MODE_HDR1286/*!< Indicates the maximum permissible value. */1287} ktx_pack_astc_encoder_mode_e;12881289extern KTX_API const ktx_uint32_t KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL;12901291/**1292* @memberof ktxTexture1293* @~English1294* @brief Structure for passing extended parameters to1295* ktxTexture_CompressAstc.1296*1297* Passing a struct initialized to 0 (e.g. " = {0};") will use blockDimension1298* 4x4, mode LDR and qualityLevel FASTEST. Setting qualityLevel to1299* KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM is recommended.1300*/1301typedef struct ktxAstcParams {1302ktx_uint32_t structSize;1303/*!< Size of this struct. Used so library can tell which version1304of struct is being passed.1305*/13061307ktx_bool_t verbose;1308/*!< If true, prints Astc encoder operation details to1309@c stdout. Not recommended for GUI apps.1310*/13111312ktx_uint32_t threadCount;1313/*!< Number of threads used for compression. Default is 1.1314*/13151316/* astcenc params */1317ktx_uint32_t blockDimension;1318/*!< Combinations of block dimensions that astcenc supports1319i.e. 6x6, 8x8, 6x5 etc1320*/13211322ktx_uint32_t mode;1323/*!< Can be {ldr/hdr} from astcenc1324*/13251326ktx_uint32_t qualityLevel;1327/*!< astcenc supports -fastest, -fast, -medium, -thorough, -exhaustive1328*/13291330ktx_bool_t normalMap;1331/*!< Tunes codec parameters for better quality on normal maps1332In this mode normals are compressed to X,Y components1333Discarding Z component, reader will need to generate Z1334component in shaders.1335*/13361337ktx_bool_t perceptual;1338/*!< The codec should optimize for perceptual error, instead of direct1339RMS error. This aims to improves perceived image quality, but1340typically lowers the measured PSNR score. Perceptual methods are1341currently only available for normal maps and RGB color data.1342*/13431344char inputSwizzle[4];1345/*!< A swizzle to provide as input to astcenc. It must match the regular1346expression /^[rgba01]{4}$/.1347*/1348} ktxAstcParams;13491350KTX_API KTX_error_code KTX_APIENTRY1351ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params);13521353KTX_API KTX_error_code KTX_APIENTRY1354ktxTexture2_CompressAstc(ktxTexture2* This, ktx_uint32_t quality);13551356KTX_API KTX_error_code KTX_APIENTRY1357ktxTexture2_DecodeAstc(ktxTexture2* This);13581359/**1360* @memberof ktxTexture21361* @~English1362* @brief Structure for passing extended parameters to1363* ktxTexture2_CompressBasisEx().1364*1365* If you only want default values, use ktxTexture2_CompressBasis(). Here, at1366* a minimum you must initialize the structure as follows:1367* @code1368* ktxBasisParams params = {0};1369* params.structSize = sizeof(params);1370* params.compressionLevel = KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL;1371* @endcode1372*1373* @e compressionLevel has to be explicitly set because 0 is a valid1374* @e compressionLevel but is not the default used by the BasisU encoder1375* when no value is set. Only the other settings that are to be non-default1376* must be non-zero.1377*/1378typedef struct ktxBasisParams {1379ktx_uint32_t structSize;1380/*!< Size of this struct. Used so library can tell which version1381of struct is being passed.1382*/1383ktx_bool_t uastc;1384/*!< True to use UASTC base, false to use ETC1S base. */1385ktx_bool_t verbose;1386/*!< If true, prints Basis Universal encoder operation details to1387@c stdout. Not recommended for GUI apps.1388*/1389ktx_bool_t noSSE;1390/*!< True to forbid use of the SSE instruction set. Ignored if CPU1391does not support SSE. */1392ktx_uint32_t threadCount;1393/*!< Number of threads used for compression. Default is 1. */13941395/* ETC1S params */13961397ktx_uint32_t compressionLevel;1398/*!< Encoding speed vs. quality tradeoff. Range is [0,6]. Higher values1399are much slower, but give slightly higher quality. Higher levels1400are intended for video. There is no default. Callers must1401explicitly set this value. Callers can use1402KTX\_ETC1S\_DEFAULT\_COMPRESSION\_LEVEL as a default value.1403Currently this is 2.1404*/1405ktx_uint32_t qualityLevel;1406/*!< Compression quality. Range is [1,255]. Lower gives better1407compression/lower quality/faster. Higher gives less compression1408/higher quality/slower. This automatically determines values for1409@c maxEndpoints, @c maxSelectors,1410@c endpointRDOThreshold and @c selectorRDOThreshold1411for the target quality level. Setting these parameters overrides1412the values determined by @c qualityLevel which defaults to1413128 if neither it nor both of @c maxEndpoints and1414@c maxSelectors have been set.1415@note @e Both of @c maxEndpoints and @c maxSelectors1416must be set for them to have any effect.1417@note qualityLevel will only determine values for1418@c endpointRDOThreshold and @c selectorRDOThreshold1419when its value exceeds 128, otherwise their defaults will be used.1420*/1421ktx_uint32_t maxEndpoints;1422/*!< Manually set the max number of color endpoint clusters.1423Range is [1,16128]. Default is 0, unset. If this is set, maxSelectors1424must also be set, otherwise the value will be ignored.1425*/1426float endpointRDOThreshold;1427/*!< Set endpoint RDO quality threshold. The default is 1.25. Lower is1428higher quality but less quality per output bit (try [1.0,3.0].1429This will override the value chosen by @c qualityLevel.1430*/1431ktx_uint32_t maxSelectors;1432/*!< Manually set the max number of color selector clusters. Range1433is [1,16128]. Default is 0, unset. If this is set, maxEndpoints1434must also be set, otherwise the value will be ignored.1435*/1436float selectorRDOThreshold;1437/*!< Set selector RDO quality threshold. The default is 1.5. Lower is1438higher quality but less quality per output bit (try [1.0,3.0]).1439This will override the value chosen by @c qualityLevel.1440*/1441char inputSwizzle[4];1442/*!< A swizzle to apply before encoding. It must match the regular1443expression /^[rgba01]{4}$/. If both this and preSwizzle1444are specified ktxTexture_CompressBasisEx will raise1445KTX_INVALID_OPERATION. Usable with both ETC1S and UASTC.1446*/1447ktx_bool_t normalMap;1448/*!< Tunes codec parameters for better quality on normal maps (no1449selector RDO, no endpoint RDO) and sets the texture's DFD appropriately.1450Only valid for linear textures.1451*/1452ktx_bool_t separateRGToRGB_A;1453/*!< @deprecated This was and is a no-op. 2-component inputs have1454always been automatically separated using an "rrrg" inputSwizzle.1455@sa inputSwizzle and normalMode.1456*/1457ktx_bool_t preSwizzle;1458/*!< If the texture has @c KTXswizzle metadata, apply it before1459compressing. Swizzling, like @c rabb may yield drastically1460different error metrics if done after supercompression. Usable1461for both ETC1S and UASTC.1462*/1463ktx_bool_t noEndpointRDO;1464/*!< Disable endpoint rate distortion optimizations. Slightly faster,1465less noisy output, but lower quality per output bit. Default is1466KTX_FALSE.1467*/1468ktx_bool_t noSelectorRDO;1469/*!< Disable selector rate distortion optimizations. Slightly faster,1470less noisy output, but lower quality per output bit. Default is1471KTX_FALSE.1472*/14731474/* UASTC params */14751476ktx_pack_uastc_flags uastcFlags;1477/*!< A set of ::ktx_pack_uastc_flag_bits_e controlling UASTC1478encoding. The most important value is the level given in the1479least-significant 4 bits which selects a speed vs quality tradeoff1480as shown in the following table:14811482Level/Speed | Quality1483:-----: | :-------:1484KTX_PACK_UASTC_LEVEL_FASTEST | 43.45dB1485KTX_PACK_UASTC_LEVEL_FASTER | 46.49dB1486KTX_PACK_UASTC_LEVEL_DEFAULT | 47.47dB1487KTX_PACK_UASTC_LEVEL_SLOWER | 48.01dB1488KTX_PACK_UASTC_LEVEL_VERYSLOW | 48.24dB1489*/1490ktx_bool_t uastcRDO;1491/*!< Enable Rate Distortion Optimization (RDO) post-processing.1492*/1493float uastcRDOQualityScalar;1494/*!< UASTC RDO quality scalar (lambda). Lower values yield higher1495quality/larger LZ compressed files, higher values yield lower1496quality/smaller LZ compressed files. A good range to try is [.2,4].1497Full range is [.001,50.0]. Default is 1.0.1498*/1499ktx_uint32_t uastcRDODictSize;1500/*!< UASTC RDO dictionary size in bytes. Default is 4096. Lower1501values=faster, but give less compression. Range is [64,65536].1502*/1503float uastcRDOMaxSmoothBlockErrorScale;1504/*!< UASTC RDO max smooth block error scale. Range is [1,300].1505Default is 10.0, 1.0 is disabled. Larger values suppress more1506artifacts (and allocate more bits) on smooth blocks.1507*/1508float uastcRDOMaxSmoothBlockStdDev;1509/*!< UASTC RDO max smooth block standard deviation. Range is1510[.01,65536.0]. Default is 18.0. Larger values expand the range of1511blocks considered smooth.1512*/1513ktx_bool_t uastcRDODontFavorSimplerModes;1514/*!< Do not favor simpler UASTC modes in RDO mode.1515*/1516ktx_bool_t uastcRDONoMultithreading;1517/*!< Disable RDO multithreading (slightly higher compression,1518deterministic).1519*/15201521} ktxBasisParams;15221523KTX_API KTX_error_code KTX_APIENTRY1524ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params);15251526/**1527* @~English1528* @brief Enumerators for specifying the transcode target format.1529*1530* For BasisU/ETC1S format, @e Opaque and @e alpha here refer to 2 separate1531* RGB images, a.k.a slices within the BasisU compressed data. For UASTC1532* format they refer to the RGB and the alpha components of the UASTC data. If1533* the original image had only 2 components, R will be in the opaque portion1534* and G in the alpha portion. The R value will be replicated in the RGB1535* components. In the case of BasisU the G value will be replicated in all 31536* components of the alpha slice. If the original image had only 1 component1537* it's value is replicated in all 3 components of the opaque portion and1538* there is no alpha.1539*1540* @note You should not transcode sRGB encoded data to @c KTX_TTF_BC4_R,1541* @c KTX_TTF_BC5_RG, @c KTX_TTF_ETC2_EAC_R{,G}11, @c KTX_TTF_RGB565,1542* @c KTX_TTF_BGR565 or @c KTX_TTF_RGBA4444 formats as neither OpenGL nor1543* Vulkan support sRGB variants of these. Doing sRGB decoding in the shader1544* will not produce correct results if any texture filtering is being used.1545*/1546typedef enum ktx_transcode_fmt_e {1547// Compressed formats15481549// ETC1-21550KTX_TTF_ETC1_RGB = 0,1551/*!< Opaque only. Returns RGB or alpha data, if1552KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1553specified. */1554KTX_TTF_ETC2_RGBA = 1,1555/*!< Opaque+alpha. EAC_A8 block followed by an ETC1 block. The1556alpha channel will be opaque for textures without an alpha1557channel. */15581559// BC1-5, BC7 (desktop, some mobile devices)1560KTX_TTF_BC1_RGB = 2,1561/*!< Opaque only, no punchthrough alpha support yet. Returns RGB1562or alpha data, if KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS1563flag is specified. */1564KTX_TTF_BC3_RGBA = 3,1565/*!< Opaque+alpha. BC4 block with alpha followed by a BC1 block. The1566alpha channel will be opaque for textures without an alpha1567channel. */1568KTX_TTF_BC4_R = 4,1569/*!< One BC4 block. R = opaque.g or alpha.g, if1570KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1571specified. */1572KTX_TTF_BC5_RG = 5,1573/*!< Two BC4 blocks, R=opaque.g and G=alpha.g The texture should1574have an alpha channel (if not G will be all 255's. For tangent1575space normal maps. */1576KTX_TTF_BC7_RGBA = 6,1577/*!< RGB or RGBA mode 5 for ETC1S, modes 1, 2, 3, 4, 5, 6, 7 for1578UASTC. */15791580// PVRTC1 4bpp (mobile, PowerVR devices)1581KTX_TTF_PVRTC1_4_RGB = 8,1582/*!< Opaque only. Returns RGB or alpha data, if1583KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1584specified. */1585KTX_TTF_PVRTC1_4_RGBA = 9,1586/*!< Opaque+alpha. Most useful for simple opacity maps. If the1587texture doesn't have an alpha channel KTX_TTF_PVRTC1_4_RGB1588will be used instead. Lowest quality of any supported1589texture format. */15901591// ASTC (mobile, Intel devices, hopefully all desktop GPU's one day)1592KTX_TTF_ASTC_4x4_RGBA = 10,1593/*!< Opaque+alpha, ASTC 4x4. The alpha channel will be opaque for1594textures without an alpha channel. The transcoder uses1595RGB/RGBA/L/LA modes, void extent, and up to two ([0,47] and1596[0,255]) endpoint precisions. */15971598// ATC and FXT1 formats are not supported by KTX2 as there1599// are no equivalent VkFormats.16001601KTX_TTF_PVRTC2_4_RGB = 18,1602/*!< Opaque-only. Almost BC1 quality, much faster to transcode1603and supports arbitrary texture dimensions (unlike1604PVRTC1 RGB). */1605KTX_TTF_PVRTC2_4_RGBA = 19,1606/*!< Opaque+alpha. Slower to transcode than cTFPVRTC2_4_RGB.1607Premultiplied alpha is highly recommended, otherwise the1608color channel can leak into the alpha channel on transparent1609blocks. */16101611KTX_TTF_ETC2_EAC_R11 = 20,1612/*!< R only (ETC2 EAC R11 unsigned). R = opaque.g or alpha.g, if1613KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1614specified. */1615KTX_TTF_ETC2_EAC_RG11 = 21,1616/*!< RG only (ETC2 EAC RG11 unsigned), R=opaque.g, G=alpha.g. The1617texture should have an alpha channel (if not G will be all1618255's. For tangent space normal maps. */16191620// Uncompressed (raw pixel) formats1621KTX_TTF_RGBA32 = 13,1622/*!< 32bpp RGBA image stored in raster (not block) order in1623memory, R is first byte, A is last byte. */1624KTX_TTF_RGB565 = 14,1625/*!< 16bpp RGB image stored in raster (not block) order in memory,1626R at bit position 11. */1627KTX_TTF_BGR565 = 15,1628/*!< 16bpp RGB image stored in raster (not block) order in memory,1629R at bit position 0. */1630KTX_TTF_RGBA4444 = 16,1631/*!< 16bpp RGBA image stored in raster (not block) order in memory,1632R at bit position 12, A at bit position 0. */16331634// Values for automatic selection of RGB or RGBA depending if alpha1635// present.1636KTX_TTF_ETC = 22,1637/*!< Automatically selects @c KTX_TTF_ETC1_RGB or1638@c KTX_TTF_ETC2_RGBA according to presence of alpha. */1639KTX_TTF_BC1_OR_3 = 23,1640/*!< Automatically selects @c KTX_TTF_BC1_RGB or1641@c KTX_TTF_BC3_RGBA according to presence of alpha. */16421643KTX_TTF_NOSELECTION = 0x7fffffff,16441645// Old enums for compatibility with code compiled against previous1646// versions of libktx.1647KTX_TF_ETC1 = KTX_TTF_ETC1_RGB,1648//!< @deprecated Use #KTX_TTF_ETC1_RGB.1649KTX_TF_ETC2 = KTX_TTF_ETC,1650//!< @deprecated Use #KTX_TTF_ETC.1651KTX_TF_BC1 = KTX_TTF_BC1_RGB,1652//!< @deprecated Use #KTX_TTF_BC1_RGB.1653KTX_TF_BC3 = KTX_TTF_BC3_RGBA,1654//!< @deprecated Use #KTX_TTF_BC3_RGBA.1655KTX_TF_BC4 = KTX_TTF_BC4_R,1656//!< @deprecated Use #KTX_TTF_BC4_R.1657KTX_TF_BC5 = KTX_TTF_BC5_RG,1658//!< @deprecated Use #KTX_TTF_BC5_RG.1659KTX_TTF_BC7_M6_RGB = KTX_TTF_BC7_RGBA,1660//!< @deprecated Use #KTX_TTF_BC7_RGBA.1661KTX_TTF_BC7_M5_RGBA = KTX_TTF_BC7_RGBA,1662//!< @deprecated Use #KTX_TTF_BC7_RGBA.1663KTX_TF_BC7_M6_OPAQUE_ONLY = KTX_TTF_BC7_RGBA,1664//!< @deprecated Use #KTX_TTF_BC7_RGBA1665KTX_TF_PVRTC1_4_OPAQUE_ONLY = KTX_TTF_PVRTC1_4_RGB1666//!< @deprecated Use #KTX_TTF_PVRTC1_4_RGB.1667} ktx_transcode_fmt_e;16681669/**1670* @~English1671* @brief Flags guiding transcoding of Basis Universal compressed textures.1672*/1673typedef enum ktx_transcode_flag_bits_e {1674KTX_TF_PVRTC_DECODE_TO_NEXT_POW2 = 2,1675/*!< PVRTC1: decode non-pow2 ETC1S texture level to the next larger1676power of 2 (not implemented yet, but we're going to support it).1677Ignored if the slice's dimensions are already a power of 2.1678*/1679KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS = 4,1680/*!< When decoding to an opaque texture format, if the Basis data has1681alpha, decode the alpha slice instead of the color slice to the1682output texture format. Has no effect if there is no alpha data.1683*/1684KTX_TF_HIGH_QUALITY = 32,1685/*!< Request higher quality transcode of UASTC to BC1, BC3, ETC2_EAC_R11 and1686ETC2_EAC_RG11. The flag is unused by other UASTC transcoders.1687*/1688} ktx_transcode_flag_bits_e;1689typedef ktx_uint32_t ktx_transcode_flags;16901691KTX_API KTX_error_code KTX_APIENTRY1692ktxTexture2_TranscodeBasis(ktxTexture2* This, ktx_transcode_fmt_e fmt,1693ktx_transcode_flags transcodeFlags);16941695/*1696* Returns a string corresponding to a KTX error code.1697*/1698KTX_API const char* KTX_APIENTRY1699ktxErrorString(KTX_error_code error);17001701/*1702* Returns a string corresponding to a supercompression scheme.1703*/1704KTX_API const char* KTX_APIENTRY1705ktxSupercompressionSchemeString(ktxSupercmpScheme scheme);17061707/*1708* Returns a string corresponding to a transcode target format.1709*/1710KTX_API const char* KTX_APIENTRY1711ktxTranscodeFormatString(ktx_transcode_fmt_e format);17121713KTX_API KTX_error_code KTX_APIENTRY ktxHashList_Create(ktxHashList** ppHl);1714KTX_API KTX_error_code KTX_APIENTRY1715ktxHashList_CreateCopy(ktxHashList** ppHl, ktxHashList orig);1716KTX_API void KTX_APIENTRY ktxHashList_Construct(ktxHashList* pHl);1717KTX_API void KTX_APIENTRY1718ktxHashList_ConstructCopy(ktxHashList* pHl, ktxHashList orig);1719KTX_API void KTX_APIENTRY ktxHashList_Destroy(ktxHashList* head);1720KTX_API void KTX_APIENTRY ktxHashList_Destruct(ktxHashList* head);17211722/*1723* Adds a key-value pair to a hash list.1724*/1725KTX_API KTX_error_code KTX_APIENTRY1726ktxHashList_AddKVPair(ktxHashList* pHead, const char* key,1727unsigned int valueLen, const void* value);17281729/*1730* Deletes a ktxHashListEntry from a ktxHashList.1731*/1732KTX_API KTX_error_code KTX_APIENTRY1733ktxHashList_DeleteEntry(ktxHashList* pHead, ktxHashListEntry* pEntry);17341735/*1736* Finds the entry for a key in a ktxHashList and deletes it.1737*/1738KTX_API KTX_error_code KTX_APIENTRY1739ktxHashList_DeleteKVPair(ktxHashList* pHead, const char* key);17401741/*1742* Looks up a key and returns the ktxHashListEntry.1743*/1744KTX_API KTX_error_code KTX_APIENTRY1745ktxHashList_FindEntry(ktxHashList* pHead, const char* key,1746ktxHashListEntry** ppEntry);17471748/*1749* Looks up a key and returns the value.1750*/1751KTX_API KTX_error_code KTX_APIENTRY1752ktxHashList_FindValue(ktxHashList* pHead, const char* key,1753unsigned int* pValueLen, void** pValue);17541755/*1756* Return the next entry in a ktxHashList.1757*/1758KTX_API ktxHashListEntry* KTX_APIENTRY1759ktxHashList_Next(ktxHashListEntry* entry);17601761/*1762* Sorts a ktxHashList into order of the key codepoints.1763*/1764KTX_API KTX_error_code KTX_APIENTRY1765ktxHashList_Sort(ktxHashList* pHead);17661767/*1768* Serializes a ktxHashList to a block of memory suitable for1769* writing to a KTX file.1770*/1771KTX_API KTX_error_code KTX_APIENTRY1772ktxHashList_Serialize(ktxHashList* pHead,1773unsigned int* kvdLen, unsigned char** kvd);17741775/*1776* Creates a hash table from the serialized data read from a1777* a KTX file.1778*/1779KTX_API KTX_error_code KTX_APIENTRY1780ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* kvd);17811782/*1783* Get the key from a ktxHashListEntry1784*/1785KTX_API KTX_error_code KTX_APIENTRY1786ktxHashListEntry_GetKey(ktxHashListEntry* This,1787unsigned int* pKeyLen, char** ppKey);17881789/*1790* Get the value from a ktxHashListEntry1791*/1792KTX_API KTX_error_code KTX_APIENTRY1793ktxHashListEntry_GetValue(ktxHashListEntry* This,1794unsigned int* pValueLen, void** ppValue);17951796/*===========================================================*1797* Utilities for printing info about a KTX file. *1798*===========================================================*/17991800KTX_API KTX_error_code KTX_APIENTRY ktxPrintInfoForStdioStream(FILE* stdioStream);1801KTX_API KTX_error_code KTX_APIENTRY ktxPrintInfoForNamedFile(const char* const filename);1802KTX_API KTX_error_code KTX_APIENTRY ktxPrintInfoForMemory(const ktx_uint8_t* bytes, ktx_size_t size);18031804/*===========================================================*1805* Utilities for printing info about a KTX v1 file. *1806*===========================================================*/18071808KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX1InfoTextForStream(ktxStream* stream);18091810/*===========================================================*1811* Utilities for printing info about a KTX v2 file. *1812*===========================================================*/18131814KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForMemory(const ktx_uint8_t* bytes, ktx_size_t size);1815KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForNamedFile(const char* const filename);1816KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForStdioStream(FILE* stdioStream);1817KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForStream(ktxStream* stream);1818KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);1819KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForNamedFile(const char* const filename, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);1820KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForStdioStream(FILE* stdioStream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);1821KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForStream(ktxStream* stream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);18221823#ifdef __cplusplus1824}1825#endif18261827/**1828@~English1829@page libktx_history Revision History18301831No longer updated. Kept to preserve ancient history. For more recent history see the repo log at1832https://github.com/KhronosGroup/KTX-Software. See also the Release Notes in the repo.18331834@section v8 Version 4.01835Added:1836@li Support for KTX Version 2.1837@li Support for encoding and transcoding Basis Universal images in KTX Version 2 files.1838@li Function to print info about a KTX file.18391840@section v7 Version 3.0.11841Fixed:1842@li GitHub issue #159: compile failure with recent Vulkan SDKs.1843@li Incorrect mapping of GL DXT3 and DXT5 formats to Vulkan equivalents.1844@li Incorrect BC4 blocksize.1845@li Missing mapping of PVRTC formats from GL to Vulkan.1846@li Incorrect block width and height calculations for sizes that are not1847a multiple of the block size.1848@li Incorrect KTXorientation key in test images.18491850@section v6 Version 3.01851Added:1852@li new ktxTexture object based API for reading KTX files without an OpenGL context.1853@li Vulkan loader. @#include <ktxvulkan.h> to use it.18541855Changed:1856@li ktx.h to not depend on KHR/khrplatform.h and GL{,ES*}/gl{corearb,}.h.1857Applications using OpenGL must now include these files themselves.1858@li ktxLoadTexture[FMN], removing the hack of loading 1D textures as 2D textures1859when the OpenGL context does not support 1D textures.1860KTX_UNSUPPORTED_TEXTURE_TYPE is now returned.18611862@section v5 Version 2.0.21863Added:1864@li Support for cubemap arrays.18651866Changed:1867@li New build system18681869Fixed:1870@li GitHub issue #40: failure to byte-swap key-value lengths.1871@li GitHub issue #33: returning incorrect target when loading cubemaps.1872@li GitHub PR #42: loading of texture arrays.1873@li GitHub PR #41: compilation error when KTX_OPENGL_ES2=1 defined.1874@li GitHub issue #39: stack-buffer-overflow in toktx1875@li Don't use GL_EXTENSIONS on recent OpenGL versions.18761877@section v4 Version 2.0.11878Added:1879@li CMake build files. Thanks to Pavel Rotjberg for the initial version.18801881Changed:1882@li ktxWriteKTXF to check the validity of the type & format combinations1883passed to it.18841885Fixed:1886@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=999">999</a>: 16-bit luminance texture cannot be written.1887@li compile warnings from compilers stricter than MS Visual C++. Thanks to1888Pavel Rotjberg.18891890@section v3 Version 2.01891Added:1892@li support for decoding ETC2 and EAC formats in the absence of a hardware1893decoder.1894@li support for converting textures with legacy LUMINANCE, LUMINANCE_ALPHA,1895etc. formats to the equivalent R, RG, etc. format with an1896appropriate swizzle, when loading in OpenGL Core Profile contexts.1897@li ktxErrorString function to return a string corresponding to an error code.1898@li tests for ktxLoadTexture[FN] that run under OpenGL ES 3.0 and OpenGL 3.3.1899The latter includes an EGL on WGL wrapper that makes porting apps between1900OpenGL ES and OpenGL easier on Windows.1901@li more texture formats to ktxLoadTexture[FN] and toktx tests.19021903Changed:1904@li ktxLoadTexture[FMN] to discover the capabilities of the GL context at1905run time and load textures, or not, according to those capabilities.19061907Fixed:1908@li failure of ktxWriteKTXF to pad image rows to 4 bytes as required by the KTX1909format.1910@li ktxWriteKTXF exiting with KTX_FILE_WRITE_ERROR when attempting to write1911more than 1 byte of face-LOD padding.19121913Although there is only a very minor API change, the addition of ktxErrorString,1914the functional changes are large enough to justify bumping the major revision1915number.19161917@section v2 Version 1.0.11918Implemented ktxLoadTextureM.1919Fixed the following:1920@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=571">571</a>: crash when null passed for pIsMipmapped.1921@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=572">572</a>: memory leak when unpacking ETC textures.1922@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=573">573</a>: potential crash when unpacking ETC textures with unused padding pixels.1923@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=576">576</a>: various small fixes.19241925Thanks to Krystian Bigaj for the ktxLoadTextureM implementation and these fixes.19261927@section v1 Version 1.01928Initial release.19291930*/19311932#endif /* KTX_H_A55A6F00956F42F3A137C11929827FE1 */193319341935