summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2013-03-27 13:19:23 +1100
committerskidau <skidau@gmail.com>2013-03-27 13:19:23 +1100
commit7784fa4c67cc8d2545f45694d83805e7e89cd583 (patch)
tree7724133aabe971ec417d1dea0977a525bb8debfb /Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp
parentd33c19b0cd2bae982c8d35e86a9d3551f9e5c72f (diff)
parent5cea0d9defeaa23e7af94adf7615a44fb2c9c173 (diff)
Merge branch 'master' into wii-network
# By Ryan Houdek (185) and others # Via degasus (12) and others * master: (625 commits) Revert "Don't open/close file for every file operation." as it was crashing PokePark in Windows builds. Array overrun fixed in VertexShaderCache for the DX11 plugin. Fixed DSPTool build. Windows build fix Go back to assuming every HID device is a wiimote on Windows. Fixed issue 6117. Unfixed issue 6031. VideoSoftware: Improve fog range adjustment by using less magic and more comments. revert RasterFont for VideoSoftware ogl: fix virtual xfb Windows build fix from web interface... Adjusted the audio loop criteria, using >= on the Wii and == on GC. This fixes the audio static that occurred in Wii games after hours of play. Forced the exception check only for ARAM DMA transfers. Removed the Eternal Darkness boot hack and replaced it with an exception check. VideoSoftware: Implement fog range adjustment, fixing issue 6147. implement 4xSSAA for OGL move ogl-only settings into backend Fix description of disable fog, and move it to enhancements tab. Reverted rd76ca5783743 as it was made obsolete by r1d550f4496e4. Removed the tracking of the FIFO Writes as it was made obsolete by r1d550f4496e4. Forced the external exception check to occur sooner by changing the downcount. Mark the Direct3D9 backend deprecated. Prefer D3D11 and OpenGL over D3D9 by default. ... Conflicts: CMakeLists.txt Source/Core/Common/Common.vcxproj.filters Source/Core/Common/Src/CommonPaths.h Source/Core/Core/Core.vcxproj.filters Source/Core/Core/Src/Core.cpp Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp Source/VSProps/Dolphin.Win32.props Source/VSProps/Dolphin.x64.props
Diffstat (limited to 'Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp')
-rw-r--r--Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp62
1 files changed, 55 insertions, 7 deletions
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp
index 927f8931e9..fa072508eb 100644
--- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp
+++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp
@@ -20,11 +20,13 @@
#include "Tev.h"
#include "EfbInterface.h"
#include "TextureSampler.h"
+#include "XFMemLoader.h"
+#include "SWPixelEngine.h"
#include "SWStatistics.h"
#include "SWVideoConfig.h"
#include "DebugUtil.h"
-#include <math.h>
+#include <cmath>
#ifdef _DEBUG
#define ALLOW_TEV_DUMPS 1
@@ -747,10 +749,22 @@ void Tev::Draw()
}
- // stuff to do!
- // here, where we'll have to add/handle x range adjustment (if related BP register it's enabled)
- // x_adjust = sqrt((x-center)^2 + k^2)/k
- // ze *= x_adjust
+ if(bpmem.fogRange.Base.Enabled)
+ {
+ // TODO: This is untested and should definitely be checked against real hw.
+ // - No idea if offset is really normalized against the viewport width or against the projection matrix or yet something else
+ // - scaling of the "k" coefficient isn't clear either.
+
+ // First, calculate the offset from the viewport center (normalized to 0..1)
+ float offset = (Position[0] - (bpmem.fogRange.Base.Center - 342)) / (float)swxfregs.viewport.wd;
+ // Based on that, choose the index such that points which are far away from the z-axis use the 10th "k" value and such that central points use the first value.
+ int index = 9 - std::abs(offset) * 9.f;
+ index = (index < 0) ? 0 : (index > 9) ? 9 : 0; // TODO: Shouldn't be necessary!
+ // Look up coefficient... Seems like multiplying by 4 makes Fortune Street work properly (fog is too strong without the factor)
+ float k = bpmem.fogRange.K[index/2].GetValue(index%2) * 4.f;
+ float x_adjust = sqrt(offset*offset + k*k)/k;
+ ze *= x_adjust; // NOTE: This is basically dividing by a cosine (hidden behind GXInitFogAdjTable): 1/cos = c/b = sqrt(a^2+b^2)/b
+ }
ze -= bpmem.fog.c_proj_fsel.GetC();
@@ -787,8 +801,13 @@ void Tev::Draw()
bool late_ztest = !bpmem.zcontrol.early_ztest || !g_SWVideoConfig.bZComploc;
if (late_ztest && bpmem.zmode.testenable)
{
- if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2]))
- return;
+ // TODO: Check against hw if these values get incremented even if depth testing is disabled
+ SWPixelEngine::pereg.IncZInputQuadCount(false);
+
+ if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2]))
+ return;
+
+ SWPixelEngine::pereg.IncZOutputQuadCount(false);
}
#if ALLOW_TEV_DUMPS
@@ -812,6 +831,7 @@ void Tev::Draw()
#endif
INCSTAT(swstats.thisFrame.tevPixelsOut);
+ SWPixelEngine::pereg.IncBlendInputQuadCount();
EfbInterface::BlendTev(Position[0], Position[1], output);
}
@@ -827,3 +847,31 @@ void Tev::SetRegColor(int reg, int comp, bool konst, s16 color)
Reg[reg][comp] = color;
}
}
+
+void Tev::DoState(PointerWrap &p)
+{
+ p.DoArray(Reg, sizeof(Reg));
+
+ p.DoArray(KonstantColors, sizeof(KonstantColors));
+ p.DoArray(TexColor,4);
+ p.DoArray(RasColor,4);
+ p.DoArray(StageKonst,4);
+ p.DoArray(Zero16,4);
+
+ p.DoArray(FixedConstants,9);
+ p.Do(AlphaBump);
+ p.DoArray(IndirectTex, sizeof(IndirectTex));
+ p.Do(TexCoord);
+
+ p.DoArray(m_BiasLUT,4);
+ p.DoArray(m_ScaleLShiftLUT,4);
+ p.DoArray(m_ScaleRShiftLUT,4);
+
+ p.DoArray(Position,3);
+ p.DoArray(Color, sizeof(Color));
+ p.DoArray(Uv, 8);
+ p.DoArray(IndirectLod,4);
+ p.DoArray(IndirectLinear,4);
+ p.DoArray(TextureLod,16);
+ p.DoArray(TextureLinear,16);
+}