Quicker way to update the through projection matrix with the split framebuffer offset

This commit is contained in:
Henrik Rydgård 2022-08-31 08:44:15 +02:00
parent 95b299766e
commit d99e4b6714
2 changed files with 7 additions and 4 deletions

View file

@ -581,7 +581,9 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
renderHeightFactor = renderHeight / 272.0f;
}
// negative offsets we take care of in the projection matrix.
// We take care negative offsets of in the projection matrix.
// These come from split framebuffers (Killzone).
// TODO: Might be safe to do get rid of this here and do the same for positive offsets?
renderX = std::max(gstate_c.curRTOffsetX, 0);
renderY = std::max(gstate_c.curRTOffsetY, 0);

View file

@ -152,10 +152,11 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
if (!useBufferedRendering && g_display_rotation != DisplayRotation::ROTATE_0) {
proj_through = proj_through * g_display_rot_matrix;
}
// Negative RT offsets come from split framebuffers (Killzone)
if (gstate_c.curRTOffsetX < 0 || gstate_c.curRTOffsetY < 0) {
Matrix4x4 xlate;
xlate.setTranslation(Lin::Vec3(2.0f * gstate_c.curRTOffsetX / (int)gstate_c.curRTWidth, 2.0f * gstate_c.curRTOffsetY / (int)gstate_c.curRTHeight, 0.0f));
proj_through = proj_through * xlate;
proj_through.wx += 2.0f * (float)gstate_c.curRTOffsetX / (float)gstate_c.curRTWidth;
proj_through.wy += 2.0f * (float)gstate_c.curRTOffsetY / (float)gstate_c.curRTHeight;
}
CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr());