Compute shader object can not find kernel, unity exception!

So the shader code is here: PathFinding.compute - Pastebin.com

And the script is here: Controller.cs - Pastebin.com

If I try to find the only kernel that I have, I get this:

Kernel 'CSMain' not found
UnityEngine.ComputeShader:FindKernel(String)
Controller:Start() (at Assets/Controller.cs:10)

and

UnityException: FindKernel failed
Controller.Start () (at Assets/Controller.cs:10)

If I try to Dispatch directly by index such as this:

shader.Dispatch(0, 1, 1, 1);

Then I receive this error:

Kernel index (0) out of range
UnityEngine.ComputeShader:smile:ispatch(Int32, Int32, Int32, Int32)

Bug report submitted already: https://fogbugz.unity3d.com/default.asp?889614_6t75kdr4bstq1f83

The fact that you can’t find a kernel usually means it didn’t compile correctly. Select your shader and you should see list of errors in inspector.
I see this for your shader (in Unity 5.5):

Shader error in 'NewComputeShader.compute': Program 'CSMain', error X4505: Sum of temp registers and indexable temp registers exceeds limit of 4096 (on d3d11)
5 Likes

Sorry for delayed response, I took the code to another PC in office and yes, this error suddenly popped up. I guess its my home PC’s driver issue. I did a lot of modifications to the shader later on, a bit painful it was and now it compiles and finds kernel anyway.
Nonetheless, if a shader is not successfully compiled, unity should throw some meaningful error messages upon FindKernel() sothat I can understand, what is going on. :frowning:

Do any of you guys use any tool to debug compute shaders apart from playing with debug buffers? Deving compute shader is so painful :(:frowning:

The error is from DirectX compiler. It is strange you can’t see it. Drivers shouldn’t matter. It should be HW independent. Maybe this is a Unity bug.

There are several shader debuggers. Mostly annotated assembly debugging. RenderDoc is integrated in Unity so that’s by far the easiest method. Popular alternatives are Visual Studio graphics debugger and NVidia NSight but you need standalone build for those and that gets old quickly. Don’t forget to use “#pragma enable_d3d11_debug_symbols”.
Btw. the shaders are heavily optimized and there’s currently no easy way how to disable optimizations.