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

Implement EFB Peeks for compressed z16 formats #9673

Merged
merged 2 commits into from May 5, 2021

Conversation

phire
Copy link
Member

@phire phire commented Apr 26, 2021

Dolphin doesn't correctly emulate 3xMSAA mode. It probably never will as it's kind of pointless when users can just force everything to have 4xMSAA or 16xMSAA or even stupidly high Internal Resolutions.

Besides, Not many games uses the 3xMSAA mode. It's a real pain to use when it cuts the vertical EFB resolution in half to 640x264, requiring multiple passes to get a complete 4:3 frame.

But Rogue Squadron uses it. Actually, Factor 5 cheap out and only uses it during cutscenes. They cheap out even further by rendering many of those cutscenes in a "cinematic widescreen" aspect ratio with a resolution of 512x264 that just so happens to fit inside a single 3xMSAA EFB buffer.

Dolphin's trickery is usually hidden from games. Except RS3 also directly accesses the EFB framebuffer to check the occlusion of engine exhaust plumes. This was previously working in main gameplay, but in cutscenes dolphin would return the wrong depth and the occlusion query would always pass, resulting in the lens flare effect shining though solid objects.

Dolphin had some previous code to automatically convert from Z24 to Z16 formats during an efb peek, but it was hardcoded to the Linear format, while RS3 uses the ZFAR compressed Z16 format.

This PR implements the compressed Z16 formats, which fixes this visual glitch in RS3 cutscenes.

Screenshots:

Before

hanger-before

After

hanger-after

Before

GLRE64_2021-04-26_22-30-42

After

GLRE64_2021-04-26_22-21-44

@phire phire requested review from stenzek and lioncash and removed request for stenzek April 26, 2021 10:58
@Rumi-Larry
Copy link

Perhaps the second example should be included into Fifoci

@JMC47
Copy link
Contributor

JMC47 commented Apr 26, 2021

It cannot be, for the results get baked into the fifolog. We already checked for that.

@JMC47
Copy link
Contributor

JMC47 commented Apr 26, 2021

This seems to only affect Rogue Squadron 3. I pushed this through a big part of my library of games that do EFB Access, and it just doesn't seem to catch anything at all. No fixes, no regressions, no nothing. Just Rogue Squadron 3.

@PatrickFerry
Copy link
Contributor

Copy link
Contributor

@stenzek stenzek left a comment

Choose a reason for hiding this comment

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

I'm unfamiliar with how the hardware works here, but the in-source explanation makes sense to me.

@phire
Copy link
Member Author

phire commented Apr 27, 2021

To be clear, I didn't do hardware testing here.

The data format was documented from REed Z16 decompression/compression functions decompiled from game code (that appear to be originally from the Gamecube SDK)

I don't know if it's 100% correct, but It's close enough to make RE3 behave correctly.

Source/Core/VideoCommon/VideoCommon.h Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VideoCommon.h Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VideoCommon.h Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VideoCommon.h Outdated Show resolved Hide resolved
@PatrickFerry
Copy link
Contributor

There is a TODO for checking for compressed z16 format changes in BPFunctions.cpp -> OnPixelFormatChange()

I am assuming "special compression format" means ZFAR, if that's the case could you add Star Wars:RS3 to the comment?

@phire
Copy link
Member Author

phire commented May 3, 2021

There is a TODO for checking for compressed z16 format changes in BPFunctions.cpp -> OnPixelFormatChange()

I am assuming "special compression format" means ZFAR, if that's the case could you add Star Wars:RS3 to the comment?

ZFAR, ZMID and ZNEAR are the 3 options for "special compression format", on top of ZLINEAR.

I've updated the TODO to be more accurate and have more up-to-date infomation.

@phire phire removed the request for review from lioncash May 3, 2021 04:40
Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

LGTM, the first three commits should probably be squashed together

phire added 2 commits May 5, 2021 11:32
This fixes an issue in RS3 where engine lens flares would shine
though ships during cutscenes
@phire
Copy link
Member Author

phire commented May 5, 2021

Squashed, ready for merge

@JMC47 JMC47 merged commit 4b827f3 into dolphin-emu:master May 5, 2021
10 checks passed
@phire phire deleted the z16peeks branch May 9, 2021 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants