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

Add GDExtension compatibility methods #76577

Closed
wants to merge 1 commit into from

Conversation

RedworkDE
Copy link
Member

@RedworkDE RedworkDE commented Apr 29, 2023

Requires #76446. Split into many commit to make it possible to cherry pick only the relevant bits (assuming that #76446 gets backported). I will add a commit with compat bindings for #75779, if that becomes possible. looks like that's not happening (for now)


Compared to 4.0.2 this leaved one reported issue:

Validate extension JSON: API was removed: classes/AnimationTrackEditPlugin

Which was completely useless and intentionally removed.

Compared to 4.0.1 a whole bunch of additional issues appear, that are all the hash changes that can't have compat methods atm:

Validate extension JSON: Error: Hash mismatch for 'classes/AnimatedSprite2D/methods/play'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/AnimatedSprite3D/methods/play'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Animation/methods/compress'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/AnimationPlayer/methods/play'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/AudioStreamPlayer/methods/play'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/AudioStreamPlayer2D/methods/play'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/AudioStreamPlayer3D/methods/play'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/CanvasItem/methods/draw_set_transform'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Curve2D/methods/sample_baked'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Curve2D/methods/sample_baked_with_rotation'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Curve2D/methods/tessellate_even_length'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Curve3D/methods/sample_baked'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Curve3D/methods/sample_baked_with_rotation'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Curve3D/methods/tessellate_even_length'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/DisplayServer/methods/tts_speak'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Font/methods/find_variation'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/GridMap/methods/make_baked_meshes'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Image/methods/save_jpg_to_buffer'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Image/methods/save_webp_to_buffer'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Image/methods/bump_map_to_normal_map'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/PhysicsBody2D/methods/move_and_collide'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/PhysicsBody3D/methods/move_and_collide'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/PhysicsBody3D/methods/test_move'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/RandomNumberGenerator/methods/randfn'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/RenderingServer/methods/environment_set_ambient_light'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/RenderingServer/methods/canvas_item_set_canvas_group_mode'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/RenderingServer/methods/force_draw'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Window/methods/popup_centered_ratio'. This means that the function has changed and no compatibility function was provided.
Validate extension JSON: Error: Hash mismatch for 'classes/Window/methods/popup_centered_clamped'. This means that the function has changed and no compatibility function was provided.

And finally 4.0.0 has a few more changes where no compat code can be created:

Validate extension JSON: Error: Field 'classes/MenuBar/properties/start_index': type changed value in new API, from "bool" to "int".
Validate extension JSON: Error: Field 'native_structures/PhysicsServer3DExtensionMotionCollision': format changed value in new API, from "Vector3 position;Vector3 normal;Vector3 collider_velocity;real_t depth;int local_shape;ObjectID collider_id;RID collider;int collider_shape" to "Vector3 position;Vector3 normal;Vector3 collider_velocity;Vector3 collider_angular_velocity;real_t depth;int local_shape;ObjectID collider_id;RID collider;int collider_shape".
Validate extension JSON: Error: Field 'native_structures/PhysicsServer3DExtensionMotionResult': format changed value in new API, from "Vector3 travel;Vector3 remainder;real_t collision_safe_fraction;real_t collision_unsafe_fraction;PhysicsServer3DExtensionMotionCollision collisions[32];int collision_count" to "Vector3 travel;Vector3 remainder;real_t collision_depth;real_t collision_safe_fraction;real_t collision_unsafe_fraction;PhysicsServer3DExtensionMotionCollision collisions[32];int collision_count".

Additionally a bunch of virtual methods have changes between 4.0 and 4.1 but they are currently not validated.
Check misc/extension_api_validation/*.expected for up to date details.

@dsnopek
Copy link
Contributor

dsnopek commented May 1, 2023

Thanks, these look great!

I manually tested the compatibility function for RichTextLabel::push_list() and it worked perfectly. I didn't test any of the others, but skimming the code, it all looks good to me :-)

@RedworkDE RedworkDE force-pushed the gdextension-compat branch from ae95c8f to 7cb29cd Compare May 4, 2023 16:57
@dsnopek
Copy link
Contributor

dsnopek commented May 13, 2023

Discussed at the GDExtension meeting, and it looks good!

Otherwise this just needs to be rebased after PR #76446 is merged, and then the remaining commits squashed into one commit, and then we'll approve it!

@RedworkDE RedworkDE force-pushed the gdextension-compat branch from 7cb29cd to 670a801 Compare May 15, 2023 10:34
@RedworkDE RedworkDE marked this pull request as ready for review May 15, 2023 10:35
@RedworkDE RedworkDE requested review from a team as code owners May 15, 2023 10:35
@RedworkDE RedworkDE force-pushed the gdextension-compat branch from 670a801 to f0d8ac0 Compare May 15, 2023 12:16
@RedworkDE RedworkDE force-pushed the gdextension-compat branch from f0d8ac0 to 43e447b Compare May 15, 2023 18:32
@RedworkDE RedworkDE requested a review from a team as a code owner May 15, 2023 18:32
@RedworkDE
Copy link
Member Author

Added more of the same, 3 more PR with similar breaking changes have been merged since.

And #69988 has removed a whole bunch of APIs but I didn't do anything about that (also IIRC these apis were marked experimental before anyways)

@dsnopek dsnopek requested a review from a team May 15, 2023 19:01
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

The latest updates look good to me!

core/object/object.cpp Outdated Show resolved Hide resolved
@RedworkDE RedworkDE force-pushed the gdextension-compat branch 2 times, most recently from 886f675 to eaf8bc7 Compare May 24, 2023 21:42
@RedworkDE RedworkDE force-pushed the gdextension-compat branch from 205d7c5 to f806e07 Compare May 26, 2023 19:58
@fire
Copy link
Member

fire commented May 27, 2023

@TokageItLab Protected methods were made public, can we check the AnimationNode? Maybe they need to be private.

scene/animation/animation_tree.h Outdated Show resolved Hide resolved
@YuriSizov
Copy link
Contributor

Needs a rebase, by the way.

@RedworkDE RedworkDE force-pushed the gdextension-compat branch from f806e07 to 9d3c431 Compare May 27, 2023 18:21
@RedworkDE RedworkDE force-pushed the gdextension-compat branch from 9d3c431 to f4bced9 Compare June 5, 2023 13:33
@YuriSizov
Copy link
Contributor

2. I added a second commit that avoids polluting the headers with the compatibility methods, by allowing binds with an explicit this parameter ala bind_function for builtin classes. It is a separate commit for now, as I am not sure if the changes in method_bind.h (tho pretty straight forward) are worth it or if these changes should better be moved to a different PR.

This is something I'd like @reduz to sign off on, so I think moving this to a different PR makes sense.

@RedworkDE RedworkDE force-pushed the gdextension-compat branch from f4bced9 to 4be7a81 Compare June 7, 2023 08:53
@dsnopek
Copy link
Contributor

dsnopek commented Jun 7, 2023

Assuming we don't end up reverting PR #77410, we've now pretty completely broken compatibility with GDExtensions built for Godot 4.0, which makes these compatibility methods not very useful for Godot 4.1.

That said, this work in general is still very useful, as it helps figure out exactly how we're going to add these going forward! And I still really support the idea of using the compatibility method system ASAP, so that we can get some valuable practice with using it.

@YuriSizov
Copy link
Contributor

@dsnopek So what do you think we should do with this PR then? Reject it, but return to it post 4.1? Or merge anyway as a reference point?

@dsnopek
Copy link
Contributor

dsnopek commented Jun 7, 2023

So what do you think we should do with this PR then? Reject it, but return to it post 4.1? Or merge anyway as a reference point?

That's a good question.

Maybe leave it be for a little while as we watch how things turn out after #77410? But assuming that all turns out good, I'd personally probably lean towards "Reject it, but return to it post 4.1?" It doesn't really make sense to merge code that won't ever get used, and I'm sure we'll have no shortage of compatibility methods to add after 4.1 stable is out.

What do others think?

@YuriSizov YuriSizov modified the milestones: 4.1, 4.x Jun 12, 2023
@YuriSizov
Copy link
Contributor

I guess we can leave it be for now, so when we need to make a 4.1+ version, we have a starting point. I'll turn it into a draft for now.

@RedworkDE
Copy link
Member Author

Closing as there are probably enough compat methods in the engine so that this is no longer needed as reference.

@RedworkDE RedworkDE closed this Aug 26, 2023
@RedworkDE RedworkDE deleted the gdextension-compat branch August 26, 2023 11:54
@AThousandShips AThousandShips removed this from the 4.x milestone Aug 26, 2023
@YuriSizov
Copy link
Contributor

Indeed, but still thanks for work and for providing everyone with a framework!

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.

9 participants