On Intel GPU, wglGetProcAddress is being called a lot

My entire testcase:

#define _SILENCE_TR2_SYS_NAMESPACE_DEPRECATION_WARNING
#define _HAS_TR2_SYS_NAMESPACE 1
#include <cinder/app/App.h>
#include <cinder/app/RendererGl.h>

struct SApp : ci::app::App {
};

CINDER_APP(SApp, ci::app::RendererGl);

On my laptop, I have “switchable graphics” - Intel HD Graphics 620 and Geforce 940MX. I’m able to make the computer use whichever one I choose, per-executable.

When I use the GeForce for the testcase, all is fine (no wglGetProcAddress calls). But when I use the Intel, I get ~7k calls of wglGetProcAddress per second. At least that’s what NSight (Visual Studio edition) reports.

In my real app, the number is ~200k and is reported to take ~20% of the rendering time.

Is it possible that this is an intentional behavior of Cinder?

Btw, I’ve config’d NSight to start tracing 16 seconds after launch, and to trace for 3 seconds after that.

Hi,

wglGetProcAddress is used to get the memory address of an OpenGL function call. Typically, you’d store the function pointer and then use it over and over. It should not be necessary to call wglGetProcAddress more than once for each OpenGL function you use.

Cinder uses the “glload” library to retrieve and store the function pointers for later use. I guess maybe Cinder tries to obtain a function pointer but fails to retrieve it (maybe because it isn’tsupported by the driver), then tries again and again.

Could you find out which OpenGL function(s) it tries to retrieve? You could search the code for uses of wglGetProcAddress and then place a breakpoint there.

~Paul

1 Like

Thanks!

I set a breakpoint for the actual wglGetProcAddress function (and not to all its usages in Cinder), because that was simpler to do. If I keep that bpoint on during app launch, it does get hit (of course). But if I turn the bpoint on after app launch, it doesn’t get hit.

I suppose NSight is just buggy, then. What do you think?

I had a thought: Maybe somehow NSight records the wGPA calls even before it has started to “officially” trace. So I tried changing the app’s trace duration from 3 seconds to 9. Result: 69k wGPA calls. So that theory is out.

Ok, I think I figured it out. NSight simply doesn’t support non-NVidia GPUs.

Sources:
https://developer.nvidia.com/nsight-visual-studio-edition-supported-gpus-full-list

That also explains why CodeXL and RenderDoc didn’t show any calls to wGPA.

1 Like