From ff94974df989c63bc21c05041283b764a960d401 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 4 Dec 2021 14:47:28 -0800 Subject: [PATCH] softgpu: Avoid texlevel check when maxlevel is 0. --- GPU/Software/Sampler.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/GPU/Software/Sampler.cpp b/GPU/Software/Sampler.cpp index bc6982ef14..812c90ae53 100644 --- a/GPU/Software/Sampler.cpp +++ b/GPU/Software/Sampler.cpp @@ -113,10 +113,17 @@ void SamplerJitCache::Clear() { void SamplerJitCache::ComputeSamplerID(SamplerID *id_out, bool linear) { SamplerID id{}; + int maxLevel = gstate.isMipmapEnabled() ? gstate.getTextureMaxLevel() : 0; + for (int i = 0; i <= maxLevel; ++i) { + if (gstate.getTextureAddress(i) == 0) { + id.hasInvalidPtr = true; + } + } + id.texfmt = gstate.getTextureFormat(); id.swizzle = gstate.isTextureSwizzled(); // Only CLUT4 can use separate CLUTs per mimap. - id.useSharedClut = gstate.getTextureFormat() != GE_TFMT_CLUT4 || !gstate.isMipmapEnabled() || gstate.isClutSharedForMipmaps(); + id.useSharedClut = gstate.getTextureFormat() != GE_TFMT_CLUT4 || maxLevel == 0 || !gstate.isMipmapEnabled() || gstate.isClutSharedForMipmaps(); if (gstate.isTextureFormatIndexed()) { id.clutfmt = gstate.getClutPaletteFormat(); id.hasClutMask = gstate.getClutIndexMask() != 0xFF; @@ -124,12 +131,6 @@ void SamplerJitCache::ComputeSamplerID(SamplerID *id_out, bool linear) { id.hasClutOffset = gstate.getClutIndexStartPos() != 0; } id.linear = linear; - int maxLevel = gstate.isMipmapEnabled() ? gstate.getTextureMaxLevel() : 0; - for (int i = 0; i <= maxLevel; ++i) { - if (gstate.getTextureAddress(i) == 0) { - id.hasInvalidPtr = true; - } - } *id_out = id; }