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

switch to SDL3 #2052

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

switch to SDL3 #2052

wants to merge 10 commits into from

Conversation

rfomin
Copy link
Collaborator

@rfomin rfomin commented Nov 27, 2024

SDL3_Net doesn't have UDP broadcast mode, so we're still using SDL2_Net. It looks like we need to rewrite it.

@MrAlaux
Copy link
Collaborator

MrAlaux commented Nov 27, 2024

I was wondering if SDL3 would still run on my machine, so I tried the latest Win-64 artifact as of now, and I'm glad to say that it does run. Now, I'm aware that this is a draft at the moment, but I'd like to report that I'm getting much lower FPS on that build, and trying to increase the resolution scale made the game crash.

@fabiangreffrath
Copy link
Owner

Impessive effort, thank you! Did you use one of the semi-automated migration tools announced here or did you go through this line by line?

https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md

Regarding SDL2_Net, do we know of any other widely used network abstraction library? SMFL, or would that be too much of a change?

@rfomin
Copy link
Collaborator Author

rfomin commented Nov 27, 2024

I'd like to report that I'm getting much lower FPS on that build,

I added sdl_renderer_name config option in 8af9754. Try setting it to "direct3d" or "opengl". On my system SDL3 selects direct3d11 and I've got slitghly more FPS. Also, what is the output of "woof -verbose" on your system?

trying to increase the resolution scale made the game crash.

Should work with d409b3e

@fabiangreffrath
Copy link
Owner

Should work with d409b3e

Doesn't this introduce a memory leak?

@rfomin
Copy link
Collaborator Author

rfomin commented Nov 27, 2024

Did you use one of the semi-automated migration tools announced here or did you go through this line by line?

I used python scripts, they just rename functions/headers.

Regarding SDL2_Net, do we know of any other widely used network abstraction library? SMFL, or would that be too much of a change?

SMFL is too big, we can replace the whole SDL with it. SDL_Net is a small wrapper around BSD Sockets/WinSock, I think we should rewrite it (and for Choco/Crispy too).

Should work with d409b3e

Doesn't this introduce a memory leak?

Possibly. I guess we need to bring back memcpy.

@MrAlaux
Copy link
Collaborator

MrAlaux commented Nov 27, 2024

what is the output of "woof -verbose" on your system?

Without setting sdl_renderer_name:

WARNING: D3D12: Could not find d3d12.dll
SDL render driver: direct3d11

At least with D3D11, I can change resolution properly. I also tried changing widescreen, and noticed that it messes with the mouse in menus; the rects seem to become misaligned.

Performance comparisons, judging from some quick tests (640p, DRS and VSync off, otherwise default settings):

  • Non-exclusive fullscreen: D3D (~126 FPS) > OpenGL (~124) > D3D11 (~37)
  • Exclusive fullscreen: D3D (~162) > OpenGL (~124) > D3D11 (~37)

@rfomin
Copy link
Collaborator Author

rfomin commented Nov 27, 2024

Should work with d409b3e

Doesn't this introduce a memory leak?

Possibly. I guess we need to bring back memcpy.

Fixed in 090a8ca (I think)

D3D (~126 FPS) > OpenGL (~124) > D3D11 (~37)

Wow, D3D11 is very slow on your system for some reason. Does SDL2 work well in D3D11 mode?

@MrAlaux
Copy link
Collaborator

MrAlaux commented Nov 27, 2024

Wow, D3D11 is very slow on your system for some reason. Does SDL2 work well in D3D11 mode?

I tried D3D11 on the current Nugget master (I kept the sdl_renderdriver setting from an earlier Woof version), and it also performs badly.

Do note, however, that my laptop has both integrated and dedicated graphics, and it defaults to the former for Nugget; if I force using dedicated graphics, D3D11 starts out running at 60 FPS, but after a few seconds it suddenly lowers to ~15. Not sure what's going on there.

For comparison, D3D runs better with integrated graphics, but when using dedicated graphics there's no sudden decrease in performance like with D3D11, or at least it doesn't happen as quickly.

@rfomin
Copy link
Collaborator Author

rfomin commented Nov 27, 2024

if I force using dedicated graphics, D3D11 starts out running at 60 FPS, but after a few seconds it suddenly lowers to ~15.

Sounds like overheating, replace the cooler (I did it on my old laptop, it's easy to find).

Anyway, not much has changed in the SDL3 2D Render backend, it works the same. API improved with different VSync modes, SDL_SyncWindow(), SDL_GetFullscreenDisplayModes() etc.

@MrAlaux
Copy link
Collaborator

MrAlaux commented Nov 27, 2024

Sounds like overheating

According to Open Hardware Monitor, the CPU and GPU stay at around 60ºC and under 50ºC respectively (the TJ max for the CPU seems to be 90ºC). Toggling exclusive fullscreen in-game (which "restarts" the screen to some degree) repeats the process: smooth performance for a few seconds, then a slowdown. Knowing that said sudden slowdown certainly doesn't happen with other games, I'm pretty sure that there's something else going on.

@Pedro-Beirao
Copy link
Contributor

Is SDL3 stable yet? I havent seen anything adopt it

And what does it improve in woof?

@rfomin
Copy link
Collaborator Author

rfomin commented Nov 27, 2024

Is SDL3 stable yet? I havent seen anything adopt it

Based on my limited testing, it works pretty stable. They say that Valve is using it.

And what does it improve in woof?

Currently some code is mostly being removed, for example SDL3 introduces nanosecond timer/wait functions. There are also better video mode functions for adaptive VSync, exclusive full screen, etc.

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.

4 participants