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 delayed depth readbacks, Vulkan only #16916

Merged
merged 6 commits into from
Feb 8, 2023

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Feb 5, 2023

This is a Vulkan implementation of some ideas from #16900, more specifically the mode where we just keep readbacks around until the next time the same "frame context" comes around, and if a readback is perform, we just return the old data immediately instead of reading new data, plus we schedule a read so we have the data next time.

The delay can be too large and Syphon Filter's lights are a bit flickery and weird since the Z values aren't exactly what the game expects when moving around, but performance is fantastic on mobile and they are at least roughly occluded right, so it's better than before at least. Anyway due to the problems I'm not really happy with this as-is for Syphon, but will likely work for Dangan Ronpa for example, as commented in the other issue by @unknownbrackets .

In this PR it's only enabled for depth readbacks, which are currently only enabled in Syphon anyway, but there will be further development of this before it can be merged, plus it needs to be implemented for OpenGL as well where possible using PBOs.

Changed it, now it's only enabled for the Dangan Ronpa readback, where it really has no discernable side effect, only a good speed boost.

I ran into trouble with my OpenGL implementation so postponing that.

Will later add an "as-fast-as-possible" mode, which will be slightly less safe and vulkan-only. This PR only implements the safest and longest-latency version of the idea.

@hrydgard hrydgard added Vulkan GE emulation Backend-independent GPU issues labels Feb 5, 2023
@hrydgard hrydgard changed the title Implement delayed depth readbacks, proof of concept Implement delayed depth readbacks, Vulkan only Feb 6, 2023
@hrydgard
Copy link
Owner Author

hrydgard commented Feb 7, 2023

I have experimentally found that it's possible to get the Syphon Filter lens flares to look near-perfect even with delayed feedbacks, with a little fudge factor - just multiply the read-back depths by 0.95 for example. Things still occlude just fine generally, while no longer flickering with movement. Quickly descending through the depravity levels of game-hackery though :)

Dangan Ronpa demo readbacks work great delayed.

@hrydgard hrydgard force-pushed the implement-delayed-readback branch from d5f173c to 00e2e59 Compare February 7, 2023 22:14
@hrydgard hrydgard marked this pull request as ready for review February 7, 2023 23:56
@hrydgard hrydgard force-pushed the implement-delayed-readback branch from 00e2e59 to 735cd26 Compare February 7, 2023 23:56
GPU/Common/FramebufferManagerCommon.cpp Outdated Show resolved Hide resolved
@@ -218,14 +218,18 @@ bool FramebufferManagerCommon::ReadbackDepthbuffer(Draw::Framebuffer *fbo, int x

DepthUB ub{};

// Setting this to 0.95f eliminates flickering lights with delayed readback in Syphon Filter.
// That's pretty ugly though! But we'll need to do that if we're gonna enable delayed readback in those games.
Copy link
Collaborator

@unknownbrackets unknownbrackets Feb 8, 2023

Choose a reason for hiding this comment

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

While it's ugly, tbh if we're sure it's fine and looks about right across the game this is actually a type of game hack / compatibility flag I'm not so against. Since this is conceptually taking something we know how to do right (blocking) and applying an engine or series specific hack to make it still look the same but run faster.

That doesn't betray the goals of making the emulator capable of running all games well and solving underlying problems. It is ugly, though. Not saying it's not ugly.

That said, I feel like it must make some lights occlude early/late or something which I might be a bit less a fan of.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

It does, but it's only really noticeable if you really look for it. However it's also possible there are some situations with thin walls where lights will shine through now when they didn't before - I didn't find any playing for a while, but it would not surprise me.

So before I do a compat hack for this, I want to see how good we can get it with fully async readbacks (that happen as soon as the GPU performs it, and doesn't wait until a guaranteed safe time the next time around the frame contexts).

Common/GPU/Vulkan/VulkanRenderManager.cpp Outdated Show resolved Hide resolved
@hrydgard hrydgard mentioned this pull request Feb 8, 2023
7 tasks
@hrydgard hrydgard merged commit 2d0252f into master Feb 8, 2023
@hrydgard hrydgard deleted the implement-delayed-readback branch February 8, 2023 20:34
@hrydgard hrydgard added this to the v1.15.0 milestone Feb 8, 2023
@hrydgard hrydgard added the GPU readback Issue related to readbacks from the GPU to CPU label Feb 16, 2023
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 GPU readback Issue related to readbacks from the GPU to CPU Vulkan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants