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
|
|
|
|
|
|
|
|
#include "GS.h"
|
|
|
|
#include "GSLocalMemory.h"
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
2010-01-01 05:18:32 +00:00
|
|
|
__aligned16 class GSDrawingContext
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
GIFRegXYOFFSET XYOFFSET;
|
|
|
|
GIFRegTEX0 TEX0;
|
|
|
|
GIFRegTEX1 TEX1;
|
|
|
|
GIFRegTEX2 TEX2;
|
|
|
|
GIFRegCLAMP CLAMP;
|
|
|
|
GIFRegMIPTBP1 MIPTBP1;
|
|
|
|
GIFRegMIPTBP2 MIPTBP2;
|
|
|
|
GIFRegSCISSOR SCISSOR;
|
|
|
|
GIFRegALPHA ALPHA;
|
|
|
|
GIFRegTEST TEST;
|
|
|
|
GIFRegFBA FBA;
|
|
|
|
GIFRegFRAME FRAME;
|
|
|
|
GIFRegZBUF ZBUF;
|
|
|
|
|
2010-01-01 05:18:32 +00:00
|
|
|
__aligned16 struct
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
GSVector4i dx10;
|
|
|
|
GSVector4 dx9;
|
|
|
|
GSVector4 in;
|
|
|
|
GSVector4 ex;
|
|
|
|
} scissor;
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
struct
|
2009-07-22 03:55:28 +00:00
|
|
|
{
|
|
|
|
GSOffset* fb;
|
|
|
|
GSOffset* zb;
|
|
|
|
GSOffset* tex;
|
|
|
|
GSPixelOffset4* fzb;
|
|
|
|
} offset;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
GSDrawingContext()
|
|
|
|
{
|
2009-07-22 03:55:28 +00:00
|
|
|
memset(&offset, 0, sizeof(offset));
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
memset(&XYOFFSET, 0, sizeof(XYOFFSET));
|
|
|
|
memset(&TEX0, 0, sizeof(TEX0));
|
|
|
|
memset(&TEX1, 0, sizeof(TEX1));
|
|
|
|
memset(&TEX2, 0, sizeof(TEX2));
|
|
|
|
memset(&CLAMP, 0, sizeof(CLAMP));
|
|
|
|
memset(&MIPTBP1, 0, sizeof(MIPTBP1));
|
|
|
|
memset(&MIPTBP2, 0, sizeof(MIPTBP2));
|
|
|
|
memset(&SCISSOR, 0, sizeof(SCISSOR));
|
|
|
|
memset(&ALPHA, 0, sizeof(ALPHA));
|
|
|
|
memset(&TEST, 0, sizeof(TEST));
|
|
|
|
memset(&FBA, 0, sizeof(FBA));
|
|
|
|
memset(&FRAME, 0, sizeof(FRAME));
|
|
|
|
memset(&ZBUF, 0, sizeof(ZBUF));
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateScissor()
|
|
|
|
{
|
|
|
|
scissor.dx10 = GSVector4i(
|
|
|
|
(int)((SCISSOR.SCAX0 << 4) + XYOFFSET.OFX),
|
|
|
|
(int)((SCISSOR.SCAY0 << 4) + XYOFFSET.OFY),
|
|
|
|
(int)((SCISSOR.SCAX1 << 4) + XYOFFSET.OFX),
|
|
|
|
(int)((SCISSOR.SCAY1 << 4) + XYOFFSET.OFY));
|
|
|
|
|
|
|
|
scissor.dx9 = GSVector4(scissor.dx10);
|
|
|
|
|
|
|
|
scissor.in = GSVector4(
|
|
|
|
(int)SCISSOR.SCAX0,
|
|
|
|
(int)SCISSOR.SCAY0,
|
|
|
|
(int)SCISSOR.SCAX1 + 1,
|
|
|
|
(int)SCISSOR.SCAY1 + 1);
|
|
|
|
|
2009-06-27 03:32:33 +00:00
|
|
|
scissor.ex = GSVector4(
|
2009-02-09 21:15:56 +00:00
|
|
|
(int)SCISSOR.SCAX0,
|
|
|
|
(int)SCISSOR.SCAY0,
|
|
|
|
(int)SCISSOR.SCAX1,
|
|
|
|
(int)SCISSOR.SCAY1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DepthRead() const
|
|
|
|
{
|
|
|
|
return TEST.ZTE && TEST.ZTST >= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DepthWrite() const
|
|
|
|
{
|
|
|
|
if(TEST.ATE && TEST.ATST == ATST_NEVER && TEST.AFAIL != AFAIL_ZB_ONLY) // alpha test, all pixels fail, z buffer is not updated
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ZBUF.ZMSK == 0 && TEST.ZTE != 0; // ZTE == 0 is bug on the real hardware, write is blocked then
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
#pragma pack(pop)
|