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

Fix Vulkan crash with TextureChange::Modified #155

Merged

Conversation

patowen
Copy link
Contributor

@patowen patowen commented May 5, 2024

The TextureChange::Removed and TextureChange::Modified match arms in YakuiVulkan::update_textures both have logic to remove a texture, but the logic is inconsistent between the two arms. This PR changes the TextureChange::Modified branch to be consistent with TextureChange::Removed.

This change also fixes a crash I experienced when trying to change UI text based on in-game information on a game that has a graphics pipeline depth (simultaneous frames in flight) of 2. The following Vulkan validation error appeared during this crash:
Validation Error: [ VUID-vkDestroyImage-image-01000 ] | MessageID = 0xf2d29b5a | vkDestroyImage(): can't be called on VkImage 0xe3343f000000028f[] that is currently in use by VkCommandBuffer 0x20919128700[frame]. The Vulkan spec states: All submitted commands that refer to image, either directly or via a VkImageView, must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyImage-image-01000) id=VUID-vkDestroyImage-image-01000 number=-221078694 queue_labels= cmd_labels= objects=
Setting a breakpoint on the validation error did point me to the TextureChange::Modified match arm.

I am still relatively inexperienced in Vulkan, so I'm not certain this fix is correct nor would I be confident in setting up some kind of test case to be able to reproduce the issue in this repo itself. For extra context, I encountered this issue in Ralith/hypermine#391.

@patowen patowen requested review from Ralith and kanerogers as code owners May 5, 2024 23:14
@kanerogers
Copy link
Collaborator

Thanks for another fantastic PR - well documented and great explanations.

@Ralith I'll defer sync stuff to you as it's not my strong suit, but happy to take a look myself if you're time poor.

@patowen
Copy link
Contributor Author

patowen commented May 5, 2024

Thanks for the kind words!

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

This change makes sense to me. The prior code calls VulkanTexture::cleanup directly upon yakui's TexterChange::Modified, which frees the associated Vulkan resources immediately. The new code instead queues the texture for deferred cleanup, just like removal. In both cases this is required because the texture might still be in use by a previously submitted transfer or draw. I'm surprised we haven't noticed this before!

@Ralith Ralith merged commit 21dc69a into SecondHalfGames:main May 6, 2024
2 checks passed
@patowen patowen deleted the vulkan-texturechange-modified-crash branch May 6, 2024 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants