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

Deferred depth buffer copies #15777

Closed
wants to merge 3 commits into from
Closed

Deferred depth buffer copies #15777

wants to merge 3 commits into from

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Aug 1, 2022

Due to the fact that the PSP overlaps stencil with color alpha, and PC interleaves stencil with depth instead, to get the semantics right we often have to copy the depth buffer from a previously bound framebuffer.

This avoids doing that if we never use depth after binding a color buffer, before binding the next one. This results in eliminated depth copies in several and perhaps many games, including God of War, saving some GPU performance.

This was made possible after #15700 and was @unknownbrackets 's idea (see comments in the issue) so cred goes to him.

Don't really have any numbers for the improvement, but eliminating unnecessary operations is always good. There is some extra checking per draw though.. wonder if there's a way to reduce that.

NOTE: This is draft because it doesn't avoid splitting render passes on OpenGL yet, in case the depth draw is not the first in a pass. That probably doesn't happen very often though.

EDIT: Regressions found during testing, check off once fixed:

EDIT: There's problem with the pass injection. It's too aggressive, it should not happen when we are on the first draw on a new framebuffer.

@hrydgard hrydgard added GE emulation Backend-independent GPU issues Performance Unexpected slow performance issues labels Aug 1, 2022
@hrydgard hrydgard added this to the v1.14.0 milestone Aug 1, 2022
@hrydgard
Copy link
Owner Author

The color-to-depth mode for Kuroyuo complicates this a lot. Before I get this in, I'm going to remove it in favor of a copying-based scheme instead (powered by the new sequence numbers).

@hrydgard
Copy link
Owner Author

hrydgard commented Aug 17, 2022

OK, I've decided that I'm gonna have to get this in together with the new color-to-depth replacement, as that one doesn't work properly without this.

Here's a note to self about my progress figuring out Kuroyou.

There's an issue in the beginning of the scene that somehow wasn't a problem before, but is now:

  • Drawing the background to 0000000/0044000 (alternating)
  • Drawing the depth buffer using RGB565 to 88000 (in four strips)
  • Texturing from 288000 in 565 format, drawing to 116400 (in four strips). This is black.
  • Texturing from 116400 in 565 format, drawing to 88000 (same addr is bound as depth buffer, should be ignored).
  • Finally, drawing the scene with depth testing to 0000000/0044000, with depth buffer at 88000.

The 565 bounce through 116400 of the depth image is presumably to swizzle the color data into the standard depth buffer ordering. We misinterpret this as depth texturing, causing our nice depth-image to turn black (I think - either way the problem is likely in the framebuffer-texture matching). This should use the sequence numbers.

Then other shenanigans happen later in the rendering:

  • Next, texturing from 00000/44000 in 5551 format, while drawing to CC000. Alpha testing seems to be going on to isolate the characters?

  • Then texturing from CC000 (5551) while drawing to 44000, multiple times, some slight blur I think.

  • Then texturing with CLUT16 from 88000 (which should now have the real depth buffer) drawing to cc000, then the rest is various bloom downsampling/upsampling etc.

@hrydgard
Copy link
Owner Author

Closing in favor of #15858

@hrydgard hrydgard closed this Aug 17, 2022
@hrydgard hrydgard deleted the deferred-depth-copy branch September 5, 2022 07:49
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 Performance Unexpected slow performance issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant