softgpu: Avoid projecting textures in common case.

Several games appear to intentionally set the matrix flat.
This commit is contained in:
Unknown W. Brackets 2022-09-29 21:47:56 -07:00
parent 7cf05d0a46
commit dc90a5a851
2 changed files with 12 additions and 3 deletions

View file

@ -130,6 +130,12 @@ void ComputeRasterizerState(RasterizerState *state) {
state->minFilt = gstate.isMinifyFilteringEnabled();
state->magFilt = gstate.isMagnifyFilteringEnabled();
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) {
state->textureProj = false;
}
}
}
state->shadeGouraud = gstate.getShadeMode() == GE_SHADE_GOURAUD;

View file

@ -1127,8 +1127,11 @@ void SoftGPU::Execute_TgenMtxData(u32 op, u32 diff) {
if (num < 12) {
u32 *target = (u32 *)&gstate.tgenMatrix[num];
u32 newVal = op << 8;
// No dirtying, read during vertex read.
*target = newVal;
if (newVal != *target) {
*target = newVal;
// This is mainly used in vertex read, but also affects if we enable texture projection.
dirtyFlags_ |= SoftDirty::RAST_TEX;
}
}
// Doesn't wrap to any other matrix.
@ -1198,7 +1201,7 @@ bool SoftGPU::GetMatrix24(GEMatrixType type, u32_le *result, u32 cmdbits) {
void SoftGPU::ResetMatrices() {
GPUCommon::ResetMatrices();
dirtyFlags_ |= SoftDirty::TRANSFORM_MATRIX;
dirtyFlags_ |= SoftDirty::TRANSFORM_MATRIX | SoftDirty::RAST_TEX;
}
void SoftGPU::Execute_ImmVertexAlphaPrim(u32 op, u32 diff) {