/* -*- 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 profile mode1277* This and function is used later to derive the profile.1278*/1279typedef enum ktx_pack_astc_encoder_mode_e {1280KTX_PACK_ASTC_ENCODER_MODE_DEFAULT,1281KTX_PACK_ASTC_ENCODER_MODE_LDR,1282KTX_PACK_ASTC_ENCODER_MODE_HDR,1283KTX_PACK_ASTC_ENCODER_MODE_MAX = KTX_PACK_ASTC_ENCODER_MODE_HDR1284} ktx_pack_astc_encoder_mode_e;12851286extern KTX_API const ktx_uint32_t KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL;12871288/**1289* @memberof ktxTexture1290* @~English1291* @brief Structure for passing extended parameters to1292* ktxTexture_CompressAstc.1293*1294* Passing a struct initialized to 0 (e.g. " = {0};") will use blockDimension1295* 4x4, mode LDR and qualityLevel FASTEST. Setting qualityLevel to1296* KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM is recommended.1297*/1298typedef struct ktxAstcParams {1299ktx_uint32_t structSize;1300/*!< Size of this struct. Used so library can tell which version1301of struct is being passed.1302*/13031304ktx_bool_t verbose;1305/*!< If true, prints Astc encoder operation details to1306@c stdout. Not recommended for GUI apps.1307*/13081309ktx_uint32_t threadCount;1310/*!< Number of threads used for compression. Default is 1.1311*/13121313/* astcenc params */1314ktx_uint32_t blockDimension;1315/*!< Combinations of block dimensions that astcenc supports1316i.e. 6x6, 8x8, 6x5 etc1317*/13181319ktx_uint32_t mode;1320/*!< Can be {ldr/hdr} from astcenc1321*/13221323ktx_uint32_t qualityLevel;1324/*!< astcenc supports -fastest, -fast, -medium, -thorough, -exhaustive1325*/13261327ktx_bool_t normalMap;1328/*!< Tunes codec parameters for better quality on normal maps1329In this mode normals are compressed to X,Y components1330Discarding Z component, reader will need to generate Z1331component in shaders.1332*/13331334ktx_bool_t perceptual;1335/*!< The codec should optimize for perceptual error, instead of direct1336RMS error. This aims to improves perceived image quality, but1337typically lowers the measured PSNR score. Perceptual methods are1338currently only available for normal maps and RGB color data.1339*/13401341char inputSwizzle[4];1342/*!< A swizzle to provide as input to astcenc. It must match the regular1343expression /^[rgba01]{4}$/.1344*/1345} ktxAstcParams;13461347KTX_API KTX_error_code KTX_APIENTRY1348ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params);13491350KTX_API KTX_error_code KTX_APIENTRY1351ktxTexture2_CompressAstc(ktxTexture2* This, ktx_uint32_t quality);13521353KTX_API KTX_error_code KTX_APIENTRY1354ktxTexture2_DecodeAstc(ktxTexture2* This);13551356/**1357* @memberof ktxTexture21358* @~English1359* @brief Structure for passing extended parameters to1360* ktxTexture2_CompressBasisEx().1361*1362* If you only want default values, use ktxTexture2_CompressBasis(). Here, at1363* a minimum you must initialize the structure as follows:1364* @code1365* ktxBasisParams params = {0};1366* params.structSize = sizeof(params);1367* params.compressionLevel = KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL;1368* @endcode1369*1370* @e compressionLevel has to be explicitly set because 0 is a valid1371* @e compressionLevel but is not the default used by the BasisU encoder1372* when no value is set. Only the other settings that are to be non-default1373* must be non-zero.1374*/1375typedef struct ktxBasisParams {1376ktx_uint32_t structSize;1377/*!< Size of this struct. Used so library can tell which version1378of struct is being passed.1379*/1380ktx_bool_t uastc;1381/*!< True to use UASTC base, false to use ETC1S base. */1382ktx_bool_t verbose;1383/*!< If true, prints Basis Universal encoder operation details to1384@c stdout. Not recommended for GUI apps.1385*/1386ktx_bool_t noSSE;1387/*!< True to forbid use of the SSE instruction set. Ignored if CPU1388does not support SSE. */1389ktx_uint32_t threadCount;1390/*!< Number of threads used for compression. Default is 1. */13911392/* ETC1S params */13931394ktx_uint32_t compressionLevel;1395/*!< Encoding speed vs. quality tradeoff. Range is [0,6]. Higher values1396are much slower, but give slightly higher quality. Higher levels1397are intended for video. There is no default. Callers must1398explicitly set this value. Callers can use1399KTX\_ETC1S\_DEFAULT\_COMPRESSION\_LEVEL as a default value.1400Currently this is 2.1401*/1402ktx_uint32_t qualityLevel;1403/*!< Compression quality. Range is [1,255]. Lower gives better1404compression/lower quality/faster. Higher gives less compression1405/higher quality/slower. This automatically determines values for1406@c maxEndpoints, @c maxSelectors,1407@c endpointRDOThreshold and @c selectorRDOThreshold1408for the target quality level. Setting these parameters overrides1409the values determined by @c qualityLevel which defaults to1410128 if neither it nor both of @c maxEndpoints and1411@c maxSelectors have been set.1412@note @e Both of @c maxEndpoints and @c maxSelectors1413must be set for them to have any effect.1414@note qualityLevel will only determine values for1415@c endpointRDOThreshold and @c selectorRDOThreshold1416when its value exceeds 128, otherwise their defaults will be used.1417*/1418ktx_uint32_t maxEndpoints;1419/*!< Manually set the max number of color endpoint clusters.1420Range is [1,16128]. Default is 0, unset. If this is set, maxSelectors1421must also be set, otherwise the value will be ignored.1422*/1423float endpointRDOThreshold;1424/*!< Set endpoint RDO quality threshold. The default is 1.25. Lower is1425higher quality but less quality per output bit (try [1.0,3.0].1426This will override the value chosen by @c qualityLevel.1427*/1428ktx_uint32_t maxSelectors;1429/*!< Manually set the max number of color selector clusters. Range1430is [1,16128]. Default is 0, unset. If this is set, maxEndpoints1431must also be set, otherwise the value will be ignored.1432*/1433float selectorRDOThreshold;1434/*!< Set selector RDO quality threshold. The default is 1.5. Lower is1435higher quality but less quality per output bit (try [1.0,3.0]).1436This will override the value chosen by @c qualityLevel.1437*/1438char inputSwizzle[4];1439/*!< A swizzle to apply before encoding. It must match the regular1440expression /^[rgba01]{4}$/. If both this and preSwizzle1441are specified ktxTexture_CompressBasisEx will raise1442KTX_INVALID_OPERATION. Usable with both ETC1S and UASTC.1443*/1444ktx_bool_t normalMap;1445/*!< Tunes codec parameters for better quality on normal maps (no1446selector RDO, no endpoint RDO) and sets the texture's DFD appropriately.1447Only valid for linear textures.1448*/1449ktx_bool_t separateRGToRGB_A;1450/*!< @deprecated This was and is a no-op. 2-component inputs have1451always been automatically separated using an "rrrg" inputSwizzle.1452@sa inputSwizzle and normalMode.1453*/1454ktx_bool_t preSwizzle;1455/*!< If the texture has @c KTXswizzle metadata, apply it before1456compressing. Swizzling, like @c rabb may yield drastically1457different error metrics if done after supercompression. Usable1458for both ETC1S and UASTC.1459*/1460ktx_bool_t noEndpointRDO;1461/*!< Disable endpoint rate distortion optimizations. Slightly faster,1462less noisy output, but lower quality per output bit. Default is1463KTX_FALSE.1464*/1465ktx_bool_t noSelectorRDO;1466/*!< Disable selector rate distortion optimizations. Slightly faster,1467less noisy output, but lower quality per output bit. Default is1468KTX_FALSE.1469*/14701471/* UASTC params */14721473ktx_pack_uastc_flags uastcFlags;1474/*!< A set of ::ktx_pack_uastc_flag_bits_e controlling UASTC1475encoding. The most important value is the level given in the1476least-significant 4 bits which selects a speed vs quality tradeoff1477as shown in the following table:14781479Level/Speed | Quality1480:-----: | :-------:1481KTX_PACK_UASTC_LEVEL_FASTEST | 43.45dB1482KTX_PACK_UASTC_LEVEL_FASTER | 46.49dB1483KTX_PACK_UASTC_LEVEL_DEFAULT | 47.47dB1484KTX_PACK_UASTC_LEVEL_SLOWER | 48.01dB1485KTX_PACK_UASTC_LEVEL_VERYSLOW | 48.24dB1486*/1487ktx_bool_t uastcRDO;1488/*!< Enable Rate Distortion Optimization (RDO) post-processing.1489*/1490float uastcRDOQualityScalar;1491/*!< UASTC RDO quality scalar (lambda). Lower values yield higher1492quality/larger LZ compressed files, higher values yield lower1493quality/smaller LZ compressed files. A good range to try is [.2,4].1494Full range is [.001,50.0]. Default is 1.0.1495*/1496ktx_uint32_t uastcRDODictSize;1497/*!< UASTC RDO dictionary size in bytes. Default is 4096. Lower1498values=faster, but give less compression. Range is [64,65536].1499*/1500float uastcRDOMaxSmoothBlockErrorScale;1501/*!< UASTC RDO max smooth block error scale. Range is [1,300].1502Default is 10.0, 1.0 is disabled. Larger values suppress more1503artifacts (and allocate more bits) on smooth blocks.1504*/1505float uastcRDOMaxSmoothBlockStdDev;1506/*!< UASTC RDO max smooth block standard deviation. Range is1507[.01,65536.0]. Default is 18.0. Larger values expand the range of1508blocks considered smooth.1509*/1510ktx_bool_t uastcRDODontFavorSimplerModes;1511/*!< Do not favor simpler UASTC modes in RDO mode.1512*/1513ktx_bool_t uastcRDONoMultithreading;1514/*!< Disable RDO multithreading (slightly higher compression,1515deterministic).1516*/15171518} ktxBasisParams;15191520KTX_API KTX_error_code KTX_APIENTRY1521ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params);15221523/**1524* @~English1525* @brief Enumerators for specifying the transcode target format.1526*1527* For BasisU/ETC1S format, @e Opaque and @e alpha here refer to 2 separate1528* RGB images, a.k.a slices within the BasisU compressed data. For UASTC1529* format they refer to the RGB and the alpha components of the UASTC data. If1530* the original image had only 2 components, R will be in the opaque portion1531* and G in the alpha portion. The R value will be replicated in the RGB1532* components. In the case of BasisU the G value will be replicated in all 31533* components of the alpha slice. If the original image had only 1 component1534* it's value is replicated in all 3 components of the opaque portion and1535* there is no alpha.1536*1537* @note You should not transcode sRGB encoded data to @c KTX_TTF_BC4_R,1538* @c KTX_TTF_BC5_RG, @c KTX_TTF_ETC2_EAC_R{,G}11, @c KTX_TTF_RGB565,1539* @c KTX_TTF_BGR565 or @c KTX_TTF_RGBA4444 formats as neither OpenGL nor1540* Vulkan support sRGB variants of these. Doing sRGB decoding in the shader1541* will not produce correct results if any texture filtering is being used.1542*/1543typedef enum ktx_transcode_fmt_e {1544// Compressed formats15451546// ETC1-21547KTX_TTF_ETC1_RGB = 0,1548/*!< Opaque only. Returns RGB or alpha data, if1549KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1550specified. */1551KTX_TTF_ETC2_RGBA = 1,1552/*!< Opaque+alpha. EAC_A8 block followed by an ETC1 block. The1553alpha channel will be opaque for textures without an alpha1554channel. */15551556// BC1-5, BC7 (desktop, some mobile devices)1557KTX_TTF_BC1_RGB = 2,1558/*!< Opaque only, no punchthrough alpha support yet. Returns RGB1559or alpha data, if KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS1560flag is specified. */1561KTX_TTF_BC3_RGBA = 3,1562/*!< Opaque+alpha. BC4 block with alpha followed by a BC1 block. The1563alpha channel will be opaque for textures without an alpha1564channel. */1565KTX_TTF_BC4_R = 4,1566/*!< One BC4 block. R = opaque.g or alpha.g, if1567KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1568specified. */1569KTX_TTF_BC5_RG = 5,1570/*!< Two BC4 blocks, R=opaque.g and G=alpha.g The texture should1571have an alpha channel (if not G will be all 255's. For tangent1572space normal maps. */1573KTX_TTF_BC7_RGBA = 6,1574/*!< RGB or RGBA mode 5 for ETC1S, modes 1, 2, 3, 4, 5, 6, 7 for1575UASTC. */15761577// PVRTC1 4bpp (mobile, PowerVR devices)1578KTX_TTF_PVRTC1_4_RGB = 8,1579/*!< Opaque only. Returns RGB or alpha data, if1580KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1581specified. */1582KTX_TTF_PVRTC1_4_RGBA = 9,1583/*!< Opaque+alpha. Most useful for simple opacity maps. If the1584texture doesn't have an alpha channel KTX_TTF_PVRTC1_4_RGB1585will be used instead. Lowest quality of any supported1586texture format. */15871588// ASTC (mobile, Intel devices, hopefully all desktop GPU's one day)1589KTX_TTF_ASTC_4x4_RGBA = 10,1590/*!< Opaque+alpha, ASTC 4x4. The alpha channel will be opaque for1591textures without an alpha channel. The transcoder uses1592RGB/RGBA/L/LA modes, void extent, and up to two ([0,47] and1593[0,255]) endpoint precisions. */15941595// ATC and FXT1 formats are not supported by KTX2 as there1596// are no equivalent VkFormats.15971598KTX_TTF_PVRTC2_4_RGB = 18,1599/*!< Opaque-only. Almost BC1 quality, much faster to transcode1600and supports arbitrary texture dimensions (unlike1601PVRTC1 RGB). */1602KTX_TTF_PVRTC2_4_RGBA = 19,1603/*!< Opaque+alpha. Slower to transcode than cTFPVRTC2_4_RGB.1604Premultiplied alpha is highly recommended, otherwise the1605color channel can leak into the alpha channel on transparent1606blocks. */16071608KTX_TTF_ETC2_EAC_R11 = 20,1609/*!< R only (ETC2 EAC R11 unsigned). R = opaque.g or alpha.g, if1610KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS flag is1611specified. */1612KTX_TTF_ETC2_EAC_RG11 = 21,1613/*!< RG only (ETC2 EAC RG11 unsigned), R=opaque.g, G=alpha.g. The1614texture should have an alpha channel (if not G will be all1615255's. For tangent space normal maps. */16161617// Uncompressed (raw pixel) formats1618KTX_TTF_RGBA32 = 13,1619/*!< 32bpp RGBA image stored in raster (not block) order in1620memory, R is first byte, A is last byte. */1621KTX_TTF_RGB565 = 14,1622/*!< 16bpp RGB image stored in raster (not block) order in memory,1623R at bit position 11. */1624KTX_TTF_BGR565 = 15,1625/*!< 16bpp RGB image stored in raster (not block) order in memory,1626R at bit position 0. */1627KTX_TTF_RGBA4444 = 16,1628/*!< 16bpp RGBA image stored in raster (not block) order in memory,1629R at bit position 12, A at bit position 0. */16301631// Values for automatic selection of RGB or RGBA depending if alpha1632// present.1633KTX_TTF_ETC = 22,1634/*!< Automatically selects @c KTX_TTF_ETC1_RGB or1635@c KTX_TTF_ETC2_RGBA according to presence of alpha. */1636KTX_TTF_BC1_OR_3 = 23,1637/*!< Automatically selects @c KTX_TTF_BC1_RGB or1638@c KTX_TTF_BC3_RGBA according to presence of alpha. */16391640KTX_TTF_NOSELECTION = 0x7fffffff,16411642// Old enums for compatibility with code compiled against previous1643// versions of libktx.1644KTX_TF_ETC1 = KTX_TTF_ETC1_RGB,1645//!< @deprecated Use #KTX_TTF_ETC1_RGB.1646KTX_TF_ETC2 = KTX_TTF_ETC,1647//!< @deprecated Use #KTX_TTF_ETC.1648KTX_TF_BC1 = KTX_TTF_BC1_RGB,1649//!< @deprecated Use #KTX_TTF_BC1_RGB.1650KTX_TF_BC3 = KTX_TTF_BC3_RGBA,1651//!< @deprecated Use #KTX_TTF_BC3_RGBA.1652KTX_TF_BC4 = KTX_TTF_BC4_R,1653//!< @deprecated Use #KTX_TTF_BC4_R.1654KTX_TF_BC5 = KTX_TTF_BC5_RG,1655//!< @deprecated Use #KTX_TTF_BC5_RG.1656KTX_TTF_BC7_M6_RGB = KTX_TTF_BC7_RGBA,1657//!< @deprecated Use #KTX_TTF_BC7_RGBA.1658KTX_TTF_BC7_M5_RGBA = KTX_TTF_BC7_RGBA,1659//!< @deprecated Use #KTX_TTF_BC7_RGBA.1660KTX_TF_BC7_M6_OPAQUE_ONLY = KTX_TTF_BC7_RGBA,1661//!< @deprecated Use #KTX_TTF_BC7_RGBA1662KTX_TF_PVRTC1_4_OPAQUE_ONLY = KTX_TTF_PVRTC1_4_RGB1663//!< @deprecated Use #KTX_TTF_PVRTC1_4_RGB.1664} ktx_transcode_fmt_e;16651666/**1667* @~English1668* @brief Flags guiding transcoding of Basis Universal compressed textures.1669*/1670typedef enum ktx_transcode_flag_bits_e {1671KTX_TF_PVRTC_DECODE_TO_NEXT_POW2 = 2,1672/*!< PVRTC1: decode non-pow2 ETC1S texture level to the next larger1673power of 2 (not implemented yet, but we're going to support it).1674Ignored if the slice's dimensions are already a power of 2.1675*/1676KTX_TF_TRANSCODE_ALPHA_DATA_TO_OPAQUE_FORMATS = 4,1677/*!< When decoding to an opaque texture format, if the Basis data has1678alpha, decode the alpha slice instead of the color slice to the1679output texture format. Has no effect if there is no alpha data.1680*/1681KTX_TF_HIGH_QUALITY = 32,1682/*!< Request higher quality transcode of UASTC to BC1, BC3, ETC2_EAC_R11 and1683ETC2_EAC_RG11. The flag is unused by other UASTC transcoders.1684*/1685} ktx_transcode_flag_bits_e;1686typedef ktx_uint32_t ktx_transcode_flags;16871688KTX_API KTX_error_code KTX_APIENTRY1689ktxTexture2_TranscodeBasis(ktxTexture2* This, ktx_transcode_fmt_e fmt,1690ktx_transcode_flags transcodeFlags);16911692/*1693* Returns a string corresponding to a KTX error code.1694*/1695KTX_API const char* KTX_APIENTRY1696ktxErrorString(KTX_error_code error);16971698/*1699* Returns a string corresponding to a supercompression scheme.1700*/1701KTX_API const char* KTX_APIENTRY1702ktxSupercompressionSchemeString(ktxSupercmpScheme scheme);17031704/*1705* Returns a string corresponding to a transcode target format.1706*/1707KTX_API const char* KTX_APIENTRY1708ktxTranscodeFormatString(ktx_transcode_fmt_e format);17091710KTX_API KTX_error_code KTX_APIENTRY ktxHashList_Create(ktxHashList** ppHl);1711KTX_API KTX_error_code KTX_APIENTRY1712ktxHashList_CreateCopy(ktxHashList** ppHl, ktxHashList orig);1713KTX_API void KTX_APIENTRY ktxHashList_Construct(ktxHashList* pHl);1714KTX_API void KTX_APIENTRY1715ktxHashList_ConstructCopy(ktxHashList* pHl, ktxHashList orig);1716KTX_API void KTX_APIENTRY ktxHashList_Destroy(ktxHashList* head);1717KTX_API void KTX_APIENTRY ktxHashList_Destruct(ktxHashList* head);17181719/*1720* Adds a key-value pair to a hash list.1721*/1722KTX_API KTX_error_code KTX_APIENTRY1723ktxHashList_AddKVPair(ktxHashList* pHead, const char* key,1724unsigned int valueLen, const void* value);17251726/*1727* Deletes a ktxHashListEntry from a ktxHashList.1728*/1729KTX_API KTX_error_code KTX_APIENTRY1730ktxHashList_DeleteEntry(ktxHashList* pHead, ktxHashListEntry* pEntry);17311732/*1733* Finds the entry for a key in a ktxHashList and deletes it.1734*/1735KTX_API KTX_error_code KTX_APIENTRY1736ktxHashList_DeleteKVPair(ktxHashList* pHead, const char* key);17371738/*1739* Looks up a key and returns the ktxHashListEntry.1740*/1741KTX_API KTX_error_code KTX_APIENTRY1742ktxHashList_FindEntry(ktxHashList* pHead, const char* key,1743ktxHashListEntry** ppEntry);17441745/*1746* Looks up a key and returns the value.1747*/1748KTX_API KTX_error_code KTX_APIENTRY1749ktxHashList_FindValue(ktxHashList* pHead, const char* key,1750unsigned int* pValueLen, void** pValue);17511752/*1753* Return the next entry in a ktxHashList.1754*/1755KTX_API ktxHashListEntry* KTX_APIENTRY1756ktxHashList_Next(ktxHashListEntry* entry);17571758/*1759* Sorts a ktxHashList into order of the key codepoints.1760*/1761KTX_API KTX_error_code KTX_APIENTRY1762ktxHashList_Sort(ktxHashList* pHead);17631764/*1765* Serializes a ktxHashList to a block of memory suitable for1766* writing to a KTX file.1767*/1768KTX_API KTX_error_code KTX_APIENTRY1769ktxHashList_Serialize(ktxHashList* pHead,1770unsigned int* kvdLen, unsigned char** kvd);17711772/*1773* Creates a hash table from the serialized data read from a1774* a KTX file.1775*/1776KTX_API KTX_error_code KTX_APIENTRY1777ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* kvd);17781779/*1780* Get the key from a ktxHashListEntry1781*/1782KTX_API KTX_error_code KTX_APIENTRY1783ktxHashListEntry_GetKey(ktxHashListEntry* This,1784unsigned int* pKeyLen, char** ppKey);17851786/*1787* Get the value from a ktxHashListEntry1788*/1789KTX_API KTX_error_code KTX_APIENTRY1790ktxHashListEntry_GetValue(ktxHashListEntry* This,1791unsigned int* pValueLen, void** ppValue);17921793/*===========================================================*1794* Utilities for printing info about a KTX file. *1795*===========================================================*/17961797KTX_API KTX_error_code KTX_APIENTRY ktxPrintInfoForStdioStream(FILE* stdioStream);1798KTX_API KTX_error_code KTX_APIENTRY ktxPrintInfoForNamedFile(const char* const filename);1799KTX_API KTX_error_code KTX_APIENTRY ktxPrintInfoForMemory(const ktx_uint8_t* bytes, ktx_size_t size);18001801/*===========================================================*1802* Utilities for printing info about a KTX2 file. *1803*===========================================================*/18041805KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForMemory(const ktx_uint8_t* bytes, ktx_size_t size);1806KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForNamedFile(const char* const filename);1807KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForStdioStream(FILE* stdioStream);1808KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoTextForStream(ktxStream* stream);1809KTX_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);1810KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForNamedFile(const char* const filename, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);1811KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForStdioStream(FILE* stdioStream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);1812KTX_API KTX_error_code KTX_APIENTRY ktxPrintKTX2InfoJSONForStream(ktxStream* stream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified);18131814#ifdef __cplusplus1815}1816#endif18171818/**1819@~English1820@page libktx_history Revision History18211822No longer updated. Kept to preserve ancient history. For more recent history see the repo log at1823https://github.com/KhronosGroup/KTX-Software. See also the Release Notes in the repo.18241825@section v8 Version 4.01826Added:1827@li Support for KTX Version 2.1828@li Support for encoding and transcoding Basis Universal images in KTX Version 2 files.1829@li Function to print info about a KTX file.18301831@section v7 Version 3.0.11832Fixed:1833@li GitHub issue #159: compile failure with recent Vulkan SDKs.1834@li Incorrect mapping of GL DXT3 and DXT5 formats to Vulkan equivalents.1835@li Incorrect BC4 blocksize.1836@li Missing mapping of PVRTC formats from GL to Vulkan.1837@li Incorrect block width and height calculations for sizes that are not1838a multiple of the block size.1839@li Incorrect KTXorientation key in test images.18401841@section v6 Version 3.01842Added:1843@li new ktxTexture object based API for reading KTX files without an OpenGL context.1844@li Vulkan loader. @#include <ktxvulkan.h> to use it.18451846Changed:1847@li ktx.h to not depend on KHR/khrplatform.h and GL{,ES*}/gl{corearb,}.h.1848Applications using OpenGL must now include these files themselves.1849@li ktxLoadTexture[FMN], removing the hack of loading 1D textures as 2D textures1850when the OpenGL context does not support 1D textures.1851KTX_UNSUPPORTED_TEXTURE_TYPE is now returned.18521853@section v5 Version 2.0.21854Added:1855@li Support for cubemap arrays.18561857Changed:1858@li New build system18591860Fixed:1861@li GitHub issue #40: failure to byte-swap key-value lengths.1862@li GitHub issue #33: returning incorrect target when loading cubemaps.1863@li GitHub PR #42: loading of texture arrays.1864@li GitHub PR #41: compilation error when KTX_OPENGL_ES2=1 defined.1865@li GitHub issue #39: stack-buffer-overflow in toktx1866@li Don't use GL_EXTENSIONS on recent OpenGL versions.18671868@section v4 Version 2.0.11869Added:1870@li CMake build files. Thanks to Pavel Rotjberg for the initial version.18711872Changed:1873@li ktxWriteKTXF to check the validity of the type & format combinations1874passed to it.18751876Fixed:1877@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=999">999</a>: 16-bit luminance texture cannot be written.1878@li compile warnings from compilers stricter than MS Visual C++. Thanks to1879Pavel Rotjberg.18801881@section v3 Version 2.01882Added:1883@li support for decoding ETC2 and EAC formats in the absence of a hardware1884decoder.1885@li support for converting textures with legacy LUMINANCE, LUMINANCE_ALPHA,1886etc. formats to the equivalent R, RG, etc. format with an1887appropriate swizzle, when loading in OpenGL Core Profile contexts.1888@li ktxErrorString function to return a string corresponding to an error code.1889@li tests for ktxLoadTexture[FN] that run under OpenGL ES 3.0 and OpenGL 3.3.1890The latter includes an EGL on WGL wrapper that makes porting apps between1891OpenGL ES and OpenGL easier on Windows.1892@li more texture formats to ktxLoadTexture[FN] and toktx tests.18931894Changed:1895@li ktxLoadTexture[FMN] to discover the capabilities of the GL context at1896run time and load textures, or not, according to those capabilities.18971898Fixed:1899@li failure of ktxWriteKTXF to pad image rows to 4 bytes as required by the KTX1900format.1901@li ktxWriteKTXF exiting with KTX_FILE_WRITE_ERROR when attempting to write1902more than 1 byte of face-LOD padding.19031904Although there is only a very minor API change, the addition of ktxErrorString,1905the functional changes are large enough to justify bumping the major revision1906number.19071908@section v2 Version 1.0.11909Implemented ktxLoadTextureM.1910Fixed the following:1911@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=571">571</a>: crash when null passed for pIsMipmapped.1912@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=572">572</a>: memory leak when unpacking ETC textures.1913@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.1914@li Public Bugzilla <a href="http://www.khronos.org/bugzilla/show_bug.cgi?id=576">576</a>: various small fixes.19151916Thanks to Krystian Bigaj for the ktxLoadTextureM implementation and these fixes.19171918@section v1 Version 1.01919Initial release.19201921*/19221923#endif /* KTX_H_A55A6F00956F42F3A137C11929827FE1 */192419251926