Fix Vulkan validation errors #92
No reviewers
Labels
No labels
audio
bug
confirmed
cpu
critical
development
enhancement
gpu
graphics-backend:opengl
graphics-backend:vulkan
gui
help wanted
horizon/hle
i18n
infra
input
kernel
linux
macos
suggestion
windows
No assignees
2 participants
Notifications
Due date
No due date set.
Reference
projects/Ryubing!92
Loading…
Reference in a new issue
No description provided.
Delete branch "AsperTheDog/Ryubing:fix-validation-errors"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR fixes several validation errors caused by invalid Vulkan usage. These validation errors often end up invoking Undefined Behavior on the driver side, which can lead to artifacts or crashes which are driver specific and otherwise incredibly hard to track. I don't think it should have any impact on performance, but it would be good to test it with as many games as possible (maybe a bug in a game was fixed?).
Each commit fixes an error. I added to each a description with the validation error that was fixed and a small explanation on what was causing it and how I fixed it.
``` vkCmdBlitImage(): pRegions[0].dstOffsets[0].x is 0 and dstOffsets[1].x is 2 which exceed dstSubresource width extent (1). The VK_IMAGE_TYPE_2D VkImage was created with format VK_FORMAT_R8G8B8A8_SRGB and an extent of [width = 256, height = 512, depth = 1] mipLevel 8 is [width = 1, height = 2, depth = 1] The Vulkan spec states: For each element of pRegions, dstOffsets[0].x and dstOffsets[1].x must both be greater than or equal to 0 and less than or equal to the width of the specified dstSubresource of dstImage (https://docs.vulkan.org/spec/latest/chapters/copies.html#VUID-vkCmdBlitImage-dstOffset-00248) ``` Same shape as the prior TextureCopy.Copy clamp. The Switch texture cache hands views whose reported dimensions can exceed the underlying storage at the view's mip level, and vkCmdBlitImage rejects offsets that go past the actual destination mip extents. Fixed by passing the underlying TextureStorage's Info to TextureCopy.Blit and clamping each iteration's computed blit offsets to the storage mip's real dimensions, so well-formed views are unaffected and aliased views get Switch-like out-of-bounds clipping.d868d5d5f4a533996325