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
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GSRenderer.h"
|
|
|
|
#include "GSTextureCacheSW.h"
|
|
|
|
#include "GSDrawScanline.h"
|
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
class GSRendererSW : public GSRenderer
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2016-07-06 23:21:31 +00:00
|
|
|
static GSVector4 m_pos_scale;
|
|
|
|
#if _M_SSE >= 0x501
|
|
|
|
static GSVector8 m_pos_scale2;
|
|
|
|
#endif
|
|
|
|
|
2012-01-08 17:10:00 +00:00
|
|
|
class SharedData : public GSDrawScanline::SharedData
|
2011-12-18 08:13:20 +00:00
|
|
|
{
|
2016-05-11 23:24:37 +00:00
|
|
|
struct alignas(16) TextureLevel
|
2012-01-28 10:07:17 +00:00
|
|
|
{
|
|
|
|
GSVector4i r;
|
|
|
|
GSTextureCacheSW::Texture* t;
|
|
|
|
};
|
|
|
|
|
2012-01-21 04:44:04 +00:00
|
|
|
public:
|
2011-12-23 15:53:53 +00:00
|
|
|
GSRendererSW* m_parent;
|
2012-01-05 02:40:24 +00:00
|
|
|
const uint32* m_fb_pages;
|
|
|
|
const uint32* m_zb_pages;
|
2012-01-28 10:07:17 +00:00
|
|
|
int m_fpsm;
|
|
|
|
int m_zpsm;
|
2011-12-27 09:15:35 +00:00
|
|
|
bool m_using_pages;
|
2012-01-28 10:07:17 +00:00
|
|
|
TextureLevel m_tex[7 + 1]; // NULL terminated
|
|
|
|
enum {SyncNone, SyncSource, SyncTarget} m_syncpoint;
|
2011-12-23 15:53:53 +00:00
|
|
|
|
2011-12-18 08:13:20 +00:00
|
|
|
public:
|
2012-01-08 17:10:00 +00:00
|
|
|
SharedData(GSRendererSW* parent);
|
|
|
|
virtual ~SharedData();
|
2011-12-18 08:13:20 +00:00
|
|
|
|
2012-01-28 10:07:17 +00:00
|
|
|
void UsePages(const uint32* fb_pages, int fpsm, const uint32* zb_pages, int zpsm);
|
|
|
|
void ReleasePages();
|
2012-01-21 04:44:04 +00:00
|
|
|
|
|
|
|
void SetSource(GSTextureCacheSW::Texture* t, const GSVector4i& r, int level);
|
2012-01-28 10:07:17 +00:00
|
|
|
void UpdateSource();
|
2011-12-19 01:20:55 +00:00
|
|
|
};
|
2011-12-18 08:13:20 +00:00
|
|
|
|
2012-01-21 04:44:04 +00:00
|
|
|
typedef void (GSRendererSW::*ConvertVertexBufferPtr)(GSVertexSW* RESTRICT dst, const GSVertex* RESTRICT src, size_t count);
|
|
|
|
|
|
|
|
ConvertVertexBufferPtr m_cvb[4][2][2];
|
|
|
|
|
|
|
|
template<uint32 primclass, uint32 tme, uint32 fst>
|
|
|
|
void ConvertVertexBuffer(GSVertexSW* RESTRICT dst, const GSVertex* RESTRICT src, size_t count);
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
protected:
|
2011-12-20 14:33:28 +00:00
|
|
|
IRasterizer* m_rl;
|
2009-02-09 21:15:56 +00:00
|
|
|
GSTextureCacheSW* m_tc;
|
2009-05-22 01:22:52 +00:00
|
|
|
GSTexture* m_texture[2];
|
2011-02-19 03:36:30 +00:00
|
|
|
uint8* m_output;
|
2011-12-18 08:13:20 +00:00
|
|
|
GSPixelOffset4* m_fzb;
|
2012-01-18 11:47:31 +00:00
|
|
|
GSVector4i m_fzb_bbox;
|
|
|
|
uint32 m_fzb_cur_pages[16];
|
2015-02-28 09:59:48 +00:00
|
|
|
std::atomic<uint32> m_fzb_pages[512]; // uint16 frame/zbuf pages interleaved
|
|
|
|
std::atomic<uint16> m_tex_pages[512];
|
2012-01-06 01:20:01 +00:00
|
|
|
uint32 m_tmp_pages[512 + 1];
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
void Reset();
|
|
|
|
void VSync(int field);
|
|
|
|
void ResetDevice();
|
2016-03-19 11:37:25 +00:00
|
|
|
GSTexture* GetOutput(int i, int& y_offset);
|
2016-10-09 15:48:07 +00:00
|
|
|
GSTexture* GetFeedbackOutput();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
void Draw();
|
2012-01-28 10:07:17 +00:00
|
|
|
void Queue(shared_ptr<GSRasterizerData>& item);
|
2011-12-22 14:36:54 +00:00
|
|
|
void Sync(int reason);
|
2009-05-22 01:22:52 +00:00
|
|
|
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
|
2011-12-20 14:33:28 +00:00
|
|
|
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2015-02-28 09:59:48 +00:00
|
|
|
void UsePages(const uint32* pages, const int type);
|
|
|
|
void ReleasePages(const uint32* pages, const int type);
|
2012-01-21 04:44:04 +00:00
|
|
|
|
2012-01-18 11:47:31 +00:00
|
|
|
bool CheckTargetPages(const uint32* fb_pages, const uint32* zb_pages, const GSVector4i& r);
|
2012-01-21 04:44:04 +00:00
|
|
|
bool CheckSourcePages(SharedData* sd);
|
2011-12-18 21:57:48 +00:00
|
|
|
|
2012-01-08 17:10:00 +00:00
|
|
|
bool GetScanlineGlobalData(SharedData* data);
|
2012-01-05 02:40:24 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
public:
|
2016-07-06 23:21:31 +00:00
|
|
|
static void InitVectors();
|
|
|
|
|
2011-02-17 03:24:37 +00:00
|
|
|
GSRendererSW(int threads);
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual ~GSRendererSW();
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|