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

Struct (union) offsets are wrong #194

Open
andrew-boyarshin opened this issue May 16, 2021 · 1 comment
Open

Struct (union) offsets are wrong #194

andrew-boyarshin opened this issue May 16, 2021 · 1 comment

Comments

@andrew-boyarshin
Copy link
Contributor

andrew-boyarshin commented May 16, 2021

Noticed when manually reviewing Vortice.MediaFoundation bindings. MFTOPONODE_ATTRIBUTE_UPDATE is an example of a wrong structure. cfa2b3b adds a repro, without a fix. Union fields are supposed to all have an offset of 32, but the first member of a union (u32) is generated to have an offset of 28, which will lead to incorrectly behaving bindings.
Most likely StructTransform is not robust enough, and I'm not sure why union is aligned to 8 byte boundary, instead of traditional 4. This will require investigation into struct layout ABIs.
This is confirmed not to be a regression from 2.0.0-beta.7 to 2.0.0-beta.8.

public override void Process(CsStruct csStruct)
{
// TODO: this mapping must be robust. Current calculation for field offset is not always accurate for union.
// TODO: need to handle align/packing correctly.

FYI, @amerkoleci.

@amerkoleci
Copy link
Contributor

Saw that with other bindings, I had to manually remap the structure, an example is https://github.com/amerkoleci/Vortice.Windows/blob/main/src/Vortice.Direct3D12/RaytracingInstanceDescription.cs

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

No branches or pull requests

2 participants