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

Open
wants to merge 12 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@nikolas
Copy link
Contributor

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

@nikolas nikolas force-pushed the nikolas:sdl2 branch from 41c3401 to 1ffd64d Jan 23, 2019

@nielsmh

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

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.

@nikolas nikolas force-pushed the nikolas:sdl2 branch from 1ffd64d to 0a9d162 Jan 23, 2019

@LordAro LordAro added the wip label Jan 24, 2019

@nikolas nikolas force-pushed the nikolas:sdl2 branch 8 times, most recently from 4496b98 to 0a60edb Jan 24, 2019

@nikolas

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

commented Jan 27, 2019

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

@nikolas

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

commented Jan 27, 2019

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

@TrueBrain

This comment has been minimized.

Copy link
Member

commented Jan 27, 2019

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 nikolas:sdl2 branch 7 times, most recently from c3493e4 to 07dd81c Jan 27, 2019

@nikolas nikolas force-pushed the nikolas:sdl2 branch 2 times, most recently from ea749d0 to cf22438 Feb 5, 2019

Show resolved Hide resolved src/video/sdl_v.cpp Outdated

@nikolas nikolas force-pushed the nikolas:sdl2 branch 2 times, most recently from 3e08300 to 5c681af Apr 6, 2019

@LordAro

This comment has been minimized.

Copy link
Member

commented Apr 9, 2019

Just tried to run this on Linux:

 > ./bin/openttd
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  109
  Current serial number in output stream:  110

SDL1 (master) works fine

@nikolas nikolas force-pushed the nikolas:sdl2 branch from 5c681af to 45c80e9 Apr 9, 2019

@LordAro

This comment has been minimized.

Copy link
Member

commented Apr 9, 2019

Seems the above is due to my OpenGL being somewhat broken (it tends to happen when my Kernel/graphics driver is updated and I haven't updated yet)

But, would be nice if it could gracefully fallback like SDL1 (and other programs) do...

@LordAro

This comment has been minimized.

Copy link
Member

commented Apr 9, 2019

Yup, SDL "bug" - https://bugzilla.libsdl.org/show_bug.cgi?id=4527
Feel free to ignore the above.

@nikolas nikolas force-pushed the nikolas:sdl2 branch 4 times, most recently from f475398 to cc43c42 Apr 10, 2019

@nikolas nikolas force-pushed the nikolas:sdl2 branch 3 times, most recently from 396df6c to ce433a7 Apr 19, 2019

@nikolas nikolas force-pushed the nikolas:sdl2 branch 3 times, most recently from a978752 to dcba9ae Apr 29, 2019

@nikolas nikolas force-pushed the nikolas:sdl2 branch from dcba9ae to a8016ba May 7, 2019

@nikolas nikolas force-pushed the nikolas:sdl2 branch from a8016ba to 42a735f May 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.