From b1536a755f5327035aecd1d931d0fa1e6994f20a Mon Sep 17 00:00:00 2001 From: "sudonim1@gmail.com" Date: Fri, 8 Feb 2013 15:36:54 +0000 Subject: [PATCH] GSDX: Nothing is fixed, the last two revisions did not happen. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5549 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSClut.cpp | 12 ++-- plugins/GSdx/GSLocalMemory.cpp | 74 ++++++++++++------------ plugins/GSdx/GSLocalMemory.h | 94 ++++++++++++++++--------------- plugins/GSdx/GSRendererDX.cpp | 2 +- plugins/GSdx/GSState.cpp | 48 ++++++++-------- plugins/GSdx/GSTextureCache.cpp | 7 +-- plugins/GSdx/GSTextureCacheSW.cpp | 4 +- 7 files changed, 123 insertions(+), 118 deletions(-) diff --git a/plugins/GSdx/GSClut.cpp b/plugins/GSdx/GSClut.cpp index bfe6274fdb..f61dabcfe6 100644 --- a/plugins/GSdx/GSClut.cpp +++ b/plugins/GSdx/GSClut.cpp @@ -172,14 +172,14 @@ template void GSClut::WriteCLUT32_CSM2(const GIFRegTEX0& TEX0, const GIFR { GSOffset* o = m_mem->GetOffset(TEX0.CBP, TEXCLUT.CBW, PSM_PSMCT32); - uint32 addr = o->pixel.row[TEXCLUT.COV]; + uint32* RESTRICT s = &m_mem->m_vm32[o->pixel.row[TEXCLUT.COV]]; int* RESTRICT col = &o->pixel.col[0][TEXCLUT.COU << 4]; uint16* RESTRICT clut = m_clut + (TEX0.CSA << 4); for(int i = 0; i < n; i++) { - uint32 c = m_mem->ReadPixel32(addr + col[i]); + uint32 c = s[col[i]]; clut[i] = (uint16)(c & 0xffff); clut[i + 256] = (uint16)(c >> 16); @@ -190,14 +190,14 @@ template void GSClut::WriteCLUT16_CSM2(const GIFRegTEX0& TEX0, const GIFR { GSOffset* o = m_mem->GetOffset(TEX0.CBP, TEXCLUT.CBW, PSM_PSMCT16); - uint32 addr = o->pixel.row[TEXCLUT.COV]; + uint16* RESTRICT s = &m_mem->m_vm16[o->pixel.row[TEXCLUT.COV]]; int* RESTRICT col = &o->pixel.col[0][TEXCLUT.COU << 4]; uint16* RESTRICT clut = m_clut + (TEX0.CSA << 4); for(int i = 0; i < n; i++) { - clut[i] = (uint16)m_mem->ReadPixel16(addr + col[i]); + clut[i] = s[col[i]]; } } @@ -205,14 +205,14 @@ template void GSClut::WriteCLUT16S_CSM2(const GIFRegTEX0& TEX0, const GIF { GSOffset* o = m_mem->GetOffset(TEX0.CBP, TEXCLUT.CBW, PSM_PSMCT16S); - uint32 addr = o->pixel.row[TEXCLUT.COV]; + uint16* RESTRICT s = &m_mem->m_vm16[o->pixel.row[TEXCLUT.COV]]; int* RESTRICT col = &o->pixel.col[0][TEXCLUT.COU << 4]; uint16* RESTRICT clut = m_clut + (TEX0.CSA << 4); for(int i = 0; i < n; i++) { - clut[i] = (uint16)m_mem->ReadPixel16(addr + col[i]); + clut[i] = s[col[i]]; } } diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 990ee3c12b..dac52f6d95 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -83,11 +83,9 @@ GSLocalMemory::psm_t GSLocalMemory::m_psm[64]; GSLocalMemory::GSLocalMemory() : m_clut(this) { - m_vm8 = (uint8*)vmalloc(m_vmsize * 16, false); + m_vm8 = (uint8*)vmalloc(m_vmsize * 2, false); m_vm16 = (uint16*)m_vm8; m_vm32 = (uint32*)m_vm8; - DWORD oldprotect; - VirtualProtect(m_vm8 + m_vmsize, m_vmsize * 15, PAGE_NOACCESS, &oldprotect); memset(m_vm8, 0, m_vmsize); @@ -623,7 +621,7 @@ vector* GSLocalMemory::GetPage2TileMap(const GIFRegTEX0& TEX0) for(int x = 0, i = y << 7; x < tw; x += bs.x, i += bs.x) { - uint32 page = (base + o->block.col[x >> 3]) >> 5 & 511; + uint32 page = (base + o->block.col[x >> 3]) >> 5; if(page < MAX_PAGES) { @@ -1385,8 +1383,6 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB int sx = (int)TRXPOS.SSAX; int ex = sx + (int)TRXREG.RRW; - uint32 addr = psm->pa(0, y, bp, bw); - switch(BITBLTBUF.SPSM) { case PSM_PSMCT32: @@ -1399,18 +1395,19 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* RESTRICT offset = psm->rowOffset[y & 7]; + uint32* RESTRICT ps = &m_vm32[psm->pa(0, y, bp, bw)]; for(int ex4 = ex - 4; len >= 4 && x <= ex4; len -= 4, x += 4, pd += 4) { - pd[0] = ReadPixel32(addr + offset[x + 0]); - pd[1] = ReadPixel32(addr + offset[x + 1]); - pd[2] = ReadPixel32(addr + offset[x + 2]); - pd[3] = ReadPixel32(addr + offset[x + 3]); + pd[0] = ps[offset[x + 0]]; + pd[1] = ps[offset[x + 1]]; + pd[2] = ps[offset[x + 2]]; + pd[3] = ps[offset[x + 3]]; } for(; len > 0 && x < ex; len--, x++, pd++) { - *pd = ReadPixel32(addr + offset[x]); + *pd = ps[offset[x]]; } if(x == ex) {x = sx; y++;} @@ -1426,10 +1423,11 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* RESTRICT offset = psm->rowOffset[y & 7]; + uint32* RESTRICT ps = &m_vm32[psm->pa(0, y, bp, bw)]; for(; len > 0 && x < ex; len--, x++, pb += 3) { - uint32 c = ReadPixel32(addr + offset[x]); + uint32 c = ps[offset[x]]; pb[0] = (uint8)(c); pb[1] = (uint8)(c >> 8); @@ -1451,18 +1449,19 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* RESTRICT offset = psm->rowOffset[y & 7]; + uint16* RESTRICT ps = &m_vm16[psm->pa(0, y, bp, bw)]; for(int ex4 = ex - 4; len >= 4 && x <= ex4; len -= 4, x += 4, pw += 4) { - pw[0] = (uint16)ReadPixel16(addr + offset[x + 0]); - pw[1] = (uint16)ReadPixel16(addr + offset[x + 1]); - pw[2] = (uint16)ReadPixel16(addr + offset[x + 2]); - pw[3] = (uint16)ReadPixel16(addr + offset[x + 3]); + pw[0] = ps[offset[x + 0]]; + pw[1] = ps[offset[x + 1]]; + pw[2] = ps[offset[x + 2]]; + pw[3] = ps[offset[x + 3]]; } for(; len > 0 && x < ex; len--, x++, pw++) { - *pw = (uint16)ReadPixel16(addr + offset[x]); + *pw = ps[offset[x]]; } if(x == ex) {x = sx; y++;} @@ -1475,18 +1474,19 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* RESTRICT offset = psm->rowOffset[y & 7]; + uint8* RESTRICT ps = &m_vm8[psm->pa(0, y, bp, bw)]; for(int ex4 = ex - 4; len >= 4 && x <= ex4; len -= 4, x += 4, pb += 4) { - pb[0] = (uint8)ReadPixel8(addr + offset[x + 0]); - pb[1] = (uint8)ReadPixel8(addr + offset[x + 1]); - pb[2] = (uint8)ReadPixel8(addr + offset[x + 2]); - pb[3] = (uint8)ReadPixel8(addr + offset[x + 3]); + pb[0] = ps[offset[x + 0]]; + pb[1] = ps[offset[x + 1]]; + pb[2] = ps[offset[x + 2]]; + pb[3] = ps[offset[x + 3]]; } for(; len > 0 && x < ex; len--, x++, pb++) { - *pb = (uint8)ReadPixel8(addr + offset[x]); + *pb = ps[offset[x]]; } if(x == ex) {x = sx; y++;} @@ -1498,11 +1498,12 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { + uint32 addr = psm->pa(0, y, bp, bw); int* RESTRICT offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) { - *pb = (uint8)(ReadPixel4(addr + offset[x + 0]) | (ReadPixel4(addr + offset[x + 1]) << 4)); + *pb = ReadPixel4(addr + offset[x + 0]) | (ReadPixel4(addr + offset[x + 1]) << 4); } if(x == ex) {x = sx; y++;} @@ -1515,18 +1516,19 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* RESTRICT offset = psm->rowOffset[y & 7]; + uint32* RESTRICT ps = &m_vm32[psm->pa(0, y, bp, bw)]; for(int ex4 = ex - 4; len >= 4 && x <= ex4; len -= 4, x += 4, pb += 4) { - pb[0] = (uint8)ReadPixel8H(addr + offset[x + 0]); - pb[1] = (uint8)ReadPixel8H(addr + offset[x + 1]); - pb[2] = (uint8)ReadPixel8H(addr + offset[x + 2]); - pb[3] = (uint8)ReadPixel8H(addr + offset[x + 3]); + pb[0] = (uint8)(ps[offset[x + 0]] >> 24); + pb[1] = (uint8)(ps[offset[x + 1]] >> 24); + pb[2] = (uint8)(ps[offset[x + 2]] >> 24); + pb[3] = (uint8)(ps[offset[x + 3]] >> 24); } for(; len > 0 && x < ex; len--, x++, pb++) { - *pb = (uint8)ReadPixel8H(addr + offset[x]); + *pb = (uint8)(ps[offset[x]] >> 24); } if(x == ex) {x = sx; y++;} @@ -1539,13 +1541,14 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* offset = psm->rowOffset[y & 7]; + uint32* RESTRICT ps = &m_vm32[psm->pa(0, y, bp, bw)]; for(; len > 0 && x < ex; len--, x += 2, pb++) { - uint32 c0 = ReadPixel4HL(addr + offset[x + 0]); - uint32 c1 = ReadPixel4HL(addr + offset[x + 1]); + uint32 c0 = (ps[offset[x + 0]] >> 24) & 0x0f; + uint32 c1 = (ps[offset[x + 1]] >> 20) & 0xf0; - *pb = (uint8)(c0 | c1 << 4); + *pb = (uint8)(c0 | c1); } if(x == ex) {x = sx; y++;} @@ -1558,13 +1561,14 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITB while(len > 0) { int* RESTRICT offset = psm->rowOffset[y & 7]; + uint32* RESTRICT ps = &m_vm32[psm->pa(0, y, bp, bw)]; for(; len > 0 && x < ex; len--, x += 2, pb++) { - uint32 c0 = ReadPixel4HH(addr + offset[x + 0]); - uint32 c1 = ReadPixel4HH(addr + offset[x + 1]); + uint32 c0 = (ps[offset[x + 0]] >> 28) & 0x0f; + uint32 c1 = (ps[offset[x + 1]] >> 24) & 0xf0; - *pb = (uint8)(c0 | c1 << 4); + *pb = (uint8)(c0 | c1); } if(x == ex) {x = sx; y++;} @@ -2036,7 +2040,7 @@ uint32* GSOffset::GetPages(const GSVector4i& rect, uint32* pages, GSVector4i* bb for(int x = r.left; x < r.right; x += bs.x) { - uint32 n = (base + block.col[x]) >> 5 & (MAX_PAGES-1); + uint32 n = (base + block.col[x]) >> 5; if(n < MAX_PAGES) { diff --git a/plugins/GSdx/GSLocalMemory.h b/plugins/GSdx/GSLocalMemory.h index ee3c8da939..2a7e16426b 100644 --- a/plugins/GSdx/GSLocalMemory.h +++ b/plugins/GSdx/GSLocalMemory.h @@ -186,51 +186,53 @@ public: static uint32 BlockNumber32(int x, int y, uint32 bp, uint32 bw) { - return bp + (y & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable32[(y >> 3) & 3][(x >> 3) & 7] & 16383; + return bp + (y & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable32[(y >> 3) & 3][(x >> 3) & 7]; } static uint32 BlockNumber16(int x, int y, uint32 bp, uint32 bw) { - return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16[(y >> 3) & 7][(x >> 4) & 3] & 16383; + return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16[(y >> 3) & 7][(x >> 4) & 3]; } static uint32 BlockNumber16S(int x, int y, uint32 bp, uint32 bw) { - return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16S[(y >> 3) & 7][(x >> 4) & 3] & 16383; + return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16S[(y >> 3) & 7][(x >> 4) & 3]; } static uint32 BlockNumber8(int x, int y, uint32 bp, uint32 bw) { // ASSERT((bw & 1) == 0); // allowed for mipmap levels - return bp + ((y >> 1) & ~0x1f) * (bw >> 1) + ((x >> 2) & ~0x1f) + blockTable8[(y >> 4) & 3][(x >> 4) & 7] & 16383; + return bp + ((y >> 1) & ~0x1f) * (bw >> 1) + ((x >> 2) & ~0x1f) + blockTable8[(y >> 4) & 3][(x >> 4) & 7]; } static uint32 BlockNumber4(int x, int y, uint32 bp, uint32 bw) { // ASSERT((bw & 1) == 0); // allowed for mipmap levels - return bp + ((y >> 2) & ~0x1f) * (bw >> 1) + ((x >> 2) & ~0x1f) + blockTable4[(y >> 4) & 7][(x >> 5) & 3] & 16383; + return bp + ((y >> 2) & ~0x1f) * (bw >> 1) + ((x >> 2) & ~0x1f) + blockTable4[(y >> 4) & 7][(x >> 5) & 3]; } static uint32 BlockNumber32Z(int x, int y, uint32 bp, uint32 bw) { - return bp + (y & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable32Z[(y >> 3) & 3][(x >> 3) & 7] & 16383; + return bp + (y & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable32Z[(y >> 3) & 3][(x >> 3) & 7]; } static uint32 BlockNumber16Z(int x, int y, uint32 bp, uint32 bw) { - return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16Z[(y >> 3) & 7][(x >> 4) & 3] & 16383; + return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16Z[(y >> 3) & 7][(x >> 4) & 3]; } static uint32 BlockNumber16SZ(int x, int y, uint32 bp, uint32 bw) { - return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16SZ[(y >> 3) & 7][(x >> 4) & 3] & 16383; + return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16SZ[(y >> 3) & 7][(x >> 4) & 3]; } uint8* BlockPtr(uint32 bp) const { - return &m_vm8[(bp & MAX_BLOCKS-1) << 8]; + ASSERT(bp < 16384); + + return &m_vm8[bp << 8]; } uint8* BlockPtr32(int x, int y, uint32 bp, uint32 bw) const @@ -315,7 +317,7 @@ public: static __forceinline uint32 PixelAddress32(int x, int y, uint32 bp, uint32 bw) { - uint32 page = (bp >> 5) + (y >> 5) * bw + (x >> 6) & 511; + uint32 page = (bp >> 5) + (y >> 5) * bw + (x >> 6); uint32 word = (page << 11) + pageOffset32[bp & 0x1f][y & 0x1f][x & 0x3f]; return word; @@ -323,7 +325,7 @@ public: static __forceinline uint32 PixelAddress16(int x, int y, uint32 bp, uint32 bw) { - uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6) & 511; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); uint32 word = (page << 12) + pageOffset16[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; @@ -331,7 +333,7 @@ public: static __forceinline uint32 PixelAddress16S(int x, int y, uint32 bp, uint32 bw) { - uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6) & 511; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); uint32 word = (page << 12) + pageOffset16S[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; @@ -341,7 +343,7 @@ public: { // ASSERT((bw & 1) == 0); // allowed for mipmap levels - uint32 page = (bp >> 5) + (y >> 6) * (bw >> 1) + (x >> 7) & 511; + uint32 page = (bp >> 5) + (y >> 6) * (bw >> 1) + (x >> 7); uint32 word = (page << 13) + pageOffset8[bp & 0x1f][y & 0x3f][x & 0x7f]; return word; @@ -351,7 +353,7 @@ public: { // ASSERT((bw & 1) == 0); // allowed for mipmap levels - uint32 page = (bp >> 5) + (y >> 7) * (bw >> 1) + (x >> 7) & 511; + uint32 page = (bp >> 5) + (y >> 7) * (bw >> 1) + (x >> 7); uint32 word = (page << 14) + pageOffset4[bp & 0x1f][y & 0x7f][x & 0x7f]; return word; @@ -359,7 +361,7 @@ public: static __forceinline uint32 PixelAddress32Z(int x, int y, uint32 bp, uint32 bw) { - uint32 page = (bp >> 5) + (y >> 5) * bw + (x >> 6) & 511; + uint32 page = (bp >> 5) + (y >> 5) * bw + (x >> 6); uint32 word = (page << 11) + pageOffset32Z[bp & 0x1f][y & 0x1f][x & 0x3f]; return word; @@ -367,7 +369,7 @@ public: static __forceinline uint32 PixelAddress16Z(int x, int y, uint32 bp, uint32 bw) { - uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6) & 511; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); uint32 word = (page << 12) + pageOffset16Z[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; @@ -375,7 +377,7 @@ public: static __forceinline uint32 PixelAddress16SZ(int x, int y, uint32 bp, uint32 bw) { - uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6) & 511; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); uint32 word = (page << 12) + pageOffset16SZ[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; @@ -385,52 +387,52 @@ public: __forceinline uint32 ReadPixel32(uint32 addr) const { - return m_vm32[addr & 0xFFFFF]; + return m_vm32[addr]; } __forceinline uint32 ReadPixel24(uint32 addr) const { - return m_vm32[addr & 0xFFFFF] & 0x00ffffff; + return m_vm32[addr] & 0x00ffffff; } __forceinline uint32 ReadPixel16(uint32 addr) const { - return (uint32)m_vm16[addr & 0x1FFFFF]; + return (uint32)m_vm16[addr]; } __forceinline uint32 ReadPixel8(uint32 addr) const { - return (uint32)m_vm8[addr & 0x3FFFFF]; + return (uint32)m_vm8[addr]; } __forceinline uint32 ReadPixel4(uint32 addr) const { - return (m_vm8[addr >> 1 & 0x3FFFFF] >> ((addr & 1) << 2)) & 0x0f; + return (m_vm8[addr >> 1] >> ((addr & 1) << 2)) & 0x0f; } __forceinline uint32 ReadPixel8H(uint32 addr) const { - return m_vm32[addr & 0xFFFFF] >> 24; + return m_vm32[addr] >> 24; } __forceinline uint32 ReadPixel4HL(uint32 addr) const { - return (m_vm32[addr & 0xFFFFF] >> 24) & 0x0f; + return (m_vm32[addr] >> 24) & 0x0f; } __forceinline uint32 ReadPixel4HH(uint32 addr) const { - return (m_vm32[addr & 0xFFFFF] >> 28) & 0x0f; + return (m_vm32[addr] >> 28) & 0x0f; } __forceinline uint32 ReadFrame24(uint32 addr) const { - return 0x80000000 | (m_vm32[addr & 0xFFFFF] & 0xffffff); + return 0x80000000 | (m_vm32[addr] & 0xffffff); } __forceinline uint32 ReadFrame16(uint32 addr) const { - uint32 c = (uint32)m_vm16[addr & 0x1FFFFF]; + uint32 c = (uint32)m_vm16[addr]; return ((c & 0x8000) << 16) | ((c & 0x7c00) << 9) | ((c & 0x03e0) << 6) | ((c & 0x001f) << 3); } @@ -532,44 +534,44 @@ public: __forceinline void WritePixel32(uint32 addr, uint32 c) { - m_vm32[addr & 0xFFFFF] = c; + m_vm32[addr] = c; } __forceinline void WritePixel24(uint32 addr, uint32 c) { - m_vm32[addr & 0xFFFFF] = (m_vm32[addr & 0xFFFFF] & 0xff000000) | (c & 0x00ffffff); + m_vm32[addr] = (m_vm32[addr] & 0xff000000) | (c & 0x00ffffff); } __forceinline void WritePixel16(uint32 addr, uint32 c) { - m_vm16[addr & 0x1FFFFF] = (uint16)c; + m_vm16[addr] = (uint16)c; } __forceinline void WritePixel8(uint32 addr, uint32 c) { - m_vm8[addr & 0x3FFFFF] = (uint8)c; + m_vm8[addr] = (uint8)c; } __forceinline void WritePixel4(uint32 addr, uint32 c) { int shift = (addr & 1) << 2; addr >>= 1; - m_vm8[addr & 0x3FFFFF] = (uint8)((m_vm8[addr & 0x3FFFFF] & (0xf0 >> shift)) | ((c & 0x0f) << shift)); + m_vm8[addr] = (uint8)((m_vm8[addr] & (0xf0 >> shift)) | ((c & 0x0f) << shift)); } __forceinline void WritePixel8H(uint32 addr, uint32 c) { - m_vm32[addr & 0xFFFFF] = (m_vm32[addr & 0xFFFFF] & 0x00ffffff) | (c << 24); + m_vm32[addr] = (m_vm32[addr] & 0x00ffffff) | (c << 24); } __forceinline void WritePixel4HL(uint32 addr, uint32 c) { - m_vm32[addr & 0xFFFFF] = (m_vm32[addr & 0xFFFFF] & 0xf0ffffff) | ((c & 0x0f) << 24); + m_vm32[addr] = (m_vm32[addr] & 0xf0ffffff) | ((c & 0x0f) << 24); } __forceinline void WritePixel4HH(uint32 addr, uint32 c) { - m_vm32[addr & 0xFFFFF] = (m_vm32[addr & 0xFFFFF] & 0x0fffffff) | ((c & 0x0f) << 28); + m_vm32[addr] = (m_vm32[addr] & 0x0fffffff) | ((c & 0x0f) << 28); } __forceinline void WriteFrame16(uint32 addr, uint32 c) @@ -672,12 +674,12 @@ public: for(int y = r.top; y < r.bottom; y++, src += pitch) { uint32* RESTRICT s = (uint32*)src; - int d = o->pixel.row[y]; + uint32* RESTRICT d = &m_vm32[o->pixel.row[y]]; int* RESTRICT col = o->pixel.col[0]; for(int x = r.left; x < r.right; x++) { - m_vm32[d + col[x] & 0xFFFFF] = s[x]; + d[col[x]] = s[x]; } } } @@ -689,12 +691,12 @@ public: for(int y = r.top; y < r.bottom; y++, src += pitch) { uint32* RESTRICT s = (uint32*)src; - int d = o->pixel.row[y]; + uint32* RESTRICT d = &m_vm32[o->pixel.row[y]]; int* RESTRICT col = o->pixel.col[0]; for(int x = r.left; x < r.right; x++) { - m_vm32[d + col[x] & 0xFFFFF] = (m_vm32[d + col[x] & 0xFFFFF] & 0xff000000) | (s[x] & 0x00ffffff); + d[col[x]] = (d[col[x]] & 0xff000000) | (s[x] & 0x00ffffff); } } } @@ -706,12 +708,12 @@ public: for(int y = r.top; y < r.bottom; y++, src += pitch) { uint16* RESTRICT s = (uint16*)src; - int d = o->pixel.row[y]; + uint16* RESTRICT d = &m_vm16[o->pixel.row[y]]; int* RESTRICT col = o->pixel.col[0]; for(int x = r.left; x < r.right; x++) { - m_vm16[d + col[x] & 0x1FFFFF] = s[x]; + d[col[x]] = s[x]; } } } @@ -723,7 +725,7 @@ public: for(int y = r.top; y < r.bottom; y++, src += pitch) { uint32* RESTRICT s = (uint32*)src; - int d = o->pixel.row[y]; + uint16* RESTRICT d = &m_vm16[o->pixel.row[y]]; int* RESTRICT col = o->pixel.col[0]; for(int x = r.left; x < r.right; x++) @@ -731,24 +733,24 @@ public: uint32 rb = s[x] & 0x00f800f8; uint32 ga = s[x] & 0x8000f800; - m_vm16[d + col[x] & 0x1FFFFF] = (uint16)((ga >> 16) | (rb >> 9) | (ga >> 6) | (rb >> 3)); + d[col[x]] = (uint16)((ga >> 16) | (rb >> 9) | (ga >> 6) | (rb >> 3)); } } } __forceinline uint32 ReadTexel32(uint32 addr, const GIFRegTEXA& TEXA) const { - return m_vm32[addr & 0xFFFFF]; + return m_vm32[addr]; } __forceinline uint32 ReadTexel24(uint32 addr, const GIFRegTEXA& TEXA) const { - return Expand24To32(m_vm32[addr & 0xFFFFF], TEXA); + return Expand24To32(m_vm32[addr], TEXA); } __forceinline uint32 ReadTexel16(uint32 addr, const GIFRegTEXA& TEXA) const { - return Expand16To32(m_vm16[addr & 0x1FFFFF], TEXA); + return Expand16To32(m_vm16[addr], TEXA); } __forceinline uint32 ReadTexel8(uint32 addr, const GIFRegTEXA& TEXA) const diff --git a/plugins/GSdx/GSRendererDX.cpp b/plugins/GSdx/GSRendererDX.cpp index eab387828a..1349e76c41 100644 --- a/plugins/GSdx/GSRendererDX.cpp +++ b/plugins/GSdx/GSRendererDX.cpp @@ -170,7 +170,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc { if(m_vt.m_max.p.z > 0xffff) { - //ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo + ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo // Fixme : Same as above, I guess. if (m_vt.m_min.p.z > 0xffff) { diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 2cb5d12a9b..6a58518031 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -1572,20 +1572,20 @@ void GSState::Move() { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint32* RESTRICT s = &m_mem.m_vm32[spo->pixel.row[sy]]; + uint32* RESTRICT d = &m_mem.m_vm32[dpo->pixel.row[dy]]; - for(int x = 0; x < w; x++) m_mem.WritePixel32(d + dcol[x], m_mem.ReadPixel32(s + scol[x])); + for(int x = 0; x < w; x++) d[dcol[x]] = s[scol[x]]; } } else { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint32* RESTRICT s = &m_mem.m_vm32[spo->pixel.row[sy]]; + uint32* RESTRICT d = &m_mem.m_vm32[dpo->pixel.row[dy]]; - for(int x = 0; x > -w; x--) m_mem.WritePixel32(d + dcol[x], m_mem.ReadPixel32(s + scol[x])); + for(int x = 0; x > -w; x--) d[dcol[x]] = s[scol[x]]; } } } @@ -1595,20 +1595,20 @@ void GSState::Move() { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint32* RESTRICT s = &m_mem.m_vm32[spo->pixel.row[sy]]; + uint32* RESTRICT d = &m_mem.m_vm32[dpo->pixel.row[dy]]; - for(int x = 0; x < w; x++) m_mem.WritePixel24(d + dcol[x], m_mem.ReadPixel24(s + scol[x])); + for(int x = 0; x < w; x++) d[dcol[x]] = (d[dcol[x]] & 0xff000000) | (s[scol[x]] & 0x00ffffff); } } else { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint32* RESTRICT s = &m_mem.m_vm32[spo->pixel.row[sy]]; + uint32* RESTRICT d = &m_mem.m_vm32[dpo->pixel.row[dy]]; - for(int x = 0; x > -w; x--) m_mem.WritePixel24(d + dcol[x], m_mem.ReadPixel24(s + scol[x])); + for(int x = 0; x > -w; x--) d[dcol[x]] = (d[dcol[x]] & 0xff000000) | (s[scol[x]] & 0x00ffffff); } } } @@ -1618,20 +1618,20 @@ void GSState::Move() { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint16* RESTRICT s = &m_mem.m_vm16[spo->pixel.row[sy]]; + uint16* RESTRICT d = &m_mem.m_vm16[dpo->pixel.row[dy]]; - for(int x = 0; x < w; x++) m_mem.WritePixel16(d + dcol[x], m_mem.ReadPixel16(s + scol[x])); + for(int x = 0; x < w; x++) d[dcol[x]] = s[scol[x]]; } } else { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint16* RESTRICT s = &m_mem.m_vm16[spo->pixel.row[sy]]; + uint16* RESTRICT d = &m_mem.m_vm16[dpo->pixel.row[dy]]; - for(int x = 0; x > -w; x--) m_mem.WritePixel16(d + dcol[x], m_mem.ReadPixel16(s + scol[x])); + for(int x = 0; x > -w; x--) d[dcol[x]] = s[scol[x]]; } } } @@ -1642,26 +1642,26 @@ void GSState::Move() { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint8* RESTRICT s = &m_mem.m_vm8[spo->pixel.row[sy]]; + uint8* RESTRICT d = &m_mem.m_vm8[dpo->pixel.row[dy]]; int* RESTRICT scol = &spo->pixel.col[sy & 7][sx]; int* RESTRICT dcol = &dpo->pixel.col[dy & 7][dx]; - for(int x = 0; x < w; x++) m_mem.WritePixel8(d + dcol[x], m_mem.ReadPixel8(s + scol[x])); + for(int x = 0; x < w; x++) d[dcol[x]] = s[scol[x]]; } } else { for(int y = 0; y < h; y++, sy += yinc, dy += yinc) { - uint32 s = spo->pixel.row[sy]; - uint32 d = dpo->pixel.row[dy]; + uint8* RESTRICT s = &m_mem.m_vm8[spo->pixel.row[sy]]; + uint8* RESTRICT d = &m_mem.m_vm8[dpo->pixel.row[dy]]; int* RESTRICT scol = &spo->pixel.col[sy & 7][sx]; int* RESTRICT dcol = &dpo->pixel.col[dy & 7][dx]; - for(int x = 0; x > -w; x--) m_mem.WritePixel8(d + dcol[x], m_mem.ReadPixel8(s + scol[x])); + for(int x = 0; x > -w; x--) d[dcol[x]] = s[scol[x]]; } } } diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 5f273c5f13..d82ed1242f 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -409,7 +409,6 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* o, const GSVector4i& rect, boo if(GSUtil::HasSharedBits(psm, t->m_TEX0.PSM) && bp < t->m_TEX0.TBP0) { uint32 rowsize = bw * 8192; - // FIXME: what if TBP0 < bp? uint32 offset = (uint32)((t->m_TEX0.TBP0 - bp) * 256); if(rowsize > 0 && offset % rowsize == 0) @@ -923,7 +922,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect) for(int x = r.left, i = (y << 7) + x; x < r.right; x += bs.x, i += bs.x) { - uint32 block = base + o->block.col[x >> 3] & (MAX_BLOCKS-1); + uint32 block = base + o->block.col[x >> 3]; if(block < MAX_BLOCKS) { @@ -952,7 +951,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect) for(int x = r.left; x < r.right; x += bs.x) { - uint32 block = base + o->block.col[x >> 3] & (MAX_BLOCKS-1); + uint32 block = base + o->block.col[x >> 3]; if(block < MAX_BLOCKS) { @@ -1186,7 +1185,7 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, const GSO for(int x = 0; x < tw; x += bs.x) { - uint32 page = (base + o->block.col[x >> 3]) >> 5 & (MAX_PAGES-1); + uint32 page = (base + o->block.col[x >> 3]) >> 5; if(page < MAX_PAGES) { diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 8127cb6c2e..3700e52795 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -278,7 +278,7 @@ bool GSTextureCacheSW::Texture::Update(const GSVector4i& rect) for(int x = r.left, i = (y << 7) + x; x < r.right; x += bs.x, i += bs.x) { - uint32 block = base + o->block.col[x] & (MAX_BLOCKS-1); + uint32 block = base + o->block.col[x]; if(block < MAX_BLOCKS) { @@ -305,7 +305,7 @@ bool GSTextureCacheSW::Texture::Update(const GSVector4i& rect) for(int x = r.left; x < r.right; x += bs.x) { - uint32 block = base + o->block.col[x] & (MAX_BLOCKS-1); + uint32 block = base + o->block.col[x]; if(block < MAX_BLOCKS) {