summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2013-01-24 13:10:13 +0100
committerdegasus <wickmarkus@web.de>2013-01-24 13:10:13 +0100
commitf69b6b595ef80acf5ce776a80b1df27033bc7fdf (patch)
tree49f3f32255b2ee867b5e0dff2d79f86927159945 /Source/Core
parentfe7e691d77550195f71ae2b7af67c6395493908d (diff)
change projection_type to u32
Fix issue 5740 thx @ erwan_taf for debuging all the week
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/Src/Statistics.h2
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderManager.cpp61
-rw-r--r--Source/Core/VideoCommon/Src/XFMemory.h15
3 files changed, 46 insertions, 32 deletions
diff --git a/Source/Core/VideoCommon/Src/Statistics.h b/Source/Core/VideoCommon/Src/Statistics.h
index 7238398b42..e173bfc682 100644
--- a/Source/Core/VideoCommon/Src/Statistics.h
+++ b/Source/Core/VideoCommon/Src/Statistics.h
@@ -43,7 +43,7 @@ struct Statistics
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_6, gproj_7, gproj_8, gproj_9, gproj_10, gproj_11, gproj_12, gproj_13, gproj_14, gproj_15;
diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp
index 84340c6b98..1dce567b0d 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp
@@ -350,26 +350,28 @@ void VertexShaderManager::SetConstants()
if (bProjectionChanged)
{
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[2] = xfregs.rawProjection[1];
+ g_fProjectionMatrix[2] = rawProjection[1];
g_fProjectionMatrix[3] = 0.0f;
g_fProjectionMatrix[4] = 0.0f;
- g_fProjectionMatrix[5] = xfregs.rawProjection[2] * g_ActiveConfig.fAspectRatioHackH;
- g_fProjectionMatrix[6] = xfregs.rawProjection[3];
+ g_fProjectionMatrix[5] = rawProjection[2] * g_ActiveConfig.fAspectRatioHackH;
+ g_fProjectionMatrix[6] = rawProjection[3];
g_fProjectionMatrix[7] = 0.0f;
g_fProjectionMatrix[8] = 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[13] = 0.0f;
@@ -394,24 +396,24 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]);
SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]);
SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]);
- }
- else
- {
- // Orthographic Projection
- g_fProjectionMatrix[0] = xfregs.rawProjection[0];
+ break;
+
+ case GX_ORTHOGRAPHIC:
+
+ g_fProjectionMatrix[0] = rawProjection[0];
g_fProjectionMatrix[1] = 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[5] = xfregs.rawProjection[2];
+ g_fProjectionMatrix[5] = rawProjection[2];
g_fProjectionMatrix[6] = 0.0f;
- g_fProjectionMatrix[7] = xfregs.rawProjection[3];
+ g_fProjectionMatrix[7] = rawProjection[3];
g_fProjectionMatrix[8] = 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[11] = (g_ProjHack2.value + xfregs.rawProjection[5]) * ((g_ProjHack2.sign == 0) ? 1.0f : g_ProjHack2.sign);
+ g_fProjectionMatrix[10] = (g_ProjHack1.value + rawProjection[4]) * ((g_ProjHack1.sign == 0) ? 1.0f : g_ProjHack1.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[13] = 0.0f;
@@ -424,7 +426,7 @@ void VertexShaderManager::SetConstants()
*/
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_1, g_fProjectionMatrix[1]);
@@ -442,18 +444,21 @@ void VertexShaderManager::SetConstants()
SETSTAT_FT(stats.g2proj_13, g_fProjectionMatrix[13]);
SETSTAT_FT(stats.g2proj_14, g_fProjectionMatrix[14]);
SETSTAT_FT(stats.g2proj_15, g_fProjectionMatrix[15]);
- SETSTAT_FT(stats.proj_0, xfregs.rawProjection[0]);
- SETSTAT_FT(stats.proj_1, xfregs.rawProjection[1]);
- SETSTAT_FT(stats.proj_2, xfregs.rawProjection[2]);
- SETSTAT_FT(stats.proj_3, xfregs.rawProjection[3]);
- SETSTAT_FT(stats.proj_4, xfregs.rawProjection[4]);
- SETSTAT_FT(stats.proj_5, xfregs.rawProjection[5]);
- SETSTAT_FT(stats.proj_6, xfregs.rawProjection[6]);
+ SETSTAT_FT(stats.proj_0, rawProjection[0]);
+ SETSTAT_FT(stats.proj_1, rawProjection[1]);
+ SETSTAT_FT(stats.proj_2, rawProjection[2]);
+ SETSTAT_FT(stats.proj_3, rawProjection[3]);
+ SETSTAT_FT(stats.proj_4, rawProjection[4]);
+ SETSTAT_FT(stats.proj_5, rawProjection[5]);
+ 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 mtxB;
diff --git a/Source/Core/VideoCommon/Src/XFMemory.h b/Source/Core/VideoCommon/Src/XFMemory.h
index ee3c3b0fdc..fc199b8c32 100644
--- a/Source/Core/VideoCommon/Src/XFMemory.h
+++ b/Source/Core/VideoCommon/Src/XFMemory.h
@@ -61,6 +61,9 @@
#define LIGHTATTN_NONE 2
#define LIGHTATTN_DIR 3
+#define GX_PERSPECTIVE 0
+#define GX_ORTHOGRAPHIC 1
+
#define XFMEM_SIZE 0x8000
#define XFMEM_POSMATRICES 0x000
#define XFMEM_POSMATRICES_END 0x100
@@ -235,6 +238,12 @@ struct Viewport
float farZ;
};
+struct Projection
+{
+ float rawProjection[6];
+ u32 type; // only GX_PERSPECTIVE or GX_ORTHOGRAPHIC are allowed
+};
+
struct XFRegisters
{
u32 error; // 0x1000
@@ -257,10 +266,10 @@ struct XFRegisters
u32 unk5; // 0x1015
u32 unk6; // 0x1016
u32 unk7; // 0x1017
- u32 MatrixIndexA; // 0x1018
- u32 MatrixIndexB; // 0x1019
+ u32 MatrixIndexA; // 0x1018
+ u32 MatrixIndexB; // 0x1019
Viewport viewport; // 0x101a - 0x101f
- float rawProjection[7]; // 0x1020 - 0x1026
+ Projection projection; // 0x1020 - 0x1026
u32 unk8[24]; // 0x1027 - 0x103e
NumTexGen numTexGen; // 0x103f
TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047