File size: 5,617 Bytes
ee1cef6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | /* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab: */
/*
* Copyright 2010-2020 The Khronos Group Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @~English
*
* @brief Functions to return a string corresponding to various enumerations.
*
* @author Mark Callow, HI Corporation
*/
#include "ktx.h"
#include "basis_sgd.h"
static const char* const errorStrings[] = {
"Operation succeeded.", /* KTX_SUCCESS */
"File data is inconsistent with KTX spec.", /* KTX_FILE_DATA_ERROR */
"File is a pipe; seek operations not possible.", /* KTX_FILE_ISPIPE */
"File open failed.", /* KTX_FILE_OPEN_FAILED */
"Operation would exceed the max file size.", /* KTX_FILE_OVERFLOW */
"File read error.", /* KTX_FILE_READ_ERROR */
"File seek error.", /* KTX_FILE_SEEK_ERROR */
"File does not have enough data for request.", /* KTX_FILE_UNEXPECTED_EOF */
"File write error.", /* KTX_FILE_WRITE_ERROR */
"GL error occurred.", /* KTX_GL_ERROR */
"Operation not allowed in the current state.", /* KTX_INVALID_OPERATION */
"Invalid parameter value.", /* KTX_INVALID_VALUE */
"Metadata key or loader-required GPU function not found.", /* KTX_NOT_FOUND */
"Out of memory.", /* KTX_OUT_OF_MEMORY */
"Transcoding of block compressed texture failed.",/* KTX_TRANSCODE_FAILED */
"Not a KTX file.", /* KTX_UNKNOWN_FILE_FORMAT */
"Texture type not supported.", /* KTX_UNSUPPORTED_TEXTURE_TYPE */
"Feature not included in in-use library or not yet implemented.", /* KTX_UNSUPPORTED_FEATURE */
"Library dependency (OpenGL or Vulkan) not linked into application.", /* KTX_LIBRARY_NOT_LINKED */
"Decompressed byte count does not match expected byte size", /* KTX_DECOMPRESS_LENGTH_ERROR */
"Checksum mismatch when decompressing" /* KTX_DECOMPRESS_CHECKSUM_ERROR */
};
/* This will cause compilation to fail if number of messages and codes doesn't match */
typedef int errorStrings_SIZE_ASSERT[sizeof(errorStrings) / sizeof(char*) - 1 == KTX_ERROR_MAX_ENUM];
/**
* @~English
* @brief Return a string corresponding to a KTX error code.
*
* @param error the error code for which to return a string
*
* @return pointer to the message string.
*
* @internal Use UTF-8 for translated message strings.
*
* @author Mark Callow
*/
const char* ktxErrorString(KTX_error_code error)
{
if (error < 0 || error > KTX_ERROR_MAX_ENUM)
return "Unrecognized error code";
return errorStrings[error];
}
/**
* @~English
* @brief Return a string corresponding to a transcode format enumeration.
*
* @param format the transcode format for which to return a string.
*
* @return pointer to the message string.
*
* @internal Use UTF-8 for translated message strings.
*
* @author Mark Callow
*/
const char* ktxTranscodeFormatString(ktx_transcode_fmt_e format)
{
switch (format) {
case KTX_TTF_ETC1_RGB: return "ETC1_RGB";
case KTX_TTF_ETC2_RGBA: return "ETC2_RGBA";
case KTX_TTF_BC1_RGB: return "BC1_RGB";
case KTX_TTF_BC3_RGBA: return "BC3_RGBA";
case KTX_TTF_BC4_R: return "BC4_R";
case KTX_TTF_BC5_RG: return "BC5_RG";
case KTX_TTF_BC7_RGBA: return "BC7_RGBA";
case KTX_TTF_PVRTC1_4_RGB: return "PVRTC1_4_RGB";
case KTX_TTF_PVRTC1_4_RGBA: return "PVRTC1_4_RGBA";
case KTX_TTF_ASTC_4x4_RGBA: return "ASTC_4x4_RGBA";
case KTX_TTF_RGBA32: return "RGBA32";
case KTX_TTF_RGB565: return "RGB565";
case KTX_TTF_BGR565: return "BGR565";
case KTX_TTF_RGBA4444: return "RGBA4444";
case KTX_TTF_PVRTC2_4_RGB: return "PVRTC2_4_RGB";
case KTX_TTF_PVRTC2_4_RGBA: return "PVRTC2_4_RGBA";
case KTX_TTF_ETC2_EAC_R11: return "ETC2_EAC_R11";
case KTX_TTF_ETC2_EAC_RG11: return "ETC2_EAC_RG11";
case KTX_TTF_ETC: return "ETC";
case KTX_TTF_BC1_OR_3: return "BC1 or BC3";
default: return "Unrecognized format";
}
}
/**
* @~English
* @brief Return a string corresponding to a supercompressionScheme enumeration.
*
* @param scheme the supercompression scheme for which to return a string.
*
* @return pointer to the message string.
*
* @internal Use UTF-8 for translated message strings.
*
* @author Mark Callow
*/
const char *
ktxSupercompressionSchemeString(ktxSupercmpScheme scheme)
{
switch (scheme) {
case KTX_SS_NONE: return "KTX_SS_NONE";
case KTX_SS_BASIS_LZ: return "KTX_SS_BASIS_LZ";
case KTX_SS_ZSTD: return "KTX_SS_ZSTD";
case KTX_SS_ZLIB: return "KTX_SS_ZLIB";
default:
if (scheme < KTX_SS_BEGIN_VENDOR_RANGE
|| scheme >= KTX_SS_BEGIN_RESERVED)
return "Invalid scheme value";
else
return "Vendor or reserved scheme";
}
}
/**
* @~English
* @brief Return a string corresponding to a bu_image_flags bit.
*
* @param bit_index the bu_image_flag bit to test.
* @param bit_value the bu_image_flag bit value.
*
* @return pointer to the message string or NULL otherwise.
*
* @internal Use UTF-8 for translated message strings.
*/
const char* ktxBUImageFlagsBitString(ktx_uint32_t bit_index, bool bit_value)
{
if (!bit_value)
return NULL;
switch (1u << bit_index) {
case ETC1S_P_FRAME: return "ETC1S_P_FRAME";
default: return NULL;
}
}
|