KillZone: Fix margin detection on the title screen, fixing some glitches. Need more fixes though to fix the shimmer effect.

See #6207 comments
This commit is contained in:
Henrik Rydgård 2022-08-31 11:40:10 +02:00
parent 3168f8d119
commit 437d6d30a0
3 changed files with 23 additions and 13 deletions

View File

@ -333,8 +333,11 @@ void GetFramebufferHeuristicInputs(FramebufferHeuristicParams *params, const GPU
params->viewportHeight = (int)(fabsf(vpy) * 2.0f);
params->regionWidth = gstate.getRegionX2() + 1;
params->regionHeight = gstate.getRegionY2() + 1;
params->scissorWidth = gstate.getScissorX2() + 1;
params->scissorHeight = gstate.getScissorY2() + 1;
params->scissorLeft = gstate.getScissorX1();
params->scissorTop = gstate.getScissorY1();
params->scissorRight = gstate.getScissorX2() + 1;
params->scissorBottom = gstate.getScissorY2() + 1;
if (gstate.getRegionRateX() != 0x100 || gstate.getRegionRateY() != 0x100) {
WARN_LOG_REPORT_ONCE(regionRate, G3D, "Drawing region rate add non-zero: %04x, %04x of %04x, %04x", gstate.getRegionRateX(), gstate.getRegionRateY(), gstate.getRegionX2(), gstate.getRegionY2());
@ -352,7 +355,7 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(Framebuffer
// As there are no clear "framebuffer width" and "framebuffer height" registers,
// we need to infer the size of the current framebuffer somehow.
int drawing_width, drawing_height;
EstimateDrawingSize(params.fb_address, std::max(params.fb_stride, (u16)4), params.fb_format, params.viewportWidth, params.viewportHeight, params.regionWidth, params.regionHeight, params.scissorWidth, params.scissorHeight, drawing_width, drawing_height);
EstimateDrawingSize(params.fb_address, std::max(params.fb_stride, (u16)4), params.fb_format, params.viewportWidth, params.viewportHeight, params.regionWidth, params.regionHeight, params.scissorRight, params.scissorBottom, drawing_width, drawing_height);
if (params.fb_address == params.z_address) {
// Most likely Z will not be used in this pass, as that would wreak havoc (undefined behavior for sure)
@ -2876,10 +2879,10 @@ VirtualFramebuffer *FramebufferManagerCommon::ResolveFramebufferColorToFormat(Vi
static void ApplyKillzoneFramebufferSplit(FramebufferHeuristicParams *params, int *drawing_width) {
// Detect whether we're rendering to the margin.
bool margin;
if (params->scissorWidth == 32) {
// Title screen has this easy case.
if ((params->scissorRight - params->scissorLeft) == 32) {
// Title screen has this easy case. It also uses non-through verts, so lucky for us that we have this.
margin = true;
} else if (params->scissorWidth == 480) {
} else if (params->scissorRight == 480) {
margin = false;
} else {
// Go deep, look at the vertices. Killzone-specific, of course.

View File

@ -165,10 +165,12 @@ struct FramebufferHeuristicParams {
bool isBlending;
int viewportWidth;
int viewportHeight;
int regionWidth;
int regionHeight;
int scissorWidth;
int scissorHeight;
int16_t regionWidth;
int16_t regionHeight;
int16_t scissorLeft;
int16_t scissorTop;
int16_t scissorRight;
int16_t scissorBottom;
};
struct GPUgstate;

View File

@ -1686,9 +1686,14 @@ void GPUCommon::Execute_Prim(u32 op, u32 diff) {
}
}
if ((gstate.vertType & 0xFFFFFF) == 0x00800102 && PSP_CoreParameter().compat.flags().SplitFramebufferMargin) {
// Need to re-check the framebuffer every draw.
gstate_c.Dirty(DIRTY_FRAMEBUF);
if (PSP_CoreParameter().compat.flags().SplitFramebufferMargin) {
switch (gstate.vertType & 0xFFFFFF) {
case 0x00800102: // through, u16 uv, u16 pos (used for the framebuffer effect in-game)
case 0x0080011c: // through, 8888 color, s16 pos (used for clearing in the margin of the title screen)
case 0x00000183: // float uv, float pos (used for drawing in the margin of the title screen)
// Need to re-check the framebuffer every one of these draws, to update the split if needed.
gstate_c.Dirty(DIRTY_FRAMEBUF);
}
}
// This also makes skipping drawing very effective.