Re: [angleproject] Angle implementation not recognizing GPU and crashing when calling glGenTextures

259 views
Skip to first unread message
Message has been deleted

Jamie Madill

unread,
Feb 13, 2017, 10:14:44 AM2/13/17
to shinba...@gmail.com, angleproject
Hi,

Which function is failing? I didn't see from your message what the error was.

On Mon, Feb 13, 2017 at 10:11 AM, <shinba...@gmail.com> wrote:
Hi Guys! I am trying to implement Angle in a project so I can emulate OpenGL as DirectX.

I am getting no errors while initializing the environment, eglGetErrors() returns me 12288 which means EGL_SUCCESS.

So I am printing at the following order those informations: "Graphics!" eglGetError(), eglQueryString(m_eglDisplay, EGL_VENDOR), eglQueryString(m_eglDisplay, EGL_VERSION), eglQueryString(m_eglDisplay, EGL_CLIENT_APIS)))

And the default OpenGL environment prints, 
"Graphics!" glGetError(), glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_VERSION))):


I tried including d3dcompiler_47 that I compiled and the one in Windows10 system32 folder, also everything seems to be linked properly.
Other thing I've noticed is that the .exe don't requires to have d3dcompilre_47 in its folder, it can execute without it.

The code is written in C++, this is where the environment gets initialized.
void WIN32Window::internalCreateGLContext()
{
    m_eglDisplay
= eglGetDisplay(m_deviceContext);
   
if(m_eglDisplay == EGL_NO_DISPLAY)
        g_logger
.fatal("EGL not supported");

   
if(!eglInitialize(m_eglDisplay, &m_eglMajor, &m_eglMinor)) //NULL, NULL
        g_logger
.fatal("Unable to initialize EGL");

   
static int configList[] = {
#if OPENGL_ES==2
        EGL_RENDERABLE_TYPE
, EGL_OPENGL_ES2_BIT,
#else
        EGL_RENDERABLE_TYPE
, EGL_OPENGL_ES_BIT,
#endif
        EGL_RED_SIZE
, 4,
        EGL_GREEN_SIZE
, 4,
        EGL_BLUE_SIZE
, 4,
        EGL_ALPHA_SIZE
, 4,
        EGL_NONE
   
};

   
EGLint numConfig;

   
if(!eglGetConfigs(m_eglDisplay, NULL, 0, &numConfig))
        g_logger
.fatal("No valid GL configurations");

   
if(!eglChooseConfig(m_eglDisplay, configList, &m_eglConfig, 1, &numConfig))
        g_logger
.fatal("Failed to choose EGL config");

   
if(numConfig != 1)
        g_logger
.warning("Didn't got the exact EGL config");

       
if (!eglBindAPI(EGL_OPENGL_ES_API))
                g_logger
.fatal("Failed to bind API!");

   
EGLint contextAtrrList[] = {
#if OPENGL_ES==2
        EGL_CONTEXT_CLIENT_VERSION
, 2,
#else
        EGL_CONTEXT_CLIENT_VERSION
, 1,
#endif
        EGL_NONE
   
};

     m_eglContext
= eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAtrrList);
     
if (m_eglContext == EGL_NO_CONTEXT)
         g_logger
.fatal(stdext::format("Unable to create EGL context: %s", eglGetError()));

    m_eglSurface
= eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_window, NULL);
   
if(m_eglSurface == EGL_NO_SURFACE)
        g_logger
.fatal(stdext::format("Unable to create EGL surface: %s", eglGetError()));

   
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
       g_logger
.fatal("Unable to make current EGL context");
}


So, would anyone know why is this implementation not recognizing the GPU board and failing to execute its fuctions?

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

shinba...@gmail.com

unread,
Feb 13, 2017, 10:29:31 AM2/13/17
to angleproject, shinba...@gmail.com
Hey Jamie, thanks for answering.

glGenTextures is failing and crashing the program. 
 

Corentin Wallez

unread,
Feb 13, 2017, 10:32:45 AM2/13/17
to shinba...@gmail.com, angleproject
What Jamie meant is that the setup code you provided gives little information about what the root cause of the failure is.
  • Is this glGenTextures call the first GL call you do on ANGLE? If not, what other calls were before and worked?
  • What is the nature of the crash? Is it an null pointer exception because glGenTextures is NULL? Is it crashing inside ANGLE? Do you have a stack trace?
  • What parameters do you pass to glGenTextures, could it be possible that the array you give to ANGLE is too small?

On Mon, Feb 13, 2017 at 10:29 AM, <shinba...@gmail.com> wrote:
Hey Jamie, thanks for answering.

glGenTextures is failing and crashing the program. 
 

--

shinba...@gmail.com

unread,
Feb 13, 2017, 10:56:11 AM2/13/17
to angleproject, shinba...@gmail.com

Yes, glGenTextures is the first one called, because its called to load textures into the program.

Here is the call stack, its failing when creating the textures and there is the call to the function that calls the glGenTextures:


And here is the code of the function that does the call:
void Texture::createTexture()
{
   
glGenTextures(1, &m_id); //m_id = 0
   
assert(m_id != 0);
}

To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.

Corentin Wallez

unread,
Feb 13, 2017, 11:09:16 AM2/13/17
to shinba...@gmail.com, angleproject
This is weird, glGenTextures stays at the state-tracking layer of ANGLE and doesn't do any driver calls. Can you double-check your OpenGL function pointer loader, and that glGenTextures isn't NULL? (also that &m_id is valid). Otherwise I'm not sure, and you might want to compile ANGLE in Debug so you can have a more complete stack trace.

To unsubscribe from this group and stop receiving emails from it, send an email to angleproject+unsubscribe@googlegroups.com.

shinba...@gmail.com

unread,
Feb 13, 2017, 11:27:44 AM2/13/17
to angleproject, shinba...@gmail.com
I'm not sure how can I check the OpenGL function pointer loader.
The glGenTextures when I'm not debugging and I go to definition it popup the function at gl2.h, but when I am debugging it says: A definition for the symbol "glGenTextures" could not be located.
I'm also not sure if this answers your question because I don't know how to check if the pointer glGenTextures function is null.
If it's not enough, could u enlight me how to do the checks you need?

m_id is a global variable inside Texture class. So it is declared as 0 before the call to createTexture().

Corentin Wallez

unread,
Feb 13, 2017, 11:49:34 AM2/13/17
to shinba...@gmail.com, angleproject
You must use an OpenGL function pointer loader library like GLEW or GLAD in you project that loads the entrypoints from the driver or ANGLE. This library will either make glGenTextures a macro, or an extern function pointer variable defined in a header. The check would be glGenTextures == nullptr,  or &glGenTextures == nullptr.

To unsubscribe from this group and stop receiving emails from it, send an email to angleproject+unsubscribe@googlegroups.com.

Geoff Lang

unread,
Feb 13, 2017, 12:16:13 PM2/13/17
to cwa...@google.com, shinba...@gmail.com, angleproject
It's also possible that you are loading the GL entry point from the wrong dll (the windows opengl32.dll instead of ANGLE's libGLESv2.dll)

shinba...@gmail.com

unread,
Feb 13, 2017, 12:17:43 PM2/13/17
to angleproject, shinba...@gmail.com
I've updated the function with the code to check glGen~, it's looking like this now.
void Texture::createTexture()
{
       
if (&glGenTextures == nullptr || glGenTextures == nullptr) {
                std
::cout << "POINTER NULL" << std::endl;
               
return;

       
}

    glGenTextures
(1, &m_id); //m_id = 0

   
assert(m_id != 0); //BREAKING HERE
}


And it's breaking at assert now, so I looks like glGenTextures isn't NULL.

So, probably leaves us the last option. I have GLEW in this project, but it is not related to this implementation, but to the default graphics code and it's used like this:
GLenum err = glewInit();
       
if (err != GLEW_OK)
               
g_logger.fatal(stdext::format("Unable to init GLEW: %s", glewGetErrorString(err)));

       
// overwrite framebuffer API if needed
       
if (GLEW_EXT_framebuffer_object && !GLEW_ARB_framebuffer_object) {
               
glGenFramebuffers = glGenFramebuffersEXT;
               
glDeleteFramebuffers = glDeleteFramebuffersEXT;
               
glBindFramebuffer = glBindFramebufferEXT;
               
glFramebufferTexture2D = glFramebufferTexture2DEXT;
               
glCheckFramebufferStatus = glCheckFramebufferStatusEXT;
               
glGenerateMipmap = glGenerateMipmapEXT;
       
}


While at this same function the implementation only creates and assing the global variable "painterOGL2".

Should I add this code to the OPENGL_ES? Would it work as a entrypoint loading?

Geoff Lang

unread,
Feb 13, 2017, 12:22:28 PM2/13/17
to shinba...@gmail.com, angleproject
Ok, this is definitely an issue with GLEW.  GLEW does not support OpenGL ES and is loading the windows entry points instead of ANGLE's.  I recommend glad as a loading library but I haven't tested it with ANGLE myself.

Message has been deleted
Message has been deleted
Message has been deleted

Corentin Wallez

unread,
Feb 13, 2017, 12:53:22 PM2/13/17
to shinba...@gmail.com, angleproject
GLEW isn't maintained anymore, glad is the modern alternative and handles loading functions pointers for both OpenGL and OpenGL ES from an eglGetProcAddress function.

ANGLE only provide the eglGetProcAddress way of loading entry-points (just like all other GL drivers). To make the program swap (at startup time) between OpenGL  and OpenGL ES, you would provide either ANGLE's eglGetProcAddress or the driver's wglGetProcAddress.

On Mon, Feb 13, 2017 at 12:37 PM, <shinba...@gmail.com> wrote:
So how can identify that? Because both libraries are linked so the program can switch between OpenGL and OpenGL ES

shinba...@gmail.com

unread,
Feb 13, 2017, 12:53:30 PM2/13/17
to angleproject, cwa...@google.com, shinba...@gmail.com
Precisely! I've unlinked opengl32.lib and it's working now! Thanks ! God Bless you all! :D

Em segunda-feira, 13 de fevereiro de 2017 15:16:13 UTC-2, Geoff Lang escreveu:

Tristam MacDonald

unread,
Feb 14, 2017, 6:52:04 PM2/14/17
to shinba...@gmail.com, angleproject
Literally, you should be able to assert(glGenTextures != null);
Reply all
Reply to author
Forward
0 new messages