2010-04-25 00:31:27 +00:00
|
|
|
/*
|
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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* 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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2010-04-25 00:31:27 +00:00
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2009-05-18 11:08:04 +00:00
|
|
|
#include "GSdx.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "GSWnd.h"
|
|
|
|
#include "GSState.h"
|
2009-06-23 04:12:32 +00:00
|
|
|
#include "GSVertexTrace.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "GSVertexList.h"
|
|
|
|
#include "GSCapture.h"
|
|
|
|
|
2009-05-22 23:23:38 +00:00
|
|
|
class GSRenderer : public GSState
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-05-22 23:23:38 +00:00
|
|
|
GSCapture m_capture;
|
|
|
|
string m_snapshot;
|
2010-06-24 20:25:33 +00:00
|
|
|
bool m_snapdump;
|
2009-05-22 23:23:38 +00:00
|
|
|
int m_shader;
|
|
|
|
|
|
|
|
bool Merge(int field);
|
|
|
|
|
|
|
|
protected:
|
2009-02-09 21:15:56 +00:00
|
|
|
int m_interlace;
|
|
|
|
int m_aspectratio;
|
|
|
|
int m_filter;
|
|
|
|
bool m_vsync;
|
2009-03-09 01:42:56 +00:00
|
|
|
bool m_aa1;
|
2009-10-31 01:06:23 +00:00
|
|
|
bool m_framelimit;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual GSTexture* GetOutput(int i) = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-23 04:12:32 +00:00
|
|
|
GSVertexTrace m_vt;
|
|
|
|
|
|
|
|
// following functions need m_vt to be initialized
|
|
|
|
|
2009-06-27 03:32:33 +00:00
|
|
|
void GetTextureMinMax(GSVector4i& r, bool linear);
|
2009-06-23 04:12:32 +00:00
|
|
|
void GetAlphaMinMax();
|
|
|
|
bool TryAlphaTest(uint32& fm, uint32& zm);
|
2009-06-27 03:32:33 +00:00
|
|
|
bool IsLinear();
|
2009-06-23 04:12:32 +00:00
|
|
|
bool IsOpaque();
|
|
|
|
|
2009-05-18 11:08:04 +00:00
|
|
|
public:
|
|
|
|
GSWnd m_wnd;
|
2009-05-22 01:22:52 +00:00
|
|
|
GSDevice* m_dev;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
int s_n;
|
|
|
|
bool s_dump;
|
|
|
|
bool s_save;
|
|
|
|
bool s_savez;
|
2009-07-05 12:58:59 +00:00
|
|
|
int s_saven;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
2009-09-18 19:54:56 +00:00
|
|
|
GSRenderer();
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual ~GSRenderer();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-09-17 07:40:38 +00:00
|
|
|
virtual bool CreateWnd(const string& title, int w, int h);
|
|
|
|
virtual bool CreateDevice(GSDevice* dev);
|
2011-02-19 03:36:30 +00:00
|
|
|
virtual void ResetDevice();
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual void VSync(int field);
|
|
|
|
virtual bool MakeSnapshot(const string& path);
|
2010-06-24 20:25:33 +00:00
|
|
|
virtual void KeyEvent(GSKeyEventData* e);
|
2011-02-19 03:36:30 +00:00
|
|
|
virtual bool CanUpscale() {return false;}
|
|
|
|
virtual int GetUpscaleMultiplier() {return 1;}
|
|
|
|
void SetAspectRatio(int aspect) {m_aspectratio = aspect;}
|
|
|
|
void SetVSync(bool enabled);
|
2009-10-31 01:06:23 +00:00
|
|
|
void SetFrameLimit(bool limit);
|
2009-12-04 03:24:59 +00:00
|
|
|
virtual void SetExclusive(bool isExcl) {}
|
2009-10-31 01:06:23 +00:00
|
|
|
|
2010-06-24 20:25:33 +00:00
|
|
|
virtual void BeginCapture();
|
|
|
|
virtual void EndCapture();
|
|
|
|
|
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
|
|
|
public:
|
2011-02-19 03:36:30 +00:00
|
|
|
GSCritSec m_pGSsetTitle_Crit;
|
|
|
|
|
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
|
|
|
char m_GStitleInfoBuffer[128];
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
template<class Vertex> class GSRendererT : public GSRenderer
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
Vertex* m_vertices;
|
|
|
|
int m_count;
|
|
|
|
int m_maxcount;
|
|
|
|
GSVertexList<Vertex> m_vl;
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
m_count = 0;
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
|
2011-02-19 03:36:30 +00:00
|
|
|
GSRenderer::Reset();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetPrim()
|
|
|
|
{
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
void FlushPrim()
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-07-22 03:55:28 +00:00
|
|
|
if(m_count == 0) return;
|
|
|
|
|
|
|
|
if(GSLocalMemory::m_psm[m_context->FRAME.PSM].fmt < 3 && GSLocalMemory::m_psm[m_context->ZBUF.PSM].fmt < 3)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-07-22 03:55:28 +00:00
|
|
|
// FIXME: berserk fpsm = 27 (8H)
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
if(!m_dev->IsLost())
|
|
|
|
{
|
2009-07-22 14:28:14 +00:00
|
|
|
m_vt.Update(m_vertices, m_count, GSUtil::GetPrimClass(PRIM->PRIM));
|
2009-06-27 03:32:33 +00:00
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
Draw();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
m_perfmon.Put(GSPerfMon::Draw, 1);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-07-22 03:55:28 +00:00
|
|
|
|
|
|
|
m_count = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GrowVertexBuffer()
|
|
|
|
{
|
2011-02-19 03:36:30 +00:00
|
|
|
if(m_vertices != NULL) _aligned_free(m_vertices);
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
m_maxcount = max(10000, m_maxcount * 3/2);
|
2011-02-19 03:36:30 +00:00
|
|
|
m_vertices = (Vertex*)_aligned_malloc(sizeof(Vertex) * m_maxcount, 32);
|
2009-02-09 21:15:56 +00:00
|
|
|
m_maxcount -= 100;
|
|
|
|
}
|
|
|
|
|
2010-08-17 04:38:49 +00:00
|
|
|
// Returns a pointer to the drawing vertex. Can return NULL!
|
2011-02-07 01:59:05 +00:00
|
|
|
|
|
|
|
template<uint32 prim> __forceinline Vertex* DrawingKick(bool skip, int& count)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
switch(prim)
|
|
|
|
{
|
|
|
|
case GS_POINTLIST: count = 1; break;
|
|
|
|
case GS_LINELIST: count = 2; break;
|
|
|
|
case GS_LINESTRIP: count = 2; break;
|
|
|
|
case GS_TRIANGLELIST: count = 3; break;
|
|
|
|
case GS_TRIANGLESTRIP: count = 3; break;
|
|
|
|
case GS_TRIANGLEFAN: count = 3; break;
|
|
|
|
case GS_SPRITE: count = 2; break;
|
|
|
|
case GS_INVALID: count = 1; break;
|
|
|
|
default: __assume(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_vl.GetCount() < count)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m_count >= m_maxcount)
|
|
|
|
{
|
|
|
|
GrowVertexBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
Vertex* v = &m_vertices[m_count];
|
|
|
|
|
|
|
|
switch(prim)
|
|
|
|
{
|
|
|
|
case GS_POINTLIST:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
break;
|
|
|
|
case GS_LINELIST:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.GetAt(1, v[1]);
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
break;
|
|
|
|
case GS_LINESTRIP:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.GetAt(1, v[1]);
|
|
|
|
m_vl.RemoveAt(0, 1);
|
|
|
|
break;
|
|
|
|
case GS_TRIANGLELIST:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.GetAt(1, v[1]);
|
|
|
|
m_vl.GetAt(2, v[2]);
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
break;
|
|
|
|
case GS_TRIANGLESTRIP:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.GetAt(1, v[1]);
|
|
|
|
m_vl.GetAt(2, v[2]);
|
|
|
|
m_vl.RemoveAt(0, 2);
|
|
|
|
break;
|
|
|
|
case GS_TRIANGLEFAN:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.GetAt(1, v[1]);
|
|
|
|
m_vl.GetAt(2, v[2]);
|
|
|
|
m_vl.RemoveAt(1, 1);
|
|
|
|
break;
|
|
|
|
case GS_SPRITE:
|
|
|
|
m_vl.GetAt(0, v[0]);
|
|
|
|
m_vl.GetAt(1, v[1]);
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
break;
|
|
|
|
case GS_INVALID:
|
|
|
|
ASSERT(0);
|
|
|
|
m_vl.RemoveAll();
|
|
|
|
return NULL;
|
|
|
|
default:
|
|
|
|
__assume(0);
|
|
|
|
}
|
|
|
|
|
2011-02-07 01:59:05 +00:00
|
|
|
return !skip ? v : NULL;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Draw() = 0;
|
|
|
|
|
|
|
|
public:
|
2009-09-18 19:54:56 +00:00
|
|
|
GSRendererT()
|
|
|
|
: GSRenderer()
|
2009-06-27 03:32:33 +00:00
|
|
|
, m_vertices(NULL)
|
2009-02-09 21:15:56 +00:00
|
|
|
, m_count(0)
|
|
|
|
, m_maxcount(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
virtual ~GSRendererT()
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
if(m_vertices) _aligned_free(m_vertices);
|
|
|
|
}
|
|
|
|
};
|