mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 01:33:45 +01:00
Minor code cleanup
This commit is contained in:
1 parent
0bf1d12053
commit
4f925fa5f2
3 files changed
+34
-35
No files matched your search
@@ -385,21 +385,24 @@ void TextureCacheCommon::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutB
|
||||
clutBuf_ = clutBufRaw_;
|
||||
|
||||
// Special optimization: fonts typically draw clut4 with just alpha values in a single color.
|
||||
clutAlphaLinear_ = false;
|
||||
clutAlphaLinearColor_ = 0;
|
||||
bool alphaLinear = false;
|
||||
u16 alphaLinearColor = 0;
|
||||
if (clutFormat == GE_CMODE_16BIT_ABGR4444 && clutIndexIsSimple) {
|
||||
const u16_le *clut = GetCurrentClut<u16_le>();
|
||||
clutAlphaLinear_ = true;
|
||||
clutAlphaLinearColor_ = clut[15] & 0x0FFF;
|
||||
const u16 *clut = (const u16 *)(clutBuf_);
|
||||
alphaLinear = true;
|
||||
alphaLinearColor = clut[15] & 0x0FFF;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
u16 step = clutAlphaLinearColor_ | (i << 12);
|
||||
u16 step = alphaLinearColor | (i << 12);
|
||||
if (clut[i] != step) {
|
||||
clutAlphaLinear_ = false;
|
||||
alphaLinear = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clutProperties_.clutAlphaLinear = alphaLinear;
|
||||
clutProperties_.clutAlphaLinearColor = alphaLinearColor;
|
||||
|
||||
clutLastFormat_ = gstate.clutformat;
|
||||
}
|
||||
|
||||
@@ -1841,23 +1844,23 @@ TextureAlpha TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETex
|
||||
{
|
||||
// The w > 1 check is to not need a case that handles a single pixel
|
||||
// in DeIndexTexture4Optimal<u16>.
|
||||
if (clutAlphaLinear_ && mipmapShareClut && !expandTo32bit && w >= 4) {
|
||||
// We don't bother with fullalpha here (clutAlphaLinear_)
|
||||
if (clutProperties_.clutAlphaLinear && mipmapShareClut && !expandTo32bit && w >= 4) {
|
||||
// We don't bother with fullalpha here (clutAlphaLinear)
|
||||
// Here, reverseColors means the CLUT is already reversed.
|
||||
if (reverseColors) {
|
||||
for (int y = 0; y < h; ++y) {
|
||||
DeIndexTexture4Optimal((u16 *)(out + outPitch * y), texptr + (bufw * y) / 2, w, clutAlphaLinearColor_);
|
||||
DeIndexTexture4Optimal((u16 *)(out + outPitch * y), texptr + (bufw * y) / 2, w, clutProperties_.clutAlphaLinearColor);
|
||||
}
|
||||
} else {
|
||||
for (int y = 0; y < h; ++y) {
|
||||
DeIndexTexture4OptimalRev((u16 *)(out + outPitch * y), texptr + (bufw * y) / 2, w, clutAlphaLinearColor_);
|
||||
DeIndexTexture4OptimalRev((u16 *)(out + outPitch * y), texptr + (bufw * y) / 2, w, clutProperties_.clutAlphaLinearColor);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Need to have the "un-reversed" (raw) CLUT here since we are using a generic conversion function.
|
||||
if (expandTo32bit) {
|
||||
// We simply expand the CLUT to 32-bit, then we deindex as usual. Probably the fastest way.
|
||||
const u16 *clut = GetCurrentRawClut<u16>() + clutSharingOffset;
|
||||
const u16 *clut = (const u16 *)(clutBufRaw_) + clutSharingOffset;
|
||||
const int clutStart = gstate.getClutIndexStartPos();
|
||||
if (gstate.getClutIndexShift() == 0 || gstate.getClutIndexMask() <= 16) {
|
||||
ConvertFormatToRGBA8888(clutformat, expandClut_ + clutStart, clut + clutStart, 16);
|
||||
@@ -1871,7 +1874,7 @@ TextureAlpha TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETex
|
||||
}
|
||||
} else {
|
||||
// If we're reversing colors, the CLUT was already reversed, no special handling needed.
|
||||
const u16 *clut = GetCurrentClut<u16>() + clutSharingOffset;
|
||||
const u16 *clut = (const u16 *)(clutBuf_) + clutSharingOffset;
|
||||
fullAlphaMask = ClutFormatToFullAlpha(clutformat, reverseColors);
|
||||
for (int y = 0; y < h; ++y) {
|
||||
DeIndexTexture4<u16>((u16 *)(out + outPitch * y), texptr + (bufw * y) / 2, w, clut, &alphaSum);
|
||||
@@ -1888,7 +1891,7 @@ TextureAlpha TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETex
|
||||
|
||||
case GE_CMODE_32BIT_ABGR8888:
|
||||
{
|
||||
const u32 *clut = GetCurrentClut<u32>() + clutSharingOffset;
|
||||
const u32 *clut = (const u32 *)(clutBuf_) + clutSharingOffset;
|
||||
fullAlphaMask = 0xFF000000;
|
||||
for (int y = 0; y < h; ++y) {
|
||||
DeIndexTexture4<u32>((u32 *)(out + outPitch * y), texptr + (bufw * y) / 2, w, clut, &alphaSum);
|
||||
|
||||
@@ -247,6 +247,12 @@ struct AttachCandidate {
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
struct CLUTProperties {
|
||||
// True if the clut is just alpha values in the same order (RGBA4444-bit only.)
|
||||
bool clutAlphaLinear = false;
|
||||
u16 clutAlphaLinearColor;
|
||||
};
|
||||
|
||||
class FramebufferManagerCommon;
|
||||
|
||||
struct BuildTexturePlan {
|
||||
@@ -416,16 +422,6 @@ protected:
|
||||
// Return value is mapData normally, but could be another buffer allocated with AllocateAlignedMemory.
|
||||
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, size_t dataSize, int mapRowPitch, BuildTexturePlan &plan, int srcLevel, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags);
|
||||
|
||||
template <typename T>
|
||||
inline const T *GetCurrentClut() {
|
||||
return (const T *)clutBuf_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const T *GetCurrentRawClut() {
|
||||
return (const T *)clutBufRaw_;
|
||||
}
|
||||
|
||||
// These need to be member functions just for IsVideo and Replacer.
|
||||
SamplerCacheKey GetSamplingParams(int maxLevel, const TexCacheEntry *entry, bool flatZ);
|
||||
SamplerCacheKey GetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight);
|
||||
@@ -517,16 +513,14 @@ protected:
|
||||
u32 *clutBufConverted_;
|
||||
// This is the active one.
|
||||
u32 *clutBuf_;
|
||||
|
||||
u32 clutLastFormat_ = 0xFFFFFFFF;
|
||||
u32 clutTotalBytes_ = 0;
|
||||
u32 clutMaxBytes_ = 0;
|
||||
u32 clutRenderAddress_ = 0xFFFFFFFF;
|
||||
u32 clutRenderOffset_;
|
||||
GEBufferFormat clutRenderFormat_;
|
||||
|
||||
// True if the clut is just alpha values in the same order (RGBA4444-bit only.)
|
||||
bool clutAlphaLinear_ = false;
|
||||
u16 clutAlphaLinearColor_;
|
||||
CLUTProperties clutProperties_;
|
||||
|
||||
// Facilities for GPU depal of static textures.
|
||||
Draw::Framebuffer *dynamicClutTemp_ = nullptr;
|
||||
|
||||
@@ -174,20 +174,22 @@ void TextureCacheGLES::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBas
|
||||
}
|
||||
|
||||
// Special optimization: fonts typically draw clut4 with just alpha values in a single color.
|
||||
clutAlphaLinear_ = false;
|
||||
clutAlphaLinearColor_ = 0;
|
||||
bool alphaLinear = false;
|
||||
u16 alphaLinearColor = 0;
|
||||
if (clutFormat == GE_CMODE_16BIT_ABGR4444 && clutIndexIsSimple) {
|
||||
const u16_le *clut = GetCurrentClut<u16_le>();
|
||||
clutAlphaLinear_ = true;
|
||||
clutAlphaLinearColor_ = clut[15] & 0xFFF0;
|
||||
const u16 *clut = (const u16 *)(clutBuf_);
|
||||
alphaLinear = true;
|
||||
alphaLinearColor = clut[15] & 0xFFF0;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
u16 step = clutAlphaLinearColor_ | i;
|
||||
u16 step = alphaLinearColor | i;
|
||||
if (clut[i] != step) {
|
||||
clutAlphaLinear_ = false;
|
||||
alphaLinear = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
clutProperties_.clutAlphaLinear = alphaLinear;
|
||||
clutProperties_.clutAlphaLinearColor = alphaLinearColor;
|
||||
|
||||
clutLastFormat_ = gstate.clutformat;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user