Skip to content

Commit

Permalink
softgpu: Allow almost flat rectangles to go fast.
Browse files Browse the repository at this point in the history
Improves transform rectangles used in Chains of Olympus, for example on
the title screen.
  • Loading branch information
unknownbrackets committed Sep 10, 2022
1 parent 6004d4a commit e7d49cd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions GPU/Software/RasterizerRectangle.cpp
Expand Up @@ -333,10 +333,18 @@ static bool AreCoordsRectangleCompatible(const RasterizerState &state, const Ver
if (!state.throughMode && !(data1.color1 == data0.color1))
return false;
// Do we have to think about perspective correction or slope mip level?
if (state.enableTextures && data1.clippos.w != data0.clippos.w)
return false;
if (state.pixelID.applyFog && data1.fogdepth != data0.fogdepth)
return false;
if (state.enableTextures && data1.clippos.w != data0.clippos.w) {
// If the w is off by less than a factor of 1/512, it should be safe to treat as a rectangle.
static constexpr float halftexel = 0.5f / 512.0f;
if (data1.clippos.w - halftexel > data0.clippos.w || data1.clippos.w + halftexel < data0.clippos.w)
return false;
}
if (state.pixelID.applyFog && data1.fogdepth != data0.fogdepth) {
// Similar to w, this only matters if they're farther apart than 1/255.
static constexpr float foghalfstep = 0.5f / 255.0f;
if (data1.fogdepth - foghalfstep > data0.fogdepth || data1.fogdepth + foghalfstep < data0.fogdepth)
return false;
}
}
return true;
}
Expand Down

0 comments on commit e7d49cd

Please sign in to comment.