practical-tools-for-simple-design icon indicating copy to clipboard operation
practical-tools-for-simple-design copied to clipboard

Some machine doesn't like singleton implementation

Open ntut-rick opened this issue 11 months ago • 0 comments

Problem

On macOS, some programs will experience significant performance hits when items on screen gets too many. According to this answer on Stack Overflow, using singletons with OpenGL uniform buffers prevents macOS's OpenGL to Metal wrapper to perform parallelization optimizations. For whatever reason this doesn't seem to happen on Windows or Linux OpenGL driver implementations (or Intel / AMD / Nvidia)

Fixing history

  • #162

Other Info

There are other resources such as Program and VertexArray that are still singletons. However, the difference is they are not updated every frame like UniformBuffer I don't know if changing those to normal class members will incur a performance penalty or not as I haven't properly configured profiling on a macOS machine. I'll leave them as is.

Originally posted by @NOOBDY in https://github.com/ntut-open-source-club/practical-tools-for-simple-design/pull/162#issue-2215733359

ntut-rick avatar Apr 03 '24 10:04 ntut-rick