mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 01:29:41 +01:00
Merge pull request #8971 from unknownbrackets/alphatest
Correct alphatest optimization with late texture decode
This commit is contained in:
commit
883b659eff
3 files changed
+18
-9
No files matched your search
@@ -261,6 +261,8 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey,
|
||||
png_image_free(&png);
|
||||
#endif
|
||||
}
|
||||
|
||||
result->alphaStatus_ = ReplacedTextureAlpha::UNKNOWN;
|
||||
}
|
||||
|
||||
#ifndef USING_QT_UI
|
||||
@@ -488,7 +490,9 @@ void ReplacedTexture::Load(int level, void *out, int rowPitch) {
|
||||
bool checkedAlpha = false;
|
||||
if ((png.format & PNG_FORMAT_FLAG_ALPHA) == 0) {
|
||||
// Well, we know for sure it doesn't have alpha.
|
||||
alphaStatus_ = ReplacedTextureAlpha::FULL;
|
||||
if (level == 0) {
|
||||
alphaStatus_ = ReplacedTextureAlpha::FULL;
|
||||
}
|
||||
checkedAlpha = true;
|
||||
}
|
||||
png.format = PNG_FORMAT_RGBA;
|
||||
@@ -498,10 +502,14 @@ void ReplacedTexture::Load(int level, void *out, int rowPitch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (level == 0 && !checkedAlpha) {
|
||||
if (!checkedAlpha) {
|
||||
// This will only check the hashed bits.
|
||||
CheckAlphaResult res = CheckAlphaRGBA8888Basic((u32 *)out, rowPitch / sizeof(u32), png.width, png.height);
|
||||
alphaStatus_ = ReplacedTextureAlpha(res);
|
||||
if (res == CHECKALPHA_ANY || level == 0) {
|
||||
alphaStatus_ = ReplacedTextureAlpha(res);
|
||||
} else if (res == CHECKALPHA_ZERO && alphaStatus_ == ReplacedTextureAlpha::FULL) {
|
||||
alphaStatus_ = ReplacedTextureAlpha(res);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
@@ -306,8 +306,6 @@ void DrawEngineDX9::ApplyDrawStateLate() {
|
||||
// At this point, we know if the vertices are full alpha or not.
|
||||
// TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)?
|
||||
if (!gstate.isModeClear()) {
|
||||
// TODO: Test texture?
|
||||
|
||||
textureCache_->ApplyTexture();
|
||||
|
||||
if (fboTexNeedBind_) {
|
||||
@@ -319,6 +317,8 @@ void DrawEngineDX9::ApplyDrawStateLate() {
|
||||
fboTexBound_ = true;
|
||||
fboTexNeedBind_ = false;
|
||||
}
|
||||
|
||||
// TODO: Test texture?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -373,10 +373,6 @@ void DrawEngineGLES::ApplyDrawStateLate() {
|
||||
// At this point, we know if the vertices are full alpha or not.
|
||||
// TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)?
|
||||
if (!gstate.isModeClear()) {
|
||||
if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) {
|
||||
fragmentTestCache_->BindTestTexture(GL_TEXTURE2);
|
||||
}
|
||||
|
||||
if (fboTexNeedBind_) {
|
||||
// Note that this is positions, not UVs, that we need the copy from.
|
||||
framebufferManager_->BindFramebufferColor(GL_TEXTURE1, gstate.getFrameBufRawAddress(), nullptr, BINDFBCOLOR_MAY_COPY);
|
||||
@@ -394,5 +390,10 @@ void DrawEngineGLES::ApplyDrawStateLate() {
|
||||
// Apply the texture after the FBO tex, since it might unbind the texture.
|
||||
// TODO: Could use a separate texture unit to be safer?
|
||||
textureCache_->ApplyTexture();
|
||||
|
||||
// Apply last, once we know the alpha params of the texture.
|
||||
if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) {
|
||||
fragmentTestCache_->BindTestTexture(GL_TEXTURE2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user