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

Shader blending in Vulkan through input attachments #15944

Merged
merged 7 commits into from
Sep 16, 2022

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Sep 2, 2022

This uses input attachments, a subpass self-dependency and barriers to implement limited shader blending for unextended Vulkan, avoiding copies.

This of course has the limitation that self-overlapping draw calls will not necessarily (although might on some hardware or if lucky) blend correctly with earlier parts of themselves, but it's generally not an issue and is also an issue of the copy-texture-based shader blending (though the wrong results will likely not be exactly the same).

Should be a modest performance boost for some games, and result in cleaner output in RenderDoc. And is simply the right thing to do, additionally opens up to more uses for this technique, such as implementing the self-depal horror used in Jackass (#13676).

Things left to do:

  • Don't force this on in all render passes, since it forces us to use a possibly less optimal image layout (GENERAL instead of COLOR_ATTACHMENT_OPTIMAL). Fixing this will require a bit of refactoring and having separately compiled pipelines for these (since pipelines include renderpasses in their creation).
  • Testing on various hardware
    • Works great on NVIDIA
    • Works great on both Mali and Adreno in Outrun
    • Breaks on Adreno in DBZ: TTT :( (but works on Mali)

@hrydgard hrydgard added Vulkan GE emulation Backend-independent GPU issues labels Sep 2, 2022
@hrydgard hrydgard added this to the v1.14.0 milestone Sep 2, 2022
@hrydgard hrydgard force-pushed the vulkan-shader-blending branch from fd16769 to 3141971 Compare September 5, 2022 08:07
@hrydgard
Copy link
Owner Author

hrydgard commented Sep 5, 2022

Rebased on master, confirmed working in Outrun etc for the logic stuff. Still, work remains before this can be merged.

@hrydgard
Copy link
Owner Author

hrydgard commented Sep 7, 2022

Rebased on top of #15982 , which should be merged first.

Obviously, only the last three commits here need reviewing separately.

I'm not using the new extensions yet, not sure if we'll need them.

@hrydgard hrydgard marked this pull request as ready for review September 7, 2022 22:51
@hrydgard hrydgard force-pushed the vulkan-shader-blending branch 2 times, most recently from 99b0baa to 4b28ff8 Compare September 8, 2022 07:41
@hrydgard
Copy link
Owner Author

hrydgard commented Sep 8, 2022

Alright, rebased on master after merging #15982 . Will need more testing before merge.

@hrydgard hrydgard force-pushed the vulkan-shader-blending branch 2 times, most recently from 04a915c to 6170f92 Compare September 16, 2022 11:25
@hrydgard
Copy link
Owner Author

hrydgard commented Sep 16, 2022

This now works fine on all platforms, except for some reason in Dragon Ball Z: TTT on Adreno, getting vertical artifacts between the rectangles in the strip. I'm guessing there's some small overlap in the draw, where behavior becomes undefined (and accidentally worse than without this...). Bah.

EDIT: Actually no overlap in the draw, though there are multiple adjacent triangles next to each other. But that should work. Don't know what's going on then...

Maybe I'll just disable this path on Adreno.

EDIT2: I'm thinking of flattening rect strips like this into a single rectangle, that should also fix it:

image

hrydgard added a commit that referenced this pull request Sep 16, 2022
Helps an issue with #15944 (DBZ: TTT), and is a small GPU optimization
(mainly less pixels on diagonals - those cause "quad overlap" even
though the resulting pixels don't)
@hrydgard
Copy link
Owner Author

hrydgard commented Sep 16, 2022

Actually doesn't fix it, still getting artifacts along the one remaining diagonal. Seems this type of shader blending isn't working on at least old Adreno drivers, or we're still getting some barrier wrong. I'm gonna add a bug flag for now, and only enable this on non-Adreno.

@hrydgard hrydgard force-pushed the vulkan-shader-blending branch from 6170f92 to 262a306 Compare September 16, 2022 17:20
@hrydgard hrydgard merged commit 143be81 into master Sep 16, 2022
@hrydgard hrydgard deleted the vulkan-shader-blending branch September 16, 2022 21:31
@hrydgard
Copy link
Owner Author

OK, let's see if anything else breaks, hopefully not :)

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 Vulkan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants