Offset the draws properly. Now just some texel clamping left to fix

This commit is contained in:
Henrik Rydgård 2022-08-31 01:40:53 +02:00
parent 70f7f74a05
commit 7186fc2c17
3 changed files with 13 additions and 3 deletions

View File

@ -581,8 +581,9 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
renderHeightFactor = renderHeight / 272.0f;
}
renderX = gstate_c.curRTOffsetX;
renderY = gstate_c.curRTOffsetY;
// negative offsets we take care of in the projection matrix.
renderX = std::max(gstate_c.curRTOffsetX, 0);
renderY = std::max(gstate_c.curRTOffsetY, 0);
// Scissor
int scissorX1 = gstate.getScissorX1();
@ -609,6 +610,9 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
float offsetY = gstate.getOffsetY();
if (out.throughMode) {
// If renderX/renderY are offset to compensate for a split framebuffer,
// applying the offset to the viewport isn't enough, since the viewport clips.
// We need to apply either directly to the vertices, or to the "through" projection matrix.
out.viewportX = renderX * renderWidthFactor + displayOffsetX;
out.viewportY = renderY * renderHeightFactor + displayOffsetY;
out.viewportW = curRTWidth * renderWidthFactor;

View File

@ -152,6 +152,12 @@ 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;
}
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;
}
CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr());
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
}

View File

@ -625,7 +625,7 @@ struct GPUStateCache {
if (xoff != curRTOffsetX || yoff != curRTOffsetY) {
curRTOffsetX = xoff;
curRTOffsetY = yoff;
Dirty(DIRTY_VIEWPORTSCISSOR_STATE);
Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_PROJTHROUGHMATRIX);
}
}
int curRTOffsetX;