mirror of https://github.com/PCSX2/pcsx2.git
GSdx: texture filtering checkbox fixed, changed texture lookup a bit, removed more unused code
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1351 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
70cd55b332
commit
b678bb129c
|
@ -75,7 +75,9 @@ GSVector4i GSDirtyRectList::GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const G
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
return r.rintersect(GSVector4i(0, 0, size.x, size.y));
|
GSVector2i bs = GSLocalMemory::m_psm[TEX0.PSM].bs;
|
||||||
|
|
||||||
|
return r.ralign<GSVector4i::Outside>(bs).rintersect(GSVector4i(0, 0, size.x, size.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GSVector4i::zero();
|
return GSVector4i::zero();
|
||||||
|
|
|
@ -1720,26 +1720,7 @@ void GSLocalMemory::ReadTextureBlock16SZ(uint32 bp, uint8* dst, int dstpitch, co
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
void GSLocalMemory::ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP)
|
void GSLocalMemory::ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
|
||||||
{
|
|
||||||
readTexture rtx = m_psm[TEX0.PSM].rtx;
|
|
||||||
readTexel rt = m_psm[TEX0.PSM].rt;
|
|
||||||
GSVector2i bs = m_psm[TEX0.PSM].bs;
|
|
||||||
|
|
||||||
if(r.width() < bs.x || r.height() < bs.y
|
|
||||||
|| (r.left & (bs.x - 1)) || (r.top & (bs.y - 1))
|
|
||||||
|| (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1))
|
|
||||||
|| CLAMP.WMS == 3 || CLAMP.WMT == 3)
|
|
||||||
{
|
|
||||||
ReadTexture<uint32>(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(this->*rtx)(r, dst, dstpitch, TEX0, TEXA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GSLocalMemory::ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP)
|
|
||||||
{
|
{
|
||||||
readTexture rtx = m_psm[TEX0.PSM].rtx;
|
readTexture rtx = m_psm[TEX0.PSM].rtx;
|
||||||
readTexel rt = m_psm[TEX0.PSM].rt;
|
readTexel rt = m_psm[TEX0.PSM].rt;
|
||||||
|
@ -1749,7 +1730,7 @@ void GSLocalMemory::ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch,
|
||||||
|| (r.left & (bs.x - 1)) || (r.top & (bs.y - 1))
|
|| (r.left & (bs.x - 1)) || (r.top & (bs.y - 1))
|
||||||
|| (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1)))
|
|| (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1)))
|
||||||
{
|
{
|
||||||
ReadTextureNC<uint32>(r, dst, dstpitch, TEX0, TEXA, rt, rtx);
|
ReadTexture<uint32>(r, dst, dstpitch, TEX0, TEXA, rt, rtx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1936,50 +1917,7 @@ void GSLocalMemory::ReadTexture16SZNP(const GSVector4i& r, uint8* dst, int dstpi
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
void GSLocalMemory::ReadTextureNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP)
|
void GSLocalMemory::ReadTextureNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
|
||||||
{
|
|
||||||
readTexture rtx = m_psm[TEX0.PSM].rtxNP;
|
|
||||||
readTexel rt = m_psm[TEX0.PSM].rtNP;
|
|
||||||
GSVector2i bs = m_psm[TEX0.PSM].bs;
|
|
||||||
|
|
||||||
if(r.width() < bs.x || r.height() < bs.y
|
|
||||||
|| (r.left & (bs.x - 1)) || (r.top & (bs.y - 1))
|
|
||||||
|| (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1))
|
|
||||||
|| CLAMP.WMS == 3 || CLAMP.WMT == 3)
|
|
||||||
{
|
|
||||||
uint32 psm = TEX0.PSM;
|
|
||||||
|
|
||||||
switch(psm)
|
|
||||||
{
|
|
||||||
case PSM_PSMT8:
|
|
||||||
case PSM_PSMT8H:
|
|
||||||
case PSM_PSMT4:
|
|
||||||
case PSM_PSMT4HL:
|
|
||||||
case PSM_PSMT4HH:
|
|
||||||
psm = TEX0.CPSM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(psm)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case PSM_PSMCT32:
|
|
||||||
case PSM_PSMCT24:
|
|
||||||
ReadTexture<uint32>(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx);
|
|
||||||
break;
|
|
||||||
case PSM_PSMCT16:
|
|
||||||
case PSM_PSMCT16S:
|
|
||||||
ReadTexture<uint16>(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(this->*rtx)(r, dst, dstpitch, TEX0, TEXA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GSLocalMemory::ReadTextureNPNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP)
|
|
||||||
{
|
{
|
||||||
readTexture rtx = m_psm[TEX0.PSM].rtxNP;
|
readTexture rtx = m_psm[TEX0.PSM].rtxNP;
|
||||||
readTexel rt = m_psm[TEX0.PSM].rtNP;
|
readTexel rt = m_psm[TEX0.PSM].rtNP;
|
||||||
|
@ -2007,11 +1945,11 @@ void GSLocalMemory::ReadTextureNPNC(const GSVector4i& r, uint8* dst, int dstpitc
|
||||||
default:
|
default:
|
||||||
case PSM_PSMCT32:
|
case PSM_PSMCT32:
|
||||||
case PSM_PSMCT24:
|
case PSM_PSMCT24:
|
||||||
ReadTextureNC<uint32>(r, dst, dstpitch, TEX0, TEXA, rt, rtx);
|
ReadTexture<uint32>(r, dst, dstpitch, TEX0, TEXA, rt, rtx);
|
||||||
break;
|
break;
|
||||||
case PSM_PSMCT16:
|
case PSM_PSMCT16:
|
||||||
case PSM_PSMCT16S:
|
case PSM_PSMCT16S:
|
||||||
ReadTextureNC<uint16>(r, dst, dstpitch, TEX0, TEXA, rt, rtx);
|
ReadTexture<uint16>(r, dst, dstpitch, TEX0, TEXA, rt, rtx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2106,266 +2044,9 @@ void GSLocalMemory::ReadTextureBlock4HHP(uint32 bp, uint8* dst, int dstpitch, co
|
||||||
//
|
//
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void GSLocalMemory::ReadTexture(const GSVector4i& r2, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, readTexel rt, readTexture rtx)
|
void GSLocalMemory::ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx)
|
||||||
{
|
{
|
||||||
// TODO: this is a mess, make it more simple
|
GSVector4i cr = r.ralign<GSVector4i::Inside>(m_psm[TEX0.PSM].bs);
|
||||||
|
|
||||||
GSVector4i r = r2;
|
|
||||||
|
|
||||||
uint32 wms = CLAMP.WMS, wmt = CLAMP.WMT;
|
|
||||||
uint32 minu = CLAMP.MINU, maxu = CLAMP.MAXU;
|
|
||||||
uint32 minv = CLAMP.MINV, maxv = CLAMP.MAXV;
|
|
||||||
|
|
||||||
GSVector2i bs = m_psm[TEX0.PSM].bs;
|
|
||||||
|
|
||||||
int bsxm = bs.x - 1;
|
|
||||||
int bsym = bs.y - 1;
|
|
||||||
|
|
||||||
if(wms == 3 || wmt == 3)
|
|
||||||
{
|
|
||||||
if(wms == 3 && wmt == 3)
|
|
||||||
{
|
|
||||||
int w = minu + 1;
|
|
||||||
int h = minv + 1;
|
|
||||||
|
|
||||||
w = (w + bsxm) & ~bsxm;
|
|
||||||
h = (h + bsym) & ~bsym;
|
|
||||||
|
|
||||||
if(w % bs.x == 0 && maxu % bs.x == 0 && h % bs.y == 0 && maxv % bs.y == 0)
|
|
||||||
{
|
|
||||||
// printf("!!! 1 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom);
|
|
||||||
|
|
||||||
T* buff = (T*)_aligned_malloc(w * h * sizeof(T), 16);
|
|
||||||
|
|
||||||
(this->*rtx)(GSVector4i(maxu, maxv, maxu + w, maxv + h), (uint8*)buff, w * sizeof(T), TEX0, TEXA);
|
|
||||||
|
|
||||||
dst -= r.left * sizeof(T);
|
|
||||||
|
|
||||||
// int left = (r.left + minu) & ~minu;
|
|
||||||
// int right = r.right & ~minu;
|
|
||||||
|
|
||||||
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
|
||||||
{
|
|
||||||
T* src = &buff[(y & minv) * w];
|
|
||||||
|
|
||||||
int x = r.left;
|
|
||||||
/*
|
|
||||||
for(; x < left; x++)
|
|
||||||
{
|
|
||||||
((T*)dst)[x] = src[x & minu];
|
|
||||||
}
|
|
||||||
|
|
||||||
for(; x < right; x += minu + 1)
|
|
||||||
{
|
|
||||||
memcpy(&((T*)dst)[x], src, sizeof(T) * (minu + 1));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for(; x < r.right; x++)
|
|
||||||
{
|
|
||||||
((T*)dst)[x] = src[x & minu];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_aligned_free(buff);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wms == 2)
|
|
||||||
{
|
|
||||||
int left = r.left;
|
|
||||||
r.left = min(r.right, max(r.left, (int)minu));
|
|
||||||
r.right = max(r.left, min(r.right, (int)maxu + 1));
|
|
||||||
dst += (r.left - left) * sizeof(T);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wmt == 2)
|
|
||||||
{
|
|
||||||
int top = r.top;
|
|
||||||
r.top = min(r.bottom, max(r.top, (int)minv));
|
|
||||||
r.bottom = max(r.top, min(r.bottom, (int)maxv + 1));
|
|
||||||
dst += (r.top - top) * dstpitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wms == 3 && wmt != 3)
|
|
||||||
{
|
|
||||||
int w = ((minu + 1) + bsxm) & ~bsxm;
|
|
||||||
|
|
||||||
if(w % bs.x == 0 && maxu % bs.x == 0)
|
|
||||||
{
|
|
||||||
// printf("!!! 2 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom);
|
|
||||||
int top = r.top & ~bsym;
|
|
||||||
int bottom = (r.bottom + bsym) & ~bsym;
|
|
||||||
|
|
||||||
int h = bottom - top;
|
|
||||||
|
|
||||||
T* buff = (T*)_aligned_malloc(w * h * sizeof(T), 16);
|
|
||||||
|
|
||||||
(this->*rtx)(GSVector4i(maxu, top, maxu + w, top + h), (uint8*)buff, w * sizeof(T), TEX0, TEXA);
|
|
||||||
|
|
||||||
dst -= r.left * sizeof(T);
|
|
||||||
|
|
||||||
// int left = (r.left + minu) & ~minu;
|
|
||||||
// int right = r.right & ~minu;
|
|
||||||
|
|
||||||
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
|
||||||
{
|
|
||||||
T* src = &buff[(y - top) * w];
|
|
||||||
|
|
||||||
int x = r.left;
|
|
||||||
/*
|
|
||||||
for(; x < left; x++)
|
|
||||||
{
|
|
||||||
((T*)dst)[x] = src[x & minu];
|
|
||||||
}
|
|
||||||
|
|
||||||
for(; x < right; x += minu + 1)
|
|
||||||
{
|
|
||||||
memcpy(&((T*)dst)[x], src, sizeof(T) * (minu + 1));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for(; x < r.right; x++)
|
|
||||||
{
|
|
||||||
((T*)dst)[x] = src[x & minu];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_aligned_free(buff);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wms != 3 && wmt == 3)
|
|
||||||
{
|
|
||||||
int h = (minv + 1 + bsym) & ~bsym;
|
|
||||||
|
|
||||||
if(h % bs.y == 0 && maxv % bs.y == 0)
|
|
||||||
{
|
|
||||||
// printf("!!! 3 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom);
|
|
||||||
int left = r.left & ~bsxm;
|
|
||||||
int right = (r.right + bsxm) & ~bsxm;
|
|
||||||
|
|
||||||
int w = right - left;
|
|
||||||
|
|
||||||
T* buff = (T*)_aligned_malloc(w * h * sizeof(T), 16);
|
|
||||||
|
|
||||||
(this->*rtx)(GSVector4i(left, maxv, left + w, maxv + h), (uint8*)buff, w * sizeof(T), TEX0, TEXA);
|
|
||||||
|
|
||||||
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
|
||||||
{
|
|
||||||
T* src = &buff[(y & minv) * w + (r.left - left)];
|
|
||||||
|
|
||||||
memcpy(dst, src, sizeof(T) * r.width());
|
|
||||||
}
|
|
||||||
|
|
||||||
_aligned_free(buff);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(wms)
|
|
||||||
{
|
|
||||||
default: for(int x = r.left; x < r.right; x++) m_xtbl[x] = x; break;
|
|
||||||
case 3: for(int x = r.left; x < r.right; x++) m_xtbl[x] = (x & minu) | maxu; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(wmt)
|
|
||||||
{
|
|
||||||
default: for(int y = r.top; y < r.bottom; y++) m_ytbl[y] = y; break;
|
|
||||||
case 3: for(int y = r.top; y < r.bottom; y++) m_ytbl[y] = (y & minv) | maxv; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// printf("!!! 4 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom);
|
|
||||||
|
|
||||||
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
|
||||||
for(int x = r.left, i = 0; x < r.right; x++, i++)
|
|
||||||
((T*)dst)[i] = (T)(this->*rt)(m_xtbl[x], m_ytbl[y], TEX0, TEXA);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// find a block-aligned rect that fits between r and the region clamped area (if any)
|
|
||||||
|
|
||||||
GSVector4i r1 = r;
|
|
||||||
GSVector4i r2 = r;
|
|
||||||
|
|
||||||
r1.left = (r1.left + bsxm) & ~bsxm;
|
|
||||||
r1.top = (r1.top + bsym) & ~bsym;
|
|
||||||
r1.right = r1.right & ~bsxm;
|
|
||||||
r1.bottom = r1.bottom & ~bsym;
|
|
||||||
|
|
||||||
if(wms == 2 && minu < maxu)
|
|
||||||
{
|
|
||||||
r2.left = minu & ~bsxm;
|
|
||||||
r2.right = (maxu + bsxm) & ~bsxm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(wmt == 2 && minv < maxv)
|
|
||||||
{
|
|
||||||
r2.top = minv & ~bsym;
|
|
||||||
r2.bottom = (maxv + bsym) & ~bsym;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSVector4i cr = r1.rintersect(r2);
|
|
||||||
|
|
||||||
bool aligned = ((DWORD_PTR)(dst + (cr.left - r.left) * sizeof(T)) & 0xf) == 0;
|
|
||||||
|
|
||||||
if(cr.rempty() || !aligned)
|
|
||||||
{
|
|
||||||
// TODO: expand r to block size, read into temp buffer, copy to r (like above)
|
|
||||||
|
|
||||||
if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n");
|
|
||||||
|
|
||||||
// printf("!!! 5 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom);
|
|
||||||
|
|
||||||
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
|
||||||
for(int x = r.left, i = 0; x < r.right; x++, i++)
|
|
||||||
((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// printf("!!! 6 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom);
|
|
||||||
|
|
||||||
for(int y = r.top; y < cr.top; y++, dst += dstpitch)
|
|
||||||
for(int x = r.left, i = 0; x < r.right; x++, i++)
|
|
||||||
((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA);
|
|
||||||
|
|
||||||
if(!cr.rempty())
|
|
||||||
{
|
|
||||||
(this->*rtx)(cr, dst + (cr.left - r.left) * sizeof(T), dstpitch, TEX0, TEXA);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int y = cr.top; y < cr.bottom; y++, dst += dstpitch)
|
|
||||||
{
|
|
||||||
for(int x = r.left, i = 0; x < cr.left; x++, i++)
|
|
||||||
((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA);
|
|
||||||
for(int x = cr.right, i = x - r.left; x < r.right; x++, i++)
|
|
||||||
((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int y = cr.bottom; y < r.bottom; y++, dst += dstpitch)
|
|
||||||
for(int x = r.left, i = 0; x < r.right; x++, i++)
|
|
||||||
((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void GSLocalMemory::ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx)
|
|
||||||
{
|
|
||||||
GSVector2i bs = m_psm[TEX0.PSM].bs;
|
|
||||||
|
|
||||||
int bsxm = bs.x - 1;
|
|
||||||
int bsym = bs.y - 1;
|
|
||||||
|
|
||||||
GSVector4i cr;
|
|
||||||
|
|
||||||
cr.left = (r.left + bsxm) & ~bsxm;
|
|
||||||
cr.top = (r.top + bsym) & ~bsym;
|
|
||||||
cr.right = r.right & ~bsxm;
|
|
||||||
cr.bottom = r.bottom & ~bsym;
|
|
||||||
|
|
||||||
bool aligned = ((DWORD_PTR)(dst + (cr.left - r.left) * sizeof(T)) & 0xf) == 0;
|
bool aligned = ((DWORD_PTR)(dst + (cr.left - r.left) * sizeof(T)) & 0xf) == 0;
|
||||||
|
|
||||||
|
@ -2373,7 +2054,8 @@ void GSLocalMemory::ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch,
|
||||||
{
|
{
|
||||||
// TODO: expand r to block size, read into temp buffer, copy to r (like above)
|
// TODO: expand r to block size, read into temp buffer, copy to r (like above)
|
||||||
|
|
||||||
if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n");
|
if(!aligned)
|
||||||
|
printf("unaligned memory pointer passed to ReadTexture\n");
|
||||||
|
|
||||||
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
for(int y = r.top; y < r.bottom; y++, dst += dstpitch)
|
||||||
for(int x = r.left, i = 0; x < r.right; x++, i++)
|
for(int x = r.left, i = 0; x < r.right; x++, i++)
|
||||||
|
|
|
@ -795,8 +795,7 @@ public:
|
||||||
void ReadTexture16Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
void ReadTexture16Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
||||||
void ReadTexture16SZ(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
void ReadTexture16SZ(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
||||||
|
|
||||||
void ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP);
|
void ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA);
|
||||||
void ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP);
|
|
||||||
|
|
||||||
void ReadTextureBlock32(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const;
|
void ReadTextureBlock32(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const;
|
||||||
void ReadTextureBlock24(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const;
|
void ReadTextureBlock24(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const;
|
||||||
|
@ -824,8 +823,7 @@ public:
|
||||||
void ReadTexture16ZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
void ReadTexture16ZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
||||||
void ReadTexture16SZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
void ReadTexture16SZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const;
|
||||||
|
|
||||||
void ReadTextureNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP);
|
void ReadTextureNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA);
|
||||||
void ReadTextureNPNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP);
|
|
||||||
|
|
||||||
// pal ? 8 : 32
|
// pal ? 8 : 32
|
||||||
|
|
||||||
|
@ -845,8 +843,7 @@ public:
|
||||||
|
|
||||||
static uint32 m_xtbl[1024], m_ytbl[1024];
|
static uint32 m_xtbl[1024], m_ytbl[1024];
|
||||||
|
|
||||||
template<typename T> void ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, readTexel rt, readTexture rtx);
|
template<typename T> void ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx);
|
||||||
template<typename T> void ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
|
@ -324,28 +324,27 @@ void GSRendererHW10::Draw(int prim, GSTexture* rt, GSTexture* ds, GSTextureCache
|
||||||
ps_sel.clr1 = om_bsel.abe && om_bsel.a == 1 && om_bsel.b == 2 && om_bsel.d == 1;
|
ps_sel.clr1 = om_bsel.abe && om_bsel.a == 1 && om_bsel.b == 2 && om_bsel.d == 1;
|
||||||
ps_sel.fba = context->FBA.FBA;
|
ps_sel.fba = context->FBA.FBA;
|
||||||
ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0;
|
ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0;
|
||||||
|
ps_sel.ltf = m_filter == 2 ? context->TEX1.IsLinear() : m_filter;
|
||||||
|
|
||||||
GSTextureFX10::PSSamplerSelector ps_ssel;
|
GSTextureFX10::PSSamplerSelector ps_ssel;
|
||||||
|
|
||||||
ps_ssel.min = m_filter == 2 ? (context->TEX1.MMIN & 1) : m_filter;
|
|
||||||
ps_ssel.mag = m_filter == 2 ? (context->TEX1.MMAG & 1) : m_filter;
|
|
||||||
ps_ssel.tau = 0;
|
ps_ssel.tau = 0;
|
||||||
ps_ssel.tav = 0;
|
ps_ssel.tav = 0;
|
||||||
|
ps_ssel.ltf = ps_sel.ltf;
|
||||||
|
|
||||||
GSTextureFX10::PSConstantBuffer ps_cb;
|
GSTextureFX10::PSConstantBuffer ps_cb;
|
||||||
|
|
||||||
ps_cb.FogColor = GSVector4(env.FOGCOL.FCR, env.FOGCOL.FCG, env.FOGCOL.FCB, 0) / 255.0f;
|
ps_cb.FogColorAREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, (int)context->TEST.AREF) / 255;
|
||||||
ps_cb.TA0 = (float)(int)env.TEXA.TA0 / 255;
|
ps_cb.TA0 = (float)(int)env.TEXA.TA0 / 255;
|
||||||
ps_cb.TA1 = (float)(int)env.TEXA.TA1 / 255;
|
ps_cb.TA1 = (float)(int)env.TEXA.TA1 / 255;
|
||||||
ps_cb.AREF = (float)(int)context->TEST.AREF / 255;
|
|
||||||
|
|
||||||
if(context->TEST.ATST == 2 || context->TEST.ATST == 5)
|
if(context->TEST.ATST == 2 || context->TEST.ATST == 5)
|
||||||
{
|
{
|
||||||
ps_cb.AREF -= 0.9f/256;
|
ps_cb.FogColorAREF.a -= 0.9f / 255;
|
||||||
}
|
}
|
||||||
else if(context->TEST.ATST == 3 || context->TEST.ATST == 6)
|
else if(context->TEST.ATST == 3 || context->TEST.ATST == 6)
|
||||||
{
|
{
|
||||||
ps_cb.AREF += 0.9f/256;
|
ps_cb.FogColorAREF.a += 0.9f / 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tex)
|
if(tex)
|
||||||
|
@ -400,7 +399,6 @@ void GSRendererHW10::Draw(int prim, GSTexture* rt, GSTexture* ds, GSTextureCache
|
||||||
float h = (float)tex->m_texture->GetHeight();
|
float h = (float)tex->m_texture->GetHeight();
|
||||||
|
|
||||||
ps_cb.WH = GSVector2(w, h);
|
ps_cb.WH = GSVector2(w, h);
|
||||||
ps_cb.rWrH = GSVector2(1.0f / w, 1.0f / h);
|
|
||||||
ps_cb.HalfTexel = GSVector4(-0.5f / w, -0.5f / h, +0.5f / w, +0.5f / h);
|
ps_cb.HalfTexel = GSVector4(-0.5f / w, -0.5f / h, +0.5f / w, +0.5f / h);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -298,28 +298,27 @@ void GSRendererHW9::Draw(int prim, GSTexture* rt, GSTexture* ds, GSTextureCache:
|
||||||
ps_sel.fog = PRIM->FGE;
|
ps_sel.fog = PRIM->FGE;
|
||||||
ps_sel.clr1 = om_bsel.abe && om_bsel.a == 1 && om_bsel.b == 2 && om_bsel.d == 1;
|
ps_sel.clr1 = om_bsel.abe && om_bsel.a == 1 && om_bsel.b == 2 && om_bsel.d == 1;
|
||||||
ps_sel.rt = tex && tex->m_rendered;
|
ps_sel.rt = tex && tex->m_rendered;
|
||||||
|
ps_sel.ltf = m_filter == 2 ? context->TEX1.IsLinear() : m_filter;
|
||||||
|
|
||||||
GSTextureFX9::PSSamplerSelector ps_ssel;
|
GSTextureFX9::PSSamplerSelector ps_ssel;
|
||||||
|
|
||||||
ps_ssel.min = m_filter == 2 ? (context->TEX1.MMIN & 1) : m_filter;
|
|
||||||
ps_ssel.mag = m_filter == 2 ? (context->TEX1.MMAG & 1) : m_filter;
|
|
||||||
ps_ssel.tau = 0;
|
ps_ssel.tau = 0;
|
||||||
ps_ssel.tav = 0;
|
ps_ssel.tav = 0;
|
||||||
|
ps_ssel.ltf = ps_sel.ltf;
|
||||||
|
|
||||||
GSTextureFX9::PSConstantBuffer ps_cb;
|
GSTextureFX9::PSConstantBuffer ps_cb;
|
||||||
|
|
||||||
ps_cb.FogColor = GSVector4(env.FOGCOL.FCR, env.FOGCOL.FCG, env.FOGCOL.FCB, 0) / 255.0f;
|
ps_cb.FogColorAREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, (int)context->TEST.AREF) / 255;
|
||||||
ps_cb.TA0 = (float)(int)env.TEXA.TA0 / 255;
|
ps_cb.TA0 = (float)(int)env.TEXA.TA0 / 255;
|
||||||
ps_cb.TA1 = (float)(int)env.TEXA.TA1 / 255;
|
ps_cb.TA1 = (float)(int)env.TEXA.TA1 / 255;
|
||||||
ps_cb.AREF = (float)(int)context->TEST.AREF / 255;
|
|
||||||
|
|
||||||
if(context->TEST.ATST == 2 || context->TEST.ATST == 5)
|
if(context->TEST.ATST == 2 || context->TEST.ATST == 5)
|
||||||
{
|
{
|
||||||
ps_cb.AREF -= 0.9f/256;
|
ps_cb.FogColorAREF.a -= 0.9f / 255;
|
||||||
}
|
}
|
||||||
else if(context->TEST.ATST == 3 || context->TEST.ATST == 6)
|
else if(context->TEST.ATST == 3 || context->TEST.ATST == 6)
|
||||||
{
|
{
|
||||||
ps_cb.AREF += 0.9f/256;
|
ps_cb.FogColorAREF.a += 0.9f / 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tex)
|
if(tex)
|
||||||
|
@ -374,7 +373,6 @@ void GSRendererHW9::Draw(int prim, GSTexture* rt, GSTexture* ds, GSTextureCache:
|
||||||
float h = (float)tex->m_texture->GetHeight();
|
float h = (float)tex->m_texture->GetHeight();
|
||||||
|
|
||||||
ps_cb.WH = GSVector2(w, h);
|
ps_cb.WH = GSVector2(w, h);
|
||||||
ps_cb.rWrH = GSVector2(1.0f / w, 1.0f / h);
|
|
||||||
ps_cb.HalfTexel = GSVector4(-0.5f / w, -0.5f / h, +0.5f / w, +0.5f / h);
|
ps_cb.HalfTexel = GSVector4(-0.5f / w, -0.5f / h, +0.5f / w, +0.5f / h);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -114,15 +114,11 @@ GSTexture* GSRendererSW::GetOutput(int i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GIFRegCLAMP CLAMP;
|
|
||||||
|
|
||||||
CLAMP.WMS = CLAMP.WMT = 1;
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
|
static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
|
||||||
static int pitch = 1024 * 4;
|
static int pitch = 1024 * 4;
|
||||||
|
|
||||||
m_mem.ReadTexture(r, buff, pitch, TEX0, m_env.TEXA, CLAMP);
|
m_mem.ReadTexture(r, buff, pitch, TEX0, m_env.TEXA);
|
||||||
|
|
||||||
m_texture[i]->Update(r, buff, pitch);
|
m_texture[i]->Update(r, buff, pitch);
|
||||||
|
|
||||||
|
|
|
@ -260,21 +260,21 @@ GSTextureCache::GSCachedTexture* GSTextureCache::GetTexture()
|
||||||
|
|
||||||
for(list<GSCachedTexture*>::iterator i = m_tex.begin(); i != m_tex.end(); i++)
|
for(list<GSCachedTexture*>::iterator i = m_tex.begin(); i != m_tex.end(); i++)
|
||||||
{
|
{
|
||||||
t = *i;
|
GSCachedTexture* t2 = *i;
|
||||||
|
|
||||||
if(GSUtil::HasSharedBits(t->m_TEX0.TBP0, t->m_TEX0.PSM, TEX0.TBP0, TEX0.PSM))
|
if((((t2->m_TEX0.u32[0] ^ TEX0.u32[0]) & 0xffefffff) | ((t2->m_TEX0.u32[1] ^ TEX0.u32[1]) & 3)) != 0) // TBP0 TBW (PSM & ~1) TW TH
|
||||||
{
|
{
|
||||||
if(TEX0.PSM == t->m_TEX0.PSM && TEX0.TBW == t->m_TEX0.TBW
|
continue;
|
||||||
&& TEX0.TW == t->m_TEX0.TW && TEX0.TH == t->m_TEX0.TH
|
|
||||||
&& (pal == 0 || TEX0.CPSM == t->m_TEX0.CPSM && GSVector4i::compare(t->m_clut, clut, pal * sizeof(clut[0]))))
|
|
||||||
{
|
|
||||||
m_tex.splice(m_tex.begin(), m_tex, i);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t = NULL;
|
if(!(pal == 0 || t2->m_TEX0.CPSM == TEX0.CPSM && GSVector4i::compare(t2->m_clut, clut, pal * sizeof(clut[0]))))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
t = t2;
|
||||||
|
|
||||||
|
m_tex.splice(m_tex.begin(), m_tex, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t == NULL)
|
if(t == NULL)
|
||||||
|
@ -367,6 +367,8 @@ GSTextureCache::GSCachedTexture* GSTextureCache::GetTexture()
|
||||||
|
|
||||||
t->Update();
|
t->Update();
|
||||||
|
|
||||||
|
m_tex_used = true;
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,9 +597,11 @@ void GSTextureCache::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const
|
||||||
|
|
||||||
void GSTextureCache::IncAge()
|
void GSTextureCache::IncAge()
|
||||||
{
|
{
|
||||||
RecycleByAge(m_tex, 2);
|
RecycleByAge(m_tex, m_tex_used ? 2 : 30);
|
||||||
RecycleByAge(m_rt);
|
RecycleByAge(m_rt);
|
||||||
RecycleByAge(m_ds);
|
RecycleByAge(m_ds);
|
||||||
|
|
||||||
|
m_tex_used = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GSTextureCache::GSSurface
|
// GSTextureCache::GSSurface
|
||||||
|
@ -704,7 +708,7 @@ void GSTextureCache::GSCachedTexture::Update()
|
||||||
{
|
{
|
||||||
// in dx9 managed textures can be written directly, less copying is faster, but still not as fast as dx10's UpdateResource
|
// in dx9 managed textures can be written directly, less copying is faster, but still not as fast as dx10's UpdateResource
|
||||||
|
|
||||||
m_renderer->m_mem.ReadTextureNPNC(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
|
m_renderer->m_mem.ReadTextureNP(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA);
|
||||||
|
|
||||||
m_texture->Unmap();
|
m_texture->Unmap();
|
||||||
}
|
}
|
||||||
|
@ -714,7 +718,7 @@ void GSTextureCache::GSCachedTexture::Update()
|
||||||
|
|
||||||
pitch = ((r.width() + 3) & ~3) * 4;
|
pitch = ((r.width() + 3) & ~3) * 4;
|
||||||
|
|
||||||
m_renderer->m_mem.ReadTextureNPNC(r, buff, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
|
m_renderer->m_mem.ReadTextureNP(r, buff, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA);
|
||||||
|
|
||||||
m_texture->Update(r, buff, pitch);
|
m_texture->Update(r, buff, pitch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@ public:
|
||||||
bool GetDirtyRect(GSVector4i& r);
|
bool GetDirtyRect(GSVector4i& r);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GIFRegCLAMP m_CLAMP;
|
|
||||||
uint32* m_clut; // *
|
uint32* m_clut; // *
|
||||||
GSVector4i m_valid;
|
GSVector4i m_valid;
|
||||||
int m_bpp;
|
int m_bpp;
|
||||||
|
@ -96,6 +95,8 @@ protected:
|
||||||
list<GSDepthStencil*> m_ds;
|
list<GSDepthStencil*> m_ds;
|
||||||
list<GSCachedTexture*> m_tex;
|
list<GSCachedTexture*> m_tex;
|
||||||
|
|
||||||
|
bool m_tex_used;
|
||||||
|
|
||||||
template<class T> void RecycleByAge(list<T*>& l, int maxage = 60)
|
template<class T> void RecycleByAge(list<T*>& l, int maxage = 60)
|
||||||
{
|
{
|
||||||
for(list<T*>::iterator i = l.begin(); i != l.end(); )
|
for(list<T*>::iterator i = l.begin(); i != l.end(); )
|
||||||
|
|
|
@ -55,12 +55,7 @@ void GSTextureCache10::GSRenderTargetHW10::Update()
|
||||||
TEXA.TA0 = 0;
|
TEXA.TA0 = 0;
|
||||||
TEXA.TA1 = 0x80;
|
TEXA.TA1 = 0x80;
|
||||||
|
|
||||||
GIFRegCLAMP CLAMP;
|
m_renderer->m_mem.ReadTexture(r, buff, pitch, m_TEX0, TEXA);
|
||||||
|
|
||||||
CLAMP.WMS = 0;
|
|
||||||
CLAMP.WMT = 0;
|
|
||||||
|
|
||||||
m_renderer->m_mem.ReadTexture(r, buff, pitch, m_TEX0, TEXA, CLAMP);
|
|
||||||
|
|
||||||
// s->m_perfmon.Put(GSPerfMon::Unswizzle, w * h * 4);
|
// s->m_perfmon.Put(GSPerfMon::Unswizzle, w * h * 4);
|
||||||
|
|
||||||
|
@ -182,7 +177,6 @@ bool GSTextureCache10::GSCachedTextureHW10::Create()
|
||||||
// m_renderer->m_perfmon.Put(GSPerfMon::WriteTexture, 1);
|
// m_renderer->m_perfmon.Put(GSPerfMon::WriteTexture, 1);
|
||||||
|
|
||||||
m_TEX0 = m_renderer->m_context->TEX0;
|
m_TEX0 = m_renderer->m_context->TEX0;
|
||||||
m_CLAMP = m_renderer->m_context->CLAMP;
|
|
||||||
|
|
||||||
uint32 psm = m_TEX0.PSM;
|
uint32 psm = m_TEX0.PSM;
|
||||||
|
|
||||||
|
@ -240,7 +234,6 @@ bool GSTextureCache10::GSCachedTextureHW10::Create(GSRenderTarget* rt)
|
||||||
// m_renderer->m_perfmon.Put(GSPerfMon::ConvertRT2T, 1);
|
// m_renderer->m_perfmon.Put(GSPerfMon::ConvertRT2T, 1);
|
||||||
|
|
||||||
m_TEX0 = m_renderer->m_context->TEX0;
|
m_TEX0 = m_renderer->m_context->TEX0;
|
||||||
m_CLAMP = m_renderer->m_context->CLAMP;
|
|
||||||
m_rendered = true;
|
m_rendered = true;
|
||||||
|
|
||||||
int tw = 1 << m_TEX0.TW;
|
int tw = 1 << m_TEX0.TW;
|
||||||
|
|
|
@ -57,12 +57,7 @@ void GSTextureCache9::GSRenderTarget9::Update()
|
||||||
TEXA.TA0 = 0;
|
TEXA.TA0 = 0;
|
||||||
TEXA.TA1 = 0x80;
|
TEXA.TA1 = 0x80;
|
||||||
|
|
||||||
GIFRegCLAMP CLAMP;
|
m_renderer->m_mem.ReadTexture(r, bits, pitch, m_TEX0, TEXA);
|
||||||
|
|
||||||
CLAMP.WMS = 0;
|
|
||||||
CLAMP.WMT = 0;
|
|
||||||
|
|
||||||
m_renderer->m_mem.ReadTexture(r, bits, pitch, m_TEX0, TEXA, CLAMP);
|
|
||||||
|
|
||||||
t->Unmap();
|
t->Unmap();
|
||||||
|
|
||||||
|
@ -181,7 +176,6 @@ bool GSTextureCache9::GSCachedTexture9::Create()
|
||||||
// m_renderer->m_perfmon.Put(GSPerfMon::WriteTexture, 1);
|
// m_renderer->m_perfmon.Put(GSPerfMon::WriteTexture, 1);
|
||||||
|
|
||||||
m_TEX0 = m_renderer->m_context->TEX0;
|
m_TEX0 = m_renderer->m_context->TEX0;
|
||||||
m_CLAMP = m_renderer->m_context->CLAMP;
|
|
||||||
|
|
||||||
uint32 psm = m_TEX0.PSM;
|
uint32 psm = m_TEX0.PSM;
|
||||||
|
|
||||||
|
@ -239,7 +233,6 @@ bool GSTextureCache9::GSCachedTexture9::Create(GSRenderTarget* rt)
|
||||||
// m_renderer->m_perfmon.Put(GSPerfMon::ConvertRT2T, 1);
|
// m_renderer->m_perfmon.Put(GSPerfMon::ConvertRT2T, 1);
|
||||||
|
|
||||||
m_TEX0 = m_renderer->m_context->TEX0;
|
m_TEX0 = m_renderer->m_context->TEX0;
|
||||||
m_CLAMP = m_renderer->m_context->CLAMP;
|
|
||||||
m_rendered = true;
|
m_rendered = true;
|
||||||
|
|
||||||
int tw = 1 << m_TEX0.TW;
|
int tw = 1 << m_TEX0.TW;
|
||||||
|
|
|
@ -46,8 +46,7 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE
|
||||||
{
|
{
|
||||||
GSTexture* t2 = (*i).first;
|
GSTexture* t2 = (*i).first;
|
||||||
|
|
||||||
// if(t2->m_TEX0.TBP0 != TEX0.TBP0 || t2->m_TEX0.TBW != TEX0.TBW || t2->m_TEX0.PSM != TEX0.PSM || t2->m_TEX0.TW != TEX0.TW || t2->m_TEX0.TH != TEX0.TH)
|
if(((t2->m_TEX0.u32[0] ^ TEX0.u32[0]) | ((t2->m_TEX0.u32[1] ^ TEX0.u32[1]) & 3)) != 0) // TBP0 TBW PSM TW TH
|
||||||
if(((t2->m_TEX0.u32[0] ^ TEX0.u32[0]) | ((t2->m_TEX0.u32[1] ^ TEX0.u32[1]) & 3)) != 0)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
|
||||||
|
|
||||||
if(i == m_ps.end())
|
if(i == m_ps.end())
|
||||||
{
|
{
|
||||||
string str[13];
|
string str[14];
|
||||||
|
|
||||||
str[0] = format("%d", sel.fst);
|
str[0] = format("%d", sel.fst);
|
||||||
str[1] = format("%d", sel.wms);
|
str[1] = format("%d", sel.wms);
|
||||||
|
@ -228,6 +228,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
|
||||||
str[10] = format("%d", sel.clr1);
|
str[10] = format("%d", sel.clr1);
|
||||||
str[11] = format("%d", sel.fba);
|
str[11] = format("%d", sel.fba);
|
||||||
str[12] = format("%d", sel.aout);
|
str[12] = format("%d", sel.aout);
|
||||||
|
str[13] = format("%d", sel.ltf);
|
||||||
|
|
||||||
D3D10_SHADER_MACRO macro[] =
|
D3D10_SHADER_MACRO macro[] =
|
||||||
{
|
{
|
||||||
|
@ -244,6 +245,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
|
||||||
{"CLR1", str[10].c_str()},
|
{"CLR1", str[10].c_str()},
|
||||||
{"FBA", str[11].c_str()},
|
{"FBA", str[11].c_str()},
|
||||||
{"AOUT", str[12].c_str()},
|
{"AOUT", str[12].c_str()},
|
||||||
|
{"LTF", str[13].c_str()},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -280,11 +282,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
|
||||||
|
|
||||||
memset(&sd, 0, sizeof(sd));
|
memset(&sd, 0, sizeof(sd));
|
||||||
|
|
||||||
sd.Filter = D3D10_ENCODE_BASIC_FILTER(
|
sd.Filter = ssel.ltf ? D3D10_FILTER_MIN_MAG_LINEAR_MIP_POINT : D3D10_FILTER_MIN_MAG_MIP_POINT;
|
||||||
(ssel.min ? D3D10_FILTER_TYPE_LINEAR : D3D10_FILTER_TYPE_POINT),
|
|
||||||
(ssel.mag ? D3D10_FILTER_TYPE_LINEAR : D3D10_FILTER_TYPE_POINT),
|
|
||||||
D3D10_FILTER_TYPE_POINT,
|
|
||||||
false);
|
|
||||||
|
|
||||||
sd.AddressU = ssel.tau ? D3D10_TEXTURE_ADDRESS_WRAP : D3D10_TEXTURE_ADDRESS_CLAMP;
|
sd.AddressU = ssel.tau ? D3D10_TEXTURE_ADDRESS_WRAP : D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
sd.AddressV = ssel.tav ? D3D10_TEXTURE_ADDRESS_WRAP : D3D10_TEXTURE_ADDRESS_CLAMP;
|
sd.AddressV = ssel.tav ? D3D10_TEXTURE_ADDRESS_WRAP : D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
|
|
@ -77,7 +77,11 @@ public:
|
||||||
|
|
||||||
__declspec(align(16)) struct PSConstantBuffer
|
__declspec(align(16)) struct PSConstantBuffer
|
||||||
{
|
{
|
||||||
GSVector4 FogColor;
|
GSVector4 FogColorAREF;
|
||||||
|
GSVector4 HalfTexel;
|
||||||
|
GSVector2 WH;
|
||||||
|
float TA0;
|
||||||
|
float TA1;
|
||||||
float MINU;
|
float MINU;
|
||||||
float MINV;
|
float MINV;
|
||||||
float MAXU;
|
float MAXU;
|
||||||
|
@ -86,13 +90,6 @@ public:
|
||||||
uint32 VMSK;
|
uint32 VMSK;
|
||||||
uint32 UFIX;
|
uint32 UFIX;
|
||||||
uint32 VFIX;
|
uint32 VFIX;
|
||||||
float TA0;
|
|
||||||
float TA1;
|
|
||||||
float AREF;
|
|
||||||
float _pad[1];
|
|
||||||
GSVector2 WH;
|
|
||||||
GSVector2 rWrH;
|
|
||||||
GSVector4 HalfTexel;
|
|
||||||
|
|
||||||
struct PSConstantBuffer() {memset(this, 0, sizeof(*this));}
|
struct PSConstantBuffer() {memset(this, 0, sizeof(*this));}
|
||||||
|
|
||||||
|
@ -106,16 +103,14 @@ public:
|
||||||
GSVector4i b2 = b[2];
|
GSVector4i b2 = b[2];
|
||||||
GSVector4i b3 = b[3];
|
GSVector4i b3 = b[3];
|
||||||
GSVector4i b4 = b[4];
|
GSVector4i b4 = b[4];
|
||||||
GSVector4i b5 = b[5];
|
|
||||||
|
|
||||||
if(!((a[0] == b0) & (a[1] == b1) & (a[2] == b2) & (a[3] == b3) & (a[4] == b4) & (a[5] == b5)).alltrue())
|
if(!((a[0] == b0) & (a[1] == b1) & (a[2] == b2) & (a[3] == b3) & (a[4] == b4)).alltrue())
|
||||||
{
|
{
|
||||||
a[0] = b0;
|
a[0] = b0;
|
||||||
a[1] = b1;
|
a[1] = b1;
|
||||||
a[2] = b2;
|
a[2] = b2;
|
||||||
a[3] = b3;
|
a[3] = b3;
|
||||||
a[4] = b4;
|
a[4] = b4;
|
||||||
a[5] = b5;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -124,6 +119,19 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
union GSSelector
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32 iip:1;
|
||||||
|
uint32 prim:2;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32 key;
|
||||||
|
|
||||||
|
operator uint32() {return key & 0x7;}
|
||||||
|
};
|
||||||
|
|
||||||
union PSSelector
|
union PSSelector
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
@ -141,24 +149,12 @@ public:
|
||||||
uint32 clr1:1;
|
uint32 clr1:1;
|
||||||
uint32 fba:1;
|
uint32 fba:1;
|
||||||
uint32 aout:1;
|
uint32 aout:1;
|
||||||
|
uint32 ltf:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
|
|
||||||
operator uint32() {return key & 0x1fffff;}
|
operator uint32() {return key & 0x3fffff;}
|
||||||
};
|
|
||||||
|
|
||||||
union GSSelector
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint32 iip:1;
|
|
||||||
uint32 prim:2;
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32 key;
|
|
||||||
|
|
||||||
operator uint32() {return key & 0x7;}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union PSSamplerSelector
|
union PSSamplerSelector
|
||||||
|
@ -167,13 +163,12 @@ public:
|
||||||
{
|
{
|
||||||
uint32 tau:1;
|
uint32 tau:1;
|
||||||
uint32 tav:1;
|
uint32 tav:1;
|
||||||
uint32 min:1;
|
uint32 ltf:1;
|
||||||
uint32 mag:1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
|
|
||||||
operator uint32() {return key & 0xf;}
|
operator uint32() {return key & 0x7;}
|
||||||
};
|
};
|
||||||
|
|
||||||
union OMDepthStencilSelector
|
union OMDepthStencilSelector
|
||||||
|
|
|
@ -180,7 +180,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
||||||
|
|
||||||
if(i == m_ps.end())
|
if(i == m_ps.end())
|
||||||
{
|
{
|
||||||
string str[12];
|
string str[13];
|
||||||
|
|
||||||
str[0] = format("%d", sel.fst);
|
str[0] = format("%d", sel.fst);
|
||||||
str[1] = format("%d", sel.wms);
|
str[1] = format("%d", sel.wms);
|
||||||
|
@ -194,6 +194,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
||||||
str[9] = format("%d", sel.fog);
|
str[9] = format("%d", sel.fog);
|
||||||
str[10] = format("%d", sel.clr1);
|
str[10] = format("%d", sel.clr1);
|
||||||
str[11] = format("%d", sel.rt);
|
str[11] = format("%d", sel.rt);
|
||||||
|
str[12] = format("%d", sel.ltf);
|
||||||
|
|
||||||
D3DXMACRO macro[] =
|
D3DXMACRO macro[] =
|
||||||
{
|
{
|
||||||
|
@ -209,6 +210,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
||||||
{"FOG", str[9].c_str()},
|
{"FOG", str[9].c_str()},
|
||||||
{"CLR1", str[10].c_str()},
|
{"CLR1", str[10].c_str()},
|
||||||
{"RT", str[11].c_str()},
|
{"RT", str[11].c_str()},
|
||||||
|
{"LTF", str[12].c_str()},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -227,10 +229,10 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
||||||
|
|
||||||
if(sel.tfx != 4)
|
if(sel.tfx != 4)
|
||||||
{
|
{
|
||||||
bool b = sel.bpp < 3 && sel.wms < 3 && sel.wmt < 3;
|
if(!(sel.bpp < 3 && sel.wms < 3 && sel.wmt < 3))
|
||||||
|
{
|
||||||
ssel.min = b;
|
ssel.ltf = 0;
|
||||||
ssel.mag = b;
|
}
|
||||||
|
|
||||||
hash_map<uint32, Direct3DSamplerState9* >::const_iterator i = m_ps_ss.find(ssel);
|
hash_map<uint32, Direct3DSamplerState9* >::const_iterator i = m_ps_ss.find(ssel);
|
||||||
|
|
||||||
|
@ -244,8 +246,8 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
||||||
|
|
||||||
memset(ss, 0, sizeof(*ss));
|
memset(ss, 0, sizeof(*ss));
|
||||||
|
|
||||||
ss->FilterMin[0] = ssel.min ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
ss->FilterMin[0] = ssel.ltf ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
||||||
ss->FilterMag[0] = ssel.mag ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
ss->FilterMag[0] = ssel.ltf ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
||||||
ss->FilterMin[1] = D3DTEXF_POINT;
|
ss->FilterMin[1] = D3DTEXF_POINT;
|
||||||
ss->FilterMag[1] = D3DTEXF_POINT;
|
ss->FilterMag[1] = D3DTEXF_POINT;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,11 @@ public:
|
||||||
|
|
||||||
struct PSConstantBuffer
|
struct PSConstantBuffer
|
||||||
{
|
{
|
||||||
GSVector4 FogColor;
|
GSVector4 FogColorAREF;
|
||||||
|
GSVector4 HalfTexel;
|
||||||
|
GSVector2 WH;
|
||||||
|
float TA0;
|
||||||
|
float TA1;
|
||||||
float MINU;
|
float MINU;
|
||||||
float MINV;
|
float MINV;
|
||||||
float MAXU;
|
float MAXU;
|
||||||
|
@ -62,13 +66,6 @@ public:
|
||||||
uint32 VMSK;
|
uint32 VMSK;
|
||||||
uint32 UFIX;
|
uint32 UFIX;
|
||||||
uint32 VFIX;
|
uint32 VFIX;
|
||||||
float TA0;
|
|
||||||
float TA1;
|
|
||||||
float AREF;
|
|
||||||
float _pad[1];
|
|
||||||
GSVector2 WH;
|
|
||||||
GSVector2 rWrH;
|
|
||||||
GSVector4 HalfTexel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union PSSelector
|
union PSSelector
|
||||||
|
@ -87,11 +84,12 @@ public:
|
||||||
uint32 fog:1;
|
uint32 fog:1;
|
||||||
uint32 clr1:1;
|
uint32 clr1:1;
|
||||||
uint32 rt:1;
|
uint32 rt:1;
|
||||||
|
uint32 ltf:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
|
|
||||||
operator uint32() {return key & 0xfffff;}
|
operator uint32() {return key & 0x1fffff;}
|
||||||
};
|
};
|
||||||
|
|
||||||
union PSSamplerSelector
|
union PSSamplerSelector
|
||||||
|
@ -100,13 +98,12 @@ public:
|
||||||
{
|
{
|
||||||
uint32 tau:1;
|
uint32 tau:1;
|
||||||
uint32 tav:1;
|
uint32 tav:1;
|
||||||
uint32 min:1;
|
uint32 ltf:1;
|
||||||
uint32 mag:1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
|
|
||||||
operator uint32() {return key & 0xf;}
|
operator uint32() {return key & 0x7;}
|
||||||
};
|
};
|
||||||
|
|
||||||
union OMDepthStencilSelector
|
union OMDepthStencilSelector
|
||||||
|
|
|
@ -1398,6 +1398,14 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\GSTextureCache.cpp"
|
RelativePath=".\GSTextureCache.cpp"
|
||||||
>
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release SSE4|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AssemblerOutput="4"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\GSTextureCache10.cpp"
|
RelativePath=".\GSTextureCache10.cpp"
|
||||||
|
|
|
@ -162,18 +162,16 @@ SamplerState PaletteSampler;
|
||||||
|
|
||||||
cbuffer cb1
|
cbuffer cb1
|
||||||
{
|
{
|
||||||
float4 FogColor;
|
float3 FogColor;
|
||||||
|
float AREF;
|
||||||
|
float4 HalfTexel;
|
||||||
|
float2 WH;
|
||||||
|
float TA0;
|
||||||
|
float TA1;
|
||||||
float2 MINUV;
|
float2 MINUV;
|
||||||
float2 MAXUV;
|
float2 MAXUV;
|
||||||
uint2 UVMSK;
|
uint2 UVMSK;
|
||||||
uint2 UVFIX;
|
uint2 UVFIX;
|
||||||
float TA0;
|
|
||||||
float TA1;
|
|
||||||
float AREF;
|
|
||||||
float _pad;
|
|
||||||
float2 WH;
|
|
||||||
float2 rWrH;
|
|
||||||
float4 HalfTexel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
|
@ -191,18 +189,19 @@ struct PS_OUTPUT
|
||||||
|
|
||||||
#ifndef FST
|
#ifndef FST
|
||||||
#define FST 0
|
#define FST 0
|
||||||
#define WMS 0
|
#define WMS 1
|
||||||
#define WMT 0
|
#define WMT 1
|
||||||
#define BPP 0
|
#define BPP 0
|
||||||
#define AEM 0
|
#define AEM 0
|
||||||
#define TFX 0
|
#define TFX 0
|
||||||
#define TCC 1
|
#define TCC 1
|
||||||
#define ATE 0
|
#define ATE 1
|
||||||
#define ATST 2
|
#define ATST 2
|
||||||
#define FOG 0
|
#define FOG 1
|
||||||
#define CLR1 0
|
#define CLR1 0
|
||||||
#define FBA 0
|
#define FBA 0
|
||||||
#define AOUT 0
|
#define AOUT 0
|
||||||
|
#define LTF 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float4 Normalize16(float4 f)
|
float4 Normalize16(float4 f)
|
||||||
|
@ -377,7 +376,14 @@ float4 sample(float2 tc, float w)
|
||||||
t11 = Texture.Load(int3(iuv.zw, 0));
|
t11 = Texture.Load(int3(iuv.zw, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y);
|
if(LTF)
|
||||||
|
{
|
||||||
|
t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t = t00;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BPP == 1) // 24
|
if(BPP == 1) // 24
|
||||||
|
|
|
@ -71,19 +71,16 @@ VS_OUTPUT vs_main(VS_INPUT input)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 ps_params[6];
|
float4 ps_params[4];
|
||||||
|
|
||||||
#define FogColor ps_params[0].bgra
|
#define FogColor ps_params[0].bgr
|
||||||
#define MINUV ps_params[1].xy
|
#define AREF ps_params[0].a
|
||||||
#define MAXUV ps_params[1].zw
|
#define HalfTexel ps_params[1]
|
||||||
#define UVMSK ps_params[2].xy
|
#define WH ps_params[2].xy
|
||||||
#define UVFIX ps_params[2].zw
|
#define TA0 ps_params[2].z
|
||||||
#define TA0 ps_params[3].x
|
#define TA1 ps_params[2].w
|
||||||
#define TA1 ps_params[3].y
|
#define MINUV ps_params[3].xy
|
||||||
#define AREF ps_params[3].z
|
#define MAXUV ps_params[3].zw
|
||||||
#define WH ps_params[4].xy
|
|
||||||
#define rWrH ps_params[4].zw
|
|
||||||
#define HalfTexel ps_params[5]
|
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
{
|
{
|
||||||
|
@ -93,17 +90,18 @@ struct PS_INPUT
|
||||||
|
|
||||||
#ifndef FST
|
#ifndef FST
|
||||||
#define FST 0
|
#define FST 0
|
||||||
#define WMS 3
|
#define WMS 1
|
||||||
#define WMT 3
|
#define WMT 1
|
||||||
#define BPP 0
|
#define BPP 0
|
||||||
#define AEM 0
|
#define AEM 0
|
||||||
#define TFX 0
|
#define TFX 0
|
||||||
#define TCC 1
|
#define TCC 1
|
||||||
#define ATE 0
|
#define ATE 1
|
||||||
#define ATST 0
|
#define ATST 4
|
||||||
#define FOG 0
|
#define FOG 1
|
||||||
#define CLR1 0
|
#define CLR1 0
|
||||||
#define RT 0
|
#define RT 0
|
||||||
|
#define LTF 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sampler Texture : register(s0);
|
sampler Texture : register(s0);
|
||||||
|
@ -252,7 +250,14 @@ float4 sample(float2 tc, float w)
|
||||||
t11 = tex2D(Texture, uv.zw);
|
t11 = tex2D(Texture, uv.zw);
|
||||||
}
|
}
|
||||||
|
|
||||||
t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y);
|
if(LTF)
|
||||||
|
{
|
||||||
|
t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t = t00;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BPP == 0) // 32
|
if(BPP == 0) // 32
|
||||||
|
@ -350,7 +355,7 @@ float4 fog(float4 c, float f)
|
||||||
{
|
{
|
||||||
if(FOG == 1)
|
if(FOG == 1)
|
||||||
{
|
{
|
||||||
c.rgb = lerp(FogColor.rgb, c.rgb, f);
|
c.rgb = lerp(FogColor, c.rgb, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
Loading…
Reference in New Issue