ntut-open-source-club/practical-tools-for-simple-design

Some machine doesn't like singleton implementation

Open

#168 opened on Apr 3, 2024

 (0 comments) (0 reactions) (0 assignees)C++ (27 forks)auto 404
help wantedoptimization

Repository metrics

Stars
 (27 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Contributor guide