MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / mapAstcError

Function mapAstcError

lib/astc_codec.cpp:152–185  ·  view source on GitHub ↗

* @internal * @~English * @brief Map astcenc error code to KTX error code * * Asserts are fired on errors reflecting bad parameters passed by libktx * or astcenc compilation settings that do not permit correct operation. * * @param astc_error The error code to be mapped. * @return An equivalent KTX error code. */

Source from the content-addressed store, hash-verified

150 * @return An equivalent KTX error code.
151 */
152static ktx_error_code_e
153mapAstcError(astcenc_error astc_error) {
154 switch (astc_error) {
155 case ASTCENC_SUCCESS:
156 return KTX_SUCCESS;
157 case ASTCENC_ERR_OUT_OF_MEM:
158 return KTX_OUT_OF_MEMORY;
159 case ASTCENC_ERR_BAD_BLOCK_SIZE: //[[fallthrough]];
160 case ASTCENC_ERR_BAD_DECODE_MODE: //[[fallthrough]];
161 case ASTCENC_ERR_BAD_FLAGS: //[[fallthrough]];
162 case ASTCENC_ERR_BAD_PARAM: //[[fallthrough]];
163 case ASTCENC_ERR_BAD_PROFILE: //[[fallthrough]];
164 case ASTCENC_ERR_BAD_QUALITY: //[[fallthrough]];
165 case ASTCENC_ERR_BAD_SWIZZLE:
166 assert(false && "libktx passing bad parameter to astcenc");
167 return KTX_INVALID_VALUE;
168 case ASTCENC_ERR_BAD_CONTEXT:
169 assert(false && "libktx has set up astcenc context incorrectly");
170 return KTX_INVALID_OPERATION;
171 case ASTCENC_ERR_BAD_CPU_FLOAT:
172 assert(false && "Code compiled such that float operations do not meet codec's assumptions.");
173 // Most likely compiled with fast math enabled.
174 return KTX_INVALID_OPERATION;
175 case ASTCENC_ERR_NOT_IMPLEMENTED:
176 assert(false && "ASTCENC_BLOCK_MAX_TEXELS not enough for specified block size");
177 return KTX_UNSUPPORTED_FEATURE;
178 // gcc fails to detect that the switch handles all astcenc_error
179 // enumerators and raises a return-type error, "control reaches end of
180 // non-void function", hence this
181 default:
182 assert(false && "Unhandled astcenc error");
183 return KTX_INVALID_OPERATION;
184 }
185}
186
187/**
188 * @memberof ktxTexture

Callers 2

ktxTexture2_DecodeAstcFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected