Skip to content

Commit

Permalink
Fix divide by zero when recovering from missed draw (Vulkan), authore…
Browse files Browse the repository at this point in the history
…d by EmulationEnjoyer (#235)

Adds the fix for the crash in the opening cutscene of Baldo: The Sacred
Owls when using Vulkan, from ryujinx-mirror. The original discussion
about the fix can be found
[here.](ryujinx-mirror/ryujinx#52)

It's up to you if you want to merge this, it's one of the very few
improvements that ryujinx-mirror got that hasn't made it into your fork
yet. My opinion is that without a graphics expert on board, we can't
know the real cause of this divide-by-zero issue and will have to make
do with this patch to fix it. And I think we will have to do this many
times in the future for other games that suffer crashes at the moment as
well, at least going by current discussions in the #development section
of the discord.

I did not come up with this fix, all credit goes to
[EmulationEnjoyer](https://github.com/EmulationEnjoyer) for putting
Ryujinx through a debugger and discovering the cause of the crash.
  • Loading branch information
extherian authored Nov 14, 2024
1 parent 4cb5946 commit 5fccfb7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ public void BindVertexBuffer(VulkanRenderer gd, CommandBufferScoped cbs, uint bi
if (_handle != BufferHandle.Null)
{
// May need to restride the vertex buffer.

if (gd.NeedsVertexBufferAlignment(AttributeScalarAlignment, out int alignment) && (_stride % alignment) != 0)
//
// Fix divide by zero when recovering from missed draw (Oct. 16 2024)
// (fixes crash in 'Baldo: The Guardian Owls' opening cutscene)
if (gd.NeedsVertexBufferAlignment(AttributeScalarAlignment, out int alignment) && alignment != 0 && (_stride % alignment) != 0)
{
autoBuffer = gd.BufferManager.GetAlignedVertexBuffer(cbs, _handle, _offset, _size, _stride, alignment);

Expand Down

0 comments on commit 5fccfb7

Please sign in to comment.