From ee9c9ac8f30ff9157bfc759a36fd372bf9809019 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Mon, 14 Nov 2011 03:08:13 +0000 Subject: [PATCH] GSdx: Added a simple workaround for the 32-bit z problem talked about in the comments of r4956. Since sprites are flat and there was an unused vertex member (t.w), I just decided to pass the raw uint32 value in that to the scanline drawing function. It does not fix triangles and other primitive types, of course. The ideal solution would be to break z into two parts (like 8:24 bits, and only care about the upper part when not zero), interpolate separately and rejoin when needed, it is just too hard to add another variable when the assembly code is already so tightly optimized to use every register. (HW mode z-test expects a float input, so this trick cannot be done there.) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4966 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSRendererSW.cpp | 5 +++++ plugins/GSdx/GSSetupPrimCodeGenerator.x86.avx.cpp | 7 +++++++ plugins/GSdx/GSSetupPrimCodeGenerator.x86.cpp | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index 5635624a21..de9e28fb58 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -766,6 +766,11 @@ void GSRendererSW::VertexKick(bool skip) dst.c = GSVector4::rgba32(m_v.RGBAQ.u32[0], 7); + if(prim == GS_SPRITE) + { + dst.t.u32[3] = m_v.XYZ.Z; + } + int count = 0; if(GSVertexSW* v = DrawingKick(skip, count)) diff --git a/plugins/GSdx/GSSetupPrimCodeGenerator.x86.avx.cpp b/plugins/GSdx/GSSetupPrimCodeGenerator.x86.avx.cpp index 8620124946..5e2d664bcd 100644 --- a/plugins/GSdx/GSSetupPrimCodeGenerator.x86.avx.cpp +++ b/plugins/GSdx/GSSetupPrimCodeGenerator.x86.avx.cpp @@ -123,6 +123,12 @@ void GSSetupPrimCodeGenerator::Depth() if(m_en.z) { + // uint32 z is bypassed in t.w + + vmovdqa(xmm0, ptr[ecx + offsetof(GSVertexSW, t)]); + vpshufd(xmm0, xmm0, _MM_SHUFFLE(3, 3, 3, 3)); + +/* // GSVector4 z = p.zzzz(); vshufps(xmm0, xmm0, _MM_SHUFFLE(2, 2, 2, 2)); @@ -149,6 +155,7 @@ void GSSetupPrimCodeGenerator::Depth() vcvttps2dq(xmm0, xmm0); } +*/ vmovdqa(ptr[&m_local.p.z], xmm0); } diff --git a/plugins/GSdx/GSSetupPrimCodeGenerator.x86.cpp b/plugins/GSdx/GSSetupPrimCodeGenerator.x86.cpp index 67be7a7b36..5066928b20 100644 --- a/plugins/GSdx/GSSetupPrimCodeGenerator.x86.cpp +++ b/plugins/GSdx/GSSetupPrimCodeGenerator.x86.cpp @@ -128,6 +128,12 @@ void GSSetupPrimCodeGenerator::Depth() if(m_en.z) { + // uint32 z is bypassed in t.w + + movdqa(xmm0, ptr[ecx + offsetof(GSVertexSW, t)]); + pshufd(xmm0, xmm0, _MM_SHUFFLE(3, 3, 3, 3)); + + /* // GSVector4 z = p.zzzz(); shufps(xmm0, xmm0, _MM_SHUFFLE(2, 2, 2, 2)); @@ -154,6 +160,7 @@ void GSSetupPrimCodeGenerator::Depth() cvttps2dq(xmm0, xmm0); } + */ movdqa(ptr[&m_local.p.z], xmm0); }