This commit is contained in:
gabest
2008-06-30 14:32:36 +00:00
parent d49e1c1c7a
commit 840dc31ddd
11 changed files with 301 additions and 172 deletions

View File

@@ -1817,15 +1817,17 @@ public:
GSVector4i* s = (GSVector4i*)clut;
GSVector4i* d = (GSVector4i*)dst;
GSVector4i r0 = s[0];
GSVector4i r1 = s[1];
GSVector4i r2 = s[32];
GSVector4i r3 = s[33];
GSVector4i v0 = s[0];
GSVector4i v1 = s[1];
GSVector4i v2 = s[32];
GSVector4i v3 = s[33];
d[0] = r0.upl16(r2);
d[1] = r0.uph16(r2);
d[2] = r1.upl16(r3);
d[3] = r1.uph16(r3);
GSVector4i::sw16(v0, v2, v1, v3);
d[0] = v0;
d[1] = v1;
d[2] = v2;
d[3] = v3;
#else

View File

@@ -35,7 +35,7 @@ interface __declspec(uuid("59C193BB-C520-41F3-BC1D-E245B80A86FA"))
IGSSource : public IUnknown
{
STDMETHOD(DeliverNewSegment)() PURE;
STDMETHOD(DeliverFrame)(const void* bits, int pitch) PURE;
STDMETHOD(DeliverFrame)(const void* bits, int pitch, bool rgba) PURE;
STDMETHOD(DeliverEOS)() PURE;
};
@@ -206,7 +206,7 @@ public:
return m_output->DeliverNewSegment(0, _I64_MAX, 1.0);
}
STDMETHODIMP DeliverFrame(const void* bits, int pitch)
STDMETHODIMP DeliverFrame(const void* bits, int pitch, bool rgba)
{
if(!m_output || !m_output->IsConnected())
{
@@ -248,34 +248,48 @@ public:
const GSVector4 vs(-0.071f / 2, -0.368f / 2, 0.439f / 2, 0.0f);
const GSVector4 offset(16, 128, 16, 128);
for(int j = 0; j < h; j++, dst += dstpitch, src += srcpitch)
if(rgba)
{
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
for(int i = 0; i < w; i += 2)
for(int j = 0; j < h; j++, dst += dstpitch, src += srcpitch)
{
GSVector4 c0 = GSVector4(s[i + 0]);
GSVector4 c1 = GSVector4(s[i + 1]);
GSVector4 c2 = c0 + c1;
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
#if 0//_M_SSE >= 0x400
for(int i = 0; i < w; i += 2)
{
GSVector4 c0 = GSVector4(s[i + 0]);
GSVector4 c1 = GSVector4(s[i + 1]);
GSVector4 c2 = c0 + c1;
GSVector4 lo = c0.dp<0x71>(ys) | c2.dp<0x72>(vs);
GSVector4 hi = c1.dp<0x74>(ys) | c2.dp<0x78>(us);
GSVector4 lo = (c0 * ys).hadd(c2 * vs);
GSVector4 hi = (c1 * ys).hadd(c2 * us);
GSVector4 c = (lo | hi) + offset;
GSVector4 c = lo.hadd(hi) + offset;
#else
*((DWORD*)&d[i]) = GSVector4i(c).rgba32();
}
}
}
else
{
for(int j = 0; j < h; j++, dst += dstpitch, src += srcpitch)
{
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
GSVector4 lo = (c0 * ys).hadd(c2 * vs);
GSVector4 hi = (c1 * ys).hadd(c2 * us);
for(int i = 0; i < w; i += 2)
{
GSVector4 c0 = GSVector4(s[i + 0]).zyxw();
GSVector4 c1 = GSVector4(s[i + 1]).zyxw();
GSVector4 c2 = c0 + c1;
GSVector4 c = lo.hadd(hi) + offset;
GSVector4 lo = (c0 * ys).hadd(c2 * vs);
GSVector4 hi = (c1 * ys).hadd(c2 * us);
#endif
GSVector4 c = lo.hadd(hi) + offset;
*((DWORD*)&d[i]) = GSVector4i(c).rgba32();
*((DWORD*)&d[i]) = GSVector4i(c).rgba32();
}
}
}
}
@@ -292,39 +306,46 @@ public:
for(int j = 0; j < h; j++, dst += dstpitch, src += srcpitch)
{
#if _M_SSE >= 0x301
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
GSVector4i mask(2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
for(int i = 0, w4 = w >> 2; i < w4; i++)
if(rgba)
{
d[i] = s[i].shuffle8(mask);
#if _M_SSE >= 0x301
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
GSVector4i mask(2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
for(int i = 0, w4 = w >> 2; i < w4; i++)
{
d[i] = s[i].shuffle8(mask);
}
#elif _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
for(int i = 0, w4 = w >> 2; i < w4; i++)
{
d[i] = ((s[i] & 0x00ff0000) >> 16) | ((s[i] & 0x000000ff) << 16) | (s[i] & 0x0000ff00);
}
#else
DWORD* s = (DWORD*)src;
DWORD* d = (DWORD*)dst;
for(int i = 0; i < w; i++)
{
d[i] = ((s[i] & 0x00ff0000) >> 16) | ((s[i] & 0x000000ff) << 16) | (s[i] & 0x0000ff00);
}
#endif
}
#elif _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
for(int i = 0, w4 = w >> 2; i < w4; i++)
else
{
d[i] = ((s[i] & 0x00ff0000) >> 16) | ((s[i] & 0x000000ff) << 16) | (s[i] & 0x0000ff00);
memcpy(dst, src, w * 4);
}
#else
DWORD* s = (DWORD*)src;
DWORD* d = (DWORD*)dst;
for(int i = 0; i < w; i++)
{
d[i] = ((s[i] & 0x00ff0000) >> 16) | ((s[i] & 0x000000ff) << 16) | (s[i] & 0x0000ff00);
}
#endif
}
}
else
@@ -437,6 +458,30 @@ bool GSCapture::BeginCapture(int fps)
return false;
}
BeginEnumFilters(m_graph, pEF, pBF)
{
CFilterInfo fi;
pBF->QueryFilterInfo(&fi);
printf("Filter [%p]: %s\n", pBF.p, CStringA(fi.achName));
BeginEnumPins(pBF, pEP, pPin)
{
CComPtr<IPin> pPinTo;
pPin->ConnectedTo(&pPinTo);
CPinInfo pi;
pPin->QueryPinInfo(&pi);
printf("- Pin [%p - %p]: %s (%s)\n", pPin.p, pPinTo.p, CStringA(pi.achName), pi.dir ? "out" : "in");
BeginEnumMediaTypes(pPin, pEMT, pmt)
{
}
EndEnumMediaTypes(pmt)
}
EndEnumPins
}
EndEnumFilters
hr = CComQIPtr<IMediaControl>(m_graph)->Run();
CComQIPtr<IGSSource>(m_src)->DeliverNewSegment();
@@ -446,7 +491,7 @@ bool GSCapture::BeginCapture(int fps)
return true;
}
bool GSCapture::DeliverFrame(const void* bits, int pitch)
bool GSCapture::DeliverFrame(const void* bits, int pitch, bool rgba)
{
CAutoLock cAutoLock(this);
@@ -459,7 +504,7 @@ bool GSCapture::DeliverFrame(const void* bits, int pitch)
if(m_src)
{
CComQIPtr<IGSSource>(m_src)->DeliverFrame(bits, pitch);
CComQIPtr<IGSSource>(m_src)->DeliverFrame(bits, pitch, rgba);
return true;
}

View File

@@ -35,7 +35,7 @@ public:
virtual ~GSCapture();
bool BeginCapture(int fps);
bool DeliverFrame(const void* bits, int pitch);
bool DeliverFrame(const void* bits, int pitch, bool rgba);
bool EndCapture();
bool IsCapturing() {return m_capturing;}

View File

@@ -236,4 +236,9 @@ public:
return true;
}
virtual bool IsCurrentRGBA()
{
return true;
}
};

View File

@@ -182,6 +182,11 @@ public:
HRESULT CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il);
HRESULT CompileShader(UINT id, LPCSTR entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps);
virtual bool IsCurrentRGBA()
{
return false;
}
// TODO
bool SaveToFileD24S8(IDirect3DSurface9* ds, LPCTSTR fn);
};

View File

@@ -77,9 +77,9 @@ GSLocalMemory::GSLocalMemory()
memset(m_vm8, 0, m_vmsize);
m_pCLUT = (WORD*)_aligned_malloc(256 * 2 * sizeof(WORD) * 2, 16);
m_pCLUT32 = (DWORD*)_aligned_malloc(256 * sizeof(DWORD), 16);
m_pCLUT64 = (UINT64*)_aligned_malloc(256 * sizeof(UINT64), 16);
m_clut = (WORD*)_aligned_malloc(256 * 2 * sizeof(WORD) * 2, 16);
m_clut32 = (DWORD*)_aligned_malloc(256 * sizeof(DWORD), 16);
m_clut64 = (UINT64*)_aligned_malloc(256 * sizeof(UINT64), 16);
for(int bp = 0; bp < 32; bp++)
{
@@ -374,9 +374,9 @@ GSLocalMemory::~GSLocalMemory()
{
VirtualFree(m_vm8, 0, MEM_RELEASE);
_aligned_free(m_pCLUT);
_aligned_free(m_pCLUT32);
_aligned_free(m_pCLUT64);
_aligned_free(m_clut);
_aligned_free(m_clut32);
_aligned_free(m_clut64);
}
bool GSLocalMemory::FillRect(const CRect& r, DWORD c, DWORD psm, DWORD fbp, DWORD fbw)
@@ -585,7 +585,7 @@ bool GSLocalMemory::WriteCLUT(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT)
DWORD bp = TEX0.CBP;
DWORD bw = TEX0.CSM == 0 ? 1 : TEXCLUT.CBW;
WORD* pCLUT = m_pCLUT + (TEX0.CSA << 4);
WORD* clut = m_clut + (TEX0.CSA << 4);
// NOTE: TEX0.CPSM == PSM_PSMCT24 is non-standard, KH uses it
@@ -593,28 +593,28 @@ bool GSLocalMemory::WriteCLUT(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT)
{
if(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S)
{
WORD* vm = &m_vm16[TEX0.CPSM == PSM_PSMCT16 ? BlockAddress16(0, 0, bp, bw) : BlockAddress16S(0, 0, bp, bw)];
WORD* src = &m_vm16[TEX0.CPSM == PSM_PSMCT16 ? BlockAddress16(0, 0, bp, bw) : BlockAddress16S(0, 0, bp, bw)];
if(TEX0.PSM == PSM_PSMT8 || TEX0.PSM == PSM_PSMT8H)
{
WriteCLUT_T16_I8_CSM1(vm, pCLUT);
WriteCLUT_T16_I8_CSM1(src, clut);
}
else if(TEX0.PSM == PSM_PSMT4HH || TEX0.PSM == PSM_PSMT4HL || TEX0.PSM == PSM_PSMT4)
{
WriteCLUT_T16_I4_CSM1(vm, pCLUT);
WriteCLUT_T16_I4_CSM1(src, clut);
}
}
else if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
DWORD* vm = &m_vm32[BlockAddress32(0, 0, bp, bw)];
DWORD* src = &m_vm32[BlockAddress32(0, 0, bp, bw)];
if(TEX0.PSM == PSM_PSMT8 || TEX0.PSM == PSM_PSMT8H)
{
WriteCLUT_T32_I8_CSM1(vm, pCLUT);
WriteCLUT_T32_I8_CSM1(src, clut);
}
else if(TEX0.PSM == PSM_PSMT4HH || TEX0.PSM == PSM_PSMT4HL || TEX0.PSM == PSM_PSMT4)
{
WriteCLUT_T32_I4_CSM1(vm, pCLUT);
WriteCLUT_T32_I4_CSM1(src, clut);
}
}
}
@@ -632,7 +632,7 @@ bool GSLocalMemory::WriteCLUT(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT)
{
for(int i = 0; i < pal; i++)
{
pCLUT[i] = (WORD)(this->*rp)((TEXCLUT.COU << 4) + i, TEXCLUT.COV, bp, bw);
clut[i] = (WORD)(this->*rp)((TEXCLUT.COU << 4) + i, TEXCLUT.COV, bp, bw);
}
}
else if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
@@ -641,8 +641,8 @@ bool GSLocalMemory::WriteCLUT(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT)
{
DWORD dw = (this->*rp)((TEXCLUT.COU << 4) + i, TEXCLUT.COV, bp, bw);
pCLUT[i] = (WORD)(dw & 0xffff);
pCLUT[i + 256] = (WORD)(dw >> 16);
clut[i] = (WORD)(dw & 0xffff);
clut[i + 256] = (WORD)(dw >> 16);
}
}
}
@@ -652,11 +652,11 @@ bool GSLocalMemory::WriteCLUT(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT)
//
void GSLocalMemory::ReadCLUT(GIFRegTEX0 TEX0, DWORD* pCLUT32)
void GSLocalMemory::ReadCLUT(GIFRegTEX0 TEX0, DWORD* clut32)
{
ASSERT(pCLUT32);
ASSERT(clut32);
WORD* pCLUT = m_pCLUT + (TEX0.CSA << 4);
WORD* clut = m_clut + (TEX0.CSA << 4);
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@@ -664,12 +664,12 @@ void GSLocalMemory::ReadCLUT(GIFRegTEX0 TEX0, DWORD* pCLUT32)
{
case PSM_PSMT8:
case PSM_PSMT8H:
ReadCLUT_T32_I8(pCLUT, pCLUT32);
ReadCLUT_T32_I8(clut, clut32);
break;
case PSM_PSMT4:
case PSM_PSMT4HL:
case PSM_PSMT4HH:
ReadCLUT_T32_I4(pCLUT, pCLUT32);
ReadCLUT_T32_I4(clut, clut32);
break;
}
}
@@ -679,12 +679,12 @@ void GSLocalMemory::ReadCLUT(GIFRegTEX0 TEX0, DWORD* pCLUT32)
{
case PSM_PSMT8:
case PSM_PSMT8H:
ReadCLUT_T16_I8(pCLUT, pCLUT32);
ReadCLUT_T16_I8(clut, clut32);
break;
case PSM_PSMT4:
case PSM_PSMT4HL:
case PSM_PSMT4HH:
ReadCLUT_T16_I4(pCLUT, pCLUT32);
ReadCLUT_T16_I4(clut, clut32);
break;
}
}
@@ -692,9 +692,9 @@ void GSLocalMemory::ReadCLUT(GIFRegTEX0 TEX0, DWORD* pCLUT32)
void GSLocalMemory::SetupCLUT(GIFRegTEX0 TEX0)
{
// TODO: cache m_pCLUT*
// TODO: cache m_clut*
ReadCLUT(TEX0, m_pCLUT32);
ReadCLUT(TEX0, m_clut32);
switch(TEX0.PSM)
{
@@ -704,8 +704,8 @@ void GSLocalMemory::SetupCLUT(GIFRegTEX0 TEX0)
// sse2?
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
DWORD* src = m_pCLUT32;
DWORD* dst = (DWORD*)m_pCLUT64;
DWORD* src = m_clut32;
DWORD* dst = (DWORD*)m_clut64;
for(int j = 0; j < 16; j++, dst += 32)
{
@@ -720,8 +720,8 @@ void GSLocalMemory::SetupCLUT(GIFRegTEX0 TEX0)
}
else
{
DWORD* src = m_pCLUT32;
DWORD* dst = (DWORD*)m_pCLUT64;
DWORD* src = m_clut32;
DWORD* dst = (DWORD*)m_clut64;
for(int j = 0; j < 16; j++, dst += 32)
{
@@ -740,11 +740,11 @@ void GSLocalMemory::SetupCLUT(GIFRegTEX0 TEX0)
//
void GSLocalMemory::ReadCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA, DWORD* pCLUT32)
void GSLocalMemory::ReadCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA, DWORD* clut32)
{
ASSERT(pCLUT32);
ASSERT(clut32);
WORD* pCLUT = m_pCLUT + (TEX0.CSA << 4);
WORD* clut = m_clut + (TEX0.CSA << 4);
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@@ -752,26 +752,26 @@ void GSLocalMemory::ReadCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA, DWORD* pCLUT32)
{
case PSM_PSMT8:
case PSM_PSMT8H:
ReadCLUT_T32_I8(pCLUT, pCLUT32);
ReadCLUT_T32_I8(clut, clut32);
break;
case PSM_PSMT4:
case PSM_PSMT4HL:
case PSM_PSMT4HH:
ReadCLUT_T32_I4(pCLUT, pCLUT32);
ReadCLUT_T32_I4(clut, clut32);
break;
}
}
else if(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S)
{
Expand16(pCLUT, pCLUT32, m_psm[TEX0.PSM].pal, &TEXA);
Expand16(clut, clut32, m_psm[TEX0.PSM].pal, &TEXA);
}
}
void GSLocalMemory::SetupCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA)
{
// TODO: cache m_pCLUT*
// TODO: cache m_clut*
ReadCLUT32(TEX0, TEXA, m_pCLUT32);
ReadCLUT32(TEX0, TEXA, m_clut32);
switch(TEX0.PSM)
{
@@ -780,8 +780,8 @@ void GSLocalMemory::SetupCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA)
case PSM_PSMT4HH:
// sse2?
{
DWORD* src = m_pCLUT32;
DWORD* dst = (DWORD*)m_pCLUT64;
DWORD* src = m_clut32;
DWORD* dst = (DWORD*)m_clut64;
for(int j = 0; j < 16; j++, dst += 32)
{
@@ -799,9 +799,9 @@ void GSLocalMemory::SetupCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA)
}
}
void GSLocalMemory::CopyCLUT32(DWORD* pCLUT32, int n)
void GSLocalMemory::CopyCLUT32(DWORD* clut32, int n)
{
memcpy(pCLUT32, m_pCLUT32, sizeof(DWORD) * n);
memcpy(clut32, m_clut32, sizeof(DWORD) * n);
}
#define IsTopLeftAligned(dsax, tx, ty, bw, bh) \
@@ -2131,7 +2131,7 @@ void GSLocalMemory::ReadTexture16S(const CRect& r, BYTE* dst, int dstpitch, GIFR
void GSLocalMemory::ReadTexture8(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
FOREACH_BLOCK_START(r, 16, 16, 8)
{
@@ -2142,7 +2142,7 @@ void GSLocalMemory::ReadTexture8(const CRect& r, BYTE* dst, int dstpitch, GIFReg
void GSLocalMemory::ReadTexture4(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
UINT64* pal = m_pCLUT64;
UINT64* pal = m_clut64;
FOREACH_BLOCK_START(r, 32, 16, 4)
{
@@ -2153,7 +2153,7 @@ void GSLocalMemory::ReadTexture4(const CRect& r, BYTE* dst, int dstpitch, GIFReg
void GSLocalMemory::ReadTexture8H(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
FOREACH_BLOCK_START(r, 8, 8, 32)
{
@@ -2164,7 +2164,7 @@ void GSLocalMemory::ReadTexture8H(const CRect& r, BYTE* dst, int dstpitch, GIFRe
void GSLocalMemory::ReadTexture4HL(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
FOREACH_BLOCK_START(r, 8, 8, 32)
{
@@ -2175,7 +2175,7 @@ void GSLocalMemory::ReadTexture4HL(const CRect& r, BYTE* dst, int dstpitch, GIFR
void GSLocalMemory::ReadTexture4HH(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
FOREACH_BLOCK_START(r, 8, 8, 32)
{
@@ -2292,7 +2292,7 @@ void GSLocalMemory::ReadTexture16SNP(const CRect& r, BYTE* dst, int dstpitch, GI
void GSLocalMemory::ReadTexture8NP(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@@ -2320,7 +2320,7 @@ void GSLocalMemory::ReadTexture8NP(const CRect& r, BYTE* dst, int dstpitch, GIFR
void GSLocalMemory::ReadTexture4NP(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
UINT64* pal = m_pCLUT64;
UINT64* pal = m_clut64;
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@@ -2348,7 +2348,7 @@ void GSLocalMemory::ReadTexture4NP(const CRect& r, BYTE* dst, int dstpitch, GIFR
void GSLocalMemory::ReadTexture8HNP(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@@ -2376,7 +2376,7 @@ void GSLocalMemory::ReadTexture8HNP(const CRect& r, BYTE* dst, int dstpitch, GIF
void GSLocalMemory::ReadTexture4HLNP(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@@ -2404,7 +2404,7 @@ void GSLocalMemory::ReadTexture4HLNP(const CRect& r, BYTE* dst, int dstpitch, GI
void GSLocalMemory::ReadTexture4HHNP(const CRect& r, BYTE* dst, int dstpitch, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
{
DWORD* pal = m_pCLUT32;
DWORD* pal = m_clut32;
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{

View File

@@ -92,9 +92,9 @@ protected:
static int rowOffset4[2][2048];
DWORD m_CBP[2];
WORD* m_pCLUT;
DWORD* m_pCLUT32;
UINT64* m_pCLUT64;
WORD* m_clut;
DWORD* m_clut32;
UINT64* m_clut64;
GIFRegTEX0 m_prevTEX0;
GIFRegTEXCLUT m_prevTEXCLUT;
@@ -623,27 +623,27 @@ public:
__forceinline DWORD ReadTexel8(DWORD addr, GIFRegTEXA& TEXA)
{
return m_pCLUT32[ReadPixel8(addr)];
return m_clut32[ReadPixel8(addr)];
}
__forceinline DWORD ReadTexel4(DWORD addr, GIFRegTEXA& TEXA)
{
return m_pCLUT32[ReadPixel4(addr)];
return m_clut32[ReadPixel4(addr)];
}
__forceinline DWORD ReadTexel8H(DWORD addr, GIFRegTEXA& TEXA)
{
return m_pCLUT32[ReadPixel8H(addr)];
return m_clut32[ReadPixel8H(addr)];
}
__forceinline DWORD ReadTexel4HL(DWORD addr, GIFRegTEXA& TEXA)
{
return m_pCLUT32[ReadPixel4HL(addr)];
return m_clut32[ReadPixel4HL(addr)];
}
__forceinline DWORD ReadTexel4HH(DWORD addr, GIFRegTEXA& TEXA)
{
return m_pCLUT32[ReadPixel4HH(addr)];
return m_clut32[ReadPixel4HH(addr)];
}
__forceinline DWORD ReadTexel32(int x, int y, GIFRegTEX0& TEX0, GIFRegTEXA& TEXA)
@@ -1047,15 +1047,15 @@ public:
bool IsCLUTUpdating(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT);
bool WriteCLUT(GIFRegTEX0 TEX0, GIFRegTEXCLUT TEXCLUT);
void ReadCLUT(GIFRegTEX0 TEX0, DWORD* pCLUT32);
void ReadCLUT(GIFRegTEX0 TEX0, DWORD* clut32);
void SetupCLUT(GIFRegTEX0 TEX0);
// expands 16->32
void ReadCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA, DWORD* pCLUT32);
void ReadCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA, DWORD* clut32);
void SetupCLUT32(GIFRegTEX0 TEX0, GIFRegTEXA TEXA);
void CopyCLUT32(DWORD* pCLUT32, int n);
DWORD* GetCLUT32() {return m_pCLUT32;}
void CopyCLUT32(DWORD* clut32, int n);
DWORD* GetCLUT32() {return m_clut32;}
//

View File

@@ -50,28 +50,9 @@ protected:
while(msg.message != WM_QUIT && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_KEYDOWN)
if(OnMessage(msg))
{
int step = (::GetAsyncKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
if(msg.wParam == VK_F5)
{
m_interlace = (m_interlace + 7 + step) % 7;
continue;
}
if(msg.wParam == VK_F6)
{
m_aspectratio = (m_aspectratio + 3 + step) % 3;
continue;
}
if(msg.wParam == VK_F7)
{
SetWindowText(_T("PCSX2"));
m_osd = !m_osd;
continue;
}
continue;
}
TranslateMessage(&msg);
@@ -79,6 +60,35 @@ protected:
}
}
virtual bool OnMessage(const MSG& msg)
{
if(msg.message == WM_KEYDOWN)
{
int step = (::GetAsyncKeyState(VK_SHIFT) & 0x8000) ? -1 : 1;
if(msg.wParam == VK_F5)
{
m_interlace = (m_interlace + 7 + step) % 7;
return true;
}
if(msg.wParam == VK_F6)
{
m_aspectratio = (m_aspectratio + 3 + step) % 3;
return true;
}
if(msg.wParam == VK_F7)
{
SetWindowText(_T("PCSX2"));
m_osd = !m_osd;
return true;
}
}
return false;
}
public:
GSRendererBase(BYTE* base, bool mt, void (*irq)(), int nloophack, const GSRendererSettings& rs)
: GSState(base, mt, irq, nloophack)
@@ -231,13 +241,36 @@ str.Format(_T("%d %f %f %f %f "), i, o.x, o.y, dr[i].z, dr[i].w);
if(offscreen.Map(&bits, pitch))
{
m_capture.DeliverFrame(bits, pitch);
m_capture.DeliverFrame(bits, pitch, m_dev.IsCurrentRGBA());
offscreen.Unmap();
}
m_dev.Recycle(offscreen);
}
}
virtual bool OnMessage(const MSG& msg)
{
if(msg.message == WM_KEYDOWN)
{
if(msg.wParam == VK_F12)
{
if(m_capture.IsCapturing())
{
m_capture.EndCapture();
}
else
{
m_capture.BeginCapture(GetFPS());
}
return true;
}
}
return __super::OnMessage(msg);
}
public:
Device m_dev;
@@ -438,20 +471,6 @@ public:
bool MakeSnapshot(LPCTSTR path)
{
if((::GetAsyncKeyState(VK_CONTROL) & 0x8000))
{
if(m_capture.IsCapturing())
{
m_capture.EndCapture();
}
else
{
m_capture.BeginCapture(GetFPS());
}
return true;
}
CString fn;
fn.Format(_T("%s_%s"), path, CTime::GetCurrentTime().Format(_T("%Y%m%d%H%M%S")));

View File

@@ -112,11 +112,13 @@ bool GSTexture9::Update(CRect r, const void* data, int pitch)
bool GSTexture9::Map(BYTE** bits, int& pitch, const RECT* r)
{
HRESULT hr;
if(CComPtr<IDirect3DSurface9> surface = *this)
{
D3DLOCKED_RECT lr;
if(SUCCEEDED(surface->LockRect(&lr, r, 0)))
if(SUCCEEDED(hr = surface->LockRect(&lr, r, 0)))
{
*bits = (BYTE*)lr.pBits;
pitch = (int)lr.Pitch;

View File

@@ -183,6 +183,69 @@ typedef struct {
#define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
#endif
class CPinInfo : public PIN_INFO
{
public:
CPinInfo() {pFilter = NULL;}
~CPinInfo() {if(pFilter) pFilter->Release();}
};
class CFilterInfo : public FILTER_INFO
{
public:
CFilterInfo() {pGraph = NULL;}
~CFilterInfo() {if(pGraph) pGraph->Release();}
};
#define BeginEnumFilters(pFilterGraph, pEnumFilters, pBaseFilter) \
{CComPtr<IEnumFilters> pEnumFilters; \
if(pFilterGraph && SUCCEEDED(pFilterGraph->EnumFilters(&pEnumFilters))) \
{ \
for(CComPtr<IBaseFilter> pBaseFilter; S_OK == pEnumFilters->Next(1, &pBaseFilter, 0); pBaseFilter = NULL) \
{ \
#define EndEnumFilters }}}
#define BeginEnumCachedFilters(pGraphConfig, pEnumFilters, pBaseFilter) \
{CComPtr<IEnumFilters> pEnumFilters; \
if(pGraphConfig && SUCCEEDED(pGraphConfig->EnumCacheFilter(&pEnumFilters))) \
{ \
for(CComPtr<IBaseFilter> pBaseFilter; S_OK == pEnumFilters->Next(1, &pBaseFilter, 0); pBaseFilter = NULL) \
{ \
#define EndEnumCachedFilters }}}
#define BeginEnumPins(pBaseFilter, pEnumPins, pPin) \
{CComPtr<IEnumPins> pEnumPins; \
if(pBaseFilter && SUCCEEDED(pBaseFilter->EnumPins(&pEnumPins))) \
{ \
for(CComPtr<IPin> pPin; S_OK == pEnumPins->Next(1, &pPin, 0); pPin = NULL) \
{ \
#define EndEnumPins }}}
#define BeginEnumMediaTypes(pPin, pEnumMediaTypes, pMediaType) \
{CComPtr<IEnumMediaTypes> pEnumMediaTypes; \
if(pPin && SUCCEEDED(pPin->EnumMediaTypes(&pEnumMediaTypes))) \
{ \
AM_MEDIA_TYPE* pMediaType = NULL; \
for(; S_OK == pEnumMediaTypes->Next(1, &pMediaType, NULL); DeleteMediaType(pMediaType), pMediaType = NULL) \
{ \
#define EndEnumMediaTypes(pMediaType) } if(pMediaType) DeleteMediaType(pMediaType); }}
#define BeginEnumSysDev(clsid, pMoniker) \
{CComPtr<ICreateDevEnum> pDevEnum4$##clsid; \
pDevEnum4$##clsid.CoCreateInstance(CLSID_SystemDeviceEnum); \
CComPtr<IEnumMoniker> pClassEnum4$##clsid; \
if(SUCCEEDED(pDevEnum4$##clsid->CreateClassEnumerator(clsid, &pClassEnum4$##clsid, 0)) \
&& pClassEnum4$##clsid) \
{ \
for(CComPtr<IMoniker> pMoniker; pClassEnum4$##clsid->Next(1, &pMoniker, 0) == S_OK; pMoniker = NULL) \
{ \
#define EndEnumSysDev }}}
#else
#ifdef DEBUG
#pragma message("STREAMS.H included TWICE")

View File

@@ -73,15 +73,3 @@
#define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RGB|D3DCOLORWRITEENABLE_ALPHA)
#define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) :
#define BeginEnumSysDev(clsid, pMoniker) \
{CComPtr<ICreateDevEnum> pDevEnum4$##clsid; \
pDevEnum4$##clsid.CoCreateInstance(CLSID_SystemDeviceEnum); \
CComPtr<IEnumMoniker> pClassEnum4$##clsid; \
if(SUCCEEDED(pDevEnum4$##clsid->CreateClassEnumerator(clsid, &pClassEnum4$##clsid, 0)) \
&& pClassEnum4$##clsid) \
{ \
for(CComPtr<IMoniker> pMoniker; pClassEnum4$##clsid->Next(1, &pMoniker, 0) == S_OK; pMoniker = NULL) \
{ \
#define EndEnumSysDev }}}