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); void RestoreRenderState(const BPCmd &bp);
u8 *GetPointer(const u32 &address); u8 *GetPointer(const u32 &address);
bool GetConfig(const int &type); bool GetConfig(const int &type);
void SetSamplerState(const BPCmd &bp); void SetTextureMode(const BPCmd &bp);
void SetInterlacingMode(const BPCmd &bp); void SetInterlacingMode(const BPCmd &bp);
}; };

View File

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

View File

@ -243,6 +243,7 @@ void Flush()
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (usedtextures & (1 << i)) { if (usedtextures & (1 << i)) {
Renderer::SetSamplerState(i & 3, i >> 2);
FourTexUnits &tex = bpmem.tex[i >> 2]; FourTexUnits &tex = bpmem.tex[i >> 2];
TextureCache::TCacheEntry* tentry = TextureCache::Load(i, TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5, (tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,

View File

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