2009-02-09 21:15:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* This Program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This Program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "GPUDrawScanline.h"
|
|
|
|
|
|
|
|
GPUDrawScanline::GPUDrawScanline(GPUState* state, int id)
|
|
|
|
: m_state(state)
|
|
|
|
, m_id(id)
|
2009-02-20 10:59:10 +00:00
|
|
|
, m_sp(m_env)
|
2009-02-19 13:13:20 +00:00
|
|
|
, m_ds(m_env)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUDrawScanline::~GPUDrawScanline()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUDrawScanline::BeginDraw(const GSRasterizerData* data, Functions* f)
|
|
|
|
{
|
|
|
|
GPUDrawingEnvironment& env = m_state->m_env;
|
|
|
|
|
|
|
|
const GPUScanlineParam* p = (const GPUScanlineParam*)data->param;
|
|
|
|
|
|
|
|
m_env.sel = p->sel;
|
|
|
|
|
2009-02-19 13:13:20 +00:00
|
|
|
m_env.vm = m_state->m_mem.GetPixelAddress(0, 0);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
if(m_env.sel.tme)
|
|
|
|
{
|
|
|
|
m_env.tex = p->tex;
|
|
|
|
m_env.clut = p->clut;
|
|
|
|
|
|
|
|
if(m_env.sel.twin)
|
|
|
|
{
|
|
|
|
DWORD u, v;
|
|
|
|
|
|
|
|
u = ~(env.TWIN.TWW << 3) & 0xff;
|
|
|
|
v = ~(env.TWIN.TWH << 3) & 0xff;
|
|
|
|
|
2009-02-19 13:13:20 +00:00
|
|
|
m_env.twin[0].u = GSVector4i((u << 16) | u);
|
|
|
|
m_env.twin[0].v = GSVector4i((v << 16) | v);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
u = env.TWIN.TWX << 3;
|
|
|
|
v = env.TWIN.TWY << 3;
|
|
|
|
|
2009-02-19 13:13:20 +00:00
|
|
|
m_env.twin[1].u = GSVector4i((u << 16) | u) & ~m_env.twin[0].u;
|
|
|
|
m_env.twin[1].v = GSVector4i((v << 16) | v) & ~m_env.twin[0].v;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 13:13:20 +00:00
|
|
|
//
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-19 13:13:20 +00:00
|
|
|
f->ssl = m_ds.Lookup(m_env.sel);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
f->sr = NULL; // TODO
|
2009-02-19 13:13:20 +00:00
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
// doesn't need all bits => less functions generated
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
GPUScanlineSelector sel;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
sel.key = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
sel.iip = m_env.sel.iip;
|
|
|
|
sel.tfx = m_env.sel.tfx;
|
|
|
|
sel.twin = m_env.sel.twin;
|
|
|
|
sel.sprite = m_env.sel.sprite;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
f->ssp = m_sp.Lookup(sel);
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
void GPUDrawScanline::EndDraw(const GSRasterizerStats& stats)
|
|
|
|
{
|
|
|
|
m_ds.UpdateStats(stats, m_state->m_perfmon.GetFrame());
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
GPUDrawScanline::GPUSetupPrimMap::GPUSetupPrimMap(GPUScanlineEnvironment& env)
|
2009-02-22 16:28:39 +00:00
|
|
|
: GSCodeGeneratorFunctionMap("GPUSetupPrim")
|
|
|
|
, m_env(env)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-02-20 10:59:10 +00:00
|
|
|
GPUSetupPrimCodeGenerator* GPUDrawScanline::GPUSetupPrimMap::Create(DWORD key, void* ptr, size_t maxsize)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-02-20 10:59:10 +00:00
|
|
|
return new GPUSetupPrimCodeGenerator(m_env, ptr, maxsize);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 13:13:20 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
GPUDrawScanline::GPUDrawScanlineMap::GPUDrawScanlineMap(GPUScanlineEnvironment& env)
|
2009-02-22 16:28:39 +00:00
|
|
|
: GSCodeGeneratorFunctionMap("GPUDrawScanline")
|
|
|
|
, m_env(env)
|
2009-02-19 13:13:20 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUDrawScanlineCodeGenerator* GPUDrawScanline::GPUDrawScanlineMap::Create(DWORD key, void* ptr, size_t maxsize)
|
|
|
|
{
|
|
|
|
return new GPUDrawScanlineCodeGenerator(m_env, ptr, maxsize);
|
|
|
|
}
|