This commit is contained in:
gabest 2008-12-05 09:47:18 +00:00
parent 40cc27f48a
commit fc1035cbab
105 changed files with 245 additions and 248 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -105,14 +105,16 @@ EXPORT_C_(INT32) GPUopen(HWND hWnd)
rs.m_scale.cx = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_x"), 0);
rs.m_scale.cy = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_y"), 0);
int threads = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("swthreads"), 1);
int renderer = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("Renderer"), 1);
switch(renderer)
{
default:
// TODO: case 0: s_gpu = new GPURendererSW<GSDevice7>(rs); break;
case 1: s_gpu = new GPURendererSW<GSDevice9>(rs); break;
case 2: s_gpu = new GPURendererSW<GSDevice10>(rs); break;
case 1: s_gpu = new GPURendererSW<GSDevice9>(rs, threads); break;
case 2: s_gpu = new GPURendererSW<GSDevice10>(rs, threads); break;
// TODO: case 3: s_gpu = new GPURendererNull<GSDeviceNull>(rs); break;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -22,10 +22,10 @@
#include "StdAfx.h"
#include "GPUDrawScanline.h"
GPUDrawScanline::GPUDrawScanline(GPUState* state, int filter, int dither)
GPUDrawScanline::GPUDrawScanline(GPUState* state)
: m_state(state)
, m_filter(filter)
, m_dither(dither)
, m_filter(0)
, m_dither(1)
{
Init();
}
@ -119,8 +119,6 @@ void GPUDrawScanline::DrawScanline(int top, int left, int right, const Vertex& v
void GPUDrawScanline::FillRect(const GSVector4i& r, const Vertex& v)
{
// TODO
ASSERT(0);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -97,7 +97,7 @@ protected:
int m_dither;
public:
GPUDrawScanline(GPUState* state, int filter, int dither);
GPUDrawScanline(GPUState* state);
virtual ~GPUDrawScanline();
void SetOptions(int filter, int dither);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -30,10 +30,7 @@ class GPURendererSW : public GPURenderer<Device, GSVertexSW>, public IDrawAsync
typedef GSVertexSW Vertex;
protected:
long* m_sync;
long m_threads;
GSRasterizer* m_rst;
CAtlList<GSRasterizerMT*> m_rmt;
GSRasterizerList m_rl;
Texture m_texture;
void ResetDevice()
@ -135,56 +132,28 @@ protected:
//
GPUDrawScanline* ds = (GPUDrawScanline*)m_rst->GetDrawScanline();
ds->SetOptions(m_filter, m_dither);
ds->SetupDraw(m_vertices, m_count, texture);
//
*m_sync = 0;
POSITION pos = m_rmt.GetHeadPosition();
while(pos)
{
GSRasterizerMT* r = m_rmt.GetNext(pos);
GPUDrawScanline* ds = (GPUDrawScanline*)r->GetDrawScanline();
ds->SetOptions(m_filter, m_dither);
ds->SetupDraw(m_vertices, m_count, texture);
r->Draw();
}
// 1st thread is this thread
int prims = DrawAsync(m_rst);
// wait for the other threads to finish
while(*m_sync)
{
_mm_pause();
}
m_perfmon.Put(GSPerfMon::Prim, prims);
m_perfmon.Put(GSPerfMon::Draw, 1);
{
int pixels = m_rst->GetPixels();
POSITION pos = m_rmt.GetHeadPosition();
POSITION pos = m_rl.GetHeadPosition();
while(pos)
{
pixels += m_rmt.GetNext(pos)->GetPixels();
}
GSRasterizerMT* r = m_rl.GetNext(pos);
m_perfmon.Put(GSPerfMon::Fillrate, pixels);
GPUDrawScanline* ds = (GPUDrawScanline*)r->GetDrawScanline();
ds->SetOptions(m_filter, m_dither);
}
}
int prims = m_rl.Draw(m_vertices, m_count, texture);
m_perfmon.Put(GSPerfMon::Prim, prims);
m_perfmon.Put(GSPerfMon::Draw, 1);
int pixels = m_rl.GetPixels();
m_perfmon.Put(GSPerfMon::Fillrate, pixels);
// TODO
{
@ -216,6 +185,8 @@ protected:
{
GSVector4i scissor = GetScissor();
//
int prims = 0;
switch(m_env.PRIM.TYPE)
@ -243,18 +214,10 @@ protected:
}
public:
GPURendererSW(const GPURendererSettings& rs)
GPURendererSW(const GPURendererSettings& rs, int threads)
: GPURenderer(rs)
{
m_sync = (long*)_aligned_malloc(sizeof(*m_sync), 128); // get a whole cache line
m_threads = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("swthreads"), 1);
m_rst = new GSRasterizer(new GPUDrawScanline(this, m_filter, m_dither), 0, m_threads);
for(int i = 1; i < m_threads; i++)
{
m_rmt.AddTail(new GSRasterizerMT(new GPUDrawScanline(this, m_filter, m_dither), i, m_threads, this, m_sync));
}
m_rl.Create<GPUDrawScanline>(this, this, threads);
m_fpDrawingKickHandlers[GPU_POLYGON] = (DrawingKickHandler)&GPURendererSW::DrawingKickTriangle;
m_fpDrawingKickHandlers[GPU_LINE] = (DrawingKickHandler)&GPURendererSW::DrawingKickLine;
@ -263,11 +226,5 @@ public:
virtual ~GPURendererSW()
{
delete m_rst;
while(!m_rmt.IsEmpty())
{
delete m_rmt.RemoveHead();
}
}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -118,16 +118,18 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer)
rs.m_vsync = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("vsync"), FALSE);
rs.m_nativeres = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("nativeres"), FALSE);
int threads = AfxGetApp()->GetProfileInt(_T("Settings"), _T("swthreads"), 1);
switch(renderer)
{
default:
case 0: s_gs = new GSRendererHW9(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 1: s_gs = new GSRendererSW<GSDevice9>(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 1: s_gs = new GSRendererSW<GSDevice9>(s_basemem, !!mt, s_irq, nloophack, rs, threads); break;
case 2: s_gs = new GSRendererNull<GSDevice9>(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 3: s_gs = new GSRendererHW10(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 4: s_gs = new GSRendererSW<GSDevice10>(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 4: s_gs = new GSRendererSW<GSDevice10>(s_basemem, !!mt, s_irq, nloophack, rs, threads); break;
case 5: s_gs = new GSRendererNull<GSDevice10>(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 6: s_gs = new GSRendererSW<GSDeviceNull>(s_basemem, !!mt, s_irq, nloophack, rs); break;
case 6: s_gs = new GSRendererSW<GSDeviceNull>(s_basemem, !!mt, s_irq, nloophack, rs, threads); break;
case 7: s_gs = new GSRendererNull<GSDeviceNull>(s_basemem, !!mt, s_irq, nloophack, rs); break;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -420,7 +420,6 @@ void GSDrawScanline::SampleTexture(int pixels, DWORD ztst, DWORD ltf, DWORD tlu,
c00 = c00.lerp(c10, vff.v[i]);
c[i] = c00;
}
while(++i < pixels);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -471,7 +471,10 @@ GSRasterizerMT::GSRasterizerMT(IDrawScanline* ds, int id, int threads, IDrawAsyn
, m_ThreadId(0)
, m_hThread(NULL)
{
m_hThread = CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
if(id > 0)
{
m_hThread = CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
}
}
GSRasterizerMT::~GSRasterizerMT()
@ -489,9 +492,22 @@ GSRasterizerMT::~GSRasterizerMT()
}
}
void GSRasterizerMT::Draw()
int GSRasterizerMT::Draw(Vertex* vertices, int count, const void* texture)
{
InterlockedBitTestAndSet(m_sync, m_id);
m_ds->SetupDraw(vertices, count, texture);
int prims = 0;
if(m_id == 0)
{
prims = m_da->DrawAsync(this);
}
else
{
InterlockedBitTestAndSet(m_sync, m_id);
}
return prims;
}
DWORD WINAPI GSRasterizerMT::StaticThreadProc(LPVOID lpParam)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -66,6 +66,7 @@ public:
void DrawSprite(Vertex* v, const GSVector4i& scissor, bool solid);
IDrawScanline* GetDrawScanline() {return m_ds;}
int GetPixels() {int pixels = m_pixels; m_pixels = 0; return pixels;}
};
@ -91,5 +92,84 @@ public:
GSRasterizerMT(IDrawScanline* ds, int id, int threads, IDrawAsync* da, long* sync);
virtual ~GSRasterizerMT();
void Draw();
int Draw(Vertex* vertices, int count, const void* texture);
};
class GSRasterizerList : public CAtlList<GSRasterizerMT*>
{
long* m_sync;
void FreeRasterizers()
{
while(!IsEmpty())
{
delete RemoveHead();
}
}
public:
GSRasterizerList()
{
// get a whole cache line (twice the size for future cpus ;)
m_sync = (long*)_aligned_malloc(sizeof(*m_sync), 128);
}
virtual ~GSRasterizerList()
{
_aligned_free(m_sync);
FreeRasterizers();
}
template<class DS, class T> void Create(T* parent, IDrawAsync* da, int threads)
{
FreeRasterizers();
threads = max(threads, 1); // TODO: min(threads, number of cpu cores)
for(int i = 0; i < threads; i++)
{
AddTail(new GSRasterizerMT(new DS(parent), i, threads, da, m_sync));
}
}
int Draw(GSVertexSW* vertices, int count, const void* texture)
{
*m_sync = 0;
int prims = 0;
POSITION pos = GetHeadPosition();
while(pos)
{
GSRasterizerMT* r = GetNext(pos);
prims += r->Draw(vertices, count, texture);
}
// wait for the other threads to finish
while(*m_sync)
{
_mm_pause();
}
return prims;
}
int GetPixels()
{
int pixels = 0;
POSITION pos = GetHeadPosition();
while(pos)
{
pixels += GetNext(pos)->GetPixels();
}
return pixels;
}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
@ -33,11 +33,8 @@ class GSRendererSW : public GSRendererT<Device, GSVertexSW>, public IDrawAsync
typedef GSVertexSW Vertex;
protected:
long* m_sync;
long m_threads;
GSRasterizerList m_rl;
GSTextureCacheSW* m_tc;
GSRasterizer* m_rst;
CAtlList<GSRasterizerMT*> m_rmt;
Texture m_texture[2];
bool m_reset;
@ -322,53 +319,14 @@ protected:
//
GSDrawScanline* ds = (GSDrawScanline*)m_rst->GetDrawScanline();
ds->SetupDraw(m_vertices, m_count, texture);
//
*m_sync = 0;
POSITION pos = m_rmt.GetHeadPosition();
while(pos)
{
GSRasterizerMT* r = m_rmt.GetNext(pos);
GSDrawScanline* ds = (GSDrawScanline*)r->GetDrawScanline();
ds->SetupDraw(m_vertices, m_count, texture);
r->Draw();
}
// 1st thread is this thread
int prims = DrawAsync(m_rst);
// wait for the other threads to finish
while(*m_sync)
{
_mm_pause();
}
int prims = m_rl.Draw(m_vertices, m_count, texture);
m_perfmon.Put(GSPerfMon::Prim, prims);
m_perfmon.Put(GSPerfMon::Draw, 1);
{
int pixels = m_rst->GetPixels();
POSITION pos = m_rmt.GetHeadPosition();
int pixels = m_rl.GetPixels();
while(pos)
{
pixels += m_rmt.GetNext(pos)->GetPixels();
}
m_perfmon.Put(GSPerfMon::Fillrate, pixels);
}
m_perfmon.Put(GSPerfMon::Fillrate, pixels);
// TODO
@ -481,19 +439,12 @@ protected:
}
public:
GSRendererSW(BYTE* base, bool mt, void (*irq)(), int nloophack, const GSRendererSettings& rs)
GSRendererSW(BYTE* base, bool mt, void (*irq)(), int nloophack, const GSRendererSettings& rs, int threads)
: GSRendererT(base, mt, irq, nloophack, rs)
{
m_sync = (long*)_aligned_malloc(sizeof(*m_sync), 128); // get a whole cache line
m_threads = AfxGetApp()->GetProfileInt(_T("Settings"), _T("swthreads"), 1);
m_rl.Create<GSDrawScanline>(this, this, threads);
m_tc = new GSTextureCacheSW(this);
m_rst = new GSRasterizer(new GSDrawScanline(this), 0, m_threads);
for(int i = 1; i < m_threads; i++)
{
m_rmt.AddTail(new GSRasterizerMT(new GSDrawScanline(this), i, m_threads, this, m_sync));
}
m_fpDrawingKickHandlers[GS_POINTLIST] = (DrawingKickHandler)&GSRendererSW::DrawingKickPoint;
m_fpDrawingKickHandlers[GS_LINELIST] = (DrawingKickHandler)&GSRendererSW::DrawingKickLine;
@ -507,16 +458,10 @@ public:
virtual ~GSRendererSW()
{
delete m_tc;
delete m_rst;
while(!m_rmt.IsEmpty())
{
delete m_rmt.RemoveHead();
}
}
GSRasterizer* GetRasterizer()
{
return m_rst;
return m_rl.GetHead();
}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2007 Gabest
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify

Some files were not shown because too many files have changed in this diff Show More