change projection_type to u32

Fix issue 5740

thx @ erwan_taf for debuging all the week
This commit is contained in:
degasus 2013-01-24 13:10:13 +01:00
parent fe7e691d77
commit f69b6b595e
3 changed files with 46 additions and 32 deletions

View File

@ -43,7 +43,7 @@ struct Statistics
int numUniquePixelShaders; int numUniquePixelShaders;
float proj_0, proj_1, proj_2, proj_3, proj_4, proj_5, proj_6; float proj_0, proj_1, proj_2, proj_3, proj_4, proj_5;
float gproj_0, gproj_1, gproj_2, gproj_3, gproj_4, gproj_5; float gproj_0, gproj_1, gproj_2, gproj_3, gproj_4, gproj_5;
float gproj_6, gproj_7, gproj_8, gproj_9, gproj_10, gproj_11, gproj_12, gproj_13, gproj_14, gproj_15; float gproj_6, gproj_7, gproj_8, gproj_9, gproj_10, gproj_11, gproj_12, gproj_13, gproj_14, gproj_15;

View File

@ -350,26 +350,28 @@ void VertexShaderManager::SetConstants()
if (bProjectionChanged) if (bProjectionChanged)
{ {
bProjectionChanged = false; bProjectionChanged = false;
float *rawProjection = xfregs.projection.rawProjection;
if (xfregs.rawProjection[6] == 0) switch(xfregs.projection.type)
{ {
// Perspective case GX_PERSPECTIVE:
g_fProjectionMatrix[0] = xfregs.rawProjection[0] * g_ActiveConfig.fAspectRatioHackW; g_fProjectionMatrix[0] = rawProjection[0] * g_ActiveConfig.fAspectRatioHackW;
g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = xfregs.rawProjection[1]; g_fProjectionMatrix[2] = rawProjection[1];
g_fProjectionMatrix[3] = 0.0f; g_fProjectionMatrix[3] = 0.0f;
g_fProjectionMatrix[4] = 0.0f; g_fProjectionMatrix[4] = 0.0f;
g_fProjectionMatrix[5] = xfregs.rawProjection[2] * g_ActiveConfig.fAspectRatioHackH; g_fProjectionMatrix[5] = rawProjection[2] * g_ActiveConfig.fAspectRatioHackH;
g_fProjectionMatrix[6] = xfregs.rawProjection[3]; g_fProjectionMatrix[6] = rawProjection[3];
g_fProjectionMatrix[7] = 0.0f; g_fProjectionMatrix[7] = 0.0f;
g_fProjectionMatrix[8] = 0.0f; g_fProjectionMatrix[8] = 0.0f;
g_fProjectionMatrix[9] = 0.0f; g_fProjectionMatrix[9] = 0.0f;
g_fProjectionMatrix[10] = xfregs.rawProjection[4]; g_fProjectionMatrix[10] = rawProjection[4];
g_fProjectionMatrix[11] = xfregs.rawProjection[5]; g_fProjectionMatrix[11] = rawProjection[5];
g_fProjectionMatrix[12] = 0.0f; g_fProjectionMatrix[12] = 0.0f;
g_fProjectionMatrix[13] = 0.0f; g_fProjectionMatrix[13] = 0.0f;
@ -394,24 +396,24 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]); SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]);
SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]); SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]);
SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]); SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]);
} break;
else
{ case GX_ORTHOGRAPHIC:
// Orthographic Projection
g_fProjectionMatrix[0] = xfregs.rawProjection[0]; g_fProjectionMatrix[0] = rawProjection[0];
g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = 0.0f; g_fProjectionMatrix[2] = 0.0f;
g_fProjectionMatrix[3] = xfregs.rawProjection[1]; g_fProjectionMatrix[3] = rawProjection[1];
g_fProjectionMatrix[4] = 0.0f; g_fProjectionMatrix[4] = 0.0f;
g_fProjectionMatrix[5] = xfregs.rawProjection[2]; g_fProjectionMatrix[5] = rawProjection[2];
g_fProjectionMatrix[6] = 0.0f; g_fProjectionMatrix[6] = 0.0f;
g_fProjectionMatrix[7] = xfregs.rawProjection[3]; g_fProjectionMatrix[7] = rawProjection[3];
g_fProjectionMatrix[8] = 0.0f; g_fProjectionMatrix[8] = 0.0f;
g_fProjectionMatrix[9] = 0.0f; g_fProjectionMatrix[9] = 0.0f;
g_fProjectionMatrix[10] = (g_ProjHack1.value + xfregs.rawProjection[4]) * ((g_ProjHack1.sign == 0) ? 1.0f : g_ProjHack1.sign); g_fProjectionMatrix[10] = (g_ProjHack1.value + rawProjection[4]) * ((g_ProjHack1.sign == 0) ? 1.0f : g_ProjHack1.sign);
g_fProjectionMatrix[11] = (g_ProjHack2.value + xfregs.rawProjection[5]) * ((g_ProjHack2.sign == 0) ? 1.0f : g_ProjHack2.sign); g_fProjectionMatrix[11] = (g_ProjHack2.value + rawProjection[5]) * ((g_ProjHack2.sign == 0) ? 1.0f : g_ProjHack2.sign);
g_fProjectionMatrix[12] = 0.0f; g_fProjectionMatrix[12] = 0.0f;
g_fProjectionMatrix[13] = 0.0f; g_fProjectionMatrix[13] = 0.0f;
@ -424,7 +426,7 @@ void VertexShaderManager::SetConstants()
*/ */
g_fProjectionMatrix[14] = 0.0f; g_fProjectionMatrix[14] = 0.0f;
g_fProjectionMatrix[15] = (g_ProjHack3 && xfregs.rawProjection[0] == 2.0f ? 0.0f : 1.0f); //causes either the efb copy or bloom layer not to show if proj hack enabled g_fProjectionMatrix[15] = (g_ProjHack3 && rawProjection[0] == 2.0f ? 0.0f : 1.0f); //causes either the efb copy or bloom layer not to show if proj hack enabled
SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]); SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]);
SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]); SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]);
@ -442,18 +444,21 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.g2proj_13, g_fProjectionMatrix[13]); SETSTAT_FT(stats.g2proj_13, g_fProjectionMatrix[13]);
SETSTAT_FT(stats.g2proj_14, g_fProjectionMatrix[14]); SETSTAT_FT(stats.g2proj_14, g_fProjectionMatrix[14]);
SETSTAT_FT(stats.g2proj_15, g_fProjectionMatrix[15]); SETSTAT_FT(stats.g2proj_15, g_fProjectionMatrix[15]);
SETSTAT_FT(stats.proj_0, xfregs.rawProjection[0]); SETSTAT_FT(stats.proj_0, rawProjection[0]);
SETSTAT_FT(stats.proj_1, xfregs.rawProjection[1]); SETSTAT_FT(stats.proj_1, rawProjection[1]);
SETSTAT_FT(stats.proj_2, xfregs.rawProjection[2]); SETSTAT_FT(stats.proj_2, rawProjection[2]);
SETSTAT_FT(stats.proj_3, xfregs.rawProjection[3]); SETSTAT_FT(stats.proj_3, rawProjection[3]);
SETSTAT_FT(stats.proj_4, xfregs.rawProjection[4]); SETSTAT_FT(stats.proj_4, rawProjection[4]);
SETSTAT_FT(stats.proj_5, xfregs.rawProjection[5]); SETSTAT_FT(stats.proj_5, rawProjection[5]);
SETSTAT_FT(stats.proj_6, xfregs.rawProjection[6]); break;
default:
ERROR_LOG(VIDEO, "unknown projection type: %d", xfregs.projection.type);
} }
PRIM_LOG("Projection: %f %f %f %f %f %f\n", xfregs.rawProjection[0], xfregs.rawProjection[1], xfregs.rawProjection[2], xfregs.rawProjection[3], xfregs.rawProjection[4], xfregs.rawProjection[5]); PRIM_LOG("Projection: %f %f %f %f %f %f\n", rawProjection[0], rawProjection[1], rawProjection[2], rawProjection[3], rawProjection[4], rawProjection[5]);
if ((g_ActiveConfig.bFreeLook || g_ActiveConfig.bAnaglyphStereo ) && xfregs.rawProjection[6] == 0) if ((g_ActiveConfig.bFreeLook || g_ActiveConfig.bAnaglyphStereo ) && xfregs.projection.type == GX_PERSPECTIVE)
{ {
Matrix44 mtxA; Matrix44 mtxA;
Matrix44 mtxB; Matrix44 mtxB;

View File

@ -61,6 +61,9 @@
#define LIGHTATTN_NONE 2 #define LIGHTATTN_NONE 2
#define LIGHTATTN_DIR 3 #define LIGHTATTN_DIR 3
#define GX_PERSPECTIVE 0
#define GX_ORTHOGRAPHIC 1
#define XFMEM_SIZE 0x8000 #define XFMEM_SIZE 0x8000
#define XFMEM_POSMATRICES 0x000 #define XFMEM_POSMATRICES 0x000
#define XFMEM_POSMATRICES_END 0x100 #define XFMEM_POSMATRICES_END 0x100
@ -235,6 +238,12 @@ struct Viewport
float farZ; float farZ;
}; };
struct Projection
{
float rawProjection[6];
u32 type; // only GX_PERSPECTIVE or GX_ORTHOGRAPHIC are allowed
};
struct XFRegisters struct XFRegisters
{ {
u32 error; // 0x1000 u32 error; // 0x1000
@ -257,10 +266,10 @@ struct XFRegisters
u32 unk5; // 0x1015 u32 unk5; // 0x1015
u32 unk6; // 0x1016 u32 unk6; // 0x1016
u32 unk7; // 0x1017 u32 unk7; // 0x1017
u32 MatrixIndexA; // 0x1018 u32 MatrixIndexA; // 0x1018
u32 MatrixIndexB; // 0x1019 u32 MatrixIndexB; // 0x1019
Viewport viewport; // 0x101a - 0x101f Viewport viewport; // 0x101a - 0x101f
float rawProjection[7]; // 0x1020 - 0x1026 Projection projection; // 0x1020 - 0x1026
u32 unk8[24]; // 0x1027 - 0x103e u32 unk8[24]; // 0x1027 - 0x103e
NumTexGen numTexGen; // 0x103f NumTexGen numTexGen; // 0x103f
TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047 TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047