Vulkan: Godot randomly freezes when using triplanar UVs in material
Godot version
v4.0.beta14.official.28a24639c
System information
Windows10, Vulkan, RX5700XT, latest drivers(31.0.12029.10015)
Issue description
Whenver I use triplanar UVs in a material godot either freezes istantaneously or takes some time to freeze. In either case it freezes after showing this message in the console:(sometimes it spams a bunch of them)
ERROR: Condition "err" is true. Returning: ERR_CANT_CREATE at: swap_buffers (drivers/vulkan/vulkan_context.cpp:2299)
I tried my project on a macbook pro M1 and it never freezes. I also tried it on my brother PC, which also has a RX5700xt and has the exact same issue. Sadly I could not try with a Nvidia graphics card.
Steps to reproduce
Open the MRP(better with console to eventually kill the window if it freezes) and stay in the godot 3D view in the main scene. Godot might freeze istantaneously, usually resulting in a graphics drivers crash, requiring a reboot of the OS. In the best case, Godot will simply hang forever and you have to kill it by closing the console.
I tried with no other windows open except for godot and the crash still happens
Minimal reproduction project
I can't reproduce this on 4.0.beta 621e32971 (Linux, GeForce RTX 4090 with NVIDIA 525.60.11). This is likely a driver bug caused by an infinite loop in the shader (or similar).
Can you reproduce this in 3.5.1 when using a triplanar material there?
I tried on 3.5.1 but the crash never happens there.
The crashes on godot 4 happened since the early alphas all the way to now to beta 14
This sounds like it may be a duplicate of #69156 which will be fixed by #71581
Could you confirm whether #71581 fixes this issue as well?
Thanks clayjohn. I compiled godot on #71581 with your fix and tried working with triplanar materials but sadly it did not solve the issue.
I guess it might really be a driver issue like calinou pointed out since no one else reported similar crashes with triplanar materials.
Tested the example and no crash so far. Using AMD Radeon RX 480.
I also can't reproduce the crash on Windows 10 RX 6900 XT.
Is anything printed to the console when it freezes/crashes?
Nope. Other than what I wrote in the issue description there is nothing more. Here is a capture of the screen and the console.
I'm using triplanar UVs in another project and it's freezing randomly too. I guess is the same problem.
This is the project: https://github.com/rbarongr/GodotFirstPersonController
Using:
- v4.0.beta17.official [c40020513]
- Vulkan API 1.3.217 - Using Vulkan Device #0: AMD - AMD Radeon RX 5600 XT
- Windows 10
Can you reproduce this in any of the old 4.0 betas to determine when the regression started?
beta15 - no crash beta16 - starts crashing
Seems to me that this issue might be caused by https://github.com/godotengine/godot/pull/71581 since that is the only pull request that touched general texture/render pipeline handling in any generalized way.
I am skeptical that #71581 caused this issue as the original report was from beta 14 and the user says they have been facing the crash since the early alphas. Needless to say, the bug has been around long before #71581 was merged
After extensive testing it turns out that beta 15 crashes completely unpredictably as well. Not sure about which version this problem started on, seems to be persistent for most of the betas...
It would be nice if someone who has the issue tried to go back to beta 1 to see if it happens on it. (I fully understand that the testing will take some time)
Alpha 5 - No Crash so far. Alpha 10 - Crashed after 40 minutes. Alpha 11 - Crashed twice, but seems like these older versions took longer for it to happen for some reason? Still the same error however. Could be a fluke.
These versions also Crashed multiple times: Alpha 12, Beta 1, Beta 3, Beta 4, Beta 7, Beta 15 These versions crashed within the first 10 minutes, again, could just a fluke too.
The problem is that the error is random and inconsistent. Sometimes it crashes as soon as I press play, sometimes it takes several minutes. AFAIK Alpha 5 COULD have the issue too and it just didn't crashed because of its random nature?
It will be hard to pinpoint until we find a way to trigger the error consistently. But I'll keep testing it in the meantime.
Btw all of the crashes gave the same error mentioned by the op.
Update: After some testing, both Alpha 5, and Alpha 1 crashed too with the same error + driver timeout. Had to run the game for about an hour on each.
These are my specs as mentioned before on the other thread: Windows 11 | R5 3600 | RX 5600 XT Driver Version: 22.40.01.10-221213a-386778E-ISV-NDA-AMD-Software-Adrenalin-Edition
It may be worth using Shader Playground, reconstructing the triplanar sampling shader code from scene/resources/material.cpp then looking at the generated assembly using those options:

gfx1010, gfx1011 and gfx1012 are internal names for RDNA1 GPUs. For example, gfx1012 is a RX 5500 XT – I believe lower numbers are higher-end variants (similar to "Navi 10" being higher-end than "Navi 11"). You can find a more complete list of internal names here (press Escape before the page is done loading to avoid being redirected to docs.amd.com).
Problem seems to be gone in 4.1 dev 2
Problem seems to be gone in 4.1 dev 2
Tested for about 90 minutes here, no crashes yet.