mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-15 07:11:20 +00:00
CTextureBoo: Make use of anonymous namespace
Makes some helper functions have internal linkage, silencing some -Wmissing-declarations warnings, and also allows preventing ODR violations from ever occurring with the RGBA8 and DXT1Block structs.
This commit is contained in:
parent
bfbb027117
commit
fee8d91dca
@ -7,28 +7,43 @@
|
|||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
static logvisor::Module Log("urde::CTextureBoo");
|
namespace {
|
||||||
|
logvisor::Module Log("urde::CTextureBoo");
|
||||||
|
|
||||||
|
struct RGBA8 {
|
||||||
|
u8 r;
|
||||||
|
u8 g;
|
||||||
|
u8 b;
|
||||||
|
u8 a;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DXT1Block {
|
||||||
|
u16 color1;
|
||||||
|
u16 color2;
|
||||||
|
u8 lines[4];
|
||||||
|
};
|
||||||
|
|
||||||
/* GX uses this upsampling technique to extract full 8-bit range */
|
/* GX uses this upsampling technique to extract full 8-bit range */
|
||||||
constexpr uint8_t Convert3To8(uint8_t v) {
|
constexpr u8 Convert3To8(u8 v) {
|
||||||
/* Swizzle bits: 00000123 -> 12312312 */
|
/* Swizzle bits: 00000123 -> 12312312 */
|
||||||
return (v << 5) | (v << 2) | (v >> 1);
|
return (v << 5) | (v << 2) | (v >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint8_t Convert4To8(uint8_t v) {
|
constexpr u8 Convert4To8(u8 v) {
|
||||||
/* Swizzle bits: 00001234 -> 12341234 */
|
/* Swizzle bits: 00001234 -> 12341234 */
|
||||||
return (v << 4) | v;
|
return (v << 4) | v;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint8_t Convert5To8(uint8_t v) {
|
constexpr u8 Convert5To8(u8 v) {
|
||||||
/* Swizzle bits: 00012345 -> 12345123 */
|
/* Swizzle bits: 00012345 -> 12345123 */
|
||||||
return (v << 3) | (v >> 2);
|
return (v << 3) | (v >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint8_t Convert6To8(uint8_t v) {
|
constexpr u8 Convert6To8(u8 v) {
|
||||||
/* Swizzle bits: 00123456 -> 12345612 */
|
/* Swizzle bits: 00123456 -> 12345612 */
|
||||||
return (v << 2) | (v >> 4);
|
return (v << 2) | (v >> 4);
|
||||||
}
|
}
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
size_t CTexture::ComputeMippedTexelCount() const {
|
size_t CTexture::ComputeMippedTexelCount() const {
|
||||||
size_t w = x4_w;
|
size_t w = x4_w;
|
||||||
@ -58,13 +73,6 @@ size_t CTexture::ComputeMippedBlockCountDXT1() const {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RGBA8 {
|
|
||||||
u8 r;
|
|
||||||
u8 g;
|
|
||||||
u8 b;
|
|
||||||
u8 a;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CTexture::BuildI4FromGCN(CInputStream& in) {
|
void CTexture::BuildI4FromGCN(CInputStream& in) {
|
||||||
size_t texelCount = ComputeMippedTexelCount();
|
size_t texelCount = ComputeMippedTexelCount();
|
||||||
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
std::unique_ptr<RGBA8[]> buf(new RGBA8[texelCount]);
|
||||||
@ -492,12 +500,6 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in) {
|
|||||||
} BooTrace);
|
} BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DXT1Block {
|
|
||||||
uint16_t color1;
|
|
||||||
uint16_t color2;
|
|
||||||
uint8_t lines[4];
|
|
||||||
};
|
|
||||||
|
|
||||||
void CTexture::BuildDXT1FromGCN(CInputStream& in) {
|
void CTexture::BuildDXT1FromGCN(CInputStream& in) {
|
||||||
size_t blockCount = ComputeMippedBlockCountDXT1();
|
size_t blockCount = ComputeMippedBlockCountDXT1();
|
||||||
std::unique_ptr<DXT1Block[]> buf(new DXT1Block[blockCount]);
|
std::unique_ptr<DXT1Block[]> buf(new DXT1Block[blockCount]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user