Huge difference in OpenGL performance in Linux vs macOS, same hardware

I am creating an OpenGL application. The only inconvenient thing it does with OpenGL is that it uses several (5 or more) fairly large (2000x2000 or more) textures. The rest is a pretty default modern OpenGL 3.3 product (FBO, VBO, IBO, VOA, shaders, etc.). Since these textures are so large and require some bit depth over 8 bits, I use the internal pixel format GL_R11F_G11F_B10F

to save memory (however, changing this to something simple doesn't help (see below)).

Now here's the thing: very precise code, works on Windows, Linux and macOS (I'm using SDL as my abstraction layer). The performance difference between Linux and macOS on the same hardware (my late 2011 MacBook Pro 13 ", Intel HD Graphics 3000 @ 1280x800), same compiler ( clang -O3 -mavx

), is huge. On macOS my cycle time is from 30ms down to 80ms.However, on Linux this is a staggering 1ms to 4ms.Again, the same laptop just rebooted in different OSs. it seems like the pixel shader / rasterization is the bottleneck (my shader is really quite complex).

I have to say that in the past I have had better time frames on macOS (13ms to 20ms). Therefore, after discovering this fact, I become very suspicious that Apple could "degrade" the graphics driver for Intel HD Graphics 3000 specifically through system updates to encourage customers to buy new products. I must say that I was thinking about buying a new laptop, but since I discovered this, I suddenly got disgusted.

Now the question is: what do you think might happen here? Buggy driver? Apple deliberately makes things slower? Is an unmanaged GLSL compiler included in the driver? Or maybe some bad practice in my OpenGL code in the application? Do drivers often have poor support for non-8-bit texture formats?

I just hate that the app is fantastic to use on Linux and not like it on macOS. Hardware can do better.


Some tests as requested by @BDL:

  • Reducing textures by 4x in each dimension (with 16x less memory, which gives us a texture of 500x500) does not affect frame time.
  • Using GL_RGB8 or GL_SRGB8 as internal format does not affect frame time.
  • Reducing the complexity of the shaders helps: I can get it up to 8ms when throwing away a lot of computation in the fragment shader.

I'll try the glsl shader optimizer tomorrow: https://github.com/aras-p/glsl-optimizer Hope this helps a little.

+3


source to share


2 answers


What method do you use to measure frame render times? In my experiments with the timing behavior of various OpenGL implementations, the Mesa / Intel HD drivers had a harder time explaining timing.

Intel HD Graphics Drivers for MacOS X is a completely different codebase (zero source overlap!) Written by a completely different development team (mainly Apple, AFAIK).

Keep in mind that OpenGL uses an asynchronous execution model and that there is no hard-and-fast specification for the exact timing of a buffer change call. On Linux, both AMD and NVidia OpenGL pretty much have a block …SwapBuffers

to V-Sync (if V-Sync is enabled). However, I found that the Mesa / Intel implementation treats it …SwapBuffers

as just another command in the queue, and the real block will only execute with the command queue filling up and a call that can ultimately only be executed after the buffer has been replaced (for example, flushing the back buffer).



To shorten the long story, I found the only reliable way to actually measure the render presentation of a frame1 times, by placing a call glClear

immediately after …SwapBuffers

(i.e. clearing for the next frame that appears in the next iteration) and measuring the time from the start of rendering until an unusually placed call will be made glClear

.

Net render times (no view part) are best measured with query objects.

+2


source


In general, it is difficult to understand the essence of these stack overflow problems, since we do not have access to your code, but here are a few things you can try:

  • Update your drivers to the latest version supported by the OS.
  • Open a graphical debugger and check buffer sizes, texture sizes, RAM usage, memory usage, etc.


It might be some sync issues that need to be sorted between OSX and Linux, you can also get the raw windows resource pointer from SDL and fix the problem that way.

-2


source







All Articles