scp-fs2open / scp-fs2open/fs2open.github.com
HUD rendering tanks frame rate on M1 Mac
- Dominant language
- C++
- Stars
- 487
- Forks
- 184
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 44
Description
```
Initializing SDL video...
Initializing OpenGL graphics device at 1920x1080 with 32-bit color...
Requested SDL Pixel values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1, FSAA: 0
Requested SDL Pixel values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1, FSAA: 0
Could not create OpenGL Context: Failed creating OpenGL context at version requested
Requested SDL Pixel values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1, FSAA: 0
Could not create OpenGL Context: Failed creating OpenGL context at version requested
Requested SDL Pixel values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1, FSAA: 0
Could not create OpenGL Context: Failed creating OpenGL context at version requested
Requested SDL Pixel values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1, FSAA: 0
Could not create OpenGL Context: Failed creating OpenGL context at version requested
Requested SDL Pixel values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1, FSAA: 0
Actual SDL Video values = R: 8, G: 8, B: 8, depth: 32, stencil: 8, double-buffer: 1, FSAA: 0
OpenGL Vendor : Apple
OpenGL Renderer : Apple M1 Ultra
OpenGL Version : 4.1 Metal - 83
WARNING: Failed to find uniform 'clipEnabled'.
Max texture units: 2 (16)
Max client texture states: 2 (1)
Max elements vertices: 1048575
Max elements indices: 150000
Max texture size: 16384x16384
Max render buffer size: 16384x16384
Can use compressed textures: YES
Texture compression available: YES
Post-processing enabled: YES
Using trilinear texture filter.
OpenGL Shader Version: 4.10
Max uniform block size: 65536
Max uniform buffer bindings: 80
Uniform buffer byte offset alignment: 256
... OpenGL init is complete!
Initializing path renderer...
Checking graphics capabilities:
Persistent buffer mapping: Disabled
Checking mod required rendering features...
All required features are supported.
GRAPHICS: Initializing default colors...
```
I'm trying to get this running natively on a M1 Ultra Mac running Mac OS Ventura. I did get it working after hacking around the prebuilt libraries not being arm64, but I noticed that the frame rate is unexpectedly jerky even with all settings and resolution turned all the way down. By enabling the "-profile-frame-time" option it becomes clear that this is because more than 16 ms is spent on the HUD alone (and apparently around 6 on NanoVG):

By disabling the HUD the frame rate massively improves (probably full-speed without the profiling):

I further experimented with hacking out NanoVG, which had some benefit (without apparently affecting the HUD display?), but the major impact appears to come from rendering the HUD itself, which doesn't look like it should be expensive at all.
It seems most likely to me that it's somehow using OpenGL in a way that Apple's OpenGL -> Metal wrapper doesn't like. I'm not sure what that could be, however. Does anyone have any suggestions on how to get to the bottom of this?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.