/* -*- tab-width: 4; -*- */1/* vi: set sw=2 ts=4 expandtab textwidth=70: */23/*4* Copyright 2019-2020 The Khronos Group Inc.5* SPDX-License-Identifier: Apache-2.06*/78/**9* @internal10* @file basisu_sgd.h11* @~English12*13* @brief Declare global data for Basis LZ supercompression with ETC1S.14*15* These functions are private and should not be used outside the library.16*/1718#ifndef _BASIS_SGD_H_19#define _BASIS_SGD_H_2021#include <stdint.h>2223#ifdef __cplusplus24extern "C" {25#endif2627// This must be the same value as cSliceDescFlagsFrameIsIFrame so we can just28// invert the bit when passing back & forth. As FrameIsIFrame is within29// a C namespace it can't easily be accessed from a c header.30enum bu_image_flags__bits_e { ETC1S_P_FRAME = 0x02 };3132typedef uint32_t buFlags;3334typedef struct ktxBasisLzGlobalHeader {35uint16_t endpointCount;36uint16_t selectorCount;37uint32_t endpointsByteLength;38uint32_t selectorsByteLength;39uint32_t tablesByteLength;40uint32_t extendedByteLength;41} ktxBasisLzGlobalHeader;4243// This header is followed by imageCount "slice" descriptions.4445// 1, or 2 slices per image (i.e. layer, face & slice).46// These offsets are relative to start of a mip level as given by the47// main levelIndex.48typedef struct ktxBasisLzEtc1sImageDesc {49buFlags imageFlags;50uint32_t rgbSliceByteOffset;51uint32_t rgbSliceByteLength;52uint32_t alphaSliceByteOffset;53uint32_t alphaSliceByteLength;54} ktxBasisLzEtc1sImageDesc;5556#define BGD_ETC1S_IMAGE_DESCS(bgd) \57reinterpret_cast<ktxBasisLzEtc1sImageDesc*>(bgd + sizeof(ktxBasisLzGlobalHeader))5859// The are followed in the global data by these ...60// uint8_t[endpointsByteLength] endpointsData;61// uint8_t[selectorsByteLength] selectorsData;62// uint8_t[tablesByteLength] tablesData;6364#define BGD_ENDPOINTS_ADDR(bgd, imageCount) \65(bgd + sizeof(ktxBasisLzGlobalHeader) + sizeof(ktxBasisLzEtc1sImageDesc) * imageCount)6667#define BGD_SELECTORS_ADDR(bgd, bgdh, imageCount) (BGD_ENDPOINTS_ADDR(bgd, imageCount) + bgdh.endpointsByteLength)6869#define BGD_TABLES_ADDR(bgd, bgdh, imageCount) (BGD_SELECTORS_ADDR(bgd, bgdh, imageCount) + bgdh.selectorsByteLength)7071#define BGD_EXTENDED_ADDR(bgd, bgdh, imageCount) (BGD_TABLES_ADDR(bgd, bgdh, imageCount) + bgdh.tablesByteLength)7273// Just because this is a convenient place to put it for basis_{en,trans}code.74enum alpha_content_e {75eNone,76eAlpha,77eGreen78};7980#ifdef __cplusplus81}82#endif8384#endif /* _BASIS_SGD_H_ */858687