2010-10-23 08:15:39 +00:00
|
|
|
/* ZZ Open GL graphics plugin
|
|
|
|
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
|
|
|
|
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
|
|
|
|
*
|
|
|
|
* 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 of the License, 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 this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Zerogs:VB implementation.
|
|
|
|
// VB stands for Visual Buffer, as I think
|
|
|
|
|
2011-03-25 05:06:49 +00:00
|
|
|
#ifndef ZZOGLVB_H_INCLUDED
|
|
|
|
#define ZZOGLVB_H_INCLUDED
|
2010-10-23 08:15:39 +00:00
|
|
|
|
|
|
|
#include "targets.h"
|
|
|
|
|
|
|
|
extern const GLenum primtype[8];
|
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
class VB
|
2010-10-23 08:15:39 +00:00
|
|
|
{
|
2010-10-24 04:09:42 +00:00
|
|
|
public:
|
|
|
|
VB();
|
|
|
|
~VB();
|
|
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
inline bool CheckPrim()
|
|
|
|
{
|
|
|
|
static const int PRIMMASK = 0x0e; // for now ignore 0x10 (AA)
|
|
|
|
|
|
|
|
if ((PRIMMASK & prim->_val) != (PRIMMASK & curprim._val) || primtype[prim->prim] != primtype[curprim.prim])
|
|
|
|
return nCount > 0;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-31 07:10:21 +00:00
|
|
|
|
|
|
|
void SetCurrentPrim()
|
|
|
|
{
|
|
|
|
curprim._val = prim->_val;
|
|
|
|
curprim.prim = prim->prim;
|
|
|
|
}
|
2010-10-24 04:09:42 +00:00
|
|
|
|
|
|
|
void CheckFrame(int tbp);
|
|
|
|
|
|
|
|
// context specific state
|
|
|
|
Point offset;
|
|
|
|
Rect2 scissor;
|
|
|
|
tex0Info tex0;
|
|
|
|
tex1Info tex1;
|
|
|
|
miptbpInfo miptbp0;
|
|
|
|
miptbpInfo miptbp1;
|
|
|
|
alphaInfo alpha;
|
|
|
|
fbaInfo fba;
|
|
|
|
clampInfo clamp;
|
|
|
|
pixTest test;
|
|
|
|
u32 ptexClamp[2]; // textures for x and y dir region clamping
|
|
|
|
|
|
|
|
void FlushTexData();
|
|
|
|
inline int CheckFrameAddConstraints(int tbp);
|
|
|
|
inline void CheckScissors(int maxpos);
|
|
|
|
inline void CheckFrame32bitRes(int maxpos);
|
|
|
|
inline int FindMinimalMemoryConstrain(int tbp, int maxpos);
|
|
|
|
inline int FindZbufferMemoryConstrain(int tbp, int maxpos);
|
|
|
|
inline int FindMinimalHeightConstrain(int maxpos);
|
|
|
|
|
|
|
|
inline int CheckFrameResolveRender(int tbp);
|
|
|
|
inline void CheckFrame16vs32Conversion();
|
|
|
|
inline int CheckFrameResolveDepth(int tbp);
|
|
|
|
|
|
|
|
inline void FlushTexUnchangedClutDontUpdate() ;
|
|
|
|
inline void FlushTexClutDontUpdate() ;
|
|
|
|
inline void FlushTexClutting() ;
|
|
|
|
inline void FlushTexSetNewVars(u32 psm) ;
|
2010-10-31 07:10:21 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
// Increase the size of pbuf
|
|
|
|
void IncreaseVertexBuffer()
|
2010-10-23 08:15:39 +00:00
|
|
|
{
|
2010-10-31 14:19:46 +00:00
|
|
|
assert(pBufferData != NULL);
|
2010-10-24 04:09:42 +00:00
|
|
|
nNumVertices *= 2;
|
|
|
|
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nNumVertices, 256);
|
2014-08-27 03:45:23 +00:00
|
|
|
memcpy(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
|
2010-10-24 04:09:42 +00:00
|
|
|
assert(nCount <= nNumVertices);
|
|
|
|
_aligned_free(pBufferData);
|
|
|
|
pBufferData = ptemp;
|
2010-10-23 08:15:39 +00:00
|
|
|
}
|
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
void Init(int nVerts)
|
|
|
|
{
|
|
|
|
if (pBufferData == NULL && nVerts > 0)
|
|
|
|
{
|
|
|
|
pBufferData = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nVerts, 256);
|
|
|
|
nNumVertices = nVerts;
|
|
|
|
}
|
|
|
|
|
|
|
|
nCount = 0;
|
|
|
|
}
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
u8 bNeedFrameCheck;
|
|
|
|
u8 bNeedZCheck;
|
|
|
|
u8 bNeedTexCheck;
|
|
|
|
u8 dummy0;
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
union
|
2010-10-23 08:15:39 +00:00
|
|
|
{
|
2010-10-24 04:09:42 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u8 bTexConstsSync; // only pixel shader constants that context owns
|
|
|
|
u8 bVarsTexSync; // texture info
|
|
|
|
u8 bVarsSetTarg;
|
|
|
|
u8 dummy1;
|
|
|
|
};
|
|
|
|
|
|
|
|
u32 bSyncVars;
|
2010-10-23 08:15:39 +00:00
|
|
|
};
|
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
int ictx;
|
|
|
|
VertexGPU* pBufferData; // current allocated data
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
int nNumVertices; // size of pBufferData in terms of VertexGPU objects
|
|
|
|
int nCount;
|
|
|
|
primInfo curprim; // the previous prim the current buffers are set to
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
zbufInfo zbuf;
|
|
|
|
frameInfo gsfb; // the real info set by FRAME cmd
|
|
|
|
frameInfo frame;
|
|
|
|
int zprimmask; // zmask for incoming points
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
u32 uCurTex0Data[2]; // current tex0 data
|
|
|
|
GIFRegTEX0 uCurTex0;
|
|
|
|
};
|
|
|
|
u32 uNextTex0Data[2]; // tex0 data that has to be applied if bNeedTexCheck is 1
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
//int nFrameHeights[8]; // frame heights for the past frame changes
|
|
|
|
int nNextFrameHeight;
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2010-10-24 04:09:42 +00:00
|
|
|
CMemoryTarget* pmemtarg; // the current mem target set
|
|
|
|
CRenderTarget* prndr;
|
|
|
|
CDepthTarget* pdepth;
|
2010-10-23 08:15:39 +00:00
|
|
|
|
2011-03-25 05:06:49 +00:00
|
|
|
};
|
2010-10-23 08:15:39 +00:00
|
|
|
|
|
|
|
// VB variables
|
|
|
|
extern VB vb[2];
|
2011-03-25 05:06:49 +00:00
|
|
|
|
|
|
|
#endif // ZZOGLVB_H_INCLUDED
|