softgpu: Optimize out texture proj for UVs.

Seen in NFS Most Wanted 5-1-0.
This commit is contained in:
Unknown W. Brackets 2022-12-01 23:13:20 -08:00
parent d7224a8401
commit 33abbca464

View file

@ -132,7 +132,12 @@ void ComputeRasterizerState(RasterizerState *state, std::function<void()> flushF
state->textureProj = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX;
if (state->textureProj) {
// We may be able to optimize this off. This is actually kinda common.
if (gstate.tgenMatrix[2] == 0.0f && gstate.tgenMatrix[5] == 0.0f && gstate.tgenMatrix[8] == 0.0f && gstate.tgenMatrix[11] == 1.0f) {
const bool qZeroST = gstate.tgenMatrix[2] == 0.0f && gstate.tgenMatrix[5] == 0.0f;
const bool qZeroQ = gstate.tgenMatrix[8] == 0.0f;
// Two common cases: the source q factor is zero, OR source is UV.
const bool qFactorZero = gstate.getUVProjMode() == GE_PROJMAP_UV;
if (qZeroST && (qZeroQ || qFactorZero) && gstate.tgenMatrix[11] == 1.0f) {
state->textureProj = false;
}
}