Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad performance in spheric mirror distortion mode #3535

Closed
ImmersiveTheatres opened this issue Dec 6, 2023 · 112 comments · Fixed by #3954
Closed

Bad performance in spheric mirror distortion mode #3535

ImmersiveTheatres opened this issue Dec 6, 2023 · 112 comments · Fixed by #3954
Assignees
Labels
importance: high Obvious error, very annoying, but no crash
Milestone

Comments

@ImmersiveTheatres
Copy link

I have been asked to open a new issue with this request

I am not a coder. I am an astronomy teacher. I am asking this question (and other questions below) because I don't understand deep coding - and this is a forum to help Stellarium users.

I work with inflatable planetariums, and over the past 10 years I have used Stellarium as my main astronomy application. I use the spherical mirror projection mode, and I think Stellarium is awesome.

I only use MacBook Pros in my planetariums.

Last week I installed Stellarium v23.3 (Stellarium-23.3-qt6-macOS.zip) on a brand new MacBook Pro (Nov 2023) with M3 Pro chip, 18 GB memory, running macOS 14.1.2 (Sonoma).

Previously I was using Stellarium v19.3 on a MacBook Pro (2019) with 2.8 GHz Quad-Core Intel Core i7 chip, 16 GB memory, running macOS 10.15.7 (Catalina). The Stellarium motion of the sky (diurnal motion) on this old laptop is perfect, silky-smooth and absolutely beautiful.

Unfortunately, the motion of the sky on my new laptop is currently rough, juddery and sticky.

I am using the same config file settings as on my old laptop - yet changing these settings seems to make no difference to the quality of the motion:

[video]
dithering_mode = color888
fullscreen = true
maximum_fps = 50000
minimum_fps = 100
screen_h = 768
screen_number = 1
screen_w = 1024
screen_x = 237
screen_y = 85
tm_display_adaptation_luminance = 50
viewport_effect = sphericMirrorDistorter

Here is my log file after I launch Stellarium (without doing anything else). I wonder if anyone can please suggest something I can change, to make the motion of the sky work more smoothly?

I'm also wondering why the following error is so strong ie. is there something I can do about this error, or not? (if possible, an answer in non-technical language would be helpful please).

/Users/aw/stellarium/src/core/StelApp.cpp:915: OpenGL error: 1282 (GL_INVALID_OPERATION)

Here is the full config.ini I am using at the moment.

Thanks very much

Mario

@10110111
Copy link
Contributor

10110111 commented Dec 6, 2023

/Users/aw/stellarium/src/core/StelApp.cpp:915: OpenGL error: 1282 (GL_INVALID_OPERATION)

I can reproduce this when I turn on spheric mirror distortion. Something works badly there. But I don't reproduce the slowdown.

If you speed up time, does the animation look choppy, or is it only panning around that has this problem?

@gzotti gzotti added the importance: high Obvious error, very annoying, but no crash label Dec 6, 2023
@ImmersiveTheatres
Copy link
Author

Thanks for your reply. With my shows I don't do any panning around. I only speed up / slow down time. The more I speed up time, the more choppy the animation looks.

If it may help, here is the Log file of my smooth Stellarium v19.3 on MacBook Pro (2019) with 2.8 GHz Quad-Core Intel Core i7 chip, 16 GB memory, running macOS 10.15.7 (Catalina) - also operating with spherical mirror distortion.

@10110111
Copy link
Contributor

10110111 commented Dec 6, 2023

Did you try v19.3 on the new machine?

@ImmersiveTheatres
Copy link
Author

I haven't tried v19.3 on the new MacBook. I will do so now. Do you suggest I remove v23 - or can I keep both versions on the laptop?

@10110111
Copy link
Contributor

10110111 commented Dec 6, 2023

Do you suggest I remove v23 - or can I keep both versions on the laptop?

I have no idea about the macOS environment. To be on the safe side I'd remove the other version first.

@ImmersiveTheatres
Copy link
Author

OK great, I'll do so this afternoon and report back soon

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

You can keep both (or more) versions on the laptop - just change names of packages

@ImmersiveTheatres
Copy link
Author

Actually, v19.3 won't open on the new MacBook - I think because it's an Apple M3 chip (not Intel)?

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

Actually, v19.3 won't open on the new MacBook - I think because it's an Apple M3 chip (not Intel)?

Why not? Rosetta2 works ;)

@10110111
Copy link
Contributor

10110111 commented Dec 6, 2023

Rosetta2 works

Won't it lead to a performance hit, especially if the problem is in some CPU-bound computation?

@ImmersiveTheatres
Copy link
Author

I don't know - when I try and open v19.3 it crashes. You can see the crash log file here.

Is it maybe crashing because v23.3 is also on the system - or because it's not an Intel chip?

@10110111
Copy link
Contributor

10110111 commented Dec 6, 2023

Don't know about the crash, but this line makes me wonder:

OpenGL supported version: "2.1 Metal - 88"

What if you run v23.3 with --opengl-compat command line option?

@ImmersiveTheatres
Copy link
Author

OK I'd love to try, but I have no idea how to launch Stellarium with command line options.

If you could please explain how to do it step-by-step, I should be able to do it?

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

I don't know - when I try and open v19.3 it crashes. You can see the crash log file here.

Is it maybe crashing because v23.3 is also on the system - or because it's not an Intel chip?

Please delete file ~/Library/Application Support/Stellarium/data/ssystem_minor.ini before run v0.19.3 because newest version of file is not compatible with v0.19.3

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

Rosetta2 works

Won't it lead to a performance hit, especially if the problem is in some CPU-bound computation?

No performance hit, at least I don’t see it (maybe 1-2%)

@ImmersiveTheatres
Copy link
Author

OK cool, I deleted ssystem_minor.ini, and now v19.3 runs on the new MacBook - and daily motion is beautiful and smooth 😊✨

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

OK cool, I deleted ssystem_minor.ini, and now v19.3 runs on the new MacBook - and daily motion is beautiful and smooth 😊✨

Please check v0.22.2 and v0.21.3 also - https://github.com/Stellarium/stellarium/tags

@10110111
Copy link
Contributor

10110111 commented Dec 6, 2023

@alex-w how do we run Stellarium with a command line option?

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

@alex-w how do we run Stellarium with a command line option?

In Terminal.app: ./Stellarium.app/Contents/MacOS/stellarium --opengl-compat

@ImmersiveTheatres
Copy link
Author

ImmersiveTheatres commented Dec 6, 2023

Wow. OK, so this is the test result of daily motion on the new MacBook Pro M3:

  • v19.3 - super smooth
  • v21.3 - super smooth
  • v22.2 - super smooth
  • v23.3 - choppy

@ImmersiveTheatres
Copy link
Author

Shall I run that command in the Terminal app? Do I need to do anything before / after I run it?

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

Wow. OK, so this is the test result of daily motion on the new MacBook Pro M3:

  • v19.3 - super smooth
  • v21.3 - super smooth
  • v22.2 - super smooth
  • v23.3 - choppy

Probably v1.0 will be smooth and v1.1 will be choppy

@alex-w
Copy link
Member

alex-w commented Dec 6, 2023

Shall I run that command in the Terminal app? Do I need to do anything before / after I run it?

Go to directory where Stellarium is located within Terminal.app

@ImmersiveTheatres
Copy link
Author

OK, I ran the --opengl-compat command in Terminal from the directory where Stellarium v23.3 is located.

Terminal executed a lot of commands, and then Stellarium v23.3 launched automatically.

I tried daily motion - and it is still choppy 😐

@ImmersiveTheatres
Copy link
Author

ImmersiveTheatres commented Dec 7, 2023

I have now installed and tried more versions on the new M3 laptop.

This is the result:

SMOOTH

  • v1.0
  • v19.3
  • v21.3
  • v22.2

CHOPPY

  • v1.1
  • v1.2
  • v23.1_arm
  • v23.1
  • v23.2_arm
  • v23.2
  • v23.3

@ImmersiveTheatres
Copy link
Author

My problem is that I have now created a script for v23.3. The script is long and complex, but it runs perfectly in v23.3.

Unfortunately, the script does not run in v22.2 (the most recent version with smooth motion) 🫤

@gzotti
Copy link
Member

gzotti commented Dec 7, 2023

Where does it break? User Guide, Table 17.1 is crucial for compatibility between 0.22 and 1+ versions, but else? Maybe some functions were called slightly differently. The logfile or script GUI can help finding the unknown function. Or do you use some critical new addition?

@10110111
Copy link
Contributor

10110111 commented Dec 7, 2023

Please run v23.3 with --opengl-compat option and post the resulting log.txt. The switch from v1.0 to v1.1 added support for OpenGL 3.3 Core on macOS, which is what this option turns off.

@ImmersiveTheatres
Copy link
Author

OK I ran v23.3 with --opengl-compat. Daily motion is still choppy, and the log.txt is here

@gzotti
Copy link
Member

gzotti commented Oct 15, 2024

Phew! With the 4 changes applied to master, it becomes definitely more responsive. Regular fullscreen 140fps, distorted 14fps. (Was 3fps without.) Seems you are on the right track, but in 0.22.2 it was 32fps regular/25fps distorted. Are there more places like this?

@10110111
Copy link
Contributor

OK, I've looked at the whole process of the distortion rendering, and it appears to be totally inefficient. First, there is a constant set of vertex, texcoord, color arrays, which get rewritten from RAM to VRAM on every frame inside StelPainter::drawFromArray. Second, these arrays are split into max_y strips, which is 150 on my machine, resulting in the rewriting happening 150 times per frame.

The proper solution is to rewrite the distorter so that it maintains a custom VAO with this constant set of data and simply enables it to draw from in paintViewportBuffer without any copies happening.

@10110111 10110111 changed the title Bad Performance in Mac M3 Bad performance in spheric mirror distortion mode Oct 16, 2024
@gzotti gzotti removed os: macos Specific issues for macOS-family OS hw: arm Specific issues for ARM-devices labels Oct 16, 2024
@10110111 10110111 self-assigned this Oct 17, 2024
10110111 added a commit that referenced this issue Oct 17, 2024
The old version rewrote VBO about 150×3 times per frame, which is very
inefficient, especially given that the data written never change.
This version writes these constant data once in the constructor of the
distorter and uses them on rendering.

Fixes #3535
@gzotti gzotti added this to the 24.4 milestone Oct 17, 2024
@gzotti
Copy link
Member

gzotti commented Oct 17, 2024

@10110111's fix works great! Now, @ImmersiveTheatres could help the community by describing how to set up a projector system with a spherical mirror. What parameters to tweak in the config.ini, anything to take care when selecting a projector/lens/spherical mirror? One page in the User Guide should hopefully suffice. This was last described probably 20 years ago, but I have never seen these guides.

alex-w pushed a commit that referenced this issue Oct 18, 2024
The old version rewrote VBO about 150×3 times per frame, which is very
inefficient, especially given that the data written never change.
This version writes these constant data once in the constructor of the
distorter and uses them on rendering.

Fixes #3535
@ImmersiveTheatres
Copy link
Author

Wow, this sounds REALLY exciting. You guys have fixed the problem already? Amazing!

Yes, thank you, I would love to create a page for the User Guide on spherical mirror projection. I'll keep the information short and compact, with links for users who wish to learn more.

I'm busy over the next week, but will have time to compile this information next weekend (25-27 Oct) 👍🏻

@alex-w alex-w added the state: published The fix has been published for testing in weekly binary package label Oct 22, 2024
Copy link

Hello @ImmersiveTheatres!

Please check the fresh version (development snapshot) of Stellarium:
https://github.com/Stellarium/stellarium-data/releases/tag/weekly-snapshot

@ImmersiveTheatres
Copy link
Author

Please check the fresh version (development snapshot) of Stellarium: https://github.com/Stellarium/stellarium-
data/releases/tag/weekly-snapshot

FABULOUS! Diurnal motion and meteors are now as SMOOTH as SILK! Well done and thank you SO much for fixing the issue. You guys are awesome!

@ImmersiveTheatres
Copy link
Author

ImmersiveTheatres commented Oct 25, 2024

Now, @ImmersiveTheatres could help the community by describing how to set up a projector system with a spherical mirror. What parameters to tweak in the config.ini, anything to take care when selecting a projector/lens/spherical mirror? One page in the User Guide should hopefully suffice.

OK I've created a document called Stellarium and Spherical Mirror Projection. I've kept it as concise as possible, but it's two pages long. Yet it describes everything required to successfully create an inexpensive Stellarium-based planetarium.

Please let me know if you think it needs shortening (and which parts you think should be removed).

@10110111
Copy link
Contributor

@ImmersiveTheatres

Interesting, now I realize why someone (was it you?) requested that atmosphere could be disabled leaving star twinkling on. Indeed, a planetarium is closer to where you'd want to see the scene in real brightness scale, rather than the tone-mapped one we are showing. But as I see, you have a workaround.

I've noticed that your domes described in link 4 (which should be presented without a shortener, BTW) are actually faceted rather than smoothly curved. They may benefit from defining a custom distortion file, which is documented a bit here. Reading further comments there though, I'm not sure if the feature works as it should.

@gzotti
Copy link
Member

gzotti commented Oct 25, 2024

Thank you! I have not looked inside yet, but I'd like to just put the documentation as section (6.3?) into the User Guide. Of course, you will be acknowledged as section author. Is that OK with you?

@ImmersiveTheatres
Copy link
Author

Thank you! I have not looked inside yet, but I'd like to just put the documentation as section (6.3?) into the User Guide. Of course, you will be acknowledged as section author. Is that OK with you?

You're welcome, thank you for inviting me to write this. Yes, no problem using my name if you wish. If possible I'd prefer just 'immersive-theatres.com' - but if you need a personal name, feel free to use Mario Di Maggio.

@ImmersiveTheatres
Copy link
Author

ImmersiveTheatres commented Oct 26, 2024

Interesting, now I realize why someone (was it you?)

Yes that was me

I've noticed that your domes described in link 4 (which should be presented without a shortener, BTW) are actually faceted rather than smoothly curved.

Actually that's not my website or my domes (mine are here: https://immersive-theatres.com/about-us/dome-photos ) - but it's a good reference to use describing spherical mirror projection options.

They may benefit from defining a custom distortion file, which is documented a bit here. Reading further comments there though, I'm not sure if the feature works as it should.

Wow - I didn't realise Stellarium can accept the custom distortion file! I have one for my system, so I will experiment and try it out, thanks. I didn't mention the Meshmapper configuration option (https://paulbourke.net/dome/meshmapper), because it's a little complicated and most small dome operators don't carry it out. Maybe I'll try it out first with my custom distortion file and we can add it in in the future.

@gzotti
Copy link
Member

gzotti commented Oct 26, 2024

Gosh, yes, it's lost bits of info like this turning up here and there that need to go into the Guide!

@ImmersiveTheatres
Copy link
Author

I've created a second version and included a short description of the Meshmapper configuration.

Until we've tested that custom distortion files work correctly in Stellarium, perhaps it's best we don't give any more details for now.

@gzotti
Copy link
Member

gzotti commented Oct 30, 2024

I added your text and a final note that points to this thread. When we find out more about how this works, we may continue.

@trevorkjorlien
Copy link

Just want to chime in: THANK YOU!

The performance increase here is incredible with spheric mirror distortion. I can't believe how buttery-smooth it feels now. Thank you!

I will also test my custom distortion files and report back.

@ImmersiveTheatres
Copy link
Author

Do we know approx. when v24.4 will become publicly available? I want to share this brilliant improvement with the small planetarium community, but I'd prefer to do so with an official release 😊

@alex-w
Copy link
Member

alex-w commented Nov 15, 2024

Do we know approx. when v24.4 will become publicly available? I want to share this brilliant improvement with the small planetarium community, but I'd prefer to do so with an official release 😊

See https://github.com/Stellarium/stellarium/milestones ;)

@alex-w alex-w removed the state: published The fix has been published for testing in weekly binary package label Dec 22, 2024
Copy link

Hello @ImmersiveTheatres!

Please check the latest stable version of Stellarium:
https://github.com/Stellarium/stellarium/releases/latest

@ImmersiveTheatres
Copy link
Author

ImmersiveTheatres commented Jan 2, 2025

Hello @ImmersiveTheatres!

Please check the latest stable version of Stellarium: https://github.com/Stellarium/stellarium/releases/latest

Thank you, today I installed it and it's looking very good! Over the next few months I'll report back if I notice anything unusual during my school bookings.

Thank you again for fixing the diurnal motion. I informed another small planetarium operator today and he was delighted and rushed home to install the latest version of Stellarium 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
importance: high Obvious error, very annoying, but no crash
Development

Successfully merging a pull request may close this issue.

5 participants