2010-04-25 00:31:27 +00:00
/*
2010-04-24 21:37:39 +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
*
2010-04-24 21:37:39 +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
*
2010-04-24 21:37:39 +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 0213 9 , USA .
2010-04-24 21:37:39 +00:00
* http : //www.gnu.org/copyleft/gpl.html
*
*/
# pragma once
# include "GSLocalMemory.h"
# include "GSVector.h"
union GSScanlineSelector
{
struct
{
uint32 fpsm : 2 ; // 0
uint32 zpsm : 2 ; // 2
uint32 ztst : 2 ; // 4 (0: off, 1: write, 2: test (ge), 3: test (g))
uint32 atst : 3 ; // 6
uint32 afail : 2 ; // 9
uint32 iip : 1 ; // 11
uint32 tfx : 3 ; // 12
uint32 tcc : 1 ; // 15
uint32 fst : 1 ; // 16
uint32 ltf : 1 ; // 17
uint32 tlu : 1 ; // 18
uint32 fge : 1 ; // 19
uint32 date : 1 ; // 20
uint32 abe : 1 ; // 21
uint32 aba : 2 ; // 22
uint32 abb : 2 ; // 24
uint32 abc : 2 ; // 26
uint32 abd : 2 ; // 28
uint32 pabe : 1 ; // 30
uint32 aa1 : 1 ; // 31
uint32 fwrite : 1 ; // 32
uint32 ftest : 1 ; // 33
uint32 rfb : 1 ; // 34
uint32 zwrite : 1 ; // 35
uint32 ztest : 1 ; // 36
uint32 zoverflow : 1 ; // 37 (z max >= 0x80000000)
uint32 wms : 2 ; // 38
uint32 wmt : 2 ; // 40
uint32 datm : 1 ; // 42
uint32 colclamp : 1 ; // 43
uint32 fba : 1 ; // 44
uint32 dthe : 1 ; // 45
uint32 sprite : 1 ; // 46
uint32 edge : 1 ; // 47
2011-02-12 21:45:16 +00:00
uint32 tw : 3 ; // 48 (encodes values between 3 -> 10, texture cache makes sure it is at least 3)
2011-03-17 02:55:20 +00:00
uint32 lcm : 1 ; // 49
uint32 mmin : 2 ; // 50
2010-04-24 21:37:39 +00:00
} ;
struct
{
uint32 _pad1 : 22 ;
uint32 ababcd : 8 ;
uint32 _pad2 : 2 ;
uint32 fb : 2 ;
uint32 _pad3 : 1 ;
uint32 zb : 2 ;
} ;
struct
{
uint32 lo ;
uint32 hi ;
} ;
uint64 key ;
2011-02-17 03:24:37 +00:00
operator uint32 ( ) const { return lo ; }
operator uint64 ( ) const { return key ; }
2010-04-24 21:37:39 +00:00
2011-02-17 03:24:37 +00:00
bool IsSolidRect ( ) const
2010-04-24 21:37:39 +00:00
{
return sprite
& & iip = = 0
& & tfx = = TFX_NONE
2010-04-25 00:31:27 +00:00
& & abe = = 0
& & ztst < = 1
2010-04-24 21:37:39 +00:00
& & atst < = 1
& & date = = 0
& & fge = = 0 ;
}
} ;
2011-02-18 01:56:05 +00:00
__aligned ( struct , 32 ) GSScanlineGlobalData // per batch variables, this is like a pixel shader constant buffer
2010-04-24 21:37:39 +00:00
{
GSScanlineSelector sel ;
2011-02-17 03:24:37 +00:00
// - the data of vm, tex, clut, dimx may change, multi-threaded drawing must be finished before that happens (an idea: remember which pages are used, sync when something needs to read or write them)
// - tex is a cached texture, it may be recycled to free up memory, its absolute address cannot be compiled into code
// - row and column pointers are allocated once and never change or freed, thier address can be used directly
// - if in the future drawing does not have to be synchronized per batch, the rest of GSRasterizerData should be copied here, too (scissor, prim type, vertices)
2010-04-24 21:37:39 +00:00
void * vm ;
2011-03-17 02:55:20 +00:00
const void * tex [ 7 ] ;
2010-04-24 21:37:39 +00:00
const uint32 * clut ;
2011-02-17 03:24:37 +00:00
const GSVector4i * dimx ;
2010-04-24 21:37:39 +00:00
2011-02-17 03:24:37 +00:00
const int * fbr ;
const int * zbr ;
const int * fbc ;
const int * zbc ;
const GSVector2i * fzbr ;
const GSVector2i * fzbc ;
2010-04-24 21:37:39 +00:00
GSVector4i fm , zm ;
2011-03-17 02:55:20 +00:00
struct { GSVector4i min , max , minmax , mask , invmask ; } t ; // [u] x 4 [v] x 4
2010-04-24 21:37:39 +00:00
GSVector4i aref ;
GSVector4i afix ;
GSVector4i frb , fga ;
2011-03-17 02:55:20 +00:00
GSVector4 mxl ;
2011-03-14 03:32:28 +00:00
GSVector4 k ; // TEX1.K * 0x10000
GSVector4 l ; // TEX1.L * -0x10000
2011-03-17 02:55:20 +00:00
struct { GSVector4i i , f ; } lod ; // lcm == 1
2011-02-17 03:24:37 +00:00
} ;
2011-02-18 01:56:05 +00:00
__aligned ( struct , 32 ) GSScanlineLocalData // per prim variables, each thread has its own
2011-02-17 03:24:37 +00:00
{
2011-03-14 03:32:28 +00:00
struct skip { GSVector4 z , s , t , q ; GSVector4i rb , ga , f , _pad ; } d [ 4 ] ;
struct step { GSVector4 z , stq ; GSVector4i c , f ; } d4 ;
2010-04-24 21:37:39 +00:00
struct { GSVector4i rb , ga ; } c ;
struct { GSVector4i z , f ; } p ;
2011-02-17 03:24:37 +00:00
// these should be stored on stack as normal local variables (no free regs to use, esp cannot be saved to anywhere, and we need an aligned stack)
2011-03-17 02:55:20 +00:00
struct
{
2011-12-04 09:49:55 +00:00
GSVector4 z , zo ;
2011-11-25 23:48:59 +00:00
GSVector4i f ;
GSVector4 s , t , q ;
2011-03-17 02:55:20 +00:00
GSVector4i rb , ga ;
GSVector4i zs , zd ;
GSVector4i uf , vf ;
GSVector4i cov ;
// mipmapping
2011-04-01 12:36:21 +00:00
2011-03-17 02:55:20 +00:00
struct { GSVector4i i , f ; } lod ;
GSVector4i uv [ 2 ] ;
GSVector4i uv_minmax [ 2 ] ;
GSVector4i trb , tga ;
GSVector4i test ;
} temp ;
2011-04-01 12:36:21 +00:00
//
const GSScanlineGlobalData * gd ;
2010-04-24 21:37:39 +00:00
} ;