diff --git a/plugins/GSdx/GPURendererSW.cpp b/plugins/GSdx/GPURendererSW.cpp index 7c693c4afd..6eb1f078e3 100644 --- a/plugins/GSdx/GPURendererSW.cpp +++ b/plugins/GSdx/GPURendererSW.cpp @@ -69,28 +69,6 @@ GSTexture* GPURendererSW::GetOutput() void GPURendererSW::Draw() { - class GPURasterizerData : public GSRasterizerData - { - public: - GPURasterizerData() - { - GPUScanlineGlobalData* gd = (GPUScanlineGlobalData*)_aligned_malloc(sizeof(GPUScanlineGlobalData), 32); - - gd->clut = NULL; - - param = gd; - } - - virtual ~GPURasterizerData() - { - GPUScanlineGlobalData* gd = (GPUScanlineGlobalData*)param; - - if(gd->clut) _aligned_free(gd->clut); - - _aligned_free(gd); - } - }; - shared_ptr data(new GPURasterizerData()); GPUScanlineGlobalData& gd = *(GPUScanlineGlobalData*)data->param; diff --git a/plugins/GSdx/GPURendererSW.h b/plugins/GSdx/GPURendererSW.h index cb9ea9e691..c9d4ccef00 100644 --- a/plugins/GSdx/GPURendererSW.h +++ b/plugins/GSdx/GPURendererSW.h @@ -26,6 +26,28 @@ class GPURendererSW : public GPURendererT { + class GPURasterizerData : public GSRasterizerData + { + public: + GPURasterizerData() + { + GPUScanlineGlobalData* gd = (GPUScanlineGlobalData*)_aligned_malloc(sizeof(GPUScanlineGlobalData), 32); + + gd->clut = NULL; + + param = gd; + } + + virtual ~GPURasterizerData() + { + GPUScanlineGlobalData* gd = (GPUScanlineGlobalData*)param; + + if(gd->clut) _aligned_free(gd->clut); + + _aligned_free(gd); + } + }; + protected: GSRasterizerList* m_rl; GSTexture* m_texture; diff --git a/plugins/GSdx/GSRasterizer.cpp b/plugins/GSdx/GSRasterizer.cpp index 27198c3988..3c470fb6c7 100644 --- a/plugins/GSdx/GSRasterizer.cpp +++ b/plugins/GSdx/GSRasterizer.cpp @@ -126,7 +126,7 @@ void GSRasterizer::Draw(shared_ptr data) m_ds->EndDraw(data->frame, ticks, m_pixels); } -template +template void GSRasterizer::DrawPoint(const GSVertexSW* v, int count) { for(; count > 0; count--, v++) @@ -186,7 +186,7 @@ void GSRasterizer::DrawLine(const GSVertexSW* v) if(m_scissor.top <= p.y && p.y < m_scissor.bottom && IsOneOfMyScanlines(p.y)) { GSVector4 scissor = m_fscissor.xzxz(); - + GSVector4 lrf = scan.p.upl(v[1].p.blend32(v[0].p, mask)).ceil(); GSVector4 l = lrf.max(scissor); GSVector4 r = lrf.min(scissor); @@ -301,7 +301,7 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) GSVector4 cross = dv[0].p * dv[1].p.yxwz(); cross = (cross - cross.yxwz()).yyyy(); // select the second component, the negated cross product - + // the longest horizontal span would be cross.x / dv[1].p.y, but we don't need its actual value int j = cross.upl(cross == GSVector4::zero()).mask(); @@ -317,8 +317,8 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) GSVector4 dx = dxy01.xzxy(dv[2].p); GSVector4 dy = dxy01.ywyx(dv[2].p); - GSVector4 ddx[3]; - + GSVector4 ddx[3]; + ddx[0] = dx / dy; ddx[1] = ddx[0].yxzw(); ddx[2] = ddx[0].xzyw(); @@ -336,7 +336,7 @@ void GSRasterizer::DrawTriangle(const GSVertexSW* vertices) GSVector4 _s = dxy01c * dv[1].t.xxxx(dv[0].t); // dx0 * s1, dy0 * s1, dx1 * s0, dy1 * s0 GSVector4 _t = dxy01c * dv[1].t.yyyy(dv[0].t); // dx0 * t1, dy0 * t1, dx1 * t0, dy1 * t0 GSVector4 _q = dxy01c * dv[1].t.zzzz(dv[0].t); // dx0 * q1, dy0 * q1, dx1 * q0, dy1 * q0 - + dscan.t = _s.ywyw(_t).hsub(_q.ywyw()); // dy0 * s1 - dy1 * s0, dy0 * t1 - dy1 * t0, dy0 * q1 - dy1 * q0 dedge.t = _s.zxzx(_t).hsub(_q.zxzx()); // dx1 * s0 - dx0 * s1, dx1 * t0 - dx0 * t1, dx1 * q0 - dx0 * q1 @@ -418,7 +418,7 @@ void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& edge, co GSVector4 dy = GSVector4(top) - p0.yyyy(); GSVertexSW scan; - + scan.p = edge.p + dedge.p * dy; GSVector4 lrf = scan.p.ceil(); @@ -441,7 +441,7 @@ void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& edge, co } } while(++top < bottom); - + m_edge.count += e - &m_edge.buff[m_edge.count]; } @@ -526,7 +526,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS // TODO: it does not always line up with the edge of the surrounded triangle GSVertexSW* RESTRICT e = &m_edge.buff[m_edge.count]; - + GSVector4 lrtb = v0.p.upl(v1.p).ceil(); if(orientation) @@ -727,7 +727,7 @@ void GSRasterizer::Flush(const GSVertexSW* vertices, const GSVertexSW& dscan, bo if(!edge) { - do + do { int pixels = e->p.i16[0]; int left = e->p.i16[1]; @@ -741,7 +741,7 @@ void GSRasterizer::Flush(const GSVertexSW* vertices, const GSVertexSW& dscan, bo } else { - do + do { int pixels = e->p.i16[0]; int left = e->p.i16[1]; @@ -798,7 +798,7 @@ void GSRasterizerMT::Queue(shared_ptr data) void GSRasterizerMT::Sync() { - while(!m_queue.empty()) _mm_pause(); + while(!m_queue.empty()) _mm_pause(); m_break = true; @@ -820,7 +820,14 @@ void GSRasterizerMT::ThreadProc() { GSAutoLock l(&m_lock); - queue.swap(m_queue); + // TODO: queue.swap(m_queue); // GCC + + while(!m_queue.empty()) + { + queue.push(m_queue.front()); + + m_queue.pop(); + } } while(!queue.empty()) @@ -832,7 +839,7 @@ void GSRasterizerMT::ThreadProc() } else { - _mm_pause(); + _mm_pause(); } } @@ -876,7 +883,7 @@ void GSRasterizerList::Queue(shared_ptr data) GSVector4i bbox = data->bbox.rintersect(data->scissor); for(int i = 0; i < size(); i++) - { + { GSRasterizer* r = (*this)[i]; if(r->IsOneOfMyScanlines(bbox.top, bbox.bottom)) diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index 4d6f0442fa..02004cb3a8 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -136,9 +136,9 @@ void GSRendererSW::Draw() { if(m_dump) m_dump.Object(m_vertices, m_count, m_vt.m_primclass); - if(m_fzb != m_context->offset.fzb) + if(m_fzb != m_context->offset.fzb) { - // rasterizers must write the same outputs at the same time, this makes sure each thread has its own private surface area + // rasterizers must write the same outputs at the same time, this makes sure each thread has its own private surface area // TODO: detect if frame/zbuf overlap eachother (?) @@ -147,7 +147,7 @@ void GSRendererSW::Draw() Sync(); } - shared_ptr data(new GSRasterizerData2(this)); + shared_ptr data(new GSRasterizerData2()); GSScanlineGlobalData* gd = (GSScanlineGlobalData*)data->param; @@ -310,7 +310,7 @@ void GSRendererSW::InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GS void GSRendererSW::InvalidatePages(const GSTextureCacheSW::Texture* t) { //printf("tex %05x %d %d\n", t->m_TEX0.TBP0, t->m_TEX0.TBW, t->m_TEX0.PSM); - + for(size_t i = 0; i < countof(t->m_pages); i++) { if(m_fzb_pages[i] & t->m_pages[i]) // currently begin drawn to? => sync @@ -338,7 +338,7 @@ void GSRendererSW::InvalidatePages(const GSOffset* o, const GSVector4i& rect) for(int x = r.left; x < r.right; x += bs.x) { - uint32 page = (base + o->block.col[x >> 3]) >> 5; + uint32 page = (base + o->block.col[x >> 3]) >> 5; if(page < MAX_PAGES) { @@ -360,7 +360,7 @@ bool GSRendererSW::CheckPages(const GSOffset* o, const GSVector4i& rect) for(int x = r.left; x < r.right; x += bs.x) { - uint32 page = (base + o->block.col[x >> 3]) >> 5; + uint32 page = (base + o->block.col[x >> 3]) >> 5; if(page < MAX_PAGES) { @@ -524,7 +524,7 @@ bool GSRendererSW::GetScanlineGlobalData(GSScanlineGlobalData& gd) // 011 p tri // 100 l round // 101 l tri - + if(m_vt.m_lod.x > 0) { gd.sel.ltf = context->TEX1.MMIN >> 2; @@ -600,29 +600,29 @@ bool GSRendererSW::GetScanlineGlobalData(GSScanlineGlobalData& gd) { switch(i) { - case 1: - MIP_TEX0.TBP0 = context->MIPTBP1.TBP1; - MIP_TEX0.TBW = context->MIPTBP1.TBW1; + case 1: + MIP_TEX0.TBP0 = context->MIPTBP1.TBP1; + MIP_TEX0.TBW = context->MIPTBP1.TBW1; break; - case 2: - MIP_TEX0.TBP0 = context->MIPTBP1.TBP2; - MIP_TEX0.TBW = context->MIPTBP1.TBW2; + case 2: + MIP_TEX0.TBP0 = context->MIPTBP1.TBP2; + MIP_TEX0.TBW = context->MIPTBP1.TBW2; break; - case 3: - MIP_TEX0.TBP0 = context->MIPTBP1.TBP3; - MIP_TEX0.TBW = context->MIPTBP1.TBW3; + case 3: + MIP_TEX0.TBP0 = context->MIPTBP1.TBP3; + MIP_TEX0.TBW = context->MIPTBP1.TBW3; break; - case 4: - MIP_TEX0.TBP0 = context->MIPTBP2.TBP4; - MIP_TEX0.TBW = context->MIPTBP2.TBW4; + case 4: + MIP_TEX0.TBP0 = context->MIPTBP2.TBP4; + MIP_TEX0.TBW = context->MIPTBP2.TBW4; break; - case 5: - MIP_TEX0.TBP0 = context->MIPTBP2.TBP5; - MIP_TEX0.TBW = context->MIPTBP2.TBW5; + case 5: + MIP_TEX0.TBP0 = context->MIPTBP2.TBP5; + MIP_TEX0.TBW = context->MIPTBP2.TBW5; break; - case 6: - MIP_TEX0.TBP0 = context->MIPTBP2.TBP6; - MIP_TEX0.TBW = context->MIPTBP2.TBW6; + case 6: + MIP_TEX0.TBP0 = context->MIPTBP2.TBP6; + MIP_TEX0.TBW = context->MIPTBP2.TBW6; break; default: __assume(0); diff --git a/plugins/GSdx/GSRendererSW.h b/plugins/GSdx/GSRendererSW.h index 5922a10387..86199b4587 100644 --- a/plugins/GSdx/GSRendererSW.h +++ b/plugins/GSdx/GSRendererSW.h @@ -30,7 +30,7 @@ class GSRendererSW : public GSRendererT class GSRasterizerData2 : public GSRasterizerData { public: - GSRasterizerData2(GSRenderer* r) + GSRasterizerData2() { GSScanlineGlobalData* gd = (GSScanlineGlobalData*)_aligned_malloc(sizeof(GSScanlineGlobalData), 32); @@ -49,7 +49,7 @@ class GSRendererSW : public GSRendererT _aligned_free(gd); } - }; + }; protected: GSRasterizerList* m_rl; @@ -81,6 +81,6 @@ public: GSRendererSW(int threads); virtual ~GSRendererSW(); - template + template void VertexKick(bool skip); }; diff --git a/plugins/GSdx/GSdx.gcc.cbp b/plugins/GSdx/GSdx.gcc.cbp index 2e1e041952..b6e13de18e 100644 --- a/plugins/GSdx/GSdx.gcc.cbp +++ b/plugins/GSdx/GSdx.gcc.cbp @@ -118,6 +118,8 @@ + + diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 10c5638451..f7d5de3879 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -92,6 +92,14 @@ using namespace std; +#ifdef __GNUC__ + +#include + +using namespace std::tr1; + +#endif + #ifdef _WINDOWS #include