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

[Not for review] Thunks: Implement data layout analysis and struct repacking. Add 32-bit support to Wayland and Vulkan #3135

Closed
wants to merge 48 commits into from

Conversation

neobrain
Copy link
Member

@neobrain neobrain commented Sep 22, 2023

I'll split these changes up into smaller PRs for easier review. Having the full set of changes visible may be useful to judge the design during review though.

Full list of changes:

  • Data layout analysis pass
  • Data layout comparison module
  • Automatic struct repacking for structs without pointers
  • Assisted, semi-automatic struct repacking ("custom repacking")
  • New annotations: ptr_passthrough/is_opaque/assume_compatible_data_layout/custom_repack
  • 32-bit support for Wayland and Vulkan, sufficient to run vkcube / Super Meat Boy / zink
  • Tests... All the tests

Related PRs:

The set of these types is tracked in AnalysisAction, to which extensive
verification logic is added to detect potential incompatibilities and to
enforce use of annotatations where needed.
This adds a ComputeDataLayout function that maps a set of clang::Types
to an internal representation of their data layout (size, member list, ...).
This runs the data layout analysis pass added in the previous change twice:
Once for the host architecture and once for the guest architecture. This
allows the new DataLayoutCompareAction to query architecture differences for
each type, which can then be used to instruct code generation accordingly.

Currently, type compatibility is classified into 3 categories:
* Fully compatible (same size/alignment for the type itself and any members)
* Repackable (incompatibility can be resolved with emission of automatable
  repacking code, e.g. when struct members are located at differing offsets
  due to padding bytes)
* Incompatible
Previously, two functions with the same signature would always be wrapped
in the same logic. This change allows customizing one function with
annotations while leaving the other one unchanged.
…back arguments

This will be used later to aid automatic struct repacking.
This annotation can be used for data types that can't be repacked
automatically even with custom repack annotations. With ptr_passthrough,
the types are wrapped in guest_layout and passed to the host like that.
These annotations allow for a given type or parameter to be treated as
"compatible" even if data layout analysis can't infer this automatically.

assume_compatible_data_layout is more powerful than is_opaque, since it
allows for structs containing members of a certain type to be automatically
inferred as "compatible".

Conversely however, is_opaque enforces that the underlying data is never
accessed directly, since non-pointer uses of the type would still be
detected as "incompatible".
…rs. Thunks/gen: Adapt for new metadata definitions
…nges

The interface files themselves don't use FEXLoader. Only the final library
does.
This can be used to allow automatically handling structures that require
special behavior for one member but are automatically repackable otherwise.
The feature is enabled using the new custom_repack annotation and requires
additional repacking functions to be defined in the host file for each
customized member.
…ng tests; Add tests for void pointer parameters"

This reverts commit ea59f314e469bc9be1c1c01c3913e131a70e1f9f.
…on-repackable types. TODO: Needs an explicit mechanism to do this anyway if all members match vaguely!
@neobrain
Copy link
Member Author

What a ride! Other than 32-bit Vulkan support itself, everything originally implemented in this PR has now been integrated into main.

@neobrain neobrain closed this May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant