sydd sydd - 3 months ago 20
Android Question

Get maximum workgroup size for compute shaders?

I am writing an OpenGL ES 3.1 program and want to know the maximum workgroup size for the device I'm running on (its running on Android 6).

For PC querying

GL_MAX_COMPUTE_WORK_GROUP_COUNT
and
GL_MAX_COMPUTE_WORK_GROUP_SIZE
works fine, but I cant seem to do the equivalent for on Android, I get
OpenGL error: InvalidEnum
when I try something like

OpenTK code:

int[] work_grp_cnt = new int[3];
GL.GetInteger(All.MaxComputeWorkGroupCount, work_grp_cnt);


Same with native Android APIs:

int[] work_grp_cnt = new int[3];
IntBuffer maxCount = IntBuffer.Allocate(3);
GLES20.GlGetIntegerv(GLES31.GlMaxComputeWorkGroupCount, maxCount);
maxCount.Get(work_grp_cnt);


(in both cases the GLGetInteger raises the same InvalidEnum error)
Is this possible with OpenGL ES 3.1?

I am using a Sony Xperia Z5

Answer

In C, you must call glGetIntegeri_v, which takes an index. For GL_MAX_COMPUTE_WORK_GROUP_COUNT, the index is the dimension you want to query. It only returns one value at a time.

You will need to find and use the Java-equivalent of this function.