############Code Review##############
eglCurrentContext = eglGetCurrentContext();
if (eglCurrentContext == EGL_NO_CONTEXT)
{
FAIL( “YYYY EGL_NO_CONTEXT”);
}
ret = eglQueryContext(eglDisplay, eglCurrentContext, EGL_CONFIG_ID, &configID);
if (!ret)
{
FAIL( “eglQueryContext EGL_CONFIG_ID failed”);
}
LOG(“eglQueryContext configID : %d”, configID); // configId > 0 before Unity 2018.2, configID = 0 after Unity 2018.3 ???
############Code Review##############
why? I am going to collapse…
Did you try using eglGetError - EGL Reference Pages to understand what is happening?
Thanks for your reply.
I have tried to call eglGetError(), but there is no error message.
I checked the egl source code and found that it is allowed to return 0, but I am not clear why it was not 0 before Unity 2018.3。
switch (attribute) {
case EGL_CONFIG_ID:
/*
* From EGL_KHR_no_config_context:
*
* "Querying EGL_CONFIG_ID returns the ID of the EGLConfig with
* respect to which the context was created, or zero if created
* without respect to an EGLConfig."
*/
*value = c->Config ? c->Config->ConfigID : 0;
break;
What was changed in unity 2018.3? why c->Config is null?
Thanks for your reply again.
At present, I use eglQuerySurfece() instead of eglQueryContext() to get the CONFIG_ID。
/*will return correct configID*/
EGLBoolean ret = eglQuerySurface(eglDisplay, eglMainSurface, EGL_CONFIG_ID, &configID);
/*will return configID = 0 */
EGLBoolean ret = eglQueryContext(eglDisplay, eglShareContext, EGL_CONFIG_ID, &configID);
why eglQuerySurface() is OK?
The extension I linked says:
A context can be used with any EGLSurface that it is
with (subject to the restrictions discussed in the section on
address space). A context and surface are compatible if they were
created with respect to the same EGLDisplay, and if either of the
following sets of conditions apply:
- The context was created without an EGLConfig. Such contexts match
any valid EGLSurface.
Which in turn means that:
When a valid surface is created, it has to have a valid config.
When a context is created without a config, if will accept any valid surface.
So it’s totally fine to get the config from the surface.
Keep in mind, though, that the surface can be recreated during appliaction runtime.
I have the same issue.
I want to know why Unity 2018.3.X can’t get configID through eglQueryContext but Unity 2018.2.X could.
ret = eglQueryContext(eglDisplay, eglCurrentContext, EGL_CONFIG_ID, &configID);
Is there a bug in Unity 2018.3.X ?
As I mentioned earlier, I suppose this is because we started using the EGL_KHR_no_config_context (https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_no_config_context.txt) extension.