GSdx: couple of fixes

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1447 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gabest11 2009-07-01 21:14:12 +00:00
parent 57066d229b
commit 5a292d202d
18 changed files with 181 additions and 85 deletions

View File

@ -32,6 +32,7 @@ CRC::Game CRC::m_games[] =
{0xDDB59F46, KyuuketsuKitanMoonties, JP, PointListPalette},
{0xC8EE2562, PiaCarroteYoukosoGPGakuenPrincess, JP, PointListPalette},
{0x6CF94A43, KazokuKeikakuKokoroNoKizuna, JP, PointListPalette},
{0xEDAF602D, DuelSaviorDestiny, JP, PointListPalette},
{0xa39517ab, FFX, EU, 0},
{0xa39517ae, FFX, FR, 0},
{0x941bb7d9, FFX, DE, 0},
@ -133,12 +134,13 @@ CRC::Game CRC::m_games[] =
{0x6BF11378, Onimusha3, US, 0},
{0xF442260C, MajokkoALaMode2, JP, 0},
{0x14FE77F7, TalesOfAbyss, US, 0},
{0x045D77E9, TalesOfAbyss, US, 0}, // undub
{0x045D77E9, TalesOfAbyss, JPUNDUB, 0},
{0xAA5EC3A3, TalesOfAbyss, JP, 0},
{0xFB236A46, SonicUnleashed, US, 0},
{0x4C7BB3C8, SimpsonsGame, Unknown, 0},
{0x4C94B32C, SimpsonsGame, Unknown, 0},
{0xD71B57F4, Genji, Unknown, 0},
{0x23A97857, StarOcean3, JPUNDUB, 0},
};
hash_map<uint32, CRC::Game*> CRC::m_map;

View File

@ -34,6 +34,7 @@ public:
KyuuketsuKitanMoonties,
PiaCarroteYoukosoGPGakuenPrincess,
KazokuKeikakuKokoroNoKizuna,
DuelSaviorDestiny,
FFX,
FFX2,
FFXII,
@ -70,6 +71,7 @@ public:
SonicUnleashed,
SimpsonsGame,
Genji,
StarOcean3,
TitleCount,
};

View File

@ -502,7 +502,6 @@ GSTexture* GSDevice9::CreateRenderTarget(int w, int h, int format)
GSTexture* GSDevice9::CreateDepthStencil(int w, int h, int format)
{
return __super::CreateDepthStencil(w, h, format ? format : D3DFMT_D24S8);
// return __super::CreateDepthStencil(w, h, format ? format : D3DFMT_D32F_LOCKABLE);
}
GSTexture* GSDevice9::CreateTexture(int w, int h, int format)

View File

@ -195,18 +195,25 @@ public:
ps_cb.FogColor_AREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, (int)context->TEST.AREF) / 255;
if(ps_sel.atst == 2 || ps_sel.atst == 5)
if(ps_sel.atst == ATST_LESS || ps_sel.atst == ATST_GEQUAL)
{
ps_cb.FogColor_AREF.a -= 0.9f / 255;
ps_cb.FogColor_AREF.a -= 1.0f / 255;
}
else if(ps_sel.atst == 3 || ps_sel.atst == 6)
else if(ps_sel.atst == ATST_LEQUAL || ps_sel.atst == ATST_GREATER)
{
ps_cb.FogColor_AREF.a += 0.9f / 255;
// example:
// ATST = ATST_GREATER, AREF = 127
// alpha = (int)127.0 => fail
// alpha = (int)127.5 => fail (!)
// alpha = (int)128.0 => pass
ps_cb.FogColor_AREF.a += 1.0f / 255;
}
if(tex)
{
ps_sel.bpp = tex->m_bpp;
ps_sel.rt = tex->m_target;
int w = tex->m_texture->GetWidth();
int h = tex->m_texture->GetHeight();

View File

@ -890,7 +890,7 @@ void GSState::GIFRegHandlerHWREG(GIFReg* r)
{
ASSERT(m_env.TRXDIR.XDIR == 0); // host => local
Write((uint8*)r, 8); // hunting ground
Write((uint8*)r, 8); // haunting ground
}
void GSState::GIFRegHandlerSIGNAL(GIFReg* r)
@ -2211,6 +2211,26 @@ bool GSC_Genji(const GSFrameInfo& fi, int& skip)
return true;
}
bool GSC_StarOcean3(const GSFrameInfo& fi, int& skip)
{
if(skip == 0)
{
if(fi.TME && fi.FBP == fi.TBP0 && fi.FPSM == PSM_PSMCT32 && fi.TPSM == PSM_PSMT4HH)
{
skip = 1000; //
}
}
else
{
if(!(fi.TME && fi.FBP == fi.TBP0 && fi.FPSM == PSM_PSMCT32 && fi.TPSM == PSM_PSMT4HH))
{
skip = 0;
}
}
return true;
}
bool GSState::IsBadFrame(int& skip)
{
GSFrameInfo fi;
@ -2258,6 +2278,7 @@ bool GSState::IsBadFrame(int& skip)
map[CRC::TalesOfAbyss] = GSC_TalesOfAbyss;
map[CRC::SonicUnleashed] = GSC_SonicUnleashed;
map[CRC::Genji] = GSC_Genji;
map[CRC::StarOcean3] = GSC_StarOcean3;
}
// TODO: just set gsc in SetGameCRC once

View File

@ -54,9 +54,9 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
Source* src = NULL;
const hash_map<Source*, bool>& map = m_src.m_map[TEX0.TBP0 >> 5];
hash_map<Source*, bool>& m = m_src.m_map[TEX0.TBP0 >> 5];
for(hash_map<Source*, bool>::const_iterator i = map.begin(); i != map.end(); i++)
for(hash_map<Source*, bool>::iterator i = m.begin(); i != m.end(); i++)
{
Source* s = i->first;
@ -242,9 +242,9 @@ void GSTextureCache::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const
if(!target)
{
const hash_map<Source*, bool>& map = m_src.m_map[bp >> 5];
const hash_map<Source*, bool>& m = m_src.m_map[bp >> 5];
for(hash_map<Source*, bool>::const_iterator i = map.begin(); i != map.end(); )
for(hash_map<Source*, bool>::const_iterator i = m.begin(); i != m.end(); )
{
hash_map<Source*, bool>::const_iterator j = i++;
@ -267,9 +267,9 @@ void GSTextureCache::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const
if(page < MAX_PAGES)
{
const hash_map<Source*, bool>& map = m_src.m_map[page];
const hash_map<Source*, bool>& m = m_src.m_map[page];
for(hash_map<Source*, bool>::const_iterator i = map.begin(); i != map.end(); )
for(hash_map<Source*, bool>::const_iterator i = m.begin(); i != m.end(); )
{
hash_map<Source*, bool>::const_iterator j = i++;
@ -279,10 +279,8 @@ void GSTextureCache::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const
{
if(!s->m_target)
{
s->m_blocks -= s->m_valid[page].count;
s->m_valid[page].block = 0;
s->m_valid[page].count = 0;
s->m_valid[page] = 0;
s->m_complete = false;
found = true;
}
@ -485,6 +483,7 @@ GSTextureCache::Source::Source(GSRenderer* r)
, m_initpalette(false)
, m_bpp(0)
, m_target(false)
, m_complete(false)
{
memset(m_valid, 0, sizeof(m_valid));
@ -509,7 +508,7 @@ void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
{
__super::Update();
if(m_target)
if(m_complete || m_target)
{
return;
}
@ -517,17 +516,17 @@ void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
m_TEX0 = TEX0;
m_TEXA = TEXA;
if(m_blocks == m_total_blocks)
{
return;
}
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[m_TEX0.PSM];
GSVector2i bs = psm.bs;
GSVector4i r = rect.ralign<GSVector4i::Outside>(bs);
if(r.eq(GSVector4i(0, 0, 1 << m_TEX0.TW, 1 << m_TEX0.TH)))
{
m_complete = true; // lame, but better than nothing
}
uint32 bp = m_TEX0.TBP0;
uint32 bw = m_TEX0.TBW;
@ -548,11 +547,12 @@ void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
uint32 row = block >> 5;
uint32 col = 1 << (block & 31);
if((m_valid[row].block & col) == 0)
if((m_valid[row] & col) == 0)
{
if(!repeating) m_valid[row].block |= col;
m_valid[row].count++;
if(!repeating)
{
m_valid[row] |= col;
}
Write(GSVector4i(x, y, x + bs.x, y + bs.y));
@ -579,14 +579,12 @@ void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
uint32 row = block >> 5;
uint32 col = 1 << (block & 31);
m_valid[row].block |= col;
m_valid[row] |= col;
}
}
}
}
m_blocks += blocks;
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, bs.x * bs.y * sizeof(uint32) * blocks);
Flush(m_write.count);
@ -785,9 +783,7 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0)
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM];
GSVector2i bs = psm.bs;
int blocks = 0;
GSVector2i bs = (bp & 31) ? psm.pgs : psm.bs;
for(int y = 0; y < th; y += bs.y)
{
@ -795,19 +791,33 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0)
for(int x = 0; x < tw; x += bs.x)
{
uint32 block = base + psm.blockOffset[x >> 3];
uint32 page = (base + psm.blockOffset[x >> 3]) >> 5;
if(block < MAX_BLOCKS)
if(page < MAX_PAGES)
{
m_map[block >> 5][s] = true;
blocks++;
m_pages[page >> 5] |= 1 << (page & 31);
}
}
}
s->m_blocks = 0;
s->m_total_blocks = blocks;
for(int i = 0; i < countof(m_pages); i++)
{
if(m_pages[i])
{
hash_map<Source*, bool>* m = &m_map[i << 5];
uint32 p = m_pages[i];
for(int j = 0; j < 32; j++)
{
if(p & (1 << j))
{
m[j][s] = true;
}
}
m_pages[i] = 0;
}
}
}
void GSTextureCache::SourceMap::RemoveAll()
@ -819,7 +829,7 @@ void GSTextureCache::SourceMap::RemoveAll()
m_surfaces.clear();
for(int i = 0; i < MAX_PAGES; i++)
for(uint32 i = 0; i < countof(m_map); i++)
{
m_map[i].clear();
}
@ -829,7 +839,7 @@ void GSTextureCache::SourceMap::RemoveAt(Source* s)
{
m_surfaces.erase(s);
for(int i = 0; i < countof(m_map); i++)
for(uint32 i = s->m_TEX0.TBP0 >> 5; i < countof(m_map); i++)
{
m_map[i].erase(s);
}

View File

@ -58,11 +58,11 @@ public:
public:
GSTexture* m_palette;
bool m_initpalette;
uint32 m_blocks, m_total_blocks;
struct {uint32 block, count;} m_valid[MAX_PAGES]; // each uint32 bits map to the 32 blocks of that page
uint32 m_valid[MAX_PAGES]; // each uint32 bits map to the 32 blocks of that page
uint32* m_clut;
int m_bpp;
bool m_target;
bool m_complete;
public:
explicit Source(GSRenderer* renderer);
@ -95,9 +95,10 @@ protected:
{
hash_map<Source*, bool> m_surfaces;
hash_map<Source*, bool> m_map[MAX_PAGES];
uint32 m_pages[16];
bool m_used;
SourceMap() : m_used(false) {}
SourceMap() : m_used(false) {memset(m_pages, 0, sizeof(m_pages));}
void Add(Source* s, const GIFRegTEX0& TEX0);
void RemoveAll();

View File

@ -203,8 +203,14 @@ bool GSTextureCache10::Source10::Create(Target* dst)
m_initpalette = true;
break;
case PSM_PSMT4HL:
m_bpp = 4;
m_palette = m_renderer->m_dev->CreateTexture(256, 1);
m_initpalette = true;
break;
case PSM_PSMT4HH:
ASSERT(0); // TODO
m_bpp = 5;
m_palette = m_renderer->m_dev->CreateTexture(256, 1);
m_initpalette = true;
break;
}

View File

@ -205,8 +205,14 @@ bool GSTextureCache11::Source11::Create(Target* dst)
m_initpalette = true;
break;
case PSM_PSMT4HL:
m_bpp = 4;
m_palette = m_renderer->m_dev->CreateTexture(256, 1);
m_initpalette = true;
break;
case PSM_PSMT4HH:
ASSERT(0); // TODO
m_bpp = 5;
m_palette = m_renderer->m_dev->CreateTexture(256, 1);
m_initpalette = true;
break;
}

View File

@ -203,8 +203,14 @@ bool GSTextureCache9::Source9::Create(Target* dst)
m_initpalette = true;
break;
case PSM_PSMT4HL:
m_bpp = 4;
m_palette = m_renderer->m_dev->CreateTexture(256, 1);
m_initpalette = true;
break;
case PSM_PSMT4HH:
ASSERT(0); // TODO
m_bpp = 5;
m_palette = m_renderer->m_dev->CreateTexture(256, 1);
m_initpalette = true;
break;
}

View File

@ -177,7 +177,6 @@ void GSTextureCacheSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, cons
if(GSUtil::HasSharedBits(BITBLTBUF.DPSM, t->m_TEX0.PSM))
{
t->m_valid[page] = 0;
t->m_complete = false;
}
}
@ -237,7 +236,7 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
GSVector4i r = rect.ralign<GSVector4i::Outside>(s);
if(r.left == 0 && r.top == 0 && r.right == tw && r.bottom == th)
if(r.eq(GSVector4i(0, 0, tw, th)))
{
m_complete = true; // lame, but better than nothing
}

View File

@ -288,7 +288,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
m_ps_ss[ssel] = ss0;
}
if(sel.bpp == 3)
if(sel.bpp >= 3)
{
ss1 = m_palette_ss;
}

View File

@ -292,7 +292,7 @@ void GSTextureFX11::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
m_ps_ss[ssel] = ss0;
}
if(sel.bpp == 3)
if(sel.bpp >= 3)
{
ss1 = m_palette_ss;
}

View File

@ -97,21 +97,6 @@ bool GSUtil::HasCompatibleBits(uint32 spsm, uint32 dpsm)
return s_maps.CompatibleBitsField[spsm][dpsm];
}
bool GSUtil::IsRectInRect(const GSVector4i& inner, const GSVector4i& outer)
{
return outer.left <= inner.left && inner.right <= outer.right && outer.top <= inner.top && inner.bottom <= outer.bottom;
}
bool GSUtil::IsRectInRectH(const GSVector4i& inner, const GSVector4i& outer)
{
return outer.top <= inner.top && inner.bottom <= outer.bottom;
}
bool GSUtil::IsRectInRectV(const GSVector4i& inner, const GSVector4i& outer)
{
return outer.left <= inner.left && inner.right <= outer.right;
}
bool GSUtil::CheckDirectX()
{
if(HINSTANCE hDll = LoadLibrary(format("d3dx9_%d.dll", D3DX_SDK_VERSION).c_str()))

View File

@ -32,10 +32,6 @@ public:
static bool HasSharedBits(uint32 sbp, uint32 spsm, uint32 dbp, uint32 dpsm);
static bool HasCompatibleBits(uint32 spsm, uint32 dpsm);
static bool IsRectInRect(const GSVector4i& inner, const GSVector4i& outer);
static bool IsRectInRectH(const GSVector4i& inner, const GSVector4i& outer);
static bool IsRectInRectV(const GSVector4i& inner, const GSVector4i& outer);
static uint32 EncodePSM(uint32 psm)
{
switch(psm)

View File

@ -24,18 +24,6 @@ public:
this->y = y;
}
GSVector2T(const GSVector2T& v)
{
*this = v;
}
const GSVector2T& operator = (const GSVector2T& v)
{
_mm_storel_epi64((__m128i*)this, _mm_loadl_epi64((__m128i*)&v));
return *this;
}
bool operator == (const GSVector2T& v) const
{
return x == v.x && y == v.y;

View File

@ -481,7 +481,7 @@ float4 sample(float2 tc, float w)
float4 t00, t01, t10, t11;
if(PS_BPP == 3) // 8HP
if(PS_BPP == 3) // 8H
{
float4 a;
@ -495,6 +495,38 @@ float4 sample(float2 tc, float w)
t10 = Palette.Sample(PaletteSampler, a.z);
t11 = Palette.Sample(PaletteSampler, a.w);
}
else if(PS_BPP == 4) // 4HL
{
float4 a;
a.x = Texture.Sample(TextureSampler, uv.xy).a;
a.y = Texture.Sample(TextureSampler, uv.zy).a;
a.z = Texture.Sample(TextureSampler, uv.xw).a;
a.w = Texture.Sample(TextureSampler, uv.zw).a;
a = fmod(a, 1.0f / 16);
t00 = Palette.Sample(PaletteSampler, a.x);
t01 = Palette.Sample(PaletteSampler, a.y);
t10 = Palette.Sample(PaletteSampler, a.z);
t11 = Palette.Sample(PaletteSampler, a.w);
}
else if(PS_BPP == 5) // 4HH
{
float4 a;
a.x = Texture.Sample(TextureSampler, uv.xy).a;
a.y = Texture.Sample(TextureSampler, uv.zy).a;
a.z = Texture.Sample(TextureSampler, uv.xw).a;
a.w = Texture.Sample(TextureSampler, uv.zw).a;
a = fmod(a * 16, 1.0f / 16);
t00 = Palette.Sample(PaletteSampler, a.x);
t01 = Palette.Sample(PaletteSampler, a.y);
t10 = Palette.Sample(PaletteSampler, a.z);
t11 = Palette.Sample(PaletteSampler, a.w);
}
else
{
t00 = Texture.Sample(TextureSampler, uv.xy);
@ -658,6 +690,42 @@ float4 sample(float2 tc, float w)
t10 = tex1D(Palette, a.z);
t11 = tex1D(Palette, a.w);
}
else if(PS_BPP == 4) // 4HL
{
float4 a;
a.x = tex2D(Texture, uv.xy).a;
a.y = tex2D(Texture, uv.zy).a;
a.z = tex2D(Texture, uv.xw).a;
a.w = tex2D(Texture, uv.zw).a;
if(PS_RT == 1) a *= 0.5;
a = fmod(a, 1.0f / 16);
t00 = tex1D(Palette, a.x);
t01 = tex1D(Palette, a.y);
t10 = tex1D(Palette, a.z);
t11 = tex1D(Palette, a.w);
}
else if(PS_BPP == 5) // 4HH
{
float4 a;
a.x = tex2D(Texture, uv.xy).a;
a.y = tex2D(Texture, uv.zy).a;
a.z = tex2D(Texture, uv.xw).a;
a.w = tex2D(Texture, uv.zw).a;
if(PS_RT == 1) a *= 0.5;
a = fmod(a * 16, 1.0f / 16);
t00 = tex1D(Palette, a.x);
t01 = tex1D(Palette, a.y);
t10 = tex1D(Palette, a.z);
t11 = tex1D(Palette, a.w);
}
else
{
t00 = tex2D(Texture, uv.xy);

View File

@ -167,7 +167,7 @@ struct EnableSetEip : public Gen {
Gen::call((void*)local::set_eip_to_esi);
break;
case Xbyak::Operand::EDI:
Gen::call((void*)local::set_eip_to_esi);
Gen::call((void*)local::set_eip_to_edi);
break;
case Xbyak::Operand::EBP:
Gen::call((void*)local::set_eip_to_ebp);