D3D: Fix some texture wrapping issues by setting the texture state for every texture used at draw time. Hopefully there will not be a noticable slowdown, thanks to the state caching. Also some minor cleanup. Should fix issues like repeated shadows. TODO: In theory it should have worked without this, so I should investigate why this change was needed.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4815 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2010-01-12 23:40:30 +00:00
parent 4172928b14
commit a81efdb597
6 changed files with 19 additions and 64 deletions

View File

@ -50,7 +50,7 @@ void ClearScreen(const BPCmd &bp, const EFBRectangle &rc);
void RestoreRenderState(const BPCmd &bp);
u8 *GetPointer(const u32 &address);
bool GetConfig(const int &type);
void SetSamplerState(const BPCmd &bp);
void SetTextureMode(const BPCmd &bp);
void SetInterlacingMode(const BPCmd &bp);
};

View File

@ -430,13 +430,7 @@ void BPWritten(const BPCmd& bp)
// Texture Environment Order
// -------------------------
case BPMEM_TREF:
case BPMEM_TREF+1:
case BPMEM_TREF+2:
case BPMEM_TREF+3:
case BPMEM_TREF+4:
case BPMEM_TREF+5:
case BPMEM_TREF+6:
case BPMEM_TREF+7:
break;
// ----------------------
// Set wrap size
@ -464,22 +458,13 @@ void BPWritten(const BPCmd& bp)
// BPMEM_TX_SETMODE1 - (LOD Stuff) - Max LOD, Min LOD
// ------------------------
case BPMEM_TX_SETMODE0: // (0x90 for linear)
case BPMEM_TX_SETMODE0+1:
case BPMEM_TX_SETMODE0+2:
case BPMEM_TX_SETMODE0+3:
SetSamplerState(bp);
case BPMEM_TX_SETMODE1:
case BPMEM_TX_SETMODE1+1:
case BPMEM_TX_SETMODE1+2:
case BPMEM_TX_SETMODE1+3:
case BPMEM_TX_SETMODE0_4:
case BPMEM_TX_SETMODE0_4+1:
case BPMEM_TX_SETMODE0_4+2:
case BPMEM_TX_SETMODE0_4+3:
// Shouldn't need to call this here, we call it for each active texture right before rendering
SetTextureMode(bp);
break;
case BPMEM_TX_SETMODE1:
case BPMEM_TX_SETMODE1_4:
case BPMEM_TX_SETMODE1_4+1:
case BPMEM_TX_SETMODE1_4+2:
case BPMEM_TX_SETMODE1_4+3:
break;
// --------------------------------------------
// BPMEM_TX_SETIMAGE0 - Texture width, height, format
@ -488,51 +473,22 @@ void BPWritten(const BPCmd& bp)
// BPMEM_TX_SETIMAGE3 - Address of Texture in main memory
// --------------------------------------------
case BPMEM_TX_SETIMAGE0:
case BPMEM_TX_SETIMAGE0+1:
case BPMEM_TX_SETIMAGE0+2:
case BPMEM_TX_SETIMAGE0+3:
case BPMEM_TX_SETIMAGE0_4:
case BPMEM_TX_SETIMAGE0_4+1:
case BPMEM_TX_SETIMAGE0_4+2:
case BPMEM_TX_SETIMAGE0_4+3:
case BPMEM_TX_SETIMAGE1:
case BPMEM_TX_SETIMAGE1+1:
case BPMEM_TX_SETIMAGE1+2:
case BPMEM_TX_SETIMAGE1+3:
case BPMEM_TX_SETIMAGE1_4:
case BPMEM_TX_SETIMAGE1_4+1:
case BPMEM_TX_SETIMAGE1_4+2:
case BPMEM_TX_SETIMAGE1_4+3:
case BPMEM_TX_SETIMAGE2:
case BPMEM_TX_SETIMAGE2+1:
case BPMEM_TX_SETIMAGE2+2:
case BPMEM_TX_SETIMAGE2+3:
case BPMEM_TX_SETIMAGE2_4:
case BPMEM_TX_SETIMAGE2_4+1:
case BPMEM_TX_SETIMAGE2_4+2:
case BPMEM_TX_SETIMAGE2_4+3:
case BPMEM_TX_SETIMAGE3:
case BPMEM_TX_SETIMAGE3+1:
case BPMEM_TX_SETIMAGE3+2:
case BPMEM_TX_SETIMAGE3+3:
case BPMEM_TX_SETIMAGE3_4:
case BPMEM_TX_SETIMAGE3_4+1:
case BPMEM_TX_SETIMAGE3_4+2:
case BPMEM_TX_SETIMAGE3_4+3:
break;
// -------------------------------
// Set a TLUT
// BPMEM_TX_SETTLUT - Format, TMEM Offset (offset of TLUT from start of TMEM high bank > > 5)
// -------------------------------
case BPMEM_TX_SETTLUT:
case BPMEM_TX_SETTLUT+1:
case BPMEM_TX_SETTLUT+2:
case BPMEM_TX_SETTLUT+3:
case BPMEM_TX_SETLUT_4:
case BPMEM_TX_SETLUT_4+1:
case BPMEM_TX_SETLUT_4+2:
case BPMEM_TX_SETLUT_4+3:
break;
// ---------------------------------------------------
// Set the TEV Color
// ---------------------------------------------------
@ -544,15 +500,14 @@ void BPWritten(const BPCmd& bp)
case BPMEM_TEV_REGISTER_H+4:
case BPMEM_TEV_REGISTER_L+6: // Reg 4
case BPMEM_TEV_REGISTER_H+6:
if (bp.address & 1) // only run this code for the _H! is this right? what if L is set independently?
{
if (bp.address & 1)
{
// don't compare with changes!
int num = (bp.address >> 1 ) & 0x3;
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
}
break;
// don't compare with changes!
int num = (bp.address >> 1) & 0x3;
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
}
break;
// ------------------------------------------------
// On Default, we try to look for other things
// before we give up and say its an unknown opcode

View File

@ -140,10 +140,9 @@ u8 *GetPointer(const u32 &address)
return g_VideoInitialize.pGetMemoryPointer(address);
}
void SetSamplerState(const BPCmd &bp)
void SetTextureMode(const BPCmd &bp)
{
int stage = (bp.address & 3);//(addr>>4)&2;
Renderer::SetSamplerState(stage,(bp.address & 0xE0) == 0xA0);
Renderer::SetSamplerState(bp.address & 3, (bp.address & 0xE0) == 0xA0);
}
void SetInterlacingMode(const BPCmd &bp)

View File

@ -1059,7 +1059,7 @@ void Renderer::SetLineWidth()
D3D::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
}
void Renderer::SetSamplerState(int stage,int texindex)
void Renderer::SetSamplerState(int stage, int texindex)
{
const FourTexUnits &tex = bpmem.tex[texindex];
const TexMode0 &tm0 = tex.texMode0[stage];

View File

@ -243,10 +243,11 @@ void Flush()
for (int i = 0; i < 8; i++)
{
if (usedtextures & (1 << i)) {
Renderer::SetSamplerState(i & 3, i >> 2);
FourTexUnits &tex = bpmem.tex[i >> 2];
TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
tex.texImage0[i&3].width+1, tex.texImage0[i&3].height+1,
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
tex.texTlut[i&3].tlut_format);

View File

@ -129,7 +129,7 @@ u8 *GetPointer(const u32 &address)
return g_VideoInitialize.pGetMemoryPointer(address);
}
void SetSamplerState(const BPCmd &bp)
void SetTextureMode(const BPCmd &bp)
{
// TODO
}