Skip to content

SDL3 Support #1915

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

Open
wants to merge 69 commits into
base: 9.0.0-dev
Choose a base branch
from
Open

SDL3 Support #1915

wants to merge 69 commits into from

Conversation

Fancy2209
Copy link

@Fancy2209 Fancy2209 commented Mar 6, 2025

Current work to get Lime working on SDL3

Fixes: #1848

@Fancy2209 Fancy2209 marked this pull request as draft March 6, 2025 23:41
@mcagabe19
Copy link

mcagabe19 commented Mar 8, 2025

the thing is sdl module needs to switched with sdl3 and vulkan implementation needed in lime and SDL android java codes needs to be updated too

@Fancy2209
Copy link
Author

the thing is sdl module needs to switched with sdl3 and vulkan implementation needed in lime and SDL android java codes needs to be updated too

I did update the module to SDL3.
SDL still supports OpenGL, no need for Vulkan.
I will update Android Java when I get this working on desktoo

@mcagabe19
Copy link

I did update the module to SDL3.

I meant to say SDL2 needs to be removed from the lime and fully switched with SDL3

@Fancy2209
Copy link
Author

Fancy2209 commented Mar 8, 2025

I did update the module to SDL3.

I meant to say SDL2 needs to be removed from the lime and fully switched with SDL3

It does not? I don't see why SDL2 shouldn't be an option.

tobil4sk and others added 11 commits March 10, 2025 01:17
A HxString is not guaranteed to be utf8 on hxcpp, so we need to use
hxs_utf8 to convert it otherwise it incorrectly displays any utf16
encoded string.

Unfortunately, hxs_utf8 doesn't give us the length of the utf8 string.
The best thing we can do is to tell harfbuzz it is null terminated. This
isn't perfect because technically hxcpp strings are allowed to contain
NULL, but it's better than all utf16 strings being broken.
This function wants the utf8 length, but text->length does not give
this. We can instead use -1 to tell harfbuzz to treat it as null-
terminating, which is the case with all hashlink strings anyway.
Fix utf8 conversions in hb_buffer_add_utf8
…to ios-deploy

Devices running iOS 16 and older don't support xcrun devicectl, but they should still work with ios-deploy.
…ble (paired) and wired (closes openfl#1918)

Consolidate fallback to ios-deploy when Xcode version < 16 and when xcrun devicectl doesn't find any devices
cl : Command line warning D9002 : ignoring unknown option '-std=c11'
…un devicectl includes iPadOS, so there's no need to check for that one separately
@EliteMasterEric
Copy link
Contributor

Interesting that the proposal is to have both available

Maybe the SDL2 can be available, and used by default, and deprecated later as Lime's SDL3 implementation is proven to be stable.

@Fancy2209
Copy link
Author

Fancy2209 commented Mar 10, 2025

Interesting that the proposal is to have both available

Maybe the SDL2 can be available, and used by default, and deprecated later as Lime's SDL3 implementation is proven to be stable.

It was mostly because mojoAL doesn't have a SDL3 version yet, and from what I was reading on the build files it's used for Audio on the Switch

@ACrazyTown
Copy link
Contributor

It'a also used instead of OpenAL Soft when static linking (due to licensing conflicts) I believe

tobil4sk and others added 8 commits March 11, 2025 01:19
Previously, the first for loop would reach the end of the characters, so
no further characters were read in the second loop. This meant that the
array remained filled with 0 values.
The array size is already determined by the first loop
If the text is invalid, then readNextChar returns -1 and does not
progress to the next character. This previously meant that we got stuck
and looped indefinitely.
…loop

Fix Font.getGlyphs returning zeros and looping
@Fancy2209
Copy link
Author

That was a lot of work, wew
Finally all targets pass Ci and now this is ready for proper reviewing and better testing

@Fancy2209 Fancy2209 marked this pull request as ready for review March 31, 2025 21:21
@Fancy2209 Fancy2209 changed the title WIP: SDL3 Support SDL3 Support Mar 31, 2025
Copy link
Contributor

@EliteMasterEric EliteMasterEric left a comment

Choose a reason for hiding this comment

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

We have been reviewing this pull request internally and have found no major issues so far, only a couple missing graphics (which should be trivially resolved on our end). Performance seems similar and it would be great to have the new features introduced once this is merged.

@Fancy2209
Copy link
Author

Fancy2209 commented Apr 8, 2025

We have been reviewing this pull request internally and have found no major issues so far, only a couple missing graphics (which should be trivially resolved on our end). Performance seems similar and it would be great to have the new features introduced once this is merged.

Good to know!

About missing graphics, I've had a few FileIO issues, but I thought I had (finally) fully fixed them, could you elaborate one what you mean? I just wanna make sure I didn't break something

@Kade-github
Copy link

Theres only one function in this PR that I needed to get, which was SDL_GetTicksNS(), which is similar to the function being exposed as "System::GetTimer();" I implemented this as "System::GetTimerNS();" but I am wondering of other SDL3 only features have yet to be exposed? Otherwise this PR looks good :D

@EliteMasterEric
Copy link
Contributor

We have been reviewing this pull request internally and have found no major issues so far, only a couple missing graphics (which should be trivially resolved on our end). Performance seems similar and it would be great to have the new features introduced once this is merged.

Good to know!

About missing graphics, I've had a few FileIO issues, but I thought I had (finally) fully fixed them, could you elaborate one what you mean? I just wanna make sure I didn't break something

After more testing I found that the missing graphic was related to how I was handling SDL timestamps, and resolving the issue fixed the graphic. There are no FileIO issues that I am aware of.

@Fancy2209
Copy link
Author

Fancy2209 commented Apr 9, 2025

Theres only one function in this PR that I needed to get, which was SDL_GetTicksNS(), which is similar to the function being exposed as "System::GetTimer();" I implemented this as "System::GetTimerNS();" but I am wondering of other SDL3 only features have yet to be exposed? Otherwise this PR looks good :D

Oh yeah definitely, I at the very least want to

  • expose SDL_GetTicksNS like y'all did on Funkin
  • Allow Windows to optionally support for transparent backgrounds (I already figured this one out just waiting on this to get merged before PRing it)
  • replace file dialogs with the SDL Dialog API when using SDL3
  • Expose SDL_GetSystemTheme

I also know SDL3 adds a camera API who would allow us to implement Camera support, same thing with the System Tray API.
I also need to check what we need to change for Clipboard to handle the fact it can get more than just text now.

The only thing currently exposed is that enabling high DPI should also work on windows now, the above is only my wishlist/to work on list after this one gets merged.

If you wanna see everything SDL3 adds this is a pretty good list, though I noticed it doesn't mention some things like SDL_WINDOW_TRANSPARENT
https://wiki.libsdl.org/SDL3/NewFeatures

@joshtynjala
Copy link
Member

I am wondering of other SDL3 only features have yet to be exposed

We've asked Fancy to wait on exposing any of SDL3's new features. To be clear, we definitely plan to take advantage of many of those new features in Lime and OpenFL because there are a lot of very nice things in SDL3. However, in terms of testing and review, it's much easier if we can focus on the upgrade with the same set of features that already existed in SDL2. After we merge this foundational SDL3 support, then we can start having fun with the new stuff.

@Kade-github
Copy link

Kade-github commented Apr 9, 2025

I am wondering of other SDL3 only features have yet to be exposed

To be clear, we definitely plan to take advantage of many of those new features in Lime and OpenFL because there are a lot of very nice things in SDL3.

Awesome! Can't wait :D

@EliteMasterEric
Copy link
Contributor

EliteMasterEric commented Apr 12, 2025

It will also be great to start seeing changes in OpenFL as well, such as replacing this line with the proper nanosecond timestamp call:

https://github.com/openfl/openfl/blob/782627b89de76ff6ca85c267f8e36e2e09e1dc92/src/openfl/display/FPS.hx#L54

(i.e. finally resolving #1569 )

@dimensionscape
Copy link
Member

dimensionscape commented Apr 12, 2025

It will also be great to start seeing changes in OpenFL as well, such as replacing this line with the proper nanosecond timestamp call:

https://github.com/openfl/openfl/blob/782627b89de76ff6ca85c267f8e36e2e09e1dc92/src/openfl/display/FPS.hx#L54

(i.e. finally resolving #1569 )

That line only affects the flash target... and does not actually solve anything. We also can't use anything from our native libraries in flash at all.

WIth that said, the main loop has been overhauled for exact preciseness with better support for vsync (and fallback for hardware that doesnt support vsync). Most of that work is about 95% complete and should make it's way into 8.3 over the coming months.

@KarimAkra
Copy link

KarimAkra commented Apr 12, 2025

I tried this on Android and image files (PNG atleast) decoding seems to have broke? I did some logging and ended up with the assumption that the lime::fread method on SDLSystem isn't working properly (although it's literally the same thing in SDL3 migration docs... could be an internal issue with SDL..? Tho i found nothing on SDL issues)
I might be wrong but if that is the source of the issue then any C++ target other than Windows should have Image decoding issues and anything that uses lime::fread would be broken on these platforms

@KarimAkra
Copy link

Also forgot to mention that trying to get displayMode is throwing a segfault for me on Android

@Fancy2209
Copy link
Author

Fancy2209 commented Apr 12, 2025

Tho i found nothing on SDL issues) I might be wrong but if that is the source of the issue then any C++ target other than Windows should have Image decoding issues and anything that uses lime::fread would be broken on these platforms

I know it isn't because this whole PR was made on Linux... Very weird Android is broken

@gepatto
Copy link
Contributor

gepatto commented Apr 12, 2025

Just chiming in.
I've tested on a Raspberry Pi.
And it works with some adjustments to the build.xml
I have been working with a default sdl3-config file that one gets when compiling sdl3 with default settings.
It's a bit different from custom linux sdl3 config in this lime branch so I'm using a separate file for the Raspberry Pi.

@dimensionscape
Copy link
Member

Just chiming in. I've tested on a Raspberry Pi. And it works with some adjustments to the build.xml I have been working with a default sdl3-config file that one gets when compiling sdl3 with default settings. It's a bit different from custom linux sdl3 config in this lime branch so I'm using a separate file for the Raspberry Pi.

Yay this is really important. I'm glad you chimed in I was just wondering how well this worked on Pi.

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.

10 participants