Skip to content

Commit

Permalink
Don't apply smart 2d texture filter to video.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 18, 2024
1 parent 902b736 commit 103d8b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions GPU/Common/SoftwareTransformCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy

inds = newInds;
}
} else if (throughmode && g_Config.bSmart2DTexFiltering) {
} else if (throughmode && g_Config.bSmart2DTexFiltering && !gstate_c.textureIsVideo) {
// We check some common cases for pixel mapping.
// TODO: It's not really optimal that some previous step has removed the triangle strip.
if (vertexCount <= 6 && prim == GE_PRIM_TRIANGLES) {
Expand Down Expand Up @@ -682,7 +682,7 @@ bool SoftwareTransform::ExpandRectangles(int vertexCount, int &numDecodedVerts,
vscale /= gstate_c.curTextureHeight;
}

bool pixelMapped = g_Config.bSmart2DTexFiltering;
bool pixelMapped = g_Config.bSmart2DTexFiltering && !gstate_c.textureIsVideo;

for (int i = 0; i < vertexCount; i += 2) {
const TransformedVertex &transVtxTL = transformed[indsIn[i + 0]];
Expand Down
5 changes: 5 additions & 0 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
if (!Memory::IsValidAddress(texaddr)) {
// Bind a null texture and return.
Unbind();
gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D(false);
gstate_c.SetTextureIsArray(false);
gstate_c.SetTextureIsFramebuffer(false);
Expand Down Expand Up @@ -569,6 +570,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
// got one!
gstate_c.curTextureWidth = w;
gstate_c.curTextureHeight = h;
gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0);
gstate_c.SetTextureIsArray(false);
gstate_c.SetTextureIsBGRA((entry->status & TexCacheEntry::STATUS_BGRA) != 0);
Expand Down Expand Up @@ -675,6 +677,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {

gstate_c.curTextureWidth = w;
gstate_c.curTextureHeight = h;
gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0);
gstate_c.SetTextureIsArray(false); // Ordinary 2D textures still aren't used by array view in VK. We probably might as well, though, at this point..
gstate_c.SetTextureIsFramebuffer(false);
Expand Down Expand Up @@ -1197,6 +1200,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate)
nextTexture_ = nullptr;
}

gstate_c.SetTextureIsVideo(false);
gstate_c.SetTextureIs3D(false);
gstate_c.SetTextureIsArray(true);

Expand Down Expand Up @@ -2154,6 +2158,7 @@ void TextureCacheCommon::ApplyTexture() {
ForgetLastTexture();
}

gstate_c.SetTextureIsVideo((entry->status & TexCacheEntry::STATUS_VIDEO) != 0);
if (entry->status & TexCacheEntry::STATUS_CLUT_GPU) {
// Special process.
ApplyTextureDepal(entry);
Expand Down
4 changes: 4 additions & 0 deletions GPU/GPUState.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ struct GPUStateCache {
Dirty(DIRTY_FRAGMENTSHADER_STATE);
}
}
void SetTextureIsVideo(bool isVideo) {
textureIsVideo = isVideo;
}
void SetTextureIsBGRA(bool isBGRA) {
if (bgraTexture != isBGRA) {
bgraTexture = isBGRA;
Expand Down Expand Up @@ -657,6 +660,7 @@ struct GPUStateCache {
bool needShaderTexClamp;
bool textureIsArray;
bool textureIsFramebuffer;
bool textureIsVideo;
bool useFlagsChanged;

float morphWeights[8];
Expand Down

0 comments on commit 103d8b1

Please sign in to comment.