mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 20:37:18 +12:00
Replace Texture::Formats
with PICA::ColorFmt
This enum was a duplicate of the PICA one. Now the PICA one is more complete. Migrate `textureFormatToString` to be next to the enums definition.
This commit is contained in:
parent
5f07f77c94
commit
134e16d8ea
4 changed files with 72 additions and 88 deletions
|
@ -131,16 +131,20 @@ namespace PICA {
|
|||
}
|
||||
|
||||
enum class ColorFmt : u32 {
|
||||
RGBA8 = 0,
|
||||
BGR8 = 1,
|
||||
RGB5A1 = 2,
|
||||
RGB565 = 3,
|
||||
RGBA4 = 4,
|
||||
|
||||
// Technically selectable, but their function is unknown
|
||||
Unknown5 = 5,
|
||||
Unknown6 = 6,
|
||||
Unknown7 = 7,
|
||||
RGBA8 = 0x0,
|
||||
RGB8 = 0x1,
|
||||
RGBA5551 = 0x2,
|
||||
RGB565 = 0x3,
|
||||
RGBA4 = 0x4,
|
||||
IA8 = 0x5,
|
||||
RG8 = 0x6,
|
||||
I8 = 0x7,
|
||||
A8 = 0x8,
|
||||
IA4 = 0x9,
|
||||
I4 = 0xA,
|
||||
A4 = 0xB,
|
||||
ETC1 = 0xC,
|
||||
ETC1A4 = 0xD,
|
||||
};
|
||||
|
||||
enum class DepthFmt : u32 {
|
||||
|
@ -150,6 +154,27 @@ namespace PICA {
|
|||
Depth24Stencil8 = 3,
|
||||
};
|
||||
|
||||
// Returns the string representation of a texture format
|
||||
inline constexpr const char* textureFormatToString(ColorFmt fmt) {
|
||||
switch (fmt) {
|
||||
case ColorFmt::RGBA8: return "RGBA8";
|
||||
case ColorFmt::RGB8: return "RGB8";
|
||||
case ColorFmt::RGBA5551: return "RGBA5551";
|
||||
case ColorFmt::RGB565: return "RGB565";
|
||||
case ColorFmt::RGBA4: return "RGBA4";
|
||||
case ColorFmt::IA8: return "IA8";
|
||||
case ColorFmt::RG8: return "RG8";
|
||||
case ColorFmt::I8: return "I8";
|
||||
case ColorFmt::A8: return "A8";
|
||||
case ColorFmt::IA4: return "IA4";
|
||||
case ColorFmt::I4: return "I4";
|
||||
case ColorFmt::A4: return "A4";
|
||||
case ColorFmt::ETC1: return "ETC1";
|
||||
case ColorFmt::ETC1A4: return "ETC1A4";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr bool hasStencil(DepthFmt format) { return format == PICA::DepthFmt::Depth24Stencil8; }
|
||||
|
||||
// Size occupied by each pixel in bytes
|
||||
|
@ -157,7 +182,7 @@ namespace PICA {
|
|||
// All formats are 16BPP except for RGBA8 (32BPP) and BGR8 (24BPP)
|
||||
inline constexpr usize sizePerPixel(ColorFmt format) {
|
||||
switch (format) {
|
||||
case ColorFmt::BGR8: return 3;
|
||||
case ColorFmt::RGB8: return 3;
|
||||
case ColorFmt::RGBA8: return 4;
|
||||
default: return 2;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include "PICA/regs.hpp"
|
||||
#include "boost/icl/interval.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "opengl.hpp"
|
||||
|
@ -9,28 +10,9 @@ template <typename T>
|
|||
using Interval = boost::icl::right_open_interval<T>;
|
||||
|
||||
struct Texture {
|
||||
enum class Formats : u32 {
|
||||
RGBA8 = 0,
|
||||
RGB8 = 1,
|
||||
RGBA5551 = 2,
|
||||
RGB565 = 3,
|
||||
RGBA4 = 4,
|
||||
IA8 = 5,
|
||||
RG8 = 6,
|
||||
I8 = 7,
|
||||
A8 = 8,
|
||||
IA4 = 9,
|
||||
I4 = 10,
|
||||
A4 = 11,
|
||||
ETC1 = 12,
|
||||
ETC1A4 = 13,
|
||||
|
||||
Trash1 = 14, Trash2 = 15 // TODO: What are these?
|
||||
};
|
||||
|
||||
u32 location;
|
||||
u32 config; // Magnification/minification filter, wrapping configs, etc
|
||||
Formats format;
|
||||
PICA::ColorFmt format;
|
||||
OpenGL::uvec2 size;
|
||||
bool valid;
|
||||
|
||||
|
@ -41,7 +23,7 @@ struct Texture {
|
|||
|
||||
Texture() : valid(false) {}
|
||||
|
||||
Texture(u32 loc, Formats format, u32 x, u32 y, u32 config, bool valid = true)
|
||||
Texture(u32 loc, PICA::ColorFmt format, u32 x, u32 y, u32 config, bool valid = true)
|
||||
: location(loc), format(format), size({x, y}), config(config), valid(valid) {
|
||||
|
||||
u64 endLoc = (u64)loc + sizeInBytes();
|
||||
|
@ -62,7 +44,7 @@ struct Texture {
|
|||
void free();
|
||||
u64 sizeInBytes();
|
||||
|
||||
u32 decodeTexel(u32 u, u32 v, Formats fmt, const void* data);
|
||||
u32 decodeTexel(u32 u, u32 v, PICA::ColorFmt fmt, const void* data);
|
||||
|
||||
// Get the morton interleave offset of a texel based on its U and V values
|
||||
static u32 mortonInterleave(u32 u, u32 v);
|
||||
|
@ -70,12 +52,9 @@ struct Texture {
|
|||
static u32 getSwizzledOffset(u32 u, u32 v, u32 width, u32 bytesPerPixel);
|
||||
static u32 getSwizzledOffset_4bpp(u32 u, u32 v, u32 width);
|
||||
|
||||
// Returns the string representation of a texture format
|
||||
static std::string textureFormatToString(Formats fmt);
|
||||
|
||||
// Returns the format of this texture as a string
|
||||
std::string formatToString() {
|
||||
return textureFormatToString(format);
|
||||
return PICA::textureFormatToString(format);
|
||||
}
|
||||
|
||||
// Returns the texel at coordinates (u, v) of an ETC1(A4) texture
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue