294 return green(format);
504 return alpha(format);
684 return red(format) == -1;
693 const auto a =
alpha(format);
780[[nodiscard]]
constexpr uint16_t
getMipDim(uint8_t mip, uint16_t dim,
bool addCompressedFormatPadding =
false) {
784 for (
int i = 0; i < mip && dim > 1; i++) {
787 if (addCompressedFormatPadding) {
801[[nodiscard]]
constexpr std::pair<uint16_t, uint16_t>
getMipDims(uint8_t mip, uint16_t width, uint16_t height,
bool addCompressedFormatPadding =
false) {
802 for (
int i = 0; i < mip && (width > 1 || height > 1); i++) {
803 if ((width >>= 1) < 1) width = 1;
804 if ((height >>= 1) < 1) height = 1;
806 if (addCompressedFormatPadding) {
810 return {width, height};
822[[nodiscard]]
constexpr std::tuple<uint16_t, uint16_t, uint16_t>
getMipDims(uint8_t mip, uint16_t width, uint16_t height, uint16_t depth,
bool addCompressedFormatPadding =
false) {
823 for (
int i = 0; i < mip && (width > 1 || height > 1 || depth > 1); i++) {
824 if ((width >>= 1) < 1) width = 1;
825 if ((height >>= 1) < 1) height = 1;
826 if ((depth >>= 1) < 1) depth = 1;
828 if (addCompressedFormatPadding) {
832 return {width, height, depth};
844[[nodiscard]]
constexpr uint8_t
getMaximumMipCount(uint16_t width, uint16_t height, uint16_t depth = 1) {
845 uint8_t numMipLevels = 1;
846 if (width && height && depth) {
847 while (width > 1 || height > 1 || depth > 1) {
848 if ((width >>= 1) < 1) width = 1;
849 if ((height >>= 1) < 1) height = 1;
850 if ((depth >>= 1) < 1) depth = 1;
859namespace ImageFormatDetails {
871 return ((width + 3) / 4) * ((height + 3) / 4) * depth *
bpp(format) * 2;
873 return width * height * depth * (
bpp(format) / 8);
888[[nodiscard]]
constexpr uint32_t
getDataLength(
ImageFormat format, uint8_t mipCount, uint16_t frameCount, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t depth = 1) {
890 for (
int i = mipCount - 1; i >= 0; i--) {
913[[nodiscard]]
constexpr uint32_t
getDataLengthXBOX(
bool padded,
ImageFormat format, uint8_t mipCount, uint16_t frameCount, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t depth = 1) {
915 for (
int j = 0; j < frameCount; j++) {
916 for (
int i = 0; i < mipCount; i++) {
920 if (padded && j + 1 != frameCount && length > 512) {
944[[nodiscard]]
constexpr bool getDataPosition(uint32_t& offset, uint32_t& length,
ImageFormat format, uint8_t mip, uint8_t mipCount, uint16_t frame, uint16_t frameCount, uint8_t face, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t slice = 0, uint16_t depth = 1) {
947 for (
int i = mipCount - 1; i >= 0; i--) {
949 for (
int j = 0; j < frameCount; j++) {
950 for (
int k = 0; k < faceCount; k++) {
951 for (
int l = 0; l < mipDepth; l++) {
953 if (i == mip && j == frame && k == face && l == slice) {
986[[nodiscard]]
constexpr bool getDataPositionXBOX(uint32_t& offset, uint32_t& length,
bool padded,
ImageFormat format, uint8_t mip, uint8_t mipCount, uint16_t frame, uint16_t frameCount, uint8_t face, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t slice = 0, uint16_t depth = 1) {
989 for (
int j = 0; j < frameCount; j++) {
990 for (
int k = 0; k < faceCount; k++) {
991 for (
int i = 0; i < mipCount; i++) {
993 for (
int l = 0; l < mipDepth; l++) {
995 if (i == mip && j == frame && k == face && l == slice) {
1003 if (padded && j + 1 != frameCount && offset > 512) {
constexpr uint16_t paddingForAlignment(uint16_t alignment, uint64_t n)
constexpr uint8_t getMaximumMipCount(uint16_t width, uint16_t height, uint16_t depth=1)
Calculate the largest mip count a texture with the given width, height, and depth can contain.
constexpr std::pair< uint16_t, uint16_t > getMipDims(uint8_t mip, uint16_t width, uint16_t height, bool addCompressedFormatPadding=false)
Get the width and height at a given mip level.
constexpr uint16_t getMipDim(uint8_t mip, uint16_t dim, bool addCompressedFormatPadding=false)
Get the dimension at a given mip level.
@ CONSOLE_ARGB8888_LINEAR
@ CONSOLE_BGRX8888_LINEAR
@ CONSOLE_RGBA8888_LINEAR
@ CONSOLE_ABGR8888_LINEAR
@ CONSOLE_BGRX5551_LINEAR
@ CONSOLE_BGRA8888_LINEAR
@ CONSOLE_RGBA16161616_LINEAR