Skip to content

[ARM/ARM64] C# interop broken due to HVA ABI #90

@JunaMeinhold

Description

@JunaMeinhold

On ARM/ARM64, the current Hexa.NET.ImGui bindings break because C# cannot handle homogeneous vector aggregates (HVAs) correctly. Functions that take or return ImVec2, ImVec4, or similar types fail at runtime due to ABI mismatches.

Root Cause:

  • ARM64 ABI passes HVAs in SIMD registers.
  • C# P/Invoke does not support HVAs, leading to corrupted arguments/returns.
  • Works on x86/x64 because ABI rules differ.

Proposed Solution:
Develop a C++ → C generator for the bindings:

  1. Automatically generate C ABI-safe wrapper functions from the ImGui C++ API.
  2. Replace vector-type parameters/returns with scalar equivalents or plain structs with const ptr.
  3. Expose only C-style functions to C#, ensuring ABI compatibility across ARM/ARM64 and x86/x64.

Benefits:

  • Eliminates manual binding errors.
  • Ensures ARM64 compatibility.
  • Keeps API surface consistent for managed consumers.

Action Items:

Notes:

  • This approach is preferable to attempting direct P/Invoke of C++ vectors.
  • Could be extended in the future for other C++ libraries with similar issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions