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

Change #6173: Update SDL driver to use SDL 2.0 #7086

Merged
merged 1 commit into from
Sep 19, 2019
Merged

Conversation

nikolas
Copy link
Member

@nikolas nikolas commented Jan 23, 2019

This has been working well for me. Based on the documentation here: https://wiki.libsdl.org/MigrationGuide

Will require testing on different setups.

Here's the FPS window on both old and new SDL, rendering a whole map.

SDL 1.2:
2019-01-22-213340_1366x768_scrot

SDL 2.0:
2019-01-22-214647_1366x768_scrot

closes #7296

@nielsmh
Copy link
Contributor

nielsmh commented Jan 23, 2019

The number to pay attention to on those screenshots: Video output has decreased from 4 ms to 2 ms with the SDL 2 driver.
Not tested it myself.

@nikolas
Copy link
Member Author

nikolas commented Jan 23, 2019

Also worth mentioning is that this changes the SDL driver from software rendering to hardware rendering, which has to potential to cause problems since we're now relying on the user's graphics drivers.

I've seen this branch segfault when the program starts on an old Mac mini I have, running Linux and the nouveau DRI drivers. This computer can run OpenTTD with SDL 1.2 just fine, and obviously we don't want to introduce this regression.

So I'll need to implement a software rendering fallback using either SDL_CreateSoftwareRenderer() or SDL_CreateRenderer() with the SDL_RENDERER_SOFTWARE flag. I'm not sure exactly how to "fall back" to the software renderer, but I'm sure there's some examples around. I'll take a look.

@LordAro LordAro added the wip Work in progress. Feature branch that will require feedback during the development process label Jan 24, 2019
@nikolas nikolas force-pushed the sdl2 branch 8 times, most recently from 4496b98 to 0a60edb Compare January 26, 2019 23:47
@nikolas
Copy link
Member Author

nikolas commented Jan 26, 2019

Alright, I've gotten a chance to debug the issue on the Mac mini system I mentioned above. It's working fine with an update I just made to this branch: using a renderer created with the SDL_RENDERER_SOFTWARE flag instead of SDL_RENDERER_ACCELERATED. Unfortunately, just passing in 0 here and letting SDL choose doesn't fix the problem: seems to be a driver bug, which other people have run into with these nouveau drivers.

Anyways, we're not losing anything by using software rendering here, as that's how it currently works. Please test this branch, anyone who's able and willing, and let me know of any problems you see!

@glx22
Copy link
Contributor

glx22 commented Jan 27, 2019

Of course CI fails for linux because SDL2-dev is not installed

@nikolas
Copy link
Member Author

nikolas commented Jan 27, 2019

Hmm, I can't see the exact libsdl failure - though I'm not used to Azure.

I see a bunch of messages like "Unable to find image 'openttd/compile-farm-ci:linux-amd64-gcc-6' locally" here: https://github.com/OpenTTD/OpenTTD/pull/7086/checks?check_run_id=55198664

Anyways, this Dockerfile would need to be updated to include libsdl2-dev. I'll make a PR.
https://github.com/OpenTTD/CompileFarm/blob/master/base-linux/Dockerfile#L29

@glx22
Copy link
Contributor

glx22 commented Jan 27, 2019

It fails on configure, https://github.com/OpenTTD/CompileFarm/blob/master/base-linux/Dockerfile needs an udpate

nikolas added a commit to nikolas/CompileFarm that referenced this pull request Jan 27, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@TrueBrain
Copy link
Member

If you go to the Azure results, here: https://dev.azure.com/openttd/OpenTTD/_build/results?buildId=607
You can click a build that failed. Then you can click again on the step that failed. There you see: 2019-01-26T23:49:22.1701030Z configure: error: no video driver development files found. We have an open bug to make the reporting more verbose.

@nikolas nikolas force-pushed the sdl2 branch 7 times, most recently from c3493e4 to 07dd81c Compare February 2, 2019 23:10
@nikolas nikolas force-pushed the sdl2 branch 2 times, most recently from ea749d0 to cf22438 Compare February 7, 2019 00:38
@stormcone
Copy link
Contributor

I have the same problem as @Nik-mmzd in #7296.

At the first start after compilation the NewGRF scanning window appears and the progress bar goes up to 95% and before it closes the screen freezes. The game itself keeps running because I can hear the sounds from the title game. Just nothing happens on the screen.

After I close the game, at the following game starts the screen freezes immediately. The NewGRF scanning window appears, but the progress bar stops at 0%. The game still running in these cases as well.

My system is a Fedora 29 on a physical hardware.

Software versions:
OpenTTD: 9124b35 from your sdl2 branch
Kernel: 4.20.15-200.fc29.x86_64
SDL2: 2.0.9 (both of 32 and 64 bit versions)
NVIDIA Driver Version: 418.43

openttd -d driver=1:
dbg: [driver] Successfully loaded blitter '32bpp-anim'
dbg: [driver] SDL: using mode 1920x1054x32
dbg: [driver] SDL: using driver 'x11'
dbg: [driver] Successfully probed video driver 'sdl'
dbg: [driver] Successfully probed sound driver 'sdl'
dbg: [driver] Successfully probed music driver 'extmidi'
dbg: [driver] Successfully loaded blitter '32bpp-sse2-anim'
dbg: [driver] SDL: using mode 1920x1054x32
dbg: [driver] SDL: using threads
dbg: [driver] SDL: using mode 1920x1054x32
dbg: [driver] extmidi: set volume not implemented

@nikolas
Copy link
Member Author

nikolas commented Jul 19, 2019

@stormcone Good to hear it works with the Nouveau driver, but let me know when you're able to test this with the Nvidia proprietary driver again.

@stormcone
Copy link
Contributor

stormcone commented Jul 19, 2019

@nikolas Thank you. :)

I tried out your new commit with the disabled hardware acceleration and now the game starts normally. I can use the menu and start a new game. So looks like that commit solves the problem. :)

Edit: I mean with the NVIDIA driver.

@LordAro
Copy link
Member

LordAro commented Jul 20, 2019

Confirmed, now runs

@LordAro
Copy link
Member

LordAro commented Jul 20, 2019

Simulation rate is still consistently running at 1.02x (for me) but that's the same as SDL1, so I'm not too concerned about it

@nikolas nikolas force-pushed the sdl2 branch 2 times, most recently from d535ec5 to 8306506 Compare July 28, 2019 02:32
@Nik-mmzd
Copy link

I'm on nikolas/OpenTTD@8306506; linux; sdl 2.0.9
Found two bugs:

  1. Numpad Enter does not acts like Enter
  2. Arrow buttons do not move cursor but ctrl-right/left arrow moves cursor by a word

Also, thanks for fixed #7296

@Nik-mmzd
Copy link

Wow, it works, thanks

@nikolas
Copy link
Member Author

nikolas commented Aug 2, 2019

@nielsmh this is ready for another review, since known issues are now fixed. Just fyi.

Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there, I think :)

LordAro
LordAro previously approved these changes Sep 14, 2019
Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but it triggered my OCD :P

@nielsmh nielsmh merged commit 2d27e8e into OpenTTD:master Sep 19, 2019
douiwby pushed a commit to douiwby/OpenTTD that referenced this pull request Apr 16, 2020
archlinux-github pushed a commit to archlinux/aur that referenced this pull request Jul 27, 2022

Verified

This commit was signed with the committer’s verified signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't type non-latin symbols from keyboard in game on linux
8 participants
Contributor stormcone commented I have the same problem as @Nik-mmzd in #7296. At the first start after compilation the NewGRF scanning window appears and the progress bar goes up to 95% and before it closes the screen freezes. The game itself keeps running because I can hear the sounds from the title game. Just nothing happens on the screen. After I close the game, at the following game starts the screen freezes immediately. The NewGRF scanning window appears, but the progress bar stops at 0%. The game still running in these cases as well. My system is a Fedora 29 on a physical hardware. Software versions: OpenTTD: 9124b35 from your sdl2 branch Kernel: 4.20.15-200.fc29.x86_64 SDL2: 2.0.9 (both of 32 and 64 bit versions) NVIDIA Driver Version: 418.43 openttd -d driver=1: dbg: [driver] Successfully loaded blitter '32bpp-anim' dbg: [driver] SDL: using mode 1920x1054x32 dbg: [driver] SDL: using driver 'x11' dbg: [driver] Successfully probed video driver 'sdl' dbg: [driver] Successfully probed sound driver 'sdl' dbg: [driver] Successfully probed music driver 'extmidi' dbg: [driver] Successfully loaded blitter '32bpp-sse2-anim' dbg: [driver] SDL: using mode 1920x1054x32 dbg: [driver] SDL: using threads dbg: [driver] SDL: using mode 1920x1054x32 dbg: [driver] extmidi: set volume not implemented