godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.83k stars 21.13k forks source link

`vkCmdCopyImageToBuffer` called with zero image extent on Godot XR template #98242

Open PixelyIon opened 2 weeks ago

PixelyIon commented 2 weeks ago

Tested versions

System information

Vulkan 1.3.296 - Forward Mobile - Using Device #0: Qualcomm - Turnip Adreno (TM) 750

Issue description

Godot when launched with the XR template having no modifications, ends up calling vkCmdCopyImageToBuffer with one of the VkBufferImageCopys having an imageExtent.width of 0 (height/depth are both 1) which breaks VUID-VkBufferImageCopy-imageExtent-06659 ("imageExtent.width must not be 0"). These problematic copies should be dropped on the Godot's end since as far as VK drivers are concerned, this is UB.

Additional Context: I'm a developer of Mesa3D Turnip (FOSS VK driver for QCOM Adreno GPUs), breaking the VK specification causes a crash on our driver and since this is an application bug it isn't something we would fix.

Steps to reproduce

  1. Download Godot XR Template v4.1.0 from Asset Store.
  2. Load it up.

Minimal reproduction project (MRP)

Godot XR Template v4.1.0

felipejfc commented 3 days ago

I think this was due to the recent update to vulkan 296 in the build pipelines in this commit: https://github.com/godotengine/godot/commit/74df6f192a5d123d291a90519805fd340282b97b

Vulkan is now pulling .296 instead of .290 which I believe had all working properly. We identified this same problem in all iphone X family (X, XS, XR) in our recent builds and that's y we started investigating. Try using the 1.3.290.0 version from here https://vulkan.lunarg.com/sdk/home

PixelyIon commented 3 days ago

An SDK version difference won't cause this, it's just due to Godot not dropping copies with an effective size of zero pixels within their Vulkan backend.

felipejfc commented 2 days ago

Maybe not causing this specific issue, however we saw similar problems that caused corrupted buffers when using this same VK version you're using and solved it with a rollback to 1.3.290

PixelyIon commented 2 days ago

Not sure what the root cause for that issue would be, it could be related given you're on MacOS since MoltenVK ships with the Vulkan SDK to my knowledge? It could handle this case differently depending on the version. It's worth noting however that the failure I'm seeing is on Linux, with a native VK driver (Mesa3D Turnip) that is separate from the Vulkan SDK.

felipejfc commented 1 day ago

Yeah it's definitely caused by MoltenVK. And you're right. I should probably open another issue for this problem