softgpu: Avoid splitting rectangles for fog.

If the fog factor would result in the same amount of fog, we're just
adding more work for no reason.
This commit is contained in:
Unknown W. Brackets 2022-11-13 09:23:06 -08:00
parent 21064edfca
commit a66056217f

View file

@ -203,7 +203,15 @@ void ProcessRect(const ClipVertexData &v0, const ClipVertexData &v1, BinManager
else if (outsidePos >= 2 || outsideNeg >= 2)
return;
if (v0.v.fogdepth != v1.v.fogdepth) {
bool splitFog = v0.v.fogdepth != v1.v.fogdepth;
if (splitFog) {
// If they match the same 1/255, we can consider the fog flat. Seen in Resistance.
// More efficient if we can avoid splitting.
static constexpr float foghalfstep = 0.5f / 255.0f;
if (v1.v.fogdepth - foghalfstep <= v0.v.fogdepth && v1.v.fogdepth + foghalfstep >= v0.v.fogdepth)
splitFog = false;
}
if (splitFog) {
// Rectangles seem to always use nearest along X for fog depth, but reversed.
// TODO: Check exactness of middle.
VertexData vhalf0 = v1.v;