More work on making new pixel shader uids work
This commit is contained in:
parent
67be1e939a
commit
700cce9588
|
@ -39,7 +39,6 @@
|
|||
|
||||
template<class T, GenOutput type> static void WriteStage(char *&p, int n, API_TYPE ApiType);
|
||||
template<class T, GenOutput type> static void SampleTexture(T& out, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType);
|
||||
// static void WriteAlphaCompare(char *&p, int num, int comp);
|
||||
template<class T, GenOutput type> static void WriteAlphaTest(T& out, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode);
|
||||
template<class T, GenOutput type> static void WriteFog(T& out);
|
||||
|
||||
|
@ -250,6 +249,7 @@ static void BuildSwapModeTable()
|
|||
template<class T, GenOutput type>
|
||||
void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
|
||||
{
|
||||
// TODO: Can be optimized if using alpha pass
|
||||
#define SetUidField(name, value) if (type == GO_ShaderUid) {out.GetUidData().name = value; };
|
||||
#define OR_UidField(name, value) if (type == GO_ShaderUid) {out.GetUidData().name |= value; };
|
||||
if (type == GO_ShaderCode)
|
||||
|
@ -664,10 +664,12 @@ static void WriteStage(T& out, int n, API_TYPE ApiType)
|
|||
// Wrapping
|
||||
// ---------
|
||||
|
||||
if (n < 8) { OR_UidField(tevorders_n_sw1, bpmem.tevind[n].sw << (3 * n)); }
|
||||
else OR_UidField(tevorders_n_sw2, bpmem.tevind[n].sw << (3 * n - 24));
|
||||
if (n < 8) { OR_UidField(tevorders_n_tw1, bpmem.tevind[n].tw << (3 * n)); }
|
||||
else OR_UidField(tevorders_n_tw2, bpmem.tevind[n].tw << (3 * n - 24));
|
||||
if (n < 8) { OR_UidField(tevind_n_sw1, bpmem.tevind[n].sw << (3 * n)); }
|
||||
else OR_UidField(tevind_n_sw2, bpmem.tevind[n].sw << (3 * n - 24));
|
||||
if (n < 8) { OR_UidField(tevind_n_tw1, bpmem.tevind[n].tw << (3 * n)); }
|
||||
else OR_UidField(tevind_n_tw2, bpmem.tevind[n].tw << (3 * n - 24));
|
||||
|
||||
OR_UidField(tevind_n_fb_addprev, bpmem.tevind[n].fb_addprev << n);
|
||||
|
||||
// wrap S
|
||||
if (bpmem.tevind[n].sw == ITW_OFF)
|
||||
|
@ -694,6 +696,9 @@ static void WriteStage(T& out, int n, API_TYPE ApiType)
|
|||
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC;
|
||||
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC;
|
||||
|
||||
SetUidField(combiners[n].colorC.hex, cc.hex&0xFFFFFF);
|
||||
SetUidField(combiners[n].alphaC.hex, ac.hex&0xFFFFFF);
|
||||
|
||||
if(cc.a == TEVCOLORARG_RASA || cc.a == TEVCOLORARG_RASC
|
||||
|| cc.b == TEVCOLORARG_RASA || cc.b == TEVCOLORARG_RASC
|
||||
|| cc.c == TEVCOLORARG_RASA || cc.c == TEVCOLORARG_RASC
|
||||
|
@ -1023,9 +1028,12 @@ static const char *tevFogFuncsTable[] =
|
|||
template<class T, GenOutput type>
|
||||
static void WriteFog(T& out)
|
||||
{
|
||||
SetUidField(fog.fsel, bpmem.fog.c_proj_fsel.fsel);
|
||||
if(bpmem.fog.c_proj_fsel.fsel == 0)
|
||||
return; //no Fog
|
||||
|
||||
SetUidField(fog.proj, bpmem.fog.c_proj_fsel.proj);
|
||||
|
||||
if (bpmem.fog.c_proj_fsel.proj == 0)
|
||||
{
|
||||
// perspective
|
||||
|
@ -1042,6 +1050,7 @@ static void WriteFog(T& out)
|
|||
// x_adjust = sqrt((x-center)^2 + k^2)/k
|
||||
// ze *= x_adjust
|
||||
// this is completely theoretical as the real hardware seems to use a table intead of calculating the values.
|
||||
SetUidField(fog.RangeBaseEnabled, bpmem.fogRange.Base.Enabled);
|
||||
if(bpmem.fogRange.Base.Enabled)
|
||||
{
|
||||
out.Write(" float x_adjust = (2.0f * (clipPos.x / " I_FOG"[2].y)) - 1.0f - " I_FOG"[2].x;\n");
|
||||
|
|
|
@ -97,10 +97,11 @@ struct pixel_shader_uid_data
|
|||
|
||||
u32 tevorders_n_texcoord1 : 24; // 8 x 3 bit
|
||||
u32 tevorders_n_texcoord2 : 24; // 8 x 3 bit
|
||||
u32 tevorders_n_sw1 : 24; // 8 x 3 bit
|
||||
u32 tevorders_n_sw2 : 24; // 8 x 3 bit
|
||||
u32 tevorders_n_tw1 : 24; // 8 x 3 bit
|
||||
u32 tevorders_n_tw2 : 24; // 8 x 3 bit
|
||||
u32 tevind_n_sw1 : 24; // 8 x 3 bit
|
||||
u32 tevind_n_sw2 : 24; // 8 x 3 bit
|
||||
u32 tevind_n_tw1 : 24; // 8 x 3 bit
|
||||
u32 tevind_n_tw2 : 24; // 8 x 3 bit
|
||||
u32 tevind_n_fb_addprev : 16; // 16 x 1 bit
|
||||
|
||||
u32 tevind_n_bs : 32; // 16 x 2 bit
|
||||
u32 tevind_n_fmt : 32; // 16 x 2 bit
|
||||
|
@ -113,35 +114,41 @@ struct pixel_shader_uid_data
|
|||
u32 tevksel_n_swap : 32; // 8 x 2 bit (swap1) + 8 x 2 bit (swap2)
|
||||
struct
|
||||
{
|
||||
struct //abc=8bit,d=10bit
|
||||
{
|
||||
u32 d : 4; // TEVSELCC_X
|
||||
u32 c : 4; // TEVSELCC_X
|
||||
u32 b : 4; // TEVSELCC_X
|
||||
u32 a : 4; // TEVSELCC_X
|
||||
union {
|
||||
struct //abc=8bit,d=10bit
|
||||
{
|
||||
u32 d : 4; // TEVSELCC_X
|
||||
u32 c : 4; // TEVSELCC_X
|
||||
u32 b : 4; // TEVSELCC_X
|
||||
u32 a : 4; // TEVSELCC_X
|
||||
|
||||
u32 bias : 2;
|
||||
u32 op : 1;
|
||||
u32 clamp : 1;
|
||||
u32 bias : 2;
|
||||
u32 op : 1;
|
||||
u32 clamp : 1;
|
||||
|
||||
u32 shift : 2;
|
||||
u32 dest : 2; //1,2,3
|
||||
u32 shift : 2;
|
||||
u32 dest : 2; //1,2,3
|
||||
};
|
||||
u32 hex : 24;
|
||||
} colorC;
|
||||
struct
|
||||
{
|
||||
u32 rswap : 2;
|
||||
u32 tswap : 2;
|
||||
u32 d : 3; // TEVSELCA_
|
||||
u32 c : 3; // TEVSELCA_
|
||||
u32 b : 3; // TEVSELCA_
|
||||
u32 a : 3; // TEVSELCA_
|
||||
union {
|
||||
struct
|
||||
{
|
||||
u32 rswap : 2;
|
||||
u32 tswap : 2;
|
||||
u32 d : 3; // TEVSELCA_
|
||||
u32 c : 3; // TEVSELCA_
|
||||
u32 b : 3; // TEVSELCA_
|
||||
u32 a : 3; // TEVSELCA_
|
||||
|
||||
u32 bias : 2; //GXTevBias
|
||||
u32 op : 1;
|
||||
u32 clamp : 1;
|
||||
u32 bias : 2; //GXTevBias
|
||||
u32 op : 1;
|
||||
u32 clamp : 1;
|
||||
|
||||
u32 shift : 2;
|
||||
u32 dest : 2; //1,2,3
|
||||
u32 shift : 2;
|
||||
u32 dest : 2; //1,2,3
|
||||
};
|
||||
u32 hex : 24;
|
||||
} alphaC;
|
||||
} combiners[16];
|
||||
struct
|
||||
|
@ -152,6 +159,17 @@ struct pixel_shader_uid_data
|
|||
// TODO: ref???
|
||||
} alpha_test;
|
||||
|
||||
union {
|
||||
struct
|
||||
{
|
||||
u32 proj : 1; // 0 - perspective, 1 - orthographic
|
||||
u32 fsel : 3; // 0 - off, 2 - linear, 4 - exp, 5 - exp2, 6 - backward exp, 7 - backward exp2
|
||||
u32 RangeBaseEnabled : 1;
|
||||
};
|
||||
u32 hex : 4;
|
||||
} fog;
|
||||
|
||||
|
||||
u32 bHasIndStage : 16;
|
||||
|
||||
u32 xfregs_numTexGen_numTexGens : 4;
|
||||
|
@ -159,9 +177,11 @@ struct pixel_shader_uid_data
|
|||
|
||||
typedef ShaderUid<pixel_shader_uid_data> PixelShaderUid;
|
||||
typedef ShaderCode<pixel_shader_uid_data> PixelShaderCode;
|
||||
//typedef ShaderConstantProfile<pixel_shader_uid_data> PixelShaderConstantProfile;
|
||||
|
||||
|
||||
void GeneratePixelShaderCode(PixelShaderCode& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
void GetPixelShaderUid(PixelShaderUid& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
//void GetPixelShaderConstantProfile(PixelShaderConstantProfile& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
|
||||
#endif // GCOGL_PIXELSHADER_H
|
||||
|
|
Loading…
Reference in New Issue