Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Vulkan errors on Android related to compute shader

Discussion in 'Shaders' started by KayH, Sep 6, 2023.

  1. KayH

    KayH

    Joined:
    Jan 6, 2017
    Posts:
    107
    I started learning to write compute shaders recently and I had a working shader for my purpose (texture encoding/decoding), running on Android. Now I made some modifications and it stopped working on Android. Not just that, it results in the app not displaying anything anymore at all, even parts that don't use the compute shader, like a texture displaying the source I'm encoding.

    It does work in the editor on Windows and I'm not getting any warnings or errors for the shader code. There is some buggy behavior (graphical corruptions/noise after decoding) which I have to yet to figure out but it does display everything fine apart from that.

    Not sure what causes the problem on Android and I have problem finding explanations for the errors. The first one is right at the start:
    Error vulkan invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call

    But this one occurs even on an earlier version using my old compute shader, so it doesn't seem to be breaking anything necessarily. The other ones are all new though and unique to the version not displaying anything.

    This one I get after calling GetData on an RWStructuredBuffer:
    Error SwappyVk Failed to wait for fence -4


    The next one is some time (not immediately) after uploading data to a RWStructuredBuffer:
    Error SwappyVk Failed to vkQueueSubmit -4

    I get this twice in a row.*

    The next one doesn't seem to relate directly to any call to the compute shader but the last action was calling dispatch on some kernels (which are called for the first time here):
    Error vulkan dequeueBuffer failed: Function not implemented (-38)


    The last error I get after another dispatch on different kernels:
    Error SwappyVk Failed to wait for fence 2

    This is also twice in the row. These kernels were previously called without raising an error, before downloading data from the RWStructuredBuffer that gave the Failed to wait for fence -4 error above.

    After that execution stops entirely and no other logcat messages are received until I pause/unpause the device.

    *Rerunning the app the timing of the errors isn't consistent, but the order and the content of the errors is always the same.
     
    Last edited: Sep 6, 2023
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,845
    Hi!
    Please report a bug.

    For a workaround, you can try disabling optimized frame pacing.
     
  3. KayH

    KayH

    Joined:
    Jan 6, 2017
    Posts:
    107
    Thanks for the workaround but it turned out the problem was definitely caused by myself. It was an out of bound problem, the dimensions for the dispatch call were too large and I ended up writing to the buffer at indices larger than its size. That seems to have caused the GPU to crash entirely, unsurprisingly.

    I made the thread hoping for help to make sense of the error messages I listed. Meanwhile I found the problem by pin pointing the cause with consecutive edits. It turned out I was setting the dispatch call dimensions wrongly because I was reusing a variable for several different buffers and the last value adjustment happened in an #if UNITY_EDITOR block which of course wasn't processed on the Android build.