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

[macOS / Windows] Add optional ANGLE support. #72475

Closed
wants to merge 1 commit into from

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Jan 31, 2023

A new version of #54914

Screenshot 2023-01-31 at 23 55 21

Screenshot_20230202_094624

Pre-build ANGLE libraries are required, build it from source or get from the CEF minimal distribution. Headers are included.


To test it with upstream ANGLE:

  • Build Godot with additional options:
    opengl_implementation=angle extra_suffix=angle
  • Copy libEGL.dylib and libGLESv2.dylib to the .app bundle Frameworks folder (macOS).
  • Copy libEGL.dll and libGLESv2.dll to the executable folder (Windows).

ANGLE platform type can be selected by running Godot with --angle-platform-type type command line argument.

  • On macOS, valid type values are: metal (default) and opengl.
  • On Windows, valid type values are: d3d11 (default), vulkan, and opengl.

@Riteo
Copy link
Contributor

Riteo commented Jan 31, 2023

Mh, I'm not sure, but this looks like this works with EGL? I'm not sure if ANGLE magic is changing things up. Couldn't this be based somehow on #68944? If there's no magic behind the scenes we could avoid having multiple EGL manager implementations floating around when the time comes.

I guess that, with that PR, there could be two derived EGL managers: EGLManagerMetalANGLE and EGLManagerANGLE, each one having a different platform string. That sounds a lot but it'd be just two dumb static methods returning a constant value per manager. Then the DisplayServer could attempt initializing either and there could be the fallbacking based on the result, I guess.

I also recall @clayjohn trying to do ANGLE stuff with my generic EGLManager driver, wonder what came from that.

I'm curious on what's possible and I'd be glad to help, but I know nothing about Apple developoment so I might be ignoring important stuff.

@bruvzg
Copy link
Member Author

bruvzg commented Feb 1, 2023

Mh, I'm not sure, but this looks like this works with EGL? I'm not sure if ANGLE magic is changing things up. Couldn't this be based somehow on #68944? If there's no magic behind the scenes we could avoid having multiple EGL manager implementations floating around when the time comes.

Apart for a few extra attributes for the display creation and two Objective-C lines which can be moved to the DisplayServer, it should be generic EGL, so I guess it can use the same GLManager. I'm not sure about GLAD (it does not support ANGLE platform extensions, but it's probably only a few enums), I'll check it out.

@bruvzg bruvzg changed the title [macOS] Add optional ANGLE or MetalANGLE support. [macOS] Add optional ANGLE support. Feb 1, 2023
@bruvzg bruvzg force-pushed the metal_angle_support branch 2 times, most recently from ec0892b to 48c5c4b Compare February 1, 2023 17:15
@bruvzg
Copy link
Member Author

bruvzg commented Feb 1, 2023

Couldn't this be based somehow on #68944?

Updated to use common EGL manager based on #68944 and GLAD (dylibs are no longer necessary to build Godot, only to run with GL renderer). Since it's using GLES not GL I have added a few extra virtual methods to the EGL manager to configure API type and arguments for display and context.

GL/GLES defines and includes will need a bit of cleanup, it's a mess right now.

@Riteo
Copy link
Contributor

Riteo commented Feb 1, 2023

@bruvzg

Updated to use common EGL manager based on #68944 and GLAD (dylibs are no longer necessary to build Godot, only to run with GL renderer).

Great!

Since it's using GLES not GL I have added a few extra virtual methods to the EGL manager to configure API type and arguments for display and context.

I saw the diff and those methods seem to make sense, great job! I'm glad that the driver's API is good enough even for this funky library.

GL/GLES defines and includes will need a bit of cleanup, it's a mess right now.

Yeah, I noticed that too. There's also some GLAD-related stuff that isn't confined in its own defines.

@bruvzg
Copy link
Member Author

bruvzg commented Feb 1, 2023

Added EGL_ANDROID_blob_cache caching to mitigate slow ANGLE shader conversion, now it starts instantly on the subsequent runs.

@clayjohn clayjohn modified the milestones: 4.x, 4.1 Feb 1, 2023
@bruvzg bruvzg changed the title [macOS] Add optional ANGLE support. [macOS / Windows] Add optional ANGLE support. Feb 2, 2023
@bruvzg bruvzg force-pushed the metal_angle_support branch 4 times, most recently from 07ffb81 to b2fa96d Compare February 2, 2023 08:03
…d EGL_ANDROID_blob_cache caching.

Co-authored-by: Riteo <riteo@posteo.net>
@bruvzg bruvzg marked this pull request as ready for review February 2, 2023 13:44
@bruvzg bruvzg requested review from a team as code owners February 2, 2023 13:44
@clayjohn
Copy link
Member

clayjohn commented Feb 2, 2023

As a note, our original plan for ANGLE was to utilize it as an optional driver (like how you will be able to select between Vulkan and D3D12). How difficult do you think it would be to make angle/non-angle selectable in the project settings instead of making it a compile time option?

godotengine/godot-proposals#4261

@bruvzg

This comment was marked as outdated.

@bruvzg

This comment was marked as outdated.

@bruvzg
Copy link
Member Author

bruvzg commented Feb 3, 2023

How difficult do you think it would be to make angle/non-angle selectable in the project settings instead of making it a compile time option?

Got it working on macOS, so it is possible. Need a lot of cleanup, and some extra work to make sure it is working on mobile and web, since these do no use GLAD. Also, I have not touched OpenXR stuff at all. But here's a draft branch:

https://github.com/bruvzg/godot/tree/angle%2B%2B

An --rendering-driver opengl3_angle / --rendering-driver opengl3 argument can be used to select ANGLE or native GL. It's currently not exposed to UI/project settings. Maybe it should use rendering_method = gl_native / gl_angle instead of renderer name?

@bruvzg
Copy link
Member Author

bruvzg commented Feb 8, 2023

Superseded by #72831

@bruvzg bruvzg closed this Feb 8, 2023
@akien-mga akien-mga modified the milestones: 4.1, 4.0 Feb 9, 2023
@bruvzg bruvzg deleted the metal_angle_support branch July 16, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants