rename ktx_ to ktx2_ for consistency
This commit is contained in:
parent
4efbb11178
commit
4158234fb2
|
@ -18,20 +18,20 @@ GNU General Public License for more details.
|
|||
#include "ktx2.h"
|
||||
|
||||
qboolean Image_LoadKTX2( const char *name, const byte *buffer, fs_offset_t filesize ) {
|
||||
ktx_header_t header;
|
||||
ktx2_header_t header;
|
||||
|
||||
if( filesize < KTX_MINIMAL_HEADER_SIZE )
|
||||
if( filesize < KTX2_MINIMAL_HEADER_SIZE )
|
||||
return false;
|
||||
|
||||
if ( memcmp(buffer, KTX_IDENTIFIER, KTX_IDENTIFIER_SIZE) != 0 ) {
|
||||
if ( memcmp(buffer, KTX2_IDENTIFIER, KTX2_IDENTIFIER_SIZE) != 0 ) {
|
||||
Con_DPrintf( S_ERROR "%s: (%s) has invalid identifier\n", __FUNCTION__, name );
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(&header, buffer + KTX_IDENTIFIER_SIZE, sizeof header);
|
||||
memcpy(&header, buffer + KTX2_IDENTIFIER_SIZE, sizeof header);
|
||||
|
||||
/* ktx_index_t index; */
|
||||
/* memcpy(&header, buffer + KTX_IDENTIFIER_SIZE + sizeof header, sizeof index); */
|
||||
/* ktx2_index_t index; */
|
||||
/* memcpy(&header, buffer + KTX2_IDENTIFIER_SIZE + sizeof header, sizeof index); */
|
||||
|
||||
image.width = header.pixelWidth;
|
||||
image.height = header.pixelHeight;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define KTX_IDENTIFIER_SIZE 12
|
||||
#define KTX_IDENTIFIER "\xABKTX 20\xBB\r\n\x1A\n"
|
||||
#define KTX2_IDENTIFIER_SIZE 12
|
||||
#define KTX2_IDENTIFIER "\xABKTX 20\xBB\r\n\x1A\n"
|
||||
|
||||
/*
|
||||
static const char k_ktx2_identifier[KTX_IDENTIFIER_SIZE] = {
|
||||
static const char k_ktx2_identifier[ktx2_IDENTIFIER_SIZE] = {
|
||||
'\xAB', 'K', 'T', 'X', ' ', '2', '0', '\xBB', '\r', '\n', '\x1A', '\n'
|
||||
};
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ typedef struct {
|
|||
uint32_t faceCount;
|
||||
uint32_t levelCount;
|
||||
uint32_t supercompressionScheme;
|
||||
} ktx_header_t;
|
||||
} ktx2_header_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dfdByteOffset;
|
||||
|
@ -30,12 +30,12 @@ typedef struct {
|
|||
uint32_t kvdByteLength;
|
||||
uint64_t sgdByteOffset;
|
||||
uint64_t sgdByteLength;
|
||||
} ktx_index_t;
|
||||
} ktx2_index_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t byteOffset;
|
||||
uint64_t byteLength;
|
||||
uint64_t uncompressedByteLength;
|
||||
} ktx_level_t;
|
||||
} ktx2_level_t;
|
||||
|
||||
#define KTX_MINIMAL_HEADER_SIZE (KTX_IDENTIFIER_SIZE + sizeof(ktx_header_t) + sizeof(ktx_index_t) + sizeof(ktx_level_t))
|
||||
#define KTX2_MINIMAL_HEADER_SIZE (KTX2_IDENTIFIER_SIZE + sizeof(ktx2_header_t) + sizeof(ktx2_index_t) + sizeof(ktx2_level_t))
|
||||
|
|
|
@ -907,13 +907,13 @@ static qboolean loadKtx2Raw( vk_texture_t *tex, const rgbdata_t* pic ) {
|
|||
const byte *const data = pic->buffer;
|
||||
const int size = pic->size;
|
||||
|
||||
const ktx_header_t* header;
|
||||
const ktx_index_t* index;
|
||||
const ktx_level_t* levels;
|
||||
const ktx2_header_t* header;
|
||||
const ktx2_index_t* index;
|
||||
const ktx2_level_t* levels;
|
||||
|
||||
header = (const ktx_header_t*)(data + KTX_IDENTIFIER_SIZE);
|
||||
index = (const ktx_index_t*)(data + KTX_IDENTIFIER_SIZE + sizeof(ktx_header_t));
|
||||
levels = (const ktx_level_t*)(data + KTX_IDENTIFIER_SIZE + sizeof(ktx_header_t) + sizeof(ktx_index_t));
|
||||
header = (const ktx2_header_t*)(data + KTX2_IDENTIFIER_SIZE);
|
||||
index = (const ktx2_index_t*)(data + KTX2_IDENTIFIER_SIZE + sizeof(ktx2_header_t));
|
||||
levels = (const ktx2_level_t*)(data + KTX2_IDENTIFIER_SIZE + sizeof(ktx2_header_t) + sizeof(ktx2_index_t));
|
||||
|
||||
DEBUG(" header:");
|
||||
#define X(field) DEBUG(" " # field "=%d", header->field);
|
||||
|
@ -938,7 +938,7 @@ static qboolean loadKtx2Raw( vk_texture_t *tex, const rgbdata_t* pic ) {
|
|||
#undef X
|
||||
|
||||
for (int mip = 0; mip < header->levelCount; ++mip) {
|
||||
const ktx_level_t* const level = levels + mip;
|
||||
const ktx2_level_t* const level = levels + mip;
|
||||
DEBUG(" level[%d]:", mip);
|
||||
DEBUG(" byteOffset=%llu", (unsigned long long)level->byteOffset);
|
||||
DEBUG(" byteLength=%llu", (unsigned long long)level->byteLength);
|
||||
|
@ -997,7 +997,7 @@ static qboolean loadKtx2Raw( vk_texture_t *tex, const rgbdata_t* pic ) {
|
|||
// 3. For levels
|
||||
// 3.1 upload
|
||||
for (int mip = 0; mip < header->levelCount; ++mip) {
|
||||
const ktx_level_t* const level = levels + mip;
|
||||
const ktx2_level_t* const level = levels + mip;
|
||||
const uint32_t width = Q_max(1, header->pixelWidth >> mip);
|
||||
const uint32_t height = Q_max(1, header->pixelHeight >> mip);
|
||||
const size_t mip_size = level->byteLength;
|
||||
|
|
Loading…
Reference in New Issue