-
-
Notifications
You must be signed in to change notification settings - Fork 98
Add support for aligned memory alloc/realloc/free in GDExtension #12336
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
Comments
In principle, this makes sense to me: if Godot has it, then godot-cpp should have it too. However, it doesn't look like these methods are actually used much in the engine. I see it in two files So, it would be good to get an idea of the intended usage of those functions from the core team: are they meant to be a general purpose thing used by any part of the engine? It looks like they were added ~10 months ago to support rendering in PR godotengine/godot#90993 In any case, if we do want to expose them to godot-cpp, we have two options:
Which one makes the most sense I think depends on the intended usage of those functions. I'd personally probably lean towards option nr 1?
With this approach, you'd add new function pointers to gdextension_interface.h and register implementations in gdextension_interface.cpp UPDATE: Ah, I see you posted PR godotengine/godot#105947 doing this :-) |
I agree that using the existing alloc methods would be best, but I dont think they support any kind of alignment so I don't see how that information would be communicated to them, unless you can pass it through the padding? Also if the aligned methods aren't using the same tracking as the standard methods, that seems more like an issue with the engine side implementation rather than the interface with extensions. I'd be willing to look at implementing that if you're patient enough to let me learn how. |
I'm not an expert in this area, but looking at the code, I think we could do the same thing in a custom |
Okay that makes sense. I could try implementing that instead since I haven't finished the godot-cpp side yet. |
I created a PR on the godot-cpp side that implements both an update to the extension interface (# 2 on your suggestions) as commented code, as well as a re-implementation of the engine's aligned managment using the existing interface methods (# 1 on your suggestions). If/when you decide which is the better implementation (if any is desirable at all), I can update this accordingly. |
Describe the project you are working on
A fluid simulation written in GDExtension that tries to make use of compiler vectorization for performance.
Describe the problem or limitation you are having in your project
The Memory class in Godot currently allows for managing aligned memory through the use of
alloc_aligned_static
, etc. However, these methods are not exposed to the GDExtension interface like the default ones.Describe the feature / enhancement and how it helps to overcome the problem or limitation
I propose GDExtensionInterface gains access to those methods. On the other side, godot-cpp would also need to be updated to add the other side of the interface as well.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
It's probably as simple as adding the new methods and implementing them similarly to how the existing non-aligned methods behave. I could probably implement it myself if I knew a little more about the internals of GDExtensionInterface. I think I have a handle on the godot-cpp side, but haven't found the actual implementation of that on the engine side.
If this enhancement will not be used often, can it be worked around with a few lines of script?
It's part of the extension interface so no scripting could tackle this.
Is there a reason why this should be core and not an add-on in the asset library?
I don't think you can modify the extension interface in an add-on.
The text was updated successfully, but these errors were encountered: