-2

I have a big problem in dealing with many task dispatches in GLES3. I use compute shader to do compute intensive works. Originally it was done with OpenCL and Cuda. The following code shows how my program works. The middle part is task dispatches. Dispatch can be dozens or hundreds of times. When the number of dispatch is small, it works correctly. If the number is large, after initial few dispatches, the rest is not working correctly. It looks like losing dispatches;

// initial context setup
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLContext context = eglCreateContext(dpy, cfg, EGL_NO_CONTEXT, context_attribs);
returnValue = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, context);

// many shader storage buffers are created here.

// the following dispatch will be done dozens or hundread times at once.
// furthermore it will be repeated.
glUseProgram(...) // choose program shader
glUniform1f(...); // set uniform parameters
glBindBufferBase(...) // set buffers
glDispatchCompute(....); // MANY DISPATCHES!

// get the final result value
glBindBuffer(GL_SHADER_STORAGE_BUFFER, mVALUE);
float *pOut = (float *) glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 2 * sizeof(float),
                                             GL_MAP_READ_BIT);
if (pOut != NULL) {
   for (int i = 0; i < 2; i++) {
         RESULTVALUE[i] = pOut[i];
   }
} else {
     msg += "NULL\n";
}


// release context
eglDestroyContext(dpy, context);
eglTerminate(dpy);

I added glFlush() or glFinish() every three dispatches to reduce queue overflowing. glFlush has no impact. After glFinish(), data cannot be retried from buffer objects. pOut becomes NULL.

Is there any method that can deal with large number of dispatches in GLES 3?

genpfault
  • 51,148
  • 11
  • 85
  • 139
underflow
  • 1
  • 1
  • I think I know the problem. Program is correct. I am testing on Android tablet. But when lots of computation is done on GPU, Android seems skipping dispatch jobs without terminating the process. So for large computation cannot be done on Android GPU. – underflow Aug 11 '23 at 21:52
  • Did you ever checked for errors after invoking `glDispatchCompute`? `GL_INVALID_VALUE` is generated if any of the groups is greater than or equal to the maximum work-group count. **Associated Gets:** `glGet` with argument `GL_MAX_COMPUTE_WORK_GROUP_COUNT`. – Erdal Küçük Aug 13 '23 at 03:20
  • It's not work group size issue as much bigger size has been done before the problem dispatch. I reduced the input image size and it worked perfectly. I am testing using Android tablet until I receive Orange PI SBC. I think Android ignores overworks. – underflow Aug 13 '23 at 03:45

0 Answers0