diff --git a/plugins/GSdx/GPUDrawScanline.cpp b/plugins/GSdx/GPUDrawScanline.cpp index 0bc5896f5e..23387fc9fa 100644 --- a/plugins/GSdx/GPUDrawScanline.cpp +++ b/plugins/GSdx/GPUDrawScanline.cpp @@ -86,7 +86,7 @@ void GPUDrawScanline::PrintStats() m_ds_map.PrintStats(); } -#ifndef JIT_DRAW +#ifndef ENABLE_JIT_RASTERIZER void GPUDrawScanline::SetupPrim(const GSVertexSW* vertices, const GSVertexSW& dscan) { diff --git a/plugins/GSdx/GPUDrawScanline.h b/plugins/GSdx/GPUDrawScanline.h index 5dc1db5fab..87690e6f09 100644 --- a/plugins/GSdx/GPUDrawScanline.h +++ b/plugins/GSdx/GPUDrawScanline.h @@ -45,7 +45,7 @@ public: void EndDraw(const GSRasterizerStats& stats, uint64 frame); void PrintStats(); -#ifndef JIT_DRAW +#ifndef ENABLE_JIT_RASTERIZER void SetupPrim(const GSVertexSW* vertices, const GSVertexSW& dscan); void DrawScanline(int pixels, int left, int top, const GSVertexSW& scan); diff --git a/plugins/GSdx/GSCrc.cpp b/plugins/GSdx/GSCrc.cpp index 188900f624..c4951c8fec 100644 --- a/plugins/GSdx/GSCrc.cpp +++ b/plugins/GSdx/GSCrc.cpp @@ -366,7 +366,7 @@ CRC::Game CRC::Lookup(uint32 crc) // printf( "GSdx: excluding CRC hack for 0x%08x\n", m_games[i].crc ); } } -#ifndef NO_CRC_HACKS +#ifndef DISABLE_CRC_HACKS hash_map::iterator i = m_map.find(crc); if(i != m_map.end()) diff --git a/plugins/GSdx/GSDeviceSW.cpp b/plugins/GSdx/GSDeviceSW.cpp index bc6d408d41..a0494c7b3b 100644 --- a/plugins/GSdx/GSDeviceSW.cpp +++ b/plugins/GSdx/GSDeviceSW.cpp @@ -117,7 +117,7 @@ void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) class ShaderBase { protected: - GSVector4i Sample(const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) + GSVector4i Sample(const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) const { GSVector4i c0 = c.upl8(); GSVector4i c1 = c.uph8(); @@ -128,17 +128,17 @@ protected: return c0; } - GSVector4i Blend(const GSVector4i& c0, const GSVector4i& c1) + GSVector4i Blend(const GSVector4i& c0, const GSVector4i& c1) const { return c0.lerp16<0>(c1, c1.wwwwl().sll16(7)); } - GSVector4i Blend2x(const GSVector4i& c0, const GSVector4i& c1) + GSVector4i Blend2x(const GSVector4i& c0, const GSVector4i& c1) const { return c0.lerp16<0>(c1, c1.wwwwl().sll16(1).pu16().uph8().sll16(7)); // .sll16(1).pu16() => 2x, then clamp (...) } - GSVector4i Blend(const GSVector4i& c0, const GSVector4i& c1, const GSVector4i& f) + GSVector4i Blend(const GSVector4i& c0, const GSVector4i& c1, const GSVector4i& f) const { return c0.lerp16<0>(c1, f); } @@ -147,12 +147,12 @@ protected: class ShaderCopy : public ShaderBase { public: - void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) + void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) const { *dst = Sample(c, uf, vf).pu16().extract32<0>(); } - void operator() (uint32* RESTRICT dst, uint32 c) + void operator() (uint32* RESTRICT dst, uint32 c) const { *dst = c; } @@ -161,12 +161,12 @@ public: class ShaderAlphaBlend : public ShaderBase { public: - void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) + void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) const { *dst = Blend(Sample(c, uf, vf), GSVector4i(*dst).uph8()).pu16().extract32<0>(); } - void operator() (uint32* RESTRICT dst, uint32 c) + void operator() (uint32* RESTRICT dst, uint32 c) const { *dst = Blend(GSVector4i(c), GSVector4i(*dst).uph8()).pu16().extract32<0>(); } @@ -175,12 +175,12 @@ public: class ShaderAlpha2xBlend : public ShaderBase { public: - void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) + void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) const { *dst = Blend2x(Sample(c, uf, vf), GSVector4i(*dst).uph8()).pu16().extract32<0>(); } - void operator() (uint32* RESTRICT dst, uint32 c) + void operator() (uint32* RESTRICT dst, uint32 c) const { *dst = Blend2x(GSVector4i(c), GSVector4i(*dst).uph8()).pu16().extract32<0>(); } @@ -196,18 +196,18 @@ public: m_f = GSVector4i((f << 16) | f).xxxx().srl16(1); } - void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) + void operator() (uint32* RESTRICT dst, const GSVector4i& c, const GSVector4i& uf, const GSVector4i& vf) const { *dst = Blend(Sample(c, uf, vf), GSVector4i(*dst).uph8(), m_f).pu16().extract32<0>(); } - void operator() (uint32* RESTRICT dst, uint32 c) + void operator() (uint32* RESTRICT dst, uint32 c) const { *dst = Blend(GSVector4i(c), GSVector4i(*dst).uph8(), m_f).pu16().extract32<0>(); } }; -template static void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, SHADER shader, bool linear) +template static void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, const SHADER& shader, bool linear) { GSVector4i r(dr.ceil()); diff --git a/plugins/GSdx/GSDialog.h b/plugins/GSdx/GSDialog.h index 7bf312b7a7..51e810e743 100644 --- a/plugins/GSdx/GSDialog.h +++ b/plugins/GSdx/GSDialog.h @@ -40,6 +40,8 @@ public: GSDialog(UINT id); virtual ~GSDialog() {} + int GetId() const {return m_id;} + INT_PTR DoModal(); string GetText(UINT id); diff --git a/plugins/GSdx/GSDrawScanline.cpp b/plugins/GSdx/GSDrawScanline.cpp index bc97ad7acb..da33b36926 100644 --- a/plugins/GSdx/GSDrawScanline.cpp +++ b/plugins/GSdx/GSDrawScanline.cpp @@ -105,7 +105,7 @@ void GSDrawScanline::PrintStats() m_ds_map.PrintStats(); } -#ifndef JIT_DRAW +#ifndef ENABLE_JIT_RASTERIZER void GSDrawScanline::SetupPrim(const GSVertexSW* vertices, const GSVertexSW& dscan) { diff --git a/plugins/GSdx/GSDrawScanline.h b/plugins/GSdx/GSDrawScanline.h index 20fb4c3072..9befae9626 100644 --- a/plugins/GSdx/GSDrawScanline.h +++ b/plugins/GSdx/GSDrawScanline.h @@ -56,7 +56,7 @@ public: void DrawRect(const GSVector4i& r, const GSVertexSW& v); -#ifndef JIT_DRAW +#ifndef ENABLE_JIT_RASTERIZER void SetupPrim(const GSVertexSW* vertices, const GSVertexSW& dscan); void DrawScanline(int pixels, int left, int top, const GSVertexSW& scan); diff --git a/plugins/GSdx/GSFunctionMap.h b/plugins/GSdx/GSFunctionMap.h index b23f9d469b..c5bd13afac 100644 --- a/plugins/GSdx/GSFunctionMap.h +++ b/plugins/GSdx/GSFunctionMap.h @@ -168,14 +168,6 @@ public: } }; -#if 0 // we can't legally distribute vtune libraries or headers -#ifdef _WINDOWS - -#include "vtune/JITProfiling.h" - -#endif -#endif - template class GSCodeGeneratorFunctionMap : public GSFunctionMap { @@ -215,8 +207,7 @@ public: m_cgmap[key] = ret; - #if 0 // we can't legally distribute vtune libraries or headers - #ifdef _WINDOWS + #ifdef ENABLE_VTUNE // vtune method registration @@ -254,7 +245,6 @@ public: */ } - #endif #endif delete cg; diff --git a/plugins/GSdx/GSRasterizer.cpp b/plugins/GSdx/GSRasterizer.cpp index 67f006bd37..383c178f9e 100644 --- a/plugins/GSdx/GSRasterizer.cpp +++ b/plugins/GSdx/GSRasterizer.cpp @@ -36,7 +36,7 @@ GSRasterizer::GSRasterizer(IDrawScanline* ds) m_myscanline = (uint8*)_aligned_malloc((2048 >> THREAD_HEIGHT) + 16, 64); - SetThreadId(0, 1); + Init(0, 1); } GSRasterizer::~GSRasterizer() @@ -53,6 +53,46 @@ bool GSRasterizer::IsOneOfMyScanlines(int scanline) const return m_myscanline[scanline >> THREAD_HEIGHT] != 0; } +bool GSRasterizer::IsOneOfMyScanlines(int top, int bottom) const +{ + top >>= THREAD_HEIGHT; + bottom >>= THREAD_HEIGHT; + + do + { + if(m_myscanline[top]) return true; + } + while(top++ < bottom); + + return false; +} + +void GSRasterizer::Init(int id, int threads) +{ + if(m_id != id || m_threads != threads) + { + m_id = id; + m_threads = threads; + + if(threads > 1) + { + int row = 0; + + while(row < (2048 >> THREAD_HEIGHT)) + { + for(int i = 0; i < threads; i++, row++) + { + m_myscanline[row] = i == id ? 1 : 0; + } + } + } + else + { + memset(m_myscanline, 1, 2048 >> THREAD_HEIGHT); + } + } +} + void GSRasterizer::Draw(const GSRasterizerData* data) { m_ds->BeginDraw(data->param); @@ -100,32 +140,6 @@ void GSRasterizer::Draw(const GSRasterizerData* data) m_ds->EndDraw(m_stats, data->frame); } -void GSRasterizer::SetThreadId(int id, int threads) -{ - if(m_id != id || m_threads != threads) - { - m_id = id; - m_threads = threads; - - if(threads > 1) - { - int row = 0; - - while(row < (2048 >> THREAD_HEIGHT)) - { - for(int i = 0; i < threads; i++, row++) - { - m_myscanline[row] = i == id ? 1 : 0; - } - } - } - else - { - memset(m_myscanline, 1, 2048 >> THREAD_HEIGHT); - } - } -} - void GSRasterizer::GetStats(GSRasterizerStats& stats) { stats = m_stats; @@ -250,8 +264,6 @@ void GSRasterizer::DrawLine(const GSVertexSW* v) m_edge.count = e - m_edge.buff; - m_stats.pixels += m_edge.count; - Flush(v, GSVertexSW::zero()); } } @@ -301,6 +313,8 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) GSVector4 tbmin = tbf.min(m_fscissor.ywyw()); GSVector4i tb = GSVector4i(tbmax.xzyw(tbmin)); + if(m_threads > 1 && !IsOneOfMyScanlines(tb.x, tb.w)) return; + dv[0] = v[1] - v[0]; dv[1] = v[2] - v[0]; dv[2] = v[2] - v[1]; @@ -364,13 +378,11 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) edge.p = edge.p.insert<0, 1>(v[j].p); dedge.p = ddx[2 - (j << 1)].yzzw(dedge.p); - DrawTriangleSection(tb.x, tb.w, edge, dedge, dscan, v[1 - j].p.xxxx(), v[1 - j].p.yyyy()); + DrawTriangleSection(tb.x, tb.w, edge, dedge, dscan, v[1 - j].p); } } else { - GSVector4 x0 = v[0].p.xxxx(); - if(tb.x < tb.z) { edge = v[0]; @@ -378,17 +390,17 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) edge.p = edge.p.xxzw(); dedge.p = ddx[j].xyzw(dedge.p); - DrawTriangleSection(tb.x, tb.z, edge, dedge, dscan, x0, v[0].p.yyyy()); + DrawTriangleSection(tb.x, tb.z, edge, dedge, dscan, v[0].p); } if(tb.y < tb.w) { edge = v[1]; - edge.p = (x0 + ddx[j] * dv[0].p.yyyy()).xyzw(edge.p); + edge.p = (v[0].p.xxxx() + ddx[j] * dv[0].p.yyyy()).xyzw(edge.p); dedge.p = ddx[2 - (j << 1)].yzzw(dedge.p); - DrawTriangleSection(tb.y, tb.w, edge, dedge, dscan, v[1].p.xxxx(), v[1].p.yyyy()); + DrawTriangleSection(tb.y, tb.w, edge, dedge, dscan, v[1].p); } } @@ -411,7 +423,7 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) } } -void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& edge, const GSVertexSW& dedge, const GSVertexSW& dscan, const GSVector4& x0, const GSVector4& y0) +void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& edge, const GSVertexSW& dedge, const GSVertexSW& dscan, const GSVector4& p0) { ASSERT(top < bottom); ASSERT(edge.p.x <= edge.p.y); @@ -420,12 +432,16 @@ void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& edge, co GSVector4 scissor = m_fscissor.xzxz(); - while(1) + do { if(IsOneOfMyScanlines(top)) { - GSVertexSW scan = edge + dedge * (GSVector4(top) - y0); + GSVector4 dy = GSVector4(top) - p0.yyyy(); + + GSVertexSW scan; + scan.p = edge.p + dedge.p * dy; + GSVector4 lrf = scan.p.ceil(); GSVector4 l = lrf.max(scissor); GSVector4 r = lrf.min(scissor); @@ -438,17 +454,15 @@ void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& edge, co if(pixels > 0) { - m_stats.pixels += pixels; + scan.t = edge.t + dedge.t * dy; + scan.c = edge.c + dedge.c * dy; - GSVector4 prestep = l.xxxx() - x0; - - AddScanline(e++, pixels, left, top, scan + dscan * prestep); + AddScanline(e++, pixels, left, top, scan + dscan * (l - p0).xxxx()); } } - - if(++top >= bottom) break; } - + while(++top < bottom); + m_edge.count += e - &m_edge.buff[m_edge.count]; } @@ -707,11 +721,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS } } - int count = e - &m_edge.buff[m_edge.count]; - - m_stats.pixels += count; - - m_edge.count += count; + m_edge.count += e - &m_edge.buff[m_edge.count]; } void GSRasterizer::AddScanline(GSVertexSW* e, int pixels, int left, int top, const GSVertexSW& scan) @@ -744,6 +754,8 @@ void GSRasterizer::Flush(const GSVertexSW* vertices, const GSVertexSW& dscan, bo int left = e->p.i16[1]; int top = e->p.i16[2]; + m_stats.pixels += pixels; + m_ds->DrawScanline(pixels, left, top, *e++); } while(e < ee); @@ -756,6 +768,8 @@ void GSRasterizer::Flush(const GSVertexSW* vertices, const GSVertexSW& dscan, bo int left = e->p.i16[1]; int top = e->p.i16[2]; + m_stats.pixels += pixels; + m_ds->DrawEdge(pixels, left, top, *e++); } while(e < ee); @@ -777,6 +791,8 @@ GSRasterizerMT::GSRasterizerMT(IDrawScanline* ds, volatile long& sync) GSRasterizerMT::~GSRasterizerMT() { + Init(0, 1); + Draw(NULL); CloseThread(); @@ -808,23 +824,9 @@ GSRasterizerList::GSRasterizerList() GSRasterizerList::~GSRasterizerList() { - for(size_t i = 0; i < size(); i++) delete (*this)[i]; -} - -void GSRasterizerList::Sync() -{ - while(m_sync) _mm_pause(); - - m_stats.ticks = __rdtsc() - m_start; - - for(int i = 0; i < m_threads; i++) + for(size_t i = 0; i < size(); i++) { - GSRasterizerStats s; - - (*this)[i]->GetStats(s); - - m_stats.pixels += s.pixels; - m_stats.prims = std::max(m_stats.prims, s.prims); + delete (*this)[i]; } } @@ -845,14 +847,31 @@ void GSRasterizerList::Draw(const GSRasterizerData* data, int width, int height) for(int i = 1; i < m_threads; i++) { - (*this)[i]->SetThreadId(i, m_threads); + (*this)[i]->Init(i, m_threads); (*this)[i]->Draw(data); } - (*this)[0]->SetThreadId(0, m_threads); + (*this)[0]->Init(0, m_threads); (*this)[0]->Draw(data); } +void GSRasterizerList::Sync() +{ + while(m_sync) _mm_pause(); + + m_stats.ticks = __rdtsc() - m_start; + + for(int i = 0; i < m_threads; i++) + { + GSRasterizerStats s; + + (*this)[i]->GetStats(s); + + m_stats.pixels += s.pixels; + m_stats.prims = std::max(m_stats.prims, s.prims); + } +} + void GSRasterizerList::GetStats(GSRasterizerStats& stats) { stats = m_stats; @@ -863,5 +882,16 @@ void GSRasterizerList::PrintStats() if(!empty()) { front()->PrintStats(); + + /* + int index = 0; + + for(std::vector::iterator i = begin(); i != end(); i++) + { + printf("[Thread %d]\n", index++); + + (*i)->PrintStats(); + } + */ } } diff --git a/plugins/GSdx/GSRasterizer.h b/plugins/GSdx/GSRasterizer.h index 8aa40c6c90..9309951214 100644 --- a/plugins/GSdx/GSRasterizer.h +++ b/plugins/GSdx/GSRasterizer.h @@ -27,9 +27,6 @@ #include "GSThread.h" #include "GSAlignedClass.h" -// -#define JIT_DRAW - __aligned(class, 32) GSRasterizerData { public: @@ -65,7 +62,7 @@ public: virtual void EndDraw(const GSRasterizerStats& stats, uint64 frame) = 0; virtual void PrintStats() = 0; -#ifdef JIT_DRAW +#ifdef ENABLE_JIT_RASTERIZER __forceinline void SetupPrim(const GSVertexSW* vertices, const GSVertexSW& dscan) {m_sp(vertices, dscan);} __forceinline void DrawScanline(int pixels, int left, int top, const GSVertexSW& scan) {m_ds(pixels, left, top, scan);} @@ -90,8 +87,8 @@ class IRasterizer public: virtual ~IRasterizer() {} + virtual void Init(int id, int threads) = 0; virtual void Draw(const GSRasterizerData* data) = 0; - virtual void SetThreadId(int id, int threads) = 0; virtual void GetStats(GSRasterizerStats& stats) = 0; virtual void PrintStats() = 0; }; @@ -116,11 +113,12 @@ protected: void DrawTriangle(const GSVertexSW* v); void DrawSprite(const GSVertexSW* v); - __forceinline void DrawTriangleSection(int top, int bottom, GSVertexSW& edge, const GSVertexSW& dedge, const GSVertexSW& dscan, const GSVector4& x0, const GSVector4& y0); + __forceinline void DrawTriangleSection(int top, int bottom, GSVertexSW& edge, const GSVertexSW& dedge, const GSVertexSW& dscan, const GSVector4& p0); void DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GSVertexSW& dv, int orientation, int side); __forceinline bool IsOneOfMyScanlines(int scanline) const; + __forceinline bool IsOneOfMyScanlines(int top, int bottom) const; __forceinline void AddScanline(GSVertexSW* e, int pixels, int left, int top, const GSVertexSW& scan); __forceinline void Flush(const GSVertexSW* vertices, const GSVertexSW& dscan, bool edge = false); @@ -130,8 +128,8 @@ public: // IRasterizer + void Init(int id, int threads); void Draw(const GSRasterizerData* data); - void SetThreadId(int id, int threads); void GetStats(GSRasterizerStats& stats); void PrintStats() {m_ds->PrintStats();} }; @@ -178,9 +176,8 @@ public: } } - void Sync(); - void Draw(const GSRasterizerData* data, int width, int height); + void Sync(); void GetStats(GSRasterizerStats& stats); void PrintStats(); }; diff --git a/plugins/GSdx/GSRendererDX11.cpp b/plugins/GSdx/GSRendererDX11.cpp index 12b4f509b9..adf754e5b8 100644 --- a/plugins/GSdx/GSRendererDX11.cpp +++ b/plugins/GSdx/GSRendererDX11.cpp @@ -45,7 +45,7 @@ void GSRendererDX11::VertexKick(bool skip) dst = *(GSVertexHW11*)&m_v; -#ifdef USE_UPSCALE_HACKS +#ifdef ENABLE_UPSCALE_HACKS if(tme && fst) { diff --git a/plugins/GSdx/GSRendererDX9.cpp b/plugins/GSdx/GSRendererDX9.cpp index de7a9c640c..d2c167a2ee 100644 --- a/plugins/GSdx/GSRendererDX9.cpp +++ b/plugins/GSdx/GSRendererDX9.cpp @@ -84,7 +84,7 @@ void GSRendererDX9::VertexKick(bool skip) { dst.t = m_v.GetUV(); - #ifdef USE_UPSCALE_HACKS + #ifdef ENABLE_UPSCALE_HACKS int Udiff = 0; int Vdiff = 0; diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index b183a70407..a408357bbd 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -756,7 +756,7 @@ protected: void Draw() { -#ifndef NO_CRC_HACKS +#ifndef DISABLE_CRC_HACKS if(GSRendererT::IsBadFrame(m_skip, m_userhacks_skipdraw)) return; #endif @@ -922,7 +922,7 @@ protected: s_n++; } -#ifdef HW_NO_TEXTURE_CACHE +#ifdef DISABLE_HW_TEXTURE_CACHE m_tc->Read(rt, r); #endif } diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index cbc9869a53..fe984eadce 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -782,25 +782,24 @@ void GSRendererSW::VertexKick(bool skip) if(GSVertexSW* v = DrawingKick(skip, count)) { + GS_PRIM_CLASS primclass = GSUtil::GetPrimClass(prim); + if(!m_dump) { GSVector4 pmin, pmax; - switch(prim) + switch(primclass) { - case GS_POINTLIST: + case GS_POINT_CLASS: pmin = v[0].p; pmax = v[0].p; break; - case GS_LINELIST: - case GS_LINESTRIP: - case GS_SPRITE: + case GS_LINE_CLASS: + case GS_SPRITE_CLASS: pmin = v[0].p.min(v[1].p); pmax = v[0].p.max(v[1].p); break; - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: + case GS_TRIANGLE_CLASS: pmin = v[0].p.min(v[1].p).min(v[2].p); pmax = v[0].p.max(v[1].p).max(v[2].p); break; @@ -810,21 +809,17 @@ if(!m_dump) GSVector4 test = (pmax < scissor) | (pmin > scissor.zwxy()); - switch(prim) + switch(primclass) { - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: - case GS_SPRITE: + case GS_TRIANGLE_CLASS: + case GS_SPRITE_CLASS: test |= pmin.ceil() == pmax.ceil(); break; } - switch(prim) + switch(primclass) { - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: + case GS_TRIANGLE_CLASS: // are in line or just two of them are the same (cross product == 0) GSVector4 tmp = (v[1].p - v[0].p) * (v[2].p - v[0].p).yxwz(); test |= tmp == tmp.yxwz(); @@ -836,42 +831,26 @@ if(!m_dump) return; } } - switch(prim) + switch(primclass) { - case GS_POINTLIST: + case GS_POINT_CLASS: break; - case GS_LINELIST: - case GS_LINESTRIP: + case GS_LINE_CLASS: if(PRIM->IIP == 0) {v[0].c = v[1].c;} break; - case GS_TRIANGLELIST: - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: + case GS_TRIANGLE_CLASS: if(PRIM->IIP == 0) {v[0].c = v[2].c; v[1].c = v[2].c;} break; - case GS_SPRITE: + case GS_SPRITE_CLASS: break; } if(m_count < 30 && m_count >= 3) { - GSVertexSW* v = &m_vertices[m_count - 3]; - int tl = 0; int br = 0; - bool isquad = false; - - switch(prim) - { - case GS_TRIANGLESTRIP: - case GS_TRIANGLEFAN: - case GS_TRIANGLELIST: - isquad = GSVertexSW::IsQuad(v, tl, br); - break; - } - - if(isquad) + if(primclass == GS_TRIANGLE_CLASS && GSVertexSW::IsQuad(&m_vertices[m_count - 3], tl, br)) { m_count -= 3; diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index f0d36105a6..2d83ef4a8a 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -256,7 +256,11 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code) theApp.SetConfig("upscale_multiplier", 1); } - theApp.SetConfig("windowed", (int)IsDlgButtonChecked(m_hWnd, IDC_WINDOWED)); + if(GetId() == IDD_CONFIG) // TODO: other options may not be present in IDD_CONFIG2 as well + { + theApp.SetConfig("windowed", (int)IsDlgButtonChecked(m_hWnd, IDC_WINDOWED)); + } + theApp.SetConfig("filter", (int)IsDlgButtonChecked(m_hWnd, IDC_FILTER)); theApp.SetConfig("paltex", (int)IsDlgButtonChecked(m_hWnd, IDC_PALTEX)); theApp.SetConfig("vsync", (int)IsDlgButtonChecked(m_hWnd, IDC_VSYNC)); diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index cc9b2d04fa..56bed5c0ab 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -22,11 +22,6 @@ #include "stdafx.h" #include "GSState.h" -//#define DISABLE_BITMASKING -//#define DISABLE_COLCLAMP -//#define DISABLE_DATE -//see stdafx.h for #define HW_NO_TEXTURE_CACHE and #define NO_CRC_HACKS - //#define Offset_ST // Fixes Persona3 mini map alignment which is off even in software rendering //#define Offset_UV // Fixes / breaks various titles @@ -1119,7 +1114,16 @@ void GSState::FlushWrite() if(len <= 0) return; - int y = m_tr.y; + GSVector4i r; + + r.left = m_env.TRXPOS.DSAX; + r.top = m_env.TRXPOS.DSAY; + r.right = r.left + m_env.TRXREG.RRW; + r.bottom = r.top + m_env.TRXREG.RRH; + + InvalidateVideoMem(m_env.BITBLTBUF, r); + + //int y = m_tr.y; GSLocalMemory::writeImage wi = GSLocalMemory::m_psm[m_env.BITBLTBUF.DPSM].wi; @@ -1129,6 +1133,7 @@ void GSState::FlushWrite() m_perfmon.Put(GSPerfMon::Swizzle, len); + /* GSVector4i r; r.left = m_env.TRXPOS.DSAX; @@ -1137,6 +1142,7 @@ void GSState::FlushWrite() r.bottom = std::min(r.top + m_env.TRXREG.RRH, m_tr.x == r.left ? m_tr.y : m_tr.y + 1); InvalidateVideoMem(m_env.BITBLTBUF, r); + */ /* static int n = 0; string s; @@ -1174,12 +1180,6 @@ void GSState::Write(const uint8* mem, int len) // printf("%d >= %d\n", len, m_tr.total); - (m_mem.*psm.wi)(m_tr.x, m_tr.y, mem, m_tr.total, m_env.BITBLTBUF, m_env.TRXPOS, m_env.TRXREG); - - m_tr.start = m_tr.end = m_tr.total; - - m_perfmon.Put(GSPerfMon::Swizzle, len); - GSVector4i r; r.left = m_env.TRXPOS.DSAX; @@ -1188,6 +1188,12 @@ void GSState::Write(const uint8* mem, int len) r.bottom = r.top + m_env.TRXREG.RRH; InvalidateVideoMem(m_env.BITBLTBUF, r); + + (m_mem.*psm.wi)(m_tr.x, m_tr.y, mem, m_tr.total, m_env.BITBLTBUF, m_env.TRXPOS, m_env.TRXREG); + + m_tr.start = m_tr.end = m_tr.total; + + m_perfmon.Put(GSPerfMon::Swizzle, len); } else { @@ -3211,9 +3217,7 @@ bool GSC_JamesBondEverythingOrNothing(const GSFrameInfo& fi, int& skip) return true; } - -//#define USE_DYNAMIC_CRC_HACK -#ifdef USE_DYNAMIC_CRC_HACK +#ifdef ENABLE_DYNAMIC_CRC_HACK #define DYNA_DLL_PATH "c:/dev/pcsx2/trunk/tools/dynacrchack/DynaCrcHack.dll" diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 0fbbfa4923..29319a5a54 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -88,7 +88,7 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con Target* dst = NULL; -#ifdef HW_NO_TEXTURE_CACHE +#ifdef DISABLE_HW_TEXTURE_CACHE if( 0 ) #else if(src == NULL) @@ -191,7 +191,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int if(multiplier > 1) // it's limited to a maximum of 4 on reading the config { -#if 0 //#ifdef USE_UPSCALE_HACKS //not happy with this yet.. +#if 0 //#ifdef ENABLE_UPSCALE_HACKS //not happy with this yet.. float x = 1.0f; float y = 1.0f; diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index ac5241a38d..f2fc753212 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -127,14 +127,14 @@ protected: // TODO: virtual void Write(Source* s, const GSVector4i& r) = 0; // TODO: virtual void Write(Target* t, const GSVector4i& r) = 0; -#ifndef HW_NO_TEXTURE_CACHE +#ifndef DISABLE_HW_TEXTURE_CACHE virtual void Read(Target* t, const GSVector4i& r) = 0; #endif public: GSTextureCache(GSRenderer* r); virtual ~GSTextureCache(); -#ifdef HW_NO_TEXTURE_CACHE +#ifdef DISABLE_HW_TEXTURE_CACHE virtual void Read(Target* t, const GSVector4i& r) = 0; #endif void RemoveAll(); diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 1d2b103e13..fdd29ae61e 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -135,8 +135,10 @@ const GSTextureCacheSW::Texture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TEX0 return t; } -void GSTextureCacheSW::InvalidateVideoMem(const GSOffset* o, const GSVector4i& rect) +bool GSTextureCacheSW::InvalidateVideoMem(const GSOffset* o, const GSVector4i& rect) { + bool changed = false; + uint32 bp = o->bp; uint32 bw = o->bw; uint32 psm = o->psm; @@ -163,6 +165,8 @@ void GSTextureCacheSW::InvalidateVideoMem(const GSOffset* o, const GSVector4i& r if(GSUtil::HasSharedBits(psm, t->m_TEX0.PSM)) { + changed = true; + if(t->m_repeating) { list& l = t->m_p2t[page]; @@ -183,6 +187,8 @@ void GSTextureCacheSW::InvalidateVideoMem(const GSOffset* o, const GSVector4i& r } } } + + return changed; } void GSTextureCacheSW::RemoveAll() diff --git a/plugins/GSdx/GSTextureCacheSW.h b/plugins/GSdx/GSTextureCacheSW.h index ddd261f98c..9f113a0a0f 100644 --- a/plugins/GSdx/GSTextureCacheSW.h +++ b/plugins/GSdx/GSTextureCacheSW.h @@ -63,7 +63,7 @@ public: const Texture* Lookup(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i& r, uint32 tw0 = 0); - void InvalidateVideoMem(const GSOffset* o, const GSVector4i& r); + bool InvalidateVideoMem(const GSOffset* o, const GSVector4i& r); void RemoveAll(); void RemoveAt(Texture* t); diff --git a/plugins/GSdx/GSdx.vcxproj b/plugins/GSdx/GSdx.vcxproj index ddc498b1e3..82412e5e72 100644 --- a/plugins/GSdx/GSdx.vcxproj +++ b/plugins/GSdx/GSdx.vcxproj @@ -1618,6 +1618,7 @@ + diff --git a/plugins/GSdx/GSdx.vcxproj.filters b/plugins/GSdx/GSdx.vcxproj.filters index b281f5b5b7..59464dc543 100644 --- a/plugins/GSdx/GSdx.vcxproj.filters +++ b/plugins/GSdx/GSdx.vcxproj.filters @@ -644,6 +644,9 @@ Header Files + + Header Files + diff --git a/plugins/GSdx/config.h b/plugins/GSdx/config.h new file mode 100644 index 0000000000..1f63b0142f --- /dev/null +++ b/plugins/GSdx/config.h @@ -0,0 +1,23 @@ +#pragma once + +//#define ENABLE_VTUNE + +#define ENABLE_JIT_RASTERIZER + +//#define ENABLE_DYNAMIC_CRC_HACK + +#define ENABLE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers + +//#define DISABLE_HW_TEXTURE_CACHE // Slow but fixes a lot of bugs + +//#define DISABLE_CRC_HACKS // Disable all game specific hacks + +#if defined(DISABLE_HW_TEXTURE_CACHE) && !defined(DISABLE_CRC_HACKS) + #define DISABLE_CRC_HACKS +#endif + +//#define DISABLE_BITMASKING + +//#define DISABLE_COLCLAMP + +//#define DISABLE_DATE diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index cc28f6ca91..e25d1974ce 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -25,6 +25,8 @@ #pragma once +#include "config.h" + #ifdef _WINDOWS // The following macros define the minimum required platform. The minimum required platform @@ -91,29 +93,29 @@ using namespace std; #ifdef _WINDOWS -#include -#include + #include + #include -using namespace stdext; + using namespace stdext; -#define vsnprintf _vsnprintf -#define snprintf _snprintf + #define vsnprintf _vsnprintf + #define snprintf _snprintf -#define DIRECTORY_SEPARATOR '\\' + #define DIRECTORY_SEPARATOR '\\' #else -#define _BACKWARD_BACKWARD_WARNING_H + #define _BACKWARD_BACKWARD_WARNING_H -#define hash_map map -#define hash_set set + #define hash_map map + #define hash_set set -//#include -//#include + //#include + //#include -//using namespace __gnu_cxx; + //using namespace __gnu_cxx; -#define DIRECTORY_SEPARATOR '/' + #define DIRECTORY_SEPARATOR '/' #endif @@ -276,61 +278,66 @@ typedef signed long long int64; #if !defined(_MSC_VER) -#if !defined(HAVE_ALIGNED_MALLOC) + #if !defined(HAVE_ALIGNED_MALLOC) -extern void* _aligned_malloc(size_t size, size_t alignment); -extern void _aligned_free(void* p); + extern void* _aligned_malloc(size_t size, size_t alignment); + extern void _aligned_free(void* p); -#endif + #endif -// http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin_x86.h?view=markup -// - the other intrin_x86.h of pcsx2 is not up to date, its _interlockedbittestandreset simply does not work. + // http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin_x86.h?view=markup + // - the other intrin_x86.h of pcsx2 is not up to date, its _interlockedbittestandreset simply does not work. -__forceinline unsigned char _BitScanForward(unsigned long* const Index, const unsigned long Mask) -{ - __asm__("bsfl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask)); - return Mask ? 1 : 0; -} + __forceinline unsigned char _BitScanForward(unsigned long* const Index, const unsigned long Mask) + { + __asm__("bsfl %[Mask], %[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask)); + return Mask ? 1 : 0; + } -__forceinline unsigned char _interlockedbittestandreset(volatile long* a, const long b) -{ - unsigned char retval; - __asm__("lock; btrl %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval), [a] "+m" (*a) : [b] "Ir" (b) : "memory"); - return retval; -} + __forceinline unsigned char _interlockedbittestandreset(volatile long* a, const long b) + { + unsigned char retval; + __asm__("lock; btrl %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval), [a] "+m" (*a) : [b] "Ir" (b) : "memory"); + return retval; + } -__forceinline unsigned char _interlockedbittestandset(volatile long* a, const long b) -{ - unsigned char retval; - __asm__("lock; btsl %[b], %[a]; setc %b[retval]" : [retval] "=q" (retval), [a] "+m" (*a) : [b] "Ir" (b) : "memory"); - return retval; -} + __forceinline unsigned char _interlockedbittestandset(volatile long* a, const long b) + { + unsigned char retval; + __asm__("lock; btsl %[b], %[a]; setc %b[retval]" : [retval] "=q" (retval), [a] "+m" (*a) : [b] "Ir" (b) : "memory"); + return retval; + } -#ifdef __GNUC__ + #ifdef __GNUC__ -__forceinline unsigned long long __rdtsc() -{ - #if defined(__amd64__) || defined(__x86_64__) - unsigned long long low, high; - __asm__ __volatile__("rdtsc" : "=a"(low), "=d"(high)); - return low | (high << 32); - #else - unsigned long long retval; - __asm__ __volatile__("rdtsc" : "=A"(retval)); - return retval; - #endif -} + __forceinline unsigned long long __rdtsc() + { + #if defined(__amd64__) || defined(__x86_64__) + unsigned long long low, high; + __asm__ __volatile__("rdtsc" : "=a"(low), "=d"(high)); + return low | (high << 32); + #else + unsigned long long retval; + __asm__ __volatile__("rdtsc" : "=A"(retval)); + return retval; + #endif + } -#endif + #endif #endif extern void* vmalloc(size_t size, bool code); extern void vmfree(void* ptr, size_t size); -#define USE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers -//#define HW_NO_TEXTURE_CACHE // Slow but fixes a lot of bugs -//#define NO_CRC_HACKS // Disable all game specific hacks -#ifdef HW_NO_TEXTURE_CACHE - #define NO_CRC_HACKS -#endif \ No newline at end of file +#ifdef _WINDOWS + + #ifdef ENABLE_VTUNE + + #include + + #pragma comment(lib, "jitprofiling.lib") + + #endif + +#endif diff --git a/plugins/GSdx/vsprops/common.props b/plugins/GSdx/vsprops/common.props index 2e2aaa841f..fc7deac604 100644 --- a/plugins/GSdx/vsprops/common.props +++ b/plugins/GSdx/vsprops/common.props @@ -14,7 +14,7 @@ Level4 ProgramDatabase 4996;4995;4324;4100;4101;4201;4556;%(DisableSpecificWarnings) - $(DXSDK_DIR)include + $(DXSDK_DIR)include;$(VTUNE_AMPLIFIER_XE_2011_DIR)include;%(AdditionalIncludeDirectories) true @@ -23,6 +23,7 @@ true Windows false + $(VTUNE_AMPLIFIER_XE_2011_DIR)lib32;%(AdditionalLibraryDirectories) .\postBuild.cmd "$(TargetPath)" "$(TargetName)" $(TargetExt) $(PcsxSubsection)