Skip to content

[imgui] sdl3 bindings#42850

Merged
JavierMatosD merged 12 commits intomicrosoft:masterfrom
constcuriosity:imgui-sdl3-bindings
Feb 25, 2025
Merged

[imgui] sdl3 bindings#42850
JavierMatosD merged 12 commits intomicrosoft:masterfrom
constcuriosity:imgui-sdl3-bindings

Conversation

@constcuriosity
Copy link
Contributor

@constcuriosity constcuriosity commented Dec 22, 2024

Adds new sdl3-binding and sdl3-renderer-binding features to the imgui port.

Imgui already has backends implemented for sdl3. They just hadn't yet been exposed as options like the sdl2 backends were. This change mainly just copies the same operations that are done for sdl2 support, but swaps the 2 for a 3.

  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

@constcuriosity
Copy link
Contributor Author

@microsoft-github-policy-service agree

@constcuriosity constcuriosity marked this pull request as ready for review December 23, 2024 00:54
@constcuriosity constcuriosity changed the title Imgui sdl3 bindings [imgui] sdl3 bindings Dec 23, 2024
@Cheney-W Cheney-W added category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. labels Dec 23, 2024
@JavierMatosD
Copy link
Contributor

Hi @constcuriosity, thank you for the contribution. Unfortunately, all feature sets in ports should be side by side installable. This is implementing alternatives as features. See -> https://learn.microsoft.com/en-us/vcpkg/contributing/maintainer-guide#do-not-use-features-to-implement-alternatives

Currently, vcpkg install imgui[sdl2-binding,sdl3-binding] will not build.

Marking this vcpkg-team-review for a path forward.

@JavierMatosD JavierMatosD marked this pull request as draft December 23, 2024 17:26
@JavierMatosD JavierMatosD added the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Dec 23, 2024
@constcuriosity
Copy link
Contributor Author

Hi @JavierMatosD, thanks for taking a look at this pull request. I'll take a look at seeing if there's a way forward for these two features to compile together.

Do you know offhand if all of the directx version features are able to compile together? I'm just looking to extend the pattern that's already been established by the port.

@JavierMatosD
Copy link
Contributor

Hi @JavierMatosD, thanks for taking a look at this pull request. I'll take a look at seeing if there's a way forward for these two features to compile together.

I spoke with my coworkers and it seems that the SDL project currently calls 2.x "current". See -> https://www.libsdl.org/. We think SDL2 should remain the canonical one for now. We encourage you to create an overlay port with this added functionality for your own purposes. See -> https://learn.microsoft.com/vcpkg/concepts/overlay-ports

Do you know offhand if all of the directx version features are able to compile together? I'm just looking to extend the pattern that's already been established by the port.

These features were probably added erroneously.

I'm closing this PR for now. Please feel free to reopen the PR if you feel we are mistaken.

@constcuriosity
Copy link
Contributor Author

I spoke with my coworkers and it seems that the SDL project currently calls 2.x "current". See -> https://www.libsdl.org/. We think SDL2 should remain the canonical one for now. We encourage you to create an overlay port with this added functionality for your own purposes. See -> https://learn.microsoft.com/vcpkg/concepts/overlay-ports

SDL3 has hit API and ABI lock as listed at https://wiki.libsdl.org/SDL3/FrontPage as well as in the formation of the sdl3 port a bit ago #40867. While not official yet, projects are now encouraged to move towards adoption of SDL3.

@constcuriosity
Copy link
Contributor Author

While you can have a vcpkg.json file that includes both sdl2 and sdl3, you can't follow the usage lines for both of them in your own cmake files. Doing so will have the 2nd library inclusion complain about a difference between the INTERFACE_SDL_VERSION and the SDL_VERSION of the next to-be-included library. And this is what causes the sdl2-binding and sdl3-binding incompatibility. Those features request either sdl2 or sdl3 as dependencies, and turning on both features will attempt to enforce that both are included, which triggers the above error.

This feels like it breaks the spirit of Ports in the current baseline must be installable simultaneously, since while you can technically install both SDL2 and SDL3 simultaneously, you can't have both of them as a dependency. If that was possible, then these features would work fine together.

Practically though... I don't know when that'd really happen. I think the vast majority of projects would only ever use one or the other. And same would go for these features on the imgui port. I guess the workaround would be to remove the dependency on each of the features, and rely on the project author add the dependencies themselves, but that's counter to the goal of vcpkg.

So with the TL;DR "It's not the features' fault, it's SDL2 and SDL3 incompatibility", I'd like to request an exception to the "no mutually exclusive features" policy. Making an overlay port would certainly work but it introduces a continuous maintenance burden by forking a frequently updated port (the version was even bumped within the short lifetime of this PR), and I believe the likelihood of a project purposefully including both SDL versions and both features to be very small.

Thanks for your time.

@constcuriosity
Copy link
Contributor Author

@JavierMatosD Sorry to ping you directly but it doesn't look like I have permission to re-open the PR myself.

@Mengna-Li Mengna-Li reopened this Dec 26, 2024
@Cheney-W Cheney-W removed info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. labels Dec 27, 2024
@Agorath
Copy link
Contributor

Agorath commented Dec 29, 2024

This feels like it breaks the spirit of Ports in the current baseline must be installable simultaneously, since while you can technically install both SDL2 and SDL3 simultaneously, you can't have both of them as a dependency. If that was possible, then these features would work fine together.

Practically though... I don't know when that'd really happen. I think the vast majority of projects would only ever use one or the other. And same would go for these features on the imgui port. I guess the workaround would be to remove the dependency on each of the features, and rely on the project author add the dependencies themselves, but that's counter to the goal of vcpkg.

So with the TL;DR "It's not the features' fault, it's SDL2 and SDL3 incompatibility", I'd like to request an exception to the "no mutually exclusive features" policy. Making an overlay port would certainly work but it introduces a continuous maintenance burden by forking a frequently updated port (the version was even bumped within the short lifetime of this PR), and I believe the likelihood of a project purposefully including both SDL versions and both features to be very small.

Thanks for your time.

I want to voice my support for @constcuriosity's request for an exception to the abovementioned rule.
SDL3 is just about to become the stable version. If you look at SDL's GitHub repository, you will see that they already switched the main branch to SDL3 and moved SDL2 into a separate branch.
As SDL2 will undoubtedly continue to be used by many existing applications due to the complexity of completely switching from SDL2 to SDL3, not exposing both imgui backend APIs for SDL2/3 as features is, IMHO, not an option for the foreseeable future.
I'd also like to request an exception to the mentioned rule since SDL2 and SDL3 are not compatible with each other anyway, and it would make no sense to install both features simultaneously.

SDL2 and SDL3 are mutually exclusive ports. They're two versions of the same library with API differences. While the ports can be successfully installed alongside each other, you can't include both as dependencies. The SDL library has a version enforcement mechanism.

The best practice though is for vcpkg ports and features to always be installable alongside each other. But we can't do that because of above dependency conflicts. So this commit makes it so that if both the sdl2 and sdl3 features are enabled, the sdl2 ones are effecitvely ignored and a warning is logged to the user.
@constcuriosity
Copy link
Contributor Author

I've authored a compromise where the sdl2-binding, sdl3-binding, sdl2-renderer-binding, and sdl3-renderer-binding features can all be included as enabled features. When both SDL2 and SDL3 features are enabled, the SDL2 features are basically ignored and a warning is logged that says that the SDL2 dependency was not enforced.

So the ports and features now technically satisfy the maintainer guidelines, but I wouldn't say it adheres to the spirit of them. Nevertheless it continues with my statement about that including both SDL2 and SDL3 features is not expected and very much not desired behavior.

@constcuriosity constcuriosity marked this pull request as ready for review December 30, 2024 00:58
@MasterDrake
Copy link

So, what's the next move or general consensus of what to do?

@vicroms
Copy link
Member

vicroms commented Feb 25, 2025

@constcuriosity can you resolve the file conflicts and change the PR as ready for review.

@Cheney-W please test features and mark as reviewed when ready.

# Conflicts:
#	ports/imgui/vcpkg.json
#	versions/baseline.json
#	versions/i-/imgui.json
- Incremented port version imgui/vcpkg.json
- Updated baseline.json with updated port version
- Too master's version of imgui.json. Going to need to regenerate version.
@constcuriosity
Copy link
Contributor Author

Hey, sorry I've been radio silent. My main work caught up with me post my holiday break.

I've gotten latest on master and updated the versions. Otherwise the functionality of the CMAKE files has stayed the same.

@constcuriosity constcuriosity marked this pull request as ready for review February 25, 2025 08:09
@dg0yt
Copy link
Contributor

dg0yt commented Feb 25, 2025

We wait until SDL3 is officially released and then drop SDL2 for SDL3 in the imgui port as proposed above.
=> This would, from that point onwards, prevent users with legacy SDL2 applications from upgrading to newer imgui versions via vcpkg.

After discussing this with @vicroms, @ras0219-msft, @AugP, @BillyONeal we believe that this is the right approach. Please more this out of draft when SDL3 is officially released.

Reminder, sdl2 features are expected to be removed at this point.

@Agorath
Copy link
Contributor

Agorath commented Feb 25, 2025

Hi, sorry as well for my radio silence the last few weeks... Work work...
I was about to say that the changes of commit ee88b23 would have to be reversed and all references to SDL2 would have to be removed before continuing. 🤔

@constcuriosity
Copy link
Contributor Author

We wait until SDL3 is officially released and then drop SDL2 for SDL3 in the imgui port as proposed above.
=> This would, from that point onwards, prevent users with legacy SDL2 applications from upgrading to newer imgui versions via vcpkg.

After discussing this with @vicroms, @ras0219-msft, @AugP, @BillyONeal we believe that this is the right approach. Please more this out of draft when SDL3 is officially released.

Alright... That doesn't bother my side project because I'm starting fresh with sdl3 and haven't used sdl2 before, but what's the recourse for anyone that was using sdl2 before? Are they expected to maintain their own overlay port at that point? Just want it to be very explicit for anyone that needs to deal with the downstream wake.

Also, it looks like because I did a merge on some of the files instead of a complete stomp and edit, it's blocking the pull request completely. Is there a way to salvage the pull, steam roll everything, or is it just cleaner to make a fresh pull request? Not really a fan of losing the context of this thread though.

@constcuriosity constcuriosity marked this pull request as draft February 25, 2025 08:27
@dg0yt
Copy link
Contributor

dg0yt commented Feb 25, 2025

Also, it looks like because I did a merge on some of the files instead of a complete stomp and edit, it's blocking the pull request completely. Is there a way to salvage the pull, steam roll everything, or is it just cleaner to make a fresh pull request? Not really a fan of losing the context of this thread though.

The "Merging is blocked ... This branch must not contain merge commits" also appears on clean PRs ATM. I suggest to ignore it.

Since SDL2 and SDL3 can't coexist, and vcpkg is designed to support the combination of any and all ports and features, the SDL2 and SDL3 features can't exist at the same time. Now that SDL3 is official, the decision of vcpkg team is to remove the old SDL2 bindings to support these new SDL3 ones.
@constcuriosity constcuriosity marked this pull request as ready for review February 25, 2025 08:38
@Agorath
Copy link
Contributor

Agorath commented Feb 25, 2025

Alright... That doesn't bother my side project because I'm starting fresh with sdl3 and haven't used sdl2 before, but what's the recourse for anyone that was using sdl2 before? Are they expected to maintain their own overlay port at that point? Just want it to be very explicit for anyone that needs to deal with the downstream wake.

I'll work on a new vcpkg port for the new "sdl2-compat"-layer I mentioned above. I plan to create a pull request after the sdl2-compat port is approved and merged, which adds the sdl2 feature back to the imgui port via the sdl2-compat layer. This way, users with existing sdl2 projects should still be able to continue using recent versions of imgui.

@constcuriosity
Copy link
Contributor Author

Ok, latest changes remove the SDL2 feature bindings and replaces them with the SDL3 ones.

Copy link
Contributor

@Agorath Agorath left a comment

Choose a reason for hiding this comment

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

The changes look good to me.
The previous entries for SDL2 were replaced with SDL3.

@Cheney-W
Copy link
Contributor

New feature test passed with below triplets:

x86-windows
x64-windows
x64-windows-static

@JavierMatosD JavierMatosD merged commit 790b14a into microsoft:master Feb 25, 2025
18 checks passed
@MasterDrake
Copy link

Finally, big thanks to everyone!
can't wait to actually use sdl3 :D

pull bot pushed a commit to adamtajti/vcpkg that referenced this pull request Feb 25, 2025
@Cheney-W Cheney-W added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Feb 26, 2025
adamtajti pushed a commit to adamtajti/vcpkg that referenced this pull request Feb 27, 2025
adamtajti pushed a commit to adamtajti/vcpkg that referenced this pull request Feb 27, 2025
@dg0yt dg0yt mentioned this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants