virtualx-engine/modules
Ignacio Roldán Etcheverry 3f645f980c C#: Optimize Variant conversion callbacks
These callbacks are used for marshaling by callables and generic Godot
collections.

C# generics don't support specialization the way C++ templates do.
I knew NativeAOT could optimize away many type checks when the types
are known at compile time, but I didn't trust the JIT would do as good
a job, so I initially went with cached function pointers.

Well, it turns out the JIT is also very good at optimizing in this
scenario, so I'm changing the methods to do the conversion directly,
rather than returning a function pointer for the conversion.

The methods were moved to `VariantUtils`, and were renamed from
`GetFromVariantCallback/GetToVariantCallback` to `ConvertTo/CreateFrom`.

The new implementation looks like it goes through many `if` checks
at runtime to find the right branch for the type, but in practice it
works pretty much like template specialization. The JIT only generates
code for the relevant branch. Together with inlining, the result is
very close or the same as doing the conversion manually:

```cs
godot_variant variant;

int foo = variant.Int;
int bar = VariantUtils.ConvertTo<int>(variant);
```

If the type is a generic Godot collection, the conversion still goes
through a function pointer call.

The new code happens to be much shorter as well, with the file going
from 1057 lines to 407.

Side note: `Variant.cs` was mistakenly created in the wrong folder,
so I moved it to the `Core` folder.
2022-11-25 03:14:10 +01:00
..
basis_universal Make some Image methods static 2022-10-14 14:34:15 +02:00
bmp Make some Image methods static 2022-10-14 14:34:15 +02:00
camera Make some Image methods static 2022-10-14 14:34:15 +02:00
csg Document collision_priority in the CSGShape3D class 2022-10-24 18:44:30 +02:00
cvtt Make some Image methods static 2022-10-14 14:34:15 +02:00
dds
denoise Make some Image methods static 2022-10-14 14:34:15 +02:00
enet [MP] Remove connection state signals from MultiplayerPeer. 2022-11-02 15:17:23 +01:00
etcpak Make some Image methods static 2022-10-14 14:34:15 +02:00
freetype SCons: Unify tools/target build type configuration 2022-09-26 16:31:46 +02:00
gdscript Merge pull request #69134 from jquinl/export_range_int_fix 2022-11-24 23:30:40 +01:00
glslang vulkan: Update all components to Vulkan SDK 1.3.231.1 2022-11-03 12:20:46 +01:00
gltf Merge pull request #69083 from fire/abstract_gltf_material 2022-11-24 18:54:25 +01:00
gridmap Cleanup remaining EditorUndoRedoManager usages 2022-11-24 18:56:22 +01:00
hdr Make some Image methods static 2022-10-14 14:34:15 +02:00
jpg Merge pull request #66929 from MladoniSzabi/save_jpeg_file 2022-10-31 10:48:10 +01:00
jsonrpc
lightmapper_rd Add optional UV2 logic for lightmapping to primitive shapes 2022-11-13 19:28:10 +11:00
mbedtls Code simplifications found by cppcheck 2022-11-21 08:43:36 +01:00
meshoptimizer
minimp3 Change time parameters and variables to double type 2022-09-26 13:52:54 -05:00
mobile_vr Style: Misc docs and comment style and language fixes 2022-11-02 19:01:18 +01:00
mono C#: Optimize Variant conversion callbacks 2022-11-25 03:14:10 +01:00
msdfgen
multiplayer Merge pull request #68689 from Faless/mp/4.x_offline_is_server 2022-11-20 15:37:26 +01:00
navigation Remove redundant Variant-types initializations 2022-11-14 19:35:19 +01:00
noise Use forward-declarations in EditorPlugin where possible 2022-11-11 20:25:51 +01:00
ogg Change Array arguments to TypedArray 2022-09-01 13:13:19 +02:00
openxr Merge pull request #68023 from rsjtdrjgfuzkfg/pico 2022-11-24 10:43:15 +01:00
raycast Fix MSVC warnings C4324, C4389, C4456, and C4459 2022-09-28 16:43:09 +02:00
regex Style: Misc docs and comment style and language fixes 2022-11-02 19:01:18 +01:00
squish Make some Image methods static 2022-10-14 14:34:15 +02:00
svg ImageLoaderSVG: Improve error reporting 2022-11-23 13:27:31 +01:00
text_server_adv [TextServer] Fix line breaking for the special fonts that substitute a long string (with breaks opportunities in it) with a single glyph. 2022-11-21 09:42:34 +02:00
text_server_fb Implement SVG in OT support. 2022-11-04 14:10:54 +02:00
tga Add buffer size check to Image.load_tga_from_buffer(). Fixes #67985 2022-10-30 11:20:50 -05:00
theora Merge pull request #66516 from DeeJayLSP/update_theora 2022-11-15 16:25:05 +01:00
tinyexr Make some Image methods static 2022-10-14 14:34:15 +02:00
upnp Style: Misc docs and comment style and language fixes 2022-11-02 19:01:18 +01:00
vhacd
vorbis Code simplifications found by cppcheck 2022-11-21 08:43:36 +01:00
webp Overhaul WebP packer and split compression options 2022-11-15 11:52:22 -03:00
webrtc [MP] Remove connection state signals from MultiplayerPeer. 2022-11-02 15:17:23 +01:00
websocket Fix WebSocket connection failed on Web. 2022-11-03 14:29:39 +08:00
webxr Fix WebXR after changing Emscripten configuration noExitRuntime to false 2022-11-10 16:10:47 -06:00
xatlas_unwrap SCons: Unify tools/target build type configuration 2022-09-26 16:31:46 +02:00
zip Merge pull request #68581 from oganm/oganm/master 2022-11-22 12:36:45 +01:00
modules_builders.py
register_module_types.h
SCsub