mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-05 04:03:49 +01:00
Rearrange the texture status flags, rename Full alpha to Solid alpha for textures
This commit is contained in:
1 parent
ec6c7b08f5
commit
7ced074154
7 files changed
+42
-46
No files matched your search
@@ -74,7 +74,7 @@ bool IsAlphaTestTriviallyTrue() {
|
||||
return true;
|
||||
|
||||
case GE_COMP_GEQUAL:
|
||||
if (gstate_c.vertexFullAlpha && (gstate_c.textureFullAlpha || !gstate.isTextureAlphaUsed()))
|
||||
if (gstate_c.vertexFullAlpha && (gstate_c.textureSolidAlpha || !gstate.isTextureAlphaUsed()))
|
||||
return true; // If alpha is full, it doesn't matter what the ref value is.
|
||||
return gstate.getAlphaTestRef() == 0;
|
||||
|
||||
@@ -91,7 +91,7 @@ bool IsAlphaTestTriviallyTrue() {
|
||||
case GE_COMP_GREATER:
|
||||
{
|
||||
// If the texture and vertex only use 1.0 alpha, then the ref value doesn't matter.
|
||||
if (gstate_c.vertexFullAlpha && (gstate_c.textureFullAlpha || !gstate.isTextureAlphaUsed()))
|
||||
if (gstate_c.vertexFullAlpha && (gstate_c.textureSolidAlpha || !gstate.isTextureAlphaUsed()))
|
||||
return true;
|
||||
return gstate.getAlphaTestRef() == 0 && !NeedsTestDiscard();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool useBuffe
|
||||
|
||||
if (dirtyUniforms & DIRTY_TEX_ALPHA_MUL) {
|
||||
bool doTextureAlpha = gstate.isTextureAlphaUsed();
|
||||
if (gstate_c.textureFullAlpha && gstate.getTextureFunction() != GE_TEXFUNC_REPLACE) {
|
||||
if (gstate_c.textureSolidAlpha && gstate.getTextureFunction() != GE_TEXFUNC_REPLACE) {
|
||||
doTextureAlpha = false;
|
||||
}
|
||||
ub->texNoAlpha = doTextureAlpha ? 0.0f : 1.0f;
|
||||
|
||||
@@ -2205,7 +2205,7 @@ void TextureCacheCommon::ApplyTexture(bool doBind, bool flatZ) {
|
||||
// Special process.
|
||||
ApplyTextureDepal(entry);
|
||||
entry->lastFrame = gpuStats.totals.numFlips;
|
||||
gstate_c.SetTextureFullAlpha(false);
|
||||
gstate_c.SetTextureSolidAlpha(false);
|
||||
gstate_c.SetTextureIs3D(false);
|
||||
gstate_c.SetTextureIsArray(false);
|
||||
gstate_c.SetTextureIsBGRA(false);
|
||||
@@ -2214,7 +2214,7 @@ void TextureCacheCommon::ApplyTexture(bool doBind, bool flatZ) {
|
||||
if (doBind) {
|
||||
BindTexture(entry, flatZ);
|
||||
}
|
||||
gstate_c.SetTextureFullAlpha(entry->GetAlphaStatus() == TextureAlpha::Solid);
|
||||
gstate_c.SetTextureSolidAlpha((entry->status & TexCacheEntry::STATUS_ALPHA_SOLID) != 0);
|
||||
gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0);
|
||||
gstate_c.SetTextureIsArray(false);
|
||||
gstate_c.SetTextureIsBGRA((entry->status & TexCacheEntry::STATUS_BGRA) != 0);
|
||||
@@ -2360,7 +2360,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16);
|
||||
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
||||
TextureAlpha alphaStatus = CheckCLUTAlpha((const uint8_t *)clutBufRaw_, clutFormat, clutTotalColors);
|
||||
gstate_c.SetTextureFullAlpha(alphaStatus == TextureAlpha::Solid);
|
||||
gstate_c.SetTextureSolidAlpha(alphaStatus == TextureAlpha::Solid);
|
||||
|
||||
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);
|
||||
return;
|
||||
@@ -2435,7 +2435,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
||||
|
||||
TextureAlpha alphaStatus = CheckCLUTAlpha((const uint8_t *)clutBufRaw_, clutFormat, clutTotalColors);
|
||||
gstate_c.SetTextureFullAlpha(alphaStatus == TextureAlpha::Solid);
|
||||
gstate_c.SetTextureSolidAlpha(alphaStatus == TextureAlpha::Solid);
|
||||
|
||||
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);
|
||||
shaderManager_->DirtyLastShader();
|
||||
@@ -2445,7 +2445,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
BoundFramebufferTexture();
|
||||
|
||||
gstate_c.SetUseShaderDepal(ShaderDepalMode::OFF);
|
||||
gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
gstate_c.SetTextureSolidAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
}
|
||||
|
||||
SamplerCacheKey samplerKey = GetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight);
|
||||
@@ -2537,7 +2537,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) {
|
||||
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
||||
|
||||
// We don't know about alpha at all.
|
||||
gstate_c.SetTextureFullAlpha(false);
|
||||
gstate_c.SetTextureSolidAlpha(false);
|
||||
|
||||
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);
|
||||
shaderManager_->DirtyLastShader();
|
||||
@@ -3005,7 +3005,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
|
||||
}
|
||||
|
||||
// Will be filled in again during decode.
|
||||
entry->status &= ~TexCacheEntry::STATUS_ALPHA_MASK;
|
||||
entry->SetAlphaStatus(TextureAlpha::Any);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3111,8 +3111,8 @@ const char *TexHashStatusToString(TexHashStatus status) {
|
||||
|
||||
std::string TexStatusToString(TexCacheEntry::TexStatus status) {
|
||||
std::string result;
|
||||
if (status & TexCacheEntry::STATUS_ALPHA_MASK) {
|
||||
result += "ALPHA";
|
||||
if (status & TexCacheEntry::STATUS_ALPHA_SOLID) {
|
||||
result += "SOLID_ALPHA ";
|
||||
}
|
||||
if (status & TexCacheEntry::STATUS_CLUT_VARIANTS) {
|
||||
result += "CLUTVARIANTS ";
|
||||
|
||||
@@ -147,33 +147,25 @@ struct TexCacheEntry {
|
||||
const static int FRAMES_REGAIN_TRUST = 1000;
|
||||
|
||||
enum TexStatus {
|
||||
STATUS_ALPHA_UNKNOWN = 0x04,
|
||||
STATUS_ALPHA_FULL = 0x00, // Has no alpha channel, or always full alpha.
|
||||
STATUS_ALPHA_MASK = 0x04,
|
||||
STATUS_VIDEO = (1 << 0),
|
||||
STATUS_BGRA = (1 << 1),
|
||||
STATUS_ALPHA_SOLID = (1 << 2), // Has no alpha channel, or always solid (==1.0) alpha.
|
||||
|
||||
STATUS_CLUT_VARIANTS = 0x08, // Has multiple CLUT variants.
|
||||
STATUS_CHANGE_FREQUENT = 0x10, // Changes often (less than 6 frames in between.)
|
||||
STATUS_CLUT_RECHECK = 0x20, // Another texture with same addr had a hashfail.
|
||||
STATUS_TO_SCALE = 0x80, // Pending texture scaling in a later frame.
|
||||
STATUS_IS_SCALED_OR_REPLACED = 0x100, // Has been scaled already (ignored for replacement checks).
|
||||
STATUS_TO_REPLACE = 0x0200, // Pending texture replacement.
|
||||
STATUS_CLUT_VARIANTS = (1 << 3), // Has multiple CLUT variants.
|
||||
STATUS_CHANGE_FREQUENT = (1 << 4), // Changes often (less than 6 frames in between.)
|
||||
STATUS_CLUT_RECHECK = (1 << 5), // Another texture with same addr had a hashfail.
|
||||
STATUS_TO_SCALE = (1 << 7), // Pending texture scaling in a later frame.
|
||||
STATUS_IS_SCALED_OR_REPLACED = (1 << 8), // Has been scaled already (ignored for replacement checks).
|
||||
STATUS_TO_REPLACE = (1 << 9), // Pending texture replacement.
|
||||
// When hashing large textures, we optimize 512x512 down to 512x272 by default, since this
|
||||
// is commonly the only part accessed. If access is made above 272, we hash the entire
|
||||
// texture, and set this flag to allow scaling the texture just once for the new hash.
|
||||
STATUS_FREE_CHANGE = 0x0400, // Allow one change before marking "frequent".
|
||||
|
||||
STATUS_NO_MIPS = 0x0800, // Has bad or unusable mipmap levels.
|
||||
|
||||
STATUS_FRAMEBUFFER_OVERLAP = 0x1000,
|
||||
|
||||
STATUS_FORCE_REBUILD = 0x2000,
|
||||
|
||||
STATUS_3D = 0x4000,
|
||||
|
||||
STATUS_CLUT_GPU = 0x8000,
|
||||
|
||||
STATUS_VIDEO = 0x10000,
|
||||
STATUS_BGRA = 0x20000,
|
||||
STATUS_FREE_CHANGE = (1 << 10), // Allow one change before marking "frequent".
|
||||
STATUS_NO_MIPS = (1 << 11), // Has bad or unusable mipmap levels.
|
||||
STATUS_FRAMEBUFFER_OVERLAP = (1 << 12),
|
||||
STATUS_FORCE_REBUILD = (1 << 13),
|
||||
STATUS_3D = (1 << 14),
|
||||
STATUS_CLUT_GPU = (1 << 15),
|
||||
};
|
||||
|
||||
// TexStatus enum flag combination.
|
||||
@@ -206,10 +198,14 @@ struct TexCacheEntry {
|
||||
ReplacedTexture *replacedTexture;
|
||||
|
||||
TextureAlpha GetAlphaStatus() {
|
||||
return (status & STATUS_ALPHA_MASK) == STATUS_ALPHA_FULL ? TextureAlpha::Solid : TextureAlpha::Any;
|
||||
return (status & STATUS_ALPHA_SOLID) ? TextureAlpha::Solid : TextureAlpha::Any;
|
||||
}
|
||||
void SetAlphaStatus(TextureAlpha newStatus) {
|
||||
status = (status & ~STATUS_ALPHA_MASK) | (newStatus == TextureAlpha::Solid ? STATUS_ALPHA_FULL : STATUS_ALPHA_UNKNOWN);
|
||||
if (newStatus == TextureAlpha::Solid) {
|
||||
status |= STATUS_ALPHA_SOLID;
|
||||
} else {
|
||||
status &= ~STATUS_ALPHA_SOLID;
|
||||
}
|
||||
}
|
||||
void SetAlphaStatus(TextureAlpha newStatus, int level) {
|
||||
// For non-level zero, only set more restrictive.
|
||||
|
||||
@@ -336,7 +336,7 @@ static inline bool GuessVRDrawingHUD(bool is2D, bool flatScreen) {
|
||||
//HUD texture cannot be in CLUT32 format
|
||||
else if (gstate.getTextureFormat() == GETextureFormat::GE_TFMT_CLUT32) hud = false;
|
||||
//HUD cannot have full texture alpha
|
||||
else if (gstate_c.textureFullAlpha && gstate.getTextureFormat() != GETextureFormat::GE_TFMT_CLUT4) hud = false;
|
||||
else if (gstate_c.textureSolidAlpha && gstate.getTextureFormat() != GETextureFormat::GE_TFMT_CLUT4) hud = false;
|
||||
//HUD must have full vertex alpha
|
||||
else if (!gstate_c.vertexFullAlpha && gstate.getDepthTestFunction() == GE_COMP_NEVER) hud = false;
|
||||
//HUD cannot render FB screenshot
|
||||
@@ -428,7 +428,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc
|
||||
}
|
||||
if (dirty & DIRTY_TEX_ALPHA_MUL) {
|
||||
bool doTextureAlpha = gstate.isTextureAlphaUsed();
|
||||
if (gstate_c.textureFullAlpha && gstate.getTextureFunction() != GE_TEXFUNC_REPLACE) {
|
||||
if (gstate_c.textureSolidAlpha && gstate.getTextureFunction() != GE_TEXFUNC_REPLACE) {
|
||||
doTextureAlpha = false;
|
||||
}
|
||||
float noAlphaMul[2] = { doTextureAlpha ? 0.0f : 1.0f, gstate.isColorDoublingEnabled() ? 2.0f : 1.0f };
|
||||
|
||||
+3
-3
@@ -256,7 +256,7 @@ struct GPUStateCache_v0 {
|
||||
u32 offsetAddr;
|
||||
|
||||
bool textureChanged;
|
||||
bool textureFullAlpha;
|
||||
bool textureSolidAlpha;
|
||||
bool vertexFullAlpha;
|
||||
bool framebufChanged;
|
||||
|
||||
@@ -281,7 +281,7 @@ void GPUStateCache::DoState(PointerWrap &p) {
|
||||
indexAddr = old.indexAddr;
|
||||
offsetAddr = old.offsetAddr;
|
||||
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
|
||||
textureFullAlpha = old.textureFullAlpha;
|
||||
textureSolidAlpha = old.textureSolidAlpha;
|
||||
vertexFullAlpha = old.vertexFullAlpha;
|
||||
skipDrawReason = old.skipDrawReason;
|
||||
uv = old.uv;
|
||||
@@ -295,7 +295,7 @@ void GPUStateCache::DoState(PointerWrap &p) {
|
||||
uint8_t textureChanged = 0;
|
||||
Do(p, textureChanged); // legacy
|
||||
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
|
||||
Do(p, textureFullAlpha);
|
||||
Do(p, textureSolidAlpha);
|
||||
Do(p, vertexFullAlpha);
|
||||
bool framebufChanged = false; // legacy
|
||||
Do(p, framebufChanged);
|
||||
|
||||
+4
-4
@@ -546,9 +546,9 @@ struct GPUStateCache {
|
||||
Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
}
|
||||
void SetTextureFullAlpha(bool fullAlpha) {
|
||||
if (fullAlpha != textureFullAlpha) {
|
||||
textureFullAlpha = fullAlpha;
|
||||
void SetTextureSolidAlpha(bool solidAlpha) {
|
||||
if (solidAlpha != textureSolidAlpha) {
|
||||
textureSolidAlpha = solidAlpha;
|
||||
Dirty(DIRTY_FRAGMENTSHADER_STATE | DIRTY_TEX_ALPHA_MUL);
|
||||
}
|
||||
}
|
||||
@@ -626,7 +626,7 @@ public:
|
||||
bool usingDepth; // For deferred depth copies.
|
||||
bool clearingDepth;
|
||||
|
||||
bool textureFullAlpha;
|
||||
bool textureSolidAlpha;
|
||||
bool vertexFullAlpha;
|
||||
|
||||
int skipDrawReason;
|
||||
|
||||
Reference in new issue
Block a user