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?