Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU: Support framebuf depal from rendered CLUT #16454

Merged
merged 3 commits into from
Nov 28, 2022

Conversation

unknownbrackets
Copy link
Collaborator

This fixes the transitions into battle in Kurhyo 2 (see #15956.) They're no longer incorrectly red.

For reproduction / posterity:

Here's a frame dump entering battle (incorrectly red before these changes):
#15956_NPJH90274_kurohyo_red_bg.zip

Correct rendering (PSP, software looks the same):
#15956_NPJH90274_kurohyo_red_bg

CLUT is rendered at 64/767, to 0x04116200 (256x1, 565.) It's textured from a RAM texture. It's read back as 8888, with & 0x1f (pass 1), then (>> 5) & 0x1f (pass 2), etc. Basically red/green/blue ramps next to each other. The CLUT address is adjusted each time, which is the first issue:

  • 69/767 uses red (CLUT at 04116200, 0-31 - so pixels 0-63 of 565 render)
  • 73/767 uses green (CLUT at 04116280, 0-31 - so pixels 64-127 of 565 render)
  • 77/767 uses blue (CLUT at 04116300, 0-31 - so pixels 128-191 of 565 render)

Next, it uses this to depal a framebuffer, so that's the second issue. Finally, it uses this same rendered CLUT for many frames without re-rendering it, and previously we decimated framebuffers if they weren't updated.

-[Unknown]

We already copy to a temp, so just use that copy to normalize out the
offset.  Should even get RECT2LIN correct, but most cases are 1 pixel high
anyway.
Using a temporary always for simplicity.
Fixes color changing after a few moments in Kurohyo.
Copy link
Owner

@hrydgard hrydgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, great stuff!

I will test it a bit on my usual-suspect render-to-clut games and then merge.

@hrydgard
Copy link
Owner

Works perfectly as expected. In it goes, thanks!

@hrydgard hrydgard merged commit ed15147 into hrydgard:master Nov 28, 2022
@unknownbrackets unknownbrackets deleted the fb-depal-fb branch November 28, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GE emulation Backend-independent GPU issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants