mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-14 00:58:51 +02:00
Software: Fix OOB tex coord indices
Previously we set the texture coordinate to zero, now we set the texture coordinate *index* to zero. This fixes the ripple effect of the Mario painting in Luigi's Mansion.
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
@ -559,9 +560,16 @@ void Tev::Draw()
|
|||||||
const int stageNum2 = stageNum >> 1;
|
const int stageNum2 = stageNum >> 1;
|
||||||
const int stageOdd = stageNum & 1;
|
const int stageOdd = stageNum & 1;
|
||||||
|
|
||||||
const u32 texcoordSel = bpmem.tevindref.getTexCoord(stageNum);
|
u32 texcoordSel = bpmem.tevindref.getTexCoord(stageNum);
|
||||||
const u32 texmap = bpmem.tevindref.getTexMap(stageNum);
|
const u32 texmap = bpmem.tevindref.getTexMap(stageNum);
|
||||||
|
|
||||||
|
// Quirk: when the tex coord is not less than the number of tex gens (i.e. the tex coord does
|
||||||
|
// not exist), then tex coord 0 is used (though sometimes glitchy effects happen on console).
|
||||||
|
// This affects the Mario portrait in Luigi's Mansion, where the developers forgot to set
|
||||||
|
// the number of tex gens to 2 (bug 11462).
|
||||||
|
if (texcoordSel >= bpmem.genMode.numtexgens)
|
||||||
|
texcoordSel = 0;
|
||||||
|
|
||||||
const TEXSCALE& texscale = bpmem.texscale[stageNum2];
|
const TEXSCALE& texscale = bpmem.texscale[stageNum2];
|
||||||
const s32 scaleS = stageOdd ? texscale.ss1 : texscale.ss0;
|
const s32 scaleS = stageOdd ? texscale.ss1 : texscale.ss0;
|
||||||
const s32 scaleT = stageOdd ? texscale.ts1 : texscale.ts0;
|
const s32 scaleT = stageOdd ? texscale.ts1 : texscale.ts0;
|
||||||
@ -592,8 +600,13 @@ void Tev::Draw()
|
|||||||
const TevStageCombiner::ColorCombiner& cc = bpmem.combiners[stageNum].colorC;
|
const TevStageCombiner::ColorCombiner& cc = bpmem.combiners[stageNum].colorC;
|
||||||
const TevStageCombiner::AlphaCombiner& ac = bpmem.combiners[stageNum].alphaC;
|
const TevStageCombiner::AlphaCombiner& ac = bpmem.combiners[stageNum].alphaC;
|
||||||
|
|
||||||
const int texcoordSel = order.getTexCoord(stageOdd);
|
u32 texcoordSel = order.getTexCoord(stageOdd);
|
||||||
const int texmap = order.getTexMap(stageOdd);
|
const u32 texmap = order.getTexMap(stageOdd);
|
||||||
|
|
||||||
|
// Quirk: when the tex coord is not less than the number of tex gens (i.e. the tex coord does
|
||||||
|
// not exist), then tex coord 0 is used (though sometimes glitchy effects happen on console).
|
||||||
|
if (texcoordSel >= bpmem.genMode.numtexgens)
|
||||||
|
texcoordSel = 0;
|
||||||
|
|
||||||
Indirect(stageNum, Uv[texcoordSel].s, Uv[texcoordSel].t);
|
Indirect(stageNum, Uv[texcoordSel].s, Uv[texcoordSel].t);
|
||||||
|
|
||||||
@ -603,8 +616,17 @@ void Tev::Draw()
|
|||||||
// RGBA
|
// RGBA
|
||||||
u8 texel[4];
|
u8 texel[4];
|
||||||
|
|
||||||
TextureSampler::Sample(TexCoord.s, TexCoord.t, TextureLod[stageNum], TextureLinear[stageNum],
|
if (bpmem.genMode.numtexgens > 0)
|
||||||
texmap, texel);
|
{
|
||||||
|
TextureSampler::Sample(TexCoord.s, TexCoord.t, TextureLod[stageNum],
|
||||||
|
TextureLinear[stageNum], texmap, texel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// It seems like the result is always black when no tex coords are enabled, but further
|
||||||
|
// hardware testing is needed.
|
||||||
|
std::memset(texel, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
#if ALLOW_TEV_DUMPS
|
#if ALLOW_TEV_DUMPS
|
||||||
if (g_ActiveConfig.bDumpTevTextureFetches)
|
if (g_ActiveConfig.bDumpTevTextureFetches)
|
||||||
|
Reference in New Issue
Block a user