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

Make sure blend is disabled if render target has integer format #5122

Merged
merged 2 commits into from May 28, 2023

Conversation

gdkchan
Copy link
Member

@gdkchan gdkchan commented May 28, 2023

Having blend enabled for integer formats is invalid. The most common case where this happens is when logic operations are enabled, and in this case the blend is ignored. Since Metal/MoltenVK does not support logical operations, it is never enabled there, and having blend enabled in this case causes a Metal assert and crash. To avoid this, this change forces blend to be disabled if the respective framebuffer attachment is using a integer format.

This should be safe to enable for all vendors, but here I'm enabling it only on MoltenVK just to be on the safe side. But I can enable it for all vendors too.

Fixes crashes on Xenoblade games, and should fix also fix some crashes on Luigi's Mansion 3 (on macOS). The Luigi's Mansion 3 crash would usually happen when entering the bathroom on Luigi's room for example.

Contributes to #4062.

@gdkchan gdkchan added gpu Related to Ryujinx.Graphics fix Fix something graphics-backend:vulkan Graphical bugs when using the Vulkan API os:macOS An issue or feature request exclusively relating to macOS labels May 28, 2023
@gdkchan gdkchan requested a review from marysaka May 28, 2023 00:55
@marysaka marysaka requested review from riperiperi and a team May 28, 2023 06:14
Copy link
Contributor

@marysaka marysaka left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@riperiperi riperiperi left a comment

Choose a reason for hiding this comment

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

That's sensible. Does this cause a validation error normally or is it just ignored?

@gdkchan
Copy link
Member Author

gdkchan commented May 28, 2023

That's sensible. Does this cause a validation error normally or is it just ignored?

Yes, it has this validation error:

Validation Error: [ VUID-vkCmdDrawIndexed-blendEnable-04727 ] Object 0: handle = 0x4c8e060000040ccd, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0x8a06751e | vkCmdDrawIndexed: Image view's format features of the color attachment (0) of the active subpass do not contain VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT bit, but active pipeline's pAttachments[0].blendEnable is not VK_FALSE. The Vulkan spec states: If rasterization is not disabled in the bound graphics pipeline, then for each color attachment in the subpass, if the corresponding image view's format features do not contain VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT, then the blendEnable member of the corresponding element of the pAttachments member of pColorBlendState must be VK_FALSE (https://vulkan.lunarg.com/doc/view/1.3.231.1/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-blendEnable-04727)

@gdkchan gdkchan mentioned this pull request May 28, 2023
16 tasks
@AcK77 AcK77 merged commit 832a5e8 into Ryujinx:master May 28, 2023
8 checks passed
@gdkchan gdkchan deleted the no-blend-integer branch May 28, 2023 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fix something gpu Related to Ryujinx.Graphics graphics-backend:vulkan Graphical bugs when using the Vulkan API os:macOS An issue or feature request exclusively relating to macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants