How to use compute shaders on mobile unity?

5.6k views Asked by At

I have been studying compute shaders and tried to test it on mobile phone (android). But it is always throwing error.

Kernel 'CSMain' not found
UnityEngine.ComputeShader:FindKernel(String)

Compute shader has no code.

// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain

[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
}

Here is the compiled version:

**** Platform OpenGL ES 3:
Compiled code for kernel CSMain:
#version 310 es

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
void main()
{
    return;
}




**** Platform OpenGL ES 2:
  no variants for this platform (no compute support, or no kernels)

In the editor it works fine, but on android it seems to not work at all. Am I missing something?
EDIT:
Tested on BlueStacks
Project was created with URP
OpenGL 2.0 was removed

1

There are 1 answers

1
Raguel On BEST ANSWER

Apparently, compute shaders are not fully supported on all mobile devices and how it will work varies from phone to phone. Some android phones have partial support while others might have no support at all. I haven't tested on iPhones but phones like Samsung Galaxy S6 have partial support.