Compute Shaders on Mobile platform

Hi,
I’m trying to run a simple test of compute shader on mobile (android),

#include "/Engine/Public/Platform.ush"
RWStructuredBuffer<int> Buff;
int Incr;
[numthreads(16, 1, 1)]
void MainComputeShader(uint3 ThreadId : SV_DispatchThreadID)
{
	int index = ThreadId.x;
	Buff[index] = Buff[index] + Incr;
}

However, the shader do not compile for OpoenGLES3_1, it seems that the RWStructuredBuffer isn’t supported by unreal because all the RWStructuredBuffer variables raise an undeclared error when I build to my android
EDIT: I testedRWStructuredBuffer<int> it does work nicely, but RWStructuedBuffer<float3> doesn’t. Basically all “struct types” do not work
For vulkan the shader compile fine, but the shader doesn’t write back into the Buffer, the Buffer doesn’t get changed after extraction

(I’ve tested the shader and it works fine when played on the editor)
Is there any way to make this compute shader work on android ?

Thanks

1 Like

since i tried using my StructuredBuffer in Vertex-Shader, this is not possible on Android OpenGL, even though this works on Android Vulkan. To work around this, i rather use Texture2D

(it gets written in a ComputeShader as SHADER_PARAMETER_UAV( RWTexture2D).

When reading from it in the Vertex or Pixel-Shader, it was curial to make the it a ShaderResourceView SHADER_PARAMETER_SRV( Texture2D, … ) and then use the .Load( uint3 uvw ) function in the shader.