summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authordonkopunchstania <donkopunchstania@gmail.com>2010-12-01 04:26:21 +0000
committerdonkopunchstania <donkopunchstania@gmail.com>2010-12-01 04:26:21 +0000
commit1f660de7e53eb3675bc258dc57dfff99d779fc55 (patch)
treef31378952893f088af43b544735514cde4defdef /Source
parent0718e1bd772e641cfad180b42d800f5fb49b46d7 (diff)
Avoid repeatedly asserting in SWG plugin when matrix indices don't match. Small change to the transform unit to avoid some unnecessary work. Check if Q is zero before dividing UV coordinates by it. Fixes issue 3454.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6504 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Common/Src/LinearDiskCache.h2
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp7
-rw-r--r--Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp32
-rw-r--r--Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp38
4 files changed, 56 insertions, 23 deletions
diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h
index 252713d2c3..4fc86b6f0c 100644
--- a/Source/Core/Common/Src/LinearDiskCache.h
+++ b/Source/Core/Common/Src/LinearDiskCache.h
@@ -26,7 +26,7 @@
// shader cache for every revision, graphics-related or not, which is simply annoying.
enum
{
- LINEAR_DISKCACHE_VER = 6473
+ LINEAR_DISKCACHE_VER = 6504
};
// On disk format:
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index 44964acc61..9f0d20ba53 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -730,7 +730,12 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
{
// optional perspective divides
if (xfregs.texcoords[i].texmtxinfo.projection == XF_TEXPROJ_STQ)
- WRITE(p, "uv%d.xy = uv%d.xy/uv%d.z;\n", i, i, i);
+ {
+ WRITE(p, "if (uv%d.z)", i);
+ WRITE(p, " uv%d.xy = uv%d.xy / uv%d.z;\n", i, i, i);
+ WRITE(p, "else");
+ WRITE(p, " uv%d.xy = float2(0.0f, 0.0f);\n", i);
+ }
WRITE(p, "uv%d.xy = uv%d.xy * "I_TEXDIMS"[%d].zw;\n", i, i, i);
}
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp
index dcdf0daa1f..f17074d1c9 100644
--- a/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp
+++ b/Source/Plugins/Plugin_VideoSoftware/Src/TransformUnit.cpp
@@ -35,6 +35,7 @@ void MultiplyVec2Mat24(const Vec3 &vec, const float *mat, Vec3 &result)
{
result.x = mat[0] * vec.x + mat[1] * vec.y + mat[2] + mat[3];
result.y = mat[4] * vec.x + mat[5] * vec.y + mat[6] + mat[7];
+ result.z = 1.0f;
}
void MultiplyVec2Mat34(const Vec3 &vec, const float *mat, Vec3 &result)
@@ -51,6 +52,13 @@ void MultiplyVec3Mat33(const Vec3 &vec, const float *mat, Vec3 &result)
result.z = mat[6] * vec.x + mat[7] * vec.y + mat[8] * vec.z;
}
+void MultiplyVec3Mat24(const Vec3 &vec, const float *mat, Vec3 &result)
+{
+ result.x = mat[0] * vec.x + mat[1] * vec.y + mat[2] * vec.z + mat[3];
+ result.y = mat[4] * vec.x + mat[5] * vec.y + mat[6] * vec.z + mat[7];
+ result.z = 1.0f;
+}
+
void MultiplyVec3Mat34(const Vec3 &vec, const float *mat, Vec3 &result)
{
result.x = mat[0] * vec.x + mat[1] * vec.y + mat[2] * vec.z + mat[3];
@@ -134,14 +142,22 @@ inline void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bo
const float *mat = (const float*)&xfregs.posMatrices[srcVertex->texMtx[coordNum] * 4];
Vec3 *dst = &dstVertex->texCoords[coordNum];
- if (texinfo.inputform == XF_TEXINPUT_AB11)
- {
- MultiplyVec2Mat34(*src, mat, *dst);
- }
- else
- {
- MultiplyVec3Mat34(*src, mat, *dst);
- }
+ if (texinfo.projection == XF_TEXPROJ_ST)
+ {
+ if (texinfo.inputform == XF_TEXINPUT_AB11 || specialCase)
+ MultiplyVec2Mat24(*src, mat, *dst);
+ else
+ MultiplyVec3Mat24(*src, mat, *dst);
+ }
+ else // texinfo.projection == XF_TEXPROJ_STQ
+ {
+ _assert_(!specialCase);
+
+ if (texinfo.inputform == XF_TEXINPUT_AB11)
+ MultiplyVec2Mat34(*src, mat, *dst);
+ else
+ MultiplyVec3Mat34(*src, mat, *dst);
+ }
if (xfregs.dualTexTrans)
{
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp
index 8dba89fce7..2dd89b4713 100644
--- a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp
+++ b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp
@@ -107,16 +107,26 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
m_NumAttributeLoaders = 0;
// Reset vertex
- // matrix index from xfregs or cp memory?
- _assert_msg_(VIDEO, xfregs.MatrixIndexA.PosNormalMtxIdx == MatrixIndexA.PosNormalMtxIdx, "Matrix indices don't match");
- //_assert_msg_(VIDEO, xfregs.MatrixIndexA.Tex0MtxIdx == MatrixIndexA.Tex0MtxIdx, "Matrix indices don't match");
- //_assert_msg_(VIDEO, xfregs.MatrixIndexA.Tex1MtxIdx == MatrixIndexA.Tex1MtxIdx, "Matrix indices don't match");
- _assert_msg_(VIDEO, xfregs.MatrixIndexA.Tex2MtxIdx == MatrixIndexA.Tex2MtxIdx, "Matrix indices don't match");
- _assert_msg_(VIDEO, xfregs.MatrixIndexA.Tex3MtxIdx == MatrixIndexA.Tex3MtxIdx, "Matrix indices don't match");
- _assert_msg_(VIDEO, xfregs.MatrixIndexB.Tex4MtxIdx == MatrixIndexB.Tex4MtxIdx, "Matrix indices don't match");
- _assert_msg_(VIDEO, xfregs.MatrixIndexB.Tex5MtxIdx == MatrixIndexB.Tex5MtxIdx, "Matrix indices don't match");
- _assert_msg_(VIDEO, xfregs.MatrixIndexB.Tex6MtxIdx == MatrixIndexB.Tex6MtxIdx, "Matrix indices don't match");
- _assert_msg_(VIDEO, xfregs.MatrixIndexB.Tex7MtxIdx == MatrixIndexB.Tex7MtxIdx, "Matrix indices don't match");
+ // matrix index from xf regs or cp memory?
+ if (xfregs.MatrixIndexA.PosNormalMtxIdx != MatrixIndexA.PosNormalMtxIdx ||
+ xfregs.MatrixIndexA.Tex0MtxIdx != MatrixIndexA.Tex0MtxIdx ||
+ xfregs.MatrixIndexA.Tex1MtxIdx != MatrixIndexA.Tex1MtxIdx ||
+ xfregs.MatrixIndexA.Tex2MtxIdx != MatrixIndexA.Tex2MtxIdx ||
+ xfregs.MatrixIndexA.Tex3MtxIdx != MatrixIndexA.Tex3MtxIdx ||
+ xfregs.MatrixIndexB.Tex4MtxIdx != MatrixIndexB.Tex4MtxIdx ||
+ xfregs.MatrixIndexB.Tex5MtxIdx != MatrixIndexB.Tex5MtxIdx ||
+ xfregs.MatrixIndexB.Tex6MtxIdx != MatrixIndexB.Tex6MtxIdx ||
+ xfregs.MatrixIndexB.Tex7MtxIdx != MatrixIndexB.Tex7MtxIdx)
+ {
+ WARN_LOG(VIDEO, "Matrix indices don't match");
+
+ // Just show the assert once
+ static bool showedAlert = false;
+ _assert_msg_(VIDEO, showedAlert, "Matrix indices don't match");
+ showedAlert = true;
+ }
+
+#if(1)
m_Vertex.posMtx = xfregs.MatrixIndexA.PosNormalMtxIdx;
m_Vertex.texMtx[0] = xfregs.MatrixIndexA.Tex0MtxIdx;
m_Vertex.texMtx[1] = xfregs.MatrixIndexA.Tex1MtxIdx;
@@ -126,7 +136,8 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
m_Vertex.texMtx[5] = xfregs.MatrixIndexB.Tex5MtxIdx;
m_Vertex.texMtx[6] = xfregs.MatrixIndexB.Tex6MtxIdx;
m_Vertex.texMtx[7] = xfregs.MatrixIndexB.Tex7MtxIdx;
- /*m_Vertex.posMtx = MatrixIndexA.PosNormalMtxIdx;
+#else
+ m_Vertex.posMtx = MatrixIndexA.PosNormalMtxIdx;
m_Vertex.texMtx[0] = MatrixIndexA.Tex0MtxIdx;
m_Vertex.texMtx[1] = MatrixIndexA.Tex1MtxIdx;
m_Vertex.texMtx[2] = MatrixIndexA.Tex2MtxIdx;
@@ -134,7 +145,8 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
m_Vertex.texMtx[4] = MatrixIndexB.Tex4MtxIdx;
m_Vertex.texMtx[5] = MatrixIndexB.Tex5MtxIdx;
m_Vertex.texMtx[6] = MatrixIndexB.Tex6MtxIdx;
- m_Vertex.texMtx[7] = MatrixIndexB.Tex7MtxIdx;*/
+ m_Vertex.texMtx[7] = MatrixIndexB.Tex7MtxIdx;
+#endif
if (g_VtxDesc.PosMatIdx != NOT_PRESENT) {
AddAttributeLoader(LoadPosMtx);
@@ -258,7 +270,7 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
m_TexGenSpecialCase =
((g_VtxDesc.Hex & 0x60600L) == g_VtxDesc.Hex) && // only pos and tex coord 0
(g_VtxDesc.Tex0Coord != NOT_PRESENT) &&
- (xfregs.texMtxInfo[0].inputform == XF_TEXINPUT_AB11);
+ (xfregs.texMtxInfo[0].projection == XF_TEXPROJ_ST);
m_SetupUnit->Init(primitiveType);