mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
revert: remove COLOR_PAL, MippedImgSet, and related changes for future discrete PRs
This commit is contained in:
parent
e4fb4d83fd
commit
4d3ca41cfe
@ -20,7 +20,6 @@ namespace Texture {
|
|||||||
int32_t s_createBlpAsync; // Invented name
|
int32_t s_createBlpAsync; // Invented name
|
||||||
MipBits* s_mipBits;
|
MipBits* s_mipBits;
|
||||||
int32_t s_mipBitsValid;
|
int32_t s_mipBitsValid;
|
||||||
size_t s_mipBitsSize;
|
|
||||||
TSHashTable<CTexture, HASHKEY_TEXTUREFILE> s_textureCache;
|
TSHashTable<CTexture, HASHKEY_TEXTUREFILE> s_textureCache;
|
||||||
|
|
||||||
EGxTexFormat s_pixelFormatToGxTexFormat[10] = {
|
EGxTexFormat s_pixelFormatToGxTexFormat[10] = {
|
||||||
@ -381,28 +380,6 @@ MipBits* TextureAllocMippedImg(PIXEL_FORMAT pixelFormat, uint32_t width, uint32_
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MippedImgSet(MipBits* image, uint32_t fourCC, uint32_t width, uint32_t height) {
|
|
||||||
uint32_t levelCount = CalcLevelCount(width, height);
|
|
||||||
uint32_t levelDataSize = CalcLevelOffset(levelCount, width, height, fourCC);
|
|
||||||
size_t imageSize = (sizeof(MipBits::mip) * levelCount) + levelDataSize + MIPPED_IMG_ALIGN;
|
|
||||||
|
|
||||||
if (Texture::s_mipBitsSize && imageSize > Texture::s_mipBitsSize) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto imageData = reinterpret_cast<char*>(image);
|
|
||||||
auto mipBase = imageData + (sizeof(MipBits::mip) * levelCount);
|
|
||||||
auto alignedMipBase = static_cast<char*>(ALIGN_PTR(mipBase, MIPPED_IMG_ALIGN));
|
|
||||||
|
|
||||||
uint32_t levelOffset = 0;
|
|
||||||
for (int32_t level = 0; level < levelCount; level++) {
|
|
||||||
image->mip[level] = reinterpret_cast<C4Pixel*>(alignedMipBase + levelOffset);
|
|
||||||
levelOffset += CalcLevelSize(level, width, height, fourCC);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxTexUpdate(CGxTex* texId, int32_t minX, int32_t minY, int32_t maxX, int32_t maxY, int32_t immediate) {
|
void GxTexUpdate(CGxTex* texId, int32_t minX, int32_t minY, int32_t maxX, int32_t maxY, int32_t immediate) {
|
||||||
CiRect rect = { minY, minX, maxY, maxX };
|
CiRect rect = { minY, minX, maxY, maxX };
|
||||||
GxTexUpdate(texId, rect, immediate);
|
GxTexUpdate(texId, rect, immediate);
|
||||||
@ -669,11 +646,6 @@ int32_t PumpBlpTextureAsync(CTexture* texture, void* buf) {
|
|||||||
|
|
||||||
GetTextureFormats(&pixFormat, &gxTexFormat, preferredFormat, alphaSize);
|
GetTextureFormats(&pixFormat, &gxTexFormat, preferredFormat, alphaSize);
|
||||||
|
|
||||||
if (image.m_header.colorEncoding == COLOR_PAL) {
|
|
||||||
pixFormat = PIXEL_ARGB8888;
|
|
||||||
gxTexFormat = GxTex_Argb8888;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mipLevel = texture->bestMip;
|
int32_t mipLevel = texture->bestMip;
|
||||||
|
|
||||||
Texture::s_mipBitsValid = 1;
|
Texture::s_mipBitsValid = 1;
|
||||||
@ -1151,7 +1123,6 @@ void TextureIncreasePriority(CTexture* texture) {
|
|||||||
void TextureInitialize() {
|
void TextureInitialize() {
|
||||||
uint32_t v0 = MippedImgCalcSize(2, 1024, 1024);
|
uint32_t v0 = MippedImgCalcSize(2, 1024, 1024);
|
||||||
Texture::s_mipBits = reinterpret_cast<MipBits*>(SMemAlloc(v0, __FILE__, __LINE__, 0));
|
Texture::s_mipBits = reinterpret_cast<MipBits*>(SMemAlloc(v0, __FILE__, __LINE__, 0));
|
||||||
Texture::s_mipBitsSize = v0;
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// - rest of function
|
// - rest of function
|
||||||
|
|||||||
@ -29,67 +29,8 @@ int32_t CBLPFile::Lock2(const char* fileName, PIXEL_FORMAT format, uint32_t mipL
|
|||||||
|
|
||||||
switch (this->m_header.colorEncoding) {
|
switch (this->m_header.colorEncoding) {
|
||||||
case COLOR_PAL:
|
case COLOR_PAL:
|
||||||
if (format != PIXEL_ARGB8888) {
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
uint32_t width = this->m_header.width >> mipLevel;
|
|
||||||
uint32_t height = this->m_header.height >> mipLevel;
|
|
||||||
|
|
||||||
if (!width) {
|
|
||||||
width = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!height) {
|
|
||||||
height = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pixelCount = width * height;
|
|
||||||
auto indices = reinterpret_cast<uint8_t*>(mipData);
|
|
||||||
const uint8_t* alpha = nullptr;
|
|
||||||
|
|
||||||
if (this->m_header.alphaSize) {
|
|
||||||
alpha = indices + pixelCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BlpPalPixel* palette = this->m_header.extended.palette;
|
|
||||||
auto out = reinterpret_cast<uint32_t*>(data);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pixelCount; ++i) {
|
|
||||||
const auto& pal = palette[indices[i]];
|
|
||||||
uint8_t a = 0xFF;
|
|
||||||
|
|
||||||
switch (this->m_header.alphaSize) {
|
|
||||||
case 1: {
|
|
||||||
uint8_t byte = alpha[i >> 3];
|
|
||||||
a = ((byte >> (i & 7)) & 0x1) ? 0xFF : 0x00;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 4: {
|
|
||||||
uint8_t byte = alpha[i >> 1];
|
|
||||||
uint8_t nibble = (i & 1) ? (byte >> 4) : (byte & 0x0F);
|
|
||||||
a = static_cast<uint8_t>((nibble << 4) | nibble);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
a = alpha[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = (static_cast<uint32_t>(a) << 24)
|
|
||||||
| (static_cast<uint32_t>(static_cast<uint8_t>(pal.r)) << 16)
|
|
||||||
| (static_cast<uint32_t>(static_cast<uint8_t>(pal.g)) << 8)
|
|
||||||
| static_cast<uint32_t>(static_cast<uint8_t>(pal.b));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
case COLOR_DXT:
|
case COLOR_DXT:
|
||||||
switch (format) {
|
switch (format) {
|
||||||
@ -155,9 +96,9 @@ int32_t CBLPFile::LockChain2(const char* fileName, PIXEL_FORMAT format, MipBits*
|
|||||||
v14 = 1;
|
v14 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MippedImgSet(images, format, v14, v13)) {
|
|
||||||
return 0;
|
// TODO
|
||||||
}
|
// MippedImgSet(format, v14, v13, mipLevel);
|
||||||
} else {
|
} else {
|
||||||
uint32_t v9 = this->m_header.height >> mipLevel;
|
uint32_t v9 = this->m_header.height >> mipLevel;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user